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.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/noncore/apps/checkbook/mainwindow.cpp b/noncore/apps/checkbook/mainwindow.cpp
index ce15e3e..c7ffa7c 100644
--- a/noncore/apps/checkbook/mainwindow.cpp
+++ b/noncore/apps/checkbook/mainwindow.cpp
@@ -172,49 +172,50 @@ void MainWindow::buildList()
172 cbList->setAllColumnsShowFocus( TRUE ); 172 cbList->setAllColumnsShowFocus( TRUE );
173 cbList->setSorting( posName ); 173 cbList->setSorting( posName );
174 QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold ); 174 QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold );
175 connect( cbList, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ), 175 connect( cbList, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ),
176 this, SLOT( slotEdit() ) ); 176 this, SLOT( slotEdit() ) );
177 setCentralWidget( cbList ); 177 setCentralWidget( cbList );
178 178
179 for ( CBInfo *cb = checkbooks->first(); cb; cb = checkbooks->next() ) 179 for ( CBInfo *cb = checkbooks->first(); cb; cb = checkbooks->next() )
180 { 180 {
181 addCheckbook( cb ); 181 addCheckbook( cb );
182 } 182 }
183} 183}
184 184
185void MainWindow::addCheckbook( CBInfo *cb ) 185void MainWindow::addCheckbook( CBInfo *cb )
186{ 186{
187 QListViewItem *lvi = new QListViewItem( cbList ); 187 QListViewItem *lvi = new QListViewItem( cbList );
188 if ( _cfg.getShowLocks() && !cb->password().isNull() ) 188 if ( _cfg.getShowLocks() && !cb->password().isNull() )
189 { 189 {
190 lvi->setPixmap( 0, lockIcon ); 190 lvi->setPixmap( 0, lockIcon );
191 } 191 }
192 lvi->setText( posName, cb->name() ); 192 lvi->setText( posName, cb->name() );
193 if ( _cfg.getShowBalances() ) 193 if ( _cfg.getShowBalances() )
194 { 194 {
195 QString balance; 195 QString balance;
196 balance.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() ); 196 balance.sprintf( "%.2f", cb->balance() );
197 balance.prepend( _cfg.getCurrencySymbol() );
197 lvi->setText( posName + 1, balance ); 198 lvi->setText( posName + 1, balance );
198 } 199 }
199} 200}
200 201
201void MainWindow::buildFilename( const QString &name ) 202void MainWindow::buildFilename( const QString &name )
202{ 203{
203 tempFilename = cbDir; 204 tempFilename = cbDir;
204 tempFilename.append( name ); 205 tempFilename.append( name );
205 tempFilename.append( ".qcb" ); 206 tempFilename.append( ".qcb" );
206} 207}
207 208
208void MainWindow::slotNew() 209void MainWindow::slotNew()
209{ 210{
210 CBInfo *cb = new CBInfo(); 211 CBInfo *cb = new CBInfo();
211 212
212 Checkbook *currcb = new Checkbook( this, cb, &_cfg ); 213 Checkbook *currcb = new Checkbook( this, cb, &_cfg );
213 if ( QPEApplication::execDialog( currcb ) == QDialog::Accepted ) 214 if ( QPEApplication::execDialog( currcb ) == QDialog::Accepted )
214 { 215 {
215 // Save new checkbook 216 // Save new checkbook
216 buildFilename( cb->name() ); 217 buildFilename( cb->name() );
217 _cfg.setLastBook( cb->name() ); 218 _cfg.setLastBook( cb->name() );
218 cb->setFilename( tempFilename ); 219 cb->setFilename( tempFilename );
219 cb->write(); 220 cb->write();
220 221
@@ -283,49 +284,50 @@ void MainWindow::openBook(QListViewItem *curritem)
283 QFile f( tempFilename ); 284 QFile f( tempFilename );
284 if ( f.exists() ) 285 if ( f.exists() )
285 f.remove(); 286 f.remove();
286 287
287 // Get new filename 288 // Get new filename
288 buildFilename( newname ); 289 buildFilename( newname );
289 cb->setFilename( tempFilename ); 290 cb->setFilename( tempFilename );
290 } 291 }
291 292
292 cb->write(); 293 cb->write();
293 294
294 // Update lock if changed 295 // Update lock if changed
295 if ( _cfg.getShowLocks() && !cb->password().isNull() != currlock ) 296 if ( _cfg.getShowLocks() && !cb->password().isNull() != currlock )
296 { 297 {
297 if ( !cb->password().isNull() ) 298 if ( !cb->password().isNull() )
298 curritem->setPixmap( 0, lockIcon ); 299 curritem->setPixmap( 0, lockIcon );
299 else 300 else
300 curritem->setPixmap( 0, nullIcon ); 301 curritem->setPixmap( 0, nullIcon );
301 } 302 }
302 303
303 // Update balance if changed 304 // Update balance if changed
304 if ( _cfg.getShowBalances() && cb->balance() != currbalance ) 305 if ( _cfg.getShowBalances() && cb->balance() != currbalance )
305 { 306 {
306 QString tempstr; 307 QString tempstr;
307 tempstr.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() ); 308 tempstr.sprintf( "%.2f", cb->balance() );
309 tempstr.prepend( _cfg.getCurrencySymbol() );
308 curritem->setText( posName + 1, tempstr ); 310 curritem->setText( posName + 1, tempstr );
309 } 311 }
310 312
311 // write config, if needed 313 // write config, if needed
312 if( _cfg.isDirty() ) { 314 if( _cfg.isDirty() ) {
313 Config config("checkbook"); 315 Config config("checkbook");
314 _cfg.writeConfig( config ); 316 _cfg.writeConfig( config );
315 } 317 }
316 } 318 }
317 delete currcb; 319 delete currcb;
318} 320}
319 321
320// --- slotDelete ------------------------------------------------------------- 322// --- slotDelete -------------------------------------------------------------
321void MainWindow::slotDelete() 323void MainWindow::slotDelete()
322{ 324{
323 QString currname = cbList->currentItem()->text( posName ); 325 QString currname = cbList->currentItem()->text( posName );
324 326
325 if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), currname ) ) 327 if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), currname ) )
326 { 328 {
327 buildFilename( currname ); 329 buildFilename( currname );
328 QFile f( tempFilename ); 330 QFile f( tempFilename );
329 if ( f.exists() ) 331 if ( f.exists() )
330 { 332 {
331 f.remove(); 333 f.remove();