* Fix some Group operations bugs. Still a buggy version with Group management !

This commit is contained in:
2010-10-01 20:09:15 +02:00
parent d9f75e5329
commit 7dfe4bdb18
4 changed files with 54 additions and 22 deletions

View File

@@ -430,6 +430,8 @@ void AccountPanel::UpdateStats()
for (it=_curOperations->begin(); it!=_curOperations->end(); it++)
{
if (it->meta) continue;
if (it->amount > 0)
{
if (day >= it->day)

View File

@@ -421,10 +421,11 @@ void GridAccount::InsertIntoGrid(Operation* op)
}
}
if (!(_displayedOperations)[i]->fix_cost && op->fix_cost)
if (i == (int)_displayedOperations.size() ||
i == _fixCosts)
i--;
else if (!(_displayedOperations)[i]->fix_cost && op->fix_cost)
i --;
else if (i == (int)_displayedOperations.size() ||
i == _fixCosts) i--;
_operations->push_back(*op);
@@ -768,7 +769,7 @@ void GridAccount::OnOperationModified(wxGridEvent& event)
event.Skip();
}
void GridAccount::UpdateMeta(Operation* op, std::vector<Operation*> ops)
void GridAccount::UpdateMeta(Operation* op, std::vector<Operation*>& ops)
{
std::vector<Operation*>::iterator it;
Operation* op_ ;
@@ -802,6 +803,7 @@ void GridAccount::UpdateMeta(Operation* op, std::vector<Operation*> ops)
if (op_->category.Length() && op_->category != category)
updateCat = false;
}
op_->parent = op->id;
}
if (updateCat)
@@ -815,7 +817,7 @@ void GridAccount::Group()
std::vector<Operation*> ops;
std::vector<Operation*>::iterator it2, it3;
wxString parent = wxT("");
Operation* op;
Operation* op=NULL;
int fix = -1, i;
// Singly selected cells.
@@ -837,31 +839,40 @@ void GridAccount::Group()
if (!parent.Length())
{
if (op->parent.Length())
{
parent = op->parent;
continue;
}
else if(op->meta)
parent = op->id;
}
else
{
if ((parent.Length() && op->parent != parent) || (fix != -1 && ((!fix && op->fix_cost) || (fix && !op->fix_cost))))
if ((parent.Length() && op->parent.Length() && op->parent != parent))
{
wxMessageBox(_("Cannot group these operations"), _("Error"), wxICON_ERROR | wxOK);
return ;
}
}
if (fix != -1 && ((!fix && op->fix_cost) || (fix && !op->fix_cost)))
{
wxMessageBox(_("Cannot group these operations"), _("Error"), wxICON_ERROR | wxOK);
return ;
}
if (fix == -1)
fix = op->fix_cost ? 1 : 0;
rows.push_back(c.GetRow());
ops.push_back(op);
rows.push_back(c.GetRow());
}
}
if (rows.size() < 2) return;
if (!parent.Length())
{
if (rows.size() < 2) return;
op = new Operation;
op->parent = wxT("");
op->day = ops[0]->day;
@@ -881,10 +892,17 @@ void GridAccount::Group()
}
else
{
for(i=0, it2=ops.begin(); it2!=ops.end(); it2++, i++)
if ((*it2)->id == parent)
if (rows.size() < 1) return;
for(i=0, it2=_displayedOperations.begin(); it2!=_displayedOperations.end(); it2++, i++)
if (*it2 && (*it2)->id == parent)
{
RemoveMeta(*it2, i, true, false);
op = *it2;
break;
op = *it2;
}
if (!op) return;
}
std::sort(rows.begin(), rows.end());

View File

@@ -68,7 +68,7 @@ private:
void ResetWeeks();
void InsertIntoGrid(Operation* op);
void DeleteOperation(const Operation& op);
void UpdateMeta(Operation* op, std::vector<Operation*> ops);
void UpdateMeta(Operation* op, std::vector<Operation*>& ops);
void RemoveMeta(Operation* op, int line, bool removeRoot, bool deleteOp);
DECLARE_EVENT_TABLE();