Move check modification processing in OnCheckClicked()

This commit is contained in:
Grégory Soutadé 2011-11-01 18:12:11 +01:00
parent 6c4ee9dec3
commit 63b235d8db

View File

@ -668,6 +668,10 @@ void GridAccount::OnCheckClicked(int id)
{
std::vector<Operation>::iterator it;
int row;
Operation op2;
QColor color;
User* user = _kiss->GetUser();
unsigned char r, g, b;
if (_inModification || _loadOperations) return;
@ -677,10 +681,52 @@ void GridAccount::OnCheckClicked(int id)
if (it == _displayedOperations.end()) return ;
_inModification = true;
row = it-_displayedOperations.begin();
_displayedOperations[row].checked = (checkBox->checkState() == Qt::Checked);
OnOperationModified(row, CHECKED);
color = user->GetCategory(it->category).backcolor;
if (it->checked)
{
r = ((color.red()*1.5) >= 0xFF) ? 0xFF : color.red()*1.5 ;
g = ((color.green()*1.5) >= 0xFF) ? 0xFF : color.green()*1.5 ;
b = ((color.blue()*1.5) >= 0xFF) ? 0xFF : color.blue()*1.5 ;
color.setRgb(r, g, b);
}
SET_ROW_COLOR(row, color, user->GetCategory(it->category).forecolor);
SET_ROW_FONT(row, user->GetCategoryFont(it->category));
UpdateOperation(*it);
if (it->meta)
CheckMeta(*it, row, it->checked);
else
{
if (it->parent)
{
op2 = GetOperation(it->parent);
UpdateMeta(op2);
int row2 = GetDisplayedRow(op2.id);
QCheckBox* checkBox = qobject_cast<QCheckBox*>(cellWidget(row2, CHECKED));
checkBox->setCheckState(op2.checked ? Qt::Checked : Qt::Unchecked);
color = user->GetCategory(op2.category).backcolor;
if (op2.checked)
{
r = ((color.red()*1.5) >= 0xFF) ? 0xFF : color.red()*1.5 ;
g = ((color.green()*1.5) >= 0xFF) ? 0xFF : color.green()*1.5 ;
b = ((color.blue()*1.5) >= 0xFF) ? 0xFF : color.blue()*1.5 ;
color.setRgb(r, g, b);
}
SET_ROW_COLOR(row2, color, user->GetCategory(op2.category).forecolor);
}
}
_inModification = false;
_kiss->UpdateStats();
}
@ -889,60 +935,19 @@ void GridAccount::OnOperationModified(int row, int col)
new_op.checked = false;
op_complete--;
if (col == CHECKED || col == CATEGORY)
color = user->GetCategory(new_op.category).backcolor;
if (col == CATEGORY && new_op.checked)
{
color = user->GetCategory(new_op.category).backcolor;
if (new_op.checked)
{
r = ((color.red()*1.5) >= 0xFF) ? 0xFF : color.red()*1.5 ;
g = ((color.green()*1.5) >= 0xFF) ? 0xFF : color.green()*1.5 ;
b = ((color.blue()*1.5) >= 0xFF) ? 0xFF : color.blue()*1.5 ;
color.setRgb(r, g, b);
}
SET_ROW_COLOR(row, color, user->GetCategory(new_op.category).forecolor);
SET_ROW_FONT(row, user->GetCategoryFont(new_op.category));
if (col == CHECKED)
{
cur_op.checked = new_op.checked;
UpdateOperation(cur_op);
if (cur_op.meta)
CheckMeta(cur_op, row, cur_op.checked);
else
{
if (cur_op.parent)
{
op2 = GetOperation(cur_op.parent);
UpdateMeta(op2);
int row2 = GetDisplayedRow(op2.id);
QCheckBox* checkBox = qobject_cast<QCheckBox*>(cellWidget(row2, CHECKED));
checkBox->setCheckState(op2.checked ? Qt::Checked : Qt::Unchecked);
color = user->GetCategory(op2.category).backcolor;
if (op2.checked)
{
r = ((color.red()*1.5) >= 0xFF) ? 0xFF : color.red()*1.5 ;
g = ((color.green()*1.5) >= 0xFF) ? 0xFF : color.green()*1.5 ;
b = ((color.blue()*1.5) >= 0xFF) ? 0xFF : color.blue()*1.5 ;
color.setRgb(r, g, b);
}
SET_ROW_COLOR(row2, color, user->GetCategory(op2.category).forecolor);
}
}
_inModification = false;
return;
}
}
else
{
SET_ROW_COLOR(row, user->GetCategory(new_op.category).backcolor, user->GetCategory(new_op.category).forecolor);
SET_ROW_FONT(row, user->GetCategoryFont(new_op.category));
r = ((color.red()*1.5) >= 0xFF) ? 0xFF : color.red()*1.5 ;
g = ((color.green()*1.5) >= 0xFF) ? 0xFF : color.green()*1.5 ;
b = ((color.blue()*1.5) >= 0xFF) ? 0xFF : color.blue()*1.5 ;
color.setRgb(r, g, b);
}
SET_ROW_COLOR(row, color, user->GetCategory(new_op.category).forecolor);
SET_ROW_FONT(row, user->GetCategoryFont(new_op.category));
// Modify a fix operation
if (row < _fixCosts || !_canAddOperation)
{