From d6ade299e3cabaf26d493196d032e75c02166748 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Sun, 3 Apr 2011 19:11:34 +0200 Subject: [PATCH] Display virtual accounts at the end Fix a bug in LonkOrUnlinkOperation (when year was not previously loaded) Translate categories in PreferencesPanel --- src/model/Database.cpp | 4 ++-- src/model/User.cpp | 6 ++++++ src/view/PreferencesPanel.cpp | 3 ++- src/view/SearchPanel.cpp | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/model/Database.cpp b/src/model/Database.cpp index 735ba5f..3535a47 100644 --- a/src/model/Database.cpp +++ b/src/model/Database.cpp @@ -230,7 +230,7 @@ User* Database::LoadUser(const wxString& name) set.Finalize(); - req = wxT("SELECT * FROM account WHERE user='") + user->_id + wxT("' ORDER BY default_account DESC, blocked, virtual, name ASC"); + req = wxT("SELECT * FROM account WHERE user='") + user->_id + wxT("' ORDER BY default_account DESC, virtual, blocked, name ASC"); EXECUTE_SQL_QUERY_WITH_CODE(req, set, NULL, {delete user;}, {delete user;}); @@ -248,7 +248,7 @@ User* Database::LoadUser(const wxString& name) } set.Finalize(); - req = wxT("SELECT * FROM account WHERE id IN (SELECT account FROM shared_account WHERE user='") + user->_id + wxT("') ORDER BY blocked, virtual, name ASC"); + req = wxT("SELECT * FROM account WHERE id IN (SELECT account FROM shared_account WHERE user='") + user->_id + wxT("') ORDER BY name, blocked, virtual ASC"); EXECUTE_SQL_QUERY_WITH_CODE(req, set, NULL, {delete user;}, {delete user;}); diff --git a/src/model/User.cpp b/src/model/User.cpp index 5299bb1..1b6110f 100644 --- a/src/model/User.cpp +++ b/src/model/User.cpp @@ -170,6 +170,12 @@ void User::LinkOrUnlinkOperation(Operation& op) std::vector::iterator it; Account account, account2; + if (!_operations[op.year]) + _db->LoadYear(this, op.year); + + if (!_operations[op.year]) + return; + // Not Linked if (!op.transfert.Length()) { diff --git a/src/view/PreferencesPanel.cpp b/src/view/PreferencesPanel.cpp index 3ee4c5b..3e97df8 100644 --- a/src/view/PreferencesPanel.cpp +++ b/src/view/PreferencesPanel.cpp @@ -232,6 +232,7 @@ void PreferencesPanel::AddAccount(int line, Account ac) _accountsGrid->SetCellRenderer(line, ACCOUNT_DELETE, new wxGridCellBoolRenderer ()); _accountsGrid->SetCellEditor(line, ACCOUNT_DELETE, new wxGridCellBoolEditor ()); _accountsGrid->SetCellValue(line, ACCOUNT_DEFAULT, (ac._default)?wxT("1"):wxT("0")); + _accountsGrid->SetCellValue(line, ACCOUNT_VIRTUAL, (ac._virtual)?wxT("1"):wxT("0")); _accountsGrid->SetCellValue(line, ACCOUNT_BLOCKED, (ac.blocked)?wxT("1"):wxT("0")); _accountsGrid->SetCellAlignment(line, ACCOUNT_DEFAULT, wxALIGN_CENTRE, wxALIGN_CENTRE); @@ -702,7 +703,7 @@ void PreferencesPanel::OnCategoryModified(wxGridEvent& event) a = 0; for(i=0; i < user->GetCategoriesNumber(); i++) if (user->_categories[i].id != new_cat.id) - categories[++a] = user->_categories[i].name; + categories[++a] = wxGetTranslation(user->_categories[i].name); wxSingleChoiceDialog dialog(_wxUI, _("Wich category will replace this one ?"), wxT("KissCount"), user->GetCategoriesNumber(), categories); if (dialog.ShowModal() == wxID_CANCEL) { diff --git a/src/view/SearchPanel.cpp b/src/view/SearchPanel.cpp index ba20a76..dde8494 100644 --- a/src/view/SearchPanel.cpp +++ b/src/view/SearchPanel.cpp @@ -346,7 +346,7 @@ void SearchPanel::OnButtonChangeCategory(wxCommandEvent& event) categories[0] = _("None"); a = 0; for(i=0; i < user->GetCategoriesNumber(); i++) - categories[++a] = user->_categories[i].name; + categories[++a] = wxGetTranslation(user->_categories[i].name); wxSingleChoiceDialog dialog(_wxUI, _("Choose a new category"), wxT("KissCount"), user->GetCategoriesNumber()+1, categories);