summaryrefslogtreecommitdiff
path: root/noncore/apps/checkbook/checkbook.cpp
Unidiff
Diffstat (limited to 'noncore/apps/checkbook/checkbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/checkbook/checkbook.cpp59
1 files changed, 29 insertions, 30 deletions
diff --git a/noncore/apps/checkbook/checkbook.cpp b/noncore/apps/checkbook/checkbook.cpp
index 4b81c6d..20b42b5 100644
--- a/noncore/apps/checkbook/checkbook.cpp
+++ b/noncore/apps/checkbook/checkbook.cpp
@@ -25,12 +25,14 @@
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include "checkbook.h" 29#include "checkbook.h"
30#include "transaction.h" 30#include "transaction.h"
31#include "graph.h"
32#include "graphinfo.h"
31 33
32#include <opie/otabwidget.h> 34#include <opie/otabwidget.h>
33#include <qpe/config.h> 35#include <qpe/config.h>
34#include <qpe/qpeapplication.h> 36#include <qpe/qpeapplication.h>
35#include <qpe/qpemessagebox.h> 37#include <qpe/qpemessagebox.h>
36#include <qpe/resource.h> 38#include <qpe/resource.h>
@@ -47,20 +49,25 @@
47#include <qwidget.h> 49#include <qwidget.h>
48 50
49Checkbook::Checkbook( QWidget *parent, const QString &n, const QString &fd, char symbol ) 51Checkbook::Checkbook( QWidget *parent, const QString &n, const QString &fd, char symbol )
50 : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) 52 : QDialog( parent, 0, TRUE, WStyle_ContextHelp )
51{ 53{
52 name = n; 54 name = n;
53 filename = fd + name + ".qcb"; 55 filename = fd;
56 filename.append( name );
57 filename.append( ".qcb" );
54 filedir = fd; 58 filedir = fd;
55 currencySymbol = symbol; 59 currencySymbol = symbol;
56 currBalance = 0.0; 60 currBalance = 0.0;
57 61
58 if ( name != "" ) 62 if ( name != "" )
59 { 63 {
60 setCaption( name + " - " + tr( "Checkbook" ) ); 64 QString tempstr = name;
65 tempstr.append( " - " );
66 tempstr.append( tr( "Checkbook" ) );
67 setCaption( tempstr );
61 } 68 }
62 else 69 else
63 { 70 {
64 setCaption( tr( "New checkbook" ) ); 71 setCaption( tr( "New checkbook" ) );
65 } 72 }
66 73
@@ -239,19 +246,20 @@ QWidget *Checkbook::initCharts()
239 graphList->insertItem( tr( "By category" ) ); 246 graphList->insertItem( tr( "By category" ) );
240 graphList->insertItem( tr( "..." ) ); 247 graphList->insertItem( tr( "..." ) );
241 graphList->insertItem( tr( "..." ) ); 248 graphList->insertItem( tr( "..." ) );
242 layout->addWidget( graphList, 0, 1 ); 249 layout->addWidget( graphList, 0, 1 );
243*/ 250*/
244 251
245 QWidget *graphWidget = new QWidget( control ); 252 GraphInfo* info = new GraphInfo( GraphInfo::BarChart, 0x0, tr( "Graph Title" ),
246 QWhatsThis::add( graphWidget, tr( "Graph not implemented yet." ) ); 253 tr( "X-Axis" ), tr( "Y-Axis" ) );
254 graphWidget = new Graph( control, info );
255 QWhatsThis::add( graphWidget, tr( "Charting is not implemented yet." ) );
247 layout->addMultiCellWidget( graphWidget, 0, 0, 0, 1 ); 256 layout->addMultiCellWidget( graphWidget, 0, 0, 0, 1 );
248 graphWidget->setBackgroundMode( QWidget::PaletteBase );
249 257
250 QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/drawbtn" ), tr( "Draw" ), control ); 258 QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/drawbtn" ), tr( "Draw" ), control );
251 QWhatsThis::add( btn, tr( "Click here to draw the graph." ) ); 259 QWhatsThis::add( btn, tr( "Click here to draw the chart." ) );
252 connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) ); 260 connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) );
253 layout->addWidget( btn, 1, 1 ); 261 layout->addWidget( btn, 1, 1 );
254 262
255 return control; 263 return control;
256} 264}
257 265
@@ -273,14 +281,14 @@ void Checkbook::loadCheckbook()
273 if ( typeList->currentText() == temptext ) 281 if ( typeList->currentText() == temptext )
274 { 282 {
275 break; 283 break;
276 } 284 }
277 } 285 }
278 bankEdit->setText( config.readEntry( "Bank", "" ) ); 286 bankEdit->setText( config.readEntry( "Bank", "" ) );
279 acctNumEdit->setText( config.readEntry( "Number", "" ) ); 287 acctNumEdit->setText( config.readEntryCrypt( "Number", "" ) );
280 pinNumEdit->setText( config.readEntry( "PINNumber", "" ) ); 288 pinNumEdit->setText( config.readEntryCrypt( "PINNumber", "" ) );
281 balanceEdit->setText( config.readEntry( "Balance", "0.0" ) ); 289 balanceEdit->setText( config.readEntry( "Balance", "0.0" ) );
282 notesEdit->setText( config.readEntry( "Notes", "" ) ); 290 notesEdit->setText( config.readEntry( "Notes", "" ) );
283 291
284 bool ok; 292 bool ok;
285 currBalance = balanceEdit->text().toFloat( &ok ); 293 currBalance = balanceEdit->text().toFloat( &ok );
286 startBalance = currBalance; 294 startBalance = currBalance;
@@ -306,17 +314,13 @@ void Checkbook::loadCheckbook()
306 stramount.sprintf( "%c%.2f", currencySymbol, amount ); 314 stramount.sprintf( "%c%.2f", currencySymbol, amount );
307 315
308 // Add to transaction list 316 // Add to transaction list
309 transactions.append( tran ); 317 transactions.append( tran );
310 318
311 // Add to transaction table 319 // Add to transaction table
312 QDate date = tran->date(); 320 ( void ) new QListViewItem( tranTable, QString::number( i ), tran->datestr(),
313 QString datestr = QString::number( date.month() ) + "/" +
314 QString::number( date.day() ) + "/" +
315 QString::number( date.year() );
316 ( void ) new QListViewItem( tranTable, QString::number( i ), datestr,
317 trandesc, stramount ); 321 trandesc, stramount );
318 } 322 }
319 else 323 else
320 { 324 {
321 delete tran; 325 delete tran;
322 } 326 }
@@ -354,14 +358,14 @@ void Checkbook::accept()
354 Config *config = new Config(filename, Config::File); 358 Config *config = new Config(filename, Config::File);
355 359
356 // Save info 360 // Save info
357 config->setGroup( "Account" ); 361 config->setGroup( "Account" );
358 config->writeEntry( "Type", typeList->currentText() ); 362 config->writeEntry( "Type", typeList->currentText() );
359 config->writeEntry( "Bank", bankEdit->text() ); 363 config->writeEntry( "Bank", bankEdit->text() );
360 config->writeEntry( "Number", acctNumEdit->text() ); 364 config->writeEntryCrypt( "Number", acctNumEdit->text() );
361 config->writeEntry( "PINNumber", pinNumEdit->text() ); 365 config->writeEntryCrypt( "PINNumber", pinNumEdit->text() );
362 config->writeEntry( "Balance", balanceEdit->text() ); 366 config->writeEntry( "Balance", balanceEdit->text() );
363 config->writeEntry( "Notes", notesEdit->text() ); 367 config->writeEntry( "Notes", notesEdit->text() );
364 368
365 // Save transactions 369 // Save transactions
366 TranInfo *tran = transactions.first(); 370 TranInfo *tran = transactions.first();
367 int i = 1; 371 int i = 1;
@@ -376,14 +380,19 @@ void Checkbook::accept()
376 QDialog::accept(); 380 QDialog::accept();
377} 381}
378 382
379void Checkbook::slotNameChanged( const QString &newname ) 383void Checkbook::slotNameChanged( const QString &newname )
380{ 384{
381 name = newname; 385 name = newname;
382 filename = filedir + newname + ".qcb"; 386 filename = filedir;
383 setCaption( name + " - " + tr( "Checkbook" ) ); 387 filename.append( newname );
388 filename.append( ".qcb" );
389 QString tempstr = name;
390 tempstr.append( " - " );
391 tempstr.append( tr( "Checkbook" ) );
392 setCaption( tempstr );
384} 393}
385 394
386void Checkbook::slotStartingBalanceChanged( const QString &newbalance ) 395void Checkbook::slotStartingBalanceChanged( const QString &newbalance )
387{ 396{
388 currBalance -= startBalance; 397 currBalance -= startBalance;
389 bool ok; 398 bool ok;
@@ -411,19 +420,14 @@ void Checkbook::slotNewTran()
411 stramount.sprintf( "%c%.2f", currencySymbol, amount ); 420 stramount.sprintf( "%c%.2f", currencySymbol, amount );
412 421
413 // Add to transaction list 422 // Add to transaction list
414 transactions.append( traninfo ); 423 transactions.append( traninfo );
415 424
416 // Add to transaction table 425 // Add to transaction table
417 426 ( void ) new QListViewItem( tranTable, QString::number( highTranNum ),
418 QDate date = traninfo->date(); 427 traninfo->datestr(), traninfo->desc(), stramount );
419 QString datestr = QString::number( date.month() ) + "/" +
420 QString::number( date.day() ) + "/" +
421 QString::number( date.year() );
422 ( void ) new QListViewItem( tranTable, QString::number( highTranNum ), datestr,
423 traninfo->desc(), stramount );
424 428
425 adjustBalance( amount ); 429 adjustBalance( amount );
426 } 430 }
427 else 431 else
428 { 432 {
429 highTranNum--; 433 highTranNum--;
@@ -451,17 +455,13 @@ void Checkbook::slotEditTran()
451 Transaction *currtran = new Transaction( this, name, 455 Transaction *currtran = new Transaction( this, name,
452 traninfo, 456 traninfo,
453 currencySymbol ); 457 currencySymbol );
454 currtran->showMaximized(); 458 currtran->showMaximized();
455 if ( currtran->exec() == QDialog::Accepted ) 459 if ( currtran->exec() == QDialog::Accepted )
456 { 460 {
457 QDate date = traninfo->date(); 461 curritem->setText( 1, traninfo->datestr() );
458 QString datestr = QString::number( date.month() ) + "/" +
459 QString::number( date.day() ) + "/" +
460 QString::number( date.year() );
461 curritem->setText( 1, datestr );
462 462
463 curritem->setText( 2, traninfo->desc() ); 463 curritem->setText( 2, traninfo->desc() );
464 464
465 float amount = traninfo->amount(); 465 float amount = traninfo->amount();
466 if ( traninfo->withdrawal() ) 466 if ( traninfo->withdrawal() )
467 { 467 {
@@ -486,13 +486,12 @@ void Checkbook::slotDeleteTran()
486 { 486 {
487 return; 487 return;
488 } 488 }
489 489
490 bool ok; 490 bool ok;
491 int tranid = curritem->text( 0 ).toInt( &ok ); 491 int tranid = curritem->text( 0 ).toInt( &ok );
492 //TranInfo *traninfo = transactions.at( tranid - 1 );
493 TranInfo *traninfo = findTranByID( tranid ); 492 TranInfo *traninfo = findTranByID( tranid );
494 493
495 if ( QPEMessageBox::confirmDelete ( this, tr( "Delete transaction" ), traninfo->desc() ) ) 494 if ( QPEMessageBox::confirmDelete ( this, tr( "Delete transaction" ), traninfo->desc() ) )
496 { 495 {
497 float amount = traninfo->amount(); 496 float amount = traninfo->amount();
498 if ( traninfo->withdrawal() ) 497 if ( traninfo->withdrawal() )