summaryrefslogtreecommitdiff
authordrw <drw>2002-11-02 23:13:41 (UTC)
committer drw <drw>2002-11-02 23:13:41 (UTC)
commite224e28dfa730ce315caa7ae570496c9cd3ffbe2 (patch) (unidiff)
treeed97aca731ee3f92dfb6c7c47a4394da87061b66
parentefb3cb40de57d53de1eb22662261e58333a3a39d (diff)
downloadopie-e224e28dfa730ce315caa7ae570496c9cd3ffbe2.zip
opie-e224e28dfa730ce315caa7ae570496c9cd3ffbe2.tar.gz
opie-e224e28dfa730ce315caa7ae570496c9cd3ffbe2.tar.bz2
Fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/checkbook/checkbook.cpp6
-rw-r--r--noncore/apps/checkbook/traninfo.cpp15
-rw-r--r--noncore/apps/checkbook/traninfo.h8
3 files changed, 25 insertions, 4 deletions
diff --git a/noncore/apps/checkbook/checkbook.cpp b/noncore/apps/checkbook/checkbook.cpp
index 77c1f57..ab25516 100644
--- a/noncore/apps/checkbook/checkbook.cpp
+++ b/noncore/apps/checkbook/checkbook.cpp
@@ -122,475 +122,475 @@ QWidget *Checkbook::initInfo()
122 layout->addWidget( label, 0, 0 ); 122 layout->addWidget( label, 0, 0 );
123 nameEdit = new QLineEdit( container ); 123 nameEdit = new QLineEdit( container );
124 QWhatsThis::add( nameEdit, tr( "Enter name of checkbook here." ) ); 124 QWhatsThis::add( nameEdit, tr( "Enter name of checkbook here." ) );
125 connect( nameEdit, SIGNAL( textChanged( const QString & ) ), 125 connect( nameEdit, SIGNAL( textChanged( const QString & ) ),
126 this, SLOT( slotNameChanged( const QString & ) ) ); 126 this, SLOT( slotNameChanged( const QString & ) ) );
127 layout->addWidget( nameEdit, 0, 1 ); 127 layout->addWidget( nameEdit, 0, 1 );
128 128
129 // Type of account 129 // Type of account
130 label = new QLabel( tr( "Type:" ), container ); 130 label = new QLabel( tr( "Type:" ), container );
131 QWhatsThis::add( label, tr( "Select type of checkbook here." ) ); 131 QWhatsThis::add( label, tr( "Select type of checkbook here." ) );
132 layout->addWidget( label, 1, 0 ); 132 layout->addWidget( label, 1, 0 );
133 typeList = new QComboBox( container ); 133 typeList = new QComboBox( container );
134 QWhatsThis::add( typeList, tr( "Select type of checkbook here." ) ); 134 QWhatsThis::add( typeList, tr( "Select type of checkbook here." ) );
135 typeList->insertItem( tr( "Savings" ) ); // 0 135 typeList->insertItem( tr( "Savings" ) ); // 0
136 typeList->insertItem( tr( "Checking" ) ); // 1 136 typeList->insertItem( tr( "Checking" ) ); // 1
137 typeList->insertItem( tr( "CD" ) ); // 2 137 typeList->insertItem( tr( "CD" ) ); // 2
138 typeList->insertItem( tr( "Money market" ) );// 3 138 typeList->insertItem( tr( "Money market" ) );// 3
139 typeList->insertItem( tr( "Mutual fund" ) );// 4 139 typeList->insertItem( tr( "Mutual fund" ) );// 4
140 typeList->insertItem( tr( "Other" ) ); // 5 140 typeList->insertItem( tr( "Other" ) ); // 5
141 layout->addWidget( typeList, 1, 1 ); 141 layout->addWidget( typeList, 1, 1 );
142 142
143 // Bank/institution name 143 // Bank/institution name
144 label = new QLabel( tr( "Bank:" ), container ); 144 label = new QLabel( tr( "Bank:" ), container );
145 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." ) );
146 layout->addWidget( label, 2, 0 ); 146 layout->addWidget( label, 2, 0 );
147 bankEdit = new QLineEdit( container ); 147 bankEdit = new QLineEdit( container );
148 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." ) );
149 layout->addWidget( bankEdit, 2, 1 ); 149 layout->addWidget( bankEdit, 2, 1 );
150 150
151 // Account number 151 // Account number
152 label = new QLabel( tr( "Account number:" ), container ); 152 label = new QLabel( tr( "Account number:" ), container );
153 QWhatsThis::add( label, tr( "Enter account number for this checkbook here." ) ); 153 QWhatsThis::add( label, tr( "Enter account number for this checkbook here." ) );
154 layout->addWidget( label, 3, 0 ); 154 layout->addWidget( label, 3, 0 );
155 acctNumEdit = new QLineEdit( container ); 155 acctNumEdit = new QLineEdit( container );
156 QWhatsThis::add( acctNumEdit, tr( "Enter account number for this checkbook here." ) ); 156 QWhatsThis::add( acctNumEdit, tr( "Enter account number for this checkbook here." ) );
157 layout->addWidget( acctNumEdit, 3, 1 ); 157 layout->addWidget( acctNumEdit, 3, 1 );
158 158
159 // PIN number 159 // PIN number
160 label = new QLabel( tr( "PIN number:" ), container ); 160 label = new QLabel( tr( "PIN number:" ), container );
161 QWhatsThis::add( label, tr( "Enter PIN number for this checkbook here." ) ); 161 QWhatsThis::add( label, tr( "Enter PIN number for this checkbook here." ) );
162 layout->addWidget( label, 4, 0 ); 162 layout->addWidget( label, 4, 0 );
163 pinNumEdit = new QLineEdit( container ); 163 pinNumEdit = new QLineEdit( container );
164 QWhatsThis::add( pinNumEdit, tr( "Enter PIN number for this checkbook here." ) ); 164 QWhatsThis::add( pinNumEdit, tr( "Enter PIN number for this checkbook here." ) );
165 layout->addWidget( pinNumEdit, 4, 1 ); 165 layout->addWidget( pinNumEdit, 4, 1 );
166 166
167 // Starting balance 167 // Starting balance
168 label = new QLabel( tr( "Starting balance:" ), container ); 168 label = new QLabel( tr( "Starting balance:" ), container );
169 QWhatsThis::add( label, tr( "Enter the initial balance for this checkbook here." ) ); 169 QWhatsThis::add( label, tr( "Enter the initial balance for this checkbook here." ) );
170 layout->addWidget( label, 5, 0 ); 170 layout->addWidget( label, 5, 0 );
171 balanceEdit = new QLineEdit( container ); 171 balanceEdit = new QLineEdit( container );
172 QWhatsThis::add( balanceEdit, tr( "Enter the initial balance for this checkbook here." ) ); 172 QWhatsThis::add( balanceEdit, tr( "Enter the initial balance for this checkbook here." ) );
173 connect( balanceEdit, SIGNAL( textChanged( const QString & ) ), 173 connect( balanceEdit, SIGNAL( textChanged( const QString & ) ),
174 this, SLOT( slotStartingBalanceChanged( const QString & ) ) ); 174 this, SLOT( slotStartingBalanceChanged( const QString & ) ) );
175 layout->addWidget( balanceEdit, 5, 1 ); 175 layout->addWidget( balanceEdit, 5, 1 );
176 176
177 // Notes 177 // Notes
178 label = new QLabel( tr( "Notes:" ), container ); 178 label = new QLabel( tr( "Notes:" ), container );
179 QWhatsThis::add( label, tr( "Enter any additional information for this checkbook here." ) ); 179 QWhatsThis::add( label, tr( "Enter any additional information for this checkbook here." ) );
180 layout->addWidget( label, 6, 0 ); 180 layout->addWidget( label, 6, 0 );
181 notesEdit = new QMultiLineEdit( container ); 181 notesEdit = new QMultiLineEdit( container );
182 QWhatsThis::add( notesEdit, tr( "Enter any additional information for this checkbook here." ) ); 182 QWhatsThis::add( notesEdit, tr( "Enter any additional information for this checkbook here." ) );
183 notesEdit->setMaximumHeight( 85 ); 183 notesEdit->setMaximumHeight( 85 );
184 layout->addMultiCellWidget( notesEdit, 7, 7, 0, 1 ); 184 layout->addMultiCellWidget( notesEdit, 7, 7, 0, 1 );
185 185
186 return control; 186 return control;
187} 187}
188 188
189QWidget *Checkbook::initTransactions() 189QWidget *Checkbook::initTransactions()
190{ 190{
191 QWidget *control = new QWidget( mainWidget ); 191 QWidget *control = new QWidget( mainWidget );
192 192
193 QGridLayout *layout = new QGridLayout( control ); 193 QGridLayout *layout = new QGridLayout( control );
194 layout->setSpacing( 2 ); 194 layout->setSpacing( 2 );
195 layout->setMargin( 4 ); 195 layout->setMargin( 4 );
196 196
197 balanceLabel = new QLabel( tr( "Current balance: %10.00" ).arg( currencySymbol ), 197 balanceLabel = new QLabel( tr( "Current balance: %10.00" ).arg( currencySymbol ),
198 control ); 198 control );
199 QWhatsThis::add( balanceLabel, tr( "This area shows the current balance in this checkbook." ) ); 199 QWhatsThis::add( balanceLabel, tr( "This area shows the current balance in this checkbook." ) );
200 layout->addMultiCellWidget( balanceLabel, 0, 0, 0, 2 ); 200 layout->addMultiCellWidget( balanceLabel, 0, 0, 0, 2 );
201 201
202 tranTable = new QListView( control ); 202 tranTable = new QListView( control );
203 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." ) ); 203 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 tranTable->addColumn( tr( "ID" ) ); 204 tranTable->addColumn( tr( "ID" ) );
205 tranTable->addColumn( tr( "Date" ) ); 205 tranTable->addColumn( tr( "Date" ) );
206 tranTable->addColumn( tr( "Description" ) ); 206 tranTable->addColumn( tr( "Description" ) );
207 int colnum = tranTable->addColumn( tr( "Amount" ) ); 207 int colnum = tranTable->addColumn( tr( "Amount" ) );
208 tranTable->setColumnAlignment( colnum, Qt::AlignRight ); 208 tranTable->setColumnAlignment( colnum, Qt::AlignRight );
209 tranTable->setAllColumnsShowFocus( TRUE ); 209 tranTable->setAllColumnsShowFocus( TRUE );
210 layout->addMultiCellWidget( tranTable, 1, 1, 0, 2 ); 210 layout->addMultiCellWidget( tranTable, 1, 1, 0, 2 );
211 QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold ); 211 QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold );
212 connect( tranTable, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), 212 connect( tranTable, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ),
213 this, SLOT( slotEditTran() ) ); 213 this, SLOT( slotEditTran() ) );
214 214
215 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), control ); 215 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), control );
216 QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) ); 216 QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) );
217 connect( btn, SIGNAL( clicked() ), this, SLOT( slotNewTran() ) ); 217 connect( btn, SIGNAL( clicked() ), this, SLOT( slotNewTran() ) );
218 layout->addWidget( btn, 2, 0 ); 218 layout->addWidget( btn, 2, 0 );
219 219
220 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), control ); 220 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), control );
221 QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) ); 221 QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) );
222 connect( btn, SIGNAL( clicked() ), this, SLOT( slotEditTran() ) ); 222 connect( btn, SIGNAL( clicked() ), this, SLOT( slotEditTran() ) );
223 layout->addWidget( btn, 2, 1 ); 223 layout->addWidget( btn, 2, 1 );
224 224
225 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), control ); 225 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), control );
226 QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) ); 226 QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) );
227 connect( btn, SIGNAL( clicked() ), this, SLOT( slotDeleteTran() ) ); 227 connect( btn, SIGNAL( clicked() ), this, SLOT( slotDeleteTran() ) );
228 layout->addWidget( btn, 2, 2 ); 228 layout->addWidget( btn, 2, 2 );
229 229
230 return( control ); 230 return( control );
231} 231}
232 232
233QWidget *Checkbook::initCharts() 233QWidget *Checkbook::initCharts()
234{ 234{
235 graphInfo = 0x0; 235 graphInfo = 0x0;
236 236
237 QWidget *control = new QWidget( mainWidget ); 237 QWidget *control = new QWidget( mainWidget );
238 238
239 QGridLayout *layout = new QGridLayout( control ); 239 QGridLayout *layout = new QGridLayout( control );
240 layout->setSpacing( 2 ); 240 layout->setSpacing( 2 );
241 layout->setMargin( 4 ); 241 layout->setMargin( 4 );
242 242
243 graphWidget = new Graph( control ); 243 graphWidget = new Graph( control );
244 QWhatsThis::add( graphWidget, tr( "Select the desired chart below and then click on the Draw button." ) ); 244 QWhatsThis::add( graphWidget, tr( "Select the desired chart below and then click on the Draw button." ) );
245 layout->addMultiCellWidget( graphWidget, 0, 0, 0, 2 ); 245 layout->addMultiCellWidget( graphWidget, 0, 0, 0, 2 );
246 246
247 graphList = new QComboBox( control ); 247 graphList = new QComboBox( control );
248 QWhatsThis::add( graphList, tr( "Click here to select the desired chart type." ) ); 248 QWhatsThis::add( graphList, tr( "Click here to select the desired chart type." ) );
249 graphList->insertItem( tr( "Account balance" ) ); 249 graphList->insertItem( tr( "Account balance" ) );
250 graphList->insertItem( tr( "Withdrawals by category" ) ); 250 graphList->insertItem( tr( "Withdrawals by category" ) );
251 graphList->insertItem( tr( "Deposits by category" ) ); 251 graphList->insertItem( tr( "Deposits by category" ) );
252 252
253 layout->addMultiCellWidget( graphList, 1, 1, 0, 1 ); 253 layout->addMultiCellWidget( graphList, 1, 1, 0, 1 );
254 254
255 QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/drawbtn" ), tr( "Draw" ), control ); 255 QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/drawbtn" ), tr( "Draw" ), control );
256 QWhatsThis::add( btn, tr( "Click here to draw the selected chart." ) ); 256 QWhatsThis::add( btn, tr( "Click here to draw the selected chart." ) );
257 connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) ); 257 connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) );
258 layout->addWidget( btn, 1, 2 ); 258 layout->addWidget( btn, 1, 2 );
259 259
260 return control; 260 return control;
261} 261}
262 262
263void Checkbook::loadCheckbook() 263void Checkbook::loadCheckbook()
264{ 264{
265 transactions.clear(); 265 transactions.clear();
266 266
267 Config config(filename, Config::File); 267 Config config(filename, Config::File);
268 268
269 // Load info 269 // Load info
270 config.setGroup( "Account" ); 270 config.setGroup( "Account" );
271 nameEdit->setText( name ); 271 nameEdit->setText( name );
272 QString temptext = config.readEntry( "Type" ); 272 QString temptext = config.readEntry( "Type" );
273 int i = typeList->count(); 273 int i = typeList->count();
274 while ( i > 0 ) 274 while ( i > 0 )
275 { 275 {
276 i--; 276 i--;
277 typeList->setCurrentItem( i ); 277 typeList->setCurrentItem( i );
278 if ( typeList->currentText() == temptext ) 278 if ( typeList->currentText() == temptext )
279 { 279 {
280 break; 280 break;
281 } 281 }
282 } 282 }
283 bankEdit->setText( config.readEntry( "Bank", "" ) ); 283 bankEdit->setText( config.readEntry( "Bank", "" ) );
284 acctNumEdit->setText( config.readEntryCrypt( "Number", "" ) ); 284 acctNumEdit->setText( config.readEntryCrypt( "Number", "" ) );
285 pinNumEdit->setText( config.readEntryCrypt( "PINNumber", "" ) ); 285 pinNumEdit->setText( config.readEntryCrypt( "PINNumber", "" ) );
286 balanceEdit->setText( config.readEntry( "Balance", "0.0" ) ); 286 balanceEdit->setText( config.readEntry( "Balance", "0.0" ) );
287 notesEdit->setText( config.readEntry( "Notes", "" ) ); 287 notesEdit->setText( config.readEntry( "Notes", "" ) );
288 288
289 bool ok; 289 bool ok;
290 currBalance = balanceEdit->text().toFloat( &ok ); 290 currBalance = balanceEdit->text().toFloat( &ok );
291 startBalance = currBalance; 291 startBalance = currBalance;
292 292
293 // Load transactions 293 // Load transactions
294 TranInfo *tran; 294 TranInfo *tran;
295 QString trandesc = ""; 295 QString trandesc = "";
296 float amount; 296 float amount;
297 QString stramount; 297 QString stramount;
298 for ( int i = 1; trandesc != QString::null; i++ ) 298 for ( int i = 1; trandesc != QString::null; i++ )
299 { 299 {
300 tran = new TranInfo( config, i ); 300 tran = new TranInfo( config, i );
301 trandesc = tran->desc(); 301 trandesc = tran->desc();
302 if ( trandesc != QString::null ) 302 if ( trandesc != QString::null )
303 { 303 {
304 currBalance -= tran->fee(); 304 currBalance -= tran->fee();
305 amount = tran->amount(); 305 amount = tran->amount();
306 if ( tran->withdrawal() ) 306 if ( tran->withdrawal() )
307 { 307 {
308 amount *= -1; 308 amount *= -1;
309 } 309 }
310 currBalance += amount; 310 currBalance += amount;
311 stramount.sprintf( "%c%.2f", currencySymbol, amount ); 311 stramount.sprintf( "%c%.2f", currencySymbol, amount );
312 312
313 // Add to transaction list 313 // Add to transaction list
314 transactions.append( tran ); 314 transactions.inSort( tran );
315 315
316 // Add to transaction table 316 // Add to transaction table
317 ( void ) new QListViewItem( tranTable, QString::number( i ), tran->datestr(), 317 ( void ) new QListViewItem( tranTable, QString::number( i ), tran->datestr(),
318 trandesc, stramount ); 318 trandesc, stramount );
319 } 319 }
320 else 320 else
321 { 321 {
322 delete tran; 322 delete tran;
323 } 323 }
324 } 324 }
325 balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) ); 325 balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) );
326 326
327 highTranNum = transactions.count(); 327 highTranNum = transactions.count();
328} 328}
329 329
330void Checkbook::adjustBalance( float amount ) 330void Checkbook::adjustBalance( float amount )
331{ 331{
332 currBalance += amount; 332 currBalance += amount;
333 balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) ); 333 balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) );
334 334
335} 335}
336 336
337TranInfo *Checkbook::findTranByID( int id ) 337TranInfo *Checkbook::findTranByID( int id )
338{ 338{
339 TranInfo *traninfo = transactions.first(); 339 TranInfo *traninfo = transactions.first();
340 while ( traninfo && traninfo->id() != id ) 340 while ( traninfo && traninfo->id() != id )
341 { 341 {
342 traninfo = transactions.next(); 342 traninfo = transactions.next();
343 } 343 }
344 return( traninfo ); 344 return( traninfo );
345} 345}
346 346
347void Checkbook::accept() 347void Checkbook::accept()
348{ 348{
349 QFile f( filename ); 349 QFile f( filename );
350 if ( f.exists() ) 350 if ( f.exists() )
351 { 351 {
352 f.remove(); 352 f.remove();
353 } 353 }
354 354
355 Config *config = new Config(filename, Config::File); 355 Config *config = new Config(filename, Config::File);
356 356
357 // Save info 357 // Save info
358 config->setGroup( "Account" ); 358 config->setGroup( "Account" );
359 config->writeEntry( "Type", typeList->currentText() ); 359 config->writeEntry( "Type", typeList->currentText() );
360 config->writeEntry( "Bank", bankEdit->text() ); 360 config->writeEntry( "Bank", bankEdit->text() );
361 config->writeEntryCrypt( "Number", acctNumEdit->text() ); 361 config->writeEntryCrypt( "Number", acctNumEdit->text() );
362 config->writeEntryCrypt( "PINNumber", pinNumEdit->text() ); 362 config->writeEntryCrypt( "PINNumber", pinNumEdit->text() );
363 config->writeEntry( "Balance", balanceEdit->text() ); 363 config->writeEntry( "Balance", balanceEdit->text() );
364 config->writeEntry( "Notes", notesEdit->text() ); 364 config->writeEntry( "Notes", notesEdit->text() );
365 365
366 // Save transactions 366 // Save transactions
367 int i = 1; 367 int i = 1;
368 for ( TranInfo *tran = transactions.first(); tran; tran = transactions.next() ) 368 for ( TranInfo *tran = transactions.first(); tran; tran = transactions.next() )
369 { 369 {
370 tran->write( config, i ); 370 tran->write( config, i );
371 i++; 371 i++;
372 } 372 }
373 config->write(); 373 config->write();
374 374
375 QDialog::accept(); 375 QDialog::accept();
376} 376}
377 377
378void Checkbook::slotNameChanged( const QString &newname ) 378void Checkbook::slotNameChanged( const QString &newname )
379{ 379{
380 name = newname; 380 name = newname;
381 filename = filedir; 381 filename = filedir;
382 filename.append( newname ); 382 filename.append( newname );
383 filename.append( ".qcb" ); 383 filename.append( ".qcb" );
384 QString tempstr = name; 384 QString tempstr = name;
385 tempstr.append( " - " ); 385 tempstr.append( " - " );
386 tempstr.append( tr( "Checkbook" ) ); 386 tempstr.append( tr( "Checkbook" ) );
387 setCaption( tempstr ); 387 setCaption( tempstr );
388} 388}
389 389
390void Checkbook::slotStartingBalanceChanged( const QString &newbalance ) 390void Checkbook::slotStartingBalanceChanged( const QString &newbalance )
391{ 391{
392 currBalance -= startBalance; 392 currBalance -= startBalance;
393 bool ok; 393 bool ok;
394 startBalance = newbalance.toFloat( &ok ); 394 startBalance = newbalance.toFloat( &ok );
395 adjustBalance( startBalance ); 395 adjustBalance( startBalance );
396} 396}
397 397
398void Checkbook::slotNewTran() 398void Checkbook::slotNewTran()
399{ 399{
400 highTranNum++; 400 highTranNum++;
401 TranInfo *traninfo = new TranInfo( highTranNum ); 401 TranInfo *traninfo = new TranInfo( highTranNum );
402 402
403 Transaction *currtran = new Transaction( this, name, 403 Transaction *currtran = new Transaction( this, name,
404 traninfo, 404 traninfo,
405 currencySymbol ); 405 currencySymbol );
406 currtran->showMaximized(); 406 currtran->showMaximized();
407 if ( currtran->exec() == QDialog::Accepted ) 407 if ( currtran->exec() == QDialog::Accepted )
408 { 408 {
409 float amount = traninfo->amount(); 409 float amount = traninfo->amount();
410 if ( traninfo->withdrawal() ) 410 if ( traninfo->withdrawal() )
411 { 411 {
412 amount *= -1; 412 amount *= -1;
413 } 413 }
414 QString stramount; 414 QString stramount;
415 stramount.sprintf( "%c%.2f", currencySymbol, amount ); 415 stramount.sprintf( "%c%.2f", currencySymbol, amount );
416 416
417 // Add to transaction list 417 // Add to transaction list
418 transactions.append( traninfo ); 418 transactions.inSort( traninfo );
419 419
420 // Add to transaction table 420 // Add to transaction table
421 ( void ) new QListViewItem( tranTable, QString::number( highTranNum ), 421 ( void ) new QListViewItem( tranTable, QString::number( highTranNum ),
422 traninfo->datestr(), traninfo->desc(), stramount ); 422 traninfo->datestr(), traninfo->desc(), stramount );
423 423
424 adjustBalance( amount ); 424 adjustBalance( amount );
425 } 425 }
426 else 426 else
427 { 427 {
428 highTranNum--; 428 highTranNum--;
429 delete traninfo; 429 delete traninfo;
430 } 430 }
431} 431}
432 432
433void Checkbook::slotEditTran() 433void Checkbook::slotEditTran()
434{ 434{
435 bool ok; 435 bool ok;
436 QListViewItem *curritem = tranTable->currentItem(); 436 QListViewItem *curritem = tranTable->currentItem();
437 if ( !curritem ) 437 if ( !curritem )
438 { 438 {
439 return; 439 return;
440 } 440 }
441 441
442 int tranid = curritem->text( 0 ).toInt( &ok ); 442 int tranid = curritem->text( 0 ).toInt( &ok );
443 TranInfo *traninfo = findTranByID( tranid ); 443 TranInfo *traninfo = findTranByID( tranid );
444 float origamt = traninfo->amount(); 444 float origamt = traninfo->amount();
445 if ( traninfo->withdrawal() ) 445 if ( traninfo->withdrawal() )
446 { 446 {
447 origamt *= -1; 447 origamt *= -1;
448 } 448 }
449 449
450 Transaction *currtran = new Transaction( this, name, 450 Transaction *currtran = new Transaction( this, name,
451 traninfo, 451 traninfo,
452 currencySymbol ); 452 currencySymbol );
453 currtran->showMaximized(); 453 currtran->showMaximized();
454 if ( currtran->exec() == QDialog::Accepted ) 454 if ( currtran->exec() == QDialog::Accepted )
455 { 455 {
456 curritem->setText( 1, traninfo->datestr() ); 456 curritem->setText( 1, traninfo->datestr() );
457 457
458 curritem->setText( 2, traninfo->desc() ); 458 curritem->setText( 2, traninfo->desc() );
459 459
460 float amount = traninfo->amount(); 460 float amount = traninfo->amount();
461 if ( traninfo->withdrawal() ) 461 if ( traninfo->withdrawal() )
462 { 462 {
463 amount *= -1; 463 amount *= -1;
464 } 464 }
465 adjustBalance( origamt * -1 ); 465 adjustBalance( origamt * -1 );
466 adjustBalance( amount ); 466 adjustBalance( amount );
467 QString stramount; 467 QString stramount;
468 stramount.sprintf( "%c%.2f", currencySymbol, amount ); 468 stramount.sprintf( "%c%.2f", currencySymbol, amount );
469 curritem->setText( 3, stramount ); 469 curritem->setText( 3, stramount );
470 470
471 balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) ); 471 balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) );
472 472
473 delete currtran; 473 delete currtran;
474 } 474 }
475} 475}
476 476
477void Checkbook::slotDeleteTran() 477void Checkbook::slotDeleteTran()
478{ 478{
479 QListViewItem *curritem = tranTable->currentItem(); 479 QListViewItem *curritem = tranTable->currentItem();
480 if ( !curritem ) 480 if ( !curritem )
481 { 481 {
482 return; 482 return;
483 } 483 }
484 484
485 bool ok; 485 bool ok;
486 int tranid = curritem->text( 0 ).toInt( &ok ); 486 int tranid = curritem->text( 0 ).toInt( &ok );
487 TranInfo *traninfo = findTranByID( tranid ); 487 TranInfo *traninfo = findTranByID( tranid );
488 488
489 if ( QPEMessageBox::confirmDelete ( this, tr( "Delete transaction" ), traninfo->desc() ) ) 489 if ( QPEMessageBox::confirmDelete ( this, tr( "Delete transaction" ), traninfo->desc() ) )
490 { 490 {
491 float amount = traninfo->amount(); 491 float amount = traninfo->amount();
492 if ( traninfo->withdrawal() ) 492 if ( traninfo->withdrawal() )
493 { 493 {
494 amount *= -1; 494 amount *= -1;
495 } 495 }
496 496
497 transactions.remove( traninfo ); 497 transactions.remove( traninfo );
498 delete traninfo; 498 delete traninfo;
499 delete curritem; 499 delete curritem;
500 500
501 adjustBalance( amount * -1 ); 501 adjustBalance( amount * -1 );
502 } 502 }
503} 503}
504 504
505void Checkbook::slotDrawGraph() 505void Checkbook::slotDrawGraph()
506{ 506{
507 if ( graphInfo ) 507 if ( graphInfo )
508 { 508 {
509 delete graphInfo; 509 delete graphInfo;
510 } 510 }
511 511
512 switch ( graphList->currentItem() ) 512 switch ( graphList->currentItem() )
513 { 513 {
514 case 0 : drawBalanceChart(); 514 case 0 : drawBalanceChart();
515 break; 515 break;
516 case 1 : drawCategoryChart( TRUE ); 516 case 1 : drawCategoryChart( TRUE );
517 break; 517 break;
518 case 2 : drawCategoryChart( FALSE ); 518 case 2 : drawCategoryChart( FALSE );
519 break; 519 break;
520 }; 520 };
521 521
522 graphWidget->setGraphInfo( graphInfo ); 522 graphWidget->setGraphInfo( graphInfo );
523 graphWidget->drawGraph( TRUE ); 523 graphWidget->drawGraph( TRUE );
524} 524}
525 525
526void Checkbook::drawBalanceChart() 526void Checkbook::drawBalanceChart()
527{ 527{
528 DataPointList *list = new DataPointList(); 528 DataPointList *list = new DataPointList();
529 529
530 float balance = startBalance; 530 float balance = startBalance;
531 float amount; 531 float amount;
532 QString label; 532 QString label;
533 int i = 0; 533 int i = 0;
534 int count = transactions.count(); 534 int count = transactions.count();
535 535
536 for ( TranInfo *tran = transactions.first(); tran; tran = transactions.next() ) 536 for ( TranInfo *tran = transactions.first(); tran; tran = transactions.next() )
537 { 537 {
538 i++; 538 i++;
539 balance -= tran->fee(); 539 balance -= tran->fee();
540 amount = tran->amount(); 540 amount = tran->amount();
541 if ( tran->withdrawal() ) 541 if ( tran->withdrawal() )
542 { 542 {
543 amount *= -1; 543 amount *= -1;
544 } 544 }
545 balance += amount; 545 balance += amount;
546 if ( i == 1 || i == count / 2 || i == count ) 546 if ( i == 1 || i == count / 2 || i == count )
547 { 547 {
548 label = tran->datestr(); 548 label = tran->datestr();
549 } 549 }
550 else 550 else
551 { 551 {
552 label = ""; 552 label = "";
553 } 553 }
554 list->append( new DataPointInfo( label, balance ) ); 554 list->append( new DataPointInfo( label, balance ) );
555 } 555 }
556 556
557 graphInfo = new GraphInfo( GraphInfo::BarChart, list ); 557 graphInfo = new GraphInfo( GraphInfo::BarChart, list );
558} 558}
559 559
560void Checkbook::drawCategoryChart( bool withdrawals ) 560void Checkbook::drawCategoryChart( bool withdrawals )
561{ 561{
562 DataPointList *list = new DataPointList(); 562 DataPointList *list = new DataPointList();
563 563
564 TranInfo *tran = transactions.first(); 564 TranInfo *tran = transactions.first();
565 if ( tran->withdrawal() == withdrawals ) 565 if ( tran && tran->withdrawal() == withdrawals )
566 { 566 {
567 list->append( new DataPointInfo( tran->category(), tran->amount() ) ); 567 list->append( new DataPointInfo( tran->category(), tran->amount() ) );
568 } 568 }
569 tran = transactions.next(); 569 tran = transactions.next();
570 570
571 DataPointInfo *cat; 571 DataPointInfo *cat;
572 for ( ; tran; tran = transactions.next() ) 572 for ( ; tran; tran = transactions.next() )
573 { 573 {
574 if ( tran->withdrawal() == withdrawals ) 574 if ( tran->withdrawal() == withdrawals )
575 { 575 {
576 // Find category in list 576 // Find category in list
577 for ( cat = list->first(); cat; cat = list->next() ) 577 for ( cat = list->first(); cat; cat = list->next() )
578 { 578 {
579 if ( cat->label() == tran->category() ) 579 if ( cat->label() == tran->category() )
580 { 580 {
581 break; 581 break;
582 } 582 }
583 } 583 }
584 if ( cat && cat->label() == tran->category() ) 584 if ( cat && cat->label() == tran->category() )
585 { // Found category, add to transaction to category total 585 { // Found category, add to transaction to category total
586 cat->addToValue( tran->amount() ); 586 cat->addToValue( tran->amount() );
587 } 587 }
588 else 588 else
589 { // Didn't find category, add category to list 589 { // Didn't find category, add category to list
590 list->append( new DataPointInfo( tran->category(), tran->amount() ) ); 590 list->append( new DataPointInfo( tran->category(), tran->amount() ) );
591 } 591 }
592 } 592 }
593 } 593 }
594 594
595 graphInfo = new GraphInfo( GraphInfo::PieChart, list ); 595 graphInfo = new GraphInfo( GraphInfo::PieChart, list );
596} 596}
diff --git a/noncore/apps/checkbook/traninfo.cpp b/noncore/apps/checkbook/traninfo.cpp
index 460466c..dcba869 100644
--- a/noncore/apps/checkbook/traninfo.cpp
+++ b/noncore/apps/checkbook/traninfo.cpp
@@ -1,175 +1,190 @@
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 <williamsdr@acm.org> 4             .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.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 32
33QString tempstr; 33QString tempstr;
34 34
35TranInfo::TranInfo( int id, const QString &desc, const QDate &date, bool withdrawal, 35TranInfo::TranInfo( int id, const QString &desc, const QDate &date, bool withdrawal,
36 const QString &type, const QString &category, float amount, 36 const QString &type, const QString &category, float amount,
37 float fee, const QString &number, const QString &notes ) 37 float fee, const QString &number, const QString &notes )
38{ 38{
39 i = id; 39 i = id;
40 d = desc; 40 d = desc;
41 td = date; 41 td = date;
42 w = withdrawal; 42 w = withdrawal;
43 t = type; 43 t = type;
44 c = category; 44 c = category;
45 a = amount; 45 a = amount;
46 f = fee; 46 f = fee;
47 cn = number; 47 cn = number;
48 n = notes; 48 n = notes;
49} 49}
50 50
51TranInfo::TranInfo( Config config, int entry ) 51TranInfo::TranInfo( Config config, int entry )
52{ 52{
53 config.setGroup( QString::number( entry ) ); 53 config.setGroup( QString::number( entry ) );
54 QString desc = config.readEntry( "Description", "Not Found" ); 54 QString desc = config.readEntry( "Description", "Not Found" );
55 if ( desc != "Not Found" ) 55 if ( desc != "Not Found" )
56 { 56 {
57 // ID 57 // ID
58 i = entry; 58 i = entry;
59 59
60 // Description 60 // Description
61 d = desc; 61 d = desc;
62 62
63 // Transaction date 63 // Transaction date
64 int yr, mn, dy; 64 int yr, mn, dy;
65 QString datestr = config.readEntry( "Date", "" ); 65 QString datestr = config.readEntry( "Date", "" );
66 int begin, end; 66 int begin, end;
67 begin = datestr.find( '/' ); 67 begin = datestr.find( '/' );
68 mn = datestr.left( begin ).toInt(); 68 mn = datestr.left( begin ).toInt();
69 end = datestr.find( '/', ++begin ); 69 end = datestr.find( '/', ++begin );
70 dy = datestr.mid( begin, end - begin ).toInt(); 70 dy = datestr.mid( begin, end - begin ).toInt();
71 yr = datestr.right( datestr.length() - end - 1).toInt(); 71 yr = datestr.right( datestr.length() - end - 1).toInt();
72 td.setYMD( yr, mn, dy ); 72 td.setYMD( yr, mn, dy );
73 73
74 // Deposit/withdrawal indicator ( withdrawal == TRUE ) 74 // Deposit/withdrawal indicator ( withdrawal == TRUE )
75 w = ( config.readEntry( "Payment", "false" ) == "true" ); 75 w = ( config.readEntry( "Payment", "false" ) == "true" );
76 76
77 // Type 77 // Type
78 QString type = config.readEntry( "Type", "0" ); 78 QString type = config.readEntry( "Type", "0" );
79 if ( w ) 79 if ( w )
80 { // Withdrawal types 80 { // Withdrawal types
81 if( type == "0" ) 81 if( type == "0" )
82 t = "Debit Charge"; 82 t = "Debit Charge";
83 else if( type == "1" ) 83 else if( type == "1" )
84 t = "Written Check"; 84 t = "Written Check";
85 else if( type == "2" ) 85 else if( type == "2" )
86 t = "Transfer"; 86 t = "Transfer";
87 else if( type == "3" ) 87 else if( type == "3" )
88 t = "Credit Card"; 88 t = "Credit Card";
89 } 89 }
90 else 90 else
91 { 91 {
92 if( type == "0" ) 92 if( type == "0" )
93 t = "Written Check"; 93 t = "Written Check";
94 else if( type == "1" ) 94 else if( type == "1" )
95 t = "Automatic Payment"; 95 t = "Automatic Payment";
96 else if( type == "2" ) 96 else if( type == "2" )
97 t = "Transfer"; 97 t = "Transfer";
98 else if( type == "3" ) 98 else if( type == "3" )
99 t = "Cash"; 99 t = "Cash";
100 } 100 }
101 101
102 // Category 102 // Category
103 c = config.readEntry( "Category", "" ); 103 c = config.readEntry( "Category", "" );
104 104
105 // Transaction amount 105 // Transaction amount
106 QString stramount = config.readEntry( "Amount", "0.00" ); 106 QString stramount = config.readEntry( "Amount", "0.00" );
107 bool ok; 107 bool ok;
108 a = stramount.toFloat( &ok ); 108 a = stramount.toFloat( &ok );
109 109
110 // Transaction fee 110 // Transaction fee
111 stramount = config.readEntry( "TransactionFee", "0.00" ); 111 stramount = config.readEntry( "TransactionFee", "0.00" );
112 f = stramount.toFloat( &ok ); 112 f = stramount.toFloat( &ok );
113 113
114 // Transaction number 114 // Transaction number
115 cn = config.readEntry( "CheckNumber", "" ); 115 cn = config.readEntry( "CheckNumber", "" );
116 116
117 // Notes 117 // Notes
118 n = config.readEntry( "Comments", "" ); 118 n = config.readEntry( "Comments", "" );
119 } 119 }
120} 120}
121 121
122const QString &TranInfo::datestr() 122const QString &TranInfo::datestr()
123{ 123{
124 tempstr = QString::number( td.year() ); 124 tempstr = QString::number( td.year() );
125 tempstr.append( '/' ); 125 tempstr.append( '/' );
126 int tempfield = td.month(); 126 int tempfield = td.month();
127 if ( tempfield < 10 ) tempstr.append( '0' ); 127 if ( tempfield < 10 ) tempstr.append( '0' );
128 tempstr.append( QString::number( tempfield ) ); 128 tempstr.append( QString::number( tempfield ) );
129 tempstr.append( '/' ); 129 tempstr.append( '/' );
130 tempfield = td.day(); 130 tempfield = td.day();
131 if ( tempfield < 10 ) tempstr.append( '0' ); 131 if ( tempfield < 10 ) tempstr.append( '0' );
132 tempstr.append( QString::number( tempfield ) ); 132 tempstr.append( QString::number( tempfield ) );
133 133
134 return( tempstr ); 134 return( tempstr );
135} 135}
136 136
137void TranInfo::write( Config *config, int entry ) 137void TranInfo::write( Config *config, int entry )
138{ 138{
139 config->setGroup( QString::number( entry ) ); 139 config->setGroup( QString::number( entry ) );
140 140
141 config->writeEntry( "Description", d ); 141 config->writeEntry( "Description", d );
142 142
143 tempstr = QString::number( td.month() ); 143 tempstr = QString::number( td.month() );
144 tempstr.append( '/' ); 144 tempstr.append( '/' );
145 tempstr.append( QString::number( td.day() ) ); 145 tempstr.append( QString::number( td.day() ) );
146 tempstr.append( '/' ); 146 tempstr.append( '/' );
147 tempstr.append( QString::number( td.year() ) ); 147 tempstr.append( QString::number( td.year() ) );
148 config->writeEntry( "Date", tempstr ); 148 config->writeEntry( "Date", tempstr );
149 149
150 w ? tempstr = "true" 150 w ? tempstr = "true"
151 : tempstr = "false"; 151 : tempstr = "false";
152 config->writeEntry( "Payment", tempstr ); 152 config->writeEntry( "Payment", tempstr );
153 153
154 if ( t == "Debit Charge" || t == "Written Check" ) 154 if ( t == "Debit Charge" || t == "Written Check" )
155 tempstr = "0"; 155 tempstr = "0";
156 else if ( t == "Written Check" || t == "Automatic Payment" ) 156 else if ( t == "Written Check" || t == "Automatic Payment" )
157 tempstr = "1"; 157 tempstr = "1";
158 else if ( t == "Transfer" ) 158 else if ( t == "Transfer" )
159 tempstr = "2"; 159 tempstr = "2";
160 else if ( t == "Credit Card" || t == "Cash" ) 160 else if ( t == "Credit Card" || t == "Cash" )
161 tempstr = "3"; 161 tempstr = "3";
162 config->writeEntry( "Type", tempstr ); 162 config->writeEntry( "Type", tempstr );
163 163
164 config->writeEntry( "Category", c ); 164 config->writeEntry( "Category", c );
165 165
166 tempstr.setNum( a, 'f', 2 ); 166 tempstr.setNum( a, 'f', 2 );
167 config->writeEntry( "Amount", tempstr ); 167 config->writeEntry( "Amount", tempstr );
168 168
169 tempstr.setNum( f, 'f', 2 ); 169 tempstr.setNum( f, 'f', 2 );
170 config->writeEntry( "TransactionFee", tempstr ); 170 config->writeEntry( "TransactionFee", tempstr );
171 171
172 config->writeEntry( "CheckNumber", cn ); 172 config->writeEntry( "CheckNumber", cn );
173 173
174 config->writeEntry( "Comments", n ); 174 config->writeEntry( "Comments", n );
175} 175}
176
177int TranInfoList::compareItems( QCollection::Item item1, QCollection::Item item2 )
178{
179 QDate d1 = ((TranInfo *)item1)->date();
180 QDate d2 = ((TranInfo *)item2)->date();
181 int r = -1;
182
183 if ( d1 < d2 )
184 r = -1;
185 else if ( d1 == d2 )
186 r = 0;
187 else if ( d1 > d2 )
188 r = 1;
189 return( r );
190} \ No newline at end of file
diff --git a/noncore/apps/checkbook/traninfo.h b/noncore/apps/checkbook/traninfo.h
index e944c29..e488816 100644
--- a/noncore/apps/checkbook/traninfo.h
+++ b/noncore/apps/checkbook/traninfo.h
@@ -1,86 +1,92 @@
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 <williamsdr@acm.org> 4             .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.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
84typedef QList<TranInfo> TranInfoList; 84class TranInfoList : public QList<TranInfo>
85{
86 protected:
87 int compareItems( QCollection::Item, QCollection::Item );
88};
89
90//typedef TranList<TranInfo> TranInfoList;
85 91
86#endif 92#endif