-rw-r--r-- | noncore/apps/checkbook/checkbook.cpp | 2 |
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 | |||
@@ -423,236 +423,236 @@ void Checkbook::slotNewTran() | |||
423 | // Add to transaction list | 423 | // Add to transaction list |
424 | info->addTransaction( traninfo ); | 424 | info->addTransaction( traninfo ); |
425 | 425 | ||
426 | // Add to transaction table | 426 | // Add to transaction table |
427 | float amount; | 427 | float amount; |
428 | QString stramount; | 428 | QString stramount; |
429 | 429 | ||
430 | amount = traninfo->amount(); | 430 | amount = traninfo->amount(); |
431 | if ( traninfo->withdrawal() ) | 431 | if ( traninfo->withdrawal() ) |
432 | { | 432 | { |
433 | amount *= -1; | 433 | amount *= -1; |
434 | } | 434 | } |
435 | stramount.sprintf( "%s%.2f", currencySymbol.latin1(), amount ); | 435 | stramount.sprintf( "%s%.2f", currencySymbol.latin1(), amount ); |
436 | 436 | ||
437 | ( void ) new CBListItem( tranTable, traninfo->number(), traninfo->datestr(), traninfo->desc(), | 437 | ( void ) new CBListItem( tranTable, traninfo->number(), traninfo->datestr(), traninfo->desc(), |
438 | stramount ); | 438 | stramount ); |
439 | 439 | ||
440 | adjustBalance(); | 440 | adjustBalance(); |
441 | } | 441 | } |
442 | else | 442 | else |
443 | { | 443 | { |
444 | highTranNum--; | 444 | highTranNum--; |
445 | delete traninfo; | 445 | delete traninfo; |
446 | } | 446 | } |
447 | } | 447 | } |
448 | 448 | ||
449 | void Checkbook::slotEditTran() | 449 | void Checkbook::slotEditTran() |
450 | { | 450 | { |
451 | QListViewItem *curritem = tranTable->currentItem(); | 451 | QListViewItem *curritem = tranTable->currentItem(); |
452 | if ( !curritem ) | 452 | if ( !curritem ) |
453 | { | 453 | { |
454 | return; | 454 | return; |
455 | } | 455 | } |
456 | 456 | ||
457 | TranInfo *traninfo = info->findTransaction( curritem->text( 0 ), curritem->text( 1 ), | 457 | TranInfo *traninfo = info->findTransaction( curritem->text( 0 ), curritem->text( 1 ), |
458 | curritem->text( 2 ) ); | 458 | curritem->text( 2 ) ); |
459 | 459 | ||
460 | Transaction *currtran = new Transaction( this, info->name(), | 460 | Transaction *currtran = new Transaction( this, info->name(), |
461 | traninfo, | 461 | traninfo, |
462 | currencySymbol ); | 462 | currencySymbol ); |
463 | currtran->showMaximized(); | 463 | currtran->showMaximized(); |
464 | if ( currtran->exec() == QDialog::Accepted ) | 464 | if ( currtran->exec() == QDialog::Accepted ) |
465 | { | 465 | { |
466 | curritem->setText( 0, traninfo->number() ); | 466 | curritem->setText( 0, traninfo->number() ); |
467 | curritem->setText( 1, traninfo->datestr() ); | 467 | curritem->setText( 1, traninfo->datestr() ); |
468 | curritem->setText( 2, traninfo->desc() ); | 468 | curritem->setText( 2, traninfo->desc() ); |
469 | 469 | ||
470 | float amount = traninfo->amount(); | 470 | float amount = traninfo->amount(); |
471 | if ( traninfo->withdrawal() ) | 471 | if ( traninfo->withdrawal() ) |
472 | { | 472 | { |
473 | amount *= -1; | 473 | amount *= -1; |
474 | } | 474 | } |
475 | QString stramount; | 475 | QString stramount; |
476 | stramount.sprintf( "%s%.2f", currencySymbol.latin1(), amount ); | 476 | stramount.sprintf( "%s%.2f", currencySymbol.latin1(), amount ); |
477 | curritem->setText( 3, stramount ); | 477 | curritem->setText( 3, stramount ); |
478 | 478 | ||
479 | adjustBalance(); | 479 | adjustBalance(); |
480 | } | 480 | } |
481 | 481 | ||
482 | delete currtran; | 482 | delete currtran; |
483 | } | 483 | } |
484 | 484 | ||
485 | void Checkbook::slotDeleteTran() | 485 | void Checkbook::slotDeleteTran() |
486 | { | 486 | { |
487 | QListViewItem *curritem = tranTable->currentItem(); | 487 | QListViewItem *curritem = tranTable->currentItem(); |
488 | if ( !curritem ) | 488 | if ( !curritem ) |
489 | { | 489 | { |
490 | return; | 490 | return; |
491 | } | 491 | } |
492 | 492 | ||
493 | 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 ) ); |
494 | 494 | ||
495 | if ( QPEMessageBox::confirmDelete ( this, tr( "Delete transaction" ), traninfo->desc() ) ) | 495 | if ( QPEMessageBox::confirmDelete ( this, tr( "Delete transaction" ), traninfo->desc() ) ) |
496 | { | 496 | { |
497 | info->removeTransaction( traninfo ); | 497 | info->removeTransaction( traninfo ); |
498 | delete curritem; | 498 | delete curritem; |
499 | adjustBalance(); | 499 | adjustBalance(); |
500 | } | 500 | } |
501 | } | 501 | } |
502 | 502 | ||
503 | void Checkbook::slotDrawGraph() | 503 | void Checkbook::slotDrawGraph() |
504 | { | 504 | { |
505 | if ( graphInfo ) | 505 | if ( graphInfo ) |
506 | { | 506 | { |
507 | delete graphInfo; | 507 | delete graphInfo; |
508 | } | 508 | } |
509 | 509 | ||
510 | switch ( graphList->currentItem() ) | 510 | switch ( graphList->currentItem() ) |
511 | { | 511 | { |
512 | case 0 : drawBalanceChart(); | 512 | case 0 : drawBalanceChart(); |
513 | break; | 513 | break; |
514 | case 1 : drawCategoryChart( TRUE ); | 514 | case 1 : drawCategoryChart( TRUE ); |
515 | break; | 515 | break; |
516 | case 2 : drawCategoryChart( FALSE ); | 516 | case 2 : drawCategoryChart( FALSE ); |
517 | break; | 517 | break; |
518 | }; | 518 | }; |
519 | 519 | ||
520 | graphWidget->setGraphInfo( graphInfo ); | 520 | graphWidget->setGraphInfo( graphInfo ); |
521 | graphWidget->drawGraph( TRUE ); | 521 | graphWidget->drawGraph( TRUE ); |
522 | } | 522 | } |
523 | 523 | ||
524 | void Checkbook::drawBalanceChart() | 524 | void 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 | ||
558 | void Checkbook::drawCategoryChart( bool withdrawals ) | 558 | void 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 | ||
596 | CBListItem::CBListItem( QListView *parent, QString label1, QString label2, | 596 | CBListItem::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 | ||
605 | void CBListItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align ) | 605 | void 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 | ||
620 | bool CBListItem::isAltBackground() | 620 | bool 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 | } |