-rw-r--r-- | noncore/apps/checkbook/cfg.cpp | 3 | ||||
-rw-r--r-- | noncore/apps/checkbook/cfg.h | 45 | ||||
-rw-r--r-- | noncore/apps/checkbook/checkbook.cpp | 5 | ||||
-rw-r--r-- | noncore/apps/checkbook/configuration.cpp | 6 | ||||
-rw-r--r-- | noncore/apps/checkbook/configuration.h | 1 |
5 files changed, 38 insertions, 22 deletions
diff --git a/noncore/apps/checkbook/cfg.cpp b/noncore/apps/checkbook/cfg.cpp index 24fa4cb..4f70593 100644 --- a/noncore/apps/checkbook/cfg.cpp +++ b/noncore/apps/checkbook/cfg.cpp | |||
@@ -1,221 +1,224 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | =. | 3 | =. |
4 | .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> | 4 | .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This file is free software; you can | 6 | _;:, .> :=|. This file is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This file is distributed in the hope that | 13 | .i_,=:_. -<s. This file is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <stdio.h> | 29 | #include <stdio.h> |
30 | 30 | ||
31 | #include <qwidget.h> | 31 | #include <qwidget.h> |
32 | #include <qpe/config.h> | 32 | #include <qpe/config.h> |
33 | 33 | ||
34 | #include "cfg.h" | 34 | #include "cfg.h" |
35 | 35 | ||
36 | // --- Cfg -------------------------------------------------------------------- | 36 | // --- Cfg -------------------------------------------------------------------- |
37 | Cfg::Cfg() | 37 | Cfg::Cfg() |
38 | { | 38 | { |
39 | _currencySymbol="$"; | 39 | _currencySymbol="$"; |
40 | _useSmallFont=TRUE; | ||
40 | _showLocks=FALSE; | 41 | _showLocks=FALSE; |
41 | _showBalances=FALSE; | 42 | _showBalances=FALSE; |
42 | _pCategories=new CategoryList(); | 43 | _pCategories=new CategoryList(); |
43 | _bDirty=false; | 44 | _bDirty=false; |
44 | } | 45 | } |
45 | 46 | ||
46 | // --- readStringList --------------------------------------------------------- | 47 | // --- readStringList --------------------------------------------------------- |
47 | // Reads the entries for the control from a configuration file and returns | 48 | // Reads the entries for the control from a configuration file and returns |
48 | // them in a StringList. Later this list can be used to create the control. It | 49 | // them in a StringList. Later this list can be used to create the control. It |
49 | // is assumed, that the group is already set. Key is used to enumerate the | 50 | // is assumed, that the group is already set. Key is used to enumerate the |
50 | // entries. | 51 | // entries. |
51 | void Cfg::readStringList(Config &cfg, const char *sKey, QStringList &lst) | 52 | void Cfg::readStringList(Config &cfg, const char *sKey, QStringList &lst) |
52 | { | 53 | { |
53 | QString sEntry; | 54 | QString sEntry; |
54 | int iCount; | 55 | int iCount; |
55 | 56 | ||
56 | // read count of elements | 57 | // read count of elements |
57 | sEntry.sprintf("%s_Count", sKey); | 58 | sEntry.sprintf("%s_Count", sKey); |
58 | iCount=cfg.readNumEntry(sEntry, 0); | 59 | iCount=cfg.readNumEntry(sEntry, 0); |
59 | 60 | ||
60 | // read entries | 61 | // read entries |
61 | for(int i=1; i<=iCount; i++) { | 62 | for(int i=1; i<=iCount; i++) { |
62 | sEntry.sprintf("%s%d", sKey, i); | 63 | sEntry.sprintf("%s%d", sKey, i); |
63 | QString sType=cfg.readEntry(sEntry); | 64 | QString sType=cfg.readEntry(sEntry); |
64 | if( sType!=NULL ) | 65 | if( sType!=NULL ) |
65 | lst.append(sType); | 66 | lst.append(sType); |
66 | } | 67 | } |
67 | } | 68 | } |
68 | 69 | ||
69 | 70 | ||
70 | // --- readConfig ------------------------------------------------------------- | 71 | // --- readConfig ------------------------------------------------------------- |
71 | // Reads the member data from the given config file. It will also set the group | 72 | // Reads the member data from the given config file. It will also set the group |
72 | // "Config" | 73 | // "Config" |
73 | void Cfg::readConfig(Config &config) | 74 | void Cfg::readConfig(Config &config) |
74 | { | 75 | { |
75 | // set group | 76 | // set group |
76 | config.setGroup( "Config" ); | 77 | config.setGroup( "Config" ); |
77 | 78 | ||
78 | // read scalars | 79 | // read scalars |
79 | _currencySymbol = config.readEntry( "CurrencySymbol", "$" ); | 80 | _currencySymbol = config.readEntry( "CurrencySymbol", "$" ); |
81 | _useSmallFont = config.readBoolEntry( "UseSmallFont", TRUE ); | ||
80 | _showLocks = config.readBoolEntry( "ShowLocks", FALSE ); | 82 | _showLocks = config.readBoolEntry( "ShowLocks", FALSE ); |
81 | _showBalances = config.readBoolEntry( "ShowBalances", FALSE ); | 83 | _showBalances = config.readBoolEntry( "ShowBalances", FALSE ); |
82 | _openLastBook = config.readBoolEntry( "OpenLastBook", FALSE ); | 84 | _openLastBook = config.readBoolEntry( "OpenLastBook", FALSE ); |
83 | _sLastBook = config.readEntry("LastBook", ""); | 85 | _sLastBook = config.readEntry("LastBook", ""); |
84 | _showLastTab = config.readBoolEntry( "ShowLastTab", FALSE ); | 86 | _showLastTab = config.readBoolEntry( "ShowLastTab", FALSE ); |
85 | _bSavePayees = config.readBoolEntry( "SavePayees", FALSE ); | 87 | _bSavePayees = config.readBoolEntry( "SavePayees", FALSE ); |
86 | 88 | ||
87 | // Account types | 89 | // Account types |
88 | readStringList(config, "AccType", _AccountTypes); | 90 | readStringList(config, "AccType", _AccountTypes); |
89 | if( _AccountTypes.isEmpty() ) { | 91 | if( _AccountTypes.isEmpty() ) { |
90 | _AccountTypes+= (const char *)QWidget::tr("Savings"); | 92 | _AccountTypes+= (const char *)QWidget::tr("Savings"); |
91 | _AccountTypes+= (const char *)QWidget::tr("Checking"); | 93 | _AccountTypes+= (const char *)QWidget::tr("Checking"); |
92 | _AccountTypes+= (const char *)QWidget::tr("CD"); | 94 | _AccountTypes+= (const char *)QWidget::tr("CD"); |
93 | _AccountTypes+= (const char *)QWidget::tr("Money market"); | 95 | _AccountTypes+= (const char *)QWidget::tr("Money market"); |
94 | _AccountTypes+= (const char *)QWidget::tr("Mutual fund"); | 96 | _AccountTypes+= (const char *)QWidget::tr("Mutual fund"); |
95 | _AccountTypes+= (const char *)QWidget::tr("Other"); | 97 | _AccountTypes+= (const char *)QWidget::tr("Other"); |
96 | writeStringList(config, "AccType", _AccountTypes); | 98 | writeStringList(config, "AccType", _AccountTypes); |
97 | config.write(); | 99 | config.write(); |
98 | } | 100 | } |
99 | 101 | ||
100 | // Payees | 102 | // Payees |
101 | readStringList(config, "Payee", _Payees); | 103 | readStringList(config, "Payee", _Payees); |
102 | 104 | ||
103 | // Read Categories | 105 | // Read Categories |
104 | QStringList lst; | 106 | QStringList lst; |
105 | readStringList(config, "Category", lst); | 107 | readStringList(config, "Category", lst); |
106 | if( lst.isEmpty() ) { | 108 | if( lst.isEmpty() ) { |
107 | QString type=QWidget::tr("Expense"); | 109 | QString type=QWidget::tr("Expense"); |
108 | lst += QWidget::tr( "Automobile" )+";"+type; | 110 | lst += QWidget::tr( "Automobile" )+";"+type; |
109 | lst += QWidget::tr( "Bills" )+";"+type; | 111 | lst += QWidget::tr( "Bills" )+";"+type; |
110 | lst += QWidget::tr( "CDs" )+";"+type; | 112 | lst += QWidget::tr( "CDs" )+";"+type; |
111 | lst += QWidget::tr( "Clothing" )+";"+type; | 113 | lst += QWidget::tr( "Clothing" )+";"+type; |
112 | lst += QWidget::tr( "Computer" )+";"+type; | 114 | lst += QWidget::tr( "Computer" )+";"+type; |
113 | lst += QWidget::tr( "DVDs" )+";"+type; | 115 | lst += QWidget::tr( "DVDs" )+";"+type; |
114 | lst += QWidget::tr( "Electronics" )+";"+type; | 116 | lst += QWidget::tr( "Electronics" )+";"+type; |
115 | lst += QWidget::tr( "Entertainment" )+";"+type; | 117 | lst += QWidget::tr( "Entertainment" )+";"+type; |
116 | lst += QWidget::tr( "Food" )+";"+type; | 118 | lst += QWidget::tr( "Food" )+";"+type; |
117 | lst += QWidget::tr( "Gasoline" )+";"+type; | 119 | lst += QWidget::tr( "Gasoline" )+";"+type; |
118 | lst += QWidget::tr( "Misc" )+";"+type; | 120 | lst += QWidget::tr( "Misc" )+";"+type; |
119 | lst += QWidget::tr( "Movies" )+";"+type; | 121 | lst += QWidget::tr( "Movies" )+";"+type; |
120 | lst += QWidget::tr( "Rent" )+";"+type; | 122 | lst += QWidget::tr( "Rent" )+";"+type; |
121 | lst += QWidget::tr( "Travel" )+";"+type; | 123 | lst += QWidget::tr( "Travel" )+";"+type; |
122 | 124 | ||
123 | type=QWidget::tr( "Income" ); | 125 | type=QWidget::tr( "Income" ); |
124 | lst += QWidget::tr( "Work" )+";"+type; | 126 | lst += QWidget::tr( "Work" )+";"+type; |
125 | lst += QWidget::tr( "Family Member" )+";"+type; | 127 | lst += QWidget::tr( "Family Member" )+";"+type; |
126 | lst += QWidget::tr( "Misc. Credit" )+";"+type; | 128 | lst += QWidget::tr( "Misc. Credit" )+";"+type; |
127 | 129 | ||
128 | setCategories(lst); | 130 | setCategories(lst); |
129 | writeStringList(config, "Category", lst); | 131 | writeStringList(config, "Category", lst); |
130 | config.write(); | 132 | config.write(); |
131 | } else { | 133 | } else { |
132 | setCategories(lst); | 134 | setCategories(lst); |
133 | } | 135 | } |
134 | 136 | ||
135 | // not dirty | 137 | // not dirty |
136 | _bDirty=false; | 138 | _bDirty=false; |
137 | } | 139 | } |
138 | 140 | ||
139 | 141 | ||
140 | // --- writeStringList -------------------------------------------------------- | 142 | // --- writeStringList -------------------------------------------------------- |
141 | // Writes the entries in the control in a configuration file. It is assumed, | 143 | // Writes the entries in the control in a configuration file. It is assumed, |
142 | // that the group is already set. Key is used to enumerate the entries | 144 | // that the group is already set. Key is used to enumerate the entries |
143 | void Cfg::writeStringList(Config &cfg, const char *sKey, QStringList &lst) | 145 | void Cfg::writeStringList(Config &cfg, const char *sKey, QStringList &lst) |
144 | { | 146 | { |
145 | QString sEntry; | 147 | QString sEntry; |
146 | int iCount=0; | 148 | int iCount=0; |
147 | QStringList::Iterator itr; | 149 | QStringList::Iterator itr; |
148 | for(itr=lst.begin(); itr!=lst.end(); itr++) { | 150 | for(itr=lst.begin(); itr!=lst.end(); itr++) { |
149 | sEntry.sprintf("%s%d", sKey, ++iCount); | 151 | sEntry.sprintf("%s%d", sKey, ++iCount); |
150 | cfg.writeEntry(sEntry, *itr ); | 152 | cfg.writeEntry(sEntry, *itr ); |
151 | } | 153 | } |
152 | sEntry.sprintf("%s_Count", sKey); | 154 | sEntry.sprintf("%s_Count", sKey); |
153 | cfg.writeEntry(sEntry, iCount); | 155 | cfg.writeEntry(sEntry, iCount); |
154 | } | 156 | } |
155 | 157 | ||
156 | 158 | ||
157 | // --- writeConfig ----------------------------------------------------------- | 159 | // --- writeConfig ----------------------------------------------------------- |
158 | // Writes all config data back to the config file. The group will be set to | 160 | // Writes all config data back to the config file. The group will be set to |
159 | // "Config" and the write be commited | 161 | // "Config" and the write be commited |
160 | void Cfg::writeConfig(Config &config) | 162 | void Cfg::writeConfig(Config &config) |
161 | { | 163 | { |
162 | // set the group | 164 | // set the group |
163 | config.setGroup( "Config" ); | 165 | config.setGroup( "Config" ); |
164 | 166 | ||
165 | // write scalars | 167 | // write scalars |
166 | config.writeEntry( "CurrencySymbol", _currencySymbol ); | 168 | config.writeEntry( "CurrencySymbol", _currencySymbol ); |
169 | config.writeEntry( "UseSmallFont", _useSmallFont ); | ||
167 | config.writeEntry( "ShowLocks", _showLocks ); | 170 | config.writeEntry( "ShowLocks", _showLocks ); |
168 | config.writeEntry( "ShowBalances", _showBalances ); | 171 | config.writeEntry( "ShowBalances", _showBalances ); |
169 | config.writeEntry( "OpenLastBook", _openLastBook ); | 172 | config.writeEntry( "OpenLastBook", _openLastBook ); |
170 | config.writeEntry( "LastBook", _sLastBook ); | 173 | config.writeEntry( "LastBook", _sLastBook ); |
171 | config.writeEntry( "ShowLastTab", _showLastTab ); | 174 | config.writeEntry( "ShowLastTab", _showLastTab ); |
172 | config.writeEntry( "SavePayees", _bSavePayees ); | 175 | config.writeEntry( "SavePayees", _bSavePayees ); |
173 | 176 | ||
174 | // write account types | 177 | // write account types |
175 | writeStringList(config, "AccType", _AccountTypes); | 178 | writeStringList(config, "AccType", _AccountTypes); |
176 | 179 | ||
177 | // write payees | 180 | // write payees |
178 | writeStringList(config, "Payee", _Payees); | 181 | writeStringList(config, "Payee", _Payees); |
179 | 182 | ||
180 | // write categories | 183 | // write categories |
181 | QStringList lst=getCategories(); | 184 | QStringList lst=getCategories(); |
182 | writeStringList(config, "Category", lst ); | 185 | writeStringList(config, "Category", lst ); |
183 | 186 | ||
184 | // commit write | 187 | // commit write |
185 | config.write(); | 188 | config.write(); |
186 | _bDirty=false; | 189 | _bDirty=false; |
187 | } | 190 | } |
188 | 191 | ||
189 | 192 | ||
190 | // --- getCategories ---------------------------------------------------------- | 193 | // --- getCategories ---------------------------------------------------------- |
191 | QStringList Cfg::getCategories() | 194 | QStringList Cfg::getCategories() |
192 | { | 195 | { |
193 | QStringList ret; | 196 | QStringList ret; |
194 | for(Category *itr=_pCategories->first(); itr; itr=_pCategories->next() ) { | 197 | for(Category *itr=_pCategories->first(); itr; itr=_pCategories->next() ) { |
195 | QString sEntry; | 198 | QString sEntry; |
196 | sEntry.sprintf("%s;%s", (const char *)itr->getName(), (const char *)(itr->isIncome() ? QWidget::tr("Income") : QWidget::tr("Expense")) ); | 199 | sEntry.sprintf("%s;%s", (const char *)itr->getName(), (const char *)(itr->isIncome() ? QWidget::tr("Income") : QWidget::tr("Expense")) ); |
197 | ret.append(sEntry); | 200 | ret.append(sEntry); |
198 | } | 201 | } |
199 | return(ret); | 202 | return(ret); |
200 | } | 203 | } |
201 | 204 | ||
202 | 205 | ||
203 | // --- setCategories ---------------------------------------------------------- | 206 | // --- setCategories ---------------------------------------------------------- |
204 | void Cfg::setCategories(QStringList &lst) | 207 | void Cfg::setCategories(QStringList &lst) |
205 | { | 208 | { |
206 | _pCategories->clear(); | 209 | _pCategories->clear(); |
207 | QStringList::Iterator itr; | 210 | QStringList::Iterator itr; |
208 | for(itr=lst.begin(); itr!=lst.end(); itr++) { | 211 | for(itr=lst.begin(); itr!=lst.end(); itr++) { |
209 | QStringList split=QStringList::split(";", *itr, true); | 212 | QStringList split=QStringList::split(";", *itr, true); |
210 | if( split.count()<2 ) continue; | 213 | if( split.count()<2 ) continue; |
211 | bool bIncome= (split[1]==QWidget::tr("Income")); | 214 | bool bIncome= (split[1]==QWidget::tr("Income")); |
212 | _pCategories->append( new Category(split[0], bIncome) ); | 215 | _pCategories->append( new Category(split[0], bIncome) ); |
213 | } | 216 | } |
214 | } | 217 | } |
215 | 218 | ||
216 | 219 | ||
217 | // --- CategoryList ------------------------------------------------------------ | 220 | // --- CategoryList ------------------------------------------------------------ |
218 | CategoryList::CategoryList() : QList<Category>() | 221 | CategoryList::CategoryList() : QList<Category>() |
219 | { | 222 | { |
220 | setAutoDelete(true); | 223 | setAutoDelete(true); |
221 | } | 224 | } |
diff --git a/noncore/apps/checkbook/cfg.h b/noncore/apps/checkbook/cfg.h index 20692b4..418bd93 100644 --- a/noncore/apps/checkbook/cfg.h +++ b/noncore/apps/checkbook/cfg.h | |||
@@ -1,132 +1,135 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | =. | 3 | =. |
4 | .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> | 4 | .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This file is free software; you can | 6 | _;:, .> :=|. This file is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This file is distributed in the hope that | 13 | .i_,=:_. -<s. This file is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef CFG_H | 29 | #ifndef CFG_H |
30 | #define CFG_H | 30 | #define CFG_H |
31 | 31 | ||
32 | #include <qstring.h> | 32 | #include <qstring.h> |
33 | #include <qlist.h> | 33 | #include <qlist.h> |
34 | #include <qstringlist.h> | 34 | #include <qstringlist.h> |
35 | class Config; | 35 | class Config; |
36 | 36 | ||
37 | // --- Category --------------------------------------------------------------- | 37 | // --- Category --------------------------------------------------------------- |
38 | class Category | 38 | class Category |
39 | { | 39 | { |
40 | public: | 40 | public: |
41 | // --- Constructor: | 41 | // --- Constructor: |
42 | Category(QString &sName, bool bIncome=false) { _sName=sName; _bIncome=bIncome; } | 42 | Category(QString &sName, bool bIncome=false) { _sName=sName; _bIncome=bIncome; } |
43 | 43 | ||
44 | // members | 44 | // members |
45 | QString &getName() { return(_sName); } | 45 | QString &getName() { return(_sName); } |
46 | bool isIncome() { return(_bIncome); } | 46 | bool isIncome() { return(_bIncome); } |
47 | void setName(QString &sName) { _sName=sName; } | 47 | void setName(QString &sName) { _sName=sName; } |
48 | void setIncome(bool bIncome) { _bIncome=bIncome; } | 48 | void setIncome(bool bIncome) { _bIncome=bIncome; } |
49 | 49 | ||
50 | private: | 50 | private: |
51 | QString _sName; | 51 | QString _sName; |
52 | bool _bIncome; | 52 | bool _bIncome; |
53 | }; | 53 | }; |
54 | 54 | ||
55 | class CategoryList : public QList<Category> | 55 | class CategoryList : public QList<Category> |
56 | { | 56 | { |
57 | public: | 57 | public: |
58 | // --- Constructor | 58 | // --- Constructor |
59 | CategoryList(); | 59 | CategoryList(); |
60 | }; | 60 | }; |
61 | 61 | ||
62 | 62 | ||
63 | // --- Cfg -------------------------------------------------------------------- | 63 | // --- Cfg -------------------------------------------------------------------- |
64 | class Cfg | 64 | class Cfg |
65 | { | 65 | { |
66 | public: | 66 | public: |
67 | // --- Constructor | 67 | // --- Constructor |
68 | Cfg(); | 68 | Cfg(); |
69 | 69 | ||
70 | // --- members | 70 | // --- members |
71 | bool getUseSmallFont() { return(_useSmallFont); } | ||
72 | void setUseSmallFont(bool n) { _useSmallFont=n; } | ||
71 | bool getShowLocks() { return(_showLocks); } | 73 | bool getShowLocks() { return(_showLocks); } |
72 | void setShowLocks(bool n) { _showLocks=n; } | 74 | void setShowLocks(bool n) { _showLocks=n; } |
73 | bool getShowBalances() { return(_showBalances); } | 75 | bool getShowBalances() { return(_showBalances); } |
74 | void setShowBalances(bool n) { _showBalances=n; } | 76 | void setShowBalances(bool n) { _showBalances=n; } |
75 | QString &getCurrencySymbol() { return(_currencySymbol); } | 77 | QString &getCurrencySymbol() { return(_currencySymbol); } |
76 | void setCurrencySymbol(QString n) {_currencySymbol= n; } | 78 | void setCurrencySymbol(QString n) {_currencySymbol= n; } |
77 | void setCurrencySymbol(const char *n) { _currencySymbol=n; } | 79 | void setCurrencySymbol(const char *n) { _currencySymbol=n; } |
78 | QStringList &getAccountTypes() { return(_AccountTypes); } | 80 | QStringList &getAccountTypes() { return(_AccountTypes); } |
79 | 81 | ||
80 | // --- Payees | 82 | // --- Payees |
81 | QStringList &getPayees() { return(_Payees); } | 83 | QStringList &getPayees() { return(_Payees); } |
82 | bool getSavePayees() { return(_bSavePayees); } | 84 | bool getSavePayees() { return(_bSavePayees); } |
83 | void setSavePayees(bool bSave) { _bSavePayees=bSave; } | 85 | void setSavePayees(bool bSave) { _bSavePayees=bSave; } |
84 | 86 | ||
85 | // --- Categories | 87 | // --- Categories |
86 | QStringList getCategories(); | 88 | QStringList getCategories(); |
87 | void setCategories(QStringList &lst); | 89 | void setCategories(QStringList &lst); |
88 | CategoryList *getCategoryList() { return(_pCategories); } | 90 | CategoryList *getCategoryList() { return(_pCategories); } |
89 | 91 | ||
90 | // --- last book | 92 | // --- last book |
91 | void setOpenLastBook(bool openLastBook) { _openLastBook=openLastBook; } | 93 | void setOpenLastBook(bool openLastBook) { _openLastBook=openLastBook; } |
92 | bool isOpenLastBook() { return(_openLastBook); } | 94 | bool isOpenLastBook() { return(_openLastBook); } |
93 | void setLastBook(const QString &lastBook) { _sLastBook=lastBook; } | 95 | void setLastBook(const QString &lastBook) { _sLastBook=lastBook; } |
94 | QString &getLastBook() { return(_sLastBook); } | 96 | QString &getLastBook() { return(_sLastBook); } |
95 | 97 | ||
96 | // --- last tab | 98 | // --- last tab |
97 | void setShowLastTab(bool showLastTab) { _showLastTab=showLastTab; } | 99 | void setShowLastTab(bool showLastTab) { _showLastTab=showLastTab; } |
98 | bool isShowLastTab() { return(_showLastTab); } | 100 | bool isShowLastTab() { return(_showLastTab); } |
99 | 101 | ||
100 | // --- reads data from config file | 102 | // --- reads data from config file |
101 | void readConfig(Config &cfg); | 103 | void readConfig(Config &cfg); |
102 | 104 | ||
103 | // --- writes data to config file | 105 | // --- writes data to config file |
104 | void writeConfig(Config &cfg); | 106 | void writeConfig(Config &cfg); |
105 | 107 | ||
106 | // --- dirty flag | 108 | // --- dirty flag |
107 | bool isDirty() { return(_bDirty); } | 109 | bool isDirty() { return(_bDirty); } |
108 | void setDirty(bool bDirty) { _bDirty=bDirty; } | 110 | void setDirty(bool bDirty) { _bDirty=bDirty; } |
109 | 111 | ||
110 | protected: | 112 | protected: |
111 | // --- reads list from config file | 113 | // --- reads list from config file |
112 | static void readStringList(Config &cfg, const char *sKey, QStringList &lst); | 114 | static void readStringList(Config &cfg, const char *sKey, QStringList &lst); |
113 | 115 | ||
114 | // --- writes list in configuration file | 116 | // --- writes list in configuration file |
115 | static void writeStringList(Config &cfg, const char *sKey, QStringList &lst); | 117 | static void writeStringList(Config &cfg, const char *sKey, QStringList &lst); |
116 | 118 | ||
117 | private: | 119 | private: |
118 | QString _currencySymbol; | 120 | QString _currencySymbol; |
121 | bool _useSmallFont; | ||
119 | bool _showLocks; | 122 | bool _showLocks; |
120 | bool _showBalances; | 123 | bool _showBalances; |
121 | bool _openLastBook; | 124 | bool _openLastBook; |
122 | bool _showLastTab; | 125 | bool _showLastTab; |
123 | bool _bDirty; | 126 | bool _bDirty; |
124 | bool _bSavePayees; | 127 | bool _bSavePayees; |
125 | QString _sLastBook; | 128 | QString _sLastBook; |
126 | QStringList _AccountTypes; | 129 | QStringList _AccountTypes; |
127 | CategoryList *_pCategories; | 130 | CategoryList *_pCategories; |
128 | QStringList _Payees; | 131 | QStringList _Payees; |
129 | 132 | ||
130 | }; | 133 | }; |
131 | 134 | ||
132 | #endif | 135 | #endif |
diff --git a/noncore/apps/checkbook/checkbook.cpp b/noncore/apps/checkbook/checkbook.cpp index b325f45..1231f42 100644 --- a/noncore/apps/checkbook/checkbook.cpp +++ b/noncore/apps/checkbook/checkbook.cpp | |||
@@ -1,608 +1,611 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | =. | 3 | =. |
4 | .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> | 4 | .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This file is free software; you can | 6 | _;:, .> :=|. This file is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This file is distributed in the hope that | 13 | .i_,=:_. -<s. This file is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "checkbook.h" | 29 | #include "checkbook.h" |
30 | #include "cbinfo.h" | 30 | #include "cbinfo.h" |
31 | #include "transaction.h" | 31 | #include "transaction.h" |
32 | #include "traninfo.h" | 32 | #include "traninfo.h" |
33 | #include "graph.h" | 33 | #include "graph.h" |
34 | #include "graphinfo.h" | 34 | #include "graphinfo.h" |
35 | #include "password.h" | 35 | #include "password.h" |
36 | #include "cfg.h" | 36 | #include "cfg.h" |
37 | 37 | ||
38 | #include <opie2/oresource.h> | 38 | #include <opie2/oresource.h> |
39 | 39 | ||
40 | #include <qpe/applnk.h> | 40 | #include <qpe/applnk.h> |
41 | #include <qpe/qpeapplication.h> | 41 | #include <qpe/qpeapplication.h> |
42 | #include <qpe/qpemessagebox.h> | 42 | #include <qpe/qpemessagebox.h> |
43 | 43 | ||
44 | #include <qcheckbox.h> | 44 | #include <qcheckbox.h> |
45 | #include <qcombobox.h> | 45 | #include <qcombobox.h> |
46 | #include <qlabel.h> | 46 | #include <qlabel.h> |
47 | #include <qlayout.h> | 47 | #include <qlayout.h> |
48 | #include <qlineedit.h> | 48 | #include <qlineedit.h> |
49 | #include <qmultilineedit.h> | 49 | #include <qmultilineedit.h> |
50 | #include <qpushbutton.h> | 50 | #include <qpushbutton.h> |
51 | #include <qwhatsthis.h> | 51 | #include <qwhatsthis.h> |
52 | #include <qpopupmenu.h> | 52 | #include <qpopupmenu.h> |
53 | 53 | ||
54 | #define COL_ID 0 | 54 | #define COL_ID 0 |
55 | #define COL_SORTDATE 1 | 55 | #define COL_SORTDATE 1 |
56 | #define COL_NUM 2 | 56 | #define COL_NUM 2 |
57 | #define COL_DATE 3 | 57 | #define COL_DATE 3 |
58 | #define COL_DESC 4 | 58 | #define COL_DESC 4 |
59 | #define COL_AMOUNT 5 | 59 | #define COL_AMOUNT 5 |
60 | #define COL_BAL 6 | 60 | #define COL_BAL 6 |
61 | 61 | ||
62 | // --- Checkbook -------------------------------------------------------------- | 62 | // --- Checkbook -------------------------------------------------------------- |
63 | using namespace Opie::Ui; | 63 | using namespace Opie::Ui; |
64 | Checkbook::Checkbook( QWidget *parent, CBInfo *i, Cfg *cfg ) | 64 | Checkbook::Checkbook( QWidget *parent, CBInfo *i, Cfg *cfg ) |
65 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) | 65 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) |
66 | { | 66 | { |
67 | info = i; | 67 | info = i; |
68 | _pCfg=cfg; | 68 | _pCfg=cfg; |
69 | 69 | ||
70 | // Title bar | 70 | // Title bar |
71 | if ( info->name() != "" ) | 71 | if ( info->name() != "" ) |
72 | { | 72 | { |
73 | QString tempstr = info->name(); | 73 | QString tempstr = info->name(); |
74 | tempstr.append( " - " ); | 74 | tempstr.append( " - " ); |
75 | tempstr.append( tr( "Checkbook" ) ); | 75 | tempstr.append( tr( "Checkbook" ) ); |
76 | setCaption( tempstr ); | 76 | setCaption( tempstr ); |
77 | } | 77 | } |
78 | else | 78 | else |
79 | { | 79 | { |
80 | setCaption( tr( "New checkbook" ) ); | 80 | setCaption( tr( "New checkbook" ) ); |
81 | } | 81 | } |
82 | 82 | ||
83 | 83 | ||
84 | // Setup layout to make everything pretty | 84 | // Setup layout to make everything pretty |
85 | QVBoxLayout *layout = new QVBoxLayout( this ); | 85 | QVBoxLayout *layout = new QVBoxLayout( this ); |
86 | layout->setMargin( 2 ); | 86 | layout->setMargin( 2 ); |
87 | layout->setSpacing( 4 ); | 87 | layout->setSpacing( 4 ); |
88 | 88 | ||
89 | // Setup tabs for all info | 89 | // Setup tabs for all info |
90 | mainWidget = new OTabWidget( this ); | 90 | mainWidget = new OTabWidget( this ); |
91 | layout->addWidget( mainWidget ); | 91 | layout->addWidget( mainWidget ); |
92 | mainWidget->addTab( initInfo(), "checkbook/infotab", tr( "Info" ) ); | 92 | mainWidget->addTab( initInfo(), "checkbook/infotab", tr( "Info" ) ); |
93 | mainWidget->addTab( initTransactions(), "checkbook/trantab", tr( "Transactions" ) ); | 93 | mainWidget->addTab( initTransactions(), "checkbook/trantab", tr( "Transactions" ) ); |
94 | mainWidget->addTab( initCharts(), "checkbook/charttab", tr( "Charts" ) ); | 94 | mainWidget->addTab( initCharts(), "checkbook/charttab", tr( "Charts" ) ); |
95 | if( _pCfg->isShowLastTab() ) | 95 | if( _pCfg->isShowLastTab() ) |
96 | mainWidget->setCurrentTab( info->getLastTab() ); | 96 | mainWidget->setCurrentTab( info->getLastTab() ); |
97 | else | 97 | else |
98 | mainWidget->setCurrentTab( tr( "Info" ) ); | 98 | mainWidget->setCurrentTab( tr( "Info" ) ); |
99 | connect( mainWidget, SIGNAL( currentChanged(QWidget*) ), this, SLOT( slotTab(QWidget*) ) ); | 99 | connect( mainWidget, SIGNAL( currentChanged(QWidget*) ), this, SLOT( slotTab(QWidget*) ) ); |
100 | 100 | ||
101 | // Load checkbook information | 101 | // Load checkbook information |
102 | loadCheckbook(); | 102 | loadCheckbook(); |
103 | } | 103 | } |
104 | 104 | ||
105 | Checkbook::~Checkbook() | 105 | Checkbook::~Checkbook() |
106 | { | 106 | { |
107 | } | 107 | } |
108 | 108 | ||
109 | // --- initInfo --------------------------------------------------------------- | 109 | // --- initInfo --------------------------------------------------------------- |
110 | QWidget *Checkbook::initInfo() | 110 | QWidget *Checkbook::initInfo() |
111 | { | 111 | { |
112 | QWidget *control = new QWidget( mainWidget, tr("Info") ); | 112 | QWidget *control = new QWidget( mainWidget, tr("Info") ); |
113 | 113 | ||
114 | QVBoxLayout *vb = new QVBoxLayout( control ); | 114 | QVBoxLayout *vb = new QVBoxLayout( control ); |
115 | 115 | ||
116 | QScrollView *sv = new QScrollView( control ); | 116 | QScrollView *sv = new QScrollView( control ); |
117 | vb->addWidget( sv, 0, 0 ); | 117 | vb->addWidget( sv, 0, 0 ); |
118 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 118 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
119 | sv->setFrameStyle( QFrame::NoFrame ); | 119 | sv->setFrameStyle( QFrame::NoFrame ); |
120 | 120 | ||
121 | QWidget *container = new QWidget( sv->viewport() ); | 121 | QWidget *container = new QWidget( sv->viewport() ); |
122 | sv->addChild( container ); | 122 | sv->addChild( container ); |
123 | 123 | ||
124 | QGridLayout *layout = new QGridLayout( container ); | 124 | QGridLayout *layout = new QGridLayout( container ); |
125 | layout->setSpacing( 2 ); | 125 | layout->setSpacing( 2 ); |
126 | layout->setMargin( 4 ); | 126 | layout->setMargin( 4 ); |
127 | 127 | ||
128 | // Password protection | 128 | // Password protection |
129 | passwordCB = new QCheckBox( tr( "Password protect" ), container ); | 129 | passwordCB = new QCheckBox( tr( "Password protect" ), container ); |
130 | QWhatsThis::add( passwordCB, tr( "Click here to enable/disable password protection of this checkbook." ) ); | 130 | QWhatsThis::add( passwordCB, tr( "Click here to enable/disable password protection of this checkbook." ) ); |
131 | connect( passwordCB, SIGNAL( clicked() ), this, SLOT( slotPasswordClicked() ) ); | 131 | connect( passwordCB, SIGNAL( clicked() ), this, SLOT( slotPasswordClicked() ) ); |
132 | layout->addMultiCellWidget( passwordCB, 0, 0, 0, 1 ); | 132 | layout->addMultiCellWidget( passwordCB, 0, 0, 0, 1 ); |
133 | 133 | ||
134 | // Account name | 134 | // Account name |
135 | QLabel *label = new QLabel( tr( "Name:" ), container ); | 135 | QLabel *label = new QLabel( tr( "Name:" ), container ); |
136 | QWhatsThis::add( label, tr( "Enter name of checkbook here." ) ); | 136 | QWhatsThis::add( label, tr( "Enter name of checkbook here." ) ); |
137 | layout->addWidget( label, 1, 0 ); | 137 | layout->addWidget( label, 1, 0 ); |
138 | nameEdit = new QLineEdit( container ); | 138 | nameEdit = new QLineEdit( container ); |
139 | QWhatsThis::add( nameEdit, tr( "Enter name of checkbook here." ) ); | 139 | QWhatsThis::add( nameEdit, tr( "Enter name of checkbook here." ) ); |
140 | connect( nameEdit, SIGNAL( textChanged(const QString&) ), | 140 | connect( nameEdit, SIGNAL( textChanged(const QString&) ), |
141 | this, SLOT( slotNameChanged(const QString&) ) ); | 141 | this, SLOT( slotNameChanged(const QString&) ) ); |
142 | layout->addWidget( nameEdit, 1, 1 ); | 142 | layout->addWidget( nameEdit, 1, 1 ); |
143 | 143 | ||
144 | // Type of account | 144 | // Type of account |
145 | label = new QLabel( tr( "Type:" ), container ); | 145 | label = new QLabel( tr( "Type:" ), container ); |
146 | QWhatsThis::add( label, tr( "Select type of checkbook here." ) ); | 146 | QWhatsThis::add( label, tr( "Select type of checkbook here." ) ); |
147 | layout->addWidget( label, 2, 0 ); | 147 | layout->addWidget( label, 2, 0 ); |
148 | typeList = new QComboBox( container ); | 148 | typeList = new QComboBox( container ); |
149 | QWhatsThis::add( typeList, tr( "Select type of checkbook here." ) ); | 149 | QWhatsThis::add( typeList, tr( "Select type of checkbook here." ) ); |
150 | typeList->insertStringList( _pCfg->getAccountTypes() ); | 150 | typeList->insertStringList( _pCfg->getAccountTypes() ); |
151 | layout->addWidget( typeList, 2, 1 ); | 151 | layout->addWidget( typeList, 2, 1 ); |
152 | 152 | ||
153 | // Bank/institution name | 153 | // Bank/institution name |
154 | label = new QLabel( tr( "Bank:" ), container ); | 154 | label = new QLabel( tr( "Bank:" ), container ); |
155 | QWhatsThis::add( label, tr( "Enter name of the bank for this checkbook here." ) ); | 155 | QWhatsThis::add( label, tr( "Enter name of the bank for this checkbook here." ) ); |
156 | layout->addWidget( label, 3, 0 ); | 156 | layout->addWidget( label, 3, 0 ); |
157 | bankEdit = new QLineEdit( container ); | 157 | bankEdit = new QLineEdit( container ); |
158 | QWhatsThis::add( bankEdit, tr( "Enter name of the bank for this checkbook here." ) ); | 158 | QWhatsThis::add( bankEdit, tr( "Enter name of the bank for this checkbook here." ) ); |
159 | layout->addWidget( bankEdit, 3, 1 ); | 159 | layout->addWidget( bankEdit, 3, 1 ); |
160 | 160 | ||
161 | // Account number | 161 | // Account number |
162 | label = new QLabel( tr( "Account number:" ), container ); | 162 | label = new QLabel( tr( "Account number:" ), container ); |
163 | QWhatsThis::add( label, tr( "Enter account number for this checkbook here." ) ); | 163 | QWhatsThis::add( label, tr( "Enter account number for this checkbook here." ) ); |
164 | layout->addWidget( label, 4, 0 ); | 164 | layout->addWidget( label, 4, 0 ); |
165 | acctNumEdit = new QLineEdit( container ); | 165 | acctNumEdit = new QLineEdit( container ); |
166 | QWhatsThis::add( acctNumEdit, tr( "Enter account number for this checkbook here." ) ); | 166 | QWhatsThis::add( acctNumEdit, tr( "Enter account number for this checkbook here." ) ); |
167 | layout->addWidget( acctNumEdit, 4, 1 ); | 167 | layout->addWidget( acctNumEdit, 4, 1 ); |
168 | 168 | ||
169 | // PIN number | 169 | // PIN number |
170 | label = new QLabel( tr( "PIN number:" ), container ); | 170 | label = new QLabel( tr( "PIN number:" ), container ); |
171 | QWhatsThis::add( label, tr( "Enter PIN number for this checkbook here." ) ); | 171 | QWhatsThis::add( label, tr( "Enter PIN number for this checkbook here." ) ); |
172 | layout->addWidget( label, 5, 0 ); | 172 | layout->addWidget( label, 5, 0 ); |
173 | pinNumEdit = new QLineEdit( container ); | 173 | pinNumEdit = new QLineEdit( container ); |
174 | QWhatsThis::add( pinNumEdit, tr( "Enter PIN number for this checkbook here." ) ); | 174 | QWhatsThis::add( pinNumEdit, tr( "Enter PIN number for this checkbook here." ) ); |
175 | layout->addWidget( pinNumEdit, 5, 1 ); | 175 | layout->addWidget( pinNumEdit, 5, 1 ); |
176 | 176 | ||
177 | // Starting balance | 177 | // Starting balance |
178 | label = new QLabel( tr( "Starting balance:" ), container ); | 178 | label = new QLabel( tr( "Starting balance:" ), container ); |
179 | QWhatsThis::add( label, tr( "Enter the initial balance for this checkbook here." ) ); | 179 | QWhatsThis::add( label, tr( "Enter the initial balance for this checkbook here." ) ); |
180 | layout->addWidget( label, 6, 0 ); | 180 | layout->addWidget( label, 6, 0 ); |
181 | balanceEdit = new QLineEdit( container ); | 181 | balanceEdit = new QLineEdit( container ); |
182 | QWhatsThis::add( balanceEdit, tr( "Enter the initial balance for this checkbook here." ) ); | 182 | QWhatsThis::add( balanceEdit, tr( "Enter the initial balance for this checkbook here." ) ); |
183 | connect( balanceEdit, SIGNAL( textChanged(const QString&) ), | 183 | connect( balanceEdit, SIGNAL( textChanged(const QString&) ), |
184 | this, SLOT( slotStartingBalanceChanged(const QString&) ) ); | 184 | this, SLOT( slotStartingBalanceChanged(const QString&) ) ); |
185 | layout->addWidget( balanceEdit, 6, 1 ); | 185 | layout->addWidget( balanceEdit, 6, 1 ); |
186 | 186 | ||
187 | // Notes | 187 | // Notes |
188 | label = new QLabel( tr( "Notes:" ), container ); | 188 | label = new QLabel( tr( "Notes:" ), container ); |
189 | QWhatsThis::add( label, tr( "Enter any additional information for this checkbook here." ) ); | 189 | QWhatsThis::add( label, tr( "Enter any additional information for this checkbook here." ) ); |
190 | layout->addWidget( label, 7, 0 ); | 190 | layout->addWidget( label, 7, 0 ); |
191 | notesEdit = new QMultiLineEdit( container ); | 191 | notesEdit = new QMultiLineEdit( container ); |
192 | QWhatsThis::add( notesEdit, tr( "Enter any additional information for this checkbook here." ) ); | 192 | QWhatsThis::add( notesEdit, tr( "Enter any additional information for this checkbook here." ) ); |
193 | notesEdit->setMinimumHeight( 25 ); | 193 | notesEdit->setMinimumHeight( 25 ); |
194 | notesEdit->setMaximumHeight( 65 ); | 194 | notesEdit->setMaximumHeight( 65 ); |
195 | layout->addMultiCellWidget( notesEdit, 8, 8, 0, 1 ); | 195 | layout->addMultiCellWidget( notesEdit, 8, 8, 0, 1 ); |
196 | 196 | ||
197 | return control; | 197 | return control; |
198 | } | 198 | } |
199 | 199 | ||
200 | 200 | ||
201 | // --- initTransactions ------------------------------------------------------- | 201 | // --- initTransactions ------------------------------------------------------- |
202 | QWidget *Checkbook::initTransactions() | 202 | QWidget *Checkbook::initTransactions() |
203 | { | 203 | { |
204 | QWidget *control = new QWidget( mainWidget, tr("Transactions") ); | 204 | QWidget *control = new QWidget( mainWidget, tr("Transactions") ); |
205 | 205 | ||
206 | QGridLayout *layout = new QGridLayout( control ); | 206 | QGridLayout *layout = new QGridLayout( control ); |
207 | layout->setSpacing( 2 ); | 207 | layout->setSpacing( 2 ); |
208 | layout->setMargin( 4 ); | 208 | layout->setMargin( 4 ); |
209 | 209 | ||
210 | // Sort selector | 210 | // Sort selector |
211 | QLabel *label = new QLabel( tr( "Sort by:" ), control ); | 211 | QLabel *label = new QLabel( tr( "Sort by:" ), control ); |
212 | QWhatsThis::add( label, tr( "Select checkbook sorting here." ) ); | 212 | QWhatsThis::add( label, tr( "Select checkbook sorting here." ) ); |
213 | layout->addMultiCellWidget( label, 0, 0, 0, 1 ); | 213 | layout->addMultiCellWidget( label, 0, 0, 0, 1 ); |
214 | _cbSortType=new QComboBox( control ); | 214 | _cbSortType=new QComboBox( control ); |
215 | _cbSortType->insertItem( tr("Entry Order") ); | 215 | _cbSortType->insertItem( tr("Entry Order") ); |
216 | _cbSortType->insertItem( tr("Date") ); | 216 | _cbSortType->insertItem( tr("Date") ); |
217 | _cbSortType->insertItem( tr("Number") ); | 217 | _cbSortType->insertItem( tr("Number") ); |
218 | layout->addMultiCellWidget( _cbSortType, 0, 0, 1, 2 ); | 218 | layout->addMultiCellWidget( _cbSortType, 0, 0, 1, 2 ); |
219 | connect( _cbSortType, SIGNAL( activated(const QString&) ), this, SLOT( slotSortChanged(const QString&) ) ); | 219 | connect( _cbSortType, SIGNAL( activated(const QString&) ), this, SLOT( slotSortChanged(const QString&) ) ); |
220 | 220 | ||
221 | // Table | 221 | // Table |
222 | tranTable = new QListView( control ); | 222 | tranTable = new QListView( control ); |
223 | QFont fnt(QPEApplication::font()); | 223 | QFont fnt(QPEApplication::font()); |
224 | fnt.setPointSize( fnt.pointSize()-1 ); | 224 | if( _pCfg->getUseSmallFont() ) |
225 | { | ||
226 | fnt.setPointSize( fnt.pointSize()-1 ); | ||
227 | } | ||
225 | tranTable->setFont( fnt ); | 228 | tranTable->setFont( fnt ); |
226 | QWhatsThis::add( tranTable, tr( "This is a listing of all transactions entered for this checkbook.\n\nTo sort entries by a specific field, click on the column name." ) ); | 229 | QWhatsThis::add( tranTable, tr( "This is a listing of all transactions entered for this checkbook.\n\nTo sort entries by a specific field, click on the column name." ) ); |
227 | tranTable->addColumn( tr( "Id" ) ); | 230 | tranTable->addColumn( tr( "Id" ) ); |
228 | tranTable->setColumnWidthMode( COL_ID, QListView::Manual ); | 231 | tranTable->setColumnWidthMode( COL_ID, QListView::Manual ); |
229 | tranTable->setColumnWidth( COL_ID, 0); | 232 | tranTable->setColumnWidth( COL_ID, 0); |
230 | tranTable->addColumn( tr( "SortDate" ) ); | 233 | tranTable->addColumn( tr( "SortDate" ) ); |
231 | tranTable->setColumnWidthMode( COL_SORTDATE, QListView::Manual ); | 234 | tranTable->setColumnWidthMode( COL_SORTDATE, QListView::Manual ); |
232 | tranTable->setColumnWidth( COL_SORTDATE, 0); | 235 | tranTable->setColumnWidth( COL_SORTDATE, 0); |
233 | tranTable->addColumn( tr( "Num" ) ); | 236 | tranTable->addColumn( tr( "Num" ) ); |
234 | tranTable->addColumn( tr( "Date" ) ); | 237 | tranTable->addColumn( tr( "Date" ) ); |
235 | //tranTable->addColumn( tr( "Cleared" ) ); | 238 | //tranTable->addColumn( tr( "Cleared" ) ); |
236 | tranTable->addColumn( tr( "Description" ) ); | 239 | tranTable->addColumn( tr( "Description" ) ); |
237 | int column = tranTable->addColumn( tr( "Amount" ) ); | 240 | int column = tranTable->addColumn( tr( "Amount" ) ); |
238 | tranTable->setColumnAlignment( column, Qt::AlignRight ); | 241 | tranTable->setColumnAlignment( column, Qt::AlignRight ); |
239 | column=tranTable->addColumn( tr("Balance") ); | 242 | column=tranTable->addColumn( tr("Balance") ); |
240 | tranTable->setColumnAlignment( column, Qt::AlignRight ); | 243 | tranTable->setColumnAlignment( column, Qt::AlignRight ); |
241 | tranTable->setAllColumnsShowFocus( TRUE ); | 244 | tranTable->setAllColumnsShowFocus( TRUE ); |
242 | tranTable->setSorting( -1 ); | 245 | tranTable->setSorting( -1 ); |
243 | layout->addMultiCellWidget( tranTable, 1, 1, 0, 2 ); | 246 | layout->addMultiCellWidget( tranTable, 1, 1, 0, 2 ); |
244 | QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold ); | 247 | QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold ); |
245 | connect( tranTable, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ), | 248 | connect( tranTable, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ), |
246 | this, SLOT( slotMenuTran(QListViewItem*,const QPoint&) ) ); | 249 | this, SLOT( slotMenuTran(QListViewItem*,const QPoint&) ) ); |
247 | connect( tranTable, SIGNAL( doubleClicked(QListViewItem*) ), | 250 | connect( tranTable, SIGNAL( doubleClicked(QListViewItem*) ), |
248 | this, SLOT( slotEditTran() ) ); | 251 | this, SLOT( slotEditTran() ) ); |
249 | _sortCol=COL_ID; | 252 | _sortCol=COL_ID; |
250 | 253 | ||
251 | // Buttons | 254 | // Buttons |
252 | QPushButton *btn = new QPushButton( Opie::Core::OResource::loadPixmap( "new", Opie::Core::OResource::SmallIcon ), | 255 | QPushButton *btn = new QPushButton( Opie::Core::OResource::loadPixmap( "new", Opie::Core::OResource::SmallIcon ), |
253 | tr( "New" ), control ); | 256 | tr( "New" ), control ); |
254 | btn->setFixedHeight( AppLnk::smallIconSize()+4 ); | 257 | btn->setFixedHeight( AppLnk::smallIconSize()+4 ); |
255 | QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) ); | 258 | QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) ); |
256 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotNewTran() ) ); | 259 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotNewTran() ) ); |
257 | layout->addWidget( btn, 2, 0 ); | 260 | layout->addWidget( btn, 2, 0 ); |
258 | 261 | ||
259 | btn = new QPushButton( Opie::Core::OResource::loadPixmap( "edit", Opie::Core::OResource::SmallIcon ), | 262 | btn = new QPushButton( Opie::Core::OResource::loadPixmap( "edit", Opie::Core::OResource::SmallIcon ), |
260 | tr( "Edit" ), control ); | 263 | tr( "Edit" ), control ); |
261 | btn->setFixedHeight( AppLnk::smallIconSize()+4 ); | 264 | btn->setFixedHeight( AppLnk::smallIconSize()+4 ); |
262 | QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) ); | 265 | QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) ); |
263 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotEditTran() ) ); | 266 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotEditTran() ) ); |
264 | layout->addWidget( btn, 2, 1 ); | 267 | layout->addWidget( btn, 2, 1 ); |
265 | 268 | ||
266 | btn = new QPushButton( Opie::Core::OResource::loadPixmap( "trash", Opie::Core::OResource::SmallIcon ), | 269 | btn = new QPushButton( Opie::Core::OResource::loadPixmap( "trash", Opie::Core::OResource::SmallIcon ), |
267 | tr( "Delete" ), control ); | 270 | tr( "Delete" ), control ); |
268 | btn->setFixedHeight( AppLnk::smallIconSize()+4 ); | 271 | btn->setFixedHeight( AppLnk::smallIconSize()+4 ); |
269 | QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) ); | 272 | QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) ); |
270 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDeleteTran() ) ); | 273 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDeleteTran() ) ); |
271 | layout->addWidget( btn, 2, 2 ); | 274 | layout->addWidget( btn, 2, 2 ); |
272 | 275 | ||
273 | return( control ); | 276 | return( control ); |
274 | } | 277 | } |
275 | 278 | ||
276 | 279 | ||
277 | // --- initCharts ------------------------------------------------------------- | 280 | // --- initCharts ------------------------------------------------------------- |
278 | QWidget *Checkbook::initCharts() | 281 | QWidget *Checkbook::initCharts() |
279 | { | 282 | { |
280 | graphInfo = 0x0; | 283 | graphInfo = 0x0; |
281 | 284 | ||
282 | QWidget *control = new QWidget( mainWidget, tr("Charts") ); | 285 | QWidget *control = new QWidget( mainWidget, tr("Charts") ); |
283 | 286 | ||
284 | QGridLayout *layout = new QGridLayout( control ); | 287 | QGridLayout *layout = new QGridLayout( control ); |
285 | layout->setSpacing( 2 ); | 288 | layout->setSpacing( 2 ); |
286 | layout->setMargin( 4 ); | 289 | layout->setMargin( 4 ); |
287 | 290 | ||
288 | graphWidget = new Graph( control ); | 291 | graphWidget = new Graph( control ); |
289 | QWhatsThis::add( graphWidget, tr( "Select the desired chart below and then click on the Draw button." ) ); | 292 | QWhatsThis::add( graphWidget, tr( "Select the desired chart below and then click on the Draw button." ) ); |
290 | layout->addMultiCellWidget( graphWidget, 0, 0, 0, 2 ); | 293 | layout->addMultiCellWidget( graphWidget, 0, 0, 0, 2 ); |
291 | 294 | ||
292 | graphList = new QComboBox( control ); | 295 | graphList = new QComboBox( control ); |
293 | QWhatsThis::add( graphList, tr( "Click here to select the desired chart type." ) ); | 296 | QWhatsThis::add( graphList, tr( "Click here to select the desired chart type." ) ); |
294 | graphList->insertItem( tr( "Account balance" ) ); | 297 | graphList->insertItem( tr( "Account balance" ) ); |
295 | graphList->insertItem( tr( "Withdrawals by category" ) ); | 298 | graphList->insertItem( tr( "Withdrawals by category" ) ); |
296 | graphList->insertItem( tr( "Deposits by category" ) ); | 299 | graphList->insertItem( tr( "Deposits by category" ) ); |
297 | 300 | ||
298 | layout->addMultiCellWidget( graphList, 1, 1, 0, 1 ); | 301 | layout->addMultiCellWidget( graphList, 1, 1, 0, 1 ); |
299 | 302 | ||
300 | QPushButton *btn = new QPushButton( Opie::Core::OResource::loadPixmap( "checkbook/drawbtn", Opie::Core::OResource::SmallIcon ), | 303 | QPushButton *btn = new QPushButton( Opie::Core::OResource::loadPixmap( "checkbook/drawbtn", Opie::Core::OResource::SmallIcon ), |
301 | tr( "Draw" ), control ); | 304 | tr( "Draw" ), control ); |
302 | btn->setFixedHeight( AppLnk::smallIconSize()+4 ); | 305 | btn->setFixedHeight( AppLnk::smallIconSize()+4 ); |
303 | QWhatsThis::add( btn, tr( "Click here to draw the selected chart." ) ); | 306 | QWhatsThis::add( btn, tr( "Click here to draw the selected chart." ) ); |
304 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) ); | 307 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) ); |
305 | layout->addWidget( btn, 1, 2 ); | 308 | layout->addWidget( btn, 1, 2 ); |
306 | 309 | ||
307 | return control; | 310 | return control; |
308 | } | 311 | } |
309 | 312 | ||
310 | // --- loadCheckbook ---------------------------------------------------------- | 313 | // --- loadCheckbook ---------------------------------------------------------- |
311 | void Checkbook::loadCheckbook() | 314 | void Checkbook::loadCheckbook() |
312 | { | 315 | { |
313 | if ( !info ) | 316 | if ( !info ) |
314 | { | 317 | { |
315 | return; | 318 | return; |
316 | } | 319 | } |
317 | 320 | ||
318 | tranList = info->transactions(); | 321 | tranList = info->transactions(); |
319 | 322 | ||
320 | passwordCB->setChecked( !info->password().isNull() ); | 323 | passwordCB->setChecked( !info->password().isNull() ); |
321 | nameEdit->setText( info->name() ); | 324 | nameEdit->setText( info->name() ); |
322 | QString temptext = info->type(); | 325 | QString temptext = info->type(); |
323 | int i = typeList->count(); | 326 | int i = typeList->count(); |
324 | while ( i > 0 ) | 327 | while ( i > 0 ) |
325 | { | 328 | { |
326 | i--; | 329 | i--; |
327 | typeList->setCurrentItem( i ); | 330 | typeList->setCurrentItem( i ); |
328 | if ( typeList->currentText() == temptext ) | 331 | if ( typeList->currentText() == temptext ) |
329 | { | 332 | { |
330 | break; | 333 | break; |
331 | } | 334 | } |
332 | } | 335 | } |
333 | if( i<=0 ) { | 336 | if( i<=0 ) { |
334 | typeList->insertItem( temptext, 0 ); | 337 | typeList->insertItem( temptext, 0 ); |
335 | typeList->setCurrentItem(0); | 338 | typeList->setCurrentItem(0); |
336 | } | 339 | } |
337 | bankEdit->setText( info->bank() ); | 340 | bankEdit->setText( info->bank() ); |
338 | acctNumEdit->setText( info->account() ); | 341 | acctNumEdit->setText( info->account() ); |
339 | pinNumEdit->setText( info->pin() ); | 342 | pinNumEdit->setText( info->pin() ); |
340 | temptext.setNum( info->startingBalance(), 'f', 2 ); | 343 | temptext.setNum( info->startingBalance(), 'f', 2 ); |
341 | balanceEdit->setText( temptext ); | 344 | balanceEdit->setText( temptext ); |
342 | notesEdit->setText( info->notes() ); | 345 | notesEdit->setText( info->notes() ); |
343 | 346 | ||
344 | // Load transactions | 347 | // Load transactions |
345 | float amount; | 348 | float amount; |
346 | QString stramount; | 349 | QString stramount; |
347 | QString symbol = _pCfg->getCurrencySymbol(); | 350 | QString symbol = _pCfg->getCurrencySymbol(); |
348 | for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() ) | 351 | for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() ) |
349 | { | 352 | { |
350 | amount = tran->amount(); | 353 | amount = tran->amount(); |
351 | if ( tran->withdrawal() ) | 354 | if ( tran->withdrawal() ) |
352 | { | 355 | { |
353 | amount *= -1; | 356 | amount *= -1; |
354 | } | 357 | } |
355 | stramount.sprintf( "%.2f", amount ); | 358 | stramount.sprintf( "%.2f", amount ); |
356 | stramount.prepend( symbol ); | 359 | stramount.prepend( symbol ); |
357 | ( void ) new CBListItem( tran, tranTable, tran->getIdStr(), tran->datestr(false), tran->number(), tran->datestr(true), tran->desc(), stramount ); | 360 | ( void ) new CBListItem( tran, tranTable, tran->getIdStr(), tran->datestr(false), tran->number(), tran->datestr(true), tran->desc(), stramount ); |
358 | } | 361 | } |
359 | 362 | ||
360 | // set sort order | 363 | // set sort order |
361 | bool bOk=false; | 364 | bool bOk=false; |
362 | for(int i=0; i<_cbSortType->count(); i++) { | 365 | for(int i=0; i<_cbSortType->count(); i++) { |
363 | if( _cbSortType->text(i)==info->getSortOrder() ) { | 366 | if( _cbSortType->text(i)==info->getSortOrder() ) { |
364 | _cbSortType->setCurrentItem(i); | 367 | _cbSortType->setCurrentItem(i); |
365 | slotSortChanged( info->getSortOrder() ); | 368 | slotSortChanged( info->getSortOrder() ); |
366 | bOk=true; | 369 | bOk=true; |
367 | break; | 370 | break; |
368 | } | 371 | } |
369 | } | 372 | } |
370 | if( !bOk ) { | 373 | if( !bOk ) { |
371 | _cbSortType->setCurrentItem(0); | 374 | _cbSortType->setCurrentItem(0); |
372 | slotSortChanged( _cbSortType->currentText() ); | 375 | slotSortChanged( _cbSortType->currentText() ); |
373 | } | 376 | } |
374 | 377 | ||
375 | // calc running balance | 378 | // calc running balance |
376 | adjustBalance(); | 379 | adjustBalance(); |
377 | } | 380 | } |
378 | 381 | ||
379 | 382 | ||
380 | // --- adjustBalance ---------------------------------------------------------- | 383 | // --- adjustBalance ---------------------------------------------------------- |
381 | void Checkbook::adjustBalance() | 384 | void Checkbook::adjustBalance() |
382 | { | 385 | { |
383 | // update running balance in register | 386 | // update running balance in register |
384 | QString sRunning; | 387 | QString sRunning; |
385 | QString symbol = _pCfg->getCurrencySymbol(); | 388 | QString symbol = _pCfg->getCurrencySymbol(); |
386 | float bal=info->startingBalance(); | 389 | float bal=info->startingBalance(); |
387 | 390 | ||
388 | for(CBListItem *item=(CBListItem *)tranTable->firstChild(); item; item=(CBListItem *)item->nextSibling() ) { | 391 | for(CBListItem *item=(CBListItem *)tranTable->firstChild(); item; item=(CBListItem *)item->nextSibling() ) { |
389 | TranInfo *tran=item->getTranInfo(); | 392 | TranInfo *tran=item->getTranInfo(); |
390 | bal=bal + (tran->withdrawal() ? -1 : 1)*tran->amount() - tran->fee(); | 393 | bal=bal + (tran->withdrawal() ? -1 : 1)*tran->amount() - tran->fee(); |
391 | sRunning.sprintf( "%.2f", bal ); | 394 | sRunning.sprintf( "%.2f", bal ); |
392 | sRunning.prepend(symbol); | 395 | sRunning.prepend(symbol); |
393 | item->setText( COL_BAL, sRunning); | 396 | item->setText( COL_BAL, sRunning); |
394 | } | 397 | } |
395 | } | 398 | } |
396 | 399 | ||
397 | // --- resort ----------------------------------------------------------------- | 400 | // --- resort ----------------------------------------------------------------- |
398 | void Checkbook::resort() | 401 | void Checkbook::resort() |
399 | { | 402 | { |
400 | tranTable->setSorting(_sortCol); | 403 | tranTable->setSorting(_sortCol); |
401 | tranTable->sort(); | 404 | tranTable->sort(); |
402 | tranTable->setSorting(-1); | 405 | tranTable->setSorting(-1); |
403 | } | 406 | } |
404 | 407 | ||
405 | 408 | ||
406 | // --- accept ----------------------------------------------------------------- | 409 | // --- accept ----------------------------------------------------------------- |
407 | void Checkbook::accept() | 410 | void Checkbook::accept() |
408 | { | 411 | { |
409 | info->setName( nameEdit->text() ); | 412 | info->setName( nameEdit->text() ); |
410 | info->setType( typeList->currentText() ); | 413 | info->setType( typeList->currentText() ); |
411 | info->setBank( bankEdit->text() ); | 414 | info->setBank( bankEdit->text() ); |
412 | info->setAccount( acctNumEdit->text() ); | 415 | info->setAccount( acctNumEdit->text() ); |
413 | info->setPin( pinNumEdit->text() ); | 416 | info->setPin( pinNumEdit->text() ); |
414 | bool ok; | 417 | bool ok; |
415 | info->setStartingBalance( balanceEdit->text().toFloat( &ok ) ); | 418 | info->setStartingBalance( balanceEdit->text().toFloat( &ok ) ); |
416 | info->setNotes( notesEdit->text() ); | 419 | info->setNotes( notesEdit->text() ); |
417 | 420 | ||
418 | QDialog::accept(); | 421 | QDialog::accept(); |
419 | } | 422 | } |
420 | 423 | ||
421 | // --- slotPasswordClicked ---------------------------------------------------- | 424 | // --- slotPasswordClicked ---------------------------------------------------- |
422 | void Checkbook::slotPasswordClicked() | 425 | void Checkbook::slotPasswordClicked() |
423 | { | 426 | { |
424 | if ( info->password().isNull() && passwordCB->isChecked() ) | 427 | if ( info->password().isNull() && passwordCB->isChecked() ) |
425 | { | 428 | { |
426 | Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); | 429 | Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); |
427 | if ( pw->exec() != QDialog::Accepted ) | 430 | if ( pw->exec() != QDialog::Accepted ) |
428 | { | 431 | { |
429 | passwordCB->setChecked( FALSE ); | 432 | passwordCB->setChecked( FALSE ); |
430 | delete pw; | 433 | delete pw; |
431 | return; | 434 | return; |
432 | } | 435 | } |
433 | info->setPassword( pw->password ); | 436 | info->setPassword( pw->password ); |
434 | delete pw; | 437 | delete pw; |
435 | 438 | ||
436 | pw = new Password( this, tr( "Confirm password" ), tr( "Please confirm your password:" ) ); | 439 | pw = new Password( this, tr( "Confirm password" ), tr( "Please confirm your password:" ) ); |
437 | if ( pw->exec() != QDialog::Accepted || pw->password != info->password() ) | 440 | if ( pw->exec() != QDialog::Accepted || pw->password != info->password() ) |
438 | { | 441 | { |
439 | passwordCB->setChecked( FALSE ); | 442 | passwordCB->setChecked( FALSE ); |
440 | info->setPassword( QString::null ); | 443 | info->setPassword( QString::null ); |
441 | } | 444 | } |
442 | 445 | ||
443 | delete pw; | 446 | delete pw; |
444 | } | 447 | } |
445 | else if ( !info->password().isNull() && !passwordCB->isChecked() ) | 448 | else if ( !info->password().isNull() && !passwordCB->isChecked() ) |
446 | { | 449 | { |
447 | Password *pw = new Password( this, tr( "Enter password" ), | 450 | Password *pw = new Password( this, tr( "Enter password" ), |
448 | tr( "Please enter your password to confirm removal of password protection:" ) ); | 451 | tr( "Please enter your password to confirm removal of password protection:" ) ); |
449 | if ( pw->exec() == QDialog::Accepted && pw->password == info->password() ) | 452 | if ( pw->exec() == QDialog::Accepted && pw->password == info->password() ) |
450 | { | 453 | { |
451 | info->setPassword( QString::null ); | 454 | info->setPassword( QString::null ); |
452 | delete pw; | 455 | delete pw; |
453 | return; | 456 | return; |
454 | } | 457 | } |
455 | else | 458 | else |
456 | { | 459 | { |
457 | passwordCB->setChecked( TRUE ); | 460 | passwordCB->setChecked( TRUE ); |
458 | } | 461 | } |
459 | 462 | ||
460 | delete pw; | 463 | delete pw; |
461 | } | 464 | } |
462 | } | 465 | } |
463 | 466 | ||
464 | void Checkbook::slotNameChanged( const QString &newname ) | 467 | void Checkbook::slotNameChanged( const QString &newname ) |
465 | { | 468 | { |
466 | info->setName( newname ); | 469 | info->setName( newname ); |
467 | 470 | ||
468 | // TODO - need filedir | 471 | // TODO - need filedir |
469 | // QString namestr = filedir; | 472 | // QString namestr = filedir; |
470 | // namestr.append( newname ); | 473 | // namestr.append( newname ); |
471 | // namestr.append( ".qcb" ); | 474 | // namestr.append( ".qcb" ); |
472 | // info->setFilename( namestr ); | 475 | // info->setFilename( namestr ); |
473 | 476 | ||
474 | QString namestr = newname; | 477 | QString namestr = newname; |
475 | namestr.append( " - " ); | 478 | namestr.append( " - " ); |
476 | namestr.append( tr( "Checkbook" ) ); | 479 | namestr.append( tr( "Checkbook" ) ); |
477 | setCaption( namestr ); | 480 | setCaption( namestr ); |
478 | } | 481 | } |
479 | 482 | ||
480 | 483 | ||
481 | // ---slotStartingBalanceChanged ---------------------------------------------- | 484 | // ---slotStartingBalanceChanged ---------------------------------------------- |
482 | void Checkbook::slotStartingBalanceChanged( const QString &newbalance ) | 485 | void Checkbook::slotStartingBalanceChanged( const QString &newbalance ) |
483 | { | 486 | { |
484 | bool ok; | 487 | bool ok; |
485 | info->setStartingBalance( newbalance.toFloat( &ok ) ); | 488 | info->setStartingBalance( newbalance.toFloat( &ok ) ); |
486 | adjustBalance(); | 489 | adjustBalance(); |
487 | } | 490 | } |
488 | 491 | ||
489 | 492 | ||
490 | // --- slotNewTran ------------------------------------------------------------ | 493 | // --- slotNewTran ------------------------------------------------------------ |
491 | void Checkbook::slotNewTran() | 494 | void Checkbook::slotNewTran() |
492 | { | 495 | { |
493 | TranInfo *traninfo = new TranInfo( info->getNextNumber() ); | 496 | TranInfo *traninfo = new TranInfo( info->getNextNumber() ); |
494 | if( !_dLastNew.isNull() ) | 497 | if( !_dLastNew.isNull() ) |
495 | traninfo->setDate(_dLastNew); | 498 | traninfo->setDate(_dLastNew); |
496 | 499 | ||
497 | Transaction *currtran = new Transaction( this, true, info->name(), | 500 | Transaction *currtran = new Transaction( this, true, info->name(), |
498 | traninfo, | 501 | traninfo, |
499 | _pCfg ); | 502 | _pCfg ); |
500 | QString symbol = _pCfg->getCurrencySymbol(); | 503 | QString symbol = _pCfg->getCurrencySymbol(); |
501 | if ( QPEApplication::execDialog( currtran ) == QDialog::Accepted ) | 504 | if ( QPEApplication::execDialog( currtran ) == QDialog::Accepted ) |
502 | { | 505 | { |
503 | // Add to transaction list | 506 | // Add to transaction list |
504 | info->addTransaction( traninfo ); | 507 | info->addTransaction( traninfo ); |
505 | 508 | ||
506 | // Add to transaction table | 509 | // Add to transaction table |
507 | float amount; | 510 | float amount; |
508 | QString stramount; | 511 | QString stramount; |
509 | amount = (traninfo->withdrawal() ? -1 : 1)*traninfo->amount(); | 512 | amount = (traninfo->withdrawal() ? -1 : 1)*traninfo->amount(); |
510 | stramount.sprintf( "%.2f", amount ); | 513 | stramount.sprintf( "%.2f", amount ); |
511 | stramount.prepend(symbol); | 514 | stramount.prepend(symbol); |
512 | ( void ) new CBListItem( traninfo, tranTable, traninfo->getIdStr(), traninfo->datestr(false), | 515 | ( void ) new CBListItem( traninfo, tranTable, traninfo->getIdStr(), traninfo->datestr(false), |
513 | traninfo->number(), traninfo->datestr(true), traninfo->desc(), | 516 | traninfo->number(), traninfo->datestr(true), traninfo->desc(), |
514 | stramount ); | 517 | stramount ); |
515 | resort(); | 518 | resort(); |
516 | adjustBalance(); | 519 | adjustBalance(); |
517 | 520 | ||
518 | // save last date | 521 | // save last date |
519 | _dLastNew = traninfo->date(); | 522 | _dLastNew = traninfo->date(); |
520 | 523 | ||
521 | // save description in list of payees, if not in there | 524 | // save description in list of payees, if not in there |
522 | QStringList *pLst=&_pCfg->getPayees(); | 525 | QStringList *pLst=&_pCfg->getPayees(); |
523 | if( _pCfg->getSavePayees() && pLst->contains(traninfo->desc())==0 ) { | 526 | if( _pCfg->getSavePayees() && pLst->contains(traninfo->desc())==0 ) { |
524 | pLst->append( traninfo->desc() ); | 527 | pLst->append( traninfo->desc() ); |
525 | pLst->sort(); | 528 | pLst->sort(); |
526 | _pCfg->setDirty(true); | 529 | _pCfg->setDirty(true); |
527 | } | 530 | } |
528 | } | 531 | } |
529 | else | 532 | else |
530 | { | 533 | { |
531 | delete traninfo; | 534 | delete traninfo; |
532 | } | 535 | } |
533 | } | 536 | } |
534 | 537 | ||
535 | 538 | ||
536 | // --- slotEditTran ----------------------------------------------------------- | 539 | // --- slotEditTran ----------------------------------------------------------- |
537 | void Checkbook::slotEditTran() | 540 | void Checkbook::slotEditTran() |
538 | { | 541 | { |
539 | QListViewItem *curritem = tranTable->currentItem(); | 542 | QListViewItem *curritem = tranTable->currentItem(); |
540 | if ( !curritem ) | 543 | if ( !curritem ) |
541 | return; | 544 | return; |
542 | 545 | ||
543 | TranInfo *traninfo=info->findTransaction( curritem->text(COL_ID) ); | 546 | TranInfo *traninfo=info->findTransaction( curritem->text(COL_ID) ); |
544 | 547 | ||
545 | Transaction *currtran = new Transaction( this, false, info->name(), | 548 | Transaction *currtran = new Transaction( this, false, info->name(), |
546 | traninfo, | 549 | traninfo, |
547 | _pCfg ); | 550 | _pCfg ); |
548 | if ( QPEApplication::execDialog( currtran ) == QDialog::Accepted ) | 551 | if ( QPEApplication::execDialog( currtran ) == QDialog::Accepted ) |
549 | { | 552 | { |
550 | curritem->setText( COL_NUM, traninfo->number() ); | 553 | curritem->setText( COL_NUM, traninfo->number() ); |
551 | curritem->setText( COL_SORTDATE, traninfo->datestr(false) ); | 554 | curritem->setText( COL_SORTDATE, traninfo->datestr(false) ); |
552 | curritem->setText( COL_DATE, traninfo->datestr(true) ); | 555 | curritem->setText( COL_DATE, traninfo->datestr(true) ); |
553 | curritem->setText( COL_DESC, traninfo->desc() ); | 556 | curritem->setText( COL_DESC, traninfo->desc() ); |
554 | 557 | ||
555 | float amount = traninfo->amount(); | 558 | float amount = traninfo->amount(); |
556 | if ( traninfo->withdrawal() ) | 559 | if ( traninfo->withdrawal() ) |
557 | { | 560 | { |
558 | amount *= -1; | 561 | amount *= -1; |
559 | } | 562 | } |
560 | QString stramount; | 563 | QString stramount; |
561 | stramount.sprintf( "%.2f", amount ); | 564 | stramount.sprintf( "%.2f", amount ); |
562 | stramount.prepend( _pCfg->getCurrencySymbol() ); | 565 | stramount.prepend( _pCfg->getCurrencySymbol() ); |
563 | curritem->setText( COL_AMOUNT, stramount ); | 566 | curritem->setText( COL_AMOUNT, stramount ); |
564 | resort(); | 567 | resort(); |
565 | adjustBalance(); | 568 | adjustBalance(); |
566 | 569 | ||
567 | // save description in list of payees, if not in there | 570 | // save description in list of payees, if not in there |
568 | QStringList *pLst=&_pCfg->getPayees(); | 571 | QStringList *pLst=&_pCfg->getPayees(); |
569 | if( _pCfg->getSavePayees() && pLst->contains(traninfo->desc())==0 ) { | 572 | if( _pCfg->getSavePayees() && pLst->contains(traninfo->desc())==0 ) { |
570 | pLst->append( traninfo->desc() ); | 573 | pLst->append( traninfo->desc() ); |
571 | pLst->sort(); | 574 | pLst->sort(); |
572 | _pCfg->setDirty(true); | 575 | _pCfg->setDirty(true); |
573 | } | 576 | } |
574 | } | 577 | } |
575 | 578 | ||
576 | delete currtran; | 579 | delete currtran; |
577 | } | 580 | } |
578 | 581 | ||
579 | // --- slotMenuTran ----------------------------------------------------------- | 582 | // --- slotMenuTran ----------------------------------------------------------- |
580 | void Checkbook::slotMenuTran(QListViewItem *item, const QPoint &pnt) | 583 | void Checkbook::slotMenuTran(QListViewItem *item, const QPoint &pnt) |
581 | { | 584 | { |
582 | // active item? | 585 | // active item? |
583 | if( !item ) | 586 | if( !item ) |
584 | return; | 587 | return; |
585 | 588 | ||
586 | // Display menu | 589 | // Display menu |
587 | QPopupMenu m; | 590 | QPopupMenu m; |
588 | m.insertItem( QWidget::tr( "Edit" ), 1 ); | 591 | m.insertItem( QWidget::tr( "Edit" ), 1 ); |
589 | m.insertItem( QWidget::tr( "New" ), 2 ); | 592 | m.insertItem( QWidget::tr( "New" ), 2 ); |
590 | m.insertItem( QWidget::tr( "Delete" ), 3 ); | 593 | m.insertItem( QWidget::tr( "Delete" ), 3 ); |
591 | int r = m.exec( pnt ); | 594 | int r = m.exec( pnt ); |
592 | switch(r) { | 595 | switch(r) { |
593 | case 1: | 596 | case 1: |
594 | slotEditTran(); | 597 | slotEditTran(); |
595 | break; | 598 | break; |
596 | case 2: | 599 | case 2: |
597 | slotNewTran(); | 600 | slotNewTran(); |
598 | break; | 601 | break; |
599 | case 3: | 602 | case 3: |
600 | slotDeleteTran(); | 603 | slotDeleteTran(); |
601 | break; | 604 | break; |
602 | } | 605 | } |
603 | } | 606 | } |
604 | 607 | ||
605 | 608 | ||
606 | // --- slotDeleteTran --------------------------------------------------------- | 609 | // --- slotDeleteTran --------------------------------------------------------- |
607 | void Checkbook::slotDeleteTran() | 610 | void Checkbook::slotDeleteTran() |
608 | { | 611 | { |
diff --git a/noncore/apps/checkbook/configuration.cpp b/noncore/apps/checkbook/configuration.cpp index 872d9b2..929c7c0 100644 --- a/noncore/apps/checkbook/configuration.cpp +++ b/noncore/apps/checkbook/configuration.cpp | |||
@@ -1,173 +1,179 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | =. | 3 | =. |
4 | .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> | 4 | .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This file is free software; you can | 6 | _;:, .> :=|. This file is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This file is distributed in the hope that | 13 | .i_,=:_. -<s. This file is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "configuration.h" | 29 | #include "configuration.h" |
30 | #include "listedit.h" | 30 | #include "listedit.h" |
31 | 31 | ||
32 | #include <qcheckbox.h> | 32 | #include <qcheckbox.h> |
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | #include <qlayout.h> | 34 | #include <qlayout.h> |
35 | #include <qlineedit.h> | 35 | #include <qlineedit.h> |
36 | #include <qwhatsthis.h> | 36 | #include <qwhatsthis.h> |
37 | #include <qlistview.h> | 37 | #include <qlistview.h> |
38 | #include <qtabwidget.h> | 38 | #include <qtabwidget.h> |
39 | 39 | ||
40 | Configuration::Configuration( QWidget *parent, Cfg &cfg ) | 40 | Configuration::Configuration( QWidget *parent, Cfg &cfg ) |
41 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) | 41 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) |
42 | { | 42 | { |
43 | setCaption( tr( "Configure Checkbook" ) ); | 43 | setCaption( tr( "Configure Checkbook" ) ); |
44 | 44 | ||
45 | // Setup layout to make everything pretty | 45 | // Setup layout to make everything pretty |
46 | QVBoxLayout *layout = new QVBoxLayout( this ); | 46 | QVBoxLayout *layout = new QVBoxLayout( this ); |
47 | layout->setMargin( 2 ); | 47 | layout->setMargin( 2 ); |
48 | layout->setSpacing( 4 ); | 48 | layout->setSpacing( 4 ); |
49 | 49 | ||
50 | // Setup tabs for all info | 50 | // Setup tabs for all info |
51 | _mainWidget = new QTabWidget( this ); | 51 | _mainWidget = new QTabWidget( this ); |
52 | layout->addWidget( _mainWidget ); | 52 | layout->addWidget( _mainWidget ); |
53 | 53 | ||
54 | // Settings tab | 54 | // Settings tab |
55 | _mainWidget->addTab( initSettings(cfg), tr( "&Settings" ) ); | 55 | _mainWidget->addTab( initSettings(cfg), tr( "&Settings" ) ); |
56 | 56 | ||
57 | // Account Types tab | 57 | // Account Types tab |
58 | ColumnDef *d; | 58 | ColumnDef *d; |
59 | _listEditTypes=new ListEdit(_mainWidget, "TYPES" ); | 59 | _listEditTypes=new ListEdit(_mainWidget, "TYPES" ); |
60 | d=new ColumnDef( tr("Type"), (ColumnDef::ColumnType)(ColumnDef::typeString | ColumnDef::typeUnique), tr("New Account Type")); | 60 | d=new ColumnDef( tr("Type"), (ColumnDef::ColumnType)(ColumnDef::typeString | ColumnDef::typeUnique), tr("New Account Type")); |
61 | _listEditTypes->addColumnDef( d ); | 61 | _listEditTypes->addColumnDef( d ); |
62 | _listEditTypes->addData( cfg.getAccountTypes() ); | 62 | _listEditTypes->addData( cfg.getAccountTypes() ); |
63 | _mainWidget->addTab( _listEditTypes, tr( "&Account Types" ) ); | 63 | _mainWidget->addTab( _listEditTypes, tr( "&Account Types" ) ); |
64 | 64 | ||
65 | // Categories tab | 65 | // Categories tab |
66 | _listEditCategories=new ListEdit(_mainWidget, "CATEGORIES" ); | 66 | _listEditCategories=new ListEdit(_mainWidget, "CATEGORIES" ); |
67 | _listEditCategories->addColumnDef( new ColumnDef( tr("Category"), (ColumnDef::ColumnType)(ColumnDef::typeString | ColumnDef::typeUnique), tr("New Category")) ); | 67 | _listEditCategories->addColumnDef( new ColumnDef( tr("Category"), (ColumnDef::ColumnType)(ColumnDef::typeString | ColumnDef::typeUnique), tr("New Category")) ); |
68 | d=new ColumnDef( tr("Type"), ColumnDef::typeList, tr("Expense") ); | 68 | d=new ColumnDef( tr("Type"), ColumnDef::typeList, tr("Expense") ); |
69 | d->addColumnValue( tr("Expense") ); | 69 | d->addColumnValue( tr("Expense") ); |
70 | d->addColumnValue( tr("Income") ); | 70 | d->addColumnValue( tr("Income") ); |
71 | _listEditCategories->addColumnDef( d ); | 71 | _listEditCategories->addColumnDef( d ); |
72 | QStringList lst=cfg.getCategories(); | 72 | QStringList lst=cfg.getCategories(); |
73 | _listEditCategories->addData( lst ); | 73 | _listEditCategories->addData( lst ); |
74 | _mainWidget->addTab( _listEditCategories, tr( "&Categories" ) ); | 74 | _mainWidget->addTab( _listEditCategories, tr( "&Categories" ) ); |
75 | 75 | ||
76 | // Payees tab | 76 | // Payees tab |
77 | _listEditPayees=new ListEdit(_mainWidget, "PAYEES"); | 77 | _listEditPayees=new ListEdit(_mainWidget, "PAYEES"); |
78 | _listEditPayees->addColumnDef( new ColumnDef( tr("Payee"), (ColumnDef::ColumnType)(ColumnDef::typeString | ColumnDef::typeUnique), tr("New Payee")) ); | 78 | _listEditPayees->addColumnDef( new ColumnDef( tr("Payee"), (ColumnDef::ColumnType)(ColumnDef::typeString | ColumnDef::typeUnique), tr("New Payee")) ); |
79 | _listEditPayees->addData( cfg.getPayees() ); | 79 | _listEditPayees->addData( cfg.getPayees() ); |
80 | _mainWidget->addTab( _listEditPayees, tr("&Payees") ); | 80 | _mainWidget->addTab( _listEditPayees, tr("&Payees") ); |
81 | } | 81 | } |
82 | 82 | ||
83 | Configuration::~Configuration() | 83 | Configuration::~Configuration() |
84 | { | 84 | { |
85 | } | 85 | } |
86 | 86 | ||
87 | // ---- initSettings ---------------------------------------------------------- | 87 | // ---- initSettings ---------------------------------------------------------- |
88 | QWidget *Configuration::initSettings(Cfg &cfg) | 88 | QWidget *Configuration::initSettings(Cfg &cfg) |
89 | { | 89 | { |
90 | QWidget *control = new QWidget( _mainWidget ); | 90 | QWidget *control = new QWidget( _mainWidget ); |
91 | 91 | ||
92 | QFontMetrics fm = fontMetrics(); | 92 | QFontMetrics fm = fontMetrics(); |
93 | int fh = fm.height(); | 93 | int fh = fm.height(); |
94 | 94 | ||
95 | QVBoxLayout *vb = new QVBoxLayout( control ); | 95 | QVBoxLayout *vb = new QVBoxLayout( control ); |
96 | 96 | ||
97 | QScrollView *sv = new QScrollView( control ); | 97 | QScrollView *sv = new QScrollView( control ); |
98 | vb->addWidget( sv, 0, 0 ); | 98 | vb->addWidget( sv, 0, 0 ); |
99 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 99 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
100 | sv->setFrameStyle( QFrame::NoFrame ); | 100 | sv->setFrameStyle( QFrame::NoFrame ); |
101 | 101 | ||
102 | QWidget *container = new QWidget( sv->viewport() ); | 102 | QWidget *container = new QWidget( sv->viewport() ); |
103 | sv->addChild( container ); | 103 | sv->addChild( container ); |
104 | 104 | ||
105 | QGridLayout *layout = new QGridLayout( container ); | 105 | QGridLayout *layout = new QGridLayout( container ); |
106 | layout->setSpacing( 4 ); | 106 | layout->setSpacing( 4 ); |
107 | layout->setMargin( 4 ); | 107 | layout->setMargin( 4 ); |
108 | 108 | ||
109 | QLabel *label = new QLabel( tr( "Enter currency symbol:" ), container ); | 109 | QLabel *label = new QLabel( tr( "Enter currency symbol:" ), container ); |
110 | QWhatsThis::add( label, tr( "Enter your local currency symbol here." ) ); | 110 | QWhatsThis::add( label, tr( "Enter your local currency symbol here." ) ); |
111 | label->setMaximumHeight( fh + 3 ); | 111 | label->setMaximumHeight( fh + 3 ); |
112 | layout->addWidget( label, 0, 0 ); | 112 | layout->addWidget( label, 0, 0 ); |
113 | 113 | ||
114 | symbolEdit = new QLineEdit( cfg.getCurrencySymbol(), container ); | 114 | symbolEdit = new QLineEdit( cfg.getCurrencySymbol(), container ); |
115 | QWhatsThis::add( symbolEdit, tr( "Enter your local currency symbol here." ) ); | 115 | QWhatsThis::add( symbolEdit, tr( "Enter your local currency symbol here." ) ); |
116 | symbolEdit->setMaximumHeight( fh + 5 ); | 116 | symbolEdit->setMaximumHeight( fh + 5 ); |
117 | symbolEdit->setFocus(); | 117 | symbolEdit->setFocus(); |
118 | layout->addWidget( symbolEdit, 0, 1 ); | 118 | layout->addWidget( symbolEdit, 0, 1 ); |
119 | 119 | ||
120 | lockCB = new QCheckBox( tr( "Show whether checkbook is password\nprotected" ), container ); | 120 | lockCB = new QCheckBox( tr( "Show whether checkbook is password\nprotected" ), container ); |
121 | QWhatsThis::add( lockCB, tr( "Click here to select whether or not the main window will display that the checkbook is protected with a password." ) ); | 121 | QWhatsThis::add( lockCB, tr( "Click here to select whether or not the main window will display that the checkbook is protected with a password." ) ); |
122 | lockCB->setChecked( cfg.getShowLocks() ); | 122 | lockCB->setChecked( cfg.getShowLocks() ); |
123 | layout->addMultiCellWidget( lockCB, 1, 1, 0, 1 ); | 123 | layout->addMultiCellWidget( lockCB, 1, 1, 0, 1 ); |
124 | 124 | ||
125 | balCB = new QCheckBox( tr( "Show checkbook balances" ), container ); | 125 | balCB = new QCheckBox( tr( "Show checkbook balances" ), container ); |
126 | QWhatsThis::add( balCB, tr( "Click here to select whether or not the main window will display the current balance for each checkbook." ) ); | 126 | QWhatsThis::add( balCB, tr( "Click here to select whether or not the main window will display the current balance for each checkbook." ) ); |
127 | balCB->setMaximumHeight( fh + 5 ); | 127 | balCB->setMaximumHeight( fh + 5 ); |
128 | balCB->setChecked( cfg.getShowBalances() ); | 128 | balCB->setChecked( cfg.getShowBalances() ); |
129 | layout->addMultiCellWidget( balCB, 2, 2, 0, 1 ); | 129 | layout->addMultiCellWidget( balCB, 2, 2, 0, 1 ); |
130 | 130 | ||
131 | openLastBookCB = new QCheckBox( tr("Open last checkbook" ), container ); | 131 | openLastBookCB = new QCheckBox( tr("Open last checkbook" ), container ); |
132 | QWhatsThis::add( openLastBookCB, tr("Click here to select whether the last open checkbook will be opened at startup.") ); | 132 | QWhatsThis::add( openLastBookCB, tr("Click here to select whether the last open checkbook will be opened at startup.") ); |
133 | openLastBookCB->setMaximumHeight(fh+5); | 133 | openLastBookCB->setMaximumHeight(fh+5); |
134 | openLastBookCB->setChecked( cfg.isOpenLastBook() ); | 134 | openLastBookCB->setChecked( cfg.isOpenLastBook() ); |
135 | layout->addMultiCellWidget( openLastBookCB, 3, 3, 0, 1 ); | 135 | layout->addMultiCellWidget( openLastBookCB, 3, 3, 0, 1 ); |
136 | 136 | ||
137 | lastTabCB = new QCheckBox( tr("Show last checkbook tab" ), container ); | 137 | lastTabCB = new QCheckBox( tr("Show last checkbook tab" ), container ); |
138 | QWhatsThis::add( lastTabCB, tr("Click here to select whether the last tab in a checkbook should be displayed.") ); | 138 | QWhatsThis::add( lastTabCB, tr("Click here to select whether the last tab in a checkbook should be displayed.") ); |
139 | lastTabCB->setMaximumHeight(fh+5); | 139 | lastTabCB->setMaximumHeight(fh+5); |
140 | lastTabCB->setChecked( cfg.isShowLastTab() ); | 140 | lastTabCB->setChecked( cfg.isShowLastTab() ); |
141 | layout->addMultiCellWidget( lastTabCB, 4, 4, 0, 1 ); | 141 | layout->addMultiCellWidget( lastTabCB, 4, 4, 0, 1 ); |
142 | 142 | ||
143 | savePayees = new QCheckBox( tr("Save new description as payee"), container ); | 143 | savePayees = new QCheckBox( tr("Save new description as payee"), container ); |
144 | QWhatsThis::add( savePayees, tr("Click here to save new descriptions in the list of payess.") ); | 144 | QWhatsThis::add( savePayees, tr("Click here to save new descriptions in the list of payess.") ); |
145 | savePayees->setMaximumHeight(fh+5); | 145 | savePayees->setMaximumHeight(fh+5); |
146 | savePayees->setChecked( cfg.getSavePayees() ); | 146 | savePayees->setChecked( cfg.getSavePayees() ); |
147 | layout->addMultiCellWidget( savePayees, 5, 5, 0, 1 ); | 147 | layout->addMultiCellWidget( savePayees, 5, 5, 0, 1 ); |
148 | 148 | ||
149 | smallFontCB = new QCheckBox( tr( "Use smaller font for list" ), container ); | ||
150 | QWhatsThis::add( smallFontCB, tr( "Click here to select smaller font for transactions." ) ); | ||
151 | smallFontCB->setChecked( cfg.getUseSmallFont() ); | ||
152 | layout->addMultiCellWidget( smallFontCB, 6, 6, 0, 1 ); | ||
153 | |||
149 | return(control); | 154 | return(control); |
150 | } | 155 | } |
151 | 156 | ||
152 | // --- saveConfig ------------------------------------------------------------- | 157 | // --- saveConfig ------------------------------------------------------------- |
153 | void Configuration::saveConfig(Cfg &cfg) | 158 | void Configuration::saveConfig(Cfg &cfg) |
154 | { | 159 | { |
155 | // Settings | 160 | // Settings |
156 | cfg.setCurrencySymbol( symbolEdit->text() ); | 161 | cfg.setCurrencySymbol( symbolEdit->text() ); |
162 | cfg.setUseSmallFont( smallFontCB->isChecked() ); | ||
157 | cfg.setShowLocks( lockCB->isChecked() ); | 163 | cfg.setShowLocks( lockCB->isChecked() ); |
158 | cfg.setShowBalances( balCB->isChecked() ); | 164 | cfg.setShowBalances( balCB->isChecked() ); |
159 | cfg.setOpenLastBook( openLastBookCB->isChecked() ); | 165 | cfg.setOpenLastBook( openLastBookCB->isChecked() ); |
160 | cfg.setShowLastTab( lastTabCB->isChecked() ); | 166 | cfg.setShowLastTab( lastTabCB->isChecked() ); |
161 | cfg.setSavePayees( savePayees->isChecked() ); | 167 | cfg.setSavePayees( savePayees->isChecked() ); |
162 | 168 | ||
163 | // Typelist | 169 | // Typelist |
164 | _listEditTypes->storeInList( cfg.getAccountTypes() ); | 170 | _listEditTypes->storeInList( cfg.getAccountTypes() ); |
165 | 171 | ||
166 | // Category list | 172 | // Category list |
167 | QStringList lst; | 173 | QStringList lst; |
168 | _listEditCategories->storeInList( lst ); | 174 | _listEditCategories->storeInList( lst ); |
169 | cfg.setCategories( lst ); | 175 | cfg.setCategories( lst ); |
170 | 176 | ||
171 | // Payees | 177 | // Payees |
172 | _listEditPayees->storeInList( cfg.getPayees() ); | 178 | _listEditPayees->storeInList( cfg.getPayees() ); |
173 | } | 179 | } |
diff --git a/noncore/apps/checkbook/configuration.h b/noncore/apps/checkbook/configuration.h index 663514d..44c9717 100644 --- a/noncore/apps/checkbook/configuration.h +++ b/noncore/apps/checkbook/configuration.h | |||
@@ -1,69 +1,70 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | =. | 3 | =. |
4 | .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> | 4 | .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This file is free software; you can | 6 | _;:, .> :=|. This file is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This file is distributed in the hope that | 13 | .i_,=:_. -<s. This file is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef CONFIGURATION_H | 29 | #ifndef CONFIGURATION_H |
30 | #define CONFIGURATION_H | 30 | #define CONFIGURATION_H |
31 | 31 | ||
32 | #include <qdialog.h> | 32 | #include <qdialog.h> |
33 | #include "cfg.h" | 33 | #include "cfg.h" |
34 | 34 | ||
35 | class QCheckBox; | 35 | class QCheckBox; |
36 | class QLineEdit; | 36 | class QLineEdit; |
37 | class QString; | 37 | class QString; |
38 | class QTabWidget; | 38 | class QTabWidget; |
39 | class ListEdit; | 39 | class ListEdit; |
40 | 40 | ||
41 | class Configuration : public QDialog | 41 | class Configuration : public QDialog |
42 | { | 42 | { |
43 | Q_OBJECT | 43 | Q_OBJECT |
44 | 44 | ||
45 | public: | 45 | public: |
46 | // Constructor | 46 | // Constructor |
47 | Configuration( QWidget *, Cfg &cfg); | 47 | Configuration( QWidget *, Cfg &cfg); |
48 | ~Configuration(); | 48 | ~Configuration(); |
49 | 49 | ||
50 | QLineEdit *symbolEdit; | 50 | QLineEdit *symbolEdit; |
51 | QCheckBox *smallFontCB; | ||
51 | QCheckBox *lockCB; | 52 | QCheckBox *lockCB; |
52 | QCheckBox *balCB; | 53 | QCheckBox *balCB; |
53 | QCheckBox *openLastBookCB; | 54 | QCheckBox *openLastBookCB; |
54 | QCheckBox *lastTabCB; | 55 | QCheckBox *lastTabCB; |
55 | QCheckBox *savePayees; | 56 | QCheckBox *savePayees; |
56 | QTabWidget *_mainWidget; | 57 | QTabWidget *_mainWidget; |
57 | ListEdit *_listEditTypes; | 58 | ListEdit *_listEditTypes; |
58 | ListEdit *_listEditCategories; | 59 | ListEdit *_listEditCategories; |
59 | ListEdit *_listEditPayees; | 60 | ListEdit *_listEditPayees; |
60 | 61 | ||
61 | // saves settings in config struct | 62 | // saves settings in config struct |
62 | void saveConfig(Cfg &cfg); | 63 | void saveConfig(Cfg &cfg); |
63 | 64 | ||
64 | protected: | 65 | protected: |
65 | // creates settings tap from configuration | 66 | // creates settings tap from configuration |
66 | QWidget *initSettings(Cfg &cfg); | 67 | QWidget *initSettings(Cfg &cfg); |
67 | }; | 68 | }; |
68 | 69 | ||
69 | #endif | 70 | #endif |