Possibility to work on multiple operations (rename, change category, change account)

New database version (2) :
		fix_cost for categories
		virtual account
This commit is contained in:
2011-02-13 19:30:12 +01:00
parent 142837b59e
commit c03562851a
40 changed files with 682 additions and 268 deletions

View File

@@ -1,4 +1,4 @@
v0.2_dev (09/02/2011)
v0.2_dev (13/02/2011)
** User **
Better use of sizers (so better interface!)
@@ -7,11 +7,16 @@ v0.2_dev (09/02/2011)
Show stats for current month even if next month has not been generated
Possibility to choose a replacement when deleting accounts and categories
Possibility to find operations with unknown category/account
Possibility to work on multiple operations (rename, change category, change account)
** Dev **
Use a factory to create panels (prepare for plug-in)
Better cross compilation support (Makefile and package.sh)
Update Copyright
New database version (2) :
fix_cost for categories
virtual account
Database checking & upgrading
** Bugs **
Bug on GenerateMonth with different years

View File

@@ -1,9 +1,9 @@
CREATE TABLE kisscount(db_version VARCHAR(20));
CREATE TABLE kisscount(db_version VARCHAR(20));
CREATE TABLE user (id INTEGER PRIMARY KEY, name VARCHAR(255), password VARCHAR(255));
CREATE TABLE account(id INTEGER PRIMARY KEY, user REFERENCES user(id), name VARCHAR(255), number VARCHAR(255), shared CHAR(1), blocked CHAR(1), default_account CHAR(1));
CREATE TABLE shared_account(account REFERENCES account(id), user REFERENCES user(id));
CREATE TABLE account_amount(id INTEGER PRIMARY KEY, account REFERENCES account(id), year INTEGER, month INTEGER, amount FLOAT);
CREATE TABLE operation(id INTEGER PRIMARY KEY, parent REFERENCES operation(id), user REFERENCES user(id), account REFERENCES account(id), year INTEGER, month INTEGER, day INTEGER, amount FLOAT, description VARCHAR(255), category REFERENCES category(id), fix_cost CHAR(1), checked CHAR(1), formula VARCHAR(255), transfert REFERENCES operation(id), meta CHAR(1));
CREATE TABLE category(id INTEGER PRIMARY KEY, user REFERENCES user(id), parent REFERENCES category(id), name VARCHAR(255), backcolor VARCHAR(10), forecolor VARCHAR(10), font VARCHAR(255));
CREATE TABLE category(id INTEGER PRIMARY KEY, user REFERENCES user(id), parent REFERENCES category(id), name VARCHAR(255), backcolor VARCHAR(10), forecolor VARCHAR(10), font VARCHAR(255), fix_cost CHAR(1));
CREATE TABLE preference(id INTEGER PRIMARY KEY, user REFERENCES user(id), name VARCHAR(255), value VARCHAR(255));
INSERT INTO kisscount ("db_version") VALUES ("1");
INSERT INTO kisscount ("db_version") VALUES ("2");

Binary file not shown.

View File

