Replace pointers by references
This commit is contained in:
parent
6bd42b26a8
commit
6e0b51c9fe
|
@ -398,7 +398,7 @@ void GridAccount::DeleteOperation(const Operation& op)
|
|||
}
|
||||
}
|
||||
|
||||
void GridAccount::InsertIntoGrid(Operation* op)
|
||||
void GridAccount::InsertIntoGrid(Operation& op)
|
||||
{
|
||||
int i;
|
||||
User* user = _kiss->GetUser();
|
||||
|
@ -406,17 +406,17 @@ void GridAccount::InsertIntoGrid(Operation* op)
|
|||
for(i=0; i<(int)_displayedOperations.size(); i++)
|
||||
{
|
||||
if (_displayedOperations[i] == NULL) continue;
|
||||
if ((_displayedOperations)[i]->fix_cost && !op->fix_cost) continue;
|
||||
if (!(_displayedOperations)[i]->fix_cost && op->fix_cost) break;
|
||||
if ((_displayedOperations)[i]->fix_cost && !op.fix_cost) continue;
|
||||
if (!(_displayedOperations)[i]->fix_cost && op.fix_cost) break;
|
||||
if (user->_preferences[wxT("operation_order")] == wxT("ASC"))
|
||||
{
|
||||
if ((_displayedOperations)[i]->day > op->day)
|
||||
if ((_displayedOperations)[i]->day > op.day)
|
||||
break;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((_displayedOperations)[i]->day < op->day)
|
||||
if ((_displayedOperations)[i]->day < op.day)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -424,27 +424,29 @@ void GridAccount::InsertIntoGrid(Operation* op)
|
|||
if (i == (int)_displayedOperations.size() ||
|
||||
i == _fixCosts)
|
||||
i--;
|
||||
else if (!(_displayedOperations)[i]->fix_cost && op->fix_cost)
|
||||
else if (!(_displayedOperations)[i]->fix_cost && op.fix_cost)
|
||||
i --;
|
||||
|
||||
_operations->push_back(*op);
|
||||
_operations->push_back(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);
|
||||
}
|
||||
|
||||
void GridAccount::RemoveMeta(Operation* op, int line, bool removeRoot, bool deleteOp)
|
||||
/* !!! op must not be a reference because we modify _displayedOerations !!! */
|
||||
void GridAccount::RemoveMeta(Operation op, int line, bool removeRoot, bool deleteOp)
|
||||
{
|
||||
std::vector<Operation*>::iterator it, it2;
|
||||
wxGridCellTreeButtonRenderer* treeRenderer;
|
||||
int i;
|
||||
|
||||
treeRenderer = (wxGridCellTreeButtonRenderer*) GetCellRenderer(line, TREE);
|
||||
|
||||
if (treeRenderer->IsCollapsed())
|
||||
{
|
||||
for(it=op->childs.begin(); it!=op->childs.end(); it++)
|
||||
for(i=0; i<(int)op.childs.size(); i++)
|
||||
{
|
||||
if ((*it)->meta)
|
||||
RemoveMeta(*it, line+1, true, deleteOp);
|
||||
if (op.childs[i]->meta)
|
||||
RemoveMeta(*op.childs[i], line+1, true, deleteOp);
|
||||
else
|
||||
{
|
||||
DeleteRows(line+1, 1);
|
||||
|
@ -452,23 +454,24 @@ void GridAccount::RemoveMeta(Operation* op, int line, bool removeRoot, bool dele
|
|||
_displayedOperations.erase(_displayedOperations.begin()+line+1);
|
||||
if (deleteOp)
|
||||
{
|
||||
DeleteOperation(**it);
|
||||
_kiss->DeleteOperation(**it);
|
||||
DeleteOperation(*op.childs[i]);
|
||||
_kiss->DeleteOperation(*op.childs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
op.childs.clear();
|
||||
|
||||
if (removeRoot)
|
||||
{
|
||||
DeleteRows(line, 1);
|
||||
if (_displayedOperations[line]->fix_cost) _fixCosts--;
|
||||
_displayedOperations.erase(_displayedOperations.begin()+line);
|
||||
if (deleteOp)
|
||||
{
|
||||
DeleteOperation(*op);
|
||||
_kiss->DeleteOperation(*op);
|
||||
DeleteOperation(op);
|
||||
_kiss->DeleteOperation(op);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -512,7 +515,7 @@ void GridAccount::OnOperationModified(wxGridEvent& event)
|
|||
}
|
||||
else
|
||||
{
|
||||
RemoveMeta(op, row, false, false);
|
||||
RemoveMeta(*op, row, false, false);
|
||||
}
|
||||
|
||||
treeRenderer->DecRef();
|
||||
|
@ -631,7 +634,7 @@ void GridAccount::OnOperationModified(wxGridEvent& event)
|
|||
user->UnGroup(_displayedOperations[row]);
|
||||
|
||||
if (cur_op.meta)
|
||||
RemoveMeta(_displayedOperations[row], row, true, true);
|
||||
RemoveMeta(*_displayedOperations[row], row, true, true);
|
||||
else
|
||||
{
|
||||
DeleteRows(row, 1);
|
||||
|
@ -711,7 +714,7 @@ void GridAccount::OnOperationModified(wxGridEvent& event)
|
|||
user->UnGroup(_displayedOperations[row]);
|
||||
|
||||
if (cur_op.meta)
|
||||
RemoveMeta(_displayedOperations[row], row, true, true);
|
||||
RemoveMeta(*_displayedOperations[row], row, true, true);
|
||||
else
|
||||
{
|
||||
DeleteRows(row, 1);
|
||||
|
@ -764,33 +767,33 @@ void GridAccount::OnOperationModified(wxGridEvent& event)
|
|||
}
|
||||
|
||||
if (need_insertion)
|
||||
InsertIntoGrid(&new_op);
|
||||
InsertIntoGrid(new_op);
|
||||
|
||||
inModification = false ;
|
||||
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_ ;
|
||||
wxString category = wxT("");
|
||||
bool updateCat = false ;
|
||||
|
||||
op->category = wxT("");
|
||||
op.category = wxT("");
|
||||
|
||||
for(it=ops.begin(); it!=ops.end(); it++)
|
||||
{
|
||||
op_ = *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->month = op_->month;
|
||||
op->day = op_->day;
|
||||
op.year = op_->year;
|
||||
op.month = op_->month;
|
||||
op.day = op_->day;
|
||||
}
|
||||
op->amount += op_->amount;
|
||||
if (!op->description.Length() && op_->description.Length())
|
||||
op->description = op_->description;
|
||||
op.amount += op_->amount;
|
||||
if (!op.description.Length() && op_->description.Length())
|
||||
op.description = op_->description;
|
||||
if (!category.Length())
|
||||
{
|
||||
if (op_->category.Length())
|
||||
|
@ -804,11 +807,11 @@ void GridAccount::UpdateMeta(Operation* op, std::vector<Operation*>& ops)
|
|||
if (op_->category.Length() && op_->category != category)
|
||||
updateCat = false;
|
||||
}
|
||||
op_->parent = op->id;
|
||||
op_->parent = op.id;
|
||||
}
|
||||
|
||||
if (updateCat)
|
||||
op->category = category;
|
||||
op.category = category;
|
||||
}
|
||||
|
||||
void GridAccount::Group()
|
||||
|
@ -898,7 +901,7 @@ void GridAccount::Group()
|
|||
for(i=0, it2=_displayedOperations.begin(); it2!=_displayedOperations.end(); it2++, i++)
|
||||
if (*it2 && (*it2)->id == parent)
|
||||
{
|
||||
RemoveMeta(*it2, i, true, false);
|
||||
RemoveMeta(**it2, i, true, false);
|
||||
op = *it2;
|
||||
break;
|
||||
}
|
||||
|
@ -913,7 +916,7 @@ void GridAccount::Group()
|
|||
if (rows[i] >= i)
|
||||
{
|
||||
if (ops[i]->meta)
|
||||
RemoveMeta(ops[i], rows[i]-i, true, false);
|
||||
RemoveMeta(*ops[i], rows[i]-i, true, false);
|
||||
else
|
||||
{
|
||||
DeleteRows(rows[i]-i, 1);
|
||||
|
@ -923,7 +926,7 @@ void GridAccount::Group()
|
|||
else
|
||||
{
|
||||
if (ops[i]->meta)
|
||||
RemoveMeta(ops[i], rows[i], true, false);
|
||||
RemoveMeta(*ops[i], rows[i], true, false);
|
||||
else
|
||||
{
|
||||
DeleteRows(rows[i], 1);
|
||||
|
@ -932,7 +935,7 @@ void GridAccount::Group()
|
|||
}
|
||||
}
|
||||
|
||||
UpdateMeta(op, ops);
|
||||
UpdateMeta(*op, ops);
|
||||
|
||||
for(it2=ops.begin(); it2!=ops.end(); it2++)
|
||||
{
|
||||
|
@ -955,7 +958,7 @@ void GridAccount::Group()
|
|||
}
|
||||
|
||||
_kiss->UpdateOperation(*op);
|
||||
InsertIntoGrid(op);
|
||||
InsertIntoGrid(*op);
|
||||
}
|
||||
|
||||
void GridAccount::UnGroup()
|
||||
|
|
|
@ -66,10 +66,10 @@ private:
|
|||
|
||||
void SetWeek(int week, int line);
|
||||
void ResetWeeks();
|
||||
void InsertIntoGrid(Operation* op);
|
||||
void InsertIntoGrid(Operation& op);
|
||||
void DeleteOperation(const Operation& op);
|
||||
void UpdateMeta(Operation* op, std::vector<Operation*>& ops);
|
||||
void RemoveMeta(Operation* op, int line, bool removeRoot, bool deleteOp);
|
||||
void UpdateMeta(Operation& op, std::vector<Operation*>& ops);
|
||||
void RemoveMeta(Operation op, int line, bool removeRoot, bool deleteOp);
|
||||
|
||||
DECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user