summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-10-30 13:18:08 (UTC)
committer mickeyl <mickeyl>2003-10-30 13:18:08 (UTC)
commit37414f207b147af4cf6778b323a0aa23127901bd (patch) (unidiff)
treeb08c10043ab689b0a40425d268cd72226799b0cf
parentd53637f46cf217fc760d7aac58b4596843a73803 (diff)
downloadopie-37414f207b147af4cf6778b323a0aa23127901bd.zip
opie-37414f207b147af4cf6778b323a0aa23127901bd.tar.gz
opie-37414f207b147af4cf6778b323a0aa23127901bd.tar.bz2
apply patch to HEAD
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/checkbook/cfg.cpp15
-rw-r--r--noncore/apps/checkbook/cfg.h16
-rw-r--r--noncore/apps/checkbook/checkbook.cpp91
-rw-r--r--noncore/apps/checkbook/checkbook.h8
-rw-r--r--noncore/apps/checkbook/configuration.cpp16
-rw-r--r--noncore/apps/checkbook/configuration.h2
-rw-r--r--noncore/apps/checkbook/listedit.cpp4
-rw-r--r--noncore/apps/checkbook/mainwindow.cpp7
-rw-r--r--noncore/apps/checkbook/traninfo.cpp25
-rw-r--r--noncore/apps/checkbook/traninfo.h5
-rw-r--r--noncore/apps/checkbook/transaction.cpp92
-rw-r--r--noncore/apps/checkbook/transaction.h12
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
@@ -1,213 +1,224 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 =. 3 =.
4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> 4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .: 19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include <stdio.h> 29#include <stdio.h>
30 30
31#include <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 --------------------------------------------------------------------
40Cfg::Cfg() 40Cfg::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.
53void Cfg::readStringList(Config &cfg, const char *sKey, QStringList &lst) 54void Cfg::readStringList(Config &cfg, const char *sKey, QStringList &lst)
54{ 55{
55qDebug( "%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"
77void Cfg::readConfig(Config &config) 76void 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
140void Cfg::writeStringList(Config &cfg, const char *sKey, QStringList &lst) 146void 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
157void Cfg::writeConfig(Config &config) 163void 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 ----------------------------------------------------------
183QStringList Cfg::getCategories() 194QStringList 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 ----------------------------------------------------------
196void Cfg::setCategories(QStringList &lst) 207void 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 ------------------------------------------------------------
210CategoryList::CategoryList() : QList<Category>() 221CategoryList::CategoryList() : QList<Category>()
211{ 222{
212 setAutoDelete(true); 223 setAutoDelete(true);
213} 224}
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
@@ -1,120 +1,132 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 =. 3 =.
4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> 4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .: 19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#ifndef CFG_H 29#ifndef CFG_H
30#define CFG_H 30#define CFG_H
31 31
32#include <qstring.h> 32#include <qstring.h>
33#include <qlist.h> 33#include <qlist.h>
34#include <qstringlist.h> 34#include <qstringlist.h>
35class Config; 35class Config;
36 36
37// --- Category --------------------------------------------------------------- 37// --- Category ---------------------------------------------------------------
38class Category 38class Category
39{ 39{
40 public: 40 public:
41 // --- Constructor: 41 // --- Constructor:
42 Category(QString &sName, bool bIncome=false) { _sName=sName; _bIncome=bIncome; } 42 Category(QString &sName, bool bIncome=false) { _sName=sName; _bIncome=bIncome; }
43 43
44 // members 44 // members
45 QString &getName() { return(_sName); } 45 QString &getName() { return(_sName); }
46 bool isIncome() { return(_bIncome); } 46 bool isIncome() { return(_bIncome); }
47 void setName(QString &sName) { _sName=sName; } 47 void setName(QString &sName) { _sName=sName; }
48 void setIncome(bool bIncome) { _bIncome=bIncome; } 48 void setIncome(bool bIncome) { _bIncome=bIncome; }
49 49
50 private: 50 private:
51 QString _sName; 51 QString _sName;
52 bool _bIncome; 52 bool _bIncome;
53}; 53};
54 54
55class CategoryList : public QList<Category> 55class 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 --------------------------------------------------------------------
64class Cfg 64class 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
@@ -1,730 +1,789 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 =. 3 =.
4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> 4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .: 19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include "checkbook.h" 29#include "checkbook.h"
30#include "cbinfo.h" 30#include "cbinfo.h"
31#include "transaction.h" 31#include "transaction.h"
32#include "traninfo.h" 32#include "traninfo.h"
33#include "graph.h" 33#include "graph.h"
34#include "graphinfo.h" 34#include "graphinfo.h"
35#include "password.h" 35#include "password.h"
36#include "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 --------------------------------------------------------------
61Checkbook::Checkbook( QWidget *parent, CBInfo *i, Cfg *cfg ) 63Checkbook::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" ) );
91 mainWidget->addTab( initCharts(), "checkbook/charttab", tr( "Charts" ) ); 93 mainWidget->addTab( initCharts(), "checkbook/charttab", tr( "Charts" ) );
92 if( _pCfg->isShowLastTab() ) 94 if( _pCfg->isShowLastTab() )
93 mainWidget->setCurrentTab( info->getLastTab() ); 95 mainWidget->setCurrentTab( info->getLastTab() );
94 else 96 else
95 mainWidget->setCurrentTab( tr( "Info" ) ); 97 mainWidget->setCurrentTab( tr( "Info" ) );
96 connect( mainWidget, SIGNAL( currentChanged(QWidget *) ), this, SLOT( slotTab(QWidget *) ) ); 98 connect( mainWidget, SIGNAL( currentChanged(QWidget *) ), this, SLOT( slotTab(QWidget *) ) );
97 99
98 // Load checkbook information 100 // Load checkbook information
99 loadCheckbook(); 101 loadCheckbook();
100} 102}
101 103
102Checkbook::~Checkbook() 104Checkbook::~Checkbook()
103{ 105{
104} 106}
105 107
106// --- initInfo --------------------------------------------------------------- 108// --- initInfo ---------------------------------------------------------------
107QWidget *Checkbook::initInfo() 109QWidget *Checkbook::initInfo()
108{ 110{
109 QWidget *control = new QWidget( mainWidget, tr("Info") ); 111 QWidget *control = new QWidget( mainWidget, tr("Info") );
110 112
111 QVBoxLayout *vb = new QVBoxLayout( control ); 113 QVBoxLayout *vb = new QVBoxLayout( control );
112 114
113 QScrollView *sv = new QScrollView( control ); 115 QScrollView *sv = new QScrollView( control );
114 vb->addWidget( sv, 0, 0 ); 116 vb->addWidget( sv, 0, 0 );
115 sv->setResizePolicy( QScrollView::AutoOneFit ); 117 sv->setResizePolicy( QScrollView::AutoOneFit );
116 sv->setFrameStyle( QFrame::NoFrame ); 118 sv->setFrameStyle( QFrame::NoFrame );
117 119
118 QWidget *container = new QWidget( sv->viewport() ); 120 QWidget *container = new QWidget( sv->viewport() );
119 sv->addChild( container ); 121 sv->addChild( container );
120 122
121 QGridLayout *layout = new QGridLayout( container ); 123 QGridLayout *layout = new QGridLayout( container );
122 layout->setSpacing( 2 ); 124 layout->setSpacing( 2 );
123 layout->setMargin( 4 ); 125 layout->setMargin( 4 );
124 126
125 // Password protection 127 // Password protection
126 passwordCB = new QCheckBox( tr( "Password protect" ), container ); 128 passwordCB = new QCheckBox( tr( "Password protect" ), container );
127 QWhatsThis::add( passwordCB, tr( "Click here to enable/disable password protection of this checkbook." ) ); 129 QWhatsThis::add( passwordCB, tr( "Click here to enable/disable password protection of this checkbook." ) );
128 connect( passwordCB, SIGNAL( clicked() ), this, SLOT( slotPasswordClicked() ) ); 130 connect( passwordCB, SIGNAL( clicked() ), this, SLOT( slotPasswordClicked() ) );
129 layout->addMultiCellWidget( passwordCB, 0, 0, 0, 1 ); 131 layout->addMultiCellWidget( passwordCB, 0, 0, 0, 1 );
130 132
131 // Account name 133 // Account name
132 QLabel *label = new QLabel( tr( "Name:" ), container ); 134 QLabel *label = new QLabel( tr( "Name:" ), container );
133 QWhatsThis::add( label, tr( "Enter name of checkbook here." ) ); 135 QWhatsThis::add( label, tr( "Enter name of checkbook here." ) );
134 layout->addWidget( label, 1, 0 ); 136 layout->addWidget( label, 1, 0 );
135 nameEdit = new QLineEdit( container ); 137 nameEdit = new QLineEdit( container );
136 QWhatsThis::add( nameEdit, tr( "Enter name of checkbook here." ) ); 138 QWhatsThis::add( nameEdit, tr( "Enter name of checkbook here." ) );
137 connect( nameEdit, SIGNAL( textChanged( const QString & ) ), 139 connect( nameEdit, SIGNAL( textChanged( const QString & ) ),
138 this, SLOT( slotNameChanged( const QString & ) ) ); 140 this, SLOT( slotNameChanged( const QString & ) ) );
139 layout->addWidget( nameEdit, 1, 1 ); 141 layout->addWidget( nameEdit, 1, 1 );
140 142
141 // Type of account 143 // Type of account
142 label = new QLabel( tr( "Type:" ), container ); 144 label = new QLabel( tr( "Type:" ), container );
143 QWhatsThis::add( label, tr( "Select type of checkbook here." ) ); 145 QWhatsThis::add( label, tr( "Select type of checkbook here." ) );
144 layout->addWidget( label, 2, 0 ); 146 layout->addWidget( label, 2, 0 );
145 typeList = new QComboBox( container ); 147 typeList = new QComboBox( container );
146 QWhatsThis::add( typeList, tr( "Select type of checkbook here." ) ); 148 QWhatsThis::add( typeList, tr( "Select type of checkbook here." ) );
147 typeList->insertStringList( _pCfg->getAccountTypes() ); 149 typeList->insertStringList( _pCfg->getAccountTypes() );
148 layout->addWidget( typeList, 2, 1 ); 150 layout->addWidget( typeList, 2, 1 );
149 151
150 // Bank/institution name 152 // Bank/institution name
151 label = new QLabel( tr( "Bank:" ), container ); 153 label = new QLabel( tr( "Bank:" ), container );
152 QWhatsThis::add( label, tr( "Enter name of the bank for this checkbook here." ) ); 154 QWhatsThis::add( label, tr( "Enter name of the bank for this checkbook here." ) );
153 layout->addWidget( label, 3, 0 ); 155 layout->addWidget( label, 3, 0 );
154 bankEdit = new QLineEdit( container ); 156 bankEdit = new QLineEdit( container );
155 QWhatsThis::add( bankEdit, tr( "Enter name of the bank for this checkbook here." ) ); 157 QWhatsThis::add( bankEdit, tr( "Enter name of the bank for this checkbook here." ) );
156 layout->addWidget( bankEdit, 3, 1 ); 158 layout->addWidget( bankEdit, 3, 1 );
157 159
158 // Account number 160 // Account number
159 label = new QLabel( tr( "Account number:" ), container ); 161 label = new QLabel( tr( "Account number:" ), container );
160 QWhatsThis::add( label, tr( "Enter account number for this checkbook here." ) ); 162 QWhatsThis::add( label, tr( "Enter account number for this checkbook here." ) );
161 layout->addWidget( label, 4, 0 ); 163 layout->addWidget( label, 4, 0 );
162 acctNumEdit = new QLineEdit( container ); 164 acctNumEdit = new QLineEdit( container );
163 QWhatsThis::add( acctNumEdit, tr( "Enter account number for this checkbook here." ) ); 165 QWhatsThis::add( acctNumEdit, tr( "Enter account number for this checkbook here." ) );
164 layout->addWidget( acctNumEdit, 4, 1 ); 166 layout->addWidget( acctNumEdit, 4, 1 );
165 167
166 // PIN number 168 // PIN number
167 label = new QLabel( tr( "PIN number:" ), container ); 169 label = new QLabel( tr( "PIN number:" ), container );
168 QWhatsThis::add( label, tr( "Enter PIN number for this checkbook here." ) ); 170 QWhatsThis::add( label, tr( "Enter PIN number for this checkbook here." ) );
169 layout->addWidget( label, 5, 0 ); 171 layout->addWidget( label, 5, 0 );
170 pinNumEdit = new QLineEdit( container ); 172 pinNumEdit = new QLineEdit( container );
171 QWhatsThis::add( pinNumEdit, tr( "Enter PIN number for this checkbook here." ) ); 173 QWhatsThis::add( pinNumEdit, tr( "Enter PIN number for this checkbook here." ) );
172 layout->addWidget( pinNumEdit, 5, 1 ); 174 layout->addWidget( pinNumEdit, 5, 1 );
173 175
174 // Starting balance 176 // Starting balance
175 label = new QLabel( tr( "Starting balance:" ), container ); 177 label = new QLabel( tr( "Starting balance:" ), container );
176 QWhatsThis::add( label, tr( "Enter the initial balance for this checkbook here." ) ); 178 QWhatsThis::add( label, tr( "Enter the initial balance for this checkbook here." ) );
177 layout->addWidget( label, 6, 0 ); 179 layout->addWidget( label, 6, 0 );
178 balanceEdit = new QLineEdit( container ); 180 balanceEdit = new QLineEdit( container );
179 QWhatsThis::add( balanceEdit, tr( "Enter the initial balance for this checkbook here." ) ); 181 QWhatsThis::add( balanceEdit, tr( "Enter the initial balance for this checkbook here." ) );
180 connect( balanceEdit, SIGNAL( textChanged( const QString & ) ), 182 connect( balanceEdit, SIGNAL( textChanged( const QString & ) ),
181 this, SLOT( slotStartingBalanceChanged( const QString & ) ) ); 183 this, SLOT( slotStartingBalanceChanged( const QString & ) ) );
182 layout->addWidget( balanceEdit, 6, 1 ); 184 layout->addWidget( balanceEdit, 6, 1 );
183 185
184 // Notes 186 // Notes
185 label = new QLabel( tr( "Notes:" ), container ); 187 label = new QLabel( tr( "Notes:" ), container );
186 QWhatsThis::add( label, tr( "Enter any additional information for this checkbook here." ) ); 188 QWhatsThis::add( label, tr( "Enter any additional information for this checkbook here." ) );
187 layout->addWidget( label, 7, 0 ); 189 layout->addWidget( label, 7, 0 );
188 notesEdit = new QMultiLineEdit( container ); 190 notesEdit = new QMultiLineEdit( container );
189 QWhatsThis::add( notesEdit, tr( "Enter any additional information for this checkbook here." ) ); 191 QWhatsThis::add( notesEdit, tr( "Enter any additional information for this checkbook here." ) );
190 notesEdit->setMinimumHeight( 25 ); 192 notesEdit->setMinimumHeight( 25 );
191 notesEdit->setMaximumHeight( 65 ); 193 notesEdit->setMaximumHeight( 65 );
192 layout->addMultiCellWidget( notesEdit, 8, 8, 0, 1 ); 194 layout->addMultiCellWidget( notesEdit, 8, 8, 0, 1 );
193 195
194 return control; 196 return control;
195} 197}
196 198
197 199
198// --- initTransactions ------------------------------------------------------- 200// --- initTransactions -------------------------------------------------------
199QWidget *Checkbook::initTransactions() 201QWidget *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 -------------------------------------------------------------
264QWidget *Checkbook::initCharts() 271QWidget *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 );
273 280
274 graphWidget = new Graph( control ); 281 graphWidget = new Graph( control );
275 QWhatsThis::add( graphWidget, tr( "Select the desired chart below and then click on the Draw button." ) ); 282 QWhatsThis::add( graphWidget, tr( "Select the desired chart below and then click on the Draw button." ) );
276 layout->addMultiCellWidget( graphWidget, 0, 0, 0, 2 ); 283 layout->addMultiCellWidget( graphWidget, 0, 0, 0, 2 );
277 284
278 graphList = new QComboBox( control ); 285 graphList = new QComboBox( control );
279 QWhatsThis::add( graphList, tr( "Click here to select the desired chart type." ) ); 286 QWhatsThis::add( graphList, tr( "Click here to select the desired chart type." ) );
280 graphList->insertItem( tr( "Account balance" ) ); 287 graphList->insertItem( tr( "Account balance" ) );
281 graphList->insertItem( tr( "Withdrawals by category" ) ); 288 graphList->insertItem( tr( "Withdrawals by category" ) );
282 graphList->insertItem( tr( "Deposits by category" ) ); 289 graphList->insertItem( tr( "Deposits by category" ) );
283 290
284 layout->addMultiCellWidget( graphList, 1, 1, 0, 1 ); 291 layout->addMultiCellWidget( graphList, 1, 1, 0, 1 );
285 292
286 QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/drawbtn" ), tr( "Draw" ), control ); 293 QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/drawbtn" ), tr( "Draw" ), control );
287 QWhatsThis::add( btn, tr( "Click here to draw the selected chart." ) ); 294 QWhatsThis::add( btn, tr( "Click here to draw the selected chart." ) );
288 connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) ); 295 connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) );
289 layout->addWidget( btn, 1, 2 ); 296 layout->addWidget( btn, 1, 2 );
290 297
291 return control; 298 return control;
292} 299}
293 300
294// --- loadCheckbook ---------------------------------------------------------- 301// --- loadCheckbook ----------------------------------------------------------
295void Checkbook::loadCheckbook() 302void Checkbook::loadCheckbook()
296{ 303{
297 if ( !info ) 304 if ( !info )
298 { 305 {
299 return; 306 return;
300 } 307 }
301 308
302 tranList = info->transactions(); 309 tranList = info->transactions();
303 310
304 passwordCB->setChecked( !info->password().isNull() ); 311 passwordCB->setChecked( !info->password().isNull() );
305 nameEdit->setText( info->name() ); 312 nameEdit->setText( info->name() );
306 QString temptext = info->type(); 313 QString temptext = info->type();
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 ----------------------------------------------------------
362void Checkbook::adjustBalance() 370void 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 -----------------------------------------------------------------
376void Checkbook::resort() 384void 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 -----------------------------------------------------------------
385void Checkbook::accept() 393void 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 ----------------------------------------------------
399void Checkbook::slotPasswordClicked() 408void 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;
431 } 440 }
432 else 441 else
433 { 442 {
434 passwordCB->setChecked( TRUE ); 443 passwordCB->setChecked( TRUE );
435 } 444 }
436 445
437 delete pw; 446 delete pw;
438 } 447 }
439} 448}
440 449
441void Checkbook::slotNameChanged( const QString &newname ) 450void 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 ----------------------------------------------
459void Checkbook::slotStartingBalanceChanged( const QString &newbalance ) 468void 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 ------------------------------------------------------------
467void Checkbook::slotNewTran() 477void 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 -----------------------------------------------------------
502void Checkbook::slotEditTran() 522void 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 -----------------------------------------------------------
565void 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 ---------------------------------------------------------
535void Checkbook::slotDeleteTran() 592void 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
551void Checkbook::slotDrawGraph() 608void 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
572void Checkbook::drawBalanceChart() 629void 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
606void Checkbook::drawCategoryChart( bool withdrawals ) 663void 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 {
627 break; 684 break;
628 } 685 }
629 } 686 }
630 if ( cat && cat->label() == tran->category() ) 687 if ( cat && cat->label() == tran->category() )
631 { // Found category, add to transaction to category total 688 { // Found category, add to transaction to category total
632 cat->addToValue( tran->amount() ); 689 cat->addToValue( tran->amount() );
633 } 690 }
634 else 691 else
635 { // Didn't find category, add category to list 692 { // Didn't find category, add category to list
636 list->append( new DataPointInfo( tran->category(), tran->amount() ) ); 693 list->append( new DataPointInfo( tran->category(), tran->amount() ) );
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
644CBListItem::CBListItem( TranInfo *pTran, QListView *parent, QString label1, QString label2, 701CBListItem::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
654void CBListItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align ) 711void 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 --------------------------------------------
669bool CBListItem::isAltBackground() 727bool 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 ----------------------------------------------------------------
711void Checkbook::slotTab(QWidget *tab) 769void 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 ---------------------------------------------------------
719void Checkbook::slotSortChanged( const QString &selc ) 777void 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
@@ -1,142 +1,148 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 =. 3 =.
4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> 4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .: 19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#ifndef 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
36class OTabWidget; 36class OTabWidget;
37 37
38class CBInfo; 38class CBInfo;
39class Graph; 39class Graph;
40class GraphInfo; 40class GraphInfo;
41class QCheckBox; 41class QCheckBox;
42class QComboBox; 42class QComboBox;
43class QLabel; 43class QLabel;
44class QLineEdit; 44class QLineEdit;
45class QListView; 45class QListView;
46class QMultiLineEdit; 46class QMultiLineEdit;
47class QString; 47class QString;
48class TranInfo; 48class TranInfo;
49class TranInfoList; 49class TranInfoList;
50class Cfg; 50class Cfg;
51class QMouseEvent;
51 52
52 53
53// --- Checkbook -------------------------------------------------------------- 54// --- Checkbook --------------------------------------------------------------
54class Checkbook : public QDialog 55class 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 -------------------------------------------------------------
118class CBListItem : public QListViewItem 124class 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
@@ -1,161 +1,177 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 =. 3 =.
4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> 4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .: 19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include "configuration.h" 29#include "configuration.h"
30#include "mainwindow.h" 30#include "mainwindow.h"
31#include "listedit.h" 31#include "listedit.h"
32#include "tabledef.h" 32#include "tabledef.h"
33 33
34#include <qcheckbox.h> 34#include <qcheckbox.h>
35#include <qlabel.h> 35#include <qlabel.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qlineedit.h> 37#include <qlineedit.h>
38#include <qwhatsthis.h> 38#include <qwhatsthis.h>
39#include <qlistview.h> 39#include <qlistview.h>
40#include <qpushbutton.h> 40#include <qpushbutton.h>
41#include <qtabwidget.h> 41#include <qtabwidget.h>
42#include <qpe/resource.h> 42#include <qpe/resource.h>
43 43
44Configuration::Configuration( QWidget *parent, Cfg &cfg ) 44Configuration::Configuration( QWidget *parent, Cfg &cfg )
45 : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) 45 : QDialog( parent, 0, TRUE, WStyle_ContextHelp )
46{ 46{
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
81Configuration::~Configuration() 87Configuration::~Configuration()
82{ 88{
83} 89}
84 90
85// ---- initSettings ---------------------------------------------------------- 91// ---- initSettings ----------------------------------------------------------
86QWidget *Configuration::initSettings(Cfg &cfg) 92QWidget *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 -------------------------------------------------------------
145void Configuration::saveConfig(Cfg &cfg) 157void 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
@@ -1,67 +1,69 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 =. 3 =.
4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> 4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .: 19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#ifndef CONFIGURATION_H 29#ifndef CONFIGURATION_H
30#define CONFIGURATION_H 30#define CONFIGURATION_H
31 31
32#include <qdialog.h> 32#include <qdialog.h>
33#include "cfg.h" 33#include "cfg.h"
34 34
35class QCheckBox; 35class QCheckBox;
36class QLineEdit; 36class QLineEdit;
37class QString; 37class QString;
38class QTabWidget; 38class QTabWidget;
39class ListEdit; 39class ListEdit;
40 40
41class Configuration : public QDialog 41class 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
@@ -1,340 +1,344 @@
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 "listedit.h" 29#include "listedit.h"
30#include <qlayout.h> 30#include <qlayout.h>
31#include <qlineedit.h> 31#include <qlineedit.h>
32#include <qlistview.h> 32#include <qlistview.h>
33#include <qwidgetstack.h> 33#include <qwidgetstack.h>
34#include <qcombobox.h> 34#include <qcombobox.h>
35#include <qpushbutton.h> 35#include <qpushbutton.h>
36#include <qpe/resource.h> 36#include <qpe/resource.h>
37 37
38 38
39// --- ListEdit --------------------------------------------------------------- 39// --- ListEdit ---------------------------------------------------------------
40ListEdit::ListEdit( QWidget *parent, const char *sName ) 40ListEdit::ListEdit( QWidget *parent, const char *sName )
41 : QWidget(parent, sName), TableDef(sName) 41 : QWidget(parent, sName), TableDef(sName)
42{ 42{
43 // get font height 43 // get font height
44 int fh = fontMetrics().height(); 44 int fh = fontMetrics().height();
45 45
46 // create layout 46 // create layout
47 QGridLayout *layout=new QGridLayout(this); 47 QGridLayout *layout=new QGridLayout(this);
48 layout->setSpacing( 2 ); 48 layout->setSpacing( 2 );
49 layout->setMargin( 4 ); 49 layout->setMargin( 4 );
50 50
51 // type table 51 // type table
52 _typeTable = new QListView( this ); 52 _typeTable = new QListView( this );
53 ColumnDef *def=first(); 53 ColumnDef *def=first();
54 while( def ) { 54 while( def ) {
55 _typeTable->addColumn( def->getName() ); 55 _typeTable->addColumn( def->getName() );
56 def=next(); 56 def=next();
57 } 57 }
58 connect( _typeTable, SIGNAL( clicked(QListViewItem *, const QPoint &, int) ), this, SLOT( slotClick(QListViewItem *, const QPoint &, int ) ) ); 58 connect( _typeTable, SIGNAL( clicked(QListViewItem *, const QPoint &, int) ), this, SLOT( slotClick(QListViewItem *, const QPoint &, int ) ) );
59 layout->addMultiCellWidget(_typeTable, 0,4,0,4); 59 layout->addMultiCellWidget(_typeTable, 0,4,0,4);
60 _currentItem=NULL; 60 _currentItem=NULL;
61 61
62 // edit field 62 // edit field
63 _stack=new QWidgetStack( this ); 63 _stack=new QWidgetStack( this );
64 _stack->setMaximumHeight(fh+5); 64 _stack->setMaximumHeight(fh+5);
65 layout->addMultiCellWidget(_stack, 5,5,0,2); 65 layout->addMultiCellWidget(_stack, 5,5,0,2);
66 _typeEdit = new QLineEdit( _stack ); 66 _typeEdit = new QLineEdit( _stack );
67 _stack->raiseWidget(_typeEdit ); 67 _stack->raiseWidget(_typeEdit );
68 connect( _typeEdit, SIGNAL( textChanged(const QString &) ), this, SLOT( slotEditChanged(const QString &) ) ); 68 connect( _typeEdit, SIGNAL( textChanged(const QString &) ), this, SLOT( slotEditChanged(const QString &) ) );
69 69
70 // combo box 70 // combo box
71 _box=new QComboBox( _stack ); 71 _box=new QComboBox( _stack );
72 connect( _box, SIGNAL( activated(const QString &) ), this, SLOT( slotActivated(const QString &) ) ); 72 connect( _box, SIGNAL( activated(const QString &) ), this, SLOT( slotActivated(const QString &) ) );
73 73
74 74
75 // add button 75 // add button
76 QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/add" ), tr( "Add" ), this ); 76 QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/add" ), tr( "Add" ), this );
77 connect( btn, SIGNAL( clicked() ), this, SLOT( slotAdd() ) ); 77 connect( btn, SIGNAL( clicked() ), this, SLOT( slotAdd() ) );
78 layout->addWidget( btn, 5, 3 ); 78 layout->addWidget( btn, 5, 3 );
79 79
80 // delete button 80 // delete button
81 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), this ); 81 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), this );
82 connect( btn, SIGNAL( clicked() ), this, SLOT( slotDel() ) ); 82 connect( btn, SIGNAL( clicked() ), this, SLOT( slotDel() ) );
83 layout->addWidget( btn, 5, 4 ); 83 layout->addWidget( btn, 5, 4 );
84} 84}
85 85
86// --- ~ListEdit -------------------------------------------------------------- 86// --- ~ListEdit --------------------------------------------------------------
87ListEdit::~ListEdit() 87ListEdit::~ListEdit()
88{ 88{
89} 89}
90 90
91 91
92// --- slotEditTypeChanged ---------------------------------------------------- 92// --- slotEditTypeChanged ----------------------------------------------------
93void ListEdit::slotEditChanged(const QString &str) 93void 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 ------------------------------------------------------------
100void ListEdit::slotAdd() 100void 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 -------------------------------------------------------------
122void ListEdit::slotDel() 126void 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.
136class ColMap { 140class 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
150class ColList : public QList<QString> 154class ColList : public QList<QString>
151{ 155{
152 public: 156 public:
153 ColList() : QList<QString>() { } 157 ColList() : QList<QString>() { }
154 158
155 protected: 159 protected:
156 int compareItems(QCollection::Item, QCollection::Item); 160 int compareItems(QCollection::Item, QCollection::Item);
157}; 161};
158 162
159int ColList::compareItems(QCollection::Item i1, QCollection::Item i2) { 163int ColList::compareItems(QCollection::Item i1, QCollection::Item i2) {
160 return( ((QString *)i1)->compare(*(QString *)i2) ); 164 return( ((QString *)i1)->compare(*(QString *)i2) );
161} 165}
162 166
163void ListEdit::fixTypes(int iColumn) 167void ListEdit::fixTypes(int iColumn)
164{ 168{
165 // get column def 169 // get column def
166 ColumnDef *pDef=this->at(iColumn); 170 ColumnDef *pDef=this->at(iColumn);
167 171
168 // create map of entries 172 // create map of entries
169 if( !_typeTable->childCount() ) return; 173 if( !_typeTable->childCount() ) return;
170 ColMap **colMap=new (ColMap *)[_typeTable->childCount()]; 174 ColMap **colMap=new (ColMap *)[_typeTable->childCount()];
171 QListViewItem *cur=_typeTable->firstChild(); 175 QListViewItem *cur=_typeTable->firstChild();
172 ColList lst; 176 ColList lst;
173 for(int i=0; i<_typeTable->childCount(); i++) { 177 for(int i=0; i<_typeTable->childCount(); i++) {
174 colMap[i]=new ColMap(cur->text(iColumn), cur); 178 colMap[i]=new ColMap(cur->text(iColumn), cur);
175 lst.append( &(colMap[i]->getValue()) ); 179 lst.append( &(colMap[i]->getValue()) );
176 cur=cur->nextSibling(); 180 cur=cur->nextSibling();
177 } 181 }
178 182
179 // fix empty entries 183 // fix empty entries
180 int i=0; 184 int i=0;
181 for(QString *ptr=lst.first(); ptr; ptr=lst.next()) { 185 for(QString *ptr=lst.first(); ptr; ptr=lst.next()) {
182 *ptr=ptr->stripWhiteSpace(); 186 *ptr=ptr->stripWhiteSpace();
183 if( ptr->isEmpty() ) { 187 if( ptr->isEmpty() ) {
184 i++; 188 i++;
185 if( i==1 ) *ptr=pDef->getNewValue(); 189 if( i==1 ) *ptr=pDef->getNewValue();
186 else ptr->sprintf("%s %d", (const char *)pDef->getNewValue(), i); 190 else ptr->sprintf("%s %d", (const char *)pDef->getNewValue(), i);
187 } 191 }
188 } 192 }
189 193
190 // fix dups 194 // fix dups
191 lst.sort(); 195 lst.sort();
192 QString repl; 196 QString repl;
193 for(uint iCur=0; iCur<lst.count()-1; iCur++) { 197 for(uint iCur=0; iCur<lst.count()-1; iCur++) {
194 QString *current=lst.at(iCur); 198 QString *current=lst.at(iCur);
195 for(uint iNext=iCur+1; iNext<lst.count(); iNext++ ) { 199 for(uint iNext=iCur+1; iNext<lst.count(); iNext++ ) {
196 if( *current!=*lst.at(iNext) ) continue; 200 if( *current!=*lst.at(iNext) ) continue;
197 for(int i=2; ; i++) { 201 for(int i=2; ; i++) {
198 repl.sprintf("%s %d", (const char *)*current, i); 202 repl.sprintf("%s %d", (const char *)*current, i);
199 bool bDup=false; 203 bool bDup=false;
200 uint iChk=iNext+1; 204 uint iChk=iNext+1;
201 while( iChk<lst.count() ) { 205 while( iChk<lst.count() ) {
202 QString *chk=lst.at(iChk); 206 QString *chk=lst.at(iChk);
203 if( !chk->startsWith(*current) ) break; 207 if( !chk->startsWith(*current) ) break;
204 if( *chk==repl ) { 208 if( *chk==repl ) {
205 bDup=true; 209 bDup=true;
206 break; 210 break;
207 } 211 }
208 iChk++; 212 iChk++;
209 } 213 }
210 if( !bDup ) { 214 if( !bDup ) {
211 *lst.at(iNext)=repl; 215 *lst.at(iNext)=repl;
212 break; 216 break;
213 } 217 }
214 } 218 }
215 } 219 }
216 } 220 }
217 lst.sort(); 221 lst.sort();
218 222
219 // copy back clean up col map 223 // copy back clean up col map
220 for(int i=0; i<_typeTable->childCount(); i++) { 224 for(int i=0; i<_typeTable->childCount(); i++) {
221 colMap[i]->getItem()->setText(iColumn, colMap[i]->getValue()); 225 colMap[i]->getItem()->setText(iColumn, colMap[i]->getValue());
222 delete colMap[i]; 226 delete colMap[i];
223 } 227 }
224 delete colMap; 228 delete colMap;
225} 229}
226 230
227void ListEdit::fixTypes() 231void ListEdit::fixTypes()
228{ 232{
229 int i; 233 int i;
230 ColumnDef *pDef; 234 ColumnDef *pDef;
231 for(pDef=this->first(), i=0; pDef; pDef=this->next(), i++) { 235 for(pDef=this->first(), i=0; pDef; pDef=this->next(), i++) {
232 if( pDef->hasFlag(ColumnDef::typeUnique) ) 236 if( pDef->hasFlag(ColumnDef::typeUnique) )
233 fixTypes(i); 237 fixTypes(i);
234 } 238 }
235 _typeTable->sort(); 239 _typeTable->sort();
236} 240}
237 241
238 242
239// --- storeInList ------------------------------------------------------------ 243// --- storeInList ------------------------------------------------------------
240void ListEdit::storeInList(QStringList &lst) 244void ListEdit::storeInList(QStringList &lst)
241{ 245{
242 // delete old content 246 // delete old content
243 lst.clear(); 247 lst.clear();
244 248
245 // add new one 249 // add new one
246 fixTypes(); 250 fixTypes();
247 QListViewItem *itm=_typeTable->firstChild(); 251 QListViewItem *itm=_typeTable->firstChild();
248 while( itm ) { 252 while( itm ) {
249 int i=0; 253 int i=0;
250 QString sAdd; 254 QString sAdd;
251 ColumnDef *pDef; 255 ColumnDef *pDef;
252 for(pDef=this->first(), i=0; pDef; pDef=this->next(), i++) { 256 for(pDef=this->first(), i=0; pDef; pDef=this->next(), i++) {
253 if( i>=1 ) sAdd+=";"; 257 if( i>=1 ) sAdd+=";";
254 sAdd += itm->text(i); 258 sAdd += itm->text(i);
255 } 259 }
256 lst.append( sAdd ); 260 lst.append( sAdd );
257 itm=itm->nextSibling(); 261 itm=itm->nextSibling();
258 } 262 }
259} 263}
260 264
261 265
262// --- slotClicked ------------------------------------------------------------ 266// --- slotClicked ------------------------------------------------------------
263void ListEdit::slotClick(QListViewItem *itm, const QPoint &pnt, int col) 267void ListEdit::slotClick(QListViewItem *itm, const QPoint &pnt, int col)
264{ 268{
265 (void)pnt; // get rid of unused warning; 269 (void)pnt; // get rid of unused warning;
266 270
267 // save values 271 // save values
268 _currentItem=itm; 272 _currentItem=itm;
269 _currentColumn=col; 273 _currentColumn=col;
270 if( itm==NULL ) { 274 if( itm==NULL ) {
271 _typeEdit->setText(""); 275 _typeEdit->setText("");
272 _stack->raiseWidget(_typeEdit); 276 _stack->raiseWidget(_typeEdit);
273 return; 277 return;
274 } 278 }
275 279
276 // display value 280 // display value
277 if( _currentColumn<0 ) _currentColumn=0; 281 if( _currentColumn<0 ) _currentColumn=0;
278 ColumnDef *pDef=this->at(_currentColumn); 282 ColumnDef *pDef=this->at(_currentColumn);
279 if( pDef->isType(ColumnDef::typeString) ) { 283 if( pDef->isType(ColumnDef::typeString) ) {
280 _typeEdit->setText( _currentItem->text(_currentColumn) ); 284 _typeEdit->setText( _currentItem->text(_currentColumn) );
281 _stack->raiseWidget(_typeEdit); 285 _stack->raiseWidget(_typeEdit);
282 } else if( pDef->isType(ColumnDef::typeList) ){ 286 } else if( pDef->isType(ColumnDef::typeList) ){
283 _box->clear(); 287 _box->clear();
284 _box->insertStringList( pDef->getValueList() ); 288 _box->insertStringList( pDef->getValueList() );
285 QStringList::Iterator itr; 289 QStringList::Iterator itr;
286 int i=0; 290 int i=0;
287 for(itr=pDef->getValueList().begin(); itr!=pDef->getValueList().end(); itr++) { 291 for(itr=pDef->getValueList().begin(); itr!=pDef->getValueList().end(); itr++) {
288 if( (*itr)==_currentItem->text(_currentColumn) ) { 292 if( (*itr)==_currentItem->text(_currentColumn) ) {
289 _box->setCurrentItem(i); 293 _box->setCurrentItem(i);
290 i=-1; 294 i=-1;
291 break; 295 break;
292 } 296 }
293 i++; 297 i++;
294 } 298 }
295 if( i>=0 ) { 299 if( i>=0 ) {
296 _box->insertItem( _currentItem->text(_currentColumn) ); 300 _box->insertItem( _currentItem->text(_currentColumn) );
297 _box->setCurrentItem(i); 301 _box->setCurrentItem(i);
298 } 302 }
299 _stack->raiseWidget(_box); 303 _stack->raiseWidget(_box);
300 } else { 304 } else {
301 qDebug( "Unsupported column type for column %s", (const char *)pDef->getName() ); 305 qDebug( "Unsupported column type for column %s", (const char *)pDef->getName() );
302 _typeEdit->setText(""); 306 _typeEdit->setText("");
303 _stack->raiseWidget(_typeEdit); 307 _stack->raiseWidget(_typeEdit);
304 } 308 }
305} 309}
306 310
307 311
308// --- addColumnDef ----------------------------------------------------------- 312// --- addColumnDef -----------------------------------------------------------
309void ListEdit::addColumnDef(ColumnDef *pDef) 313void ListEdit::addColumnDef(ColumnDef *pDef)
310{ 314{
311 _typeTable->addColumn( pDef->getName() ); 315 _typeTable->addColumn( pDef->getName() );
312 _vColumns.append(pDef); 316 _vColumns.append(pDef);
313} 317}
314 318
315// --- addData ---------------------------------------------------------------- 319// --- addData ----------------------------------------------------------------
316void ListEdit::addData(QStringList &lst) 320void ListEdit::addData(QStringList &lst)
317{ 321{
318 // run through list 322 // run through list
319 QStringList::Iterator itr; 323 QStringList::Iterator itr;
320 for(itr=lst.begin(); itr!=lst.end(); itr++) { 324 for(itr=lst.begin(); itr!=lst.end(); itr++) {
321 QStringList split=QStringList::split(";", *itr, true); 325 QStringList split=QStringList::split(";", *itr, true);
322 QStringList::Iterator entry; 326 QStringList::Iterator entry;
323 QString args[8]; 327 QString args[8];
324 int i=0; 328 int i=0;
325 for(entry=split.begin(); entry!=split.end() && i<8; entry++, i++) { 329 for(entry=split.begin(); entry!=split.end() && i<8; entry++, i++) {
326 args[i]= (*entry); 330 args[i]= (*entry);
327 } 331 }
328 while(i<8) { 332 while(i<8) {
329 args[i++]=""; 333 args[i++]="";
330 } 334 }
331 new QListViewItem(_typeTable, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]); 335 new QListViewItem(_typeTable, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
332 } 336 }
333} 337}
334 338
335// --- slotActivated ---------------------------------------------------------- 339// --- slotActivated ----------------------------------------------------------
336void ListEdit::slotActivated(const QString &str) 340void ListEdit::slotActivated(const QString &str)
337{ 341{
338 if( _currentItem==NULL || _currentColumn<0 ) return; 342 if( _currentItem==NULL || _currentColumn<0 ) return;
339 _currentItem->setText(_currentColumn, str); 343 _currentItem->setText(_currentColumn, str);
340} 344}
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
@@ -1,360 +1,365 @@
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 "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
51MainWindow::MainWindow( QWidget* parent, const char* name, WFlags fl ) 51MainWindow::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" );
61qDebug( "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 );
94 93
95 popup->insertSeparator(); 94 popup->insertSeparator();
96 95
97 a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); 96 a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 );
98 a->setWhatsThis( tr( "Click here to configure this app." ) ); 97 a->setWhatsThis( tr( "Click here to configure this app." ) );
99 connect( a, SIGNAL( activated() ), this, SLOT( slotConfigure() ) ); 98 connect( a, SIGNAL( activated() ), this, SLOT( slotConfigure() ) );
100 a->addTo( popup ); 99 a->addTo( popup );
101 a->addTo( bar ); 100 a->addTo( bar );
102 101
103 mb->insertItem( tr( "Checkbook" ), popup ); 102 mb->insertItem( tr( "Checkbook" ), popup );
104 103
105 // Load Checkbook selection list 104 // Load Checkbook selection list
106 checkbooks = new CBInfoList(); 105 checkbooks = new CBInfoList();
107 106
108 QDir checkdir( cbDir ); 107 QDir checkdir( cbDir );
109 if (checkdir.exists() == true) 108 if (checkdir.exists() == true)
110 { 109 {
111 QStringList cblist = checkdir.entryList( "*.qcb", QDir::Files|QDir::Readable|QDir::Writable, 110 QStringList cblist = checkdir.entryList( "*.qcb", QDir::Files|QDir::Readable|QDir::Writable,
112 QDir::Time ); 111 QDir::Time );
113 CBInfo *cb = 0x0; 112 CBInfo *cb = 0x0;
114 QString filename; 113 QString filename;
115 114
116 for ( QStringList::Iterator it = cblist.begin(); it != cblist.end(); it++ ) 115 for ( QStringList::Iterator it = cblist.begin(); it != cblist.end(); it++ )
117 { 116 {
118 filename = cbDir; 117 filename = cbDir;
119 filename.append( (*it) ); 118 filename.append( (*it) );
120 119
121 cb = new CBInfo( (*it).remove( (*it).find('.'), (*it).length() ), filename ); 120 cb = new CBInfo( (*it).remove( (*it).find('.'), (*it).length() ), filename );
122 checkbooks->inSort( cb ); 121 checkbooks->inSort( cb );
123 } 122 }
124 } 123 }
125 124
126 // Build Checkbook selection list control 125 // Build Checkbook selection list control
127 cbList = 0x0; 126 cbList = 0x0;
128 buildList(); 127 buildList();
129 128
130 // open last book? 129 // open last book?
131 if( _cfg.isOpenLastBook() ) { 130 if( _cfg.isOpenLastBook() ) {
132 this->show(); 131 this->show();
133 this->showMaximized(); 132 this->showMaximized();
134 QListViewItem *itm=cbList->firstChild(); 133 QListViewItem *itm=cbList->firstChild();
135 while( itm ) { 134 while( itm ) {
136 if( itm->text(posName)==_cfg.getLastBook() ) { 135 if( itm->text(posName)==_cfg.getLastBook() ) {
137 openBook( itm ); 136 openBook( itm );
138 break; 137 break;
139 } 138 }
140 itm=itm->nextSibling(); 139 itm=itm->nextSibling();
141 } 140 }
142 } 141 }
143} 142}
144 143
145 144
146// --- ~MainWindow ------------------------------------------------------------ 145// --- ~MainWindow ------------------------------------------------------------
147MainWindow::~MainWindow() 146MainWindow::~MainWindow()
148{ 147{
149 writeConfig(); 148 writeConfig();
150} 149}
151 150
152 151
153// --- buildList -------------------------------------------------------------- 152// --- buildList --------------------------------------------------------------
154void MainWindow::buildList() 153void MainWindow::buildList()
155{ 154{
156 if ( cbList ) 155 if ( cbList )
157 delete cbList; 156 delete cbList;
158 157
159 cbList = new QListView( this ); 158 cbList = new QListView( this );
160 QWhatsThis::add( cbList, tr( "This is a listing of all checkbooks currently available." ) ); 159 QWhatsThis::add( cbList, tr( "This is a listing of all checkbooks currently available." ) );
161 160
162 if ( _cfg.getShowLocks() ) 161 if ( _cfg.getShowLocks() )
163 { 162 {
164 cbList->addColumn( Resource::loadIconSet( "locked" ), "", 24 ); 163 cbList->addColumn( Resource::loadIconSet( "locked" ), "", 24 );
165 posName = 1; 164 posName = 1;
166 } 165 }
167 else 166 else
168 { 167 {
169 posName = 0; 168 posName = 0;
170 } 169 }
171 cbList->addColumn( tr( "Checkbook Name" ) ); 170 cbList->addColumn( tr( "Checkbook Name" ) );
172 if ( _cfg.getShowBalances() ) 171 if ( _cfg.getShowBalances() )
173 { 172 {
174 int colnum = cbList->addColumn( tr( "Balance" ) ); 173 int colnum = cbList->addColumn( tr( "Balance" ) );
175 cbList->setColumnAlignment( colnum, Qt::AlignRight ); 174 cbList->setColumnAlignment( colnum, Qt::AlignRight );
176 } 175 }
177 cbList->setAllColumnsShowFocus( TRUE ); 176 cbList->setAllColumnsShowFocus( TRUE );
178 cbList->setSorting( posName ); 177 cbList->setSorting( posName );
179 QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold ); 178 QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold );
180 connect( cbList, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), 179 connect( cbList, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ),
181 this, SLOT( slotEdit() ) ); 180 this, SLOT( slotEdit() ) );
182 setCentralWidget( cbList ); 181 setCentralWidget( cbList );
183 182
184 for ( CBInfo *cb = checkbooks->first(); cb; cb = checkbooks->next() ) 183 for ( CBInfo *cb = checkbooks->first(); cb; cb = checkbooks->next() )
185 { 184 {
186 addCheckbook( cb ); 185 addCheckbook( cb );
187 } 186 }
188} 187}
189 188
190void MainWindow::addCheckbook( CBInfo *cb ) 189void MainWindow::addCheckbook( CBInfo *cb )
191{ 190{
192 QListViewItem *lvi = new QListViewItem( cbList ); 191 QListViewItem *lvi = new QListViewItem( cbList );
193 if ( _cfg.getShowLocks() && !cb->password().isNull() ) 192 if ( _cfg.getShowLocks() && !cb->password().isNull() )
194 { 193 {
195 lvi->setPixmap( 0, lockIcon ); 194 lvi->setPixmap( 0, lockIcon );
196 } 195 }
197 lvi->setText( posName, cb->name() ); 196 lvi->setText( posName, cb->name() );
198 if ( _cfg.getShowBalances() ) 197 if ( _cfg.getShowBalances() )
199 { 198 {
200 QString balance; 199 QString balance;
201 balance.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() ); 200 balance.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() );
202 lvi->setText( posName + 1, balance ); 201 lvi->setText( posName + 1, balance );
203 } 202 }
204} 203}
205 204
206void MainWindow::buildFilename( const QString &name ) 205void MainWindow::buildFilename( const QString &name )
207{ 206{
208 tempFilename = cbDir; 207 tempFilename = cbDir;
209 tempFilename.append( name ); 208 tempFilename.append( name );
210 tempFilename.append( ".qcb" ); 209 tempFilename.append( ".qcb" );
211} 210}
212 211
213void MainWindow::slotNew() 212void MainWindow::slotNew()
214{ 213{
215 CBInfo *cb = new CBInfo(); 214 CBInfo *cb = new CBInfo();
216 215
217 Checkbook *currcb = new Checkbook( this, cb, &_cfg ); 216 Checkbook *currcb = new Checkbook( this, cb, &_cfg );
218 currcb->showMaximized(); 217 currcb->showMaximized();
219 if ( currcb->exec() == QDialog::Accepted ) 218 if ( currcb->exec() == QDialog::Accepted )
220 { 219 {
221 // Save new checkbook 220 // Save new checkbook
222 buildFilename( cb->name() ); 221 buildFilename( cb->name() );
223 _cfg.setLastBook( cb->name() ); 222 _cfg.setLastBook( cb->name() );
224 cb->setFilename( tempFilename ); 223 cb->setFilename( tempFilename );
225 cb->write(); 224 cb->write();
226 225
227 // Add to listbox 226 // Add to listbox
228 checkbooks->inSort( cb ); 227 checkbooks->inSort( cb );
229 addCheckbook( cb ); 228 addCheckbook( cb );
230 } 229 }
231 delete currcb; 230 delete currcb;
232} 231}
233 232
234// --- slotEdit --------------------------------------------------------------- 233// --- slotEdit ---------------------------------------------------------------
235void MainWindow::slotEdit() 234void MainWindow::slotEdit()
236{ 235{
237 // get name and open it 236 // get name and open it
238 QListViewItem *curritem = cbList->currentItem(); 237 QListViewItem *curritem = cbList->currentItem();
239 if ( !curritem ) 238 if ( !curritem )
240 return; 239 return;
241 openBook( curritem ); 240 openBook( curritem );
242} 241}
243 242
244 243
245// --- openBook --------------------------------------------------------------- 244// --- openBook ---------------------------------------------------------------
246void MainWindow::openBook(QListViewItem *curritem) 245void MainWindow::openBook(QListViewItem *curritem)
247{ 246{
248 // find book in List 247 // find book in List
249 QString currname=curritem->text(posName); 248 QString currname=curritem->text(posName);
250 CBInfo *cb = checkbooks->first(); 249 CBInfo *cb = checkbooks->first();
251 while ( cb ) { 250 while ( cb ) {
252 if ( cb->name() == currname ) 251 if ( cb->name() == currname )
253 break; 252 break;
254 cb = checkbooks->next(); 253 cb = checkbooks->next();
255 } 254 }
256 if ( !cb ) return; 255 if ( !cb ) return;
257 256
258 // 257 //
259 buildFilename( currname ); 258 buildFilename( currname );
260 float currbalance = cb->balance(); 259 float currbalance = cb->balance();
261 bool currlock = !cb->password().isNull(); 260 bool currlock = !cb->password().isNull();
262 261
263 if ( currlock ) 262 if ( currlock )
264 { 263 {
265 Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); 264 Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) );
266 if ( pw->exec() != QDialog::Accepted || pw->password != cb->password() ) 265 if ( pw->exec() != QDialog::Accepted || pw->password != cb->password() )
267 { 266 {
268 delete pw; 267 delete pw;
269 return; 268 return;
270 } 269 }
271 delete pw; 270 delete pw;
272 } 271 }
273 272
274 _cfg.setLastBook( currname ); 273 _cfg.setLastBook( currname );
275 Checkbook *currcb = new Checkbook( this, cb, &_cfg ); 274 Checkbook *currcb = new Checkbook( this, cb, &_cfg );
276 currcb->showMaximized(); 275 currcb->showMaximized();
277 if ( currcb->exec() == QDialog::Accepted ) 276 if ( currcb->exec() == QDialog::Accepted )
278 { 277 {
279 QString newname = cb->name(); 278 QString newname = cb->name();
280 if ( currname != newname ) 279 if ( currname != newname )
281 { 280 {
282 // Update name if changed 281 // Update name if changed
283 if( curritem ) { 282 if( curritem ) {
284 curritem->setText( posName, newname ); 283 curritem->setText( posName, newname );
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 -------------------------------------------------------------
322void MainWindow::slotDelete() 327void 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 ----------------------------------------------------------
340void MainWindow::slotConfigure() 345void 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();
349 buildList(); 354 buildList();
350 } 355 }
351 delete cfgdlg; 356 delete cfgdlg;
352} 357}
353 358
354 359
355// --- writeConfig -------------------------------------------------------------- 360// --- writeConfig --------------------------------------------------------------
356void MainWindow::writeConfig() 361void MainWindow::writeConfig()
357{ 362{
358 Config config("checkbook"); 363 Config config("checkbook");
359 _cfg.writeConfig( config ); 364 _cfg.writeConfig( config );
360} 365}
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,212 +1,227 @@
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
33QString tempstr; 34QString tempstr;
34 35
35TranInfo::TranInfo( int id, const QString &desc, const QDate &date, bool withdrawal, 36TranInfo::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 &notes, int next ) 38 float fee, const QString &number, const QString &notes, 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
52TranInfo::TranInfo( Config config, int entry ) 53TranInfo::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
64 // Transaction date 65 // Transaction date
65 int yr, mn, dy; 66 int yr, mn, dy;
66 QString datestr = config.readEntry( "Date", "" ); 67 QString datestr = config.readEntry( "Date", "" );
67 int begin, end; 68 int begin, end;
68 begin = datestr.find( '/' ); 69 begin = datestr.find( '/' );
69 mn = datestr.left( begin ).toInt(); 70 mn = datestr.left( begin ).toInt();
70 end = datestr.find( '/', ++begin ); 71 end = datestr.find( '/', ++begin );
71 dy = datestr.mid( begin, end - begin ).toInt(); 72 dy = datestr.mid( begin, end - begin ).toInt();
72 yr = datestr.right( datestr.length() - end - 1).toInt(); 73 yr = datestr.right( datestr.length() - end - 1).toInt();
73 td.setYMD( yr, mn, dy ); 74 td.setYMD( yr, mn, dy );
74 75
75 // Deposit/withdrawal indicator ( withdrawal == TRUE ) 76 // Deposit/withdrawal indicator ( withdrawal == TRUE )
76 w = ( config.readEntry( "Payment", "false" ) == "true" ); 77 w = ( config.readEntry( "Payment", "false" ) == "true" );
77 78
78 // Type 79 // Type
79 QString type = config.readEntry( "Type", "0" ); 80 QString type = config.readEntry( "Type", "0" );
80 if ( w ) 81 if ( w )
81 { // Withdrawal types 82 { // Withdrawal types
82 if( type == "0" ) 83 if( type == "0" )
83 t = "Debit Charge"; 84 t = "Debit Charge";
84 else if( type == "1" ) 85 else if( type == "1" )
85 t = "Written Check"; 86 t = "Written Check";
86 else if( type == "2" ) 87 else if( type == "2" )
87 t = "Transfer"; 88 t = "Transfer";
88 else if( type == "3" ) 89 else if( type == "3" )
89 t = "Credit Card"; 90 t = "Credit Card";
90 } 91 }
91 else 92 else
92 { 93 {
93 if( type == "0" ) 94 if( type == "0" )
94 t = "Written Check"; 95 t = "Written Check";
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 ----------------------------------------------------------------
127const QString &TranInfo::datestr() 128const 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 ---------------------------------------------------------------
136const QString &TranInfo::getIdStr() 140const 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 ------------------------------------------------------------------
143void TranInfo::write( Config *config ) 147void 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" )
167 tempstr = "3"; 171 tempstr = "3";
168 config->writeEntry( "Type", tempstr ); 172 config->writeEntry( "Type", tempstr );
169 173
170 config->writeEntry( "Category", c ); 174 config->writeEntry( "Category", c );
171 175
172 tempstr.setNum( a, 'f', 2 ); 176 tempstr.setNum( a, 'f', 2 );
173 config->writeEntry( "Amount", tempstr ); 177 config->writeEntry( "Amount", tempstr );
174 178
175 tempstr.setNum( f, 'f', 2 ); 179 tempstr.setNum( f, 'f', 2 );
176 config->writeEntry( "TransactionFee", tempstr ); 180 config->writeEntry( "TransactionFee", tempstr );
177 181
178 config->writeEntry( "CheckNumber", cn ); 182 config->writeEntry( "CheckNumber", cn );
179 config->writeEntry( "Comments", n ); 183 config->writeEntry( "Comments", n );
180 config->writeEntry( "Next", _next ); 184 config->writeEntry( "Next", _next );
181} 185}
182 186
183 187
184int TranInfoList::compareItems( QCollection::Item item1, QCollection::Item item2 ) 188int 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 ---------------------------------------------------------------
200QString TranInfo::toString() 204QString 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 ---------------------------------------------------
220TranInfo *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
@@ -1,100 +1,103 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 =. 3 =.
4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> 4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .: 19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#ifndef 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
35class Config; 35class Config;
36 36
37class TranInfo 37class 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 &notes() const { return n; } 59 const QString &notes() 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 &notes ) { n = notes; } 71 void setNotes( const QString &notes ) { 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
94class TranInfoList : public QList<TranInfo> 94class 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,270 +1,338 @@
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
44Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *info, 46Transaction::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." ) );
84 layout2->addWidget( depBtn, 0, 1 ); 87 layout2->addWidget( depBtn, 0, 1 );
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 -----------------------------------------------------------
182void 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 -----------------------------------------------------------
211Transaction::~Transaction() 250Transaction::~Transaction()
212{ 251{
213} 252}
214 253
254// --- accept -----------------------------------------------------------------
215void Transaction::accept() 255void 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
231void Transaction::slotWithdrawalClicked() 271void 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
248void Transaction::slotDepositClicked() 288void 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 --------------------------------------------------------
265void Transaction::slotDateChanged( int y, int m, int d ) 306void 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
318void 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 -----------------------------------------------------------------
334void 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
@@ -1,79 +1,83 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 =. 3 =.
4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> 4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .: 19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#ifndef 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
34class DateBookMonth; 34class DateBookMonth;
35class QComboBox; 35class QComboBox;
36class QLineEdit; 36class QLineEdit;
37class QMultiLineEdit; 37class QMultiLineEdit;
38class QPushButton; 38class QPushButton;
39class QRadioButton; 39class QRadioButton;
40class QString; 40class QString;
41class QWidget; 41class QWidget;
42class TranInfo; 42class TranInfo;
43class Cfg; 43class Cfg;
44 44
45class Transaction : public QDialog 45class 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