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 | |||
@@ -46,48 +46,49 @@ TransactionDisplay::TransactionDisplay ( QWidget* parent ) : QWidget ( parent ) | |||
46 | toggletransaction = new QPushButton ( firstline ); | 46 | toggletransaction = new QPushButton ( firstline ); |
47 | toggletransaction->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/redo.png") ); | 47 | toggletransaction->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/redo.png") ); |
48 | connect ( toggletransaction, SIGNAL ( released () ), this, SLOT ( checkListViewToggle () ) ); | 48 | connect ( toggletransaction, SIGNAL ( released () ), this, SLOT ( checkListViewToggle () ) ); |
49 | 49 | ||
50 | viewtransactionnotes = new QPushButton ( firstline ); | 50 | viewtransactionnotes = new QPushButton ( firstline ); |
51 | viewtransactionnotes->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/info.png") ); | 51 | viewtransactionnotes->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/info.png") ); |
52 | connect ( viewtransactionnotes, SIGNAL ( released () ), this, SLOT ( showTransactionNotes () ) ); | 52 | connect ( viewtransactionnotes, SIGNAL ( released () ), this, SLOT ( showTransactionNotes () ) ); |
53 | 53 | ||
54 | secondline = new QHBox ( this ); | 54 | secondline = new QHBox ( this ); |
55 | secondline->setSpacing ( 5 ); | 55 | secondline->setSpacing ( 5 ); |
56 | 56 | ||
57 | name = new QLabel ( secondline ); | 57 | name = new QLabel ( secondline ); |
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 | ||
77 | void TransactionDisplay::addTransaction () | 78 | void TransactionDisplay::addTransaction () |
78 | { | 79 | { |
79 | // create local variables | 80 | // create local variables |
80 | int cleared = -1; | 81 | int cleared = -1; |
81 | 82 | ||
82 | // create new transaction window | 83 | // create new transaction window |
83 | NewTransaction *newtransaction = new NewTransaction ( this ); | 84 | NewTransaction *newtransaction = new NewTransaction ( this ); |
84 | int width = this->size().width(); | 85 | int width = this->size().width(); |
85 | newtransaction->transactionname->setMaximumWidth ( ( int ) ( width * 0.45 ) ); | 86 | newtransaction->transactionname->setMaximumWidth ( ( int ) ( width * 0.45 ) ); |
86 | newtransaction->transactionname->setMinimumWidth ( ( int ) ( width * 0.35 ) ); | 87 | newtransaction->transactionname->setMinimumWidth ( ( int ) ( width * 0.35 ) ); |
87 | newtransaction->lineitembox->setMaximumWidth ( ( int ) ( width * 0.45 ) ); | 88 | newtransaction->lineitembox->setMaximumWidth ( ( int ) ( width * 0.45 ) ); |
88 | newtransaction->transactiondatebox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); | 89 | newtransaction->transactiondatebox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); |
89 | newtransaction->transactionamountbox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); | 90 | newtransaction->transactionamountbox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); |
90 | newtransaction->transactionnumber->setMaximumWidth ( ( int ) ( width * 0.25 ) ); | 91 | newtransaction->transactionnumber->setMaximumWidth ( ( int ) ( width * 0.25 ) ); |
91 | 92 | ||
92 | // enter today's date in the date box as defaul | 93 | // enter today's date in the date box as defaul |
93 | QDate today = QDate::currentDate (); | 94 | QDate today = QDate::currentDate (); |
@@ -112,49 +113,49 @@ void TransactionDisplay::addTransaction () | |||
112 | amount = amount * -1; | 113 | amount = amount * -1; |
113 | 114 | ||
114 | // add the transaction name to the memory items | 115 | // add the transaction name to the memory items |
115 | memory->addMemoryItem ( newtransaction->transactionname->currentText() ); | 116 | memory->addMemoryItem ( newtransaction->transactionname->currentText() ); |
116 | 117 | ||
117 | // add the transaction | 118 | // add the transaction |
118 | if ( newtransaction->getDateEdited () == TRUE ) | 119 | if ( newtransaction->getDateEdited () == TRUE ) |
119 | transaction->addTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), accountid, account->getParentAccountID ( accountid ), | 120 | 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(), | 121 | newtransaction->transactionnumber->text().toInt(), newtransaction->getDay(), newtransaction->getMonth(), newtransaction->getYear(), amount, cleared, newtransaction->getCurrentBudget(), |
121 | newtransaction->getCurrentLineItem() ); | 122 | newtransaction->getCurrentLineItem() ); |
122 | else | 123 | else |
123 | transaction->addTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), accountid, account->getParentAccountID ( accountid ), | 124 | 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() ); | 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 | ||
149 | void TransactionDisplay::checkListViewEdit () | 150 | void TransactionDisplay::checkListViewEdit () |
150 | { | 151 | { |
151 | if ( listview->selectedItem() == 0 ) | 152 | if ( listview->selectedItem() == 0 ) |
152 | QMessageBox::warning ( this, "QashMoney", "Please select a transaction\nto edit."); | 153 | QMessageBox::warning ( this, "QashMoney", "Please select a transaction\nto edit."); |
153 | else if ( listview->currentItem()->text ( getIDColumn() ).toInt() < 0 ) | 154 | else if ( listview->currentItem()->text ( getIDColumn() ).toInt() < 0 ) |
154 | editTransfer (); | 155 | editTransfer (); |
155 | else | 156 | else |
156 | editTransaction(); | 157 | editTransaction(); |
157 | } | 158 | } |
158 | 159 | ||
159 | void TransactionDisplay::showCalculator () | 160 | void TransactionDisplay::showCalculator () |
160 | { | 161 | { |
@@ -351,125 +352,125 @@ void TransactionDisplay::editTransaction () | |||
351 | // add the transaction name to the memory items | 352 | // add the transaction name to the memory items |
352 | memory->addMemoryItem ( newtransaction->transactionname->currentText() ); | 353 | memory->addMemoryItem ( newtransaction->transactionname->currentText() ); |
353 | 354 | ||
354 | // update the transaction | 355 | // update the transaction |
355 | transaction->updateTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), newtransaction->transactionnumber->text().toInt(), | 356 | transaction->updateTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), newtransaction->transactionnumber->text().toInt(), |
356 | newtransaction->getDay(), newtransaction->getMonth(), newtransaction->getYear(), | 357 | newtransaction->getDay(), newtransaction->getMonth(), newtransaction->getYear(), |
357 | amount, cleared, newtransaction->getCurrentBudget(), newtransaction->getCurrentLineItem(), transactionid ); | 358 | amount, cleared, newtransaction->getCurrentBudget(), newtransaction->getCurrentLineItem(), transactionid ); |
358 | 359 | ||
359 | updateAndDisplay ( transaction->getAccountID ( transactionid ) ); | 360 | updateAndDisplay ( transaction->getAccountID ( transactionid ) ); |
360 | } | 361 | } |
361 | } | 362 | } |
362 | 363 | ||
363 | void TransactionDisplay::updateAndDisplay ( int id ) | 364 | void 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 | ||
387 | void TransactionDisplay::checkListViewDelete () | 388 | void TransactionDisplay::checkListViewDelete () |
388 | { | 389 | { |
389 | if ( listview->selectedItem() == 0 ) | 390 | if ( listview->selectedItem() == 0 ) |
390 | QMessageBox::warning ( this, "QashMoney", "Please select a transaction to\ndelete."); | 391 | QMessageBox::warning ( this, "QashMoney", "Please select a transaction to\ndelete."); |
391 | else | 392 | else |
392 | deleteTransaction (); | 393 | deleteTransaction (); |
393 | } | 394 | } |
394 | 395 | ||
395 | void TransactionDisplay::deleteTransaction () | 396 | void TransactionDisplay::deleteTransaction () |
396 | { | 397 | { |
397 | int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt(); | 398 | int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt(); |
398 | 399 | ||
399 | if ( transactionid > 0 ) // takes care of deleting transactions | 400 | if ( transactionid > 0 ) // takes care of deleting transactions |
400 | { | 401 | { |
401 | // check if we are viewing child transactions through a parent | 402 | // check if we are viewing child transactions through a parent |
402 | // in that case we will have to update balances for the parent | 403 | // in that case we will have to update balances for the parent |
403 | // which is represented by accountid and the child account | 404 | // which is represented by accountid and the child account |
404 | // which will be represented by childaccountid | 405 | // which will be represented by childaccountid |
405 | int childaccountid = -1; | 406 | int childaccountid = -1; |
406 | if ( listview->columns() == 5 ) | 407 | if ( listview->columns() == 5 ) |
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 |
432 | redisplayAccountBalance (); | 433 | redisplayAccountBalance (); |
433 | } | 434 | } |
434 | else // takes care of deleting transfers | 435 | else // takes care of deleting transfers |
435 | { | 436 | { |
436 | // get the accountids before we delete the transfer | 437 | // get the accountids before we delete the transfer |
437 | int fromaccountid = transfer->getFromAccountID ( transactionid ); | 438 | int fromaccountid = transfer->getFromAccountID ( transactionid ); |
438 | int toaccountid = transfer->getToAccountID ( transactionid ); | 439 | int toaccountid = transfer->getToAccountID ( transactionid ); |
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 |
464 | redisplayAccountBalance (); | 465 | redisplayAccountBalance (); |
465 | } | 466 | } |
466 | } | 467 | } |
467 | 468 | ||
468 | void TransactionDisplay::checkListViewToggle () | 469 | void TransactionDisplay::checkListViewToggle () |
469 | { | 470 | { |
470 | if ( listview->selectedItem() == 0 ) | 471 | if ( listview->selectedItem() == 0 ) |
471 | QMessageBox::warning ( this, "QashMoney", "Please select a transaction to\nclear or reset."); | 472 | QMessageBox::warning ( this, "QashMoney", "Please select a transaction to\nclear or reset."); |
472 | else | 473 | else |
473 | toggleTransaction (); | 474 | toggleTransaction (); |
474 | } | 475 | } |
475 | 476 | ||
@@ -480,49 +481,49 @@ void TransactionDisplay::toggleTransaction () | |||
480 | 481 | ||
481 | if ( transactionid > 0 ) // if this is a transaction | 482 | if ( transactionid > 0 ) // if this is a transaction |
482 | { | 483 | { |
483 | if ( transaction->getCleared ( transactionid ) == 0 ) | 484 | if ( transaction->getCleared ( transactionid ) == 0 ) |
484 | transaction->setCleared ( transactionid, 1 ); | 485 | transaction->setCleared ( transactionid, 1 ); |
485 | else | 486 | else |
486 | transaction->setCleared ( transactionid, 0 ); | 487 | transaction->setCleared ( transactionid, 0 ); |
487 | } | 488 | } |
488 | else | 489 | else |
489 | { | 490 | { |
490 | if ( transfer->getCleared ( transactionid ) == 0 ) | 491 | if ( transfer->getCleared ( transactionid ) == 0 ) |
491 | transfer->setCleared ( transactionid, 1 ); | 492 | transfer->setCleared ( transactionid, 1 ); |
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 | ||
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 | ||
513 | void TransactionDisplay::setChildren ( bool c ) | 514 | void TransactionDisplay::setChildren ( bool c ) |
514 | { | 515 | { |
515 | children = c; | 516 | children = c; |
516 | } | 517 | } |
517 | 518 | ||
518 | void TransactionDisplay::setAccountID ( int id ) | 519 | void TransactionDisplay::setAccountID ( int id ) |
519 | { | 520 | { |
520 | accountid = id; | 521 | accountid = id; |
521 | } | 522 | } |
522 | 523 | ||
523 | ColorListItem::ColorListItem ( QListView *parent ) : QListViewItem ( parent ) | 524 | ColorListItem::ColorListItem ( QListView *parent ) : QListViewItem ( parent ) |
524 | { | 525 | { |
525 | } | 526 | } |
526 | 527 | ||
527 | ColorListItem::ColorListItem ( QListView *parent, QString label1, QString label2, QString label3, QString label4 ) | 528 | ColorListItem::ColorListItem ( QListView *parent, QString label1, QString label2, QString label3, QString label4 ) |
528 | : QListViewItem ( parent, label1, label2, label3, label4 ) | 529 | : QListViewItem ( parent, label1, label2, label3, label4 ) |
@@ -530,59 +531,64 @@ ColorListItem::ColorListItem ( QListView *parent, QString label1, QString label2 | |||
530 | } | 531 | } |
531 | 532 | ||
532 | ColorListItem::ColorListItem ( QListView *parent, QString label1, QString label2, QString label3, QString label4, QString label5 ) | 533 | ColorListItem::ColorListItem ( QListView *parent, QString label1, QString label2, QString label3, QString label4, QString label5 ) |
533 | : QListViewItem ( parent, label1, label2, label3, label4, label5 ) | 534 | : QListViewItem ( parent, label1, label2, label3, label4, label5 ) |
534 | { | 535 | { |
535 | } | 536 | } |
536 | 537 | ||
537 | void ColorListItem::paintCell ( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ) | 538 | void ColorListItem::paintCell ( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ) |
538 | { | 539 | { |
539 | QColorGroup _cg ( cg ); | 540 | QColorGroup _cg ( cg ); |
540 | _cg.setColor ( QColorGroup::Text, Qt::red ); | 541 | _cg.setColor ( QColorGroup::Text, Qt::red ); |
541 | QListViewItem::paintCell ( p, _cg, column, width, alignment ); | 542 | QListViewItem::paintCell ( p, _cg, column, width, alignment ); |
542 | } | 543 | } |
543 | 544 | ||
544 | void TransactionDisplay::saveColumnSize ( int column, int oldsize, int newsize ) | 545 | void 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 | ||
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 ) |
573 | return counter; | 579 | return counter; |
574 | } | 580 | } |
575 | 581 | ||
576 | void TransactionDisplay::showTransactionNotes () | 582 | void TransactionDisplay::showTransactionNotes () |
577 | { | 583 | { |
578 | if ( listview->selectedItem() == 0 || listview->currentItem()->text ( getIDColumn() ).toInt() < 0 ) | 584 | if ( listview->selectedItem() == 0 || listview->currentItem()->text ( getIDColumn() ).toInt() < 0 ) |
579 | QMessageBox::warning ( this, "QashMoney", "Please select a valid\ntransaction to view notes."); | 585 | QMessageBox::warning ( this, "QashMoney", "Please select a valid\ntransaction to view notes."); |
580 | else | 586 | else |
581 | { | 587 | { |
582 | int transactionid = listview->selectedItem()->text ( getIDColumn() ).toInt (); | 588 | int transactionid = listview->selectedItem()->text ( getIDColumn() ).toInt (); |
583 | QDialog *description = new QDialog ( this, "description", TRUE ); | 589 | QDialog *description = new QDialog ( this, "description", TRUE ); |
584 | description->setCaption ( "Notes" ); | 590 | description->setCaption ( "Notes" ); |
585 | QMultiLineEdit *notes = new QMultiLineEdit ( description ); | 591 | QMultiLineEdit *notes = new QMultiLineEdit ( description ); |
586 | notes->setFixedSize ( ( int ) (this->width() * 0.75 ), ( int ) ( this->height() * 0.5 ) ); | 592 | notes->setFixedSize ( ( int ) (this->width() * 0.75 ), ( int ) ( this->height() * 0.5 ) ); |
587 | notes->setWrapColumnOrWidth ( ( int ) (this->width() * 0.75 ) ); | 593 | notes->setWrapColumnOrWidth ( ( int ) (this->width() * 0.75 ) ); |
588 | notes->setWordWrap ( QMultiLineEdit::WidgetWidth ); | 594 | notes->setWordWrap ( QMultiLineEdit::WidgetWidth ); |
@@ -598,26 +604,26 @@ void TransactionDisplay::setTransactionDisplayDate () | |||
598 | int limittype = preferences->getPreference ( 7 ); | 604 | int limittype = preferences->getPreference ( 7 ); |
599 | if ( limittype != 5 ) // set today's date if we are not showing all transactions | 605 | if ( limittype != 5 ) // set today's date if we are not showing all transactions |
600 | { | 606 | { |
601 | QDate today = QDate::currentDate (); | 607 | QDate today = QDate::currentDate (); |
602 | switch ( limittype ) // if we are not showing all transactions | 608 | switch ( limittype ) // if we are not showing all transactions |
603 | { | 609 | { |
604 | case 0: // viewing two weeks | 610 | case 0: // viewing two weeks |
605 | displaydate = today.addDays ( -14 ); | 611 | displaydate = today.addDays ( -14 ); |
606 | break; | 612 | break; |
607 | case 1: // viewing one month | 613 | case 1: // viewing one month |
608 | displaydate = today.addDays ( -30 ); | 614 | displaydate = today.addDays ( -30 ); |
609 | break; | 615 | break; |
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 | } |