@@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-02-08 21:12+0100\n"
"POT-Creation-Date: 2011-02-13 19:27+0100\n"
"PO-Revision-Date: \n"
"Last-Translator: Soutadé <soutade@gmail.com>\n"
"Language-Team: \n"
@@ -25,19 +25,19 @@ msgid " - "
msgstr " - "
#: src/view/UsersDialog.cpp:120
#: src/view/PreferencesPanel.cpp:485
#: src/view/PreferencesPanel.cpp:505
#: src/view/PreferencesPanel.cpp:714
#: src/view/PreferencesPanel.cpp:733
#: src/view/PreferencesPanel.cpp:482
#: src/view/PreferencesPanel.cpp:502
#: src/view/PreferencesPanel.cpp:712
#: src/view/PreferencesPanel.cpp:731
#: src/view/PreferencesPanel.cpp:775
msgid " already exists"
msgstr " existe déjà"
#: src/view/SearchPanel.cpp:243
#: src/view/SearchPanel.cpp:269
msgid " entries found"
msgstr " entrées trouvées"
#: src/model/Database.cpp:147
#: src/model/Database.cpp:96
msgid " not found, aborting"
msgstr " non trouvé, arrêt"
@@ -49,21 +49,21 @@ msgstr " opérations ?"
msgid " profil ?"
msgstr " profil ?"
#: src/model/Database.cpp:136
#: src/model/Database.cpp:85
msgid "!! Warning !! If there was a bug, the old database will be suppressed !"
msgstr "!! Attention !! S'il y a eu un bug, l'ancienne base de donnée va être supprimée !"
#: src/view/SearchPanel.cpp:245
#: src/view/SearchPanel.cpp:271
msgid "1 entry found"
msgstr "1 entrée trouvée"
#: src/view/SearchPanel.cpp:90
#: src/view/SearchPanel.cpp:99
#: src/view/grid/GridAccount.cpp:67
msgid "Account"
msgstr "Compte"
#: src/view/PreferencesPanel.cpp:485
#: src/view/PreferencesPanel.cpp:505
#: src/view/PreferencesPanel.cpp:482
#: src/view/PreferencesPanel.cpp:502
msgid "Account "
msgstr "Le compte "
@@ -84,11 +84,11 @@ msgstr "Numéro de compte"
msgid "Accounts"
msgstr "Comptes"
#: src/view/SearchPanel.cpp:86
#: src/view/SearchPanel.cpp:95
msgid "Amount from"
msgstr "Montant min"
#: src/view/SearchPanel.cpp:87
#: src/view/SearchPanel.cpp:96
msgid "Amount to"
msgstr "Montant max"
@@ -97,7 +97,7 @@ msgstr "Montant max"
msgid "Are you sure want to delete "
msgstr "Etes vous sûr de vouloir supprimer "
#: src/view/grid/GridAccount.cpp:829
#: src/view/grid/GridAccount.cpp:836
msgid "Are you sure want to delete : \n"
msgstr "Etes vous sûr de vouloir supprimer : \n"
@@ -119,13 +119,13 @@ msgstr "Bloqué"
msgid "Cancel"
msgstr "Annuler"
#: src/view/grid/GridAccount.cpp:1263
#: src/view/grid/GridAccount.cpp:1270
#: src/view/grid/GridAccount.cpp:1267
#: src/view/grid/GridAccount.cpp:1274
msgid "Cannot group these operations"
msgstr "Impossible de grouper ces opérations"
#: src/view/grid/GridAccount.cpp:1389
#: src/view/grid/GridAccount.cpp:1395
#: src/view/grid/GridAccount.cpp:1393
#: src/view/grid/GridAccount.cpp:1399
msgid "Cannot ungroup these operations"
msgstr "Impossible de dégrouper ces opérations"
@@ -133,13 +133,13 @@ msgstr "Impossible de dégrouper ces opérations"
msgid "Categories"
msgstr "Catégories"
#: src/view/SearchPanel.cpp:88
#: src/view/SearchPanel.cpp:97
#: src/view/grid/GridAccount.cpp:67
msgid "Category"
msgstr "Catégorie"
#: src/view/PreferencesPanel.cpp:714
#: src/view/PreferencesPanel.cpp:733
#: src/view/PreferencesPanel.cpp:712
#: src/view/PreferencesPanel.cpp:731
msgid "Category "
msgstr "La catégorie "
@@ -151,6 +151,14 @@ msgstr "Changer de nom"
msgid "Change Password"
msgstr "Changer le mot de passe"
#: src/view/SearchPanel.cpp:125
msgid "Change account"
msgstr "Changer de compte"
#: src/view/SearchPanel.cpp:126
msgid "Change category"
msgstr "Changer la catégorie"
#: src/view/PasswordDialog.cpp:29
msgid "Change password"
msgstr "Changer le mot de passe"
@@ -159,10 +167,18 @@ msgstr "Changer le mot de passe"
msgid "Check mode"
msgstr "Mode rapprochement"
#: src/view/SearchPanel.cpp:76
#: src/view/SearchPanel.cpp:84
msgid "Checked"
msgstr "Rapprochée"
#: src/view/SearchPanel.cpp:309
msgid "Choose a new account"
msgstr "Nouveau compte"
#: src/view/SearchPanel.cpp:351
msgid "Choose a new category"
msgstr "Nouvelle catégorie"
#: src/view/PasswordDialog.cpp:46
msgid "Confirm password "
msgstr "Confirmer le mot de passe "
@@ -192,11 +208,11 @@ msgstr "Valeur courante"
msgid "Date"
msgstr "Date"
#: src/view/SearchPanel.cpp:49
#: src/view/SearchPanel.cpp:56
msgid "Date from"
msgstr "Date min"
#: src/view/SearchPanel.cpp:50
#: src/view/SearchPanel.cpp:57
msgid "Date to"
msgstr "Date max"
@@ -218,44 +234,47 @@ msgstr "Supprimer"
msgid "Descending"
msgstr "Décroissant"
#: src/view/SearchPanel.cpp:85
#: src/view/SearchPanel.cpp:94
#: src/view/grid/GridAccount.cpp:67
msgid "Description"
msgstr "Description"
#: src/view/SearchPanel.cpp:394
msgid "Enter a new description"
msgstr "Nouvelle description"
#: src/view/UsersDialog.cpp:90
#: src/view/UsersDialog.cpp:120
#: src/view/SearchPanel.cpp:158
#: src/view/SearchPanel.cpp:168
#: src/view/SearchPanel.cpp:182
#: src/view/SearchPanel.cpp:193
#: src/view/SearchPanel.cpp:179
#: src/view/SearchPanel.cpp:189
#: src/view/SearchPanel.cpp:203
#: src/view/SearchPanel.cpp:214
#: src/view/PreferencesPanel.cpp:422
#: src/view/PreferencesPanel.cpp:485
#: src/view/PreferencesPanel.cpp:505
#: src/view/PreferencesPanel.cpp:714
#: src/view/PreferencesPanel.cpp:733
#: src/view/PreferencesPanel.cpp:482
#: src/view/PreferencesPanel.cpp:502
#: src/view/PreferencesPanel.cpp:712
#: src/view/PreferencesPanel.cpp:731
#: src/view/PreferencesPanel.cpp:769
#: src/view/PreferencesPanel.cpp:775
#: src/view/PasswordDialog.cpp:72
#: src/view/PasswordDialog.cpp:78
#: src/view/AccountPanel.cpp:748
#: src/view/grid/GridAccount.cpp:1263
#: src/view/grid/GridAccount.cpp:1270
#: src/view/grid/GridAccount.cpp:1389
#: src/view/grid/GridAccount.cpp:1395
#: src/view/grid/GridAccount.cpp:1267
#: src/view/grid/GridAccount.cpp:1274
#: src/view/grid/GridAccount.cpp:1393
#: src/view/grid/GridAccount.cpp:1399
#: src/view/grid/wxGridCellFormulaEditor.cpp:69
#: src/model/Database.cpp:38
#: src/model/Database.cpp:55
#: src/model/Database.cpp:95
#: src/model/Database.cpp:102
#: src/model/Database.cpp:120
#: src/model/Database.cpp:147
#: src/model/Database.cpp:155
#: src/model/Database.cpp:176
#: src/model/Database.cpp:42
#: src/model/Database.cpp:49
#: src/model/Database.cpp:67
#: src/model/Database.cpp:96
#: src/model/Database.cpp:104
#: src/model/Database.cpp:125
#: src/model/Database_Update.cpp:23
msgid "Error"
msgstr "Erreur"
#: src/model/Database.cpp:176
#: src/model/Database.cpp:125
msgid "Error creating original database"
msgstr "Erreur durant la création de la base de données initiale"
@@ -263,9 +282,8 @@ msgstr "Erreur durant la création de la base de données initiale"
msgid "Final value"
msgstr "Valeur finale"
#: src/view/SearchPanel.cpp:76
#: src/view/grid/GridAccount.cpp:326
#: src/model/Database.cpp:331
#: src/view/SearchPanel.cpp:84
#: src/view/grid/GridAccount.cpp:329
#: src/controller/KissCount.cpp:379
msgid "Fix"
msgstr "Fixe"
@@ -307,19 +325,19 @@ msgstr "Loisirs"
msgid "Initial value"
msgstr "Valeur initiale"
#: src/view/SearchPanel.cpp:168
#: src/view/SearchPanel.cpp:189
msgid "Invalid amount from"
msgstr "Montant min invalide"
#: src/view/SearchPanel.cpp:193
#: src/view/SearchPanel.cpp:214
msgid "Invalid amount range"
msgstr "Intervalle des montants invalide"
#: src/view/SearchPanel.cpp:182
#: src/view/SearchPanel.cpp:203
msgid "Invalid amount to"
msgstr "Montant max invalide"
#: src/view/SearchPanel.cpp:158
#: src/view/SearchPanel.cpp:179
msgid "Invalid date range"
msgstr "Intervalle de temps invalide"
@@ -358,6 +376,7 @@ msgstr "Kill me"
#: src/view/StatsPanel.cpp:377
#: src/view/PreferencesPanel.cpp:809
#: src/view/PreferencesPanel.cpp:812
#: src/model/Database_Update.cpp:127
msgid "KissCount"
msgstr "KissCount"
@@ -392,7 +411,7 @@ msgstr "Nouvel utilisateur"
msgid "New password "
msgstr "Nouveau mot de passe "
#: src/model/Database.cpp:135
#: src/model/Database.cpp:84
msgid ""
"No database found, would you like to create a new one ?\n"
"\n"
@@ -400,20 +419,22 @@ msgstr ""
"Aucune base de données trouvée, voulez vous en créer une nouvelle ?\n"
"\n"
#: src/view/SearchPanel.cpp:248
#: src/view/SearchPanel.cpp:274
msgid "No entry found"
msgstr "Pas d'entrée trouvée"
#: src/view/SearchPanel.cpp:76
#: src/view/SearchPanel.cpp:84
msgid "Non fix"
msgstr "Courantes"
#: src/view/PreferencesPanel.cpp:429
#: src/view/PreferencesPanel.cpp:689
#: src/view/SearchPanel.cpp:304
#: src/view/SearchPanel.cpp:346
#: src/view/PreferencesPanel.cpp:427
#: src/view/PreferencesPanel.cpp:687
msgid "None"
msgstr "Aucun"
#: src/view/SearchPanel.cpp:76
#: src/view/SearchPanel.cpp:84
msgid "Not checked"
msgstr "Non rapprochée"
@@ -439,7 +460,7 @@ msgstr "Fonctionnement"
msgid "Operation order"
msgstr "Ordre des opérations"
#: src/view/SearchPanel.cpp:89
#: src/view/SearchPanel.cpp:98
#: src/view/AccountPanel.cpp:175
msgid "Operations"
msgstr "Opérations"
@@ -456,7 +477,7 @@ msgstr "Mot de passe "
msgid "Password changed"
msgstr "Mot de passe changé"
#: src/view/wxUI.cpp:245
#: src/view/wxUI.cpp:247
msgid ""
"Personal accounting software\n"
"\n"
@@ -484,11 +505,7 @@ msgstr "Re entrez le mot de passe"
msgid "Preferences"
msgstr "Préférences"
#: src/model/Database.cpp:55
msgid "Query failed !\n"
msgstr "La requête a échouée !\n"
#: src/view/wxUI.cpp:252
#: src/view/wxUI.cpp:254
msgid "Quit KissCount ?"
msgstr "Quitter KissCount ?"
@@ -496,9 +513,13 @@ msgstr "Quitter KissCount ?"
msgid "Remains"
msgstr "Restant"
#: src/view/SearchPanel.cpp:83
#: src/view/SearchPanel.cpp:143
#: src/view/SearchPanel.cpp:259
#: src/view/SearchPanel.cpp:127
msgid "Rename"
msgstr "Renommer"
#: src/view/SearchPanel.cpp:92
#: src/view/SearchPanel.cpp:164
#: src/view/SearchPanel.cpp:410
msgid "Search"
msgstr "Chercher"
@@ -536,10 +557,10 @@ msgstr "Total Débit"
msgid "UnGroup"
msgstr "Dégrouper"
#: src/model/Database.cpp:95
#: src/model/Database.cpp:102
#: src/model/Database.cpp:120
#: src/model/Database.cpp:155
#: src/model/Database.cpp:42
#: src/model/Database.cpp:49
#: src/model/Database.cpp:67
#: src/model/Database.cpp:104
msgid "Unable to open Database"
msgstr "Impossible d'ouvrir la base de données"
@@ -547,16 +568,14 @@ msgstr "Impossible d'ouvrir la base de données"
msgid "Unexpected"
msgstr "Exceptionnel"
#: src/model/User.cpp:52
#: src/model/User.cpp:72
#: src/model/User.cpp:120
#: src/view/SearchPanel.cpp:80
#: src/view/SearchPanel.cpp:88
#: src/model/User.cpp:59
#: src/model/User.cpp:79
#: src/model/User.cpp:127
msgid "Unknown"
msgstr "Inconnu"
#: src/model/Database.cpp:38
msgid "Update failed !\n"
msgstr "La mise à jour à échouée !\n"
#: src/view/PreferencesPanel.cpp:59
msgid "User"
msgstr "Utilisateur"
@@ -571,19 +590,19 @@ msgstr "Utilisateur "
msgid "Users"
msgstr "Utilisateurs"
#: src/view/grid/GridAccount.cpp:1037
#: src/view/grid/GridAccount.cpp:1044
msgid "Warning"
msgstr "Attention"
#: src/view/PreferencesPanel.cpp:434
#: src/view/PreferencesPanel.cpp:432
msgid "Wich account will replace this one ?"
msgstr "Quel compte va remplacer celui-ci ?"
#: src/view/PreferencesPanel.cpp:694
#: src/view/PreferencesPanel.cpp:692
msgid "Wich category will replace this one ?"
msgstr "Quelle catégorie va remplacer celle-ci"
#: src/view/grid/GridAccount.cpp:1037
#: src/view/grid/GridAccount.cpp:1044
msgid "You made a debit on a blocked account"
msgstr "Vous avez effectué une opération de débit sur un compte bloqué"
@@ -635,6 +654,10 @@ msgstr "octobre"
msgid "september"
msgstr "septembre"
#~ msgid "Query failed !\n"
#~ msgstr "La requête a échouée !\n"
#~ msgid "Update failed !\n"
#~ msgstr "La mise à jour à échouée !\n"
#~ msgid "About"
#~ msgstr "A propos"
#~ msgid "Change user"

