-rw-r--r-- | noncore/apps/checkbook/checkbook.cpp | 59 | ||||
-rw-r--r-- | noncore/apps/checkbook/checkbook.h | 5 | ||||
-rw-r--r-- | noncore/apps/checkbook/checkbook.pro | 42 | ||||
-rw-r--r-- | noncore/apps/checkbook/graph.cpp | 112 | ||||
-rw-r--r-- | noncore/apps/checkbook/graph.h | 63 | ||||
-rw-r--r-- | noncore/apps/checkbook/graphinfo.cpp | 84 | ||||
-rw-r--r-- | noncore/apps/checkbook/graphinfo.h | 82 | ||||
-rw-r--r-- | noncore/apps/checkbook/mainwindow.cpp | 11 | ||||
-rw-r--r-- | noncore/apps/checkbook/traninfo.cpp | 25 | ||||
-rw-r--r-- | noncore/apps/checkbook/traninfo.h | 1 | ||||
-rw-r--r-- | noncore/apps/checkbook/transaction.cpp | 4 |
11 files changed, 430 insertions, 58 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 @@ -1,513 +1,512 @@ /* This file is part of the OPIE Project =. .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This file is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General ..}^=.= = ; Public License for more details. ++= -. .` .: : = ...= . :.=- You should have received a copy of the GNU -. .:....=;==+<; General Public License along with this file; -_. . . )=. = see the file COPYING. If not, write to the -- :-=` 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> #include <qfile.h> #include <qlabel.h> #include <qlayout.h> #include <qlineedit.h> #include <qlistview.h> #include <qmultilineedit.h> #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 ); layout->setMargin( 2 ); layout->setSpacing( 4 ); // Setup tabs for all info mainWidget = new OTabWidget( this ); layout->addWidget( mainWidget ); mainWidget->addTab( initInfo(), "checkbook/infotab", tr( "Info" ) ); mainWidget->addTab( initTransactions(), "checkbook/trantab", tr( "Transactions" ) ); mainWidget->addTab( initCharts(), "checkbook/charttab", tr( "Charts" ) ); mainWidget->setCurrentTab( tr( "Info" ) ); // Load checkbook information loadCheckbook(); } Checkbook::~Checkbook() { } const QString &Checkbook::getName() { return( name ); } QWidget *Checkbook::initInfo() { QWidget *control = new QWidget( mainWidget ); QVBoxLayout *vb = new QVBoxLayout( control ); QScrollView *sv = new QScrollView( control ); vb->addWidget( sv, 0, 0 ); sv->setResizePolicy( QScrollView::AutoOneFit ); sv->setFrameStyle( QFrame::NoFrame ); QWidget *container = new QWidget( sv->viewport() ); sv->addChild( container ); QGridLayout *layout = new QGridLayout( container ); layout->setSpacing( 2 ); layout->setMargin( 4 ); // Account name QLabel *label = new QLabel( tr( "Name:" ), container ); QWhatsThis::add( label, tr( "Enter name of checkbook here." ) ); layout->addWidget( label, 0, 0 ); nameEdit = new QLineEdit( container ); QWhatsThis::add( nameEdit, tr( "Enter name of checkbook here." ) ); connect( nameEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( slotNameChanged( const QString & ) ) ); layout->addWidget( nameEdit, 0, 1 ); // Type of account label = new QLabel( tr( "Type:" ), container ); QWhatsThis::add( label, tr( "Select type of checkbook here." ) ); layout->addWidget( label, 1, 0 ); typeList = new QComboBox( container ); QWhatsThis::add( typeList, tr( "Select type of checkbook here." ) ); typeList->insertItem( tr( "Savings" ) ); // 0 typeList->insertItem( tr( "Checking" ) ); // 1 typeList->insertItem( tr( "CD" ) ); // 2 typeList->insertItem( tr( "Money market" ) ); // 3 typeList->insertItem( tr( "Mutual fund" ) ); // 4 typeList->insertItem( tr( "Other" ) ); // 5 layout->addWidget( typeList, 1, 1 ); // Bank/institution name label = new QLabel( tr( "Bank:" ), container ); QWhatsThis::add( label, tr( "Enter name of the bank for this checkbook here." ) ); layout->addWidget( label, 2, 0 ); bankEdit = new QLineEdit( container ); QWhatsThis::add( bankEdit, tr( "Enter name of the bank for this checkbook here." ) ); layout->addWidget( bankEdit, 2, 1 ); // Account number label = new QLabel( tr( "Account number:" ), container ); QWhatsThis::add( label, tr( "Enter account number for this checkbook here." ) ); layout->addWidget( label, 3, 0 ); acctNumEdit = new QLineEdit( container ); QWhatsThis::add( acctNumEdit, tr( "Enter account number for this checkbook here." ) ); layout->addWidget( acctNumEdit, 3, 1 ); // PIN number label = new QLabel( tr( "PIN number:" ), container ); QWhatsThis::add( label, tr( "Enter PIN number for this checkbook here." ) ); layout->addWidget( label, 4, 0 ); pinNumEdit = new QLineEdit( container ); QWhatsThis::add( pinNumEdit, tr( "Enter PIN number for this checkbook here." ) ); layout->addWidget( pinNumEdit, 4, 1 ); // Starting balance label = new QLabel( tr( "Starting balance:" ), container ); QWhatsThis::add( label, tr( "Enter the initial balance for this checkbook here." ) ); layout->addWidget( label, 5, 0 ); balanceEdit = new QLineEdit( container ); QWhatsThis::add( balanceEdit, tr( "Enter the initial balance for this checkbook here." ) ); connect( balanceEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( slotStartingBalanceChanged( const QString & ) ) ); layout->addWidget( balanceEdit, 5, 1 ); // Notes label = new QLabel( tr( "Notes:" ), container ); QWhatsThis::add( label, tr( "Enter any additional information for this checkbook here." ) ); layout->addWidget( label, 6, 0 ); notesEdit = new QMultiLineEdit( container ); QWhatsThis::add( notesEdit, tr( "Enter any additional information for this checkbook here." ) ); notesEdit->setMaximumHeight( 85 ); layout->addMultiCellWidget( notesEdit, 7, 7, 0, 1 ); return control; } QWidget *Checkbook::initTransactions() { QWidget *control = new QWidget( mainWidget ); QGridLayout *layout = new QGridLayout( control ); layout->setSpacing( 2 ); layout->setMargin( 4 ); balanceLabel = new QLabel( tr( "Current balance: %10.00" ).arg( currencySymbol ), control ); QWhatsThis::add( balanceLabel, tr( "This area shows the current balance in this checkbook." ) ); layout->addMultiCellWidget( balanceLabel, 0, 0, 0, 2 ); tranTable = new QListView( control ); QWhatsThis::add( tranTable, tr( "This is a listing of all transactions entered for this checkbook.\n\nTo sort entries by a specific field, click on the column name." ) ); tranTable->addColumn( tr( "ID" ) ); tranTable->addColumn( tr( "Date" ) ); tranTable->addColumn( tr( "Description" ) ); int colnum = tranTable->addColumn( tr( "Amount" ) ); tranTable->setColumnAlignment( colnum, Qt::AlignRight ); tranTable->setAllColumnsShowFocus( TRUE ); layout->addMultiCellWidget( tranTable, 1, 1, 0, 2 ); QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold ); connect( tranTable, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), this, SLOT( slotEditTran() ) ); QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), control ); QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) ); connect( btn, SIGNAL( clicked() ), this, SLOT( slotNewTran() ) ); layout->addWidget( btn, 2, 0 ); btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), control ); QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) ); connect( btn, SIGNAL( clicked() ), this, SLOT( slotEditTran() ) ); layout->addWidget( btn, 2, 1 ); btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), control ); QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) ); connect( btn, SIGNAL( clicked() ), this, SLOT( slotDeleteTran() ) ); layout->addWidget( btn, 2, 2 ); return( control ); } QWidget *Checkbook::initCharts() { QWidget *control = new QWidget( mainWidget ); QGridLayout *layout = new QGridLayout( control ); layout->setSpacing( 2 ); layout->setMargin( 4 ); /* QLabel *label = new QLabel( control ); label->setText( tr( "Graph type:" ) ); 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() { transactions.clear(); Config config(filename, Config::File); // Load info config.setGroup( "Account" ); nameEdit->setText( name ); QString temptext = config.readEntry( "Type" ); int i = typeList->count(); while ( i > 0 ) { 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 TranInfo *tran; QString trandesc = ""; float amount; QString stramount; for ( int i = 1; trandesc != QString::null; i++ ) { tran = new TranInfo( config, i ); trandesc = tran->desc(); if ( trandesc != QString::null ) { currBalance -= tran->fee(); amount = tran->amount(); if ( tran->withdrawal() ) { amount *= -1; } 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 ) ); highTranNum = transactions.count(); } void Checkbook::adjustBalance( float amount ) { currBalance += amount; balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) ); } TranInfo *Checkbook::findTranByID( int id ) { TranInfo *traninfo = transactions.first(); while ( traninfo && traninfo->id() != id ) { traninfo = transactions.next(); } return( traninfo ); } void Checkbook::accept() { QFile f( filename ); if ( f.exists() ) { f.remove(); } 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 ) { tran->write( config, i ); tran = transactions.next(); i++; } 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 ); } void Checkbook::slotNewTran() { highTranNum++; TranInfo *traninfo = new TranInfo( highTranNum ); Transaction *currtran = new Transaction( this, name, traninfo, currencySymbol ); currtran->showMaximized(); if ( currtran->exec() == QDialog::Accepted ) { float amount = traninfo->amount(); if ( traninfo->withdrawal() ) { amount *= -1; } 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; } } void Checkbook::slotEditTran() { bool ok; QListViewItem *curritem = tranTable->currentItem(); if ( !curritem ) { return; } int tranid = curritem->text( 0 ).toInt( &ok ); TranInfo *traninfo = findTranByID( tranid ); float origamt = traninfo->amount(); if ( traninfo->withdrawal() ) { origamt *= -1; } 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; } adjustBalance( origamt * -1 ); adjustBalance( amount ); QString stramount; stramount.sprintf( "%c%.2f", currencySymbol, amount ); curritem->setText( 3, stramount ); balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) ); delete currtran; } } 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; } transactions.remove( traninfo ); delete traninfo; delete curritem; adjustBalance( amount * -1 ); } } void Checkbook::slotDrawGraph() { } diff --git a/noncore/apps/checkbook/checkbook.h b/noncore/apps/checkbook/checkbook.h index a86c0f9..01f1115 100644 --- a/noncore/apps/checkbook/checkbook.h +++ b/noncore/apps/checkbook/checkbook.h @@ -1,102 +1,103 @@ /* This file is part of the OPIE Project =. .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This file is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General ..}^=.= = ; Public License for more details. ++= -. .` .: : = ...= . :.=- You should have received a copy of the GNU -. .:....=;==+<; General Public License along with this file; -_. . . )=. = see the file COPYING. If not, write to the -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef CHECKBOOK_H #define CHECKBOOK_H #include "traninfo.h" #include <qdialog.h> class OTabWidget; +class Graph; class QComboBox; class QLabel; class QLineEdit; class QListView; class QMultiLineEdit; class QString; class Checkbook : public QDialog { Q_OBJECT public: Checkbook( QWidget * = 0x0, const QString & = 0x0, const QString & = 0x0, char = '$' ); ~Checkbook(); const QString &getName(); private: TranInfoList transactions; QString name; QString filename; QString filedir; char currencySymbol; int highTranNum; OTabWidget *mainWidget; void loadCheckbook(); void adjustBalance( float ); TranInfo *findTranByID( int ); // Info tab QWidget *initInfo(); QLineEdit *nameEdit; QComboBox *typeList; QLineEdit *bankEdit; QLineEdit *acctNumEdit; QLineEdit *pinNumEdit; QLineEdit *balanceEdit; QMultiLineEdit *notesEdit; float startBalance; // Transactions tab QWidget *initTransactions(); QListView *tranTable; QLabel *balanceLabel; float currBalance; // Charts tab - QWidget *initCharts(); + QWidget *initCharts(); //QComboBox *graphList; - QWidget *graphWidget; + Graph *graphWidget; protected slots: void accept(); private slots: void slotNameChanged( const QString & ); void slotStartingBalanceChanged( const QString & ); void slotNewTran(); void slotEditTran(); void slotDeleteTran(); void slotDrawGraph(); }; #endif diff --git a/noncore/apps/checkbook/checkbook.pro b/noncore/apps/checkbook/checkbook.pro index 07cc012..bd69939 100644 --- a/noncore/apps/checkbook/checkbook.pro +++ b/noncore/apps/checkbook/checkbook.pro @@ -1,32 +1,36 @@ TEMPLATE = app CONFIG = qt warn_on release HEADERS = mainwindow.h \ - traninfo.h \ - checkbook.h \ - transaction.h -SOURCES = main.cpp \ - mainwindow.cpp \ - traninfo.cpp \ - checkbook.cpp \ - transaction.cpp + traninfo.h \ + graphinfo.h \ + checkbook.h \ + transaction.h \ + graph.h +SOURCES = main.cpp \ + mainwindow.cpp \ + traninfo.cpp \ + graphinfo.cpp \ + checkbook.cpp \ + transaction.cpp \ + graph.cpp INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lopie TARGET = checkbook DESTDIR = $(OPIEDIR)/bin TRANSLATIONS = ../../../i18n/de/checkbook.ts \ - ../../../i18n/en/checkbook.ts \ - ../../../i18n/es/checkbook.ts \ - ../../../i18n/fr/checkbook.ts \ - ../../../i18n/hu/checkbook.ts \ - ../../../i18n/ja/checkbook.ts \ - ../../../i18n/ko/checkbook.ts \ - ../../../i18n/no/checkbook.ts \ - ../../../i18n/pl/checkbook.ts \ - ../../../i18n/pt/checkbook.ts \ + ../../../i18n/en/checkbook.ts \ + ../../../i18n/es/checkbook.ts \ + ../../../i18n/fr/checkbook.ts \ + ../../../i18n/hu/checkbook.ts \ + ../../../i18n/ja/checkbook.ts \ + ../../../i18n/ko/checkbook.ts \ + ../../../i18n/no/checkbook.ts \ + ../../../i18n/pl/checkbook.ts \ + ../../../i18n/pt/checkbook.ts \ ../../../i18n/pt_BR/checkbook.ts \ - ../../../i18n/sl/checkbook.ts \ + ../../../i18n/sl/checkbook.ts \ ../../../i18n/zh_CN/checkbook.ts \ ../../../i18n/zh_TW/checkbook.ts \ - ../../../i18n/it/checkbook.ts + ../../../i18n/it/checkbook.ts diff --git a/noncore/apps/checkbook/graph.cpp b/noncore/apps/checkbook/graph.cpp new file mode 100644 index 0000000..bae92da --- a/dev/null +++ b/noncore/apps/checkbook/graph.cpp @@ -0,0 +1,112 @@ +/* + This file is part of the OPIE Project + =. + .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ + +#include "graph.h" +#include "graphinfo.h" + +#include <qpainter.h> + +Graph::Graph( QWidget *parent, GraphInfo *d, const QString &name, int flags ) + : QWidget( parent, name, flags ) +{ + setBackgroundMode( QWidget::PaletteBase ); + + data = d; + + graph.setOptimization( QPixmap::BestOptim ); +} + +void Graph::setGraphInfo( GraphInfo *d ) +{ + data = d; +} + +void Graph::drawGraph( bool regen ) +{ + if ( regen ) + { + initGraph(); + } + QPainter p( this ); + p.drawPixmap( 0, 0, graph ); +} + +void Graph::paintEvent( QPaintEvent * ) +{ + drawGraph( FALSE ); +} + +void Graph::resizeEvent( QResizeEvent * ) +{ + drawGraph( TRUE ); +} + +void Graph::initGraph() +{ + graph.resize( width(), height() ); + graph.fill( QColor( 255, 255, 255 ) ); + + if ( !data ) + { + return; + } + + // Any common stuff here (titles, ???) + + switch ( data->graphType() ) + { + case GraphInfo::BarChart : + { + drawBarChart(); + } + break; + case GraphInfo::LineChart : + { + drawLineChart(); + } + break; + case GraphInfo::PieChart : + { + drawPieChart(); + } + }; +} + +void Graph::drawBarChart() +{ + //Find max value in GraphInfo->dataPoints() - make function in GraphInfo!!! +} + +void Graph::drawLineChart() +{ +} + +void Graph::drawPieChart() +{ +} + diff --git a/noncore/apps/checkbook/graph.h b/noncore/apps/checkbook/graph.h new file mode 100644 index 0000000..7379be7 --- a/dev/null +++ b/noncore/apps/checkbook/graph.h @@ -0,0 +1,63 @@ +/* + This file is part of the OPIE Project + =. + .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ + +#ifndef GRAPH_H +#define GRAPH_H + +#include <qpixmap.h> +#include <qwidget.h> + +class GraphInfo; + +class Graph : public QWidget +{ + Q_OBJECT + + public: + Graph( QWidget * = 0x0, GraphInfo * = 0x0, const QString & = 0x0, int = 0 ); + + void setGraphInfo( GraphInfo * ); + + void drawGraph( bool = FALSE ); + + protected: + void paintEvent( QPaintEvent * ); + void resizeEvent( QResizeEvent * ); + + private: + GraphInfo *data; + + QPixmap graph; + + void initGraph(); + void drawBarChart(); + void drawLineChart(); + void drawPieChart(); +}; + +#endif diff --git a/noncore/apps/checkbook/graphinfo.cpp b/noncore/apps/checkbook/graphinfo.cpp new file mode 100644 index 0000000..7b06bdb --- a/dev/null +++ b/noncore/apps/checkbook/graphinfo.cpp @@ -0,0 +1,84 @@ +/* + This file is part of the OPIE Project + =. + .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ + +#include "graphinfo.h" + +GraphInfo::GraphInfo( GraphType type, DataPointList *data, const QString &title, + const QString &xtitle, const QString &ytitle ) +{ + t = type; + d = data; + gt = title; + xt = xtitle; + yt = ytitle; +} + +GraphInfo::GraphType GraphInfo::graphType() +{ + return t; +} + +void GraphInfo::setGraphType( GraphType type ) +{ + t = type; +} + +DataPointList *GraphInfo::dataPoints() +{ + return d; +} + +void GraphInfo::setDataPoints( DataPointList *data ) +{ + d = data; +} + +float GraphInfo::maxValue() +{ + float max; + +} + +float GraphInfo::minValue() +{ +} + +void GraphInfo::setGraphTitle( const QString &title ) +{ + gt = title; +} + +void GraphInfo::setXAxisTitle( const QString &xtitle ) +{ + xt = xtitle; +} + +void GraphInfo::setYAxisTitle( const QString &ytitle ) +{ + yt = ytitle; +} diff --git a/noncore/apps/checkbook/graphinfo.h b/noncore/apps/checkbook/graphinfo.h new file mode 100644 index 0000000..4ad1dc9 --- a/dev/null +++ b/noncore/apps/checkbook/graphinfo.h @@ -0,0 +1,82 @@ +/* + This file is part of the OPIE Project + =. + .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ + +#ifndef GRAPHINFO_H +#define GRAPHINFO_H + +#include <qlist.h> +#include <qstringlist.h> + +class DataPointInfo +{ + public: + DataPointInfo() + : l( 0x0 ), v( 0.0 ) {} + DataPointInfo( const QString &label, float value ) + : l( label ), v( value ) {} + + const QString &label() { return l; } + float value() { return v; } + + private: + QString l; + float v; +}; + +typedef QList<DataPointInfo> DataPointList; + +class GraphInfo +{ + public: + enum GraphType { BarChart, LineChart, PieChart }; + + GraphInfo( GraphType = BarChart, DataPointList * = 0x0, + const QString & = 0x0, const QString & = 0x0, const QString & = 0x0 ); + + GraphInfo::GraphType graphType(); + void setGraphType( GraphType ); + + DataPointList *dataPoints(); + void setDataPoints( DataPointList * ); + + float maxValue(); + float minValue(); + + void setGraphTitle( const QString & ); + void setXAxisTitle( const QString & ); + void setYAxisTitle( const QString & ); + + private: + GraphType t; + DataPointList *d; + QString gt; + QString xt; + QString yt; +}; + +#endif diff --git a/noncore/apps/checkbook/mainwindow.cpp b/noncore/apps/checkbook/mainwindow.cpp index ead17b4..2eb8396 100644 --- a/noncore/apps/checkbook/mainwindow.cpp +++ b/noncore/apps/checkbook/mainwindow.cpp @@ -1,163 +1,168 @@ /* This file is part of the OPIE Project =. .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This file is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General ..}^=.= = ; Public License for more details. ++= -. .` .: : = ...= . :.=- You should have received a copy of the GNU -. .:....=;==+<; General Public License along with this file; -_. . . )=. = see the file COPYING. If not, write to the -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "mainwindow.h" #include "checkbook.h" #include <qpe/global.h> #include <qpe/qpeapplication.h> #include <qpe/qpemenubar.h> #include <qpe/qpemessagebox.h> #include <qpe/qpetoolbar.h> #include <qpe/resource.h> #include <qaction.h> #include <qdir.h> #include <qlistbox.h> #include <qpopupmenu.h> #include <qstring.h> #include <qwhatsthis.h> MainWindow::MainWindow() : QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) { setCaption( tr( "Checkbook" ) ); cbDir = Global::applicationFileName( "checkbook", "" ); // Build menu and tool bars setToolBarsMovable( FALSE ); QPEToolBar *bar = new QPEToolBar( this ); bar->setHorizontalStretchable( TRUE ); QPEMenuBar *mb = new QPEMenuBar( bar ); mb->setMargin( 0 ); QPopupMenu *popup = new QPopupMenu( this ); bar = new QPEToolBar( this ); QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); a->setWhatsThis( tr( "Click here to create a new checkbook.\n\nYou also can select New from the Checkbook menu." ) ); connect( a, SIGNAL( activated() ), this, SLOT( slotNew() ) ); a->addTo( popup ); a->addTo( bar ); actionOpen = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, 0, this, 0 ); 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." ) ); connect( actionOpen, SIGNAL( activated() ), this, SLOT( slotEdit() ) ); actionOpen->addTo( popup ); actionOpen->addTo( bar ); actionDelete = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); actionDelete->setWhatsThis( tr( "Select a checkbook and then click here delete it.\n\nYou also can select Delete from the Checkbook menu." ) ); connect( actionDelete, SIGNAL( activated() ), this, SLOT( slotDelete() ) ); actionDelete->addTo( popup ); actionDelete->addTo( bar ); mb->insertItem( tr( "Checkbook" ), popup ); // Build Checkbook selection list control cbList = new QListBox( this ); QWhatsThis::add( cbList, tr( "This is a listing of all checkbooks currently available." ) ); QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold ); connect( cbList, SIGNAL( rightButtonPressed( QListBoxItem *, const QPoint & ) ), this, SLOT( slotEdit() ) ); setCentralWidget( cbList ); // Load Checkbook selection list QDir checkdir( cbDir ); if (checkdir.exists() == true) { QStringList checkbooks = checkdir.entryList( "*.qcb", QDir::Files|QDir::Readable|QDir::Writable, QDir::Time ); for ( QStringList::Iterator it = checkbooks.begin(); it != checkbooks.end(); it++ ) { (*it) = (*it).remove( (*it).find('.'), (*it).length() ); } cbList->insertStringList( checkbooks ); } cbList->sort(); cbList->setSelected( 0, TRUE ); currencySymbol = '$'; } MainWindow::~MainWindow() { } void MainWindow::slotNew() { Checkbook *currcb = new Checkbook( this, "", cbDir, currencySymbol ); currcb->showMaximized(); if ( currcb->exec() == QDialog::Accepted ) { cbList->insertItem( currcb->getName() ); cbList->sort(); delete currcb; } } void MainWindow::slotEdit() { QString currname = cbList->currentText(); Checkbook *currcb = new Checkbook( this, currname, cbDir, currencySymbol ); currcb->showMaximized(); if ( currcb->exec() == QDialog::Accepted ) { QString newname = currcb->getName(); if ( currname != newname ) { cbList->changeItem( newname, cbList->currentItem() ); cbList->sort(); - QFile f( cbDir + currname + ".qcb" ); + QString tempstr = cbDir; + tempstr.append( currname ); + tempstr.append( ".qcb" ); + QFile f( tempstr ); if ( f.exists() ) { f.remove(); } } delete currcb; } } void MainWindow::slotDelete() { if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), cbList->currentText() ) ) { - QString name = cbDir + cbList->currentText() + ".qcb"; - QFile f( name ); + QString tempstr = cbDir; + tempstr.append( cbList->currentText() ); + tempstr.append( ".qcb" ); + QFile f( tempstr ); if ( f.exists() ) { f.remove(); } cbList->removeItem( cbList->currentItem() ); } } diff --git a/noncore/apps/checkbook/traninfo.cpp b/noncore/apps/checkbook/traninfo.cpp index 5a770b0..460466c 100644 --- a/noncore/apps/checkbook/traninfo.cpp +++ b/noncore/apps/checkbook/traninfo.cpp @@ -1,156 +1,175 @@ /* This file is part of the OPIE Project =. .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This file is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General ..}^=.= = ; Public License for more details. ++= -. .` .: : = ...= . :.=- You should have received a copy of the GNU -. .:....=;==+<; General Public License along with this file; -_. . . )=. = see the file COPYING. If not, write to the -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "traninfo.h" #include <qpe/config.h> +QString tempstr; + TranInfo::TranInfo( int id, const QString &desc, const QDate &date, bool withdrawal, const QString &type, const QString &category, float amount, float fee, const QString &number, const QString ¬es ) { i = id; d = desc; td = date; w = withdrawal; t = type; c = category; a = amount; f = fee; cn = number; n = notes; } TranInfo::TranInfo( Config config, int entry ) { config.setGroup( QString::number( entry ) ); QString desc = config.readEntry( "Description", "Not Found" ); if ( desc != "Not Found" ) { // ID i = entry; // Description d = desc; // Transaction date int yr, mn, dy; QString datestr = config.readEntry( "Date", "" ); int begin, end; begin = datestr.find( '/' ); mn = datestr.left( begin ).toInt(); end = datestr.find( '/', ++begin ); dy = datestr.mid( begin, end - begin ).toInt(); yr = datestr.right( datestr.length() - end - 1).toInt(); td.setYMD( yr, mn, dy ); // Deposit/withdrawal indicator ( withdrawal == TRUE ) w = ( config.readEntry( "Payment", "false" ) == "true" ); // Type QString type = config.readEntry( "Type", "0" ); if ( w ) { // Withdrawal types if( type == "0" ) t = "Debit Charge"; else if( type == "1" ) t = "Written Check"; else if( type == "2" ) t = "Transfer"; else if( type == "3" ) t = "Credit Card"; } else { if( type == "0" ) t = "Written Check"; else if( type == "1" ) t = "Automatic Payment"; else if( type == "2" ) t = "Transfer"; else if( type == "3" ) t = "Cash"; } // Category c = config.readEntry( "Category", "" ); // Transaction amount QString stramount = config.readEntry( "Amount", "0.00" ); bool ok; a = stramount.toFloat( &ok ); // Transaction fee stramount = config.readEntry( "TransactionFee", "0.00" ); f = stramount.toFloat( &ok ); // Transaction number cn = config.readEntry( "CheckNumber", "" ); // Notes n = config.readEntry( "Comments", "" ); } } +const QString &TranInfo::datestr() +{ + tempstr = QString::number( td.year() ); + tempstr.append( '/' ); + int tempfield = td.month(); + if ( tempfield < 10 ) tempstr.append( '0' ); + tempstr.append( QString::number( tempfield ) ); + tempstr.append( '/' ); + tempfield = td.day(); + if ( tempfield < 10 ) tempstr.append( '0' ); + tempstr.append( QString::number( tempfield ) ); + + return( tempstr ); +} + void TranInfo::write( Config *config, int entry ) { config->setGroup( QString::number( entry ) ); config->writeEntry( "Description", d ); - QString tempstr = QString::number( td.month() ) + "/" + - QString::number( td.day() ) + "/" + - QString::number( td.year() ); + tempstr = QString::number( td.month() ); + tempstr.append( '/' ); + tempstr.append( QString::number( td.day() ) ); + tempstr.append( '/' ); + tempstr.append( QString::number( td.year() ) ); config->writeEntry( "Date", tempstr ); w ? tempstr = "true" : tempstr = "false"; config->writeEntry( "Payment", tempstr ); if ( t == "Debit Charge" || t == "Written Check" ) tempstr = "0"; else if ( t == "Written Check" || t == "Automatic Payment" ) tempstr = "1"; else if ( t == "Transfer" ) tempstr = "2"; else if ( t == "Credit Card" || t == "Cash" ) tempstr = "3"; config->writeEntry( "Type", tempstr ); config->writeEntry( "Category", c ); tempstr.setNum( a, 'f', 2 ); config->writeEntry( "Amount", tempstr ); tempstr.setNum( f, 'f', 2 ); config->writeEntry( "TransactionFee", tempstr ); config->writeEntry( "CheckNumber", cn ); config->writeEntry( "Comments", n ); } diff --git a/noncore/apps/checkbook/traninfo.h b/noncore/apps/checkbook/traninfo.h index 1743ff7..e944c29 100644 --- a/noncore/apps/checkbook/traninfo.h +++ b/noncore/apps/checkbook/traninfo.h @@ -1,85 +1,86 @@ /* This file is part of the OPIE Project =. .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This file is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General ..}^=.= = ; Public License for more details. ++= -. .` .: : = ...= . :.=- You should have received a copy of the GNU -. .:....=;==+<; General Public License along with this file; -_. . . )=. = see the file COPYING. If not, write to the -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef TRANINFO_H #define TRANINFO_H #include <qdatetime.h> #include <qlist.h> #include <qstring.h> class Config; class TranInfo { public: TranInfo( int = 0, const QString & = 0x0, const QDate & = QDate::currentDate(), bool = TRUE, const QString & = 0x0, const QString & = 0x0, float = 0.0, float = 0.0, const QString & = 0x0, const QString & = 0x0 ); TranInfo( Config, int ); int id() const { return i; } const QString &desc() const { return d; } const QDate &date() const { return td; } + const QString &datestr(); bool withdrawal() const { return w; } const QString &type() const { return t; } const QString &category() const { return c; } float amount() const { return a; } float fee() const { return f; } const QString &number() const { return cn; } const QString ¬es() const { return n; } void setDesc( const QString &desc ) { d = desc; } void setDate( const QDate &date ) { td = date; } void setWithdrawal( bool withdrawal ) { w = withdrawal; } void setType( const QString &type ) { t = type; } void setCategory( const QString &cat ) { c = cat; } void setAmount( float amount ) { a = amount; } void setFee( float fee ) { f = fee; } void setNumber( const QString &num ) { cn = num; } void setNotes( const QString ¬es ) { n = notes; } void write( Config *, int ); private: int i; QString d; QDate td; bool w; QString t; QString c; float a; float f; QString cn; QString n; }; typedef QList<TranInfo> TranInfoList; #endif diff --git a/noncore/apps/checkbook/transaction.cpp b/noncore/apps/checkbook/transaction.cpp index 82baec9..a921491 100644 --- a/noncore/apps/checkbook/transaction.cpp +++ b/noncore/apps/checkbook/transaction.cpp @@ -1,244 +1,246 @@ /* This file is part of the OPIE Project =. .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This file is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General ..}^=.= = ; Public License for more details. ++= -. .` .: : = ...= . :.=- You should have received a copy of the GNU -. .:....=;==+<; General Public License along with this file; -_. . . )=. = see the file COPYING. If not, write to the -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "transaction.h" #include "traninfo.h" #include <qpe/datebookmonth.h> #include <qpe/timestring.h> #include <qbuttongroup.h> #include <qcombobox.h> #include <qlabel.h> #include <qlayout.h> #include <qlineedit.h> #include <qmultilineedit.h> #include <qpopupmenu.h> #include <qpushbutton.h> #include <qradiobutton.h> #include <qscrollview.h> #include <qstring.h> #include <qwhatsthis.h> Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *info, char symbol ) : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) { - setCaption( tr( "Transaction for " ) + acctname ); + QString tempstr = tr( "Transaction for " ); + tempstr.append( acctname ); + setCaption( tempstr ); tran = info; currencySymbol = symbol; QVBoxLayout *vb = new QVBoxLayout( this ); QScrollView *sv = new QScrollView( this ); vb->addWidget( sv, 0, 0 ); sv->setResizePolicy( QScrollView::AutoOneFit ); sv->setFrameStyle( QFrame::NoFrame ); QWidget *container = new QWidget( sv->viewport() ); sv->addChild( container ); QGridLayout *layout = new QGridLayout( container ); layout->setSpacing( 2 ); layout->setMargin( 4 ); // Withdrawal/Deposit QButtonGroup *btngrp = new QButtonGroup( container ); btngrp->setColumnLayout(0, Qt::Vertical ); btngrp->layout()->setSpacing( 0 ); btngrp->layout()->setMargin( 0 ); btngrp->setMaximumWidth( 220 ); QGridLayout *layout2 = new QGridLayout( btngrp->layout() ); layout2->setSpacing( 2 ); layout2->setMargin( 2 ); withBtn = new QRadioButton( tr( "Withdrawal" ), btngrp ); QWhatsThis::add( withBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) ); layout2->addWidget( withBtn, 0, 0 ); connect( withBtn, SIGNAL( clicked() ), this, SLOT( slotWithdrawalClicked() ) ); depBtn = new QRadioButton( tr( "Deposit" ), btngrp ); QWhatsThis::add( depBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) ); layout2->addWidget( depBtn, 0, 1 ); btngrp->setMaximumSize( 320, withBtn->height() ); connect( depBtn, SIGNAL( clicked() ), this, SLOT( slotDepositClicked() ) ); layout->addMultiCellWidget( btngrp, 0, 0, 0, 3 ); // Date QLabel *label = new QLabel( tr( "Date:" ), container ); QWhatsThis::add( label, tr( "Select date of transaction here." ) ); layout->addWidget( label, 1, 0 ); dateBtn = new QPushButton( TimeString::shortDate( QDate::currentDate() ), container ); QWhatsThis::add( dateBtn, tr( "Select date of transaction here." ) ); QPopupMenu *m1 = new QPopupMenu( container ); datePicker = new DateBookMonth( m1, 0, TRUE ); m1->insertItem( datePicker ); dateBtn->setPopup( m1 ); connect( datePicker, SIGNAL( dateClicked( int, int, int ) ), this, SLOT( slotDateChanged( int, int, int ) ) ); layout->addWidget( dateBtn, 1, 1 ); // Check number label = new QLabel( tr( "Number:" ), container ); QWhatsThis::add( label, tr( "Enter check number here." ) ); layout->addWidget( label, 1, 2 ); numEdit = new QLineEdit( container ); QWhatsThis::add( numEdit, tr( "Enter check number here." ) ); numEdit->setMaximumWidth( 40 ); layout->addWidget( numEdit, 1, 3 ); // Description label = new QLabel( tr( "Description:" ), container ); QWhatsThis::add( label, tr( "Enter description of transaction here." ) ); layout->addWidget( label, 2, 0 ); descEdit = new QLineEdit( container ); QWhatsThis::add( descEdit, tr( "Enter description of transaction here." ) ); layout->addMultiCellWidget( descEdit, 2, 2, 1, 3 ); // Category label = new QLabel( tr( "Category:" ), container ); QWhatsThis::add( label, tr( "Select transaction category here." ) ); layout->addWidget( label, 3, 0 ); catList = new QComboBox( container ); QWhatsThis::add( catList, tr( "Select transaction category here." ) ); layout->addMultiCellWidget( catList, 3, 3, 1, 3 ); // Type label = new QLabel( tr( "Type:" ), container ); QWhatsThis::add( label, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) ); layout->addWidget( label, 4, 0 ); typeList = new QComboBox( container ); QWhatsThis::add( typeList, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) ); layout->addMultiCellWidget( typeList, 4, 4, 1, 3 ); // Amount label = new QLabel( tr( "Amount:" ), container ); QWhatsThis::add( label, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) ); layout->addWidget( label, 5, 0 ); amtEdit = new QLineEdit( container ); QWhatsThis::add( amtEdit, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) ); layout->addMultiCellWidget( amtEdit, 5, 5, 1, 3 ); // Fee label = new QLabel( tr( "Fee:" ), container ); QWhatsThis::add( label, tr( "Enter any fee amount assoiciated with this transaction.\n\nThe value entered should always be positive." ) ); layout->addWidget( label, 6, 0 ); feeEdit = new QLineEdit( container ); QWhatsThis::add( feeEdit, tr( "Enter any fee amount assoiciated with this transaction.\n\nThe value entered should always be positive." ) ); layout->addMultiCellWidget( feeEdit, 6, 6, 1, 3 ); // Notes label = new QLabel( tr( "Notes:" ), container ); QWhatsThis::add( label, tr( "Enter any additional information for this transaction here." ) ); layout->addWidget( label, 7, 0 ); noteEdit = new QMultiLineEdit( container ); QWhatsThis::add( noteEdit, tr( "Enter any additional information for this transaction here." ) ); layout->addMultiCellWidget( noteEdit, 8, 8, 0, 3 ); // Populate current values if provided if ( info ) { if ( info->withdrawal() ) { withBtn->setChecked( TRUE ); slotWithdrawalClicked(); } else { depBtn->setChecked( TRUE ); slotDepositClicked(); } QDate dt = info->date(); slotDateChanged( dt.year(), dt.month(), dt.day() ); datePicker->setDate( dt ); numEdit->setText( info->number() ); descEdit->setText( info->desc() ); QString temptext = info->category(); int i = catList->count(); while ( i > 0 ) { i--; catList->setCurrentItem( i ); if ( catList->currentText() == temptext ) { break; } } temptext = info->type(); i = typeList->count(); while ( i > 0 ) { i--; typeList->setCurrentItem( i ); if ( typeList->currentText() == temptext ) { break; } } amtEdit->setText( QString( "%1" ).arg( info->amount(), 0, 'f', 2 ) ); feeEdit->setText( QString( "%1" ).arg( info->fee(), 0, 'f', 2 ) ); noteEdit->setText( info->notes() ); } else { withBtn->setChecked( TRUE ); } } Transaction::~Transaction() { } void Transaction::accept() { tran->setDesc( descEdit->text() ); tran->setDate( datePicker->selectedDate() ); tran->setWithdrawal( withBtn->isChecked() ); tran->setType( typeList->currentText() ); tran->setCategory( catList->currentText() ); bool ok; tran->setAmount( amtEdit->text().toFloat( &ok ) ); tran->setFee( feeEdit->text().toFloat( &ok ) ); tran->setNumber( numEdit->text() ); tran->setNotes( noteEdit->text() ); QDialog::accept(); } void Transaction::slotWithdrawalClicked() { catList->clear(); catList->insertItem( tr( "Automobile" ) ); catList->insertItem( tr( "Bills" ) ); catList->insertItem( tr( "CDs" ) ); catList->insertItem( tr( "Clothing" ) ); catList->insertItem( tr( "Computer" ) ); catList->insertItem( tr( "DVDs" ) ); catList->insertItem( tr( "Eletronics" ) ); catList->insertItem( tr( "Entertainment" ) ); catList->insertItem( tr( "Food" ) ); |