Diffstat (limited to 'noncore/apps/qashmoney/transactiondisplay.cpp') (more/less context) (ignore whitespace changes)
-rwxr-xr-x | noncore/apps/qashmoney/transactiondisplay.cpp | 20 |
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 | |||
@@ -62,16 +62,17 @@ TransactionDisplay::TransactionDisplay ( QWidget* parent ) : QWidget ( parent ) | |||
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 | ||
77 | void TransactionDisplay::addTransaction () | 78 | void TransactionDisplay::addTransaction () |
@@ -128,17 +129,17 @@ void TransactionDisplay::addTransaction () | |||
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 |
@@ -367,17 +368,17 @@ void TransactionDisplay::updateAndDisplay ( int id ) | |||
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 |
@@ -411,17 +412,17 @@ void TransactionDisplay::deleteTransaction () | |||
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 ) ); |
@@ -443,17 +444,17 @@ void TransactionDisplay::deleteTransaction () | |||
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 ); |
@@ -496,17 +497,17 @@ void TransactionDisplay::toggleTransaction () | |||
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 | ||
507 | void TransactionDisplay::redisplayAccountBalance () | 508 | void 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 | ||
@@ -546,27 +547,32 @@ void TransactionDisplay::saveColumnSize ( int column, int oldsize, int newsize ) | |||
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 | ||
555 | void TransactionDisplay::saveSortingPreference ( int column ) | ||
556 | { | ||
557 | preferences->changeSortingPreference ( 2, column ); | ||
558 | } | ||
559 | |||
554 | void TransactionDisplay::limitDisplay ( const QString &text ) | 560 | void 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 | ||
567 | int TransactionDisplay::getIDColumn () | 573 | int 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 ) |
@@ -614,10 +620,10 @@ void TransactionDisplay::setTransactionDisplayDate () | |||
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 | } |