Create default categories using locales (need better translation)

This commit is contained in:
Grégory Soutadé 2010-07-07 21:19:47 +02:00
parent 63ca3a9c22
commit cef0e4eb3c
3 changed files with 16 additions and 31 deletions

View File

@ -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");

View File

@ -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());
}

View File

@ -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 ;
}