summaryrefslogtreecommitdiff
path: root/noncore/apps/qashmoney/transactiondisplay.cpp
authorallenforsythe <allenforsythe>2003-05-14 10:55:23 (UTC)
committer allenforsythe <allenforsythe>2003-05-14 10:55:23 (UTC)
commitb92483d866f263235bc9b52aa271241e1e55112e (patch) (unidiff)
treec729906a788de935c321b0188964a0602b66036d /noncore/apps/qashmoney/transactiondisplay.cpp
parent79e34e9dc4870885c58f80c29a723d0227f7b788 (diff)
downloadopie-b92483d866f263235bc9b52aa271241e1e55112e.zip
opie-b92483d866f263235bc9b52aa271241e1e55112e.tar.gz
opie-b92483d866f263235bc9b52aa271241e1e55112e.tar.bz2
Initial revision
Diffstat (limited to 'noncore/apps/qashmoney/transactiondisplay.cpp') (more/less context) (ignore whitespace changes)
-rwxr-xr-xnoncore/apps/qashmoney/transactiondisplay.cpp586
1 files changed, 586 insertions, 0 deletions
diff --git a/noncore/apps/qashmoney/transactiondisplay.cpp b/noncore/apps/qashmoney/transactiondisplay.cpp
new file mode 100755
index 0000000..6e5c4f6
--- a/dev/null
+++ b/noncore/apps/qashmoney/transactiondisplay.cpp
@@ -0,0 +1,586 @@
1#include "transactiondisplay.h"
2#include "newtransaction.h"
3#include "account.h"
4#include "budget.h"
5#include "memory.h"
6#include "transfer.h"
7#include "preferences.h"
8#include "calculator.h"
9#include "datepicker.h"
10
11#include <qdatetime.h>
12#include <qmessagebox.h>
13#include <qheader.h>
14#include <qmultilineedit.h>
15#include <iostream.h>
16#include <qdatetime.h>
17
18extern Transaction *transaction;
19extern Budget *budget;
20extern Account *account;
21extern Preferences *preferences;
22extern Memory *memory;
23extern Transfer *transfer;
24
25TransactionDisplay::TransactionDisplay ( QWidget* parent ) : QWidget ( parent )
26 {
27 // set transactiondisplay variables;
28 accountid = 0;
29 children = TRUE;
30
31 firstline = new QHBox ( this );
32 firstline->setSpacing ( 2 );
33
34 newtransaction = new QPushButton ( firstline );
35 newtransaction->setPixmap ( QPixmap ("/opt/QtPalmtop/pics/new.png") );
36 connect ( newtransaction, SIGNAL ( released () ), this, SLOT ( addTransaction () ) );
37
38 edittransaction = new QPushButton ( firstline );
39 edittransaction->setPixmap( QPixmap ("/opt/QtPalmtop/pics/edit.png") );
40 connect ( edittransaction, SIGNAL ( released () ), this, SLOT ( checkListViewEdit () ) );
41
42 deletetransaction = new QPushButton ( firstline );
43 deletetransaction->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/delete.png") );
44 connect ( deletetransaction, SIGNAL ( released () ), this, SLOT ( checkListViewDelete () ) );
45
46 toggletransaction = new QPushButton ( firstline );
47 toggletransaction->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/redo.png") );
48 connect ( toggletransaction, SIGNAL ( released () ), this, SLOT ( checkListViewToggle () ) );
49
50 viewtransactionnotes = new QPushButton ( firstline );
51 viewtransactionnotes->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/info.png") );
52 connect ( viewtransactionnotes, SIGNAL ( released () ), this, SLOT ( showTransactionNotes () ) );
53
54 secondline = new QHBox ( this );
55 secondline->setSpacing ( 5 );
56
57 name = new QLabel ( secondline );
58 balance = new QLabel ( secondline );
59
60 QLabel *limit = new QLabel ( "Limit", secondline );
61 limitbox = new QLineEdit ( secondline );
62 limitbox->setMinimumWidth ( ( int ) ( this->width() / 6 ) );
63 connect ( limitbox, SIGNAL ( textChanged ( const QString & ) ), this, SLOT ( limitDisplay ( const QString & ) ) );
64
65 listview = new QListView ( this );
66 listview->setAllColumnsShowFocus ( TRUE );
67 listview->setShowSortIndicator ( TRUE );
68 listview->header()->setTracking ( FALSE );
69 connect ( listview->header(), SIGNAL ( sizeChange ( int, int, int ) ), this, SLOT ( saveColumnSize ( int, int, int ) ) );
70
71 layout = new QVBoxLayout ( this, 2, 2 );
72 layout->addWidget ( firstline );
73 layout->addWidget ( secondline );
74 layout->addWidget ( listview );
75 }
76
77void TransactionDisplay::addTransaction ()
78 {
79 // create local variables
80 int cleared = -1;
81
82 // create new transaction window
83 NewTransaction *newtransaction = new NewTransaction ( this );
84 int width = this->size().width();
85 newtransaction->transactionname->setMaximumWidth ( ( int ) ( width * 0.45 ) );
86 newtransaction->transactionname->setMinimumWidth ( ( int ) ( width * 0.35 ) );
87 newtransaction->lineitembox->setMaximumWidth ( ( int ) ( width * 0.45 ) );
88 newtransaction->transactiondatebox->setMaximumWidth ( ( int ) ( width * 0.4 ) );
89 newtransaction->transactionamountbox->setMaximumWidth ( ( int ) ( width * 0.4 ) );
90 newtransaction->transactionnumber->setMaximumWidth ( ( int ) ( width * 0.25 ) );
91
92 // enter today's date in the date box as defaul
93 QDate today = QDate::currentDate ();
94 int defaultday = today.day();
95 int defaultmonth = today.month();
96 int defaultyear = today.year();
97 newtransaction->transactiondate->setText ( preferences->getDate ( defaultyear, defaultmonth, defaultday ) );
98
99 // add memory items to the transactionname combobox
100 memory->displayMemoryItems ( newtransaction->transactionname );
101 newtransaction->transactionname->insertItem ( "", 0 );
102
103 if ( newtransaction->exec () == QDialog::Accepted )
104 {
105 if ( newtransaction->clearedcheckbox->isChecked () == TRUE ) // set a parent id and type for a child transaction
106 cleared = 1;
107 else
108 cleared = 0;
109
110 float amount = newtransaction->transactionamount->text().toFloat();
111 if ( newtransaction->depositbox->isChecked() == FALSE )
112 amount = amount * -1;
113
114 // add the transaction name to the memory items
115 memory->addMemoryItem ( newtransaction->transactionname->currentText() );
116
117 // add the transaction
118 if ( newtransaction->getDateEdited () == TRUE )
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(),
121 newtransaction->getCurrentLineItem() );
122 else
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() );
125
126 // redisplay transactions
127 listview->clear();
128 QString displaytext = "%";
129 displaytext.prepend ( limitbox->text() );
130 if ( transaction->getNumberOfTransactions() > 0 )
131 transaction->displayTransactions ( listview, accountid, children, displaytext );
132
133 // redisplay transfers
134 if ( transfer->getNumberOfTransfers() > 0 )
135 transfer->displayTransfers ( listview, accountid, children );
136
137 // add the transaction amount to the account it's associated with
138 // and update its parent account balance if necessary
139 account->updateAccountBalance ( accountid );
140 if ( account->getParentAccountID ( accountid ) != -1 )
141 account->changeParentAccountBalance ( account->getParentAccountID ( accountid ) );
142
143 // format then reset the account balance
144 redisplayAccountBalance ();
145 }
146 }
147
148void TransactionDisplay::checkListViewEdit ()
149 {
150 if ( listview->selectedItem() == 0 )
151 QMessageBox::warning ( this, "QashMoney", "Please select a transaction\nto edit.");
152 else if ( listview->currentItem()->text ( getIDColumn() ).toInt() < 0 )
153 editTransfer ();
154 else
155 editTransaction();
156 }
157
158void TransactionDisplay::showCalculator ()
159 {
160 Calculator *calculator = new Calculator ( this );
161 if ( calculator->exec () == QDialog::Accepted )
162 amount->setText ( calculator->display->text() );
163 }
164
165void TransactionDisplay::showCalendar ()
166 {
167 QDate newDate = QDate::currentDate ();
168 DatePicker *dp = new DatePicker ( newDate );
169 if ( dp->exec () == QDialog::Accepted )
170 {
171 year = dp->getYear();
172 month = dp->getMonth();
173 day = dp->getDay();
174 date->setText ( preferences->getDate ( year, month, day ) );
175 }
176 }
177
178void TransactionDisplay::editTransfer ()
179 {
180 transferid = listview->currentItem()->text ( getIDColumn() ).toInt();
181 fromaccount = transfer->getFromAccountID ( transferid );
182 toaccount = transfer->getToAccountID ( transferid );
183 year = transfer->getYear ( transferid );
184 month = transfer->getMonth ( transferid );
185 day = transfer->getDay ( transferid );
186
187 QDialog *editransfer = new QDialog ( this, "edittransfer", TRUE );
188 editransfer->setCaption ( "Transfer" );
189
190 QStringList accountnames = account->getAccountNames();
191 QStringList accountids = account->getAccountIDs();
192
193 QLabel *fromaccountlabel = new QLabel ( "From Account:", editransfer );
194 QFont f = this->font();
195 f.setWeight ( QFont::Bold );
196 fromaccountlabel->setFont ( f );
197
198 QComboBox *fromaccountbox = new QComboBox ( editransfer );
199 fromaccountbox->insertStringList ( accountnames );
200 fromaccountbox->setCurrentItem ( accountids.findIndex ( QString::number ( fromaccount ) ) );
201
202 QLabel *toaccountlabel = new QLabel ( "To Account:", editransfer );
203 toaccountlabel->setFont ( f );
204
205 QComboBox *toaccountbox = new QComboBox ( editransfer );
206 toaccountbox->insertStringList ( accountnames );
207 toaccountbox->setCurrentItem ( accountids.findIndex ( QString::number ( toaccount ) ) );
208
209 QLabel *datelabel = new QLabel ( "Date", editransfer );
210 QHBox *datebox = new QHBox ( editransfer );
211 datebox->setSpacing ( 2 );
212 date = new QLineEdit ( datebox );
213 date->setAlignment ( Qt::AlignRight );
214 date->setDisabled ( TRUE );
215 date->setText ( preferences->getDate ( year, month, day ) );
216 QPushButton *datebutton = new QPushButton ( datebox );
217 datebutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/date.png" ) );
218 connect ( datebutton, SIGNAL ( released () ), this, SLOT ( showCalendar () ) );
219
220 QLabel *amounttlabel = new QLabel ( "Amount", editransfer );
221
222 QHBox *amountbox = new QHBox ( editransfer );
223 amountbox->setSpacing ( 2 );
224 amount = new QLineEdit ( amountbox );
225 amount->setAlignment ( Qt::AlignRight );
226 amount->setText ( transfer->getAmount ( transferid ) );
227 QPushButton *calculatorbutton = new QPushButton( amountbox );
228 calculatorbutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/kcalc.png" ) );
229 connect ( calculatorbutton, SIGNAL ( released() ), this, SLOT ( showCalculator() ) );
230
231 QCheckBox *clearedcheckbox = new QCheckBox ( "Cleared", editransfer );
232
233 QBoxLayout *layout = new QVBoxLayout ( editransfer, 4, 2 );
234 layout->addWidget ( fromaccountlabel, Qt::AlignLeft );
235 layout->addWidget ( fromaccountbox, Qt::AlignLeft );
236 layout->addWidget ( toaccountlabel, Qt::AlignLeft );
237 layout->addWidget ( toaccountbox, Qt::AlignLeft );
238 layout->addSpacing ( 5 );
239 layout->addWidget ( datelabel, Qt::AlignLeft );
240 layout->addWidget ( datebox, Qt::AlignLeft );
241 layout->addWidget ( amounttlabel, Qt::AlignLeft );
242 layout->addWidget ( amountbox, Qt::AlignLeft );
243 layout->addWidget ( clearedcheckbox, Qt::AlignLeft );
244
245 if ( editransfer->exec() == QDialog::Accepted )
246 {
247 //get fromaccount
248 fromaccount = ( accountids.operator[] ( fromaccountbox->currentItem() ) ).toInt();
249
250 //get to account
251 toaccount = ( accountids.operator[] ( toaccountbox->currentItem() ) ).toInt();
252
253 //set cleared flag
254 int cleared = 0;
255 if ( clearedcheckbox->isChecked() == TRUE )
256 cleared = 1;
257
258 //update transfer
259 transfer->updateTransfer ( fromaccount, account->getParentAccountID ( fromaccount ), toaccount, account->getParentAccountID ( toaccount ),
260 day, month, year, amount->text().toFloat(), cleared, transferid );
261
262 account->updateAccountBalance ( fromaccount );
263 if ( account->getParentAccountID ( fromaccount ) != -1 )
264 account->changeParentAccountBalance ( fromaccount );
265
266 updateAndDisplay ( toaccount );
267 }
268 }
269
270void TransactionDisplay::editTransaction ()
271 {
272 int cleared;
273
274 // set the transaction id and budgetid
275 int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt();
276 int budgetid = transaction->getBudgetID ( transactionid );
277 int lineitemid = transaction->getLineItemID ( transactionid );
278
279 // create edit transaction window
280 NewTransaction *newtransaction = new NewTransaction ( this );
281 int width = this->width();
282 newtransaction->transactionname->setMaximumWidth ( ( int ) ( width * 0.45 ) );
283 newtransaction->transactionname->setMinimumWidth ( ( int ) ( width * 0.35 ) );
284 newtransaction->lineitembox->setMaximumWidth ( ( int ) ( width * 0.45 ) );
285 newtransaction->transactiondatebox->setMaximumWidth ( ( int ) ( width * 0.4 ) );
286 newtransaction->transactionamountbox->setMaximumWidth ( ( int ) ( width * 0.4 ) );
287 newtransaction->transactionnumber->setMaximumWidth ( ( int ) ( width * 0.25 ) );
288
289 // enter the date in the date box
290 newtransaction->year = transaction->getYear ( transactionid );
291 newtransaction->month = transaction->getMonth ( transactionid );
292 newtransaction->day = transaction->getDay ( transactionid );
293 newtransaction->transactiondate->setText ( preferences->getDate ( newtransaction->year, newtransaction->month, newtransaction->day ) );
294
295 // set the description
296 newtransaction->setDescription ( transaction->getTransactionDescription ( transactionid ) );
297
298 // add memory items to the transactionname combobox
299 memory->displayMemoryItems ( newtransaction->transactionname );
300
301 // add correct transaction name
302 newtransaction->transactionname->setEditText ( transaction->getPayee ( transactionid ) );
303
304 // add transaction number
305 newtransaction->transactionnumber->setText ( transaction->getNumber ( transactionid ) );
306
307 // add transaction amount
308 newtransaction->transactionamount->setText ( transaction->getAbsoluteAmount ( transactionid ) );
309
310 // check for and set the correct budget
311 if ( budgetid >= 1 ) // only do it if this transaction has a budget and line item
312 {
313 newtransaction->budgetbox->setCurrentItem ( newtransaction->getBudgetIndex ( budgetid ) + 1 );
314 if ( lineitemid >= 1 )
315 {
316 newtransaction->setLineItems ();
317 newtransaction->lineitembox->setCurrentItem ( newtransaction->getLineItemIndex ( lineitemid ) );
318 }
319 else
320 {
321 newtransaction->lineitemlabel->setEnabled ( FALSE );
322 newtransaction->lineitembox->setEnabled ( FALSE );
323 }
324 }
325 else
326 {
327 newtransaction->lineitemlabel->setEnabled ( FALSE );
328 newtransaction->lineitembox->setEnabled ( FALSE );
329 }
330
331 // check cleared checkbox if necessary
332 if ( transaction->getCleared ( transactionid ) == 1 )
333 newtransaction->clearedcheckbox->setChecked ( TRUE );
334
335 // check deposit box if necessary
336 if ( transaction->getAmount ( transactionid ).toFloat() > 0 )
337 newtransaction->depositbox->setChecked ( TRUE );
338
339 if ( newtransaction->exec () == QDialog::Accepted )
340 {
341 if ( newtransaction->clearedcheckbox->isChecked () == TRUE )
342 cleared = 1;
343 else
344 cleared = 0;
345
346 float amount = newtransaction->transactionamount->text().toFloat();
347 if ( newtransaction->depositbox->isChecked() == FALSE )
348 amount = amount * -1;
349
350 // add the transaction name to the memory items
351 memory->addMemoryItem ( newtransaction->transactionname->currentText() );
352
353 // update the transaction
354 transaction->updateTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), newtransaction->transactionnumber->text().toInt(),
355 newtransaction->getDay(), newtransaction->getMonth(), newtransaction->getYear(),
356 amount, cleared, newtransaction->getCurrentBudget(), newtransaction->getCurrentLineItem(), transactionid );
357
358 updateAndDisplay ( transaction->getAccountID ( transactionid ) );
359 }
360 }
361
362void TransactionDisplay::updateAndDisplay ( int id )
363 {
364 // redisplay transactions
365 listview->clear();
366 QString displaytext = "%";
367 displaytext.prepend ( limitbox->text() );
368 if ( transaction->getNumberOfTransactions() > 0 )
369 transaction->displayTransactions ( listview, accountid, children, displaytext );
370
371 // redisplay transfers
372 if ( transfer->getNumberOfTransfers() > 0 )
373 transfer->displayTransfers ( listview, accountid, children );
374
375 // add the transaction amount to the account it's associated with
376 // and update its parent account balance if necessary
377 account->updateAccountBalance ( id );
378 if ( account->getParentAccountID ( id ) != -1 )
379 account->changeParentAccountBalance ( account->getParentAccountID ( id ) );
380
381 // format then reset the account balance
382 redisplayAccountBalance ();
383 }
384
385void TransactionDisplay::checkListViewDelete ()
386 {
387 if ( listview->selectedItem() == 0 )
388 QMessageBox::warning ( this, "QashMoney", "Please select a transaction to\ndelete.");
389 else
390 deleteTransaction ();
391 }
392
393void TransactionDisplay::deleteTransaction ()
394 {
395 int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt();
396
397 if ( transactionid > 0 ) // takes care of deleting transactions
398 {
399 // check if we are viewing child transactions through a parent
400 // in that case we will have to update balances for the parent
401 // which is represented by accountid and the child account
402 // which will be represented by childaccountid
403 int childaccountid = -1;
404 if ( listview->columns() == 5 )
405 childaccountid = transaction->getAccountID ( transactionid );
406
407 transaction->deleteTransaction ( transactionid );
408
409 listview->clear();
410 QString displaytext = "%";
411 displaytext.prepend ( limitbox->text() );
412 if ( transaction->getNumberOfTransactions() > 0 )
413 transaction->displayTransactions ( listview, accountid, children, displaytext );
414
415 if ( transfer->getNumberOfTransfers() > 0 )
416 transfer->displayTransfers ( listview, accountid, children );
417
418 // if we are viewing different child accounts through the parent account
419 // ie if there are five columns and the parentid is -1
420 // update the accountid ( which is the parent ) and update the child account
421 // balance. Get its accountid from the transactionid
422 account->updateAccountBalance ( accountid ); // will update either a parent or child
423 if ( account->getParentAccountID ( accountid ) != -1 ) // update its parent if there is one
424 account->changeParentAccountBalance ( account->getParentAccountID ( accountid ) );
425 if ( childaccountid != -1 ) // we've set childaccountid
426 account->updateAccountBalance ( childaccountid );
427
428 // format then reset the account balance
429 redisplayAccountBalance ();
430 }
431 else // takes care of deleting transfers
432 {
433 // get the accountids before we delete the transfer
434 int fromaccountid = transfer->getFromAccountID ( transactionid );
435 int toaccountid = transfer->getToAccountID ( transactionid );
436
437 // delete the transfer and redisplay transactions
438 transfer->deleteTransfer ( transactionid );
439
440 listview->clear();
441 QString displaytext = "%";
442 displaytext.prepend ( limitbox->text() );
443 if ( transaction->getNumberOfTransactions() > 0 )
444 transaction->displayTransactions ( listview, accountid, children, displaytext );
445
446 if ( transfer->getNumberOfTransfers() > 0 )
447 transfer->displayTransfers ( listview, accountid, children );
448
449 // for the from account
450 account->updateAccountBalance ( fromaccountid );
451 if ( account->getParentAccountID ( fromaccountid ) != -1 )
452 account->changeParentAccountBalance ( account->getParentAccountID ( fromaccountid ) );
453
454 // for the to account
455 account->updateAccountBalance ( toaccountid );
456 if ( account->getParentAccountID ( toaccountid ) != -1 )
457 account->changeParentAccountBalance ( account->getParentAccountID ( toaccountid ) );
458
459 // format then reset the account balance
460 redisplayAccountBalance ();
461 }
462 }
463
464void TransactionDisplay::checkListViewToggle ()
465 {
466 if ( listview->selectedItem() == 0 )
467 QMessageBox::warning ( this, "QashMoney", "Please select a transaction to\nclear or reset.");
468 else
469 toggleTransaction ();
470 }
471
472void TransactionDisplay::toggleTransaction ()
473 {
474 //get the transaction of the selected transaction to determine if its a transaction or transfer
475 int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt();
476
477 if ( transactionid > 0 ) // if this is a transaction
478 {
479 if ( transaction->getCleared ( transactionid ) == 0 )
480 transaction->setCleared ( transactionid, 1 );
481 else
482 transaction->setCleared ( transactionid, 0 );
483 }
484 else
485 {
486 if ( transfer->getCleared ( transactionid ) == 0 )
487 transfer->setCleared ( transactionid, 1 );
488 else
489 transfer->setCleared ( transactionid, 0 );
490 }
491
492 listview->clear();
493 QString displaytext = "%";
494 displaytext.prepend ( limitbox->text() );
495 if ( transaction->getNumberOfTransactions() > 0 )
496 transaction->displayTransactions ( listview, accountid, children, displaytext );
497
498 if ( transfer->getNumberOfTransfers() != 0 )
499 transfer->displayTransfers ( listview, accountid, children );
500 }
501
502void TransactionDisplay::redisplayAccountBalance ()
503 {
504 QString accountbalance = account->getAccountBalance ( accountid );
505 balance->setText ( accountbalance );
506 }
507
508void TransactionDisplay::setChildren ( bool c )
509 {
510 children = c;
511 }
512
513void TransactionDisplay::setAccountID ( int id )
514 {
515 accountid = id;
516 }
517
518ColorListItem::ColorListItem ( QListView *parent ) : QListViewItem ( parent )
519 {
520 }
521
522ColorListItem::ColorListItem ( QListView *parent, QString label1, QString label2, QString label3, QString label4 )
523 : QListViewItem ( parent, label1, label2, label3, label4 )
524 {
525 }
526
527ColorListItem::ColorListItem ( QListView *parent, QString label1, QString label2, QString label3, QString label4, QString label5 )
528 : QListViewItem ( parent, label1, label2, label3, label4, label5 )
529 {
530 }
531
532void ColorListItem::paintCell ( QPainter *p, const QColorGroup &cg, int column, int width, int alignment )
533 {
534 QColorGroup _cg ( cg );
535 _cg.setColor ( QColorGroup::Text, Qt::red );
536 QListViewItem::paintCell ( p, _cg, column, width, alignment );
537 }
538
539void TransactionDisplay::saveColumnSize ( int column, int oldsize, int newsize )
540 {
541 if ( listview->columns() == 4 )
542 preferences->changeColumnPreference ( column + 3, newsize );
543 else if ( listview->columns() == 5 && column != 4 )
544 preferences->changeColumnPreference ( column + 6, newsize );
545 else
546 preferences->changeColumnPreference ( 9, newsize );
547 }
548
549void TransactionDisplay::limitDisplay ( const QString &text )
550 {
551 listview->clear ();
552 QString displaytext = "%";
553 displaytext.prepend ( text );
554 transaction->displayTransactions ( listview, accountid, children, displaytext );
555 if ( displaytext.length() == 1 || preferences->getPreference ( 6 ) == 1 )
556 transfer->displayTransfers ( listview, accountid, children );
557 }
558
559int TransactionDisplay::getIDColumn ()
560 {
561 int counter;
562 int columns = listview->columns();
563 for ( counter = 0; counter <= columns; counter++ )
564 if ( listview->header()->label ( counter ).length() == 0 )
565 return counter;
566 }
567
568void TransactionDisplay::showTransactionNotes ()
569 {
570 if ( listview->selectedItem() == 0 || listview->currentItem()->text ( getIDColumn() ).toInt() < 0 )
571 QMessageBox::warning ( this, "QashMoney", "Please select a valid\ntransaction to view notes.");
572 else
573 {
574 int transactionid = listview->selectedItem()->text ( getIDColumn() ).toInt ();
575 QDialog *description = new QDialog ( this, "description", TRUE );
576 description->setCaption ( "Notes" );
577 QMultiLineEdit *notes = new QMultiLineEdit ( description );
578 notes->setFixedSize ( ( int ) (this->width() * 0.75 ), ( int ) ( this->height() * 0.5 ) );
579 notes->setWrapColumnOrWidth ( ( int ) (this->width() * 0.75 ) );
580 notes->setWordWrap ( QMultiLineEdit::WidgetWidth );
581 notes->setEnabled ( FALSE );
582 notes->setText ( transaction->getTransactionDescription ( transactionid ) );
583 description->show();
584 }
585 }
586