From 1383d228182baa6135bd7d7993da3335099792d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Sat, 3 Jul 2010 11:32:30 +0200 Subject: [PATCH] Replace Account class by account structure --- controller/KissCount.cpp | 12 ++++++------ controller/KissCount.h | 6 +++--- model/Database.cpp | 20 ++++++++++---------- model/Database.h | 6 +++--- model/User.cpp | 4 ++-- model/User.h | 4 ++-- view/AccountPanel.cpp | 12 ++++++------ view/PreferencesPanel.cpp | 6 +++--- 8 files changed, 35 insertions(+), 35 deletions(-) diff --git a/controller/KissCount.cpp b/controller/KissCount.cpp index 0392ec4..36388a3 100644 --- a/controller/KissCount.cpp +++ b/controller/KissCount.cpp @@ -102,15 +102,15 @@ void KissCount::SetAccountAmount(int month, int year, wxString accountId, double _db->SetAccountAmount(month, year, accountId, amount); } -void KissCount::AddAccount(struct Account ac) +void KissCount::AddAccount(struct account ac) { ac.id = _db->AddAccount(_user, ac); _user->_accounts.push_back(ac); } -void KissCount::UpdateAccount(struct Account ac) +void KissCount::UpdateAccount(struct account ac) { - std::vector::iterator it; + std::vector::iterator it; int i; _db->UpdateAccount(ac); @@ -119,9 +119,9 @@ void KissCount::UpdateAccount(struct Account ac) _user->_accounts[i] = ac; } -void KissCount::DeleteAccount(struct Account ac) +void KissCount::DeleteAccount(struct account ac) { - std::vector::iterator it; + std::vector::iterator it; int i; _db->DeleteAccount(ac); @@ -221,7 +221,7 @@ void KissCount::ChangeName(wxString name) void KissCount::NewUser(wxString name) { wxDateTime curDate; - struct Account ac = {wxT(""), wxT("Account 1"), wxT(""), false, true}; + struct account ac = {wxT(""), wxT("Account 1"), wxT(""), false, true}; _db->NewUser(name); if (_user) delete _user; diff --git a/controller/KissCount.h b/controller/KissCount.h index f03af26..70b26fc 100644 --- a/controller/KissCount.h +++ b/controller/KissCount.h @@ -33,9 +33,9 @@ class KissCount double GetAccountAmount(wxString id, int month, int year); void SetAccountAmount(int month, int year, wxString accountId, double value); - void AddAccount(struct Account ac); - void UpdateAccount(struct Account ac); - void DeleteAccount(struct Account ac); + void AddAccount(struct account ac); + void UpdateAccount(struct account ac); + void DeleteAccount(struct account ac); wxString AddCategory(struct category category); void UpdateCategory(struct category category); diff --git a/model/Database.cpp b/model/Database.cpp index 6ad929a..e8d0dde 100644 --- a/model/Database.cpp +++ b/model/Database.cpp @@ -169,10 +169,10 @@ User* Database::LoadUser(wxString name) wxSQLite3ResultSet set; wxString req; User* user; - struct Account account; + struct account account; struct category category; - std::vector::iterator it; + std::vector::iterator it; req = wxT("SELECT * FROM user WHERE name='") + name + wxT("'"); @@ -259,7 +259,7 @@ void Database::LoadYear(User* user, int year) { wxSQLite3ResultSet set; wxString req; - std::vector::iterator it; + std::vector::iterator it; if (user->_operations[year] == NULL) user->_operations[year] = new std::map >(); @@ -407,7 +407,7 @@ void Database::DeleteOperation(struct operation op) void Database::DeleteOperations(User* user, int month, int year) { wxString req; - std::vector::iterator it; + std::vector::iterator it; it = user->_accounts.begin(); req = wxT("DELETE FROM account_amount WHERE account IN('") + it->id; @@ -470,7 +470,7 @@ void Database::SetAccountAmount(int month, int year, wxString accountId, double } } -wxString Database::AddAccount(User* user, struct Account ac) +wxString Database::AddAccount(User* user, struct account ac) { wxString req, res; wxSQLite3ResultSet set; @@ -506,7 +506,7 @@ wxString Database::AddAccount(User* user, struct Account ac) return res; } -void Database::UpdateAccount(struct Account ac) +void Database::UpdateAccount(struct account ac) { wxString req; req = wxT("UPDATE account SET ") ; @@ -525,7 +525,7 @@ void Database::UpdateAccount(struct Account ac) EXECUTE_SQL_UPDATE(req, ); } -void Database::DeleteAccount(struct Account ac) +void Database::DeleteAccount(struct account ac) { wxString req; req = wxT("DELETE FROM account WHERE id='") + ac.id + wxT("'"); @@ -608,7 +608,7 @@ std::map > Database::GetAllOperations(User* user) { wxString req; wxSQLite3ResultSet set, set2; - std::vector::iterator it; + std::vector::iterator it; std::map > res; int year; @@ -659,7 +659,7 @@ std::map > Database::GetAllOperations(User* user) void Database::GenerateMonth(User* user, int monthFrom, int yearFrom, int monthTo, int yearTo) { - std::vector::iterator it; + std::vector::iterator it; wxString req; wxSQLite3ResultSet set; double amount; @@ -823,7 +823,7 @@ void Database::NewUser(wxString name) void Database::KillMe(User* user) { wxString req; - std::vector::iterator it; + std::vector::iterator it; req = wxT("DELETE FROM preference WHERE user='") + user->_id + wxT("'"); EXECUTE_SQL_UPDATE(req, ); diff --git a/model/Database.h b/model/Database.h index b24fa4d..d02973b 100644 --- a/model/Database.h +++ b/model/Database.h @@ -31,9 +31,9 @@ class Database double GetAccountAmount(wxString id, int month, int year); void SetAccountAmount(int month, int year, wxString accountId, double amount); - wxString AddAccount(User* user, struct Account ac); - void UpdateAccount(struct Account ac); - void DeleteAccount(struct Account ac); + wxString AddAccount(User* user, struct account ac); + void UpdateAccount(struct account ac); + void DeleteAccount(struct account ac); wxString AddCategory(User* user, struct category category); void UpdateCategory(struct category category); diff --git a/model/User.cpp b/model/User.cpp index 95f9eb0..18f10b2 100644 --- a/model/User.cpp +++ b/model/User.cpp @@ -54,7 +54,7 @@ wxString User::GetCategoryId(wxString catName) wxString User::GetAccountName(wxString accountId) { - std::vector::iterator it; + std::vector::iterator it; for (it=_accounts.begin(); it !=_accounts.end(); it++) if (it->id == accountId) return it->name; @@ -64,7 +64,7 @@ wxString User::GetAccountName(wxString accountId) wxString User::GetAccountId(wxString accountName) { - std::vector::iterator it; + std::vector::iterator it; for (it=_accounts.begin(); it !=_accounts.end(); it++) if (it->name == accountName) return it->id; diff --git a/model/User.h b/model/User.h index 188680a..e9060b8 100644 --- a/model/User.h +++ b/model/User.h @@ -19,7 +19,7 @@ struct operation { bool checked; } ; -struct Account { +struct account { wxString id; wxString name; wxString number; @@ -44,7 +44,7 @@ public: wxString _id; wxString _name; wxString _password; - std::vector _accounts; + std::vector _accounts; std::map >* > _operations; std::vector _categories; std::map _preferences; diff --git a/view/AccountPanel.cpp b/view/AccountPanel.cpp index 4c6b25c..14baf64 100644 --- a/view/AccountPanel.cpp +++ b/view/AccountPanel.cpp @@ -29,7 +29,7 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : wxScrolledWindow(&(* int i ; DEFAULT_FONT(font); User* user = _kiss->GetUser(); - std::vector::iterator accountIt; + std::vector::iterator accountIt; std::vector::iterator categoryIt; wxColour categoryColors[] = {wxColour(0x00, 0x45, 0x86), wxColour(0xFF, 0x3E, 0x0E), @@ -230,7 +230,7 @@ void AccountPanel::ChangeUser() else _tree.AppendItem(rootNode, wxString::Format(wxT("%d"), it->first)); } - + Fit(); if (curYear != -1) { _tree.SelectItem(curNode, true); @@ -273,7 +273,7 @@ void AccountPanel::LoadYear(int year, bool showMonth) } _tree.Expand(parentNode); - + Fit(); if (showMonth) { _tree.SelectItem(curMonthNode, true); @@ -373,7 +373,7 @@ void AccountPanel::ShowMonth(int month, int year) UpdateStats(); - // Fit(); + Fit(); // SetMinSize(GetSize()); } @@ -474,7 +474,7 @@ void AccountPanel::InsertOperation(User* user, operation* op, int line, bool fix void AccountPanel::InitAccountsGrid(User* user, int month, int year) { - std::vector::iterator it; + std::vector::iterator it; int curLine = 0; double value; int i, a; @@ -516,7 +516,7 @@ void AccountPanel::UpdateStats() std::map curAccountAmount, finalAccountAmount; std::map::iterator doubleIt; std::map::iterator intIt; - std::vector::iterator accountIt; + std::vector::iterator accountIt; unsigned int day; day = _calendar->GetDate().GetDay()-1; diff --git a/view/PreferencesPanel.cpp b/view/PreferencesPanel.cpp index 43782db..9e31e96 100644 --- a/view/PreferencesPanel.cpp +++ b/view/PreferencesPanel.cpp @@ -85,9 +85,9 @@ PreferencesPanel::PreferencesPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*p void PreferencesPanel::InitAccounts(User* user) { - std::vector::iterator it; + std::vector::iterator it; int curLine = 0; - Account account ; + struct account account ; DEFAULT_FONT(font); _accountsGrid->CreateGrid(0, NUMBER_COLS_ACCOUNT); @@ -180,7 +180,7 @@ void PreferencesPanel::OnAccountModified(wxGridEvent& event) { int op_complete = 2; wxString value ; - struct Account new_account, account; + struct account new_account, account; User* user = _kiss->GetUser(); int row = event.GetRow(); int col = event.GetCol();