summaryrefslogtreecommitdiff
path: root/noncore/apps/checkbook/mainwindow.cpp
Unidiff
Diffstat (limited to 'noncore/apps/checkbook/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/checkbook/mainwindow.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/noncore/apps/checkbook/mainwindow.cpp b/noncore/apps/checkbook/mainwindow.cpp
index 8d64cad..bf00102 100644
--- a/noncore/apps/checkbook/mainwindow.cpp
+++ b/noncore/apps/checkbook/mainwindow.cpp
@@ -37,49 +37,48 @@
37#include <qpe/global.h> 37#include <qpe/global.h>
38#include <qpe/qpeapplication.h> 38#include <qpe/qpeapplication.h>
39#include <qpe/qpemenubar.h> 39#include <qpe/qpemenubar.h>
40#include <qpe/qpemessagebox.h> 40#include <qpe/qpemessagebox.h>
41#include <qpe/qpetoolbar.h> 41#include <qpe/qpetoolbar.h>
42#include <qpe/resource.h> 42#include <qpe/resource.h>
43 43
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
51MainWindow::MainWindow( QWidget* parent, const char* name, WFlags fl ) 51MainWindow::MainWindow( QWidget* parent, const char* name, WFlags fl )
52 : QMainWindow( parent, name, fl || WStyle_ContextHelp ) 52 : QMainWindow( parent, name, fl || 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" );
61qDebug( "Reading config" );
62 _cfg.readConfig( config ); 61 _cfg.readConfig( config );
63 62
64 63
65 // Build menu and tool bars 64 // Build menu and tool bars
66 setToolBarsMovable( FALSE ); 65 setToolBarsMovable( FALSE );
67 66
68 QPEToolBar *bar = new QPEToolBar( this ); 67 QPEToolBar *bar = new QPEToolBar( this );
69 bar->setHorizontalStretchable( TRUE ); 68 bar->setHorizontalStretchable( TRUE );
70 QPEMenuBar *mb = new QPEMenuBar( bar ); 69 QPEMenuBar *mb = new QPEMenuBar( bar );
71 mb->setMargin( 0 ); 70 mb->setMargin( 0 );
72 QPopupMenu *popup = new QPopupMenu( this ); 71 QPopupMenu *popup = new QPopupMenu( this );
73 72
74 bar = new QPEToolBar( this ); 73 bar = new QPEToolBar( this );
75 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 );
76 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." ) );
77 connect( a, SIGNAL( activated() ), this, SLOT( slotNew() ) ); 76 connect( a, SIGNAL( activated() ), this, SLOT( slotNew() ) );
78 a->addTo( popup ); 77 a->addTo( popup );
79 a->addTo( bar ); 78 a->addTo( bar );
80 79
81 actionOpen = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, 80 actionOpen = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null,
82 0, this, 0 ); 81 0, this, 0 );
83 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." ) );
84 connect( actionOpen, SIGNAL( activated() ), this, SLOT( slotEdit() ) ); 83 connect( actionOpen, SIGNAL( activated() ), this, SLOT( slotEdit() ) );
85 actionOpen->addTo( popup ); 84 actionOpen->addTo( popup );
@@ -293,48 +292,54 @@ void MainWindow::openBook(QListViewItem *curritem)
293 292
294 // Get new filename 293 // Get new filename
295 buildFilename( newname ); 294 buildFilename( newname );
296 cb->setFilename( tempFilename ); 295 cb->setFilename( tempFilename );
297 } 296 }
298 297
299 cb->write(); 298 cb->write();
300 299
301 // Update lock if changed 300 // Update lock if changed
302 if ( _cfg.getShowLocks() && !cb->password().isNull() != currlock ) 301 if ( _cfg.getShowLocks() && !cb->password().isNull() != currlock )
303 { 302 {
304 if ( !cb->password().isNull() ) 303 if ( !cb->password().isNull() )
305 curritem->setPixmap( 0, lockIcon ); 304 curritem->setPixmap( 0, lockIcon );
306 else 305 else
307 curritem->setPixmap( 0, nullIcon ); 306 curritem->setPixmap( 0, nullIcon );
308 } 307 }
309 308
310 // Update balance if changed 309 // Update balance if changed
311 if ( _cfg.getShowBalances() && cb->balance() != currbalance ) 310 if ( _cfg.getShowBalances() && cb->balance() != currbalance )
312 { 311 {
313 QString tempstr; 312 QString tempstr;
314 tempstr.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() ); 313 tempstr.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() );
315 curritem->setText( posName + 1, tempstr ); 314 curritem->setText( posName + 1, tempstr );
316 } 315 }
316
317 // write config, if needed
318 if( _cfg.isDirty() ) {
319 Config config("checkbook");
320 _cfg.writeConfig( config );
321 }
317 } 322 }
318 delete currcb; 323 delete currcb;
319} 324}
320 325
321// --- slotDelete ------------------------------------------------------------- 326// --- slotDelete -------------------------------------------------------------
322void MainWindow::slotDelete() 327void MainWindow::slotDelete()
323{ 328{
324 QString currname = cbList->currentItem()->text( posName ); 329 QString currname = cbList->currentItem()->text( posName );
325 330
326 if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), currname ) ) 331 if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), currname ) )
327 { 332 {
328 buildFilename( currname ); 333 buildFilename( currname );
329 QFile f( tempFilename ); 334 QFile f( tempFilename );
330 if ( f.exists() ) 335 if ( f.exists() )
331 { 336 {
332 f.remove(); 337 f.remove();
333 } 338 }
334 339
335 delete cbList->currentItem(); 340 delete cbList->currentItem();
336 } 341 }
337} 342}
338 343
339// --- slotConfigure ---------------------------------------------------------- 344// --- slotConfigure ----------------------------------------------------------
340void MainWindow::slotConfigure() 345void MainWindow::slotConfigure()