author | alwin <alwin> | 2004-02-23 12:16:18 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-02-23 12:16:18 (UTC) |
commit | 2d37d653310da0a9d6e2e2e6c9f5bf092e54cbbb (patch) (unidiff) | |
tree | 35694478a6b36a1e707719262b1642c42f3f7968 | |
parent | 957697a1158c9bfeae88ea35190b821fe002834a (diff) | |
download | opie-2d37d653310da0a9d6e2e2e6c9f5bf092e54cbbb.zip opie-2d37d653310da0a9d6e2e2e6c9f5bf092e54cbbb.tar.gz opie-2d37d653310da0a9d6e2e2e6c9f5bf092e54cbbb.tar.bz2 |
sorry, forgot a stdc++ reference
-rwxr-xr-x | noncore/apps/qashmoney/accountdisplay.cpp | 3 |
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,68 +1,67 @@ | |||
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 | ||
13 | extern Account *account; | 12 | extern Account *account; |
14 | extern Transaction *transaction; | 13 | extern Transaction *transaction; |
15 | extern Transfer *transfer; | 14 | extern Transfer *transfer; |
16 | extern Preferences *preferences; | 15 | extern Preferences *preferences; |
17 | 16 | ||
18 | AccountDisplay::AccountDisplay ( QWidget *parent ) : QWidget ( parent ) | 17 | AccountDisplay::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 ) ) ); |
53 | 52 | ||
54 | layout = new QVBoxLayout ( this, 2, 5 ); | 53 | layout = new QVBoxLayout ( this, 2, 5 ); |
55 | layout->addWidget ( firstline ); | 54 | layout->addWidget ( firstline ); |
56 | layout->addWidget ( listview ); | 55 | layout->addWidget ( listview ); |
57 | } | 56 | } |
58 | 57 | ||
59 | void AccountDisplay::setTabs ( QWidget *newtab2, QTabWidget *newtabs ) | 58 | void AccountDisplay::setTabs ( QWidget *newtab2, QTabWidget *newtabs ) |
60 | { | 59 | { |
61 | tab2 = newtab2; | 60 | tab2 = newtab2; |
62 | maintabs = newtabs; | 61 | maintabs = newtabs; |
63 | } | 62 | } |
64 | 63 | ||
65 | void AccountDisplay::addAccount () | 64 | void AccountDisplay::addAccount () |
66 | { | 65 | { |
67 | // initialize local variables | 66 | // initialize local variables |
68 | int parentid = 0; | 67 | int parentid = 0; |
@@ -209,129 +208,129 @@ void AccountDisplay::setToggleButton () | |||
209 | int counter = 0; | 208 | int counter = 0; |
210 | for ( ; it.current(); ++it ) | 209 | for ( ; it.current(); ++it ) |
211 | { | 210 | { |
212 | // add one to counter if we find a transferable account | 211 | // add one to counter if we find a transferable account |
213 | if ( it.current()->parent() != 0 || ( it.current()->childCount() ) == 0 ) | 212 | if ( it.current()->parent() != 0 || ( it.current()->childCount() ) == 0 ) |
214 | counter++; | 213 | counter++; |
215 | } | 214 | } |
216 | if ( counter > 1 ) | 215 | if ( counter > 1 ) |
217 | transferbutton->show(); | 216 | transferbutton->show(); |
218 | else | 217 | else |
219 | transferbutton->hide(); | 218 | transferbutton->hide(); |
220 | } | 219 | } |
221 | 220 | ||
222 | void AccountDisplay::accountTransfer ( bool state ) | 221 | void AccountDisplay::accountTransfer ( bool state ) |
223 | { | 222 | { |
224 | if ( state == TRUE ) | 223 | if ( state == TRUE ) |
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 | ||
244 | void AccountDisplay::getTransferAccounts ( QListViewItem * item ) | 243 | void 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 | ||
308 | void AccountDisplay::disableParentsWithChildren () | 307 | void 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 | ||
319 | void AccountDisplay::enableAccounts () | 318 | void AccountDisplay::enableAccounts () |
320 | { | 319 | { |
321 | // iterate through accountdisplay listview and enable all accounts | 320 | // iterate through accountdisplay listview and enable all accounts |
322 | QListViewItemIterator it ( listview ); | 321 | QListViewItemIterator it ( listview ); |
323 | for ( ; it.current(); ++it ) | 322 | for ( ; it.current(); ++it ) |
324 | it.current()->setSelectable ( TRUE ); | 323 | it.current()->setSelectable ( TRUE ); |
325 | } | 324 | } |
326 | 325 | ||
327 | void AccountDisplay::saveColumnSize ( int column, int oldsize, int newsize ) | 326 | void AccountDisplay::saveColumnSize ( int column, int oldsize, int newsize ) |
328 | { | 327 | { |
329 | switch ( column ) | 328 | switch ( column ) |
330 | { | 329 | { |
331 | case 0: | 330 | case 0: |
332 | if ( listview->columns() == 3 ) | 331 | if ( listview->columns() == 3 ) |
333 | preferences->changeColumnPreference ( 1, newsize ); | 332 | preferences->changeColumnPreference ( 1, newsize ); |
334 | else | 333 | else |
335 | preferences->changeColumnPreference ( 10, newsize ); | 334 | preferences->changeColumnPreference ( 10, newsize ); |
336 | break; | 335 | break; |
337 | case 1: | 336 | case 1: |