00001 #include "transactiondisplay.h"
00002 #include "newtransaction.h"
00003 #include "account.h"
00004 #include "budget.h"
00005 #include "memory.h"
00006 #include "transfer.h"
00007 #include "calculator.h"
00008 #include "datepicker.h"
00009
00010 #include <qmessagebox.h>
00011 #include <qheader.h>
00012 #include <qmultilineedit.h>
00013
00014 extern Transaction *transaction;
00015 extern Budget *budget;
00016 extern Account *account;
00017 extern Preferences *preferences;
00018 extern Memory *memory;
00019 extern Transfer *transfer;
00020
00021 TransactionDisplay::TransactionDisplay ( QWidget* parent ) : QWidget ( parent )
00022 {
00023
00024 accountid = 0;
00025 children = TRUE;
00026
00027 firstline = new QHBox ( this );
00028 firstline->setSpacing ( 2 );
00029
00030 newtransaction = new QPushButton ( firstline );
00031 newtransaction->setPixmap ( QPixmap ("/opt/QtPalmtop/pics/new.png") );
00032 connect ( newtransaction, SIGNAL ( released() ), this, SLOT ( addTransaction() ) );
00033
00034 edittransaction = new QPushButton ( firstline );
00035 edittransaction->setPixmap( QPixmap ("/opt/QtPalmtop/pics/edit.png") );
00036 connect ( edittransaction, SIGNAL ( released() ), this, SLOT ( checkListViewEdit() ) );
00037
00038 deletetransaction = new QPushButton ( firstline );
00039 deletetransaction->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/delete.png") );
00040 connect ( deletetransaction, SIGNAL ( released() ), this, SLOT ( checkListViewDelete() ) );
00041
00042 toggletransaction = new QPushButton ( firstline );
00043 toggletransaction->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/redo.png") );
00044 connect ( toggletransaction, SIGNAL ( released() ), this, SLOT ( checkListViewToggle() ) );
00045
00046 viewtransactionnotes = new QPushButton ( firstline );
00047 viewtransactionnotes->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/info.png") );
00048 connect ( viewtransactionnotes, SIGNAL ( released() ), this, SLOT ( showTransactionNotes() ) );
00049
00050 secondline = new QHBox ( this );
00051 secondline->setSpacing ( 5 );
00052
00053 name = new QLabel ( secondline );
00054 balance = new QLabel ( secondline );
00055
00056 QLabel *limit = new QLabel ( "Limit", secondline );
00057 limitbox = new QLineEdit ( secondline );
00058 limitbox->setMinimumWidth ( ( int ) ( this->width() / 6 ) );
00059 connect ( limitbox, SIGNAL ( textChanged(const QString&) ), this, SLOT ( limitDisplay(const QString&) ) );
00060
00061 listview = new QListView ( this );
00062 listview->setAllColumnsShowFocus ( TRUE );
00063 listview->setShowSortIndicator ( TRUE );
00064 listview->header()->setTracking ( FALSE );
00065 connect ( listview->header(), SIGNAL ( sizeChange(int,int,int) ), this, SLOT ( saveColumnSize(int,int,int) ) );
00066 connect ( listview->header(), SIGNAL ( clicked(int) ), this, SLOT ( saveSortingPreference(int) ) );
00067
00068 layout = new QVBoxLayout ( this, 2, 2 );
00069 layout->addWidget ( firstline );
00070 layout->addWidget ( secondline );
00071 layout->addWidget ( listview );
00072 }
00073
00074 void TransactionDisplay::addTransaction ()
00075 {
00076
00077 int cleared = -1;
00078
00079
00080 NewTransaction *newtransaction = new NewTransaction ( this );
00081 int width = this->size().width();
00082 newtransaction->transactionname->setMaximumWidth ( ( int ) ( width * 0.45 ) );
00083 newtransaction->transactionname->setMinimumWidth ( ( int ) ( width * 0.35 ) );
00084 newtransaction->lineitembox->setMaximumWidth ( ( int ) ( width * 0.45 ) );
00085 newtransaction->transactiondatebox->setMaximumWidth ( ( int ) ( width * 0.4 ) );
00086 newtransaction->transactionamountbox->setMaximumWidth ( ( int ) ( width * 0.4 ) );
00087 newtransaction->transactionnumber->setMaximumWidth ( ( int ) ( width * 0.25 ) );
00088
00089
00090 QDate today = QDate::currentDate ();
00091 int defaultday = today.day();
00092 int defaultmonth = today.month();
00093 int defaultyear = today.year();
00094 newtransaction->transactiondate->setText ( preferences->getDate ( defaultyear, defaultmonth, defaultday ) );
00095
00096
00097 memory->displayMemoryItems ( newtransaction->transactionname );
00098 newtransaction->transactionname->insertItem ( "", 0 );
00099
00100 if ( newtransaction->exec () == QDialog::Accepted )
00101 {
00102 if ( newtransaction->clearedcheckbox->isChecked () == TRUE )
00103 cleared = 1;
00104 else
00105 cleared = 0;
00106
00107 float amount = newtransaction->transactionamount->text().toFloat();
00108 if ( newtransaction->depositbox->isChecked() == FALSE )
00109 amount = amount * -1;
00110
00111
00112 memory->addMemoryItem ( newtransaction->transactionname->currentText() );
00113
00114
00115 if ( newtransaction->getDateEdited () == TRUE )
00116 transaction->addTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), accountid, account->getParentAccountID ( accountid ),
00117 newtransaction->transactionnumber->text().toInt(), newtransaction->getDay(), newtransaction->getMonth(), newtransaction->getYear(), amount, cleared, newtransaction->getCurrentBudget(),
00118 newtransaction->getCurrentLineItem() );
00119 else
00120 transaction->addTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), accountid, account->getParentAccountID ( accountid ),
00121 newtransaction->transactionnumber->text().toInt(), defaultday, defaultmonth, defaultyear, amount, cleared, newtransaction->getCurrentBudget(), newtransaction->getCurrentLineItem() );
00122
00123
00124 listview->clear();
00125 QString displaytext = "%";
00126 displaytext.prepend ( limitbox->text() );
00127 setTransactionDisplayDate ();
00128 if ( transaction->getNumberOfTransactions() > 0 )
00129 transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate );
00130
00131
00132 if ( transfer->getNumberOfTransfers() > 0 )
00133 transfer->displayTransfers ( listview, accountid, children, displaydate );
00134
00135
00136
00137 account->updateAccountBalance ( accountid );
00138 if ( account->getParentAccountID ( accountid ) != -1 )
00139 account->changeParentAccountBalance ( account->getParentAccountID ( accountid ) );
00140
00141
00142 redisplayAccountBalance ();
00143 }
00144 }
00145
00146 void TransactionDisplay::checkListViewEdit ()
00147 {
00148 if ( listview->selectedItem() == 0 )
00149 QMessageBox::warning ( this, "QashMoney", "Please select a transaction\nto edit.");
00150 else if ( listview->currentItem()->text ( getIDColumn() ).toInt() < 0 )
00151 editTransfer ();
00152 else
00153 editTransaction();
00154 }
00155
00156 void TransactionDisplay::showCalculator ()
00157 {
00158 Calculator *calculator = new Calculator ( this );
00159 if ( calculator->exec () == QDialog::Accepted )
00160 amount->setText ( calculator->display->text() );
00161 }
00162
00163 void TransactionDisplay::showCalendar ()
00164 {
00165 QDate newDate = QDate::currentDate ();
00166 DatePicker *dp = new DatePicker ( newDate );
00167 if ( dp->exec () == QDialog::Accepted )
00168 {
00169 year = dp->getYear();
00170 month = dp->getMonth();
00171 day = dp->getDay();
00172 date->setText ( preferences->getDate ( year, month, day ) );
00173 }
00174 }
00175
00176 void TransactionDisplay::editTransfer ()
00177 {
00178 transferid = listview->currentItem()->text ( getIDColumn() ).toInt();
00179 fromaccount = transfer->getFromAccountID ( transferid );
00180 toaccount = transfer->getToAccountID ( transferid );
00181 year = transfer->getYear ( transferid );
00182 month = transfer->getMonth ( transferid );
00183 day = transfer->getDay ( transferid );
00184
00185 QDialog *editransfer = new QDialog ( this, "edittransfer", TRUE );
00186 editransfer->setCaption ( "Transfer" );
00187
00188 QStringList accountnames = account->getAccountNames();
00189 QStringList accountids = account->getAccountIDs();
00190
00191 QLabel *fromaccountlabel = new QLabel ( "From Account:", editransfer );
00192 QFont f = this->font();
00193 f.setWeight ( QFont::Bold );
00194 fromaccountlabel->setFont ( f );
00195
00196 QComboBox *fromaccountbox = new QComboBox ( editransfer );
00197 fromaccountbox->insertStringList ( accountnames );
00198 fromaccountbox->setCurrentItem ( accountids.findIndex ( QString::number ( fromaccount ) ) );
00199
00200 QLabel *toaccountlabel = new QLabel ( "To Account:", editransfer );
00201 toaccountlabel->setFont ( f );
00202
00203 QComboBox *toaccountbox = new QComboBox ( editransfer );
00204 toaccountbox->insertStringList ( accountnames );
00205 toaccountbox->setCurrentItem ( accountids.findIndex ( QString::number ( toaccount ) ) );
00206
00207 QLabel *datelabel = new QLabel ( "Date", editransfer );
00208 QHBox *datebox = new QHBox ( editransfer );
00209 datebox->setSpacing ( 2 );
00210 date = new QLineEdit ( datebox );
00211 date->setAlignment ( Qt::AlignRight );
00212 date->setDisabled ( TRUE );
00213 date->setText ( preferences->getDate ( year, month, day ) );
00214 QPushButton *datebutton = new QPushButton ( datebox );
00215 datebutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/date.png" ) );
00216 connect ( datebutton, SIGNAL ( released() ), this, SLOT ( showCalendar() ) );
00217
00218 QLabel *amounttlabel = new QLabel ( "Amount", editransfer );
00219
00220 QHBox *amountbox = new QHBox ( editransfer );
00221 amountbox->setSpacing ( 2 );
00222 amount = new QLineEdit ( amountbox );
00223 amount->setAlignment ( Qt::AlignRight );
00224 amount->setText ( transfer->getAmount ( transferid ) );
00225 QPushButton *calculatorbutton = new QPushButton( amountbox );
00226 calculatorbutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/kcalc.png" ) );
00227 connect ( calculatorbutton, SIGNAL ( released() ), this, SLOT ( showCalculator() ) );
00228
00229 QCheckBox *clearedcheckbox = new QCheckBox ( "Cleared", editransfer );
00230
00231 QBoxLayout *layout = new QVBoxLayout ( editransfer, 4, 2 );
00232 layout->addWidget ( fromaccountlabel, Qt::AlignLeft );
00233 layout->addWidget ( fromaccountbox, Qt::AlignLeft );
00234 layout->addWidget ( toaccountlabel, Qt::AlignLeft );
00235 layout->addWidget ( toaccountbox, Qt::AlignLeft );
00236 layout->addSpacing ( 5 );
00237 layout->addWidget ( datelabel, Qt::AlignLeft );
00238 layout->addWidget ( datebox, Qt::AlignLeft );
00239 layout->addWidget ( amounttlabel, Qt::AlignLeft );
00240 layout->addWidget ( amountbox, Qt::AlignLeft );
00241 layout->addWidget ( clearedcheckbox, Qt::AlignLeft );
00242
00243 if ( editransfer->exec() == QDialog::Accepted )
00244 {
00245
00246 fromaccount = ( accountids.operator[] ( fromaccountbox->currentItem() ) ).toInt();
00247
00248
00249 toaccount = ( accountids.operator[] ( toaccountbox->currentItem() ) ).toInt();
00250
00251
00252 int cleared = 0;
00253 if ( clearedcheckbox->isChecked() == TRUE )
00254 cleared = 1;
00255
00256
00257 transfer->updateTransfer ( fromaccount, account->getParentAccountID ( fromaccount ), toaccount, account->getParentAccountID ( toaccount ),
00258 day, month, year, amount->text().toFloat(), cleared, transferid );
00259
00260 account->updateAccountBalance ( fromaccount );
00261 if ( account->getParentAccountID ( fromaccount ) != -1 )
00262 account->changeParentAccountBalance ( account->getParentAccountID ( fromaccount ) );
00263
00264 updateAndDisplay ( toaccount );
00265 }
00266 }
00267
00268 void TransactionDisplay::editTransaction ()
00269 {
00270 int cleared;
00271
00272
00273 int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt();
00274 int budgetid = transaction->getBudgetID ( transactionid );
00275 int lineitemid = transaction->getLineItemID ( transactionid );
00276
00277
00278 NewTransaction *newtransaction = new NewTransaction ( this );
00279 int width = this->width();
00280 newtransaction->transactionname->setMaximumWidth ( ( int ) ( width * 0.45 ) );
00281 newtransaction->transactionname->setMinimumWidth ( ( int ) ( width * 0.35 ) );
00282 newtransaction->lineitembox->setMaximumWidth ( ( int ) ( width * 0.45 ) );
00283 newtransaction->transactiondatebox->setMaximumWidth ( ( int ) ( width * 0.4 ) );
00284 newtransaction->transactionamountbox->setMaximumWidth ( ( int ) ( width * 0.4 ) );
00285 newtransaction->transactionnumber->setMaximumWidth ( ( int ) ( width * 0.25 ) );
00286
00287
00288 newtransaction->year = transaction->getYear ( transactionid );
00289 newtransaction->month = transaction->getMonth ( transactionid );
00290 newtransaction->day = transaction->getDay ( transactionid );
00291 newtransaction->transactiondate->setText ( preferences->getDate ( newtransaction->year, newtransaction->month, newtransaction->day ) );
00292
00293
00294 newtransaction->setDescription ( transaction->getTransactionDescription ( transactionid ) );
00295
00296
00297 memory->displayMemoryItems ( newtransaction->transactionname );
00298
00299
00300 newtransaction->transactionname->setEditText ( transaction->getPayee ( transactionid ) );
00301
00302
00303 newtransaction->transactionnumber->setText ( transaction->getNumber ( transactionid ) );
00304
00305
00306 newtransaction->transactionamount->setText ( transaction->getAbsoluteAmount ( transactionid ) );
00307
00308
00309 if ( budgetid >= 1 )
00310 {
00311 newtransaction->budgetbox->setCurrentItem ( newtransaction->getBudgetIndex ( budgetid ) + 1 );
00312 if ( lineitemid >= 1 )
00313 {
00314 newtransaction->setLineItems ();
00315 newtransaction->lineitembox->setCurrentItem ( newtransaction->getLineItemIndex ( lineitemid ) );
00316 }
00317 else
00318 {
00319 newtransaction->lineitemlabel->setEnabled ( FALSE );
00320 newtransaction->lineitembox->setEnabled ( FALSE );
00321 }
00322 }
00323 else
00324 {
00325 newtransaction->lineitemlabel->setEnabled ( FALSE );
00326 newtransaction->lineitembox->setEnabled ( FALSE );
00327 }
00328
00329
00330 if ( transaction->getCleared ( transactionid ) == 1 )
00331 newtransaction->clearedcheckbox->setChecked ( TRUE );
00332
00333
00334 if ( transaction->getAmount ( transactionid ).toFloat() > 0 )
00335 newtransaction->depositbox->setChecked ( TRUE );
00336
00337 if ( newtransaction->exec () == QDialog::Accepted )
00338 {
00339 if ( newtransaction->clearedcheckbox->isChecked () == TRUE )
00340 cleared = 1;
00341 else
00342 cleared = 0;
00343
00344 float amount = newtransaction->transactionamount->text().toFloat();
00345 if ( newtransaction->depositbox->isChecked() == FALSE )
00346 amount = amount * -1;
00347
00348
00349 memory->addMemoryItem ( newtransaction->transactionname->currentText() );
00350
00351
00352 transaction->updateTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), newtransaction->transactionnumber->text().toInt(),
00353 newtransaction->getDay(), newtransaction->getMonth(), newtransaction->getYear(),
00354 amount, cleared, newtransaction->getCurrentBudget(), newtransaction->getCurrentLineItem(), transactionid );
00355
00356 updateAndDisplay ( transaction->getAccountID ( transactionid ) );
00357 }
00358 }
00359
00360 void TransactionDisplay::updateAndDisplay ( int id )
00361 {
00362
00363 listview->clear();
00364 QString displaytext = "%";
00365 displaytext.prepend ( limitbox->text() );
00366 setTransactionDisplayDate ();
00367 if ( transaction->getNumberOfTransactions() > 0 )
00368 transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate );
00369
00370
00371 if ( transfer->getNumberOfTransfers() > 0 )
00372 transfer->displayTransfers ( listview, accountid, children, displaydate );
00373
00374
00375
00376 account->updateAccountBalance ( id );
00377 if ( account->getParentAccountID ( id ) != -1 )
00378 account->changeParentAccountBalance ( account->getParentAccountID ( id ) );
00379
00380
00381 redisplayAccountBalance ();
00382 }
00383
00384 void TransactionDisplay::checkListViewDelete ()
00385 {
00386 if ( listview->selectedItem() == 0 )
00387 QMessageBox::warning ( this, "QashMoney", "Please select a transaction to\ndelete.");
00388 else
00389 deleteTransaction ();
00390 }
00391
00392 void TransactionDisplay::deleteTransaction ()
00393 {
00394 int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt();
00395
00396 if ( transactionid > 0 )
00397 {
00398
00399
00400
00401
00402 int childaccountid = -1;
00403 if ( listview->columns() == 5 )
00404 childaccountid = transaction->getAccountID ( transactionid );
00405
00406 transaction->deleteTransaction ( transactionid );
00407
00408 listview->clear();
00409 QString displaytext = "%";
00410 displaytext.prepend ( limitbox->text() );
00411 setTransactionDisplayDate ();
00412 if ( transaction->getNumberOfTransactions() > 0 )
00413 transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate );
00414
00415 if ( transfer->getNumberOfTransfers() > 0 )
00416 transfer->displayTransfers ( listview, accountid, children, displaydate );
00417
00418
00419
00420
00421
00422 account->updateAccountBalance ( accountid );
00423 if ( account->getParentAccountID ( accountid ) != -1 )
00424 account->changeParentAccountBalance ( account->getParentAccountID ( accountid ) );
00425 if ( childaccountid != -1 )
00426 account->updateAccountBalance ( childaccountid );
00427
00428
00429 redisplayAccountBalance ();
00430 }
00431 else
00432 {
00433
00434 int fromaccountid = transfer->getFromAccountID ( transactionid );
00435 int toaccountid = transfer->getToAccountID ( transactionid );
00436
00437
00438 transfer->deleteTransfer ( transactionid );
00439
00440 listview->clear();
00441 QString displaytext = "%";
00442 displaytext.prepend ( limitbox->text() );
00443 setTransactionDisplayDate ();
00444 if ( transaction->getNumberOfTransactions() > 0 )
00445 transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate );
00446
00447 if ( transfer->getNumberOfTransfers() > 0 )
00448 transfer->displayTransfers ( listview, accountid, children, displaydate );
00449
00450
00451 account->updateAccountBalance ( fromaccountid );
00452 if ( account->getParentAccountID ( fromaccountid ) != -1 )
00453 account->changeParentAccountBalance ( account->getParentAccountID ( fromaccountid ) );
00454
00455
00456 account->updateAccountBalance ( toaccountid );
00457 if ( account->getParentAccountID ( toaccountid ) != -1 )
00458 account->changeParentAccountBalance ( account->getParentAccountID ( toaccountid ) );
00459
00460
00461 redisplayAccountBalance ();
00462 }
00463 }
00464
00465 void TransactionDisplay::checkListViewToggle ()
00466 {
00467 if ( listview->selectedItem() == 0 )
00468 QMessageBox::warning ( this, "QashMoney", "Please select a transaction to\nclear or reset.");
00469 else
00470 toggleTransaction ();
00471 }
00472
00473 void TransactionDisplay::toggleTransaction ()
00474 {
00475
00476 int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt();
00477
00478 if ( transactionid > 0 )
00479 {
00480 if ( transaction->getCleared ( transactionid ) == 0 )
00481 transaction->setCleared ( transactionid, 1 );
00482 else
00483 transaction->setCleared ( transactionid, 0 );
00484 }
00485 else
00486 {
00487 if ( transfer->getCleared ( transactionid ) == 0 )
00488 transfer->setCleared ( transactionid, 1 );
00489 else
00490 transfer->setCleared ( transactionid, 0 );
00491 }
00492
00493 listview->clear();
00494 QString displaytext = "%";
00495 displaytext.prepend ( limitbox->text() );
00496 setTransactionDisplayDate ();
00497 if ( transaction->getNumberOfTransactions() > 0 )
00498 transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate );
00499
00500 if ( transfer->getNumberOfTransfers() != 0 )
00501 transfer->displayTransfers ( listview, accountid, children, displaydate );
00502 }
00503
00504 void TransactionDisplay::redisplayAccountBalance ()
00505 {
00506 QString accountbalance = account->getAccountBalance ( accountid );
00507 balance->setText ( accountbalance );
00508 }
00509
00510 void TransactionDisplay::setChildren ( bool c )
00511 {
00512 children = c;
00513 }
00514
00515 void TransactionDisplay::setAccountID ( int id )
00516 {
00517 accountid = id;
00518 }
00519
00520 ColorListItem::ColorListItem ( QListView *parent ) : QListViewItem ( parent )
00521 {
00522 }
00523
00524 ColorListItem::ColorListItem ( QListView *parent, QString label1, QString label2, QString label3, QString label4 )
00525 : QListViewItem ( parent, label1, label2, label3, label4 )
00526 {
00527 }
00528
00529 ColorListItem::ColorListItem ( QListView *parent, QString label1, QString label2, QString label3, QString label4, QString label5 )
00530 : QListViewItem ( parent, label1, label2, label3, label4, label5 )
00531 {
00532 }
00533
00534 void ColorListItem::paintCell ( QPainter *p, const QColorGroup &cg, int column, int width, int alignment )
00535 {
00536 QColorGroup _cg ( cg );
00537 _cg.setColor ( QColorGroup::Text, Qt::red );
00538 QListViewItem::paintCell ( p, _cg, column, width, alignment );
00539 }
00540
00541 void TransactionDisplay::saveColumnSize ( int column, int oldsize, int newsize )
00542 {
00543 if ( listview->columns() == 4 )
00544 preferences->changeColumnPreference ( column + 3, newsize );
00545 else if ( listview->columns() == 5 && column != 4 )
00546 preferences->changeColumnPreference ( column + 6, newsize );
00547 else
00548 preferences->changeColumnPreference ( 9, newsize );
00549 }
00550
00551 void TransactionDisplay::saveSortingPreference ( int column )
00552 {
00553 preferences->changeSortingPreference ( 2, column );
00554 }
00555
00556 void TransactionDisplay::limitDisplay ( const QString &text )
00557 {
00558 listview->clear ();
00559 QString displaytext = "%";
00560 displaytext.prepend ( text );
00561 setTransactionDisplayDate ();
00562 if ( transaction->getNumberOfTransactions() > 0 )
00563 transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate );
00564
00565 if ( displaytext.length() == 1 || preferences->getPreference ( 6 ) == 1 )
00566 transfer->displayTransfers ( listview, accountid, children, displaydate );
00567 }
00568
00569 int TransactionDisplay::getIDColumn ()
00570 {
00571 int counter;
00572 int columns = listview->columns();
00573 for ( counter = 0; counter <= columns; counter++ )
00574 if ( listview->header()->label ( counter ).length() == 0 )
00575 return counter;
00576 }
00577
00578 void TransactionDisplay::showTransactionNotes ()
00579 {
00580 if ( listview->selectedItem() == 0 || listview->currentItem()->text ( getIDColumn() ).toInt() < 0 )
00581 QMessageBox::warning ( this, "QashMoney", "Please select a valid\ntransaction to view notes.");
00582 else
00583 {
00584 int transactionid = listview->selectedItem()->text ( getIDColumn() ).toInt ();
00585 QDialog *description = new QDialog ( this, "description", TRUE );
00586 description->setCaption ( "Notes" );
00587 QMultiLineEdit *notes = new QMultiLineEdit ( description );
00588 notes->setFixedSize ( ( int ) (this->width() * 0.75 ), ( int ) ( this->height() * 0.5 ) );
00589 notes->setWrapColumnOrWidth ( ( int ) (this->width() * 0.75 ) );
00590 notes->setWordWrap ( QMultiLineEdit::WidgetWidth );
00591 notes->setEnabled ( FALSE );
00592 notes->setText ( transaction->getTransactionDescription ( transactionid ) );
00593 description->show();
00594 }
00595 }
00596
00597 void TransactionDisplay::setTransactionDisplayDate ()
00598 {
00599
00600 int limittype = preferences->getPreference ( 7 );
00601 if ( limittype != 5 )
00602 {
00603 QDate today = QDate::currentDate ();
00604 switch ( limittype )
00605 {
00606 case 0:
00607 displaydate = today.addDays ( -14 );
00608 break;
00609 case 1:
00610 displaydate = today.addDays ( -30 );
00611 break;
00612 case 2:
00613 displaydate = today.addDays ( -90 );
00614 break;
00615 case 3:
00616 displaydate = today.addDays ( -180 );
00617 break;
00618 case 4:
00619 displaydate = today.addDays ( -365 );
00620 break;
00621 }
00622 }
00623 else
00624 displaydate = QDate ( 1900, 1, 1 );
00625 }