* Improve check/uncheck on grouped operations
This commit is contained in:
parent
340a53094d
commit
8ff39c01e9
|
@ -140,6 +140,19 @@ Operation& GridAccount::GetOperation(const wxString& id)
|
||||||
return *it;
|
return *it;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GridAccount::UpdateOperation(Operation& op)
|
||||||
|
{
|
||||||
|
std::vector<Operation>::iterator it;
|
||||||
|
|
||||||
|
for(it=_operations->begin(); it!=_operations->end(); it++)
|
||||||
|
if (it->id == op.id)
|
||||||
|
{
|
||||||
|
*it = op;
|
||||||
|
_kiss->UpdateOperation(op);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int GridAccount::GetDisplayedRow(const wxString& id)
|
int GridAccount::GetDisplayedRow(const wxString& id)
|
||||||
{
|
{
|
||||||
for(int i=0; i<(int)_displayedOperations.size(); i++)
|
for(int i=0; i<(int)_displayedOperations.size(); i++)
|
||||||
|
@ -455,7 +468,6 @@ void GridAccount::InsertIntoGrid(Operation& op)
|
||||||
InsertOperationWithWeek(user, (*_operations)[_operations->size()-1], i, op.fix_cost, _curMonth, _curYear);
|
InsertOperationWithWeek(user, (*_operations)[_operations->size()-1], i, op.fix_cost, _curMonth, _curYear);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* !!! op must not be a reference because we modify _displayedOerations !!! */
|
|
||||||
void GridAccount::RemoveMeta(Operation& op, int line, bool removeRoot, bool deleteOp)
|
void GridAccount::RemoveMeta(Operation& op, int line, bool removeRoot, bool deleteOp)
|
||||||
{
|
{
|
||||||
std::vector<Operation*>::iterator it, it2;
|
std::vector<Operation*>::iterator it, it2;
|
||||||
|
@ -503,6 +515,47 @@ void GridAccount::RemoveMeta(Operation& op, int line, bool removeRoot, bool dele
|
||||||
treeRenderer->DecRef();
|
treeRenderer->DecRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GridAccount::CheckMeta(Operation& op, int line, bool check)
|
||||||
|
{
|
||||||
|
std::vector<Operation*>::iterator it, it2;
|
||||||
|
wxGridCellTreeButtonRenderer* treeRenderer;
|
||||||
|
int i;
|
||||||
|
Operation op2;
|
||||||
|
wxColour color ;
|
||||||
|
unsigned char r, g, b;
|
||||||
|
User* user = _kiss->GetUser();
|
||||||
|
|
||||||
|
treeRenderer = (wxGridCellTreeButtonRenderer*) GetCellRenderer(line, TREE);
|
||||||
|
|
||||||
|
for(i=0; i<(int)op.childs.size(); i++)
|
||||||
|
{
|
||||||
|
op2 = GetOperation(op.childs[i]);
|
||||||
|
op2.checked = check;
|
||||||
|
UpdateOperation(op2);
|
||||||
|
|
||||||
|
if (op2.meta)
|
||||||
|
CheckMeta(op2, line+1, check);
|
||||||
|
|
||||||
|
if (treeRenderer->IsCollapsed())
|
||||||
|
{
|
||||||
|
SetCellValue(line+i+1, CHECKED, check ? wxT("1") : wxT("0"));
|
||||||
|
color = user->GetCategory(op2.category).backcolor;
|
||||||
|
|
||||||
|
if (check)
|
||||||
|
{
|
||||||
|
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.Set(r, g, b, color.Alpha());
|
||||||
|
}
|
||||||
|
|
||||||
|
SET_ROW_COLOR(line+i+1, color, user->GetCategory(op2.category).forecolor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
treeRenderer->DecRef();
|
||||||
|
}
|
||||||
|
|
||||||
void GridAccount::OnOperationModified(wxGridEvent& event)
|
void GridAccount::OnOperationModified(wxGridEvent& event)
|
||||||
{
|
{
|
||||||
User* user = _kiss->GetUser();
|
User* user = _kiss->GetUser();
|
||||||
|
@ -638,6 +691,38 @@ void GridAccount::OnOperationModified(wxGridEvent& event)
|
||||||
|
|
||||||
SET_ROW_COLOR(row, color, user->GetCategory(new_op.category).forecolor);
|
SET_ROW_COLOR(row, color, user->GetCategory(new_op.category).forecolor);
|
||||||
SET_ROW_FONT(row, user->GetCategoryFont(new_op.category));
|
SET_ROW_FONT(row, user->GetCategoryFont(new_op.category));
|
||||||
|
|
||||||
|
if (col == CHECKED)
|
||||||
|
{
|
||||||
|
cur_op.checked = new_op.checked;
|
||||||
|
UpdateOperation(cur_op);
|
||||||
|
inModification = false;
|
||||||
|
if (cur_op.meta)
|
||||||
|
CheckMeta(cur_op, row, cur_op.checked);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (cur_op.parent.Length())
|
||||||
|
{
|
||||||
|
op2 = GetOperation(cur_op.parent);
|
||||||
|
UpdateMeta(op2);
|
||||||
|
int row2 = GetDisplayedRow(op2.id);
|
||||||
|
SetCellValue(row2, CHECKED, op2.checked ? wxT("1") : wxT("0"));
|
||||||
|
|
||||||
|
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.Set(r, g, b, color.Alpha());
|
||||||
|
}
|
||||||
|
|
||||||
|
SET_ROW_COLOR(row2, color, user->GetCategory(op2.category).forecolor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (col == DELETE)
|
if (col == DELETE)
|
||||||
|
@ -688,11 +773,11 @@ void GridAccount::OnOperationModified(wxGridEvent& event)
|
||||||
DeleteOperation(cur_op);
|
DeleteOperation(cur_op);
|
||||||
_displayedOperations.erase(_displayedOperations.begin()+row);
|
_displayedOperations.erase(_displayedOperations.begin()+row);
|
||||||
_fixCosts--;
|
_fixCosts--;
|
||||||
_kiss->UpdateOperation(new_op);
|
UpdateOperation(new_op);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_kiss->UpdateOperation(new_op);
|
UpdateOperation(new_op);
|
||||||
(_displayedOperations)[row] = new_op;
|
(_displayedOperations)[row] = new_op;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -758,11 +843,11 @@ void GridAccount::OnOperationModified(wxGridEvent& event)
|
||||||
DeleteRows(row, 1);
|
DeleteRows(row, 1);
|
||||||
DeleteOperation(cur_op);
|
DeleteOperation(cur_op);
|
||||||
_displayedOperations.erase(_displayedOperations.begin()+row);
|
_displayedOperations.erase(_displayedOperations.begin()+row);
|
||||||
_kiss->UpdateOperation(new_op);
|
UpdateOperation(new_op);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_kiss->UpdateOperation(new_op);
|
UpdateOperation(new_op);
|
||||||
(_displayedOperations)[row] = new_op;
|
(_displayedOperations)[row] = new_op;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -796,15 +881,6 @@ void GridAccount::OnOperationModified(wxGridEvent& event)
|
||||||
|
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -851,7 +927,7 @@ void GridAccount::UpdateMeta(Operation& op)
|
||||||
if (updateCat)
|
if (updateCat)
|
||||||
op.category = category;
|
op.category = category;
|
||||||
|
|
||||||
_kiss->UpdateOperation(op);
|
UpdateOperation(op);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GridAccount::Group()
|
void GridAccount::Group()
|
||||||
|
@ -996,7 +1072,7 @@ void GridAccount::Group()
|
||||||
op.childs.insert(op.childs.begin()+i, it2->id);
|
op.childs.insert(op.childs.begin()+i, it2->id);
|
||||||
|
|
||||||
it2->parent = op.id;
|
it2->parent = op.id;
|
||||||
_kiss->UpdateOperation(*it2);
|
UpdateOperation(*it2);
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateMeta(op);
|
UpdateMeta(op);
|
||||||
|
|
|
@ -70,8 +70,10 @@ private:
|
||||||
void DeleteOperation(const Operation& op);
|
void DeleteOperation(const Operation& op);
|
||||||
void UpdateMeta(Operation& op);
|
void UpdateMeta(Operation& op);
|
||||||
void RemoveMeta(Operation& op, int line, bool removeRoot, bool deleteOp);
|
void RemoveMeta(Operation& op, int line, bool removeRoot, bool deleteOp);
|
||||||
|
void CheckMeta(Operation& op, int line, bool check);
|
||||||
|
|
||||||
Operation& GetOperation(const wxString& id);
|
Operation& GetOperation(const wxString& id);
|
||||||
|
void UpdateOperation(Operation& op);
|
||||||
int GetDisplayedRow(const wxString& id);
|
int GetDisplayedRow(const wxString& id);
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE();
|
DECLARE_EVENT_TABLE();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user