author | mickeyl <mickeyl> | 2003-10-30 13:18:08 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-10-30 13:18:08 (UTC) |
commit | 37414f207b147af4cf6778b323a0aa23127901bd (patch) (unidiff) | |
tree | b08c10043ab689b0a40425d268cd72226799b0cf | |
parent | d53637f46cf217fc760d7aac58b4596843a73803 (diff) | |
download | opie-37414f207b147af4cf6778b323a0aa23127901bd.zip opie-37414f207b147af4cf6778b323a0aa23127901bd.tar.gz opie-37414f207b147af4cf6778b323a0aa23127901bd.tar.bz2 |
apply patch to HEAD
-rw-r--r-- | noncore/apps/checkbook/cfg.cpp | 15 | ||||
-rw-r--r-- | noncore/apps/checkbook/cfg.h | 16 | ||||
-rw-r--r-- | noncore/apps/checkbook/checkbook.cpp | 91 | ||||
-rw-r--r-- | noncore/apps/checkbook/checkbook.h | 8 | ||||
-rw-r--r-- | noncore/apps/checkbook/configuration.cpp | 16 | ||||
-rw-r--r-- | noncore/apps/checkbook/configuration.h | 2 | ||||
-rw-r--r-- | noncore/apps/checkbook/listedit.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/checkbook/mainwindow.cpp | 7 | ||||
-rw-r--r-- | noncore/apps/checkbook/traninfo.cpp | 25 | ||||
-rw-r--r-- | noncore/apps/checkbook/traninfo.h | 5 | ||||
-rw-r--r-- | noncore/apps/checkbook/transaction.cpp | 92 | ||||
-rw-r--r-- | noncore/apps/checkbook/transaction.h | 12 |
12 files changed, 249 insertions, 44 deletions
diff --git a/noncore/apps/checkbook/cfg.cpp b/noncore/apps/checkbook/cfg.cpp index 1e0ec5c..0d5d9ed 100644 --- a/noncore/apps/checkbook/cfg.cpp +++ b/noncore/apps/checkbook/cfg.cpp | |||
@@ -14,197 +14,208 @@ | |||
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 <qstring.h> | 31 | #include <qstring.h> |
32 | #include <qstringlist.h> | 32 | #include <qstringlist.h> |
33 | #include <qwidget.h> | 33 | #include <qwidget.h> |
34 | #include <qpe/resource.h> | 34 | #include <qpe/resource.h> |
35 | #include <qpe/config.h> | 35 | #include <qpe/config.h> |
36 | 36 | ||
37 | #include "cfg.h" | 37 | #include "cfg.h" |
38 | 38 | ||
39 | // --- Cfg -------------------------------------------------------------------- | 39 | // --- Cfg -------------------------------------------------------------------- |
40 | Cfg::Cfg() | 40 | Cfg::Cfg() |
41 | { | 41 | { |
42 | _currencySymbol="$"; | 42 | _currencySymbol="$"; |
43 | _showLocks=FALSE; | 43 | _showLocks=FALSE; |
44 | _showBalances=FALSE; | 44 | _showBalances=FALSE; |
45 | _pCategories=new CategoryList(); | 45 | _pCategories=new CategoryList(); |
46 | _bDirty=false; | ||
46 | } | 47 | } |
47 | 48 | ||
48 | // --- readStringList --------------------------------------------------------- | 49 | // --- readStringList --------------------------------------------------------- |
49 | // Reads the entries for the control from a configuration file and returns | 50 | // Reads the entries for the control from a configuration file and returns |
50 | // them in a StringList. Later this list can be used to create the control. It | 51 | // them in a StringList. Later this list can be used to create the control. It |
51 | // is assumed, that the group is already set. Key is used to enumerate the | 52 | // is assumed, that the group is already set. Key is used to enumerate the |
52 | // entries. | 53 | // entries. |
53 | void Cfg::readStringList(Config &cfg, const char *sKey, QStringList &lst) | 54 | void Cfg::readStringList(Config &cfg, const char *sKey, QStringList &lst) |
54 | { | 55 | { |
55 | qDebug( "%s", sKey ); | ||
56 | |||
57 | QString sEntry; | 56 | QString sEntry; |
58 | int iCount; | 57 | int iCount; |
59 | 58 | ||
60 | // read count of elements | 59 | // read count of elements |
61 | sEntry.sprintf("%s_Count", sKey); | 60 | sEntry.sprintf("%s_Count", sKey); |
62 | iCount=cfg.readNumEntry(sEntry, 0); | 61 | iCount=cfg.readNumEntry(sEntry, 0); |
63 | 62 | ||
64 | // read entries | 63 | // read entries |
65 | for(int i=1; i<=iCount; i++) { | 64 | for(int i=1; i<=iCount; i++) { |
66 | sEntry.sprintf("%s%d", sKey, i); | 65 | sEntry.sprintf("%s%d", sKey, i); |
67 | QString sType=cfg.readEntry(sEntry); | 66 | QString sType=cfg.readEntry(sEntry); |
68 | if( sType!=NULL ) | 67 | if( sType!=NULL ) |
69 | lst.append(sType); | 68 | lst.append(sType); |
70 | } | 69 | } |
71 | } | 70 | } |
72 | 71 | ||
73 | 72 | ||
74 | // --- readConfig ------------------------------------------------------------- | 73 | // --- readConfig ------------------------------------------------------------- |
75 | // Reads the member data from the given config file. It will also set the group | 74 | // Reads the member data from the given config file. It will also set the group |
76 | // "Config" | 75 | // "Config" |
77 | void Cfg::readConfig(Config &config) | 76 | void Cfg::readConfig(Config &config) |
78 | { | 77 | { |
79 | // set group | 78 | // set group |
80 | config.setGroup( "Config" ); | 79 | config.setGroup( "Config" ); |
81 | 80 | ||
82 | // read scalars | 81 | // read scalars |
83 | _currencySymbol = config.readEntry( "CurrencySymbol", "$" ); | 82 | _currencySymbol = config.readEntry( "CurrencySymbol", "$" ); |
84 | _showLocks = config.readBoolEntry( "ShowLocks", FALSE ); | 83 | _showLocks = config.readBoolEntry( "ShowLocks", FALSE ); |
85 | _showBalances = config.readBoolEntry( "ShowBalances", FALSE ); | 84 | _showBalances = config.readBoolEntry( "ShowBalances", FALSE ); |
86 | _openLastBook = config.readBoolEntry( "OpenLastBook", FALSE ); | 85 | _openLastBook = config.readBoolEntry( "OpenLastBook", FALSE ); |
87 | _sLastBook = config.readEntry("LastBook", ""); | 86 | _sLastBook = config.readEntry("LastBook", ""); |
88 | _showLastTab = config.readBoolEntry( "ShowLastTab", FALSE ); | 87 | _showLastTab = config.readBoolEntry( "ShowLastTab", FALSE ); |
88 | _bSavePayees = config.readBoolEntry( "SavePayees", FALSE ); | ||
89 | 89 | ||
90 | // Account types | 90 | // Account types |
91 | readStringList(config, "AccType", _AccountTypes); | 91 | readStringList(config, "AccType", _AccountTypes); |
92 | if( _AccountTypes.isEmpty() ) { | 92 | if( _AccountTypes.isEmpty() ) { |
93 | _AccountTypes+= (const char *)QWidget::tr("Savings"); | 93 | _AccountTypes+= (const char *)QWidget::tr("Savings"); |
94 | _AccountTypes+= (const char *)QWidget::tr("Checking"); | 94 | _AccountTypes+= (const char *)QWidget::tr("Checking"); |
95 | _AccountTypes+= (const char *)QWidget::tr("CD"); | 95 | _AccountTypes+= (const char *)QWidget::tr("CD"); |
96 | _AccountTypes+= (const char *)QWidget::tr("Money market"); | 96 | _AccountTypes+= (const char *)QWidget::tr("Money market"); |
97 | _AccountTypes+= (const char *)QWidget::tr("Mutual fund"); | 97 | _AccountTypes+= (const char *)QWidget::tr("Mutual fund"); |
98 | _AccountTypes+= (const char *)QWidget::tr("Other"); | 98 | _AccountTypes+= (const char *)QWidget::tr("Other"); |
99 | writeStringList(config, "AccType", _AccountTypes); | 99 | writeStringList(config, "AccType", _AccountTypes); |
100 | config.write(); | 100 | config.write(); |
101 | } | 101 | } |
102 | 102 | ||
103 | // Payees | ||
104 | readStringList(config, "Payee", _Payees); | ||
105 | |||
103 | // Read Categories | 106 | // Read Categories |
104 | QStringList lst; | 107 | QStringList lst; |
105 | readStringList(config, "Category", lst); | 108 | readStringList(config, "Category", lst); |
106 | if( lst.isEmpty() ) { | 109 | if( lst.isEmpty() ) { |
107 | QString type=QWidget::tr("Expense"); | 110 | QString type=QWidget::tr("Expense"); |
108 | lst += QWidget::tr( "Automobile" )+";"+type; | 111 | lst += QWidget::tr( "Automobile" )+";"+type; |
109 | lst += QWidget::tr( "Bills" )+";"+type; | 112 | lst += QWidget::tr( "Bills" )+";"+type; |
110 | lst += QWidget::tr( "CDs" )+";"+type; | 113 | lst += QWidget::tr( "CDs" )+";"+type; |
111 | lst += QWidget::tr( "Clothing" )+";"+type; | 114 | lst += QWidget::tr( "Clothing" )+";"+type; |
112 | lst += QWidget::tr( "Computer" )+";"+type; | 115 | lst += QWidget::tr( "Computer" )+";"+type; |
113 | lst += QWidget::tr( "DVDs" )+";"+type; | 116 | lst += QWidget::tr( "DVDs" )+";"+type; |
114 | lst += QWidget::tr( "Electronics" )+";"+type; | 117 | lst += QWidget::tr( "Electronics" )+";"+type; |
115 | lst += QWidget::tr( "Entertainment" )+";"+type; | 118 | lst += QWidget::tr( "Entertainment" )+";"+type; |
116 | lst += QWidget::tr( "Food" )+";"+type; | 119 | lst += QWidget::tr( "Food" )+";"+type; |
117 | lst += QWidget::tr( "Gasoline" )+";"+type; | 120 | lst += QWidget::tr( "Gasoline" )+";"+type; |
118 | lst += QWidget::tr( "Misc" )+";"+type; | 121 | lst += QWidget::tr( "Misc" )+";"+type; |
119 | lst += QWidget::tr( "Movies" )+";"+type; | 122 | lst += QWidget::tr( "Movies" )+";"+type; |
120 | lst += QWidget::tr( "Rent" )+";"+type; | 123 | lst += QWidget::tr( "Rent" )+";"+type; |
121 | lst += QWidget::tr( "Travel" )+";"+type; | 124 | lst += QWidget::tr( "Travel" )+";"+type; |
122 | 125 | ||
123 | type=QWidget::tr( "Income" ); | 126 | type=QWidget::tr( "Income" ); |
124 | lst += QWidget::tr( "Work" )+";"+type; | 127 | lst += QWidget::tr( "Work" )+";"+type; |
125 | lst += QWidget::tr( "Family Member" )+";"+type; | 128 | lst += QWidget::tr( "Family Member" )+";"+type; |
126 | lst += QWidget::tr( "Misc. Credit" )+";"+type; | 129 | lst += QWidget::tr( "Misc. Credit" )+";"+type; |
127 | 130 | ||
128 | setCategories(lst); | 131 | setCategories(lst); |
129 | writeStringList(config, "Category", lst); | 132 | writeStringList(config, "Category", lst); |
130 | config.write(); | 133 | config.write(); |
131 | } else { | 134 | } else { |
132 | setCategories(lst); | 135 | setCategories(lst); |
133 | } | 136 | } |
137 | |||
138 | // not dirty | ||
139 | _bDirty=false; | ||
134 | } | 140 | } |
135 | 141 | ||
136 | 142 | ||
137 | // --- writeStringList -------------------------------------------------------- | 143 | // --- writeStringList -------------------------------------------------------- |
138 | // Writes the entries in the control in a configuration file. It is assumed, | 144 | // Writes the entries in the control in a configuration file. It is assumed, |
139 | // that the group is already set. Key is used to enumerate the entries | 145 | // that the group is already set. Key is used to enumerate the entries |
140 | void Cfg::writeStringList(Config &cfg, const char *sKey, QStringList &lst) | 146 | void Cfg::writeStringList(Config &cfg, const char *sKey, QStringList &lst) |
141 | { | 147 | { |
142 | QString sEntry; | 148 | QString sEntry; |
143 | int iCount=0; | 149 | int iCount=0; |
144 | QStringList::Iterator itr; | 150 | QStringList::Iterator itr; |
145 | for(itr=lst.begin(); itr!=lst.end(); itr++) { | 151 | for(itr=lst.begin(); itr!=lst.end(); itr++) { |
146 | sEntry.sprintf("%s%d", sKey, ++iCount); | 152 | sEntry.sprintf("%s%d", sKey, ++iCount); |
147 | cfg.writeEntry(sEntry, *itr ); | 153 | cfg.writeEntry(sEntry, *itr ); |
148 | } | 154 | } |
149 | sEntry.sprintf("%s_Count", sKey); | 155 | sEntry.sprintf("%s_Count", sKey); |
150 | cfg.writeEntry(sEntry, iCount); | 156 | cfg.writeEntry(sEntry, iCount); |
151 | } | 157 | } |
152 | 158 | ||
153 | 159 | ||
154 | // --- writeConfig ----------------------------------------------------------- | 160 | // --- writeConfig ----------------------------------------------------------- |
155 | // Writes all config data back to the config file. The group will be set to | 161 | // Writes all config data back to the config file. The group will be set to |
156 | // "Config" and the write be commited | 162 | // "Config" and the write be commited |
157 | void Cfg::writeConfig(Config &config) | 163 | void Cfg::writeConfig(Config &config) |
158 | { | 164 | { |
159 | // set the group | 165 | // set the group |
160 | config.setGroup( "Config" ); | 166 | config.setGroup( "Config" ); |
161 | 167 | ||
162 | // write scalars | 168 | // write scalars |
163 | config.writeEntry( "CurrencySymbol", _currencySymbol ); | 169 | config.writeEntry( "CurrencySymbol", _currencySymbol ); |
164 | config.writeEntry( "ShowLocks", _showLocks ); | 170 | config.writeEntry( "ShowLocks", _showLocks ); |
165 | config.writeEntry( "ShowBalances", _showBalances ); | 171 | config.writeEntry( "ShowBalances", _showBalances ); |
166 | config.writeEntry( "OpenLastBook", _openLastBook ); | 172 | config.writeEntry( "OpenLastBook", _openLastBook ); |
167 | config.writeEntry( "LastBook", _sLastBook ); | 173 | config.writeEntry( "LastBook", _sLastBook ); |
168 | config.writeEntry( "ShowLastTab", _showLastTab ); | 174 | config.writeEntry( "ShowLastTab", _showLastTab ); |
175 | config.writeEntry( "SavePayees", _bSavePayees ); | ||
169 | 176 | ||
170 | // write account types | 177 | // write account types |
171 | writeStringList(config, "AccType", _AccountTypes); | 178 | writeStringList(config, "AccType", _AccountTypes); |
172 | 179 | ||
180 | // write payees | ||
181 | writeStringList(config, "Payee", _Payees); | ||
182 | |||
173 | // write categories | 183 | // write categories |
174 | QStringList lst=getCategories(); | 184 | QStringList lst=getCategories(); |
175 | writeStringList(config, "Category", lst ); | 185 | writeStringList(config, "Category", lst ); |
176 | 186 | ||
177 | // commit write | 187 | // commit write |
178 | config.write(); | 188 | config.write(); |
189 | _bDirty=false; | ||
179 | } | 190 | } |
180 | 191 | ||
181 | 192 | ||
182 | // --- getCategories ---------------------------------------------------------- | 193 | // --- getCategories ---------------------------------------------------------- |
183 | QStringList Cfg::getCategories() | 194 | QStringList Cfg::getCategories() |
184 | { | 195 | { |
185 | QStringList ret; | 196 | QStringList ret; |
186 | for(Category *itr=_pCategories->first(); itr; itr=_pCategories->next() ) { | 197 | for(Category *itr=_pCategories->first(); itr; itr=_pCategories->next() ) { |
187 | QString sEntry; | 198 | QString sEntry; |
188 | 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")) ); |
189 | ret.append(sEntry); | 200 | ret.append(sEntry); |
190 | } | 201 | } |
191 | return(ret); | 202 | return(ret); |
192 | } | 203 | } |
193 | 204 | ||
194 | 205 | ||
195 | // --- setCategories ---------------------------------------------------------- | 206 | // --- setCategories ---------------------------------------------------------- |
196 | void Cfg::setCategories(QStringList &lst) | 207 | void Cfg::setCategories(QStringList &lst) |
197 | { | 208 | { |
198 | _pCategories->clear(); | 209 | _pCategories->clear(); |
199 | QStringList::Iterator itr; | 210 | QStringList::Iterator itr; |
200 | for(itr=lst.begin(); itr!=lst.end(); itr++) { | 211 | for(itr=lst.begin(); itr!=lst.end(); itr++) { |
201 | QStringList split=QStringList::split(";", *itr, true); | 212 | QStringList split=QStringList::split(";", *itr, true); |
202 | if( split.count()<2 ) continue; | 213 | if( split.count()<2 ) continue; |
203 | bool bIncome= (split[1]==QWidget::tr("Income")); | 214 | bool bIncome= (split[1]==QWidget::tr("Income")); |
204 | _pCategories->append( new Category(split[0], bIncome) ); | 215 | _pCategories->append( new Category(split[0], bIncome) ); |
205 | } | 216 | } |
206 | } | 217 | } |
207 | 218 | ||
208 | 219 | ||
209 | // --- CategoryList ------------------------------------------------------------ | 220 | // --- CategoryList ------------------------------------------------------------ |
210 | CategoryList::CategoryList() : QList<Category>() | 221 | CategoryList::CategoryList() : QList<Category>() |
diff --git a/noncore/apps/checkbook/cfg.h b/noncore/apps/checkbook/cfg.h index 2b69368..20692b4 100644 --- a/noncore/apps/checkbook/cfg.h +++ b/noncore/apps/checkbook/cfg.h | |||
@@ -48,73 +48,85 @@ class Category | |||
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 getShowLocks() { return(_showLocks); } | 71 | bool getShowLocks() { return(_showLocks); } |
72 | void setShowLocks(bool n) { _showLocks=n; } | 72 | void setShowLocks(bool n) { _showLocks=n; } |
73 | bool getShowBalances() { return(_showBalances); } | 73 | bool getShowBalances() { return(_showBalances); } |
74 | void setShowBalances(bool n) { _showBalances=n; } | 74 | void setShowBalances(bool n) { _showBalances=n; } |
75 | QString &getCurrencySymbol() { return(_currencySymbol); } | 75 | QString &getCurrencySymbol() { return(_currencySymbol); } |
76 | void setCurrencySymbol(QString n) {_currencySymbol= n; } | 76 | void setCurrencySymbol(QString n) {_currencySymbol= n; } |
77 | void setCurrencySymbol(const char *n) { _currencySymbol=n; } | 77 | void setCurrencySymbol(const char *n) { _currencySymbol=n; } |
78 | QStringList &getAccountTypes() { return(_AccountTypes); } | 78 | QStringList &getAccountTypes() { return(_AccountTypes); } |
79 | 79 | ||
80 | // --- Payees | ||
81 | QStringList &getPayees() { return(_Payees); } | ||
82 | bool getSavePayees() { return(_bSavePayees); } | ||
83 | void setSavePayees(bool bSave) { _bSavePayees=bSave; } | ||
84 | |||
80 | // --- Categories | 85 | // --- Categories |
81 | QStringList getCategories(); | 86 | QStringList getCategories(); |
82 | void setCategories(QStringList &lst); | 87 | void setCategories(QStringList &lst); |
83 | CategoryList *getCategoryList() { return(_pCategories); } | 88 | CategoryList *getCategoryList() { return(_pCategories); } |
84 | 89 | ||
85 | // --- last book | 90 | // --- last book |
86 | void setOpenLastBook(bool openLastBook) { _openLastBook=openLastBook; } | 91 | void setOpenLastBook(bool openLastBook) { _openLastBook=openLastBook; } |
87 | bool isOpenLastBook() { return(_openLastBook); } | 92 | bool isOpenLastBook() { return(_openLastBook); } |
88 | void setLastBook(const QString &lastBook) { _sLastBook=lastBook; } | 93 | void setLastBook(const QString &lastBook) { _sLastBook=lastBook; } |
89 | QString &getLastBook() { return(_sLastBook); } | 94 | QString &getLastBook() { return(_sLastBook); } |
90 | 95 | ||
91 | // --- last tab | 96 | // --- last tab |
92 | void setShowLastTab(bool showLastTab) { _showLastTab=showLastTab; } | 97 | void setShowLastTab(bool showLastTab) { _showLastTab=showLastTab; } |
93 | bool isShowLastTab() { return(_showLastTab); } | 98 | bool isShowLastTab() { return(_showLastTab); } |
94 | 99 | ||
95 | // --- reads data from config file | 100 | // --- reads data from config file |
96 | void readConfig(Config &cfg); | 101 | void readConfig(Config &cfg); |
97 | 102 | ||
98 | // --- writes data to config file | 103 | // --- writes data to config file |
99 | void writeConfig(Config &cfg); | 104 | void writeConfig(Config &cfg); |
100 | 105 | ||
106 | // --- dirty flag | ||
107 | bool isDirty() { return(_bDirty); } | ||
108 | void setDirty(bool bDirty) { _bDirty=bDirty; } | ||
109 | |||
110 | protected: | ||
101 | // --- reads list from config file | 111 | // --- reads list from config file |
102 | static void readStringList(Config &cfg, const char *sKey, QStringList &lst); | 112 | static void readStringList(Config &cfg, const char *sKey, QStringList &lst); |
103 | 113 | ||
104 | // --- writes list in configuration file | 114 | // --- writes list in configuration file |
105 | static void writeStringList(Config &cfg, const char *sKey, QStringList &lst); | 115 | static void writeStringList(Config &cfg, const char *sKey, QStringList &lst); |
106 | 116 | ||
107 | |||
108 | |||
109 | private: | 117 | private: |
110 | QString _currencySymbol; | 118 | QString _currencySymbol; |
111 | bool _showLocks; | 119 | bool _showLocks; |
112 | bool _showBalances; | 120 | bool _showBalances; |
113 | bool _openLastBook; | 121 | bool _openLastBook; |
114 | bool _showLastTab; | 122 | bool _showLastTab; |
123 | bool _bDirty; | ||
124 | bool _bSavePayees; | ||
115 | QString _sLastBook; | 125 | QString _sLastBook; |
116 | QStringList _AccountTypes; | 126 | QStringList _AccountTypes; |
117 | CategoryList *_pCategories; | 127 | CategoryList *_pCategories; |
128 | QStringList _Payees; | ||
129 | |||
118 | }; | 130 | }; |
119 | 131 | ||
120 | #endif | 132 | #endif |
diff --git a/noncore/apps/checkbook/checkbook.cpp b/noncore/apps/checkbook/checkbook.cpp index c53e889..a42c824 100644 --- a/noncore/apps/checkbook/checkbook.cpp +++ b/noncore/apps/checkbook/checkbook.cpp | |||
@@ -20,71 +20,73 @@ | |||
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 "mainwindow.h" | 36 | #include "mainwindow.h" |
37 | #include "cfg.h" | 37 | #include "cfg.h" |
38 | 38 | ||
39 | #include <opie/otabwidget.h> | 39 | #include <opie/otabwidget.h> |
40 | #include <qpe/qpeapplication.h> | 40 | #include <qpe/qpeapplication.h> |
41 | #include <qpe/qpemessagebox.h> | 41 | #include <qpe/qpemessagebox.h> |
42 | #include <qpe/resource.h> | 42 | #include <qpe/resource.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 | 53 | ||
53 | #define COL_ID 0 | 54 | #define COL_ID 0 |
54 | #define COL_NUM 1 | 55 | #define COL_SORTDATE 1 |
55 | #define COL_DATE 2 | 56 | #define COL_NUM 2 |
56 | #define COL_DESC 3 | 57 | #define COL_DATE 3 |
57 | #define COL_AMOUNT 4 | 58 | #define COL_DESC 4 |
58 | #define COL_BAL 5 | 59 | #define COL_AMOUNT 5 |
60 | #define COL_BAL 6 | ||
59 | 61 | ||
60 | // --- Checkbook -------------------------------------------------------------- | 62 | // --- Checkbook -------------------------------------------------------------- |
61 | Checkbook::Checkbook( QWidget *parent, CBInfo *i, Cfg *cfg ) | 63 | Checkbook::Checkbook( QWidget *parent, CBInfo *i, Cfg *cfg ) |
62 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) | 64 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) |
63 | { | 65 | { |
64 | info = i; | 66 | info = i; |
65 | _pCfg=cfg; | 67 | _pCfg=cfg; |
66 | 68 | ||
67 | // Title bar | 69 | // Title bar |
68 | if ( info->name() != "" ) | 70 | if ( info->name() != "" ) |
69 | { | 71 | { |
70 | QString tempstr = info->name(); | 72 | QString tempstr = info->name(); |
71 | tempstr.append( " - " ); | 73 | tempstr.append( " - " ); |
72 | tempstr.append( tr( "Checkbook" ) ); | 74 | tempstr.append( tr( "Checkbook" ) ); |
73 | setCaption( tempstr ); | 75 | setCaption( tempstr ); |
74 | } | 76 | } |
75 | else | 77 | else |
76 | { | 78 | { |
77 | setCaption( tr( "New checkbook" ) ); | 79 | setCaption( tr( "New checkbook" ) ); |
78 | } | 80 | } |
79 | 81 | ||
80 | 82 | ||
81 | // Setup layout to make everything pretty | 83 | // Setup layout to make everything pretty |
82 | QVBoxLayout *layout = new QVBoxLayout( this ); | 84 | QVBoxLayout *layout = new QVBoxLayout( this ); |
83 | layout->setMargin( 2 ); | 85 | layout->setMargin( 2 ); |
84 | layout->setSpacing( 4 ); | 86 | layout->setSpacing( 4 ); |
85 | 87 | ||
86 | // Setup tabs for all info | 88 | // Setup tabs for all info |
87 | mainWidget = new OTabWidget( this ); | 89 | mainWidget = new OTabWidget( this ); |
88 | layout->addWidget( mainWidget ); | 90 | layout->addWidget( mainWidget ); |
89 | mainWidget->addTab( initInfo(), "checkbook/infotab", tr( "Info" ) ); | 91 | mainWidget->addTab( initInfo(), "checkbook/infotab", tr( "Info" ) ); |
90 | mainWidget->addTab( initTransactions(), "checkbook/trantab", tr( "Transactions" ) ); | 92 | mainWidget->addTab( initTransactions(), "checkbook/trantab", tr( "Transactions" ) ); |
@@ -195,78 +197,83 @@ QWidget *Checkbook::initInfo() | |||
195 | } | 197 | } |
196 | 198 | ||
197 | 199 | ||
198 | // --- initTransactions ------------------------------------------------------- | 200 | // --- initTransactions ------------------------------------------------------- |
199 | QWidget *Checkbook::initTransactions() | 201 | QWidget *Checkbook::initTransactions() |
200 | { | 202 | { |
201 | QWidget *control = new QWidget( mainWidget, tr("Transactions") ); | 203 | QWidget *control = new QWidget( mainWidget, tr("Transactions") ); |
202 | 204 | ||
203 | QGridLayout *layout = new QGridLayout( control ); | 205 | QGridLayout *layout = new QGridLayout( control ); |
204 | layout->setSpacing( 2 ); | 206 | layout->setSpacing( 2 ); |
205 | layout->setMargin( 4 ); | 207 | layout->setMargin( 4 ); |
206 | 208 | ||
207 | // Sort selector | 209 | // Sort selector |
208 | QLabel *label = new QLabel( tr( "Sort by:" ), control ); | 210 | QLabel *label = new QLabel( tr( "Sort by:" ), control ); |
209 | QWhatsThis::add( label, tr( "Select checkbook sorting here." ) ); | 211 | QWhatsThis::add( label, tr( "Select checkbook sorting here." ) ); |
210 | layout->addMultiCellWidget( label, 0, 0, 0, 1 ); | 212 | layout->addMultiCellWidget( label, 0, 0, 0, 1 ); |
211 | _cbSortType=new QComboBox( control ); | 213 | _cbSortType=new QComboBox( control ); |
212 | _cbSortType->insertItem( tr("Entry Order") ); | 214 | _cbSortType->insertItem( tr("Entry Order") ); |
213 | _cbSortType->insertItem( tr("Date") ); | 215 | _cbSortType->insertItem( tr("Date") ); |
214 | _cbSortType->insertItem( tr("Number") ); | 216 | _cbSortType->insertItem( tr("Number") ); |
215 | layout->addMultiCellWidget( _cbSortType, 0, 0, 1, 2 ); | 217 | layout->addMultiCellWidget( _cbSortType, 0, 0, 1, 2 ); |
216 | connect( _cbSortType, SIGNAL( activated(const QString &) ), this, SLOT( slotSortChanged( const QString & ) ) ); | 218 | connect( _cbSortType, SIGNAL( activated(const QString &) ), this, SLOT( slotSortChanged( const QString & ) ) ); |
217 | 219 | ||
218 | // Table | 220 | // Table |
219 | tranTable = new QListView( control ); | 221 | tranTable = new QListView( control ); |
220 | QFont fnt(QPEApplication::font()); | 222 | QFont fnt(QPEApplication::font()); |
221 | fnt.setPointSize( fnt.pointSize()-1 ); | 223 | fnt.setPointSize( fnt.pointSize()-1 ); |
222 | tranTable->setFont( fnt ); | 224 | tranTable->setFont( fnt ); |
223 | 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." ) ); | 225 | 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." ) ); |
224 | tranTable->addColumn( tr( "Id" ) ); | 226 | tranTable->addColumn( tr( "Id" ) ); |
225 | tranTable->setColumnWidthMode( COL_ID, QListView::Manual ); | 227 | tranTable->setColumnWidthMode( COL_ID, QListView::Manual ); |
226 | tranTable->setColumnWidth( COL_ID, 0); | 228 | tranTable->setColumnWidth( COL_ID, 0); |
229 | tranTable->addColumn( tr( "SortDate" ) ); | ||
230 | tranTable->setColumnWidthMode( COL_SORTDATE, QListView::Manual ); | ||
231 | tranTable->setColumnWidth( COL_SORTDATE, 0); | ||
227 | tranTable->addColumn( tr( "Num" ) ); | 232 | tranTable->addColumn( tr( "Num" ) ); |
228 | tranTable->addColumn( tr( "Date" ) ); | 233 | tranTable->addColumn( tr( "Date" ) ); |
229 | //tranTable->addColumn( tr( "Cleared" ) ); | 234 | //tranTable->addColumn( tr( "Cleared" ) ); |
230 | tranTable->addColumn( tr( "Description" ) ); | 235 | tranTable->addColumn( tr( "Description" ) ); |
231 | int column = tranTable->addColumn( tr( "Amount" ) ); | 236 | int column = tranTable->addColumn( tr( "Amount" ) ); |
232 | tranTable->setColumnAlignment( column, Qt::AlignRight ); | 237 | tranTable->setColumnAlignment( column, Qt::AlignRight ); |
233 | column=tranTable->addColumn( tr("Balance") ); | 238 | column=tranTable->addColumn( tr("Balance") ); |
234 | tranTable->setColumnAlignment( column, Qt::AlignRight ); | 239 | tranTable->setColumnAlignment( column, Qt::AlignRight ); |
235 | tranTable->setAllColumnsShowFocus( TRUE ); | 240 | tranTable->setAllColumnsShowFocus( TRUE ); |
236 | tranTable->setSorting( -1 ); | 241 | tranTable->setSorting( -1 ); |
237 | layout->addMultiCellWidget( tranTable, 1, 1, 0, 2 ); | 242 | layout->addMultiCellWidget( tranTable, 1, 1, 0, 2 ); |
238 | QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold ); | 243 | QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold ); |
239 | connect( tranTable, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), | 244 | connect( tranTable, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), |
240 | this, SLOT( slotEditTran() ) ); | 245 | this, SLOT( slotMenuTran(QListViewItem *, const QPoint &) ) ); |
246 | connect( tranTable, SIGNAL( doubleClicked( QListViewItem * ) ), | ||
247 | this, SLOT( slotEditTran() ) ); | ||
241 | _sortCol=COL_ID; | 248 | _sortCol=COL_ID; |
242 | 249 | ||
243 | // Buttons | 250 | // Buttons |
244 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), control ); | 251 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), control ); |
245 | QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) ); | 252 | QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) ); |
246 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotNewTran() ) ); | 253 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotNewTran() ) ); |
247 | layout->addWidget( btn, 2, 0 ); | 254 | layout->addWidget( btn, 2, 0 ); |
248 | 255 | ||
249 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), control ); | 256 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), control ); |
250 | QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) ); | 257 | QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) ); |
251 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotEditTran() ) ); | 258 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotEditTran() ) ); |
252 | layout->addWidget( btn, 2, 1 ); | 259 | layout->addWidget( btn, 2, 1 ); |
253 | 260 | ||
254 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), control ); | 261 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), control ); |
255 | QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) ); | 262 | QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) ); |
256 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDeleteTran() ) ); | 263 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDeleteTran() ) ); |
257 | layout->addWidget( btn, 2, 2 ); | 264 | layout->addWidget( btn, 2, 2 ); |
258 | 265 | ||
259 | return( control ); | 266 | return( control ); |
260 | } | 267 | } |
261 | 268 | ||
262 | 269 | ||
263 | // --- initCharts ------------------------------------------------------------- | 270 | // --- initCharts ------------------------------------------------------------- |
264 | QWidget *Checkbook::initCharts() | 271 | QWidget *Checkbook::initCharts() |
265 | { | 272 | { |
266 | graphInfo = 0x0; | 273 | graphInfo = 0x0; |
267 | 274 | ||
268 | QWidget *control = new QWidget( mainWidget, tr("Charts") ); | 275 | QWidget *control = new QWidget( mainWidget, tr("Charts") ); |
269 | 276 | ||
270 | QGridLayout *layout = new QGridLayout( control ); | 277 | QGridLayout *layout = new QGridLayout( control ); |
271 | layout->setSpacing( 2 ); | 278 | layout->setSpacing( 2 ); |
272 | layout->setMargin( 4 ); | 279 | layout->setMargin( 4 ); |
@@ -307,124 +314,126 @@ void Checkbook::loadCheckbook() | |||
307 | int i = typeList->count(); | 314 | int i = typeList->count(); |
308 | while ( i > 0 ) | 315 | while ( i > 0 ) |
309 | { | 316 | { |
310 | i--; | 317 | i--; |
311 | typeList->setCurrentItem( i ); | 318 | typeList->setCurrentItem( i ); |
312 | if ( typeList->currentText() == temptext ) | 319 | if ( typeList->currentText() == temptext ) |
313 | { | 320 | { |
314 | break; | 321 | break; |
315 | } | 322 | } |
316 | } | 323 | } |
317 | if( i<=0 ) { | 324 | if( i<=0 ) { |
318 | typeList->insertItem( temptext, 0 ); | 325 | typeList->insertItem( temptext, 0 ); |
319 | typeList->setCurrentItem(0); | 326 | typeList->setCurrentItem(0); |
320 | } | 327 | } |
321 | bankEdit->setText( info->bank() ); | 328 | bankEdit->setText( info->bank() ); |
322 | acctNumEdit->setText( info->account() ); | 329 | acctNumEdit->setText( info->account() ); |
323 | pinNumEdit->setText( info->pin() ); | 330 | pinNumEdit->setText( info->pin() ); |
324 | temptext.setNum( info->startingBalance(), 'f', 2 ); | 331 | temptext.setNum( info->startingBalance(), 'f', 2 ); |
325 | balanceEdit->setText( temptext ); | 332 | balanceEdit->setText( temptext ); |
326 | notesEdit->setText( info->notes() ); | 333 | notesEdit->setText( info->notes() ); |
327 | 334 | ||
328 | // Load transactions | 335 | // Load transactions |
329 | float amount; | 336 | float amount; |
330 | QString stramount; | 337 | QString stramount; |
331 | for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() ) | 338 | for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() ) |
332 | { | 339 | { |
333 | amount = tran->amount(); | 340 | amount = tran->amount(); |
334 | if ( tran->withdrawal() ) | 341 | if ( tran->withdrawal() ) |
335 | { | 342 | { |
336 | amount *= -1; | 343 | amount *= -1; |
337 | } | 344 | } |
338 | stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); | 345 | stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); |
339 | ( void ) new CBListItem( tran, tranTable, tran->getIdStr(), tran->number(), tran->datestr(), tran->desc(), stramount ); | 346 | ( void ) new CBListItem( tran, tranTable, tran->getIdStr(), tran->datestr(false), tran->number(), tran->datestr(true), tran->desc(), stramount ); |
340 | } | 347 | } |
341 | 348 | ||
342 | // set sort order | 349 | // set sort order |
343 | bool bOk=false; | 350 | bool bOk=false; |
344 | for(int i=0; i<_cbSortType->count(); i++) { | 351 | for(int i=0; i<_cbSortType->count(); i++) { |
345 | if( _cbSortType->text(i)==info->getSortOrder() ) { | 352 | if( _cbSortType->text(i)==info->getSortOrder() ) { |
346 | _cbSortType->setCurrentItem(i); | 353 | _cbSortType->setCurrentItem(i); |
347 | slotSortChanged( info->getSortOrder() ); | 354 | slotSortChanged( info->getSortOrder() ); |
348 | bOk=true; | 355 | bOk=true; |
349 | break; | 356 | break; |
350 | } | 357 | } |
351 | } | 358 | } |
352 | if( !bOk ) { | 359 | if( !bOk ) { |
353 | _cbSortType->setCurrentItem(0); | 360 | _cbSortType->setCurrentItem(0); |
354 | slotSortChanged( _cbSortType->currentText() ); | 361 | slotSortChanged( _cbSortType->currentText() ); |
355 | } | 362 | } |
356 | 363 | ||
357 | // calc running balance | 364 | // calc running balance |
358 | adjustBalance(); | 365 | adjustBalance(); |
359 | } | 366 | } |
360 | 367 | ||
368 | |||
361 | // --- adjustBalance ---------------------------------------------------------- | 369 | // --- adjustBalance ---------------------------------------------------------- |
362 | void Checkbook::adjustBalance() | 370 | void Checkbook::adjustBalance() |
363 | { | 371 | { |
364 | // update running balance in register | 372 | // update running balance in register |
365 | QString sRunning; | 373 | QString sRunning; |
366 | float bal=info->startingBalance(); | 374 | float bal=info->startingBalance(); |
367 | for(CBListItem *item=(CBListItem *)tranTable->firstChild(); item; item=(CBListItem *)item->nextSibling() ) { | 375 | for(CBListItem *item=(CBListItem *)tranTable->firstChild(); item; item=(CBListItem *)item->nextSibling() ) { |
368 | TranInfo *tran=item->getTranInfo(); | 376 | TranInfo *tran=item->getTranInfo(); |
369 | bal=bal + (tran->withdrawal() ? -1 : 1)*tran->amount() - tran->fee(); | 377 | bal=bal + (tran->withdrawal() ? -1 : 1)*tran->amount() - tran->fee(); |
370 | sRunning.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), bal ); | 378 | sRunning.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), bal ); |
371 | item->setText( COL_BAL, sRunning); | 379 | item->setText( COL_BAL, sRunning); |
372 | } | 380 | } |
373 | } | 381 | } |
374 | 382 | ||
375 | // --- resort ----------------------------------------------------------------- | 383 | // --- resort ----------------------------------------------------------------- |
376 | void Checkbook::resort() | 384 | void Checkbook::resort() |
377 | { | 385 | { |
378 | tranTable->setSorting(_sortCol); | 386 | tranTable->setSorting(_sortCol); |
379 | tranTable->sort(); | 387 | tranTable->sort(); |
380 | tranTable->setSorting(-1); | 388 | tranTable->setSorting(-1); |
381 | } | 389 | } |
382 | 390 | ||
383 | 391 | ||
384 | // --- accept ----------------------------------------------------------------- | 392 | // --- accept ----------------------------------------------------------------- |
385 | void Checkbook::accept() | 393 | void Checkbook::accept() |
386 | { | 394 | { |
387 | info->setName( nameEdit->text() ); | 395 | info->setName( nameEdit->text() ); |
388 | info->setType( typeList->currentText() ); | 396 | info->setType( typeList->currentText() ); |
389 | info->setBank( bankEdit->text() ); | 397 | info->setBank( bankEdit->text() ); |
390 | info->setAccount( acctNumEdit->text() ); | 398 | info->setAccount( acctNumEdit->text() ); |
391 | info->setPin( pinNumEdit->text() ); | 399 | info->setPin( pinNumEdit->text() ); |
392 | bool ok; | 400 | bool ok; |
393 | info->setStartingBalance( balanceEdit->text().toFloat( &ok ) ); | 401 | info->setStartingBalance( balanceEdit->text().toFloat( &ok ) ); |
394 | info->setNotes( notesEdit->text() ); | 402 | info->setNotes( notesEdit->text() ); |
395 | 403 | ||
396 | QDialog::accept(); | 404 | QDialog::accept(); |
397 | } | 405 | } |
398 | 406 | ||
407 | // --- slotPasswordClicked ---------------------------------------------------- | ||
399 | void Checkbook::slotPasswordClicked() | 408 | void Checkbook::slotPasswordClicked() |
400 | { | 409 | { |
401 | if ( info->password().isNull() && passwordCB->isChecked() ) | 410 | if ( info->password().isNull() && passwordCB->isChecked() ) |
402 | { | 411 | { |
403 | Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); | 412 | Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); |
404 | if ( pw->exec() != QDialog::Accepted ) | 413 | if ( pw->exec() != QDialog::Accepted ) |
405 | { | 414 | { |
406 | passwordCB->setChecked( FALSE ); | 415 | passwordCB->setChecked( FALSE ); |
407 | delete pw; | 416 | delete pw; |
408 | return; | 417 | return; |
409 | } | 418 | } |
410 | info->setPassword( pw->password ); | 419 | info->setPassword( pw->password ); |
411 | delete pw; | 420 | delete pw; |
412 | 421 | ||
413 | pw = new Password( this, tr( "Confirm password" ), tr( "Please confirm your password:" ) ); | 422 | pw = new Password( this, tr( "Confirm password" ), tr( "Please confirm your password:" ) ); |
414 | if ( pw->exec() != QDialog::Accepted || pw->password != info->password() ) | 423 | if ( pw->exec() != QDialog::Accepted || pw->password != info->password() ) |
415 | { | 424 | { |
416 | passwordCB->setChecked( FALSE ); | 425 | passwordCB->setChecked( FALSE ); |
417 | info->setPassword( QString::null ); | 426 | info->setPassword( QString::null ); |
418 | } | 427 | } |
419 | 428 | ||
420 | delete pw; | 429 | delete pw; |
421 | } | 430 | } |
422 | else if ( !info->password().isNull() && !passwordCB->isChecked() ) | 431 | else if ( !info->password().isNull() && !passwordCB->isChecked() ) |
423 | { | 432 | { |
424 | Password *pw = new Password( this, tr( "Enter password" ), | 433 | Password *pw = new Password( this, tr( "Enter password" ), |
425 | tr( "Please enter your password to confirm removal of password protection:" ) ); | 434 | tr( "Please enter your password to confirm removal of password protection:" ) ); |
426 | if ( pw->exec() == QDialog::Accepted && pw->password == info->password() ) | 435 | if ( pw->exec() == QDialog::Accepted && pw->password == info->password() ) |
427 | { | 436 | { |
428 | info->setPassword( QString::null ); | 437 | info->setPassword( QString::null ); |
429 | delete pw; | 438 | delete pw; |
430 | return; | 439 | return; |
@@ -435,192 +444,240 @@ void Checkbook::slotPasswordClicked() | |||
435 | } | 444 | } |
436 | 445 | ||
437 | delete pw; | 446 | delete pw; |
438 | } | 447 | } |
439 | } | 448 | } |
440 | 449 | ||
441 | void Checkbook::slotNameChanged( const QString &newname ) | 450 | void Checkbook::slotNameChanged( const QString &newname ) |
442 | { | 451 | { |
443 | info->setName( newname ); | 452 | info->setName( newname ); |
444 | 453 | ||
445 | // TODO - need filedir | 454 | // TODO - need filedir |
446 | //QString namestr = filedir; | 455 | //QString namestr = filedir; |
447 | //namestr.append( newname ); | 456 | //namestr.append( newname ); |
448 | //namestr.append( ".qcb" ); | 457 | //namestr.append( ".qcb" ); |
449 | //info->setFilename( namestr ); | 458 | //info->setFilename( namestr ); |
450 | 459 | ||
451 | QString namestr = newname; | 460 | QString namestr = newname; |
452 | namestr.append( " - " ); | 461 | namestr.append( " - " ); |
453 | namestr.append( tr( "Checkbook" ) ); | 462 | namestr.append( tr( "Checkbook" ) ); |
454 | setCaption( namestr ); | 463 | setCaption( namestr ); |
455 | } | 464 | } |
456 | 465 | ||
457 | 466 | ||
458 | // ---slotStartingBalanceChanged ---------------------------------------------- | 467 | // ---slotStartingBalanceChanged ---------------------------------------------- |
459 | void Checkbook::slotStartingBalanceChanged( const QString &newbalance ) | 468 | void Checkbook::slotStartingBalanceChanged( const QString &newbalance ) |
460 | { | 469 | { |
461 | bool ok; | 470 | bool ok; |
462 | info->setStartingBalance( newbalance.toFloat( &ok ) ); | 471 | info->setStartingBalance( newbalance.toFloat( &ok ) ); |
463 | adjustBalance(); | 472 | adjustBalance(); |
464 | } | 473 | } |
465 | 474 | ||
466 | 475 | ||
476 | // --- slotNewTran ------------------------------------------------------------ | ||
467 | void Checkbook::slotNewTran() | 477 | void Checkbook::slotNewTran() |
468 | { | 478 | { |
469 | TranInfo *traninfo = new TranInfo( info->getNextNumber() ); | 479 | TranInfo *traninfo = new TranInfo( info->getNextNumber() ); |
470 | if( !_dLastNew.isNull() ) | 480 | if( !_dLastNew.isNull() ) |
471 | traninfo->setDate(_dLastNew); | 481 | traninfo->setDate(_dLastNew); |
472 | 482 | ||
473 | Transaction *currtran = new Transaction( this, info->name(), | 483 | Transaction *currtran = new Transaction( this, true, info->name(), |
474 | traninfo, | 484 | traninfo, |
475 | _pCfg ); | 485 | _pCfg ); |
476 | currtran->showMaximized(); | 486 | currtran->showMaximized(); |
477 | if ( currtran->exec() == QDialog::Accepted ) | 487 | if ( currtran->exec() == QDialog::Accepted ) |
478 | { | 488 | { |
479 | // Add to transaction list | 489 | // Add to transaction list |
480 | info->addTransaction( traninfo ); | 490 | info->addTransaction( traninfo ); |
481 | 491 | ||
482 | // Add to transaction table | 492 | // Add to transaction table |
483 | float amount; | 493 | float amount; |
484 | QString stramount; | 494 | QString stramount; |
485 | amount = (traninfo->withdrawal() ? -1 : 1)*traninfo->amount(); | 495 | amount = (traninfo->withdrawal() ? -1 : 1)*traninfo->amount(); |
486 | stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); | 496 | stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); |
487 | ( void ) new CBListItem( traninfo, tranTable, traninfo->getIdStr(), | 497 | ( void ) new CBListItem( traninfo, tranTable, traninfo->getIdStr(), traninfo->datestr(false), |
488 | traninfo->number(), traninfo->datestr(), traninfo->desc(), | 498 | traninfo->number(), traninfo->datestr(true), traninfo->desc(), |
489 | stramount ); | 499 | stramount ); |
490 | resort(); | 500 | resort(); |
491 | adjustBalance(); | 501 | adjustBalance(); |
492 | 502 | ||
493 | // save last date | 503 | // save last date |
494 | _dLastNew = traninfo->date(); | 504 | _dLastNew = traninfo->date(); |
505 | |||
506 | // save description in list of payees, if not in there | ||
507 | QStringList *pLst=&_pCfg->getPayees(); | ||
508 | if( _pCfg->getSavePayees() && pLst->contains(traninfo->desc())==0 ) { | ||
509 | pLst->append( traninfo->desc() ); | ||
510 | pLst->sort(); | ||
511 | _pCfg->setDirty(true); | ||
512 | } | ||
495 | } | 513 | } |
496 | else | 514 | else |
497 | { | 515 | { |
498 | delete traninfo; | 516 | delete traninfo; |
499 | } | 517 | } |
500 | } | 518 | } |
501 | 519 | ||
520 | |||
521 | // --- slotEditTran ----------------------------------------------------------- | ||
502 | void Checkbook::slotEditTran() | 522 | void Checkbook::slotEditTran() |
503 | { | 523 | { |
504 | QListViewItem *curritem = tranTable->currentItem(); | 524 | QListViewItem *curritem = tranTable->currentItem(); |
505 | if ( !curritem ) | 525 | if ( !curritem ) |
506 | return; | 526 | return; |
507 | 527 | ||
508 | TranInfo *traninfo=info->findTransaction( curritem->text(COL_ID) ); | 528 | TranInfo *traninfo=info->findTransaction( curritem->text(COL_ID) ); |
509 | 529 | ||
510 | Transaction *currtran = new Transaction( this, info->name(), | 530 | Transaction *currtran = new Transaction( this, false, info->name(), |
511 | traninfo, | 531 | traninfo, |
512 | _pCfg ); | 532 | _pCfg ); |
513 | currtran->showMaximized(); | 533 | currtran->showMaximized(); |
514 | if ( currtran->exec() == QDialog::Accepted ) | 534 | if ( currtran->exec() == QDialog::Accepted ) |
515 | { | 535 | { |
516 | curritem->setText( COL_NUM, traninfo->number() ); | 536 | curritem->setText( COL_NUM, traninfo->number() ); |
517 | curritem->setText( COL_DATE, traninfo->datestr() ); | 537 | curritem->setText( COL_SORTDATE, traninfo->datestr(false) ); |
538 | curritem->setText( COL_DATE, traninfo->datestr(true) ); | ||
518 | curritem->setText( COL_DESC, traninfo->desc() ); | 539 | curritem->setText( COL_DESC, traninfo->desc() ); |
519 | 540 | ||
520 | float amount = traninfo->amount(); | 541 | float amount = traninfo->amount(); |
521 | if ( traninfo->withdrawal() ) | 542 | if ( traninfo->withdrawal() ) |
522 | { | 543 | { |
523 | amount *= -1; | 544 | amount *= -1; |
524 | } | 545 | } |
525 | QString stramount; | 546 | QString stramount; |
526 | stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); | 547 | stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); |
527 | curritem->setText( COL_AMOUNT, stramount ); | 548 | curritem->setText( COL_AMOUNT, stramount ); |
528 | resort(); | 549 | resort(); |
529 | adjustBalance(); | 550 | adjustBalance(); |
551 | |||
552 | // save description in list of payees, if not in there | ||
553 | QStringList *pLst=&_pCfg->getPayees(); | ||
554 | if( _pCfg->getSavePayees() && pLst->contains(traninfo->desc())==0 ) { | ||
555 | pLst->append( traninfo->desc() ); | ||
556 | pLst->sort(); | ||
557 | _pCfg->setDirty(true); | ||
558 | } | ||
530 | } | 559 | } |
531 | 560 | ||
532 | delete currtran; | 561 | delete currtran; |
533 | } | 562 | } |
534 | 563 | ||
564 | // --- slotMenuTran ----------------------------------------------------------- | ||
565 | void Checkbook::slotMenuTran(QListViewItem *item, const QPoint &pnt) | ||
566 | { | ||
567 | // active item? | ||
568 | if( !item ) | ||
569 | return; | ||
570 | |||
571 | // Display menu | ||
572 | QPopupMenu m; | ||
573 | m.insertItem( QWidget::tr( "Edit" ), 1 ); | ||
574 | m.insertItem( QWidget::tr( "New" ), 2 ); | ||
575 | m.insertItem( QWidget::tr( "Delete" ), 3 ); | ||
576 | int r = m.exec( pnt ); | ||
577 | switch(r) { | ||
578 | case 1: | ||
579 | slotEditTran(); | ||
580 | break; | ||
581 | case 2: | ||
582 | slotNewTran(); | ||
583 | break; | ||
584 | case 3: | ||
585 | slotDeleteTran(); | ||
586 | break; | ||
587 | } | ||
588 | } | ||
589 | |||
590 | |||
591 | // --- slotDeleteTran --------------------------------------------------------- | ||
535 | void Checkbook::slotDeleteTran() | 592 | void Checkbook::slotDeleteTran() |
536 | { | 593 | { |
537 | QListViewItem *curritem = tranTable->currentItem(); | 594 | QListViewItem *curritem = tranTable->currentItem(); |
538 | if ( !curritem ) | 595 | if ( !curritem ) |
539 | return; | 596 | return; |
540 | 597 | ||
541 | TranInfo *traninfo = info->findTransaction( curritem->text(COL_ID) ); | 598 | TranInfo *traninfo = info->findTransaction( curritem->text(COL_ID) ); |
542 | 599 | ||
543 | if ( QPEMessageBox::confirmDelete ( this, tr( "Delete transaction" ), traninfo->desc() ) ) | 600 | if ( QPEMessageBox::confirmDelete ( this, tr( "Delete transaction" ), traninfo->desc() ) ) |
544 | { | 601 | { |
545 | info->removeTransaction( traninfo ); | 602 | info->removeTransaction( traninfo ); |
546 | delete curritem; | 603 | delete curritem; |
547 | adjustBalance(); | 604 | adjustBalance(); |
548 | } | 605 | } |
549 | } | 606 | } |
550 | 607 | ||
551 | void Checkbook::slotDrawGraph() | 608 | void Checkbook::slotDrawGraph() |
552 | { | 609 | { |
553 | if ( graphInfo ) | 610 | if ( graphInfo ) |
554 | { | 611 | { |
555 | delete graphInfo; | 612 | delete graphInfo; |
556 | } | 613 | } |
557 | 614 | ||
558 | switch ( graphList->currentItem() ) | 615 | switch ( graphList->currentItem() ) |
559 | { | 616 | { |
560 | case 0 : drawBalanceChart(); | 617 | case 0 : drawBalanceChart(); |
561 | break; | 618 | break; |
562 | case 1 : drawCategoryChart( TRUE ); | 619 | case 1 : drawCategoryChart( TRUE ); |
563 | break; | 620 | break; |
564 | case 2 : drawCategoryChart( FALSE ); | 621 | case 2 : drawCategoryChart( FALSE ); |
565 | break; | 622 | break; |
566 | }; | 623 | }; |
567 | 624 | ||
568 | graphWidget->setGraphInfo( graphInfo ); | 625 | graphWidget->setGraphInfo( graphInfo ); |
569 | graphWidget->drawGraph( TRUE ); | 626 | graphWidget->drawGraph( TRUE ); |
570 | } | 627 | } |
571 | 628 | ||
572 | void Checkbook::drawBalanceChart() | 629 | void Checkbook::drawBalanceChart() |
573 | { | 630 | { |
574 | DataPointList *list = new DataPointList(); | 631 | DataPointList *list = new DataPointList(); |
575 | 632 | ||
576 | float balance = info->startingBalance(); | 633 | float balance = info->startingBalance(); |
577 | float amount; | 634 | float amount; |
578 | QString label; | 635 | QString label; |
579 | int i = 0; | 636 | int i = 0; |
580 | int count = tranList->count(); | 637 | int count = tranList->count(); |
581 | 638 | ||
582 | for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() ) | 639 | for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() ) |
583 | { | 640 | { |
584 | i++; | 641 | i++; |
585 | balance -= tran->fee(); | 642 | balance -= tran->fee(); |
586 | amount = tran->amount(); | 643 | amount = tran->amount(); |
587 | if ( tran->withdrawal() ) | 644 | if ( tran->withdrawal() ) |
588 | { | 645 | { |
589 | amount *= -1; | 646 | amount *= -1; |
590 | } | 647 | } |
591 | balance += amount; | 648 | balance += amount; |
592 | if ( i == 1 || i == count / 2 || i == count ) | 649 | if ( i == 1 || i == count / 2 || i == count ) |
593 | { | 650 | { |
594 | label = tran->datestr(); | 651 | label = tran->datestr(true); |
595 | } | 652 | } |
596 | else | 653 | else |
597 | { | 654 | { |
598 | label = ""; | 655 | label = ""; |
599 | } | 656 | } |
600 | list->append( new DataPointInfo( label, balance ) ); | 657 | list->append( new DataPointInfo( label, balance ) ); |
601 | } | 658 | } |
602 | 659 | ||
603 | graphInfo = new GraphInfo( GraphInfo::BarChart, list ); | 660 | graphInfo = new GraphInfo( GraphInfo::BarChart, list ); |
604 | } | 661 | } |
605 | 662 | ||
606 | void Checkbook::drawCategoryChart( bool withdrawals ) | 663 | void Checkbook::drawCategoryChart( bool withdrawals ) |
607 | { | 664 | { |
608 | DataPointList *list = new DataPointList(); | 665 | DataPointList *list = new DataPointList(); |
609 | 666 | ||
610 | TranInfo *tran = tranList->first(); | 667 | TranInfo *tran = tranList->first(); |
611 | if ( tran && tran->withdrawal() == withdrawals ) | 668 | if ( tran && tran->withdrawal() == withdrawals ) |
612 | { | 669 | { |
613 | list->append( new DataPointInfo( tran->category(), tran->amount() ) ); | 670 | list->append( new DataPointInfo( tran->category(), tran->amount() ) ); |
614 | } | 671 | } |
615 | tran = tranList->next(); | 672 | tran = tranList->next(); |
616 | 673 | ||
617 | DataPointInfo *cat; | 674 | DataPointInfo *cat; |
618 | for ( ; tran; tran = tranList->next() ) | 675 | for ( ; tran; tran = tranList->next() ) |
619 | { | 676 | { |
620 | if ( tran->withdrawal() == withdrawals ) | 677 | if ( tran->withdrawal() == withdrawals ) |
621 | { | 678 | { |
622 | // Find category in list | 679 | // Find category in list |
623 | for ( cat = list->first(); cat; cat = list->next() ) | 680 | for ( cat = list->first(); cat; cat = list->next() ) |
624 | { | 681 | { |
625 | if ( cat->label() == tran->category() ) | 682 | if ( cat->label() == tran->category() ) |
626 | { | 683 | { |
@@ -637,94 +694,96 @@ void Checkbook::drawCategoryChart( bool withdrawals ) | |||
637 | } | 694 | } |
638 | } | 695 | } |
639 | } | 696 | } |
640 | 697 | ||
641 | graphInfo = new GraphInfo( GraphInfo::PieChart, list ); | 698 | graphInfo = new GraphInfo( GraphInfo::PieChart, list ); |
642 | } | 699 | } |
643 | 700 | ||
644 | CBListItem::CBListItem( TranInfo *pTran, QListView *parent, QString label1, QString label2, | 701 | CBListItem::CBListItem( TranInfo *pTran, QListView *parent, QString label1, QString label2, |
645 | QString label3, QString label4, QString label5, QString label6, QString label7, | 702 | QString label3, QString label4, QString label5, QString label6, QString label7, |
646 | QString label8 ) | 703 | QString label8 ) |
647 | : QListViewItem( parent, label1, label2, label3, label4, label5, label6, label7, label8 ) | 704 | : QListViewItem( parent, label1, label2, label3, label4, label5, label6, label7, label8 ) |
648 | { | 705 | { |
649 | _pTran=pTran; | 706 | _pTran=pTran; |
650 | m_known = FALSE; | 707 | m_known = FALSE; |
651 | owner = parent; | 708 | owner = parent; |
652 | } | 709 | } |
653 | 710 | ||
654 | void CBListItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align ) | 711 | void CBListItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align ) |
655 | { | 712 | { |
656 | QColorGroup _cg = cg; | 713 | QColorGroup _cg = cg; |
657 | const QPixmap *pm = listView()->viewport()->backgroundPixmap(); | 714 | const QPixmap *pm = listView()->viewport()->backgroundPixmap(); |
658 | if ( pm && !pm->isNull() ) | 715 | if ( pm && !pm->isNull() ) |
659 | { | 716 | { |
660 | _cg.setBrush( QColorGroup::Base, QBrush( cg.base(), *pm ) ); | 717 | _cg.setBrush( QColorGroup::Base, QBrush( cg.base(), *pm ) ); |
661 | p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); | 718 | p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); |
662 | } | 719 | } |
663 | else if ( isAltBackground() ) | 720 | else if ( isAltBackground() ) |
664 | _cg.setColor(QColorGroup::Base, cg.background() ); | 721 | _cg.setColor(QColorGroup::Base, cg.background() ); |
665 | 722 | ||
666 | QListViewItem::paintCell(p, _cg, column, width, align); | 723 | QListViewItem::paintCell(p, _cg, column, width, align); |
667 | } | 724 | } |
668 | 725 | ||
726 | // --- CBListItem::isAltBackground -------------------------------------------- | ||
669 | bool CBListItem::isAltBackground() | 727 | bool CBListItem::isAltBackground() |
670 | { | 728 | { |
671 | QListView *lv = static_cast<QListView *>( listView() ); | 729 | QListView *lv = static_cast<QListView *>( listView() ); |
672 | if ( lv ) | 730 | if ( lv ) |
673 | { | 731 | { |
674 | CBListItem *above = 0; | 732 | CBListItem *above = 0; |
675 | above = (CBListItem *)( itemAbove() ); | 733 | above = (CBListItem *)( itemAbove() ); |
676 | m_known = above ? above->m_known : true; | 734 | m_known = above ? above->m_known : true; |
677 | if ( m_known ) | 735 | if ( m_known ) |
678 | { | 736 | { |
679 | m_odd = above ? !above->m_odd : false; | 737 | m_odd = above ? !above->m_odd : false; |
680 | } | 738 | } |
681 | else | 739 | else |
682 | { | 740 | { |
683 | CBListItem *item; | 741 | CBListItem *item; |
684 | bool previous = true; | 742 | bool previous = true; |
685 | if ( parent() ) | 743 | if ( parent() ) |
686 | { | 744 | { |
687 | item = (CBListItem *)( parent() ); | 745 | item = (CBListItem *)( parent() ); |
688 | if ( item ) | 746 | if ( item ) |
689 | previous = item->m_odd; | 747 | previous = item->m_odd; |
690 | item = (CBListItem *)( parent()->firstChild() ); | 748 | item = (CBListItem *)( parent()->firstChild() ); |
691 | } | 749 | } |
692 | else | 750 | else |
693 | { | 751 | { |
694 | item = (CBListItem *)( lv->firstChild() ); | 752 | item = (CBListItem *)( lv->firstChild() ); |
695 | } | 753 | } |
696 | 754 | ||
697 | while(item) | 755 | while(item) |
698 | { | 756 | { |
699 | item->m_odd = previous = !previous; | 757 | item->m_odd = previous = !previous; |
700 | item->m_known = true; | 758 | item->m_known = true; |
701 | item = (CBListItem *)( item->nextSibling() ); | 759 | item = (CBListItem *)( item->nextSibling() ); |
702 | } | 760 | } |
703 | } | 761 | } |
704 | return m_odd; | 762 | return m_odd; |
705 | } | 763 | } |
706 | return false; | 764 | return false; |
707 | } | 765 | } |
708 | 766 | ||
709 | 767 | ||
710 | // --- slotTab ---------------------------------------------------------------- | 768 | // --- slotTab ---------------------------------------------------------------- |
711 | void Checkbook::slotTab(QWidget *tab) | 769 | void Checkbook::slotTab(QWidget *tab) |
712 | { | 770 | { |
713 | if( !tab || !info ) return; | 771 | if( !tab || !info ) return; |
714 | info->setLastTab( tab->name() ); | 772 | info->setLastTab( tab->name() ); |
715 | } | 773 | } |
716 | 774 | ||
717 | 775 | ||
718 | // --- slotSortChanged --------------------------------------------------------- | 776 | // --- slotSortChanged --------------------------------------------------------- |
719 | void Checkbook::slotSortChanged( const QString &selc ) | 777 | void Checkbook::slotSortChanged( const QString &selc ) |
720 | { | 778 | { |
721 | if( selc==tr("Entry Order") ) { | 779 | if( selc==tr("Entry Order") ) { |
722 | _sortCol=COL_ID; | 780 | _sortCol=COL_ID; |
723 | } else if( selc==tr("Number") ) { | 781 | } else if( selc==tr("Number") ) { |
724 | _sortCol=COL_NUM; | 782 | _sortCol=COL_NUM; |
725 | } else if( selc==tr("Date") ) { | 783 | } else if( selc==tr("Date") ) { |
726 | _sortCol=COL_DATE; | 784 | _sortCol=COL_SORTDATE; |
727 | } | 785 | } |
728 | info->setSortOrder( selc ); | 786 | info->setSortOrder( selc ); |
729 | resort(); | 787 | resort(); |
730 | } | 788 | } |
789 | |||
diff --git a/noncore/apps/checkbook/checkbook.h b/noncore/apps/checkbook/checkbook.h index 1b6a2d3..e18f00c 100644 --- a/noncore/apps/checkbook/checkbook.h +++ b/noncore/apps/checkbook/checkbook.h | |||
@@ -19,124 +19,130 @@ | |||
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 CHECKBOOK_H | 29 | #ifndef CHECKBOOK_H |
30 | #define CHECKBOOK_H | 30 | #define CHECKBOOK_H |
31 | 31 | ||
32 | #include <qdatetime.h> | 32 | #include <qdatetime.h> |
33 | #include <qdialog.h> | 33 | #include <qdialog.h> |
34 | #include <qlistview.h> | 34 | #include <qlistview.h> |
35 | 35 | ||
36 | class OTabWidget; | 36 | class OTabWidget; |
37 | 37 | ||
38 | class CBInfo; | 38 | class CBInfo; |
39 | class Graph; | 39 | class Graph; |
40 | class GraphInfo; | 40 | class GraphInfo; |
41 | class QCheckBox; | 41 | class QCheckBox; |
42 | class QComboBox; | 42 | class QComboBox; |
43 | class QLabel; | 43 | class QLabel; |
44 | class QLineEdit; | 44 | class QLineEdit; |
45 | class QListView; | 45 | class QListView; |
46 | class QMultiLineEdit; | 46 | class QMultiLineEdit; |
47 | class QString; | 47 | class QString; |
48 | class TranInfo; | 48 | class TranInfo; |
49 | class TranInfoList; | 49 | class TranInfoList; |
50 | class Cfg; | 50 | class Cfg; |
51 | class QMouseEvent; | ||
51 | 52 | ||
52 | 53 | ||
53 | // --- Checkbook -------------------------------------------------------------- | 54 | // --- Checkbook -------------------------------------------------------------- |
54 | class Checkbook : public QDialog | 55 | class Checkbook : public QDialog |
55 | { | 56 | { |
56 | Q_OBJECT | 57 | Q_OBJECT |
57 | 58 | ||
58 | public: | 59 | public: |
59 | Checkbook( QWidget *, CBInfo *, Cfg *cfg ); | 60 | Checkbook( QWidget *, CBInfo *, Cfg *cfg ); |
60 | ~Checkbook(); | 61 | ~Checkbook(); |
61 | 62 | ||
62 | // resort | 63 | // resort |
63 | void resort(); | 64 | void resort(); |
64 | 65 | ||
66 | // members | ||
67 | TranInfoList *getTranList() { return(tranList); } | ||
68 | |||
65 | private: | 69 | private: |
66 | CBInfo *info; | 70 | CBInfo *info; |
67 | TranInfoList *tranList; | 71 | TranInfoList *tranList; |
68 | Cfg *_pCfg; | 72 | Cfg *_pCfg; |
69 | 73 | ||
70 | OTabWidget *mainWidget; | 74 | OTabWidget *mainWidget; |
71 | void loadCheckbook(); | 75 | void loadCheckbook(); |
72 | void adjustBalance(); | 76 | void adjustBalance(); |
73 | 77 | ||
74 | // Info tab | 78 | // Info tab |
75 | QWidget *initInfo(); | 79 | QWidget *initInfo(); |
76 | QCheckBox *passwordCB; | 80 | QCheckBox *passwordCB; |
77 | QLineEdit *nameEdit; | 81 | QLineEdit *nameEdit; |
78 | QComboBox *typeList; | 82 | QComboBox *typeList; |
79 | QLineEdit *bankEdit; | 83 | QLineEdit *bankEdit; |
80 | QLineEdit *acctNumEdit; | 84 | QLineEdit *acctNumEdit; |
81 | QLineEdit *pinNumEdit; | 85 | QLineEdit *pinNumEdit; |
82 | QLineEdit *balanceEdit; | 86 | QLineEdit *balanceEdit; |
83 | QMultiLineEdit *notesEdit; | 87 | QMultiLineEdit *notesEdit; |
84 | int _sortCol; | 88 | int _sortCol; |
85 | 89 | ||
86 | // Transactions tab | 90 | // Transactions tab |
87 | QWidget *initTransactions(); | 91 | QWidget *initTransactions(); |
88 | QListView *tranTable; | 92 | QListView *tranTable; |
89 | QComboBox *_cbSortType; | 93 | QComboBox *_cbSortType; |
90 | QDate _dLastNew; | 94 | QDate _dLastNew; |
91 | 95 | ||
92 | // Charts tab | 96 | // Charts tab |
93 | QWidget *initCharts(); | 97 | QWidget *initCharts(); |
94 | GraphInfo *graphInfo; | 98 | GraphInfo *graphInfo; |
95 | QComboBox *graphList; | 99 | QComboBox *graphList; |
96 | Graph *graphWidget; | 100 | Graph *graphWidget; |
97 | 101 | ||
98 | void drawBalanceChart(); | 102 | void drawBalanceChart(); |
99 | void drawCategoryChart( bool = TRUE ); | 103 | void drawCategoryChart( bool = TRUE ); |
100 | 104 | ||
101 | 105 | ||
102 | protected slots: | 106 | protected slots: |
103 | void accept(); | 107 | void accept(); |
104 | void slotTab(QWidget *tab); | 108 | void slotTab(QWidget *tab); |
105 | 109 | ||
106 | private slots: | 110 | private slots: |
107 | void slotPasswordClicked(); | 111 | void slotPasswordClicked(); |
108 | void slotNameChanged( const QString & ); | 112 | void slotNameChanged( const QString & ); |
109 | void slotStartingBalanceChanged( const QString & ); | 113 | void slotStartingBalanceChanged( const QString & ); |
110 | void slotNewTran(); | 114 | void slotNewTran(); |
111 | void slotEditTran(); | 115 | void slotEditTran(); |
116 | void slotMenuTran(QListViewItem *, const QPoint &); | ||
112 | void slotDeleteTran(); | 117 | void slotDeleteTran(); |
113 | void slotDrawGraph(); | 118 | void slotDrawGraph(); |
114 | void slotSortChanged( const QString & ); | 119 | void slotSortChanged( const QString & ); |
115 | }; | 120 | }; |
116 | 121 | ||
122 | |||
117 | // --- CBListItem ------------------------------------------------------------- | 123 | // --- CBListItem ------------------------------------------------------------- |
118 | class CBListItem : public QListViewItem | 124 | class CBListItem : public QListViewItem |
119 | { | 125 | { |
120 | //Q_OBJECT | 126 | //Q_OBJECT |
121 | 127 | ||
122 | public: | 128 | public: |
123 | CBListItem( TranInfo *, QListView *, QString = QString::null, QString = QString::null, | 129 | CBListItem( TranInfo *, QListView *, QString = QString::null, QString = QString::null, |
124 | QString = QString::null, QString = QString::null, QString = QString::null, | 130 | QString = QString::null, QString = QString::null, QString = QString::null, |
125 | QString = QString::null, QString = QString::null, QString = QString::null ); | 131 | QString = QString::null, QString = QString::null, QString = QString::null ); |
126 | 132 | ||
127 | void paintCell( QPainter *, const QColorGroup &, int, int, int ); | 133 | void paintCell( QPainter *, const QColorGroup &, int, int, int ); |
128 | 134 | ||
129 | // --- members | 135 | // --- members |
130 | TranInfo *getTranInfo() { return(_pTran); } | 136 | TranInfo *getTranInfo() { return(_pTran); } |
131 | 137 | ||
132 | private: | 138 | private: |
133 | TranInfo *_pTran; | 139 | TranInfo *_pTran; |
134 | QListView *owner; | 140 | QListView *owner; |
135 | bool m_known; | 141 | bool m_known; |
136 | bool m_odd; | 142 | bool m_odd; |
137 | 143 | ||
138 | bool isAltBackground(); | 144 | bool isAltBackground(); |
139 | }; | 145 | }; |
140 | 146 | ||
141 | 147 | ||
142 | #endif | 148 | #endif |
diff --git a/noncore/apps/checkbook/configuration.cpp b/noncore/apps/checkbook/configuration.cpp index 3f5662d..dfae446 100644 --- a/noncore/apps/checkbook/configuration.cpp +++ b/noncore/apps/checkbook/configuration.cpp | |||
@@ -47,115 +47,131 @@ Configuration::Configuration( QWidget *parent, Cfg &cfg ) | |||
47 | setCaption( tr( "Configure Checkbook" ) ); | 47 | setCaption( tr( "Configure Checkbook" ) ); |
48 | 48 | ||
49 | // Setup layout to make everything pretty | 49 | // Setup layout to make everything pretty |
50 | QVBoxLayout *layout = new QVBoxLayout( this ); | 50 | QVBoxLayout *layout = new QVBoxLayout( this ); |
51 | layout->setMargin( 2 ); | 51 | layout->setMargin( 2 ); |
52 | layout->setSpacing( 4 ); | 52 | layout->setSpacing( 4 ); |
53 | 53 | ||
54 | // Setup tabs for all info | 54 | // Setup tabs for all info |
55 | _mainWidget = new QTabWidget( this ); | 55 | _mainWidget = new QTabWidget( this ); |
56 | layout->addWidget( _mainWidget ); | 56 | layout->addWidget( _mainWidget ); |
57 | 57 | ||
58 | // Settings tab | 58 | // Settings tab |
59 | _mainWidget->addTab( initSettings(cfg), tr( "&Settings" ) ); | 59 | _mainWidget->addTab( initSettings(cfg), tr( "&Settings" ) ); |
60 | 60 | ||
61 | // Account Types tab | 61 | // Account Types tab |
62 | ColumnDef *d; | 62 | ColumnDef *d; |
63 | _listEditTypes=new ListEdit(_mainWidget, "TYPES" ); | 63 | _listEditTypes=new ListEdit(_mainWidget, "TYPES" ); |
64 | d=new ColumnDef( tr("Type"), (ColumnDef::ColumnType)(ColumnDef::typeString | ColumnDef::typeUnique), tr("New Account Type")); | 64 | d=new ColumnDef( tr("Type"), (ColumnDef::ColumnType)(ColumnDef::typeString | ColumnDef::typeUnique), tr("New Account Type")); |
65 | _listEditTypes->addColumnDef( d ); | 65 | _listEditTypes->addColumnDef( d ); |
66 | _listEditTypes->addData( cfg.getAccountTypes() ); | 66 | _listEditTypes->addData( cfg.getAccountTypes() ); |
67 | _mainWidget->addTab( _listEditTypes, tr( "&Account Types" ) ); | 67 | _mainWidget->addTab( _listEditTypes, tr( "&Account Types" ) ); |
68 | 68 | ||
69 | // Categories tab | 69 | // Categories tab |
70 | _listEditCategories=new ListEdit(_mainWidget, "CATEGORIES" ); | 70 | _listEditCategories=new ListEdit(_mainWidget, "CATEGORIES" ); |
71 | _listEditCategories->addColumnDef( new ColumnDef( tr("Category"), (ColumnDef::ColumnType)(ColumnDef::typeString | ColumnDef::typeUnique), tr("New Category")) ); | 71 | _listEditCategories->addColumnDef( new ColumnDef( tr("Category"), (ColumnDef::ColumnType)(ColumnDef::typeString | ColumnDef::typeUnique), tr("New Category")) ); |
72 | d=new ColumnDef( tr("Type"), ColumnDef::typeList, tr("Expense") ); | 72 | d=new ColumnDef( tr("Type"), ColumnDef::typeList, tr("Expense") ); |
73 | d->addColumnValue( tr("Expense") ); | 73 | d->addColumnValue( tr("Expense") ); |
74 | d->addColumnValue( tr("Income") ); | 74 | d->addColumnValue( tr("Income") ); |
75 | _listEditCategories->addColumnDef( d ); | 75 | _listEditCategories->addColumnDef( d ); |
76 | QStringList lst=cfg.getCategories(); | 76 | QStringList lst=cfg.getCategories(); |
77 | _listEditCategories->addData( lst ); | 77 | _listEditCategories->addData( lst ); |
78 | _mainWidget->addTab( _listEditCategories, tr( "&Categories" ) ); | 78 | _mainWidget->addTab( _listEditCategories, tr( "&Categories" ) ); |
79 | |||
80 | // Payees tab | ||
81 | _listEditPayees=new ListEdit(_mainWidget, "PAYEES"); | ||
82 | _listEditPayees->addColumnDef( new ColumnDef( tr("Payee"), (ColumnDef::ColumnType)(ColumnDef::typeString | ColumnDef::typeUnique), tr("New Payee")) ); | ||
83 | _listEditPayees->addData( cfg.getPayees() ); | ||
84 | _mainWidget->addTab( _listEditPayees, tr("&Payees") ); | ||
79 | } | 85 | } |
80 | 86 | ||
81 | Configuration::~Configuration() | 87 | Configuration::~Configuration() |
82 | { | 88 | { |
83 | } | 89 | } |
84 | 90 | ||
85 | // ---- initSettings ---------------------------------------------------------- | 91 | // ---- initSettings ---------------------------------------------------------- |
86 | QWidget *Configuration::initSettings(Cfg &cfg) | 92 | QWidget *Configuration::initSettings(Cfg &cfg) |
87 | { | 93 | { |
88 | QWidget *control = new QWidget( _mainWidget ); | 94 | QWidget *control = new QWidget( _mainWidget ); |
89 | 95 | ||
90 | QFontMetrics fm = fontMetrics(); | 96 | QFontMetrics fm = fontMetrics(); |
91 | int fh = fm.height(); | 97 | int fh = fm.height(); |
92 | 98 | ||
93 | QVBoxLayout *vb = new QVBoxLayout( control ); | 99 | QVBoxLayout *vb = new QVBoxLayout( control ); |
94 | 100 | ||
95 | QScrollView *sv = new QScrollView( control ); | 101 | QScrollView *sv = new QScrollView( control ); |
96 | vb->addWidget( sv, 0, 0 ); | 102 | vb->addWidget( sv, 0, 0 ); |
97 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 103 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
98 | sv->setFrameStyle( QFrame::NoFrame ); | 104 | sv->setFrameStyle( QFrame::NoFrame ); |
99 | 105 | ||
100 | QWidget *container = new QWidget( sv->viewport() ); | 106 | QWidget *container = new QWidget( sv->viewport() ); |
101 | sv->addChild( container ); | 107 | sv->addChild( container ); |
102 | 108 | ||
103 | QGridLayout *layout = new QGridLayout( container ); | 109 | QGridLayout *layout = new QGridLayout( container ); |
104 | layout->setSpacing( 4 ); | 110 | layout->setSpacing( 4 ); |
105 | layout->setMargin( 4 ); | 111 | layout->setMargin( 4 ); |
106 | 112 | ||
107 | QLabel *label = new QLabel( tr( "Enter currency symbol:" ), container ); | 113 | QLabel *label = new QLabel( tr( "Enter currency symbol:" ), container ); |
108 | QWhatsThis::add( label, tr( "Enter your local currency symbol here." ) ); | 114 | QWhatsThis::add( label, tr( "Enter your local currency symbol here." ) ); |
109 | label->setMaximumHeight( fh + 3 ); | 115 | label->setMaximumHeight( fh + 3 ); |
110 | layout->addWidget( label, 0, 0 ); | 116 | layout->addWidget( label, 0, 0 ); |
111 | 117 | ||
112 | symbolEdit = new QLineEdit( cfg.getCurrencySymbol(), container ); | 118 | symbolEdit = new QLineEdit( cfg.getCurrencySymbol(), container ); |
113 | QWhatsThis::add( symbolEdit, tr( "Enter your local currency symbol here." ) ); | 119 | QWhatsThis::add( symbolEdit, tr( "Enter your local currency symbol here." ) ); |
114 | symbolEdit->setMaximumHeight( fh + 5 ); | 120 | symbolEdit->setMaximumHeight( fh + 5 ); |
115 | symbolEdit->setFocus(); | 121 | symbolEdit->setFocus(); |
116 | layout->addWidget( symbolEdit, 0, 1 ); | 122 | layout->addWidget( symbolEdit, 0, 1 ); |
117 | 123 | ||
118 | lockCB = new QCheckBox( tr( "Show whether checkbook is password\nprotected" ), container ); | 124 | lockCB = new QCheckBox( tr( "Show whether checkbook is password\nprotected" ), container ); |
119 | QWhatsThis::add( lockCB, tr( "Click here to select whether or not the main window will display that the checkbook is protected with a password." ) ); | 125 | QWhatsThis::add( lockCB, tr( "Click here to select whether or not the main window will display that the checkbook is protected with a password." ) ); |
120 | lockCB->setChecked( cfg.getShowLocks() ); | 126 | lockCB->setChecked( cfg.getShowLocks() ); |
121 | layout->addMultiCellWidget( lockCB, 1, 1, 0, 1 ); | 127 | layout->addMultiCellWidget( lockCB, 1, 1, 0, 1 ); |
122 | 128 | ||
123 | balCB = new QCheckBox( tr( "Show checkbook balances" ), container ); | 129 | balCB = new QCheckBox( tr( "Show checkbook balances" ), container ); |
124 | QWhatsThis::add( balCB, tr( "Click here to select whether or not the main window will display the current balance for each checkbook." ) ); | 130 | QWhatsThis::add( balCB, tr( "Click here to select whether or not the main window will display the current balance for each checkbook." ) ); |
125 | balCB->setMaximumHeight( fh + 5 ); | 131 | balCB->setMaximumHeight( fh + 5 ); |
126 | balCB->setChecked( cfg.getShowBalances() ); | 132 | balCB->setChecked( cfg.getShowBalances() ); |
127 | layout->addMultiCellWidget( balCB, 2, 2, 0, 1 ); | 133 | layout->addMultiCellWidget( balCB, 2, 2, 0, 1 ); |
128 | 134 | ||
129 | openLastBookCB = new QCheckBox( tr("Open last checkbook" ), container ); | 135 | openLastBookCB = new QCheckBox( tr("Open last checkbook" ), container ); |
130 | QWhatsThis::add( openLastBookCB, tr("Click here to select whether the last open checkbook will be opened at startup.") ); | 136 | QWhatsThis::add( openLastBookCB, tr("Click here to select whether the last open checkbook will be opened at startup.") ); |
131 | openLastBookCB->setMaximumHeight(fh+5); | 137 | openLastBookCB->setMaximumHeight(fh+5); |
132 | openLastBookCB->setChecked( cfg.isOpenLastBook() ); | 138 | openLastBookCB->setChecked( cfg.isOpenLastBook() ); |
133 | layout->addMultiCellWidget( openLastBookCB, 3, 3, 0, 1 ); | 139 | layout->addMultiCellWidget( openLastBookCB, 3, 3, 0, 1 ); |
134 | 140 | ||
135 | lastTabCB = new QCheckBox( tr("Show last checkbook tab" ), container ); | 141 | lastTabCB = new QCheckBox( tr("Show last checkbook tab" ), container ); |
136 | QWhatsThis::add( lastTabCB, tr("Click here to select whether the last tab in a checkbook should be displayed.") ); | 142 | QWhatsThis::add( lastTabCB, tr("Click here to select whether the last tab in a checkbook should be displayed.") ); |
137 | lastTabCB->setMaximumHeight(fh+5); | 143 | lastTabCB->setMaximumHeight(fh+5); |
138 | lastTabCB->setChecked( cfg.isShowLastTab() ); | 144 | lastTabCB->setChecked( cfg.isShowLastTab() ); |
139 | layout->addMultiCellWidget( lastTabCB, 4, 4, 0, 1 ); | 145 | layout->addMultiCellWidget( lastTabCB, 4, 4, 0, 1 ); |
140 | 146 | ||
147 | savePayees = new QCheckBox( tr("Save new description as payee"), container ); | ||
148 | QWhatsThis::add( savePayees, tr("Click here to save new descriptions in the list of payess.") ); | ||
149 | savePayees->setMaximumHeight(fh+5); | ||
150 | savePayees->setChecked( cfg.getSavePayees() ); | ||
151 | layout->addMultiCellWidget( savePayees, 5, 5, 0, 1 ); | ||
152 | |||
141 | return(control); | 153 | return(control); |
142 | } | 154 | } |
143 | 155 | ||
144 | // --- saveConfig ------------------------------------------------------------- | 156 | // --- saveConfig ------------------------------------------------------------- |
145 | void Configuration::saveConfig(Cfg &cfg) | 157 | void Configuration::saveConfig(Cfg &cfg) |
146 | { | 158 | { |
147 | // Settings | 159 | // Settings |
148 | cfg.setCurrencySymbol( symbolEdit->text() ); | 160 | cfg.setCurrencySymbol( symbolEdit->text() ); |
149 | cfg.setShowLocks( lockCB->isChecked() ); | 161 | cfg.setShowLocks( lockCB->isChecked() ); |
150 | cfg.setShowBalances( balCB->isChecked() ); | 162 | cfg.setShowBalances( balCB->isChecked() ); |
151 | cfg.setOpenLastBook( openLastBookCB->isChecked() ); | 163 | cfg.setOpenLastBook( openLastBookCB->isChecked() ); |
152 | cfg.setShowLastTab( lastTabCB->isChecked() ); | 164 | cfg.setShowLastTab( lastTabCB->isChecked() ); |
165 | cfg.setSavePayees( savePayees->isChecked() ); | ||
153 | 166 | ||
154 | // Typelist | 167 | // Typelist |
155 | _listEditTypes->storeInList( cfg.getAccountTypes() ); | 168 | _listEditTypes->storeInList( cfg.getAccountTypes() ); |
156 | 169 | ||
157 | // Category list | 170 | // Category list |
158 | QStringList lst; | 171 | QStringList lst; |
159 | _listEditCategories->storeInList( lst ); | 172 | _listEditCategories->storeInList( lst ); |
160 | cfg.setCategories( lst ); | 173 | cfg.setCategories( lst ); |
174 | |||
175 | // Payees | ||
176 | _listEditPayees->storeInList( cfg.getPayees() ); | ||
161 | } | 177 | } |
diff --git a/noncore/apps/checkbook/configuration.h b/noncore/apps/checkbook/configuration.h index 5893502..663514d 100644 --- a/noncore/apps/checkbook/configuration.h +++ b/noncore/apps/checkbook/configuration.h | |||
@@ -23,45 +23,47 @@ | |||
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 *lockCB; | 51 | QCheckBox *lockCB; |
52 | QCheckBox *balCB; | 52 | QCheckBox *balCB; |
53 | QCheckBox *openLastBookCB; | 53 | QCheckBox *openLastBookCB; |
54 | QCheckBox *lastTabCB; | 54 | QCheckBox *lastTabCB; |
55 | QCheckBox *savePayees; | ||
55 | QTabWidget *_mainWidget; | 56 | QTabWidget *_mainWidget; |
56 | ListEdit *_listEditTypes; | 57 | ListEdit *_listEditTypes; |
57 | ListEdit *_listEditCategories; | 58 | ListEdit *_listEditCategories; |
59 | ListEdit *_listEditPayees; | ||
58 | 60 | ||
59 | // saves settings in config struct | 61 | // saves settings in config struct |
60 | void saveConfig(Cfg &cfg); | 62 | void saveConfig(Cfg &cfg); |
61 | 63 | ||
62 | protected: | 64 | protected: |
63 | // creates settings tap from configuration | 65 | // creates settings tap from configuration |
64 | QWidget *initSettings(Cfg &cfg); | 66 | QWidget *initSettings(Cfg &cfg); |
65 | }; | 67 | }; |
66 | 68 | ||
67 | #endif | 69 | #endif |
diff --git a/noncore/apps/checkbook/listedit.cpp b/noncore/apps/checkbook/listedit.cpp index 99a6531..37f05f0 100644 --- a/noncore/apps/checkbook/listedit.cpp +++ b/noncore/apps/checkbook/listedit.cpp | |||
@@ -87,64 +87,68 @@ ListEdit::ListEdit( QWidget *parent, const char *sName ) | |||
87 | ListEdit::~ListEdit() | 87 | ListEdit::~ListEdit() |
88 | { | 88 | { |
89 | } | 89 | } |
90 | 90 | ||
91 | 91 | ||
92 | // --- slotEditTypeChanged ---------------------------------------------------- | 92 | // --- slotEditTypeChanged ---------------------------------------------------- |
93 | void ListEdit::slotEditChanged(const QString &str) | 93 | void ListEdit::slotEditChanged(const QString &str) |
94 | { | 94 | { |
95 | if( !_currentItem || _currentColumn<0 ) return; | 95 | if( !_currentItem || _currentColumn<0 ) return; |
96 | _currentItem->setText(_currentColumn, str); | 96 | _currentItem->setText(_currentColumn, str); |
97 | } | 97 | } |
98 | 98 | ||
99 | // --- slotAddType ------------------------------------------------------------ | 99 | // --- slotAddType ------------------------------------------------------------ |
100 | void ListEdit::slotAdd() | 100 | void ListEdit::slotAdd() |
101 | { | 101 | { |
102 | // construct new row | 102 | // construct new row |
103 | QString args[8]; | 103 | QString args[8]; |
104 | ColumnDef *pCol=this->first(); | 104 | ColumnDef *pCol=this->first(); |
105 | int i=0; | 105 | int i=0; |
106 | while( pCol && i<8 ) { | 106 | while( pCol && i<8 ) { |
107 | args[i++]=pCol->getNewValue(); | 107 | args[i++]=pCol->getNewValue(); |
108 | pCol=this->next(); | 108 | pCol=this->next(); |
109 | } | 109 | } |
110 | _currentItem=new QListViewItem(_typeTable, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7] ); | 110 | _currentItem=new QListViewItem(_typeTable, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7] ); |
111 | 111 | ||
112 | // fix uniques | 112 | // fix uniques |
113 | fixTypes(); | 113 | fixTypes(); |
114 | 114 | ||
115 | // display col 0 of new value | 115 | // display col 0 of new value |
116 | QPoint pnt; | 116 | QPoint pnt; |
117 | slotClick(_currentItem, pnt, 0); | 117 | slotClick(_currentItem, pnt, 0); |
118 | _typeTable->setSelected( _currentItem, true ); | 118 | _typeTable->setSelected( _currentItem, true ); |
119 | |||
120 | // make it selected | ||
121 | _typeEdit->setCursorPosition(0); | ||
122 | _typeEdit->setSelection(0, _typeEdit->text().length() ); | ||
119 | } | 123 | } |
120 | 124 | ||
121 | // --- slotDel ------------------------------------------------------------- | 125 | // --- slotDel ------------------------------------------------------------- |
122 | void ListEdit::slotDel() | 126 | void ListEdit::slotDel() |
123 | { | 127 | { |
124 | if( !_currentItem ) return; | 128 | if( !_currentItem ) return; |
125 | delete _currentItem; | 129 | delete _currentItem; |
126 | _currentItem=NULL; | 130 | _currentItem=NULL; |
127 | _typeEdit->setText(""); | 131 | _typeEdit->setText(""); |
128 | _stack->raiseWidget(_typeEdit); | 132 | _stack->raiseWidget(_typeEdit); |
129 | } | 133 | } |
130 | 134 | ||
131 | 135 | ||
132 | // --- fixTypes ---------------------------------------------------------------- | 136 | // --- fixTypes ---------------------------------------------------------------- |
133 | // Makes sure all entries have a unique name and empty entries are replaced | 137 | // Makes sure all entries have a unique name and empty entries are replaced |
134 | // by a generic string. The first version performs the operation on a particular | 138 | // by a generic string. The first version performs the operation on a particular |
135 | // column, whereas the 2nd does it for all unique columns. | 139 | // column, whereas the 2nd does it for all unique columns. |
136 | class ColMap { | 140 | class ColMap { |
137 | public: | 141 | public: |
138 | ColMap(QString sValue, QListViewItem *pEntry) { | 142 | ColMap(QString sValue, QListViewItem *pEntry) { |
139 | _sValue=sValue; | 143 | _sValue=sValue; |
140 | _pEntry=pEntry; | 144 | _pEntry=pEntry; |
141 | } | 145 | } |
142 | QString &getValue() { return(_sValue); } | 146 | QString &getValue() { return(_sValue); } |
143 | QListViewItem *getItem() { return(_pEntry); } | 147 | QListViewItem *getItem() { return(_pEntry); } |
144 | 148 | ||
145 | protected: | 149 | protected: |
146 | QString _sValue; | 150 | QString _sValue; |
147 | QListViewItem *_pEntry; | 151 | QListViewItem *_pEntry; |
148 | }; | 152 | }; |
149 | 153 | ||
150 | class ColList : public QList<QString> | 154 | class ColList : public QList<QString> |
diff --git a/noncore/apps/checkbook/mainwindow.cpp b/noncore/apps/checkbook/mainwindow.cpp index 8d64cad..bf00102 100644 --- a/noncore/apps/checkbook/mainwindow.cpp +++ b/noncore/apps/checkbook/mainwindow.cpp | |||
@@ -29,65 +29,64 @@ | |||
29 | #include "mainwindow.h" | 29 | #include "mainwindow.h" |
30 | #include "cbinfo.h" | 30 | #include "cbinfo.h" |
31 | #include "configuration.h" | 31 | #include "configuration.h" |
32 | #include "password.h" | 32 | #include "password.h" |
33 | #include "checkbook.h" | 33 | #include "checkbook.h" |
34 | #include "listedit.h" | 34 | #include "listedit.h" |
35 | 35 | ||
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | #include <qpe/global.h> | 37 | #include <qpe/global.h> |
38 | #include <qpe/qpeapplication.h> | 38 | #include <qpe/qpeapplication.h> |
39 | #include <qpe/qpemenubar.h> | 39 | #include <qpe/qpemenubar.h> |
40 | #include <qpe/qpemessagebox.h> | 40 | #include <qpe/qpemessagebox.h> |
41 | #include <qpe/qpetoolbar.h> | 41 | #include <qpe/qpetoolbar.h> |
42 | #include <qpe/resource.h> | 42 | #include <qpe/resource.h> |
43 | 43 | ||
44 | #include <qaction.h> | 44 | #include <qaction.h> |
45 | #include <qcheckbox.h> | 45 | #include <qcheckbox.h> |
46 | #include <qdir.h> | 46 | #include <qdir.h> |
47 | #include <qlineedit.h> | 47 | #include <qlineedit.h> |
48 | #include <qwhatsthis.h> | 48 | #include <qwhatsthis.h> |
49 | 49 | ||
50 | 50 | ||
51 | MainWindow::MainWindow( QWidget* parent, const char* name, WFlags fl ) | 51 | MainWindow::MainWindow( QWidget* parent, const char* name, WFlags fl ) |
52 | : QMainWindow( parent, name, fl || WStyle_ContextHelp ) | 52 | : QMainWindow( parent, name, fl || WStyle_ContextHelp ) |
53 | { | 53 | { |
54 | setCaption( tr( "Checkbook" ) ); | 54 | setCaption( tr( "Checkbook" ) ); |
55 | 55 | ||
56 | cbDir = Global::applicationFileName( "checkbook", "" ); | 56 | cbDir = Global::applicationFileName( "checkbook", "" ); |
57 | lockIcon = Resource::loadPixmap( "locked" ); | 57 | lockIcon = Resource::loadPixmap( "locked" ); |
58 | 58 | ||
59 | // Load configuration options | 59 | // Load configuration options |
60 | Config config( "checkbook" ); | 60 | Config config( "checkbook" ); |
61 | qDebug( "Reading config" ); | ||
62 | _cfg.readConfig( config ); | 61 | _cfg.readConfig( config ); |
63 | 62 | ||
64 | 63 | ||
65 | // Build menu and tool bars | 64 | // Build menu and tool bars |
66 | setToolBarsMovable( FALSE ); | 65 | setToolBarsMovable( FALSE ); |
67 | 66 | ||
68 | QPEToolBar *bar = new QPEToolBar( this ); | 67 | QPEToolBar *bar = new QPEToolBar( this ); |
69 | bar->setHorizontalStretchable( TRUE ); | 68 | bar->setHorizontalStretchable( TRUE ); |
70 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 69 | QPEMenuBar *mb = new QPEMenuBar( bar ); |
71 | mb->setMargin( 0 ); | 70 | mb->setMargin( 0 ); |
72 | QPopupMenu *popup = new QPopupMenu( this ); | 71 | QPopupMenu *popup = new QPopupMenu( this ); |
73 | 72 | ||
74 | bar = new QPEToolBar( this ); | 73 | bar = new QPEToolBar( this ); |
75 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); | 74 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
76 | a->setWhatsThis( tr( "Click here to create a new checkbook.\n\nYou also can select New from the Checkbook menu." ) ); | 75 | a->setWhatsThis( tr( "Click here to create a new checkbook.\n\nYou also can select New from the Checkbook menu." ) ); |
77 | connect( a, SIGNAL( activated() ), this, SLOT( slotNew() ) ); | 76 | connect( a, SIGNAL( activated() ), this, SLOT( slotNew() ) ); |
78 | a->addTo( popup ); | 77 | a->addTo( popup ); |
79 | a->addTo( bar ); | 78 | a->addTo( bar ); |
80 | 79 | ||
81 | actionOpen = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, | 80 | actionOpen = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, |
82 | 0, this, 0 ); | 81 | 0, this, 0 ); |
83 | actionOpen->setWhatsThis( tr( "Select a checkbook and then click here to edit it.\n\nYou also can select Edit from the Checkbook menu, or click and hold on a checkbook name." ) ); | 82 | actionOpen->setWhatsThis( tr( "Select a checkbook and then click here to edit it.\n\nYou also can select Edit from the Checkbook menu, or click and hold on a checkbook name." ) ); |
84 | connect( actionOpen, SIGNAL( activated() ), this, SLOT( slotEdit() ) ); | 83 | connect( actionOpen, SIGNAL( activated() ), this, SLOT( slotEdit() ) ); |
85 | actionOpen->addTo( popup ); | 84 | actionOpen->addTo( popup ); |
86 | actionOpen->addTo( bar ); | 85 | actionOpen->addTo( bar ); |
87 | 86 | ||
88 | actionDelete = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, | 87 | actionDelete = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, |
89 | 0, this, 0 ); | 88 | 0, this, 0 ); |
90 | actionDelete->setWhatsThis( tr( "Select a checkbook and then click here delete it.\n\nYou also can select Delete from the Checkbook menu." ) ); | 89 | actionDelete->setWhatsThis( tr( "Select a checkbook and then click here delete it.\n\nYou also can select Delete from the Checkbook menu." ) ); |
91 | connect( actionDelete, SIGNAL( activated() ), this, SLOT( slotDelete() ) ); | 90 | connect( actionDelete, SIGNAL( activated() ), this, SLOT( slotDelete() ) ); |
92 | actionDelete->addTo( popup ); | 91 | actionDelete->addTo( popup ); |
93 | actionDelete->addTo( bar ); | 92 | actionDelete->addTo( bar ); |
@@ -285,64 +284,70 @@ void MainWindow::openBook(QListViewItem *curritem) | |||
285 | cbList->sort(); | 284 | cbList->sort(); |
286 | } | 285 | } |
287 | _cfg.setLastBook( newname ); | 286 | _cfg.setLastBook( newname ); |
288 | 287 | ||
289 | // Remove old file | 288 | // Remove old file |
290 | QFile f( tempFilename ); | 289 | QFile f( tempFilename ); |
291 | if ( f.exists() ) | 290 | if ( f.exists() ) |
292 | f.remove(); | 291 | f.remove(); |
293 | 292 | ||
294 | // Get new filename | 293 | // Get new filename |
295 | buildFilename( newname ); | 294 | buildFilename( newname ); |
296 | cb->setFilename( tempFilename ); | 295 | cb->setFilename( tempFilename ); |
297 | } | 296 | } |
298 | 297 | ||
299 | cb->write(); | 298 | cb->write(); |
300 | 299 | ||
301 | // Update lock if changed | 300 | // Update lock if changed |
302 | if ( _cfg.getShowLocks() && !cb->password().isNull() != currlock ) | 301 | if ( _cfg.getShowLocks() && !cb->password().isNull() != currlock ) |
303 | { | 302 | { |
304 | if ( !cb->password().isNull() ) | 303 | if ( !cb->password().isNull() ) |
305 | curritem->setPixmap( 0, lockIcon ); | 304 | curritem->setPixmap( 0, lockIcon ); |
306 | else | 305 | else |
307 | curritem->setPixmap( 0, nullIcon ); | 306 | curritem->setPixmap( 0, nullIcon ); |
308 | } | 307 | } |
309 | 308 | ||
310 | // Update balance if changed | 309 | // Update balance if changed |
311 | if ( _cfg.getShowBalances() && cb->balance() != currbalance ) | 310 | if ( _cfg.getShowBalances() && cb->balance() != currbalance ) |
312 | { | 311 | { |
313 | QString tempstr; | 312 | QString tempstr; |
314 | tempstr.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() ); | 313 | tempstr.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() ); |
315 | curritem->setText( posName + 1, tempstr ); | 314 | curritem->setText( posName + 1, tempstr ); |
316 | } | 315 | } |
316 | |||
317 | // write config, if needed | ||
318 | if( _cfg.isDirty() ) { | ||
319 | Config config("checkbook"); | ||
320 | _cfg.writeConfig( config ); | ||
321 | } | ||
317 | } | 322 | } |
318 | delete currcb; | 323 | delete currcb; |
319 | } | 324 | } |
320 | 325 | ||
321 | // --- slotDelete ------------------------------------------------------------- | 326 | // --- slotDelete ------------------------------------------------------------- |
322 | void MainWindow::slotDelete() | 327 | void MainWindow::slotDelete() |
323 | { | 328 | { |
324 | QString currname = cbList->currentItem()->text( posName ); | 329 | QString currname = cbList->currentItem()->text( posName ); |
325 | 330 | ||
326 | if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), currname ) ) | 331 | if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), currname ) ) |
327 | { | 332 | { |
328 | buildFilename( currname ); | 333 | buildFilename( currname ); |
329 | QFile f( tempFilename ); | 334 | QFile f( tempFilename ); |
330 | if ( f.exists() ) | 335 | if ( f.exists() ) |
331 | { | 336 | { |
332 | f.remove(); | 337 | f.remove(); |
333 | } | 338 | } |
334 | 339 | ||
335 | delete cbList->currentItem(); | 340 | delete cbList->currentItem(); |
336 | } | 341 | } |
337 | } | 342 | } |
338 | 343 | ||
339 | // --- slotConfigure ---------------------------------------------------------- | 344 | // --- slotConfigure ---------------------------------------------------------- |
340 | void MainWindow::slotConfigure() | 345 | void MainWindow::slotConfigure() |
341 | { | 346 | { |
342 | Configuration *cfgdlg = new Configuration( this, _cfg ); | 347 | Configuration *cfgdlg = new Configuration( this, _cfg ); |
343 | cfgdlg->showMaximized(); | 348 | cfgdlg->showMaximized(); |
344 | if ( cfgdlg->exec() == QDialog::Accepted ) | 349 | if ( cfgdlg->exec() == QDialog::Accepted ) |
345 | { | 350 | { |
346 | // read data from config dialog & save it | 351 | // read data from config dialog & save it |
347 | cfgdlg->saveConfig( _cfg ); | 352 | cfgdlg->saveConfig( _cfg ); |
348 | writeConfig(); | 353 | writeConfig(); |
diff --git a/noncore/apps/checkbook/traninfo.cpp b/noncore/apps/checkbook/traninfo.cpp index d880bb4..506f567 100644 --- a/noncore/apps/checkbook/traninfo.cpp +++ b/noncore/apps/checkbook/traninfo.cpp | |||
@@ -1,63 +1,64 @@ | |||
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 "traninfo.h" | 29 | #include "traninfo.h" |
30 | 30 | ||
31 | #include <qpe/config.h> | 31 | #include <qpe/config.h> |
32 | #include <qpe/timestring.h> | ||
32 | 33 | ||
33 | QString tempstr; | 34 | QString tempstr; |
34 | 35 | ||
35 | TranInfo::TranInfo( int id, const QString &desc, const QDate &date, bool withdrawal, | 36 | TranInfo::TranInfo( int id, const QString &desc, const QDate &date, bool withdrawal, |
36 | const QString &type, const QString &category, float amount, | 37 | const QString &type, const QString &category, float amount, |
37 | float fee, const QString &number, const QString ¬es, int next ) | 38 | float fee, const QString &number, const QString ¬es, int next ) |
38 | { | 39 | { |
39 | i = id; | 40 | i = id; |
40 | d = desc; | 41 | d = desc; |
41 | td = date; | 42 | td = date; |
42 | w = withdrawal; | 43 | w = withdrawal; |
43 | t = type; | 44 | t = type; |
44 | c = category; | 45 | c = category; |
45 | a = amount; | 46 | a = amount; |
46 | f = fee; | 47 | f = fee; |
47 | cn = number; | 48 | cn = number; |
48 | n = notes; | 49 | n = notes; |
49 | _next=next; | 50 | _next=next; |
50 | } | 51 | } |
51 | 52 | ||
52 | TranInfo::TranInfo( Config config, int entry ) | 53 | TranInfo::TranInfo( Config config, int entry ) |
53 | { | 54 | { |
54 | config.setGroup( QString::number( entry ) ); | 55 | config.setGroup( QString::number( entry ) ); |
55 | QString desc = config.readEntry( "Description", "Not Found" ); | 56 | QString desc = config.readEntry( "Description", "Not Found" ); |
56 | if ( desc != "Not Found" ) | 57 | if ( desc != "Not Found" ) |
57 | { | 58 | { |
58 | // ID | 59 | // ID |
59 | i = entry; | 60 | i = entry; |
60 | 61 | ||
61 | // Description | 62 | // Description |
62 | d = desc; | 63 | d = desc; |
63 | 64 | ||
@@ -95,72 +96,75 @@ TranInfo::TranInfo( Config config, int entry ) | |||
95 | else if( type == "1" ) | 96 | else if( type == "1" ) |
96 | t = "Automatic Payment"; | 97 | t = "Automatic Payment"; |
97 | else if( type == "2" ) | 98 | else if( type == "2" ) |
98 | t = "Transfer"; | 99 | t = "Transfer"; |
99 | else if( type == "3" ) | 100 | else if( type == "3" ) |
100 | t = "Cash"; | 101 | t = "Cash"; |
101 | } | 102 | } |
102 | 103 | ||
103 | // Category | 104 | // Category |
104 | c = config.readEntry( "Category", "" ); | 105 | c = config.readEntry( "Category", "" ); |
105 | 106 | ||
106 | // Transaction amount | 107 | // Transaction amount |
107 | QString stramount = config.readEntry( "Amount", "0.00" ); | 108 | QString stramount = config.readEntry( "Amount", "0.00" ); |
108 | bool ok; | 109 | bool ok; |
109 | a = stramount.toFloat( &ok ); | 110 | a = stramount.toFloat( &ok ); |
110 | 111 | ||
111 | // Transaction fee | 112 | // Transaction fee |
112 | stramount = config.readEntry( "TransactionFee", "0.00" ); | 113 | stramount = config.readEntry( "TransactionFee", "0.00" ); |
113 | f = stramount.toFloat( &ok ); | 114 | f = stramount.toFloat( &ok ); |
114 | 115 | ||
115 | // Transaction number | 116 | // Transaction number |
116 | cn = config.readEntry( "CheckNumber", "" ); | 117 | cn = config.readEntry( "CheckNumber", "" ); |
117 | 118 | ||
118 | // Notes | 119 | // Notes |
119 | n = config.readEntry( "Comments", "" ); | 120 | n = config.readEntry( "Comments", "" ); |
120 | 121 | ||
121 | // next | 122 | // next |
122 | _next = config.readNumEntry("Next", -1); | 123 | _next = config.readNumEntry("Next", -1); |
123 | } | 124 | } |
124 | } | 125 | } |
125 | 126 | ||
126 | // --- datestr ---------------------------------------------------------------- | 127 | // --- datestr ---------------------------------------------------------------- |
127 | const QString &TranInfo::datestr() | 128 | const QString &TranInfo::datestr(bool bDisplayDate) |
128 | { | 129 | { |
129 | int y=td.year(); | 130 | if( bDisplayDate ) { |
130 | y= y>=2000 && y<=2099 ? y-2000 : y; | 131 | tempstr=TimeString::numberDateString( td ); |
131 | tempstr.sprintf( "%02d/%02d/%02d", y ,td.month(), td.day() ); | 132 | } else { |
132 | return( tempstr ); | 133 | tempstr.sprintf( "%04d-%02d-%02d", td.year() ,td.month(), td.day() ); |
134 | } | ||
135 | return(tempstr); | ||
133 | } | 136 | } |
134 | 137 | ||
138 | |||
135 | // --- getIdStr --------------------------------------------------------------- | 139 | // --- getIdStr --------------------------------------------------------------- |
136 | const QString &TranInfo::getIdStr() | 140 | const QString &TranInfo::getIdStr() |
137 | { | 141 | { |
138 | tempstr.sprintf("%04d", i); | 142 | tempstr.sprintf("%04d", i); |
139 | return( tempstr ); | 143 | return( tempstr ); |
140 | } | 144 | } |
141 | 145 | ||
142 | // --- write ------------------------------------------------------------------ | 146 | // --- write ------------------------------------------------------------------ |
143 | void TranInfo::write( Config *config ) | 147 | void TranInfo::write( Config *config ) |
144 | { | 148 | { |
145 | config->setGroup( QString::number( id() ) ); | 149 | config->setGroup( QString::number( id() ) ); |
146 | 150 | ||
147 | config->writeEntry( "Description", d ); | 151 | config->writeEntry( "Description", d ); |
148 | 152 | ||
149 | tempstr = QString::number( td.month() ); | 153 | tempstr = QString::number( td.month() ); |
150 | tempstr.append( '/' ); | 154 | tempstr.append( '/' ); |
151 | tempstr.append( QString::number( td.day() ) ); | 155 | tempstr.append( QString::number( td.day() ) ); |
152 | tempstr.append( '/' ); | 156 | tempstr.append( '/' ); |
153 | tempstr.append( QString::number( td.year() ) ); | 157 | tempstr.append( QString::number( td.year() ) ); |
154 | config->writeEntry( "Date", tempstr ); | 158 | config->writeEntry( "Date", tempstr ); |
155 | 159 | ||
156 | w ? tempstr = "true" | 160 | w ? tempstr = "true" |
157 | : tempstr = "false"; | 161 | : tempstr = "false"; |
158 | config->writeEntry( "Payment", tempstr ); | 162 | config->writeEntry( "Payment", tempstr ); |
159 | 163 | ||
160 | if ( t == "Debit Charge" || t == "Written Check" ) | 164 | if ( t == "Debit Charge" || t == "Written Check" ) |
161 | tempstr = "0"; | 165 | tempstr = "0"; |
162 | else if ( t == "Written Check" || t == "Automatic Payment" ) | 166 | else if ( t == "Written Check" || t == "Automatic Payment" ) |
163 | tempstr = "1"; | 167 | tempstr = "1"; |
164 | else if ( t == "Transfer" ) | 168 | else if ( t == "Transfer" ) |
165 | tempstr = "2"; | 169 | tempstr = "2"; |
166 | else if ( t == "Credit Card" || t == "Cash" ) | 170 | else if ( t == "Credit Card" || t == "Cash" ) |
@@ -181,32 +185,43 @@ void TranInfo::write( Config *config ) | |||
181 | } | 185 | } |
182 | 186 | ||
183 | 187 | ||
184 | int TranInfoList::compareItems( QCollection::Item item1, QCollection::Item item2 ) | 188 | int TranInfoList::compareItems( QCollection::Item item1, QCollection::Item item2 ) |
185 | { | 189 | { |
186 | QDate d1 = ((TranInfo *)item1)->date(); | 190 | QDate d1 = ((TranInfo *)item1)->date(); |
187 | QDate d2 = ((TranInfo *)item2)->date(); | 191 | QDate d2 = ((TranInfo *)item2)->date(); |
188 | int r = -1; | 192 | int r = -1; |
189 | 193 | ||
190 | if ( d1 < d2 ) | 194 | if ( d1 < d2 ) |
191 | r = -1; | 195 | r = -1; |
192 | else if ( d1 == d2 ) | 196 | else if ( d1 == d2 ) |
193 | r = 0; | 197 | r = 0; |
194 | else if ( d1 > d2 ) | 198 | else if ( d1 > d2 ) |
195 | r = 1; | 199 | r = 1; |
196 | return( r ); | 200 | return( r ); |
197 | } | 201 | } |
198 | 202 | ||
199 | // --- toString --------------------------------------------------------------- | 203 | // --- toString --------------------------------------------------------------- |
200 | QString TranInfo::toString() | 204 | QString TranInfo::toString() |
201 | { | 205 | { |
202 | QString ret; | 206 | QString ret; |
203 | ret.sprintf("(%4d) %10s %4s %-10s %5.2f %5.2f", | 207 | ret.sprintf("(%4d) %10s %4s %-10s %5.2f %5.2f", |
204 | id(), | 208 | id(), |
205 | (const char *)datestr(), | 209 | (const char *)datestr(), |
206 | (const char *)number(), | 210 | (const char *)number(), |
207 | (const char *)desc(), | 211 | (const char *)desc(), |
208 | (withdrawal() ? -1 : 1) * amount(), | 212 | (withdrawal() ? -1 : 1) * amount(), |
209 | fee() | 213 | fee() |
210 | ); | 214 | ); |
211 | return(ret); | 215 | return(ret); |
212 | } | 216 | } |
217 | |||
218 | |||
219 | // --- findMostRecentByDesc --------------------------------------------------- | ||
220 | TranInfo *TranInfoList::findMostRecentByDesc( const QString &desc ) | ||
221 | { | ||
222 | for(TranInfo *cur=last(); cur; cur=prev()) { | ||
223 | if( cur->desc()==desc ) | ||
224 | return( cur ); | ||
225 | } | ||
226 | return(NULL); | ||
227 | } \ No newline at end of file | ||
diff --git a/noncore/apps/checkbook/traninfo.h b/noncore/apps/checkbook/traninfo.h index 0abdc61..cbe0238 100644 --- a/noncore/apps/checkbook/traninfo.h +++ b/noncore/apps/checkbook/traninfo.h | |||
@@ -20,81 +20,84 @@ | |||
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 TRANINFO_H | 29 | #ifndef TRANINFO_H |
30 | #define TRANINFO_H | 30 | #define TRANINFO_H |
31 | 31 | ||
32 | #include <qdatetime.h> | 32 | #include <qdatetime.h> |
33 | #include <qlist.h> | 33 | #include <qlist.h> |
34 | 34 | ||
35 | class Config; | 35 | class Config; |
36 | 36 | ||
37 | class TranInfo | 37 | class TranInfo |
38 | { | 38 | { |
39 | public: | 39 | public: |
40 | TranInfo( int = 0, const QString & = 0x0, const QDate & = QDate::currentDate(), | 40 | TranInfo( int = 0, const QString & = 0x0, const QDate & = QDate::currentDate(), |
41 | bool = TRUE, const QString & = 0x0, const QString & = 0x0, | 41 | bool = TRUE, const QString & = 0x0, const QString & = 0x0, |
42 | float = 0.0, float = 0.0, | 42 | float = 0.0, float = 0.0, |
43 | const QString & = 0x0, const QString & = 0x0, int =-1 ); | 43 | const QString & = 0x0, const QString & = 0x0, int =-1 ); |
44 | TranInfo( Config, int ); | 44 | TranInfo( Config, int ); |
45 | 45 | ||
46 | // getters | 46 | // getters |
47 | int id() const { return i; } | 47 | int id() const { return i; } |
48 | const QString &getIdStr(); | 48 | const QString &getIdStr(); |
49 | 49 | ||
50 | const QString &desc() const { return d; } | 50 | const QString &desc() const { return d; } |
51 | const QDate &date() const { return td; } | 51 | const QDate &date() const { return td; } |
52 | const QString &datestr(); | 52 | const QString &datestr(bool = false); |
53 | bool withdrawal()const { return w; } | 53 | bool withdrawal()const { return w; } |
54 | const QString &type() const { return t; } | 54 | const QString &type() const { return t; } |
55 | const QString &category()const { return c; } | 55 | const QString &category()const { return c; } |
56 | float amount() const { return a; } | 56 | float amount() const { return a; } |
57 | float fee() const { return f; } | 57 | float fee() const { return f; } |
58 | const QString &number()const { return cn; } | 58 | const QString &number()const { return cn; } |
59 | const QString ¬es() const { return n; } | 59 | const QString ¬es() const { return n; } |
60 | int getNext() { return(_next); } | 60 | int getNext() { return(_next); } |
61 | 61 | ||
62 | // setters | 62 | // setters |
63 | void setDesc( const QString &desc ) { d = desc; } | 63 | void setDesc( const QString &desc ) { d = desc; } |
64 | void setDate( const QDate &date ) { td = date; } | 64 | void setDate( const QDate &date ) { td = date; } |
65 | void setWithdrawal( bool withdrawal ) { w = withdrawal; } | 65 | void setWithdrawal( bool withdrawal ) { w = withdrawal; } |
66 | void setType( const QString &type ) { t = type; } | 66 | void setType( const QString &type ) { t = type; } |
67 | void setCategory( const QString &cat ){ c = cat; } | 67 | void setCategory( const QString &cat ){ c = cat; } |
68 | void setAmount( float amount ) { a = amount; } | 68 | void setAmount( float amount ) { a = amount; } |
69 | void setFee( float fee ) { f = fee; } | 69 | void setFee( float fee ) { f = fee; } |
70 | void setNumber( const QString &num ) { cn = num; } | 70 | void setNumber( const QString &num ) { cn = num; } |
71 | void setNotes( const QString ¬es ) { n = notes; } | 71 | void setNotes( const QString ¬es ) { n = notes; } |
72 | void setNext(int next) { _next=next; } | 72 | void setNext(int next) { _next=next; } |
73 | 73 | ||
74 | // write | 74 | // write |
75 | void write( Config * ); | 75 | void write( Config * ); |
76 | 76 | ||
77 | // toString | 77 | // toString |
78 | QString toString(); | 78 | QString toString(); |
79 | 79 | ||
80 | private: | 80 | private: |
81 | int i; | 81 | int i; |
82 | QString d; | 82 | QString d; |
83 | QDate td; | 83 | QDate td; |
84 | bool w; | 84 | bool w; |
85 | QString t; | 85 | QString t; |
86 | QString c; | 86 | QString c; |
87 | float a; | 87 | float a; |
88 | float f; | 88 | float f; |
89 | QString cn; | 89 | QString cn; |
90 | QString n; | 90 | QString n; |
91 | int _next; | 91 | int _next; |
92 | }; | 92 | }; |
93 | 93 | ||
94 | class TranInfoList : public QList<TranInfo> | 94 | class TranInfoList : public QList<TranInfo> |
95 | { | 95 | { |
96 | public: | ||
97 | TranInfo *findMostRecentByDesc( const QString &desc ); | ||
98 | |||
96 | protected: | 99 | protected: |
97 | int compareItems( QCollection::Item, QCollection::Item ); | 100 | int compareItems( QCollection::Item, QCollection::Item ); |
98 | }; | 101 | }; |
99 | 102 | ||
100 | #endif | 103 | #endif |
diff --git a/noncore/apps/checkbook/transaction.cpp b/noncore/apps/checkbook/transaction.cpp index 138d0e6..9379da0 100644 --- a/noncore/apps/checkbook/transaction.cpp +++ b/noncore/apps/checkbook/transaction.cpp | |||
@@ -1,83 +1,86 @@ | |||
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 "transaction.h" | 29 | #include "transaction.h" |
30 | #include "traninfo.h" | 30 | #include "traninfo.h" |
31 | #include "cfg.h" | 31 | #include "cfg.h" |
32 | #include "checkbook.h" | ||
32 | 33 | ||
33 | #include <qpe/datebookmonth.h> | 34 | #include <qpe/datebookmonth.h> |
35 | #include <qpe/resource.h> | ||
34 | 36 | ||
35 | #include <qbuttongroup.h> | 37 | #include <qbuttongroup.h> |
36 | #include <qcombobox.h> | 38 | #include <qcombobox.h> |
37 | #include <qlabel.h> | 39 | #include <qlabel.h> |
38 | #include <qlayout.h> | 40 | #include <qlayout.h> |
39 | #include <qlineedit.h> | 41 | #include <qlineedit.h> |
40 | #include <qmultilineedit.h> | 42 | #include <qmultilineedit.h> |
41 | #include <qradiobutton.h> | 43 | #include <qradiobutton.h> |
42 | #include <qwhatsthis.h> | 44 | #include <qwhatsthis.h> |
43 | 45 | ||
44 | Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *info, | 46 | Transaction::Transaction( QWidget *parent, bool bNew, const QString &acctname, |
45 | Cfg *pCfg ) | 47 | TranInfo *info, Cfg *pCfg ) |
46 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) | 48 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) |
47 | { | 49 | { |
48 | QString tempstr = tr( "Transaction for " ); | 50 | QString tempstr = tr( "Transaction for " ); |
49 | tempstr.append( acctname ); | 51 | tempstr.append( acctname ); |
50 | setCaption( tempstr ); | 52 | setCaption( tempstr ); |
51 | 53 | ||
54 | _bNew=bNew; | ||
52 | tran = info; | 55 | tran = info; |
53 | _pCfg=pCfg; | 56 | _pCfg=pCfg; |
54 | 57 | ||
55 | QVBoxLayout *vb = new QVBoxLayout( this ); | 58 | QVBoxLayout *vb = new QVBoxLayout( this ); |
56 | 59 | ||
57 | QScrollView *sv = new QScrollView( this ); | 60 | QScrollView *sv = new QScrollView( this ); |
58 | vb->addWidget( sv, 0, 0 ); | 61 | vb->addWidget( sv, 0, 0 ); |
59 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 62 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
60 | sv->setFrameStyle( QFrame::NoFrame ); | 63 | sv->setFrameStyle( QFrame::NoFrame ); |
61 | 64 | ||
62 | QWidget *container = new QWidget( sv->viewport() ); | 65 | QWidget *container = new QWidget( sv->viewport() ); |
63 | sv->addChild( container ); | 66 | sv->addChild( container ); |
64 | 67 | ||
65 | QGridLayout *layout = new QGridLayout( container ); | 68 | QGridLayout *layout = new QGridLayout( container ); |
66 | layout->setSpacing( 2 ); | 69 | layout->setSpacing( 2 ); |
67 | layout->setMargin( 4 ); | 70 | layout->setMargin( 4 ); |
68 | 71 | ||
69 | // Withdrawal/Deposit | 72 | // Withdrawal/Deposit |
70 | QButtonGroup *btngrp = new QButtonGroup( container ); | 73 | QButtonGroup *btngrp = new QButtonGroup( container ); |
71 | btngrp->setColumnLayout(0, Qt::Vertical ); | 74 | btngrp->setColumnLayout(0, Qt::Vertical ); |
72 | btngrp->layout()->setSpacing( 0 ); | 75 | btngrp->layout()->setSpacing( 0 ); |
73 | btngrp->layout()->setMargin( 0 ); | 76 | btngrp->layout()->setMargin( 0 ); |
74 | btngrp->setMaximumWidth( 220 ); | 77 | btngrp->setMaximumWidth( 220 ); |
75 | QGridLayout *layout2 = new QGridLayout( btngrp->layout() ); | 78 | QGridLayout *layout2 = new QGridLayout( btngrp->layout() ); |
76 | layout2->setSpacing( 2 ); | 79 | layout2->setSpacing( 2 ); |
77 | layout2->setMargin( 2 ); | 80 | layout2->setMargin( 2 ); |
78 | withBtn = new QRadioButton( tr( "Withdrawal" ), btngrp ); | 81 | withBtn = new QRadioButton( tr( "Withdrawal" ), btngrp ); |
79 | QWhatsThis::add( withBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) ); | 82 | QWhatsThis::add( withBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) ); |
80 | layout2->addWidget( withBtn, 0, 0 ); | 83 | layout2->addWidget( withBtn, 0, 0 ); |
81 | connect( withBtn, SIGNAL( clicked() ), this, SLOT( slotWithdrawalClicked() ) ); | 84 | connect( withBtn, SIGNAL( clicked() ), this, SLOT( slotWithdrawalClicked() ) ); |
82 | depBtn = new QRadioButton( tr( "Deposit" ), btngrp ); | 85 | depBtn = new QRadioButton( tr( "Deposit" ), btngrp ); |
83 | QWhatsThis::add( depBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) ); | 86 | QWhatsThis::add( depBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) ); |
@@ -85,186 +88,251 @@ Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *in | |||
85 | btngrp->setMaximumSize( 320, withBtn->height() ); | 88 | btngrp->setMaximumSize( 320, withBtn->height() ); |
86 | connect( depBtn, SIGNAL( clicked() ), this, SLOT( slotDepositClicked() ) ); | 89 | connect( depBtn, SIGNAL( clicked() ), this, SLOT( slotDepositClicked() ) ); |
87 | layout->addMultiCellWidget( btngrp, 0, 0, 0, 3 ); | 90 | layout->addMultiCellWidget( btngrp, 0, 0, 0, 3 ); |
88 | 91 | ||
89 | // Date | 92 | // Date |
90 | QLabel *label = new QLabel( tr( "Date:" ), container ); | 93 | QLabel *label = new QLabel( tr( "Date:" ), container ); |
91 | QWhatsThis::add( label, tr( "Select date of transaction here." ) ); | 94 | QWhatsThis::add( label, tr( "Select date of transaction here." ) ); |
92 | layout->addWidget( label, 1, 0 ); | 95 | layout->addWidget( label, 1, 0 ); |
93 | dateBtn = new QPushButton( TimeString::shortDate( QDate::currentDate() ), | 96 | dateBtn = new QPushButton( TimeString::shortDate( QDate::currentDate() ), |
94 | container ); | 97 | container ); |
95 | QWhatsThis::add( dateBtn, tr( "Select date of transaction here." ) ); | 98 | QWhatsThis::add( dateBtn, tr( "Select date of transaction here." ) ); |
96 | QPopupMenu *m1 = new QPopupMenu( container ); | 99 | QPopupMenu *m1 = new QPopupMenu( container ); |
97 | datePicker = new DateBookMonth( m1, 0, TRUE ); | 100 | datePicker = new DateBookMonth( m1, 0, TRUE ); |
98 | m1->insertItem( datePicker ); | 101 | m1->insertItem( datePicker ); |
99 | dateBtn->setPopup( m1 ); | 102 | dateBtn->setPopup( m1 ); |
100 | connect( datePicker, SIGNAL( dateClicked( int, int, int ) ), | 103 | connect( datePicker, SIGNAL( dateClicked( int, int, int ) ), |
101 | this, SLOT( slotDateChanged( int, int, int ) ) ); | 104 | this, SLOT( slotDateChanged( int, int, int ) ) ); |
102 | layout->addWidget( dateBtn, 1, 1 ); | 105 | layout->addWidget( dateBtn, 1, 1 ); |
103 | 106 | ||
104 | // Check number | 107 | // Check number |
105 | label = new QLabel( tr( "Number:" ), container ); | 108 | label = new QLabel( tr( "Number:" ), container ); |
106 | QWhatsThis::add( label, tr( "Enter check number here." ) ); | 109 | QWhatsThis::add( label, tr( "Enter check number here." ) ); |
107 | layout->addWidget( label, 1, 2 ); | 110 | layout->addWidget( label, 1, 2 ); |
108 | numEdit = new QLineEdit( container ); | 111 | numEdit = new QLineEdit( container ); |
109 | QWhatsThis::add( numEdit, tr( "Enter check number here." ) ); | 112 | QWhatsThis::add( numEdit, tr( "Enter check number here." ) ); |
110 | numEdit->setMaximumWidth( 40 ); | 113 | numEdit->setMaximumWidth( 40 ); |
111 | layout->addWidget( numEdit, 1, 3 ); | 114 | layout->addWidget( numEdit, 1, 3 ); |
112 | 115 | ||
113 | // Description | 116 | // Description |
114 | label = new QLabel( tr( "Description:" ), container ); | 117 | label = new QLabel( tr( "Description:" ), container ); |
115 | QWhatsThis::add( label, tr( "Enter description of transaction here." ) ); | 118 | QWhatsThis::add( label, tr( "Enter description of transaction here." ) ); |
116 | layout->addWidget( label, 2, 0 ); | 119 | layout->addWidget( label, 2, 0 ); |
117 | descEdit = new QLineEdit( container ); | 120 | _cbDesc=new QComboBox( true, container ); |
118 | QWhatsThis::add( descEdit, tr( "Enter description of transaction here." ) ); | 121 | _cbDesc->insertStringList( _pCfg->getPayees() ); |
119 | layout->addMultiCellWidget( descEdit, 2, 2, 1, 3 ); | 122 | QWhatsThis::add( _cbDesc, tr( "Enter description of transaction here." ) ); |
123 | layout->addMultiCellWidget( _cbDesc, 2, 2, 1, 3 ); | ||
124 | connect( _cbDesc, SIGNAL( activated(const QString &) ), this, SLOT( slotActivated(const QString &) ) ); | ||
125 | |||
120 | 126 | ||
121 | // Category | 127 | // Category |
122 | label = new QLabel( tr( "Category:" ), container ); | 128 | label = new QLabel( tr( "Category:" ), container ); |
123 | QWhatsThis::add( label, tr( "Select transaction category here." ) ); | 129 | QWhatsThis::add( label, tr( "Select transaction category here." ) ); |
124 | layout->addWidget( label, 3, 0 ); | 130 | layout->addWidget( label, 3, 0 ); |
125 | catList = new QComboBox( container ); | 131 | catList = new QComboBox( container ); |
126 | QWhatsThis::add( catList, tr( "Select transaction category here." ) ); | 132 | QWhatsThis::add( catList, tr( "Select transaction category here." ) ); |
127 | layout->addMultiCellWidget( catList, 3, 3, 1, 3 ); | 133 | layout->addMultiCellWidget( catList, 3, 3, 1, 3 ); |
128 | 134 | ||
129 | // Type | 135 | // Type |
130 | label = new QLabel( tr( "Type:" ), container ); | 136 | label = new QLabel( tr( "Type:" ), container ); |
131 | QWhatsThis::add( label, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) ); | 137 | QWhatsThis::add( label, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) ); |
132 | layout->addWidget( label, 4, 0 ); | 138 | layout->addWidget( label, 4, 0 ); |
133 | typeList = new QComboBox( container ); | 139 | typeList = new QComboBox( container ); |
134 | QWhatsThis::add( typeList, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) ); | 140 | QWhatsThis::add( typeList, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) ); |
135 | layout->addMultiCellWidget( typeList, 4, 4, 1, 3 ); | 141 | layout->addMultiCellWidget( typeList, 4, 4, 1, 3 ); |
136 | 142 | ||
143 | |||
137 | // Amount | 144 | // Amount |
138 | label = new QLabel( tr( "Amount:" ), container ); | 145 | label = new QLabel( tr( "Amount:" ), container ); |
139 | QWhatsThis::add( label, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) ); | 146 | QWhatsThis::add( label, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) ); |
140 | layout->addWidget( label, 5, 0 ); | 147 | layout->addWidget( label, 5, 0 ); |
141 | amtEdit = new QLineEdit( container ); | 148 | amtEdit = new QLineEdit( container ); |
142 | QWhatsThis::add( amtEdit, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) ); | 149 | QWhatsThis::add( amtEdit, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) ); |
143 | layout->addMultiCellWidget( amtEdit, 5, 5, 1, 3 ); | 150 | layout->addMultiCellWidget( amtEdit, 5, 5, 1, 3 ); |
144 | 151 | ||
145 | // Fee | 152 | // Fee |
146 | label = new QLabel( tr( "Fee:" ), container ); | 153 | label = new QLabel( tr( "Fee:" ), container ); |
147 | QWhatsThis::add( label, tr( "Enter any fee amount assoiciated with this transaction.\n\nThe value entered should always be positive." ) ); | 154 | QWhatsThis::add( label, tr( "Enter any fee amount assoiciated with this transaction.\n\nThe value entered should always be positive." ) ); |
148 | layout->addWidget( label, 6, 0 ); | 155 | layout->addWidget( label, 6, 0 ); |
149 | feeEdit = new QLineEdit( container ); | 156 | feeEdit = new QLineEdit( container ); |
150 | QWhatsThis::add( feeEdit, tr( "Enter any fee amount assoiciated with this transaction.\n\nThe value entered should always be positive." ) ); | 157 | QWhatsThis::add( feeEdit, tr( "Enter any fee amount assoiciated with this transaction.\n\nThe value entered should always be positive." ) ); |
151 | layout->addMultiCellWidget( feeEdit, 6, 6, 1, 3 ); | 158 | layout->addMultiCellWidget( feeEdit, 6, 6, 1, 3 ); |
152 | 159 | ||
153 | // Notes | 160 | // Notes |
154 | label = new QLabel( tr( "Notes:" ), container ); | 161 | label = new QLabel( tr( "Notes:" ), container ); |
155 | QWhatsThis::add( label, tr( "Enter any additional information for this transaction here." ) ); | 162 | QWhatsThis::add( label, tr( "Enter any additional information for this transaction here." ) ); |
156 | layout->addWidget( label, 7, 0 ); | 163 | layout->addWidget( label, 7, 0 ); |
157 | noteEdit = new QMultiLineEdit( container ); | 164 | noteEdit = new QMultiLineEdit( container ); |
158 | QWhatsThis::add( noteEdit, tr( "Enter any additional information for this transaction here." ) ); | 165 | QWhatsThis::add( noteEdit, tr( "Enter any additional information for this transaction here." ) ); |
159 | layout->addMultiCellWidget( noteEdit, 8, 8, 0, 3 ); | 166 | layout->addMultiCellWidget( noteEdit, 8, 8, 0, 3 ); |
160 | 167 | ||
168 | // init date | ||
169 | initFromInfo( info ); | ||
170 | |||
171 | // not new handlers | ||
172 | connect( withBtn, SIGNAL( toggled(bool) ), this, SLOT( slotNotNew() ) ); | ||
173 | connect( depBtn, SIGNAL( toggled(bool) ), this, SLOT( slotNotNew() ) ); | ||
174 | connect( catList, SIGNAL(activated(const QString &)), this, SLOT( slotNotNew() ) ); | ||
175 | connect( typeList, SIGNAL(activated(const QString &)), this, SLOT( slotNotNew() ) ); | ||
176 | connect( amtEdit, SIGNAL(textChanged(const QString &)), this, SLOT( slotNotNew() ) ); | ||
177 | connect( feeEdit, SIGNAL(textChanged(const QString &)), this, SLOT( slotNotNew() ) ); | ||
178 | connect( noteEdit, SIGNAL(textChanged()), this, SLOT( slotNotNew() ) ); | ||
179 | } | ||
180 | |||
181 | // --- initFromInfo ----------------------------------------------------------- | ||
182 | void Transaction::initFromInfo(TranInfo *info, bool bPopulateOld) | ||
183 | { | ||
161 | // Populate current values if provided | 184 | // Populate current values if provided |
162 | if ( info ) | 185 | if ( info ) |
163 | { | 186 | { |
164 | if ( info->withdrawal() ) | 187 | if ( info->withdrawal() ) |
165 | { | 188 | { |
166 | withBtn->setChecked( TRUE ); | 189 | withBtn->setChecked( TRUE ); |
167 | slotWithdrawalClicked(); | 190 | slotWithdrawalClicked(); |
168 | } | 191 | } |
169 | else | 192 | else |
170 | { | 193 | { |
171 | depBtn->setChecked( TRUE ); | 194 | depBtn->setChecked( TRUE ); |
172 | slotDepositClicked(); | 195 | slotDepositClicked(); |
173 | } | 196 | } |
174 | QDate dt = info->date(); | 197 | |
175 | slotDateChanged( dt.year(), dt.month(), dt.day() ); | 198 | if( !bPopulateOld ) { |
176 | datePicker->setDate( dt ); | 199 | QDate dt = info->date(); |
177 | numEdit->setText( info->number() ); | 200 | slotDateChanged( dt.year(), dt.month(), dt.day() ); |
178 | descEdit->setText( info->desc() ); | 201 | datePicker->setDate( dt ); |
202 | numEdit->setText( info->number() ); | ||
203 | } | ||
179 | QString temptext = info->category(); | 204 | QString temptext = info->category(); |
180 | int i = catList->count(); | 205 | |
206 | // set description field | ||
207 | int i; | ||
208 | for(i=_cbDesc->count()-1; i>=0; i--) { | ||
209 | if( _cbDesc->text(i)==info->desc() ) { | ||
210 | _cbDesc->setCurrentItem(i); | ||
211 | break; | ||
212 | } | ||
213 | } | ||
214 | if( i<=0 ) | ||
215 | _cbDesc->setEditText( info->desc() ); | ||
216 | |||
217 | i = catList->count(); | ||
181 | while ( i > 0 ) | 218 | while ( i > 0 ) |
182 | { | 219 | { |
183 | i--; | 220 | i--; |
184 | catList->setCurrentItem( i ); | 221 | catList->setCurrentItem( i ); |
185 | if ( catList->currentText() == temptext ) | 222 | if ( catList->currentText() == temptext ) |
186 | { | 223 | { |
187 | break; | 224 | break; |
188 | } | 225 | } |
189 | } | 226 | } |
190 | temptext = info->type(); | 227 | temptext = info->type(); |
191 | i = typeList->count(); | 228 | i = typeList->count(); |
192 | while ( i > 0 ) | 229 | while ( i > 0 ) |
193 | { | 230 | { |
194 | i--; | 231 | i--; |
195 | typeList->setCurrentItem( i ); | 232 | typeList->setCurrentItem( i ); |
196 | if ( typeList->currentText() == temptext ) | 233 | if ( typeList->currentText() == temptext ) |
197 | { | 234 | { |
198 | break; | 235 | break; |
199 | } | 236 | } |
200 | } | 237 | } |
201 | amtEdit->setText( QString( "%1" ).arg( info->amount(), 0, 'f', 2 ) ); | 238 | amtEdit->setText( QString( "%1" ).arg( info->amount(), 0, 'f', 2 ) ); |
202 | feeEdit->setText( QString( "%1" ).arg( info->fee(), 0, 'f', 2 ) ); | 239 | feeEdit->setText( QString( "%1" ).arg( info->fee(), 0, 'f', 2 ) ); |
203 | noteEdit->setText( info->notes() ); | 240 | noteEdit->setText( info->notes() ); |
204 | } | 241 | } |
205 | else | 242 | else |
206 | { | 243 | { |
207 | withBtn->setChecked( TRUE ); | 244 | withBtn->setChecked( TRUE ); |
208 | } | 245 | } |
209 | } | 246 | } |
210 | 247 | ||
248 | |||
249 | // --- ~Transaction ----------------------------------------------------------- | ||
211 | Transaction::~Transaction() | 250 | Transaction::~Transaction() |
212 | { | 251 | { |
213 | } | 252 | } |
214 | 253 | ||
254 | // --- accept ----------------------------------------------------------------- | ||
215 | void Transaction::accept() | 255 | void Transaction::accept() |
216 | { | 256 | { |
217 | tran->setDesc( descEdit->text() ); | 257 | tran->setDesc( _cbDesc->currentText() ); |
218 | tran->setDate( datePicker->selectedDate() ); | 258 | tran->setDate( datePicker->selectedDate() ); |
219 | tran->setWithdrawal( withBtn->isChecked() ); | 259 | tran->setWithdrawal( withBtn->isChecked() ); |
220 | tran->setType( typeList->currentText() ); | 260 | tran->setType( typeList->currentText() ); |
221 | tran->setCategory( catList->currentText() ); | 261 | tran->setCategory( catList->currentText() ); |
222 | bool ok; | 262 | bool ok; |
223 | tran->setAmount( amtEdit->text().toFloat( &ok ) ); | 263 | tran->setAmount( amtEdit->text().toFloat( &ok ) ); |
224 | tran->setFee( feeEdit->text().toFloat( &ok ) ); | 264 | tran->setFee( feeEdit->text().toFloat( &ok ) ); |
225 | tran->setNumber( numEdit->text() ); | 265 | tran->setNumber( numEdit->text() ); |
226 | tran->setNotes( noteEdit->text() ); | 266 | tran->setNotes( noteEdit->text() ); |
227 | 267 | ||
228 | QDialog::accept(); | 268 | QDialog::accept(); |
229 | } | 269 | } |
230 | 270 | ||
231 | void Transaction::slotWithdrawalClicked() | 271 | void Transaction::slotWithdrawalClicked() |
232 | { | 272 | { |
233 | catList->clear(); | 273 | catList->clear(); |
234 | CategoryList *pCatList=_pCfg->getCategoryList(); | 274 | CategoryList *pCatList=_pCfg->getCategoryList(); |
235 | for(Category *pCat=pCatList->first(); pCat; pCat=pCatList->next()) { | 275 | for(Category *pCat=pCatList->first(); pCat; pCat=pCatList->next()) { |
236 | if( !pCat->isIncome() ) | 276 | if( !pCat->isIncome() ) |
237 | catList->insertItem( pCat->getName() ); | 277 | catList->insertItem( pCat->getName() ); |
238 | } | 278 | } |
239 | catList->setCurrentItem(0); | 279 | catList->setCurrentItem(0); |
240 | 280 | ||
241 | typeList->clear(); | 281 | typeList->clear(); |
242 | typeList->insertItem( tr( "Debit Charge" ) ); | 282 | typeList->insertItem( tr( "Debit Charge" ) ); |
243 | typeList->insertItem( tr( "Written Check" ) ); | 283 | typeList->insertItem( tr( "Written Check" ) ); |
244 | typeList->insertItem( tr( "Transfer" ) ); | 284 | typeList->insertItem( tr( "Transfer" ) ); |
245 | typeList->insertItem( tr( "Credit Card" ) ); | 285 | typeList->insertItem( tr( "Credit Card" ) ); |
246 | } | 286 | } |
247 | 287 | ||
248 | void Transaction::slotDepositClicked() | 288 | void Transaction::slotDepositClicked() |
249 | { | 289 | { |
250 | catList->clear(); | 290 | catList->clear(); |
251 | CategoryList *pCatList=_pCfg->getCategoryList(); | 291 | CategoryList *pCatList=_pCfg->getCategoryList(); |
252 | for(Category *pCat=pCatList->first(); pCat; pCat=pCatList->next()) { | 292 | for(Category *pCat=pCatList->first(); pCat; pCat=pCatList->next()) { |
253 | if( pCat->isIncome() ) | 293 | if( pCat->isIncome() ) |
254 | catList->insertItem( pCat->getName() ); | 294 | catList->insertItem( pCat->getName() ); |
255 | } | 295 | } |
256 | catList->setCurrentItem( 0 ); | 296 | catList->setCurrentItem( 0 ); |
257 | 297 | ||
258 | typeList->clear(); | 298 | typeList->clear(); |
259 | typeList->insertItem( tr( "Written Check" ) ); | 299 | typeList->insertItem( tr( "Written Check" ) ); |
260 | typeList->insertItem( tr( "Automatic Payment" ) ); | 300 | typeList->insertItem( tr( "Automatic Payment" ) ); |
261 | typeList->insertItem( tr( "Transfer" ) ); | 301 | typeList->insertItem( tr( "Transfer" ) ); |
262 | typeList->insertItem( tr( "Cash" ) ); | 302 | typeList->insertItem( tr( "Cash" ) ); |
263 | } | 303 | } |
264 | 304 | ||
305 | // --- slotDateChanged -------------------------------------------------------- | ||
265 | void Transaction::slotDateChanged( int y, int m, int d ) | 306 | void Transaction::slotDateChanged( int y, int m, int d ) |
266 | { | 307 | { |
267 | QDate date; | 308 | QDate date; |
268 | date.setYMD( y, m, d ); | 309 | date.setYMD( y, m, d ); |
269 | dateBtn->setText( TimeString::shortDate( date ) ); | 310 | dateBtn->setText( TimeString::shortDate( date ) ); |
270 | } | 311 | } |
312 | |||
313 | |||
314 | |||
315 | // --- slotActivated ---------------------------------------------------------- | ||
316 | // Search for the most recent transaction with this description/payee and | ||
317 | // fill amount etc here, as long the new flag is set | ||
318 | void Transaction::slotActivated(const QString &arg ) | ||
319 | { | ||
320 | if( !_bNew ) return; | ||
321 | TranInfoList *pTl=((Checkbook *)parentWidget())->getTranList(); | ||
322 | if( pTl ) { | ||
323 | TranInfo *pTi=pTl->findMostRecentByDesc( arg ); | ||
324 | if( pTi ) { | ||
325 | initFromInfo( pTi, true ); | ||
326 | amtEdit->setFocus(); | ||
327 | amtEdit->setSelection(0, amtEdit->text().length() ); | ||
328 | amtEdit->setCursorPosition(0); | ||
329 | } | ||
330 | } | ||
331 | } | ||
332 | |||
333 | // slotNotNew ----------------------------------------------------------------- | ||
334 | void Transaction::slotNotNew() | ||
335 | { | ||
336 | qDebug("Not new"); | ||
337 | _bNew=false; | ||
338 | } | ||
diff --git a/noncore/apps/checkbook/transaction.h b/noncore/apps/checkbook/transaction.h index fbe9cd3..130d769 100644 --- a/noncore/apps/checkbook/transaction.h +++ b/noncore/apps/checkbook/transaction.h | |||
@@ -18,62 +18,66 @@ | |||
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 TRANSACTION_H | 29 | #ifndef TRANSACTION_H |
30 | #define TRANSACTION_H | 30 | #define TRANSACTION_H |
31 | 31 | ||
32 | #include <qdialog.h> | 32 | #include <qdialog.h> |
33 | 33 | ||
34 | class DateBookMonth; | 34 | class DateBookMonth; |
35 | class QComboBox; | 35 | class QComboBox; |
36 | class QLineEdit; | 36 | class QLineEdit; |
37 | class QMultiLineEdit; | 37 | class QMultiLineEdit; |
38 | class QPushButton; | 38 | class QPushButton; |
39 | class QRadioButton; | 39 | class QRadioButton; |
40 | class QString; | 40 | class QString; |
41 | class QWidget; | 41 | class QWidget; |
42 | class TranInfo; | 42 | class TranInfo; |
43 | class Cfg; | 43 | class Cfg; |
44 | 44 | ||
45 | class Transaction : public QDialog | 45 | class Transaction : public QDialog |
46 | { | 46 | { |
47 | Q_OBJECT | 47 | Q_OBJECT |
48 | 48 | ||
49 | public: | 49 | public: |
50 | Transaction( QWidget *, const QString &, TranInfo *, Cfg *); | 50 | Transaction( QWidget *, bool, const QString &, TranInfo *, Cfg *); |
51 | ~Transaction(); | 51 | ~Transaction(); |
52 | 52 | ||
53 | private: | 53 | void initFromInfo(TranInfo *, bool=false); |
54 | TranInfo *tran; | ||
55 | 54 | ||
55 | private: | ||
56 | TranInfo *tran; | ||
57 | bool _bNew; | ||
56 | Cfg *_pCfg; | 58 | Cfg *_pCfg; |
57 | 59 | ||
58 | QRadioButton *withBtn; | 60 | QRadioButton *withBtn; |
59 | QRadioButton *depBtn; | 61 | QRadioButton *depBtn; |
60 | QPushButton *dateBtn; | 62 | QPushButton *dateBtn; |
61 | DateBookMonth *datePicker; | 63 | DateBookMonth *datePicker; |
62 | QLineEdit *numEdit; | 64 | QLineEdit *numEdit; |
63 | QLineEdit *descEdit; | 65 | QComboBox *_cbDesc; |
64 | QComboBox *catList; | 66 | QComboBox *catList; |
65 | QComboBox *typeList; | 67 | QComboBox *typeList; |
66 | QLineEdit *amtEdit; | 68 | QLineEdit *amtEdit; |
67 | QLineEdit *feeEdit; | 69 | QLineEdit *feeEdit; |
68 | QMultiLineEdit *noteEdit; | 70 | QMultiLineEdit *noteEdit; |
69 | 71 | ||
70 | protected slots: | 72 | protected slots: |
71 | void accept(); | 73 | void accept(); |
72 | 74 | ||
73 | private slots: | 75 | private slots: |
74 | void slotWithdrawalClicked(); | 76 | void slotWithdrawalClicked(); |
75 | void slotDepositClicked(); | 77 | void slotDepositClicked(); |
76 | void slotDateChanged( int, int, int ); | 78 | void slotDateChanged( int, int, int ); |
79 | void slotActivated(const QString & ); | ||
80 | void slotNotNew(); | ||
77 | }; | 81 | }; |
78 | 82 | ||
79 | #endif | 83 | #endif |