summaryrefslogtreecommitdiff
path: root/noncore/apps/qashmoney/transactiondisplay.cpp
Unidiff
Diffstat (limited to 'noncore/apps/qashmoney/transactiondisplay.cpp') (more/less context) (ignore whitespace changes)
-rwxr-xr-xnoncore/apps/qashmoney/transactiondisplay.cpp49
1 files changed, 43 insertions, 6 deletions
diff --git a/noncore/apps/qashmoney/transactiondisplay.cpp b/noncore/apps/qashmoney/transactiondisplay.cpp
index 14f5641..ae6223d 100755
--- a/noncore/apps/qashmoney/transactiondisplay.cpp
+++ b/noncore/apps/qashmoney/transactiondisplay.cpp
@@ -124,14 +124,15 @@ void TransactionDisplay::addTransaction ()
124 newtransaction->transactionnumber->text().toInt(), defaultday, defaultmonth, defaultyear, amount, cleared, newtransaction->getCurrentBudget(), newtransaction->getCurrentLineItem() ); 124 newtransaction->transactionnumber->text().toInt(), defaultday, defaultmonth, defaultyear, amount, cleared, newtransaction->getCurrentBudget(), newtransaction->getCurrentLineItem() );
125 125
126 // redisplay transactions 126 // redisplay transactions
127 listview->clear(); 127 listview->clear();
128 QString displaytext = "%"; 128 QString displaytext = "%";
129 displaytext.prepend ( limitbox->text() ); 129 displaytext.prepend ( limitbox->text() );
130 setTransactionDisplayDate ();
130 if ( transaction->getNumberOfTransactions() > 0 ) 131 if ( transaction->getNumberOfTransactions() > 0 )
131 transaction->displayTransactions ( listview, accountid, children, displaytext ); 132 transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate );
132 133
133 // redisplay transfers 134 // redisplay transfers
134 if ( transfer->getNumberOfTransfers() > 0 ) 135 if ( transfer->getNumberOfTransfers() > 0 )
135 transfer->displayTransfers ( listview, accountid, children ); 136 transfer->displayTransfers ( listview, accountid, children );
136 137
137 // add the transaction amount to the account it's associated with 138 // add the transaction amount to the account it's associated with
@@ -362,14 +363,15 @@ void TransactionDisplay::editTransaction ()
362void TransactionDisplay::updateAndDisplay ( int id ) 363void TransactionDisplay::updateAndDisplay ( int id )
363 { 364 {
364 // redisplay transactions 365 // redisplay transactions
365 listview->clear(); 366 listview->clear();
366 QString displaytext = "%"; 367 QString displaytext = "%";
367 displaytext.prepend ( limitbox->text() ); 368 displaytext.prepend ( limitbox->text() );
369 setTransactionDisplayDate ();
368 if ( transaction->getNumberOfTransactions() > 0 ) 370 if ( transaction->getNumberOfTransactions() > 0 )
369 transaction->displayTransactions ( listview, accountid, children, displaytext ); 371 transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate );
370 372
371 // redisplay transfers 373 // redisplay transfers
372 if ( transfer->getNumberOfTransfers() > 0 ) 374 if ( transfer->getNumberOfTransfers() > 0 )
373 transfer->displayTransfers ( listview, accountid, children ); 375 transfer->displayTransfers ( listview, accountid, children );
374 376
375 // add the transaction amount to the account it's associated with 377 // add the transaction amount to the account it's associated with
@@ -406,14 +408,15 @@ void TransactionDisplay::deleteTransaction ()
406 408
407 transaction->deleteTransaction ( transactionid ); 409 transaction->deleteTransaction ( transactionid );
408 410
409 listview->clear(); 411 listview->clear();
410 QString displaytext = "%"; 412 QString displaytext = "%";
411 displaytext.prepend ( limitbox->text() ); 413 displaytext.prepend ( limitbox->text() );
414 setTransactionDisplayDate ();
412 if ( transaction->getNumberOfTransactions() > 0 ) 415 if ( transaction->getNumberOfTransactions() > 0 )
413 transaction->displayTransactions ( listview, accountid, children, displaytext ); 416 transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate );
414 417
415 if ( transfer->getNumberOfTransfers() > 0 ) 418 if ( transfer->getNumberOfTransfers() > 0 )
416 transfer->displayTransfers ( listview, accountid, children ); 419 transfer->displayTransfers ( listview, accountid, children );
417 420
418 // if we are viewing different child accounts through the parent account 421 // if we are viewing different child accounts through the parent account
419 // ie if there are five columns and the parentid is -1 422 // ie if there are five columns and the parentid is -1
@@ -437,14 +440,15 @@ void TransactionDisplay::deleteTransaction ()
437 // delete the transfer and redisplay transactions 440 // delete the transfer and redisplay transactions
438 transfer->deleteTransfer ( transactionid ); 441 transfer->deleteTransfer ( transactionid );
439 442
440 listview->clear(); 443 listview->clear();
441 QString displaytext = "%"; 444 QString displaytext = "%";
442 displaytext.prepend ( limitbox->text() ); 445 displaytext.prepend ( limitbox->text() );
446 setTransactionDisplayDate ();
443 if ( transaction->getNumberOfTransactions() > 0 ) 447 if ( transaction->getNumberOfTransactions() > 0 )
444 transaction->displayTransactions ( listview, accountid, children, displaytext ); 448 transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate );
445 449
446 if ( transfer->getNumberOfTransfers() > 0 ) 450 if ( transfer->getNumberOfTransfers() > 0 )
447 transfer->displayTransfers ( listview, accountid, children ); 451 transfer->displayTransfers ( listview, accountid, children );
448 452
449 // for the from account 453 // for the from account
450 account->updateAccountBalance ( fromaccountid ); 454 account->updateAccountBalance ( fromaccountid );
@@ -489,14 +493,15 @@ void TransactionDisplay::toggleTransaction ()
489 transfer->setCleared ( transactionid, 0 ); 493 transfer->setCleared ( transactionid, 0 );
490 } 494 }
491 495
492 listview->clear(); 496 listview->clear();
493 QString displaytext = "%"; 497 QString displaytext = "%";
494 displaytext.prepend ( limitbox->text() ); 498 displaytext.prepend ( limitbox->text() );
499 setTransactionDisplayDate ();
495 if ( transaction->getNumberOfTransactions() > 0 ) 500 if ( transaction->getNumberOfTransactions() > 0 )
496 transaction->displayTransactions ( listview, accountid, children, displaytext ); 501 transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate );
497 502
498 if ( transfer->getNumberOfTransfers() != 0 ) 503 if ( transfer->getNumberOfTransfers() != 0 )
499 transfer->displayTransfers ( listview, accountid, children ); 504 transfer->displayTransfers ( listview, accountid, children );
500 } 505 }
501 506
502void TransactionDisplay::redisplayAccountBalance () 507void TransactionDisplay::redisplayAccountBalance ()
@@ -548,13 +553,16 @@ void TransactionDisplay::saveColumnSize ( int column, int oldsize, int newsize )
548 553
549void TransactionDisplay::limitDisplay ( const QString &text ) 554void TransactionDisplay::limitDisplay ( const QString &text )
550 { 555 {
551 listview->clear (); 556 listview->clear ();
552 QString displaytext = "%"; 557 QString displaytext = "%";
553 displaytext.prepend ( text ); 558 displaytext.prepend ( text );
554 transaction->displayTransactions ( listview, accountid, children, displaytext ); 559 setTransactionDisplayDate ();
560 if ( transaction->getNumberOfTransactions() > 0 )
561 transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate );
562
555 if ( displaytext.length() == 1 || preferences->getPreference ( 6 ) == 1 ) 563 if ( displaytext.length() == 1 || preferences->getPreference ( 6 ) == 1 )
556 transfer->displayTransfers ( listview, accountid, children ); 564 transfer->displayTransfers ( listview, accountid, children );
557 } 565 }
558 566
559int TransactionDisplay::getIDColumn () 567int TransactionDisplay::getIDColumn ()
560 { 568 {
@@ -581,6 +589,35 @@ void TransactionDisplay::showTransactionNotes ()
581 notes->setEnabled ( FALSE ); 589 notes->setEnabled ( FALSE );
582 notes->setText ( transaction->getTransactionDescription ( transactionid ) ); 590 notes->setText ( transaction->getTransactionDescription ( transactionid ) );
583 description->show(); 591 description->show();
584 } 592 }
585 } 593 }
586 594
595void TransactionDisplay::setTransactionDisplayDate ()
596 {
597 // determine how many days of transactions to show
598 int limittype = preferences->getPreference ( 7 );
599 if ( limittype != 5 ) // set today's date if we are not showing all transactions
600 {
601 QDate today = QDate::currentDate ();
602 switch ( limittype ) // if we are not showing all transactions
603 {
604 case 0: // viewing two weeks
605 displaydate = today.addDays ( -14 );
606 break;
607 case 1: // viewing one month
608 displaydate = today.addDays ( -30 );
609 break;
610 case 2: // three months
611 displaydate = today.addDays ( -90 );
612 break;
613 case 3: // six months
614 displaydate = today.addDays ( -180 );
615 break;
616 case 4: // one year
617 displaydate = today.addDays ( -365 );
618 break;
619 }
620 }
621 else
622 displaydate = QDate ( 1, 1, 1000 );
623 }