Now fixed operations is not necessary bound to fix category

This commit is contained in:
2019-01-29 19:31:35 +01:00
parent 1fbb920cb3
commit ea6a320416
5 changed files with 39 additions and 20 deletions

View File

@@ -431,9 +431,6 @@ void GridAccount::InsertOperation(User* user, Operation& op, int line, bool fix,
if (fix)
{
item = new QTableWidgetItem(_("Fix"));
setItem(line, CATEGORY, item);
SET_READ_ONLY(item);
_fixCosts++;
}
@@ -459,8 +456,8 @@ void GridAccount::InsertOperation(User* user, Operation& op, int line, bool fix,
if (!op.meta)
setItem(line, ACCOUNT, new QTableWidgetItem(user->GetAccountName(op.account)));
if (!fix && !op.meta)
setItem(line, CATEGORY, new QTableWidgetItem(_(cat.name.toStdString().c_str())));
if (!op.meta)
setItem(line, CATEGORY, new QTableWidgetItem(_(cat.name.toStdString().c_str())));
if (tag.id)
setItem(line, TAG, new QTableWidgetItem(_(tag.name.toStdString().c_str())));
@@ -481,10 +478,15 @@ void GridAccount::InsertOperation(User* user, Operation& op, int line, bool fix,
setItem(line, CREDIT, new QTableWidgetItem(v.sprintf("%.2lf", (double)amount/100)));
}
if (line <= _fixCosts)
cat = user->GetCategory(1);
if (op.category)
color = cat.backcolor;
else
color = view::OWN_GREEN;
{
color = (op.fix_cost) ? view::OWN_YELLOW : view::OWN_GREEN;
}
if (op.checked)
{
@@ -705,6 +707,7 @@ void GridAccount::CheckOperation(Operation& op, int line, bool check, bool force
QColor color;
int r,g,b;
User* user = _kiss->GetUser();
Category cat;
if (!force)
{
@@ -718,7 +721,12 @@ void GridAccount::CheckOperation(Operation& op, int line, bool check, bool force
checkBox->setCheckState(check ? Qt::Checked : Qt::Unchecked);
}
color = user->GetCategory(op.category).backcolor;
if (line <= _fixCosts)
cat = user->GetCategory(1);
else
cat = user->GetCategory(op.category);
color = cat.backcolor;
if (check)
{
@@ -1147,7 +1155,14 @@ void GridAccount::OnOperationModified(int row, int col)
(_displayedOperations)[row] = new_op;
cat = user->GetCategory(new_op.category);
CheckOperation(new_op, row, new_op.checked, true);
SET_ROW_FONT(row, user->GetCategoryFont(cat.id));
if (row <= _fixCosts)
{
SET_ROW_FONT(row, user->GetCategoryFont(0));
}
else
{
SET_ROW_FONT(row, user->GetCategoryFont(cat.id));
}
}
}
// Add an operation