summaryrefslogtreecommitdiff
path: root/noncore/apps/qashmoney/qashmoney.cpp
Unidiff
Diffstat (limited to 'noncore/apps/qashmoney/qashmoney.cpp') (more/less context) (ignore whitespace changes)
-rwxr-xr-xnoncore/apps/qashmoney/qashmoney.cpp42
1 files changed, 38 insertions, 4 deletions
diff --git a/noncore/apps/qashmoney/qashmoney.cpp b/noncore/apps/qashmoney/qashmoney.cpp
index 1ea358c..83eea01 100755
--- a/noncore/apps/qashmoney/qashmoney.cpp
+++ b/noncore/apps/qashmoney/qashmoney.cpp
@@ -134,30 +134,32 @@ void QashMoney::changeTabDisplay ()
134 transactiondisplay->newtransaction->setEnabled ( FALSE ); 134 transactiondisplay->newtransaction->setEnabled ( FALSE );
135 } 135 }
136 else //we selected a parent without children or a child 136 else //we selected a parent without children or a child
137 transactiondisplay->newtransaction->setEnabled ( TRUE ); 137 transactiondisplay->newtransaction->setEnabled ( TRUE );
138 138
139 // disable the transactionid column so it can't be red 139 // disable the transactionid column so it can't be red
140 transactiondisplay->listview->header()->setResizeEnabled ( FALSE, 3 ); 140 transactiondisplay->listview->header()->setResizeEnabled ( FALSE, 3 );
141 141
142 // set the accountid and children variables 142 // set the accountid and children variables
143 transactiondisplay->setChildren ( children ); 143 transactiondisplay->setChildren ( children );
144 transactiondisplay->setAccountID ( accountid ); 144 transactiondisplay->setAccountID ( accountid );
145 145
146 setTransactionDisplayDate ();
147
146 // display transactions 148 // display transactions
147 transactiondisplay->listview->clear(); 149 transactiondisplay->listview->clear();
148 QString displaytext = "%"; 150 QString displaytext = "%";
149 displaytext.prepend ( transactiondisplay->limitbox->text() ); 151 displaytext.prepend ( transactiondisplay->limitbox->text() );
150 if ( transaction->getNumberOfTransactions() > 0 ) 152 if ( transaction->getNumberOfTransactions() > 0 )
151 transaction->displayTransactions ( transactiondisplay->listview, accountid, children, displaytext ); 153 transaction->displayTransactions ( transactiondisplay->listview, accountid, children, displaytext, newdate );
152 154
153 // display transfers 155 // display transfers
154 transfer->displayTransfers ( transactiondisplay->listview, accountid, children ); 156 transfer->displayTransfers ( transactiondisplay->listview, accountid, children );
155 157
156 // open a new preferences object and resize the transaction display columns 158 // open a new preferences object and resize the transaction display columns
157 // each column will have a different size based on whether we are looking at a child 159 // each column will have a different size based on whether we are looking at a child
158 // account or children through a parent 160 // account or children through a parent
159 if ( parentaccountid != -1 || accountdisplay->listview->selectedItem()->childCount() == 0 ) // a parent with no children or a child - three columns 161 if ( parentaccountid != -1 || accountdisplay->listview->selectedItem()->childCount() == 0 ) // a parent with no children or a child - three columns
160 { 162 {
161 transactiondisplay->listview->setColumnWidth ( 0, preferences->getColumnPreference ( 3 ) ); // normal transaction date width 163 transactiondisplay->listview->setColumnWidth ( 0, preferences->getColumnPreference ( 3 ) ); // normal transaction date width
162 transactiondisplay->listview->setColumnWidthMode ( 0, QListView::Manual ); 164 transactiondisplay->listview->setColumnWidthMode ( 0, QListView::Manual );
163 transactiondisplay->listview->setColumnWidth ( 1, preferences->getColumnPreference ( 4 ) ); // normal transaction name width 165 transactiondisplay->listview->setColumnWidth ( 1, preferences->getColumnPreference ( 4 ) ); // normal transaction name width
@@ -245,26 +247,28 @@ void QashMoney::displayDatePreferencesDialog ()
245 // set children so we can let displayTransfers know if there are children for the selected account 247 // set children so we can let displayTransfers know if there are children for the selected account
246 bool children; 248 bool children;
247 if ( accountdisplay->listview->selectedItem()->parent() == 0 && accountdisplay->listview->selectedItem()->childCount() != 0 ) 249 if ( accountdisplay->listview->selectedItem()->parent() == 0 && accountdisplay->listview->selectedItem()->childCount() != 0 )
248 children = TRUE; 250 children = TRUE;
249 else 251 else
250 children = FALSE; 252 children = FALSE;
251 253
252 // redisplay transactions if they are visible incorporating 254 // redisplay transactions if they are visible incorporating
253 // any changes to the date format 255 // any changes to the date format
254 transactiondisplay->listview->clear(); 256 transactiondisplay->listview->clear();
255 QString displaytext = "%"; 257 QString displaytext = "%";
256 displaytext.prepend ( transactiondisplay->limitbox->text() ); 258 displaytext.prepend ( transactiondisplay->limitbox->text() );
259
260 setTransactionDisplayDate();
257 if ( transaction->getNumberOfTransactions() > 0 ) 261 if ( transaction->getNumberOfTransactions() > 0 )
258 transaction->displayTransactions ( transactiondisplay->listview, accountid, children, displaytext ); 262 transaction->displayTransactions ( transactiondisplay->listview, accountid, children, displaytext, newdate );
259 263
260 if ( transfer->getNumberOfTransfers() != 0 ) 264 if ( transfer->getNumberOfTransfers() != 0 )
261 transfer->displayTransfers ( transactiondisplay->listview, accountid, children ); 265 transfer->displayTransfers ( transactiondisplay->listview, accountid, children );
262 } 266 }
263 else if ( accountdisplay->isVisible() ) 267 else if ( accountdisplay->isVisible() )
264 { 268 {
265 accountdisplay->listview->clearSelection(); 269 accountdisplay->listview->clearSelection();
266 maintabs->setTabEnabled ( tab_2, FALSE ); 270 maintabs->setTabEnabled ( tab_2, FALSE );
267 } 271 }
268 else 272 else
269 budgetdisplay->updateBudgetInformation(); 273 budgetdisplay->updateBudgetInformation();
270 } 274 }
@@ -281,26 +285,28 @@ void QashMoney::displayTransactionPreferencesDialog ()
281 285
282 // set children so we can let displayTransfers know if there are children for the selected account 286 // set children so we can let displayTransfers know if there are children for the selected account
283 bool children; 287 bool children;
284 if ( accountdisplay->listview->selectedItem()->parent() == 0 && accountdisplay->listview->selectedItem()->childCount() != 0 ) 288 if ( accountdisplay->listview->selectedItem()->parent() == 0 && accountdisplay->listview->selectedItem()->childCount() != 0 )
285 children = TRUE; 289 children = TRUE;
286 else 290 else
287 children = FALSE; 291 children = FALSE;
288 292
289 // redisplay transactions incorporating any transaction preference changes 293 // redisplay transactions incorporating any transaction preference changes
290 transactiondisplay->listview->clear(); 294 transactiondisplay->listview->clear();
291 QString displaytext = "%"; 295 QString displaytext = "%";
292 displaytext.prepend ( transactiondisplay->limitbox->text() ); 296 displaytext.prepend ( transactiondisplay->limitbox->text() );
297
298 setTransactionDisplayDate();
293 if ( transaction->getNumberOfTransactions() > 0 ) 299 if ( transaction->getNumberOfTransactions() > 0 )
294 transaction->displayTransactions ( transactiondisplay->listview, accountid, children, displaytext ); 300 transaction->displayTransactions ( transactiondisplay->listview, accountid, children, displaytext, newdate );
295 301
296 if ( transfer->getNumberOfTransfers() != 0 ) 302 if ( transfer->getNumberOfTransfers() != 0 )
297 transfer->displayTransfers ( transactiondisplay->listview, accountid, children ); 303 transfer->displayTransfers ( transactiondisplay->listview, accountid, children );
298 } 304 }
299 else 305 else
300 { 306 {
301 accountdisplay->listview->clearSelection(); 307 accountdisplay->listview->clearSelection();
302 maintabs->setTabEnabled ( tab_2, FALSE ); 308 maintabs->setTabEnabled ( tab_2, FALSE );
303 } 309 }
304 } 310 }
305 311
306void QashMoney::displayAccountPreferencesDialog () 312void QashMoney::displayAccountPreferencesDialog ()
@@ -343,14 +349,42 @@ void QashMoney::disableOneTouchViewing ()
343 { 349 {
344 disconnect ( accountdisplay->listview, SIGNAL ( selectionChanged () ), this, SLOT ( showTransactions () ) ); 350 disconnect ( accountdisplay->listview, SIGNAL ( selectionChanged () ), this, SLOT ( showTransactions () ) );
345 } 351 }
346 352
347void QashMoney::toggleOneTouchViewing ( bool state ) 353void QashMoney::toggleOneTouchViewing ( bool state )
348 { 354 {
349 if ( state == TRUE ) 355 if ( state == TRUE )
350 disableOneTouchViewing(); 356 disableOneTouchViewing();
351 else 357 else
352 enableOneTouchViewing(); 358 enableOneTouchViewing();
353 } 359 }
354 360
355 361void QashMoney::setTransactionDisplayDate ()
362 {
363 // determine how many days of transactions to show
364 int limittype = preferences->getPreference ( 7 );
365 if ( limittype != 5 ) // set today's date if we are not showing all transactions
366 {
367 QDate today = QDate::currentDate ();
368 switch ( limittype ) // if we are not showing all transactions
369 {
370 case 0: // viewing two weeks
371 newdate = today.addDays ( -14 );
372 break;
373 case 1: // viewing one month
374 newdate = today.addDays ( -30 );
375 break;
376 case 2: // three months
377 newdate = today.addDays ( -90 );
378 break;
379 case 3: // six months
380 newdate = today.addDays ( -180 );
381 break;
382 case 4: // one year
383 newdate = today.addDays ( -365 );
384 break;
385 }
386 }
387 else
388 newdate = QDate ( 1, 1, 1000 );
389 }
356 390