View File

@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-02-08 21:12+0100\n"
"POT-Creation-Date: 2011-02-13 19:27+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -21,17 +21,17 @@ msgstr ""
msgid " - "
msgstr ""
#: src/view/UsersDialog.cpp:120 src/view/PreferencesPanel.cpp:485
#: src/view/PreferencesPanel.cpp:505 src/view/PreferencesPanel.cpp:714
#: src/view/PreferencesPanel.cpp:733 src/view/PreferencesPanel.cpp:775
#: src/view/UsersDialog.cpp:120 src/view/PreferencesPanel.cpp:482
#: src/view/PreferencesPanel.cpp:502 src/view/PreferencesPanel.cpp:712
#: src/view/PreferencesPanel.cpp:731 src/view/PreferencesPanel.cpp:775
msgid " already exists"
msgstr ""
#: src/view/SearchPanel.cpp:243
#: src/view/SearchPanel.cpp:269
msgid " entries found"
msgstr ""
#: src/model/Database.cpp:147
#: src/model/Database.cpp:96
msgid " not found, aborting"
msgstr ""
@@ -43,19 +43,19 @@ msgstr ""
msgid " profil ?"
msgstr ""
#: src/model/Database.cpp:136
#: src/model/Database.cpp:85
msgid "!! Warning !! If there was a bug, the old database will be suppressed !"
msgstr ""
#: src/view/SearchPanel.cpp:245
#: src/view/SearchPanel.cpp:271
msgid "1 entry found"
msgstr ""
#: src/view/SearchPanel.cpp:90 src/view/grid/GridAccount.cpp:67
#: src/view/SearchPanel.cpp:99 src/view/grid/GridAccount.cpp:67
msgid "Account"
msgstr ""
#: src/view/PreferencesPanel.cpp:485 src/view/PreferencesPanel.cpp:505
#: src/view/PreferencesPanel.cpp:482 src/view/PreferencesPanel.cpp:502
msgid "Account "
msgstr ""
@@ -75,11 +75,11 @@ msgstr ""
msgid "Accounts"
msgstr ""
#: src/view/SearchPanel.cpp:86
#: src/view/SearchPanel.cpp:95
msgid "Amount from"
msgstr ""
#: src/view/SearchPanel.cpp:87
#: src/view/SearchPanel.cpp:96
msgid "Amount to"
msgstr ""
@@ -87,7 +87,7 @@ msgstr ""
msgid "Are you sure want to delete "
msgstr ""
#: src/view/grid/GridAccount.cpp:829
#: src/view/grid/GridAccount.cpp:836
msgid "Are you sure want to delete : \n"
msgstr ""
@@ -108,11 +108,11 @@ msgstr ""
msgid "Cancel"
msgstr ""
#: src/view/grid/GridAccount.cpp:1263 src/view/grid/GridAccount.cpp:1270
#: src/view/grid/GridAccount.cpp:1267 src/view/grid/GridAccount.cpp:1274
msgid "Cannot group these operations"
msgstr ""
#: src/view/grid/GridAccount.cpp:1389 src/view/grid/GridAccount.cpp:1395
#: src/view/grid/GridAccount.cpp:1393 src/view/grid/GridAccount.cpp:1399
msgid "Cannot ungroup these operations"
msgstr ""
@@ -120,11 +120,11 @@ msgstr ""
msgid "Categories"
msgstr ""
#: src/view/SearchPanel.cpp:88 src/view/grid/GridAccount.cpp:67
#: src/view/SearchPanel.cpp:97 src/view/grid/GridAccount.cpp:67
msgid "Category"
msgstr ""
#: src/view/PreferencesPanel.cpp:714 src/view/PreferencesPanel.cpp:733
#: src/view/PreferencesPanel.cpp:712 src/view/PreferencesPanel.cpp:731
msgid "Category "
msgstr ""
@@ -136,6 +136,14 @@ msgstr ""
msgid "Change Password"
msgstr ""
#: src/view/SearchPanel.cpp:125
msgid "Change account"
msgstr ""
#: src/view/SearchPanel.cpp:126
msgid "Change category"
msgstr ""
#: src/view/PasswordDialog.cpp:29
msgid "Change password"
msgstr ""
@@ -144,10 +152,18 @@ msgstr ""
msgid "Check mode"
msgstr ""
#: src/view/SearchPanel.cpp:76
#: src/view/SearchPanel.cpp:84
msgid "Checked"
msgstr ""
#: src/view/SearchPanel.cpp:309
msgid "Choose a new account"
msgstr ""
#: src/view/SearchPanel.cpp:351
msgid "Choose a new category"
msgstr ""
#: src/view/PasswordDialog.cpp:46
msgid "Confirm password "
msgstr ""
@@ -176,11 +192,11 @@ msgstr ""
msgid "Date"
msgstr ""
#: src/view/SearchPanel.cpp:49
#: src/view/SearchPanel.cpp:56
msgid "Date from"
msgstr ""
#: src/view/SearchPanel.cpp:50
#: src/view/SearchPanel.cpp:57
msgid "Date to"
msgstr ""
@@ -201,29 +217,32 @@ msgstr ""
msgid "Descending"
msgstr ""
#: src/view/SearchPanel.cpp:85 src/view/grid/GridAccount.cpp:67
#: src/view/SearchPanel.cpp:94 src/view/grid/GridAccount.cpp:67
msgid "Description"
msgstr ""
#: src/view/SearchPanel.cpp:394
msgid "Enter a new description"
msgstr ""
#: src/view/UsersDialog.cpp:90 src/view/UsersDialog.cpp:120
#: src/view/SearchPanel.cpp:158 src/view/SearchPanel.cpp:168
#: src/view/SearchPanel.cpp:182 src/view/SearchPanel.cpp:193
#: src/view/PreferencesPanel.cpp:422 src/view/PreferencesPanel.cpp:485
#: src/view/PreferencesPanel.cpp:505 src/view/PreferencesPanel.cpp:714
#: src/view/PreferencesPanel.cpp:733 src/view/PreferencesPanel.cpp:769
#: src/view/SearchPanel.cpp:179 src/view/SearchPanel.cpp:189
#: src/view/SearchPanel.cpp:203 src/view/SearchPanel.cpp:214
#: src/view/PreferencesPanel.cpp:422 src/view/PreferencesPanel.cpp:482
#: src/view/PreferencesPanel.cpp:502 src/view/PreferencesPanel.cpp:712
#: src/view/PreferencesPanel.cpp:731 src/view/PreferencesPanel.cpp:769
#: src/view/PreferencesPanel.cpp:775 src/view/PasswordDialog.cpp:72
#: src/view/PasswordDialog.cpp:78 src/view/AccountPanel.cpp:748
#: src/view/grid/GridAccount.cpp:1263 src/view/grid/GridAccount.cpp:1270
#: src/view/grid/GridAccount.cpp:1389 src/view/grid/GridAccount.cpp:1395
#: src/view/grid/wxGridCellFormulaEditor.cpp:69 src/model/Database.cpp:38
#: src/model/Database.cpp:55 src/model/Database.cpp:95
#: src/model/Database.cpp:102 src/model/Database.cpp:120
#: src/model/Database.cpp:147 src/model/Database.cpp:155
#: src/model/Database.cpp:176
#: src/view/grid/GridAccount.cpp:1267 src/view/grid/GridAccount.cpp:1274
#: src/view/grid/GridAccount.cpp:1393 src/view/grid/GridAccount.cpp:1399
#: src/view/grid/wxGridCellFormulaEditor.cpp:69 src/model/Database.cpp:42
#: src/model/Database.cpp:49 src/model/Database.cpp:67
#: src/model/Database.cpp:96 src/model/Database.cpp:104
#: src/model/Database.cpp:125 src/model/Database_Update.cpp:23
msgid "Error"
msgstr ""
#: src/model/Database.cpp:176
#: src/model/Database.cpp:125
msgid "Error creating original database"
msgstr ""
@@ -231,8 +250,8 @@ msgstr ""
msgid "Final value"
msgstr ""
#: src/view/SearchPanel.cpp:76 src/view/grid/GridAccount.cpp:326
#: src/model/Database.cpp:331 src/controller/KissCount.cpp:379
#: src/view/SearchPanel.cpp:84 src/view/grid/GridAccount.cpp:329
#: src/controller/KissCount.cpp:379
msgid "Fix"
msgstr ""
@@ -272,19 +291,19 @@ msgstr ""
msgid "Initial value"
msgstr ""
#: src/view/SearchPanel.cpp:168
#: src/view/SearchPanel.cpp:189
msgid "Invalid amount from"
msgstr ""
#: src/view/SearchPanel.cpp:193
#: src/view/SearchPanel.cpp:214
msgid "Invalid amount range"
msgstr ""
#: src/view/SearchPanel.cpp:182
#: src/view/SearchPanel.cpp:203
msgid "Invalid amount to"
msgstr ""
#: src/view/SearchPanel.cpp:158
#: src/view/SearchPanel.cpp:179
msgid "Invalid date range"
msgstr ""
@@ -321,7 +340,7 @@ msgid "Kill me"
msgstr ""
#: src/view/StatsPanel.cpp:377 src/view/PreferencesPanel.cpp:809
#: src/view/PreferencesPanel.cpp:812
#: src/view/PreferencesPanel.cpp:812 src/model/Database_Update.cpp:127
msgid "KissCount"
msgstr ""
@@ -354,25 +373,26 @@ msgstr ""
msgid "New password "
msgstr ""
#: src/model/Database.cpp:135
#: src/model/Database.cpp:84
msgid ""
"No database found, would you like to create a new one ?\n"
"\n"
msgstr ""
#: src/view/SearchPanel.cpp:248
#: src/view/SearchPanel.cpp:274
msgid "No entry found"
msgstr ""
#: src/view/SearchPanel.cpp:76
#: src/view/SearchPanel.cpp:84
msgid "Non fix"
msgstr ""
#: src/view/PreferencesPanel.cpp:429 src/view/PreferencesPanel.cpp:689
#: src/view/SearchPanel.cpp:304 src/view/SearchPanel.cpp:346
#: src/view/PreferencesPanel.cpp:427 src/view/PreferencesPanel.cpp:687
msgid "None"
msgstr ""
#: src/view/SearchPanel.cpp:76
#: src/view/SearchPanel.cpp:84
msgid "Not checked"
msgstr ""
@@ -397,7 +417,7 @@ msgstr ""
msgid "Operation order"
msgstr ""
#: src/view/SearchPanel.cpp:89 src/view/AccountPanel.cpp:175
#: src/view/SearchPanel.cpp:98 src/view/AccountPanel.cpp:175
msgid "Operations"
msgstr ""
@@ -413,7 +433,7 @@ msgstr ""
msgid "Password changed"
msgstr ""
#: src/view/wxUI.cpp:245
#: src/view/wxUI.cpp:247
msgid ""
"Personal accounting software\n"
"\n"
@@ -433,11 +453,7 @@ msgstr ""
msgid "Preferences"
msgstr ""
#: src/model/Database.cpp:55
msgid "Query failed !\n"
msgstr ""
#: src/view/wxUI.cpp:252
#: src/view/wxUI.cpp:254
msgid "Quit KissCount ?"
msgstr ""
@@ -445,8 +461,12 @@ msgstr ""
msgid "Remains"
msgstr ""
#: src/view/SearchPanel.cpp:83 src/view/SearchPanel.cpp:143
#: src/view/SearchPanel.cpp:259
#: src/view/SearchPanel.cpp:127
msgid "Rename"
msgstr ""
#: src/view/SearchPanel.cpp:92 src/view/SearchPanel.cpp:164
#: src/view/SearchPanel.cpp:410
msgid "Search"
msgstr ""
@@ -482,8 +502,8 @@ msgstr ""
msgid "UnGroup"
msgstr ""
#: src/model/Database.cpp:95 src/model/Database.cpp:102
#: src/model/Database.cpp:120 src/model/Database.cpp:155
#: src/model/Database.cpp:42 src/model/Database.cpp:49
#: src/model/Database.cpp:67 src/model/Database.cpp:104
msgid "Unable to open Database"
msgstr ""
@@ -491,14 +511,11 @@ msgstr ""
msgid "Unexpected"
msgstr ""
#: src/model/User.cpp:52 src/model/User.cpp:72 src/model/User.cpp:120
#: src/view/SearchPanel.cpp:80 src/view/SearchPanel.cpp:88
#: src/model/User.cpp:59 src/model/User.cpp:79 src/model/User.cpp:127
msgid "Unknown"
msgstr ""
#: src/model/Database.cpp:38
msgid "Update failed !\n"
msgstr ""
#: src/view/PreferencesPanel.cpp:59
msgid "User"
msgstr ""
@@ -512,19 +529,19 @@ msgstr ""
msgid "Users"
msgstr ""
#: src/view/grid/GridAccount.cpp:1037
#: src/view/grid/GridAccount.cpp:1044
msgid "Warning"
msgstr ""
#: src/view/PreferencesPanel.cpp:434
#: src/view/PreferencesPanel.cpp:432
msgid "Wich account will replace this one ?"
msgstr ""
#: src/view/PreferencesPanel.cpp:694
#: src/view/PreferencesPanel.cpp:692
msgid "Wich category will replace this one ?"
msgstr ""
#: src/view/grid/GridAccount.cpp:1037
#: src/view/grid/GridAccount.cpp:1044
msgid "You made a debit on a blocked account"
msgstr ""

