summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/checkbook/TODO5
-rw-r--r--noncore/apps/checkbook/checkbook.cpp491
-rw-r--r--noncore/apps/checkbook/checkbook.h102
-rw-r--r--noncore/apps/checkbook/checkbook.pro39
-rw-r--r--noncore/apps/checkbook/config.cpp560
-rw-r--r--noncore/apps/checkbook/config.h99
-rw-r--r--noncore/apps/checkbook/main.cpp39
-rw-r--r--noncore/apps/checkbook/mainwindow.cpp164
-rw-r--r--noncore/apps/checkbook/mainwindow.h60
-rw-r--r--noncore/apps/checkbook/opie-checkbook.control4
-rw-r--r--noncore/apps/checkbook/qcheckbook.cpp153
-rw-r--r--noncore/apps/checkbook/qcheckbook.h38
-rw-r--r--noncore/apps/checkbook/qcheckdetails.cpp119
-rw-r--r--noncore/apps/checkbook/qcheckdetails.h27
-rw-r--r--noncore/apps/checkbook/qcheckdetailsbase.ui62
-rw-r--r--noncore/apps/checkbook/qcheckentry.cpp256
-rw-r--r--noncore/apps/checkbook/qcheckentry.h31
-rw-r--r--noncore/apps/checkbook/qcheckentrybase.ui610
-rw-r--r--noncore/apps/checkbook/qcheckgraph.cpp258
-rw-r--r--noncore/apps/checkbook/qcheckgraph.h25
-rw-r--r--noncore/apps/checkbook/qcheckgraphbase.ui62
-rw-r--r--noncore/apps/checkbook/qcheckmainmenu.cpp105
-rw-r--r--noncore/apps/checkbook/qcheckmainmenu.h28
-rw-r--r--noncore/apps/checkbook/qcheckmmbase.ui80
-rw-r--r--noncore/apps/checkbook/qcheckname.cpp36
-rw-r--r--noncore/apps/checkbook/qcheckname.h15
-rw-r--r--noncore/apps/checkbook/qchecknamebase.cpp81
-rw-r--r--noncore/apps/checkbook/qchecknamebase.h38
-rw-r--r--noncore/apps/checkbook/qchecknamebase.ui136
-rw-r--r--noncore/apps/checkbook/qcheckview.cpp458
-rw-r--r--noncore/apps/checkbook/qcheckview.h33
-rw-r--r--noncore/apps/checkbook/qcheckviewbase.ui122
-rw-r--r--noncore/apps/checkbook/qrestrictedcombo.cpp78
-rw-r--r--noncore/apps/checkbook/qrestrictedcombo.h96
-rw-r--r--noncore/apps/checkbook/qrestrictedline.cpp78
-rw-r--r--noncore/apps/checkbook/qrestrictedline.h96
-rw-r--r--noncore/apps/checkbook/traninfo.cpp156
-rw-r--r--noncore/apps/checkbook/traninfo.h85
-rw-r--r--noncore/apps/checkbook/transaction.cpp260
-rw-r--r--noncore/apps/checkbook/transaction.h79
40 files changed, 1444 insertions, 3820 deletions
diff --git a/noncore/apps/checkbook/TODO b/noncore/apps/checkbook/TODO
deleted file mode 100644
index adc9665..0000000
--- a/noncore/apps/checkbook/TODO
+++ b/dev/null
@@ -1,5 +0,0 @@
1TODO:
2 * Date widget
3 * Various bug fixes
4 * Fix "the" crash
5 * Fix graph's legend not showing up \ No newline at end of file
diff --git a/noncore/apps/checkbook/checkbook.cpp b/noncore/apps/checkbook/checkbook.cpp
new file mode 100644
index 0000000..2919927
--- a/dev/null
+++ b/noncore/apps/checkbook/checkbook.cpp
@@ -0,0 +1,491 @@
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 "checkbook.h"
30#include "transaction.h"
31
32#include <opie/otabwidget.h>
33#include <qpe/config.h>
34#include <qpe/qpeapplication.h>
35#include <qpe/qpemessagebox.h>
36#include <qpe/resource.h>
37
38#include <qcombobox.h>
39#include <qfile.h>
40#include <qlabel.h>
41#include <qlayout.h>
42#include <qlineedit.h>
43#include <qlistview.h>
44#include <qmultilineedit.h>
45#include <qpushbutton.h>
46#include <qwidget.h>
47
48Checkbook::Checkbook( QWidget *parent, const QString &n, const QString &fd, char symbol )
49 : QDialog( parent, 0, TRUE, 0 )
50{
51 name = n;
52 filename = fd + name + ".qcb";
53 filedir = fd;
54 currencySymbol = symbol;
55 currBalance = 0.0;
56
57 if ( name != "" )
58 {
59 setCaption( name + " - " + tr( "Checkbook" ) );
60 }
61 else
62 {
63 setCaption( tr( "New checkbook" ) );
64 }
65
66 // Setup layout to make everything pretty
67 QVBoxLayout *layout = new QVBoxLayout( this );
68 layout->setMargin( 2 );
69 layout->setSpacing( 4 );
70
71 // Setup tabs for all info
72 mainWidget = new OTabWidget( this );
73 layout->addWidget( mainWidget );
74
75 mainWidget->addTab( initInfo(), "help_icon", tr( "Info" ) );
76 mainWidget->addTab( initTransactions(), "Spreadsheet", tr( "Transactions" ) );
77 mainWidget->addTab( initCharts(), "DocumentTypePowerPoint", tr( "Charts" ) );
78 mainWidget->setCurrentTab( tr( "Info" ) );
79
80 // Load checkbook information
81 loadCheckbook();
82}
83
84Checkbook::~Checkbook()
85{
86}
87
88const QString &Checkbook::getName()
89{
90 return( name );
91}
92
93QWidget *Checkbook::initInfo()
94{
95 QWidget *control = new QWidget( mainWidget );
96
97 QVBoxLayout *vb = new QVBoxLayout( control );
98
99 QScrollView *sv = new QScrollView( control );
100 vb->addWidget( sv, 0, 0 );
101 sv->setResizePolicy( QScrollView::AutoOneFit );
102 sv->setFrameStyle( QFrame::NoFrame );
103
104 QWidget *container = new QWidget( sv->viewport() );
105 sv->addChild( container );
106
107 QGridLayout *layout = new QGridLayout( container );
108 layout->setSpacing( 2 );
109 layout->setMargin( 4 );
110
111 // Account name
112 QLabel *label = new QLabel( tr( "Name:" ), container );
113 layout->addWidget( label, 0, 0 );
114 nameEdit = new QLineEdit( container );
115 connect( nameEdit, SIGNAL( textChanged( const QString & ) ),
116 this, SLOT( slotNameChanged( const QString & ) ) );
117 layout->addWidget( nameEdit, 0, 1 );
118
119 // Type of account
120 label = new QLabel( tr( "Type:" ), container );
121 layout->addWidget( label, 1, 0 );
122 typeList = new QComboBox( container );
123 typeList->insertItem( tr( "Savings" ) ); // 0
124 typeList->insertItem( tr( "Checking" ) ); // 1
125 typeList->insertItem( tr( "CD" ) ); // 2
126 typeList->insertItem( tr( "Money market" ) );// 3
127 typeList->insertItem( tr( "Mutual fund" ) );// 4
128 typeList->insertItem( tr( "Other" ) ); // 5
129 layout->addWidget( typeList, 1, 1 );
130
131 // Bank/institution name
132 label = new QLabel( tr( "Bank:" ), container );
133 layout->addWidget( label, 2, 0 );
134 bankEdit = new QLineEdit( container );
135 layout->addWidget( bankEdit, 2, 1 );
136
137 // Account number
138 label = new QLabel( tr( "Account number:" ), container );
139 layout->addWidget( label, 3, 0 );
140 acctNumEdit = new QLineEdit( container );
141 layout->addWidget( acctNumEdit, 3, 1 );
142
143 // PIN number
144 label = new QLabel( tr( "PIN number:" ), container );
145 layout->addWidget( label, 4, 0 );
146 pinNumEdit = new QLineEdit( container );
147 layout->addWidget( pinNumEdit, 4, 1 );
148
149 // Starting balance
150 label = new QLabel( tr( "Starting balance:" ), container );
151 layout->addWidget( label, 5, 0 );
152 balanceEdit = new QLineEdit( container );
153 connect( balanceEdit, SIGNAL( textChanged( const QString & ) ),
154 this, SLOT( slotStartingBalanceChanged( const QString & ) ) );
155 layout->addWidget( balanceEdit, 5, 1 );
156
157 // Notes
158 label = new QLabel( tr( "Notes:" ), container );
159 layout->addWidget( label, 6, 0 );
160 notesEdit = new QMultiLineEdit( container );
161 notesEdit->setMaximumHeight( 85 );
162 layout->addMultiCellWidget( notesEdit, 7, 7, 0, 1 );
163
164 return control;
165}
166
167QWidget *Checkbook::initTransactions()
168{
169 QWidget *control = new QWidget( mainWidget );
170
171 QGridLayout *layout = new QGridLayout( control );
172 layout->setSpacing( 2 );
173 layout->setMargin( 4 );
174
175 balanceLabel = new QLabel( tr( "Current balance: %10.00" ).arg( currencySymbol ),
176 control );
177 layout->addMultiCellWidget( balanceLabel, 0, 0, 0, 2 );
178
179 tranTable = new QListView( control );
180 tranTable->addColumn( tr( "ID" ) );
181 tranTable->addColumn( tr( "Date" ) );
182 tranTable->addColumn( tr( "Description" ) );
183 int colnum = tranTable->addColumn( tr( "Amount" ) );
184 tranTable->setColumnAlignment( colnum, Qt::AlignRight );
185 tranTable->setAllColumnsShowFocus( TRUE );
186 layout->addMultiCellWidget( tranTable, 1, 1, 0, 2 );
187 QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold );
188 connect( tranTable, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ),
189 this, SLOT( slotEditTran() ) );
190
191 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), control );
192 connect( btn, SIGNAL( clicked() ), this, SLOT( slotNewTran() ) );
193 layout->addWidget( btn, 2, 0 );
194
195 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), control );
196 connect( btn, SIGNAL( clicked() ), this, SLOT( slotEditTran() ) );
197 layout->addWidget( btn, 2, 1 );
198
199 btn = new QPushButton( Resource::loadPixmap( "editdelete" ), tr( "Delete" ), control );
200 connect( btn, SIGNAL( clicked() ), this, SLOT( slotDeleteTran() ) );
201 layout->addWidget( btn, 2, 2 );
202
203 return( control );
204}
205
206QWidget *Checkbook::initCharts()
207{
208 QWidget *control = new QWidget( mainWidget );
209
210 QGridLayout *layout = new QGridLayout( control );
211 layout->setSpacing( 2 );
212 layout->setMargin( 4 );
213
214/*
215 QLabel *label = new QLabel( control );
216 label->setText( tr( "Graph type:" ) );
217 layout->addWidget( label, 0, 0 );
218 graphList = new QComboBox( control );
219 graphList->insertItem( tr( "By category" ) );
220 graphList->insertItem( tr( "..." ) );
221 graphList->insertItem( tr( "..." ) );
222 layout->addWidget( graphList, 0, 1 );
223*/
224
225 QWidget *graphWidget = new QWidget( control );
226 layout->addMultiCellWidget( graphWidget, 0, 0, 0, 1 );
227 graphWidget->setBackgroundMode( QWidget::PaletteBase );
228
229 QPushButton *btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Draw" ), control );
230 connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) );
231 layout->addWidget( btn, 1, 1 );
232
233 return control;
234}
235
236void Checkbook::loadCheckbook()
237{
238 transactions.clear();
239
240 Config config(filename, Config::File);
241
242 // Load info
243 config.setGroup( "Account" );
244 nameEdit->setText( name );
245 QString temptext = config.readEntry( "Type" );
246 int i = typeList->count();
247 while ( i > 0 )
248 {
249 i--;
250 typeList->setCurrentItem( i );
251 if ( typeList->currentText() == temptext )
252 {
253 break;
254 }
255 }
256 bankEdit->setText( config.readEntry( "Bank", "" ) );
257 acctNumEdit->setText( config.readEntry( "Number", "" ) );
258 pinNumEdit->setText( config.readEntry( "PINNumber", "" ) );
259 balanceEdit->setText( config.readEntry( "Balance", "0.0" ) );
260 notesEdit->setText( config.readEntry( "Notes", "" ) );
261
262 bool ok;
263 currBalance = balanceEdit->text().toFloat( &ok );
264 startBalance = currBalance;
265
266 // Load transactions
267 TranInfo *tran;
268 QString trandesc = "";
269 float amount;
270 QString stramount;
271 for ( int i = 1; trandesc != QString::null; i++ )
272 {
273 tran = new TranInfo( config, i );
274 trandesc = tran->desc();
275 if ( trandesc != QString::null )
276 {
277 currBalance -= tran->fee();
278 amount = tran->amount();
279 if ( tran->withdrawal() )
280 {
281 amount *= -1;
282 }
283 currBalance += amount;
284 stramount.sprintf( "%c%.2f", currencySymbol, amount );
285
286 // Add to transaction list
287 transactions.append( tran );
288
289 // Add to transaction table
290 QDate date = tran->date();
291 QString datestr = QString::number( date.month() ) + "/" +
292 QString::number( date.day() ) + "/" +
293 QString::number( date.year() );
294 ( void ) new QListViewItem( tranTable, QString::number( i ), datestr,
295 trandesc, stramount );
296 }
297 else
298 {
299 delete tran;
300 }
301 }
302 balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) );
303
304 highTranNum = transactions.count();
305}
306
307void Checkbook::adjustBalance( float amount )
308{
309 currBalance += amount;
310 balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) );
311
312}
313
314TranInfo *Checkbook::findTranByID( int id )
315{
316 TranInfo *traninfo = transactions.first();
317 while ( traninfo && traninfo->id() != id )
318 {
319 traninfo = transactions.next();
320 }
321 return( traninfo );
322}
323
324void Checkbook::accept()
325{
326 QFile f( filename );
327 if ( f.exists() )
328 {
329 f.remove();
330 }
331
332 Config *config = new Config(filename, Config::File);
333
334 // Save info
335 config->setGroup( "Account" );
336 config->writeEntry( "Type", typeList->currentText() );
337 config->writeEntry( "Bank", bankEdit->text() );
338 config->writeEntry( "Number", acctNumEdit->text() );
339 config->writeEntry( "PINNumber", pinNumEdit->text() );
340 config->writeEntry( "Balance", balanceEdit->text() );
341 config->writeEntry( "Notes", notesEdit->text() );
342
343 // Save transactions
344 TranInfo *tran = transactions.first();
345 int i = 1;
346 while ( tran )
347 {
348 tran->write( config, i );
349 tran = transactions.next();
350 i++;
351 }
352 config->write();
353
354 QDialog::accept();
355}
356
357void Checkbook::slotNameChanged( const QString &newname )
358{
359 name = newname;
360 filename = filedir + newname + ".qcb";
361 setCaption( name + " - " + tr( "Checkbook" ) );
362}
363
364void Checkbook::slotStartingBalanceChanged( const QString &newbalance )
365{
366 currBalance -= startBalance;
367 bool ok;
368 startBalance = newbalance.toFloat( &ok );
369 adjustBalance( startBalance );
370}
371
372void Checkbook::slotNewTran()
373{
374 highTranNum++;
375 TranInfo *traninfo = new TranInfo( highTranNum );
376
377 Transaction *currtran = new Transaction( this, name,
378 traninfo,
379 currencySymbol );
380 currtran->showMaximized();
381 if ( currtran->exec() == QDialog::Accepted )
382 {
383 float amount = traninfo->amount();
384 if ( traninfo->withdrawal() )
385 {
386 amount *= -1;
387 }
388 QString stramount;
389 stramount.sprintf( "%c%.2f", currencySymbol, amount );
390
391 // Add to transaction list
392 transactions.append( traninfo );
393
394 // Add to transaction table
395
396 QDate date = traninfo->date();
397 QString datestr = QString::number( date.month() ) + "/" +
398 QString::number( date.day() ) + "/" +
399 QString::number( date.year() );
400 ( void ) new QListViewItem( tranTable, QString::number( highTranNum ), datestr,
401 traninfo->desc(), stramount );
402
403 adjustBalance( amount );
404 }
405 else
406 {
407 highTranNum--;
408 delete traninfo;
409 }
410}
411
412void Checkbook::slotEditTran()
413{
414 bool ok;
415 QListViewItem *curritem = tranTable->currentItem();
416 if ( !curritem )
417 {
418 return;
419 }
420
421 int tranid = curritem->text( 0 ).toInt( &ok );
422 TranInfo *traninfo = findTranByID( tranid );
423 float origamt = traninfo->amount();
424 if ( traninfo->withdrawal() )
425 {
426 origamt *= -1;
427 }
428
429 Transaction *currtran = new Transaction( this, name,
430 traninfo,
431 currencySymbol );
432 currtran->showMaximized();
433 if ( currtran->exec() == QDialog::Accepted )
434 {
435 QDate date = traninfo->date();
436 QString datestr = QString::number( date.month() ) + "/" +
437 QString::number( date.day() ) + "/" +
438 QString::number( date.year() );
439 curritem->setText( 1, datestr );
440
441 curritem->setText( 2, traninfo->desc() );
442
443 float amount = traninfo->amount();
444 if ( traninfo->withdrawal() )
445 {
446 amount *= -1;
447 }
448 adjustBalance( origamt * -1 );
449 adjustBalance( amount );
450 QString stramount;
451 stramount.sprintf( "%c%.2f", currencySymbol, amount );
452 curritem->setText( 3, stramount );
453
454 balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) );
455
456 delete currtran;
457 }
458}
459
460void Checkbook::slotDeleteTran()
461{
462 QListViewItem *curritem = tranTable->currentItem();
463 if ( !curritem )
464 {
465 return;
466 }
467
468 bool ok;
469 int tranid = curritem->text( 0 ).toInt( &ok );
470 //TranInfo *traninfo = transactions.at( tranid - 1 );
471 TranInfo *traninfo = findTranByID( tranid );
472
473 if ( QPEMessageBox::confirmDelete ( this, tr( "Delete transaction" ), traninfo->desc() ) )
474 {
475 float amount = traninfo->amount();
476 if ( traninfo->withdrawal() )
477 {
478 amount *= -1;
479 }
480
481 transactions.remove( traninfo );
482 delete traninfo;
483 delete curritem;
484
485 adjustBalance( amount * -1 );
486 }
487}
488
489void Checkbook::slotDrawGraph()
490{
491}
diff --git a/noncore/apps/checkbook/checkbook.h b/noncore/apps/checkbook/checkbook.h
new file mode 100644
index 0000000..a86c0f9
--- a/dev/null
+++ b/noncore/apps/checkbook/checkbook.h
@@ -0,0 +1,102 @@
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 CHECKBOOK_H
30#define CHECKBOOK_H
31
32#include "traninfo.h"
33
34#include <qdialog.h>
35
36class OTabWidget;
37
38class QComboBox;
39class QLabel;
40class QLineEdit;
41class QListView;
42class QMultiLineEdit;
43class QString;
44
45class Checkbook : public QDialog
46{
47 Q_OBJECT
48
49 public:
50 Checkbook( QWidget * = 0x0, const QString & = 0x0, const QString & = 0x0, char = '$' );
51 ~Checkbook();
52
53 const QString &getName();
54
55 private:
56 TranInfoList transactions;
57 QString name;
58 QString filename;
59 QString filedir;
60 char currencySymbol;
61 int highTranNum;
62
63 OTabWidget *mainWidget;
64 void loadCheckbook();
65 void adjustBalance( float );
66 TranInfo *findTranByID( int );
67
68 // Info tab
69 QWidget *initInfo();
70 QLineEdit *nameEdit;
71 QComboBox *typeList;
72 QLineEdit *bankEdit;
73 QLineEdit *acctNumEdit;
74 QLineEdit *pinNumEdit;
75 QLineEdit *balanceEdit;
76 QMultiLineEdit *notesEdit;
77 float startBalance;
78
79 // Transactions tab
80 QWidget *initTransactions();
81 QListView *tranTable;
82 QLabel *balanceLabel;
83 float currBalance;
84
85 // Charts tab
86 QWidget *initCharts();
87 //QComboBox *graphList;
88 QWidget *graphWidget;
89
90 protected slots:
91 void accept();
92
93 private slots:
94 void slotNameChanged( const QString & );
95 void slotStartingBalanceChanged( const QString & );
96 void slotNewTran();
97 void slotEditTran();
98 void slotDeleteTran();
99 void slotDrawGraph();
100};
101
102#endif
diff --git a/noncore/apps/checkbook/checkbook.pro b/noncore/apps/checkbook/checkbook.pro
index cf78739..07cc012 100644
--- a/noncore/apps/checkbook/checkbook.pro
+++ b/noncore/apps/checkbook/checkbook.pro
@@ -2,33 +2,14 @@ TEMPLATE = app
2CONFIG = qt warn_on release 2CONFIG = qt warn_on release
3HEADERS = config.h \ 3HEADERS = mainwindow.h \
4 qcheckbook.h \ 4 traninfo.h \
5 qcheckdetails.h \ 5 checkbook.h \
6 qcheckentry.h \ 6 transaction.h
7 qcheckgraph.h \ 7SOURCES = main.cpp \
8 qcheckmainmenu.h \ 8 mainwindow.cpp \
9 qcheckname.h \ 9 traninfo.cpp \
10 qcheckview.h \ 10 checkbook.cpp \
11 qchecknamebase.h \ 11 transaction.cpp
12 qrestrictedcombo.h \
13 qrestrictedline.h
14SOURCES = config.cpp \
15 main.cpp \
16 qcheckbook.cpp \
17 qcheckdetails.cpp \
18 qcheckentry.cpp \
19 qcheckgraph.cpp \
20 qcheckmainmenu.cpp \
21 qcheckname.cpp \
22 qcheckview.cpp \
23 qrestrictedcombo.cpp \
24 qchecknamebase.cpp \
25 qrestrictedline.cpp
26INTERFACES = qcheckdetailsbase.ui \
27 qcheckentrybase.ui \
28 qcheckgraphbase.ui \
29 qcheckmmbase.ui \
30 qcheckviewbase.ui
31INCLUDEPATH += $(OPIEDIR)/include 12INCLUDEPATH += $(OPIEDIR)/include
32DEPENDPATH += $(OPIEDIR)/include 13DEPENDPATH += $(OPIEDIR)/include
33LIBS += -lqpe 14LIBS += -lqpe -lopie
34TARGET = checkbook 15TARGET = checkbook
diff --git a/noncore/apps/checkbook/config.cpp b/noncore/apps/checkbook/config.cpp
deleted file mode 100644
index e6c6dcc..0000000
--- a/noncore/apps/checkbook/config.cpp
+++ b/dev/null
@@ -1,560 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#include <qdir.h>
22#include <qfile.h>
23#include <qfileinfo.h>
24#include <qmessagebox.h>
25#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
26#include <qtextcodec.h>
27#endif
28#include <qtextstream.h>
29
30#include <sys/stat.h>
31#include <sys/types.h>
32#include <fcntl.h>
33#include <stdlib.h>
34#include <unistd.h>
35
36#include "config.h"
37
38
39/*!
40 \internal
41*/
42QString Config::configFilename(const QString& name, Domain d)
43{
44 switch (d) {
45 case File:
46 return name;
47 case User: {
48 QDir dir = (QString(getenv("HOME")) + "/Settings");
49 if ( !dir.exists() )
50 mkdir(dir.path().local8Bit(),0700);
51 return dir.path() + "/" + name + ".conf";
52 }
53 }
54 return name;
55}
56
57/*!
58 \class Config config.h
59 \brief The Config class provides for saving application cofniguration state.
60
61 You should keep a Config in existence only while you do not want others
62 to be able to change the state. There is no locking currently, but there
63 may be in the future.
64*/
65
66/*!
67 \enum Config::ConfigGroup
68 \internal
69*/
70
71/*!
72 \enum Config::Domain
73
74 \value File
75 \value User
76
77 See Config for details.
78*/
79
80/*!
81 Constructs a config that will load or create a configuration with the
82 given \a name in the given \a domain.
83
84 You must call setGroup() before doing much else with the Config.
85
86 In the default Domain, \e User,
87 the configuration is user-specific. \a name should not contain "/" in
88 this case, and in general should be the name of the C++ class that is
89 primarily responsible for maintaining the configuration.
90
91 In the File Domain, \a name is an absolute filename.
92*/
93Config::Config( const QString &name, Domain domain )
94 : filename( configFilename(name,domain) )
95{
96 git = groups.end();
97 read();
98
99 lang = getenv("LANG");
100 int i = lang.find(".");
101 if ( i > 0 )
102 lang = lang.left( i );
103 i = lang.find( "_" );
104 if ( i > 0 )
105 glang = lang.left(i);
106}
107
108/*!
109 Writes any changes to disk and destroys the in-memory object.
110*/
111Config::~Config()
112{
113 if ( changed )
114 write();
115}
116
117/*!
118 Returns whether the current group has an entry called \a key.
119*/
120bool Config::hasKey( const QString &key ) const
121{
122 if ( groups.end() == git )
123 return FALSE;
124 ConfigGroup::ConstIterator it = ( *git ).find( key );
125 return it != ( *git ).end();
126}
127
128/*!
129 Sets the current group for subsequent reading and writing of
130 entries to \a gname. Grouping allows the application to partition the namespace.
131
132 This function must be called prior to any reading or writing
133 of entries.
134
135 The \a gname must not be empty.
136*/
137void Config::setGroup( const QString &gname )
138{
139 QMap< QString, ConfigGroup>::Iterator it = groups.find( gname );
140 if ( it == groups.end() ) {
141 git = groups.insert( gname, ConfigGroup() );
142 changed = TRUE;
143 return;
144 }
145 git = it;
146}
147
148/*!
149 Writes a (\a key, \a value) entry to the current group.
150
151 \sa readEntry()
152*/
153void Config::writeEntry( const QString &key, const char* value )
154{
155 writeEntry(key,QString(value));
156}
157
158/*!
159 Writes a (\a key, \a value) entry to the current group.
160
161 \sa readEntry()
162*/
163void Config::writeEntry( const QString &key, const QString &value )
164{
165 if ( git == groups.end() ) {
166 qWarning( "no group set" );
167 return;
168 }
169 if ( (*git)[key] != value ) {
170 ( *git ).insert( key, value );
171 changed = TRUE;
172 }
173}
174
175/*
176 Note that the degree of protection offered by the encryption here is
177 only sufficient to avoid the most casual observation of the configuration
178 files. People with access to the files can write down the contents and
179 decrypt it using this source code.
180
181 Conceivably, and at some burden to the user, this encryption could
182 be improved.
183*/
184static QString encipher(const QString& plain)
185{
186 // mainly, we make it long
187 QString cipher;
188 int mix=28730492;
189 for (int i=0; i<(int)plain.length(); i++) {
190 int u = plain[i].unicode();
191 int c = u ^ mix;
192 QString x = QString::number(c,36);
193 cipher.append(QChar('a'+x.length()));
194 cipher.append(x);
195 mix *= u;
196 }
197 return cipher;
198}
199
200static QString decipher(const QString& cipher)
201{
202 QString plain;
203 int mix=28730492;
204 for (int i=0; i<(int)cipher.length();) {
205 int l = cipher[i].unicode()-'a';
206 QString x = cipher.mid(i+1,l); i+=l+1;
207 int u = x.toInt(0,36) ^ mix;
208 plain.append(QChar(u));
209 mix *= u;
210 }
211 return plain;
212}
213
214/*!
215 Writes an encrypted (\a key, \a value) entry to the current group.
216
217 Note that the degree of protection offered by the encryption is
218 only sufficient to avoid the most casual observation of the configuration
219 files.
220
221 \sa readEntry()
222*/
223void Config::writeEntryCrypt( const QString &key, const QString &value )
224{
225 if ( git == groups.end() ) {
226 qWarning( "no group set" );
227 return;
228 }
229 QString evalue = encipher(value);
230 if ( (*git)[key] != evalue ) {
231 ( *git ).insert( key, evalue );
232 changed = TRUE;
233 }
234}
235
236/*!
237 Writes a (\a key, \a num) entry to the current group.
238
239 \sa readNumEntry()
240*/
241void Config::writeEntry( const QString &key, int num )
242{
243 QString s;
244 s.setNum( num );
245 writeEntry( key, s );
246}
247
248#ifdef Q_HAS_BOOL_TYPE
249/*!
250 Writes a (\a key, \a b) entry to the current group. This is equivalent
251 to writing a 0 or 1 as an integer entry.
252
253 \sa readBoolEntry()
254*/
255void Config::writeEntry( const QString &key, bool b )
256{
257 QString s;
258 s.setNum( ( int )b );
259 writeEntry( key, s );
260}
261#endif
262
263/*!
264 Writes a (\a key, \a lst) entry to the current group. The list
265 is separated by \a sep, so the strings must not contain that character.
266
267 \sa readListEntry()
268*/
269void Config::writeEntry( const QString &key, const QStringList &lst, const QChar &sep )
270{
271 QString s;
272 QStringList::ConstIterator it = lst.begin();
273 for ( ; it != lst.end(); ++it )
274 s += *it + sep;
275 writeEntry( key, s );
276}
277
278/*!
279 Removes the \a key entry from the current group. Does nothing if
280 there is no such entry.
281*/
282
283void Config::removeEntry( const QString &key )
284{
285 if ( git == groups.end() ) {
286 qWarning( "no group set" );
287 return;
288 }
289 ( *git ).remove( key );
290 changed = TRUE;
291}
292
293/*!
294 \fn bool Config::operator == ( const Config & other ) const
295
296 Tests for equality with \a other. Config objects are equal if they refer to the same filename.
297*/
298
299/*!
300 \fn bool Config::operator != ( const Config & other ) const
301
302 Tests for inequality with \a other. Config objects are equal if they refer to the same filename.
303*/
304
305/*!
306 \fn QString Config::readEntry( const QString &key, const QString &deflt ) const
307
308 Reads a string entry stored with \a key, defaulting to \a deflt if there is no entry.
309*/
310
311/*!
312 \internal
313 For compatibility, non-const version.
314*/
315QString Config::readEntry( const QString &key, const QString &deflt )
316{
317 QString res = readEntryDirect( key+"["+lang+"]" );
318 if ( !res.isNull() )
319 return res;
320 if ( !glang.isEmpty() ) {
321 res = readEntryDirect( key+"["+glang+"]" );
322 if ( !res.isNull() )
323 return res;
324 }
325 return readEntryDirect( key, deflt );
326}
327
328/*!
329 \fn QString Config::readEntryCrypt( const QString &key, const QString &deflt ) const
330
331 Reads an encrypted string entry stored with \a key, defaulting to \a deflt if there is no entry.
332*/
333
334/*!
335 \internal
336 For compatibility, non-const version.
337*/
338QString Config::readEntryCrypt( const QString &key, const QString &deflt )
339{
340 QString res = readEntryDirect( key+"["+lang+"]" );
341 if ( res.isNull() && glang.isEmpty() )
342 res = readEntryDirect( key+"["+glang+"]" );
343 if ( res.isNull() )
344 res = readEntryDirect( key, QString::null );
345 if ( res.isNull() )
346 return deflt;
347 return decipher(res);
348}
349
350/*!
351 \fn QString Config::readEntryDirect( const QString &key, const QString &deflt ) const
352 \internal
353*/
354
355/*!
356 \internal
357 For compatibility, non-const version.
358*/
359QString Config::readEntryDirect( const QString &key, const QString &deflt )
360{
361 if ( git == groups.end() ) {
362 //qWarning( "no group set" );
363 return deflt;
364 }
365 ConfigGroup::ConstIterator it = ( *git ).find( key );
366 if ( it != ( *git ).end() )
367 return *it;
368 else
369 return deflt;
370}
371
372/*!
373 \fn int Config::readNumEntry( const QString &key, int deflt ) const
374 Reads a numeric entry stored with \a key, defaulting to \a deflt if there is no entry.
375*/
376
377/*!
378 \internal
379 For compatibility, non-const version.
380*/
381int Config::readNumEntry( const QString &key, int deflt )
382{
383 QString s = readEntry( key );
384 if ( s.isEmpty() )
385 return deflt;
386 else
387 return s.toInt();
388}
389
390/*!
391 \fn bool Config::readBoolEntry( const QString &key, bool deflt ) const
392 Reads a bool entry stored with \a key, defaulting to \a deflt if there is no entry.
393*/
394
395/*!
396 \internal
397 For compatibility, non-const version.
398*/
399bool Config::readBoolEntry( const QString &key, bool deflt )
400{
401 QString s = readEntry( key );
402 if ( s.isEmpty() )
403 return deflt;
404 else
405 return (bool)s.toInt();
406}
407
408/*!
409 \fn QStringList Config::readListEntry( const QString &key, const QChar &sep ) const
410 Reads a string list entry stored with \a key, and with \a sep as the separator.
411*/
412
413/*!
414 \internal
415 For compatibility, non-const version.
416*/
417
418/*!
419 Removes all entries from the current group.
420*/
421void Config::clearGroup()
422{
423 if ( git == groups.end() ) {
424 qWarning( "no group set" );
425 return;
426 }
427 if ( !(*git).isEmpty() ) {
428 ( *git ).clear();
429 changed = TRUE;
430 }
431}
432
433void Config::removeGroup()
434{
435 if ( git == groups.end() ) {
436 qWarning( "no group set" );
437 return;
438 }
439
440 groups.remove(git);
441 changed = TRUE;
442}
443
444/*!
445 \internal
446*/
447void Config::write( const QString &fn )
448{
449 QString strNewFile;
450 if ( !fn.isEmpty() )
451 filename = fn;
452 strNewFile = filename + ".new";
453
454 QFile f( strNewFile );
455 if ( !f.open( IO_WriteOnly|IO_Raw ) ) {
456 qWarning( "could not open for writing `%s'", strNewFile.latin1() );
457 git = groups.end();
458 return;
459 }
460
461 QString str;
462 QCString cstr;
463 QMap< QString, ConfigGroup >::Iterator g_it = groups.begin();
464
465 for ( ; g_it != groups.end(); ++g_it ) {
466 str += "[" + g_it.key() + "]\n";
467 ConfigGroup::Iterator e_it = ( *g_it ).begin();
468 for ( ; e_it != ( *g_it ).end(); ++e_it )
469 str += e_it.key() + " = " + *e_it + "\n";
470 }
471 cstr = str.utf8();
472
473 int total_length;
474 total_length = f.writeBlock( cstr.data(), cstr.length() );
475 if ( total_length != int(cstr.length()) ) {
476 QMessageBox::critical( 0, QObject::tr("Out of Space"),
477 QObject::tr("There was a problem creating\nConfiguration Information \nfor this program.\n\nPlease free up some space and\ntry again.") );
478 f.close();
479 QFile::remove( strNewFile );
480 return;
481 }
482
483 f.close();
484 // now rename the file...
485 if ( rename( strNewFile, filename ) < 0 ) {
486 qWarning( "problem renaming the file %s to %s", strNewFile.latin1(),
487 filename.latin1() );
488 QFile::remove( strNewFile );
489 }
490}
491
492/*!
493 Returns whether the Config is in a valid state.
494*/
495bool Config::isValid() const
496{
497 return groups.end() != git;
498}
499
500/*!
501 \internal
502*/
503void Config::read()
504{
505 changed = FALSE;
506
507 if ( !QFileInfo( filename ).exists() ) {
508 git = groups.end();
509 return;
510 }
511
512 QFile f( filename );
513 if ( !f.open( IO_ReadOnly ) ) {
514 git = groups.end();
515 return;
516 }
517
518 QTextStream s( &f );
519#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
520 // The below should work, but doesn't in Qt 2.3.0
521 s.setCodec( QTextCodec::codecForMib( 106 ) );
522#else
523 s.setEncoding( QTextStream::UnicodeUTF8 );
524#endif
525
526 QStringList list = QStringList::split('\n', s.read() );
527 f.close();
528
529 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
530 if ( !parse( *it ) ) {
531 git = groups.end();
532 return;
533 }
534 }
535}
536
537/*!
538 \internal
539*/
540bool Config::parse( const QString &l )
541{
542 QString line = l.stripWhiteSpace();
543 if ( line[ 0 ] == QChar( '[' ) ) {
544 QString gname = line;
545 gname = gname.remove( 0, 1 );
546 if ( gname[ (int)gname.length() - 1 ] == QChar( ']' ) )
547 gname = gname.remove( gname.length() - 1, 1 );
548 git = groups.insert( gname, ConfigGroup() );
549 } else if ( !line.isEmpty() ) {
550 if ( git == groups.end() )
551 return FALSE;
552 int eq = line.find( '=' );
553 if ( eq == -1 )
554 return FALSE;
555 QString key = line.left(eq).stripWhiteSpace();
556 QString value = line.mid(eq+1).stripWhiteSpace();
557 ( *git ).insert( key, value );
558 }
559 return TRUE;
560}
diff --git a/noncore/apps/checkbook/config.h b/noncore/apps/checkbook/config.h
deleted file mode 100644
index b3a8561..0000000
--- a/noncore/apps/checkbook/config.h
+++ b/dev/null
@@ -1,99 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#ifndef CONFIG_H
22#define CONFIG_H
23
24// ##### could use QSettings with Qt 3.0
25
26#include <qmap.h>
27#include <qstringlist.h>
28
29class ConfigPrivate;
30class Config
31{
32public:
33 typedef QMap< QString, QString > ConfigGroup;
34
35 enum Domain { File, User };
36 Config( const QString &name, Domain domain=User );
37 ~Config();
38
39 bool operator == ( const Config & other ) const { return (filename == other.filename); }
40 bool operator != ( const Config & other ) const { return (filename != other.filename); }
41
42 bool isValid() const;
43 bool hasKey( const QString &key ) const;
44
45 void setGroup( const QString &gname );
46 void writeEntry( const QString &key, const char* value );
47 void writeEntry( const QString &key, const QString &value );
48 void writeEntryCrypt( const QString &key, const QString &value );
49 void writeEntry( const QString &key, int num );
50#ifdef Q_HAS_BOOL_TYPE
51 void writeEntry( const QString &key, bool b );
52#endif
53 void writeEntry( const QString &key, const QStringList &lst, const QChar &sep );
54 void removeEntry( const QString &key );
55
56 QString readEntry( const QString &key, const QString &deflt = QString::null ) const;
57 QString readEntryCrypt( const QString &key, const QString &deflt = QString::null ) const;
58 QString readEntryDirect( const QString &key, const QString &deflt = QString::null ) const;
59 int readNumEntry( const QString &key, int deflt = -1 ) const;
60 bool readBoolEntry( const QString &key, bool deflt = FALSE ) const;
61
62 // For compatibility, non-const versions.
63 QString readEntry( const QString &key, const QString &deflt );
64 QString readEntryCrypt( const QString &key, const QString &deflt );
65 QString readEntryDirect( const QString &key, const QString &deflt );
66 int readNumEntry( const QString &key, int deflt );
67 bool readBoolEntry( const QString &key, bool deflt );
68
69 void clearGroup();
70 void removeGroup();
71
72 void write( const QString &fn = QString::null );
73
74protected:
75 void read();
76 bool parse( const QString &line );
77
78 QMap< QString, ConfigGroup > groups;
79 QMap< QString, ConfigGroup >::Iterator git;
80 QString filename;
81 QString lang;
82 QString glang;
83 bool changed;
84 ConfigPrivate *d;
85 static QString configFilename(const QString& name, Domain);
86};
87
88inline QString Config::readEntry( const QString &key, const QString &deflt ) const
89{ return ((Config*)this)->readEntry(key,deflt); }
90inline QString Config::readEntryCrypt( const QString &key, const QString &deflt ) const
91{ return ((Config*)this)->readEntryCrypt(key,deflt); }
92inline QString Config::readEntryDirect( const QString &key, const QString &deflt ) const
93{ return ((Config*)this)->readEntryDirect(key,deflt); }
94inline int Config::readNumEntry( const QString &key, int deflt ) const
95{ return ((Config*)this)->readNumEntry(key,deflt); }
96inline bool Config::readBoolEntry( const QString &key, bool deflt ) const
97{ return ((Config*)this)->readBoolEntry(key,deflt); }
98
99#endif
diff --git a/noncore/apps/checkbook/main.cpp b/noncore/apps/checkbook/main.cpp
index 68f00e6..832bd09 100644
--- a/noncore/apps/checkbook/main.cpp
+++ b/noncore/apps/checkbook/main.cpp
@@ -1,3 +1,32 @@
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 "mainwindow.h"
30
1#include <qpe/qpeapplication.h> 31#include <qpe/qpeapplication.h>
2#include "qcheckbook.h"
3 32
@@ -6,5 +35,7 @@ int main(int argc, char **argv)
6 QPEApplication app(argc, argv); 35 QPEApplication app(argc, argv);
7 QCheckBook *qcb = new QCheckBook(); 36
8 app.setMainWidget(qcb); 37 MainWindow *cb = new MainWindow();
9 qcb->showMaximized(); 38 app.setMainWidget(cb);
39 cb->showMaximized();
40
10 return app.exec(); 41 return app.exec();
diff --git a/noncore/apps/checkbook/mainwindow.cpp b/noncore/apps/checkbook/mainwindow.cpp
new file mode 100644
index 0000000..9410536
--- a/dev/null
+++ b/noncore/apps/checkbook/mainwindow.cpp
@@ -0,0 +1,164 @@
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 "mainwindow.h"
30#include "checkbook.h"
31
32#include <qpe/global.h>
33#include <qpe/qpeapplication.h>
34#include <qpe/qpemenubar.h>
35#include <qpe/qpemessagebox.h>
36#include <qpe/qpetoolbar.h>
37#include <qpe/resource.h>
38
39#include <qaction.h>
40#include <qdir.h>
41#include <qlistbox.h>
42#include <qpopupmenu.h>
43#include <qstring.h>
44
45MainWindow::MainWindow()
46 : QMainWindow()
47{
48 setCaption( tr( "Checkbook" ) );
49
50 cbDir = Global::applicationFileName( "checkbook", "" );
51
52 // Build menu and tool bars
53 setToolBarsMovable( FALSE );
54
55 QPEToolBar *bar = new QPEToolBar( this );
56 bar->setHorizontalStretchable( TRUE );
57 QPEMenuBar *mb = new QPEMenuBar( bar );
58 mb->setMargin( 0 );
59 QPopupMenu *popup = new QPopupMenu( this );
60
61 bar = new QPEToolBar( this );
62 actionOpen = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null,
63 0, this, 0 );
64 connect( actionOpen, SIGNAL( activated() ), this, SLOT( slotOpen() ) );
65 actionOpen->addTo( popup );
66 actionOpen->addTo( bar );
67
68 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
69 connect( a, SIGNAL( activated() ), this, SLOT( slotNew() ) );
70 a->addTo( popup );
71 a->addTo( bar );
72
73 actionDelete = new QAction( tr( "Delete" ), Resource::loadPixmap( "editdelete" ), QString::null,
74 0, this, 0 );
75 connect( actionDelete, SIGNAL( activated() ), this, SLOT( slotDelete() ) );
76 actionDelete->addTo( popup );
77 actionDelete->addTo( bar );
78
79 popup->insertSeparator();
80
81 a = new QAction( tr( "Exit" ), QString::null, 0, this, 0 );
82 connect( a, SIGNAL( activated() ), this, SLOT( close() ) );
83 a->addTo( popup );
84
85 mb->insertItem( tr( "Checkbook" ), popup );
86
87 // Build Checkbook selection list control
88 cbList = new QListBox( this );
89 QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold );
90 connect( cbList, SIGNAL( rightButtonPressed( QListBoxItem *, const QPoint & ) ),
91 this, SLOT( slotOpen() ) );
92 setCentralWidget( cbList );
93
94 // Load Checkbook selection list
95 QDir checkdir( cbDir );
96 if (checkdir.exists() == true)
97 {
98 QStringList checkbooks = checkdir.entryList( "*.qcb", QDir::Files|QDir::Readable|QDir::Writable,
99 QDir::Time );
100 for ( QStringList::Iterator it = checkbooks.begin(); it != checkbooks.end(); it++ )
101 {
102 (*it) = (*it).remove( (*it).find('.'), (*it).length() );
103 }
104 cbList->insertStringList( checkbooks );
105 }
106 cbList->sort();
107 cbList->setSelected( 0, TRUE );
108
109 currencySymbol = '$';
110}
111
112MainWindow::~MainWindow()
113{
114}
115
116void MainWindow::slotOpen()
117{
118 QString currname = cbList->currentText();
119 Checkbook *currcb = new Checkbook( this, currname, cbDir, currencySymbol );
120 currcb->showMaximized();
121 if ( currcb->exec() == QDialog::Accepted )
122 {
123 QString newname = currcb->getName();
124 if ( currname != newname )
125 {
126 cbList->changeItem( newname, cbList->currentItem() );
127 cbList->sort();
128
129 QFile f( cbDir + currname + ".qcb" );
130 if ( f.exists() )
131 {
132 f.remove();
133 }
134 }
135 delete currcb;
136 }
137}
138
139void MainWindow::slotNew()
140{
141 Checkbook *currcb = new Checkbook( this, "", cbDir, currencySymbol );
142 currcb->showMaximized();
143 if ( currcb->exec() == QDialog::Accepted )
144 {
145 cbList->insertItem( currcb->getName() );
146 cbList->sort();
147 delete currcb;
148 }
149}
150
151void MainWindow::slotDelete()
152{
153 if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), cbList->currentText() ) )
154 {
155 cbList->removeItem( cbList->currentItem() );
156
157 QString name = cbDir + cbList->currentText() + ".qcb";
158 QFile f( name );
159 if ( f.exists() )
160 {
161 f.remove();
162 }
163 }
164}
diff --git a/noncore/apps/checkbook/mainwindow.h b/noncore/apps/checkbook/mainwindow.h
new file mode 100644
index 0000000..54fbba6
--- a/dev/null
+++ b/noncore/apps/checkbook/mainwindow.h
@@ -0,0 +1,60 @@
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 MAINWINDOW_H
30#define MAINWINDOW_H
31
32#include <qmainwindow.h>
33
34class QAction;
35class QListBox;
36class QListBoxItem;
37class QString;
38
39class MainWindow : public QMainWindow
40{
41 Q_OBJECT
42
43 public:
44 MainWindow();
45 ~MainWindow();
46
47 private:
48 QListBox *cbList;
49 QString cbDir;
50 QAction *actionOpen;
51 QAction *actionDelete;
52 char currencySymbol;
53
54 private slots:
55 void slotOpen();
56 void slotNew();
57 void slotDelete();
58};
59
60#endif
diff --git a/noncore/apps/checkbook/opie-checkbook.control b/noncore/apps/checkbook/opie-checkbook.control
index 9784206..f8e14ca 100644
--- a/noncore/apps/checkbook/opie-checkbook.control
+++ b/noncore/apps/checkbook/opie-checkbook.control
@@ -3,6 +3,6 @@ Priority: optional
3Section: applications 3Section: applications
4Maintainer: ljp <llornkcor@handhelds.org> 4Maintainer: drw <drw@handhelds.org>
5Architecture: arm 5Architecture: arm
6Version: $QPE_VERSION-$SUB_VERSION 6Version: $QPE_VERSION-$SUB_VERSION
7Depends: opie-base ($QPE_VERSION) 7Depends: opie-base ($QPE_VERSION), libopie ($QPE_VERSION)
8Description: Checkbook keeping program. 8Description: Checkbook keeping program.
diff --git a/noncore/apps/checkbook/qcheckbook.cpp b/noncore/apps/checkbook/qcheckbook.cpp
deleted file mode 100644
index 26caad9..0000000
--- a/noncore/apps/checkbook/qcheckbook.cpp
+++ b/dev/null
@@ -1,153 +0,0 @@
1#include "qcheckbook.h"
2
3#include <qmenubar.h>
4#include <qstatusbar.h>
5#include <qpopupmenu.h>
6#include <qapplication.h>
7#include <qfile.h>
8#include <qdir.h>
9
10QCheckBook::QCheckBook()
11 : QMainWindow(),
12 m_view(),
13 m_view2(),
14 m_view3()
15{
16 initCheck = false;
17 initMM = false;
18 setCaption("Checking");
19 statusBar()->hide();
20 menuBar()->hide();
21
22 bar = new QToolBar(this);
23 bar->setHorizontalStretchable( TRUE );
24
25 addToolBar(bar);
26
27 Config config("qcheckbook");
28 config.setGroup("Global");
29 QString lastCheck = config.readEntry("LastCheckBook", QString(""));
30
31 QString checkdirname = QDir::homeDirPath();
32 checkdirname.append("/.checkbooks/");
33 checkdirname.append(lastCheck);
34 QFile f(checkdirname);
35
36
37 if (lastCheck.isEmpty() == false && lastCheck != "" && f.exists() == true)
38 {
39 newCheck(lastCheck);
40 } else {
41 initMainMenus();
42 }
43
44 setToolBarsMovable( FALSE );
45}
46
47void QCheckBook::newCheck(const QString &filename)
48{
49 if (filename.isEmpty() == false)
50 {
51 initCheck = true;
52 if (m_view != 0)
53 {
54 m_view=0;
55 delete m_view;
56 }
57 m_view = new QCheckView(this, filename);
58 m_view->hide();
59 connect(m_view, SIGNAL(reload(const QString &)), this, SLOT(newCheck(const QString &)));
60 if (initMM == true)
61 {
62 delete nb1;
63 }
64 bar->clear();
65 mbar = new QMenuBar(bar);
66 mbar->setMargin(0);
67
68 QPixmap newIcon = Resource::loadPixmap( "new" );
69 nb2 = new QToolButton( newIcon, "New", QString::null, m_view, SLOT(newClicked()), bar, "new item" );
70 QPixmap pixmap = Resource::loadPixmap( "pixmap" );
71 m_filename = filename;
72 nb3 = new QToolButton( pixmap, "Graph", QString::null, this, SLOT(newGraph()), bar, "new graph" );
73
74 QPixmap closeIcon = Resource::loadPixmap( "close" );
75 nb4 = new QToolButton( closeIcon, "Close", QString::null, this, SLOT(initMainMenus()), bar, "close graph" );
76
77 popup = new QPopupMenu(m_view);
78 popup->insertItem("&New Entry", m_view, SLOT(newClicked()));
79 popup->insertItem("&Graph Checkbook", this, SLOT(newGraph()));
80 popup->insertItem("&Close Checkbook", this, SLOT(initMainMenus()));
81 popup->insertItem("&Exit", this, SLOT(close()));
82 mbar->insertItem("&File", popup);
83
84 setCentralWidget(m_view);
85 m_view->show();
86
87 Config config("qcheckbook");
88 config.setGroup("Global");
89 config.writeEntry("LastCheckBook", filename);
90 initMM = false;
91 }
92}
93
94void QCheckBook::deleteCheck(const QString &filename)
95{
96 qDebug("Deleting "+filename);
97}
98
99void QCheckBook::close()
100{
101 QApplication::exit();
102}
103
104void QCheckBook::newGraph()
105{
106 if (m_filename.isEmpty() == false)
107 {
108 m_view2 = new QCheckGraph(m_filename);
109 m_view2->showMaximized();
110 }
111}
112
113void QCheckBook::initMainMenus()
114{
115 Config config("qcheckbook");
116 config.setGroup("Global");
117 config.writeEntry("LastCheckBook", QString(""));
118 initMM = true;
119 m_filename = "";
120 if (m_view3 != 0)
121 {
122 delete m_view3;
123 }
124 m_view3 = new QCheckMainMenu(this);
125 m_view3->hide();
126
127 if (initCheck == true)
128 {
129 delete nb2;
130 delete nb3;
131 delete nb4;
132 }
133
134 bar->clear();
135
136 mbar = new QMenuBar(bar);
137 mbar->setMargin(0);
138
139 QPixmap newIcon = Resource::loadPixmap( "new" );
140 nb1 = new QToolButton( newIcon, "New", QString::null, m_view3, SLOT(newClicked()), bar, "new book" );
141
142 popup = new QPopupMenu();
143 popup->insertItem("&New", m_view3, SLOT(newClicked()));
144 popup->insertItem("&Delete", m_view3, SLOT(deleteClicked()));
145 popup->insertItem("&Exit", this, SLOT(close()));
146 mbar->insertItem("&File", popup);
147
148 setCentralWidget(m_view3);
149 m_view3->show();
150
151 connect(m_view3, SIGNAL(itemSelected(const QString &)), this, SLOT(newCheck(const QString &)));
152 initCheck = false;
153}
diff --git a/noncore/apps/checkbook/qcheckbook.h b/noncore/apps/checkbook/qcheckbook.h
deleted file mode 100644
index 64b6628..0000000
--- a/noncore/apps/checkbook/qcheckbook.h
+++ b/dev/null
@@ -1,38 +0,0 @@
1#include "qcheckview.h"
2#include "qcheckgraph.h"
3#include "qcheckmainmenu.h"
4
5#include <qpe/resource.h>
6#include <qmainwindow.h>
7#include <qtoolbar.h>
8#include <qstring.h>
9#include "config.h"
10#include <qpopupmenu.h>
11
12class QCheckBook : public QMainWindow
13{
14 Q_OBJECT
15 public:
16 QCheckBook();
17 private slots:
18 void newCheck(const QString &filename);
19 void deleteCheck(const QString &filename);
20 void newGraph();
21 void close();
22 void initMainMenus();
23 private:
24 QCheckView *m_view;
25 QCheckGraph *m_view2;
26 QCheckMainMenu *m_view3;
27 QToolBar *bar;
28 QMenuBar *mbar;
29 int filemenuid;
30 QString m_filename;
31 QToolButton *nb1;
32 QToolButton *nb2;
33 QToolButton *nb3;
34 QToolButton *nb4;
35 bool initCheck;
36 bool initMM;
37 QPopupMenu *popup;
38};
diff --git a/noncore/apps/checkbook/qcheckdetails.cpp b/noncore/apps/checkbook/qcheckdetails.cpp
deleted file mode 100644
index 19a5e82..0000000
--- a/noncore/apps/checkbook/qcheckdetails.cpp
+++ b/dev/null
@@ -1,119 +0,0 @@
1#include "qcheckdetails.h"
2
3QCheckDetails::QCheckDetails(int row, int col, const QStringList item)
4 : QMainWindow(),
5 m_view()
6{
7 m_view = new QCheckDetailsBase(this);
8 setCentralWidget(m_view);
9
10 m_row = row;
11 m_col = col;
12
13 QToolBar *bar = new QToolBar(this);
14 bar->setHorizontalStretchable( TRUE );
15
16 QPixmap newIcon = Resource::loadPixmap( "edit" );
17 QPixmap trashIcon = Resource::loadPixmap( "trash" );
18 QToolButton *nb1 = new QToolButton( newIcon, "Edit", QString::null, this, SLOT(editCheck()), bar, "edit transaction" );
19 QToolButton *nb2 = new QToolButton( trashIcon, "Delete", QString::null, this, SLOT(deleteCheck()), bar, "delete transaction" );
20 addToolBar(bar);
21
22 QString text = "";
23 if (item[0] == "true")
24 {
25 text.append("<b>Payment</b> to <b>");
26 text.append(item[1]);
27 }
28 if (item[0] == "false")
29 {
30 text.append("<b>Deposit</b> from <b>");
31 text.append(item[1]);
32 }
33 text.append("</b> on <b>");
34 text.append(item[7]);
35 text.append("</b> for <b>");
36 text.append(QString("$" + item[5]));
37
38 text.append("</b>, to make your balance <b>$");
39 text.append(item[9]);
40 text.append("</b>.");
41
42 text.append("<br><br>");
43 text.append("<b>Category: </b>");
44 text.append(item[2]);
45 text.append("<br>");
46 text.append("<b>Type: </b>");
47
48 QString type = "No Type";
49 if (item[0] == "true")
50 {
51 if(item[3] == "0")
52 {
53 type = "Debit Charge";
54 }
55 if(item[3] == "1")
56 {
57 type = "Written Check";
58 }
59 if(item[3] == "2")
60 {
61 type = "Transfer";
62 }
63 if(item[3] == "3")
64 {
65 type = "Credit Card";
66 }
67 }
68
69 if (item[0] == "false")
70 {
71 if(item[3] == "0")
72 {
73 type = "Written Check";
74 }
75 if(item[3] == "1")
76 {
77 type = "Automatic Payment";
78 }
79 if(item[3] == "2")
80 {
81 type = "Transfer";
82 }
83 if(item[3] == "3")
84 {
85 type = "Cash";
86 }
87 }
88
89 text.append(type);
90 text.append("<br>");
91 if (item[4] != "0")
92 {
93 text.append("<b>Check Number: </b>");
94 text.append(item[4]);
95 text.append("<br>");
96 }
97 if (item[6] != ".00")
98 {
99 text.append("<b>Extra Fee: </b>");
100 text.append(QString("$" + item[6]));
101 m_view->checkDetails->setText(text);
102 }
103 if (item[8] != "")
104 {
105 text.append("<br><b>Additional Comments: </b>");
106 text.append(item[8]);
107 }
108 m_view->checkDetails->setText(text);
109}
110
111void QCheckDetails::editCheck()
112{
113 emit editClicked(m_row, m_col);
114}
115
116void QCheckDetails::deleteCheck()
117{
118 emit deleteClicked(m_row, m_col);
119}
diff --git a/noncore/apps/checkbook/qcheckdetails.h b/noncore/apps/checkbook/qcheckdetails.h
deleted file mode 100644
index fe5fe1a..0000000
--- a/noncore/apps/checkbook/qcheckdetails.h
+++ b/dev/null
@@ -1,27 +0,0 @@
1#include "qcheckdetailsbase.h"
2#include <qstring.h>
3#include <qtextview.h>
4#include <qtoolbar.h>
5#include <qpe/resource.h>
6#include <qpixmap.h>
7#include <qdialog.h>
8#include <qmainwindow.h>
9#include <qtoolbutton.h>
10#include <qwidget.h>
11
12class QCheckDetails : public QMainWindow
13{
14 Q_OBJECT
15 public:
16 QCheckDetails(int row, int col, const QStringList item);
17 signals:
18 void editClicked(int, int);
19 void deleteClicked(int, int);
20 public slots:
21 void editCheck();
22 void deleteCheck();
23 private:
24 int m_row;
25 int m_col;
26 QCheckDetailsBase *m_view;
27};
diff --git a/noncore/apps/checkbook/qcheckdetailsbase.ui b/noncore/apps/checkbook/qcheckdetailsbase.ui
deleted file mode 100644
index d94ba5e..0000000
--- a/noncore/apps/checkbook/qcheckdetailsbase.ui
+++ b/dev/null
@@ -1,62 +0,0 @@
1<!DOCTYPE UI><UI>
2<class>QCheckDetailsBase</class>
3<widget>
4 <class>QWidget</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>QCheckDetailsBase</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>240</width>
15 <height>265</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Transaction Details</string>
21 </property>
22 <grid>
23 <property stdset="1">
24 <name>margin</name>
25 <number>4</number>
26 </property>
27 <property stdset="1">
28 <name>spacing</name>
29 <number>0</number>
30 </property>
31 <widget row="0" column="0" >
32 <class>QTextView</class>
33 <property stdset="1">
34 <name>name</name>
35 <cstring>checkDetails</cstring>
36 </property>
37 </widget>
38 </grid>
39</widget>
40<customwidgets>
41 <customwidget>
42 <class>QWidget</class>
43 <header location="global">qwidget.h</header>
44 <sizehint>
45 <width>-1</width>
46 <height>-1</height>
47 </sizehint>
48 <container>0</container>
49 <sizepolicy>
50 <hordata>5</hordata>
51 <verdata>5</verdata>
52 </sizepolicy>
53 <pixmap>image0</pixmap>
54 </customwidget>
55</customwidgets>
56<images>
57 <image>
58 <name>image0</name>
59 <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1ddec44f503c0ae2a154410f53d0ed20e2bf6bdb656dd6861dd23d9a66591b0587fd1654235ebded6f0edcd53e419d87ae7b1f4f9b8f906d0bfe012317426a70b07bdc2f3ec77f8ed6b89559061a0343d06a124cc105596482585094bc0ae599b04646c9018926491b2205e140c485cace25755c175d0a967b622ff900b8cc9c7d29af594ea722d589167f813aa852ba07d94b9dce296e883fe7bb163f23896753</data>
60 </image>
61</images>
62</UI>
diff --git a/noncore/apps/checkbook/qcheckentry.cpp b/noncore/apps/checkbook/qcheckentry.cpp
deleted file mode 100644
index 2e8da1c..0000000
--- a/noncore/apps/checkbook/qcheckentry.cpp
+++ b/dev/null
@@ -1,256 +0,0 @@
1#include "qcheckentry.h"
2
3QCheckEntry::QCheckEntry()
4 : QCheckEntryBase()
5{
6 connect(transAmount, SIGNAL(textChanged(const QString &)), this, SLOT(amountChanged(const QString &)));
7 connect(transFee, SIGNAL(textChanged(const QString &)), this, SLOT(transFeeChanged(const QString &)));
8 connect(payment, SIGNAL(clicked()), this, SLOT(paymentClicked()));
9 connect(deposit, SIGNAL(clicked()), this, SLOT(depositClicked()));
10
11 QString todaysdate = QString::number(QDate::currentDate().month());
12 todaysdate.append("/");
13 todaysdate.append(QString::number(QDate::currentDate().day()));
14 todaysdate.append("/");
15 todaysdate.append(QString::number(QDate::currentDate().year()));
16 dateEdit->setText(todaysdate);
17
18 descriptionCombo->setFocus();
19
20 dateEdit->setValidChars("0123456789./-");
21 dateEdit->setMaxLength(10);
22
23 descriptionCombo->lineEdit()->setMaxLength(30);
24
25 checkNumber->setValidChars("0123456789-");
26 checkNumber->setMaxLength(10);
27
28 transAmount->setValidChars("0123456789.");
29
30 transFee->setMaxLength(5);
31 transFee->setValidChars("0123456789.");
32 setTabOrder(transType,checkNumber);
33 setTabOrder(checkNumber,transAmount);
34 setTabOrder(transAmount,transFee);
35 setTabOrder(transFee,dateEdit);
36 setTabOrder(dateEdit, additionalNotes );
37}
38
39void QCheckEntry::paymentClicked()
40{
41 cmbCategory->clear();
42 cmbCategory->insertItem( tr( "Automobile" ) );
43 cmbCategory->insertItem( tr( "Bills" ) );
44 cmbCategory->insertItem( tr( "CDs" ) );
45 cmbCategory->insertItem( tr( "Clothing" ) );
46 cmbCategory->insertItem( tr( "Computer" ) );
47 cmbCategory->insertItem( tr( "DVDs" ) );
48 cmbCategory->insertItem( tr( "Eletronics" ) );
49 cmbCategory->insertItem( tr( "Entertainment" ) );
50 cmbCategory->insertItem( tr( "Food" ) );
51 cmbCategory->insertItem( tr( "Gasoline" ) );
52 cmbCategory->insertItem( tr( "Misc" ) );
53 cmbCategory->insertItem( tr( "Movies" ) );
54 cmbCategory->insertItem( tr( "Rent" ) );
55 cmbCategory->insertItem( tr( "Travel" ) );
56 cmbCategory->setCurrentItem( 0 );
57 transType->clear();
58 transType->insertItem( tr( "Debit Charge" ) );
59 transType->insertItem( tr( "Written Check" ) );
60 transType->insertItem( tr( "Transfer" ) );
61 transType->insertItem( tr( "Credit Card" ) );
62}
63
64void QCheckEntry::depositClicked()
65{
66 cmbCategory->clear();
67 cmbCategory->insertItem( tr( "Work" ) );
68 cmbCategory->insertItem( tr( "Family Member" ) );
69 cmbCategory->insertItem( tr( "Misc. Credit" ) );
70 cmbCategory->setCurrentItem( 0 );
71 transType->clear();
72 transType->insertItem( tr( "Written Check" ) );
73 transType->insertItem( tr( "Automatic Payment" ) );
74 transType->insertItem( tr( "Transfer" ) );
75 transType->insertItem( tr( "Cash" ) );
76}
77
78QStringList QCheckEntry::popupEntry(const QStringList &originaldata)
79{
80 QCheckEntry qce;
81
82 // This is how the list looks:
83 // 0: true or false, true == payment, false == deposit
84 // 1: description of the transaction
85 // 2: category name
86 // 3: transaction type (stores the integer value of the index of the combobox)
87 // 4: check number of the transaction (if any)
88 // 5: transaction amount
89 // 6: transaction fee (e.g. service charge, or ATM charge).
90 // 7: date of the transaction
91 // 8: additional notes
92 // 9: recently used descriptions
93 if (originaldata.count() > 1)
94 {
95 if (originaldata[0] == "true")
96 {
97 qce.payment->setChecked(true);
98 qce.paymentClicked();
99 } else {
100 if (originaldata[0] == "false")
101 {
102 qce.deposit->setChecked(true);
103 qce.depositClicked();
104 }
105 }
106 qce.descriptionCombo->lineEdit()->setText(originaldata[1]);
107 qce.cmbCategory->lineEdit()->setText(originaldata[2]);
108 qce.transType->setCurrentItem(originaldata[3].toInt());
109 qce.checkNumber->setText(originaldata[4]);
110 qce.transAmount->setText(originaldata[5]);
111 qce.transFee->setText(originaldata[6]);
112 qce.dateEdit->setText(originaldata[7]);
113 qce.additionalNotes->setText(originaldata[8]);
114 QStringList recentlist;
115 if (!originaldata[9].isEmpty())
116 {
117 recentlist = QStringList::split(',', originaldata[9], false);
118 }
119 if (!recentlist.isEmpty())
120 {
121 qce.descriptionCombo->insertStringList(recentlist);
122 }
123 } else {
124 QStringList recentlist;
125 if (!originaldata[0].isEmpty())
126 {
127 recentlist = QStringList::split(',', originaldata[0], false);
128 }
129 if (!recentlist.isEmpty())
130 {
131 qce.descriptionCombo->insertStringList(recentlist);
132 }
133 }
134
135 qce.setWFlags(Qt::WType_Modal);
136 qce.showMaximized();
137
138 qce.descriptionCombo->lineEdit()->clear();
139
140 if (qce.exec() == QDialog::Accepted)
141 {
142 // Validate that the user has inputed a valid dollar amount
143 if (qce.transFee->text().contains('.') == 0)
144 {
145 QString text = qce.transFee->text();
146 text.append(".00");
147 qce.transFee->setText(text);
148 } else {
149 QString tmp = qce.transFee->text();
150 if (tmp.mid(tmp.find('.'), tmp.length()).length() == 1)
151 {
152 tmp.append("00");
153 qce.transFee->setText(tmp);
154 } else {
155 if (tmp.mid(tmp.find('.'), tmp.length()).length() == 2)
156 {
157 tmp.append("0");
158 qce.transFee->setText(tmp);
159 }
160 }
161 }
162 if (qce.transAmount->text().contains('.') == 0)
163 {
164 QString text = qce.transAmount->text();
165 text.append(".00");
166 qce.transAmount->setText(text);
167 } else {
168 QString tmp = qce.transAmount->text();
169 if (tmp.mid(tmp.find('.'), tmp.length()).length() == 1)
170 {
171 tmp.append("00");
172 qce.transAmount->setText(tmp);
173 } else {
174 if (tmp.mid(tmp.find('.'), tmp.length()).length() == 2)
175 {
176 tmp.append("0");
177 qce.transAmount->setText(tmp);
178 }
179 }
180 }
181
182 QString recent;
183 if (qce.descriptionCombo->count() != 0)
184 {
185 QStringList recentlist = QStringList::split(',', originaldata[9], false);
186 if (recentlist.count() >= 10)
187 {
188 recentlist.remove(recentlist.last());
189 }
190 recentlist.prepend(qce.descriptionCombo->lineEdit()->text());
191 recent = recentlist.join(",");
192 } else {
193 recent = qce.descriptionCombo->lineEdit()->text();
194 }
195
196 QString checkNumberString = qce.checkNumber->text();
197 if (checkNumberString.isEmpty() == true)
198 {
199 checkNumberString = "0";
200 }
201
202 QString paymentChecked = "true";
203 if (qce.payment->isChecked() == false)
204 {
205 paymentChecked = "false";
206 }
207 QStringList returnvalue;
208 returnvalue << paymentChecked << qce.descriptionCombo->lineEdit()->text() << qce.cmbCategory->lineEdit()->text() << QString::number(qce.transType->currentItem()) << checkNumberString << qce.transAmount->text() << qce.transFee->text() << qce.dateEdit->text() << qce.additionalNotes->text() << recent;
209 return returnvalue;
210 } else {
211 QStringList blank;
212 return blank;
213 }
214}
215
216void QCheckEntry::transFeeChanged(const QString &input)
217{
218 QString tmpinput = input;
219 if (tmpinput.contains('.') > 1)
220 {
221 int first = tmpinput.find('.');
222 tmpinput = tmpinput.remove(tmpinput.find('.', (first + 1)), 1);
223 }
224 if (tmpinput.contains(QRegExp("\\.[0-9][0-9]{2}$")) >= 1)
225 {
226 tmpinput = tmpinput.remove((tmpinput.length() - 1), 1);
227 }
228 transFee->setText(tmpinput);
229}
230
231void QCheckEntry::amountChanged(const QString &input)
232{
233 QString tmpinput = input;
234 if (tmpinput.contains('.') > 1)
235 {
236 int first = tmpinput.find('.');
237 tmpinput = tmpinput.remove(tmpinput.find('.', (first + 1)), 1);
238 }
239 if (tmpinput.contains(QRegExp("\\.[0-9][0-9]{2}$")) >= 1)
240 {
241 tmpinput = tmpinput.remove((tmpinput.length() - 1), 1);
242 }
243 transAmount->setText(tmpinput);
244}
245
246void QCheckEntry::accept()
247{
248 // Does the description combo not have any text in it? Do something if it doesn't!
249 if (descriptionCombo->lineEdit()->text().isEmpty() == true)
250 {
251 QMessageBox::critical(this, "Field Missing.", "<qt>You didn't enter a description for this transaction. Please fill out the \"Transaction Description\" field and try again.</qt>");
252 descriptionCombo->setFocus();
253 return;
254 }
255 QDialog::accept();
256}
diff --git a/noncore/apps/checkbook/qcheckentry.h b/noncore/apps/checkbook/qcheckentry.h
deleted file mode 100644
index f361bbf..0000000
--- a/noncore/apps/checkbook/qcheckentry.h
+++ b/dev/null
@@ -1,31 +0,0 @@
1#include <qstring.h>
2#include <qcombobox.h>
3#include "qrestrictedline.h"
4#include <qcombobox.h>
5#include <qstringlist.h>
6#include <qlabel.h>
7#include <qmultilineedit.h>
8#include "qcheckentrybase.h"
9#include <qdialog.h>
10#include <qregexp.h>
11#include <qmessagebox.h>
12#include <qwidget.h>
13#include <qevent.h>
14#include <qdatetime.h>
15#include <qradiobutton.h>
16#include "config.h"
17
18class QCheckEntry : public QCheckEntryBase
19{
20 Q_OBJECT
21 public:
22 QCheckEntry();
23 static QStringList popupEntry(const QStringList &originaldata);
24 private slots:
25 void amountChanged(const QString &);
26 void transFeeChanged(const QString &);
27 void paymentClicked();
28 void depositClicked();
29 protected slots:
30 virtual void accept();
31};
diff --git a/noncore/apps/checkbook/qcheckentrybase.ui b/noncore/apps/checkbook/qcheckentrybase.ui
deleted file mode 100644
index efc35ff..0000000
--- a/noncore/apps/checkbook/qcheckentrybase.ui
+++ b/dev/null
@@ -1,610 +0,0 @@
1<!DOCTYPE UI><UI>
2<class>QCheckEntryBase</class>
3<widget>
4 <class>QDialog</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>QCheckEntryBase</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>224</width>
15 <height>291</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Account Transaction</string>
21 </property>
22 <property>
23 <name>layoutMargin</name>
24 </property>
25 <property>
26 <name>layoutSpacing</name>
27 </property>
28 <grid>
29 <property stdset="1">
30 <name>margin</name>
31 <number>5</number>
32 </property>
33 <property stdset="1">
34 <name>spacing</name>
35 <number>2</number>
36 </property>
37 <spacer row="7" column="8" rowspan="1" colspan="4" >
38 <property>
39 <name>name</name>
40 <cstring>Spacer3</cstring>
41 </property>
42 <property stdset="1">
43 <name>orientation</name>
44 <enum>Horizontal</enum>
45 </property>
46 <property stdset="1">
47 <name>sizeType</name>
48 <enum>Expanding</enum>
49 </property>
50 <property>
51 <name>sizeHint</name>
52 <size>
53 <width>20</width>
54 <height>20</height>
55 </size>
56 </property>
57 </spacer>
58 <spacer row="3" column="1" rowspan="1" colspan="4" >
59 <property>
60 <name>name</name>
61 <cstring>Spacer5</cstring>
62 </property>
63 <property stdset="1">
64 <name>orientation</name>
65 <enum>Horizontal</enum>
66 </property>
67 <property stdset="1">
68 <name>sizeType</name>
69 <enum>Expanding</enum>
70 </property>
71 <property>
72 <name>sizeHint</name>
73 <size>
74 <width>20</width>
75 <height>20</height>
76 </size>
77 </property>
78 </spacer>
79 <widget row="5" column="5" >
80 <class>QLabel</class>
81 <property stdset="1">
82 <name>name</name>
83 <cstring>TextLabel6</cstring>
84 </property>
85 <property stdset="1">
86 <name>font</name>
87 <font>
88 <family>adobe-helvetica</family>
89 <bold>1</bold>
90 </font>
91 </property>
92 <property stdset="1">
93 <name>text</name>
94 <string>$</string>
95 </property>
96 </widget>
97 <spacer row="4" column="6" >
98 <property>
99 <name>name</name>
100 <cstring>Spacer8</cstring>
101 </property>
102 <property stdset="1">
103 <name>orientation</name>
104 <enum>Horizontal</enum>
105 </property>
106 <property stdset="1">
107 <name>sizeType</name>
108 <enum>Expanding</enum>
109 </property>
110 <property>
111 <name>sizeHint</name>
112 <size>
113 <width>20</width>
114 <height>20</height>
115 </size>
116 </property>
117 </spacer>
118 <widget row="2" column="0" rowspan="1" colspan="3" >
119 <class>QLabel</class>
120 <property stdset="1">
121 <name>name</name>
122 <cstring>TextLabel2</cstring>
123 </property>
124 <property stdset="1">
125 <name>text</name>
126 <string>Category:</string>
127 </property>
128 </widget>
129 <spacer row="5" column="2" rowspan="1" colspan="3" >
130 <property>
131 <name>name</name>
132 <cstring>Spacer7</cstring>
133 </property>
134 <property stdset="1">
135 <name>orientation</name>
136 <enum>Horizontal</enum>
137 </property>
138 <property stdset="1">
139 <name>sizeType</name>
140 <enum>Expanding</enum>
141 </property>
142 <property>
143 <name>sizeHint</name>
144 <size>
145 <width>20</width>
146 <height>20</height>
147 </size>
148 </property>
149 </spacer>
150 <spacer row="5" column="11" >
151 <property>
152 <name>name</name>
153 <cstring>Spacer4</cstring>
154 </property>
155 <property stdset="1">
156 <name>orientation</name>
157 <enum>Horizontal</enum>
158 </property>
159 <property stdset="1">
160 <name>sizeType</name>
161 <enum>Expanding</enum>
162 </property>
163 <property>
164 <name>sizeHint</name>
165 <size>
166 <width>20</width>
167 <height>20</height>
168 </size>
169 </property>
170 </spacer>
171 <spacer row="2" column="3" rowspan="1" colspan="2" >
172 <property>
173 <name>name</name>
174 <cstring>Spacer6</cstring>
175 </property>
176 <property stdset="1">
177 <name>orientation</name>
178 <enum>Horizontal</enum>
179 </property>
180 <property stdset="1">
181 <name>sizeType</name>
182 <enum>Expanding</enum>
183 </property>
184 <property>
185 <name>sizeHint</name>
186 <size>
187 <width>20</width>
188 <height>20</height>
189 </size>
190 </property>
191 </spacer>
192 <widget row="5" column="6" rowspan="1" colspan="5" >
193 <class>QRestrictedLine</class>
194 <property stdset="1">
195 <name>name</name>
196 <cstring>transAmount</cstring>
197 </property>
198 </widget>
199 <widget row="1" column="0" rowspan="1" colspan="5" >
200 <class>QLabel</class>
201 <property stdset="1">
202 <name>name</name>
203 <cstring>TextLabel1</cstring>
204 </property>
205 <property stdset="1">
206 <name>text</name>
207 <string>Description:</string>
208 </property>
209 </widget>
210 <widget row="3" column="0" >
211 <class>QLabel</class>
212 <property stdset="1">
213 <name>name</name>
214 <cstring>TextLabel3</cstring>
215 </property>
216 <property stdset="1">
217 <name>text</name>
218 <string>Type:</string>
219 </property>
220 </widget>
221 <widget row="5" column="0" rowspan="1" colspan="2" >
222 <class>QLabel</class>
223 <property stdset="1">
224 <name>name</name>
225 <cstring>TextLabel5</cstring>
226 </property>
227 <property stdset="1">
228 <name>text</name>
229 <string>Amount:</string>
230 </property>
231 </widget>
232 <widget row="2" column="5" rowspan="1" colspan="7" >
233 <class>QComboBox</class>
234 <item>
235 <property>
236 <name>text</name>
237 <string>Automobile</string>
238 </property>
239 </item>
240 <item>
241 <property>
242 <name>text</name>
243 <string>Bills</string>
244 </property>
245 </item>
246 <item>
247 <property>
248 <name>text</name>
249 <string>CDs</string>
250 </property>
251 </item>
252 <item>
253 <property>
254 <name>text</name>
255 <string>Clothing</string>
256 </property>
257 </item>
258 <item>
259 <property>
260 <name>text</name>
261 <string>Computer</string>
262 </property>
263 </item>
264 <item>
265 <property>
266 <name>text</name>
267 <string>DVDs</string>
268 </property>
269 </item>
270 <item>
271 <property>
272 <name>text</name>
273 <string>Eletronics</string>
274 </property>
275 </item>
276 <item>
277 <property>
278 <name>text</name>
279 <string>Entertainment</string>
280 </property>
281 </item>
282 <item>
283 <property>
284 <name>text</name>
285 <string>Food</string>
286 </property>
287 </item>
288 <item>
289 <property>
290 <name>text</name>
291 <string>Gasoline</string>
292 </property>
293 </item>
294 <item>
295 <property>
296 <name>text</name>
297 <string>Misc</string>
298 </property>
299 </item>
300 <item>
301 <property>
302 <name>text</name>
303 <string>Movies</string>
304 </property>
305 </item>
306 <item>
307 <property>
308 <name>text</name>
309 <string>Rent</string>
310 </property>
311 </item>
312 <item>
313 <property>
314 <name>text</name>
315 <string>Travel</string>
316 </property>
317 </item>
318 <property stdset="1">
319 <name>name</name>
320 <cstring>cmbCategory</cstring>
321 </property>
322 <property stdset="1">
323 <name>editable</name>
324 <bool>true</bool>
325 </property>
326 <property stdset="1">
327 <name>currentItem</name>
328 <number>0</number>
329 </property>
330 <property stdset="1">
331 <name>autoCompletion</name>
332 <bool>true</bool>
333 </property>
334 <property stdset="1">
335 <name>duplicatesEnabled</name>
336 <bool>false</bool>
337 </property>
338 </widget>
339 <widget row="4" column="0" rowspan="1" colspan="6" >
340 <class>QLabel</class>
341 <property stdset="1">
342 <name>name</name>
343 <cstring>TextLabel4</cstring>
344 </property>
345 <property stdset="1">
346 <name>text</name>
347 <string>Check Number:</string>
348 </property>
349 </widget>
350 <widget row="6" column="4" >
351 <class>QLabel</class>
352 <property stdset="1">
353 <name>name</name>
354 <cstring>TextLabel6_2</cstring>
355 </property>
356 <property stdset="1">
357 <name>font</name>
358 <font>
359 <family>adobe-helvetica</family>
360 <bold>1</bold>
361 </font>
362 </property>
363 <property stdset="1">
364 <name>text</name>
365 <string>$</string>
366 </property>
367 </widget>
368 <widget row="6" column="5" rowspan="1" colspan="4" >
369 <class>QRestrictedLine</class>
370 <property stdset="1">
371 <name>name</name>
372 <cstring>transFee</cstring>
373 </property>
374 </widget>
375 <widget row="6" column="0" rowspan="1" colspan="4" >
376 <class>QLabel</class>
377 <property stdset="1">
378 <name>name</name>
379 <cstring>TextLabel7</cstring>
380 </property>
381 <property stdset="1">
382 <name>text</name>
383 <string>Extra Fee:</string>
384 </property>
385 </widget>
386 <widget row="7" column="0" rowspan="1" colspan="8" >
387 <class>QLabel</class>
388 <property stdset="1">
389 <name>name</name>
390 <cstring>TextLabel8</cstring>
391 </property>
392 <property stdset="1">
393 <name>text</name>
394 <string>Additional Notes:</string>
395 </property>
396 </widget>
397 <widget row="1" column="5" rowspan="1" colspan="7" >
398 <class>QComboBox</class>
399 <property stdset="1">
400 <name>name</name>
401 <cstring>descriptionCombo</cstring>
402 </property>
403 <property stdset="1">
404 <name>editable</name>
405 <bool>true</bool>
406 </property>
407 <property stdset="1">
408 <name>maxCount</name>
409 <number>10</number>
410 </property>
411 <property stdset="1">
412 <name>insertionPolicy</name>
413 <enum>BeforeCurrent</enum>
414 </property>
415 <property stdset="1">
416 <name>autoCompletion</name>
417 <bool>true</bool>
418 </property>
419 <property stdset="1">
420 <name>duplicatesEnabled</name>
421 <bool>false</bool>
422 </property>
423 </widget>
424 <widget row="6" column="9" >
425 <class>QLabel</class>
426 <property stdset="1">
427 <name>name</name>
428 <cstring>TextLabel9</cstring>
429 </property>
430 <property stdset="1">
431 <name>minimumSize</name>
432 <size>
433 <width>0</width>
434 <height>0</height>
435 </size>
436 </property>
437 <property stdset="1">
438 <name>maximumSize</name>
439 <size>
440 <width>32767</width>
441 <height>32767</height>
442 </size>
443 </property>
444 <property stdset="1">
445 <name>caption</name>
446 <string></string>
447 </property>
448 <property stdset="1">
449 <name>text</name>
450 <string>Date:</string>
451 </property>
452 </widget>
453 <widget row="6" column="10" rowspan="1" colspan="2" >
454 <class>QRestrictedLine</class>
455 <property stdset="1">
456 <name>name</name>
457 <cstring>dateEdit</cstring>
458 </property>
459 </widget>
460 <widget row="4" column="7" rowspan="1" colspan="5" >
461 <class>QRestrictedLine</class>
462 <property stdset="1">
463 <name>name</name>
464 <cstring>checkNumber</cstring>
465 </property>
466 </widget>
467 <widget row="3" column="5" rowspan="1" colspan="7" >
468 <class>QComboBox</class>
469 <item>
470 <property>
471 <name>text</name>
472 <string>Debit Charge</string>
473 </property>
474 </item>
475 <item>
476 <property>
477 <name>text</name>
478 <string>Written Check</string>
479 </property>
480 </item>
481 <item>
482 <property>
483 <name>text</name>
484 <string>Transfer</string>
485 </property>
486 </item>
487 <item>
488 <property>
489 <name>text</name>
490 <string>Credit Card</string>
491 </property>
492 </item>
493 <property stdset="1">
494 <name>name</name>
495 <cstring>transType</cstring>
496 </property>
497 </widget>
498 <widget row="8" column="0" rowspan="1" colspan="12" >
499 <class>QMultiLineEdit</class>
500 <property stdset="1">
501 <name>name</name>
502 <cstring>additionalNotes</cstring>
503 </property>
504 </widget>
505 <widget row="0" column="0" rowspan="1" colspan="12" >
506 <class>QButtonGroup</class>
507 <property stdset="1">
508 <name>name</name>
509 <cstring>ButtonGroup3</cstring>
510 </property>
511 <property stdset="1">
512 <name>sizePolicy</name>
513 <sizepolicy>
514 <hsizetype>7</hsizetype>
515 <vsizetype>7</vsizetype>
516 </sizepolicy>
517 </property>
518 <property stdset="1">
519 <name>title</name>
520 <string></string>
521 </property>
522 <property>
523 <name>layoutMargin</name>
524 </property>
525 <property>
526 <name>layoutSpacing</name>
527 </property>
528 <grid>
529 <property stdset="1">
530 <name>margin</name>
531 <number>4</number>
532 </property>
533 <property stdset="1">
534 <name>spacing</name>
535 <number>0</number>
536 </property>
537 <widget row="0" column="1" >
538 <class>QRadioButton</class>
539 <property stdset="1">
540 <name>name</name>
541 <cstring>deposit</cstring>
542 </property>
543 <property stdset="1">
544 <name>sizePolicy</name>
545 <sizepolicy>
546 <hsizetype>1</hsizetype>
547 <vsizetype>1</vsizetype>
548 </sizepolicy>
549 </property>
550 <property stdset="1">
551 <name>text</name>
552 <string>Deposit</string>
553 </property>
554 </widget>
555 <widget row="0" column="0" >
556 <class>QRadioButton</class>
557 <property stdset="1">
558 <name>name</name>
559 <cstring>payment</cstring>
560 </property>
561 <property stdset="1">
562 <name>sizePolicy</name>
563 <sizepolicy>
564 <hsizetype>1</hsizetype>
565 <vsizetype>1</vsizetype>
566 </sizepolicy>
567 </property>
568 <property stdset="1">
569 <name>text</name>
570 <string>Payment</string>
571 </property>
572 <property stdset="1">
573 <name>checked</name>
574 <bool>true</bool>
575 </property>
576 </widget>
577 </grid>
578 </widget>
579 </grid>
580</widget>
581<customwidgets>
582 <customwidget>
583 <class>QRestrictedLine</class>
584 <header location="local">qrestrictedline.h</header>
585 <sizehint>
586 <width>-1</width>
587 <height>-1</height>
588 </sizehint>
589 <container>0</container>
590 <sizepolicy>
591 <hordata>5</hordata>
592 <verdata>5</verdata>
593 </sizepolicy>
594 <pixmap>image0</pixmap>
595 </customwidget>
596</customwidgets>
597<images>
598 <image>
599 <name>image0</name>
600 <data format="XPM.GZ" length="649">789c6dd23b0ec2300c00d03da7b0e22d42e9476c88232031222186c80c3074813220c4dd214dddd84dac0e759fe2386e1a07a7e3015c639e6318ef04740b0f70d7d730bccf97fdc7d8be87f8406737c62210606869dbb531f531a57f4a299d03a7e06c11cca1055508412c2889acc2ef425423b34840a645f28244936860d2c265d7923bae8b2f05cb35a91739002d2b5727d535cbe954a43ad1e22f700755caf7407cf4799fe286c47dbe3bf303014167a2</data>
601 </image>
602</images>
603<tabstops>
604 <tabstop>payment</tabstop>
605 <tabstop>descriptionCombo</tabstop>
606 <tabstop>cmbCategory</tabstop>
607 <tabstop>transType</tabstop>
608 <tabstop>additionalNotes</tabstop>
609</tabstops>
610</UI>
diff --git a/noncore/apps/checkbook/qcheckgraph.cpp b/noncore/apps/checkbook/qcheckgraph.cpp
deleted file mode 100644
index 5b21ad8..0000000
--- a/noncore/apps/checkbook/qcheckgraph.cpp
+++ b/dev/null
@@ -1,258 +0,0 @@
1#include "qcheckgraph.h"
2
3#include <qpainter.h>
4#include <qmessagebox.h>
5#include <qfontmetrics.h>
6#include <qdir.h>
7#include <qfile.h>
8#include <qstringlist.h>
9#include <qdatetime.h>
10#include <qmenubar.h>
11#include <qpopupmenu.h>
12
13QCheckGraph::QCheckGraph(const QString filename)
14 : QCheckGraphBase()
15{
16 QMenuBar *bar = new QMenuBar(this);
17 bar->setMargin(0);
18 QPopupMenu *popup = new QPopupMenu;
19 popup->insertItem("&Save Graph...", this, SLOT(saveGraphAsPicture()));
20 bar->insertItem("&File", popup);
21
22 pixmapready = false;
23 config = new Config(filename, Config::File);
24 QString forresult = "";
25 QString forresult2 = "";
26 int i = 1;
27 for (; forresult != "Not Found"; i++)
28 {
29 config->setGroup(QString::number(i));
30 forresult = config->readEntry("Description", QString("Not Found"));
31 forresult2 = config->readEntry("Category", QString("Not Found"));
32 if (forresult != "Not Found")
33 {
34 if (list.contains(forresult2) == 0)
35 {
36 config->setGroup("Totals");
37 QString larger = config->readEntry("Spent", QString("no"));
38 QString smaller = config->readEntry(forresult2, QString("no"));
39 if (larger != "no" && smaller != "no")
40 {
41 list << forresult2;
42 QString percentage = calculator(smaller, larger, true);
43
44 // Here we calculate how many pixels tall it will be by multiplying it by 200.
45 QString pixels = calculator(percentage, QString("200"), false);
46
47 // This is done because it really doesn't need to have a decimal... just an int, and
48 // QString rounds doubles up to the nearest whole number in order to convert
49 // to an int (which is correct).
50 pixels = pixels.remove(pixels.find('.'), pixels.length());
51
52 if (pixels.toInt() <= 5)
53 {
54 pixels = "6";
55 }
56
57 list2 << pixels;
58 }
59 }
60 } else {
61 continue;
62 }
63 // We want to break this loop on the 7th (remember, starts at 0->6 == 7) item.
64 if (list.count() == 6)
65 {
66 break;
67 }
68 }
69 for (QStringList::Iterator it = list.begin(); it != list.end(); it++)
70 {
71 if ((*it).length() > 11)
72 {
73 (*it).truncate(8);
74 (*it).append("...");
75 }
76 }
77 graphPixmap();
78}
79
80void QCheckGraph::graphPixmap()
81{
82 pixmapready = false;
83 graph = QPixmap(240,250);
84 QPainter p;
85 p.begin(&graph);
86 p.fillRect(0, 0, 240, 300, QColor(255,255,255));
87 // Draw the graph lines
88
89 // Y
90 p.drawLine( 40, 50, 40, 252 );
91
92 // X
93 p.drawLine( 40, 252, 203, 252 );
94
95 // Y stepup lines
96 p.drawLine( 40, 50, 37, 50);
97 p.drawLine( 40, 70, 37, 70);
98 p.drawLine( 40, 90, 37, 90);
99 p.drawLine( 40, 110, 37, 110);
100 p.drawLine( 40, 130, 37, 130);
101 p.drawLine( 40, 150, 37, 150);
102 p.drawLine( 40, 170, 37, 170);
103 p.drawLine( 40, 190, 37, 190);
104 p.drawLine( 40, 210, 37, 210);
105 p.drawLine( 40, 230, 37, 230);
106 p.drawLine( 40, 245, 37, 245);
107
108
109 // Y stepup values
110 p.drawText((35 - p.fontMetrics().width("100")), (50 + (p.fontMetrics().height() / 2)), "100");
111 p.drawText((35 - p.fontMetrics().width("90")), (70 + (p.fontMetrics().height() / 2)), "90");
112 p.drawText((35 - p.fontMetrics().width("80")), (90 + (p.fontMetrics().height() / 2)), "80");
113 p.drawText((35 - p.fontMetrics().width("70")), (110 + (p.fontMetrics().height() / 2)), "70");
114 p.drawText((35 - p.fontMetrics().width("60")), (130 + (p.fontMetrics().height() / 2)), "60");
115 p.drawText((35 - p.fontMetrics().width("50")), (150 + (p.fontMetrics().height() / 2)), "50");
116 p.drawText((35 - p.fontMetrics().width("40")), (170 + (p.fontMetrics().height() / 2)), "40");
117 p.drawText((35 - p.fontMetrics().width("30")), (190 + (p.fontMetrics().height() / 2)), "30");
118 p.drawText((35 - p.fontMetrics().width("20")), (210 + (p.fontMetrics().height() / 2)), "20");
119 p.drawText((35 - p.fontMetrics().width("10")), (230 + (p.fontMetrics().height() / 2)), "10");
120 p.drawText((35 - p.fontMetrics().width("<10")), (245 + (p.fontMetrics().height() / 2)), "<10");
121
122 // Draw the axis[sic?] labels
123 QString ylabel = "Percentage";
124 int pixel = 100;
125 for (unsigned int i = 0; i != ylabel.length(); i++)
126 {
127 p.setBrush(QColor(0,0,0));
128 p.drawText(5,pixel, QString(ylabel[i]));
129 pixel = pixel + p.fontMetrics().height();
130 }
131 p.drawText(95, 265, "Category");
132
133 int i = 0;
134 // Hack: Using if()'s... switch was acting all wierd :{
135 QStringList::Iterator it2 = list2.begin();
136 for (QStringList::Iterator it = list.begin(); it != list.end(); it++)
137 {
138 qWarning(QString::number(i));
139 if (i ==0)
140 {
141 // For the color code:
142 p.setBrush(QColor(255,0,0));
143 p.drawRect(8,12, 8, 8);
144
145 // Now the text:
146 p.setBrush(QColor(0,0,0));
147 p.drawText(18,20, (*it));
148
149 // Last, but not least, we have the actual bar graph height.
150 p.setBrush(QColor(255,0,0));
151 p.drawRect(47, ((202 - (*it2).toInt()) + 50), 15, (*it2).toInt());
152 }
153 if (i ==1)
154 {
155 p.setBrush(QColor(255,255,0));
156 p.drawRect(78,12, 8, 8);
157
158 p.setBrush(QColor(0,0,0));
159 p.drawText(88,20, (*it));
160
161 p.setBrush(QColor(255,255,0));
162 p.drawRect(70, ((202 - (*it2).toInt()) + 50), 15, (*it2).toInt());
163 }
164 if (i==2)
165 {
166 p.setBrush(QColor(0,255,0));
167 p.drawRect(153,12, 8, 8);
168 p.setBrush(QColor(0,0,0));
169 p.drawText(163,20, (*it));
170
171 p.setBrush(QColor(0,255,0));
172 p.drawRect(98, ((202 - (*it2).toInt()) + 50), 15, (*it2).toInt());
173 }
174 if (i==3)
175 {
176 p.setBrush(QColor(89,12,54));
177 p.drawRect(8,27, 8, 8);
178 p.setBrush(QColor(0,0,0));
179 p.drawText(18,35, (*it));
180
181 p.setBrush(QColor(89,12,54));
182 p.drawRect(126, ((202 - (*it2).toInt()) + 50), 15, (*it2).toInt());
183 }
184 if (i==4)
185 {
186 p.setBrush(QColor(0,0,255));
187 p.drawRect(78,27, 8, 8);
188 p.setBrush(QColor(0,0,0));
189 p.drawText(88,35, (*it));
190 p.setBrush(QColor(0,0,255));
191 p.drawRect(154, ((202 - (*it2).toInt()) + 50), 15, (*it2).toInt());
192 }
193 if (i==5)
194 {
195 p.setBrush(QColor(100,40,0));
196 p.drawRect(153,27, 8, 8);
197 p.setBrush(QColor(0,0,0));
198 p.drawText(163,35, (*it));
199 p.setBrush(QColor(100,40,0));
200 p.drawRect(182, ((202 - (*it2).toInt()) + 50), 15, (*it2).toInt());
201 }
202 i++;
203 it2++;
204 }
205
206 p.end();
207 pixmapready = true;
208 graphWidget->setBackgroundPixmap(graph);
209}
210
211QString QCheckGraph::calculator(QString largervalue, QString smallervalue, bool divide)
212{
213 //largervalue = largervalue.remove(largervalue.find(".", 0, false), 1);
214 //smallervalue = smallervalue.remove(smallervalue.find(".", 0, false), 1);
215
216 double largercents = largervalue.toDouble();
217 double smallercents = smallervalue.toDouble();
218
219 double finalammount = 0;
220
221 if (divide == true)
222 {
223 finalammount = (largercents / smallercents);
224 } else {
225 finalammount = (largercents * smallercents);
226 }
227
228 qWarning(QString::number(finalammount));
229
230 return QString::number(finalammount);
231}
232
233/*void QCheckGraph::paintEvent(QPaintEvent *e)
234{
235 if (pixmapready == true)
236 {
237 bitBlt((QPaintDevice *)(graphWidget), 0, 0, graph, 0,0);
238 QWidget::paintEvent(e);
239 }
240}
241*/
242void QCheckGraph::saveGraphAsPicture()
243{
244 QString homedir = QDir::homeDirPath();
245 QDate current = QDate::currentDate();
246 QString datestring = QString::number(current.month());
247 datestring.append(QString::number(current.day()));
248 datestring.append(QString::number(current.year()));
249 QString filename = homedir;
250 filename.append("/Documents/graph");
251 filename.append(datestring);
252 filename.append(".png");
253 graph.save(filename, "PNG", 85);
254 QString graphmessage = "<qt>The graph was saved as graph";
255 graphmessage.append(datestring);
256 graphmessage.append(".png. You may access it by returning to your home screen and clicking on the \"Documents\" tab in the upper right hand screen</qt>");
257 QMessageBox::information(0, "File Saved", graphmessage);
258}
diff --git a/noncore/apps/checkbook/qcheckgraph.h b/noncore/apps/checkbook/qcheckgraph.h
deleted file mode 100644
index 1cafef8..0000000
--- a/noncore/apps/checkbook/qcheckgraph.h
+++ b/dev/null
@@ -1,25 +0,0 @@
1#include <qstring.h>
2#include <qmainwindow.h>
3#include <qwidget.h>
4#include <qstringlist.h>
5#include <qpixmap.h>
6#include "config.h"
7
8#include "qcheckgraphbase.h"
9
10class QCheckGraph : public QCheckGraphBase
11{
12 Q_OBJECT
13 public:
14 QCheckGraph(const QString);
15 private:
16 QStringList list;
17 QStringList list2;
18 QString calculator(QString larger, QString smaller, bool divide);
19 QPixmap graph;
20 void graphPixmap();
21 bool pixmapready;
22 Config *config;
23 private slots:
24 void saveGraphAsPicture();
25};
diff --git a/noncore/apps/checkbook/qcheckgraphbase.ui b/noncore/apps/checkbook/qcheckgraphbase.ui
deleted file mode 100644
index 2763839..0000000
--- a/noncore/apps/checkbook/qcheckgraphbase.ui
+++ b/dev/null
@@ -1,62 +0,0 @@
1<!DOCTYPE UI><UI>
2<class>QCheckGraphBase</class>
3<widget>
4 <class>QDialog</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>QCheckGraphBase</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>236</width>
15 <height>285</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Account Graph</string>
21 </property>
22 <grid>
23 <property stdset="1">
24 <name>margin</name>
25 <number>0</number>
26 </property>
27 <property stdset="1">
28 <name>spacing</name>
29 <number>0</number>
30 </property>
31 <widget row="0" column="0" >
32 <class>QWidget</class>
33 <property stdset="1">
34 <name>name</name>
35 <cstring>graphWidget</cstring>
36 </property>
37 </widget>
38 </grid>
39</widget>
40<customwidgets>
41 <customwidget>
42 <class>QWidget</class>
43 <header location="global">qwidget.h</header>
44 <sizehint>
45 <width>-1</width>
46 <height>-1</height>
47 </sizehint>
48 <container>0</container>
49 <sizepolicy>
50 <hordata>5</hordata>
51 <verdata>5</verdata>
52 </sizepolicy>
53 <pixmap>image0</pixmap>
54 </customwidget>
55</customwidgets>
56<images>
57 <image>
58 <name>image0</name>
59 <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1ddec44f503c0ae2a154410f53d0ed20e2bf6bdb656dd6861dd23d9a66591b0587fd1654235ebded6f0edcd53e419d87ae7b1f4f9b8f906d0bfe012317426a70b07bdc2f3ec77f8ed6b89559061a0343d06a124cc105596482585094bc0ae599b04646c9018926491b2205e140c485cace25755c175d0a967b622ff900b8cc9c7d29af594ea722d589167f813aa852ba07d94b9dce296e883fe7bb163f23896753</data>
60 </image>
61</images>
62</UI>
diff --git a/noncore/apps/checkbook/qcheckmainmenu.cpp b/noncore/apps/checkbook/qcheckmainmenu.cpp
deleted file mode 100644
index 1aead88..0000000
--- a/noncore/apps/checkbook/qcheckmainmenu.cpp
+++ b/dev/null
@@ -1,105 +0,0 @@
1#include "qcheckmainmenu.h"
2#include "qcheckname.h"
3
4QCheckMainMenu::QCheckMainMenu(QWidget *parent)
5 : QCheckMMBase(parent)
6{
7 init();
8}
9
10void QCheckMainMenu::init()
11{
12 lstCheckBooks->clear();
13 QString checkdirname = QDir::homeDirPath();
14 checkdirname.append("/.checkbooks");
15 QDir checkdir(checkdirname);
16 if (checkdir.exists() == true)
17 {
18 QStringList checkbooks = checkdir.entryList("*.qcb", QDir::Files|QDir::Readable|QDir::Writable, QDir::Time);
19 for (QStringList::Iterator it = checkbooks.begin(); it != checkbooks.end(); it++)
20 {
21 (*it) = (*it).remove((*it).find('.'), (*it).length());
22 }
23 lstCheckBooks->insertStringList(checkbooks);
24 }
25 lstCheckBooks->clearSelection();
26 connect(lstCheckBooks, SIGNAL(clicked(QListBoxItem *)), this, SLOT(slotSelected(QListBoxItem *)));
27 lstCheckBooks->clearSelection();
28}
29
30void QCheckMainMenu::slotSelected(QListBoxItem *item)
31{
32 if (item != 0)
33 {
34 QString text = item->text();
35 if (text.isEmpty() == false)
36 {
37 text.append(".qcb");
38 QString checkdirname = QDir::homeDirPath();
39 checkdirname.append("/.checkbooks/");
40 text.prepend(checkdirname);
41 emit itemSelected(text);
42 }
43 }
44}
45
46void QCheckMainMenu::newClicked()
47{
48 QString checkname = QCheckName::getName();
49 if (checkname.isEmpty() == false)
50 {
51 QString checkdirname = QDir::homeDirPath();
52 checkdirname.append("/.checkbooks");
53 QDir checkdir(checkdirname);
54 if (checkdir.exists() == false)
55 {
56 checkdir.mkdir(checkdirname);
57 }
58 checkdirname.append("/");
59 checkdirname.append(checkname);
60 checkdirname.append(".qcb");
61 QFile file(checkdirname);
62 if (file.exists() == false)
63 {
64 file.open(IO_WriteOnly);
65 QTextStream os(&file);
66 os << "";
67 file.close();
68 }
69 QFileInfo fi(file);
70 QString noextension = fi.fileName();
71 noextension = noextension.remove(noextension.find('.'), noextension.length());
72 lstCheckBooks->insertItem(noextension);
73 }
74}
75
76void QCheckMainMenu::deleteClicked()
77{
78 QString checkname = lstCheckBooks->currentText();
79 if (checkname.isEmpty() == false) {
80 switch ( QMessageBox::warning(this,tr("Delete Account"),tr("Really delete the\n")
81 +checkname+tr(" account?")
82 ,tr("Yes"),tr("No"),0,1,1) ) {
83 case 0: {
84
85 QString checkdirname = QDir::homeDirPath();
86 checkdirname.append("/.checkbooks");
87 QDir checkdir(checkdirname);
88 QString checkDir=checkdirname;
89
90 checkdirname.append("/");
91 checkdirname.append(checkname);
92 checkdirname.append(".qcb");
93 QFile file(checkdirname);
94 if (file.exists() == true) {
95 if(!file.remove()) {
96 QMessageBox::message(tr("Checkbook"),tr("Could not remove account"));
97 return;
98 } else
99 lstCheckBooks->removeItem(lstCheckBooks->currentItem());
100 }
101 }
102 break;
103 }
104 }
105}
diff --git a/noncore/apps/checkbook/qcheckmainmenu.h b/noncore/apps/checkbook/qcheckmainmenu.h
deleted file mode 100644
index 24d601b..0000000
--- a/noncore/apps/checkbook/qcheckmainmenu.h
+++ b/dev/null
@@ -1,28 +0,0 @@
1#include <qwidget.h>
2#include <qtoolbutton.h>
3#include <qpopupmenu.h>
4#include <qfile.h>
5#include <qdir.h>
6#include <qtextstream.h>
7#include <qstring.h>
8#include <qlistbox.h>
9#include <qmessagebox.h>
10
11#include "qcheckmmbase.h"
12
13class QCheckMainMenu : public QCheckMMBase
14{
15 Q_OBJECT
16 public:
17 QCheckMainMenu(QWidget *);
18 signals:
19 void itemSelected(const QString &);
20 private:
21 void init();
22 private slots:
23 void slotSelected(QListBoxItem *);
24 public slots:
25 void newClicked();
26 void deleteClicked();
27};
28
diff --git a/noncore/apps/checkbook/qcheckmmbase.ui b/noncore/apps/checkbook/qcheckmmbase.ui
deleted file mode 100644
index efde990..0000000
--- a/noncore/apps/checkbook/qcheckmmbase.ui
+++ b/dev/null
@@ -1,80 +0,0 @@
1<!DOCTYPE UI><UI>
2<class>QCheckMMBase</class>
3<widget>
4 <class>QWidget</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>QCheckMMBase</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>256</width>
15 <height>311</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Main Menu</string>
21 </property>
22 <grid>
23 <property stdset="1">
24 <name>margin</name>
25 <number>7</number>
26 </property>
27 <property stdset="1">
28 <name>spacing</name>
29 <number>3</number>
30 </property>
31 <widget row="0" column="0" >
32 <class>QLabel</class>
33 <property stdset="1">
34 <name>name</name>
35 <cstring>TextLabel2</cstring>
36 </property>
37 <property stdset="1">
38 <name>text</name>
39 <string>Select from the check books below or click the "New" icon in the toolbar.</string>
40 </property>
41 <property stdset="1">
42 <name>alignment</name>
43 <set>WordBreak|AlignVCenter|AlignLeft</set>
44 </property>
45 <property>
46 <name>wordwrap</name>
47 </property>
48 </widget>
49 <widget row="1" column="0" >
50 <class>QListBox</class>
51 <property stdset="1">
52 <name>name</name>
53 <cstring>lstCheckBooks</cstring>
54 </property>
55 </widget>
56 </grid>
57</widget>
58<customwidgets>
59 <customwidget>
60 <class>QWidget</class>
61 <header location="global">qwidget.h</header>
62 <sizehint>
63 <width>-1</width>
64 <height>-1</height>
65 </sizehint>
66 <container>0</container>
67 <sizepolicy>
68 <hordata>5</hordata>
69 <verdata>5</verdata>
70 </sizepolicy>
71 <pixmap>image0</pixmap>
72 </customwidget>
73</customwidgets>
74<images>
75 <image>
76 <name>image0</name>
77 <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1ddec44f503c0ae2a154410f53d0ed20e2bf6bdb656dd6861dd23d9a66591b0587fd1654235ebded6f0edcd53e419d87ae7b1f4f9b8f906d0bfe012317426a70b07bdc2f3ec77f8ed6b89559061a0343d06a124cc105596482585094bc0ae599b04646c9018926491b2205e140c485cace25755c175d0a967b622ff900b8cc9c7d29af594ea722d589167f813aa852ba07d94b9dce296e883fe7bb163f23896753</data>
78 </image>
79</images>
80</UI>
diff --git a/noncore/apps/checkbook/qcheckname.cpp b/noncore/apps/checkbook/qcheckname.cpp
deleted file mode 100644
index 0e4d71c..0000000
--- a/noncore/apps/checkbook/qcheckname.cpp
+++ b/dev/null
@@ -1,36 +0,0 @@
1#include "qcheckname.h"
2#include <qmessagebox.h>
3#include <qdialog.h>
4#include <qpushbutton.h>
5#include <qlineedit.h>
6#include "qrestrictedline.h"
7
8QCheckName::QCheckName()
9 : QCheckNameBase()
10{
11 connect(cmdDone, SIGNAL(clicked()), this, SLOT(clicked()));
12}
13
14QString QCheckName::getName()
15{
16 QCheckName qcn;
17 qcn.setWFlags(Qt::WType_Modal);
18 qcn.leText->setValidChars("abcdefghijklmnopqrstuvwxyz0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ");
19 if (qcn.exec() == QDialog::Accepted)
20 {
21 return qcn.leText->text();
22 } else {
23 return QString("");
24 }
25}
26
27void QCheckName::clicked()
28{
29 if (leText->text().isEmpty() == false)
30 {
31 hide();
32 accept();
33 } else {
34 QMessageBox::critical(this, "Missing Information", "<qt>Please enter the name of your Check Book and try again.</qt>");
35 }
36}
diff --git a/noncore/apps/checkbook/qcheckname.h b/noncore/apps/checkbook/qcheckname.h
deleted file mode 100644
index c47c4f9..0000000
--- a/noncore/apps/checkbook/qcheckname.h
+++ b/dev/null
@@ -1,15 +0,0 @@
1#include "qchecknamebase.h"
2#include <qstring.h>
3#include <qwidget.h>
4
5class QCheckName : public QCheckNameBase
6{
7 Q_OBJECT
8 public:
9 QCheckName();
10 static QString getName();
11 private:
12 QWidget *m_parent;
13 private slots:
14 void clicked();
15};
diff --git a/noncore/apps/checkbook/qchecknamebase.cpp b/noncore/apps/checkbook/qchecknamebase.cpp
deleted file mode 100644
index 27bebc1..0000000
--- a/noncore/apps/checkbook/qchecknamebase.cpp
+++ b/dev/null
@@ -1,81 +0,0 @@
1/****************************************************************************
2** Form implementation generated from reading ui file 'qchecknamebase.ui'
3**
4** Created: Wed Sep 18 09:40:57 2002
5** by: The User Interface Compiler (uic)
6**
7** WARNING! All changes made in this file will be lost!
8****************************************************************************/
9#include "qchecknamebase.h"
10
11#include <qlabel.h>
12#include <qpushbutton.h>
13#include "qrestrictedline.h"
14#include <qlayout.h>
15#include <qvariant.h>
16#include <qtooltip.h>
17#include <qwhatsthis.h>
18
19/*
20 * Constructs a QCheckNameBase which is a child of 'parent', with the
21 * name 'name' and widget flags set to 'f'
22 *
23 * The dialog will by default be modeless, unless you set 'modal' to
24 * TRUE to construct a modal dialog.
25 */
26QCheckNameBase::QCheckNameBase( QWidget* parent, const char* name, bool modal, WFlags fl )
27 : QDialog( parent, name, modal, fl )
28{
29 if ( !name )
30 setName( "QCheckNameBase" );
31 resize( 228, 108 );
32 setCaption( tr( "Check Book Name" ) );
33
34 TextLabel3 = new QLabel( this, "TextLabel3" );
35 TextLabel3->setGeometry( QRect( 10, 5, 70, 16 ) );
36 QFont TextLabel3_font( TextLabel3->font() );
37 TextLabel3_font.setFamily( "BDF-helvetica" );
38 TextLabel3_font.setPointSize( 19 );
39 TextLabel3_font.setBold( TRUE );
40 TextLabel3->setFont( TextLabel3_font );
41 TextLabel3->setText( tr( "Name..." ) );
42
43 TextLabel4 = new QLabel( this, "TextLabel4" );
44 TextLabel4->setGeometry( QRect( 10, 25, 210, 25 ) );
45 TextLabel4->setText( tr( "Please name your check book.\n(limit: 15 characters):" ) );
46 TextLabel4->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter | QLabel::AlignLeft ) );
47
48 cmdDone = new QPushButton( this, "cmdDone" );
49 cmdDone->setGeometry( QRect( 75, 80, 75, 25 ) );
50 cmdDone->setText( tr( "&Done" ) );
51
52 leText = new QRestrictedLine( this, "leText" );
53 leText->setGeometry( QRect( 5, 51, 216, 25 ) );
54 leText->setFocus();
55}
56
57/*
58 * Destroys the object and frees any allocated resources
59 */
60QCheckNameBase::~QCheckNameBase()
61{
62 // no need to delete child widgets, Qt does it all for us
63}
64
65/*
66 * Main event handler. Reimplemented to handle application
67 * font changes
68 */
69bool QCheckNameBase::event( QEvent* ev )
70{
71 bool ret = QDialog::event( ev );
72 if ( ev->type() == QEvent::ApplicationFontChange ) {
73 QFont TextLabel3_font( TextLabel3->font() );
74 TextLabel3_font.setFamily( "BDF-helvetica" );
75 TextLabel3_font.setPointSize( 19 );
76 TextLabel3_font.setBold( TRUE );
77 TextLabel3->setFont( TextLabel3_font );
78 }
79 return ret;
80}
81
diff --git a/noncore/apps/checkbook/qchecknamebase.h b/noncore/apps/checkbook/qchecknamebase.h
deleted file mode 100644
index 864ecd6..0000000
--- a/noncore/apps/checkbook/qchecknamebase.h
+++ b/dev/null
@@ -1,38 +0,0 @@
1/****************************************************************************
2** Form interface generated from reading ui file 'qchecknamebase.ui'
3**
4** Created: Wed Sep 18 09:40:11 2002
5** by: The User Interface Compiler (uic)
6**
7** WARNING! All changes made in this file will be lost!
8****************************************************************************/
9#ifndef QCHECKNAMEBASE_H
10#define QCHECKNAMEBASE_H
11
12#include <qvariant.h>
13#include <qdialog.h>
14class QVBoxLayout;
15class QHBoxLayout;
16class QGridLayout;
17class QLabel;
18class QPushButton;
19class QRestrictedLine;
20
21class QCheckNameBase : public QDialog
22{
23 Q_OBJECT
24
25public:
26 QCheckNameBase( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
27 ~QCheckNameBase();
28
29 QLabel* TextLabel3;
30 QLabel* TextLabel4;
31 QPushButton* cmdDone;
32 QRestrictedLine* leText;
33
34protected:
35 bool event( QEvent* );
36};
37
38#endif // QCHECKNAMEBASE_H
diff --git a/noncore/apps/checkbook/qchecknamebase.ui b/noncore/apps/checkbook/qchecknamebase.ui
deleted file mode 100644
index b9bda19..0000000
--- a/noncore/apps/checkbook/qchecknamebase.ui
+++ b/dev/null
@@ -1,136 +0,0 @@
1<!DOCTYPE UI><UI>
2<class>QCheckNameBase</class>
3<widget>
4 <class>QDialog</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>QCheckNameBase</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>228</width>
15 <height>108</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Check Book Name</string>
21 </property>
22 <widget>
23 <class>QLabel</class>
24 <property stdset="1">
25 <name>name</name>
26 <cstring>TextLabel3</cstring>
27 </property>
28 <property stdset="1">
29 <name>geometry</name>
30 <rect>
31 <x>10</x>
32 <y>5</y>
33 <width>70</width>
34 <height>16</height>
35 </rect>
36 </property>
37 <property stdset="1">
38 <name>font</name>
39 <font>
40 <family>BDF-helvetica</family>
41 <pointsize>19</pointsize>
42 <bold>1</bold>
43 </font>
44 </property>
45 <property stdset="1">
46 <name>text</name>
47 <string>Name...</string>
48 </property>
49 </widget>
50 <widget>
51 <class>QLabel</class>
52 <property stdset="1">
53 <name>name</name>
54 <cstring>TextLabel4</cstring>
55 </property>
56 <property stdset="1">
57 <name>geometry</name>
58 <rect>
59 <x>10</x>
60 <y>25</y>
61 <width>210</width>
62 <height>25</height>
63 </rect>
64 </property>
65 <property stdset="1">
66 <name>text</name>
67 <string>Please name your check book (limit: 15 characters):</string>
68 </property>
69 <property stdset="1">
70 <name>alignment</name>
71 <set>WordBreak|AlignVCenter|AlignLeft</set>
72 </property>
73 <property>
74 <name>wordwrap</name>
75 </property>
76 </widget>
77 <widget>
78 <class>QPushButton</class>
79 <property stdset="1">
80 <name>name</name>
81 <cstring>cmdDone</cstring>
82 </property>
83 <property stdset="1">
84 <name>geometry</name>
85 <rect>
86 <x>75</x>
87 <y>80</y>
88 <width>75</width>
89 <height>25</height>
90 </rect>
91 </property>
92 <property stdset="1">
93 <name>text</name>
94 <string>&amp;Done</string>
95 </property>
96 </widget>
97 <widget>
98 <class>QRestrictedLine</class>
99 <property stdset="1">
100 <name>name</name>
101 <cstring>leText</cstring>
102 </property>
103 <property stdset="1">
104 <name>geometry</name>
105 <rect>
106 <x>5</x>
107 <y>51</y>
108 <width>216</width>
109 <height>25</height>
110 </rect>
111 </property>
112 </widget>
113</widget>
114<customwidgets>
115 <customwidget>
116 <class>QRestrictedLine</class>
117 <header location="local">qrestrictedline.h</header>
118 <sizehint>
119 <width>-1</width>
120 <height>-1</height>
121 </sizehint>
122 <container>0</container>
123 <sizepolicy>
124 <hordata>5</hordata>
125 <verdata>5</verdata>
126 </sizepolicy>
127 <pixmap>image0</pixmap>
128 </customwidget>
129</customwidgets>
130<images>
131 <image>
132 <name>image0</name>
133 <data format="XPM.GZ" length="649">789c6dd23b0ec2300c00d03da7b0e22d42e9476c88232031222186c80c3074813220c4dd214dddd84dac0e759fe2386e1a07a7e3015c639e6318ef04740b0f70d7d730bccf97fdc7d8be87f8406737c62210606869dbb531f531a57f4a299d03a7e06c11cca1055508412c2889acc2ef425423b34840a645f28244936860d2c265d7923bae8b2f05cb35a91739002d2b5727d535cbe954a43ad1e22f700755caf7407cf4799fe286c47dbe3bf303014167a2</data>
134 </image>
135</images>
136</UI>
diff --git a/noncore/apps/checkbook/qcheckview.cpp b/noncore/apps/checkbook/qcheckview.cpp
deleted file mode 100644
index ddc3fa9..0000000
--- a/noncore/apps/checkbook/qcheckview.cpp
+++ b/dev/null
@@ -1,458 +0,0 @@
1#include "qcheckview.h"
2
3#include <qpe/resource.h>
4#include <qregexp.h>
5#include <qlineedit.h>
6#include <qradiobutton.h>
7#include <qcombobox.h>
8#include <qapplication.h>
9#include <qpushbutton.h>
10#include <qdir.h>
11#include <qlabel.h>
12#include <qdatetime.h>
13#include <qmessagebox.h>
14#include <qcheckbox.h>
15#include <qfile.h>
16#include <qtextstream.h>
17#include <qbuttongroup.h>
18#include <qradiobutton.h>
19#include <qheader.h>
20
21QCheckView::QCheckView(QWidget *parent, QString filename)
22 : QCheckViewBase(parent)
23{
24 tblTransactions->setHScrollBarMode( QTable::AlwaysOff );
25 tblTransactions->setNumRows( 0 );
26 tblTransactions->setNumCols( 4 );
27 tblTransactions->setShowGrid( FALSE );
28 tblTransactions->horizontalHeader()->setLabel(0, "Num", 29);
29 tblTransactions->horizontalHeader()->setLabel(1, "Description", 81);
30 tblTransactions->horizontalHeader()->setLabel(2, "Date", 57);
31 tblTransactions->horizontalHeader()->setLabel(3, "Amount", 59);
32 tblTransactions->verticalHeader()->hide();
33 tblTransactions->setLeftMargin( 0 );
34 tblTransactions->setSelectionMode(QTable::NoSelection);
35
36 m_filename = filename;
37 load(filename);
38}
39
40void QCheckView::deleteClicked(int row, int col)
41{
42 QStringList existing;
43 QString rowText = tblTransactions->text(row, 0);
44 config->setGroup(rowText);
45 QString originalamount = config->readEntry("Amount", "0.00");
46
47 config->setGroup("Data");
48 int lastCheck = config->readNumEntry("LastCheck", 0);
49
50 qWarning(rowText);
51 config->setGroup(rowText);
52 QString payment = config->readEntry("Payment", "true");
53 if ( payment == QString("true") && rowText.toInt() <= lastCheck)
54 {
55 for(int i = row; i != (lastCheck); i++)
56 {
57 config->setGroup(tblTransactions->text(i, 0));
58 QString ibalance = config->readEntry("Balance", "0.00");
59 // this adds the old amount on to the transaction and then takes the new amount away
60 QString newbalance = calculator(ibalance, originalamount, false);
61 config->writeEntry("Balance", newbalance);
62
63 if (i == (lastCheck - 1))
64 {
65 config->setGroup("Totals");
66 config->writeEntry("Balance", newbalance);
67 break;
68 }
69 }
70 QString category = config->readEntry("Category", "Error");
71 if (category != QString("Error"))
72 {
73 config->setGroup("Totals");
74 config->writeEntry("Spent", calculator(config->readEntry("Spent", QString("0")), originalamount, true));
75 QString categorytotal = config->readEntry(category, QString("0"));
76 categorytotal = calculator(categorytotal, originalamount, true);
77 config->writeEntry(category, categorytotal);
78 }
79 }
80 if ( payment == QString("false") && rowText.toInt() <= lastCheck)
81 {
82 for(int i = row; i != (lastCheck); i++)
83 {
84 config->setGroup(tblTransactions->text(i, 0));
85 QString ibalance = config->readEntry("Balance", "0.00");
86 // this subtracts the old amount on to the transaction and then adds the new amount on
87 QString newbalance = calculator(ibalance, originalamount, true);
88 config->writeEntry("Balance", newbalance);
89
90 if (i == lastCheck - 1)
91 {
92 config->setGroup("Totals");
93 config->writeEntry("Balance", newbalance);
94 break;
95 }
96 }
97 config->setGroup("Totals");
98 config->writeEntry("Deposited", calculator(config->readEntry("Deposited", QString("0")), originalamount, true));
99 }
100 for (int i = rowText.toInt(); i != lastCheck; i++)
101 {
102 qWarning(QString::number(i +1));
103 config->setGroup(QString::number(i +1));
104 QString origamount = config->readEntry("Amount", "0");
105 qWarning(origamount);
106 QString origbalance = config->readEntry("Balance", "0");
107 QString origchecknumber = config->readEntry("CheckNumber", "0");
108 QString origcomments = config->readEntry("Comments", "");
109 QString origdate = config->readEntry("Date", "01/01/2000");
110 QString origdescription = config->readEntry("Description", "No Description");
111 QString origpayment = config->readEntry("Payment", "true");
112 QString origtransactionfee = config->readEntry("TransactionFee", "0");
113 QString origtype = config->readEntry("Type", "0");
114
115 if (config->hasKey("Category"))
116 {
117 QString origcategory = config->readEntry("Category", "No Category");
118 config->removeGroup();
119 config->setGroup(QString::number(i));
120 config->clearGroup();
121 config->writeEntry("Category", origcategory);
122 } else {
123 config->removeGroup();
124 config->setGroup(QString::number(i));
125 config->clearGroup();
126 }
127 config->writeEntry("Amount", origamount);
128 config->writeEntry("Balance", origbalance);
129 config->writeEntry("CheckNumber", origchecknumber);
130 config->writeEntry("Comments", origcomments);
131 config->writeEntry("Date", origdate);
132 config->writeEntry("Description", origdescription);
133 config->writeEntry("Payment", origpayment);
134 config->writeEntry("TransactionFee", origtransactionfee);
135 config->writeEntry("Type", origtype);
136 }
137 tblTransactions->clearCell(row, col);
138 labelBalance->setText(QString("$" + config->readEntry("Balance", QString("0.00"))));
139 config->setGroup("Data");
140 config->writeEntry("LastCheck", QString::number(QString(config->readEntry("LastCheck", 0)).toInt() -1));
141 config->write();
142 delete qcd;
143 emit reload(m_filename);
144
145}
146
147void QCheckView::load(const QString filename)
148{
149 config = new Config(filename, Config::File);
150
151 connect(tblTransactions, SIGNAL(clicked(int, int, int, const QPoint &)), this, SLOT(tableClicked(int, int, int, const QPoint &)));
152
153 config->setGroup("Totals");
154 labelBalance->setText(QString("$" + config->readEntry("Balance", QString("0.00"))));
155
156 config->setGroup("Data");
157 int lastCheck = config->readNumEntry("LastCheck", 1);
158 for (int i = 1; i != (lastCheck + 1); i++)
159 {
160 config->setGroup(QString::number(i));
161 QString item = config->readEntry("Description", QString("Not Found"));
162 if (item != "Not Found")
163 {
164 QTableItem *qti = new QTableItem(tblTransactions, QTableItem::Never, QString::number(i));
165 QTableItem *qti1 = new QTableItem(tblTransactions, QTableItem::Never, config->readEntry("Description", QString("None")));
166 QTableItem *qti2 = new QTableItem(tblTransactions, QTableItem::Never, config->readEntry("Date", QString("None")));
167 QTableItem *qti3 = new QTableItem(tblTransactions, QTableItem::Never, QString("$" + config->readEntry("Amount", QString("0.00"))));
168 int row = tblTransactions->numRows();
169 tblTransactions->setNumRows(row + 1);
170 tblTransactions->setItem(row,0, qti);
171 tblTransactions->setItem(row,1, qti1);
172 tblTransactions->setItem(row,2, qti2);
173 tblTransactions->setItem(row,3, qti3);
174 tblTransactions->updateCell(row, 0);
175 tblTransactions->updateCell(row, 1);
176 tblTransactions->updateCell(row, 2);
177 tblTransactions->updateCell(row, 3);
178 }
179 }
180}
181
182void QCheckView::editClicked(int row, int col)
183{
184 delete qcd;
185 QStringList existing;
186 QString rowText = tblTransactions->text(row, 0);
187 config->setGroup("Data");
188 QString recent = config->readEntry("Recent", "");
189
190 config->setGroup(rowText);
191 //We need the original amount to add or subtract to check's blanaces written after this edited check
192 QString originalamount = config->readEntry("Amount", "0.00");
193 QString originalcategory = config->readEntry("Category", "None");
194
195 existing << config->readEntry("Payment", "true") << config->readEntry("Description", "No Description Found") << config->readEntry("Category", "Misc.") << config->readEntry("Type", "0") << config->readEntry("CheckNumber", "0") << originalamount << config->readEntry("TransactionFee", "") << config->readEntry("Date", "01/01/2001") << config->readEntry("Comments", "") << recent;
196 QStringList result = QCheckEntry::popupEntry(existing);
197 if (result.isEmpty() == false)
198 {
199 config->setGroup("Data");
200 int lastCheck = config->readNumEntry("LastCheck", 0);
201 config->writeEntry("Recent", result[9]);
202
203 config->setGroup(rowText);
204
205 tblTransactions->setText(row, 1, result[1]);
206 tblTransactions->updateCell(row, 1);
207
208 tblTransactions->setText(row, 2, result[7]);
209 tblTransactions->updateCell(row, 2);
210
211 tblTransactions->setText(row, 3, QString("$" + result[5]));
212 tblTransactions->updateCell(row, 3);
213
214 // This is how the list looks:
215 // 0: true or false, true == payment, false == deposit
216 // 1: description of the transaction
217 // 2: category name
218 // 3: transaction type (stores the integer value of the index of the combobox)
219 // 4: check number of the transaction (if any)
220 // 5: transaction amount
221 // 6: transaction fee (e.g. service charge, or ATM charge).
222 // 7: date of the transaction
223 // 8: additional comments
224 config->writeEntry("Payment", result[0]);
225 config->writeEntry("Description", result[1]);
226 if (result[0] == QString("true"))
227 {
228 config->writeEntry("Category", result[2]);
229 }
230 config->writeEntry("Type", result[3]);
231 config->writeEntry("CheckNumber", result[4]);
232 config->writeEntry("Amount", result[5]);
233 config->writeEntry("TransactionFee", result[6]);
234 config->writeEntry("Date", result[7]);
235 config->writeEntry("Comments", result[8]);
236 if (result[0] == QString("true"))
237 {
238 if (rowText.toInt() <= lastCheck)
239 {
240 for(int i = (rowText.toInt() - 1); i != (lastCheck); i++)
241 {
242 config->setGroup(tblTransactions->text(i, 0));
243 QString ibalance = config->readEntry("Balance", "0.00");
244
245 // this adds the old amount on to the transaction and then takes the new amount away
246 QString newbalance = calculator(calculator(ibalance, originalamount, false), result[5], true);
247 config->writeEntry("Balance", newbalance);
248 if (i == (lastCheck - 1))
249 {
250 config->setGroup("Totals");
251 config->writeEntry("Balance", newbalance);
252 break;
253 }
254 }
255 }
256 config->setGroup("Totals");
257 config->writeEntry("Spent", calculator(config->readEntry("Spent", QString("0")), originalamount, true));
258 config->writeEntry("Spent", calculator(config->readEntry("Spent", QString("0")), result[5], false));
259
260 if (result[2] == originalcategory)
261 {
262 QString categorytotal = config->readEntry(result[2], QString("0"));
263 categorytotal = calculator(categorytotal, originalamount, true);
264 categorytotal = calculator(categorytotal, result[5], false);
265 config->writeEntry(result[2], categorytotal);
266 } else {
267 QString origtotal = config->readEntry(originalcategory, QString("0"));
268 QString origfinal = calculator(origtotal, result[5], true);
269 if (origfinal == "0" || origfinal == "0.00")
270 {
271 config->removeEntry(originalcategory);
272 } else {
273 config->writeEntry(originalcategory, origfinal);
274 }
275 QString categorytotal = config->readEntry(result[2], QString("0"));
276 categorytotal = calculator(categorytotal, originalamount, false);
277 config->writeEntry(result[2],categorytotal);
278 }
279 }
280 if (result[0] == QString("false"))
281 {
282 if (rowText.toInt() <= lastCheck)
283 {
284 for(int i = (rowText.toInt() - 1 ); i != (lastCheck); i++)
285 {
286 config->setGroup(tblTransactions->text(i, 0));
287 QString ibalance = config->readEntry("Balance", "0.00");
288
289 // this subtracts the old amount on to the transaction and then adds the new amount on
290 QString newbalance = calculator(calculator(ibalance, originalamount, true), result[5], false);
291 config->writeEntry("Balance", newbalance);
292 if (i == lastCheck - 1)
293 {
294 config->setGroup("Totals");
295 config->writeEntry("Balance", newbalance);
296 break;
297 }
298 }
299 }
300 config->setGroup("Totals");
301 config->writeEntry("Deposited", calculator(config->readEntry("Deposited", QString("0")), originalamount, true));
302 config->writeEntry("Deposited", calculator(config->readEntry("Deposited", QString("0")), result[5], false));
303 }
304 labelBalance->setText(QString("$" + config->readEntry("Balance", QString("0.00"))));
305 config->write();
306 }
307}
308void QCheckView::tableClicked(int row, int col, int mouseButton, const QPoint &mousePos)
309{
310 if (tblTransactions->text(row, col).isEmpty() == false)
311 {
312 QStringList existing;
313 config->setGroup(tblTransactions->text(row, 0));
314 existing << config->readEntry("Payment", "true") << config->readEntry("Description", "No Description Found") << config->readEntry("Category", "Misc.") << config->readEntry("Type", "0") << config->readEntry("CheckNumber", "0") << config->readEntry("Amount", "0.00") << config->readEntry("TransactionFee", "0.00") << config->readEntry("Date", "01/01/2001") << config->readEntry("Comments", "") << config->readEntry("Balance", "0.00");
315 qcd = new QCheckDetails(row, col, existing);
316 qcd->showMaximized();
317 connect(qcd, SIGNAL(editClicked(int, int)), this, SLOT(editClicked(int, int)));
318 connect(qcd, SIGNAL(deleteClicked(int, int)), this, SLOT(deleteClicked(int, int)));
319 }
320}
321
322void QCheckView::newClicked()
323{
324 config->setGroup("Data");
325 QString recent = config->readEntry("Recent", "");
326 QStringList kindablank;
327 kindablank << recent;
328 QStringList result = QCheckEntry::popupEntry(kindablank);
329 if (result.count() > 1)
330 {
331 QTableItem *qti = new QTableItem(tblTransactions, QTableItem::Never, result[1]);
332 int row = tblTransactions->numRows();
333 tblTransactions->setNumRows(row + 1);
334 tblTransactions->setItem(row,1, qti);
335 tblTransactions->updateCell(row, 1);
336 config->setGroup("Data");
337 config->writeEntry("Recent", result[9]);
338 int lastCheck = config->readNumEntry("LastCheck", 0);
339 if (lastCheck == 0)
340 {
341 config->writeEntry("LastCheck", 1);
342 } else {
343 config->writeEntry("LastCheck", (lastCheck + 1));
344 }
345 QString number = QString::number(lastCheck + 1);
346 config->setGroup(number);
347
348 QTableItem *qti1 = new QTableItem(tblTransactions, QTableItem::Never, number);
349 tblTransactions->setItem(row, 0, qti1);
350 tblTransactions->updateCell(row, 0);
351
352 QTableItem *qti2 = new QTableItem(tblTransactions, QTableItem::Never, result[7]);
353 tblTransactions->setItem(row, 2, qti2);
354 tblTransactions->updateCell(row, 2);
355
356 QTableItem *qti3 = new QTableItem(tblTransactions, QTableItem::Never, QString("$" + result[5]));
357 tblTransactions->setItem(row, 3, qti3);
358 tblTransactions->updateCell(row, 3);
359
360 // This is how the list looks:
361 // 0: true or false, true == payment, false == deposit
362 // 1: description of the transaction
363 // 2: category name
364 // 3: transaction type (stores the integer value of the index of the combobox)
365 // 4: check number of the transaction (if any)
366 // 5: transaction amount
367 // 6: transaction fee (e.g. service charge, or ATM charge).
368 // 7: date of the transaction
369 config->writeEntry("Payment", result[0]);
370 config->writeEntry("Description", result[1]);
371 if (result[0] == QString("true"))
372 {
373 config->writeEntry("Category", result[2]);
374 }
375 config->writeEntry("Type", result[3]);
376 config->writeEntry("CheckNumber", result[4]);
377 config->writeEntry("Amount", result[5]);
378 config->writeEntry("TransactionFee", result[6]);
379 config->writeEntry("Date", result[7]);
380 config->writeEntry("Comments", result[8]);
381 config->setGroup("Totals");
382 if (result[0] == QString("true"))
383 {
384 QString totalspent = config->readEntry("Spent", QString("0"));
385 totalspent = calculator(totalspent, result[5], false);
386 config->writeEntry("Spent", totalspent);
387 QString balance = config->readEntry("Balance", QString("0"));
388 balance = calculator(balance, result[5], true);
389
390 // Make sure to add the fee on, if any
391 balance = calculator(balance, result[6], true);
392
393 config->writeEntry("Balance", balance);
394
395 config->setGroup(number);
396 config->writeEntry("Balance", balance);
397
398 config->setGroup("Totals");
399 QString categorytotal = config->readEntry(result[2], QString("0"));
400 categorytotal = calculator(categorytotal, result[5], false);
401 config->writeEntry(result[2], categorytotal);
402 }
403 if (result[0] == QString("false"))
404 {
405 QString totaldeposited = config->readEntry("Deposited", QString("0"));
406 totaldeposited = calculator(totaldeposited, result[5], false);
407 config->writeEntry("Deposited", totaldeposited);
408 QString balance = config->readEntry("Balance", QString("0"));
409 balance = calculator(balance, result[5], false);
410
411 // Make sure to add the fee on, if any
412 balance = calculator(balance, result[6], true);
413
414 config->writeEntry("Balance", balance);
415
416 config->setGroup(number);
417 config->writeEntry("Balance", balance);
418 }
419 }
420 config->setGroup("Totals");
421 labelBalance->setText(QString("$" + config->readEntry("Balance", QString("0.00"))));
422 config->write();
423}
424
425QString QCheckView::calculator(QString largervalue, QString smallervalue, bool subtract)
426{
427 // This class provides a way to eliminate the ARM processor problem of not being able to handle
428 // decimals. I just take the two QString'ed numbers and find the decimal point, then I remove the decimal
429 // point seperating the number into two. Then I convert it to cents (times it times 100) and add/
430 // substract the two together. Put the decimals back in, and return.
431
432 largervalue = largervalue.remove(largervalue.find(".", 0, false), 1);
433 smallervalue = smallervalue.remove(smallervalue.find(".", 0, false), 1);
434
435 int largercents = largervalue.toInt();
436 int smallercents = smallervalue.toInt();
437
438 int finalammount = 0;
439
440 if (subtract == true)
441 {
442 finalammount = largercents - smallercents;
443 } else {
444 finalammount = largercents + smallercents;
445 }
446
447 QString returnvalue = QString::number(finalammount);
448 if (returnvalue.length() >= 2)
449 {
450 returnvalue.insert((returnvalue.length() - 2), ".");
451 } else {
452 if (returnvalue.length() == 1)
453 {
454 returnvalue.prepend("0.0");
455 }
456 }
457 return returnvalue;
458}
diff --git a/noncore/apps/checkbook/qcheckview.h b/noncore/apps/checkbook/qcheckview.h
deleted file mode 100644
index 840dc8b..0000000
--- a/noncore/apps/checkbook/qcheckview.h
+++ b/dev/null
@@ -1,33 +0,0 @@
1#include "qcheckviewbase.h"
2#include "qrestrictedline.h"
3#include "qcheckentry.h"
4#include "qcheckdetails.h"
5
6#include <qstring.h>
7#include "config.h"
8#include <qtable.h>
9#include <qpoint.h>
10#include <qlayout.h>
11
12class QCheckView : public QCheckViewBase
13{
14 Q_OBJECT
15 public:
16 QCheckView(QWidget *, QString filename);
17 void load(const QString filename);
18 private:
19 Config *config;
20 QString calculator(QString largervalue, QString smallervalue, bool subtract);
21 int lastSortCol;
22 bool ascend;
23 QCheckDetails *qcd;
24 QString m_filename;
25 private slots:
26 // void entryActivated(int);
27 void newClicked();
28 void tableClicked(int, int, int, const QPoint &mousePos);
29 void editClicked(int, int);
30 void deleteClicked(int, int);
31 signals:
32 void reload(const QString &filename);
33};
diff --git a/noncore/apps/checkbook/qcheckviewbase.ui b/noncore/apps/checkbook/qcheckviewbase.ui
deleted file mode 100644
index 00ed7dd..0000000
--- a/noncore/apps/checkbook/qcheckviewbase.ui
+++ b/dev/null
@@ -1,122 +0,0 @@
1<!DOCTYPE UI><UI>
2<class>QCheckViewBase</class>
3<widget>
4 <class>QWidget</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>QCheckViewBase</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>242</width>
15 <height>312</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Account Transactions</string>
21 </property>
22 <grid>
23 <property stdset="1">
24 <name>margin</name>
25 <number>5</number>
26 </property>
27 <property stdset="1">
28 <name>spacing</name>
29 <number>1</number>
30 </property>
31 <widget row="0" column="1" >
32 <class>QLabel</class>
33 <property stdset="1">
34 <name>name</name>
35 <cstring>labelBalance</cstring>
36 </property>
37 <property stdset="1">
38 <name>frameShape</name>
39 <enum>MShape</enum>
40 </property>
41 <property stdset="1">
42 <name>frameShadow</name>
43 <enum>MShadow</enum>
44 </property>
45 <property stdset="1">
46 <name>text</name>
47 <string>$0.00</string>
48 </property>
49 <property stdset="1">
50 <name>alignment</name>
51 <set>AlignCenter</set>
52 </property>
53 <property>
54 <name>hAlign</name>
55 </property>
56 </widget>
57 <widget row="1" column="0" rowspan="1" colspan="2" >
58 <class>QTable</class>
59 <property stdset="1">
60 <name>name</name>
61 <cstring>tblTransactions</cstring>
62 </property>
63 <property stdset="1">
64 <name>hScrollBarMode</name>
65 <enum>AlwaysOff</enum>
66 </property>
67 <property stdset="1">
68 <name>numRows</name>
69 <number>0</number>
70 </property>
71 <property stdset="1">
72 <name>numCols</name>
73 <number>4</number>
74 </property>
75 <property stdset="1">
76 <name>showGrid</name>
77 <bool>false</bool>
78 </property>
79 </widget>
80 <widget row="0" column="0" >
81 <class>QLabel</class>
82 <property stdset="1">
83 <name>name</name>
84 <cstring>TextLabel3</cstring>
85 </property>
86 <property stdset="1">
87 <name>text</name>
88 <string>Balance:</string>
89 </property>
90 <property stdset="1">
91 <name>alignment</name>
92 <set>AlignVCenter|AlignRight</set>
93 </property>
94 <property>
95 <name>hAlign</name>
96 </property>
97 </widget>
98 </grid>
99</widget>
100<customwidgets>
101 <customwidget>
102 <class>QWidget</class>
103 <header location="global">qwidget.h</header>
104 <sizehint>
105 <width>-1</width>
106 <height>-1</height>
107 </sizehint>
108 <container>0</container>
109 <sizepolicy>
110 <hordata>5</hordata>
111 <verdata>5</verdata>
112 </sizepolicy>
113 <pixmap>image0</pixmap>
114 </customwidget>
115</customwidgets>
116<images>
117 <image>
118 <name>image0</name>
119 <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1ddec44f503c0ae2a154410f53d0ed20e2bf6bdb656dd6861dd23d9a66591b0587fd1654235ebded6f0edcd53e419d87ae7b1f4f9b8f906d0bfe012317426a70b07bdc2f3ec77f8ed6b89559061a0343d06a124cc105596482585094bc0ae599b04646c9018926491b2205e140c485cace25755c175d0a967b622ff900b8cc9c7d29af594ea722d589167f813aa852ba07d94b9dce296e883fe7bb163f23896753</data>
120 </image>
121</images>
122</UI>
diff --git a/noncore/apps/checkbook/qrestrictedcombo.cpp b/noncore/apps/checkbook/qrestrictedcombo.cpp
deleted file mode 100644
index e1533f6..0000000
--- a/noncore/apps/checkbook/qrestrictedcombo.cpp
+++ b/dev/null
@@ -1,78 +0,0 @@
1/*
2 *
3 * $Id$
4 *
5 * Implementation of QRestrictedCombo
6 *
7 * Copyright (C) 1997 Michael Wiedmann, <mw@miwie.in-berlin.de>
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
18 *
19 * You should have received a copy of the GNU Library General Public
20 * License along with this library; if not, write to the Free
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 */
24
25#include <qkeycode.h>
26
27#include "qrestrictedcombo.h"
28
29QRestrictedCombo::QRestrictedCombo( QWidget *parent,
30 const char *name,
31 const QString& valid )
32 : QComboBox( parent, name )
33{
34 qsValidChars = valid;
35}
36
37QRestrictedCombo::~QRestrictedCombo()
38{
39 ;
40}
41
42
43void QRestrictedCombo::keyPressEvent( QKeyEvent *e )
44{
45 // let QLineEdit process "special" keys and return/enter
46 // so that we still can use the default key binding
47 if (e->key() == Key_Enter || e->key() == Key_Return || e->key() == Key_Delete || e->ascii() < 32)
48 {
49 QComboBox::keyPressEvent(e);
50 return;
51 }
52
53 // do we have a list of valid chars &&
54 // is the pressed key in the list of valid chars?
55 if (!qsValidChars.isEmpty() && !qsValidChars.contains(e->ascii()))
56 {
57 // invalid char, emit signal and return
58 emit (invalidChar(e->key()));
59 return;
60 }
61 else
62 // valid char: let QLineEdit process this key as usual
63 QComboBox::keyPressEvent(e);
64
65 return;
66}
67
68
69void QRestrictedCombo::setValidChars( const QString& valid)
70{
71 qsValidChars = valid;
72}
73
74QString QRestrictedCombo::validChars() const
75{
76 return qsValidChars;
77}
78
diff --git a/noncore/apps/checkbook/qrestrictedcombo.h b/noncore/apps/checkbook/qrestrictedcombo.h
deleted file mode 100644
index 50ea59f..0000000
--- a/noncore/apps/checkbook/qrestrictedcombo.h
+++ b/dev/null
@@ -1,96 +0,0 @@
1/*
2 *
3 * Definition of QRestrictedCombo
4 *
5 * Copyright (C) 1997 Michael Wiedmann, <mw@miwie.in-berlin.de>
6 *
7 * Edited 2001 by Nick Betcher <nbetcher@usinternet.com> to work
8 * with Qt-only. Changed class name from LRestrictedLine to
9 * QRestrictedCombo in order to accomidate Combo Boxes.
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Library General Public License for more details.
20 *
21 * You should have received a copy of the GNU Library General Public
22 * License along with this library; if not, write to the Free
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 *
25 */
26
27#ifndef QRESTRICTEDCOMBO_H
28#define QRESTRICTEDCOMBO_H
29
30#include <qcombobox.h>
31
32/**
33 * The QRestrictedCombo widget is a variant of @ref QComboBox which
34 * accepts only a restricted set of characters as input.
35 * All other characters will be discarded and the signal @ref #invalidChar()
36 * will be emitted for each of them.
37 *
38 * Valid characters can be passed as a QString to the constructor
39 * or set afterwards via @ref #setValidChars().
40 * The default key bindings of @ref QComboBox are still in effect.
41 *
42 * @short A line editor for restricted character sets.
43 * @author Michael Wiedmann <mw@miwie.in-berlin.de>
44 * @version 0.0.1
45 */
46class QRestrictedCombo : public QComboBox
47{
48 Q_OBJECT
49 Q_PROPERTY( QString validChars READ validChars WRITE setValidChars )
50
51public:
52
53 /**
54 * Constructor: This contructor takes three - optional - arguments.
55 * The first two parameters are simply passed on to @ref QLineEdit.
56 * @param parent pointer to the parent widget
57 * @param name pointer to the name of this widget
58 * @param valid pointer to set of valid characters
59 */
60 QRestrictedCombo( QWidget *parent=0, const char *name=0,
61 const QString& valid = QString::null);
62
63 /**
64 * Destructs the restricted line editor.
65 */
66 ~QRestrictedCombo();
67
68 /**
69 * All characters in the string valid are treated as
70 * acceptable characters.
71 */
72 void setValidChars(const QString& valid);
73 /**
74 * @return the string of acceptable characters.
75 */
76 QString validChars() const;
77
78signals:
79
80 /**
81 * Emitted when an invalid character was typed.
82 */
83 voidinvalidChar(int);
84
85protected:
86 /**
87 * @reimplemented
88 */
89 voidkeyPressEvent( QKeyEvent *e );
90
91private:
92 /// QString of valid characters for this line
93 QStringqsValidChars;
94};
95
96#endif // QRESTRICTEDCOMBO_H
diff --git a/noncore/apps/checkbook/qrestrictedline.cpp b/noncore/apps/checkbook/qrestrictedline.cpp
deleted file mode 100644
index 8508c33..0000000
--- a/noncore/apps/checkbook/qrestrictedline.cpp
+++ b/dev/null
@@ -1,78 +0,0 @@
1/*
2 *
3 * $Id$
4 *
5 * Implementation of QRestrictedLine
6 *
7 * Copyright (C) 1997 Michael Wiedmann, <mw@miwie.in-berlin.de>
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
18 *
19 * You should have received a copy of the GNU Library General Public
20 * License along with this library; if not, write to the Free
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 */
24
25#include <qkeycode.h>
26
27#include "qrestrictedline.h"
28
29QRestrictedLine::QRestrictedLine( QWidget *parent,
30 const char *name,
31 const QString& valid )
32 : QLineEdit( parent, name )
33{
34 qsValidChars = valid;
35}
36
37QRestrictedLine::~QRestrictedLine()
38{
39 ;
40}
41
42
43void QRestrictedLine::keyPressEvent( QKeyEvent *e )
44{
45 // let QLineEdit process "special" keys and return/enter
46 // so that we still can use the default key binding
47 if (e->key() == Key_Enter || e->key() == Key_Return || e->key() == Key_Delete || e->ascii() < 32)
48 {
49 QLineEdit::keyPressEvent(e);
50 return;
51 }
52
53 // do we have a list of valid chars &&
54 // is the pressed key in the list of valid chars?
55 if (!qsValidChars.isEmpty() && !qsValidChars.contains(e->ascii()))
56 {
57 // invalid char, emit signal and return
58 emit (invalidChar(e->key()));
59 return;
60 }
61 else
62 // valid char: let QLineEdit process this key as usual
63 QLineEdit::keyPressEvent(e);
64
65 return;
66}
67
68
69void QRestrictedLine::setValidChars( const QString& valid)
70{
71 qsValidChars = valid;
72}
73
74QString QRestrictedLine::validChars() const
75{
76 return qsValidChars;
77}
78
diff --git a/noncore/apps/checkbook/qrestrictedline.h b/noncore/apps/checkbook/qrestrictedline.h
deleted file mode 100644
index 7e41cd9..0000000
--- a/noncore/apps/checkbook/qrestrictedline.h
+++ b/dev/null
@@ -1,96 +0,0 @@
1/*
2 *
3 * Definition of QRestrictedLine
4 *
5 * Copyright (C) 1997 Michael Wiedmann, <mw@miwie.in-berlin.de>
6 *
7 * Edited 2001 by Nick Betcher <nbetcher@usinternet.com> to work
8 * with Qt-only. Changed class name from QRestrictedLine to
9 * QRestrictedLine.
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Library General Public License for more details.
20 *
21 * You should have received a copy of the GNU Library General Public
22 * License along with this library; if not, write to the Free
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 *
25 */
26
27#ifndef QRESTRICTEDLINE_H
28#define QRESTRICTEDLINE_H
29
30#include <qlineedit.h>
31
32/**
33 * The QRestrictedLine widget is a variant of @ref QLineEdit which
34 * accepts only a restricted set of characters as input.
35 * All other characters will be discarded and the signal @ref #invalidChar()
36 * will be emitted for each of them.
37 *
38 * Valid characters can be passed as a QString to the constructor
39 * or set afterwards via @ref #setValidChars().
40 * The default key bindings of @ref QLineEdit are still in effect.
41 *
42 * @short A line editor for restricted character sets.
43 * @author Michael Wiedmann <mw@miwie.in-berlin.de>
44 * @version 0.0.1
45 */
46class QRestrictedLine : public QLineEdit
47{
48 Q_OBJECT
49 Q_PROPERTY( QString validChars READ validChars WRITE setValidChars )
50
51public:
52
53 /**
54 * Constructor: This contructor takes three - optional - arguments.
55 * The first two parameters are simply passed on to @ref QLineEdit.
56 * @param parent pointer to the parent widget
57 * @param name pointer to the name of this widget
58 * @param valid pointer to set of valid characters
59 */
60 QRestrictedLine( QWidget *parent=0, const char *name=0,
61 const QString& valid = QString::null);
62
63 /**
64 * Destructs the restricted line editor.
65 */
66 ~QRestrictedLine();
67
68 /**
69 * All characters in the string valid are treated as
70 * acceptable characters.
71 */
72 void setValidChars(const QString& valid);
73 /**
74 * @return the string of acceptable characters.
75 */
76 QString validChars() const;
77
78signals:
79
80 /**
81 * Emitted when an invalid character was typed.
82 */
83 voidinvalidChar(int);
84
85protected:
86 /**
87 * @reimplemented
88 */
89 voidkeyPressEvent( QKeyEvent *e );
90
91private:
92 /// QString of valid characters for this line
93 QStringqsValidChars;
94};
95
96#endif // QRESTRICTEDLINE_H
diff --git a/noncore/apps/checkbook/traninfo.cpp b/noncore/apps/checkbook/traninfo.cpp
new file mode 100644
index 0000000..5a770b0
--- a/dev/null
+++ b/noncore/apps/checkbook/traninfo.cpp
@@ -0,0 +1,156 @@
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 "traninfo.h"
30
31#include <qpe/config.h>
32
33TranInfo::TranInfo( int id, const QString &desc, const QDate &date, bool withdrawal,
34 const QString &type, const QString &category, float amount,
35 float fee, const QString &number, const QString &notes )
36{
37 i = id;
38 d = desc;
39 td = date;
40 w = withdrawal;
41 t = type;
42 c = category;
43 a = amount;
44 f = fee;
45 cn = number;
46 n = notes;
47}
48
49TranInfo::TranInfo( Config config, int entry )
50{
51 config.setGroup( QString::number( entry ) );
52 QString desc = config.readEntry( "Description", "Not Found" );
53 if ( desc != "Not Found" )
54 {
55 // ID
56 i = entry;
57
58 // Description
59 d = desc;
60
61 // Transaction date
62 int yr, mn, dy;
63 QString datestr = config.readEntry( "Date", "" );
64 int begin, end;
65 begin = datestr.find( '/' );
66 mn = datestr.left( begin ).toInt();
67 end = datestr.find( '/', ++begin );
68 dy = datestr.mid( begin, end - begin ).toInt();
69 yr = datestr.right( datestr.length() - end - 1).toInt();
70 td.setYMD( yr, mn, dy );
71
72 // Deposit/withdrawal indicator ( withdrawal == TRUE )
73 w = ( config.readEntry( "Payment", "false" ) == "true" );
74
75 // Type
76 QString type = config.readEntry( "Type", "0" );
77 if ( w )
78 { // Withdrawal types
79 if( type == "0" )
80 t = "Debit Charge";
81 else if( type == "1" )
82 t = "Written Check";
83 else if( type == "2" )
84 t = "Transfer";
85 else if( type == "3" )
86 t = "Credit Card";
87 }
88 else
89 {
90 if( type == "0" )
91 t = "Written Check";
92 else if( type == "1" )
93 t = "Automatic Payment";
94 else if( type == "2" )
95 t = "Transfer";
96 else if( type == "3" )
97 t = "Cash";
98 }
99
100 // Category
101 c = config.readEntry( "Category", "" );
102
103 // Transaction amount
104 QString stramount = config.readEntry( "Amount", "0.00" );
105 bool ok;
106 a = stramount.toFloat( &ok );
107
108 // Transaction fee
109 stramount = config.readEntry( "TransactionFee", "0.00" );
110 f = stramount.toFloat( &ok );
111
112 // Transaction number
113 cn = config.readEntry( "CheckNumber", "" );
114
115 // Notes
116 n = config.readEntry( "Comments", "" );
117 }
118}
119
120void TranInfo::write( Config *config, int entry )
121{
122 config->setGroup( QString::number( entry ) );
123
124 config->writeEntry( "Description", d );
125
126 QString tempstr = QString::number( td.month() ) + "/" +
127 QString::number( td.day() ) + "/" +
128 QString::number( td.year() );
129 config->writeEntry( "Date", tempstr );
130
131 w ? tempstr = "true"
132 : tempstr = "false";
133 config->writeEntry( "Payment", tempstr );
134
135 if ( t == "Debit Charge" || t == "Written Check" )
136 tempstr = "0";
137 else if ( t == "Written Check" || t == "Automatic Payment" )
138 tempstr = "1";
139 else if ( t == "Transfer" )
140 tempstr = "2";
141 else if ( t == "Credit Card" || t == "Cash" )
142 tempstr = "3";
143 config->writeEntry( "Type", tempstr );
144
145 config->writeEntry( "Category", c );
146
147 tempstr.setNum( a, 'f', 2 );
148 config->writeEntry( "Amount", tempstr );
149
150 tempstr.setNum( f, 'f', 2 );
151 config->writeEntry( "TransactionFee", tempstr );
152
153 config->writeEntry( "CheckNumber", cn );
154
155 config->writeEntry( "Comments", n );
156}
diff --git a/noncore/apps/checkbook/traninfo.h b/noncore/apps/checkbook/traninfo.h
new file mode 100644
index 0000000..1743ff7
--- a/dev/null
+++ b/noncore/apps/checkbook/traninfo.h
@@ -0,0 +1,85 @@
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 TRANINFO_H
30#define TRANINFO_H
31
32#include <qdatetime.h>
33#include <qlist.h>
34#include <qstring.h>
35
36class Config;
37
38class TranInfo
39{
40 public:
41 TranInfo( int = 0, const QString & = 0x0, const QDate & = QDate::currentDate(),
42 bool = TRUE, const QString & = 0x0, const QString & = 0x0,
43 float = 0.0, float = 0.0,
44 const QString & = 0x0, const QString & = 0x0 );
45 TranInfo( Config, int );
46
47 int id() const { return i; }
48 const QString &desc() const { return d; }
49 const QDate &date() const { return td; }
50 bool withdrawal()const { return w; }
51 const QString &type() const { return t; }
52 const QString &category()const { return c; }
53 float amount() const { return a; }
54 float fee() const { return f; }
55 const QString &number() const { return cn; }
56 const QString &notes() const { return n; }
57
58 void setDesc( const QString &desc ) { d = desc; }
59 void setDate( const QDate &date ) { td = date; }
60 void setWithdrawal( bool withdrawal ){ w = withdrawal; }
61 void setType( const QString &type ) { t = type; }
62 void setCategory( const QString &cat ){ c = cat; }
63 void setAmount( float amount ) { a = amount; }
64 void setFee( float fee ) { f = fee; }
65 void setNumber( const QString &num ){ cn = num; }
66 void setNotes( const QString &notes ){ n = notes; }
67
68 void write( Config *, int );
69
70 private:
71 int i;
72 QString d;
73 QDate td;
74 bool w;
75 QString t;
76 QString c;
77 float a;
78 float f;
79 QString cn;
80 QString n;
81};
82
83typedef QList<TranInfo> TranInfoList;
84
85#endif
diff --git a/noncore/apps/checkbook/transaction.cpp b/noncore/apps/checkbook/transaction.cpp
new file mode 100644
index 0000000..7d1781b
--- a/dev/null
+++ b/noncore/apps/checkbook/transaction.cpp
@@ -0,0 +1,260 @@
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 "transaction.h"
30#include "traninfo.h"
31
32#include <qpe/datebookmonth.h>
33#include <qpe/timestring.h>
34
35#include <qbuttongroup.h>
36#include <qcombobox.h>
37#include <qlabel.h>
38#include <qlayout.h>
39#include <qlineedit.h>
40#include <qmultilineedit.h>
41#include <qpopupmenu.h>
42#include <qpushbutton.h>
43#include <qradiobutton.h>
44#include <qscrollview.h>
45#include <qstring.h>
46
47#include <stdio.h>
48
49Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *info,
50 char symbol )
51 : QDialog( parent, 0, TRUE, 0 )
52{
53 setCaption( tr( "Transaction for " ) + acctname );
54
55 tran = info;
56 currencySymbol = symbol;
57
58 QVBoxLayout *vb = new QVBoxLayout( this );
59
60 QScrollView *sv = new QScrollView( this );
61 vb->addWidget( sv, 0, 0 );
62 sv->setResizePolicy( QScrollView::AutoOneFit );
63 sv->setFrameStyle( QFrame::NoFrame );
64
65 QWidget *container = new QWidget( sv->viewport() );
66 sv->addChild( container );
67
68 QGridLayout *layout = new QGridLayout( container );
69 layout->setSpacing( 2 );
70 layout->setMargin( 4 );
71
72 // Withdrawal/Deposit
73 QButtonGroup *btngrp = new QButtonGroup( container );
74 btngrp->setColumnLayout(0, Qt::Vertical );
75 btngrp->layout()->setSpacing( 0 );
76 btngrp->layout()->setMargin( 0 );
77 btngrp->setMaximumWidth( 220 );
78 QGridLayout *layout2 = new QGridLayout( btngrp->layout() );
79 layout2->setSpacing( 2 );
80 layout2->setMargin( 2 );
81 withBtn = new QRadioButton( tr( "Withdrawal" ), btngrp );
82 layout2->addWidget( withBtn, 0, 0 );
83 connect( withBtn, SIGNAL( clicked() ), this, SLOT( slotWithdrawalClicked() ) );
84 depBtn = new QRadioButton( tr( "Deposit" ), btngrp );
85 layout2->addWidget( depBtn, 0, 1 );
86 btngrp->setMaximumSize( 320, withBtn->height() );
87 connect( depBtn, SIGNAL( clicked() ), this, SLOT( slotDepositClicked() ) );
88 layout->addMultiCellWidget( btngrp, 0, 0, 0, 3 );
89
90 // Date
91 QLabel *label = new QLabel( tr( "Date:" ), container );
92 layout->addWidget( label, 1, 0 );
93 dateBtn = new QPushButton( TimeString::shortDate( QDate::currentDate() ),
94 container );
95 QPopupMenu *m1 = new QPopupMenu( container );
96 datePicker = new DateBookMonth( m1, 0, TRUE );
97 m1->insertItem( datePicker );
98 dateBtn->setPopup( m1 );
99 connect( datePicker, SIGNAL( dateClicked( int, int, int ) ),
100 this, SLOT( slotDateChanged( int, int, int ) ) );
101 layout->addWidget( dateBtn, 1, 1 );
102
103 // Check number
104 label = new QLabel( tr( "Number:" ), container );
105 layout->addWidget( label, 1, 2 );
106 numEdit = new QLineEdit( container );
107 numEdit->setMaximumWidth( 40 );
108 layout->addWidget( numEdit, 1, 3 );
109
110 // Description
111 label = new QLabel( tr( "Description:" ), container );
112 layout->addWidget( label, 2, 0 );
113 descEdit = new QLineEdit( container );
114 layout->addMultiCellWidget( descEdit, 2, 2, 1, 3 );
115
116 // Category
117 label = new QLabel( tr( "Category:" ), container );
118 layout->addWidget( label, 3, 0 );
119 catList = new QComboBox( container );
120 layout->addMultiCellWidget( catList, 3, 3, 1, 3 );
121
122 // Type
123 label = new QLabel( tr( "Type:" ), container );
124 layout->addWidget( label, 4, 0 );
125 typeList = new QComboBox( container );
126 layout->addMultiCellWidget( typeList, 4, 4, 1, 3 );
127
128 // Amount
129 label = new QLabel( tr( "Amount:" ), container );
130 layout->addWidget( label, 5, 0 );
131 amtEdit = new QLineEdit( container );
132 layout->addMultiCellWidget( amtEdit, 5, 5, 1, 3 );
133
134 // Fee
135 label = new QLabel( tr( "Fee:" ), container );
136 layout->addWidget( label, 6, 0 );
137 feeEdit = new QLineEdit( container );
138 layout->addMultiCellWidget( feeEdit, 6, 6, 1, 3 );
139
140 // Notes
141 label = new QLabel( tr( "Notes:" ), container );
142 layout->addWidget( label, 7, 0 );
143 noteEdit = new QMultiLineEdit( container );
144 layout->addMultiCellWidget( noteEdit, 8, 8, 0, 3 );
145
146 // Populate current values if provided
147 if ( info )
148 {
149 if ( info->withdrawal() )
150 {
151 withBtn->setChecked( TRUE );
152 slotWithdrawalClicked();
153 }
154 else
155 {
156 depBtn->setChecked( TRUE );
157 slotDepositClicked();
158 }
159 QDate dt = info->date();
160 slotDateChanged( dt.year(), dt.month(), dt.day() );
161 datePicker->setDate( dt );
162 numEdit->setText( info->number() );
163 descEdit->setText( info->desc() );
164 QString temptext = info->category();
165 int i = catList->count();
166 while ( i > 0 )
167 {
168 i--;
169 catList->setCurrentItem( i );
170 if ( catList->currentText() == temptext )
171 {
172 break;
173 }
174 }
175 temptext = info->type();
176 i = typeList->count();
177 while ( i > 0 )
178 {
179 i--;
180 typeList->setCurrentItem( i );
181 if ( typeList->currentText() == temptext )
182 {
183 break;
184 }
185 }
186 amtEdit->setText( QString( "%1" ).arg( info->amount(), 0, 'f', 2 ) );
187 feeEdit->setText( QString( "%1" ).arg( info->fee(), 0, 'f', 2 ) );
188 noteEdit->setText( info->notes() );
189 }
190 else
191 {
192 withBtn->setChecked( TRUE );
193 }
194}
195
196Transaction::~Transaction()
197{
198}
199
200void Transaction::accept()
201{
202 tran->setDesc( descEdit->text() );
203 tran->setDate( datePicker->selectedDate() );
204 tran->setWithdrawal( withBtn->isChecked() );
205 tran->setType( typeList->currentText() );
206 tran->setCategory( catList->currentText() );
207 bool ok;
208 tran->setAmount( amtEdit->text().toFloat( &ok ) );
209 tran->setFee( feeEdit->text().toFloat( &ok ) );
210 tran->setNumber( numEdit->text() );
211 tran->setNotes( noteEdit->text() );
212
213 QDialog::accept();
214}
215
216void Transaction::slotWithdrawalClicked()
217{
218 catList->clear();
219 catList->insertItem( tr( "Automobile" ) );
220 catList->insertItem( tr( "Bills" ) );
221 catList->insertItem( tr( "CDs" ) );
222 catList->insertItem( tr( "Clothing" ) );
223 catList->insertItem( tr( "Computer" ) );
224 catList->insertItem( tr( "DVDs" ) );
225 catList->insertItem( tr( "Eletronics" ) );
226 catList->insertItem( tr( "Entertainment" ) );
227 catList->insertItem( tr( "Food" ) );
228 catList->insertItem( tr( "Gasoline" ) );
229 catList->insertItem( tr( "Misc" ) );
230 catList->insertItem( tr( "Movies" ) );
231 catList->insertItem( tr( "Rent" ) );
232 catList->insertItem( tr( "Travel" ) );
233 catList->setCurrentItem( 0 );
234 typeList->clear();
235 typeList->insertItem( tr( "Debit Charge" ) );
236 typeList->insertItem( tr( "Written Check" ) );
237 typeList->insertItem( tr( "Transfer" ) );
238 typeList->insertItem( tr( "Credit Card" ) );
239}
240
241void Transaction::slotDepositClicked()
242{
243 catList->clear();
244 catList->insertItem( tr( "Work" ) );
245 catList->insertItem( tr( "Family Member" ) );
246 catList->insertItem( tr( "Misc. Credit" ) );
247 catList->setCurrentItem( 0 );
248 typeList->clear();
249 typeList->insertItem( tr( "Written Check" ) );
250 typeList->insertItem( tr( "Automatic Payment" ) );
251 typeList->insertItem( tr( "Transfer" ) );
252 typeList->insertItem( tr( "Cash" ) );
253}
254
255void Transaction::slotDateChanged( int y, int m, int d )
256{
257 QDate date;
258 date.setYMD( y, m, d );
259 dateBtn->setText( TimeString::shortDate( date ) );
260}
diff --git a/noncore/apps/checkbook/transaction.h b/noncore/apps/checkbook/transaction.h
new file mode 100644
index 0000000..274e1f2
--- a/dev/null
+++ b/noncore/apps/checkbook/transaction.h
@@ -0,0 +1,79 @@
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 TRANSACTION_H
30#define TRANSACTION_H
31
32#include <qdialog.h>
33
34class DateBookMonth;
35class QComboBox;
36class QLineEdit;
37class QMultiLineEdit;
38class QPushButton;
39class QRadioButton;
40class QString;
41class QWidget;
42class TranInfo;
43
44class Transaction : public QDialog
45{
46 Q_OBJECT
47
48 public:
49 Transaction( QWidget * = 0x0, const QString & = 0x0, TranInfo * = 0x0,
50 char = '$' );
51 ~Transaction();
52
53 private:
54 TranInfo *tran;
55
56 char currencySymbol;
57
58 QRadioButton *withBtn;
59 QRadioButton *depBtn;
60 QPushButton *dateBtn;
61 DateBookMonth *datePicker;
62 QLineEdit *numEdit;
63 QLineEdit *descEdit;
64 QComboBox *catList;
65 QComboBox *typeList;
66 QLineEdit *amtEdit;
67 QLineEdit *feeEdit;
68 QMultiLineEdit *noteEdit;
69
70 protected slots:
71 void accept();
72
73 private slots:
74 void slotWithdrawalClicked();
75 void slotDepositClicked();
76 void slotDateChanged( int, int, int );
77};
78
79#endif