Diffstat (limited to 'noncore/apps/qashmoney/accountdisplay.cpp') (more/less context) (ignore whitespace changes)
-rwxr-xr-x | noncore/apps/qashmoney/accountdisplay.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/noncore/apps/qashmoney/accountdisplay.cpp b/noncore/apps/qashmoney/accountdisplay.cpp index 0fe5b09..046d997 100755 --- a/noncore/apps/qashmoney/accountdisplay.cpp +++ b/noncore/apps/qashmoney/accountdisplay.cpp | |||
@@ -1,33 +1,38 @@ | |||
1 | #include <qmessagebox.h> | ||
2 | #include <qheader.h> | ||
3 | |||
4 | #include "accountdisplay.h" | 1 | #include "accountdisplay.h" |
5 | #include "newaccount.h" | 2 | #include "newaccount.h" |
6 | #include "transaction.h" | 3 | #include "transaction.h" |
7 | #include "transferdialog.h" | 4 | #include "transferdialog.h" |
8 | #include "transfer.h" | 5 | #include "transfer.h" |
9 | 6 | ||
7 | /* OPIE */ | ||
8 | #include <opie2/odebug.h> | ||
9 | using namespace Opie::Core; | ||
10 | |||
11 | /* QT */ | ||
12 | #include <qmessagebox.h> | ||
13 | #include <qheader.h> | ||
14 | |||
10 | extern Account *account; | 15 | extern Account *account; |
11 | extern Transaction *transaction; | 16 | extern Transaction *transaction; |
12 | extern Transfer *transfer; | 17 | extern Transfer *transfer; |
13 | extern Preferences *preferences; | 18 | extern Preferences *preferences; |
14 | 19 | ||
15 | AccountDisplay::AccountDisplay ( QWidget *parent ) : QWidget ( parent ) | 20 | AccountDisplay::AccountDisplay ( QWidget *parent ) : QWidget ( parent ) |
16 | { | 21 | { |
17 | cleared = 0; | 22 | cleared = 0; |
18 | 23 | ||
19 | firstline = new QHBox ( this ); | 24 | firstline = new QHBox ( this ); |
20 | firstline->setSpacing ( 2 ); | 25 | firstline->setSpacing ( 2 ); |
21 | 26 | ||
22 | newaccount = new QPushButton ( firstline ); | 27 | newaccount = new QPushButton ( firstline ); |
23 | newaccount->setPixmap ( QPixmap ("/opt/QtPalmtop/pics/new.png") ); | 28 | newaccount->setPixmap ( QPixmap ("/opt/QtPalmtop/pics/new.png") ); |
24 | connect ( newaccount, SIGNAL ( released() ), this, SLOT ( addAccount() ) ); | 29 | connect ( newaccount, SIGNAL ( released() ), this, SLOT ( addAccount() ) ); |
25 | 30 | ||
26 | editaccount = new QPushButton ( firstline ); | 31 | editaccount = new QPushButton ( firstline ); |
27 | editaccount->setPixmap ( QPixmap ("/opt/QtPalmtop/pics/edit.png") ); | 32 | editaccount->setPixmap ( QPixmap ("/opt/QtPalmtop/pics/edit.png") ); |
28 | connect ( editaccount, SIGNAL ( released() ), this, SLOT ( editAccount() ) ); | 33 | connect ( editaccount, SIGNAL ( released() ), this, SLOT ( editAccount() ) ); |
29 | 34 | ||
30 | deleteaccount = new QPushButton ( firstline ); | 35 | deleteaccount = new QPushButton ( firstline ); |
31 | deleteaccount->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/delete.png") ); | 36 | deleteaccount->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/delete.png") ); |
32 | connect ( deleteaccount, SIGNAL ( released() ), this, SLOT ( deleteAccount() ) ); | 37 | connect ( deleteaccount, SIGNAL ( released() ), this, SLOT ( deleteAccount() ) ); |
33 | 38 | ||
@@ -246,49 +251,49 @@ void AccountDisplay::getTransferAccounts ( QListViewItem * item ) | |||
246 | firstaccountid = item->text ( getIDColumn() ).toInt(); // set first account if we've selected a valid account | 251 | firstaccountid = item->text ( getIDColumn() ).toInt(); // set first account if we've selected a valid account |
247 | else | 252 | else |
248 | if ( item->text ( getIDColumn() ).toInt() != firstaccountid ) // set the second account if its not equal to the first | 253 | if ( item->text ( getIDColumn() ).toInt() != firstaccountid ) // set the second account if its not equal to the first |
249 | secondaccountid = item->text ( getIDColumn() ).toInt(); | 254 | secondaccountid = item->text ( getIDColumn() ).toInt(); |
250 | } | 255 | } |
251 | 256 | ||
252 | // open transfer window if both accounts are set | 257 | // open transfer window if both accounts are set |
253 | if ( firstaccountid != -1 && secondaccountid != -1 ) | 258 | if ( firstaccountid != -1 && secondaccountid != -1 ) |
254 | { | 259 | { |
255 | // construct the transferdialog window | 260 | // construct the transferdialog window |
256 | TransferDialog *td = new TransferDialog ( this, firstaccountid, secondaccountid ); | 261 | TransferDialog *td = new TransferDialog ( this, firstaccountid, secondaccountid ); |
257 | 262 | ||
258 | // enter today's date in the date box as default | 263 | // enter today's date in the date box as default |
259 | QDate today = QDate::currentDate (); | 264 | QDate today = QDate::currentDate (); |
260 | int defaultday = today.day(); | 265 | int defaultday = today.day(); |
261 | int defaultmonth = today.month(); | 266 | int defaultmonth = today.month(); |
262 | int defaultyear = today.year(); | 267 | int defaultyear = today.year(); |
263 | td->date->setText ( preferences->getDate ( defaultyear, defaultmonth, defaultday ) ); | 268 | td->date->setText ( preferences->getDate ( defaultyear, defaultmonth, defaultday ) ); |
264 | 269 | ||
265 | if ( td->exec() == QDialog::Accepted ) | 270 | if ( td->exec() == QDialog::Accepted ) |
266 | { | 271 | { |
267 | // set the cleared integer if the checkbox is checked | 272 | // set the cleared integer if the checkbox is checked |
268 | if ( td->clearedcheckbox->isChecked() == TRUE ) | 273 | if ( td->clearedcheckbox->isChecked() == TRUE ) |
269 | cleared = 1; | 274 | cleared = 1; |
270 | qDebug("Year from transferdialog = %i",td->getYear()); | 275 | odebug << "Year from transferdialog = " << td->getYear() << "" << oendl; |
271 | // add the transfer with a new date if its been edited or use the default date | 276 | // add the transfer with a new date if its been edited or use the default date |
272 | if ( td->getDateEdited () == TRUE ) | 277 | if ( td->getDateEdited () == TRUE ) |
273 | transfer->addTransfer ( firstaccountid, account->getParentAccountID ( firstaccountid ), secondaccountid, account->getParentAccountID ( secondaccountid ), td->getDay(), td->getMonth(), td->getYear(), td->amount->text().toFloat(), cleared ); | 278 | transfer->addTransfer ( firstaccountid, account->getParentAccountID ( firstaccountid ), secondaccountid, account->getParentAccountID ( secondaccountid ), td->getDay(), td->getMonth(), td->getYear(), td->amount->text().toFloat(), cleared ); |
274 | else | 279 | else |
275 | transfer->addTransfer ( firstaccountid, account->getParentAccountID ( firstaccountid ), secondaccountid, account->getParentAccountID ( secondaccountid ), defaultday, defaultmonth, defaultyear, td->amount->text().toFloat(), cleared ); | 280 | transfer->addTransfer ( firstaccountid, account->getParentAccountID ( firstaccountid ), secondaccountid, account->getParentAccountID ( secondaccountid ), defaultday, defaultmonth, defaultyear, td->amount->text().toFloat(), cleared ); |
276 | 281 | ||
277 | // update account balances of both accounts and parents if necessary | 282 | // update account balances of both accounts and parents if necessary |
278 | account->updateAccountBalance ( firstaccountid ); | 283 | account->updateAccountBalance ( firstaccountid ); |
279 | if ( account->getParentAccountID ( firstaccountid ) != -1 ) | 284 | if ( account->getParentAccountID ( firstaccountid ) != -1 ) |
280 | account->changeParentAccountBalance ( account->getParentAccountID ( firstaccountid ) ); | 285 | account->changeParentAccountBalance ( account->getParentAccountID ( firstaccountid ) ); |
281 | account->updateAccountBalance ( secondaccountid ); | 286 | account->updateAccountBalance ( secondaccountid ); |
282 | if ( account->getParentAccountID ( secondaccountid ) != -1 ) | 287 | if ( account->getParentAccountID ( secondaccountid ) != -1 ) |
283 | account->changeParentAccountBalance ( account->getParentAccountID ( secondaccountid ) ); | 288 | account->changeParentAccountBalance ( account->getParentAccountID ( secondaccountid ) ); |
284 | 289 | ||
285 | // redisplay accounts | 290 | // redisplay accounts |
286 | account->displayAccounts ( listview ); | 291 | account->displayAccounts ( listview ); |
287 | } | 292 | } |
288 | else | 293 | else |
289 | { | 294 | { |
290 | firstaccountid = -1; | 295 | firstaccountid = -1; |
291 | secondaccountid = -1; | 296 | secondaccountid = -1; |
292 | listview->clearSelection (); | 297 | listview->clearSelection (); |
293 | listview->setMultiSelection ( FALSE ); | 298 | listview->setMultiSelection ( FALSE ); |
294 | disconnect ( listview, SIGNAL ( clicked(QListViewItem*) ), this, SLOT ( getTransferAccounts(QListViewItem*) ) ); | 299 | disconnect ( listview, SIGNAL ( clicked(QListViewItem*) ), this, SLOT ( getTransferAccounts(QListViewItem*) ) ); |