summaryrefslogtreecommitdiff
authordrw <drw>2002-12-04 02:12:25 (UTC)
committer drw <drw>2002-12-04 02:12:25 (UTC)
commitd000538b68b3411a409e829c4e68f42f9646b940 (patch) (unidiff)
tree72abee0785a595ef9d5edf9ecd20743a9ff16559
parent9b23bf789c15bcc84dabc400f16fa38ff3a34ebd (diff)
downloadopie-d000538b68b3411a409e829c4e68f42f9646b940.zip
opie-d000538b68b3411a409e829c4e68f42f9646b940.tar.gz
opie-d000538b68b3411a409e829c4e68f42f9646b940.tar.bz2
Abstracted checkbook storage, added new main window display/configuration options.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/checkbook/cbinfo.cpp196
-rw-r--r--noncore/apps/checkbook/cbinfo.h97
-rw-r--r--noncore/apps/checkbook/checkbook.cpp235
-rw-r--r--noncore/apps/checkbook/checkbook.h25
-rw-r--r--noncore/apps/checkbook/checkbook.pro28
-rw-r--r--noncore/apps/checkbook/configuration.cpp76
-rw-r--r--noncore/apps/checkbook/configuration.h51
-rw-r--r--noncore/apps/checkbook/graph.cpp9
-rw-r--r--noncore/apps/checkbook/graph.h1
-rw-r--r--noncore/apps/checkbook/graphinfo.h2
-rw-r--r--noncore/apps/checkbook/mainwindow.cpp230
-rw-r--r--noncore/apps/checkbook/mainwindow.h30
-rw-r--r--noncore/apps/checkbook/traninfo.h16
13 files changed, 753 insertions, 243 deletions
diff --git a/noncore/apps/checkbook/cbinfo.cpp b/noncore/apps/checkbook/cbinfo.cpp
new file mode 100644
index 0000000..3a39317
--- a/dev/null
+++ b/noncore/apps/checkbook/cbinfo.cpp
@@ -0,0 +1,196 @@
1/*
2                This file is part of the OPIE Project
3 =.
4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#include "cbinfo.h"
30#include "traninfo.h"
31
32#include <qpe/config.h>
33
34#include <qfile.h>
35
36CBInfo::CBInfo()
37{
38 n = "";
39 fn = "";
40 pw = QString::null;
41 t = "";
42 bn = "";
43 a = "";
44 p = "";
45 nt = "";
46 sb = 0.0;
47
48 tl = new TranInfoList();
49}
50
51CBInfo::CBInfo( const QString &name, const QString &filename )
52{
53 Config config( filename, Config::File );
54 config.setGroup( "Account" );
55
56 n = name;
57 fn = filename;
58 pw = config.readEntryCrypt( "Password", QString::null );
59
60 t = config.readEntry( "Type" );
61 bn = config.readEntry( "Bank", "" );
62 a = config.readEntryCrypt( "Number", "" );
63 p = config.readEntryCrypt( "PINNumber", "" );
64 nt = config.readEntry( "Notes", "" );
65
66 bool ok;
67 sb = config.readEntry( "Balance", "0.0" ).toFloat( &ok );
68
69 loadTransactions();
70}
71
72float CBInfo::balance()
73{
74 calcBalance();
75 return b;
76}
77
78void CBInfo::write()
79{
80 QFile f( fn );
81 if ( f.exists() )
82 {
83 f.remove();
84 }
85
86 Config *config = new Config(fn, Config::File);
87
88 // Save info
89 config->setGroup( "Account" );
90 config->writeEntryCrypt( "Password", pw );
91 config->writeEntry( "Type", t );
92 config->writeEntry( "Bank", bn );
93 config->writeEntryCrypt( "Number", a );
94 config->writeEntryCrypt( "PINNumber", p );
95 config->writeEntry( "Notes", n );
96 QString balstr;
97 balstr.setNum( sb, 'f', 2 );
98 config->writeEntry( "Balance", balstr );
99
100 // Save transactions
101 int i = 1;
102 for ( TranInfo *tran = tl->first(); tran; tran = tl->next() )
103 {
104 tran->write( config, i );
105 i++;
106 }
107 config->write();
108
109 delete config;
110}
111
112TranInfo *CBInfo::findTransaction( const QString &checknum, const QString &date,
113 const QString &desc )
114{
115 TranInfo *traninfo = tl->first();
116 while ( traninfo )
117 {
118 if ( traninfo->number() == checknum && traninfo->datestr() == date &&
119 traninfo->desc() == desc )
120 break;
121 traninfo = tl->next();
122 }
123 return( traninfo );
124}
125
126void CBInfo::addTransaction( TranInfo *tran )
127{
128 tl->inSort( tran );
129 calcBalance();
130}
131
132void CBInfo::removeTransaction( TranInfo *tran )
133{
134 tl->remove( tran );
135 delete tran;
136 calcBalance();
137}
138
139void CBInfo::loadTransactions()
140{
141 TranInfo *tran;
142 QString trandesc = "";
143
144 tl = new TranInfoList();
145
146 Config config( fn, Config::File );
147
148 for ( int i = 1; trandesc != QString::null; i++ )
149 {
150 tran = new TranInfo( config, i );
151 trandesc = tran->desc();
152 if ( trandesc != QString::null )
153 {
154 tl->inSort( tran );
155 }
156 else
157 {
158 delete tran;
159 }
160 }
161
162 calcBalance();
163}
164
165void CBInfo::calcBalance()
166{
167 float amount;
168
169 b = sb;
170
171 for ( TranInfo *tran = tl->first(); tran; tran = tl->next() )
172 {
173 b -= tran->fee();
174 amount = tran->amount();
175 if ( tran->withdrawal() )
176 {
177 amount *= -1;
178 }
179 b += amount;
180 }
181}
182
183int CBInfoList::compareItems( QCollection::Item item1, QCollection::Item item2 )
184{
185 QString n1 = ((CBInfo *)item1)->name();
186 QString n2 = ((CBInfo *)item2)->name();
187 int r = -1;
188
189 if ( n1 < n2 )
190 r = -1;
191 else if ( n1 == n2 )
192 r = 0;
193 else if ( n1 > n2 )
194 r = 1;
195 return( r );
196}
diff --git a/noncore/apps/checkbook/cbinfo.h b/noncore/apps/checkbook/cbinfo.h
new file mode 100644
index 0000000..5e65db2
--- a/dev/null
+++ b/noncore/apps/checkbook/cbinfo.h
@@ -0,0 +1,97 @@
1/*
2                This file is part of the OPIE Project
3 =.
4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#ifndef CBINFO_H
30#define CBINFO_H
31
32#include <qlist.h>
33#include <qstring.h>
34
35class Config;
36class TranInfo;
37class TranInfoList;
38
39class CBInfo
40{
41 public:
42 CBInfo();
43 CBInfo( const QString &, const QString & );
44
45 const QString &name() const { return n; }
46 const QString &filename() const { return fn; }
47 const QString &password() const { return pw; }
48 const QString &type() const { return t; }
49 const QString &bank() const { return bn; }
50 const QString &account() const { return a; }
51 const QString &pin() const { return p; }
52 const QString &notes() const { return nt; }
53 float startingBalance()const { return sb; }
54 float balance();
55
56 void setName( const QString &name ) { n = name; }
57 void setFilename( const QString &filename ){ fn = filename; }
58 void setPassword( const QString &password ){ pw = password; }
59 void setType( const QString &type ) { t = type; }
60 void setBank( const QString &bank ) { bn = bank; }
61 void setAccount( const QString &account ) { a = account; }
62 void setPin( const QString &pin ) { p = pin; }
63 void setNotes( const QString &notes ) { nt = notes; }
64 void setStartingBalance( float startbal ) { sb = startbal; }
65
66 void write();
67
68 TranInfoList *transactions() const { return tl; }
69 TranInfo *findTransaction( const QString &, const QString &, const QString & );
70 void addTransaction( TranInfo * );
71 void removeTransaction( TranInfo * );
72
73 private:
74 QString n;
75 QString fn;
76 QString pw;
77 QString t;
78 QString bn;
79 QString a;
80 QString p;
81 QString nt;
82 float sb;
83 float b;
84
85 TranInfoList *tl;
86
87 void loadTransactions();
88 void calcBalance();
89};
90
91class CBInfoList : public QList<CBInfo>
92{
93 protected:
94 int compareItems( QCollection::Item, QCollection::Item );
95};
96
97#endif
diff --git a/noncore/apps/checkbook/checkbook.cpp b/noncore/apps/checkbook/checkbook.cpp
index 5a6d607..7a6b7cc 100644
--- a/noncore/apps/checkbook/checkbook.cpp
+++ b/noncore/apps/checkbook/checkbook.cpp
@@ -18,61 +18,58 @@
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 "transaction.h" 31#include "transaction.h"
32#include "traninfo.h"
31#include "graph.h" 33#include "graph.h"
32#include "graphinfo.h" 34#include "graphinfo.h"
33#include "password.h" 35#include "password.h"
34 36
35#include <opie/otabwidget.h> 37#include <opie/otabwidget.h>
36#include <qpe/config.h> 38#include <qpe/config.h>
37#include <qpe/qpeapplication.h> 39#include <qpe/qpeapplication.h>
38#include <qpe/qpemessagebox.h> 40#include <qpe/qpemessagebox.h>
39#include <qpe/resource.h> 41#include <qpe/resource.h>
40 42
41#include <qcheckbox.h> 43#include <qcheckbox.h>
42#include <qcombobox.h> 44#include <qcombobox.h>
43#include <qfile.h> 45#include <qfile.h>
44#include <qfontmetrics.h> 46#include <qfontmetrics.h>
45#include <qlabel.h> 47#include <qlabel.h>
46#include <qlayout.h> 48#include <qlayout.h>
47#include <qlineedit.h> 49#include <qlineedit.h>
48#include <qmultilineedit.h> 50#include <qmultilineedit.h>
49#include <qpushbutton.h> 51#include <qpushbutton.h>
50#include <qwhatsthis.h> 52#include <qwhatsthis.h>
51#include <qwidget.h> 53#include <qwidget.h>
52 54
53Checkbook::Checkbook( QWidget *parent, const QString &n, const QString &fd, const QString &symbol ) 55Checkbook::Checkbook( QWidget *parent, CBInfo *i, const QString &symbol )
54 : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) 56 : QDialog( parent, 0, TRUE, WStyle_ContextHelp )
55{ 57{
56 name = n; 58 info = i;
57 filename = fd;
58 filename.append( name );
59 filename.append( ".qcb" );
60 filedir = fd;
61 currencySymbol = symbol; 59 currencySymbol = symbol;
62 currBalance = 0.0;
63 60
64 if ( name != "" ) 61 if ( info->name() != "" )
65 { 62 {
66 QString tempstr = name; 63 QString tempstr = info->name();
67 tempstr.append( " - " ); 64 tempstr.append( " - " );
68 tempstr.append( tr( "Checkbook" ) ); 65 tempstr.append( tr( "Checkbook" ) );
69 setCaption( tempstr ); 66 setCaption( tempstr );
70 } 67 }
71 else 68 else
72 { 69 {
73 setCaption( tr( "New checkbook" ) ); 70 setCaption( tr( "New checkbook" ) );
74 } 71 }
75 72
76 // Setup layout to make everything pretty 73 // Setup layout to make everything pretty
77 QVBoxLayout *layout = new QVBoxLayout( this ); 74 QVBoxLayout *layout = new QVBoxLayout( this );
78 layout->setMargin( 2 ); 75 layout->setMargin( 2 );
@@ -86,29 +83,24 @@ Checkbook::Checkbook( QWidget *parent, const QString &n, const QString &fd, cons
86 mainWidget->addTab( initTransactions(), "checkbook/trantab", tr( "Transactions" ) ); 83 mainWidget->addTab( initTransactions(), "checkbook/trantab", tr( "Transactions" ) );
87 mainWidget->addTab( initCharts(), "checkbook/charttab", tr( "Charts" ) ); 84 mainWidget->addTab( initCharts(), "checkbook/charttab", tr( "Charts" ) );
88 mainWidget->setCurrentTab( tr( "Info" ) ); 85 mainWidget->setCurrentTab( tr( "Info" ) );
89 86
90 // Load checkbook information 87 // Load checkbook information
91 loadCheckbook(); 88 loadCheckbook();
92} 89}
93 90
94Checkbook::~Checkbook() 91Checkbook::~Checkbook()
95{ 92{
96} 93}
97 94
98const QString &Checkbook::getName()
99{
100 return( name );
101}
102
103QWidget *Checkbook::initInfo() 95QWidget *Checkbook::initInfo()
104{ 96{
105 QWidget *control = new QWidget( mainWidget ); 97 QWidget *control = new QWidget( mainWidget );
106 98
107 QVBoxLayout *vb = new QVBoxLayout( control ); 99 QVBoxLayout *vb = new QVBoxLayout( control );
108 100
109 QScrollView *sv = new QScrollView( control ); 101 QScrollView *sv = new QScrollView( control );
110 vb->addWidget( sv, 0, 0 ); 102 vb->addWidget( sv, 0, 0 );
111 sv->setResizePolicy( QScrollView::AutoOneFit ); 103 sv->setResizePolicy( QScrollView::AutoOneFit );
112 sv->setFrameStyle( QFrame::NoFrame ); 104 sv->setFrameStyle( QFrame::NoFrame );
113 105
114 QWidget *container = new QWidget( sv->viewport() ); 106 QWidget *container = new QWidget( sv->viewport() );
@@ -264,305 +256,256 @@ QWidget *Checkbook::initCharts()
264 layout->addMultiCellWidget( graphList, 1, 1, 0, 1 ); 256 layout->addMultiCellWidget( graphList, 1, 1, 0, 1 );
265 257
266 QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/drawbtn" ), tr( "Draw" ), control ); 258 QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/drawbtn" ), tr( "Draw" ), control );
267 QWhatsThis::add( btn, tr( "Click here to draw the selected chart." ) ); 259 QWhatsThis::add( btn, tr( "Click here to draw the selected chart." ) );
268 connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) ); 260 connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) );
269 layout->addWidget( btn, 1, 2 ); 261 layout->addWidget( btn, 1, 2 );
270 262
271 return control; 263 return control;
272} 264}
273 265
274void Checkbook::loadCheckbook() 266void Checkbook::loadCheckbook()
275{ 267{
276 transactions.clear(); 268 if ( !info )
277 269 {
278 Config config( filename, Config::File ); 270 return;
271 }
279 272
280 // Load info 273 tranList = info->transactions();
281 config.setGroup( "Account" );
282 274
283 password = config.readEntryCrypt( "Password", "" ); 275 passwordCB->setChecked( !info->password().isNull() );
284 passwordCB->setChecked( password != "" ); 276 nameEdit->setText( info->name() );
285 nameEdit->setText( name ); 277 QString temptext = info->type();
286 QString temptext = config.readEntry( "Type" );
287 int i = typeList->count(); 278 int i = typeList->count();
288 while ( i > 0 ) 279 while ( i > 0 )
289 { 280 {
290 i--; 281 i--;
291 typeList->setCurrentItem( i ); 282 typeList->setCurrentItem( i );
292 if ( typeList->currentText() == temptext ) 283 if ( typeList->currentText() == temptext )
293 { 284 {
294 break; 285 break;
295 } 286 }
296 } 287 }
297 bankEdit->setText( config.readEntry( "Bank", "" ) ); 288 bankEdit->setText( info->bank() );
298 acctNumEdit->setText( config.readEntryCrypt( "Number", "" ) ); 289 acctNumEdit->setText( info->account() );
299 pinNumEdit->setText( config.readEntryCrypt( "PINNumber", "" ) ); 290 pinNumEdit->setText( info->pin() );
300 balanceEdit->setText( config.readEntry( "Balance", "0.0" ) ); 291 temptext.setNum( info->startingBalance(), 'f', 2 );
301 notesEdit->setText( config.readEntry( "Notes", "" ) ); 292 balanceEdit->setText( temptext );
302 293 notesEdit->setText( info->notes() );
303 bool ok;
304 currBalance = balanceEdit->text().toFloat( &ok );
305 startBalance = currBalance;
306 294
307 // Load transactions 295 // Load transactions
308 TranInfo *tran;
309 QString trandesc = "";
310 float amount; 296 float amount;
311 QString stramount; 297 QString stramount;
312 for ( int i = 1; trandesc != QString::null; i++ )
313 {
314 tran = new TranInfo( config, i );
315 trandesc = tran->desc();
316 if ( trandesc != QString::null )
317 {
318 currBalance -= tran->fee();
319 amount = tran->amount();
320 if ( tran->withdrawal() )
321 {
322 amount *= -1;
323 }
324 currBalance += amount;
325 stramount.sprintf( "%s%.2f", currencySymbol.latin1(), amount );
326
327 // Add to transaction list
328 transactions.inSort( tran );
329 298
330 // Add to transaction table 299 for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() )
331 ( void ) new CBListItem( tranTable, tran->number(), tran->datestr(), trandesc, stramount ); 300 {
332 } 301 amount = tran->amount();
333 else 302 if ( tran->withdrawal() )
334 { 303 {
335 delete tran; 304 amount *= -1;
336 } 305 }
306 stramount.sprintf( "%s%.2f", currencySymbol.latin1(), amount );
307 ( void ) new CBListItem( tranTable, tran->number(), tran->datestr(), tran->desc(), stramount );
337 } 308 }
338 balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) );
339 309
340 highTranNum = transactions.count(); 310 balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( info->balance(), 0, 'f', 2 ) );
311
312 highTranNum = tranList->count();
341} 313}
342 314
343void Checkbook::adjustBalance( float amount ) 315void Checkbook::adjustBalance()
344{ 316{
345 currBalance += amount; 317 balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( info->balance(), 0, 'f', 2 ) );
346 balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) );
347
348} 318}
349 319
350TranInfo *Checkbook::findTran( const QString &checknum, const QString &date, const QString &desc ) 320TranInfo *Checkbook::findTran( const QString &checknum, const QString &date, const QString &desc )
351{ 321{
352 TranInfo *traninfo = transactions.first(); 322 TranInfo *traninfo = tranList->first();
353 while ( traninfo ) 323 while ( traninfo )
354 { 324 {
355 if ( traninfo->number() == checknum && traninfo->datestr() == date && 325 if ( traninfo->number() == checknum && traninfo->datestr() == date &&
356 traninfo->desc() == desc ) 326 traninfo->desc() == desc )
357 break; 327 break;
358 traninfo = transactions.next(); 328 traninfo = tranList->next();
359 } 329 }
360 return( traninfo ); 330 return( traninfo );
361} 331}
362 332
363void Checkbook::accept() 333void Checkbook::accept()
364{ 334{
365 QFile f( filename ); 335 info->setName( nameEdit->text() );
366 if ( f.exists() ) 336 info->setType( typeList->currentText() );
367 { 337 info->setBank( bankEdit->text() );
368 f.remove(); 338 info->setAccount( acctNumEdit->text() );
369 } 339 info->setPin( pinNumEdit->text() );
370 340 bool ok;
371 Config *config = new Config(filename, Config::File); 341 info->setStartingBalance( balanceEdit->text().toFloat( &ok ) );
372 342 info->setNotes( notesEdit->text() );
373 // Save info
374 config->setGroup( "Account" );
375 config->writeEntryCrypt( "Password", password );
376 config->writeEntry( "Type", typeList->currentText() );
377 config->writeEntry( "Bank", bankEdit->text() );
378 config->writeEntryCrypt( "Number", acctNumEdit->text() );
379 config->writeEntryCrypt( "PINNumber", pinNumEdit->text() );
380 config->writeEntry( "Balance", balanceEdit->text() );
381 config->writeEntry( "Notes", notesEdit->text() );
382
383 // Save transactions
384 int i = 1;
385 for ( TranInfo *tran = transactions.first(); tran; tran = transactions.next() )
386 {
387 tran->write( config, i );
388 i++;
389 }
390 config->write();
391 343
392 QDialog::accept(); 344 QDialog::accept();
393} 345}
394 346
395void Checkbook::slotPasswordClicked() 347void Checkbook::slotPasswordClicked()
396{ 348{
397 if ( password == "" && passwordCB->isChecked() ) 349 if ( info->password().isNull() && passwordCB->isChecked() )
398 { 350 {
399 Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); 351 Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) );
400 if ( pw->exec() != QDialog::Accepted ) 352 if ( pw->exec() != QDialog::Accepted )
401 { 353 {
402 passwordCB->setChecked( FALSE ); 354 passwordCB->setChecked( FALSE );
403 delete pw; 355 delete pw;
404 return; 356 return;
405 } 357 }
406 password = pw->password; 358 info->setPassword( pw->password );
407 delete pw; 359 delete pw;
408 360
409 pw = new Password( this, tr( "Confirm password" ), tr( "Please confirm your password:" ) ); 361 pw = new Password( this, tr( "Confirm password" ), tr( "Please confirm your password:" ) );
410 if ( pw->exec() != QDialog::Accepted || pw->password != password ) 362 if ( pw->exec() != QDialog::Accepted || pw->password != info->password() )
411 { 363 {
412 passwordCB->setChecked( FALSE ); 364 passwordCB->setChecked( FALSE );
413 password = ""; 365 info->setPassword( QString::null );
414 } 366 }
415 367
416 delete pw; 368 delete pw;
417 } 369 }
418 else if ( password != "" && !passwordCB->isChecked() ) 370 else if ( !info->password().isNull() && !passwordCB->isChecked() )
419 { 371 {
420 Password *pw = new Password( this, tr( "Enter password" ), 372 Password *pw = new Password( this, tr( "Enter password" ),
421 tr( "Please enter your password to confirm removal of password protection:" ) ); 373 tr( "Please enter your password to confirm removal of password protection:" ) );
422 if ( pw->exec() == QDialog::Accepted && pw->password == password ) 374 if ( pw->exec() == QDialog::Accepted && pw->password == info->password() )
423 { 375 {
424 password = ""; 376 info->setPassword( QString::null );
425 delete pw; 377 delete pw;
426 return; 378 return;
427 } 379 }
428 else 380 else
429 { 381 {
430 passwordCB->setChecked( TRUE ); 382 passwordCB->setChecked( TRUE );
431 } 383 }
432 384
433 delete pw; 385 delete pw;
434 } 386 }
435} 387}
436 388
437void Checkbook::slotNameChanged( const QString &newname ) 389void Checkbook::slotNameChanged( const QString &newname )
438{ 390{
439 name = newname; 391 info->setName( newname );
440 filename = filedir; 392
441 filename.append( newname ); 393 // TODO - need filedir
442 filename.append( ".qcb" ); 394 //QString namestr = filedir;
443 QString tempstr = name; 395 //namestr.append( newname );
444 tempstr.append( " - " ); 396 //namestr.append( ".qcb" );
445 tempstr.append( tr( "Checkbook" ) ); 397 //info->setFilename( namestr );
446 setCaption( tempstr ); 398
399 QString namestr = newname;
400 namestr.append( " - " );
401 namestr.append( tr( "Checkbook" ) );
402 setCaption( namestr );
447} 403}
448 404
449void Checkbook::slotStartingBalanceChanged( const QString &newbalance ) 405void Checkbook::slotStartingBalanceChanged( const QString &newbalance )
450{ 406{
451 currBalance -= startBalance;
452 bool ok; 407 bool ok;
453 startBalance = newbalance.toFloat( &ok ); 408 info->setStartingBalance( newbalance.toFloat( &ok ) );
454 adjustBalance( startBalance ); 409 adjustBalance();
455} 410}
456 411
457void Checkbook::slotNewTran() 412void Checkbook::slotNewTran()
458{ 413{
459 highTranNum++; 414 highTranNum++;
460 TranInfo *traninfo = new TranInfo( highTranNum ); 415 TranInfo *traninfo = new TranInfo( highTranNum );
461 416
462 Transaction *currtran = new Transaction( this, name, 417 Transaction *currtran = new Transaction( this, info->name(),
463 traninfo, 418 traninfo,
464 currencySymbol ); 419 currencySymbol );
465 currtran->showMaximized(); 420 currtran->showMaximized();
466 if ( currtran->exec() == QDialog::Accepted ) 421 if ( currtran->exec() == QDialog::Accepted )
467 { 422 {
468 float amount = traninfo->amount(); 423 // Add to transaction list
424 info->addTransaction( traninfo );
425
426 // Add to transaction table
427 float amount;
428 QString stramount;
429
430 amount = traninfo->amount();
469 if ( traninfo->withdrawal() ) 431 if ( traninfo->withdrawal() )
470 { 432 {
471 amount *= -1; 433 amount *= -1;
472 } 434 }
473 QString stramount;
474 stramount.sprintf( "%s%.2f", currencySymbol.latin1(), amount ); 435 stramount.sprintf( "%s%.2f", currencySymbol.latin1(), amount );
475 436
476 // Add to transaction list
477 transactions.inSort( traninfo );
478
479 // Add to transaction table
480 ( void ) new CBListItem( tranTable, traninfo->number(), traninfo->datestr(), traninfo->desc(), 437 ( void ) new CBListItem( tranTable, traninfo->number(), traninfo->datestr(), traninfo->desc(),
481 stramount ); 438 stramount );
482 439
483 adjustBalance( amount ); 440 adjustBalance();
484 } 441 }
485 else 442 else
486 { 443 {
487 highTranNum--; 444 highTranNum--;
488 delete traninfo; 445 delete traninfo;
489 } 446 }
490} 447}
491 448
492void Checkbook::slotEditTran() 449void Checkbook::slotEditTran()
493{ 450{
494 QListViewItem *curritem = tranTable->currentItem(); 451 QListViewItem *curritem = tranTable->currentItem();
495 if ( !curritem ) 452 if ( !curritem )
496 { 453 {
497 return; 454 return;
498 } 455 }
499 456
500 TranInfo *traninfo = findTran( curritem->text( 0 ), curritem->text( 1 ), curritem->text( 2 ) ); 457 TranInfo *traninfo = info->findTransaction( curritem->text( 0 ), curritem->text( 1 ),
501 float origamt = traninfo->amount(); 458 curritem->text( 2 ) );
502 if ( traninfo->withdrawal() )
503 {
504 origamt *= -1;
505 }
506 459
507 Transaction *currtran = new Transaction( this, name, 460 Transaction *currtran = new Transaction( this, info->name(),
508 traninfo, 461 traninfo,
509 currencySymbol ); 462 currencySymbol );
510 currtran->showMaximized(); 463 currtran->showMaximized();
511 if ( currtran->exec() == QDialog::Accepted ) 464 if ( currtran->exec() == QDialog::Accepted )
512 { 465 {
466 curritem->setText( 0, traninfo->number() );
513 curritem->setText( 1, traninfo->datestr() ); 467 curritem->setText( 1, traninfo->datestr() );
514
515 curritem->setText( 2, traninfo->desc() ); 468 curritem->setText( 2, traninfo->desc() );
516 469
517 float amount = traninfo->amount(); 470 float amount = traninfo->amount();
518 if ( traninfo->withdrawal() ) 471 if ( traninfo->withdrawal() )
519 { 472 {
520 amount *= -1; 473 amount *= -1;
521 } 474 }
522 adjustBalance( origamt * -1 );
523 adjustBalance( amount );
524 QString stramount; 475 QString stramount;
525 stramount.sprintf( "%s%.2f", currencySymbol.latin1(), amount ); 476 stramount.sprintf( "%s%.2f", currencySymbol.latin1(), amount );
526 curritem->setText( 3, stramount ); 477 curritem->setText( 3, stramount );
527 478
528 balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) ); 479 adjustBalance();
529
530 delete currtran;
531 } 480 }
481
482 delete currtran;
532} 483}
533 484
534void Checkbook::slotDeleteTran() 485void Checkbook::slotDeleteTran()
535{ 486{
536 QListViewItem *curritem = tranTable->currentItem(); 487 QListViewItem *curritem = tranTable->currentItem();
537 if ( !curritem ) 488 if ( !curritem )
538 { 489 {
539 return; 490 return;
540 } 491 }
541 492
542 TranInfo *traninfo = findTran( curritem->text( 0 ), curritem->text( 1 ), curritem->text( 2 ) ); 493 TranInfo *traninfo = findTran( curritem->text( 0 ), curritem->text( 1 ), curritem->text( 2 ) );
543 494
544 if ( QPEMessageBox::confirmDelete ( this, tr( "Delete transaction" ), traninfo->desc() ) ) 495 if ( QPEMessageBox::confirmDelete ( this, tr( "Delete transaction" ), traninfo->desc() ) )
545 { 496 {
546 float amount = traninfo->amount(); 497 info->removeTransaction( traninfo );
547 if ( traninfo->withdrawal() )
548 {
549 amount *= -1;
550 }
551
552 transactions.remove( traninfo );
553 delete traninfo;
554 delete curritem; 498 delete curritem;
555 499 adjustBalance();
556 adjustBalance( amount * -1 );
557 } 500 }
558} 501}
559 502
560void Checkbook::slotDrawGraph() 503void Checkbook::slotDrawGraph()
561{ 504{
562 if ( graphInfo ) 505 if ( graphInfo )
563 { 506 {
564 delete graphInfo; 507 delete graphInfo;
565 } 508 }
566 509
567 switch ( graphList->currentItem() ) 510 switch ( graphList->currentItem() )
568 { 511 {
@@ -573,31 +516,31 @@ void Checkbook::slotDrawGraph()
573 case 2 : drawCategoryChart( FALSE ); 516 case 2 : drawCategoryChart( FALSE );
574 break; 517 break;
575 }; 518 };
576 519
577 graphWidget->setGraphInfo( graphInfo ); 520 graphWidget->setGraphInfo( graphInfo );
578 graphWidget->drawGraph( TRUE ); 521 graphWidget->drawGraph( TRUE );
579} 522}
580 523
581void Checkbook::drawBalanceChart() 524void Checkbook::drawBalanceChart()
582{ 525{
583 DataPointList *list = new DataPointList(); 526 DataPointList *list = new DataPointList();
584 527
585 float balance = startBalance; 528 float balance = info->startingBalance();
586 float amount; 529 float amount;
587 QString label; 530 QString label;
588 int i = 0; 531 int i = 0;
589 int count = transactions.count(); 532 int count = tranList->count();
590 533
591 for ( TranInfo *tran = transactions.first(); tran; tran = transactions.next() ) 534 for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() )
592 { 535 {
593 i++; 536 i++;
594 balance -= tran->fee(); 537 balance -= tran->fee();
595 amount = tran->amount(); 538 amount = tran->amount();
596 if ( tran->withdrawal() ) 539 if ( tran->withdrawal() )
597 { 540 {
598 amount *= -1; 541 amount *= -1;
599 } 542 }
600 balance += amount; 543 balance += amount;
601 if ( i == 1 || i == count / 2 || i == count ) 544 if ( i == 1 || i == count / 2 || i == count )
602 { 545 {
603 label = tran->datestr(); 546 label = tran->datestr();
@@ -607,33 +550,33 @@ void Checkbook::drawBalanceChart()
607 label = ""; 550 label = "";
608 } 551 }
609 list->append( new DataPointInfo( label, balance ) ); 552 list->append( new DataPointInfo( label, balance ) );
610 } 553 }
611 554
612 graphInfo = new GraphInfo( GraphInfo::BarChart, list ); 555 graphInfo = new GraphInfo( GraphInfo::BarChart, list );
613} 556}
614 557
615void Checkbook::drawCategoryChart( bool withdrawals ) 558void Checkbook::drawCategoryChart( bool withdrawals )
616{ 559{
617 DataPointList *list = new DataPointList(); 560 DataPointList *list = new DataPointList();
618 561
619 TranInfo *tran = transactions.first(); 562 TranInfo *tran = tranList->first();
620 if ( tran && tran->withdrawal() == withdrawals ) 563 if ( tran && tran->withdrawal() == withdrawals )
621 { 564 {
622 list->append( new DataPointInfo( tran->category(), tran->amount() ) ); 565 list->append( new DataPointInfo( tran->category(), tran->amount() ) );
623 } 566 }
624 tran = transactions.next(); 567 tran = tranList->next();
625 568
626 DataPointInfo *cat; 569 DataPointInfo *cat;
627 for ( ; tran; tran = transactions.next() ) 570 for ( ; tran; tran = tranList->next() )
628 { 571 {
629 if ( tran->withdrawal() == withdrawals ) 572 if ( tran->withdrawal() == withdrawals )
630 { 573 {
631 // Find category in list 574 // Find category in list
632 for ( cat = list->first(); cat; cat = list->next() ) 575 for ( cat = list->first(); cat; cat = list->next() )
633 { 576 {
634 if ( cat->label() == tran->category() ) 577 if ( cat->label() == tran->category() )
635 { 578 {
636 break; 579 break;
637 } 580 }
638 } 581 }
639 if ( cat && cat->label() == tran->category() ) 582 if ( cat && cat->label() == tran->category() )
@@ -703,13 +646,13 @@ bool CBListItem::isAltBackground()
703 } 646 }
704 647
705 while(item) 648 while(item)
706 { 649 {
707 item->m_odd = previous = !previous; 650 item->m_odd = previous = !previous;
708 item->m_known = true; 651 item->m_known = true;
709 item = (CBListItem *)( item->nextSibling() ); 652 item = (CBListItem *)( item->nextSibling() );
710 } 653 }
711 } 654 }
712 return m_odd; 655 return m_odd;
713 } 656 }
714 return false; 657 return false;
715} \ No newline at end of file 658}
diff --git a/noncore/apps/checkbook/checkbook.h b/noncore/apps/checkbook/checkbook.h
index 27658ff..4a5011b 100644
--- a/noncore/apps/checkbook/checkbook.h
+++ b/noncore/apps/checkbook/checkbook.h
@@ -20,83 +20,76 @@
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 "traninfo.h"
33
34#include <qdialog.h> 32#include <qdialog.h>
35#include <qlistview.h> 33#include <qlistview.h>
36 34
37class OTabWidget; 35class OTabWidget;
38 36
37class CBInfo;
39class Graph; 38class Graph;
40class GraphInfo; 39class GraphInfo;
41class QCheckBox; 40class QCheckBox;
42class QComboBox; 41class QComboBox;
43class QLabel; 42class QLabel;
44class QLineEdit; 43class QLineEdit;
45class QListView; 44class QListView;
46class QMultiLineEdit; 45class QMultiLineEdit;
47class QString; 46class QString;
47class TranInfo;
48class TranInfoList;
48 49
49class Checkbook : public QDialog 50class Checkbook : public QDialog
50{ 51{
51 Q_OBJECT 52 Q_OBJECT
52 53
53 public: 54 public:
54 Checkbook( QWidget * = 0x0, const QString & = 0x0, const QString & = 0x0, 55 Checkbook( QWidget * = 0x0, CBInfo * = 0x0, const QString & = "$" );
55 const QString & = "$" );
56 ~Checkbook(); 56 ~Checkbook();
57 57
58 const QString &getName();
59
60 private: 58 private:
61 TranInfoList transactions; 59 CBInfo *info;
62 QString name; 60 TranInfoList *tranList;
63 QString filename; 61 QString currencySymbol;
64 QString filedir; 62 int highTranNum;
65 QString currencySymbol;
66 QString password;
67 int highTranNum;
68 63
69 OTabWidget *mainWidget; 64 OTabWidget *mainWidget;
70 void loadCheckbook(); 65 void loadCheckbook();
71 void adjustBalance( float ); 66 void adjustBalance();
72 TranInfo *findTran( const QString &, const QString &, const QString & ); 67 TranInfo *findTran( const QString &, const QString &, const QString & );
73 68
74 // Info tab 69 // Info tab
75 QWidget *initInfo(); 70 QWidget *initInfo();
76 QCheckBox *passwordCB; 71 QCheckBox *passwordCB;
77 QLineEdit *nameEdit; 72 QLineEdit *nameEdit;
78 QComboBox *typeList; 73 QComboBox *typeList;
79 QLineEdit *bankEdit; 74 QLineEdit *bankEdit;
80 QLineEdit *acctNumEdit; 75 QLineEdit *acctNumEdit;
81 QLineEdit *pinNumEdit; 76 QLineEdit *pinNumEdit;
82 QLineEdit *balanceEdit; 77 QLineEdit *balanceEdit;
83 QMultiLineEdit *notesEdit; 78 QMultiLineEdit *notesEdit;
84 float startBalance;
85 79
86 // Transactions tab 80 // Transactions tab
87 QWidget *initTransactions(); 81 QWidget *initTransactions();
88 QListView *tranTable; 82 QListView *tranTable;
89 QLabel *balanceLabel; 83 QLabel *balanceLabel;
90 float currBalance;
91 84
92 // Charts tab 85 // Charts tab
93 QWidget *initCharts(); 86 QWidget *initCharts();
94 GraphInfo *graphInfo; 87 GraphInfo *graphInfo;
95 QComboBox *graphList; 88 QComboBox *graphList;
96 Graph *graphWidget; 89 Graph *graphWidget;
97 90
98 void drawBalanceChart(); 91 void drawBalanceChart();
99 void drawCategoryChart( bool = TRUE ); 92 void drawCategoryChart( bool = TRUE );
100 93
101 protected slots: 94 protected slots:
102 void accept(); 95 void accept();
diff --git a/noncore/apps/checkbook/checkbook.pro b/noncore/apps/checkbook/checkbook.pro
index 53b5ff4..05cac15 100644
--- a/noncore/apps/checkbook/checkbook.pro
+++ b/noncore/apps/checkbook/checkbook.pro
@@ -1,28 +1,32 @@
1TEMPLATE = app 1TEMPLATE = app
2CONFIG = qt warn_on release 2CONFIG = qt warn_on release
3HEADERS = mainwindow.h \ 3HEADERS = mainwindow.h \
4 traninfo.h \ 4 cbinfo.h \
5 graphinfo.h \ 5 traninfo.h \
6 password.h \ 6 graphinfo.h \
7 checkbook.h \ 7 configuration.h \
8 transaction.h \ 8 password.h \
9 checkbook.h \
10 transaction.h \
9 graph.h 11 graph.h
10SOURCES = main.cpp \ 12SOURCES = main.cpp \
11 mainwindow.cpp \ 13 mainwindow.cpp \
12 traninfo.cpp \ 14 cbinfo.cpp \
13 graphinfo.cpp \ 15 traninfo.cpp \
14 password.cpp \ 16 graphinfo.cpp \
15 checkbook.cpp \ 17 configuration.cpp \
16 transaction.cpp \ 18 password.cpp \
19 checkbook.cpp \
20 transaction.cpp \
17 graph.cpp 21 graph.cpp
18INCLUDEPATH += $(OPIEDIR)/include 22INCLUDEPATH += $(OPIEDIR)/include
19DEPENDPATH += $(OPIEDIR)/include 23DEPENDPATH += $(OPIEDIR)/include
20LIBS += -lqpe -lopie 24LIBS += -lqpe -lopie
21TARGET = checkbook 25TARGET = checkbook
22DESTDIR = $(OPIEDIR)/bin 26DESTDIR = $(OPIEDIR)/bin
23 27
24TRANSLATIONS = ../../../i18n/de/checkbook.ts \ 28TRANSLATIONS = ../../../i18n/de/checkbook.ts \
25 ../../../i18n/en/checkbook.ts \ 29 ../../../i18n/en/checkbook.ts \
26 ../../../i18n/es/checkbook.ts \ 30 ../../../i18n/es/checkbook.ts \
27 ../../../i18n/fr/checkbook.ts \ 31 ../../../i18n/fr/checkbook.ts \
28 ../../../i18n/hu/checkbook.ts \ 32 ../../../i18n/hu/checkbook.ts \
diff --git a/noncore/apps/checkbook/configuration.cpp b/noncore/apps/checkbook/configuration.cpp
new file mode 100644
index 0000000..37208da
--- a/dev/null
+++ b/noncore/apps/checkbook/configuration.cpp
@@ -0,0 +1,76 @@
1/*
2                This file is part of the OPIE Project
3 =.
4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#include "configuration.h"
30
31#include <qcheckbox.h>
32#include <qfontmetrics.h>
33#include <qlabel.h>
34#include <qlayout.h>
35#include <qlineedit.h>
36#include <qstring.h>
37#include <qwhatsthis.h>
38
39Configuration::Configuration( QWidget *parent, const QString &cs, bool sl, bool sb )
40 : QDialog( parent, 0, TRUE, WStyle_ContextHelp )
41{
42 setCaption( tr( "Configure Checkbook" ) );
43
44 QFontMetrics fm = fontMetrics();
45 int fh = fm.height();
46
47 QGridLayout *layout = new QGridLayout( this );
48 layout->setSpacing( 4 );
49 layout->setMargin( 4 );
50
51 QLabel *label = new QLabel( tr( "Enter currency symbol:" ), this );
52 QWhatsThis::add( label, tr( "Enter your local currency symbol here." ) );
53 label->setMaximumHeight( fh + 3 );
54 layout->addWidget( label, 0, 0 );
55
56 symbolEdit = new QLineEdit( cs, this );
57 QWhatsThis::add( symbolEdit, tr( "Enter your local currency symbol here." ) );
58 symbolEdit->setMaximumHeight( fh + 5 );
59 symbolEdit->setFocus();
60 layout->addWidget( symbolEdit, 0, 1 );
61
62 lockCB = new QCheckBox( tr( "Show whether checkbook is password\nprotected" ), this );
63 QWhatsThis::add( lockCB, tr( "Click here to select whether or not the main window will display that the checkbook is protected with a password." ) );
64 lockCB->setChecked( sl );
65 layout->addMultiCellWidget( lockCB, 1, 1, 0, 1 );
66
67 balCB = new QCheckBox( tr( "Show checkbook balances" ), this );
68 QWhatsThis::add( balCB, tr( "Click here to select whether or not the main window will display the current balance for each checkbook." ) );
69 balCB->setMaximumHeight( fh + 5 );
70 balCB->setChecked( sb );
71 layout->addMultiCellWidget( balCB, 2, 2, 0, 1 );
72}
73
74Configuration::~Configuration()
75{
76}
diff --git a/noncore/apps/checkbook/configuration.h b/noncore/apps/checkbook/configuration.h
new file mode 100644
index 0000000..9a8de02
--- a/dev/null
+++ b/noncore/apps/checkbook/configuration.h
@@ -0,0 +1,51 @@
1/*
2                This file is part of the OPIE Project
3 =.
4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#ifndef CONFIGURATION_H
30#define CONFIGURATION_H
31
32#include <qdialog.h>
33
34class QCheckBox;
35class QLineEdit;
36class QString;
37
38class Configuration : public QDialog
39{
40 Q_OBJECT
41
42 public:
43 Configuration( QWidget * = 0x0, const QString & = "$", bool = FALSE, bool = FALSE );
44 ~Configuration();
45
46 QLineEdit *symbolEdit;
47 QCheckBox *lockCB;
48 QCheckBox *balCB;
49};
50
51#endif
diff --git a/noncore/apps/checkbook/graph.cpp b/noncore/apps/checkbook/graph.cpp
index 8ae835c..acdb846 100644
--- a/noncore/apps/checkbook/graph.cpp
+++ b/noncore/apps/checkbook/graph.cpp
@@ -78,29 +78,24 @@ void Graph::initGraph()
78 return; 78 return;
79 } 79 }
80 80
81 // Any common stuff here (titles, ???) 81 // Any common stuff here (titles, ???)
82 82
83 switch ( data->graphType() ) 83 switch ( data->graphType() )
84 { 84 {
85 case GraphInfo::BarChart : 85 case GraphInfo::BarChart :
86 { 86 {
87 drawBarChart( width(), height(), data->maxValue() ); 87 drawBarChart( width(), height(), data->maxValue() );
88 } 88 }
89 break; 89 break;
90 case GraphInfo::LineChart :
91 {
92 //drawLineChart( p, s, min, max );
93 }
94 break;
95 case GraphInfo::PieChart : 90 case GraphInfo::PieChart :
96 { 91 {
97 drawPieChart( width(), height(), data->totalValue() ); 92 drawPieChart( width(), height(), data->totalValue() );
98 } 93 }
99 }; 94 };
100} 95}
101 96
102void Graph::drawBarChart( int width, int height, float max ) 97void Graph::drawBarChart( int width, int height, float max )
103{ 98{
104 QPainter p( &graph ); 99 QPainter p( &graph );
105 100
106 // Try to set the font size smaller for text 101 // Try to set the font size smaller for text
@@ -123,28 +118,24 @@ void Graph::drawBarChart( int width, int height, float max )
123 int bw = ( width - width / 4 - x ) / ( n - i ); 118 int bw = ( width - width / 4 - x ) / ( n - i );
124 int bh = int( ( height - height / 4 - 1 ) * dp->value() / max ); 119 int bh = int( ( height - height / 4 - 1 ) * dp->value() / max );
125 p.drawRect( width / 8 + x, height - height / 8 - 1 - bh, bw, bh ); 120 p.drawRect( width / 8 + x, height - height / 8 - 1 - bh, bw, bh );
126 fw = fm.width( dp->label() ); 121 fw = fm.width( dp->label() );
127 p.drawText( width / 8 + x - fw / 2 + bw / 2, height - height / 8, fw, 122 p.drawText( width / 8 + x - fw / 2 + bw / 2, height - height / 8, fw,
128 fh + height / 8, AlignTop | AlignHCenter, dp->label() ); 123 fh + height / 8, AlignTop | AlignHCenter, dp->label() );
129 // WordBreak | AlignTop | AlignHCenter, dp->label() ); 124 // WordBreak | AlignTop | AlignHCenter, dp->label() );
130 i++; 125 i++;
131 x += bw; 126 x += bw;
132 } 127 }
133} 128}
134 129
135void Graph::drawLineChart( int width, int height, float max )
136{
137}
138
139void Graph::drawPieChart( int width, int height, float sum ) 130void Graph::drawPieChart( int width, int height, float sum )
140{ 131{
141 QPainter p( &graph ); 132 QPainter p( &graph );
142 133
143 // Try to set the font size smaller for text 134 // Try to set the font size smaller for text
144 QFont f = font(); 135 QFont f = font();
145 f.setPointSize( 8 ); 136 f.setPointSize( 8 );
146 p.setFont( f ); 137 p.setFont( f );
147 138
148 int n = data->numberDataPoints(); 139 int n = data->numberDataPoints();
149 140
150 int apos = -90 * 16; 141 int apos = -90 * 16;
diff --git a/noncore/apps/checkbook/graph.h b/noncore/apps/checkbook/graph.h
index 0361718..340e910 100644
--- a/noncore/apps/checkbook/graph.h
+++ b/noncore/apps/checkbook/graph.h
@@ -48,17 +48,16 @@ class Graph : public QWidget
48 48
49 protected: 49 protected:
50 void paintEvent( QPaintEvent * ); 50 void paintEvent( QPaintEvent * );
51 void resizeEvent( QResizeEvent * ); 51 void resizeEvent( QResizeEvent * );
52 52
53 private: 53 private:
54 GraphInfo *data; 54 GraphInfo *data;
55 55
56 QPixmap graph; 56 QPixmap graph;
57 57
58 void initGraph(); 58 void initGraph();
59 void drawBarChart( int, int, float ); 59 void drawBarChart( int, int, float );
60 void drawLineChart( int, int, float );
61 void drawPieChart( int, int, float ); 60 void drawPieChart( int, int, float );
62}; 61};
63 62
64#endif 63#endif
diff --git a/noncore/apps/checkbook/graphinfo.h b/noncore/apps/checkbook/graphinfo.h
index 3bcf676..41927b4 100644
--- a/noncore/apps/checkbook/graphinfo.h
+++ b/noncore/apps/checkbook/graphinfo.h
@@ -46,25 +46,25 @@ class DataPointInfo
46 void addToValue( float value ) { v += value; } 46 void addToValue( float value ) { v += value; }
47 47
48 private: 48 private:
49 QString l; 49 QString l;
50 float v; 50 float v;
51}; 51};
52 52
53typedef QList<DataPointInfo> DataPointList; 53typedef QList<DataPointInfo> DataPointList;
54 54
55class GraphInfo 55class GraphInfo
56{ 56{
57 public: 57 public:
58 enum GraphType { BarChart, LineChart, PieChart }; 58 enum GraphType { BarChart, PieChart };
59 59
60 GraphInfo( GraphType = BarChart, DataPointList * = 0x0, 60 GraphInfo( GraphType = BarChart, DataPointList * = 0x0,
61 const QString & = 0x0, const QString & = 0x0, const QString & = 0x0 ); 61 const QString & = 0x0, const QString & = 0x0, const QString & = 0x0 );
62 ~GraphInfo(); 62 ~GraphInfo();
63 63
64 GraphInfo::GraphType graphType(); 64 GraphInfo::GraphType graphType();
65 void setGraphType( GraphType ); 65 void setGraphType( GraphType );
66 66
67 DataPointList *dataPoints(); 67 DataPointList *dataPoints();
68 void setDataPoints( DataPointList * ); 68 void setDataPoints( DataPointList * );
69 DataPointInfo *firstDataPoint(); 69 DataPointInfo *firstDataPoint();
70 DataPointInfo *nextDataPoint(); 70 DataPointInfo *nextDataPoint();
diff --git a/noncore/apps/checkbook/mainwindow.cpp b/noncore/apps/checkbook/mainwindow.cpp
index 2c0abf1..68c6aee 100644
--- a/noncore/apps/checkbook/mainwindow.cpp
+++ b/noncore/apps/checkbook/mainwindow.cpp
@@ -18,48 +18,60 @@
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"
31#include "configuration.h"
30#include "password.h" 32#include "password.h"
31#include "checkbook.h" 33#include "checkbook.h"
32 34
33#include <qpe/config.h> 35#include <qpe/config.h>
34#include <qpe/global.h> 36#include <qpe/global.h>
35#include <qpe/qpeapplication.h> 37#include <qpe/qpeapplication.h>
36#include <qpe/qpemenubar.h> 38#include <qpe/qpemenubar.h>
37#include <qpe/qpemessagebox.h> 39#include <qpe/qpemessagebox.h>
38#include <qpe/qpetoolbar.h> 40#include <qpe/qpetoolbar.h>
39#include <qpe/resource.h> 41#include <qpe/resource.h>
40 42
41#include <qaction.h> 43#include <qaction.h>
44#include <qcheckbox.h>
42#include <qdir.h> 45#include <qdir.h>
43#include <qlistbox.h> 46#include <qlineedit.h>
47#include <qlistview.h>
44#include <qpopupmenu.h> 48#include <qpopupmenu.h>
45#include <qstring.h> 49#include <qstring.h>
46#include <qwhatsthis.h> 50#include <qwhatsthis.h>
47 51
48MainWindow::MainWindow() 52MainWindow::MainWindow()
49 : QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) 53 : QMainWindow( 0x0, 0x0, WStyle_ContextHelp )
50{ 54{
51 setCaption( tr( "Checkbook" ) ); 55 setCaption( tr( "Checkbook" ) );
52 56
53 cbDir = Global::applicationFileName( "checkbook", "" ); 57 cbDir = Global::applicationFileName( "checkbook", "" );
58 lockIcon = Resource::loadPixmap( "locked" );
59
60 // Load configuration options
61 Config config( "checkbook" );
62 config.setGroup( "Config" );
63 currencySymbol = config.readEntry( "CurrencySymbol", "$" );
64 showLocks = config.readBoolEntry( "ShowLocks", FALSE );
65 showBalances = config.readBoolEntry( "ShowBalances", FALSE );
54 66
55 // Build menu and tool bars 67 // Build menu and tool bars
56 setToolBarsMovable( FALSE ); 68 setToolBarsMovable( FALSE );
57 69
58 QPEToolBar *bar = new QPEToolBar( this ); 70 QPEToolBar *bar = new QPEToolBar( this );
59 bar->setHorizontalStretchable( TRUE ); 71 bar->setHorizontalStretchable( TRUE );
60 QPEMenuBar *mb = new QPEMenuBar( bar ); 72 QPEMenuBar *mb = new QPEMenuBar( bar );
61 mb->setMargin( 0 ); 73 mb->setMargin( 0 );
62 QPopupMenu *popup = new QPopupMenu( this ); 74 QPopupMenu *popup = new QPopupMenu( this );
63 75
64 bar = new QPEToolBar( this ); 76 bar = new QPEToolBar( this );
65 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); 77 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
@@ -73,114 +85,248 @@ MainWindow::MainWindow()
73 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." ) ); 85 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." ) );
74 connect( actionOpen, SIGNAL( activated() ), this, SLOT( slotEdit() ) ); 86 connect( actionOpen, SIGNAL( activated() ), this, SLOT( slotEdit() ) );
75 actionOpen->addTo( popup ); 87 actionOpen->addTo( popup );
76 actionOpen->addTo( bar ); 88 actionOpen->addTo( bar );
77 89
78 actionDelete = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 90 actionDelete = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null,
79 0, this, 0 ); 91 0, this, 0 );
80 actionDelete->setWhatsThis( tr( "Select a checkbook and then click here delete it.\n\nYou also can select Delete from the Checkbook menu." ) ); 92 actionDelete->setWhatsThis( tr( "Select a checkbook and then click here delete it.\n\nYou also can select Delete from the Checkbook menu." ) );
81 connect( actionDelete, SIGNAL( activated() ), this, SLOT( slotDelete() ) ); 93 connect( actionDelete, SIGNAL( activated() ), this, SLOT( slotDelete() ) );
82 actionDelete->addTo( popup ); 94 actionDelete->addTo( popup );
83 actionDelete->addTo( bar ); 95 actionDelete->addTo( bar );
84 96
85 mb->insertItem( tr( "Checkbook" ), popup ); 97 popup->insertSeparator();
86 98
87 // Build Checkbook selection list control 99 a = new QAction( tr( "Configure" ), Resource::loadPixmap( "checkbook/config" ), QString::null, 0, this, 0 );
88 cbList = new QListBox( this ); 100 a->setWhatsThis( tr( "Click here to configure this app." ) );
89 QWhatsThis::add( cbList, tr( "This is a listing of all checkbooks currently available." ) ); 101 connect( a, SIGNAL( activated() ), this, SLOT( slotConfigure() ) );
90 QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold ); 102 a->addTo( popup );
91 connect( cbList, SIGNAL( rightButtonPressed( QListBoxItem *, const QPoint & ) ), 103 a->addTo( bar );
92 this, SLOT( slotEdit() ) ); 104
93 setCentralWidget( cbList ); 105 mb->insertItem( tr( "Checkbook" ), popup );
94 106
95 // Load Checkbook selection list 107 // Load Checkbook selection list
108 checkbooks = new CBInfoList();
109
96 QDir checkdir( cbDir ); 110 QDir checkdir( cbDir );
97 if (checkdir.exists() == true) 111 if (checkdir.exists() == true)
98 { 112 {
99 QStringList checkbooks = checkdir.entryList( "*.qcb", QDir::Files|QDir::Readable|QDir::Writable, 113 QStringList cblist = checkdir.entryList( "*.qcb", QDir::Files|QDir::Readable|QDir::Writable,
100 QDir::Time ); 114 QDir::Time );
101 for ( QStringList::Iterator it = checkbooks.begin(); it != checkbooks.end(); it++ ) 115 CBInfo *cb = 0x0;
116 QString filename;
117
118 for ( QStringList::Iterator it = cblist.begin(); it != cblist.end(); it++ )
102 { 119 {
103 (*it) = (*it).remove( (*it).find('.'), (*it).length() ); 120 filename = cbDir;
121 filename.append( (*it) );
122
123 cb = new CBInfo( (*it).remove( (*it).find('.'), (*it).length() ), filename );
124 checkbooks->inSort( cb );
104 } 125 }
105 cbList->insertStringList( checkbooks );
106 } 126 }
107 cbList->sort();
108 cbList->setSelected( 0, TRUE );
109 127
110 currencySymbol = "$"; 128 // Build Checkbook selection list control
129 cbList = 0x0;
130 buildList();
111} 131}
112 132
113MainWindow::~MainWindow() 133MainWindow::~MainWindow()
114{ 134{
135 //config.write();
136}
137
138void MainWindow::buildList()
139{
140 if ( cbList )
141 {
142 delete cbList;
143 }
144
145 cbList = new QListView( this );
146 QWhatsThis::add( cbList, tr( "This is a listing of all checkbooks currently available." ) );
147
148 if ( showLocks )
149 {
150 cbList->addColumn( Resource::loadIconSet( "locked" ), "", 24 );
151 posName = 1;
152 }
153 else
154 {
155 posName = 0;
156 }
157 cbList->addColumn( tr( "Checkbook Name" ) );
158 if ( showBalances )
159 {
160 int colnum = cbList->addColumn( tr( "Balance" ) );
161 cbList->setColumnAlignment( colnum, Qt::AlignRight );
162 }
163 cbList->setAllColumnsShowFocus( TRUE );
164 cbList->setSorting( posName );
165 QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold );
166 connect( cbList, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ),
167 this, SLOT( slotEdit() ) );
168 setCentralWidget( cbList );
169
170 for ( CBInfo *cb = checkbooks->first(); cb; cb = checkbooks->next() )
171 {
172 addCheckbook( cb );
173 }
174}
175
176void MainWindow::addCheckbook( CBInfo *cb )
177{
178 QListViewItem *lvi = new QListViewItem( cbList );
179 if ( showLocks && !cb->password().isNull() )
180 {
181 lvi->setPixmap( 0, lockIcon );
182 }
183 lvi->setText( posName, cb->name() );
184 if ( showBalances )
185 {
186 QString balance;
187 balance.sprintf( "%s%.2f", currencySymbol.latin1(), cb->balance() );
188 lvi->setText( posName + 1, balance );
189 }
190}
191
192void MainWindow::buildFilename( const QString &name )
193{
194 tempFilename = cbDir;
195 tempFilename.append( name );
196 tempFilename.append( ".qcb" );
115} 197}
116 198
117void MainWindow::slotNew() 199void MainWindow::slotNew()
118{ 200{
119 Checkbook *currcb = new Checkbook( this, "", cbDir, currencySymbol ); 201 CBInfo *cb = new CBInfo();
202
203 Checkbook *currcb = new Checkbook( this, cb, currencySymbol );
120 currcb->showMaximized(); 204 currcb->showMaximized();
121 if ( currcb->exec() == QDialog::Accepted ) 205 if ( currcb->exec() == QDialog::Accepted )
122 { 206 {
123 cbList->insertItem( currcb->getName() ); 207 checkbooks->inSort( cb );
124 cbList->sort(); 208 addCheckbook( cb );
125 delete currcb;
126 } 209 }
210 delete currcb;
127} 211}
128 212
129void MainWindow::slotEdit() 213void MainWindow::slotEdit()
130{ 214{
131 QString currname = cbList->currentText(); 215
132 216 QListViewItem *curritem = cbList->currentItem();
133 QString tempstr = cbDir; 217 if ( !curritem )
134 tempstr.append( currname ); 218 {
135 tempstr.append( ".qcb" ); 219 return;
136 220 }
137 Config config( tempstr, Config::File ); 221 QString currname = curritem->text( posName );
138 config.setGroup( "Account" ); 222
139 QString password = config.readEntryCrypt( "Password", "" ); 223 CBInfo *cb = checkbooks->first();
140 if ( password != "" ) 224 while ( cb )
225 {
226 if ( cb->name() == currname )
227 break;
228 cb = checkbooks->next();
229 }
230 if ( !cb )
231 {
232 return;
233 }
234
235 buildFilename( currname );
236 float currbalance = cb->balance();
237 bool currlock = !cb->password().isNull();
238
239 if ( currlock )
141 { 240 {
142 Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); 241 Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) );
143 if ( pw->exec() != QDialog::Accepted || pw->password != password ) 242 if ( pw->exec() != QDialog::Accepted || pw->password != cb->password() )
144 { 243 {
145 delete pw; 244 delete pw;
146 return; 245 return;
147 } 246 }
148 delete pw; 247 delete pw;
149 } 248 }
150 249
151 Checkbook *currcb = new Checkbook( this, currname, cbDir, currencySymbol ); 250 Checkbook *currcb = new Checkbook( this, cb, currencySymbol );
152 currcb->showMaximized(); 251 currcb->showMaximized();
153 if ( currcb->exec() == QDialog::Accepted ) 252 if ( currcb->exec() == QDialog::Accepted )
154 { 253 {
155 QString newname = currcb->getName(); 254 QString newname = cb->name();
156 if ( currname != newname ) 255 if ( currname != newname )
157 { 256 {
158 cbList->changeItem( newname, cbList->currentItem() ); 257 // Update name if changed
258 curritem->setText( posName, newname );
159 cbList->sort(); 259 cbList->sort();
160 260
161 QFile f( tempstr ); 261 // Remove old file
262 QFile f( tempFilename );
162 if ( f.exists() ) 263 if ( f.exists() )
163 { 264 {
164 f.remove(); 265 f.remove();
165 } 266 }
267
268 // Get new filename
269 buildFilename( newname );
270 cb->setFilename( tempFilename );
271 }
272
273 cb->write();
274
275 // Update lock if changed
276 if ( showLocks && !cb->password().isNull() != currlock )
277 {
278 if ( !cb->password().isNull() )
279 curritem->setPixmap( 0, lockIcon );
280 else
281 curritem->setPixmap( 0, nullIcon );
282 }
283
284 // Update balance if changed
285 if ( showBalances && cb->balance() != currbalance )
286 {
287 QString tempstr;
288 tempstr.sprintf( "%s%.2f", currencySymbol.latin1(), cb->balance() );
289 curritem->setText( posName + 1, tempstr );
166 } 290 }
167 delete currcb;
168 } 291 }
292 delete currcb;
169} 293}
170 294
171void MainWindow::slotDelete() 295void MainWindow::slotDelete()
172{ 296{
173 if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), cbList->currentText() ) ) 297 QString currname = cbList->currentItem()->text( posName );
298
299 if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), currname ) )
174 { 300 {
175 QString tempstr = cbDir; 301 buildFilename( currname );
176 tempstr.append( cbList->currentText() ); 302 QFile f( tempFilename );
177 tempstr.append( ".qcb" );
178 QFile f( tempstr );
179 if ( f.exists() ) 303 if ( f.exists() )
180 { 304 {
181 f.remove(); 305 f.remove();
182 } 306 }
183 307
184 cbList->removeItem( cbList->currentItem() ); 308 delete cbList->currentItem();
309 }
310}
311
312void MainWindow::slotConfigure()
313{
314 Configuration *cfgdlg = new Configuration( this, currencySymbol, showLocks, showBalances );
315 cfgdlg->showMaximized();
316 if ( cfgdlg->exec() == QDialog::Accepted )
317 {
318 currencySymbol = cfgdlg->symbolEdit->text();
319 showLocks = cfgdlg->lockCB->isChecked();
320 showBalances = cfgdlg->balCB->isChecked();
321
322 Config config( "checkbook" );
323 config.setGroup( "Config" );
324 config.writeEntry( "CurrencySymbol", currencySymbol );
325 config.writeEntry( "ShowLocks", showLocks );
326 config.writeEntry( "ShowBalances", showBalances );
327 config.write();
328
329 buildList();
185 } 330 }
331 delete cfgdlg;
186} 332}
diff --git a/noncore/apps/checkbook/mainwindow.h b/noncore/apps/checkbook/mainwindow.h
index 11a3343..2bc70b3 100644
--- a/noncore/apps/checkbook/mainwindow.h
+++ b/noncore/apps/checkbook/mainwindow.h
@@ -21,40 +21,56 @@
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 MAINWINDOW_H 29#ifndef MAINWINDOW_H
30#define MAINWINDOW_H 30#define MAINWINDOW_H
31 31
32#include <qmainwindow.h> 32#include <qmainwindow.h>
33#include <qpixmap.h>
33 34
35class CBInfo;
36class CBInfoList;
34class QAction; 37class QAction;
35class QListBox; 38class QListView;
36class QListBoxItem;
37class QString; 39class QString;
38 40
39class MainWindow : public QMainWindow 41class MainWindow : public QMainWindow
40{ 42{
41 Q_OBJECT 43 Q_OBJECT
42 44
43 public: 45 public:
44 MainWindow(); 46 MainWindow();
45 ~MainWindow(); 47 ~MainWindow();
46 48
47 private: 49 private:
48 QListBox *cbList; 50 QListView *cbList;
49 QString cbDir; 51 QString cbDir;
50 QAction *actionOpen; 52 QAction *actionOpen;
51 QAction *actionDelete; 53 QAction *actionDelete;
52 QString currencySymbol; 54
55 QString currencySymbol;
56 bool showLocks;
57 bool showBalances;
58 int posName;
59
60 CBInfoList *checkbooks;
61 QString tempFilename;
62 QPixmap lockIcon;
63 QPixmap nullIcon;
64
65 void buildList();
66 void addCheckbook( CBInfo * );
67 void buildFilename( const QString & );
53 68
54 private slots: 69 private slots:
55 void slotNew(); 70 void slotNew();
56 void slotEdit(); 71 void slotEdit();
57 void slotDelete(); 72 void slotDelete();
73 void slotConfigure();
58}; 74};
59 75
60#endif 76#endif
diff --git a/noncore/apps/checkbook/traninfo.h b/noncore/apps/checkbook/traninfo.h
index 59cfe14..5f67262 100644
--- a/noncore/apps/checkbook/traninfo.h
+++ b/noncore/apps/checkbook/traninfo.h
@@ -44,49 +44,47 @@ class TranInfo
44 const QString & = 0x0, const QString & = 0x0 ); 44 const QString & = 0x0, const QString & = 0x0 );
45 TranInfo( Config, int ); 45 TranInfo( Config, int );
46 46
47 int id() const { return i; } 47 int id() const { return i; }
48 const QString &desc() const { return d; } 48 const QString &desc() const { return d; }
49 const QDate &date() const { return td; } 49 const QDate &date() const { return td; }
50 const QString &datestr(); 50 const QString &datestr();
51 bool withdrawal()const { return w; } 51 bool withdrawal()const { return w; }
52 const QString &type() const { return t; } 52 const QString &type() const { return t; }
53 const QString &category()const { return c; } 53 const QString &category()const { return c; }
54 float amount() const { return a; } 54 float amount() const { return a; }
55 float fee() const { return f; } 55 float fee() const { return f; }
56 const QString &number() const { return cn; } 56 const QString &number()const { return cn; }
57 const QString &notes() const { return n; } 57 const QString &notes() const { return n; }
58 58
59 void setDesc( const QString &desc ) { d = desc; } 59 void setDesc( const QString &desc ) { d = desc; }
60 void setDate( const QDate &date ) { td = date; } 60 void setDate( const QDate &date ) { td = date; }
61 void setWithdrawal( bool withdrawal ){ w = withdrawal; } 61 void setWithdrawal( bool withdrawal ) { w = withdrawal; }
62 void setType( const QString &type ) { t = type; } 62 void setType( const QString &type ) { t = type; }
63 void setCategory( const QString &cat ){ c = cat; } 63 void setCategory( const QString &cat ){ c = cat; }
64 void setAmount( float amount ) { a = amount; } 64 void setAmount( float amount ) { a = amount; }
65 void setFee( float fee ) { f = fee; } 65 void setFee( float fee ) { f = fee; }
66 void setNumber( const QString &num ){ cn = num; } 66 void setNumber( const QString &num ) { cn = num; }
67 void setNotes( const QString &notes ){ n = notes; } 67 void setNotes( const QString &notes ) { n = notes; }
68 68
69 void write( Config *, int ); 69 void write( Config *, int );
70 70
71 private: 71 private:
72 int i; 72 int i;
73 QString d; 73 QString d;
74 QDate td; 74 QDate td;
75 bool w; 75 bool w;
76 QString t; 76 QString t;
77 QString c; 77 QString c;
78 float a; 78 float a;
79 float f; 79 float f;
80 QString cn; 80 QString cn;
81 QString n; 81 QString n;
82}; 82};
83 83
84class TranInfoList : public QList<TranInfo> 84class TranInfoList : public QList<TranInfo>
85{ 85{
86 protected: 86 protected:
87 int compareItems( QCollection::Item, QCollection::Item ); 87 int compareItems( QCollection::Item, QCollection::Item );
88}; 88};
89 89
90//typedef TranList<TranInfo> TranInfoList;
91
92#endif 90#endif