summaryrefslogtreecommitdiff
path: root/noncore/apps/checkbook/checkbook.cpp
Unidiff
Diffstat (limited to 'noncore/apps/checkbook/checkbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/checkbook/checkbook.cpp6
1 files changed, 3 insertions, 3 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
@@ -302,25 +302,25 @@ void Checkbook::loadCheckbook()
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
@@ -406,25 +406,25 @@ void Checkbook::slotNewTran()
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 }
@@ -553,25 +553,25 @@ void Checkbook::drawBalanceChart()
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() )