View File

@@ -1,5 +1,5 @@
/*
Copyright 2010 Grégory Soutadé
Copyright 2010-2011 Grégory Soutadé
This file is part of KissCount.

View File

@@ -1,5 +1,5 @@
/*
Copyright 2010 Grégory Soutadé
Copyright 2010-2011 Grégory Soutadé
This file is part of KissCount.
@@ -376,17 +376,17 @@ void KissCount::NewUser(const wxString& name)
AddAccount(ac);
cat.parent = wxT("0") ; cat.name = _("Fix") ; cat.backcolor = OWN_YELLOW ; cat.forecolor = *wxBLACK;
cat.parent = wxT("0") ; cat.name = _("Fix") ; cat.backcolor = OWN_YELLOW ; cat.forecolor = *wxBLACK; cat.fix_cost = true;
AddCategory(cat);
cat.parent = wxT("0") ; cat.name = _("Groceries") ; cat.backcolor = OWN_GREEN; cat.forecolor = *wxBLACK;
cat.parent = wxT("0") ; cat.name = _("Groceries") ; cat.backcolor = OWN_GREEN; cat.forecolor = *wxBLACK; cat.fix_cost = false;
AddCategory(cat);
cat.parent = wxT("0") ; cat.name = _("Hobbies") ; cat.backcolor = OWN_GREEN; cat.forecolor = *wxBLACK;
cat.parent = wxT("0") ; cat.name = _("Hobbies") ; cat.backcolor = OWN_GREEN; cat.forecolor = *wxBLACK; cat.fix_cost = false;
AddCategory(cat);
cat.parent = wxT("0") ; cat.name = _("Operating exepense") ; cat.backcolor = OWN_GREEN; cat.forecolor = *wxBLACK;
cat.parent = wxT("0") ; cat.name = _("Operating exepense") ; cat.backcolor = OWN_GREEN; cat.forecolor = *wxBLACK; cat.fix_cost = false;
AddCategory(cat);
cat.parent = wxT("0") ; cat.name = _("Unexpected") ; cat.backcolor = OWN_GREEN; cat.forecolor = *wxBLACK;
cat.parent = wxT("0") ; cat.name = _("Unexpected") ; cat.backcolor = OWN_GREEN; cat.forecolor = *wxBLACK; cat.fix_cost = false;
AddCategory(cat);
cat.parent = wxT("0") ; cat.name = _("Other") ; cat.backcolor = OWN_GREEN; cat.forecolor = *wxBLACK;
cat.parent = wxT("0") ; cat.name = _("Other") ; cat.backcolor = OWN_GREEN; cat.forecolor = *wxBLACK; cat.fix_cost = false;
AddCategory(cat);
SetOperationOrder(wxT("ASC"));

View File

@@ -1,5 +1,5 @@
/*
Copyright 2010 Grégory Soutadé
Copyright 2010-2011 Grégory Soutadé
This file is part of KissCount.

View File

@@ -29,6 +29,7 @@ public:
wxColour backcolor;
wxColour forecolor;
wxString font;
bool fix_cost;
};
#endif

View File

@@ -1,5 +1,5 @@
/*
Copyright 2010 Grégory Soutadé
Copyright 2010-2011 Grégory Soutadé
This file is part of KissCount.
@@ -19,59 +19,6 @@
#include "Database.h"
// if (!_db.CheckSyntax(req))
// {
// wxString s = req;
// std::cout << s.mb_str() << " is invalid !\n" ;
// code_if_syntax_fail;
// return return_value;
// }
#define EXECUTE_SQL_UPDATE_WITH_CODE(req, return_value, code_if_fail, code_if_syntax_fail) \
do{ \
try \
{ \
_db.ExecuteUpdate(req); \
} \
catch (wxSQLite3Exception e) \
{ \
wxMessageBox(_("Update failed !\n") + req, _("Error"), wxICON_ERROR | wxOK); \
std::cerr << __FUNCTION__ << "\n" ; \
std::cerr << req.mb_str() << "\n" ; \
std::cerr << e.GetMessage().mb_str() << "\n" ; \
code_if_fail; \
return return_value; \
} \
} while(0);
#define EXECUTE_SQL_QUERY_WITH_CODE(req, res, return_value, code_if_fail, code_if_syntax_fail) \
do{ \
try \
{ \
res = _db.ExecuteQuery(req); \
} \
catch (wxSQLite3Exception e) \
{ \
wxMessageBox(_("Query failed !\n") + req, _("Error"), wxICON_ERROR | wxOK); \
std::cerr << __FUNCTION__ << "\n" ; \
std::cerr << req.mb_str() << "\n" ; \
std::cerr << e.GetMessage().mb_str() << "\n" ; \
code_if_fail; \
return return_value; \
} \
} while(0);
#define EXECUTE_SQL_QUERY(req, res, return_value) EXECUTE_SQL_QUERY_WITH_CODE(req, res, return_value, {}, {})
#define EXECUTE_SQL_UPDATE(req, return_value) EXECUTE_SQL_UPDATE_WITH_CODE(req, return_value, {}, {})
#define ESCAPE_CHARS(s) { \
if (s.Find(wxT("\\\"")) == wxNOT_FOUND) \
s.Replace(wxT("\""), wxT("\\\""), true); \
if (s.Find(wxT("\\\'")) == wxNOT_FOUND) \
s.Replace(wxT("\'"), wxT("\\\'"), true); \
}
static inline wxString DoubleToString(double d)
{
wxString res;
@@ -124,6 +71,8 @@ Database::Database(const char* filename, KissCount* kiss) : _kiss(kiss)
}
bdd_file.close();
CheckDatabaseVersion();
}
void Database::CreateDatabase()
@@ -317,7 +266,7 @@ User* Database::LoadUser(const wxString& name)
set.Finalize();
}
req = wxT("SELECT * FROM category WHERE user='") + user->_id + wxT("' ORDER BY name ASC");
req = wxT("SELECT * FROM category WHERE user='") + user->_id + wxT("' ORDER BY fix_cost DESC, name ASC");
EXECUTE_SQL_QUERY_WITH_CODE(req, set, NULL, {delete user;}, {delete user;});
while (set.NextRow())
@@ -328,16 +277,10 @@ User* Database::LoadUser(const wxString& name)
category.backcolor = wxColour(set.GetAsString(wxT("backcolor")));
category.forecolor = wxColour(set.GetAsString(wxT("forecolor")));
category.font = set.GetAsString(wxT("font"));
if (category.name != _("Fix"))
{
user->_categories.push_back(category);
user->_categoriesFonts.push_back(_kiss->ExtractFont(category.font));
}
else
{
user->_categories.insert(user->_categories.begin(), category);
user->_categoriesFonts.insert(user->_categoriesFonts.begin(), _kiss->ExtractFont(category.font));
}
category.fix_cost = set.GetBool(wxT("fix_cost"));
user->_categories.push_back(category);
user->_categoriesFonts.push_back(_kiss->ExtractFont(category.font));
}
set.Finalize();
@@ -563,6 +506,10 @@ void Database::UpdateOperation(Operation& op)
req += wxT(", amount='") + DoubleToString(op.amount) + wxT("'");
req += wxT(", description=\"") + op.description + wxT("\"");
req += wxT(", category='") + op.category + wxT("'");
if (op.fix_cost)
req += wxT(", fix_cost='1'");
else
req += wxT(", fix_cost='0'");
if (op.checked)
req += wxT(", checked='1'");
else
@@ -939,13 +886,17 @@ wxString Database::AddCategory(User* user, Category& category)
forecolor += wxString::Format(wxT("%02X"), category.forecolor.Green());
forecolor += wxString::Format(wxT("%02X"), category.forecolor.Blue());
req = wxT("INSERT INTO category ('user', 'parent', 'name', 'backcolor', 'forecolor', font) VALUES ('") ;
req = wxT("INSERT INTO category ('user', 'parent', 'name', 'backcolor', 'forecolor', 'font', 'fix_cost') VALUES ('") ;
req += user->_id + wxT("'");
req += wxT(", '") + category.parent + wxT("'");
req += wxT(", '") + category.name + wxT("'");
req += wxT(", '") + backcolor + wxT("'");
req += wxT(", '") + forecolor + wxT("'");
req += wxT(", '") + category.font + wxT("'");
if (category.fix_cost)
req += wxT(", '1'");
else
req += wxT(", '0'");
req += wxT(")");
EXECUTE_SQL_UPDATE(req, wxT("0"));
@@ -974,6 +925,10 @@ void Database::UpdateCategory(Category& category)
req += wxT(", backcolor='") + backcolor + wxT("'");
req += wxT(", forecolor='") + forecolor + wxT("'");
req += wxT(", font='") + category.font + wxT("'");
if (category.fix_cost)
req += wxT(", fix_cost='1'");
else
req += wxT(", fix_cost='0'");
req += wxT(" WHERE id='") + category.id + wxT("'");
EXECUTE_SQL_UPDATE(req, );

View File

@@ -30,6 +30,8 @@
#include "model.h"
#include "../controller/KissCount.h"
#define DATABASE_VERSION 2
#define BDD_FILE "kc.bdd"
#define INIT_SCRIPT "init.sql"
@@ -38,6 +40,59 @@
#define CHECKED_OP (1 << 2)
#define NOT_CHECKED_OP (1 << 3)
// if (!_db.CheckSyntax(req))
// {
// wxString s = req;
// std::cout << s.mb_str() << " is invalid !\n" ;
// code_if_syntax_fail;
// return return_value;
// }
#define EXECUTE_SQL_UPDATE_WITH_CODE(req, return_value, code_if_fail, code_if_syntax_fail) \
do{ \
try \
{ \
_db.ExecuteUpdate(req); \
} \
catch (wxSQLite3Exception e) \
{ \
wxMessageBox(_("Update failed !\n") + req, _("Error"), wxICON_ERROR | wxOK); \
std::cerr << __FUNCTION__ << "\n" ; \
std::cerr << req.mb_str() << "\n" ; \
std::cerr << e.GetMessage().mb_str() << "\n" ; \
code_if_fail; \
return return_value; \
} \
} while(0);
#define EXECUTE_SQL_QUERY_WITH_CODE(req, res, return_value, code_if_fail, code_if_syntax_fail) \
do{ \
try \
{ \
res = _db.ExecuteQuery(req); \
} \
catch (wxSQLite3Exception e) \
{ \
wxMessageBox(_("Query failed !\n") + req, _("Error"), wxICON_ERROR | wxOK); \
std::cerr << __FUNCTION__ << "\n" ; \
std::cerr << req.mb_str() << "\n" ; \
std::cerr << e.GetMessage().mb_str() << "\n" ; \
code_if_fail; \
return return_value; \
} \
} while(0);
#define EXECUTE_SQL_QUERY(req, res, return_value) EXECUTE_SQL_QUERY_WITH_CODE(req, res, return_value, {}, {})
#define EXECUTE_SQL_UPDATE(req, return_value) EXECUTE_SQL_UPDATE_WITH_CODE(req, return_value, {}, {})
#define ESCAPE_CHARS(s) { \
if (s.Find(wxT("\\\"")) == wxNOT_FOUND) \
s.Replace(wxT("\""), wxT("\\\""), true); \
if (s.Find(wxT("\\\'")) == wxNOT_FOUND) \
s.Replace(wxT("\'"), wxT("\\\'"), true); \
}
class KissCount;
class User;
@@ -104,6 +159,10 @@ public:
std::map<wxString, double>* GetNotChecked(User* user, int month, int year);
/* Database Update */
void CheckDatabaseVersion();
private:
KissCount* _kiss;
wxSQLite3Database _db;

