Diffstat (limited to 'noncore/apps/checkbook/checkbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/checkbook/checkbook.cpp | 91 |
1 files changed, 75 insertions, 16 deletions
diff --git a/noncore/apps/checkbook/checkbook.cpp b/noncore/apps/checkbook/checkbook.cpp index c53e889..a42c824 100644 --- a/noncore/apps/checkbook/checkbook.cpp +++ b/noncore/apps/checkbook/checkbook.cpp | |||
@@ -51,9 +51,11 @@ | |||
51 | #include <qwhatsthis.h> | 51 | #include <qwhatsthis.h> |
52 | #include <qpopupmenu.h> | ||
52 | 53 | ||
53 | #define COL_ID 0 | 54 | #define COL_ID 0 |
54 | #define COL_NUM 1 | 55 | #define COL_SORTDATE 1 |
55 | #define COL_DATE 2 | 56 | #define COL_NUM 2 |
56 | #define COL_DESC 3 | 57 | #define COL_DATE 3 |
57 | #define COL_AMOUNT 4 | 58 | #define COL_DESC 4 |
58 | #define COL_BAL 5 | 59 | #define COL_AMOUNT 5 |
60 | #define COL_BAL 6 | ||
59 | 61 | ||
@@ -226,2 +228,5 @@ QWidget *Checkbook::initTransactions() | |||
226 | tranTable->setColumnWidth( COL_ID, 0); | 228 | tranTable->setColumnWidth( COL_ID, 0); |
229 | tranTable->addColumn( tr( "SortDate" ) ); | ||
230 | tranTable->setColumnWidthMode( COL_SORTDATE, QListView::Manual ); | ||
231 | tranTable->setColumnWidth( COL_SORTDATE, 0); | ||
227 | tranTable->addColumn( tr( "Num" ) ); | 232 | tranTable->addColumn( tr( "Num" ) ); |
@@ -239,3 +244,5 @@ QWidget *Checkbook::initTransactions() | |||
239 | connect( tranTable, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), | 244 | connect( tranTable, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), |
240 | this, SLOT( slotEditTran() ) ); | 245 | this, SLOT( slotMenuTran(QListViewItem *, const QPoint &) ) ); |
246 | connect( tranTable, SIGNAL( doubleClicked( QListViewItem * ) ), | ||
247 | this, SLOT( slotEditTran() ) ); | ||
241 | _sortCol=COL_ID; | 248 | _sortCol=COL_ID; |
@@ -338,3 +345,3 @@ void Checkbook::loadCheckbook() | |||
338 | stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); | 345 | stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); |
339 | ( void ) new CBListItem( tran, tranTable, tran->getIdStr(), tran->number(), tran->datestr(), tran->desc(), stramount ); | 346 | ( void ) new CBListItem( tran, tranTable, tran->getIdStr(), tran->datestr(false), tran->number(), tran->datestr(true), tran->desc(), stramount ); |
340 | } | 347 | } |
@@ -360,2 +367,3 @@ void Checkbook::loadCheckbook() | |||
360 | 367 | ||
368 | |||
361 | // --- adjustBalance ---------------------------------------------------------- | 369 | // --- adjustBalance ---------------------------------------------------------- |
@@ -398,2 +406,3 @@ void Checkbook::accept() | |||
398 | 406 | ||
407 | // --- slotPasswordClicked ---------------------------------------------------- | ||
399 | void Checkbook::slotPasswordClicked() | 408 | void Checkbook::slotPasswordClicked() |
@@ -466,2 +475,3 @@ void Checkbook::slotStartingBalanceChanged( const QString &newbalance ) | |||
466 | 475 | ||
476 | // --- slotNewTran ------------------------------------------------------------ | ||
467 | void Checkbook::slotNewTran() | 477 | void Checkbook::slotNewTran() |
@@ -472,3 +482,3 @@ void Checkbook::slotNewTran() | |||
472 | 482 | ||
473 | Transaction *currtran = new Transaction( this, info->name(), | 483 | Transaction *currtran = new Transaction( this, true, info->name(), |
474 | traninfo, | 484 | traninfo, |
@@ -486,4 +496,4 @@ void Checkbook::slotNewTran() | |||
486 | stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); | 496 | stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); |
487 | ( void ) new CBListItem( traninfo, tranTable, traninfo->getIdStr(), | 497 | ( void ) new CBListItem( traninfo, tranTable, traninfo->getIdStr(), traninfo->datestr(false), |
488 | traninfo->number(), traninfo->datestr(), traninfo->desc(), | 498 | traninfo->number(), traninfo->datestr(true), traninfo->desc(), |
489 | stramount ); | 499 | stramount ); |
@@ -494,2 +504,10 @@ void Checkbook::slotNewTran() | |||
494 | _dLastNew = traninfo->date(); | 504 | _dLastNew = traninfo->date(); |
505 | |||
506 | // save description in list of payees, if not in there | ||
507 | QStringList *pLst=&_pCfg->getPayees(); | ||
508 | if( _pCfg->getSavePayees() && pLst->contains(traninfo->desc())==0 ) { | ||
509 | pLst->append( traninfo->desc() ); | ||
510 | pLst->sort(); | ||
511 | _pCfg->setDirty(true); | ||
512 | } | ||
495 | } | 513 | } |
@@ -501,2 +519,4 @@ void Checkbook::slotNewTran() | |||
501 | 519 | ||
520 | |||
521 | // --- slotEditTran ----------------------------------------------------------- | ||
502 | void Checkbook::slotEditTran() | 522 | void Checkbook::slotEditTran() |
@@ -506,6 +526,6 @@ void Checkbook::slotEditTran() | |||
506 | return; | 526 | return; |
507 | 527 | ||
508 | TranInfo *traninfo=info->findTransaction( curritem->text(COL_ID) ); | 528 | TranInfo *traninfo=info->findTransaction( curritem->text(COL_ID) ); |
509 | 529 | ||
510 | Transaction *currtran = new Transaction( this, info->name(), | 530 | Transaction *currtran = new Transaction( this, false, info->name(), |
511 | traninfo, | 531 | traninfo, |
@@ -516,3 +536,4 @@ void Checkbook::slotEditTran() | |||
516 | curritem->setText( COL_NUM, traninfo->number() ); | 536 | curritem->setText( COL_NUM, traninfo->number() ); |
517 | curritem->setText( COL_DATE, traninfo->datestr() ); | 537 | curritem->setText( COL_SORTDATE, traninfo->datestr(false) ); |
538 | curritem->setText( COL_DATE, traninfo->datestr(true) ); | ||
518 | curritem->setText( COL_DESC, traninfo->desc() ); | 539 | curritem->setText( COL_DESC, traninfo->desc() ); |
@@ -529,2 +550,10 @@ void Checkbook::slotEditTran() | |||
529 | adjustBalance(); | 550 | adjustBalance(); |
551 | |||
552 | // save description in list of payees, if not in there | ||
553 | QStringList *pLst=&_pCfg->getPayees(); | ||
554 | if( _pCfg->getSavePayees() && pLst->contains(traninfo->desc())==0 ) { | ||
555 | pLst->append( traninfo->desc() ); | ||
556 | pLst->sort(); | ||
557 | _pCfg->setDirty(true); | ||
558 | } | ||
530 | } | 559 | } |
@@ -534,2 +563,30 @@ void Checkbook::slotEditTran() | |||
534 | 563 | ||
564 | // --- slotMenuTran ----------------------------------------------------------- | ||
565 | void Checkbook::slotMenuTran(QListViewItem *item, const QPoint &pnt) | ||
566 | { | ||
567 | // active item? | ||
568 | if( !item ) | ||
569 | return; | ||
570 | |||
571 | // Display menu | ||
572 | QPopupMenu m; | ||
573 | m.insertItem( QWidget::tr( "Edit" ), 1 ); | ||
574 | m.insertItem( QWidget::tr( "New" ), 2 ); | ||
575 | m.insertItem( QWidget::tr( "Delete" ), 3 ); | ||
576 | int r = m.exec( pnt ); | ||
577 | switch(r) { | ||
578 | case 1: | ||
579 | slotEditTran(); | ||
580 | break; | ||
581 | case 2: | ||
582 | slotNewTran(); | ||
583 | break; | ||
584 | case 3: | ||
585 | slotDeleteTran(); | ||
586 | break; | ||
587 | } | ||
588 | } | ||
589 | |||
590 | |||
591 | // --- slotDeleteTran --------------------------------------------------------- | ||
535 | void Checkbook::slotDeleteTran() | 592 | void Checkbook::slotDeleteTran() |
@@ -593,3 +650,3 @@ void Checkbook::drawBalanceChart() | |||
593 | { | 650 | { |
594 | label = tran->datestr(); | 651 | label = tran->datestr(true); |
595 | } | 652 | } |
@@ -668,2 +725,3 @@ void CBListItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int | |||
668 | 725 | ||
726 | // --- CBListItem::isAltBackground -------------------------------------------- | ||
669 | bool CBListItem::isAltBackground() | 727 | bool CBListItem::isAltBackground() |
@@ -725,3 +783,3 @@ void Checkbook::slotSortChanged( const QString &selc ) | |||
725 | } else if( selc==tr("Date") ) { | 783 | } else if( selc==tr("Date") ) { |
726 | _sortCol=COL_DATE; | 784 | _sortCol=COL_SORTDATE; |
727 | } | 785 | } |
@@ -730 +788,2 @@ void Checkbook::slotSortChanged( const QString &selc ) | |||
730 | } | 788 | } |
789 | |||