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
@@ -1,166 +1,158 @@
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 "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 );
79 layout->setSpacing( 4 ); 76 layout->setSpacing( 4 );
80 77
81 // Setup tabs for all info 78 // Setup tabs for all info
82 mainWidget = new OTabWidget( this ); 79 mainWidget = new OTabWidget( this );
83 layout->addWidget( mainWidget ); 80 layout->addWidget( mainWidget );
84 81
85 mainWidget->addTab( initInfo(), "checkbook/infotab", tr( "Info" ) ); 82 mainWidget->addTab( initInfo(), "checkbook/infotab", tr( "Info" ) );
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() );
115 sv->addChild( container ); 107 sv->addChild( container );
116 108
117 QGridLayout *layout = new QGridLayout( container ); 109 QGridLayout *layout = new QGridLayout( container );
118 layout->setSpacing( 2 ); 110 layout->setSpacing( 2 );
119 layout->setMargin( 4 ); 111 layout->setMargin( 4 );
120 112
121 // Password protection 113 // Password protection
122 passwordCB = new QCheckBox( tr( "Password protect" ), container ); 114 passwordCB = new QCheckBox( tr( "Password protect" ), container );
123 QWhatsThis::add( passwordCB, tr( "Click here to enable/disable password protection of this checkbook." ) ); 115 QWhatsThis::add( passwordCB, tr( "Click here to enable/disable password protection of this checkbook." ) );
124 connect( passwordCB, SIGNAL( clicked() ), this, SLOT( slotPasswordClicked() ) ); 116 connect( passwordCB, SIGNAL( clicked() ), this, SLOT( slotPasswordClicked() ) );
125 layout->addMultiCellWidget( passwordCB, 0, 0, 0, 1 ); 117 layout->addMultiCellWidget( passwordCB, 0, 0, 0, 1 );
126 118
127 // Account name 119 // Account name
128 QLabel *label = new QLabel( tr( "Name:" ), container ); 120 QLabel *label = new QLabel( tr( "Name:" ), container );
129 QWhatsThis::add( label, tr( "Enter name of checkbook here." ) ); 121 QWhatsThis::add( label, tr( "Enter name of checkbook here." ) );
130 layout->addWidget( label, 1, 0 ); 122 layout->addWidget( label, 1, 0 );
131 nameEdit = new QLineEdit( container ); 123 nameEdit = new QLineEdit( container );
132 QWhatsThis::add( nameEdit, tr( "Enter name of checkbook here." ) ); 124 QWhatsThis::add( nameEdit, tr( "Enter name of checkbook here." ) );
133 connect( nameEdit, SIGNAL( textChanged( const QString & ) ), 125 connect( nameEdit, SIGNAL( textChanged( const QString & ) ),
134 this, SLOT( slotNameChanged( const QString & ) ) ); 126 this, SLOT( slotNameChanged( const QString & ) ) );
135 layout->addWidget( nameEdit, 1, 1 ); 127 layout->addWidget( nameEdit, 1, 1 );
136 128
137 // Type of account 129 // Type of account
138 label = new QLabel( tr( "Type:" ), container ); 130 label = new QLabel( tr( "Type:" ), container );
139 QWhatsThis::add( label, tr( "Select type of checkbook here." ) ); 131 QWhatsThis::add( label, tr( "Select type of checkbook here." ) );
140 layout->addWidget( label, 2, 0 ); 132 layout->addWidget( label, 2, 0 );
141 typeList = new QComboBox( container ); 133 typeList = new QComboBox( container );
142 QWhatsThis::add( typeList, tr( "Select type of checkbook here." ) ); 134 QWhatsThis::add( typeList, tr( "Select type of checkbook here." ) );
143 typeList->insertItem( tr( "Savings" ) ); // 0 135 typeList->insertItem( tr( "Savings" ) ); // 0
144 typeList->insertItem( tr( "Checking" ) ); // 1 136 typeList->insertItem( tr( "Checking" ) ); // 1
145 typeList->insertItem( tr( "CD" ) ); // 2 137 typeList->insertItem( tr( "CD" ) ); // 2
146 typeList->insertItem( tr( "Money market" ) );// 3 138 typeList->insertItem( tr( "Money market" ) );// 3
147 typeList->insertItem( tr( "Mutual fund" ) );// 4 139 typeList->insertItem( tr( "Mutual fund" ) );// 4
148 typeList->insertItem( tr( "Other" ) ); // 5 140 typeList->insertItem( tr( "Other" ) ); // 5
149 layout->addWidget( typeList, 2, 1 ); 141 layout->addWidget( typeList, 2, 1 );
150 142
151 // Bank/institution name 143 // Bank/institution name
152 label = new QLabel( tr( "Bank:" ), container ); 144 label = new QLabel( tr( "Bank:" ), container );
153 QWhatsThis::add( label, tr( "Enter name of the bank for this checkbook here." ) ); 145 QWhatsThis::add( label, tr( "Enter name of the bank for this checkbook here." ) );
154 layout->addWidget( label, 3, 0 ); 146 layout->addWidget( label, 3, 0 );
155 bankEdit = new QLineEdit( container ); 147 bankEdit = new QLineEdit( container );
156 QWhatsThis::add( bankEdit, tr( "Enter name of the bank for this checkbook here." ) ); 148 QWhatsThis::add( bankEdit, tr( "Enter name of the bank for this checkbook here." ) );
157 layout->addWidget( bankEdit, 3, 1 ); 149 layout->addWidget( bankEdit, 3, 1 );
158 150
159 // Account number 151 // Account number
160 label = new QLabel( tr( "Account number:" ), container ); 152 label = new QLabel( tr( "Account number:" ), container );
161 QWhatsThis::add( label, tr( "Enter account number for this checkbook here." ) ); 153 QWhatsThis::add( label, tr( "Enter account number for this checkbook here." ) );
162 layout->addWidget( label, 4, 0 ); 154 layout->addWidget( label, 4, 0 );
163 acctNumEdit = new QLineEdit( container ); 155 acctNumEdit = new QLineEdit( container );
164 QWhatsThis::add( acctNumEdit, tr( "Enter account number for this checkbook here." ) ); 156 QWhatsThis::add( acctNumEdit, tr( "Enter account number for this checkbook here." ) );
165 layout->addWidget( acctNumEdit, 4, 1 ); 157 layout->addWidget( acctNumEdit, 4, 1 );
166 158
@@ -212,504 +204,455 @@ QWidget *Checkbook::initTransactions()
212 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." ) ); 204 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." ) );
213 tranTable->addColumn( tr( "Num" ) ); 205 tranTable->addColumn( tr( "Num" ) );
214 tranTable->addColumn( tr( "Date" ) ); 206 tranTable->addColumn( tr( "Date" ) );
215 //tranTable->addColumn( tr( "Cleared" ) ); 207 //tranTable->addColumn( tr( "Cleared" ) );
216 tranTable->addColumn( tr( "Description" ) ); 208 tranTable->addColumn( tr( "Description" ) );
217 int colnum = tranTable->addColumn( tr( "Amount" ) ); 209 int colnum = tranTable->addColumn( tr( "Amount" ) );
218 tranTable->setColumnAlignment( colnum, Qt::AlignRight ); 210 tranTable->setColumnAlignment( colnum, Qt::AlignRight );
219 tranTable->setAllColumnsShowFocus( TRUE ); 211 tranTable->setAllColumnsShowFocus( TRUE );
220 tranTable->setSorting( 1 ); 212 tranTable->setSorting( 1 );
221 layout->addMultiCellWidget( tranTable, 1, 1, 0, 2 ); 213 layout->addMultiCellWidget( tranTable, 1, 1, 0, 2 );
222 QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold ); 214 QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold );
223 connect( tranTable, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), 215 connect( tranTable, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ),
224 this, SLOT( slotEditTran() ) ); 216 this, SLOT( slotEditTran() ) );
225 217
226 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), control ); 218 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), control );
227 QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) ); 219 QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) );
228 connect( btn, SIGNAL( clicked() ), this, SLOT( slotNewTran() ) ); 220 connect( btn, SIGNAL( clicked() ), this, SLOT( slotNewTran() ) );
229 layout->addWidget( btn, 2, 0 ); 221 layout->addWidget( btn, 2, 0 );
230 222
231 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), control ); 223 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), control );
232 QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) ); 224 QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) );
233 connect( btn, SIGNAL( clicked() ), this, SLOT( slotEditTran() ) ); 225 connect( btn, SIGNAL( clicked() ), this, SLOT( slotEditTran() ) );
234 layout->addWidget( btn, 2, 1 ); 226 layout->addWidget( btn, 2, 1 );
235 227
236 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), control ); 228 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), control );
237 QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) ); 229 QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) );
238 connect( btn, SIGNAL( clicked() ), this, SLOT( slotDeleteTran() ) ); 230 connect( btn, SIGNAL( clicked() ), this, SLOT( slotDeleteTran() ) );
239 layout->addWidget( btn, 2, 2 ); 231 layout->addWidget( btn, 2, 2 );
240 232
241 return( control ); 233 return( control );
242} 234}
243 235
244QWidget *Checkbook::initCharts() 236QWidget *Checkbook::initCharts()
245{ 237{
246 graphInfo = 0x0; 238 graphInfo = 0x0;
247 239
248 QWidget *control = new QWidget( mainWidget ); 240 QWidget *control = new QWidget( mainWidget );
249 241
250 QGridLayout *layout = new QGridLayout( control ); 242 QGridLayout *layout = new QGridLayout( control );
251 layout->setSpacing( 2 ); 243 layout->setSpacing( 2 );
252 layout->setMargin( 4 ); 244 layout->setMargin( 4 );
253 245
254 graphWidget = new Graph( control ); 246 graphWidget = new Graph( control );
255 QWhatsThis::add( graphWidget, tr( "Select the desired chart below and then click on the Draw button." ) ); 247 QWhatsThis::add( graphWidget, tr( "Select the desired chart below and then click on the Draw button." ) );
256 layout->addMultiCellWidget( graphWidget, 0, 0, 0, 2 ); 248 layout->addMultiCellWidget( graphWidget, 0, 0, 0, 2 );
257 249
258 graphList = new QComboBox( control ); 250 graphList = new QComboBox( control );
259 QWhatsThis::add( graphList, tr( "Click here to select the desired chart type." ) ); 251 QWhatsThis::add( graphList, tr( "Click here to select the desired chart type." ) );
260 graphList->insertItem( tr( "Account balance" ) ); 252 graphList->insertItem( tr( "Account balance" ) );
261 graphList->insertItem( tr( "Withdrawals by category" ) ); 253 graphList->insertItem( tr( "Withdrawals by category" ) );
262 graphList->insertItem( tr( "Deposits by category" ) ); 254 graphList->insertItem( tr( "Deposits by category" ) );
263 255
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 {
569 case 0 : drawBalanceChart(); 512 case 0 : drawBalanceChart();
570 break; 513 break;
571 case 1 : drawCategoryChart( TRUE ); 514 case 1 : drawCategoryChart( TRUE );
572 break; 515 break;
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();
604 } 547 }
605 else 548 else
606 { 549 {
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() )
640 { // Found category, add to transaction to category total 583 { // Found category, add to transaction to category total
641 cat->addToValue( tran->amount() ); 584 cat->addToValue( tran->amount() );
642 } 585 }
643 else 586 else
644 { // Didn't find category, add category to list 587 { // Didn't find category, add category to list
645 list->append( new DataPointInfo( tran->category(), tran->amount() ) ); 588 list->append( new DataPointInfo( tran->category(), tran->amount() ) );
646 } 589 }
647 } 590 }
648 } 591 }
649 592
650 graphInfo = new GraphInfo( GraphInfo::PieChart, list ); 593 graphInfo = new GraphInfo( GraphInfo::PieChart, list );
651} 594}
652 595
653CBListItem::CBListItem( QListView *parent, QString label1, QString label2, 596CBListItem::CBListItem( QListView *parent, QString label1, QString label2,
654 QString label3, QString label4, QString label5, QString label6, QString label7, 597 QString label3, QString label4, QString label5, QString label6, QString label7,
655 QString label8 ) 598 QString label8 )
656 : QListViewItem( parent, label1, label2, label3, label4, label5, label6, label7, label8 ) 599 : QListViewItem( parent, label1, label2, label3, label4, label5, label6, label7, label8 )
657{ 600{
658 m_known = FALSE; 601 m_known = FALSE;
659 owner = parent; 602 owner = parent;
660} 603}
661 604
662void CBListItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align ) 605void CBListItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align )
663{ 606{
664 QColorGroup _cg = cg; 607 QColorGroup _cg = cg;
665 const QPixmap *pm = listView()->viewport()->backgroundPixmap(); 608 const QPixmap *pm = listView()->viewport()->backgroundPixmap();
666 if ( pm && !pm->isNull() ) 609 if ( pm && !pm->isNull() )
667 { 610 {
668 _cg.setBrush( QColorGroup::Base, QBrush( cg.base(), *pm ) ); 611 _cg.setBrush( QColorGroup::Base, QBrush( cg.base(), *pm ) );
669 p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); 612 p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() );
670 } 613 }
671 else if ( isAltBackground() ) 614 else if ( isAltBackground() )
672 _cg.setColor(QColorGroup::Base, QColor( 200, 255, 200 ) ); 615 _cg.setColor(QColorGroup::Base, QColor( 200, 255, 200 ) );
673 616
674 QListViewItem::paintCell(p, _cg, column, width, align); 617 QListViewItem::paintCell(p, _cg, column, width, align);
675} 618}
676 619
677bool CBListItem::isAltBackground() 620bool CBListItem::isAltBackground()
678{ 621{
679 QListView *lv = static_cast<QListView *>( listView() ); 622 QListView *lv = static_cast<QListView *>( listView() );
680 if ( lv ) 623 if ( lv )
681 { 624 {
682 CBListItem *above = 0; 625 CBListItem *above = 0;
683 above = (CBListItem *)( itemAbove() ); 626 above = (CBListItem *)( itemAbove() );
684 m_known = above ? above->m_known : true; 627 m_known = above ? above->m_known : true;
685 if ( m_known ) 628 if ( m_known )
686 { 629 {
687 m_odd = above ? !above->m_odd : false; 630 m_odd = above ? !above->m_odd : false;
688 } 631 }
689 else 632 else
690 { 633 {
691 CBListItem *item; 634 CBListItem *item;
692 bool previous = true; 635 bool previous = true;
693 if ( parent() ) 636 if ( parent() )
694 { 637 {
695 item = (CBListItem *)( parent() ); 638 item = (CBListItem *)( parent() );
696 if ( item ) 639 if ( item )
697 previous = item->m_odd; 640 previous = item->m_odd;
698 item = (CBListItem *)( parent()->firstChild() ); 641 item = (CBListItem *)( parent()->firstChild() );
699 } 642 }
700 else 643 else
701 { 644 {
702 item = (CBListItem *)( lv->firstChild() ); 645 item = (CBListItem *)( lv->firstChild() );
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
@@ -1,133 +1,126 @@
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 "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();
103 96
104 private slots: 97 private slots:
105 void slotPasswordClicked(); 98 void slotPasswordClicked();
106 void slotNameChanged( const QString & ); 99 void slotNameChanged( const QString & );
107 void slotStartingBalanceChanged( const QString & ); 100 void slotStartingBalanceChanged( const QString & );
108 void slotNewTran(); 101 void slotNewTran();
109 void slotEditTran(); 102 void slotEditTran();
110 void slotDeleteTran(); 103 void slotDeleteTran();
111 void slotDrawGraph(); 104 void slotDrawGraph();
112}; 105};
113 106
114class CBListItem : public QListViewItem 107class CBListItem : public QListViewItem
115{ 108{
116 //Q_OBJECT 109 //Q_OBJECT
117 110
118 public: 111 public:
119 CBListItem( QListView *, QString = QString::null, QString = QString::null, 112 CBListItem( QListView *, QString = QString::null, QString = QString::null,
120 QString = QString::null, QString = QString::null, QString = QString::null, 113 QString = QString::null, QString = QString::null, QString = QString::null,
121 QString = QString::null, QString = QString::null, QString = QString::null ); 114 QString = QString::null, QString = QString::null, QString = QString::null );
122 115
123 void paintCell( QPainter *, const QColorGroup &, int, int, int ); 116 void paintCell( QPainter *, const QColorGroup &, int, int, int );
124 117
125 private: 118 private:
126 QListView *owner; 119 QListView *owner;
127 bool m_known; 120 bool m_known;
128 bool m_odd; 121 bool m_odd;
129 122
130 bool isAltBackground(); 123 bool isAltBackground();
131}; 124};
132 125
133#endif 126#endif
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,38 +1,42 @@
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 \
29 ../../../i18n/ja/checkbook.ts \ 33 ../../../i18n/ja/checkbook.ts \
30 ../../../i18n/ko/checkbook.ts \ 34 ../../../i18n/ko/checkbook.ts \
31 ../../../i18n/no/checkbook.ts \ 35 ../../../i18n/no/checkbook.ts \
32 ../../../i18n/pl/checkbook.ts \ 36 ../../../i18n/pl/checkbook.ts \
33 ../../../i18n/pt/checkbook.ts \ 37 ../../../i18n/pt/checkbook.ts \
34 ../../../i18n/pt_BR/checkbook.ts \ 38 ../../../i18n/pt_BR/checkbook.ts \
35 ../../../i18n/sl/checkbook.ts \ 39 ../../../i18n/sl/checkbook.ts \
36 ../../../i18n/zh_CN/checkbook.ts \ 40 ../../../i18n/zh_CN/checkbook.ts \
37 ../../../i18n/zh_TW/checkbook.ts \ 41 ../../../i18n/zh_TW/checkbook.ts \
38 ../../../i18n/it/checkbook.ts 42 ../../../i18n/it/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
@@ -26,156 +26,147 @@
26 26
27*/ 27*/
28 28
29#include "graph.h" 29#include "graph.h"
30#include "graphinfo.h" 30#include "graphinfo.h"
31 31
32#include <qcolor.h> 32#include <qcolor.h>
33#include <qfontmetrics.h> 33#include <qfontmetrics.h>
34#include <qpainter.h> 34#include <qpainter.h>
35 35
36#include <math.h> 36#include <math.h>
37 37
38Graph::Graph( QWidget *parent, GraphInfo *d, const QString &name, int flags ) 38Graph::Graph( QWidget *parent, GraphInfo *d, const QString &name, int flags )
39 : QWidget( parent, name, flags ) 39 : QWidget( parent, name, flags )
40{ 40{
41 data = d; 41 data = d;
42 42
43 graph.setOptimization( QPixmap::BestOptim ); 43 graph.setOptimization( QPixmap::BestOptim );
44} 44}
45 45
46void Graph::setGraphInfo( GraphInfo *d ) 46void Graph::setGraphInfo( GraphInfo *d )
47{ 47{
48 data = d; 48 data = d;
49} 49}
50 50
51void Graph::drawGraph( bool regen ) 51void Graph::drawGraph( bool regen )
52{ 52{
53 if ( regen ) 53 if ( regen )
54 { 54 {
55 initGraph(); 55 initGraph();
56 } 56 }
57 QPainter p( this ); 57 QPainter p( this );
58 p.drawPixmap( 0, 0, graph ); 58 p.drawPixmap( 0, 0, graph );
59} 59}
60 60
61void Graph::paintEvent( QPaintEvent * ) 61void Graph::paintEvent( QPaintEvent * )
62{ 62{
63 drawGraph( FALSE ); 63 drawGraph( FALSE );
64} 64}
65 65
66void Graph::resizeEvent( QResizeEvent * ) 66void Graph::resizeEvent( QResizeEvent * )
67{ 67{
68 drawGraph( TRUE ); 68 drawGraph( TRUE );
69} 69}
70 70
71void Graph::initGraph() 71void Graph::initGraph()
72{ 72{
73 graph.resize( width(), height() ); 73 graph.resize( width(), height() );
74 graph.fill( QColor( 255, 255, 255 ) ); 74 graph.fill( QColor( 255, 255, 255 ) );
75 75
76 if ( !data ) 76 if ( !data )
77 { 77 {
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
107 QFont f = font(); 102 QFont f = font();
108 f.setPointSize( 8 ); 103 f.setPointSize( 8 );
109 p.setFont( f ); 104 p.setFont( f );
110 105
111 int x = 0; 106 int x = 0;
112 int i = 0; 107 int i = 0;
113 int n = data->numberDataPoints(); 108 int n = data->numberDataPoints();
114 QFontMetrics fm=fontMetrics(); 109 QFontMetrics fm=fontMetrics();
115 int fh = fm.height(); 110 int fh = fm.height();
116 int fw; 111 int fw;
117 112
118 QColor c( 0, 0, 255); 113 QColor c( 0, 0, 255);
119 p.setBrush( c ); 114 p.setBrush( c );
120 115
121 for (DataPointInfo *dp = data->firstDataPoint(); dp; dp = data->nextDataPoint() ) 116 for (DataPointInfo *dp = data->firstDataPoint(); dp; dp = data->nextDataPoint() )
122 { 117 {
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;
151 142
152 int xd = width - width / 5; 143 int xd = width - width / 5;
153 int yd = height - height / 5; 144 int yd = height - height / 5;
154 145
155 int i = 0; 146 int i = 0;
156 147
157 QColor c; 148 QColor c;
158 149
159 for (DataPointInfo *dp = data->firstDataPoint(); dp; dp = data->nextDataPoint() ) 150 for (DataPointInfo *dp = data->firstDataPoint(); dp; dp = data->nextDataPoint() )
160 { 151 {
161 c.setHsv( ( i *255) / n, 255, 255 ); 152 c.setHsv( ( i *255) / n, 255, 255 );
162 p.setBrush( c ); 153 p.setBrush( c );
163 154
164 int a = int( ( dp->value() * 360.0 ) / sum * 16.0 + 0.5 ); 155 int a = int( ( dp->value() * 360.0 ) / sum * 16.0 + 0.5 );
165 p.drawPie( width/10, height/10, xd, yd, -apos, -a ); 156 p.drawPie( width/10, height/10, xd, yd, -apos, -a );
166 apos += a; 157 apos += a;
167 i++; 158 i++;
168 } 159 }
169 160
170 double apos2 = -90 * 3.14159 / 180; 161 double apos2 = -90 * 3.14159 / 180;
171 for (DataPointInfo *dp = data->firstDataPoint(); dp; dp = data->nextDataPoint() ) 162 for (DataPointInfo *dp = data->firstDataPoint(); dp; dp = data->nextDataPoint() )
172 { 163 {
173 double a = dp->value() *360 / sum * 3.14159 / 180; 164 double a = dp->value() *360 / sum * 3.14159 / 180;
174 int x = int( cos( apos2 + a/2 ) * width * 5/16 + width/2 + 0.5 ); 165 int x = int( cos( apos2 + a/2 ) * width * 5/16 + width/2 + 0.5 );
175 int y = int( sin( apos2 + a/2 ) * height * 5/16 + height/2 + 0.5 ); 166 int y = int( sin( apos2 + a/2 ) * height * 5/16 + height/2 + 0.5 );
176 p.drawText( x - width/8, y - height/8, width/4, height/4, WordBreak | AlignCenter, 167 p.drawText( x - width/8, y - height/8, width/4, height/4, WordBreak | AlignCenter,
177 dp->label() ); 168 dp->label() );
178 apos2 += a; 169 apos2 += a;
179 } 170 }
180} 171}
181 172
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
@@ -1,64 +1,63 @@
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 GRAPH_H 29#ifndef GRAPH_H
30#define GRAPH_H 30#define GRAPH_H
31 31
32#include <qpixmap.h> 32#include <qpixmap.h>
33#include <qwidget.h> 33#include <qwidget.h>
34 34
35class GraphInfo; 35class GraphInfo;
36class QPainter; 36class QPainter;
37 37
38class Graph : public QWidget 38class Graph : public QWidget
39{ 39{
40 Q_OBJECT 40 Q_OBJECT
41 41
42 public: 42 public:
43 Graph( QWidget * = 0x0, GraphInfo * = 0x0, const QString & = 0x0, int = 0 ); 43 Graph( QWidget * = 0x0, GraphInfo * = 0x0, const QString & = 0x0, int = 0 );
44 44
45 void setGraphInfo( GraphInfo * ); 45 void setGraphInfo( GraphInfo * );
46 46
47 void drawGraph( bool = FALSE ); 47 void drawGraph( bool = FALSE );
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
@@ -1,88 +1,88 @@
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 GRAPHINFO_H 29#ifndef GRAPHINFO_H
30#define GRAPHINFO_H 30#define GRAPHINFO_H
31 31
32#include <qlist.h> 32#include <qlist.h>
33#include <qstringlist.h> 33#include <qstringlist.h>
34 34
35class DataPointInfo 35class DataPointInfo
36{ 36{
37 public: 37 public:
38 DataPointInfo() 38 DataPointInfo()
39 : l( 0x0 ), v( 0.0 ) {} 39 : l( 0x0 ), v( 0.0 ) {}
40 DataPointInfo( const QString &label, float value ) 40 DataPointInfo( const QString &label, float value )
41 : l( label ), v( value ) {} 41 : l( label ), v( value ) {}
42 42
43 const QString &label() { return l; } 43 const QString &label() { return l; }
44 float value() { return v; } 44 float value() { return v; }
45 45
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();
71 int numberDataPoints(); 71 int numberDataPoints();
72 72
73 float maxValue(); 73 float maxValue();
74 float totalValue(); 74 float totalValue();
75 75
76 void setGraphTitle( const QString & ); 76 void setGraphTitle( const QString & );
77 void setXAxisTitle( const QString & ); 77 void setXAxisTitle( const QString & );
78 void setYAxisTitle( const QString & ); 78 void setYAxisTitle( const QString & );
79 79
80 private: 80 private:
81 GraphType t; 81 GraphType t;
82 DataPointList *d; 82 DataPointList *d;
83 QString gt; 83 QString gt;
84 QString xt; 84 QString xt;
85 QString yt; 85 QString yt;
86}; 86};
87 87
88#endif 88#endif
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
@@ -1,186 +1,332 @@
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"
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 );
66 a->setWhatsThis( tr( "Click here to create a new checkbook.\n\nYou also can select New from the Checkbook menu." ) ); 78 a->setWhatsThis( tr( "Click here to create a new checkbook.\n\nYou also can select New from the Checkbook menu." ) );
67 connect( a, SIGNAL( activated() ), this, SLOT( slotNew() ) ); 79 connect( a, SIGNAL( activated() ), this, SLOT( slotNew() ) );
68 a->addTo( popup ); 80 a->addTo( popup );
69 a->addTo( bar ); 81 a->addTo( bar );
70 82
71 actionOpen = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, 83 actionOpen = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null,
72 0, this, 0 ); 84 0, this, 0 );
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
@@ -1,60 +1,76 @@
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 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
@@ -1,92 +1,90 @@
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#include <qstring.h> 34#include <qstring.h>
35 35
36class Config; 36class Config;
37 37
38class TranInfo 38class TranInfo
39{ 39{
40 public: 40 public:
41 TranInfo( int = 0, const QString & = 0x0, const QDate & = QDate::currentDate(), 41 TranInfo( int = 0, const QString & = 0x0, const QDate & = QDate::currentDate(),
42 bool = TRUE, const QString & = 0x0, const QString & = 0x0, 42 bool = TRUE, const QString & = 0x0, const QString & = 0x0,
43 float = 0.0, float = 0.0, 43 float = 0.0, float = 0.0,
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