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 | |
parent | d53637f46cf217fc760d7aac58b4596843a73803 (diff) | |
download | opie-37414f207b147af4cf6778b323a0aa23127901bd.zip opie-37414f207b147af4cf6778b323a0aa23127901bd.tar.gz opie-37414f207b147af4cf6778b323a0aa23127901bd.tar.bz2 |
apply patch to HEAD
-rw-r--r-- | noncore/apps/checkbook/cfg.cpp | 15 | ||||
-rw-r--r-- | noncore/apps/checkbook/cfg.h | 16 | ||||
-rw-r--r-- | noncore/apps/checkbook/checkbook.cpp | 91 | ||||
-rw-r--r-- | noncore/apps/checkbook/checkbook.h | 8 | ||||
-rw-r--r-- | noncore/apps/checkbook/configuration.cpp | 16 | ||||
-rw-r--r-- | noncore/apps/checkbook/configuration.h | 2 | ||||
-rw-r--r-- | noncore/apps/checkbook/listedit.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/checkbook/mainwindow.cpp | 7 | ||||
-rw-r--r-- | noncore/apps/checkbook/traninfo.cpp | 25 | ||||
-rw-r--r-- | noncore/apps/checkbook/traninfo.h | 5 | ||||
-rw-r--r-- | noncore/apps/checkbook/transaction.cpp | 92 | ||||
-rw-r--r-- | noncore/apps/checkbook/transaction.h | 12 |
12 files changed, 249 insertions, 44 deletions
diff --git a/noncore/apps/checkbook/cfg.cpp b/noncore/apps/checkbook/cfg.cpp index 1e0ec5c..0d5d9ed 100644 --- a/noncore/apps/checkbook/cfg.cpp +++ b/noncore/apps/checkbook/cfg.cpp | |||
@@ -45,2 +45,3 @@ Cfg::Cfg() | |||
45 | _pCategories=new CategoryList(); | 45 | _pCategories=new CategoryList(); |
46 | _bDirty=false; | ||
46 | } | 47 | } |
@@ -54,4 +55,2 @@ void Cfg::readStringList(Config &cfg, const char *sKey, QStringList &lst) | |||
54 | { | 55 | { |
55 | qDebug( "%s", sKey ); | ||
56 | |||
57 | QString sEntry; | 56 | QString sEntry; |
@@ -88,2 +87,3 @@ void Cfg::readConfig(Config &config) | |||
88 | _showLastTab = config.readBoolEntry( "ShowLastTab", FALSE ); | 87 | _showLastTab = config.readBoolEntry( "ShowLastTab", FALSE ); |
88 | _bSavePayees = config.readBoolEntry( "SavePayees", FALSE ); | ||
89 | 89 | ||
@@ -102,2 +102,5 @@ void Cfg::readConfig(Config &config) | |||
102 | 102 | ||
103 | // Payees | ||
104 | readStringList(config, "Payee", _Payees); | ||
105 | |||
103 | // Read Categories | 106 | // Read Categories |
@@ -133,2 +136,5 @@ void Cfg::readConfig(Config &config) | |||
133 | } | 136 | } |
137 | |||
138 | // not dirty | ||
139 | _bDirty=false; | ||
134 | } | 140 | } |
@@ -168,2 +174,3 @@ void Cfg::writeConfig(Config &config) | |||
168 | config.writeEntry( "ShowLastTab", _showLastTab ); | 174 | config.writeEntry( "ShowLastTab", _showLastTab ); |
175 | config.writeEntry( "SavePayees", _bSavePayees ); | ||
169 | 176 | ||
@@ -172,2 +179,5 @@ void Cfg::writeConfig(Config &config) | |||
172 | 179 | ||
180 | // write payees | ||
181 | writeStringList(config, "Payee", _Payees); | ||
182 | |||
173 | // write categories | 183 | // write categories |
@@ -178,2 +188,3 @@ void Cfg::writeConfig(Config &config) | |||
178 | config.write(); | 188 | config.write(); |
189 | _bDirty=false; | ||
179 | } | 190 | } |
diff --git a/noncore/apps/checkbook/cfg.h b/noncore/apps/checkbook/cfg.h index 2b69368..20692b4 100644 --- a/noncore/apps/checkbook/cfg.h +++ b/noncore/apps/checkbook/cfg.h | |||
@@ -79,2 +79,7 @@ class Cfg | |||
79 | 79 | ||
80 | // --- Payees | ||
81 | QStringList &getPayees() { return(_Payees); } | ||
82 | bool getSavePayees() { return(_bSavePayees); } | ||
83 | void setSavePayees(bool bSave) { _bSavePayees=bSave; } | ||
84 | |||
80 | // --- Categories | 85 | // --- Categories |
@@ -100,2 +105,7 @@ class Cfg | |||
100 | 105 | ||
106 | // --- dirty flag | ||
107 | bool isDirty() { return(_bDirty); } | ||
108 | void setDirty(bool bDirty) { _bDirty=bDirty; } | ||
109 | |||
110 | protected: | ||
101 | // --- reads list from config file | 111 | // --- reads list from config file |
@@ -106,4 +116,2 @@ class Cfg | |||
106 | 116 | ||
107 | |||
108 | |||
109 | private: | 117 | private: |
@@ -114,2 +122,4 @@ class Cfg | |||
114 | bool _showLastTab; | 122 | bool _showLastTab; |
123 | bool _bDirty; | ||
124 | bool _bSavePayees; | ||
115 | QString _sLastBook; | 125 | QString _sLastBook; |
@@ -117,2 +127,4 @@ class Cfg | |||
117 | CategoryList *_pCategories; | 127 | CategoryList *_pCategories; |
128 | QStringList _Payees; | ||
129 | |||
118 | }; | 130 | }; |
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 | |||
diff --git a/noncore/apps/checkbook/checkbook.h b/noncore/apps/checkbook/checkbook.h index 1b6a2d3..e18f00c 100644 --- a/noncore/apps/checkbook/checkbook.h +++ b/noncore/apps/checkbook/checkbook.h | |||
@@ -50,2 +50,3 @@ class TranInfoList; | |||
50 | class Cfg; | 50 | class Cfg; |
51 | class QMouseEvent; | ||
51 | 52 | ||
@@ -64,2 +65,5 @@ class Checkbook : public QDialog | |||
64 | 65 | ||
66 | // members | ||
67 | TranInfoList *getTranList() { return(tranList); } | ||
68 | |||
65 | private: | 69 | private: |
@@ -111,2 +115,3 @@ class Checkbook : public QDialog | |||
111 | void slotEditTran(); | 115 | void slotEditTran(); |
116 | void slotMenuTran(QListViewItem *, const QPoint &); | ||
112 | void slotDeleteTran(); | 117 | void slotDeleteTran(); |
@@ -116,2 +121,3 @@ class Checkbook : public QDialog | |||
116 | 121 | ||
122 | |||
117 | // --- CBListItem ------------------------------------------------------------- | 123 | // --- CBListItem ------------------------------------------------------------- |
@@ -131,3 +137,3 @@ class CBListItem : public QListViewItem | |||
131 | 137 | ||
132 | private: | 138 | private: |
133 | TranInfo *_pTran; | 139 | TranInfo *_pTran; |
diff --git a/noncore/apps/checkbook/configuration.cpp b/noncore/apps/checkbook/configuration.cpp index 3f5662d..dfae446 100644 --- a/noncore/apps/checkbook/configuration.cpp +++ b/noncore/apps/checkbook/configuration.cpp | |||
@@ -78,2 +78,8 @@ Configuration::Configuration( QWidget *parent, Cfg &cfg ) | |||
78 | _mainWidget->addTab( _listEditCategories, tr( "&Categories" ) ); | 78 | _mainWidget->addTab( _listEditCategories, tr( "&Categories" ) ); |
79 | |||
80 | // Payees tab | ||
81 | _listEditPayees=new ListEdit(_mainWidget, "PAYEES"); | ||
82 | _listEditPayees->addColumnDef( new ColumnDef( tr("Payee"), (ColumnDef::ColumnType)(ColumnDef::typeString | ColumnDef::typeUnique), tr("New Payee")) ); | ||
83 | _listEditPayees->addData( cfg.getPayees() ); | ||
84 | _mainWidget->addTab( _listEditPayees, tr("&Payees") ); | ||
79 | } | 85 | } |
@@ -140,2 +146,8 @@ QWidget *Configuration::initSettings(Cfg &cfg) | |||
140 | 146 | ||
147 | savePayees = new QCheckBox( tr("Save new description as payee"), container ); | ||
148 | QWhatsThis::add( savePayees, tr("Click here to save new descriptions in the list of payess.") ); | ||
149 | savePayees->setMaximumHeight(fh+5); | ||
150 | savePayees->setChecked( cfg.getSavePayees() ); | ||
151 | layout->addMultiCellWidget( savePayees, 5, 5, 0, 1 ); | ||
152 | |||
141 | return(control); | 153 | return(control); |
@@ -152,2 +164,3 @@ void Configuration::saveConfig(Cfg &cfg) | |||
152 | cfg.setShowLastTab( lastTabCB->isChecked() ); | 164 | cfg.setShowLastTab( lastTabCB->isChecked() ); |
165 | cfg.setSavePayees( savePayees->isChecked() ); | ||
153 | 166 | ||
@@ -160,2 +173,5 @@ void Configuration::saveConfig(Cfg &cfg) | |||
160 | cfg.setCategories( lst ); | 173 | cfg.setCategories( lst ); |
174 | |||
175 | // Payees | ||
176 | _listEditPayees->storeInList( cfg.getPayees() ); | ||
161 | } | 177 | } |
diff --git a/noncore/apps/checkbook/configuration.h b/noncore/apps/checkbook/configuration.h index 5893502..663514d 100644 --- a/noncore/apps/checkbook/configuration.h +++ b/noncore/apps/checkbook/configuration.h | |||
@@ -54,2 +54,3 @@ class Configuration : public QDialog | |||
54 | QCheckBox *lastTabCB; | 54 | QCheckBox *lastTabCB; |
55 | QCheckBox *savePayees; | ||
55 | QTabWidget *_mainWidget; | 56 | QTabWidget *_mainWidget; |
@@ -57,2 +58,3 @@ class Configuration : public QDialog | |||
57 | ListEdit *_listEditCategories; | 58 | ListEdit *_listEditCategories; |
59 | ListEdit *_listEditPayees; | ||
58 | 60 | ||
diff --git a/noncore/apps/checkbook/listedit.cpp b/noncore/apps/checkbook/listedit.cpp index 99a6531..37f05f0 100644 --- a/noncore/apps/checkbook/listedit.cpp +++ b/noncore/apps/checkbook/listedit.cpp | |||
@@ -118,2 +118,6 @@ void ListEdit::slotAdd() | |||
118 | _typeTable->setSelected( _currentItem, true ); | 118 | _typeTable->setSelected( _currentItem, true ); |
119 | |||
120 | // make it selected | ||
121 | _typeEdit->setCursorPosition(0); | ||
122 | _typeEdit->setSelection(0, _typeEdit->text().length() ); | ||
119 | } | 123 | } |
diff --git a/noncore/apps/checkbook/mainwindow.cpp b/noncore/apps/checkbook/mainwindow.cpp index 8d64cad..bf00102 100644 --- a/noncore/apps/checkbook/mainwindow.cpp +++ b/noncore/apps/checkbook/mainwindow.cpp | |||
@@ -60,3 +60,2 @@ MainWindow::MainWindow( QWidget* parent, const char* name, WFlags fl ) | |||
60 | Config config( "checkbook" ); | 60 | Config config( "checkbook" ); |
61 | qDebug( "Reading config" ); | ||
62 | _cfg.readConfig( config ); | 61 | _cfg.readConfig( config ); |
@@ -316,2 +315,8 @@ void MainWindow::openBook(QListViewItem *curritem) | |||
316 | } | 315 | } |
316 | |||
317 | // write config, if needed | ||
318 | if( _cfg.isDirty() ) { | ||
319 | Config config("checkbook"); | ||
320 | _cfg.writeConfig( config ); | ||
321 | } | ||
317 | } | 322 | } |
diff --git a/noncore/apps/checkbook/traninfo.cpp b/noncore/apps/checkbook/traninfo.cpp index d880bb4..506f567 100644 --- a/noncore/apps/checkbook/traninfo.cpp +++ b/noncore/apps/checkbook/traninfo.cpp | |||
@@ -31,2 +31,3 @@ | |||
31 | #include <qpe/config.h> | 31 | #include <qpe/config.h> |
32 | #include <qpe/timestring.h> | ||
32 | 33 | ||
@@ -126,10 +127,13 @@ TranInfo::TranInfo( Config config, int entry ) | |||
126 | // --- datestr ---------------------------------------------------------------- | 127 | // --- datestr ---------------------------------------------------------------- |
127 | const QString &TranInfo::datestr() | 128 | const QString &TranInfo::datestr(bool bDisplayDate) |
128 | { | 129 | { |
129 | int y=td.year(); | 130 | if( bDisplayDate ) { |
130 | y= y>=2000 && y<=2099 ? y-2000 : y; | 131 | tempstr=TimeString::numberDateString( td ); |
131 | tempstr.sprintf( "%02d/%02d/%02d", y ,td.month(), td.day() ); | 132 | } else { |
132 | return( tempstr ); | 133 | tempstr.sprintf( "%04d-%02d-%02d", td.year() ,td.month(), td.day() ); |
134 | } | ||
135 | return(tempstr); | ||
133 | } | 136 | } |
134 | 137 | ||
138 | |||
135 | // --- getIdStr --------------------------------------------------------------- | 139 | // --- getIdStr --------------------------------------------------------------- |
@@ -212 +216,12 @@ QString TranInfo::toString() | |||
212 | } | 216 | } |
217 | |||
218 | |||
219 | // --- findMostRecentByDesc --------------------------------------------------- | ||
220 | TranInfo *TranInfoList::findMostRecentByDesc( const QString &desc ) | ||
221 | { | ||
222 | for(TranInfo *cur=last(); cur; cur=prev()) { | ||
223 | if( cur->desc()==desc ) | ||
224 | return( cur ); | ||
225 | } | ||
226 | return(NULL); | ||
227 | } \ No newline at end of file | ||
diff --git a/noncore/apps/checkbook/traninfo.h b/noncore/apps/checkbook/traninfo.h index 0abdc61..cbe0238 100644 --- a/noncore/apps/checkbook/traninfo.h +++ b/noncore/apps/checkbook/traninfo.h | |||
@@ -51,3 +51,3 @@ class TranInfo | |||
51 | const QDate &date() const { return td; } | 51 | const QDate &date() const { return td; } |
52 | const QString &datestr(); | 52 | const QString &datestr(bool = false); |
53 | bool withdrawal()const { return w; } | 53 | bool withdrawal()const { return w; } |
@@ -95,2 +95,5 @@ class TranInfoList : public QList<TranInfo> | |||
95 | { | 95 | { |
96 | public: | ||
97 | TranInfo *findMostRecentByDesc( const QString &desc ); | ||
98 | |||
96 | protected: | 99 | protected: |
diff --git a/noncore/apps/checkbook/transaction.cpp b/noncore/apps/checkbook/transaction.cpp index 138d0e6..9379da0 100644 --- a/noncore/apps/checkbook/transaction.cpp +++ b/noncore/apps/checkbook/transaction.cpp | |||
@@ -31,4 +31,6 @@ | |||
31 | #include "cfg.h" | 31 | #include "cfg.h" |
32 | #include "checkbook.h" | ||
32 | 33 | ||
33 | #include <qpe/datebookmonth.h> | 34 | #include <qpe/datebookmonth.h> |
35 | #include <qpe/resource.h> | ||
34 | 36 | ||
@@ -43,4 +45,4 @@ | |||
43 | 45 | ||
44 | Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *info, | 46 | Transaction::Transaction( QWidget *parent, bool bNew, const QString &acctname, |
45 | Cfg *pCfg ) | 47 | TranInfo *info, Cfg *pCfg ) |
46 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) | 48 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) |
@@ -51,2 +53,3 @@ Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *in | |||
51 | 53 | ||
54 | _bNew=bNew; | ||
52 | tran = info; | 55 | tran = info; |
@@ -116,5 +119,8 @@ Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *in | |||
116 | layout->addWidget( label, 2, 0 ); | 119 | layout->addWidget( label, 2, 0 ); |
117 | descEdit = new QLineEdit( container ); | 120 | _cbDesc=new QComboBox( true, container ); |
118 | QWhatsThis::add( descEdit, tr( "Enter description of transaction here." ) ); | 121 | _cbDesc->insertStringList( _pCfg->getPayees() ); |
119 | layout->addMultiCellWidget( descEdit, 2, 2, 1, 3 ); | 122 | QWhatsThis::add( _cbDesc, tr( "Enter description of transaction here." ) ); |
123 | layout->addMultiCellWidget( _cbDesc, 2, 2, 1, 3 ); | ||
124 | connect( _cbDesc, SIGNAL( activated(const QString &) ), this, SLOT( slotActivated(const QString &) ) ); | ||
125 | |||
120 | 126 | ||
@@ -136,2 +142,3 @@ Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *in | |||
136 | 142 | ||
143 | |||
137 | // Amount | 144 | // Amount |
@@ -160,2 +167,18 @@ Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *in | |||
160 | 167 | ||
168 | // init date | ||
169 | initFromInfo( info ); | ||
170 | |||
171 | // not new handlers | ||
172 | connect( withBtn, SIGNAL( toggled(bool) ), this, SLOT( slotNotNew() ) ); | ||
173 | connect( depBtn, SIGNAL( toggled(bool) ), this, SLOT( slotNotNew() ) ); | ||
174 | connect( catList, SIGNAL(activated(const QString &)), this, SLOT( slotNotNew() ) ); | ||
175 | connect( typeList, SIGNAL(activated(const QString &)), this, SLOT( slotNotNew() ) ); | ||
176 | connect( amtEdit, SIGNAL(textChanged(const QString &)), this, SLOT( slotNotNew() ) ); | ||
177 | connect( feeEdit, SIGNAL(textChanged(const QString &)), this, SLOT( slotNotNew() ) ); | ||
178 | connect( noteEdit, SIGNAL(textChanged()), this, SLOT( slotNotNew() ) ); | ||
179 | } | ||
180 | |||
181 | // --- initFromInfo ----------------------------------------------------------- | ||
182 | void Transaction::initFromInfo(TranInfo *info, bool bPopulateOld) | ||
183 | { | ||
161 | // Populate current values if provided | 184 | // Populate current values if provided |
@@ -173,9 +196,23 @@ Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *in | |||
173 | } | 196 | } |
174 | QDate dt = info->date(); | 197 | |
175 | slotDateChanged( dt.year(), dt.month(), dt.day() ); | 198 | if( !bPopulateOld ) { |
176 | datePicker->setDate( dt ); | 199 | QDate dt = info->date(); |
177 | numEdit->setText( info->number() ); | 200 | slotDateChanged( dt.year(), dt.month(), dt.day() ); |
178 | descEdit->setText( info->desc() ); | 201 | datePicker->setDate( dt ); |
202 | numEdit->setText( info->number() ); | ||
203 | } | ||
179 | QString temptext = info->category(); | 204 | QString temptext = info->category(); |
180 | int i = catList->count(); | 205 | |
206 | // set description field | ||
207 | int i; | ||
208 | for(i=_cbDesc->count()-1; i>=0; i--) { | ||
209 | if( _cbDesc->text(i)==info->desc() ) { | ||
210 | _cbDesc->setCurrentItem(i); | ||
211 | break; | ||
212 | } | ||
213 | } | ||
214 | if( i<=0 ) | ||
215 | _cbDesc->setEditText( info->desc() ); | ||
216 | |||
217 | i = catList->count(); | ||
181 | while ( i > 0 ) | 218 | while ( i > 0 ) |
@@ -210,2 +247,4 @@ Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *in | |||
210 | 247 | ||
248 | |||
249 | // --- ~Transaction ----------------------------------------------------------- | ||
211 | Transaction::~Transaction() | 250 | Transaction::~Transaction() |
@@ -214,5 +253,6 @@ Transaction::~Transaction() | |||
214 | 253 | ||
254 | // --- accept ----------------------------------------------------------------- | ||
215 | void Transaction::accept() | 255 | void Transaction::accept() |
216 | { | 256 | { |
217 | tran->setDesc( descEdit->text() ); | 257 | tran->setDesc( _cbDesc->currentText() ); |
218 | tran->setDate( datePicker->selectedDate() ); | 258 | tran->setDate( datePicker->selectedDate() ); |
@@ -264,2 +304,3 @@ void Transaction::slotDepositClicked() | |||
264 | 304 | ||
305 | // --- slotDateChanged -------------------------------------------------------- | ||
265 | void Transaction::slotDateChanged( int y, int m, int d ) | 306 | void Transaction::slotDateChanged( int y, int m, int d ) |
@@ -270 +311,28 @@ void Transaction::slotDateChanged( int y, int m, int d ) | |||
270 | } | 311 | } |
312 | |||
313 | |||
314 | |||
315 | // --- slotActivated ---------------------------------------------------------- | ||
316 | // Search for the most recent transaction with this description/payee and | ||
317 | // fill amount etc here, as long the new flag is set | ||
318 | void Transaction::slotActivated(const QString &arg ) | ||
319 | { | ||
320 | if( !_bNew ) return; | ||
321 | TranInfoList *pTl=((Checkbook *)parentWidget())->getTranList(); | ||
322 | if( pTl ) { | ||
323 | TranInfo *pTi=pTl->findMostRecentByDesc( arg ); | ||
324 | if( pTi ) { | ||
325 | initFromInfo( pTi, true ); | ||
326 | amtEdit->setFocus(); | ||
327 | amtEdit->setSelection(0, amtEdit->text().length() ); | ||
328 | amtEdit->setCursorPosition(0); | ||
329 | } | ||
330 | } | ||
331 | } | ||
332 | |||
333 | // slotNotNew ----------------------------------------------------------------- | ||
334 | void Transaction::slotNotNew() | ||
335 | { | ||
336 | qDebug("Not new"); | ||
337 | _bNew=false; | ||
338 | } | ||
diff --git a/noncore/apps/checkbook/transaction.h b/noncore/apps/checkbook/transaction.h index fbe9cd3..130d769 100644 --- a/noncore/apps/checkbook/transaction.h +++ b/noncore/apps/checkbook/transaction.h | |||
@@ -49,8 +49,10 @@ class Transaction : public QDialog | |||
49 | public: | 49 | public: |
50 | Transaction( QWidget *, const QString &, TranInfo *, Cfg *); | 50 | Transaction( QWidget *, bool, const QString &, TranInfo *, Cfg *); |
51 | ~Transaction(); | 51 | ~Transaction(); |
52 | 52 | ||
53 | private: | 53 | void initFromInfo(TranInfo *, bool=false); |
54 | TranInfo *tran; | ||
55 | 54 | ||
55 | private: | ||
56 | TranInfo *tran; | ||
57 | bool _bNew; | ||
56 | Cfg *_pCfg; | 58 | Cfg *_pCfg; |
@@ -62,3 +64,3 @@ class Transaction : public QDialog | |||
62 | QLineEdit *numEdit; | 64 | QLineEdit *numEdit; |
63 | QLineEdit *descEdit; | 65 | QComboBox *_cbDesc; |
64 | QComboBox *catList; | 66 | QComboBox *catList; |
@@ -76,2 +78,4 @@ class Transaction : public QDialog | |||
76 | void slotDateChanged( int, int, int ); | 78 | void slotDateChanged( int, int, int ); |
79 | void slotActivated(const QString & ); | ||
80 | void slotNotNew(); | ||
77 | }; | 81 | }; |