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.cpp59
1 files changed, 29 insertions, 30 deletions
diff --git a/noncore/apps/checkbook/mainwindow.cpp b/noncore/apps/checkbook/mainwindow.cpp
index 9410536..ead17b4 100644
--- a/noncore/apps/checkbook/mainwindow.cpp
+++ b/noncore/apps/checkbook/mainwindow.cpp
@@ -41,9 +41,10 @@
41#include <qlistbox.h> 41#include <qlistbox.h>
42#include <qpopupmenu.h> 42#include <qpopupmenu.h>
43#include <qstring.h> 43#include <qstring.h>
44#include <qwhatsthis.h>
44 45
45MainWindow::MainWindow() 46MainWindow::MainWindow()
46 : QMainWindow() 47 : QMainWindow( 0x0, 0x0, WStyle_ContextHelp )
47{ 48{
48 setCaption( tr( "Checkbook" ) ); 49 setCaption( tr( "Checkbook" ) );
49 50
@@ -59,36 +60,34 @@ MainWindow::MainWindow()
59 QPopupMenu *popup = new QPopupMenu( this ); 60 QPopupMenu *popup = new QPopupMenu( this );
60 61
61 bar = new QPEToolBar( this ); 62 bar = new QPEToolBar( this );
62 actionOpen = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null,
63 0, this, 0 );
64 connect( actionOpen, SIGNAL( activated() ), this, SLOT( slotOpen() ) );
65 actionOpen->addTo( popup );
66 actionOpen->addTo( bar );
67
68 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); 63 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
64 a->setWhatsThis( tr( "Click here to create a new checkbook.\n\nYou also can select New from the Checkbook menu." ) );
69 connect( a, SIGNAL( activated() ), this, SLOT( slotNew() ) ); 65 connect( a, SIGNAL( activated() ), this, SLOT( slotNew() ) );
70 a->addTo( popup ); 66 a->addTo( popup );
71 a->addTo( bar ); 67 a->addTo( bar );
72 68
73 actionDelete = new QAction( tr( "Delete" ), Resource::loadPixmap( "editdelete" ), QString::null, 69 actionOpen = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null,
70 0, this, 0 );
71 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." ) );
72 connect( actionOpen, SIGNAL( activated() ), this, SLOT( slotEdit() ) );
73 actionOpen->addTo( popup );
74 actionOpen->addTo( bar );
75
76 actionDelete = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null,
74 0, this, 0 ); 77 0, this, 0 );
78 actionDelete->setWhatsThis( tr( "Select a checkbook and then click here delete it.\n\nYou also can select Delete from the Checkbook menu." ) );
75 connect( actionDelete, SIGNAL( activated() ), this, SLOT( slotDelete() ) ); 79 connect( actionDelete, SIGNAL( activated() ), this, SLOT( slotDelete() ) );
76 actionDelete->addTo( popup ); 80 actionDelete->addTo( popup );
77 actionDelete->addTo( bar ); 81 actionDelete->addTo( bar );
78 82
79 popup->insertSeparator();
80
81 a = new QAction( tr( "Exit" ), QString::null, 0, this, 0 );
82 connect( a, SIGNAL( activated() ), this, SLOT( close() ) );
83 a->addTo( popup );
84
85 mb->insertItem( tr( "Checkbook" ), popup ); 83 mb->insertItem( tr( "Checkbook" ), popup );
86 84
87 // Build Checkbook selection list control 85 // Build Checkbook selection list control
88 cbList = new QListBox( this ); 86 cbList = new QListBox( this );
87 QWhatsThis::add( cbList, tr( "This is a listing of all checkbooks currently available." ) );
89 QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold ); 88 QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold );
90 connect( cbList, SIGNAL( rightButtonPressed( QListBoxItem *, const QPoint & ) ), 89 connect( cbList, SIGNAL( rightButtonPressed( QListBoxItem *, const QPoint & ) ),
91 this, SLOT( slotOpen() ) ); 90 this, SLOT( slotEdit() ) );
92 setCentralWidget( cbList ); 91 setCentralWidget( cbList );
93 92
94 // Load Checkbook selection list 93 // Load Checkbook selection list
@@ -113,7 +112,19 @@ MainWindow::~MainWindow()
113{ 112{
114} 113}
115 114
116void MainWindow::slotOpen() 115void MainWindow::slotNew()
116{
117 Checkbook *currcb = new Checkbook( this, "", cbDir, currencySymbol );
118 currcb->showMaximized();
119 if ( currcb->exec() == QDialog::Accepted )
120 {
121 cbList->insertItem( currcb->getName() );
122 cbList->sort();
123 delete currcb;
124 }
125}
126
127void MainWindow::slotEdit()
117{ 128{
118 QString currname = cbList->currentText(); 129 QString currname = cbList->currentText();
119 Checkbook *currcb = new Checkbook( this, currname, cbDir, currencySymbol ); 130 Checkbook *currcb = new Checkbook( this, currname, cbDir, currencySymbol );
@@ -136,29 +147,17 @@ void MainWindow::slotOpen()
136 } 147 }
137} 148}
138 149
139void MainWindow::slotNew()
140{
141 Checkbook *currcb = new Checkbook( this, "", cbDir, currencySymbol );
142 currcb->showMaximized();
143 if ( currcb->exec() == QDialog::Accepted )
144 {
145 cbList->insertItem( currcb->getName() );
146 cbList->sort();
147 delete currcb;
148 }
149}
150
151void MainWindow::slotDelete() 150void MainWindow::slotDelete()
152{ 151{
153 if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), cbList->currentText() ) ) 152 if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), cbList->currentText() ) )
154 { 153 {
155 cbList->removeItem( cbList->currentItem() );
156
157 QString name = cbDir + cbList->currentText() + ".qcb"; 154 QString name = cbDir + cbList->currentText() + ".qcb";
158 QFile f( name ); 155 QFile f( name );
159 if ( f.exists() ) 156 if ( f.exists() )
160 { 157 {
161 f.remove(); 158 f.remove();
162 } 159 }
160
161 cbList->removeItem( cbList->currentItem() );
163 } 162 }
164} 163}