diff --git a/TODO b/TODO index 54a5f3e..eb78945 100644 --- a/TODO +++ b/TODO @@ -36,3 +36,7 @@ BUGS * When we broke a transfert into a meta operation and re create it, it's not taken in account by UpdateStats +* If a sub operation is found using SearchPanel but not its parent +it will not be displayed. In this case we must load whole meta. +This bug can't be resolved without use of hashtable because of +complexity in searching this issue. \ No newline at end of file diff --git a/src/controller/KissCount.cpp b/src/controller/KissCount.cpp index 33caf90..5f4ee28 100644 --- a/src/controller/KissCount.cpp +++ b/src/controller/KissCount.cpp @@ -400,10 +400,10 @@ void KissCount::SetOperationOrder(const wxString& order) std::vector* KissCount::Search(wxString* description, wxDateTime* dateFrom, wxDateTime* dateTo, wxString* amountFrom, wxString* amountTo, - std::vector categories, int Fix, std::vector accounts) + std::vector categories, int types, std::vector accounts) { - return _db->Search(_user, description, dateFrom, dateTo, amountFrom, amountTo, categories, Fix, accounts, true); + return _db->Search(_user, description, dateFrom, dateTo, amountFrom, amountTo, categories, types, accounts, true); } bool KissCount::SearchPreviousOperation(Operation* res, Operation& op, int month, int year) diff --git a/src/controller/KissCount.h b/src/controller/KissCount.h index 13cda18..7eb3a0a 100644 --- a/src/controller/KissCount.h +++ b/src/controller/KissCount.h @@ -82,7 +82,7 @@ public: std::vector* Search(wxString* description, wxDateTime* dateFrom, wxDateTime* dateTo, wxString* amountFrom, wxString* amountTo, - std::vector categories, int Fix, std::vector accounts); + std::vector categories, int types, std::vector accounts); bool SearchPreviousOperation(Operation* res, Operation& op, int month, int year); diff --git a/src/model/Database.cpp b/src/model/Database.cpp index eb45981..772e098 100644 --- a/src/model/Database.cpp +++ b/src/model/Database.cpp @@ -1239,7 +1239,7 @@ void Database::UpdatePreference(User* user, const wxString& preference) std::vector* Database::Search(User* user, wxString* description, wxDateTime* dateFrom, wxDateTime* dateTo, wxString* amountFrom, wxString* amountTo, - std::vector categories, int Fix, std::vector accounts, bool wildcards) + std::vector categories, int types, std::vector accounts, bool wildcards) { wxSQLite3ResultSet set; wxString req; @@ -1326,15 +1326,27 @@ std::vector* Database::Search(User* user, wxString* description, wxDa req += wxT("')"); } - if (Fix == FIX_OP) + if (types) { - if (firstCond) req += wxT(" AND ") ; else firstCond = true; - req += wxT(" fix_cost='1'"); - } - else if (Fix == NON_FIX_OP) - { - if (firstCond) req += wxT(" AND ") ; else firstCond = true; - req += wxT(" fix_cost='0'"); + if ((types & FIX_OP) ^ (types & NON_FIX_OP)) + { + if (firstCond) req += wxT(" AND ") ; else firstCond = true; + + if (types & FIX_OP) + req += wxT(" fix_cost='1'"); + else + req += wxT(" fix_cost='0'"); + } + + if ((types & CHECKED_OP) ^ (types & NOT_CHECKED_OP)) + { + if (firstCond) req += wxT(" AND ") ; else firstCond = true; + + if (types & CHECKED_OP) + req += wxT(" checked='1'"); + else + req += wxT(" checked='0'"); + } } if (firstCond) req += wxT(" AND ") ; else firstCond = true; diff --git a/src/model/Database.h b/src/model/Database.h index 0780da6..0a2d090 100644 --- a/src/model/Database.h +++ b/src/model/Database.h @@ -33,7 +33,10 @@ #define BDD_FILE "kc.bdd" #define INIT_SCRIPT "init.sql" -enum {BOTH, FIX_OP, NON_FIX_OP}; +#define FIX_OP (1 << 0) +#define NON_FIX_OP (1 << 1) +#define CHECKED_OP (1 << 2) +#define NOT_CHECKED_OP (1 << 3) class KissCount; class User; @@ -83,7 +86,7 @@ public: std::vector* Search(User* user, wxString* description, wxDateTime* dateFrom, wxDateTime* dateTo, wxString* amountFrom, wxString* amountTo, - std::vector categories, int Fix, std::vector accounts, bool wildcards); + std::vector categories, int types, std::vector accounts, bool wildcards); void GetStats(User* user, const wxString& monthFrom, const wxString& yearFrom, const wxString& monthTo, const wxString& yearTo, std::map > >* accountAmounts, diff --git a/src/view/SearchPanel.cpp b/src/view/SearchPanel.cpp index c9f7045..c33eabc 100644 --- a/src/view/SearchPanel.cpp +++ b/src/view/SearchPanel.cpp @@ -73,8 +73,9 @@ SearchPanel::SearchPanel(KissCount* kiss, wxUI *parent) : wxScrolledWindow(&(*pa for(categoryIt = user->_categories.begin(); categoryIt != user->_categories.end(); categoryIt++) _category->Append(categoryIt->name); - wxString fixop[] = {_("Both"), _("Fix"), _("Non fix")}; - _fix = new wxRadioBox(this, wxID_ANY, _("Operations"), wxDefaultPosition, wxDefaultSize, 3, fixop); + wxString stypes[] = {_("Fix"), _("Non fix"), _("Checked"), _("Not checked")}; + _optype = new wxCheckListBox(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 4, stypes); + _optype->Check(0); _optype->Check(1); _optype->Check(2); _optype->Check(3); _account = new wxCheckListBox(this, wxID_ANY); for(accountIt = user->_accounts.begin(); accountIt != user->_accounts.end(); accountIt++) @@ -100,7 +101,7 @@ SearchPanel::SearchPanel(KissCount* kiss, wxUI *parent) : wxScrolledWindow(&(*pa gridBagSizer->Add(_amountTo, wxGBPosition(1, 4)); gridBagSizer->Add(labelCategory, wxGBPosition(0, 5)); gridBagSizer->Add(_category, wxGBPosition(1, 5)); - gridBagSizer->Add(_fix, wxGBPosition(1, 6)); + gridBagSizer->Add(_optype, wxGBPosition(1, 6)); gridBagSizer->Add(labelAccount, wxGBPosition(0, 7)); gridBagSizer->Add(_account, wxGBPosition(1, 7)); gridBagSizer->Add(_searchButton, wxGBPosition(2, 0)); @@ -131,7 +132,7 @@ void SearchPanel::OnButtonSearch(wxCommandEvent& event) std::vector categories, accounts; wxDateTime *dateFrom=NULL, *dateTo=NULL; User* user= _kiss->GetUser(); - int i, fix; + int i, types=0; std::vector::iterator it; double af, at; @@ -207,7 +208,10 @@ void SearchPanel::OnButtonSearch(wxCommandEvent& event) if (_category->IsChecked(i)) categories.push_back(user->_categories[i].id); - fix = _fix->GetSelection(); + types |= (_optype->IsChecked(0)) ? FIX_OP : 0; + types |= (_optype->IsChecked(1)) ? NON_FIX_OP : 0; + types |= (_optype->IsChecked(2)) ? CHECKED_OP : 0; + types |= (_optype->IsChecked(3)) ? NOT_CHECKED_OP : 0; for(i=0; iGetAccountsNumber(); i++) if (_account->IsChecked(i)) @@ -216,7 +220,7 @@ void SearchPanel::OnButtonSearch(wxCommandEvent& event) if (_operations) delete _operations; - _operations = _kiss->Search(description, dateFrom, dateTo, amountFrom, amountTo, categories,fix, accounts); + _operations = _kiss->Search(description, dateFrom, dateTo, amountFrom, amountTo, categories,types, accounts); if (_operations->size() > 1) wxMessageBox(wxString::Format(wxT("%d"), _operations->size()) + _(" entries found"), wxT("KissCount"), wxICON_INFORMATION | wxOK); diff --git a/src/view/SearchPanel.h b/src/view/SearchPanel.h index ca81378..d6476a4 100644 --- a/src/view/SearchPanel.h +++ b/src/view/SearchPanel.h @@ -58,8 +58,7 @@ private: GridAccount *_grid; wxCheckBox *_checkDateFrom, *_checkDateTo; wxTextCtrl* _description, *_amountFrom, *_amountTo; - wxCheckListBox* _category, *_account; - wxRadioBox* _fix; + wxCheckListBox* _category, *_account, *_optype; wxButton* _searchButton; DECLARE_EVENT_TABLE(); };