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
@@ -118,26 +118,27 @@ void TransactionDisplay::addTransaction ()
118 if ( newtransaction->getDateEdited () == TRUE ) 118 if ( newtransaction->getDateEdited () == TRUE )
119 transaction->addTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), accountid, account->getParentAccountID ( accountid ), 119 transaction->addTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), accountid, account->getParentAccountID ( accountid ),
120 newtransaction->transactionnumber->text().toInt(), newtransaction->getDay(), newtransaction->getMonth(), newtransaction->getYear(), amount, cleared, newtransaction->getCurrentBudget(), 120 newtransaction->transactionnumber->text().toInt(), newtransaction->getDay(), newtransaction->getMonth(), newtransaction->getYear(), amount, cleared, newtransaction->getCurrentBudget(),
121 newtransaction->getCurrentLineItem() ); 121 newtransaction->getCurrentLineItem() );
122 else 122 else
123 transaction->addTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), accountid, account->getParentAccountID ( accountid ), 123 transaction->addTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), accountid, account->getParentAccountID ( accountid ),
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
138 // and update its parent account balance if necessary 139 // and update its parent account balance if necessary
139 account->updateAccountBalance ( accountid ); 140 account->updateAccountBalance ( accountid );
140 if ( account->getParentAccountID ( accountid ) != -1 ) 141 if ( account->getParentAccountID ( accountid ) != -1 )
141 account->changeParentAccountBalance ( account->getParentAccountID ( accountid ) ); 142 account->changeParentAccountBalance ( account->getParentAccountID ( accountid ) );
142 143
143 // format then reset the account balance 144 // format then reset the account balance
@@ -356,26 +357,27 @@ void TransactionDisplay::editTransaction ()
356 amount, cleared, newtransaction->getCurrentBudget(), newtransaction->getCurrentLineItem(), transactionid ); 357 amount, cleared, newtransaction->getCurrentBudget(), newtransaction->getCurrentLineItem(), transactionid );
357 358
358 updateAndDisplay ( transaction->getAccountID ( transactionid ) ); 359 updateAndDisplay ( transaction->getAccountID ( transactionid ) );
359 } 360 }
360 } 361 }
361 362
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
376 // and update its parent account balance if necessary 378 // and update its parent account balance if necessary
377 account->updateAccountBalance ( id ); 379 account->updateAccountBalance ( id );
378 if ( account->getParentAccountID ( id ) != -1 ) 380 if ( account->getParentAccountID ( id ) != -1 )
379 account->changeParentAccountBalance ( account->getParentAccountID ( id ) ); 381 account->changeParentAccountBalance ( account->getParentAccountID ( id ) );
380 382
381 // format then reset the account balance 383 // format then reset the account balance
@@ -400,26 +402,27 @@ void TransactionDisplay::deleteTransaction ()
400 // in that case we will have to update balances for the parent 402 // in that case we will have to update balances for the parent
401 // which is represented by accountid and the child account 403 // which is represented by accountid and the child account
402 // which will be represented by childaccountid 404 // which will be represented by childaccountid
403 int childaccountid = -1; 405 int childaccountid = -1;
404 if ( listview->columns() == 5 ) 406 if ( listview->columns() == 5 )
405 childaccountid = transaction->getAccountID ( transactionid ); 407 childaccountid = transaction->getAccountID ( transactionid );
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
420 // update the accountid ( which is the parent ) and update the child account 423 // update the accountid ( which is the parent ) and update the child account
421 // balance. Get its accountid from the transactionid 424 // balance. Get its accountid from the transactionid
422 account->updateAccountBalance ( accountid ); // will update either a parent or child 425 account->updateAccountBalance ( accountid ); // will update either a parent or child
423 if ( account->getParentAccountID ( accountid ) != -1 ) // update its parent if there is one 426 if ( account->getParentAccountID ( accountid ) != -1 ) // update its parent if there is one
424 account->changeParentAccountBalance ( account->getParentAccountID ( accountid ) ); 427 account->changeParentAccountBalance ( account->getParentAccountID ( accountid ) );
425 if ( childaccountid != -1 ) // we've set childaccountid 428 if ( childaccountid != -1 ) // we've set childaccountid
@@ -431,26 +434,27 @@ void TransactionDisplay::deleteTransaction ()
431 else // takes care of deleting transfers 434 else // takes care of deleting transfers
432 { 435 {
433 // get the accountids before we delete the transfer 436 // get the accountids before we delete the transfer
434 int fromaccountid = transfer->getFromAccountID ( transactionid ); 437 int fromaccountid = transfer->getFromAccountID ( transactionid );
435 int toaccountid = transfer->getToAccountID ( transactionid ); 438 int toaccountid = transfer->getToAccountID ( transactionid );
436 439
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 );
451 if ( account->getParentAccountID ( fromaccountid ) != -1 ) 455 if ( account->getParentAccountID ( fromaccountid ) != -1 )
452 account->changeParentAccountBalance ( account->getParentAccountID ( fromaccountid ) ); 456 account->changeParentAccountBalance ( account->getParentAccountID ( fromaccountid ) );
453 457
454 // for the to account 458 // for the to account
455 account->updateAccountBalance ( toaccountid ); 459 account->updateAccountBalance ( toaccountid );
456 if ( account->getParentAccountID ( toaccountid ) != -1 ) 460 if ( account->getParentAccountID ( toaccountid ) != -1 )
@@ -483,26 +487,27 @@ void TransactionDisplay::toggleTransaction ()
483 } 487 }
484 else 488 else
485 { 489 {
486 if ( transfer->getCleared ( transactionid ) == 0 ) 490 if ( transfer->getCleared ( transactionid ) == 0 )
487 transfer->setCleared ( transactionid, 1 ); 491 transfer->setCleared ( transactionid, 1 );
488 else 492 else
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 ()
503 { 508 {
504 QString accountbalance = account->getAccountBalance ( accountid ); 509 QString accountbalance = account->getAccountBalance ( accountid );
505 balance->setText ( accountbalance ); 510 balance->setText ( accountbalance );
506 } 511 }
507 512
508void TransactionDisplay::setChildren ( bool c ) 513void TransactionDisplay::setChildren ( bool c )
@@ -542,25 +547,28 @@ void TransactionDisplay::saveColumnSize ( int column, int oldsize, int newsize )
542 preferences->changeColumnPreference ( column + 3, newsize ); 547 preferences->changeColumnPreference ( column + 3, newsize );
543 else if ( listview->columns() == 5 && column != 4 ) 548 else if ( listview->columns() == 5 && column != 4 )
544 preferences->changeColumnPreference ( column + 6, newsize ); 549 preferences->changeColumnPreference ( column + 6, newsize );
545 else 550 else
546 preferences->changeColumnPreference ( 9, newsize ); 551 preferences->changeColumnPreference ( 9, newsize );
547 } 552 }
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 {
561 int counter; 569 int counter;
562 int columns = listview->columns(); 570 int columns = listview->columns();
563 for ( counter = 0; counter <= columns; counter++ ) 571 for ( counter = 0; counter <= columns; counter++ )
564 if ( listview->header()->label ( counter ).length() == 0 ) 572 if ( listview->header()->label ( counter ).length() == 0 )
565 return counter; 573 return counter;
566 } 574 }
@@ -575,12 +583,41 @@ void TransactionDisplay::showTransactionNotes ()
575 QDialog *description = new QDialog ( this, "description", TRUE ); 583 QDialog *description = new QDialog ( this, "description", TRUE );
576 description->setCaption ( "Notes" ); 584 description->setCaption ( "Notes" );
577 QMultiLineEdit *notes = new QMultiLineEdit ( description ); 585 QMultiLineEdit *notes = new QMultiLineEdit ( description );
578 notes->setFixedSize ( ( int ) (this->width() * 0.75 ), ( int ) ( this->height() * 0.5 ) ); 586 notes->setFixedSize ( ( int ) (this->width() * 0.75 ), ( int ) ( this->height() * 0.5 ) );
579 notes->setWrapColumnOrWidth ( ( int ) (this->width() * 0.75 ) ); 587 notes->setWrapColumnOrWidth ( ( int ) (this->width() * 0.75 ) );
580 notes->setWordWrap ( QMultiLineEdit::WidgetWidth ); 588 notes->setWordWrap ( QMultiLineEdit::WidgetWidth );
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 }