View File

@@ -0,0 +1,130 @@
/*
Copyright 2011 Grégory Soutadé
This file is part of KissCount.
KissCount is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
KissCount is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with KissCount. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Database.h"
#define ON_ERROR(m) \
wxMessageBox(wxT(m), _("Error"), wxICON_ERROR | wxOK); \
throw std::string(m);
typedef void (*update_func)(wxSQLite3Database& _db) ;
#define UPDATE_TABLE(from, to, step) EXECUTE_SQL_UPDATE_WITH_CODE(req, , throw std::string("Error while upgrading from version " from " to version " to ", step " step);, });
static void Version_1_to_2(wxSQLite3Database& _db)
{
wxString req ;
wxSQLite3ResultSet set;
/* Category */
req = wxT("ALTER TABLE category ADD fix_cost CHAR(1)");
UPDATE_TABLE("1", "2", "1");
req = wxT("UPDATE category SET fix_cost='0'");
UPDATE_TABLE("1", "2", "2");
req = wxT("UPDATE category SET fix_cost='1' WHERE id IN (");
req += wxT("SELECT MIN(category.id) FROM category, user WHERE category.user = user.id");
req += wxT(")");
UPDATE_TABLE("1", "2", "3");
/* Account */
req = wxT("ALTER TABLE account ADD virtual CHAR(1)");
UPDATE_TABLE("1", "2", "4");
req = wxT("UPDATE account SET virtual='0'");
UPDATE_TABLE("1", "2", "5");
}
static update_func updates[] = {
Version_1_to_2
};
void Database::CheckDatabaseVersion()
{
wxString req ;
wxSQLite3ResultSet set;
long int version;
int i;
req = wxT("SELECT db_version FROM kisscount");
EXECUTE_SQL_QUERY_WITH_CODE(req, set, , ON_ERROR("Unable to get database version"), {});
if (!set.GetAsString(wxT("db_version")).ToLong(&version))
{
ON_ERROR("Invalid database version");
}
if (version == DATABASE_VERSION) return;
if (version > DATABASE_VERSION)
{
ON_ERROR("Your current version of KissCount is too old and can't load this database. Please upgrade KissCount");
}
version--;
// Maybe one update is impossible
for(i=version; i<DATABASE_VERSION-1; i++)
{
if (!updates[i])
{
ON_ERROR("The database cannot be upgraded. Please use an older version of KissCount");
}
}
wxMessageDialog dialog(NULL, wxT("You use an old database model. KissCount will try to upgrade it to the lastest version"), wxT("KissCount"), wxICON_INFORMATION | wxOK | wxCANCEL);
if (dialog.ShowModal() == wxID_CANCEL)
throw std::string("can't load this database");
_db.Begin();
try
{
for(i=version; i<DATABASE_VERSION-1; i++)
{
updates[i](_db);
}
req = wxT("UPDATE kisscount SET db_version='") + wxString::Format(wxT("%d"), DATABASE_VERSION) + wxT("'");
EXECUTE_SQL_UPDATE_WITH_CODE(req, , throw std::string("Unable to set new database version"), {});
}
catch (std::string e)
{
std::cout << e << std::endl;
_db.Rollback();
throw e;
}
_db.Commit();
wxMessageBox(wxT("Database upgrade successful !"), _("KissCount"), wxICON_INFORMATION | wxOK);
}

