* Add formula support

*  Fix a bug (cannot add new operations due to bug in FormulaEditor)
This commit is contained in:
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/*.cpp)
SOURCES+=$(wildcard src/view/grid/*.cpp) SOURCES+=$(wildcard src/view/grid/*.cpp)
SOURCES+=$(wildcard src/controller/*.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/model/*.h)
HEADERS+=$(wildcard src/view/*.h) HEADERS+=$(wildcard src/view/*.h)
HEADERS+=$(wildcard src/view/grid/*.h) HEADERS+=$(wildcard src/view/grid/*.h)

Binary file not shown.

View File

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

View File

@@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \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" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -17,17 +17,17 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\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 " - " msgid " - "
msgstr "" msgstr ""
#: src/view/PreferencesPanel.cpp:384 src/view/PreferencesPanel.cpp:403 #: src/view/UsersDialog.cpp:118 src/view/PreferencesPanel.cpp:384
#: src/view/PreferencesPanel.cpp:553 src/view/PreferencesPanel.cpp:572 #: src/view/PreferencesPanel.cpp:403 src/view/PreferencesPanel.cpp:553
#: src/view/PreferencesPanel.cpp:618 src/view/UsersDialog.cpp:116 #: src/view/PreferencesPanel.cpp:572 src/view/PreferencesPanel.cpp:618
msgid " already exists" msgid " already exists"
msgstr "" msgstr ""
#: src/view/SearchPanel.cpp:219 #: src/view/SearchPanel.cpp:215
msgid " entries found" msgid " entries found"
msgstr "" msgstr ""
@@ -35,7 +35,7 @@ msgstr ""
msgid " not found, aborting" msgid " not found, aborting"
msgstr "" msgstr ""
#: src/view/AccountPanel.cpp:996 #: src/view/AccountPanel.cpp:705
msgid " operations ?" msgid " operations ?"
msgstr "" msgstr ""
@@ -47,7 +47,7 @@ msgstr ""
msgid "!! Warning !! If there was a bug, the old database will be suppressed !" msgid "!! Warning !! If there was a bug, the old database will be suppressed !"
msgstr "" msgstr ""
#: src/view/SearchPanel.cpp:221 #: src/view/SearchPanel.cpp:217
msgid "1 entry found" msgid "1 entry found"
msgstr "" msgstr ""
@@ -55,7 +55,7 @@ msgstr ""
msgid "About" msgid "About"
msgstr "" 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" msgid "Account"
msgstr "" msgstr ""
@@ -63,33 +63,32 @@ msgstr ""
msgid "Account " msgid "Account "
msgstr "" msgstr ""
#: src/view/AccountPanel.cpp:102 #: src/view/AccountPanel.cpp:106
msgid "Account name" msgid "Account name"
msgstr "" msgstr ""
#: src/view/AccountPanel.cpp:101 #: src/view/AccountPanel.cpp:105
msgid "Account number" msgid "Account number"
msgstr "" msgstr ""
#: src/view/PreferencesPanel.cpp:55 src/view/StatsPanel.cpp:247 #: src/view/StatsPanel.cpp:247 src/view/PreferencesPanel.cpp:55
msgid "Accounts" msgid "Accounts"
msgstr "" msgstr ""
#: src/view/SearchPanel.cpp:86 #: src/view/SearchPanel.cpp:82
msgid "Amount from" msgid "Amount from"
msgstr "" msgstr ""
#: src/view/SearchPanel.cpp:87 #: src/view/SearchPanel.cpp:83
msgid "Amount to" msgid "Amount to"
msgstr "" msgstr ""
#: src/view/PreferencesPanel.cpp:365 src/view/PreferencesPanel.cpp:667 #: 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 " msgid "Are you sure want to delete "
msgstr "" msgstr ""
#: src/view/PreferencesPanel.cpp:534 src/view/AccountPanel.cpp:675 #: src/view/PreferencesPanel.cpp:534 src/view/grid/GridAccount.cpp:743
#: src/view/SearchPanel.cpp:350
msgid "Are you sure want to delete : \n" msgid "Are you sure want to delete : \n"
msgstr "" msgstr ""
@@ -101,16 +100,24 @@ msgstr ""
msgid "Background color" msgid "Background color"
msgstr "" msgstr ""
#: src/view/PasswordDialog.cpp:56 src/view/GenerateDialog.cpp:60 #: src/view/UsersDialog.cpp:51 src/view/GenerateDialog.cpp:60
#: src/view/UsersDialog.cpp:51 #: src/view/PasswordDialog.cpp:56
msgid "Cancel" msgid "Cancel"
msgstr "" 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 #: src/view/PreferencesPanel.cpp:56
msgid "Categories" msgid "Categories"
msgstr "" 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" msgid "Category"
msgstr "" msgstr ""
@@ -134,7 +141,7 @@ msgstr ""
msgid "Change user" msgid "Change user"
msgstr "" msgstr ""
#: src/view/AccountPanel.cpp:118 #: src/view/AccountPanel.cpp:122
msgid "Check mode" msgid "Check mode"
msgstr "" msgstr ""
@@ -142,39 +149,39 @@ msgstr ""
msgid "Confirm password " msgid "Confirm password "
msgstr "" msgstr ""
#: src/view/StatsPanel.cpp:130 src/view/AccountPanel.cpp:112 #: src/view/StatsPanel.cpp:130 src/view/AccountPanel.cpp:116
msgid "Cost repartition" msgid "Cost repartition"
msgstr "" msgstr ""
#: src/view/grid/GridAccount.cpp:61 #: src/view/grid/GridAccount.cpp:63
msgid "Credit" msgid "Credit"
msgstr "" msgstr ""
#: src/view/AccountPanel.cpp:189 #: src/view/AccountPanel.cpp:202
msgid "Cur Credit" msgid "Cur Credit"
msgstr "" msgstr ""
#: src/view/AccountPanel.cpp:190 #: src/view/AccountPanel.cpp:203
msgid "Cur Debit" msgid "Cur Debit"
msgstr "" msgstr ""
#: src/view/AccountPanel.cpp:104 #: src/view/AccountPanel.cpp:108
msgid "Current value" msgid "Current value"
msgstr "" msgstr ""
#: src/view/grid/GridAccount.cpp:61 #: src/view/grid/GridAccount.cpp:63
msgid "Date" msgid "Date"
msgstr "" msgstr ""
#: src/view/SearchPanel.cpp:53 #: src/view/SearchPanel.cpp:49
msgid "Date from" msgid "Date from"
msgstr "" msgstr ""
#: src/view/SearchPanel.cpp:54 #: src/view/SearchPanel.cpp:50
msgid "Date to" msgid "Date to"
msgstr "" msgstr ""
#: src/view/grid/GridAccount.cpp:61 #: src/view/grid/GridAccount.cpp:63
msgid "Debit" msgid "Debit"
msgstr "" msgstr ""
@@ -183,7 +190,7 @@ msgid "Default"
msgstr "" msgstr ""
#: src/view/PreferencesPanel.cpp:167 src/view/PreferencesPanel.cpp:224 #: src/view/PreferencesPanel.cpp:167 src/view/PreferencesPanel.cpp:224
#: src/view/AccountPanel.cpp:850 #: src/view/AccountPanel.cpp:559
msgid "Delete" msgid "Delete"
msgstr "" msgstr ""
@@ -191,22 +198,25 @@ msgstr ""
msgid "Descending" msgid "Descending"
msgstr "" 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" msgid "Description"
msgstr "" msgstr ""
#: src/model/Database.cpp:38 src/model/Database.cpp:55 #: src/view/UsersDialog.cpp:88 src/view/UsersDialog.cpp:118
#: src/model/Database.cpp:95 src/model/Database.cpp:102 #: src/view/SearchPanel.cpp:135 src/view/SearchPanel.cpp:145
#: src/model/Database.cpp:120 src/model/Database.cpp:147 #: src/view/SearchPanel.cpp:159 src/view/SearchPanel.cpp:170
#: 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:361 src/view/PreferencesPanel.cpp:384
#: src/view/PreferencesPanel.cpp:403 src/view/PreferencesPanel.cpp:553 #: src/view/PreferencesPanel.cpp:403 src/view/PreferencesPanel.cpp:553
#: src/view/PreferencesPanel.cpp:572 src/view/PreferencesPanel.cpp:612 #: src/view/PreferencesPanel.cpp:572 src/view/PreferencesPanel.cpp:612
#: src/view/PreferencesPanel.cpp:618 src/view/AccountPanel.cpp:987 #: src/view/PreferencesPanel.cpp:618 src/view/PasswordDialog.cpp:72
#: src/view/UsersDialog.cpp:88 src/view/UsersDialog.cpp:116 #: src/view/PasswordDialog.cpp:78 src/view/AccountPanel.cpp:696
#: src/view/SearchPanel.cpp:139 src/view/SearchPanel.cpp:149 #: src/view/grid/GridAccount.cpp:1067 src/view/grid/GridAccount.cpp:1074
#: src/view/SearchPanel.cpp:163 src/view/SearchPanel.cpp:174 #: 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" msgid "Error"
msgstr "" msgstr ""
@@ -214,12 +224,12 @@ msgstr ""
msgid "Error creating original database" msgid "Error creating original database"
msgstr "" msgstr ""
#: src/view/AccountPanel.cpp:105 #: src/view/AccountPanel.cpp:109
msgid "Final value" msgid "Final value"
msgstr "" msgstr ""
#: src/model/Database.cpp:312 src/controller/KissCount.cpp:278 #: src/view/grid/GridAccount.cpp:300 src/model/Database.cpp:312
#: src/view/grid/GridAccount.cpp:144 #: src/controller/KissCount.cpp:305
msgid "Fix" msgid "Fix"
msgstr "" msgstr ""
@@ -239,38 +249,46 @@ msgstr ""
msgid "From " msgid "From "
msgstr "" msgstr ""
#: src/view/GenerateDialog.cpp:31 src/view/AccountPanel.cpp:847 #: src/view/GenerateDialog.cpp:31 src/view/AccountPanel.cpp:556
msgid "Generate month" msgid "Generate month"
msgstr "" msgstr ""
#: src/controller/KissCount.cpp:280 #: src/controller/KissCount.cpp:307
msgid "Groceries" msgid "Groceries"
msgstr "" msgstr ""
#: src/controller/KissCount.cpp:282 #: src/view/AccountPanel.cpp:126
msgid "Group"
msgstr ""
#: src/controller/KissCount.cpp:309
msgid "Hobbies" msgid "Hobbies"
msgstr "" msgstr ""
#: src/view/AccountPanel.cpp:103 #: src/view/AccountPanel.cpp:107
msgid "Initial value" msgid "Initial value"
msgstr "" msgstr ""
#: src/view/SearchPanel.cpp:149 #: src/view/SearchPanel.cpp:145
msgid "Invalid amount from" msgid "Invalid amount from"
msgstr "" msgstr ""
#: src/view/SearchPanel.cpp:174 #: src/view/SearchPanel.cpp:170
msgid "Invalid amount range" msgid "Invalid amount range"
msgstr "" msgstr ""
#: src/view/SearchPanel.cpp:163 #: src/view/SearchPanel.cpp:159
msgid "Invalid amount to" msgid "Invalid amount to"
msgstr "" msgstr ""
#: src/view/SearchPanel.cpp:139 #: src/view/SearchPanel.cpp:135
msgid "Invalid date range" msgid "Invalid date range"
msgstr "" msgstr ""
#: src/view/grid/wxGridCellFormulaEditor.cpp:68
msgid "Invalid formula !"
msgstr ""
#: src/view/PreferencesPanel.cpp:612 #: src/view/PreferencesPanel.cpp:612
msgid "Invalid name" msgid "Invalid name"
msgstr "" msgstr ""
@@ -283,7 +301,7 @@ msgstr ""
msgid "Invalid password" msgid "Invalid password"
msgstr "" msgstr ""
#: src/view/StatsPanel.cpp:297 #: src/view/StatsPanel.cpp:302
msgid "Invalide date range" msgid "Invalide date range"
msgstr "" msgstr ""
@@ -291,7 +309,7 @@ msgstr ""
msgid "It must be at least one account !" msgid "It must be at least one account !"
msgstr "" msgstr ""
#: src/view/AccountPanel.cpp:987 #: src/view/AccountPanel.cpp:696
msgid "It must be at least one month !" msgid "It must be at least one month !"
msgstr "" msgstr ""
@@ -299,8 +317,8 @@ msgstr ""
msgid "Kill me" msgid "Kill me"
msgstr "" msgstr ""
#: src/view/PreferencesPanel.cpp:652 src/view/PreferencesPanel.cpp:655 #: src/view/StatsPanel.cpp:302 src/view/PreferencesPanel.cpp:652
#: src/view/StatsPanel.cpp:297 #: src/view/PreferencesPanel.cpp:655
msgid "KissCount" msgid "KissCount"
msgstr "" msgstr ""
@@ -325,7 +343,7 @@ msgstr ""
msgid "Name changed" msgid "Name changed"
msgstr "" msgstr ""
#: src/view/UsersDialog.cpp:52 src/view/UsersDialog.cpp:105 #: src/view/UsersDialog.cpp:52 src/view/UsersDialog.cpp:107
msgid "New User" msgid "New User"
msgstr "" msgstr ""
@@ -339,7 +357,7 @@ msgid ""
"\n" "\n"
msgstr "" msgstr ""
#: src/view/SearchPanel.cpp:224 #: src/view/SearchPanel.cpp:220
msgid "No entry found" msgid "No entry found"
msgstr "" msgstr ""
@@ -347,8 +365,8 @@ msgstr ""
msgid "Number" msgid "Number"
msgstr "" msgstr ""
#: src/view/PasswordDialog.cpp:55 src/view/GenerateDialog.cpp:59 #: src/view/UsersDialog.cpp:50 src/view/GenerateDialog.cpp:59
#: src/view/UsersDialog.cpp:50 #: src/view/PasswordDialog.cpp:55
msgid "OK" msgid "OK"
msgstr "" msgstr ""
@@ -356,7 +374,7 @@ msgstr ""
msgid "Old password " msgid "Old password "
msgstr "" msgstr ""
#: src/controller/KissCount.cpp:284 #: src/controller/KissCount.cpp:311
msgid "Operating exepense" msgid "Operating exepense"
msgstr "" msgstr ""
@@ -368,7 +386,7 @@ msgstr ""
msgid "Operations" msgid "Operations"
msgstr "" msgstr ""
#: src/controller/KissCount.cpp:288 #: src/controller/KissCount.cpp:315
msgid "Other" msgid "Other"
msgstr "" msgstr ""
@@ -408,16 +426,16 @@ msgstr ""
msgid "Quit KissCount ?" msgid "Quit KissCount ?"
msgstr "" msgstr ""
#: src/view/AccountPanel.cpp:191 #: src/view/AccountPanel.cpp:204
msgid "Remains" msgid "Remains"
msgstr "" 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 #: src/view/ButtonPanel.cpp:71
msgid "Search" msgid "Search"
msgstr "" msgstr ""
#: src/view/StatsPanel.cpp:122 src/view/AccountPanel.cpp:86 #: src/view/StatsPanel.cpp:122 src/view/AccountPanel.cpp:90
msgid "Serie 1" msgid "Serie 1"
msgstr "" msgstr ""
@@ -437,20 +455,24 @@ msgstr ""
msgid "To " msgid "To "
msgstr "" msgstr ""
#: src/view/AccountPanel.cpp:173 #: src/view/AccountPanel.cpp:186
msgid "Total Credit" msgid "Total Credit"
msgstr "" msgstr ""
#: src/view/AccountPanel.cpp:174 #: src/view/AccountPanel.cpp:187
msgid "Total Debit" msgid "Total Debit"
msgstr "" msgstr ""
#: src/view/AccountPanel.cpp:127
msgid "UnGroup"
msgstr ""
#: src/model/Database.cpp:95 src/model/Database.cpp:102 #: src/model/Database.cpp:95 src/model/Database.cpp:102
#: src/model/Database.cpp:120 src/model/Database.cpp:155 #: src/model/Database.cpp:120 src/model/Database.cpp:155
msgid "Unable to open Database" msgid "Unable to open Database"
msgstr "" msgstr ""
#: src/controller/KissCount.cpp:286 #: src/controller/KissCount.cpp:313
msgid "Unexpected" msgid "Unexpected"
msgstr "" msgstr ""
@@ -466,8 +488,8 @@ msgstr ""
msgid "User" msgid "User"
msgstr "" msgstr ""
#: src/view/PreferencesPanel.cpp:618 src/view/UsersDialog.cpp:38 #: src/view/UsersDialog.cpp:38 src/view/UsersDialog.cpp:118
#: src/view/UsersDialog.cpp:116 #: src/view/PreferencesPanel.cpp:618
msgid "User " msgid "User "
msgstr "" 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(); wxString res = GetValue();
Operation op; Operation op;
char* str, *str2;
struct parse_opt opt, *r;
bool ret; bool ret;
res = res.Trim(); res = res.Trim();
if (res.StartsWith(wxT("="))) 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; _formula = res;
else
_formula = wxT("");
ret = wxGridCellTextEditor::EndEdit(row, col, grid); ret = wxGridCellTextEditor::EndEdit(row, col, grid);
if (_formula.Length()) grid->SetCellValue(row, col, wxString::Format(wxT("%.2lf"), EvaluateExpr(&opt, true)));
grid->SetCellValue(row, col, wxT("0")); }
else
{
_formula = wxT("");
ret = wxGridCellTextEditor::EndEdit(row, col, grid);
}
return ret; return ret;
} }

View File

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