summaryrefslogtreecommitdiff
path: root/noncore/apps/qashmoney/transactiondisplay.cpp
Unidiff
Diffstat (limited to 'noncore/apps/qashmoney/transactiondisplay.cpp') (more/less context) (show whitespace changes)
-rwxr-xr-xnoncore/apps/qashmoney/transactiondisplay.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/noncore/apps/qashmoney/transactiondisplay.cpp b/noncore/apps/qashmoney/transactiondisplay.cpp
index ae6223d..1839cd2 100755
--- a/noncore/apps/qashmoney/transactiondisplay.cpp
+++ b/noncore/apps/qashmoney/transactiondisplay.cpp
@@ -58,24 +58,25 @@ TransactionDisplay::TransactionDisplay ( QWidget* parent ) : QWidget ( parent )
58 balance = new QLabel ( secondline ); 58 balance = new QLabel ( secondline );
59 59
60 QLabel *limit = new QLabel ( "Limit", secondline ); 60 QLabel *limit = new QLabel ( "Limit", secondline );
61 limitbox = new QLineEdit ( secondline ); 61 limitbox = new QLineEdit ( secondline );
62 limitbox->setMinimumWidth ( ( int ) ( this->width() / 6 ) ); 62 limitbox->setMinimumWidth ( ( int ) ( this->width() / 6 ) );
63 connect ( limitbox, SIGNAL ( textChanged ( const QString & ) ), this, SLOT ( limitDisplay ( const QString & ) ) ); 63 connect ( limitbox, SIGNAL ( textChanged ( const QString & ) ), this, SLOT ( limitDisplay ( const QString & ) ) );
64 64
65 listview = new QListView ( this ); 65 listview = new QListView ( this );
66 listview->setAllColumnsShowFocus ( TRUE ); 66 listview->setAllColumnsShowFocus ( TRUE );
67 listview->setShowSortIndicator ( TRUE ); 67 listview->setShowSortIndicator ( TRUE );
68 listview->header()->setTracking ( FALSE ); 68 listview->header()->setTracking ( FALSE );
69 connect ( listview->header(), SIGNAL ( sizeChange ( int, int, int ) ), this, SLOT ( saveColumnSize ( int, int, int ) ) ); 69 connect ( listview->header(), SIGNAL ( sizeChange ( int, int, int ) ), this, SLOT ( saveColumnSize ( int, int, int ) ) );
70 connect ( listview->header(), SIGNAL ( clicked ( int ) ), this, SLOT ( saveSortingPreference ( int ) ) );
70 71
71 layout = new QVBoxLayout ( this, 2, 2 ); 72 layout = new QVBoxLayout ( this, 2, 2 );
72 layout->addWidget ( firstline ); 73 layout->addWidget ( firstline );
73 layout->addWidget ( secondline ); 74 layout->addWidget ( secondline );
74 layout->addWidget ( listview ); 75 layout->addWidget ( listview );
75 } 76 }
76 77
77void TransactionDisplay::addTransaction () 78void TransactionDisplay::addTransaction ()
78 { 79 {
79 // create local variables 80 // create local variables
80 int cleared = -1; 81 int cleared = -1;
81 82
@@ -124,25 +125,25 @@ void TransactionDisplay::addTransaction ()
124 newtransaction->transactionnumber->text().toInt(), defaultday, defaultmonth, defaultyear, amount, cleared, newtransaction->getCurrentBudget(), newtransaction->getCurrentLineItem() ); 125 newtransaction->transactionnumber->text().toInt(), defaultday, defaultmonth, defaultyear, amount, cleared, newtransaction->getCurrentBudget(), newtransaction->getCurrentLineItem() );
125 126
126 // redisplay transactions 127 // redisplay transactions
127 listview->clear(); 128 listview->clear();
128 QString displaytext = "%"; 129 QString displaytext = "%";
129 displaytext.prepend ( limitbox->text() ); 130 displaytext.prepend ( limitbox->text() );
130 setTransactionDisplayDate (); 131 setTransactionDisplayDate ();
131 if ( transaction->getNumberOfTransactions() > 0 ) 132 if ( transaction->getNumberOfTransactions() > 0 )
132 transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate ); 133 transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate );
133 134
134 // redisplay transfers 135 // redisplay transfers
135 if ( transfer->getNumberOfTransfers() > 0 ) 136 if ( transfer->getNumberOfTransfers() > 0 )
136 transfer->displayTransfers ( listview, accountid, children ); 137 transfer->displayTransfers ( listview, accountid, children, displaydate );
137 138
138 // add the transaction amount to the account it's associated with 139 // add the transaction amount to the account it's associated with
139 // and update its parent account balance if necessary 140 // and update its parent account balance if necessary
140 account->updateAccountBalance ( accountid ); 141 account->updateAccountBalance ( accountid );
141 if ( account->getParentAccountID ( accountid ) != -1 ) 142 if ( account->getParentAccountID ( accountid ) != -1 )
142 account->changeParentAccountBalance ( account->getParentAccountID ( accountid ) ); 143 account->changeParentAccountBalance ( account->getParentAccountID ( accountid ) );
143 144
144 // format then reset the account balance 145 // format then reset the account balance
145 redisplayAccountBalance (); 146 redisplayAccountBalance ();
146 } 147 }
147 } 148 }
148 149
@@ -363,25 +364,25 @@ void TransactionDisplay::editTransaction ()
363void TransactionDisplay::updateAndDisplay ( int id ) 364void TransactionDisplay::updateAndDisplay ( int id )
364 { 365 {
365 // redisplay transactions 366 // redisplay transactions
366 listview->clear(); 367 listview->clear();
367 QString displaytext = "%"; 368 QString displaytext = "%";
368 displaytext.prepend ( limitbox->text() ); 369 displaytext.prepend ( limitbox->text() );
369 setTransactionDisplayDate (); 370 setTransactionDisplayDate ();
370 if ( transaction->getNumberOfTransactions() > 0 ) 371 if ( transaction->getNumberOfTransactions() > 0 )
371 transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate ); 372 transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate );
372 373
373 // redisplay transfers 374 // redisplay transfers
374 if ( transfer->getNumberOfTransfers() > 0 ) 375 if ( transfer->getNumberOfTransfers() > 0 )
375 transfer->displayTransfers ( listview, accountid, children ); 376 transfer->displayTransfers ( listview, accountid, children, displaydate );
376 377
377 // add the transaction amount to the account it's associated with 378 // add the transaction amount to the account it's associated with
378 // and update its parent account balance if necessary 379 // and update its parent account balance if necessary
379 account->updateAccountBalance ( id ); 380 account->updateAccountBalance ( id );
380 if ( account->getParentAccountID ( id ) != -1 ) 381 if ( account->getParentAccountID ( id ) != -1 )
381 account->changeParentAccountBalance ( account->getParentAccountID ( id ) ); 382 account->changeParentAccountBalance ( account->getParentAccountID ( id ) );
382 383
383 // format then reset the account balance 384 // format then reset the account balance
384 redisplayAccountBalance (); 385 redisplayAccountBalance ();
385 } 386 }
386 387
387void TransactionDisplay::checkListViewDelete () 388void TransactionDisplay::checkListViewDelete ()
@@ -407,25 +408,25 @@ void TransactionDisplay::deleteTransaction ()
407 childaccountid = transaction->getAccountID ( transactionid ); 408 childaccountid = transaction->getAccountID ( transactionid );
408 409
409 transaction->deleteTransaction ( transactionid ); 410 transaction->deleteTransaction ( transactionid );
410 411
411 listview->clear(); 412 listview->clear();
412 QString displaytext = "%"; 413 QString displaytext = "%";
413 displaytext.prepend ( limitbox->text() ); 414 displaytext.prepend ( limitbox->text() );
414 setTransactionDisplayDate (); 415 setTransactionDisplayDate ();
415 if ( transaction->getNumberOfTransactions() > 0 ) 416 if ( transaction->getNumberOfTransactions() > 0 )
416 transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate ); 417 transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate );
417 418
418 if ( transfer->getNumberOfTransfers() > 0 ) 419 if ( transfer->getNumberOfTransfers() > 0 )
419 transfer->displayTransfers ( listview, accountid, children ); 420 transfer->displayTransfers ( listview, accountid, children, displaydate );
420 421
421 // if we are viewing different child accounts through the parent account 422 // if we are viewing different child accounts through the parent account
422 // ie if there are five columns and the parentid is -1 423 // ie if there are five columns and the parentid is -1
423 // update the accountid ( which is the parent ) and update the child account 424 // update the accountid ( which is the parent ) and update the child account
424 // balance. Get its accountid from the transactionid 425 // balance. Get its accountid from the transactionid
425 account->updateAccountBalance ( accountid ); // will update either a parent or child 426 account->updateAccountBalance ( accountid ); // will update either a parent or child
426 if ( account->getParentAccountID ( accountid ) != -1 ) // update its parent if there is one 427 if ( account->getParentAccountID ( accountid ) != -1 ) // update its parent if there is one
427 account->changeParentAccountBalance ( account->getParentAccountID ( accountid ) ); 428 account->changeParentAccountBalance ( account->getParentAccountID ( accountid ) );
428 if ( childaccountid != -1 ) // we've set childaccountid 429 if ( childaccountid != -1 ) // we've set childaccountid
429 account->updateAccountBalance ( childaccountid ); 430 account->updateAccountBalance ( childaccountid );
430 431
431 // format then reset the account balance 432 // format then reset the account balance
@@ -439,25 +440,25 @@ void TransactionDisplay::deleteTransaction ()
439 440
440 // delete the transfer and redisplay transactions 441 // delete the transfer and redisplay transactions
441 transfer->deleteTransfer ( transactionid ); 442 transfer->deleteTransfer ( transactionid );
442 443
443 listview->clear(); 444 listview->clear();
444 QString displaytext = "%"; 445 QString displaytext = "%";
445 displaytext.prepend ( limitbox->text() ); 446 displaytext.prepend ( limitbox->text() );
446 setTransactionDisplayDate (); 447 setTransactionDisplayDate ();
447 if ( transaction->getNumberOfTransactions() > 0 ) 448 if ( transaction->getNumberOfTransactions() > 0 )
448 transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate ); 449 transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate );
449 450
450 if ( transfer->getNumberOfTransfers() > 0 ) 451 if ( transfer->getNumberOfTransfers() > 0 )
451 transfer->displayTransfers ( listview, accountid, children ); 452 transfer->displayTransfers ( listview, accountid, children, displaydate );
452 453
453 // for the from account 454 // for the from account
454 account->updateAccountBalance ( fromaccountid ); 455 account->updateAccountBalance ( fromaccountid );
455 if ( account->getParentAccountID ( fromaccountid ) != -1 ) 456 if ( account->getParentAccountID ( fromaccountid ) != -1 )
456 account->changeParentAccountBalance ( account->getParentAccountID ( fromaccountid ) ); 457 account->changeParentAccountBalance ( account->getParentAccountID ( fromaccountid ) );
457 458
458 // for the to account 459 // for the to account
459 account->updateAccountBalance ( toaccountid ); 460 account->updateAccountBalance ( toaccountid );
460 if ( account->getParentAccountID ( toaccountid ) != -1 ) 461 if ( account->getParentAccountID ( toaccountid ) != -1 )
461 account->changeParentAccountBalance ( account->getParentAccountID ( toaccountid ) ); 462 account->changeParentAccountBalance ( account->getParentAccountID ( toaccountid ) );
462 463
463 // format then reset the account balance 464 // format then reset the account balance
@@ -492,25 +493,25 @@ void TransactionDisplay::toggleTransaction ()
492 else 493 else
493 transfer->setCleared ( transactionid, 0 ); 494 transfer->setCleared ( transactionid, 0 );
494 } 495 }
495 496
496 listview->clear(); 497 listview->clear();
497 QString displaytext = "%"; 498 QString displaytext = "%";
498 displaytext.prepend ( limitbox->text() ); 499 displaytext.prepend ( limitbox->text() );
499 setTransactionDisplayDate (); 500 setTransactionDisplayDate ();
500 if ( transaction->getNumberOfTransactions() > 0 ) 501 if ( transaction->getNumberOfTransactions() > 0 )
501 transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate ); 502 transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate );
502 503
503 if ( transfer->getNumberOfTransfers() != 0 ) 504 if ( transfer->getNumberOfTransfers() != 0 )
504 transfer->displayTransfers ( listview, accountid, children ); 505 transfer->displayTransfers ( listview, accountid, children, displaydate );
505 } 506 }
506 507
507void TransactionDisplay::redisplayAccountBalance () 508void TransactionDisplay::redisplayAccountBalance ()
508 { 509 {
509 QString accountbalance = account->getAccountBalance ( accountid ); 510 QString accountbalance = account->getAccountBalance ( accountid );
510 balance->setText ( accountbalance ); 511 balance->setText ( accountbalance );
511 } 512 }
512 513
513void TransactionDisplay::setChildren ( bool c ) 514void TransactionDisplay::setChildren ( bool c )
514 { 515 {
515 children = c; 516 children = c;
516 } 517 }
@@ -542,35 +543,40 @@ void ColorListItem::paintCell ( QPainter *p, const QColorGroup &cg, int column,
542 } 543 }
543 544
544void TransactionDisplay::saveColumnSize ( int column, int oldsize, int newsize ) 545void TransactionDisplay::saveColumnSize ( int column, int oldsize, int newsize )
545 { 546 {
546 if ( listview->columns() == 4 ) 547 if ( listview->columns() == 4 )
547 preferences->changeColumnPreference ( column + 3, newsize ); 548 preferences->changeColumnPreference ( column + 3, newsize );
548 else if ( listview->columns() == 5 && column != 4 ) 549 else if ( listview->columns() == 5 && column != 4 )
549 preferences->changeColumnPreference ( column + 6, newsize ); 550 preferences->changeColumnPreference ( column + 6, newsize );
550 else 551 else
551 preferences->changeColumnPreference ( 9, newsize ); 552 preferences->changeColumnPreference ( 9, newsize );
552 } 553 }
553 554
555void TransactionDisplay::saveSortingPreference ( int column )
556 {
557 preferences->changeSortingPreference ( 2, column );
558 }
559
554void TransactionDisplay::limitDisplay ( const QString &text ) 560void TransactionDisplay::limitDisplay ( const QString &text )
555 { 561 {
556 listview->clear (); 562 listview->clear ();
557 QString displaytext = "%"; 563 QString displaytext = "%";
558 displaytext.prepend ( text ); 564 displaytext.prepend ( text );
559 setTransactionDisplayDate (); 565 setTransactionDisplayDate ();
560 if ( transaction->getNumberOfTransactions() > 0 ) 566 if ( transaction->getNumberOfTransactions() > 0 )
561 transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate ); 567 transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate );
562 568
563 if ( displaytext.length() == 1 || preferences->getPreference ( 6 ) == 1 ) 569 if ( displaytext.length() == 1 || preferences->getPreference ( 6 ) == 1 )
564 transfer->displayTransfers ( listview, accountid, children ); 570 transfer->displayTransfers ( listview, accountid, children, displaydate );
565 } 571 }
566 572
567int TransactionDisplay::getIDColumn () 573int TransactionDisplay::getIDColumn ()
568 { 574 {
569 int counter; 575 int counter;
570 int columns = listview->columns(); 576 int columns = listview->columns();
571 for ( counter = 0; counter <= columns; counter++ ) 577 for ( counter = 0; counter <= columns; counter++ )
572 if ( listview->header()->label ( counter ).length() == 0 ) 578 if ( listview->header()->label ( counter ).length() == 0 )
573 return counter; 579 return counter;
574 } 580 }
575 581
576void TransactionDisplay::showTransactionNotes () 582void TransactionDisplay::showTransactionNotes ()
@@ -610,14 +616,14 @@ void TransactionDisplay::setTransactionDisplayDate ()
610 case 2: // three months 616 case 2: // three months
611 displaydate = today.addDays ( -90 ); 617 displaydate = today.addDays ( -90 );
612 break; 618 break;
613 case 3: // six months 619 case 3: // six months
614 displaydate = today.addDays ( -180 ); 620 displaydate = today.addDays ( -180 );
615 break; 621 break;
616 case 4: // one year 622 case 4: // one year
617 displaydate = today.addDays ( -365 ); 623 displaydate = today.addDays ( -365 );
618 break; 624 break;
619 } 625 }
620 } 626 }
621 else 627 else
622 displaydate = QDate ( 1, 1, 1000 ); 628 displaydate = QDate ( 1900, 1, 1 );
623 } 629 }