author | ar <ar> | 2004-02-08 19:14:56 (UTC) |
---|---|---|
committer | ar <ar> | 2004-02-08 19:14:56 (UTC) |
commit | 5f698069bca9dde2c8be9ff1bf863ee3a7a33cf0 (patch) (unidiff) | |
tree | 525f35c4937c9f4ae99538289c5d1f96c53d7fa7 /noncore/apps/checkbook | |
parent | 2dc8add65c44b3dd240cf2bd3c276c3c0155f46b (diff) | |
download | opie-5f698069bca9dde2c8be9ff1bf863ee3a7a33cf0.zip opie-5f698069bca9dde2c8be9ff1bf863ee3a7a33cf0.tar.gz opie-5f698069bca9dde2c8be9ff1bf863ee3a7a33cf0.tar.bz2 |
improve support for BigScreen
-rw-r--r-- | noncore/apps/checkbook/checkbook.cpp | 6 | ||||
-rw-r--r-- | noncore/apps/checkbook/mainwindow.cpp | 11 |
2 files changed, 6 insertions, 11 deletions
diff --git a/noncore/apps/checkbook/checkbook.cpp b/noncore/apps/checkbook/checkbook.cpp index a42c824..a5492e4 100644 --- a/noncore/apps/checkbook/checkbook.cpp +++ b/noncore/apps/checkbook/checkbook.cpp | |||
@@ -438,145 +438,143 @@ void Checkbook::slotPasswordClicked() | |||
438 | delete pw; | 438 | delete pw; |
439 | return; | 439 | return; |
440 | } | 440 | } |
441 | else | 441 | else |
442 | { | 442 | { |
443 | passwordCB->setChecked( TRUE ); | 443 | passwordCB->setChecked( TRUE ); |
444 | } | 444 | } |
445 | 445 | ||
446 | delete pw; | 446 | delete pw; |
447 | } | 447 | } |
448 | } | 448 | } |
449 | 449 | ||
450 | void Checkbook::slotNameChanged( const QString &newname ) | 450 | void Checkbook::slotNameChanged( const QString &newname ) |
451 | { | 451 | { |
452 | info->setName( newname ); | 452 | info->setName( newname ); |
453 | 453 | ||
454 | // TODO - need filedir | 454 | // TODO - need filedir |
455 | //QString namestr = filedir; | 455 | //QString namestr = filedir; |
456 | //namestr.append( newname ); | 456 | //namestr.append( newname ); |
457 | //namestr.append( ".qcb" ); | 457 | //namestr.append( ".qcb" ); |
458 | //info->setFilename( namestr ); | 458 | //info->setFilename( namestr ); |
459 | 459 | ||
460 | QString namestr = newname; | 460 | QString namestr = newname; |
461 | namestr.append( " - " ); | 461 | namestr.append( " - " ); |
462 | namestr.append( tr( "Checkbook" ) ); | 462 | namestr.append( tr( "Checkbook" ) ); |
463 | setCaption( namestr ); | 463 | setCaption( namestr ); |
464 | } | 464 | } |
465 | 465 | ||
466 | 466 | ||
467 | // ---slotStartingBalanceChanged ---------------------------------------------- | 467 | // ---slotStartingBalanceChanged ---------------------------------------------- |
468 | void Checkbook::slotStartingBalanceChanged( const QString &newbalance ) | 468 | void Checkbook::slotStartingBalanceChanged( const QString &newbalance ) |
469 | { | 469 | { |
470 | bool ok; | 470 | bool ok; |
471 | info->setStartingBalance( newbalance.toFloat( &ok ) ); | 471 | info->setStartingBalance( newbalance.toFloat( &ok ) ); |
472 | adjustBalance(); | 472 | adjustBalance(); |
473 | } | 473 | } |
474 | 474 | ||
475 | 475 | ||
476 | // --- slotNewTran ------------------------------------------------------------ | 476 | // --- slotNewTran ------------------------------------------------------------ |
477 | void Checkbook::slotNewTran() | 477 | void Checkbook::slotNewTran() |
478 | { | 478 | { |
479 | TranInfo *traninfo = new TranInfo( info->getNextNumber() ); | 479 | TranInfo *traninfo = new TranInfo( info->getNextNumber() ); |
480 | if( !_dLastNew.isNull() ) | 480 | if( !_dLastNew.isNull() ) |
481 | traninfo->setDate(_dLastNew); | 481 | traninfo->setDate(_dLastNew); |
482 | 482 | ||
483 | Transaction *currtran = new Transaction( this, true, info->name(), | 483 | Transaction *currtran = new Transaction( this, true, info->name(), |
484 | traninfo, | 484 | traninfo, |
485 | _pCfg ); | 485 | _pCfg ); |
486 | currtran->showMaximized(); | 486 | if ( QPEApplication::execDialog( currtran ) == QDialog::Accepted ) |
487 | if ( currtran->exec() == QDialog::Accepted ) | ||
488 | { | 487 | { |
489 | // Add to transaction list | 488 | // Add to transaction list |
490 | info->addTransaction( traninfo ); | 489 | info->addTransaction( traninfo ); |
491 | 490 | ||
492 | // Add to transaction table | 491 | // Add to transaction table |
493 | float amount; | 492 | float amount; |
494 | QString stramount; | 493 | QString stramount; |
495 | amount = (traninfo->withdrawal() ? -1 : 1)*traninfo->amount(); | 494 | amount = (traninfo->withdrawal() ? -1 : 1)*traninfo->amount(); |
496 | stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); | 495 | stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); |
497 | ( void ) new CBListItem( traninfo, tranTable, traninfo->getIdStr(), traninfo->datestr(false), | 496 | ( void ) new CBListItem( traninfo, tranTable, traninfo->getIdStr(), traninfo->datestr(false), |
498 | traninfo->number(), traninfo->datestr(true), traninfo->desc(), | 497 | traninfo->number(), traninfo->datestr(true), traninfo->desc(), |
499 | stramount ); | 498 | stramount ); |
500 | resort(); | 499 | resort(); |
501 | adjustBalance(); | 500 | adjustBalance(); |
502 | 501 | ||
503 | // save last date | 502 | // save last date |
504 | _dLastNew = traninfo->date(); | 503 | _dLastNew = traninfo->date(); |
505 | 504 | ||
506 | // save description in list of payees, if not in there | 505 | // save description in list of payees, if not in there |
507 | QStringList *pLst=&_pCfg->getPayees(); | 506 | QStringList *pLst=&_pCfg->getPayees(); |
508 | if( _pCfg->getSavePayees() && pLst->contains(traninfo->desc())==0 ) { | 507 | if( _pCfg->getSavePayees() && pLst->contains(traninfo->desc())==0 ) { |
509 | pLst->append( traninfo->desc() ); | 508 | pLst->append( traninfo->desc() ); |
510 | pLst->sort(); | 509 | pLst->sort(); |
511 | _pCfg->setDirty(true); | 510 | _pCfg->setDirty(true); |
512 | } | 511 | } |
513 | } | 512 | } |
514 | else | 513 | else |
515 | { | 514 | { |
516 | delete traninfo; | 515 | delete traninfo; |
517 | } | 516 | } |
518 | } | 517 | } |
519 | 518 | ||
520 | 519 | ||
521 | // --- slotEditTran ----------------------------------------------------------- | 520 | // --- slotEditTran ----------------------------------------------------------- |
522 | void Checkbook::slotEditTran() | 521 | void Checkbook::slotEditTran() |
523 | { | 522 | { |
524 | QListViewItem *curritem = tranTable->currentItem(); | 523 | QListViewItem *curritem = tranTable->currentItem(); |
525 | if ( !curritem ) | 524 | if ( !curritem ) |
526 | return; | 525 | return; |
527 | 526 | ||
528 | TranInfo *traninfo=info->findTransaction( curritem->text(COL_ID) ); | 527 | TranInfo *traninfo=info->findTransaction( curritem->text(COL_ID) ); |
529 | 528 | ||
530 | Transaction *currtran = new Transaction( this, false, info->name(), | 529 | Transaction *currtran = new Transaction( this, false, info->name(), |
531 | traninfo, | 530 | traninfo, |
532 | _pCfg ); | 531 | _pCfg ); |
533 | currtran->showMaximized(); | 532 | if ( QPEApplication::execDialog( currtran ) == QDialog::Accepted ) |
534 | if ( currtran->exec() == QDialog::Accepted ) | ||
535 | { | 533 | { |
536 | curritem->setText( COL_NUM, traninfo->number() ); | 534 | curritem->setText( COL_NUM, traninfo->number() ); |
537 | curritem->setText( COL_SORTDATE, traninfo->datestr(false) ); | 535 | curritem->setText( COL_SORTDATE, traninfo->datestr(false) ); |
538 | curritem->setText( COL_DATE, traninfo->datestr(true) ); | 536 | curritem->setText( COL_DATE, traninfo->datestr(true) ); |
539 | curritem->setText( COL_DESC, traninfo->desc() ); | 537 | curritem->setText( COL_DESC, traninfo->desc() ); |
540 | 538 | ||
541 | float amount = traninfo->amount(); | 539 | float amount = traninfo->amount(); |
542 | if ( traninfo->withdrawal() ) | 540 | if ( traninfo->withdrawal() ) |
543 | { | 541 | { |
544 | amount *= -1; | 542 | amount *= -1; |
545 | } | 543 | } |
546 | QString stramount; | 544 | QString stramount; |
547 | stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); | 545 | stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); |
548 | curritem->setText( COL_AMOUNT, stramount ); | 546 | curritem->setText( COL_AMOUNT, stramount ); |
549 | resort(); | 547 | resort(); |
550 | adjustBalance(); | 548 | adjustBalance(); |
551 | 549 | ||
552 | // save description in list of payees, if not in there | 550 | // save description in list of payees, if not in there |
553 | QStringList *pLst=&_pCfg->getPayees(); | 551 | QStringList *pLst=&_pCfg->getPayees(); |
554 | if( _pCfg->getSavePayees() && pLst->contains(traninfo->desc())==0 ) { | 552 | if( _pCfg->getSavePayees() && pLst->contains(traninfo->desc())==0 ) { |
555 | pLst->append( traninfo->desc() ); | 553 | pLst->append( traninfo->desc() ); |
556 | pLst->sort(); | 554 | pLst->sort(); |
557 | _pCfg->setDirty(true); | 555 | _pCfg->setDirty(true); |
558 | } | 556 | } |
559 | } | 557 | } |
560 | 558 | ||
561 | delete currtran; | 559 | delete currtran; |
562 | } | 560 | } |
563 | 561 | ||
564 | // --- slotMenuTran ----------------------------------------------------------- | 562 | // --- slotMenuTran ----------------------------------------------------------- |
565 | void Checkbook::slotMenuTran(QListViewItem *item, const QPoint &pnt) | 563 | void Checkbook::slotMenuTran(QListViewItem *item, const QPoint &pnt) |
566 | { | 564 | { |
567 | // active item? | 565 | // active item? |
568 | if( !item ) | 566 | if( !item ) |
569 | return; | 567 | return; |
570 | 568 | ||
571 | // Display menu | 569 | // Display menu |
572 | QPopupMenu m; | 570 | QPopupMenu m; |
573 | m.insertItem( QWidget::tr( "Edit" ), 1 ); | 571 | m.insertItem( QWidget::tr( "Edit" ), 1 ); |
574 | m.insertItem( QWidget::tr( "New" ), 2 ); | 572 | m.insertItem( QWidget::tr( "New" ), 2 ); |
575 | m.insertItem( QWidget::tr( "Delete" ), 3 ); | 573 | m.insertItem( QWidget::tr( "Delete" ), 3 ); |
576 | int r = m.exec( pnt ); | 574 | int r = m.exec( pnt ); |
577 | switch(r) { | 575 | switch(r) { |
578 | case 1: | 576 | case 1: |
579 | slotEditTran(); | 577 | slotEditTran(); |
580 | break; | 578 | break; |
581 | case 2: | 579 | case 2: |
582 | slotNewTran(); | 580 | slotNewTran(); |
diff --git a/noncore/apps/checkbook/mainwindow.cpp b/noncore/apps/checkbook/mainwindow.cpp index f29001a..60aea42 100644 --- a/noncore/apps/checkbook/mainwindow.cpp +++ b/noncore/apps/checkbook/mainwindow.cpp | |||
@@ -1,91 +1,91 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | =. | 3 | =. |
4 | .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> | 4 | .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This file is free software; you can | 6 | _;:, .> :=|. This file is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This file is distributed in the hope that | 13 | .i_,=:_. -<s. This file is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "mainwindow.h" | 29 | #include "mainwindow.h" |
30 | #include "cbinfo.h" | 30 | #include "cbinfo.h" |
31 | #include "configuration.h" | 31 | #include "configuration.h" |
32 | #include "password.h" | 32 | #include "password.h" |
33 | #include "checkbook.h" | 33 | #include "checkbook.h" |
34 | #include "listedit.h" | 34 | #include "listedit.h" |
35 | 35 | ||
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | #include <qpe/global.h> | 37 | #include <qpe/global.h> |
38 | #include <qpe/qpeapplication.h> | 38 | #include <qpe/qpeapplication.h> |
39 | #include <qmenubar.h> | ||
40 | #include <qpe/qpemessagebox.h> | 39 | #include <qpe/qpemessagebox.h> |
41 | #include <qpe/qpetoolbar.h> | 40 | #include <qpe/qpetoolbar.h> |
42 | #include <qpe/resource.h> | 41 | #include <qpe/resource.h> |
43 | 42 | ||
43 | #include <qmenubar.h> | ||
44 | #include <qaction.h> | 44 | #include <qaction.h> |
45 | #include <qcheckbox.h> | 45 | #include <qcheckbox.h> |
46 | #include <qdir.h> | 46 | #include <qdir.h> |
47 | #include <qlineedit.h> | 47 | #include <qlineedit.h> |
48 | #include <qwhatsthis.h> | 48 | #include <qwhatsthis.h> |
49 | 49 | ||
50 | 50 | ||
51 | MainWindow::MainWindow( QWidget* parent, const char* name, WFlags /*fl*/ ) | 51 | MainWindow::MainWindow( QWidget* parent, const char* name, WFlags /*fl*/ ) |
52 | : QMainWindow( parent, name, WStyle_ContextHelp ) | 52 | : QMainWindow( parent, name, WStyle_ContextHelp ) |
53 | { | 53 | { |
54 | setCaption( tr( "Checkbook" ) ); | 54 | setCaption( tr( "Checkbook" ) ); |
55 | 55 | ||
56 | cbDir = Global::applicationFileName( "checkbook", "" ); | 56 | cbDir = Global::applicationFileName( "checkbook", "" ); |
57 | lockIcon = Resource::loadPixmap( "locked" ); | 57 | lockIcon = Resource::loadPixmap( "locked" ); |
58 | 58 | ||
59 | // Load configuration options | 59 | // Load configuration options |
60 | Config config( "checkbook" ); | 60 | Config config( "checkbook" ); |
61 | _cfg.readConfig( config ); | 61 | _cfg.readConfig( config ); |
62 | 62 | ||
63 | 63 | ||
64 | // Build menu and tool bars | 64 | // Build menu and tool bars |
65 | setToolBarsMovable( FALSE ); | 65 | setToolBarsMovable( FALSE ); |
66 | 66 | ||
67 | QToolBar *bar = new QToolBar( this ); | 67 | QToolBar *bar = new QToolBar( this ); |
68 | bar->setHorizontalStretchable( TRUE ); | 68 | bar->setHorizontalStretchable( TRUE ); |
69 | QMenuBar *mb = new QMenuBar( bar ); | 69 | QMenuBar *mb = new QMenuBar( bar ); |
70 | mb->setMargin( 0 ); | 70 | mb->setMargin( 0 ); |
71 | QPopupMenu *popup = new QPopupMenu( this ); | 71 | QPopupMenu *popup = new QPopupMenu( this ); |
72 | 72 | ||
73 | bar = new QToolBar( this ); | 73 | bar = new QToolBar( this ); |
74 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); | 74 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
75 | a->setWhatsThis( tr( "Click here to create a new checkbook.\n\nYou also can select New from the Checkbook menu." ) ); | 75 | a->setWhatsThis( tr( "Click here to create a new checkbook.\n\nYou also can select New from the Checkbook menu." ) ); |
76 | connect( a, SIGNAL( activated() ), this, SLOT( slotNew() ) ); | 76 | connect( a, SIGNAL( activated() ), this, SLOT( slotNew() ) ); |
77 | a->addTo( popup ); | 77 | a->addTo( popup ); |
78 | a->addTo( bar ); | 78 | a->addTo( bar ); |
79 | 79 | ||
80 | actionOpen = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, | 80 | actionOpen = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, |
81 | 0, this, 0 ); | 81 | 0, this, 0 ); |
82 | actionOpen->setWhatsThis( tr( "Select a checkbook and then click here to edit it.\n\nYou also can select Edit from the Checkbook menu, or click and hold on a checkbook name." ) ); | 82 | actionOpen->setWhatsThis( tr( "Select a checkbook and then click here to edit it.\n\nYou also can select Edit from the Checkbook menu, or click and hold on a checkbook name." ) ); |
83 | connect( actionOpen, SIGNAL( activated() ), this, SLOT( slotEdit() ) ); | 83 | connect( actionOpen, SIGNAL( activated() ), this, SLOT( slotEdit() ) ); |
84 | actionOpen->addTo( popup ); | 84 | actionOpen->addTo( popup ); |
85 | actionOpen->addTo( bar ); | 85 | actionOpen->addTo( bar ); |
86 | 86 | ||
87 | actionDelete = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, | 87 | actionDelete = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, |
88 | 0, this, 0 ); | 88 | 0, this, 0 ); |
89 | actionDelete->setWhatsThis( tr( "Select a checkbook and then click here delete it.\n\nYou also can select Delete from the Checkbook menu." ) ); | 89 | actionDelete->setWhatsThis( tr( "Select a checkbook and then click here delete it.\n\nYou also can select Delete from the Checkbook menu." ) ); |
90 | connect( actionDelete, SIGNAL( activated() ), this, SLOT( slotDelete() ) ); | 90 | connect( actionDelete, SIGNAL( activated() ), this, SLOT( slotDelete() ) ); |
91 | actionDelete->addTo( popup ); | 91 | actionDelete->addTo( popup ); |
@@ -169,197 +169,194 @@ void MainWindow::buildList() | |||
169 | } | 169 | } |
170 | cbList->addColumn( tr( "Checkbook Name" ) ); | 170 | cbList->addColumn( tr( "Checkbook Name" ) ); |
171 | if ( _cfg.getShowBalances() ) | 171 | if ( _cfg.getShowBalances() ) |
172 | { | 172 | { |
173 | int colnum = cbList->addColumn( tr( "Balance" ) ); | 173 | int colnum = cbList->addColumn( tr( "Balance" ) ); |
174 | cbList->setColumnAlignment( colnum, Qt::AlignRight ); | 174 | cbList->setColumnAlignment( colnum, Qt::AlignRight ); |
175 | } | 175 | } |
176 | cbList->setAllColumnsShowFocus( TRUE ); | 176 | cbList->setAllColumnsShowFocus( TRUE ); |
177 | cbList->setSorting( posName ); | 177 | cbList->setSorting( posName ); |
178 | QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold ); | 178 | QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold ); |
179 | connect( cbList, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), | 179 | connect( cbList, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), |
180 | this, SLOT( slotEdit() ) ); | 180 | this, SLOT( slotEdit() ) ); |
181 | setCentralWidget( cbList ); | 181 | setCentralWidget( cbList ); |
182 | 182 | ||
183 | for ( CBInfo *cb = checkbooks->first(); cb; cb = checkbooks->next() ) | 183 | for ( CBInfo *cb = checkbooks->first(); cb; cb = checkbooks->next() ) |
184 | { | 184 | { |
185 | addCheckbook( cb ); | 185 | addCheckbook( cb ); |
186 | } | 186 | } |
187 | } | 187 | } |
188 | 188 | ||
189 | void MainWindow::addCheckbook( CBInfo *cb ) | 189 | void MainWindow::addCheckbook( CBInfo *cb ) |
190 | { | 190 | { |
191 | QListViewItem *lvi = new QListViewItem( cbList ); | 191 | QListViewItem *lvi = new QListViewItem( cbList ); |
192 | if ( _cfg.getShowLocks() && !cb->password().isNull() ) | 192 | if ( _cfg.getShowLocks() && !cb->password().isNull() ) |
193 | { | 193 | { |
194 | lvi->setPixmap( 0, lockIcon ); | 194 | lvi->setPixmap( 0, lockIcon ); |
195 | } | 195 | } |
196 | lvi->setText( posName, cb->name() ); | 196 | lvi->setText( posName, cb->name() ); |
197 | if ( _cfg.getShowBalances() ) | 197 | if ( _cfg.getShowBalances() ) |
198 | { | 198 | { |
199 | QString balance; | 199 | QString balance; |
200 | balance.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() ); | 200 | balance.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() ); |
201 | lvi->setText( posName + 1, balance ); | 201 | lvi->setText( posName + 1, balance ); |
202 | } | 202 | } |
203 | } | 203 | } |
204 | 204 | ||
205 | void MainWindow::buildFilename( const QString &name ) | 205 | void MainWindow::buildFilename( const QString &name ) |
206 | { | 206 | { |
207 | tempFilename = cbDir; | 207 | tempFilename = cbDir; |
208 | tempFilename.append( name ); | 208 | tempFilename.append( name ); |
209 | tempFilename.append( ".qcb" ); | 209 | tempFilename.append( ".qcb" ); |
210 | } | 210 | } |
211 | 211 | ||
212 | void MainWindow::slotNew() | 212 | void MainWindow::slotNew() |
213 | { | 213 | { |
214 | CBInfo *cb = new CBInfo(); | 214 | CBInfo *cb = new CBInfo(); |
215 | 215 | ||
216 | Checkbook *currcb = new Checkbook( this, cb, &_cfg ); | 216 | Checkbook *currcb = new Checkbook( this, cb, &_cfg ); |
217 | currcb->showMaximized(); | 217 | if ( QPEApplication::execDialog( currcb ) == QDialog::Accepted ) |
218 | if ( currcb->exec() == QDialog::Accepted ) | ||
219 | { | 218 | { |
220 | // Save new checkbook | 219 | // Save new checkbook |
221 | buildFilename( cb->name() ); | 220 | buildFilename( cb->name() ); |
222 | _cfg.setLastBook( cb->name() ); | 221 | _cfg.setLastBook( cb->name() ); |
223 | cb->setFilename( tempFilename ); | 222 | cb->setFilename( tempFilename ); |
224 | cb->write(); | 223 | cb->write(); |
225 | 224 | ||
226 | // Add to listbox | 225 | // Add to listbox |
227 | checkbooks->inSort( cb ); | 226 | checkbooks->inSort( cb ); |
228 | addCheckbook( cb ); | 227 | addCheckbook( cb ); |
229 | } | 228 | } |
230 | delete currcb; | 229 | delete currcb; |
231 | } | 230 | } |
232 | 231 | ||
233 | // --- slotEdit --------------------------------------------------------------- | 232 | // --- slotEdit --------------------------------------------------------------- |
234 | void MainWindow::slotEdit() | 233 | void MainWindow::slotEdit() |
235 | { | 234 | { |
236 | // get name and open it | 235 | // get name and open it |
237 | QListViewItem *curritem = cbList->currentItem(); | 236 | QListViewItem *curritem = cbList->currentItem(); |
238 | if ( !curritem ) | 237 | if ( !curritem ) |
239 | return; | 238 | return; |
240 | openBook( curritem ); | 239 | openBook( curritem ); |
241 | } | 240 | } |
242 | 241 | ||
243 | 242 | ||
244 | // --- openBook --------------------------------------------------------------- | 243 | // --- openBook --------------------------------------------------------------- |
245 | void MainWindow::openBook(QListViewItem *curritem) | 244 | void MainWindow::openBook(QListViewItem *curritem) |
246 | { | 245 | { |
247 | // find book in List | 246 | // find book in List |
248 | QString currname=curritem->text(posName); | 247 | QString currname=curritem->text(posName); |
249 | CBInfo *cb = checkbooks->first(); | 248 | CBInfo *cb = checkbooks->first(); |
250 | while ( cb ) { | 249 | while ( cb ) { |
251 | if ( cb->name() == currname ) | 250 | if ( cb->name() == currname ) |
252 | break; | 251 | break; |
253 | cb = checkbooks->next(); | 252 | cb = checkbooks->next(); |
254 | } | 253 | } |
255 | if ( !cb ) return; | 254 | if ( !cb ) return; |
256 | 255 | ||
257 | // | 256 | // |
258 | buildFilename( currname ); | 257 | buildFilename( currname ); |
259 | float currbalance = cb->balance(); | 258 | float currbalance = cb->balance(); |
260 | bool currlock = !cb->password().isNull(); | 259 | bool currlock = !cb->password().isNull(); |
261 | 260 | ||
262 | if ( currlock ) | 261 | if ( currlock ) |
263 | { | 262 | { |
264 | Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); | 263 | Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); |
265 | if ( pw->exec() != QDialog::Accepted || pw->password != cb->password() ) | 264 | if ( pw->exec() != QDialog::Accepted || pw->password != cb->password() ) |
266 | { | 265 | { |
267 | delete pw; | 266 | delete pw; |
268 | return; | 267 | return; |
269 | } | 268 | } |
270 | delete pw; | 269 | delete pw; |
271 | } | 270 | } |
272 | 271 | ||
273 | _cfg.setLastBook( currname ); | 272 | _cfg.setLastBook( currname ); |
274 | Checkbook *currcb = new Checkbook( this, cb, &_cfg ); | 273 | Checkbook *currcb = new Checkbook( this, cb, &_cfg ); |
275 | currcb->showMaximized(); | 274 | if ( QPEApplication::execDialog( currcb ) == QDialog::Accepted ) |
276 | if ( currcb->exec() == QDialog::Accepted ) | ||
277 | { | 275 | { |
278 | QString newname = cb->name(); | 276 | QString newname = cb->name(); |
279 | if ( currname != newname ) | 277 | if ( currname != newname ) |
280 | { | 278 | { |
281 | // Update name if changed | 279 | // Update name if changed |
282 | if( curritem ) { | 280 | if( curritem ) { |
283 | curritem->setText( posName, newname ); | 281 | curritem->setText( posName, newname ); |
284 | cbList->sort(); | 282 | cbList->sort(); |
285 | } | 283 | } |
286 | _cfg.setLastBook( newname ); | 284 | _cfg.setLastBook( newname ); |
287 | 285 | ||
288 | // Remove old file | 286 | // Remove old file |
289 | QFile f( tempFilename ); | 287 | QFile f( tempFilename ); |
290 | if ( f.exists() ) | 288 | if ( f.exists() ) |
291 | f.remove(); | 289 | f.remove(); |
292 | 290 | ||
293 | // Get new filename | 291 | // Get new filename |
294 | buildFilename( newname ); | 292 | buildFilename( newname ); |
295 | cb->setFilename( tempFilename ); | 293 | cb->setFilename( tempFilename ); |
296 | } | 294 | } |
297 | 295 | ||
298 | cb->write(); | 296 | cb->write(); |
299 | 297 | ||
300 | // Update lock if changed | 298 | // Update lock if changed |
301 | if ( _cfg.getShowLocks() && !cb->password().isNull() != currlock ) | 299 | if ( _cfg.getShowLocks() && !cb->password().isNull() != currlock ) |
302 | { | 300 | { |
303 | if ( !cb->password().isNull() ) | 301 | if ( !cb->password().isNull() ) |
304 | curritem->setPixmap( 0, lockIcon ); | 302 | curritem->setPixmap( 0, lockIcon ); |
305 | else | 303 | else |
306 | curritem->setPixmap( 0, nullIcon ); | 304 | curritem->setPixmap( 0, nullIcon ); |
307 | } | 305 | } |
308 | 306 | ||
309 | // Update balance if changed | 307 | // Update balance if changed |
310 | if ( _cfg.getShowBalances() && cb->balance() != currbalance ) | 308 | if ( _cfg.getShowBalances() && cb->balance() != currbalance ) |
311 | { | 309 | { |
312 | QString tempstr; | 310 | QString tempstr; |
313 | tempstr.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() ); | 311 | tempstr.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() ); |
314 | curritem->setText( posName + 1, tempstr ); | 312 | curritem->setText( posName + 1, tempstr ); |
315 | } | 313 | } |
316 | 314 | ||
317 | // write config, if needed | 315 | // write config, if needed |
318 | if( _cfg.isDirty() ) { | 316 | if( _cfg.isDirty() ) { |
319 | Config config("checkbook"); | 317 | Config config("checkbook"); |
320 | _cfg.writeConfig( config ); | 318 | _cfg.writeConfig( config ); |
321 | } | 319 | } |
322 | } | 320 | } |
323 | delete currcb; | 321 | delete currcb; |
324 | } | 322 | } |
325 | 323 | ||
326 | // --- slotDelete ------------------------------------------------------------- | 324 | // --- slotDelete ------------------------------------------------------------- |
327 | void MainWindow::slotDelete() | 325 | void MainWindow::slotDelete() |
328 | { | 326 | { |
329 | QString currname = cbList->currentItem()->text( posName ); | 327 | QString currname = cbList->currentItem()->text( posName ); |
330 | 328 | ||
331 | if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), currname ) ) | 329 | if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), currname ) ) |
332 | { | 330 | { |
333 | buildFilename( currname ); | 331 | buildFilename( currname ); |
334 | QFile f( tempFilename ); | 332 | QFile f( tempFilename ); |
335 | if ( f.exists() ) | 333 | if ( f.exists() ) |
336 | { | 334 | { |
337 | f.remove(); | 335 | f.remove(); |
338 | } | 336 | } |
339 | 337 | ||
340 | delete cbList->currentItem(); | 338 | delete cbList->currentItem(); |
341 | } | 339 | } |
342 | } | 340 | } |
343 | 341 | ||
344 | // --- slotConfigure ---------------------------------------------------------- | 342 | // --- slotConfigure ---------------------------------------------------------- |
345 | void MainWindow::slotConfigure() | 343 | void MainWindow::slotConfigure() |
346 | { | 344 | { |
347 | Configuration *cfgdlg = new Configuration( this, _cfg ); | 345 | Configuration *cfgdlg = new Configuration( this, _cfg ); |
348 | cfgdlg->showMaximized(); | 346 | if ( QPEApplication::execDialog( cfgdlg ) == QDialog::Accepted ) |
349 | if ( cfgdlg->exec() == QDialog::Accepted ) | ||
350 | { | 347 | { |
351 | // read data from config dialog & save it | 348 | // read data from config dialog & save it |
352 | cfgdlg->saveConfig( _cfg ); | 349 | cfgdlg->saveConfig( _cfg ); |
353 | writeConfig(); | 350 | writeConfig(); |
354 | buildList(); | 351 | buildList(); |
355 | } | 352 | } |
356 | delete cfgdlg; | 353 | delete cfgdlg; |
357 | } | 354 | } |
358 | 355 | ||
359 | 356 | ||
360 | // --- writeConfig -------------------------------------------------------------- | 357 | // --- writeConfig -------------------------------------------------------------- |
361 | void MainWindow::writeConfig() | 358 | void MainWindow::writeConfig() |
362 | { | 359 | { |
363 | Config config("checkbook"); | 360 | Config config("checkbook"); |
364 | _cfg.writeConfig( config ); | 361 | _cfg.writeConfig( config ); |
365 | } | 362 | } |