summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rwxr-xr-xnoncore/apps/qashmoney/accountdisplay.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/noncore/apps/qashmoney/accountdisplay.cpp b/noncore/apps/qashmoney/accountdisplay.cpp
index 64f4ea8..d0ba82a 100755
--- a/noncore/apps/qashmoney/accountdisplay.cpp
+++ b/noncore/apps/qashmoney/accountdisplay.cpp
@@ -1,52 +1,51 @@
1#include <qdatetime.h> 1#include <qdatetime.h>
2#include <qmessagebox.h> 2#include <qmessagebox.h>
3#include <qheader.h> 3#include <qheader.h>
4#include <iostream.h>
5 4
6#include "accountdisplay.h" 5#include "accountdisplay.h"
7#include "newaccount.h" 6#include "newaccount.h"
8#include "transaction.h" 7#include "transaction.h"
9#include "transferdialog.h" 8#include "transferdialog.h"
10#include "preferences.h" 9#include "preferences.h"
11#include "transfer.h" 10#include "transfer.h"
12 11
13extern Account *account; 12extern Account *account;
14extern Transaction *transaction; 13extern Transaction *transaction;
15extern Transfer *transfer; 14extern Transfer *transfer;
16extern Preferences *preferences; 15extern Preferences *preferences;
17 16
18AccountDisplay::AccountDisplay ( QWidget *parent ) : QWidget ( parent ) 17AccountDisplay::AccountDisplay ( QWidget *parent ) : QWidget ( parent )
19 { 18 {
20 cleared = 0; 19 cleared = 0;
21 20
22 firstline = new QHBox ( this ); 21 firstline = new QHBox ( this );
23 firstline->setSpacing ( 2 ); 22 firstline->setSpacing ( 2 );
24 23
25 newaccount = new QPushButton ( firstline ); 24 newaccount = new QPushButton ( firstline );
26 newaccount->setPixmap ( QPixmap ("/opt/QtPalmtop/pics/new.png") ); 25 newaccount->setPixmap ( QPixmap ("/opt/QtPalmtop/pics/new.png") );
27 connect ( newaccount, SIGNAL ( released () ), this, SLOT ( addAccount () ) ); 26 connect ( newaccount, SIGNAL ( released () ), this, SLOT ( addAccount () ) );
28 27
29 editaccount = new QPushButton ( firstline ); 28 editaccount = new QPushButton ( firstline );
30 editaccount->setPixmap ( QPixmap ("/opt/QtPalmtop/pics/edit.png") ); 29 editaccount->setPixmap ( QPixmap ("/opt/QtPalmtop/pics/edit.png") );
31 connect ( editaccount, SIGNAL ( released () ), this, SLOT ( editAccount () ) ); 30 connect ( editaccount, SIGNAL ( released () ), this, SLOT ( editAccount () ) );
32 31
33 deleteaccount = new QPushButton ( firstline ); 32 deleteaccount = new QPushButton ( firstline );
34 deleteaccount->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/delete.png") ); 33 deleteaccount->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/delete.png") );
35 connect ( deleteaccount, SIGNAL ( released () ), this, SLOT ( deleteAccount () ) ); 34 connect ( deleteaccount, SIGNAL ( released () ), this, SLOT ( deleteAccount () ) );
36 35
37 transferbutton = new QPushButton ( firstline ); 36 transferbutton = new QPushButton ( firstline );
38 transferbutton->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/transfer.png") ); 37 transferbutton->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/transfer.png") );
39 transferbutton->setToggleButton ( TRUE ); 38 transferbutton->setToggleButton ( TRUE );
40 connect ( transferbutton, SIGNAL ( toggled ( bool ) ), this, SLOT ( accountTransfer ( bool ) ) ); 39 connect ( transferbutton, SIGNAL ( toggled ( bool ) ), this, SLOT ( accountTransfer ( bool ) ) );
41 40
42 listview = new QListView ( this ); 41 listview = new QListView ( this );
43 listview->setAllColumnsShowFocus ( TRUE ); 42 listview->setAllColumnsShowFocus ( TRUE );
44 listview->setShowSortIndicator ( TRUE ); 43 listview->setShowSortIndicator ( TRUE );
45 listview->setRootIsDecorated ( TRUE ); 44 listview->setRootIsDecorated ( TRUE );
46 listview->setMultiSelection ( FALSE ); 45 listview->setMultiSelection ( FALSE );
47 connect ( listview, SIGNAL ( expanded ( QListViewItem * ) ), this, SLOT ( setAccountExpanded ( QListViewItem * ) ) ); 46 connect ( listview, SIGNAL ( expanded ( QListViewItem * ) ), this, SLOT ( setAccountExpanded ( QListViewItem * ) ) );
48 connect ( listview, SIGNAL ( collapsed ( QListViewItem * ) ), this, SLOT ( setAccountCollapsed ( QListViewItem * ) ) ); 47 connect ( listview, SIGNAL ( collapsed ( QListViewItem * ) ), this, SLOT ( setAccountCollapsed ( QListViewItem * ) ) );
49 48
50 listview->header()->setTracking ( FALSE ); 49 listview->header()->setTracking ( FALSE );
51 connect ( listview->header(), SIGNAL ( sizeChange ( int, int, int ) ), this, SLOT ( saveColumnSize ( int, int, int ) ) ); 50 connect ( listview->header(), SIGNAL ( sizeChange ( int, int, int ) ), this, SLOT ( saveColumnSize ( int, int, int ) ) );
52 connect ( listview->header(), SIGNAL ( clicked ( int ) ), this, SLOT ( saveSortingPreference ( int ) ) ); 51 connect ( listview->header(), SIGNAL ( clicked ( int ) ), this, SLOT ( saveSortingPreference ( int ) ) );
@@ -225,97 +224,97 @@ void AccountDisplay::accountTransfer ( bool state )
225 { 224 {
226 firstaccountid = -1; 225 firstaccountid = -1;
227 secondaccountid = -1; 226 secondaccountid = -1;
228 listview->clearSelection (); 227 listview->clearSelection ();
229 listview->setMultiSelection ( TRUE ); 228 listview->setMultiSelection ( TRUE );
230 disableParentsWithChildren (); 229 disableParentsWithChildren ();
231 connect ( listview, SIGNAL ( clicked ( QListViewItem * ) ), this, SLOT ( getTransferAccounts ( QListViewItem * ) ) ); 230 connect ( listview, SIGNAL ( clicked ( QListViewItem * ) ), this, SLOT ( getTransferAccounts ( QListViewItem * ) ) );
232 } 231 }
233 else 232 else
234 { 233 {
235 firstaccountid = -1; 234 firstaccountid = -1;
236 secondaccountid = -1; 235 secondaccountid = -1;
237 listview->clearSelection (); 236 listview->clearSelection ();
238 listview->setMultiSelection ( FALSE ); 237 listview->setMultiSelection ( FALSE );
239 enableAccounts (); 238 enableAccounts ();
240 disconnect ( listview, SIGNAL ( clicked ( QListViewItem * ) ), this, SLOT ( getTransferAccounts ( QListViewItem * ) ) ); 239 disconnect ( listview, SIGNAL ( clicked ( QListViewItem * ) ), this, SLOT ( getTransferAccounts ( QListViewItem * ) ) );
241 } 240 }
242 } 241 }
243 242
244void AccountDisplay::getTransferAccounts ( QListViewItem * item ) 243void AccountDisplay::getTransferAccounts ( QListViewItem * item )
245 { 244 {
246 if ( item->parent() != 0 || item->childCount() == 0 ) // only set an account for transfer if its a child or parent with no children 245 if ( item->parent() != 0 || item->childCount() == 0 ) // only set an account for transfer if its a child or parent with no children
247 { 246 {
248 if ( firstaccountid == -1 ) 247 if ( firstaccountid == -1 )
249 firstaccountid = item->text ( getIDColumn() ).toInt(); // set first account if we've selected a valid account 248 firstaccountid = item->text ( getIDColumn() ).toInt(); // set first account if we've selected a valid account
250 else 249 else
251 if ( item->text ( getIDColumn() ).toInt() != firstaccountid ) // set the second account if its not equal to the first 250 if ( item->text ( getIDColumn() ).toInt() != firstaccountid ) // set the second account if its not equal to the first
252 secondaccountid = item->text ( getIDColumn() ).toInt(); 251 secondaccountid = item->text ( getIDColumn() ).toInt();
253 } 252 }
254 253
255 // open transfer window if both accounts are set 254 // open transfer window if both accounts are set
256 if ( firstaccountid != -1 && secondaccountid != -1 ) 255 if ( firstaccountid != -1 && secondaccountid != -1 )
257 { 256 {
258 // construct the transferdialog window 257 // construct the transferdialog window
259 TransferDialog *td = new TransferDialog ( this, firstaccountid, secondaccountid ); 258 TransferDialog *td = new TransferDialog ( this, firstaccountid, secondaccountid );
260 259
261 // enter today's date in the date box as default 260 // enter today's date in the date box as default
262 QDate today = QDate::currentDate (); 261 QDate today = QDate::currentDate ();
263 int defaultday = today.day(); 262 int defaultday = today.day();
264 int defaultmonth = today.month(); 263 int defaultmonth = today.month();
265 int defaultyear = today.year(); 264 int defaultyear = today.year();
266 td->date->setText ( preferences->getDate ( defaultyear, defaultmonth, defaultday ) ); 265 td->date->setText ( preferences->getDate ( defaultyear, defaultmonth, defaultday ) );
267 266
268 if ( td->exec() == QDialog::Accepted ) 267 if ( td->exec() == QDialog::Accepted )
269 { 268 {
270 // set the cleared integer if the checkbox is checked 269 // set the cleared integer if the checkbox is checked
271 if ( td->clearedcheckbox->isChecked() == TRUE ) 270 if ( td->clearedcheckbox->isChecked() == TRUE )
272 cleared = 1; 271 cleared = 1;
273 cout << "Year from transferdialog = " << td->getYear() << endl; 272 qDebug("Year from transferdialog = %i",td->getYear());
274 // add the transfer with a new date if its been edited or use the default date 273 // add the transfer with a new date if its been edited or use the default date
275 if ( td->getDateEdited () == TRUE ) 274 if ( td->getDateEdited () == TRUE )
276 transfer->addTransfer ( firstaccountid, account->getParentAccountID ( firstaccountid ), secondaccountid, account->getParentAccountID ( secondaccountid ), td->getDay(), td->getMonth(), td->getYear(), td->amount->text().toFloat(), cleared ); 275 transfer->addTransfer ( firstaccountid, account->getParentAccountID ( firstaccountid ), secondaccountid, account->getParentAccountID ( secondaccountid ), td->getDay(), td->getMonth(), td->getYear(), td->amount->text().toFloat(), cleared );
277 else 276 else
278 transfer->addTransfer ( firstaccountid, account->getParentAccountID ( firstaccountid ), secondaccountid, account->getParentAccountID ( secondaccountid ), defaultday, defaultmonth, defaultyear, td->amount->text().toFloat(), cleared ); 277 transfer->addTransfer ( firstaccountid, account->getParentAccountID ( firstaccountid ), secondaccountid, account->getParentAccountID ( secondaccountid ), defaultday, defaultmonth, defaultyear, td->amount->text().toFloat(), cleared );
279 278
280 // update account balances of both accounts and parents if necessary 279 // update account balances of both accounts and parents if necessary
281 account->updateAccountBalance ( firstaccountid ); 280 account->updateAccountBalance ( firstaccountid );
282 if ( account->getParentAccountID ( firstaccountid ) != -1 ) 281 if ( account->getParentAccountID ( firstaccountid ) != -1 )
283 account->changeParentAccountBalance ( account->getParentAccountID ( firstaccountid ) ); 282 account->changeParentAccountBalance ( account->getParentAccountID ( firstaccountid ) );
284 account->updateAccountBalance ( secondaccountid ); 283 account->updateAccountBalance ( secondaccountid );
285 if ( account->getParentAccountID ( secondaccountid ) != -1 ) 284 if ( account->getParentAccountID ( secondaccountid ) != -1 )
286 account->changeParentAccountBalance ( account->getParentAccountID ( secondaccountid ) ); 285 account->changeParentAccountBalance ( account->getParentAccountID ( secondaccountid ) );
287 286
288 // redisplay accounts 287 // redisplay accounts
289 account->displayAccounts ( listview ); 288 account->displayAccounts ( listview );
290 } 289 }
291 else 290 else
292 { 291 {
293 firstaccountid = -1; 292 firstaccountid = -1;
294 secondaccountid = -1; 293 secondaccountid = -1;
295 listview->clearSelection (); 294 listview->clearSelection ();
296 listview->setMultiSelection ( FALSE ); 295 listview->setMultiSelection ( FALSE );
297 disconnect ( listview, SIGNAL ( clicked ( QListViewItem * ) ), this, SLOT ( getTransferAccounts ( QListViewItem * ) ) ); 296 disconnect ( listview, SIGNAL ( clicked ( QListViewItem * ) ), this, SLOT ( getTransferAccounts ( QListViewItem * ) ) );
298 } 297 }
299 298
300 // reset the accounts display window 299 // reset the accounts display window
301 transferbutton->toggle(); // toggling this button with clear the window as well 300 transferbutton->toggle(); // toggling this button with clear the window as well
302 301
303 // reenable all the accounts so the transaction tab will be properly set 302 // reenable all the accounts so the transaction tab will be properly set
304 enableAccounts (); 303 enableAccounts ();
305 } 304 }
306 } 305 }
307 306
308void AccountDisplay::disableParentsWithChildren () 307void AccountDisplay::disableParentsWithChildren ()
309 { 308 {
310 // iterate through accountdisplay listview and disable all the parents that have children 309 // iterate through accountdisplay listview and disable all the parents that have children
311 QListViewItemIterator it ( listview ); 310 QListViewItemIterator it ( listview );
312 for ( ; it.current(); ++it ) 311 for ( ; it.current(); ++it )
313 { 312 {
314 if ( it.current()->parent() == 0 && it.current()->childCount() != 0 ) 313 if ( it.current()->parent() == 0 && it.current()->childCount() != 0 )
315 it.current()->setSelectable ( FALSE ); 314 it.current()->setSelectable ( FALSE );
316 } 315 }
317 } 316 }
318 317
319void AccountDisplay::enableAccounts () 318void AccountDisplay::enableAccounts ()
320 { 319 {
321 // iterate through accountdisplay listview and enable all accounts 320 // iterate through accountdisplay listview and enable all accounts