diff --git a/TODO b/TODO index b9c404f..7256327 100644 --- a/TODO +++ b/TODO @@ -14,7 +14,6 @@ Others translation Handle bad SQL return Category color/font Button tooltip not translated -Do not consider account transferts into statistics =============================================================== Next version diff --git a/ressources/po/french.mo b/ressources/po/french.mo index 85718fa..cf05a67 100644 Binary files a/ressources/po/french.mo and b/ressources/po/french.mo differ diff --git a/ressources/po/french.po b/ressources/po/french.po index e042ef6..a9ec922 100644 --- a/ressources/po/french.po +++ b/ressources/po/french.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2010-08-21 11:44+0200\n" +"POT-Creation-Date: 2010-08-22 16:33+0200\n" "PO-Revision-Date: \n" "Last-Translator: Soutadé \n" "Language-Team: \n" @@ -36,7 +36,7 @@ msgstr " existe déjà " msgid " entries found" msgstr " entrées trouvées" -#: src/model/Database.cpp:102 +#: src/model/Database.cpp:130 msgid " not found, aborting" msgstr " non trouvé, arrêt" @@ -207,8 +207,12 @@ msgstr "Décroissant" msgid "Description" msgstr "Description" -#: src/model/Database.cpp:102 -#: src/model/Database.cpp:125 +#: src/model/Database.cpp:84 +#: src/model/Database.cpp:91 +#: src/model/Database.cpp:109 +#: src/model/Database.cpp:130 +#: src/model/Database.cpp:138 +#: src/model/Database.cpp:159 #: src/view/PasswordDialog.cpp:72 #: src/view/PasswordDialog.cpp:78 #: src/view/PreferencesPanel.cpp:336 @@ -228,7 +232,7 @@ msgstr "Description" msgid "Error" msgstr "Erreur" -#: src/model/Database.cpp:125 +#: src/model/Database.cpp:159 msgid "Error creating original database" msgstr "Erreur durant la création de la base de données initiale" @@ -236,7 +240,7 @@ msgstr "Erreur durant la création de la base de données initiale" msgid "Final value" msgstr "Valeur finale" -#: src/model/Database.cpp:260 +#: src/model/Database.cpp:294 #: src/controller/KissCount.cpp:276 #: src/view/GridAccount.cpp:126 msgid "Fix" @@ -352,7 +356,7 @@ msgstr "Nouvel utilisateur" msgid "New password " msgstr "Nouveau mot de passe" -#: src/model/Database.cpp:96 +#: src/model/Database.cpp:124 msgid "No database found, creating a new one" msgstr "Aucune base de données trouvée, création d'une nouvelle" @@ -466,6 +470,13 @@ msgstr "Total Crédit" msgid "Total Debit" msgstr "Total Débit" +#: src/model/Database.cpp:84 +#: src/model/Database.cpp:91 +#: src/model/Database.cpp:109 +#: src/model/Database.cpp:138 +msgid "Unable to open Database" +msgstr "Impossible d'ouvrir la base de données" + #: src/controller/KissCount.cpp:284 msgid "Unexpected" msgstr "Exceptionnel" diff --git a/ressources/po/kisscount.pot b/ressources/po/kisscount.pot index 3fd6a00..106d59b 100644 --- a/ressources/po/kisscount.pot +++ b/ressources/po/kisscount.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2010-08-21 11:44+0200\n" +"POT-Creation-Date: 2010-08-22 16:33+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -30,7 +30,7 @@ msgstr "" msgid " entries found" msgstr "" -#: src/model/Database.cpp:102 +#: src/model/Database.cpp:130 msgid " not found, aborting" msgstr "" @@ -190,7 +190,9 @@ msgstr "" msgid "Description" msgstr "" -#: src/model/Database.cpp:102 src/model/Database.cpp:125 +#: src/model/Database.cpp:84 src/model/Database.cpp:91 +#: src/model/Database.cpp:109 src/model/Database.cpp:130 +#: src/model/Database.cpp:138 src/model/Database.cpp:159 #: src/view/PasswordDialog.cpp:72 src/view/PasswordDialog.cpp:78 #: src/view/PreferencesPanel.cpp:336 src/view/PreferencesPanel.cpp:359 #: src/view/PreferencesPanel.cpp:378 src/view/PreferencesPanel.cpp:468 @@ -202,7 +204,7 @@ msgstr "" msgid "Error" msgstr "" -#: src/model/Database.cpp:125 +#: src/model/Database.cpp:159 msgid "Error creating original database" msgstr "" @@ -210,7 +212,7 @@ msgstr "" msgid "Final value" msgstr "" -#: src/model/Database.cpp:260 src/controller/KissCount.cpp:276 +#: src/model/Database.cpp:294 src/controller/KissCount.cpp:276 #: src/view/GridAccount.cpp:126 msgid "Fix" msgstr "" @@ -321,7 +323,7 @@ msgstr "" msgid "New password " msgstr "" -#: src/model/Database.cpp:96 +#: src/model/Database.cpp:124 msgid "No database found, creating a new one" msgstr "" @@ -427,6 +429,11 @@ msgstr "" msgid "Total Debit" msgstr "" +#: src/model/Database.cpp:84 src/model/Database.cpp:91 +#: src/model/Database.cpp:109 src/model/Database.cpp:138 +msgid "Unable to open Database" +msgstr "" + #: src/controller/KissCount.cpp:284 msgid "Unexpected" msgstr "" diff --git a/src/controller/KissCount.cpp b/src/controller/KissCount.cpp index 08ad27d..1238033 100644 --- a/src/controller/KissCount.cpp +++ b/src/controller/KissCount.cpp @@ -19,7 +19,7 @@ along with KissCount. If not, see . #include "KissCount.h" -KissCount::KissCount() : _user(NULL) +KissCount::KissCount(const char* bdd_filename) : _user(NULL) { _wxUI = new wxUI(this, wxT("KissCount"), wxPoint(50, 50), wxSize(1024, 768)); @@ -31,7 +31,7 @@ KissCount::KissCount() : _user(NULL) try { - _db = new Database(); + _db = new Database(bdd_filename); } catch (std::string s) { diff --git a/src/controller/KissCount.h b/src/controller/KissCount.h index a5be452..b8063cc 100644 --- a/src/controller/KissCount.h +++ b/src/controller/KissCount.h @@ -33,7 +33,7 @@ class wxUI; class KissCount { public: - KissCount(); + KissCount(const char* bdd_filename); ~KissCount(); std::list GetUsers(); diff --git a/src/main.cpp b/src/main.cpp index 7a4d950..70cb491 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,7 +25,10 @@ class MyApp: public wxApp { try { - new KissCount(); + if (argc == 2) + new KissCount(wxString(argv[1]).mb_str()); + else + new KissCount(NULL); } catch (std::string s) { @@ -38,28 +41,3 @@ class MyApp: public wxApp }; IMPLEMENT_APP(MyApp); - -// bool MyApp::OnInit() -// { -// Main app; - -// MyFrame *frame = new MyFrame( _("Hello World"), wxPoint(50, 50), wxSize(1024, 768) ); -// AccountPanel* f = new AccountPanel(frame); -// frame->Show(true); -// SetTopWindow(frame); - -// frame->Centre(); -// frame->Disable(); - -// try -// { -// app.Init(); -// } -// catch (std::string s) -// { -// std::cout << "Error " << s << "\n"; -// frame->Close(true); -// } -// frame->Enable(); -// return true; -// } diff --git a/src/model/Database.cpp b/src/model/Database.cpp index dd48480..3e9497b 100644 --- a/src/model/Database.cpp +++ b/src/model/Database.cpp @@ -71,19 +71,47 @@ static inline wxString DoubleToString(double d) return res; } -Database::Database() +Database::Database(const char* filename) { std::ifstream bdd_file; - bdd_file.open(BDD_FILE); - - if (!bdd_file) + if (filename) { - CreateDatabase(); + bdd_file.open(filename, std::ifstream::in); + + if (!bdd_file.good()) + { + wxMessageBox(_("Unable to open Database"), _("Error"), wxICON_ERROR | wxOK ); + throw std::string("Unable to open ") + filename; + } + + _db.Open(wxString(filename, wxConvUTF8)); + if (!_db.IsOpen()) + { + wxMessageBox(_("Unable to open Database"), _("Error"), wxICON_ERROR | wxOK ); + throw std::string("Unable to open ") + filename; + } } else - _db.Open(wxT(BDD_FILE)); + { + // If default BDD file, assume this can be the first load + bdd_file.open(BDD_FILE, std::ifstream::in); + if (!bdd_file.good()) + { + CreateDatabase(); + } + else + { + _db.Open(wxT(BDD_FILE)); + if (!_db.IsOpen()) + { + wxMessageBox(_("Unable to open Database"), _("Error"), wxICON_ERROR | wxOK ); + throw std::string("Unable to open ") + BDD_FILE; + } + } + } + bdd_file.close(); } @@ -105,6 +133,12 @@ void Database::CreateDatabase() _db.Open(wxT(BDD_FILE)); + if (!_db.IsOpen()) + { + wxMessageBox(_("Unable to open Database"), _("Error"), wxICON_ERROR | wxOK ); + throw std::string("Unable to open ") + BDD_FILE; + } + do { getline(init_script, line); diff --git a/src/model/Database.h b/src/model/Database.h index 05311d5..7d211fc 100644 --- a/src/model/Database.h +++ b/src/model/Database.h @@ -35,7 +35,7 @@ along with KissCount. If not, see . class Database { public: - Database(); + Database(const char* filename); std::list GetUsers(); bool IsValidUser(const wxString& user, const wxString& password); diff --git a/tools/package.sh b/tools/package.sh index 1368036..1be18af 100755 --- a/tools/package.sh +++ b/tools/package.sh @@ -11,9 +11,9 @@ make clean fi make || (echo "Compilation failed" ; exit 1) mkdir -p $DIR/lib -find $DIR -type f -exec strip \{\} \; cp -r lib/freechart/lib/* lib/wxsqlite3-1.9.9/lib/* $DIR/lib cp -r kc init.sql ressources tools/launch_kc.sh TODO CONTRIBUTORS COPYING README README.fr $DIR +find $DIR -type f -executable -exec strip \{\} \; tar -jcf $FILE $DIR rm -rf $DIR echo "Packaged !" \ No newline at end of file