Diffstat (limited to 'noncore/apps/checkbook/checkbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/checkbook/checkbook.cpp | 59 |
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 @@ -23,16 +23,18 @@ -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "checkbook.h" #include "transaction.h" +#include "graph.h" +#include "graphinfo.h" #include <opie/otabwidget.h> #include <qpe/config.h> #include <qpe/qpeapplication.h> #include <qpe/qpemessagebox.h> #include <qpe/resource.h> #include <qcombobox.h> @@ -45,24 +47,29 @@ #include <qpushbutton.h> #include <qwhatsthis.h> #include <qwidget.h> Checkbook::Checkbook( QWidget *parent, const QString &n, const QString &fd, char symbol ) : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) { name = n; - filename = fd + name + ".qcb"; + filename = fd; + filename.append( name ); + filename.append( ".qcb" ); filedir = fd; currencySymbol = symbol; currBalance = 0.0; if ( name != "" ) { - setCaption( name + " - " + tr( "Checkbook" ) ); + QString tempstr = name; + tempstr.append( " - " ); + tempstr.append( tr( "Checkbook" ) ); + setCaption( tempstr ); } else { setCaption( tr( "New checkbook" ) ); } // Setup layout to make everything pretty QVBoxLayout *layout = new QVBoxLayout( this ); @@ -237,23 +244,24 @@ QWidget *Checkbook::initCharts() layout->addWidget( label, 0, 0 ); graphList = new QComboBox( control ); graphList->insertItem( tr( "By category" ) ); graphList->insertItem( tr( "..." ) ); graphList->insertItem( tr( "..." ) ); layout->addWidget( graphList, 0, 1 ); */ - QWidget *graphWidget = new QWidget( control ); - QWhatsThis::add( graphWidget, tr( "Graph not implemented yet." ) ); + GraphInfo* info = new GraphInfo( GraphInfo::BarChart, 0x0, tr( "Graph Title" ), + tr( "X-Axis" ), tr( "Y-Axis" ) ); + graphWidget = new Graph( control, info ); + QWhatsThis::add( graphWidget, tr( "Charting is not implemented yet." ) ); layout->addMultiCellWidget( graphWidget, 0, 0, 0, 1 ); - graphWidget->setBackgroundMode( QWidget::PaletteBase ); QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/drawbtn" ), tr( "Draw" ), control ); - QWhatsThis::add( btn, tr( "Click here to draw the graph." ) ); + QWhatsThis::add( btn, tr( "Click here to draw the chart." ) ); connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) ); layout->addWidget( btn, 1, 1 ); return control; } void Checkbook::loadCheckbook() { @@ -271,18 +279,18 @@ void Checkbook::loadCheckbook() i--; typeList->setCurrentItem( i ); if ( typeList->currentText() == temptext ) { break; } } bankEdit->setText( config.readEntry( "Bank", "" ) ); - acctNumEdit->setText( config.readEntry( "Number", "" ) ); - pinNumEdit->setText( config.readEntry( "PINNumber", "" ) ); + acctNumEdit->setText( config.readEntryCrypt( "Number", "" ) ); + pinNumEdit->setText( config.readEntryCrypt( "PINNumber", "" ) ); balanceEdit->setText( config.readEntry( "Balance", "0.0" ) ); notesEdit->setText( config.readEntry( "Notes", "" ) ); bool ok; currBalance = balanceEdit->text().toFloat( &ok ); startBalance = currBalance; // Load transactions @@ -304,21 +312,17 @@ void Checkbook::loadCheckbook() } currBalance += amount; stramount.sprintf( "%c%.2f", currencySymbol, amount ); // Add to transaction list transactions.append( tran ); // Add to transaction table - QDate date = tran->date(); - QString datestr = QString::number( date.month() ) + "/" + - QString::number( date.day() ) + "/" + - QString::number( date.year() ); - ( void ) new QListViewItem( tranTable, QString::number( i ), datestr, + ( void ) new QListViewItem( tranTable, QString::number( i ), tran->datestr(), trandesc, stramount ); } else { delete tran; } } balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) ); @@ -352,18 +356,18 @@ void Checkbook::accept() } Config *config = new Config(filename, Config::File); // Save info config->setGroup( "Account" ); config->writeEntry( "Type", typeList->currentText() ); config->writeEntry( "Bank", bankEdit->text() ); - config->writeEntry( "Number", acctNumEdit->text() ); - config->writeEntry( "PINNumber", pinNumEdit->text() ); + config->writeEntryCrypt( "Number", acctNumEdit->text() ); + config->writeEntryCrypt( "PINNumber", pinNumEdit->text() ); config->writeEntry( "Balance", balanceEdit->text() ); config->writeEntry( "Notes", notesEdit->text() ); // Save transactions TranInfo *tran = transactions.first(); int i = 1; while ( tran ) { @@ -374,18 +378,23 @@ void Checkbook::accept() config->write(); QDialog::accept(); } void Checkbook::slotNameChanged( const QString &newname ) { name = newname; - filename = filedir + newname + ".qcb"; - setCaption( name + " - " + tr( "Checkbook" ) ); + filename = filedir; + filename.append( newname ); + filename.append( ".qcb" ); + QString tempstr = name; + tempstr.append( " - " ); + tempstr.append( tr( "Checkbook" ) ); + setCaption( tempstr ); } void Checkbook::slotStartingBalanceChanged( const QString &newbalance ) { currBalance -= startBalance; bool ok; startBalance = newbalance.toFloat( &ok ); adjustBalance( startBalance ); @@ -409,23 +418,18 @@ void Checkbook::slotNewTran() } QString stramount; stramount.sprintf( "%c%.2f", currencySymbol, amount ); // Add to transaction list transactions.append( traninfo ); // Add to transaction table - - QDate date = traninfo->date(); - QString datestr = QString::number( date.month() ) + "/" + - QString::number( date.day() ) + "/" + - QString::number( date.year() ); - ( void ) new QListViewItem( tranTable, QString::number( highTranNum ), datestr, - traninfo->desc(), stramount ); + ( void ) new QListViewItem( tranTable, QString::number( highTranNum ), + traninfo->datestr(), traninfo->desc(), stramount ); adjustBalance( amount ); } else { highTranNum--; delete traninfo; } @@ -449,21 +453,17 @@ void Checkbook::slotEditTran() } Transaction *currtran = new Transaction( this, name, traninfo, currencySymbol ); currtran->showMaximized(); if ( currtran->exec() == QDialog::Accepted ) { - QDate date = traninfo->date(); - QString datestr = QString::number( date.month() ) + "/" + - QString::number( date.day() ) + "/" + - QString::number( date.year() ); - curritem->setText( 1, datestr ); + curritem->setText( 1, traninfo->datestr() ); curritem->setText( 2, traninfo->desc() ); float amount = traninfo->amount(); if ( traninfo->withdrawal() ) { amount *= -1; } @@ -484,17 +484,16 @@ void Checkbook::slotDeleteTran() QListViewItem *curritem = tranTable->currentItem(); if ( !curritem ) { return; } bool ok; int tranid = curritem->text( 0 ).toInt( &ok ); - //TranInfo *traninfo = transactions.at( tranid - 1 ); TranInfo *traninfo = findTranByID( tranid ); if ( QPEMessageBox::confirmDelete ( this, tr( "Delete transaction" ), traninfo->desc() ) ) { float amount = traninfo->amount(); if ( traninfo->withdrawal() ) { amount *= -1; |