summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/checkbook/checkbook.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/apps/checkbook/checkbook.cpp b/noncore/apps/checkbook/checkbook.cpp
index 7a6b7cc..5fe660c 100644
--- a/noncore/apps/checkbook/checkbook.cpp
+++ b/noncore/apps/checkbook/checkbook.cpp
@@ -519,140 +519,140 @@ void Checkbook::slotDrawGraph()
519 519
520 graphWidget->setGraphInfo( graphInfo ); 520 graphWidget->setGraphInfo( graphInfo );
521 graphWidget->drawGraph( TRUE ); 521 graphWidget->drawGraph( TRUE );
522} 522}
523 523
524void Checkbook::drawBalanceChart() 524void Checkbook::drawBalanceChart()
525{ 525{
526 DataPointList *list = new DataPointList(); 526 DataPointList *list = new DataPointList();
527 527
528 float balance = info->startingBalance(); 528 float balance = info->startingBalance();
529 float amount; 529 float amount;
530 QString label; 530 QString label;
531 int i = 0; 531 int i = 0;
532 int count = tranList->count(); 532 int count = tranList->count();
533 533
534 for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() ) 534 for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() )
535 { 535 {
536 i++; 536 i++;
537 balance -= tran->fee(); 537 balance -= tran->fee();
538 amount = tran->amount(); 538 amount = tran->amount();
539 if ( tran->withdrawal() ) 539 if ( tran->withdrawal() )
540 { 540 {
541 amount *= -1; 541 amount *= -1;
542 } 542 }
543 balance += amount; 543 balance += amount;
544 if ( i == 1 || i == count / 2 || i == count ) 544 if ( i == 1 || i == count / 2 || i == count )
545 { 545 {
546 label = tran->datestr(); 546 label = tran->datestr();
547 } 547 }
548 else 548 else
549 { 549 {
550 label = ""; 550 label = "";
551 } 551 }
552 list->append( new DataPointInfo( label, balance ) ); 552 list->append( new DataPointInfo( label, balance ) );
553 } 553 }
554 554
555 graphInfo = new GraphInfo( GraphInfo::BarChart, list ); 555 graphInfo = new GraphInfo( GraphInfo::BarChart, list );
556} 556}
557 557
558void Checkbook::drawCategoryChart( bool withdrawals ) 558void Checkbook::drawCategoryChart( bool withdrawals )
559{ 559{
560 DataPointList *list = new DataPointList(); 560 DataPointList *list = new DataPointList();
561 561
562 TranInfo *tran = tranList->first(); 562 TranInfo *tran = tranList->first();
563 if ( tran && tran->withdrawal() == withdrawals ) 563 if ( tran && tran->withdrawal() == withdrawals )
564 { 564 {
565 list->append( new DataPointInfo( tran->category(), tran->amount() ) ); 565 list->append( new DataPointInfo( tran->category(), tran->amount() ) );
566 } 566 }
567 tran = tranList->next(); 567 tran = tranList->next();
568 568
569 DataPointInfo *cat; 569 DataPointInfo *cat;
570 for ( ; tran; tran = tranList->next() ) 570 for ( ; tran; tran = tranList->next() )
571 { 571 {
572 if ( tran->withdrawal() == withdrawals ) 572 if ( tran->withdrawal() == withdrawals )
573 { 573 {
574 // Find category in list 574 // Find category in list
575 for ( cat = list->first(); cat; cat = list->next() ) 575 for ( cat = list->first(); cat; cat = list->next() )
576 { 576 {
577 if ( cat->label() == tran->category() ) 577 if ( cat->label() == tran->category() )
578 { 578 {
579 break; 579 break;
580 } 580 }
581 } 581 }
582 if ( cat && cat->label() == tran->category() ) 582 if ( cat && cat->label() == tran->category() )
583 { // Found category, add to transaction to category total 583 { // Found category, add to transaction to category total
584 cat->addToValue( tran->amount() ); 584 cat->addToValue( tran->amount() );
585 } 585 }
586 else 586 else
587 { // Didn't find category, add category to list 587 { // Didn't find category, add category to list
588 list->append( new DataPointInfo( tran->category(), tran->amount() ) ); 588 list->append( new DataPointInfo( tran->category(), tran->amount() ) );
589 } 589 }
590 } 590 }
591 } 591 }
592 592
593 graphInfo = new GraphInfo( GraphInfo::PieChart, list ); 593 graphInfo = new GraphInfo( GraphInfo::PieChart, list );
594} 594}
595 595
596CBListItem::CBListItem( QListView *parent, QString label1, QString label2, 596CBListItem::CBListItem( QListView *parent, QString label1, QString label2,
597 QString label3, QString label4, QString label5, QString label6, QString label7, 597 QString label3, QString label4, QString label5, QString label6, QString label7,
598 QString label8 ) 598 QString label8 )
599 : QListViewItem( parent, label1, label2, label3, label4, label5, label6, label7, label8 ) 599 : QListViewItem( parent, label1, label2, label3, label4, label5, label6, label7, label8 )
600{ 600{
601 m_known = FALSE; 601 m_known = FALSE;
602 owner = parent; 602 owner = parent;
603} 603}
604 604
605void 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 )
606{ 606{
607 QColorGroup _cg = cg; 607 QColorGroup _cg = cg;
608 const QPixmap *pm = listView()->viewport()->backgroundPixmap(); 608 const QPixmap *pm = listView()->viewport()->backgroundPixmap();
609 if ( pm && !pm->isNull() ) 609 if ( pm && !pm->isNull() )
610 { 610 {
611 _cg.setBrush( QColorGroup::Base, QBrush( cg.base(), *pm ) ); 611 _cg.setBrush( QColorGroup::Base, QBrush( cg.base(), *pm ) );
612 p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); 612 p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() );
613 } 613 }
614 else if ( isAltBackground() ) 614 else if ( isAltBackground() )
615 _cg.setColor(QColorGroup::Base, QColor( 200, 255, 200 ) ); 615 _cg.setColor(QColorGroup::Base, cg.background() );
616 616
617 QListViewItem::paintCell(p, _cg, column, width, align); 617 QListViewItem::paintCell(p, _cg, column, width, align);
618} 618}
619 619
620bool CBListItem::isAltBackground() 620bool CBListItem::isAltBackground()
621{ 621{
622 QListView *lv = static_cast<QListView *>( listView() ); 622 QListView *lv = static_cast<QListView *>( listView() );
623 if ( lv ) 623 if ( lv )
624 { 624 {
625 CBListItem *above = 0; 625 CBListItem *above = 0;
626 above = (CBListItem *)( itemAbove() ); 626 above = (CBListItem *)( itemAbove() );
627 m_known = above ? above->m_known : true; 627 m_known = above ? above->m_known : true;
628 if ( m_known ) 628 if ( m_known )
629 { 629 {
630 m_odd = above ? !above->m_odd : false; 630 m_odd = above ? !above->m_odd : false;
631 } 631 }
632 else 632 else
633 { 633 {
634 CBListItem *item; 634 CBListItem *item;
635 bool previous = true; 635 bool previous = true;
636 if ( parent() ) 636 if ( parent() )
637 { 637 {
638 item = (CBListItem *)( parent() ); 638 item = (CBListItem *)( parent() );
639 if ( item ) 639 if ( item )
640 previous = item->m_odd; 640 previous = item->m_odd;
641 item = (CBListItem *)( parent()->firstChild() ); 641 item = (CBListItem *)( parent()->firstChild() );
642 } 642 }
643 else 643 else
644 { 644 {
645 item = (CBListItem *)( lv->firstChild() ); 645 item = (CBListItem *)( lv->firstChild() );
646 } 646 }
647 647
648 while(item) 648 while(item)
649 { 649 {
650 item->m_odd = previous = !previous; 650 item->m_odd = previous = !previous;
651 item->m_known = true; 651 item->m_known = true;
652 item = (CBListItem *)( item->nextSibling() ); 652 item = (CBListItem *)( item->nextSibling() );
653 } 653 }
654 } 654 }
655 return m_odd; 655 return m_odd;
656 } 656 }
657 return false; 657 return false;
658} 658}