summaryrefslogtreecommitdiff
path: root/noncore/apps/checkbook
Unidiff
Diffstat (limited to 'noncore/apps/checkbook') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/checkbook/checkbook.cpp59
-rw-r--r--noncore/apps/checkbook/checkbook.h5
-rw-r--r--noncore/apps/checkbook/checkbook.pro42
-rw-r--r--noncore/apps/checkbook/graph.cpp112
-rw-r--r--noncore/apps/checkbook/graph.h63
-rw-r--r--noncore/apps/checkbook/graphinfo.cpp84
-rw-r--r--noncore/apps/checkbook/graphinfo.h82
-rw-r--r--noncore/apps/checkbook/mainwindow.cpp11
-rw-r--r--noncore/apps/checkbook/traninfo.cpp25
-rw-r--r--noncore/apps/checkbook/traninfo.h1
-rw-r--r--noncore/apps/checkbook/transaction.cpp4
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
@@ -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() )
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
@@ -32,12 +32,13 @@
32#include "traninfo.h" 32#include "traninfo.h"
33 33
34#include <qdialog.h> 34#include <qdialog.h>
35 35
36class OTabWidget; 36class OTabWidget;
37 37
38class Graph;
38class QComboBox; 39class QComboBox;
39class QLabel; 40class QLabel;
40class QLineEdit; 41class QLineEdit;
41class QListView; 42class QListView;
42class QMultiLineEdit; 43class QMultiLineEdit;
43class QString; 44class QString;
@@ -80,15 +81,15 @@ class Checkbook : public QDialog
80 QWidget *initTransactions(); 81 QWidget *initTransactions();
81 QListView *tranTable; 82 QListView *tranTable;
82 QLabel *balanceLabel; 83 QLabel *balanceLabel;
83 float currBalance; 84 float currBalance;
84 85
85 // Charts tab 86 // Charts tab
86 QWidget *initCharts(); 87 QWidget *initCharts();
87 //QComboBox *graphList; 88 //QComboBox *graphList;
88 QWidget *graphWidget; 89 Graph *graphWidget;
89 90
90 protected slots: 91 protected slots:
91 void accept(); 92 void accept();
92 93
93 private slots: 94 private slots:
94 void slotNameChanged( const QString & ); 95 void slotNameChanged( const QString & );
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 @@
1TEMPLATE = app 1TEMPLATE = app
2CONFIG = qt warn_on release 2CONFIG = qt warn_on release
3HEADERS = mainwindow.h \ 3HEADERS = mainwindow.h \
4 traninfo.h \ 4 traninfo.h \
5 checkbook.h \ 5 graphinfo.h \
6 transaction.h 6 checkbook.h \
7SOURCES = main.cpp \ 7 transaction.h \
8 mainwindow.cpp \ 8 graph.h
9 traninfo.cpp \ 9SOURCES = main.cpp \
10 checkbook.cpp \ 10 mainwindow.cpp \
11 transaction.cpp 11 traninfo.cpp \
12 graphinfo.cpp \
13 checkbook.cpp \
14 transaction.cpp \
15 graph.cpp
12INCLUDEPATH += $(OPIEDIR)/include 16INCLUDEPATH += $(OPIEDIR)/include
13DEPENDPATH += $(OPIEDIR)/include 17DEPENDPATH += $(OPIEDIR)/include
14LIBS += -lqpe -lopie 18LIBS += -lqpe -lopie
15TARGET = checkbook 19TARGET = checkbook
16DESTDIR = $(OPIEDIR)/bin 20DESTDIR = $(OPIEDIR)/bin
17 21
18TRANSLATIONS = ../../../i18n/de/checkbook.ts \ 22TRANSLATIONS = ../../../i18n/de/checkbook.ts \
19 ../../../i18n/en/checkbook.ts \ 23 ../../../i18n/en/checkbook.ts \
20 ../../../i18n/es/checkbook.ts \ 24 ../../../i18n/es/checkbook.ts \
21 ../../../i18n/fr/checkbook.ts \ 25 ../../../i18n/fr/checkbook.ts \
22 ../../../i18n/hu/checkbook.ts \ 26 ../../../i18n/hu/checkbook.ts \
23 ../../../i18n/ja/checkbook.ts \ 27 ../../../i18n/ja/checkbook.ts \
24 ../../../i18n/ko/checkbook.ts \ 28 ../../../i18n/ko/checkbook.ts \
25 ../../../i18n/no/checkbook.ts \ 29 ../../../i18n/no/checkbook.ts \
26 ../../../i18n/pl/checkbook.ts \ 30 ../../../i18n/pl/checkbook.ts \
27 ../../../i18n/pt/checkbook.ts \ 31 ../../../i18n/pt/checkbook.ts \
28 ../../../i18n/pt_BR/checkbook.ts \ 32 ../../../i18n/pt_BR/checkbook.ts \
29 ../../../i18n/sl/checkbook.ts \ 33 ../../../i18n/sl/checkbook.ts \
30 ../../../i18n/zh_CN/checkbook.ts \ 34 ../../../i18n/zh_CN/checkbook.ts \
31 ../../../i18n/zh_TW/checkbook.ts \ 35 ../../../i18n/zh_TW/checkbook.ts \
32 ../../../i18n/it/checkbook.ts 36 ../../../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 @@
1/*
2                This file is part of the OPIE Project
3 =.
4             .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org>
5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#include "graph.h"
30#include "graphinfo.h"
31
32#include <qpainter.h>
33
34Graph::Graph( QWidget *parent, GraphInfo *d, const QString &name, int flags )
35 : QWidget( parent, name, flags )
36{
37 setBackgroundMode( QWidget::PaletteBase );
38
39 data = d;
40
41 graph.setOptimization( QPixmap::BestOptim );
42}
43
44void Graph::setGraphInfo( GraphInfo *d )
45{
46 data = d;
47}
48
49void Graph::drawGraph( bool regen )
50{
51 if ( regen )
52 {
53 initGraph();
54 }
55 QPainter p( this );
56 p.drawPixmap( 0, 0, graph );
57}
58
59void Graph::paintEvent( QPaintEvent * )
60{
61 drawGraph( FALSE );
62}
63
64void Graph::resizeEvent( QResizeEvent * )
65{
66 drawGraph( TRUE );
67}
68
69void Graph::initGraph()
70{
71 graph.resize( width(), height() );
72 graph.fill( QColor( 255, 255, 255 ) );
73
74 if ( !data )
75 {
76 return;
77 }
78
79 // Any common stuff here (titles, ???)
80
81 switch ( data->graphType() )
82 {
83 case GraphInfo::BarChart :
84 {
85 drawBarChart();
86 }
87 break;
88 case GraphInfo::LineChart :
89 {
90 drawLineChart();
91 }
92 break;
93 case GraphInfo::PieChart :
94 {
95 drawPieChart();
96 }
97 };
98}
99
100void Graph::drawBarChart()
101{
102 //Find max value in GraphInfo->dataPoints() - make function in GraphInfo!!!
103}
104
105void Graph::drawLineChart()
106{
107}
108
109void Graph::drawPieChart()
110{
111}
112
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 @@
1/*
2                This file is part of the OPIE Project
3 =.
4             .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org>
5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#ifndef GRAPH_H
30#define GRAPH_H
31
32#include <qpixmap.h>
33#include <qwidget.h>
34
35class GraphInfo;
36
37class Graph : public QWidget
38{
39 Q_OBJECT
40
41 public:
42 Graph( QWidget * = 0x0, GraphInfo * = 0x0, const QString & = 0x0, int = 0 );
43
44 void setGraphInfo( GraphInfo * );
45
46 void drawGraph( bool = FALSE );
47
48 protected:
49 void paintEvent( QPaintEvent * );
50 void resizeEvent( QResizeEvent * );
51
52 private:
53 GraphInfo *data;
54
55 QPixmap graph;
56
57 void initGraph();
58 void drawBarChart();
59 void drawLineChart();
60 void drawPieChart();
61};
62
63#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 @@
1/*
2                This file is part of the OPIE Project
3 =.
4             .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org>
5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#include "graphinfo.h"
30
31GraphInfo::GraphInfo( GraphType type, DataPointList *data, const QString &title,
32 const QString &xtitle, const QString &ytitle )
33{
34 t = type;
35 d = data;
36 gt = title;
37 xt = xtitle;
38 yt = ytitle;
39}
40
41GraphInfo::GraphType GraphInfo::graphType()
42{
43 return t;
44}
45
46void GraphInfo::setGraphType( GraphType type )
47{
48 t = type;
49}
50
51DataPointList *GraphInfo::dataPoints()
52{
53 return d;
54}
55
56void GraphInfo::setDataPoints( DataPointList *data )
57{
58 d = data;
59}
60
61float GraphInfo::maxValue()
62{
63 float max;
64
65}
66
67float GraphInfo::minValue()
68{
69}
70
71void GraphInfo::setGraphTitle( const QString &title )
72{
73 gt = title;
74}
75
76void GraphInfo::setXAxisTitle( const QString &xtitle )
77{
78 xt = xtitle;
79}
80
81void GraphInfo::setYAxisTitle( const QString &ytitle )
82{
83 yt = ytitle;
84}
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 @@
1/*
2                This file is part of the OPIE Project
3 =.
4             .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org>
5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#ifndef GRAPHINFO_H
30#define GRAPHINFO_H
31
32#include <qlist.h>
33#include <qstringlist.h>
34
35class DataPointInfo
36{
37 public:
38 DataPointInfo()
39 : l( 0x0 ), v( 0.0 ) {}
40 DataPointInfo( const QString &label, float value )
41 : l( label ), v( value ) {}
42
43 const QString &label() { return l; }
44 float value() { return v; }
45
46 private:
47 QString l;
48 float v;
49};
50
51typedef QList<DataPointInfo> DataPointList;
52
53class GraphInfo
54{
55 public:
56 enum GraphType { BarChart, LineChart, PieChart };
57
58 GraphInfo( GraphType = BarChart, DataPointList * = 0x0,
59 const QString & = 0x0, const QString & = 0x0, const QString & = 0x0 );
60
61 GraphInfo::GraphType graphType();
62 void setGraphType( GraphType );
63
64 DataPointList *dataPoints();
65 void setDataPoints( DataPointList * );
66
67 float maxValue();
68 float minValue();
69
70 void setGraphTitle( const QString & );
71 void setXAxisTitle( const QString & );
72 void setYAxisTitle( const QString & );
73
74 private:
75 GraphType t;
76 DataPointList *d;
77 QString gt;
78 QString xt;
79 QString yt;
80};
81
82#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
@@ -134,13 +134,16 @@ void MainWindow::slotEdit()
134 QString newname = currcb->getName(); 134 QString newname = currcb->getName();
135 if ( currname != newname ) 135 if ( currname != newname )
136 { 136 {
137 cbList->changeItem( newname, cbList->currentItem() ); 137 cbList->changeItem( newname, cbList->currentItem() );
138 cbList->sort(); 138 cbList->sort();
139 139
140 QFile f( cbDir + currname + ".qcb" ); 140 QString tempstr = cbDir;
141 tempstr.append( currname );
142 tempstr.append( ".qcb" );
143 QFile f( tempstr );
141 if ( f.exists() ) 144 if ( f.exists() )
142 { 145 {
143 f.remove(); 146 f.remove();
144 } 147 }
145 } 148 }
146 delete currcb; 149 delete currcb;
@@ -148,14 +151,16 @@ void MainWindow::slotEdit()
148} 151}
149 152
150void MainWindow::slotDelete() 153void MainWindow::slotDelete()
151{ 154{
152 if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), cbList->currentText() ) ) 155 if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), cbList->currentText() ) )
153 { 156 {
154 QString name = cbDir + cbList->currentText() + ".qcb"; 157 QString tempstr = cbDir;
155 QFile f( name ); 158 tempstr.append( cbList->currentText() );
159 tempstr.append( ".qcb" );
160 QFile f( tempstr );
156 if ( f.exists() ) 161 if ( f.exists() )
157 { 162 {
158 f.remove(); 163 f.remove();
159 } 164 }
160 165
161 cbList->removeItem( cbList->currentItem() ); 166 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
@@ -27,12 +27,14 @@
27*/ 27*/
28 28
29#include "traninfo.h" 29#include "traninfo.h"
30 30
31#include <qpe/config.h> 31#include <qpe/config.h>
32 32
33QString tempstr;
34
33TranInfo::TranInfo( int id, const QString &desc, const QDate &date, bool withdrawal, 35TranInfo::TranInfo( int id, const QString &desc, const QDate &date, bool withdrawal,
34 const QString &type, const QString &category, float amount, 36 const QString &type, const QString &category, float amount,
35 float fee, const QString &number, const QString &notes ) 37 float fee, const QString &number, const QString &notes )
36{ 38{
37 i = id; 39 i = id;
38 d = desc; 40 d = desc;
@@ -114,21 +116,38 @@ TranInfo::TranInfo( Config config, int entry )
114 116
115 // Notes 117 // Notes
116 n = config.readEntry( "Comments", "" ); 118 n = config.readEntry( "Comments", "" );
117 } 119 }
118} 120}
119 121
122const QString &TranInfo::datestr()
123{
124 tempstr = QString::number( td.year() );
125 tempstr.append( '/' );
126 int tempfield = td.month();
127 if ( tempfield < 10 ) tempstr.append( '0' );
128 tempstr.append( QString::number( tempfield ) );
129 tempstr.append( '/' );
130 tempfield = td.day();
131 if ( tempfield < 10 ) tempstr.append( '0' );
132 tempstr.append( QString::number( tempfield ) );
133
134 return( tempstr );
135}
136
120void TranInfo::write( Config *config, int entry ) 137void TranInfo::write( Config *config, int entry )
121{ 138{
122 config->setGroup( QString::number( entry ) ); 139 config->setGroup( QString::number( entry ) );
123 140
124 config->writeEntry( "Description", d ); 141 config->writeEntry( "Description", d );
125 142
126 QString tempstr = QString::number( td.month() ) + "/" + 143 tempstr = QString::number( td.month() );
127 QString::number( td.day() ) + "/" + 144 tempstr.append( '/' );
128 QString::number( td.year() ); 145 tempstr.append( QString::number( td.day() ) );
146 tempstr.append( '/' );
147 tempstr.append( QString::number( td.year() ) );
129 config->writeEntry( "Date", tempstr ); 148 config->writeEntry( "Date", tempstr );
130 149
131 w ? tempstr = "true" 150 w ? tempstr = "true"
132 : tempstr = "false"; 151 : tempstr = "false";
133 config->writeEntry( "Payment", tempstr ); 152 config->writeEntry( "Payment", tempstr );
134 153
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
@@ -44,12 +44,13 @@ class TranInfo
44 const QString & = 0x0, const QString & = 0x0 ); 44 const QString & = 0x0, const QString & = 0x0 );
45 TranInfo( Config, int ); 45 TranInfo( Config, int );
46 46
47 int id() const { return i; } 47 int id() const { return i; }
48 const QString &desc() const { return d; } 48 const QString &desc() const { return d; }
49 const QDate &date() const { return td; } 49 const QDate &date() const { return td; }
50 const QString &datestr();
50 bool withdrawal()const { return w; } 51 bool withdrawal()const { return w; }
51 const QString &type() const { return t; } 52 const QString &type() const { return t; }
52 const QString &category()const { return c; } 53 const QString &category()const { return c; }
53 float amount() const { return a; } 54 float amount() const { return a; }
54 float fee() const { return f; } 55 float fee() const { return f; }
55 const QString &number() const { return cn; } 56 const QString &number() const { return cn; }
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
@@ -46,13 +46,15 @@
46#include <qwhatsthis.h> 46#include <qwhatsthis.h>
47 47
48Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *info, 48Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *info,
49 char symbol ) 49 char symbol )
50 : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) 50 : QDialog( parent, 0, TRUE, WStyle_ContextHelp )
51{ 51{
52 setCaption( tr( "Transaction for " ) + acctname ); 52 QString tempstr = tr( "Transaction for " );
53 tempstr.append( acctname );
54 setCaption( tempstr );
53 55
54 tran = info; 56 tran = info;
55 currencySymbol = symbol; 57 currencySymbol = symbol;
56 58
57 QVBoxLayout *vb = new QVBoxLayout( this ); 59 QVBoxLayout *vb = new QVBoxLayout( this );
58 60