From d2f23fd6a088fb39ae77d5d06a009b10c55cedaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Sun, 13 Mar 2011 19:22:17 +0100 Subject: [PATCH] Temp commit --- src/view/AccountPanel.cpp | 4 ++-- src/view/SearchPanel.cpp | 4 ++-- src/view/grid/GridAccount.cpp | 17 +++++++++-------- src/view/grid/GridAccount.h | 4 ++-- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/view/AccountPanel.cpp b/src/view/AccountPanel.cpp index 23940b1..6762f7e 100644 --- a/src/view/AccountPanel.cpp +++ b/src/view/AccountPanel.cpp @@ -96,7 +96,7 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, pare _pie->SetLegend(new Legend(wxBOTTOM, wxCENTER)); - _grid = new GridAccount(_kiss, this, OPS_GRID_ID); + _grid = new GridAccount(_kiss, this, OPS_GRID_ID, true, true, true); _accountsGrid = new wxGrid(this, ACCOUNTS_GRID_ID); _accountsGrid->CreateGrid(0, NUMBER_COLS_ACCOUNTS); @@ -363,7 +363,7 @@ void AccountPanel::ShowMonth(int month, int year) // Operations are ordered _curOperations = &((*user->_operations[year])[month]); - _grid->LoadOperations(_curOperations, true, true, _curMonth, _curYear); + _grid->LoadOperations(_curOperations, _curMonth, _curYear); InitAccountsGrid(user, month, year); diff --git a/src/view/SearchPanel.cpp b/src/view/SearchPanel.cpp index 3e7fa8b..ba20a76 100644 --- a/src/view/SearchPanel.cpp +++ b/src/view/SearchPanel.cpp @@ -118,7 +118,7 @@ SearchPanel::SearchPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, parent vbox->Add(gridBagSizer, 0, wxGROW|wxALL, 5); - _grid = new GridAccount(_kiss, this, GRID_ID); + _grid = new GridAccount(_kiss, this, GRID_ID, false, false, true); hbox->Add(_grid, 0, wxGROW|wxALL, 5); @@ -275,7 +275,7 @@ void SearchPanel::OnButtonSearch(wxCommandEvent& event) return; } - _grid->LoadOperations(_operations, false, false, 0, 0); + _grid->LoadOperations(_operations, 0, 0); _wxUI->Layout(); } diff --git a/src/view/grid/GridAccount.cpp b/src/view/grid/GridAccount.cpp index b3a79a7..bd89b5f 100644 --- a/src/view/grid/GridAccount.cpp +++ b/src/view/grid/GridAccount.cpp @@ -162,7 +162,8 @@ void GridAccount::UpdateOperation(Operation& op) for(i=0; i < (int)_operations->size(); i++) if ((*_operations)[i].id == op.id) { - _kiss->UpdateOperation(op); + if (_databaseSynchronization) + _kiss->UpdateOperation(op); (*_operations)[i] = op; break; } @@ -181,10 +182,10 @@ void GridAccount::ClearGrid() { std::vector operations; - LoadOperations(&operations, false, false, 0, 0); + LoadOperations(&operations, 0, 0); } -void GridAccount::LoadOperations(std::vector* operations, bool canAddOperation, bool setWeek, int month, int year) +void GridAccount::LoadOperations(std::vector* operations, int month, int year) { std::vector::iterator it; User* user = _kiss->GetUser(); @@ -195,7 +196,6 @@ void GridAccount::LoadOperations(std::vector* operations, bool canAdd _loadOperations = true; _operations = operations; - _canAddOperation = canAddOperation; _curMonth = month; _curYear = year; _displayedOperations.clear(); @@ -210,7 +210,7 @@ void GridAccount::LoadOperations(std::vector* operations, bool canAdd { if (it->parent.Length()) continue; - if (setWeek) + if (_setWeek) InsertOperationWithWeek(user, *it, ++curLine, true, it->month, it->year); else InsertOperation(user, *it, ++curLine, true, it->month, it->year); @@ -222,7 +222,7 @@ void GridAccount::LoadOperations(std::vector* operations, bool canAdd { if (it->parent.Length()) continue; - if (setWeek) + if (_setWeek) InsertOperationWithWeek(user, *it, ++curLine, false, it->month, it->year); else InsertOperation(user, *it, ++curLine, false, it->month, it->year); @@ -1534,13 +1534,14 @@ void GridAccount::MassUpdate(std::vector& rows, updateOperationFunc func, v for(it=_operations->begin(); it!=_operations->end(); it++) { func (&(*it), params); - _kiss->UpdateOperation(*it); + if (_databaseSynchronization) + _kiss->UpdateOperation(*it); } } DeleteRows(1, GetNumberRows()-1); - LoadOperations(_operations, false, false, 0, 0); + LoadOperations(_operations, 0, 0); Layout(); diff --git a/src/view/grid/GridAccount.h b/src/view/grid/GridAccount.h index 1533290..72c6bdf 100644 --- a/src/view/grid/GridAccount.h +++ b/src/view/grid/GridAccount.h @@ -71,11 +71,11 @@ private: wxWindow* _parent; KissCount* _kiss; bool _displayLines; - bool _canAddOperation, setWeek; + bool _canAddOperation, _setWeek; bool _databaseSynchronization; wxString* _categories, *_accounts; std::vector* _operations; - bool _canAddOperation, _loadOperations; + bool _loadOperations; int _curMonth, _curYear; void SetWeek(int week, int line);