View File

@@ -1,5 +1,5 @@
/*
Copyright 2010 Grégory Soutadé
Copyright 2010-2011 Grégory Soutadé
This file is part of KissCount.
@@ -23,6 +23,11 @@ User::User(Database* db) : _db(db)
{}
User::~User()
{
InvalidateOperations();
}
void User::InvalidateOperations()
{
std::map<unsigned int, std::map<unsigned int, std::vector<Operation> >* >::iterator it;
@@ -33,6 +38,8 @@ User::~User()
delete it->second;
}
}
_operations.clear();
}
Category User::GetCategory(const wxString& catId)

View File

@@ -37,6 +37,7 @@ class User
public:
User(Database* db);
~User();
void InvalidateOperations();
wxString _id;
wxString _name;

View File

@@ -1,5 +1,5 @@
/*
Copyright 2010 Grégory Soutadé
Copyright 2010-2011 Grégory Soutadé
This file is part of KissCount.

View File

@@ -1,5 +1,5 @@
/*
Copyright 2010 Grégory Soutadé
Copyright 2010-2011 Grégory Soutadé
This file is part of KissCount.

View File

@@ -1,5 +1,5 @@
/*
Copyright 2010 Grégory Soutadé
Copyright 2010-2011 Grégory Soutadé
This file is part of KissCount.

View File

@@ -1,5 +1,5 @@
/*
Copyright 2010 Grégory Soutadé
Copyright 2010-2011 Grégory Soutadé
This file is part of KissCount.

View File

@@ -1,5 +1,5 @@
/*
Copyright 2010 Grégory Soutadé
Copyright 2010-2011 Grégory Soutadé
This file is part of KissCount.
@@ -680,6 +680,7 @@ void PreferencesPanel::OnCategoryModified(wxGridEvent& event)
if (user->GetCategoriesNumber() && row < user->GetCategoriesNumber())
{
new_cat.id = user->_categories[row].id;
new_cat.fix_cost = user->_categories[row].fix_cost;
if (col == CATEGORY_DELETE)
{
wxString *categories = new wxString[user->GetCategoriesNumber()];
@@ -731,6 +732,8 @@ void PreferencesPanel::OnCategoryModified(wxGridEvent& event)
inModification = false;
return ;
}
new_cat.fix_cost = false;
_kiss->AddCategory(new_cat);
AddCategory(row, new_cat);

View File

@@ -1,5 +1,5 @@
/*
Copyright 2010 Grégory Soutadé
Copyright 2010-2011 Grégory Soutadé
This file is part of KissCount.
@@ -19,13 +19,17 @@
#include "AccountPanel.h"
enum {SEARCH_ID, GRID_ID, CALENDAR_FROM_ID, CALENDAR_TO_ID};
enum {SEARCH_ID, GRID_ID, CALENDAR_FROM_ID, CALENDAR_TO_ID,
CHANGE_ACCOUNT_ID, CHANGE_CATEGORY_ID, RENAME_ID};
BEGIN_EVENT_TABLE(SearchPanel, wxPanel)
EVT_BUTTON(SEARCH_ID, SearchPanel::OnButtonSearch)
EVT_CALENDAR_SEL_CHANGED(CALENDAR_FROM_ID, SearchPanel::OnCalendarFromChange)
EVT_CALENDAR_SEL_CHANGED(CALENDAR_TO_ID, SearchPanel::OnCalendarToChange)
EVT_GRID_CMD_CELL_CHANGE(GRID_ID, SearchPanel::OnOperationModified)
EVT_BUTTON(CHANGE_ACCOUNT_ID, SearchPanel::OnButtonChangeAccount)
EVT_BUTTON(CHANGE_CATEGORY_ID, SearchPanel::OnButtonChangeCategory)
EVT_BUTTON(RENAME_ID, SearchPanel::OnButtonRename)
EVT_SHOW(SearchPanel::OnShow)
END_EVENT_TABLE()
@@ -44,6 +48,9 @@ SearchPanel::SearchPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, parent
wxRect rect = wxDisplay().GetGeometry();
wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL);
wxBoxSizer *vbox2 = new wxBoxSizer(wxVERTICAL);
wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL);
SetSizer(vbox);
_checkDateFrom = new wxCheckBox(this, wxID_ANY, _("Date from"));
@@ -113,7 +120,19 @@ SearchPanel::SearchPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, parent
_grid = new GridAccount(_kiss, this, GRID_ID);
vbox->Add(_grid, 0, wxGROW|wxALL, 5);
hbox->Add(_grid, 0, wxGROW|wxALL, 5);
_changeAccountButton = new wxButton(this, CHANGE_ACCOUNT_ID, _("Change account"));
_changeCategoryButton = new wxButton(this, CHANGE_CATEGORY_ID, _("Change category"));
_renameButton = new wxButton(this, RENAME_ID, _("Rename"));
vbox2->Add(_changeAccountButton, wxALL, 15);
vbox2->Add(_changeCategoryButton, wxALL, 15);
vbox2->Add(_renameButton, wxALL, 15);
hbox->Add(vbox2, 0, wxALL, 15);
vbox->Add(hbox, 0, wxGROW|wxALL, 5);
Fit();
@@ -145,7 +164,7 @@ wxString SearchPanel::GetToolTip()
return _("Search");
}
void SearchPanel::OnButtonSearch(wxCommandEvent& event)
void SearchPanel::Search()
{
wxString *description=NULL, *amountFrom=NULL, *amountTo=NULL;
std::vector<wxString> categories, accounts;
@@ -240,6 +259,11 @@ void SearchPanel::OnButtonSearch(wxCommandEvent& event)
delete _operations;
_operations = _kiss->Search(description, dateFrom, dateTo, amountFrom, amountTo, categories,types, accounts);
}
void SearchPanel::OnButtonSearch(wxCommandEvent& event)
{
Search();
if (_operations->size() > 1)
wxMessageBox(wxString::Format(wxT("%d"), _operations->size()) + _(" entries found"), wxT("KissCount"), wxICON_INFORMATION | wxOK);
@@ -256,6 +280,131 @@ void SearchPanel::OnButtonSearch(wxCommandEvent& event)
_wxUI->Layout();
}
static void ChangeAccount(Operation* op, void** params)
{
wxString* account = (wxString*) params[0];
op->account = *account;
}
void SearchPanel::OnButtonChangeAccount(wxCommandEvent& event)
{
int i, a;
std::vector<int> rows;
User* user = _kiss->GetUser();
wxString *accounts = new wxString[user->GetAccountsNumber()+1];
std::vector<Operation>::iterator it;
wxString account;
void * params[] = {&account};
if (!_operations) return;
_grid->GetSelectedOperations(&rows);
accounts[0] = _("None");
a = 0;
for(i=0; i < user->GetAccountsNumber(); i++)
accounts[++a] = user->_accounts[i].name;
wxSingleChoiceDialog dialog(_wxUI, _("Choose a new account"), wxT("KissCount"), user->GetAccountsNumber()+1, accounts);
if (dialog.ShowModal() == wxID_CANCEL)
return;
a = dialog.GetSelection();
account = (a) ? user->_accounts[a-1].id : wxT("0");
_grid->MassUpdate(rows, ChangeAccount, params);
_wxUI->NeedReload();
}
static void ChangeCategory(Operation* op, void** params)
{
wxString* category = (wxString*) params[0];
bool* fix = (bool*) params[1];
op->category = *category;
op->fix_cost = * fix;
}
void SearchPanel::OnButtonChangeCategory(wxCommandEvent& event)
{
int i, a;
std::vector<int> rows;
User* user = _kiss->GetUser();
wxString *categories = new wxString[user->GetCategoriesNumber()+1];
std::vector<Operation>::iterator it;
wxString category;
bool fix;
void * params[] = {&category, &fix};
if (!_operations) return;
_grid->GetSelectedOperations(&rows);
categories[0] = _("None");
a = 0;
for(i=0; i < user->GetCategoriesNumber(); i++)
categories[++a] = user->_categories[i].name;
wxSingleChoiceDialog dialog(_wxUI, _("Choose a new category"), wxT("KissCount"), user->GetCategoriesNumber()+1, categories);
if (dialog.ShowModal() == wxID_CANCEL)
return;
a = dialog.GetSelection();
if (a)
{
category = user->_categories[a-1].id ;
fix = user->_categories[a-1].fix_cost;
}
else
{
category = wxT("0");
fix = false;
}
_grid->MassUpdate(rows, ChangeCategory, params);
_wxUI->NeedReload();
}
static void ChangeName(Operation* op, void** params)
{
wxString* description = (wxString*) params[0];
op->description = *description;
}
void SearchPanel::OnButtonRename(wxCommandEvent& event)
{
std::vector<int> rows;
User* user = _kiss->GetUser();
std::vector<Operation>::iterator it;
wxString category;
wxString description;
void * params[] = {&description};
if (!_operations) return;
_grid->GetSelectedOperations(&rows);
wxTextEntryDialog u(this, wxT(""), _("Enter a new description"));
if (u.ShowModal() == wxID_CANCEL)
return;
description = u.GetValue();
if (!description.size()) return;
_grid->MassUpdate(rows, ChangeName, params);
_wxUI->NeedReload();
}
void SearchPanel::OnShow(wxShowEvent& event)
{
_wxUI->SetTitle(_kiss->GetUser()->_name + wxT(" - ") + _("Search"));

View File

@@ -50,14 +50,20 @@ public:
void OnCalendarFromChange(wxCalendarEvent& event);
void OnCalendarToChange(wxCalendarEvent& event);
void OnButtonChangeAccount(wxCommandEvent& event);
void OnButtonChangeCategory(wxCommandEvent& event);
void OnButtonRename(wxCommandEvent& event);
private:
void Search();
std::vector<Operation> *_operations;
wxCalendarCtrl* _calendarFrom, *_calendarTo;
GridAccount *_grid;
wxCheckBox *_checkDateFrom, *_checkDateTo;
wxTextCtrl* _description, *_amountFrom, *_amountTo;
wxCheckListBox* _category, *_account, *_optype;
wxButton* _searchButton;
wxButton* _searchButton, *_renameButton, *_changeAccountButton, *_changeCategoryButton;
DECLARE_EVENT_TABLE();
};

View File

@@ -1,5 +1,5 @@
/*
Copyright 2010 Grégory Soutadé
Copyright 2010-2011 Grégory Soutadé
This file is part of KissCount.
@@ -29,8 +29,8 @@ END_EVENT_TABLE()
StatsPanel::StatsPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, parent), _plot(NULL), _chart(NULL)
{
wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL);
_hbox2 = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL);
_hbox2 = new wxBoxSizer(wxHORIZONTAL);
_vbox2 = new wxBoxSizer(wxVERTICAL);
int i;
User* user = _kiss->GetUser();

View File

@@ -1,5 +1,5 @@
/*
Copyright 2010 Grégory Soutadé
Copyright 2010-2011 Grégory Soutadé
This file is part of KissCount.

View File

@@ -1,5 +1,5 @@
/*
Copyright 2010 Grégory Soutadé
Copyright 2010-2011 Grégory Soutadé
This file is part of KissCount.

View File

@@ -1,5 +1,5 @@
/*
Copyright 2010 Grégory Soutadé
Copyright 2010-2011 Grégory Soutadé
This file is part of KissCount.

View File

@@ -1,5 +1,5 @@
/*
Copyright 2010 Grégory Soutadé
Copyright 2010-2011 Grégory Soutadé
This file is part of KissCount.
@@ -120,6 +120,9 @@ wxPen GridAccount::GetRowGridLinePen (int row) {
row == _week4)
return wxPen(*wxBLACK, 1, wxSOLID);
}
else
if (row == 0)
return wxPen(*wxBLACK, 1, wxSOLID);
return GetCellBackgroundColour(row, 0);
}
@@ -542,13 +545,13 @@ void GridAccount::InsertIntoGrid(Operation& op)
InsertOperationWithWeek(user, (*_operations)[a], i, op.fix_cost, _curMonth, _curYear);
}
void GridAccount::RemoveMeta(Operation op, int line, bool removeRoot, bool deleteOp)
int GridAccount::RemoveMeta(Operation op, int line, bool removeRoot, bool deleteOp)
{
std::vector<Operation*>::iterator it, it2;
wxGridCellTreeButtonRenderer* treeRenderer;
int i;
int i, deletedOperations = 0;
Operation op2;
treeRenderer = (wxGridCellTreeButtonRenderer*) GetCellRenderer(line, TREE);
for(i=0; i<(int)op.childs.size(); i++)
@@ -561,6 +564,7 @@ void GridAccount::RemoveMeta(Operation op, int line, bool removeRoot, bool delet
if (treeRenderer->IsCollapsed())
{
DeleteRows(line+1, 1);
deletedOperations++;
if (op2.fix_cost) _fixCosts--;
_displayedOperations.erase(_displayedOperations.begin()+line+1);
}
@@ -585,9 +589,12 @@ void GridAccount::RemoveMeta(Operation op, int line, bool removeRoot, bool delet
DeleteOperation(op);
_kiss->DeleteOperation(op);
}
deletedOperations++;
}
treeRenderer->DecRef();
return deletedOperations;
}
void GridAccount::CheckMeta(Operation& op, int line, bool check)
@@ -1201,7 +1208,7 @@ void GridAccount::GetSelectedOperations(std::vector<int>* rows)
if (*it == row)
break;
if (it != rows->end()) continue;
if (it != rows->end() || !row) continue;
rows->push_back(row);
}
@@ -1218,7 +1225,7 @@ void GridAccount::GetSelectedOperations(std::vector<int>* rows)
if (*it == c.GetRow())
break;
if (it != rows->end()) continue;
if (it != rows->end() || !c.GetRow()) continue;
rows->push_back(c.GetRow());
}
@@ -1474,3 +1481,46 @@ removeLastGroup:
ComputeWeeks();
}
void GridAccount::MassUpdate(std::vector<int>& rows, updateOperationFunc func, void** params)
{
int i, b;
std::vector<Operation>::iterator it;
Operation op, op2;
if (rows.size())
{
for(i=0; i<(int)rows.size(); i++)
{
op = _displayedOperations[rows[i]];
func (&op, params);
UpdateOperation(op);
if (op.meta)
{
for(b=0; b<(int)op.childs.size(); b++)
{
op2 = GetOperation(op.childs[b]);
func (&op2, params);
UpdateOperation(op2);
}
}
}
}
else
{
for(it=_operations->begin(); it!=_operations->end(); it++)
{
func (&(*it), params);
_kiss->UpdateOperation(*it);
}
}
DeleteRows(1, GetNumberRows()-1);
LoadOperations(_operations, false, false, 0, 0);
Layout();
}

View File

@@ -23,6 +23,7 @@
#include <wx/wx.h>
#include <wx/grid.h>
#include <list>
#include <vector>
#include <algorithm>
#include <view/AccountPanel.h>
#include <model/model.h>
@@ -35,6 +36,8 @@
class KissCount;
typedef void (*updateOperationFunc)(Operation* op, void** params);
class GridAccount : public wxGrid
{
public:
@@ -48,6 +51,10 @@ public:
void InsertOperationWithWeek(User* user, Operation& op, int line, bool fix, int month, int year) ;
void InsertOperation(User* user, Operation& op, int line, bool fix, int month, int year) ;
void GetSelectedOperations(std::vector<int>* rows);
void MassUpdate(std::vector<int>& rows, updateOperationFunc func, void** params);
void Group();
void UnGroup();
@@ -74,13 +81,12 @@ private:
void InsertIntoGrid(Operation& op);
void DeleteOperation(const Operation& op);
void UpdateMeta(Operation& op);
void RemoveMeta(Operation op, int line, bool removeRoot, bool deleteOp);
int RemoveMeta(Operation op, int line, bool removeRoot, bool deleteOp);
void CheckMeta(Operation& op, int line, bool check);
Operation& GetOperation(const wxString& id);
void UpdateOperation(Operation& op);
int GetDisplayedRow(const wxString& id);
void GetSelectedOperations(std::vector<int>* rows);
DECLARE_EVENT_TABLE();
};

View File

@@ -1,5 +1,5 @@
/*
Copyright 2010 Grégory Soutadé
Copyright 2010-2011 Grégory Soutadé
This file is part of KissCount.

View File

@@ -1,5 +1,5 @@
/*
Copyright 2010 Grégory Soutadé
Copyright 2010-2011 Grégory Soutadé
This file is part of KissCount.

View File

@@ -1,5 +1,5 @@
/*
Copyright 2010 Grégory Soutadé
Copyright 2010-2011 Grégory Soutadé
This file is part of KissCount.

View File

@@ -1,5 +1,5 @@
/*
Copyright 2010 Grégory Soutadé
Copyright 2010-2011 Grégory Soutadé
This file is part of KissCount.

View File

@@ -1,5 +1,5 @@
/*
Copyright 2010 Grégory Soutadé
Copyright 2010-2011 Grégory Soutadé
This file is part of KissCount.

View File

@@ -1,5 +1,5 @@
/*
Copyright 2010 Grégory Soutadé
Copyright 2010-2011 Grégory Soutadé
This file is part of KissCount.

View File

@@ -1,5 +1,5 @@
/*
Copyright 2010 Grégory Soutadé
Copyright 2010-2011 Grégory Soutadé
This file is part of KissCount.

View File

@@ -1,5 +1,5 @@
/*
Copyright 2010 Grégory Soutadé
Copyright 2010-2011 Grégory Soutadé
This file is part of KissCount.

View File

@@ -1,5 +1,5 @@
/*
Copyright 2010 Grégory Soutadé
Copyright 2010-2011 Grégory Soutadé
This file is part of KissCount.
@@ -199,6 +199,7 @@ void wxUI::ShowPanel(KissPanel* panel)
{
wxShowEvent event;
int i;
User* user = _kiss->GetUser();
if (!panel) return;
@@ -210,6 +211,7 @@ void wxUI::ShowPanel(KissPanel* panel)
if (_needReload)
{
user->InvalidateOperations();
for(i=0; i<(int)_panels.size(); i++)
if (_panels[i] == panel) break;
LoadPanels();

View File

@@ -1,6 +1,6 @@
<?php
/*
Copyright 2010 Grégory Soutadé
Copyright 2010-2011 Grégory Soutadé
This file is part of KissCount.

View File

@@ -1,6 +1,6 @@
<?php
/*
Copyright 2010 Grégory Soutadé
Copyright 2010-2011 Grégory Soutadé
This file is part of KissCount.

View File

@@ -1,6 +1,6 @@
<?php
/*
Copyright 2010 Grégory Soutadé
Copyright 2010-2011 Grégory Soutadé
This file is part of KissCount.
@@ -292,6 +292,6 @@ while($operation = $operations->fetchArray())
</div>
</div>
<br /><br />
<center><a href="http://indefero.soutade.fr/p/kisscount">KissCount</a> &copy; 2010 Grégory Soutadé</center>
<center><a href="http://indefero.soutade.fr/p/kisscount">KissCount</a> &copy; 2010-2011 Grégory Soutadé</center>
</body>
</html>

View File

@@ -1,6 +1,6 @@
<?php
/*
Copyright 2010 Grégory Soutadé
Copyright 2010-2011 Grégory Soutadé
This file is part of KissCount.