From cef0e4eb3cc1a6388ec3409856cca2525b6c303e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Wed, 7 Jul 2010 21:19:47 +0200 Subject: [PATCH] Create default categories using locales (need better translation) --- init.sql | 11 ----------- src/controller/KissCount.cpp | 15 +++++++++++++++ src/model/Database.cpp | 21 +-------------------- 3 files changed, 16 insertions(+), 31 deletions(-) diff --git a/init.sql b/init.sql index f6496f5..a619184 100644 --- a/init.sql +++ b/init.sql @@ -6,18 +6,7 @@ CREATE TABLE operation(id INTEGER PRIMARY KEY, user REFERENCES user(id), account CREATE TABLE category(id INTEGER PRIMARY KEY, user REFERENCES user(id), parent REFERENCES category(id), name VARCHAR(255), color VARCHAR(255), font VARCHAR(255)); CREATE TABLE preference(id INTEGER PRIMARY KEY, user REFERENCES user(id), name VARCHAR(255), value VARCHAR(255)); CREATE TABLE default_preference(id INTEGER PRIMARY KEY, type VARCHAR(255), name VARCHAR(255), value VARCHAR(255)); -CREATE TABLE default_category(id INTEGER PRIMARY KEY, parent REFERENCES category(id), name VARCHAR(255), color VARCHAR(255), font VARCHAR(255)); INSERT INTO kisscount ("db_version") VALUES ("1"); --- INSERT INTO default_preference ("name", "value") VALUES ("category", "name", "Fixe"); --- INSERT INTO default_preference ("name", "value") VALUES ("category", "name", "Courses"); -INSERT INTO default_category ("parent", "name", "color", "font") VALUES ("0", "Fixe", "#FFFF99", ""); -INSERT INTO default_category ("parent", "name", "color", "font") VALUES ("0", "Courses", "#3DEB3D", ""); -INSERT INTO default_category ("parent", "name", "color", "font") VALUES ("0", "Loisirs", "#3DEB3D", ""); -INSERT INTO default_category ("parent", "name", "color", "font") VALUES ("0", "Frais de fonctionnement", "#3DEB3D", ""); -INSERT INTO default_category ("parent", "name", "color", "font") VALUES ("0", "Exceptionnel", "#3DEB3D", ""); -INSERT INTO default_category ("parent", "name", "color", "font") VALUES ("0", "Autre", "#3DEB3D", ""); - - -- -- No password -- INSERT INTO user ("id", "name", "password") VALUES ("0", "Greg", "da39a3ee5e6b4b0d3255bfef95601890afd80709"); diff --git a/src/controller/KissCount.cpp b/src/controller/KissCount.cpp index 4655a39..a885401 100644 --- a/src/controller/KissCount.cpp +++ b/src/controller/KissCount.cpp @@ -226,6 +226,7 @@ void KissCount::NewUser(const wxString& name) { wxDateTime curDate; Account ac = {wxT(""), wxT("Account 1"), wxT(""), false, true}; + Category cat ; _db->NewUser(name); if (_user) delete _user; @@ -234,6 +235,20 @@ void KissCount::NewUser(const wxString& name) curDate.SetToCurrent(); AddAccount(ac); + + cat.parent = wxT("0") ; cat.name = _("Fix") ; cat.color = OWN_YELLOW ; + AddCategory(cat); + cat.parent = wxT("0") ; cat.name = _("Groceries") ; cat.color = OWN_GREEN; + AddCategory(cat); + cat.parent = wxT("0") ; cat.name = _("Loisirs") ; cat.color = OWN_GREEN; + AddCategory(cat); + cat.parent = wxT("0") ; cat.name = _("Normal life") ; cat.color = OWN_GREEN; + AddCategory(cat); + cat.parent = wxT("0") ; cat.name = _("Unexpected") ; cat.color = OWN_GREEN; + AddCategory(cat); + cat.parent = wxT("0") ; cat.name = _("Other") ; cat.color = OWN_GREEN; + AddCategory(cat); + _db->GenerateMonth(_user, -1, -1, (int)curDate.GetMonth(), curDate.GetYear()); } diff --git a/src/model/Database.cpp b/src/model/Database.cpp index 8e5fe59..0372267 100644 --- a/src/model/Database.cpp +++ b/src/model/Database.cpp @@ -236,7 +236,7 @@ User* Database::LoadUser(const wxString& name) category.name = set.GetAsString(wxT("name")); category.color = wxColour(set.GetAsString(wxT("color"))); category.font = set.GetAsString(wxT("font")); - if (category.name != wxT("Fixe")) + if (category.name != _("Fixe")) user->_categories.push_back(category); else user->_categories.insert(user->_categories.begin(), category); @@ -814,25 +814,6 @@ void Database::NewUser(const wxString& name) set.Finalize(); - req = wxT("SELECT * FROM default_category"); - - EXECUTE_SQL_QUERY(req, set,); - - while (set.NextRow()) - { - req = wxT("INSERT INTO category ('user', 'parent', 'name', 'color', 'font') VALUES ('") ; - req += id + wxT("'"); - req += wxT(", '") + set.GetAsString(wxT("parent")) + wxT("'"); - req += wxT(", '") + set.GetAsString(wxT("name")) + wxT("'"); - req += wxT(", '") + set.GetAsString(wxT("color")) + wxT("'"); - req += wxT(", '") + set.GetAsString(wxT("font")) + wxT("'"); - req += wxT(")"); - - EXECUTE_SQL_UPDATE(req, ); - } - - set.Finalize(); - return ; }