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 | |
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 | 85 | ||||
-rw-r--r-- | noncore/apps/checkbook/checkbook.h | 6 | ||||
-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 | 23 | ||||
-rw-r--r-- | noncore/apps/checkbook/traninfo.h | 5 | ||||
-rw-r--r-- | noncore/apps/checkbook/transaction.cpp | 84 | ||||
-rw-r--r-- | noncore/apps/checkbook/transaction.h | 10 |
12 files changed, 239 insertions, 34 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 | |||
@@ -40,23 +40,22 @@ | |||
40 | Cfg::Cfg() | 40 | Cfg::Cfg() |
41 | { | 41 | { |
42 | _currencySymbol="$"; | 42 | _currencySymbol="$"; |
43 | _showLocks=FALSE; | 43 | _showLocks=FALSE; |
44 | _showBalances=FALSE; | 44 | _showBalances=FALSE; |
45 | _pCategories=new CategoryList(); | 45 | _pCategories=new CategoryList(); |
46 | _bDirty=false; | ||
46 | } | 47 | } |
47 | 48 | ||
48 | // --- readStringList --------------------------------------------------------- | 49 | // --- readStringList --------------------------------------------------------- |
49 | // Reads the entries for the control from a configuration file and returns | 50 | // Reads the entries for the control from a configuration file and returns |
50 | // them in a StringList. Later this list can be used to create the control. It | 51 | // them in a StringList. Later this list can be used to create the control. It |
51 | // is assumed, that the group is already set. Key is used to enumerate the | 52 | // is assumed, that the group is already set. Key is used to enumerate the |
52 | // entries. | 53 | // entries. |
53 | void Cfg::readStringList(Config &cfg, const char *sKey, QStringList &lst) | 54 | void Cfg::readStringList(Config &cfg, const char *sKey, QStringList &lst) |
54 | { | 55 | { |
55 | qDebug( "%s", sKey ); | ||
56 | |||
57 | QString sEntry; | 56 | QString sEntry; |
58 | int iCount; | 57 | int iCount; |
59 | 58 | ||
60 | // read count of elements | 59 | // read count of elements |
61 | sEntry.sprintf("%s_Count", sKey); | 60 | sEntry.sprintf("%s_Count", sKey); |
62 | iCount=cfg.readNumEntry(sEntry, 0); | 61 | iCount=cfg.readNumEntry(sEntry, 0); |
@@ -83,12 +82,13 @@ void Cfg::readConfig(Config &config) | |||
83 | _currencySymbol = config.readEntry( "CurrencySymbol", "$" ); | 82 | _currencySymbol = config.readEntry( "CurrencySymbol", "$" ); |
84 | _showLocks = config.readBoolEntry( "ShowLocks", FALSE ); | 83 | _showLocks = config.readBoolEntry( "ShowLocks", FALSE ); |
85 | _showBalances = config.readBoolEntry( "ShowBalances", FALSE ); | 84 | _showBalances = config.readBoolEntry( "ShowBalances", FALSE ); |
86 | _openLastBook = config.readBoolEntry( "OpenLastBook", FALSE ); | 85 | _openLastBook = config.readBoolEntry( "OpenLastBook", FALSE ); |
87 | _sLastBook = config.readEntry("LastBook", ""); | 86 | _sLastBook = config.readEntry("LastBook", ""); |
88 | _showLastTab = config.readBoolEntry( "ShowLastTab", FALSE ); | 87 | _showLastTab = config.readBoolEntry( "ShowLastTab", FALSE ); |
88 | _bSavePayees = config.readBoolEntry( "SavePayees", FALSE ); | ||
89 | 89 | ||
90 | // Account types | 90 | // Account types |
91 | readStringList(config, "AccType", _AccountTypes); | 91 | readStringList(config, "AccType", _AccountTypes); |
92 | if( _AccountTypes.isEmpty() ) { | 92 | if( _AccountTypes.isEmpty() ) { |
93 | _AccountTypes+= (const char *)QWidget::tr("Savings"); | 93 | _AccountTypes+= (const char *)QWidget::tr("Savings"); |
94 | _AccountTypes+= (const char *)QWidget::tr("Checking"); | 94 | _AccountTypes+= (const char *)QWidget::tr("Checking"); |
@@ -97,12 +97,15 @@ void Cfg::readConfig(Config &config) | |||
97 | _AccountTypes+= (const char *)QWidget::tr("Mutual fund"); | 97 | _AccountTypes+= (const char *)QWidget::tr("Mutual fund"); |
98 | _AccountTypes+= (const char *)QWidget::tr("Other"); | 98 | _AccountTypes+= (const char *)QWidget::tr("Other"); |
99 | writeStringList(config, "AccType", _AccountTypes); | 99 | writeStringList(config, "AccType", _AccountTypes); |
100 | config.write(); | 100 | config.write(); |
101 | } | 101 | } |
102 | 102 | ||
103 | // Payees | ||
104 | readStringList(config, "Payee", _Payees); | ||
105 | |||
103 | // Read Categories | 106 | // Read Categories |
104 | QStringList lst; | 107 | QStringList lst; |
105 | readStringList(config, "Category", lst); | 108 | readStringList(config, "Category", lst); |
106 | if( lst.isEmpty() ) { | 109 | if( lst.isEmpty() ) { |
107 | QString type=QWidget::tr("Expense"); | 110 | QString type=QWidget::tr("Expense"); |
108 | lst += QWidget::tr( "Automobile" )+";"+type; | 111 | lst += QWidget::tr( "Automobile" )+";"+type; |
@@ -128,12 +131,15 @@ void Cfg::readConfig(Config &config) | |||
128 | setCategories(lst); | 131 | setCategories(lst); |
129 | writeStringList(config, "Category", lst); | 132 | writeStringList(config, "Category", lst); |
130 | config.write(); | 133 | config.write(); |
131 | } else { | 134 | } else { |
132 | setCategories(lst); | 135 | setCategories(lst); |
133 | } | 136 | } |
137 | |||
138 | // not dirty | ||
139 | _bDirty=false; | ||
134 | } | 140 | } |
135 | 141 | ||
136 | 142 | ||
137 | // --- writeStringList -------------------------------------------------------- | 143 | // --- writeStringList -------------------------------------------------------- |
138 | // Writes the entries in the control in a configuration file. It is assumed, | 144 | // Writes the entries in the control in a configuration file. It is assumed, |
139 | // that the group is already set. Key is used to enumerate the entries | 145 | // that the group is already set. Key is used to enumerate the entries |
@@ -163,22 +169,27 @@ void Cfg::writeConfig(Config &config) | |||
163 | config.writeEntry( "CurrencySymbol", _currencySymbol ); | 169 | config.writeEntry( "CurrencySymbol", _currencySymbol ); |
164 | config.writeEntry( "ShowLocks", _showLocks ); | 170 | config.writeEntry( "ShowLocks", _showLocks ); |
165 | config.writeEntry( "ShowBalances", _showBalances ); | 171 | config.writeEntry( "ShowBalances", _showBalances ); |
166 | config.writeEntry( "OpenLastBook", _openLastBook ); | 172 | config.writeEntry( "OpenLastBook", _openLastBook ); |
167 | config.writeEntry( "LastBook", _sLastBook ); | 173 | config.writeEntry( "LastBook", _sLastBook ); |
168 | config.writeEntry( "ShowLastTab", _showLastTab ); | 174 | config.writeEntry( "ShowLastTab", _showLastTab ); |
175 | config.writeEntry( "SavePayees", _bSavePayees ); | ||
169 | 176 | ||
170 | // write account types | 177 | // write account types |
171 | writeStringList(config, "AccType", _AccountTypes); | 178 | writeStringList(config, "AccType", _AccountTypes); |
172 | 179 | ||
180 | // write payees | ||
181 | writeStringList(config, "Payee", _Payees); | ||
182 | |||
173 | // write categories | 183 | // write categories |
174 | QStringList lst=getCategories(); | 184 | QStringList lst=getCategories(); |
175 | writeStringList(config, "Category", lst ); | 185 | writeStringList(config, "Category", lst ); |
176 | 186 | ||
177 | // commit write | 187 | // commit write |
178 | config.write(); | 188 | config.write(); |
189 | _bDirty=false; | ||
179 | } | 190 | } |
180 | 191 | ||
181 | 192 | ||
182 | // --- getCategories ---------------------------------------------------------- | 193 | // --- getCategories ---------------------------------------------------------- |
183 | QStringList Cfg::getCategories() | 194 | QStringList Cfg::getCategories() |
184 | { | 195 | { |
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 | |||
@@ -74,12 +74,17 @@ class Cfg | |||
74 | void setShowBalances(bool n) { _showBalances=n; } | 74 | void setShowBalances(bool n) { _showBalances=n; } |
75 | QString &getCurrencySymbol() { return(_currencySymbol); } | 75 | QString &getCurrencySymbol() { return(_currencySymbol); } |
76 | void setCurrencySymbol(QString n) {_currencySymbol= n; } | 76 | void setCurrencySymbol(QString n) {_currencySymbol= n; } |
77 | void setCurrencySymbol(const char *n) { _currencySymbol=n; } | 77 | void setCurrencySymbol(const char *n) { _currencySymbol=n; } |
78 | QStringList &getAccountTypes() { return(_AccountTypes); } | 78 | QStringList &getAccountTypes() { return(_AccountTypes); } |
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 |
81 | QStringList getCategories(); | 86 | QStringList getCategories(); |
82 | void setCategories(QStringList &lst); | 87 | void setCategories(QStringList &lst); |
83 | CategoryList *getCategoryList() { return(_pCategories); } | 88 | CategoryList *getCategoryList() { return(_pCategories); } |
84 | 89 | ||
85 | // --- last book | 90 | // --- last book |
@@ -95,26 +100,33 @@ class Cfg | |||
95 | // --- reads data from config file | 100 | // --- reads data from config file |
96 | void readConfig(Config &cfg); | 101 | void readConfig(Config &cfg); |
97 | 102 | ||
98 | // --- writes data to config file | 103 | // --- writes data to config file |
99 | void writeConfig(Config &cfg); | 104 | void writeConfig(Config &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 |
102 | static void readStringList(Config &cfg, const char *sKey, QStringList &lst); | 112 | static void readStringList(Config &cfg, const char *sKey, QStringList &lst); |
103 | 113 | ||
104 | // --- writes list in configuration file | 114 | // --- writes list in configuration file |
105 | static void writeStringList(Config &cfg, const char *sKey, QStringList &lst); | 115 | static void writeStringList(Config &cfg, const char *sKey, QStringList &lst); |
106 | 116 | ||
107 | |||
108 | |||
109 | private: | 117 | private: |
110 | QString _currencySymbol; | 118 | QString _currencySymbol; |
111 | bool _showLocks; | 119 | bool _showLocks; |
112 | bool _showBalances; | 120 | bool _showBalances; |
113 | bool _openLastBook; | 121 | bool _openLastBook; |
114 | bool _showLastTab; | 122 | bool _showLastTab; |
123 | bool _bDirty; | ||
124 | bool _bSavePayees; | ||
115 | QString _sLastBook; | 125 | QString _sLastBook; |
116 | QStringList _AccountTypes; | 126 | QStringList _AccountTypes; |
117 | CategoryList *_pCategories; | 127 | CategoryList *_pCategories; |
128 | QStringList _Payees; | ||
129 | |||
118 | }; | 130 | }; |
119 | 131 | ||
120 | #endif | 132 | #endif |
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 | |||
@@ -46,19 +46,21 @@ | |||
46 | #include <qlabel.h> | 46 | #include <qlabel.h> |
47 | #include <qlayout.h> | 47 | #include <qlayout.h> |
48 | #include <qlineedit.h> | 48 | #include <qlineedit.h> |
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 ) |
62 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) | 64 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) |
63 | { | 65 | { |
64 | info = i; | 66 | info = i; |
@@ -221,12 +223,15 @@ QWidget *Checkbook::initTransactions() | |||
221 | fnt.setPointSize( fnt.pointSize()-1 ); | 223 | fnt.setPointSize( fnt.pointSize()-1 ); |
222 | tranTable->setFont( fnt ); | 224 | tranTable->setFont( fnt ); |
223 | QWhatsThis::add( tranTable, tr( "This is a listing of all transactions entered for this checkbook.\n\nTo sort entries by a specific field, click on the column name." ) ); | 225 | QWhatsThis::add( tranTable, tr( "This is a listing of all transactions entered for this checkbook.\n\nTo sort entries by a specific field, click on the column name." ) ); |
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" ) ); |
230 | tranTable->addColumn( tr( "Description" ) ); | 235 | tranTable->addColumn( tr( "Description" ) ); |
231 | int column = tranTable->addColumn( tr( "Amount" ) ); | 236 | int column = tranTable->addColumn( tr( "Amount" ) ); |
232 | tranTable->setColumnAlignment( column, Qt::AlignRight ); | 237 | tranTable->setColumnAlignment( column, Qt::AlignRight ); |
@@ -234,12 +239,14 @@ QWidget *Checkbook::initTransactions() | |||
234 | tranTable->setColumnAlignment( column, Qt::AlignRight ); | 239 | tranTable->setColumnAlignment( column, Qt::AlignRight ); |
235 | tranTable->setAllColumnsShowFocus( TRUE ); | 240 | tranTable->setAllColumnsShowFocus( TRUE ); |
236 | tranTable->setSorting( -1 ); | 241 | tranTable->setSorting( -1 ); |
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 | ||
243 | // Buttons | 250 | // Buttons |
244 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), control ); | 251 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), control ); |
245 | QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) ); | 252 | QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) ); |
@@ -333,13 +340,13 @@ void Checkbook::loadCheckbook() | |||
333 | amount = tran->amount(); | 340 | amount = tran->amount(); |
334 | if ( tran->withdrawal() ) | 341 | if ( tran->withdrawal() ) |
335 | { | 342 | { |
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 |
343 | bool bOk=false; | 350 | bool bOk=false; |
344 | for(int i=0; i<_cbSortType->count(); i++) { | 351 | for(int i=0; i<_cbSortType->count(); i++) { |
345 | if( _cbSortType->text(i)==info->getSortOrder() ) { | 352 | if( _cbSortType->text(i)==info->getSortOrder() ) { |
@@ -355,12 +362,13 @@ void Checkbook::loadCheckbook() | |||
355 | } | 362 | } |
356 | 363 | ||
357 | // calc running balance | 364 | // calc running balance |
358 | adjustBalance(); | 365 | adjustBalance(); |
359 | } | 366 | } |
360 | 367 | ||
368 | |||
361 | // --- adjustBalance ---------------------------------------------------------- | 369 | // --- adjustBalance ---------------------------------------------------------- |
362 | void Checkbook::adjustBalance() | 370 | void Checkbook::adjustBalance() |
363 | { | 371 | { |
364 | // update running balance in register | 372 | // update running balance in register |
365 | QString sRunning; | 373 | QString sRunning; |
366 | float bal=info->startingBalance(); | 374 | float bal=info->startingBalance(); |
@@ -393,12 +401,13 @@ void Checkbook::accept() | |||
393 | info->setStartingBalance( balanceEdit->text().toFloat( &ok ) ); | 401 | info->setStartingBalance( balanceEdit->text().toFloat( &ok ) ); |
394 | info->setNotes( notesEdit->text() ); | 402 | info->setNotes( notesEdit->text() ); |
395 | 403 | ||
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() ) |
402 | { | 411 | { |
403 | Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); | 412 | Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); |
404 | if ( pw->exec() != QDialog::Accepted ) | 413 | if ( pw->exec() != QDialog::Accepted ) |
@@ -461,19 +470,20 @@ void Checkbook::slotStartingBalanceChanged( const QString &newbalance ) | |||
461 | bool ok; | 470 | bool ok; |
462 | info->setStartingBalance( newbalance.toFloat( &ok ) ); | 471 | info->setStartingBalance( newbalance.toFloat( &ok ) ); |
463 | adjustBalance(); | 472 | adjustBalance(); |
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(); |
477 | if ( currtran->exec() == QDialog::Accepted ) | 487 | if ( currtran->exec() == QDialog::Accepted ) |
478 | { | 488 | { |
479 | // Add to transaction list | 489 | // Add to transaction list |
@@ -481,60 +491,107 @@ void Checkbook::slotNewTran() | |||
481 | 491 | ||
482 | // Add to transaction table | 492 | // Add to transaction table |
483 | float amount; | 493 | float amount; |
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 | { |
498 | delete traninfo; | 516 | delete traninfo; |
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(); |
505 | if ( !curritem ) | 525 | if ( !curritem ) |
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, |
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(); |
521 | if ( traninfo->withdrawal() ) | 542 | if ( traninfo->withdrawal() ) |
522 | { | 543 | { |
523 | amount *= -1; | 544 | amount *= -1; |
524 | } | 545 | } |
525 | QString stramount; | 546 | QString stramount; |
526 | stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); | 547 | stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); |
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(); |
538 | if ( !curritem ) | 595 | if ( !curritem ) |
539 | return; | 596 | return; |
540 | 597 | ||
@@ -588,13 +645,13 @@ void Checkbook::drawBalanceChart() | |||
588 | { | 645 | { |
589 | amount *= -1; | 646 | amount *= -1; |
590 | } | 647 | } |
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 | { |
598 | label = ""; | 655 | label = ""; |
599 | } | 656 | } |
600 | list->append( new DataPointInfo( label, balance ) ); | 657 | list->append( new DataPointInfo( label, balance ) ); |
@@ -663,12 +720,13 @@ void CBListItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int | |||
663 | else if ( isAltBackground() ) | 720 | else if ( isAltBackground() ) |
664 | _cg.setColor(QColorGroup::Base, cg.background() ); | 721 | _cg.setColor(QColorGroup::Base, cg.background() ); |
665 | 722 | ||
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() ); |
672 | if ( lv ) | 730 | if ( lv ) |
673 | { | 731 | { |
674 | CBListItem *above = 0; | 732 | CBListItem *above = 0; |
@@ -720,11 +778,12 @@ void Checkbook::slotSortChanged( const QString &selc ) | |||
720 | { | 778 | { |
721 | if( selc==tr("Entry Order") ) { | 779 | if( selc==tr("Entry Order") ) { |
722 | _sortCol=COL_ID; | 780 | _sortCol=COL_ID; |
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 | |||
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 | |||
@@ -45,12 +45,13 @@ class QLineEdit; | |||
45 | class QListView; | 45 | class QListView; |
46 | class QMultiLineEdit; | 46 | class QMultiLineEdit; |
47 | class QString; | 47 | class QString; |
48 | class TranInfo; | 48 | class TranInfo; |
49 | class TranInfoList; | 49 | class TranInfoList; |
50 | class Cfg; | 50 | class Cfg; |
51 | class QMouseEvent; | ||
51 | 52 | ||
52 | 53 | ||
53 | // --- Checkbook -------------------------------------------------------------- | 54 | // --- Checkbook -------------------------------------------------------------- |
54 | class Checkbook : public QDialog | 55 | class Checkbook : public QDialog |
55 | { | 56 | { |
56 | Q_OBJECT | 57 | Q_OBJECT |
@@ -59,12 +60,15 @@ class Checkbook : public QDialog | |||
59 | Checkbook( QWidget *, CBInfo *, Cfg *cfg ); | 60 | Checkbook( QWidget *, CBInfo *, Cfg *cfg ); |
60 | ~Checkbook(); | 61 | ~Checkbook(); |
61 | 62 | ||
62 | // resort | 63 | // resort |
63 | void resort(); | 64 | void resort(); |
64 | 65 | ||
66 | // members | ||
67 | TranInfoList *getTranList() { return(tranList); } | ||
68 | |||
65 | private: | 69 | private: |
66 | CBInfo *info; | 70 | CBInfo *info; |
67 | TranInfoList *tranList; | 71 | TranInfoList *tranList; |
68 | Cfg *_pCfg; | 72 | Cfg *_pCfg; |
69 | 73 | ||
70 | OTabWidget *mainWidget; | 74 | OTabWidget *mainWidget; |
@@ -106,17 +110,19 @@ class Checkbook : public QDialog | |||
106 | private slots: | 110 | private slots: |
107 | void slotPasswordClicked(); | 111 | void slotPasswordClicked(); |
108 | void slotNameChanged( const QString & ); | 112 | void slotNameChanged( const QString & ); |
109 | void slotStartingBalanceChanged( const QString & ); | 113 | void slotStartingBalanceChanged( const QString & ); |
110 | void slotNewTran(); | 114 | void slotNewTran(); |
111 | void slotEditTran(); | 115 | void slotEditTran(); |
116 | void slotMenuTran(QListViewItem *, const QPoint &); | ||
112 | void slotDeleteTran(); | 117 | void slotDeleteTran(); |
113 | void slotDrawGraph(); | 118 | void slotDrawGraph(); |
114 | void slotSortChanged( const QString & ); | 119 | void slotSortChanged( const QString & ); |
115 | }; | 120 | }; |
116 | 121 | ||
122 | |||
117 | // --- CBListItem ------------------------------------------------------------- | 123 | // --- CBListItem ------------------------------------------------------------- |
118 | class CBListItem : public QListViewItem | 124 | class CBListItem : public QListViewItem |
119 | { | 125 | { |
120 | //Q_OBJECT | 126 | //Q_OBJECT |
121 | 127 | ||
122 | public: | 128 | public: |
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 | |||
@@ -73,12 +73,18 @@ Configuration::Configuration( QWidget *parent, Cfg &cfg ) | |||
73 | d->addColumnValue( tr("Expense") ); | 73 | d->addColumnValue( tr("Expense") ); |
74 | d->addColumnValue( tr("Income") ); | 74 | d->addColumnValue( tr("Income") ); |
75 | _listEditCategories->addColumnDef( d ); | 75 | _listEditCategories->addColumnDef( d ); |
76 | QStringList lst=cfg.getCategories(); | 76 | QStringList lst=cfg.getCategories(); |
77 | _listEditCategories->addData( lst ); | 77 | _listEditCategories->addData( lst ); |
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 | } |
80 | 86 | ||
81 | Configuration::~Configuration() | 87 | Configuration::~Configuration() |
82 | { | 88 | { |
83 | } | 89 | } |
84 | 90 | ||
@@ -135,27 +141,37 @@ QWidget *Configuration::initSettings(Cfg &cfg) | |||
135 | lastTabCB = new QCheckBox( tr("Show last checkbook tab" ), container ); | 141 | lastTabCB = new QCheckBox( tr("Show last checkbook tab" ), container ); |
136 | QWhatsThis::add( lastTabCB, tr("Click here to select whether the last tab in a checkbook should be displayed.") ); | 142 | QWhatsThis::add( lastTabCB, tr("Click here to select whether the last tab in a checkbook should be displayed.") ); |
137 | lastTabCB->setMaximumHeight(fh+5); | 143 | lastTabCB->setMaximumHeight(fh+5); |
138 | lastTabCB->setChecked( cfg.isShowLastTab() ); | 144 | lastTabCB->setChecked( cfg.isShowLastTab() ); |
139 | layout->addMultiCellWidget( lastTabCB, 4, 4, 0, 1 ); | 145 | layout->addMultiCellWidget( lastTabCB, 4, 4, 0, 1 ); |
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); |
142 | } | 154 | } |
143 | 155 | ||
144 | // --- saveConfig ------------------------------------------------------------- | 156 | // --- saveConfig ------------------------------------------------------------- |
145 | void Configuration::saveConfig(Cfg &cfg) | 157 | void Configuration::saveConfig(Cfg &cfg) |
146 | { | 158 | { |
147 | // Settings | 159 | // Settings |
148 | cfg.setCurrencySymbol( symbolEdit->text() ); | 160 | cfg.setCurrencySymbol( symbolEdit->text() ); |
149 | cfg.setShowLocks( lockCB->isChecked() ); | 161 | cfg.setShowLocks( lockCB->isChecked() ); |
150 | cfg.setShowBalances( balCB->isChecked() ); | 162 | cfg.setShowBalances( balCB->isChecked() ); |
151 | cfg.setOpenLastBook( openLastBookCB->isChecked() ); | 163 | cfg.setOpenLastBook( openLastBookCB->isChecked() ); |
152 | cfg.setShowLastTab( lastTabCB->isChecked() ); | 164 | cfg.setShowLastTab( lastTabCB->isChecked() ); |
165 | cfg.setSavePayees( savePayees->isChecked() ); | ||
153 | 166 | ||
154 | // Typelist | 167 | // Typelist |
155 | _listEditTypes->storeInList( cfg.getAccountTypes() ); | 168 | _listEditTypes->storeInList( cfg.getAccountTypes() ); |
156 | 169 | ||
157 | // Category list | 170 | // Category list |
158 | QStringList lst; | 171 | QStringList lst; |
159 | _listEditCategories->storeInList( lst ); | 172 | _listEditCategories->storeInList( lst ); |
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 | |||
@@ -49,15 +49,17 @@ class Configuration : public QDialog | |||
49 | 49 | ||
50 | QLineEdit *symbolEdit; | 50 | QLineEdit *symbolEdit; |
51 | QCheckBox *lockCB; | 51 | QCheckBox *lockCB; |
52 | QCheckBox *balCB; | 52 | QCheckBox *balCB; |
53 | QCheckBox *openLastBookCB; | 53 | QCheckBox *openLastBookCB; |
54 | QCheckBox *lastTabCB; | 54 | QCheckBox *lastTabCB; |
55 | QCheckBox *savePayees; | ||
55 | QTabWidget *_mainWidget; | 56 | QTabWidget *_mainWidget; |
56 | ListEdit *_listEditTypes; | 57 | ListEdit *_listEditTypes; |
57 | ListEdit *_listEditCategories; | 58 | ListEdit *_listEditCategories; |
59 | ListEdit *_listEditPayees; | ||
58 | 60 | ||
59 | // saves settings in config struct | 61 | // saves settings in config struct |
60 | void saveConfig(Cfg &cfg); | 62 | void saveConfig(Cfg &cfg); |
61 | 63 | ||
62 | protected: | 64 | protected: |
63 | // creates settings tap from configuration | 65 | // creates settings tap from configuration |
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 | |||
@@ -113,12 +113,16 @@ void ListEdit::slotAdd() | |||
113 | fixTypes(); | 113 | fixTypes(); |
114 | 114 | ||
115 | // display col 0 of new value | 115 | // display col 0 of new value |
116 | QPoint pnt; | 116 | QPoint pnt; |
117 | slotClick(_currentItem, pnt, 0); | 117 | slotClick(_currentItem, pnt, 0); |
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 | } |
120 | 124 | ||
121 | // --- slotDel ------------------------------------------------------------- | 125 | // --- slotDel ------------------------------------------------------------- |
122 | void ListEdit::slotDel() | 126 | void ListEdit::slotDel() |
123 | { | 127 | { |
124 | if( !_currentItem ) return; | 128 | if( !_currentItem ) return; |
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 | |||
@@ -55,13 +55,12 @@ MainWindow::MainWindow( QWidget* parent, const char* name, WFlags fl ) | |||
55 | 55 | ||
56 | cbDir = Global::applicationFileName( "checkbook", "" ); | 56 | cbDir = Global::applicationFileName( "checkbook", "" ); |
57 | lockIcon = Resource::loadPixmap( "locked" ); | 57 | lockIcon = Resource::loadPixmap( "locked" ); |
58 | 58 | ||
59 | // Load configuration options | 59 | // Load configuration options |
60 | Config config( "checkbook" ); | 60 | Config config( "checkbook" ); |
61 | qDebug( "Reading config" ); | ||
62 | _cfg.readConfig( config ); | 61 | _cfg.readConfig( config ); |
63 | 62 | ||
64 | 63 | ||
65 | // Build menu and tool bars | 64 | // Build menu and tool bars |
66 | setToolBarsMovable( FALSE ); | 65 | setToolBarsMovable( FALSE ); |
67 | 66 | ||
@@ -311,12 +310,18 @@ void MainWindow::openBook(QListViewItem *curritem) | |||
311 | if ( _cfg.getShowBalances() && cb->balance() != currbalance ) | 310 | if ( _cfg.getShowBalances() && cb->balance() != currbalance ) |
312 | { | 311 | { |
313 | QString tempstr; | 312 | QString tempstr; |
314 | tempstr.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() ); | 313 | tempstr.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() ); |
315 | curritem->setText( posName + 1, tempstr ); | 314 | curritem->setText( posName + 1, tempstr ); |
316 | } | 315 | } |
316 | |||
317 | // write config, if needed | ||
318 | if( _cfg.isDirty() ) { | ||
319 | Config config("checkbook"); | ||
320 | _cfg.writeConfig( config ); | ||
321 | } | ||
317 | } | 322 | } |
318 | delete currcb; | 323 | delete currcb; |
319 | } | 324 | } |
320 | 325 | ||
321 | // --- slotDelete ------------------------------------------------------------- | 326 | // --- slotDelete ------------------------------------------------------------- |
322 | void MainWindow::slotDelete() | 327 | void MainWindow::slotDelete() |
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 | |||
@@ -26,12 +26,13 @@ | |||
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "traninfo.h" | 29 | #include "traninfo.h" |
30 | 30 | ||
31 | #include <qpe/config.h> | 31 | #include <qpe/config.h> |
32 | #include <qpe/timestring.h> | ||
32 | 33 | ||
33 | QString tempstr; | 34 | QString tempstr; |
34 | 35 | ||
35 | TranInfo::TranInfo( int id, const QString &desc, const QDate &date, bool withdrawal, | 36 | TranInfo::TranInfo( int id, const QString &desc, const QDate &date, bool withdrawal, |
36 | const QString &type, const QString &category, float amount, | 37 | const QString &type, const QString &category, float amount, |
37 | float fee, const QString &number, const QString ¬es, int next ) | 38 | float fee, const QString &number, const QString ¬es, int next ) |
@@ -121,20 +122,23 @@ TranInfo::TranInfo( Config config, int entry ) | |||
121 | // next | 122 | // next |
122 | _next = config.readNumEntry("Next", -1); | 123 | _next = config.readNumEntry("Next", -1); |
123 | } | 124 | } |
124 | } | 125 | } |
125 | 126 | ||
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 { |
133 | tempstr.sprintf( "%04d-%02d-%02d", td.year() ,td.month(), td.day() ); | ||
134 | } | ||
132 | return( tempstr ); | 135 | return( tempstr ); |
133 | } | 136 | } |
134 | 137 | ||
138 | |||
135 | // --- getIdStr --------------------------------------------------------------- | 139 | // --- getIdStr --------------------------------------------------------------- |
136 | const QString &TranInfo::getIdStr() | 140 | const QString &TranInfo::getIdStr() |
137 | { | 141 | { |
138 | tempstr.sprintf("%04d", i); | 142 | tempstr.sprintf("%04d", i); |
139 | return( tempstr ); | 143 | return( tempstr ); |
140 | } | 144 | } |
@@ -207,6 +211,17 @@ QString TranInfo::toString() | |||
207 | (const char *)desc(), | 211 | (const char *)desc(), |
208 | (withdrawal() ? -1 : 1) * amount(), | 212 | (withdrawal() ? -1 : 1) * amount(), |
209 | fee() | 213 | fee() |
210 | ); | 214 | ); |
211 | return(ret); | 215 | return(ret); |
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 | |||
@@ -46,13 +46,13 @@ class TranInfo | |||
46 | // getters | 46 | // getters |
47 | int id() const { return i; } | 47 | int id() const { return i; } |
48 | const QString &getIdStr(); | 48 | const QString &getIdStr(); |
49 | 49 | ||
50 | const QString &desc() const { return d; } | 50 | const QString &desc() const { return d; } |
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; } |
54 | const QString &type() const { return t; } | 54 | const QString &type() const { return t; } |
55 | const QString &category()const { return c; } | 55 | const QString &category()const { return c; } |
56 | float amount() const { return a; } | 56 | float amount() const { return a; } |
57 | float fee() const { return f; } | 57 | float fee() const { return f; } |
58 | const QString &number()const { return cn; } | 58 | const QString &number()const { return cn; } |
@@ -90,11 +90,14 @@ class TranInfo | |||
90 | QString n; | 90 | QString n; |
91 | int _next; | 91 | int _next; |
92 | }; | 92 | }; |
93 | 93 | ||
94 | class TranInfoList : public QList<TranInfo> | 94 | class TranInfoList : public QList<TranInfo> |
95 | { | 95 | { |
96 | public: | ||
97 | TranInfo *findMostRecentByDesc( const QString &desc ); | ||
98 | |||
96 | protected: | 99 | protected: |
97 | int compareItems( QCollection::Item, QCollection::Item ); | 100 | int compareItems( QCollection::Item, QCollection::Item ); |
98 | }; | 101 | }; |
99 | 102 | ||
100 | #endif | 103 | #endif |
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 | |||
@@ -26,32 +26,35 @@ | |||
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "transaction.h" | 29 | #include "transaction.h" |
30 | #include "traninfo.h" | 30 | #include "traninfo.h" |
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 | ||
35 | #include <qbuttongroup.h> | 37 | #include <qbuttongroup.h> |
36 | #include <qcombobox.h> | 38 | #include <qcombobox.h> |
37 | #include <qlabel.h> | 39 | #include <qlabel.h> |
38 | #include <qlayout.h> | 40 | #include <qlayout.h> |
39 | #include <qlineedit.h> | 41 | #include <qlineedit.h> |
40 | #include <qmultilineedit.h> | 42 | #include <qmultilineedit.h> |
41 | #include <qradiobutton.h> | 43 | #include <qradiobutton.h> |
42 | #include <qwhatsthis.h> | 44 | #include <qwhatsthis.h> |
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 ) |
47 | { | 49 | { |
48 | QString tempstr = tr( "Transaction for " ); | 50 | QString tempstr = tr( "Transaction for " ); |
49 | tempstr.append( acctname ); | 51 | tempstr.append( acctname ); |
50 | setCaption( tempstr ); | 52 | setCaption( tempstr ); |
51 | 53 | ||
54 | _bNew=bNew; | ||
52 | tran = info; | 55 | tran = info; |
53 | _pCfg=pCfg; | 56 | _pCfg=pCfg; |
54 | 57 | ||
55 | QVBoxLayout *vb = new QVBoxLayout( this ); | 58 | QVBoxLayout *vb = new QVBoxLayout( this ); |
56 | 59 | ||
57 | QScrollView *sv = new QScrollView( this ); | 60 | QScrollView *sv = new QScrollView( this ); |
@@ -111,15 +114,18 @@ Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *in | |||
111 | layout->addWidget( numEdit, 1, 3 ); | 114 | layout->addWidget( numEdit, 1, 3 ); |
112 | 115 | ||
113 | // Description | 116 | // Description |
114 | label = new QLabel( tr( "Description:" ), container ); | 117 | label = new QLabel( tr( "Description:" ), container ); |
115 | QWhatsThis::add( label, tr( "Enter description of transaction here." ) ); | 118 | QWhatsThis::add( label, tr( "Enter description of transaction here." ) ); |
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 | ||
121 | // Category | 127 | // Category |
122 | label = new QLabel( tr( "Category:" ), container ); | 128 | label = new QLabel( tr( "Category:" ), container ); |
123 | QWhatsThis::add( label, tr( "Select transaction category here." ) ); | 129 | QWhatsThis::add( label, tr( "Select transaction category here." ) ); |
124 | layout->addWidget( label, 3, 0 ); | 130 | layout->addWidget( label, 3, 0 ); |
125 | catList = new QComboBox( container ); | 131 | catList = new QComboBox( container ); |
@@ -131,12 +137,13 @@ Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *in | |||
131 | QWhatsThis::add( label, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) ); | 137 | QWhatsThis::add( label, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) ); |
132 | layout->addWidget( label, 4, 0 ); | 138 | layout->addWidget( label, 4, 0 ); |
133 | typeList = new QComboBox( container ); | 139 | typeList = new QComboBox( container ); |
134 | QWhatsThis::add( typeList, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) ); | 140 | QWhatsThis::add( typeList, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) ); |
135 | layout->addMultiCellWidget( typeList, 4, 4, 1, 3 ); | 141 | layout->addMultiCellWidget( typeList, 4, 4, 1, 3 ); |
136 | 142 | ||
143 | |||
137 | // Amount | 144 | // Amount |
138 | label = new QLabel( tr( "Amount:" ), container ); | 145 | label = new QLabel( tr( "Amount:" ), container ); |
139 | QWhatsThis::add( label, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) ); | 146 | QWhatsThis::add( label, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) ); |
140 | layout->addWidget( label, 5, 0 ); | 147 | layout->addWidget( label, 5, 0 ); |
141 | amtEdit = new QLineEdit( container ); | 148 | amtEdit = new QLineEdit( container ); |
142 | QWhatsThis::add( amtEdit, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) ); | 149 | QWhatsThis::add( amtEdit, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) ); |
@@ -155,12 +162,28 @@ Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *in | |||
155 | QWhatsThis::add( label, tr( "Enter any additional information for this transaction here." ) ); | 162 | QWhatsThis::add( label, tr( "Enter any additional information for this transaction here." ) ); |
156 | layout->addWidget( label, 7, 0 ); | 163 | layout->addWidget( label, 7, 0 ); |
157 | noteEdit = new QMultiLineEdit( container ); | 164 | noteEdit = new QMultiLineEdit( container ); |
158 | QWhatsThis::add( noteEdit, tr( "Enter any additional information for this transaction here." ) ); | 165 | QWhatsThis::add( noteEdit, tr( "Enter any additional information for this transaction here." ) ); |
159 | layout->addMultiCellWidget( noteEdit, 8, 8, 0, 3 ); | 166 | layout->addMultiCellWidget( noteEdit, 8, 8, 0, 3 ); |
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 |
162 | if ( info ) | 185 | if ( info ) |
163 | { | 186 | { |
164 | if ( info->withdrawal() ) | 187 | if ( info->withdrawal() ) |
165 | { | 188 | { |
166 | withBtn->setChecked( TRUE ); | 189 | withBtn->setChecked( TRUE ); |
@@ -168,19 +191,33 @@ Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *in | |||
168 | } | 191 | } |
169 | else | 192 | else |
170 | { | 193 | { |
171 | depBtn->setChecked( TRUE ); | 194 | depBtn->setChecked( TRUE ); |
172 | slotDepositClicked(); | 195 | slotDepositClicked(); |
173 | } | 196 | } |
197 | |||
198 | if( !bPopulateOld ) { | ||
174 | QDate dt = info->date(); | 199 | QDate dt = info->date(); |
175 | slotDateChanged( dt.year(), dt.month(), dt.day() ); | 200 | slotDateChanged( dt.year(), dt.month(), dt.day() ); |
176 | datePicker->setDate( dt ); | 201 | datePicker->setDate( dt ); |
177 | numEdit->setText( info->number() ); | 202 | numEdit->setText( info->number() ); |
178 | descEdit->setText( info->desc() ); | 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 ) |
182 | { | 219 | { |
183 | i--; | 220 | i--; |
184 | catList->setCurrentItem( i ); | 221 | catList->setCurrentItem( i ); |
185 | if ( catList->currentText() == temptext ) | 222 | if ( catList->currentText() == temptext ) |
186 | { | 223 | { |
@@ -205,19 +242,22 @@ Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *in | |||
205 | else | 242 | else |
206 | { | 243 | { |
207 | withBtn->setChecked( TRUE ); | 244 | withBtn->setChecked( TRUE ); |
208 | } | 245 | } |
209 | } | 246 | } |
210 | 247 | ||
248 | |||
249 | // --- ~Transaction ----------------------------------------------------------- | ||
211 | Transaction::~Transaction() | 250 | Transaction::~Transaction() |
212 | { | 251 | { |
213 | } | 252 | } |
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() ); |
219 | tran->setWithdrawal( withBtn->isChecked() ); | 259 | tran->setWithdrawal( withBtn->isChecked() ); |
220 | tran->setType( typeList->currentText() ); | 260 | tran->setType( typeList->currentText() ); |
221 | tran->setCategory( catList->currentText() ); | 261 | tran->setCategory( catList->currentText() ); |
222 | bool ok; | 262 | bool ok; |
223 | tran->setAmount( amtEdit->text().toFloat( &ok ) ); | 263 | tran->setAmount( amtEdit->text().toFloat( &ok ) ); |
@@ -259,12 +299,40 @@ void Transaction::slotDepositClicked() | |||
259 | typeList->insertItem( tr( "Written Check" ) ); | 299 | typeList->insertItem( tr( "Written Check" ) ); |
260 | typeList->insertItem( tr( "Automatic Payment" ) ); | 300 | typeList->insertItem( tr( "Automatic Payment" ) ); |
261 | typeList->insertItem( tr( "Transfer" ) ); | 301 | typeList->insertItem( tr( "Transfer" ) ); |
262 | typeList->insertItem( tr( "Cash" ) ); | 302 | typeList->insertItem( tr( "Cash" ) ); |
263 | } | 303 | } |
264 | 304 | ||
305 | // --- slotDateChanged -------------------------------------------------------- | ||
265 | void Transaction::slotDateChanged( int y, int m, int d ) | 306 | void Transaction::slotDateChanged( int y, int m, int d ) |
266 | { | 307 | { |
267 | QDate date; | 308 | QDate date; |
268 | date.setYMD( y, m, d ); | 309 | date.setYMD( y, m, d ); |
269 | dateBtn->setText( TimeString::shortDate( date ) ); | 310 | dateBtn->setText( TimeString::shortDate( date ) ); |
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 | |||
@@ -44,26 +44,28 @@ class Cfg; | |||
44 | 44 | ||
45 | class Transaction : public QDialog | 45 | class Transaction : public QDialog |
46 | { | 46 | { |
47 | Q_OBJECT | 47 | Q_OBJECT |
48 | 48 | ||
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 | void initFromInfo(TranInfo *, bool=false); | ||
54 | |||
53 | private: | 55 | private: |
54 | TranInfo *tran; | 56 | TranInfo *tran; |
55 | 57 | bool _bNew; | |
56 | Cfg *_pCfg; | 58 | Cfg *_pCfg; |
57 | 59 | ||
58 | QRadioButton *withBtn; | 60 | QRadioButton *withBtn; |
59 | QRadioButton *depBtn; | 61 | QRadioButton *depBtn; |
60 | QPushButton *dateBtn; | 62 | QPushButton *dateBtn; |
61 | DateBookMonth *datePicker; | 63 | DateBookMonth *datePicker; |
62 | QLineEdit *numEdit; | 64 | QLineEdit *numEdit; |
63 | QLineEdit *descEdit; | 65 | QComboBox *_cbDesc; |
64 | QComboBox *catList; | 66 | QComboBox *catList; |
65 | QComboBox *typeList; | 67 | QComboBox *typeList; |
66 | QLineEdit *amtEdit; | 68 | QLineEdit *amtEdit; |
67 | QLineEdit *feeEdit; | 69 | QLineEdit *feeEdit; |
68 | QMultiLineEdit *noteEdit; | 70 | QMultiLineEdit *noteEdit; |
69 | 71 | ||
@@ -71,9 +73,11 @@ class Transaction : public QDialog | |||
71 | void accept(); | 73 | void accept(); |
72 | 74 | ||
73 | private slots: | 75 | private slots: |
74 | void slotWithdrawalClicked(); | 76 | void slotWithdrawalClicked(); |
75 | void slotDepositClicked(); | 77 | void slotDepositClicked(); |
76 | void slotDateChanged( int, int, int ); | 78 | void slotDateChanged( int, int, int ); |
79 | void slotActivated(const QString & ); | ||
80 | void slotNotNew(); | ||
77 | }; | 81 | }; |
78 | 82 | ||
79 | #endif | 83 | #endif |