author | mickeyl <mickeyl> | 2003-10-30 13:18:08 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-10-30 13:18:08 (UTC) |
commit | 37414f207b147af4cf6778b323a0aa23127901bd (patch) (unidiff) | |
tree | b08c10043ab689b0a40425d268cd72226799b0cf /noncore/apps/checkbook/checkbook.cpp | |
parent | d53637f46cf217fc760d7aac58b4596843a73803 (diff) | |
download | opie-37414f207b147af4cf6778b323a0aa23127901bd.zip opie-37414f207b147af4cf6778b323a0aa23127901bd.tar.gz opie-37414f207b147af4cf6778b323a0aa23127901bd.tar.bz2 |
apply patch to HEAD
Diffstat (limited to 'noncore/apps/checkbook/checkbook.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/checkbook/checkbook.cpp | 85 |
1 files changed, 72 insertions, 13 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 | |||
@@ -49,13 +49,15 @@ | |||
49 | #include <qmultilineedit.h> | 49 | #include <qmultilineedit.h> |
50 | #include <qpushbutton.h> | 50 | #include <qpushbutton.h> |
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 | ||
60 | // --- Checkbook -------------------------------------------------------------- | 62 | // --- Checkbook -------------------------------------------------------------- |
61 | Checkbook::Checkbook( QWidget *parent, CBInfo *i, Cfg *cfg ) | 63 | Checkbook::Checkbook( QWidget *parent, CBInfo *i, Cfg *cfg ) |
@@ -224,6 +226,9 @@ QWidget *Checkbook::initTransactions() | |||
224 | tranTable->addColumn( tr( "Id" ) ); | 226 | tranTable->addColumn( tr( "Id" ) ); |
225 | tranTable->setColumnWidthMode( COL_ID, QListView::Manual ); | 227 | tranTable->setColumnWidthMode( COL_ID, QListView::Manual ); |
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" ) ); |
228 | tranTable->addColumn( tr( "Date" ) ); | 233 | tranTable->addColumn( tr( "Date" ) ); |
229 | //tranTable->addColumn( tr( "Cleared" ) ); | 234 | //tranTable->addColumn( tr( "Cleared" ) ); |
@@ -237,6 +242,8 @@ QWidget *Checkbook::initTransactions() | |||
237 | layout->addMultiCellWidget( tranTable, 1, 1, 0, 2 ); | 242 | layout->addMultiCellWidget( tranTable, 1, 1, 0, 2 ); |
238 | QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold ); | 243 | QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold ); |
239 | connect( tranTable, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), | 244 | connect( tranTable, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), |
245 | this, SLOT( slotMenuTran(QListViewItem *, const QPoint &) ) ); | ||
246 | connect( tranTable, SIGNAL( doubleClicked( QListViewItem * ) ), | ||
240 | this, SLOT( slotEditTran() ) ); | 247 | this, SLOT( slotEditTran() ) ); |
241 | _sortCol=COL_ID; | 248 | _sortCol=COL_ID; |
242 | 249 | ||
@@ -336,7 +343,7 @@ void Checkbook::loadCheckbook() | |||
336 | amount *= -1; | 343 | amount *= -1; |
337 | } | 344 | } |
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 | } |
341 | 348 | ||
342 | // set sort order | 349 | // set sort order |
@@ -358,6 +365,7 @@ void Checkbook::loadCheckbook() | |||
358 | adjustBalance(); | 365 | adjustBalance(); |
359 | } | 366 | } |
360 | 367 | ||
368 | |||
361 | // --- adjustBalance ---------------------------------------------------------- | 369 | // --- adjustBalance ---------------------------------------------------------- |
362 | void Checkbook::adjustBalance() | 370 | void Checkbook::adjustBalance() |
363 | { | 371 | { |
@@ -396,6 +404,7 @@ void Checkbook::accept() | |||
396 | QDialog::accept(); | 404 | QDialog::accept(); |
397 | } | 405 | } |
398 | 406 | ||
407 | // --- slotPasswordClicked ---------------------------------------------------- | ||
399 | void Checkbook::slotPasswordClicked() | 408 | void Checkbook::slotPasswordClicked() |
400 | { | 409 | { |
401 | if ( info->password().isNull() && passwordCB->isChecked() ) | 410 | if ( info->password().isNull() && passwordCB->isChecked() ) |
@@ -464,13 +473,14 @@ void Checkbook::slotStartingBalanceChanged( const QString &newbalance ) | |||
464 | } | 473 | } |
465 | 474 | ||
466 | 475 | ||
476 | // --- slotNewTran ------------------------------------------------------------ | ||
467 | void Checkbook::slotNewTran() | 477 | void Checkbook::slotNewTran() |
468 | { | 478 | { |
469 | TranInfo *traninfo = new TranInfo( info->getNextNumber() ); | 479 | TranInfo *traninfo = new TranInfo( info->getNextNumber() ); |
470 | if( !_dLastNew.isNull() ) | 480 | if( !_dLastNew.isNull() ) |
471 | traninfo->setDate(_dLastNew); | 481 | traninfo->setDate(_dLastNew); |
472 | 482 | ||
473 | Transaction *currtran = new Transaction( this, info->name(), | 483 | Transaction *currtran = new Transaction( this, true, info->name(), |
474 | traninfo, | 484 | traninfo, |
475 | _pCfg ); | 485 | _pCfg ); |
476 | currtran->showMaximized(); | 486 | currtran->showMaximized(); |
@@ -484,14 +494,22 @@ void Checkbook::slotNewTran() | |||
484 | QString stramount; | 494 | QString stramount; |
485 | amount = (traninfo->withdrawal() ? -1 : 1)*traninfo->amount(); | 495 | amount = (traninfo->withdrawal() ? -1 : 1)*traninfo->amount(); |
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 ); |
490 | resort(); | 500 | resort(); |
491 | adjustBalance(); | 501 | adjustBalance(); |
492 | 502 | ||
493 | // save last date | 503 | // save last date |
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 | } |
496 | else | 514 | else |
497 | { | 515 | { |
@@ -499,6 +517,8 @@ void Checkbook::slotNewTran() | |||
499 | } | 517 | } |
500 | } | 518 | } |
501 | 519 | ||
520 | |||
521 | // --- slotEditTran ----------------------------------------------------------- | ||
502 | void Checkbook::slotEditTran() | 522 | void Checkbook::slotEditTran() |
503 | { | 523 | { |
504 | QListViewItem *curritem = tranTable->currentItem(); | 524 | QListViewItem *curritem = tranTable->currentItem(); |
@@ -507,14 +527,15 @@ void Checkbook::slotEditTran() | |||
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, |
512 | _pCfg ); | 532 | _pCfg ); |
513 | currtran->showMaximized(); | 533 | currtran->showMaximized(); |
514 | if ( currtran->exec() == QDialog::Accepted ) | 534 | if ( currtran->exec() == QDialog::Accepted ) |
515 | { | 535 | { |
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() ); |
519 | 540 | ||
520 | float amount = traninfo->amount(); | 541 | float amount = traninfo->amount(); |
@@ -527,11 +548,47 @@ void Checkbook::slotEditTran() | |||
527 | curritem->setText( COL_AMOUNT, stramount ); | 548 | curritem->setText( COL_AMOUNT, stramount ); |
528 | resort(); | 549 | resort(); |
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 | } |
531 | 560 | ||
532 | delete currtran; | 561 | delete currtran; |
533 | } | 562 | } |
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() |
536 | { | 593 | { |
537 | QListViewItem *curritem = tranTable->currentItem(); | 594 | QListViewItem *curritem = tranTable->currentItem(); |
@@ -591,7 +648,7 @@ void Checkbook::drawBalanceChart() | |||
591 | balance += amount; | 648 | balance += amount; |
592 | if ( i == 1 || i == count / 2 || i == count ) | 649 | if ( i == 1 || i == count / 2 || i == count ) |
593 | { | 650 | { |
594 | label = tran->datestr(); | 651 | label = tran->datestr(true); |
595 | } | 652 | } |
596 | else | 653 | else |
597 | { | 654 | { |
@@ -666,6 +723,7 @@ void CBListItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int | |||
666 | QListViewItem::paintCell(p, _cg, column, width, align); | 723 | QListViewItem::paintCell(p, _cg, column, width, align); |
667 | } | 724 | } |
668 | 725 | ||
726 | // --- CBListItem::isAltBackground -------------------------------------------- | ||
669 | bool CBListItem::isAltBackground() | 727 | bool CBListItem::isAltBackground() |
670 | { | 728 | { |
671 | QListView *lv = static_cast<QListView *>( listView() ); | 729 | QListView *lv = static_cast<QListView *>( listView() ); |
@@ -723,8 +781,9 @@ void Checkbook::slotSortChanged( const QString &selc ) | |||
723 | } else if( selc==tr("Number") ) { | 781 | } else if( selc==tr("Number") ) { |
724 | _sortCol=COL_NUM; | 782 | _sortCol=COL_NUM; |
725 | } else if( selc==tr("Date") ) { | 783 | } else if( selc==tr("Date") ) { |
726 | _sortCol=COL_DATE; | 784 | _sortCol=COL_SORTDATE; |
727 | } | 785 | } |
728 | info->setSortOrder( selc ); | 786 | info->setSortOrder( selc ); |
729 | resort(); | 787 | resort(); |
730 | } | 788 | } |
789 | |||