* Fix some Group operations bugs. Still a buggy version with Group management !
This commit is contained in:
parent
d9f75e5329
commit
7dfe4bdb18
|
@ -219,7 +219,7 @@ std::map<int, std::vector<int> > KissCount::GetAllOperations()
|
||||||
|
|
||||||
void KissCount::GenerateMonth(int monthFrom, int yearFrom, int monthTo, int yearTo)
|
void KissCount::GenerateMonth(int monthFrom, int yearFrom, int monthTo, int yearTo)
|
||||||
{
|
{
|
||||||
std::vector<Operation>::iterator it;
|
std::vector<Operation>::iterator it, it2;
|
||||||
std::map<wxString, wxString> meta;
|
std::map<wxString, wxString> meta;
|
||||||
Operation op;
|
Operation op;
|
||||||
|
|
||||||
|
@ -233,28 +233,40 @@ void KissCount::GenerateMonth(int monthFrom, int yearFrom, int monthTo, int year
|
||||||
LoadYear(yearFrom, false);
|
LoadYear(yearFrom, false);
|
||||||
|
|
||||||
for(it = (*_user->_operations[yearFrom])[monthFrom].begin();
|
for(it = (*_user->_operations[yearFrom])[monthFrom].begin();
|
||||||
it != (*_user->_operations[yearFrom])[monthFrom].end()
|
it != (*_user->_operations[yearFrom])[monthFrom].end();
|
||||||
&& it->fix_cost;
|
|
||||||
it++)
|
it++)
|
||||||
{
|
{
|
||||||
|
if (!it->fix_cost) continue;
|
||||||
op = *it;
|
op = *it;
|
||||||
op.month = monthTo;
|
op.month = monthTo;
|
||||||
op.year = yearTo;
|
op.year = yearTo;
|
||||||
op.checked = false;
|
op.checked = false;
|
||||||
op.id = AddOperation(op);
|
op.id = AddOperation(op);
|
||||||
|
op.childs.clear();
|
||||||
if (op.meta)
|
if (op.meta)
|
||||||
meta[it->id] = op.id;
|
meta[it->id] = op.id;
|
||||||
(*_user->_operations[yearTo])[monthTo].push_back(op);
|
(*_user->_operations[yearTo])[monthTo].push_back(op);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Re Generate parents
|
// Re Generate parents
|
||||||
for(it = (*_user->_operations[yearFrom])[monthFrom].begin();
|
for(it = (*_user->_operations[yearFrom])[monthTo].begin();
|
||||||
it != (*_user->_operations[yearFrom])[monthFrom].end()
|
it != (*_user->_operations[yearFrom])[monthTo].end();
|
||||||
&& it->fix_cost;
|
|
||||||
it++)
|
it++)
|
||||||
{
|
{
|
||||||
if (it->parent.Length())
|
if (it->parent.Length())
|
||||||
|
{
|
||||||
it->parent = meta[it->parent];
|
it->parent = meta[it->parent];
|
||||||
|
UpdateOperation(*it);
|
||||||
|
|
||||||
|
for(it2 = (*_user->_operations[yearFrom])[monthTo].begin();
|
||||||
|
it2 != (*_user->_operations[yearFrom])[monthTo].end();
|
||||||
|
it2++)
|
||||||
|
if (it2->id == it->parent)
|
||||||
|
{
|
||||||
|
it2->childs.push_back(&(*it));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_wxUI->GenerateMonth(monthTo, yearTo);
|
_wxUI->GenerateMonth(monthTo, yearTo);
|
||||||
|
|
|
@ -430,6 +430,8 @@ void AccountPanel::UpdateStats()
|
||||||
|
|
||||||
for (it=_curOperations->begin(); it!=_curOperations->end(); it++)
|
for (it=_curOperations->begin(); it!=_curOperations->end(); it++)
|
||||||
{
|
{
|
||||||
|
if (it->meta) continue;
|
||||||
|
|
||||||
if (it->amount > 0)
|
if (it->amount > 0)
|
||||||
{
|
{
|
||||||
if (day >= it->day)
|
if (day >= it->day)
|
||||||
|
|
|
@ -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 --;
|
i --;
|
||||||
else if (i == (int)_displayedOperations.size() ||
|
|
||||||
i == _fixCosts) i--;
|
|
||||||
|
|
||||||
_operations->push_back(*op);
|
_operations->push_back(*op);
|
||||||
|
|
||||||
|
@ -768,7 +769,7 @@ void GridAccount::OnOperationModified(wxGridEvent& event)
|
||||||
event.Skip();
|
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;
|
std::vector<Operation*>::iterator it;
|
||||||
Operation* op_ ;
|
Operation* op_ ;
|
||||||
|
@ -802,6 +803,7 @@ void GridAccount::UpdateMeta(Operation* op, std::vector<Operation*> ops)
|
||||||
if (op_->category.Length() && op_->category != category)
|
if (op_->category.Length() && op_->category != category)
|
||||||
updateCat = false;
|
updateCat = false;
|
||||||
}
|
}
|
||||||
|
op_->parent = op->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (updateCat)
|
if (updateCat)
|
||||||
|
@ -815,7 +817,7 @@ void GridAccount::Group()
|
||||||
std::vector<Operation*> ops;
|
std::vector<Operation*> ops;
|
||||||
std::vector<Operation*>::iterator it2, it3;
|
std::vector<Operation*>::iterator it2, it3;
|
||||||
wxString parent = wxT("");
|
wxString parent = wxT("");
|
||||||
Operation* op;
|
Operation* op=NULL;
|
||||||
int fix = -1, i;
|
int fix = -1, i;
|
||||||
|
|
||||||
// Singly selected cells.
|
// Singly selected cells.
|
||||||
|
@ -837,31 +839,40 @@ void GridAccount::Group()
|
||||||
if (!parent.Length())
|
if (!parent.Length())
|
||||||
{
|
{
|
||||||
if (op->parent.Length())
|
if (op->parent.Length())
|
||||||
|
{
|
||||||
parent = op->parent;
|
parent = op->parent;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
else if(op->meta)
|
else if(op->meta)
|
||||||
parent = op->id;
|
parent = op->id;
|
||||||
}
|
}
|
||||||
else
|
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);
|
wxMessageBox(_("Cannot group these operations"), _("Error"), wxICON_ERROR | wxOK);
|
||||||
return ;
|
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)
|
if (fix == -1)
|
||||||
fix = op->fix_cost ? 1 : 0;
|
fix = op->fix_cost ? 1 : 0;
|
||||||
|
|
||||||
rows.push_back(c.GetRow());
|
|
||||||
ops.push_back(op);
|
ops.push_back(op);
|
||||||
|
rows.push_back(c.GetRow());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rows.size() < 2) return;
|
|
||||||
|
|
||||||
if (!parent.Length())
|
if (!parent.Length())
|
||||||
{
|
{
|
||||||
|
if (rows.size() < 2) return;
|
||||||
|
|
||||||
op = new Operation;
|
op = new Operation;
|
||||||
op->parent = wxT("");
|
op->parent = wxT("");
|
||||||
op->day = ops[0]->day;
|
op->day = ops[0]->day;
|
||||||
|
@ -881,10 +892,17 @@ void GridAccount::Group()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for(i=0, it2=ops.begin(); it2!=ops.end(); it2++, i++)
|
if (rows.size() < 1) return;
|
||||||
if ((*it2)->id == parent)
|
|
||||||
break;
|
for(i=0, it2=_displayedOperations.begin(); it2!=_displayedOperations.end(); it2++, i++)
|
||||||
|
if (*it2 && (*it2)->id == parent)
|
||||||
|
{
|
||||||
|
RemoveMeta(*it2, i, true, false);
|
||||||
op = *it2;
|
op = *it2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!op) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::sort(rows.begin(), rows.end());
|
std::sort(rows.begin(), rows.end());
|
||||||
|
|
|
@ -68,7 +68,7 @@ private:
|
||||||
void ResetWeeks();
|
void ResetWeeks();
|
||||||
void InsertIntoGrid(Operation* op);
|
void InsertIntoGrid(Operation* op);
|
||||||
void DeleteOperation(const 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);
|
void RemoveMeta(Operation* op, int line, bool removeRoot, bool deleteOp);
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE();
|
DECLARE_EVENT_TABLE();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user