* Add formula support

*  Fix a bug (cannot add new operations due to bug in FormulaEditor)
This commit is contained in:
Grégory Soutadé 2010-10-14 20:49:49 +02:00
parent effc630650
commit f33f6ab85a
8 changed files with 703 additions and 155 deletions

View File

@ -12,7 +12,7 @@ SOURCES=$(wildcard src/model/*.cpp)
SOURCES+=$(wildcard src/view/*.cpp)
SOURCES+=$(wildcard src/view/grid/*.cpp)
SOURCES+=$(wildcard src/controller/*.cpp)
SOURCES+=src/main.cpp src/sha1.cpp
SOURCES+=src/main.cpp src/sha1.cpp src/ParseExp.cpp
HEADERS=$(wildcard src/model/*.h)
HEADERS+=$(wildcard src/view/*.h)
HEADERS+=$(wildcard src/view/grid/*.h)

Binary file not shown.

View File

@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2010-09-09 20:48+0200\n"
"POT-Creation-Date: 2010-10-14 20:46+0200\n"
"PO-Revision-Date: \n"
"Last-Translator: Soutadé <soutade@gmail.com>\n"
"Language-Team: \n"
@ -19,21 +19,21 @@ msgstr ""
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#: src/view/PreferencesPanel.cpp:660
#: src/view/StatsPanel.cpp:282
#: src/view/PreferencesPanel.cpp:660
msgid " - "
msgstr " - "
#: src/view/UsersDialog.cpp:118
#: src/view/PreferencesPanel.cpp:384
#: src/view/PreferencesPanel.cpp:403
#: src/view/PreferencesPanel.cpp:553
#: src/view/PreferencesPanel.cpp:572
#: src/view/PreferencesPanel.cpp:618
#: src/view/UsersDialog.cpp:116
msgid " already exists"
msgstr " existe déjà "
#: src/view/SearchPanel.cpp:219
#: src/view/SearchPanel.cpp:215
msgid " entries found"
msgstr " entrées trouvées"
@ -41,7 +41,7 @@ msgstr " entrées trouvées"
msgid " not found, aborting"
msgstr " non trouvé, arrêt"
#: src/view/AccountPanel.cpp:996
#: src/view/AccountPanel.cpp:705
msgid " operations ?"
msgstr " opérations ?"
@ -53,7 +53,7 @@ msgstr " profil ?"
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:221
#: src/view/SearchPanel.cpp:217
msgid "1 entry found"
msgstr "1 entrée trouvée"
@ -61,8 +61,8 @@ msgstr "1 entrée trouvée"
msgid "About"
msgstr "A propos"
#: src/view/grid/GridAccount.cpp:61
#: src/view/SearchPanel.cpp:89
#: src/view/SearchPanel.cpp:85
#: src/view/grid/GridAccount.cpp:63
msgid "Account"
msgstr "Compte"
@ -71,36 +71,35 @@ msgstr "Compte"
msgid "Account "
msgstr "Le compte "
#: src/view/AccountPanel.cpp:102
#: src/view/AccountPanel.cpp:106
msgid "Account name"
msgstr "Nom du compte"
#: src/view/AccountPanel.cpp:101
#: src/view/AccountPanel.cpp:105
msgid "Account number"
msgstr "Numéro de compte"
#: src/view/PreferencesPanel.cpp:55
#: src/view/StatsPanel.cpp:247
#: src/view/PreferencesPanel.cpp:55
msgid "Accounts"
msgstr "Comptes"
#: src/view/SearchPanel.cpp:86
#: src/view/SearchPanel.cpp:82
msgid "Amount from"
msgstr "Montant min"
#: src/view/SearchPanel.cpp:87
#: src/view/SearchPanel.cpp:83
msgid "Amount to"
msgstr "Montant max"
#: src/view/PreferencesPanel.cpp:365
#: src/view/PreferencesPanel.cpp:667
#: src/view/AccountPanel.cpp:991
#: src/view/AccountPanel.cpp:700
msgid "Are you sure want to delete "
msgstr "Etes vous sûr de vouloir supprimer "
#: src/view/PreferencesPanel.cpp:534
#: src/view/AccountPanel.cpp:675
#: src/view/SearchPanel.cpp:350
#: src/view/grid/GridAccount.cpp:743
msgid "Are you sure want to delete : \n"
msgstr "Etes vous sûr de vouloir supprimer : \n"
@ -112,18 +111,28 @@ msgstr "Croissant"
msgid "Background color"
msgstr "Couleur d'arrière plan"
#: src/view/PasswordDialog.cpp:56
#: src/view/GenerateDialog.cpp:60
#: src/view/UsersDialog.cpp:51
#: src/view/GenerateDialog.cpp:60
#: src/view/PasswordDialog.cpp:56
msgid "Cancel"
msgstr "Annuler"
#: src/view/grid/GridAccount.cpp:1067
#: src/view/grid/GridAccount.cpp:1074
msgid "Cannot group these operations"
msgstr "Impossible de grouper ces opérations"
#: src/view/grid/GridAccount.cpp:1202
#: src/view/grid/GridAccount.cpp:1208
msgid "Cannot ungroup these operations"
msgstr "Impossible de dégrouper ces opérations"
#: src/view/PreferencesPanel.cpp:56
msgid "Categories"
msgstr "Catégories"
#: src/view/grid/GridAccount.cpp:61
#: src/view/SearchPanel.cpp:88
#: src/view/SearchPanel.cpp:84
#: src/view/grid/GridAccount.cpp:63
msgid "Category"
msgstr "Catégorie"
@ -148,7 +157,7 @@ msgstr "Changer le mot de passe"
msgid "Change user"
msgstr "Changer d'utilisateur"
#: src/view/AccountPanel.cpp:118
#: src/view/AccountPanel.cpp:122
msgid "Check mode"
msgstr "Mode rapprochement"
@ -157,39 +166,39 @@ msgid "Confirm password "
msgstr "Confirmer le mot de passe"
#: src/view/StatsPanel.cpp:130
#: src/view/AccountPanel.cpp:112
#: src/view/AccountPanel.cpp:116
msgid "Cost repartition"
msgstr "Répartition des coûts"
#: src/view/grid/GridAccount.cpp:61
#: src/view/grid/GridAccount.cpp:63
msgid "Credit"
msgstr "Crédit"
#: src/view/AccountPanel.cpp:189
#: src/view/AccountPanel.cpp:202
msgid "Cur Credit"
msgstr "Cur Crédit"
#: src/view/AccountPanel.cpp:190
#: src/view/AccountPanel.cpp:203
msgid "Cur Debit"
msgstr "Cur Débit"
#: src/view/AccountPanel.cpp:104
#: src/view/AccountPanel.cpp:108
msgid "Current value"
msgstr "Valeur courante"
#: src/view/grid/GridAccount.cpp:61
#: src/view/grid/GridAccount.cpp:63
msgid "Date"
msgstr "Date"
#: src/view/SearchPanel.cpp:53
#: src/view/SearchPanel.cpp:49
msgid "Date from"
msgstr "Date min"
#: src/view/SearchPanel.cpp:54
#: src/view/SearchPanel.cpp:50
msgid "Date to"
msgstr "Date max"
#: src/view/grid/GridAccount.cpp:61
#: src/view/grid/GridAccount.cpp:63
msgid "Debit"
msgstr "Débit"
@ -199,7 +208,7 @@ msgstr "Défaut"
#: src/view/PreferencesPanel.cpp:167
#: src/view/PreferencesPanel.cpp:224
#: src/view/AccountPanel.cpp:850
#: src/view/AccountPanel.cpp:559
msgid "Delete"
msgstr "Supprimer"
@ -207,11 +216,32 @@ msgstr "Supprimer"
msgid "Descending"
msgstr "Décroissant"
#: src/view/grid/GridAccount.cpp:61
#: src/view/SearchPanel.cpp:85
#: src/view/SearchPanel.cpp:81
#: src/view/grid/GridAccount.cpp:63
msgid "Description"
msgstr "Description"
#: src/view/UsersDialog.cpp:88
#: src/view/UsersDialog.cpp:118
#: src/view/SearchPanel.cpp:135
#: src/view/SearchPanel.cpp:145
#: src/view/SearchPanel.cpp:159
#: src/view/SearchPanel.cpp:170
#: src/view/PreferencesPanel.cpp:361
#: src/view/PreferencesPanel.cpp:384
#: src/view/PreferencesPanel.cpp:403
#: src/view/PreferencesPanel.cpp:553
#: src/view/PreferencesPanel.cpp:572
#: src/view/PreferencesPanel.cpp:612
#: src/view/PreferencesPanel.cpp:618
#: src/view/PasswordDialog.cpp:72
#: src/view/PasswordDialog.cpp:78
#: src/view/AccountPanel.cpp:696
#: src/view/grid/GridAccount.cpp:1067
#: src/view/grid/GridAccount.cpp:1074
#: src/view/grid/GridAccount.cpp:1202
#: src/view/grid/GridAccount.cpp:1208
#: src/view/grid/wxGridCellFormulaEditor.cpp:68
#: src/model/Database.cpp:38
#: src/model/Database.cpp:55
#: src/model/Database.cpp:95
@ -220,22 +250,6 @@ msgstr "Description"
#: src/model/Database.cpp:147
#: src/model/Database.cpp:155
#: src/model/Database.cpp:176
#: src/view/PasswordDialog.cpp:72
#: src/view/PasswordDialog.cpp:78
#: src/view/PreferencesPanel.cpp:361
#: src/view/PreferencesPanel.cpp:384
#: src/view/PreferencesPanel.cpp:403
#: src/view/PreferencesPanel.cpp:553
#: src/view/PreferencesPanel.cpp:572
#: src/view/PreferencesPanel.cpp:612
#: src/view/PreferencesPanel.cpp:618
#: src/view/AccountPanel.cpp:987
#: src/view/UsersDialog.cpp:88
#: src/view/UsersDialog.cpp:116
#: src/view/SearchPanel.cpp:139
#: src/view/SearchPanel.cpp:149
#: src/view/SearchPanel.cpp:163
#: src/view/SearchPanel.cpp:174
msgid "Error"
msgstr "Erreur"
@ -243,13 +257,13 @@ msgstr "Erreur"
msgid "Error creating original database"
msgstr "Erreur durant la création de la base de données initiale"
#: src/view/AccountPanel.cpp:105
#: src/view/AccountPanel.cpp:109
msgid "Final value"
msgstr "Valeur finale"
#: src/view/grid/GridAccount.cpp:300
#: src/model/Database.cpp:312
#: src/controller/KissCount.cpp:278
#: src/view/grid/GridAccount.cpp:144
#: src/controller/KissCount.cpp:305
msgid "Fix"
msgstr "Fixe"
@ -270,38 +284,46 @@ msgid "From "
msgstr "A partir de "
#: src/view/GenerateDialog.cpp:31
#: src/view/AccountPanel.cpp:847
#: src/view/AccountPanel.cpp:556
msgid "Generate month"
msgstr "Générer mois"
#: src/controller/KissCount.cpp:280
#: src/controller/KissCount.cpp:307
msgid "Groceries"
msgstr "Courses"
#: src/controller/KissCount.cpp:282
#: src/view/AccountPanel.cpp:126
msgid "Group"
msgstr "Grouper"
#: src/controller/KissCount.cpp:309
msgid "Hobbies"
msgstr "Loisirs"
#: src/view/AccountPanel.cpp:103
#: src/view/AccountPanel.cpp:107
msgid "Initial value"
msgstr "Valeur initiale"
#: src/view/SearchPanel.cpp:149
#: src/view/SearchPanel.cpp:145
msgid "Invalid amount from"
msgstr "Montant min invalide"
#: src/view/SearchPanel.cpp:174
#: src/view/SearchPanel.cpp:170
msgid "Invalid amount range"
msgstr "Intervalle des montants invalide"
#: src/view/SearchPanel.cpp:163
#: src/view/SearchPanel.cpp:159
msgid "Invalid amount to"
msgstr "Montant max invalide"
#: src/view/SearchPanel.cpp:139
#: src/view/SearchPanel.cpp:135
msgid "Invalid date range"
msgstr "Intervalle de temps invalide"
#: src/view/grid/wxGridCellFormulaEditor.cpp:68
msgid "Invalid formula !"
msgstr "Formule invalide !"
#: src/view/PreferencesPanel.cpp:612
msgid "Invalid name"
msgstr "Nom invalide"
@ -314,7 +336,7 @@ msgstr "Ancien mot de passe invalide"
msgid "Invalid password"
msgstr "Mot de passe invalide"
#: src/view/StatsPanel.cpp:297
#: src/view/StatsPanel.cpp:302
msgid "Invalide date range"
msgstr "Intervalle de temps invalide"
@ -322,7 +344,7 @@ msgstr "Intervalle de temps invalide"
msgid "It must be at least one account !"
msgstr "Il doit y avoir au moins un compte !"
#: src/view/AccountPanel.cpp:987
#: src/view/AccountPanel.cpp:696
msgid "It must be at least one month !"
msgstr "Il doit rester au mois un mois"
@ -330,9 +352,9 @@ msgstr "Il doit rester au mois un mois"
msgid "Kill me"
msgstr "Kill me"
#: src/view/StatsPanel.cpp:302
#: src/view/PreferencesPanel.cpp:652
#: src/view/PreferencesPanel.cpp:655
#: src/view/StatsPanel.cpp:297
msgid "KissCount"
msgstr "KissCount"
@ -359,7 +381,7 @@ msgid "Name changed"
msgstr "Nom changé"
#: src/view/UsersDialog.cpp:52
#: src/view/UsersDialog.cpp:105
#: src/view/UsersDialog.cpp:107
msgid "New User"
msgstr "Nouvel utilisateur"
@ -375,7 +397,7 @@ msgstr ""
"Aucune base de données trouvée, voulez vous en créer une nouvelle ?\n"
"\n"
#: src/view/SearchPanel.cpp:224
#: src/view/SearchPanel.cpp:220
msgid "No entry found"
msgstr "Pas d'entrée trouvée"
@ -383,9 +405,9 @@ msgstr "Pas d'entrée trouvée"
msgid "Number"
msgstr "Numéro de compte"
#: src/view/PasswordDialog.cpp:55
#: src/view/GenerateDialog.cpp:59
#: src/view/UsersDialog.cpp:50
#: src/view/GenerateDialog.cpp:59
#: src/view/PasswordDialog.cpp:55
msgid "OK"
msgstr "OK"
@ -393,7 +415,7 @@ msgstr "OK"
msgid "Old password "
msgstr "Ancien mot de passe"
#: src/controller/KissCount.cpp:284
#: src/controller/KissCount.cpp:311
msgid "Operating exepense"
msgstr "Frais de fonctionnement"
@ -405,7 +427,7 @@ msgstr "Ordre des opérations"
msgid "Operations"
msgstr "Opérations"
#: src/controller/KissCount.cpp:288
#: src/controller/KissCount.cpp:315
msgid "Other"
msgstr "Autres"
@ -449,18 +471,18 @@ msgstr "Quitter"
msgid "Quit KissCount ?"
msgstr "Quitter KissCount ?"
#: src/view/AccountPanel.cpp:191
#: src/view/AccountPanel.cpp:204
msgid "Remains"
msgstr "Restant"
#: src/view/SearchPanel.cpp:83
#: src/view/SearchPanel.cpp:244
#: src/view/SearchPanel.cpp:79
#: src/view/SearchPanel.cpp:231
#: src/view/ButtonPanel.cpp:71
msgid "Search"
msgstr "Chercher"
#: src/view/StatsPanel.cpp:122
#: src/view/AccountPanel.cpp:86
#: src/view/AccountPanel.cpp:90
msgid "Serie 1"
msgstr "Série 1"
@ -481,14 +503,18 @@ msgstr "A"
msgid "To "
msgstr "Vers "
#: src/view/AccountPanel.cpp:173
#: src/view/AccountPanel.cpp:186
msgid "Total Credit"
msgstr "Total Crédit"
#: src/view/AccountPanel.cpp:174
#: src/view/AccountPanel.cpp:187
msgid "Total Debit"
msgstr "Total Débit"
#: src/view/AccountPanel.cpp:127
msgid "UnGroup"
msgstr "Dégrouper"
#: src/model/Database.cpp:95
#: src/model/Database.cpp:102
#: src/model/Database.cpp:120
@ -496,7 +522,7 @@ msgstr "Total Débit"
msgid "Unable to open Database"
msgstr "Impossible d'ouvrir la base de données"
#: src/controller/KissCount.cpp:286
#: src/controller/KissCount.cpp:313
msgid "Unexpected"
msgstr "Exceptionnel"
@ -514,9 +540,9 @@ msgstr "La mise à jour à échouée !\n"
msgid "User"
msgstr "Utilisateur"
#: src/view/PreferencesPanel.cpp:618
#: src/view/UsersDialog.cpp:38
#: src/view/UsersDialog.cpp:116
#: src/view/UsersDialog.cpp:118
#: src/view/PreferencesPanel.cpp:618
msgid "User "
msgstr "Utilisateur"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2010-09-09 20:48+0200\n"
"POT-Creation-Date: 2010-10-14 20:46+0200\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"
@ -17,17 +17,17 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: src/view/PreferencesPanel.cpp:660 src/view/StatsPanel.cpp:282
#: src/view/StatsPanel.cpp:282 src/view/PreferencesPanel.cpp:660
msgid " - "
msgstr ""
#: src/view/PreferencesPanel.cpp:384 src/view/PreferencesPanel.cpp:403
#: src/view/PreferencesPanel.cpp:553 src/view/PreferencesPanel.cpp:572
#: src/view/PreferencesPanel.cpp:618 src/view/UsersDialog.cpp:116
#: src/view/UsersDialog.cpp:118 src/view/PreferencesPanel.cpp:384
#: src/view/PreferencesPanel.cpp:403 src/view/PreferencesPanel.cpp:553
#: src/view/PreferencesPanel.cpp:572 src/view/PreferencesPanel.cpp:618
msgid " already exists"
msgstr ""
#: src/view/SearchPanel.cpp:219
#: src/view/SearchPanel.cpp:215
msgid " entries found"
msgstr ""
@ -35,7 +35,7 @@ msgstr ""
msgid " not found, aborting"
msgstr ""
#: src/view/AccountPanel.cpp:996
#: src/view/AccountPanel.cpp:705
msgid " operations ?"
msgstr ""
@ -47,7 +47,7 @@ msgstr ""
msgid "!! Warning !! If there was a bug, the old database will be suppressed !"
msgstr ""
#: src/view/SearchPanel.cpp:221
#: src/view/SearchPanel.cpp:217
msgid "1 entry found"
msgstr ""
@ -55,7 +55,7 @@ msgstr ""
msgid "About"
msgstr ""
#: src/view/grid/GridAccount.cpp:61 src/view/SearchPanel.cpp:89
#: src/view/SearchPanel.cpp:85 src/view/grid/GridAccount.cpp:63
msgid "Account"
msgstr ""
@ -63,33 +63,32 @@ msgstr ""
msgid "Account "
msgstr ""
#: src/view/AccountPanel.cpp:102
#: src/view/AccountPanel.cpp:106
msgid "Account name"
msgstr ""
#: src/view/AccountPanel.cpp:101
#: src/view/AccountPanel.cpp:105
msgid "Account number"
msgstr ""
#: src/view/PreferencesPanel.cpp:55 src/view/StatsPanel.cpp:247
#: src/view/StatsPanel.cpp:247 src/view/PreferencesPanel.cpp:55
msgid "Accounts"
msgstr ""
#: src/view/SearchPanel.cpp:86
#: src/view/SearchPanel.cpp:82
msgid "Amount from"
msgstr ""
#: src/view/SearchPanel.cpp:87
#: src/view/SearchPanel.cpp:83
msgid "Amount to"
msgstr ""
#: src/view/PreferencesPanel.cpp:365 src/view/PreferencesPanel.cpp:667
#: src/view/AccountPanel.cpp:991
#: src/view/AccountPanel.cpp:700
msgid "Are you sure want to delete "
msgstr ""
#: src/view/PreferencesPanel.cpp:534 src/view/AccountPanel.cpp:675
#: src/view/SearchPanel.cpp:350
#: src/view/PreferencesPanel.cpp:534 src/view/grid/GridAccount.cpp:743
msgid "Are you sure want to delete : \n"
msgstr ""
@ -101,16 +100,24 @@ msgstr ""
msgid "Background color"
msgstr ""
#: src/view/PasswordDialog.cpp:56 src/view/GenerateDialog.cpp:60
#: src/view/UsersDialog.cpp:51
#: src/view/UsersDialog.cpp:51 src/view/GenerateDialog.cpp:60
#: src/view/PasswordDialog.cpp:56
msgid "Cancel"
msgstr ""
#: src/view/grid/GridAccount.cpp:1067 src/view/grid/GridAccount.cpp:1074
msgid "Cannot group these operations"
msgstr ""
#: src/view/grid/GridAccount.cpp:1202 src/view/grid/GridAccount.cpp:1208
msgid "Cannot ungroup these operations"
msgstr ""
#: src/view/PreferencesPanel.cpp:56
msgid "Categories"
msgstr ""
#: src/view/grid/GridAccount.cpp:61 src/view/SearchPanel.cpp:88
#: src/view/SearchPanel.cpp:84 src/view/grid/GridAccount.cpp:63
msgid "Category"
msgstr ""
@ -134,7 +141,7 @@ msgstr ""
msgid "Change user"
msgstr ""
#: src/view/AccountPanel.cpp:118
#: src/view/AccountPanel.cpp:122
msgid "Check mode"
msgstr ""
@ -142,39 +149,39 @@ msgstr ""
msgid "Confirm password "
msgstr ""
#: src/view/StatsPanel.cpp:130 src/view/AccountPanel.cpp:112
#: src/view/StatsPanel.cpp:130 src/view/AccountPanel.cpp:116
msgid "Cost repartition"
msgstr ""
#: src/view/grid/GridAccount.cpp:61
#: src/view/grid/GridAccount.cpp:63
msgid "Credit"
msgstr ""
#: src/view/AccountPanel.cpp:189
#: src/view/AccountPanel.cpp:202
msgid "Cur Credit"
msgstr ""
#: src/view/AccountPanel.cpp:190
#: src/view/AccountPanel.cpp:203
msgid "Cur Debit"
msgstr ""
#: src/view/AccountPanel.cpp:104
#: src/view/AccountPanel.cpp:108
msgid "Current value"
msgstr ""
#: src/view/grid/GridAccount.cpp:61
#: src/view/grid/GridAccount.cpp:63
msgid "Date"
msgstr ""
#: src/view/SearchPanel.cpp:53
#: src/view/SearchPanel.cpp:49
msgid "Date from"
msgstr ""
#: src/view/SearchPanel.cpp:54
#: src/view/SearchPanel.cpp:50
msgid "Date to"
msgstr ""
#: src/view/grid/GridAccount.cpp:61
#: src/view/grid/GridAccount.cpp:63
msgid "Debit"
msgstr ""
@ -183,7 +190,7 @@ msgid "Default"
msgstr ""
#: src/view/PreferencesPanel.cpp:167 src/view/PreferencesPanel.cpp:224
#: src/view/AccountPanel.cpp:850
#: src/view/AccountPanel.cpp:559
msgid "Delete"
msgstr ""
@ -191,22 +198,25 @@ msgstr ""
msgid "Descending"
msgstr ""
#: src/view/grid/GridAccount.cpp:61 src/view/SearchPanel.cpp:85
#: src/view/SearchPanel.cpp:81 src/view/grid/GridAccount.cpp:63
msgid "Description"
msgstr ""
#: 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/PasswordDialog.cpp:72 src/view/PasswordDialog.cpp:78
#: src/view/UsersDialog.cpp:88 src/view/UsersDialog.cpp:118
#: src/view/SearchPanel.cpp:135 src/view/SearchPanel.cpp:145
#: src/view/SearchPanel.cpp:159 src/view/SearchPanel.cpp:170
#: src/view/PreferencesPanel.cpp:361 src/view/PreferencesPanel.cpp:384
#: src/view/PreferencesPanel.cpp:403 src/view/PreferencesPanel.cpp:553
#: src/view/PreferencesPanel.cpp:572 src/view/PreferencesPanel.cpp:612
#: src/view/PreferencesPanel.cpp:618 src/view/AccountPanel.cpp:987
#: src/view/UsersDialog.cpp:88 src/view/UsersDialog.cpp:116
#: src/view/SearchPanel.cpp:139 src/view/SearchPanel.cpp:149
#: src/view/SearchPanel.cpp:163 src/view/SearchPanel.cpp:174
#: src/view/PreferencesPanel.cpp:618 src/view/PasswordDialog.cpp:72
#: src/view/PasswordDialog.cpp:78 src/view/AccountPanel.cpp:696
#: src/view/grid/GridAccount.cpp:1067 src/view/grid/GridAccount.cpp:1074
#: src/view/grid/GridAccount.cpp:1202 src/view/grid/GridAccount.cpp:1208
#: src/view/grid/wxGridCellFormulaEditor.cpp:68 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
msgid "Error"
msgstr ""
@ -214,12 +224,12 @@ msgstr ""
msgid "Error creating original database"
msgstr ""
#: src/view/AccountPanel.cpp:105
#: src/view/AccountPanel.cpp:109
msgid "Final value"
msgstr ""
#: src/model/Database.cpp:312 src/controller/KissCount.cpp:278
#: src/view/grid/GridAccount.cpp:144
#: src/view/grid/GridAccount.cpp:300 src/model/Database.cpp:312
#: src/controller/KissCount.cpp:305
msgid "Fix"
msgstr ""
@ -239,38 +249,46 @@ msgstr ""
msgid "From "
msgstr ""
#: src/view/GenerateDialog.cpp:31 src/view/AccountPanel.cpp:847
#: src/view/GenerateDialog.cpp:31 src/view/AccountPanel.cpp:556
msgid "Generate month"
msgstr ""
#: src/controller/KissCount.cpp:280
#: src/controller/KissCount.cpp:307
msgid "Groceries"
msgstr ""
#: src/controller/KissCount.cpp:282
#: src/view/AccountPanel.cpp:126
msgid "Group"
msgstr ""
#: src/controller/KissCount.cpp:309
msgid "Hobbies"
msgstr ""
#: src/view/AccountPanel.cpp:103
#: src/view/AccountPanel.cpp:107
msgid "Initial value"
msgstr ""
#: src/view/SearchPanel.cpp:149
#: src/view/SearchPanel.cpp:145
msgid "Invalid amount from"
msgstr ""
#: src/view/SearchPanel.cpp:174
#: src/view/SearchPanel.cpp:170
msgid "Invalid amount range"
msgstr ""
#: src/view/SearchPanel.cpp:163
#: src/view/SearchPanel.cpp:159
msgid "Invalid amount to"
msgstr ""
#: src/view/SearchPanel.cpp:139
#: src/view/SearchPanel.cpp:135
msgid "Invalid date range"
msgstr ""
#: src/view/grid/wxGridCellFormulaEditor.cpp:68
msgid "Invalid formula !"
msgstr ""
#: src/view/PreferencesPanel.cpp:612
msgid "Invalid name"
msgstr ""
@ -283,7 +301,7 @@ msgstr ""
msgid "Invalid password"
msgstr ""
#: src/view/StatsPanel.cpp:297
#: src/view/StatsPanel.cpp:302
msgid "Invalide date range"
msgstr ""
@ -291,7 +309,7 @@ msgstr ""
msgid "It must be at least one account !"
msgstr ""
#: src/view/AccountPanel.cpp:987
#: src/view/AccountPanel.cpp:696
msgid "It must be at least one month !"
msgstr ""
@ -299,8 +317,8 @@ msgstr ""
msgid "Kill me"
msgstr ""
#: src/view/PreferencesPanel.cpp:652 src/view/PreferencesPanel.cpp:655
#: src/view/StatsPanel.cpp:297
#: src/view/StatsPanel.cpp:302 src/view/PreferencesPanel.cpp:652
#: src/view/PreferencesPanel.cpp:655
msgid "KissCount"
msgstr ""
@ -325,7 +343,7 @@ msgstr ""
msgid "Name changed"
msgstr ""
#: src/view/UsersDialog.cpp:52 src/view/UsersDialog.cpp:105
#: src/view/UsersDialog.cpp:52 src/view/UsersDialog.cpp:107
msgid "New User"
msgstr ""
@ -339,7 +357,7 @@ msgid ""
"\n"
msgstr ""
#: src/view/SearchPanel.cpp:224
#: src/view/SearchPanel.cpp:220
msgid "No entry found"
msgstr ""
@ -347,8 +365,8 @@ msgstr ""
msgid "Number"
msgstr ""
#: src/view/PasswordDialog.cpp:55 src/view/GenerateDialog.cpp:59
#: src/view/UsersDialog.cpp:50
#: src/view/UsersDialog.cpp:50 src/view/GenerateDialog.cpp:59
#: src/view/PasswordDialog.cpp:55
msgid "OK"
msgstr ""
@ -356,7 +374,7 @@ msgstr ""
msgid "Old password "
msgstr ""
#: src/controller/KissCount.cpp:284
#: src/controller/KissCount.cpp:311
msgid "Operating exepense"
msgstr ""
@ -368,7 +386,7 @@ msgstr ""
msgid "Operations"
msgstr ""
#: src/controller/KissCount.cpp:288
#: src/controller/KissCount.cpp:315
msgid "Other"
msgstr ""
@ -408,16 +426,16 @@ msgstr ""
msgid "Quit KissCount ?"
msgstr ""
#: src/view/AccountPanel.cpp:191
#: src/view/AccountPanel.cpp:204
msgid "Remains"
msgstr ""
#: src/view/SearchPanel.cpp:83 src/view/SearchPanel.cpp:244
#: src/view/SearchPanel.cpp:79 src/view/SearchPanel.cpp:231
#: src/view/ButtonPanel.cpp:71
msgid "Search"
msgstr ""
#: src/view/StatsPanel.cpp:122 src/view/AccountPanel.cpp:86
#: src/view/StatsPanel.cpp:122 src/view/AccountPanel.cpp:90
msgid "Serie 1"
msgstr ""
@ -437,20 +455,24 @@ msgstr ""
msgid "To "
msgstr ""
#: src/view/AccountPanel.cpp:173
#: src/view/AccountPanel.cpp:186
msgid "Total Credit"
msgstr ""
#: src/view/AccountPanel.cpp:174
#: src/view/AccountPanel.cpp:187
msgid "Total Debit"
msgstr ""
#: src/view/AccountPanel.cpp:127
msgid "UnGroup"
msgstr ""
#: src/model/Database.cpp:95 src/model/Database.cpp:102
#: src/model/Database.cpp:120 src/model/Database.cpp:155
msgid "Unable to open Database"
msgstr ""
#: src/controller/KissCount.cpp:286
#: src/controller/KissCount.cpp:313
msgid "Unexpected"
msgstr ""
@ -466,8 +488,8 @@ msgstr ""
msgid "User"
msgstr ""
#: src/view/PreferencesPanel.cpp:618 src/view/UsersDialog.cpp:38
#: src/view/UsersDialog.cpp:116
#: src/view/UsersDialog.cpp:38 src/view/UsersDialog.cpp:118
#: src/view/PreferencesPanel.cpp:618
msgid "User "
msgstr ""

449
src/ParseExp.cpp Normal file
View File

@ -0,0 +1,449 @@
/*
Copyright 2010 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 <string.h>
#include <stdio.h>
#include <iostream>
#include "ParseExp.h"
/*
Algorithm
The idea of this parser is very simple : Create a binary tree with an operator, a left and a right operand.
Leafs are constants to be computed. This structure is more flexbile than a simple stack and very easy to parse
(for resultat computation).
A simple expression (3+4) will be represented by :
+
3 4
Another example (3+4+5) :
+
3 +
4 5
If an operator is less prioritary than his father we have to do a transformation.
Example with 3*4+5.
in first instance we may have this tree :
*
3 +
4 5
So we must reverse the tree into something like :
+
* 5
3 4
At each step the parser must read one operand and one operator,
fill a node with the operator and left operand and recurse on right
operand. Finally we stop with a constant (a leaf).
Operations in parenthesis must be computed separatly and filled into
the tree like constants.
*/
/* Less to most prioritary */
enum {CST, ADD, SUB, MUL, DIV, MOD, EXP};
enum {DOUBLE_POINTED=1, INVALID_CHAR, INVALID_PARENTHESIS, INVALID_OPERATION};
#ifdef DEBUG
#define P(x) x
#else
#define P(x)
#endif
double atof(char* s, int size)
{
int neg = 0;
double res = 0;
for (; size--; s++)
{
if (*s == '.')
{
neg = 10;
continue;
}
if (neg > 0)
{
res += (*s - '0') / neg;
neg *= 10;
}
else
{
res *= 10;
res += *s - '0';
}
}
return res;
}
void ParseExp(char** expr, struct parse_opt* root, bool needParenthesis)
{
char* temp;
bool pointed = false;
struct parse_opt* l, *r, *op, *op_tmp;
char type = -1;
bool negative = false, number = false;
l = r = op = op_tmp = NULL;
if (!**expr) return;
for (temp=*expr; **expr; (*expr)++)
{
if (**expr == '(')
{
op_tmp = new struct parse_opt;
op_tmp->type = CST;
op_tmp->root = root;
op_tmp->l = op_tmp->r = NULL;
(*expr)++;
ParseExp(expr, op_tmp, true);
l = op_tmp;
root->l = l;
continue;
}
if (**expr == ')')
{
if (!needParenthesis)
throw INVALID_PARENTHESIS;
if ((*expr-temp) == 0)
throw INVALID_OPERATION;
break;
}
if (**expr >= '0' && **expr <= '9')
continue;
if (**expr == '.')
{
if (!pointed)
pointed = true;
else
throw DOUBLE_POINTED;
continue;
}
if (type != -1)
throw INVALID_OPERATION;
switch(**expr)
{
case '+':
type = ADD;
break;
case '-':
if (temp == *expr)
{
if (negative)
throw INVALID_OPERATION;
temp++;
negative = true;
continue;
}
type = SUB;
break;
case '/':
type = DIV;
break;
case '*':
type = MUL;
break;
// case '%':
// type = MOD;
// break;
default:
throw INVALID_CHAR;
}
number= true;
if (!l)
{
if ((*expr-temp) == 0)
throw INVALID_OPERATION;
l = new struct parse_opt;
l->type = CST;
l->root = root;
l->l = NULL; l->r = NULL;
l->value = atof(temp, *expr-temp);
if (negative)
l->value *= -1.0;
root->l = l;
}
// Here [temp..expr] must be left operand + operator
if (root->root && root->root->type >= type)
{
// Reverse tree
op = new parse_opt;
op->root = root->root;
op->type = root->root->type;
op->r = l;
op->l = root->root->l;
op->l->root = op;
root->root->l = op;
root->root->type = type;
root->type = CST;
root->value = 0.0;
root->l = NULL ; root->r = NULL;
(*expr)++;
ParseExp(expr, root, needParenthesis);
break;
temp=*expr;
}
else
{
// Recurse on right operand
root->type = type;
// atof
r = new struct parse_opt;
r->type = CST;
r->root = root;
r->l = NULL; r->r = NULL;
r->value = 0.0;
root->r = r;
(*expr)++;
ParseExp(expr, r, needParenthesis);
break;
temp=*expr;
}
}
if (needParenthesis && **expr != ')')
throw INVALID_PARENTHESIS;
if (!number)
{
if ((*expr-temp) == 0)
throw INVALID_OPERATION;
if (op_tmp)
*root = *op_tmp;
else
{
root->type = CST;
root->l = NULL; root->r = NULL;
root->value = atof(temp, *expr-temp);
if (negative)
root->value *= -1.0;
}
}
return ;
}
double EvaluateExpr(struct parse_opt* root, bool del)
{
double l, r;
char type;
type = root->type;
if (root->type != CST)
{
l = EvaluateExpr(root->l, del);
r = EvaluateExpr(root->r, del);
}
else
l = root->value;
if (del)
{
if (root->l) delete root->l;
if (root->r) delete root->r;
}
switch (type)
{
case ADD:
P(std::cout << l << " + " << r << std::endl);
return l+r;
case SUB:
P(std::cout << l << " - " << r << std::endl);
return l+r;
case MUL:
P(std::cout << l << " * " << r << std::endl);
return l*r;
case DIV:
P(std::cout << l << " / " << r << std::endl);
return l/r;
// case MOD:
// return EvaluateExpr(root->l) % EvaluateExpr(root->r);
case EXP:
P(std::cout << l << " ^ " << r << std::endl);
return l*r;
case CST:
return l;
default:
return 0.0;
}
}
#ifdef DEBUG
int main()
{
char* e1 = new char[100] ;
char* e = e1;
struct parse_opt root, *r;
try
{
memset(&root, 0, sizeof(root));
r = &root;
strcpy(e1, "4*3");
ParseExp(&e1, r, false);
std::cout << e << " = " << EvaluateExpr(&root, true) << "\n";
e1 = e;
memset(e1, 0, 100);
strcpy(e1, "4*3+5");
memset(&root, 0, sizeof(root));
r = &root;
ParseExp(&e1, r, false);
std::cout << e << " = " << EvaluateExpr(&root, true) << "\n";
e1 = e;
memset(e1, 0, 100);
strcpy(e1, "3+3+3");
memset(&root, 0, sizeof(root));
r = &root;
ParseExp(&e1, r, false);
std::cout << e << " = " << EvaluateExpr(&root, true) << "\n";
e1 = e;
memset(e1, 0, 100);
strcpy(e1, "3+3+3+3");
memset(&root, 0, sizeof(root));
r = &root;
ParseExp(&e1, r, false);
std::cout << e << " = " << EvaluateExpr(&root, true) << "\n";
e1 = e;
memset(e1, 0, 100);
strcpy(e1, "4+3*5");
memset(&root, 0, sizeof(root));
r = &root;
ParseExp(&e1, r, false);
std::cout << e << " = " << EvaluateExpr(&root, true) << "\n";
e1 = e;
memset(e1, 0, 100);
strcpy(e1, "-4+3*5/2");
memset(&root, 0, sizeof(root));
r = &root;
ParseExp(&e1, r, false);
std::cout << e << " = " << EvaluateExpr(&root, true) << "\n";
e1 = e;
memset(e1, 0, 100);
strcpy(e1, "5+-4");
memset(&root, 0, sizeof(root));
r = &root;
ParseExp(&e1, r, false);
std::cout << e << " = " << EvaluateExpr(&root, true) << "\n";
e1 = e;
memset(e1, 0, 100);
strcpy(e1, "5--4");
memset(&root, 0, sizeof(root));
r = &root;
ParseExp(&e1, r, false);
std::cout << e << " = " << EvaluateExpr(&root, true) << "\n";
e1 = e;
memset(e1, 0, 100);
strcpy(e1, "4*(3+2)");
memset(&root, 0, sizeof(root));
r = &root;
ParseExp(&e1, r, false);
std::cout << e << " = " << EvaluateExpr(&root, true) << "\n";
e1 = e;
memset(e1, 0, 100);
strcpy(e1, "(3+2)*4");
memset(&root, 0, sizeof(root));
r = &root;
ParseExp(&e1, r, false);
std::cout << e << " = " << EvaluateExpr(&root, true) << "\n";
e1 = e;
memset(e1, 0, 100);
strcpy(e1, "4*(3+2)+5");
memset(&root, 0, sizeof(root));
r = &root;
ParseExp(&e1, r, false);
std::cout << e << " = " << EvaluateExpr(&root, true) << "\n";
e1 = e;
memset(e1, 0, 100);
strcpy(e1, "5+(3+2)*4");
memset(&root, 0, sizeof(root));
r = &root;
ParseExp(&e1, r, false);
std::cout << e << " = " << EvaluateExpr(&root, true) << "\n";
e1 = e;
memset(e1, 0, 100);
strcpy(e1, "3+(3+(3+3))");
memset(&root, 0, sizeof(root));
r = &root;
ParseExp(&e1, r, false);
std::cout << e << " = " << EvaluateExpr(&root, true) << "\n";
e1 = e;
memset(e1, 0, 100);
strcpy(e1, "3+(3+(3+(3+3)))*5");
memset(&root, 0, sizeof(root));
r = &root;
ParseExp(&e1, r, false);
std::cout << e << " = " << EvaluateExpr(&root, true) << "\n";
e1 = e;
memset(e1, 0, 100);
strcpy(e1, "5+(3/(6+8--5)*9)*4");
memset(&root, 0, sizeof(root));
r = &root;
ParseExp(&e1, r, false);
std::cout << e << " = " << EvaluateExpr(&root, true) << "\n";
e1 = e;
memset(e1, 0, 100);
strcpy(e1, "5+(3*(6+8--5)/9)*4");
memset(&root, 0, sizeof(root));
r = &root;
ParseExp(&e1, r, false);
std::cout << e << " = " << EvaluateExpr(&root, true) << "\n";
}
catch (int e)
{
std::cout << "Error " << e << std::endl;
}
return 0;
}
#endif

29
src/ParseExp.h Normal file
View File

@ -0,0 +1,29 @@
/*
Copyright 2010 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/>.
*/
struct parse_opt {
struct parse_opt* root;
char type;
double value;
struct parse_opt* l;
struct parse_opt* r;
};
void ParseExp(char** expr, struct parse_opt* root, bool needParenthesis);
double EvaluateExpr(struct parse_opt* root, bool del);

View File

@ -47,19 +47,41 @@ bool wxGridCellFormulaEditor::EndEdit (int row, int col, wxGrid *grid/*, const w
{
wxString res = GetValue();
Operation op;
char* str, *str2;
struct parse_opt opt, *r;
bool ret;
res = res.Trim();
if (res.StartsWith(wxT("=")))
{
str = (char*) std::string(res.mb_str()).c_str();
str2 = new char[strlen(str)];
strcpy(str2, str+1);
r = &opt;
str = str2;
try {
ParseExp(&str2, r, false);
}
catch(...)
{
wxMessageBox(_("Invalid formula !"), _("Error"), wxICON_ERROR | wxOK);
delete str;
return false;
}
delete str;
_formula = res;
ret = wxGridCellTextEditor::EndEdit(row, col, grid);
grid->SetCellValue(row, col, wxString::Format(wxT("%.2lf"), EvaluateExpr(&opt, true)));
}
else
{
_formula = wxT("");
ret = wxGridCellTextEditor::EndEdit(row, col, grid);
if (_formula.Length())
grid->SetCellValue(row, col, wxT("0"));
ret = wxGridCellTextEditor::EndEdit(row, col, grid);
}
return ret;
}

View File

@ -24,7 +24,7 @@
#include <wx/grid.h>
#include <wx/dc.h>
#include "GridAccount.h"
#include "../../ParseExp.h"
class wxGridCellFormulaEditor : public wxGridCellTextEditor
{
public: