Improve Group feature
This commit is contained in:
parent
5245ec2623
commit
340a53094d
|
@ -140,6 +140,15 @@ Operation& GridAccount::GetOperation(const wxString& id)
|
||||||
return *it;
|
return *it;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int GridAccount::GetDisplayedRow(const wxString& id)
|
||||||
|
{
|
||||||
|
for(int i=0; i<(int)_displayedOperations.size(); i++)
|
||||||
|
if (_displayedOperations[i].id == id)
|
||||||
|
return i;
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
void GridAccount::LoadOperations(std::vector<Operation>* operations, bool canAddOperation, bool setWeek, int month, int year)
|
void GridAccount::LoadOperations(std::vector<Operation>* operations, bool canAddOperation, bool setWeek, int month, int year)
|
||||||
{
|
{
|
||||||
std::vector<Operation>::iterator it;
|
std::vector<Operation>::iterator it;
|
||||||
|
@ -613,6 +622,8 @@ void GridAccount::OnOperationModified(wxGridEvent& event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cur_op = (_displayedOperations)[row] ;
|
||||||
|
|
||||||
if (col == CHECKED || col == CATEGORY)
|
if (col == CHECKED || col == CATEGORY)
|
||||||
{
|
{
|
||||||
color = user->GetCategory(new_op.category).backcolor;
|
color = user->GetCategory(new_op.category).backcolor;
|
||||||
|
@ -643,8 +654,6 @@ void GridAccount::OnOperationModified(wxGridEvent& event)
|
||||||
// Modify a fix operation
|
// Modify a fix operation
|
||||||
if (row < _fixCosts)
|
if (row < _fixCosts)
|
||||||
{
|
{
|
||||||
cur_op = (_displayedOperations)[row] ;
|
|
||||||
|
|
||||||
if (col == DELETE)
|
if (col == DELETE)
|
||||||
{
|
{
|
||||||
if (cur_op.parent.Length())
|
if (cur_op.parent.Length())
|
||||||
|
@ -717,7 +726,6 @@ void GridAccount::OnOperationModified(wxGridEvent& event)
|
||||||
// Modify an operation
|
// Modify an operation
|
||||||
else if (row < (int)(_displayedOperations.size()-1))
|
else if (row < (int)(_displayedOperations.size()-1))
|
||||||
{
|
{
|
||||||
cur_op = (_displayedOperations)[row] ;
|
|
||||||
new_op.id = cur_op.id;
|
new_op.id = cur_op.id;
|
||||||
new_op.fix_cost = false;
|
new_op.fix_cost = false;
|
||||||
new_op.transfert = cur_op.transfert;
|
new_op.transfert = cur_op.transfert;
|
||||||
|
@ -787,21 +795,33 @@ void GridAccount::OnOperationModified(wxGridEvent& event)
|
||||||
InsertIntoGrid(new_op);
|
InsertIntoGrid(new_op);
|
||||||
|
|
||||||
inModification = false ;
|
inModification = false ;
|
||||||
|
|
||||||
|
if (!need_insertion && (col == CHECKED || col == CATEGORY) && new_op.parent.Length())
|
||||||
|
{
|
||||||
|
op2 = GetOperation(new_op.parent);
|
||||||
|
UpdateMeta(op2);
|
||||||
|
int row2 = GetDisplayedRow(op2.id);
|
||||||
|
wxGridEvent event2(-1, 0, NULL, row2, CATEGORY);
|
||||||
|
OnOperationModified(event2);
|
||||||
|
}
|
||||||
|
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GridAccount::UpdateMeta(Operation& op, std::vector<Operation>& ops)
|
void GridAccount::UpdateMeta(Operation& op)
|
||||||
{
|
{
|
||||||
std::vector<Operation>::iterator it;
|
std::vector<wxString>::iterator it;
|
||||||
Operation op_ ;
|
Operation op_ ;
|
||||||
wxString category = wxT("");
|
wxString category = wxT("");
|
||||||
bool updateCat = false ;
|
bool updateCat = false ;
|
||||||
|
|
||||||
op.category = wxT("");
|
op.category = wxT("");
|
||||||
|
op.checked = true;
|
||||||
|
op.amount = 0;
|
||||||
|
|
||||||
for(it=ops.begin(); it!=ops.end(); it++)
|
for(it=op.childs.begin(); it!=op.childs.end(); it++)
|
||||||
{
|
{
|
||||||
op_ = *it;
|
op_ = GetOperation(*it);
|
||||||
if (op_.year <= op.year && op_.month <= op.month && op_.day < op.day)
|
if (op_.year <= op.year && op_.month <= op.month && op_.day < op.day)
|
||||||
{
|
{
|
||||||
op.year = op_.year;
|
op.year = op_.year;
|
||||||
|
@ -809,6 +829,7 @@ void GridAccount::UpdateMeta(Operation& op, std::vector<Operation>& ops)
|
||||||
op.day = op_.day;
|
op.day = op_.day;
|
||||||
}
|
}
|
||||||
op.amount += op_.amount;
|
op.amount += op_.amount;
|
||||||
|
op.checked &= op_.checked;
|
||||||
if (!op.description.Length() && op_.description.Length())
|
if (!op.description.Length() && op_.description.Length())
|
||||||
op.description = op_.description;
|
op.description = op_.description;
|
||||||
if (!category.Length())
|
if (!category.Length())
|
||||||
|
@ -829,6 +850,8 @@ void GridAccount::UpdateMeta(Operation& op, std::vector<Operation>& ops)
|
||||||
|
|
||||||
if (updateCat)
|
if (updateCat)
|
||||||
op.category = category;
|
op.category = category;
|
||||||
|
|
||||||
|
_kiss->UpdateOperation(op);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GridAccount::Group()
|
void GridAccount::Group()
|
||||||
|
@ -953,8 +976,6 @@ void GridAccount::Group()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateMeta(op, ops);
|
|
||||||
|
|
||||||
for(it2=ops.begin(); it2!=ops.end(); it2++)
|
for(it2=ops.begin(); it2!=ops.end(); it2++)
|
||||||
{
|
{
|
||||||
for (i=0, it3=op.childs.begin(); it3!=op.childs.end(); it3++, i++)
|
for (i=0, it3=op.childs.begin(); it3!=op.childs.end(); it3++, i++)
|
||||||
|
@ -978,7 +999,8 @@ void GridAccount::Group()
|
||||||
_kiss->UpdateOperation(*it2);
|
_kiss->UpdateOperation(*it2);
|
||||||
}
|
}
|
||||||
|
|
||||||
_kiss->UpdateOperation(op);
|
UpdateMeta(op);
|
||||||
|
|
||||||
InsertIntoGrid(op);
|
InsertIntoGrid(op);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,10 +68,11 @@ 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);
|
||||||
void RemoveMeta(Operation& op, int line, bool removeRoot, bool deleteOp);
|
void RemoveMeta(Operation& op, int line, bool removeRoot, bool deleteOp);
|
||||||
|
|
||||||
Operation& GetOperation(const wxString& id);
|
Operation& GetOperation(const wxString& id);
|
||||||
|
int GetDisplayedRow(const wxString& id);
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE();
|
DECLARE_EVENT_TABLE();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user