author | allenforsythe <allenforsythe> | 2003-05-16 10:01:09 (UTC) |
---|---|---|
committer | allenforsythe <allenforsythe> | 2003-05-16 10:01:09 (UTC) |
commit | c6de8acfd02b24dead5a1ff815c3f167a578a48b (patch) (unidiff) | |
tree | 6d5749b781a70741eb51e84d36974e30c3ffc1a6 | |
parent | 822414b8ac44ddc8c79aaffa630b45a13015d51a (diff) | |
download | opie-c6de8acfd02b24dead5a1ff815c3f167a578a48b.zip opie-c6de8acfd02b24dead5a1ff815c3f167a578a48b.tar.gz opie-c6de8acfd02b24dead5a1ff815c3f167a578a48b.tar.bz2 |
Fixed edit transfer and edit account/view account bugs
-rwxr-xr-x | noncore/apps/qashmoney/accountdisplay.cpp | 12 | ||||
-rwxr-xr-x | noncore/apps/qashmoney/qmaccounts.db | bin | 4096 -> 4096 bytes | |||
-rwxr-xr-x | noncore/apps/qashmoney/qmmemory.db | bin | 4096 -> 4096 bytes | |||
-rwxr-xr-x | noncore/apps/qashmoney/qmtransactions.db | bin | 4096 -> 4096 bytes | |||
-rwxr-xr-x | noncore/apps/qashmoney/qmtransfers.db | bin | 3072 -> 3072 bytes | |||
-rwxr-xr-x | noncore/apps/qashmoney/transactiondisplay.cpp | 2 |
6 files changed, 13 insertions, 1 deletions
diff --git a/noncore/apps/qashmoney/accountdisplay.cpp b/noncore/apps/qashmoney/accountdisplay.cpp index 46ab1db..b2c0838 100755 --- a/noncore/apps/qashmoney/accountdisplay.cpp +++ b/noncore/apps/qashmoney/accountdisplay.cpp | |||
@@ -224,209 +224,221 @@ void AccountDisplay::accountTransfer ( bool state ) | |||
224 | firstaccountid = -1; | 224 | firstaccountid = -1; |
225 | secondaccountid = -1; | 225 | secondaccountid = -1; |
226 | listview->clearSelection (); | 226 | listview->clearSelection (); |
227 | listview->setMultiSelection ( TRUE ); | 227 | listview->setMultiSelection ( TRUE ); |
228 | disableParentsWithChildren (); | 228 | disableParentsWithChildren (); |
229 | connect ( listview, SIGNAL ( clicked ( QListViewItem * ) ), this, SLOT ( getTransferAccounts ( QListViewItem * ) ) ); | 229 | connect ( listview, SIGNAL ( clicked ( QListViewItem * ) ), this, SLOT ( getTransferAccounts ( QListViewItem * ) ) ); |
230 | } | 230 | } |
231 | else | 231 | else |
232 | { | 232 | { |
233 | firstaccountid = -1; | 233 | firstaccountid = -1; |
234 | secondaccountid = -1; | 234 | secondaccountid = -1; |
235 | listview->clearSelection (); | 235 | listview->clearSelection (); |
236 | listview->setMultiSelection ( FALSE ); | 236 | listview->setMultiSelection ( FALSE ); |
237 | enableAccounts (); | 237 | enableAccounts (); |
238 | disconnect ( listview, SIGNAL ( clicked ( QListViewItem * ) ), this, SLOT ( getTransferAccounts ( QListViewItem * ) ) ); | 238 | disconnect ( listview, SIGNAL ( clicked ( QListViewItem * ) ), this, SLOT ( getTransferAccounts ( QListViewItem * ) ) ); |
239 | } | 239 | } |
240 | } | 240 | } |
241 | 241 | ||
242 | void AccountDisplay::getTransferAccounts ( QListViewItem * item ) | 242 | void AccountDisplay::getTransferAccounts ( QListViewItem * item ) |
243 | { | 243 | { |
244 | if ( item->parent() != 0 || item->childCount() == 0 ) // only set an account for transfer if its a child or parent with no children | 244 | if ( item->parent() != 0 || item->childCount() == 0 ) // only set an account for transfer if its a child or parent with no children |
245 | { | 245 | { |
246 | if ( firstaccountid == -1 ) | 246 | if ( firstaccountid == -1 ) |
247 | firstaccountid = item->text ( getIDColumn() ).toInt(); // set first account if we've selected a valid account | 247 | firstaccountid = item->text ( getIDColumn() ).toInt(); // set first account if we've selected a valid account |
248 | else | 248 | else |
249 | if ( item->text ( getIDColumn() ).toInt() != firstaccountid ) // set the second account if its not equal to the first | 249 | if ( item->text ( getIDColumn() ).toInt() != firstaccountid ) // set the second account if its not equal to the first |
250 | secondaccountid = item->text ( getIDColumn() ).toInt(); | 250 | secondaccountid = item->text ( getIDColumn() ).toInt(); |
251 | } | 251 | } |
252 | 252 | ||
253 | // open transfer window if both accounts are set | 253 | // open transfer window if both accounts are set |
254 | if ( firstaccountid != -1 && secondaccountid != -1 ) | 254 | if ( firstaccountid != -1 && secondaccountid != -1 ) |
255 | { | 255 | { |
256 | // construct the transferdialog window | 256 | // construct the transferdialog window |
257 | TransferDialog *td = new TransferDialog ( this, firstaccountid, secondaccountid ); | 257 | TransferDialog *td = new TransferDialog ( this, firstaccountid, secondaccountid ); |
258 | 258 | ||
259 | // enter today's date in the date box as default | 259 | // enter today's date in the date box as default |
260 | QDate today = QDate::currentDate (); | 260 | QDate today = QDate::currentDate (); |
261 | int defaultday = today.day(); | 261 | int defaultday = today.day(); |
262 | int defaultmonth = today.month(); | 262 | int defaultmonth = today.month(); |
263 | int defaultyear = today.year(); | 263 | int defaultyear = today.year(); |
264 | td->date->setText ( preferences->getDate ( defaultyear, defaultmonth, defaultday ) ); | 264 | td->date->setText ( preferences->getDate ( defaultyear, defaultmonth, defaultday ) ); |
265 | 265 | ||
266 | if ( td->exec() == QDialog::Accepted ) | 266 | if ( td->exec() == QDialog::Accepted ) |
267 | { | 267 | { |
268 | // set the cleared integer if the checkbox is checked | 268 | // set the cleared integer if the checkbox is checked |
269 | if ( td->clearedcheckbox->isChecked() == TRUE ) | 269 | if ( td->clearedcheckbox->isChecked() == TRUE ) |
270 | cleared = 1; | 270 | cleared = 1; |
271 | 271 | ||
272 | // add the transfer with a new date if its been edited or use the default date | 272 | // add the transfer with a new date if its been edited or use the default date |
273 | if ( td->getDateEdited () == TRUE ) | 273 | if ( td->getDateEdited () == TRUE ) |
274 | transfer->addTransfer ( firstaccountid, account->getParentAccountID ( firstaccountid ), secondaccountid, | 274 | transfer->addTransfer ( firstaccountid, account->getParentAccountID ( firstaccountid ), secondaccountid, |
275 | account->getParentAccountID ( secondaccountid ), td->getDay(), td->getMonth(), td->getYear(), td->amount->text().toFloat(), cleared ); | 275 | account->getParentAccountID ( secondaccountid ), td->getDay(), td->getMonth(), td->getYear(), td->amount->text().toFloat(), cleared ); |
276 | else | 276 | else |
277 | transfer->addTransfer ( firstaccountid, account->getParentAccountID ( firstaccountid ), secondaccountid, | 277 | transfer->addTransfer ( firstaccountid, account->getParentAccountID ( firstaccountid ), secondaccountid, |
278 | account->getParentAccountID ( secondaccountid ), defaultday, defaultmonth, defaultyear, td->amount->text().toFloat(), cleared ); | 278 | account->getParentAccountID ( secondaccountid ), defaultday, defaultmonth, defaultyear, td->amount->text().toFloat(), cleared ); |
279 | 279 | ||
280 | // update account balances of both accounts and parents if necessary | 280 | // update account balances of both accounts and parents if necessary |
281 | account->updateAccountBalance ( firstaccountid ); | 281 | account->updateAccountBalance ( firstaccountid ); |
282 | if ( account->getParentAccountID ( firstaccountid ) != -1 ) | 282 | if ( account->getParentAccountID ( firstaccountid ) != -1 ) |
283 | account->changeParentAccountBalance ( account->getParentAccountID ( firstaccountid ) ); | 283 | account->changeParentAccountBalance ( account->getParentAccountID ( firstaccountid ) ); |
284 | account->updateAccountBalance ( secondaccountid ); | 284 | account->updateAccountBalance ( secondaccountid ); |
285 | if ( account->getParentAccountID ( secondaccountid ) != -1 ) | 285 | if ( account->getParentAccountID ( secondaccountid ) != -1 ) |
286 | account->changeParentAccountBalance ( account->getParentAccountID ( secondaccountid ) ); | 286 | account->changeParentAccountBalance ( account->getParentAccountID ( secondaccountid ) ); |
287 | 287 | ||
288 | // redisplay accounts | 288 | // redisplay accounts |
289 | account->displayAccounts ( listview ); | 289 | account->displayAccounts ( listview ); |
290 | } | 290 | } |
291 | else | 291 | else |
292 | { | 292 | { |
293 | firstaccountid = -1; | 293 | firstaccountid = -1; |
294 | secondaccountid = -1; | 294 | secondaccountid = -1; |
295 | listview->clearSelection (); | 295 | listview->clearSelection (); |
296 | listview->setMultiSelection ( FALSE ); | 296 | listview->setMultiSelection ( FALSE ); |
297 | disconnect ( listview, SIGNAL ( clicked ( QListViewItem * ) ), this, SLOT ( getTransferAccounts ( QListViewItem * ) ) ); | 297 | disconnect ( listview, SIGNAL ( clicked ( QListViewItem * ) ), this, SLOT ( getTransferAccounts ( QListViewItem * ) ) ); |
298 | } | 298 | } |
299 | 299 | ||
300 | // reset the accounts display window | 300 | // reset the accounts display window |
301 | transferbutton->toggle(); // toggling this button with clear the window as well | 301 | transferbutton->toggle(); // toggling this button with clear the window as well |
302 | 302 | ||
303 | // reenable all the accounts so the transaction tab will be properly set | 303 | // reenable all the accounts so the transaction tab will be properly set |
304 | enableAccounts (); | 304 | enableAccounts (); |
305 | } | 305 | } |
306 | } | 306 | } |
307 | 307 | ||
308 | void AccountDisplay::disableParentsWithChildren () | 308 | void AccountDisplay::disableParentsWithChildren () |
309 | { | 309 | { |
310 | // iterate through accountdisplay listview and disable all the parents that have children | 310 | // iterate through accountdisplay listview and disable all the parents that have children |
311 | QListViewItemIterator it ( listview ); | 311 | QListViewItemIterator it ( listview ); |
312 | for ( ; it.current(); ++it ) | 312 | for ( ; it.current(); ++it ) |
313 | { | 313 | { |
314 | if ( it.current()->parent() == 0 && it.current()->childCount() != 0 ) | 314 | if ( it.current()->parent() == 0 && it.current()->childCount() != 0 ) |
315 | it.current()->setSelectable ( FALSE ); | 315 | it.current()->setSelectable ( FALSE ); |
316 | } | 316 | } |
317 | } | 317 | } |
318 | 318 | ||
319 | void AccountDisplay::enableAccounts () | 319 | void AccountDisplay::enableAccounts () |
320 | { | 320 | { |
321 | // iterate through accountdisplay listview and enable all accounts | 321 | // iterate through accountdisplay listview and enable all accounts |
322 | QListViewItemIterator it ( listview ); | 322 | QListViewItemIterator it ( listview ); |
323 | for ( ; it.current(); ++it ) | 323 | for ( ; it.current(); ++it ) |
324 | it.current()->setSelectable ( TRUE ); | 324 | it.current()->setSelectable ( TRUE ); |
325 | } | 325 | } |
326 | 326 | ||
327 | void AccountDisplay::saveColumnSize ( int column, int oldsize, int newsize ) | 327 | void AccountDisplay::saveColumnSize ( int column, int oldsize, int newsize ) |
328 | { | 328 | { |
329 | switch ( column ) | 329 | switch ( column ) |
330 | { | 330 | { |
331 | case 0: | 331 | case 0: |
332 | if ( listview->columns() == 3 ) | 332 | if ( listview->columns() == 3 ) |
333 | preferences->changeColumnPreference ( 1, newsize ); | 333 | preferences->changeColumnPreference ( 1, newsize ); |
334 | else | 334 | else |
335 | preferences->changeColumnPreference ( 10, newsize ); | 335 | preferences->changeColumnPreference ( 10, newsize ); |
336 | break; | 336 | break; |
337 | case 1: | 337 | case 1: |
338 | if ( listview->columns() == 3 ) | 338 | if ( listview->columns() == 3 ) |
339 | preferences->changeColumnPreference ( 2, newsize ); | 339 | preferences->changeColumnPreference ( 2, newsize ); |
340 | else | 340 | else |
341 | preferences->changeColumnPreference ( 11, newsize ); | 341 | preferences->changeColumnPreference ( 11, newsize ); |
342 | break; | 342 | break; |
343 | case 2: | 343 | case 2: |
344 | preferences->changeColumnPreference ( 12, newsize ); | 344 | preferences->changeColumnPreference ( 12, newsize ); |
345 | break; | 345 | break; |
346 | } | 346 | } |
347 | 347 | ||
348 | } | 348 | } |
349 | 349 | ||
350 | int AccountDisplay::getIDColumn () | 350 | int AccountDisplay::getIDColumn () |
351 | { | 351 | { |
352 | int counter; | 352 | int counter; |
353 | int columns = listview->columns(); | 353 | int columns = listview->columns(); |
354 | for ( counter = 0; counter <= columns; counter++ ) | 354 | for ( counter = 0; counter <= columns; counter++ ) |
355 | if ( listview->header()->label ( counter ).length() == 0 ) | 355 | if ( listview->header()->label ( counter ).length() == 0 ) |
356 | return counter; | 356 | return counter; |
357 | } | 357 | } |
358 | 358 | ||
359 | void AccountDisplay::editAccount () | 359 | void AccountDisplay::editAccount () |
360 | { | 360 | { |
361 | if ( listview->selectedItem() == 0 ) | 361 | if ( listview->selectedItem() == 0 ) |
362 | QMessageBox::warning ( this, "QashMoney", "Please select an account\nto edit."); | 362 | QMessageBox::warning ( this, "QashMoney", "Please select an account\nto edit."); |
363 | else | 363 | else |
364 | { | 364 | { |
365 | // set the accountid | 365 | // set the accountid |
366 | int accountid = listview->selectedItem()->text ( getIDColumn() ).toInt(); | 366 | int accountid = listview->selectedItem()->text ( getIDColumn() ).toInt(); |
367 | 367 | ||
368 | //construct new dialog box | 368 | //construct new dialog box |
369 | QDialog *editaccountwindow = new QDialog ( this, 0, TRUE ); | 369 | QDialog *editaccountwindow = new QDialog ( this, 0, TRUE ); |
370 | editaccountwindow->setCaption ( "Edit Account" ); | 370 | editaccountwindow->setCaption ( "Edit Account" ); |
371 | 371 | ||
372 | // construct the items which will go in the dialog bix | 372 | // construct the items which will go in the dialog bix |
373 | QLabel *namelabel = new QLabel ( "Account Name", editaccountwindow ); | 373 | QLabel *namelabel = new QLabel ( "Account Name", editaccountwindow ); |
374 | QLineEdit *accountname = new QLineEdit ( editaccountwindow ); | 374 | QLineEdit *accountname = new QLineEdit ( editaccountwindow ); |
375 | QLabel *descriptionlabel = new QLabel ( "Account Description", editaccountwindow ); | 375 | QLabel *descriptionlabel = new QLabel ( "Account Description", editaccountwindow ); |
376 | QLineEdit *accountdescription = new QLineEdit ( editaccountwindow ); | 376 | QLineEdit *accountdescription = new QLineEdit ( editaccountwindow ); |
377 | Currency *currencybox = new Currency ( editaccountwindow ); | 377 | Currency *currencybox = new Currency ( editaccountwindow ); |
378 | 378 | ||
379 | QVBoxLayout *layout = new QVBoxLayout ( editaccountwindow, 5, 2 ); | 379 | QVBoxLayout *layout = new QVBoxLayout ( editaccountwindow, 5, 2 ); |
380 | layout->addWidget ( namelabel ); | 380 | layout->addWidget ( namelabel ); |
381 | layout->addWidget ( accountname ); | 381 | layout->addWidget ( accountname ); |
382 | layout->addWidget ( descriptionlabel ); | 382 | layout->addWidget ( descriptionlabel ); |
383 | layout->addWidget ( accountdescription ); | 383 | layout->addWidget ( accountdescription ); |
384 | layout->addWidget ( currencybox ); | 384 | layout->addWidget ( currencybox ); |
385 | 385 | ||
386 | //set the account name | 386 | //set the account name |
387 | accountname->setText ( listview->selectedItem()->text ( 0 ) ); | 387 | accountname->setText ( listview->selectedItem()->text ( 0 ) ); |
388 | 388 | ||
389 | //set the account description | 389 | //set the account description |
390 | accountdescription->setText ( account->getAccountDescription ( accountid ) ); | 390 | accountdescription->setText ( account->getAccountDescription ( accountid ) ); |
391 | 391 | ||
392 | if ( preferences->getPreference ( 4 ) == 1 ) | 392 | if ( preferences->getPreference ( 4 ) == 1 ) |
393 | { | 393 | { |
394 | // get currency code for this account then iterate through the currency box | 394 | // get currency code for this account then iterate through the currency box |
395 | // to find the one we want | 395 | // to find the one we want |
396 | int count = currencybox->currencybox->count(); | 396 | int count = currencybox->currencybox->count(); |
397 | QString code = account->getCurrencyCode ( accountid ); | 397 | QString code = account->getCurrencyCode ( accountid ); |
398 | for ( int counter = 0; count - 1; counter++ ) | 398 | for ( int counter = 0; count - 1; counter++ ) |
399 | { | 399 | { |
400 | if ( QString::compare ( currencybox->currencybox->text ( counter ), code ) == 0 ) | 400 | if ( QString::compare ( currencybox->currencybox->text ( counter ), code ) == 0 ) |
401 | { | 401 | { |
402 | currencybox->currencybox->setCurrentItem ( counter ); | 402 | currencybox->currencybox->setCurrentItem ( counter ); |
403 | break; | 403 | break; |
404 | } | 404 | } |
405 | } | 405 | } |
406 | } | 406 | } |
407 | else | 407 | else |
408 | currencybox->setEnabled ( FALSE ); | 408 | currencybox->setEnabled ( FALSE ); |
409 | 409 | ||
410 | //execute the dialog box | 410 | //execute the dialog box |
411 | int response = editaccountwindow->exec(); | 411 | int response = editaccountwindow->exec(); |
412 | if ( response == 1 ) | 412 | if ( response == 1 ) |
413 | { | 413 | { |
414 | account->updateAccount ( accountname->text(), accountdescription->text(), currencybox->currencybox->currentText(), accountid ); | 414 | account->updateAccount ( accountname->text(), accountdescription->text(), currencybox->currencybox->currentText(), accountid ); |
415 | account->displayAccounts ( listview ); | 415 | account->displayAccounts ( listview ); |
416 | |||
417 | // Try and select the same account that was just edited | ||
418 | QListViewItemIterator it ( listview ); | ||
419 | for ( ; it.current(); ++it ) | ||
420 | { | ||
421 | if ( it.current()->text ( 0 ) == accountname->text() ) | ||
422 | { | ||
423 | listview->setSelected ( it.current(), TRUE ); | ||
424 | return; | ||
425 | } | ||
426 | } | ||
427 | maintabs->setTabEnabled ( tab2, FALSE ); | ||
416 | } | 428 | } |
417 | } | 429 | } |
418 | } | 430 | } |
419 | 431 | ||
420 | void AccountDisplay::setAccountExpanded ( QListViewItem *item ) | 432 | void AccountDisplay::setAccountExpanded ( QListViewItem *item ) |
421 | { | 433 | { |
422 | int accountid = item->text ( getIDColumn() ).toInt(); | 434 | int accountid = item->text ( getIDColumn() ).toInt(); |
423 | account->setAccountExpanded ( 1, accountid ); | 435 | account->setAccountExpanded ( 1, accountid ); |
424 | } | 436 | } |
425 | 437 | ||
426 | void AccountDisplay::setAccountCollapsed ( QListViewItem *item ) | 438 | void AccountDisplay::setAccountCollapsed ( QListViewItem *item ) |
427 | { | 439 | { |
428 | int accountid = item->text ( getIDColumn() ).toInt(); | 440 | int accountid = item->text ( getIDColumn() ).toInt(); |
429 | account->setAccountExpanded ( 0, accountid ); | 441 | account->setAccountExpanded ( 0, accountid ); |
430 | } | 442 | } |
431 | 443 | ||
432 | 444 | ||
diff --git a/noncore/apps/qashmoney/qmaccounts.db b/noncore/apps/qashmoney/qmaccounts.db index 1c6f024..449bcab 100755 --- a/noncore/apps/qashmoney/qmaccounts.db +++ b/noncore/apps/qashmoney/qmaccounts.db | |||
Binary files differ | |||
diff --git a/noncore/apps/qashmoney/qmmemory.db b/noncore/apps/qashmoney/qmmemory.db index be33cd4..5c23122 100755 --- a/noncore/apps/qashmoney/qmmemory.db +++ b/noncore/apps/qashmoney/qmmemory.db | |||
Binary files differ | |||
diff --git a/noncore/apps/qashmoney/qmtransactions.db b/noncore/apps/qashmoney/qmtransactions.db index 1b05561..9e4acc9 100755 --- a/noncore/apps/qashmoney/qmtransactions.db +++ b/noncore/apps/qashmoney/qmtransactions.db | |||
Binary files differ | |||
diff --git a/noncore/apps/qashmoney/qmtransfers.db b/noncore/apps/qashmoney/qmtransfers.db index 4c04b5f..c31df1a 100755 --- a/noncore/apps/qashmoney/qmtransfers.db +++ b/noncore/apps/qashmoney/qmtransfers.db | |||
Binary files differ | |||
diff --git a/noncore/apps/qashmoney/transactiondisplay.cpp b/noncore/apps/qashmoney/transactiondisplay.cpp index 6e5c4f6..14f5641 100755 --- a/noncore/apps/qashmoney/transactiondisplay.cpp +++ b/noncore/apps/qashmoney/transactiondisplay.cpp | |||
@@ -72,385 +72,385 @@ TransactionDisplay::TransactionDisplay ( QWidget* parent ) : QWidget ( parent ) | |||
72 | layout->addWidget ( firstline ); | 72 | layout->addWidget ( firstline ); |
73 | layout->addWidget ( secondline ); | 73 | layout->addWidget ( secondline ); |
74 | layout->addWidget ( listview ); | 74 | layout->addWidget ( listview ); |
75 | } | 75 | } |
76 | 76 | ||
77 | void TransactionDisplay::addTransaction () | 77 | void TransactionDisplay::addTransaction () |
78 | { | 78 | { |
79 | // create local variables | 79 | // create local variables |
80 | int cleared = -1; | 80 | int cleared = -1; |
81 | 81 | ||
82 | // create new transaction window | 82 | // create new transaction window |
83 | NewTransaction *newtransaction = new NewTransaction ( this ); | 83 | NewTransaction *newtransaction = new NewTransaction ( this ); |
84 | int width = this->size().width(); | 84 | int width = this->size().width(); |
85 | newtransaction->transactionname->setMaximumWidth ( ( int ) ( width * 0.45 ) ); | 85 | newtransaction->transactionname->setMaximumWidth ( ( int ) ( width * 0.45 ) ); |
86 | newtransaction->transactionname->setMinimumWidth ( ( int ) ( width * 0.35 ) ); | 86 | newtransaction->transactionname->setMinimumWidth ( ( int ) ( width * 0.35 ) ); |
87 | newtransaction->lineitembox->setMaximumWidth ( ( int ) ( width * 0.45 ) ); | 87 | newtransaction->lineitembox->setMaximumWidth ( ( int ) ( width * 0.45 ) ); |
88 | newtransaction->transactiondatebox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); | 88 | newtransaction->transactiondatebox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); |
89 | newtransaction->transactionamountbox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); | 89 | newtransaction->transactionamountbox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); |
90 | newtransaction->transactionnumber->setMaximumWidth ( ( int ) ( width * 0.25 ) ); | 90 | newtransaction->transactionnumber->setMaximumWidth ( ( int ) ( width * 0.25 ) ); |
91 | 91 | ||
92 | // enter today's date in the date box as defaul | 92 | // enter today's date in the date box as defaul |
93 | QDate today = QDate::currentDate (); | 93 | QDate today = QDate::currentDate (); |
94 | int defaultday = today.day(); | 94 | int defaultday = today.day(); |
95 | int defaultmonth = today.month(); | 95 | int defaultmonth = today.month(); |
96 | int defaultyear = today.year(); | 96 | int defaultyear = today.year(); |
97 | newtransaction->transactiondate->setText ( preferences->getDate ( defaultyear, defaultmonth, defaultday ) ); | 97 | newtransaction->transactiondate->setText ( preferences->getDate ( defaultyear, defaultmonth, defaultday ) ); |
98 | 98 | ||
99 | // add memory items to the transactionname combobox | 99 | // add memory items to the transactionname combobox |
100 | memory->displayMemoryItems ( newtransaction->transactionname ); | 100 | memory->displayMemoryItems ( newtransaction->transactionname ); |
101 | newtransaction->transactionname->insertItem ( "", 0 ); | 101 | newtransaction->transactionname->insertItem ( "", 0 ); |
102 | 102 | ||
103 | if ( newtransaction->exec () == QDialog::Accepted ) | 103 | if ( newtransaction->exec () == QDialog::Accepted ) |
104 | { | 104 | { |
105 | if ( newtransaction->clearedcheckbox->isChecked () == TRUE ) // set a parent id and type for a child transaction | 105 | if ( newtransaction->clearedcheckbox->isChecked () == TRUE ) // set a parent id and type for a child transaction |
106 | cleared = 1; | 106 | cleared = 1; |
107 | else | 107 | else |
108 | cleared = 0; | 108 | cleared = 0; |
109 | 109 | ||
110 | float amount = newtransaction->transactionamount->text().toFloat(); | 110 | float amount = newtransaction->transactionamount->text().toFloat(); |
111 | if ( newtransaction->depositbox->isChecked() == FALSE ) | 111 | if ( newtransaction->depositbox->isChecked() == FALSE ) |
112 | amount = amount * -1; | 112 | amount = amount * -1; |
113 | 113 | ||
114 | // add the transaction name to the memory items | 114 | // add the transaction name to the memory items |
115 | memory->addMemoryItem ( newtransaction->transactionname->currentText() ); | 115 | memory->addMemoryItem ( newtransaction->transactionname->currentText() ); |
116 | 116 | ||
117 | // add the transaction | 117 | // add the transaction |
118 | if ( newtransaction->getDateEdited () == TRUE ) | 118 | if ( newtransaction->getDateEdited () == TRUE ) |
119 | transaction->addTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), accountid, account->getParentAccountID ( accountid ), | 119 | transaction->addTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), accountid, account->getParentAccountID ( accountid ), |
120 | newtransaction->transactionnumber->text().toInt(), newtransaction->getDay(), newtransaction->getMonth(), newtransaction->getYear(), amount, cleared, newtransaction->getCurrentBudget(), | 120 | newtransaction->transactionnumber->text().toInt(), newtransaction->getDay(), newtransaction->getMonth(), newtransaction->getYear(), amount, cleared, newtransaction->getCurrentBudget(), |
121 | newtransaction->getCurrentLineItem() ); | 121 | newtransaction->getCurrentLineItem() ); |
122 | else | 122 | else |
123 | transaction->addTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), accountid, account->getParentAccountID ( accountid ), | 123 | transaction->addTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), accountid, account->getParentAccountID ( accountid ), |
124 | newtransaction->transactionnumber->text().toInt(), defaultday, defaultmonth, defaultyear, amount, cleared, newtransaction->getCurrentBudget(), newtransaction->getCurrentLineItem() ); | 124 | newtransaction->transactionnumber->text().toInt(), defaultday, defaultmonth, defaultyear, amount, cleared, newtransaction->getCurrentBudget(), newtransaction->getCurrentLineItem() ); |
125 | 125 | ||
126 | // redisplay transactions | 126 | // redisplay transactions |
127 | listview->clear(); | 127 | listview->clear(); |
128 | QString displaytext = "%"; | 128 | QString displaytext = "%"; |
129 | displaytext.prepend ( limitbox->text() ); | 129 | displaytext.prepend ( limitbox->text() ); |
130 | if ( transaction->getNumberOfTransactions() > 0 ) | 130 | if ( transaction->getNumberOfTransactions() > 0 ) |
131 | transaction->displayTransactions ( listview, accountid, children, displaytext ); | 131 | transaction->displayTransactions ( listview, accountid, children, displaytext ); |
132 | 132 | ||
133 | // redisplay transfers | 133 | // redisplay transfers |
134 | if ( transfer->getNumberOfTransfers() > 0 ) | 134 | if ( transfer->getNumberOfTransfers() > 0 ) |
135 | transfer->displayTransfers ( listview, accountid, children ); | 135 | transfer->displayTransfers ( listview, accountid, children ); |
136 | 136 | ||
137 | // add the transaction amount to the account it's associated with | 137 | // add the transaction amount to the account it's associated with |
138 | // and update its parent account balance if necessary | 138 | // and update its parent account balance if necessary |
139 | account->updateAccountBalance ( accountid ); | 139 | account->updateAccountBalance ( accountid ); |
140 | if ( account->getParentAccountID ( accountid ) != -1 ) | 140 | if ( account->getParentAccountID ( accountid ) != -1 ) |
141 | account->changeParentAccountBalance ( account->getParentAccountID ( accountid ) ); | 141 | account->changeParentAccountBalance ( account->getParentAccountID ( accountid ) ); |
142 | 142 | ||
143 | // format then reset the account balance | 143 | // format then reset the account balance |
144 | redisplayAccountBalance (); | 144 | redisplayAccountBalance (); |
145 | } | 145 | } |
146 | } | 146 | } |
147 | 147 | ||
148 | void TransactionDisplay::checkListViewEdit () | 148 | void TransactionDisplay::checkListViewEdit () |
149 | { | 149 | { |
150 | if ( listview->selectedItem() == 0 ) | 150 | if ( listview->selectedItem() == 0 ) |
151 | QMessageBox::warning ( this, "QashMoney", "Please select a transaction\nto edit."); | 151 | QMessageBox::warning ( this, "QashMoney", "Please select a transaction\nto edit."); |
152 | else if ( listview->currentItem()->text ( getIDColumn() ).toInt() < 0 ) | 152 | else if ( listview->currentItem()->text ( getIDColumn() ).toInt() < 0 ) |
153 | editTransfer (); | 153 | editTransfer (); |
154 | else | 154 | else |
155 | editTransaction(); | 155 | editTransaction(); |
156 | } | 156 | } |
157 | 157 | ||
158 | void TransactionDisplay::showCalculator () | 158 | void TransactionDisplay::showCalculator () |
159 | { | 159 | { |
160 | Calculator *calculator = new Calculator ( this ); | 160 | Calculator *calculator = new Calculator ( this ); |
161 | if ( calculator->exec () == QDialog::Accepted ) | 161 | if ( calculator->exec () == QDialog::Accepted ) |
162 | amount->setText ( calculator->display->text() ); | 162 | amount->setText ( calculator->display->text() ); |
163 | } | 163 | } |
164 | 164 | ||
165 | void TransactionDisplay::showCalendar () | 165 | void TransactionDisplay::showCalendar () |
166 | { | 166 | { |
167 | QDate newDate = QDate::currentDate (); | 167 | QDate newDate = QDate::currentDate (); |
168 | DatePicker *dp = new DatePicker ( newDate ); | 168 | DatePicker *dp = new DatePicker ( newDate ); |
169 | if ( dp->exec () == QDialog::Accepted ) | 169 | if ( dp->exec () == QDialog::Accepted ) |
170 | { | 170 | { |
171 | year = dp->getYear(); | 171 | year = dp->getYear(); |
172 | month = dp->getMonth(); | 172 | month = dp->getMonth(); |
173 | day = dp->getDay(); | 173 | day = dp->getDay(); |
174 | date->setText ( preferences->getDate ( year, month, day ) ); | 174 | date->setText ( preferences->getDate ( year, month, day ) ); |
175 | } | 175 | } |
176 | } | 176 | } |
177 | 177 | ||
178 | void TransactionDisplay::editTransfer () | 178 | void TransactionDisplay::editTransfer () |
179 | { | 179 | { |
180 | transferid = listview->currentItem()->text ( getIDColumn() ).toInt(); | 180 | transferid = listview->currentItem()->text ( getIDColumn() ).toInt(); |
181 | fromaccount = transfer->getFromAccountID ( transferid ); | 181 | fromaccount = transfer->getFromAccountID ( transferid ); |
182 | toaccount = transfer->getToAccountID ( transferid ); | 182 | toaccount = transfer->getToAccountID ( transferid ); |
183 | year = transfer->getYear ( transferid ); | 183 | year = transfer->getYear ( transferid ); |
184 | month = transfer->getMonth ( transferid ); | 184 | month = transfer->getMonth ( transferid ); |
185 | day = transfer->getDay ( transferid ); | 185 | day = transfer->getDay ( transferid ); |
186 | 186 | ||
187 | QDialog *editransfer = new QDialog ( this, "edittransfer", TRUE ); | 187 | QDialog *editransfer = new QDialog ( this, "edittransfer", TRUE ); |
188 | editransfer->setCaption ( "Transfer" ); | 188 | editransfer->setCaption ( "Transfer" ); |
189 | 189 | ||
190 | QStringList accountnames = account->getAccountNames(); | 190 | QStringList accountnames = account->getAccountNames(); |
191 | QStringList accountids = account->getAccountIDs(); | 191 | QStringList accountids = account->getAccountIDs(); |
192 | 192 | ||
193 | QLabel *fromaccountlabel = new QLabel ( "From Account:", editransfer ); | 193 | QLabel *fromaccountlabel = new QLabel ( "From Account:", editransfer ); |
194 | QFont f = this->font(); | 194 | QFont f = this->font(); |
195 | f.setWeight ( QFont::Bold ); | 195 | f.setWeight ( QFont::Bold ); |
196 | fromaccountlabel->setFont ( f ); | 196 | fromaccountlabel->setFont ( f ); |
197 | 197 | ||
198 | QComboBox *fromaccountbox = new QComboBox ( editransfer ); | 198 | QComboBox *fromaccountbox = new QComboBox ( editransfer ); |
199 | fromaccountbox->insertStringList ( accountnames ); | 199 | fromaccountbox->insertStringList ( accountnames ); |
200 | fromaccountbox->setCurrentItem ( accountids.findIndex ( QString::number ( fromaccount ) ) ); | 200 | fromaccountbox->setCurrentItem ( accountids.findIndex ( QString::number ( fromaccount ) ) ); |
201 | 201 | ||
202 | QLabel *toaccountlabel = new QLabel ( "To Account:", editransfer ); | 202 | QLabel *toaccountlabel = new QLabel ( "To Account:", editransfer ); |
203 | toaccountlabel->setFont ( f ); | 203 | toaccountlabel->setFont ( f ); |
204 | 204 | ||
205 | QComboBox *toaccountbox = new QComboBox ( editransfer ); | 205 | QComboBox *toaccountbox = new QComboBox ( editransfer ); |
206 | toaccountbox->insertStringList ( accountnames ); | 206 | toaccountbox->insertStringList ( accountnames ); |
207 | toaccountbox->setCurrentItem ( accountids.findIndex ( QString::number ( toaccount ) ) ); | 207 | toaccountbox->setCurrentItem ( accountids.findIndex ( QString::number ( toaccount ) ) ); |
208 | 208 | ||
209 | QLabel *datelabel = new QLabel ( "Date", editransfer ); | 209 | QLabel *datelabel = new QLabel ( "Date", editransfer ); |
210 | QHBox *datebox = new QHBox ( editransfer ); | 210 | QHBox *datebox = new QHBox ( editransfer ); |
211 | datebox->setSpacing ( 2 ); | 211 | datebox->setSpacing ( 2 ); |
212 | date = new QLineEdit ( datebox ); | 212 | date = new QLineEdit ( datebox ); |
213 | date->setAlignment ( Qt::AlignRight ); | 213 | date->setAlignment ( Qt::AlignRight ); |
214 | date->setDisabled ( TRUE ); | 214 | date->setDisabled ( TRUE ); |
215 | date->setText ( preferences->getDate ( year, month, day ) ); | 215 | date->setText ( preferences->getDate ( year, month, day ) ); |
216 | QPushButton *datebutton = new QPushButton ( datebox ); | 216 | QPushButton *datebutton = new QPushButton ( datebox ); |
217 | datebutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/date.png" ) ); | 217 | datebutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/date.png" ) ); |
218 | connect ( datebutton, SIGNAL ( released () ), this, SLOT ( showCalendar () ) ); | 218 | connect ( datebutton, SIGNAL ( released () ), this, SLOT ( showCalendar () ) ); |
219 | 219 | ||
220 | QLabel *amounttlabel = new QLabel ( "Amount", editransfer ); | 220 | QLabel *amounttlabel = new QLabel ( "Amount", editransfer ); |
221 | 221 | ||
222 | QHBox *amountbox = new QHBox ( editransfer ); | 222 | QHBox *amountbox = new QHBox ( editransfer ); |
223 | amountbox->setSpacing ( 2 ); | 223 | amountbox->setSpacing ( 2 ); |
224 | amount = new QLineEdit ( amountbox ); | 224 | amount = new QLineEdit ( amountbox ); |
225 | amount->setAlignment ( Qt::AlignRight ); | 225 | amount->setAlignment ( Qt::AlignRight ); |
226 | amount->setText ( transfer->getAmount ( transferid ) ); | 226 | amount->setText ( transfer->getAmount ( transferid ) ); |
227 | QPushButton *calculatorbutton = new QPushButton( amountbox ); | 227 | QPushButton *calculatorbutton = new QPushButton( amountbox ); |
228 | calculatorbutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/kcalc.png" ) ); | 228 | calculatorbutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/kcalc.png" ) ); |
229 | connect ( calculatorbutton, SIGNAL ( released() ), this, SLOT ( showCalculator() ) ); | 229 | connect ( calculatorbutton, SIGNAL ( released() ), this, SLOT ( showCalculator() ) ); |
230 | 230 | ||
231 | QCheckBox *clearedcheckbox = new QCheckBox ( "Cleared", editransfer ); | 231 | QCheckBox *clearedcheckbox = new QCheckBox ( "Cleared", editransfer ); |
232 | 232 | ||
233 | QBoxLayout *layout = new QVBoxLayout ( editransfer, 4, 2 ); | 233 | QBoxLayout *layout = new QVBoxLayout ( editransfer, 4, 2 ); |
234 | layout->addWidget ( fromaccountlabel, Qt::AlignLeft ); | 234 | layout->addWidget ( fromaccountlabel, Qt::AlignLeft ); |
235 | layout->addWidget ( fromaccountbox, Qt::AlignLeft ); | 235 | layout->addWidget ( fromaccountbox, Qt::AlignLeft ); |
236 | layout->addWidget ( toaccountlabel, Qt::AlignLeft ); | 236 | layout->addWidget ( toaccountlabel, Qt::AlignLeft ); |
237 | layout->addWidget ( toaccountbox, Qt::AlignLeft ); | 237 | layout->addWidget ( toaccountbox, Qt::AlignLeft ); |
238 | layout->addSpacing ( 5 ); | 238 | layout->addSpacing ( 5 ); |
239 | layout->addWidget ( datelabel, Qt::AlignLeft ); | 239 | layout->addWidget ( datelabel, Qt::AlignLeft ); |
240 | layout->addWidget ( datebox, Qt::AlignLeft ); | 240 | layout->addWidget ( datebox, Qt::AlignLeft ); |
241 | layout->addWidget ( amounttlabel, Qt::AlignLeft ); | 241 | layout->addWidget ( amounttlabel, Qt::AlignLeft ); |
242 | layout->addWidget ( amountbox, Qt::AlignLeft ); | 242 | layout->addWidget ( amountbox, Qt::AlignLeft ); |
243 | layout->addWidget ( clearedcheckbox, Qt::AlignLeft ); | 243 | layout->addWidget ( clearedcheckbox, Qt::AlignLeft ); |
244 | 244 | ||
245 | if ( editransfer->exec() == QDialog::Accepted ) | 245 | if ( editransfer->exec() == QDialog::Accepted ) |
246 | { | 246 | { |
247 | //get fromaccount | 247 | //get fromaccount |
248 | fromaccount = ( accountids.operator[] ( fromaccountbox->currentItem() ) ).toInt(); | 248 | fromaccount = ( accountids.operator[] ( fromaccountbox->currentItem() ) ).toInt(); |
249 | 249 | ||
250 | //get to account | 250 | //get to account |
251 | toaccount = ( accountids.operator[] ( toaccountbox->currentItem() ) ).toInt(); | 251 | toaccount = ( accountids.operator[] ( toaccountbox->currentItem() ) ).toInt(); |
252 | 252 | ||
253 | //set cleared flag | 253 | //set cleared flag |
254 | int cleared = 0; | 254 | int cleared = 0; |
255 | if ( clearedcheckbox->isChecked() == TRUE ) | 255 | if ( clearedcheckbox->isChecked() == TRUE ) |
256 | cleared = 1; | 256 | cleared = 1; |
257 | 257 | ||
258 | //update transfer | 258 | //update transfer |
259 | transfer->updateTransfer ( fromaccount, account->getParentAccountID ( fromaccount ), toaccount, account->getParentAccountID ( toaccount ), | 259 | transfer->updateTransfer ( fromaccount, account->getParentAccountID ( fromaccount ), toaccount, account->getParentAccountID ( toaccount ), |
260 | day, month, year, amount->text().toFloat(), cleared, transferid ); | 260 | day, month, year, amount->text().toFloat(), cleared, transferid ); |
261 | 261 | ||
262 | account->updateAccountBalance ( fromaccount ); | 262 | account->updateAccountBalance ( fromaccount ); |
263 | if ( account->getParentAccountID ( fromaccount ) != -1 ) | 263 | if ( account->getParentAccountID ( fromaccount ) != -1 ) |
264 | account->changeParentAccountBalance ( fromaccount ); | 264 | account->changeParentAccountBalance ( account->getParentAccountID ( fromaccount ) ); |
265 | 265 | ||
266 | updateAndDisplay ( toaccount ); | 266 | updateAndDisplay ( toaccount ); |
267 | } | 267 | } |
268 | } | 268 | } |
269 | 269 | ||
270 | void TransactionDisplay::editTransaction () | 270 | void TransactionDisplay::editTransaction () |
271 | { | 271 | { |
272 | int cleared; | 272 | int cleared; |
273 | 273 | ||
274 | // set the transaction id and budgetid | 274 | // set the transaction id and budgetid |
275 | int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt(); | 275 | int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt(); |
276 | int budgetid = transaction->getBudgetID ( transactionid ); | 276 | int budgetid = transaction->getBudgetID ( transactionid ); |
277 | int lineitemid = transaction->getLineItemID ( transactionid ); | 277 | int lineitemid = transaction->getLineItemID ( transactionid ); |
278 | 278 | ||
279 | // create edit transaction window | 279 | // create edit transaction window |
280 | NewTransaction *newtransaction = new NewTransaction ( this ); | 280 | NewTransaction *newtransaction = new NewTransaction ( this ); |
281 | int width = this->width(); | 281 | int width = this->width(); |
282 | newtransaction->transactionname->setMaximumWidth ( ( int ) ( width * 0.45 ) ); | 282 | newtransaction->transactionname->setMaximumWidth ( ( int ) ( width * 0.45 ) ); |
283 | newtransaction->transactionname->setMinimumWidth ( ( int ) ( width * 0.35 ) ); | 283 | newtransaction->transactionname->setMinimumWidth ( ( int ) ( width * 0.35 ) ); |
284 | newtransaction->lineitembox->setMaximumWidth ( ( int ) ( width * 0.45 ) ); | 284 | newtransaction->lineitembox->setMaximumWidth ( ( int ) ( width * 0.45 ) ); |
285 | newtransaction->transactiondatebox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); | 285 | newtransaction->transactiondatebox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); |
286 | newtransaction->transactionamountbox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); | 286 | newtransaction->transactionamountbox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); |
287 | newtransaction->transactionnumber->setMaximumWidth ( ( int ) ( width * 0.25 ) ); | 287 | newtransaction->transactionnumber->setMaximumWidth ( ( int ) ( width * 0.25 ) ); |
288 | 288 | ||
289 | // enter the date in the date box | 289 | // enter the date in the date box |
290 | newtransaction->year = transaction->getYear ( transactionid ); | 290 | newtransaction->year = transaction->getYear ( transactionid ); |
291 | newtransaction->month = transaction->getMonth ( transactionid ); | 291 | newtransaction->month = transaction->getMonth ( transactionid ); |
292 | newtransaction->day = transaction->getDay ( transactionid ); | 292 | newtransaction->day = transaction->getDay ( transactionid ); |
293 | newtransaction->transactiondate->setText ( preferences->getDate ( newtransaction->year, newtransaction->month, newtransaction->day ) ); | 293 | newtransaction->transactiondate->setText ( preferences->getDate ( newtransaction->year, newtransaction->month, newtransaction->day ) ); |
294 | 294 | ||
295 | // set the description | 295 | // set the description |
296 | newtransaction->setDescription ( transaction->getTransactionDescription ( transactionid ) ); | 296 | newtransaction->setDescription ( transaction->getTransactionDescription ( transactionid ) ); |
297 | 297 | ||
298 | // add memory items to the transactionname combobox | 298 | // add memory items to the transactionname combobox |
299 | memory->displayMemoryItems ( newtransaction->transactionname ); | 299 | memory->displayMemoryItems ( newtransaction->transactionname ); |
300 | 300 | ||
301 | // add correct transaction name | 301 | // add correct transaction name |
302 | newtransaction->transactionname->setEditText ( transaction->getPayee ( transactionid ) ); | 302 | newtransaction->transactionname->setEditText ( transaction->getPayee ( transactionid ) ); |
303 | 303 | ||
304 | // add transaction number | 304 | // add transaction number |
305 | newtransaction->transactionnumber->setText ( transaction->getNumber ( transactionid ) ); | 305 | newtransaction->transactionnumber->setText ( transaction->getNumber ( transactionid ) ); |
306 | 306 | ||
307 | // add transaction amount | 307 | // add transaction amount |
308 | newtransaction->transactionamount->setText ( transaction->getAbsoluteAmount ( transactionid ) ); | 308 | newtransaction->transactionamount->setText ( transaction->getAbsoluteAmount ( transactionid ) ); |
309 | 309 | ||
310 | // check for and set the correct budget | 310 | // check for and set the correct budget |
311 | if ( budgetid >= 1 ) // only do it if this transaction has a budget and line item | 311 | if ( budgetid >= 1 ) // only do it if this transaction has a budget and line item |
312 | { | 312 | { |
313 | newtransaction->budgetbox->setCurrentItem ( newtransaction->getBudgetIndex ( budgetid ) + 1 ); | 313 | newtransaction->budgetbox->setCurrentItem ( newtransaction->getBudgetIndex ( budgetid ) + 1 ); |
314 | if ( lineitemid >= 1 ) | 314 | if ( lineitemid >= 1 ) |
315 | { | 315 | { |
316 | newtransaction->setLineItems (); | 316 | newtransaction->setLineItems (); |
317 | newtransaction->lineitembox->setCurrentItem ( newtransaction->getLineItemIndex ( lineitemid ) ); | 317 | newtransaction->lineitembox->setCurrentItem ( newtransaction->getLineItemIndex ( lineitemid ) ); |
318 | } | 318 | } |
319 | else | 319 | else |
320 | { | 320 | { |
321 | newtransaction->lineitemlabel->setEnabled ( FALSE ); | 321 | newtransaction->lineitemlabel->setEnabled ( FALSE ); |
322 | newtransaction->lineitembox->setEnabled ( FALSE ); | 322 | newtransaction->lineitembox->setEnabled ( FALSE ); |
323 | } | 323 | } |
324 | } | 324 | } |
325 | else | 325 | else |
326 | { | 326 | { |
327 | newtransaction->lineitemlabel->setEnabled ( FALSE ); | 327 | newtransaction->lineitemlabel->setEnabled ( FALSE ); |
328 | newtransaction->lineitembox->setEnabled ( FALSE ); | 328 | newtransaction->lineitembox->setEnabled ( FALSE ); |
329 | } | 329 | } |
330 | 330 | ||
331 | // check cleared checkbox if necessary | 331 | // check cleared checkbox if necessary |
332 | if ( transaction->getCleared ( transactionid ) == 1 ) | 332 | if ( transaction->getCleared ( transactionid ) == 1 ) |
333 | newtransaction->clearedcheckbox->setChecked ( TRUE ); | 333 | newtransaction->clearedcheckbox->setChecked ( TRUE ); |
334 | 334 | ||
335 | // check deposit box if necessary | 335 | // check deposit box if necessary |
336 | if ( transaction->getAmount ( transactionid ).toFloat() > 0 ) | 336 | if ( transaction->getAmount ( transactionid ).toFloat() > 0 ) |
337 | newtransaction->depositbox->setChecked ( TRUE ); | 337 | newtransaction->depositbox->setChecked ( TRUE ); |
338 | 338 | ||
339 | if ( newtransaction->exec () == QDialog::Accepted ) | 339 | if ( newtransaction->exec () == QDialog::Accepted ) |
340 | { | 340 | { |
341 | if ( newtransaction->clearedcheckbox->isChecked () == TRUE ) | 341 | if ( newtransaction->clearedcheckbox->isChecked () == TRUE ) |
342 | cleared = 1; | 342 | cleared = 1; |
343 | else | 343 | else |
344 | cleared = 0; | 344 | cleared = 0; |
345 | 345 | ||
346 | float amount = newtransaction->transactionamount->text().toFloat(); | 346 | float amount = newtransaction->transactionamount->text().toFloat(); |
347 | if ( newtransaction->depositbox->isChecked() == FALSE ) | 347 | if ( newtransaction->depositbox->isChecked() == FALSE ) |
348 | amount = amount * -1; | 348 | amount = amount * -1; |
349 | 349 | ||
350 | // add the transaction name to the memory items | 350 | // add the transaction name to the memory items |
351 | memory->addMemoryItem ( newtransaction->transactionname->currentText() ); | 351 | memory->addMemoryItem ( newtransaction->transactionname->currentText() ); |
352 | 352 | ||
353 | // update the transaction | 353 | // update the transaction |
354 | transaction->updateTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), newtransaction->transactionnumber->text().toInt(), | 354 | transaction->updateTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), newtransaction->transactionnumber->text().toInt(), |
355 | newtransaction->getDay(), newtransaction->getMonth(), newtransaction->getYear(), | 355 | newtransaction->getDay(), newtransaction->getMonth(), newtransaction->getYear(), |
356 | amount, cleared, newtransaction->getCurrentBudget(), newtransaction->getCurrentLineItem(), transactionid ); | 356 | amount, cleared, newtransaction->getCurrentBudget(), newtransaction->getCurrentLineItem(), transactionid ); |
357 | 357 | ||
358 | updateAndDisplay ( transaction->getAccountID ( transactionid ) ); | 358 | updateAndDisplay ( transaction->getAccountID ( transactionid ) ); |
359 | } | 359 | } |
360 | } | 360 | } |
361 | 361 | ||
362 | void TransactionDisplay::updateAndDisplay ( int id ) | 362 | void TransactionDisplay::updateAndDisplay ( int id ) |
363 | { | 363 | { |
364 | // redisplay transactions | 364 | // redisplay transactions |
365 | listview->clear(); | 365 | listview->clear(); |
366 | QString displaytext = "%"; | 366 | QString displaytext = "%"; |
367 | displaytext.prepend ( limitbox->text() ); | 367 | displaytext.prepend ( limitbox->text() ); |
368 | if ( transaction->getNumberOfTransactions() > 0 ) | 368 | if ( transaction->getNumberOfTransactions() > 0 ) |
369 | transaction->displayTransactions ( listview, accountid, children, displaytext ); | 369 | transaction->displayTransactions ( listview, accountid, children, displaytext ); |
370 | 370 | ||
371 | // redisplay transfers | 371 | // redisplay transfers |
372 | if ( transfer->getNumberOfTransfers() > 0 ) | 372 | if ( transfer->getNumberOfTransfers() > 0 ) |
373 | transfer->displayTransfers ( listview, accountid, children ); | 373 | transfer->displayTransfers ( listview, accountid, children ); |
374 | 374 | ||
375 | // add the transaction amount to the account it's associated with | 375 | // add the transaction amount to the account it's associated with |
376 | // and update its parent account balance if necessary | 376 | // and update its parent account balance if necessary |
377 | account->updateAccountBalance ( id ); | 377 | account->updateAccountBalance ( id ); |
378 | if ( account->getParentAccountID ( id ) != -1 ) | 378 | if ( account->getParentAccountID ( id ) != -1 ) |
379 | account->changeParentAccountBalance ( account->getParentAccountID ( id ) ); | 379 | account->changeParentAccountBalance ( account->getParentAccountID ( id ) ); |
380 | 380 | ||
381 | // format then reset the account balance | 381 | // format then reset the account balance |
382 | redisplayAccountBalance (); | 382 | redisplayAccountBalance (); |
383 | } | 383 | } |
384 | 384 | ||
385 | void TransactionDisplay::checkListViewDelete () | 385 | void TransactionDisplay::checkListViewDelete () |
386 | { | 386 | { |
387 | if ( listview->selectedItem() == 0 ) | 387 | if ( listview->selectedItem() == 0 ) |
388 | QMessageBox::warning ( this, "QashMoney", "Please select a transaction to\ndelete."); | 388 | QMessageBox::warning ( this, "QashMoney", "Please select a transaction to\ndelete."); |
389 | else | 389 | else |
390 | deleteTransaction (); | 390 | deleteTransaction (); |
391 | } | 391 | } |
392 | 392 | ||
393 | void TransactionDisplay::deleteTransaction () | 393 | void TransactionDisplay::deleteTransaction () |
394 | { | 394 | { |
395 | int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt(); | 395 | int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt(); |
396 | 396 | ||
397 | if ( transactionid > 0 ) // takes care of deleting transactions | 397 | if ( transactionid > 0 ) // takes care of deleting transactions |
398 | { | 398 | { |
399 | // check if we are viewing child transactions through a parent | 399 | // check if we are viewing child transactions through a parent |
400 | // in that case we will have to update balances for the parent | 400 | // in that case we will have to update balances for the parent |
401 | // which is represented by accountid and the child account | 401 | // which is represented by accountid and the child account |
402 | // which will be represented by childaccountid | 402 | // which will be represented by childaccountid |
403 | int childaccountid = -1; | 403 | int childaccountid = -1; |
404 | if ( listview->columns() == 5 ) | 404 | if ( listview->columns() == 5 ) |
405 | childaccountid = transaction->getAccountID ( transactionid ); | 405 | childaccountid = transaction->getAccountID ( transactionid ); |
406 | 406 | ||
407 | transaction->deleteTransaction ( transactionid ); | 407 | transaction->deleteTransaction ( transactionid ); |
408 | 408 | ||
409 | listview->clear(); | 409 | listview->clear(); |
410 | QString displaytext = "%"; | 410 | QString displaytext = "%"; |
411 | displaytext.prepend ( limitbox->text() ); | 411 | displaytext.prepend ( limitbox->text() ); |
412 | if ( transaction->getNumberOfTransactions() > 0 ) | 412 | if ( transaction->getNumberOfTransactions() > 0 ) |
413 | transaction->displayTransactions ( listview, accountid, children, displaytext ); | 413 | transaction->displayTransactions ( listview, accountid, children, displaytext ); |
414 | 414 | ||
415 | if ( transfer->getNumberOfTransfers() > 0 ) | 415 | if ( transfer->getNumberOfTransfers() > 0 ) |
416 | transfer->displayTransfers ( listview, accountid, children ); | 416 | transfer->displayTransfers ( listview, accountid, children ); |
417 | 417 | ||
418 | // if we are viewing different child accounts through the parent account | 418 | // if we are viewing different child accounts through the parent account |
419 | // ie if there are five columns and the parentid is -1 | 419 | // ie if there are five columns and the parentid is -1 |
420 | // update the accountid ( which is the parent ) and update the child account | 420 | // update the accountid ( which is the parent ) and update the child account |
421 | // balance. Get its accountid from the transactionid | 421 | // balance. Get its accountid from the transactionid |
422 | account->updateAccountBalance ( accountid ); // will update either a parent or child | 422 | account->updateAccountBalance ( accountid ); // will update either a parent or child |
423 | if ( account->getParentAccountID ( accountid ) != -1 ) // update its parent if there is one | 423 | if ( account->getParentAccountID ( accountid ) != -1 ) // update its parent if there is one |
424 | account->changeParentAccountBalance ( account->getParentAccountID ( accountid ) ); | 424 | account->changeParentAccountBalance ( account->getParentAccountID ( accountid ) ); |
425 | if ( childaccountid != -1 ) // we've set childaccountid | 425 | if ( childaccountid != -1 ) // we've set childaccountid |
426 | account->updateAccountBalance ( childaccountid ); | 426 | account->updateAccountBalance ( childaccountid ); |
427 | 427 | ||
428 | // format then reset the account balance | 428 | // format then reset the account balance |
429 | redisplayAccountBalance (); | 429 | redisplayAccountBalance (); |
430 | } | 430 | } |
431 | else // takes care of deleting transfers | 431 | else // takes care of deleting transfers |
432 | { | 432 | { |
433 | // get the accountids before we delete the transfer | 433 | // get the accountids before we delete the transfer |
434 | int fromaccountid = transfer->getFromAccountID ( transactionid ); | 434 | int fromaccountid = transfer->getFromAccountID ( transactionid ); |
435 | int toaccountid = transfer->getToAccountID ( transactionid ); | 435 | int toaccountid = transfer->getToAccountID ( transactionid ); |
436 | 436 | ||
437 | // delete the transfer and redisplay transactions | 437 | // delete the transfer and redisplay transactions |
438 | transfer->deleteTransfer ( transactionid ); | 438 | transfer->deleteTransfer ( transactionid ); |
439 | 439 | ||
440 | listview->clear(); | 440 | listview->clear(); |
441 | QString displaytext = "%"; | 441 | QString displaytext = "%"; |
442 | displaytext.prepend ( limitbox->text() ); | 442 | displaytext.prepend ( limitbox->text() ); |
443 | if ( transaction->getNumberOfTransactions() > 0 ) | 443 | if ( transaction->getNumberOfTransactions() > 0 ) |
444 | transaction->displayTransactions ( listview, accountid, children, displaytext ); | 444 | transaction->displayTransactions ( listview, accountid, children, displaytext ); |
445 | 445 | ||
446 | if ( transfer->getNumberOfTransfers() > 0 ) | 446 | if ( transfer->getNumberOfTransfers() > 0 ) |
447 | transfer->displayTransfers ( listview, accountid, children ); | 447 | transfer->displayTransfers ( listview, accountid, children ); |
448 | 448 | ||
449 | // for the from account | 449 | // for the from account |
450 | account->updateAccountBalance ( fromaccountid ); | 450 | account->updateAccountBalance ( fromaccountid ); |
451 | if ( account->getParentAccountID ( fromaccountid ) != -1 ) | 451 | if ( account->getParentAccountID ( fromaccountid ) != -1 ) |
452 | account->changeParentAccountBalance ( account->getParentAccountID ( fromaccountid ) ); | 452 | account->changeParentAccountBalance ( account->getParentAccountID ( fromaccountid ) ); |
453 | 453 | ||
454 | // for the to account | 454 | // for the to account |
455 | account->updateAccountBalance ( toaccountid ); | 455 | account->updateAccountBalance ( toaccountid ); |
456 | if ( account->getParentAccountID ( toaccountid ) != -1 ) | 456 | if ( account->getParentAccountID ( toaccountid ) != -1 ) |