summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/checkbook/cbinfo.cpp2
-rw-r--r--noncore/apps/checkbook/traninfo.cpp24
-rw-r--r--noncore/apps/checkbook/traninfo.h2
3 files changed, 14 insertions, 14 deletions
diff --git a/noncore/apps/checkbook/cbinfo.cpp b/noncore/apps/checkbook/cbinfo.cpp
index 36dde04..6e3afa7 100644
--- a/noncore/apps/checkbook/cbinfo.cpp
+++ b/noncore/apps/checkbook/cbinfo.cpp
@@ -1,228 +1,228 @@
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 "cbinfo.h" 29#include "cbinfo.h"
30#include "traninfo.h" 30#include "traninfo.h"
31 31
32#include <qpe/config.h> 32#include <qpe/config.h>
33 33
34#include <qfile.h> 34#include <qfile.h>
35 35
36// --- CBInfo ----------------------------------------------------------------- 36// --- CBInfo -----------------------------------------------------------------
37CBInfo::CBInfo() 37CBInfo::CBInfo()
38{ 38{
39 n = ""; 39 n = "";
40 fn = ""; 40 fn = "";
41 pw = QString::null; 41 pw = QString::null;
42 t = ""; 42 t = "";
43 bn = ""; 43 bn = "";
44 a = ""; 44 a = "";
45 p = ""; 45 p = "";
46 nt = ""; 46 nt = "";
47 sb = 0.0; 47 sb = 0.0;
48 _sLastTab=""; 48 _sLastTab="";
49 _first=-1; 49 _first=-1;
50 _last=-1; 50 _last=-1;
51 51
52 tl = new TranInfoList(); 52 tl = new TranInfoList();
53} 53}
54 54
55 55
56// --- CBInfo ----------------------------------------------------------------- 56// --- CBInfo -----------------------------------------------------------------
57CBInfo::CBInfo( const QString &name, const QString &filename ) 57CBInfo::CBInfo( const QString &name, const QString &filename )
58{ 58{
59 Config config( filename, Config::File ); 59 Config config( filename, Config::File );
60 config.setGroup( "Account" ); 60 config.setGroup( "Account" );
61 61
62 n = name; 62 n = name;
63 fn = filename; 63 fn = filename;
64 pw = config.readEntryCrypt( "Password", QString::null ); 64 pw = config.readEntryCrypt( "Password", QString::null );
65 65
66 t = config.readEntry( "Type" ); 66 t = config.readEntry( "Type" );
67 bn = config.readEntry( "Bank", "" ); 67 bn = config.readEntry( "Bank", "" );
68 a = config.readEntryCrypt( "Number", "" ); 68 a = config.readEntryCrypt( "Number", "" );
69 p = config.readEntryCrypt( "PINNumber", "" ); 69 p = config.readEntryCrypt( "PINNumber", "" );
70 nt = config.readEntry( "Notes", "" ); 70 nt = config.readEntry( "Notes", "" );
71 _sLastTab = config.readEntry("LastTab", ""); 71 _sLastTab = config.readEntry("LastTab", "");
72 _first=config.readNumEntry("First", -1); 72 _first=config.readNumEntry("First", -1);
73 _sSortOrder = config.readEntry( "SortOrder", QWidget::tr("Date") ); 73 _sSortOrder = config.readEntry( "SortOrder", QWidget::tr("Date") );
74 74
75 bool ok; 75 bool ok;
76 sb = config.readEntry( "Balance", "0.0" ).toFloat( &ok ); 76 sb = config.readEntry( "Balance", "0.0" ).toFloat( &ok );
77 77
78 loadTransactions(); 78 loadTransactions();
79} 79}
80 80
81// --- balance ---------------------------------------------------------------- 81// --- balance ----------------------------------------------------------------
82float CBInfo::balance() 82float CBInfo::balance()
83{ 83{
84 calcBalance(); 84 calcBalance();
85 return b; 85 return b;
86} 86}
87 87
88// --- write ------------------------------------------------------------------ 88// --- write ------------------------------------------------------------------
89void CBInfo::write() 89void CBInfo::write()
90{ 90{
91 QFile f( fn ); 91 QFile f( fn );
92 if ( f.exists() ) 92 if ( f.exists() )
93 f.remove(); 93 f.remove();
94 94
95 Config *config = new Config(fn, Config::File); 95 Config *config = new Config(fn, Config::File);
96 96
97 97
98 // fix transaction numbers 98 // fix transaction numbers
99 _first=-1; 99 _first=-1;
100 TranInfo *prev=NULL; 100 TranInfo *prev=NULL;
101 for ( TranInfo *tran = tl->first(); tran; tran = tl->next() ) { 101 for ( TranInfo *tran = tl->first(); tran; tran = tl->next() ) {
102 if( _first<0 ) _first=tran->id(); 102 if( _first<0 ) _first=tran->id();
103 if( prev ) prev->setNext( tran->id() ); 103 if( prev ) prev->setNext( tran->id() );
104 tran->setNext(-1); 104 tran->setNext(-1);
105 prev=tran; 105 prev=tran;
106 } 106 }
107 107
108 // Save transactions 108 // Save transactions
109 for ( TranInfo *tran = tl->first(); tran; tran = tl->next() ) { 109 for ( TranInfo *tran = tl->first(); tran; tran = tl->next() ) {
110 tran->write(config); 110 tran->write(config);
111 } 111 }
112 112
113 // Save info 113 // Save info
114 if( _first<0 && _last>=0 ) _first=_last; 114 if( _first<0 && _last>=0 ) _first=_last;
115 config->setGroup( "Account" ); 115 config->setGroup( "Account" );
116 config->writeEntryCrypt( "Password", pw ); 116 config->writeEntryCrypt( "Password", pw );
117 config->writeEntry( "Type", t ); 117 config->writeEntry( "Type", t );
118 config->writeEntry( "Bank", bn ); 118 config->writeEntry( "Bank", bn );
119 config->writeEntryCrypt( "Number", a ); 119 config->writeEntryCrypt( "Number", a );
120 config->writeEntryCrypt( "PINNumber", p ); 120 config->writeEntryCrypt( "PINNumber", p );
121 config->writeEntry( "Notes", nt ); 121 config->writeEntry( "Notes", nt );
122 config->writeEntry( "LastTab", _sLastTab ); 122 config->writeEntry( "LastTab", _sLastTab );
123 QString balstr; 123 QString balstr;
124 balstr.setNum( sb, 'f', 2 ); 124 balstr.setNum( sb, 'f', 2 );
125 config->writeEntry( "Balance", balstr ); 125 config->writeEntry( "Balance", balstr );
126 config->writeEntry( "First", _first ); 126 config->writeEntry( "First", _first );
127 config->writeEntry( "SortOrder", _sSortOrder ); 127 config->writeEntry( "SortOrder", _sSortOrder );
128 128
129 config->write(); 129 config->write();
130 delete config; 130 delete config;
131} 131}
132 132
133 133
134// --- findTransaction -------------------------------------------------------- 134// --- findTransaction --------------------------------------------------------
135TranInfo *CBInfo::findTransaction( const QString &sId ) 135TranInfo *CBInfo::findTransaction( const QString &sId )
136{ 136{
137 bool bOk; 137 bool bOk;
138 int id=sId.toInt( &bOk ); 138 int id=sId.toInt( &bOk );
139 if( !bOk ) 139 if( !bOk )
140 return(false); 140 return(false);
141 TranInfo *traninfo; 141 TranInfo *traninfo;
142 for(traninfo=tl->first(); traninfo; traninfo=tl->next()) { 142 for(traninfo=tl->first(); traninfo; traninfo=tl->next()) {
143 if( traninfo->id() == id ) 143 if( traninfo->id() == id )
144 break; 144 break;
145 } 145 }
146 return(traninfo); 146 return(traninfo);
147} 147}
148 148
149void CBInfo::addTransaction( TranInfo *tran ) 149void CBInfo::addTransaction( TranInfo *tran )
150{ 150{
151 tl->append( tran ); 151 tl->append( tran );
152 calcBalance(); 152 calcBalance();
153} 153}
154 154
155void CBInfo::removeTransaction( TranInfo *tran ) 155void CBInfo::removeTransaction( TranInfo *tran )
156{ 156{
157 tl->removeRef( tran ); 157 tl->removeRef( tran );
158 delete tran; 158 delete tran;
159 calcBalance(); 159 calcBalance();
160} 160}
161 161
162 162
163// --- loadTransactions ------------------------------------------------------- 163// --- loadTransactions -------------------------------------------------------
164// Reads the transactions. Either the old way 1-n or as linked list. 164// Reads the transactions. Either the old way 1-n or as linked list.
165void CBInfo::loadTransactions() 165void CBInfo::loadTransactions()
166{ 166{
167 TranInfo *tran; 167 TranInfo *tran;
168 QString trandesc = ""; 168 QString trandesc = "";
169 169
170 tl = new TranInfoList(); 170 tl = new TranInfoList();
171 171
172 Config config( fn, Config::File ); 172 Config config( fn, Config::File );
173 int i=_first; 173 int i=_first;
174 bool bOld=false; 174 bool bOld=false;
175 if( i==-1 ) { 175 if( i==-1 ) {
176 i=1; 176 i=1;
177 bOld=true; 177 bOld=true;
178 } 178 }
179 while( i>=0 ) { 179 while( i>=0 ) {
180 _last=i; 180 _last=i;
181 tran=new TranInfo(config, i); 181 tran=new TranInfo(&config, i);
182 trandesc = tran->desc(); 182 trandesc = tran->desc();
183 if( trandesc==QString::null ) { 183 if( trandesc==QString::null ) {
184 delete tran; 184 delete tran;
185 break; 185 break;
186 } 186 }
187 tl->append(tran); 187 tl->append(tran);
188 i= bOld ? i+1 : tran->getNext(); 188 i= bOld ? i+1 : tran->getNext();
189 } 189 }
190 190
191 calcBalance(); 191 calcBalance();
192} 192}
193 193
194 194
195// --- calcBalance ------------------------------------------------------------ 195// --- calcBalance ------------------------------------------------------------
196void CBInfo::calcBalance() 196void CBInfo::calcBalance()
197{ 197{
198 float amount; 198 float amount;
199 199
200 b = sb; 200 b = sb;
201 201
202 for ( TranInfo *tran = tl->first(); tran; tran = tl->next() ) 202 for ( TranInfo *tran = tl->first(); tran; tran = tl->next() )
203 { 203 {
204 b -= tran->fee(); 204 b -= tran->fee();
205 amount = tran->amount(); 205 amount = tran->amount();
206 if ( tran->withdrawal() ) 206 if ( tran->withdrawal() )
207 { 207 {
208 amount *= -1; 208 amount *= -1;
209 } 209 }
210 b += amount; 210 b += amount;
211 } 211 }
212} 212}
213 213
214 214
215int CBInfoList::compareItems( QCollection::Item item1, QCollection::Item item2 ) 215int CBInfoList::compareItems( QCollection::Item item1, QCollection::Item item2 )
216{ 216{
217 QString n1 = ((CBInfo *)item1)->name(); 217 QString n1 = ((CBInfo *)item1)->name();
218 QString n2 = ((CBInfo *)item2)->name(); 218 QString n2 = ((CBInfo *)item2)->name();
219 int r = -1; 219 int r = -1;
220 220
221 if ( n1 < n2 ) 221 if ( n1 < n2 )
222 r = -1; 222 r = -1;
223 else if ( n1 == n2 ) 223 else if ( n1 == n2 )
224 r = 0; 224 r = 0;
225 else if ( n1 > n2 ) 225 else if ( n1 > n2 )
226 r = 1; 226 r = 1;
227 return( r ); 227 return( r );
228} 228}
diff --git a/noncore/apps/checkbook/traninfo.cpp b/noncore/apps/checkbook/traninfo.cpp
index 4833af9..7bd2004 100644
--- a/noncore/apps/checkbook/traninfo.cpp
+++ b/noncore/apps/checkbook/traninfo.cpp
@@ -1,227 +1,227 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 =. 3 =.
4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> 4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .: 19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include "traninfo.h" 29#include "traninfo.h"
30 30
31#include <qpe/config.h> 31#include <qpe/config.h>
32#include <qpe/timestring.h> 32#include <qpe/timestring.h>
33 33
34QString tempstr; 34QString tempstr;
35 35
36TranInfo::TranInfo( int id, const QString &desc, const QDate &date, bool withdrawal, 36TranInfo::TranInfo( int id, const QString &desc, const QDate &date, bool withdrawal,
37 const QString &type, const QString &category, float amount, 37 const QString &type, const QString &category, float amount,
38 float fee, const QString &number, const QString &notes, int next ) 38 float fee, const QString &number, const QString &notes, int next )
39{ 39{
40 i = id; 40 i = id;
41 d = desc; 41 d = desc;
42 td = date; 42 td = date;
43 w = withdrawal; 43 w = withdrawal;
44 t = type; 44 t = type;
45 c = category; 45 c = category;
46 a = amount; 46 a = amount;
47 f = fee; 47 f = fee;
48 cn = number; 48 cn = number;
49 n = notes; 49 n = notes;
50 _next=next; 50 _next=next;
51} 51}
52 52
53TranInfo::TranInfo( Config config, int entry ) 53TranInfo::TranInfo( Config *config, int entry )
54{ 54{
55 config.setGroup( QString::number( entry ) ); 55 config->setGroup( QString::number( entry ) );
56 QString desc = config.readEntry( "Description", "Not Found" ); 56 QString desc = config->readEntry( "Description", "Not Found" );
57 if ( desc != "Not Found" ) 57 if ( desc != "Not Found" )
58 { 58 {
59 // ID 59 // ID
60 i = entry; 60 i = entry;
61 61
62 // Description 62 // Description
63 d = desc; 63 d = desc;
64 64
65 // Transaction date 65 // Transaction date
66 int yr, mn, dy; 66 int yr, mn, dy;
67 QString datestr = config.readEntry( "Date", "" ); 67 QString datestr = config->readEntry( "Date", "" );
68 int begin, end; 68 int begin, end;
69 begin = datestr.find( '/' ); 69 begin = datestr.find( '/' );
70 mn = datestr.left( begin ).toInt(); 70 mn = datestr.left( begin ).toInt();
71 end = datestr.find( '/', ++begin ); 71 end = datestr.find( '/', ++begin );
72 dy = datestr.mid( begin, end - begin ).toInt(); 72 dy = datestr.mid( begin, end - begin ).toInt();
73 yr = datestr.right( datestr.length() - end - 1).toInt(); 73 yr = datestr.right( datestr.length() - end - 1).toInt();
74 td.setYMD( yr, mn, dy ); 74 td.setYMD( yr, mn, dy );
75 75
76 // Deposit/withdrawal indicator ( withdrawal == TRUE ) 76 // Deposit/withdrawal indicator ( withdrawal == TRUE )
77 w = ( config.readEntry( "Payment", "false" ) == "true" ); 77 w = ( config->readEntry( "Payment", "false" ) == "true" );
78 78
79 // Type 79 // Type
80 QString type = config.readEntry( "Type", "0" ); 80 QString type = config->readEntry( "Type", "0" );
81 if ( w ) 81 if ( w )
82 { // Withdrawal types 82 { // Withdrawal types
83 if( type == "0" ) 83 if( type == "0" )
84 t = "Debit Charge"; 84 t = "Debit Charge";
85 else if( type == "1" ) 85 else if( type == "1" )
86 t = "Written Check"; 86 t = "Written Check";
87 else if( type == "2" ) 87 else if( type == "2" )
88 t = "Transfer"; 88 t = "Transfer";
89 else if( type == "3" ) 89 else if( type == "3" )
90 t = "Credit Card"; 90 t = "Credit Card";
91 } 91 }
92 else 92 else
93 { 93 {
94 if( type == "0" ) 94 if( type == "0" )
95 t = "Written Check"; 95 t = "Written Check";
96 else if( type == "1" ) 96 else if( type == "1" )
97 t = "Automatic Payment"; 97 t = "Automatic Payment";
98 else if( type == "2" ) 98 else if( type == "2" )
99 t = "Transfer"; 99 t = "Transfer";
100 else if( type == "3" ) 100 else if( type == "3" )
101 t = "Cash"; 101 t = "Cash";
102 } 102 }
103 103
104 // Category 104 // Category
105 c = config.readEntry( "Category", "" ); 105 c = config->readEntry( "Category", "" );
106 106
107 // Transaction amount 107 // Transaction amount
108 QString stramount = config.readEntry( "Amount", "0.00" ); 108 QString stramount = config->readEntry( "Amount", "0.00" );
109 bool ok; 109 bool ok;
110 a = stramount.toFloat( &ok ); 110 a = stramount.toFloat( &ok );
111 111
112 // Transaction fee 112 // Transaction fee
113 stramount = config.readEntry( "TransactionFee", "0.00" ); 113 stramount = config->readEntry( "TransactionFee", "0.00" );
114 f = stramount.toFloat( &ok ); 114 f = stramount.toFloat( &ok );
115 115
116 // Transaction number 116 // Transaction number
117 cn = config.readEntry( "CheckNumber", "" ); 117 cn = config->readEntry( "CheckNumber", "" );
118 118
119 // Notes 119 // Notes
120 n = config.readEntry( "Comments", "" ); 120 n = config->readEntry( "Comments", "" );
121 121
122 // next 122 // next
123 _next = config.readNumEntry("Next", -1); 123 _next = config->readNumEntry("Next", -1);
124 } 124 }
125} 125}
126 126
127// --- datestr ---------------------------------------------------------------- 127// --- datestr ----------------------------------------------------------------
128const QString &TranInfo::datestr(bool bDisplayDate) 128const QString &TranInfo::datestr(bool bDisplayDate)
129{ 129{
130 if( bDisplayDate ) { 130 if( bDisplayDate ) {
131 tempstr=TimeString::numberDateString( td ); 131 tempstr=TimeString::numberDateString( td );
132 } else { 132 } else {
133 tempstr.sprintf( "%04d-%02d-%02d", td.year() ,td.month(), td.day() ); 133 tempstr.sprintf( "%04d-%02d-%02d", td.year() ,td.month(), td.day() );
134 } 134 }
135 return(tempstr); 135 return(tempstr);
136} 136}
137 137
138 138
139// --- getIdStr --------------------------------------------------------------- 139// --- getIdStr ---------------------------------------------------------------
140const QString &TranInfo::getIdStr() 140const QString &TranInfo::getIdStr()
141{ 141{
142 tempstr.sprintf("%04d", i); 142 tempstr.sprintf("%04d", i);
143 return( tempstr ); 143 return( tempstr );
144} 144}
145 145
146// --- write ------------------------------------------------------------------ 146// --- write ------------------------------------------------------------------
147void TranInfo::write( Config *config ) 147void TranInfo::write( Config *config )
148{ 148{
149 config->setGroup( QString::number( id() ) ); 149 config->setGroup( QString::number( id() ) );
150 150
151 config->writeEntry( "Description", d ); 151 config->writeEntry( "Description", d );
152 152
153 tempstr = QString::number( td.month() ); 153 tempstr = QString::number( td.month() );
154 tempstr.append( '/' ); 154 tempstr.append( '/' );
155 tempstr.append( QString::number( td.day() ) ); 155 tempstr.append( QString::number( td.day() ) );
156 tempstr.append( '/' ); 156 tempstr.append( '/' );
157 tempstr.append( QString::number( td.year() ) ); 157 tempstr.append( QString::number( td.year() ) );
158 config->writeEntry( "Date", tempstr ); 158 config->writeEntry( "Date", tempstr );
159 159
160 w ? tempstr = "true" 160 w ? tempstr = "true"
161 : tempstr = "false"; 161 : tempstr = "false";
162 config->writeEntry( "Payment", tempstr ); 162 config->writeEntry( "Payment", tempstr );
163 163
164 if ( t == "Debit Charge" || t == "Written Check" ) 164 if ( t == "Debit Charge" || t == "Written Check" )
165 tempstr = "0"; 165 tempstr = "0";
166 else if ( t == "Written Check" || t == "Automatic Payment" ) 166 else if ( t == "Written Check" || t == "Automatic Payment" )
167 tempstr = "1"; 167 tempstr = "1";
168 else if ( t == "Transfer" ) 168 else if ( t == "Transfer" )
169 tempstr = "2"; 169 tempstr = "2";
170 else if ( t == "Credit Card" || t == "Cash" ) 170 else if ( t == "Credit Card" || t == "Cash" )
171 tempstr = "3"; 171 tempstr = "3";
172 config->writeEntry( "Type", tempstr ); 172 config->writeEntry( "Type", tempstr );
173 173
174 config->writeEntry( "Category", c ); 174 config->writeEntry( "Category", c );
175 175
176 tempstr.setNum( a, 'f', 2 ); 176 tempstr.setNum( a, 'f', 2 );
177 config->writeEntry( "Amount", tempstr ); 177 config->writeEntry( "Amount", tempstr );
178 178
179 tempstr.setNum( f, 'f', 2 ); 179 tempstr.setNum( f, 'f', 2 );
180 config->writeEntry( "TransactionFee", tempstr ); 180 config->writeEntry( "TransactionFee", tempstr );
181 181
182 config->writeEntry( "CheckNumber", cn ); 182 config->writeEntry( "CheckNumber", cn );
183 config->writeEntry( "Comments", n ); 183 config->writeEntry( "Comments", n );
184 config->writeEntry( "Next", _next ); 184 config->writeEntry( "Next", _next );
185} 185}
186 186
187 187
188int TranInfoList::compareItems( QCollection::Item item1, QCollection::Item item2 ) 188int TranInfoList::compareItems( QCollection::Item item1, QCollection::Item item2 )
189{ 189{
190 QDate d1 = ((TranInfo *)item1)->date(); 190 QDate d1 = ((TranInfo *)item1)->date();
191 QDate d2 = ((TranInfo *)item2)->date(); 191 QDate d2 = ((TranInfo *)item2)->date();
192 int r = -1; 192 int r = -1;
193 193
194 if ( d1 < d2 ) 194 if ( d1 < d2 )
195 r = -1; 195 r = -1;
196 else if ( d1 == d2 ) 196 else if ( d1 == d2 )
197 r = 0; 197 r = 0;
198 else if ( d1 > d2 ) 198 else if ( d1 > d2 )
199 r = 1; 199 r = 1;
200 return( r ); 200 return( r );
201} 201}
202 202
203// --- toString --------------------------------------------------------------- 203// --- toString ---------------------------------------------------------------
204QString TranInfo::toString() 204QString TranInfo::toString()
205{ 205{
206 QString ret; 206 QString ret;
207 ret.sprintf("(%4d) %10s %4s %-10s %5.2f %5.2f", 207 ret.sprintf("(%4d) %10s %4s %-10s %5.2f %5.2f",
208 id(), 208 id(),
209 (const char *)datestr(), 209 (const char *)datestr(),
210 (const char *)number(), 210 (const char *)number(),
211 (const char *)desc(), 211 (const char *)desc(),
212 (withdrawal() ? -1 : 1) * amount(), 212 (withdrawal() ? -1 : 1) * amount(),
213 fee() 213 fee()
214 ); 214 );
215 return(ret); 215 return(ret);
216} 216}
217 217
218 218
219// --- findMostRecentByDesc --------------------------------------------------- 219// --- findMostRecentByDesc ---------------------------------------------------
220TranInfo *TranInfoList::findMostRecentByDesc( const QString &desc ) 220TranInfo *TranInfoList::findMostRecentByDesc( const QString &desc )
221{ 221{
222 for(TranInfo *cur=last(); cur; cur=prev()) { 222 for(TranInfo *cur=last(); cur; cur=prev()) {
223 if( cur->desc()==desc ) 223 if( cur->desc()==desc )
224 return( cur ); 224 return( cur );
225 } 225 }
226 return(NULL); 226 return(NULL);
227} 227}
diff --git a/noncore/apps/checkbook/traninfo.h b/noncore/apps/checkbook/traninfo.h
index cbe0238..2ecb60d 100644
--- a/noncore/apps/checkbook/traninfo.h
+++ b/noncore/apps/checkbook/traninfo.h
@@ -1,103 +1,103 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 =. 3 =.
4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> 4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .: 19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#ifndef TRANINFO_H 29#ifndef TRANINFO_H
30#define TRANINFO_H 30#define TRANINFO_H
31 31
32#include <qdatetime.h> 32#include <qdatetime.h>
33#include <qlist.h> 33#include <qlist.h>
34 34
35class Config; 35class Config;
36 36
37class TranInfo 37class TranInfo
38{ 38{
39 public: 39 public:
40 TranInfo( int = 0, const QString & = 0x0, const QDate & = QDate::currentDate(), 40 TranInfo( int = 0, const QString & = 0x0, const QDate & = QDate::currentDate(),
41 bool = TRUE, const QString & = 0x0, const QString & = 0x0, 41 bool = TRUE, const QString & = 0x0, const QString & = 0x0,
42 float = 0.0, float = 0.0, 42 float = 0.0, float = 0.0,
43 const QString & = 0x0, const QString & = 0x0, int =-1 ); 43 const QString & = 0x0, const QString & = 0x0, int =-1 );
44 TranInfo( Config, int ); 44 TranInfo( Config *, int );
45 45
46 // getters 46 // getters
47 int id() const { return i; } 47 int id() const { return i; }
48 const QString &getIdStr(); 48 const QString &getIdStr();
49 49
50 const QString &desc() const { return d; } 50 const QString &desc() const { return d; }
51 const QDate &date() const { return td; } 51 const QDate &date() const { return td; }
52 const QString &datestr(bool = false); 52 const QString &datestr(bool = false);
53 bool withdrawal()const { return w; } 53 bool withdrawal()const { return w; }
54 const QString &type() const { return t; } 54 const QString &type() const { return t; }
55 const QString &category()const { return c; } 55 const QString &category()const { return c; }
56 float amount() const { return a; } 56 float amount() const { return a; }
57 float fee() const { return f; } 57 float fee() const { return f; }
58 const QString &number()const { return cn; } 58 const QString &number()const { return cn; }
59 const QString &notes() const { return n; } 59 const QString &notes() const { return n; }
60 int getNext() { return(_next); } 60 int getNext() { return(_next); }
61 61
62 // setters 62 // setters
63 void setDesc( const QString &desc ) { d = desc; } 63 void setDesc( const QString &desc ) { d = desc; }
64 void setDate( const QDate &date ) { td = date; } 64 void setDate( const QDate &date ) { td = date; }
65 void setWithdrawal( bool withdrawal ) { w = withdrawal; } 65 void setWithdrawal( bool withdrawal ) { w = withdrawal; }
66 void setType( const QString &type ) { t = type; } 66 void setType( const QString &type ) { t = type; }
67 void setCategory( const QString &cat ){ c = cat; } 67 void setCategory( const QString &cat ){ c = cat; }
68 void setAmount( float amount ) { a = amount; } 68 void setAmount( float amount ) { a = amount; }
69 void setFee( float fee ) { f = fee; } 69 void setFee( float fee ) { f = fee; }
70 void setNumber( const QString &num ) { cn = num; } 70 void setNumber( const QString &num ) { cn = num; }
71 void setNotes( const QString &notes ) { n = notes; } 71 void setNotes( const QString &notes ) { n = notes; }
72 void setNext(int next) { _next=next; } 72 void setNext(int next) { _next=next; }
73 73
74 // write 74 // write
75 void write( Config * ); 75 void write( Config * );
76 76
77 // toString 77 // toString
78 QString toString(); 78 QString toString();
79 79
80 private: 80 private:
81 int i; 81 int i;
82 QString d; 82 QString d;
83 QDate td; 83 QDate td;
84 bool w; 84 bool w;
85 QString t; 85 QString t;
86 QString c; 86 QString c;
87 float a; 87 float a;
88 float f; 88 float f;
89 QString cn; 89 QString cn;
90 QString n; 90 QString n;
91 int _next; 91 int _next;
92}; 92};
93 93
94class TranInfoList : public QList<TranInfo> 94class TranInfoList : public QList<TranInfo>
95{ 95{
96 public: 96 public:
97 TranInfo *findMostRecentByDesc( const QString &desc ); 97 TranInfo *findMostRecentByDesc( const QString &desc );
98 98
99 protected: 99 protected:
100 int compareItems( QCollection::Item, QCollection::Item ); 100 int compareItems( QCollection::Item, QCollection::Item );
101}; 101};
102 102
103#endif 103#endif