-rw-r--r-- | noncore/apps/checkbook/checkbook.cpp | 59 | ||||
-rw-r--r-- | noncore/apps/checkbook/checkbook.h | 5 | ||||
-rw-r--r-- | noncore/apps/checkbook/checkbook.pro | 42 | ||||
-rw-r--r-- | noncore/apps/checkbook/graph.cpp | 112 | ||||
-rw-r--r-- | noncore/apps/checkbook/graph.h | 63 | ||||
-rw-r--r-- | noncore/apps/checkbook/graphinfo.cpp | 84 | ||||
-rw-r--r-- | noncore/apps/checkbook/graphinfo.h | 82 | ||||
-rw-r--r-- | noncore/apps/checkbook/mainwindow.cpp | 11 | ||||
-rw-r--r-- | noncore/apps/checkbook/traninfo.cpp | 25 | ||||
-rw-r--r-- | noncore/apps/checkbook/traninfo.h | 1 | ||||
-rw-r--r-- | noncore/apps/checkbook/transaction.cpp | 4 |
11 files changed, 430 insertions, 58 deletions
diff --git a/noncore/apps/checkbook/checkbook.cpp b/noncore/apps/checkbook/checkbook.cpp index 4b81c6d..20b42b5 100644 --- a/noncore/apps/checkbook/checkbook.cpp +++ b/noncore/apps/checkbook/checkbook.cpp | |||
@@ -15,62 +15,69 @@ | |||
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "checkbook.h" | 29 | #include "checkbook.h" |
30 | #include "transaction.h" | 30 | #include "transaction.h" |
31 | #include "graph.h" | ||
32 | #include "graphinfo.h" | ||
31 | 33 | ||
32 | #include <opie/otabwidget.h> | 34 | #include <opie/otabwidget.h> |
33 | #include <qpe/config.h> | 35 | #include <qpe/config.h> |
34 | #include <qpe/qpeapplication.h> | 36 | #include <qpe/qpeapplication.h> |
35 | #include <qpe/qpemessagebox.h> | 37 | #include <qpe/qpemessagebox.h> |
36 | #include <qpe/resource.h> | 38 | #include <qpe/resource.h> |
37 | 39 | ||
38 | #include <qcombobox.h> | 40 | #include <qcombobox.h> |
39 | #include <qfile.h> | 41 | #include <qfile.h> |
40 | #include <qlabel.h> | 42 | #include <qlabel.h> |
41 | #include <qlayout.h> | 43 | #include <qlayout.h> |
42 | #include <qlineedit.h> | 44 | #include <qlineedit.h> |
43 | #include <qlistview.h> | 45 | #include <qlistview.h> |
44 | #include <qmultilineedit.h> | 46 | #include <qmultilineedit.h> |
45 | #include <qpushbutton.h> | 47 | #include <qpushbutton.h> |
46 | #include <qwhatsthis.h> | 48 | #include <qwhatsthis.h> |
47 | #include <qwidget.h> | 49 | #include <qwidget.h> |
48 | 50 | ||
49 | Checkbook::Checkbook( QWidget *parent, const QString &n, const QString &fd, char symbol ) | 51 | Checkbook::Checkbook( QWidget *parent, const QString &n, const QString &fd, char symbol ) |
50 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) | 52 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) |
51 | { | 53 | { |
52 | name = n; | 54 | name = n; |
53 | filename = fd + name + ".qcb"; | 55 | filename = fd; |
56 | filename.append( name ); | ||
57 | filename.append( ".qcb" ); | ||
54 | filedir = fd; | 58 | filedir = fd; |
55 | currencySymbol = symbol; | 59 | currencySymbol = symbol; |
56 | currBalance = 0.0; | 60 | currBalance = 0.0; |
57 | 61 | ||
58 | if ( name != "" ) | 62 | if ( name != "" ) |
59 | { | 63 | { |
60 | setCaption( name + " - " + tr( "Checkbook" ) ); | 64 | QString tempstr = name; |
65 | tempstr.append( " - " ); | ||
66 | tempstr.append( tr( "Checkbook" ) ); | ||
67 | setCaption( tempstr ); | ||
61 | } | 68 | } |
62 | else | 69 | else |
63 | { | 70 | { |
64 | setCaption( tr( "New checkbook" ) ); | 71 | setCaption( tr( "New checkbook" ) ); |
65 | } | 72 | } |
66 | 73 | ||
67 | // Setup layout to make everything pretty | 74 | // Setup layout to make everything pretty |
68 | QVBoxLayout *layout = new QVBoxLayout( this ); | 75 | QVBoxLayout *layout = new QVBoxLayout( this ); |
69 | layout->setMargin( 2 ); | 76 | layout->setMargin( 2 ); |
70 | layout->setSpacing( 4 ); | 77 | layout->setSpacing( 4 ); |
71 | 78 | ||
72 | // Setup tabs for all info | 79 | // Setup tabs for all info |
73 | mainWidget = new OTabWidget( this ); | 80 | mainWidget = new OTabWidget( this ); |
74 | layout->addWidget( mainWidget ); | 81 | layout->addWidget( mainWidget ); |
75 | 82 | ||
76 | mainWidget->addTab( initInfo(), "checkbook/infotab", tr( "Info" ) ); | 83 | mainWidget->addTab( initInfo(), "checkbook/infotab", tr( "Info" ) ); |
@@ -229,104 +236,101 @@ QWidget *Checkbook::initCharts() | |||
229 | 236 | ||
230 | QGridLayout *layout = new QGridLayout( control ); | 237 | QGridLayout *layout = new QGridLayout( control ); |
231 | layout->setSpacing( 2 ); | 238 | layout->setSpacing( 2 ); |
232 | layout->setMargin( 4 ); | 239 | layout->setMargin( 4 ); |
233 | 240 | ||
234 | /* | 241 | /* |
235 | QLabel *label = new QLabel( control ); | 242 | QLabel *label = new QLabel( control ); |
236 | label->setText( tr( "Graph type:" ) ); | 243 | label->setText( tr( "Graph type:" ) ); |
237 | layout->addWidget( label, 0, 0 ); | 244 | layout->addWidget( label, 0, 0 ); |
238 | graphList = new QComboBox( control ); | 245 | graphList = new QComboBox( control ); |
239 | graphList->insertItem( tr( "By category" ) ); | 246 | graphList->insertItem( tr( "By category" ) ); |
240 | graphList->insertItem( tr( "..." ) ); | 247 | graphList->insertItem( tr( "..." ) ); |
241 | graphList->insertItem( tr( "..." ) ); | 248 | graphList->insertItem( tr( "..." ) ); |
242 | layout->addWidget( graphList, 0, 1 ); | 249 | layout->addWidget( graphList, 0, 1 ); |
243 | */ | 250 | */ |
244 | 251 | ||
245 | QWidget *graphWidget = new QWidget( control ); | 252 | GraphInfo* info = new GraphInfo( GraphInfo::BarChart, 0x0, tr( "Graph Title" ), |
246 | QWhatsThis::add( graphWidget, tr( "Graph not implemented yet." ) ); | 253 | tr( "X-Axis" ), tr( "Y-Axis" ) ); |
254 | graphWidget = new Graph( control, info ); | ||
255 | QWhatsThis::add( graphWidget, tr( "Charting is not implemented yet." ) ); | ||
247 | layout->addMultiCellWidget( graphWidget, 0, 0, 0, 1 ); | 256 | layout->addMultiCellWidget( graphWidget, 0, 0, 0, 1 ); |
248 | graphWidget->setBackgroundMode( QWidget::PaletteBase ); | ||
249 | 257 | ||
250 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/drawbtn" ), tr( "Draw" ), control ); | 258 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/drawbtn" ), tr( "Draw" ), control ); |
251 | QWhatsThis::add( btn, tr( "Click here to draw the graph." ) ); | 259 | QWhatsThis::add( btn, tr( "Click here to draw the chart." ) ); |
252 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) ); | 260 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) ); |
253 | layout->addWidget( btn, 1, 1 ); | 261 | layout->addWidget( btn, 1, 1 ); |
254 | 262 | ||
255 | return control; | 263 | return control; |
256 | } | 264 | } |
257 | 265 | ||
258 | void Checkbook::loadCheckbook() | 266 | void Checkbook::loadCheckbook() |
259 | { | 267 | { |
260 | transactions.clear(); | 268 | transactions.clear(); |
261 | 269 | ||
262 | Config config(filename, Config::File); | 270 | Config config(filename, Config::File); |
263 | 271 | ||
264 | // Load info | 272 | // Load info |
265 | config.setGroup( "Account" ); | 273 | config.setGroup( "Account" ); |
266 | nameEdit->setText( name ); | 274 | nameEdit->setText( name ); |
267 | QString temptext = config.readEntry( "Type" ); | 275 | QString temptext = config.readEntry( "Type" ); |
268 | int i = typeList->count(); | 276 | int i = typeList->count(); |
269 | while ( i > 0 ) | 277 | while ( i > 0 ) |
270 | { | 278 | { |
271 | i--; | 279 | i--; |
272 | typeList->setCurrentItem( i ); | 280 | typeList->setCurrentItem( i ); |
273 | if ( typeList->currentText() == temptext ) | 281 | if ( typeList->currentText() == temptext ) |
274 | { | 282 | { |
275 | break; | 283 | break; |
276 | } | 284 | } |
277 | } | 285 | } |
278 | bankEdit->setText( config.readEntry( "Bank", "" ) ); | 286 | bankEdit->setText( config.readEntry( "Bank", "" ) ); |
279 | acctNumEdit->setText( config.readEntry( "Number", "" ) ); | 287 | acctNumEdit->setText( config.readEntryCrypt( "Number", "" ) ); |
280 | pinNumEdit->setText( config.readEntry( "PINNumber", "" ) ); | 288 | pinNumEdit->setText( config.readEntryCrypt( "PINNumber", "" ) ); |
281 | balanceEdit->setText( config.readEntry( "Balance", "0.0" ) ); | 289 | balanceEdit->setText( config.readEntry( "Balance", "0.0" ) ); |
282 | notesEdit->setText( config.readEntry( "Notes", "" ) ); | 290 | notesEdit->setText( config.readEntry( "Notes", "" ) ); |
283 | 291 | ||
284 | bool ok; | 292 | bool ok; |
285 | currBalance = balanceEdit->text().toFloat( &ok ); | 293 | currBalance = balanceEdit->text().toFloat( &ok ); |
286 | startBalance = currBalance; | 294 | startBalance = currBalance; |
287 | 295 | ||
288 | // Load transactions | 296 | // Load transactions |
289 | TranInfo *tran; | 297 | TranInfo *tran; |
290 | QString trandesc = ""; | 298 | QString trandesc = ""; |
291 | float amount; | 299 | float amount; |
292 | QString stramount; | 300 | QString stramount; |
293 | for ( int i = 1; trandesc != QString::null; i++ ) | 301 | for ( int i = 1; trandesc != QString::null; i++ ) |
294 | { | 302 | { |
295 | tran = new TranInfo( config, i ); | 303 | tran = new TranInfo( config, i ); |
296 | trandesc = tran->desc(); | 304 | trandesc = tran->desc(); |
297 | if ( trandesc != QString::null ) | 305 | if ( trandesc != QString::null ) |
298 | { | 306 | { |
299 | currBalance -= tran->fee(); | 307 | currBalance -= tran->fee(); |
300 | amount = tran->amount(); | 308 | amount = tran->amount(); |
301 | if ( tran->withdrawal() ) | 309 | if ( tran->withdrawal() ) |
302 | { | 310 | { |
303 | amount *= -1; | 311 | amount *= -1; |
304 | } | 312 | } |
305 | currBalance += amount; | 313 | currBalance += amount; |
306 | stramount.sprintf( "%c%.2f", currencySymbol, amount ); | 314 | stramount.sprintf( "%c%.2f", currencySymbol, amount ); |
307 | 315 | ||
308 | // Add to transaction list | 316 | // Add to transaction list |
309 | transactions.append( tran ); | 317 | transactions.append( tran ); |
310 | 318 | ||
311 | // Add to transaction table | 319 | // Add to transaction table |
312 | QDate date = tran->date(); | 320 | ( void ) new QListViewItem( tranTable, QString::number( i ), tran->datestr(), |
313 | QString datestr = QString::number( date.month() ) + "/" + | ||
314 | QString::number( date.day() ) + "/" + | ||
315 | QString::number( date.year() ); | ||
316 | ( void ) new QListViewItem( tranTable, QString::number( i ), datestr, | ||
317 | trandesc, stramount ); | 321 | trandesc, stramount ); |
318 | } | 322 | } |
319 | else | 323 | else |
320 | { | 324 | { |
321 | delete tran; | 325 | delete tran; |
322 | } | 326 | } |
323 | } | 327 | } |
324 | balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) ); | 328 | balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) ); |
325 | 329 | ||
326 | highTranNum = transactions.count(); | 330 | highTranNum = transactions.count(); |
327 | } | 331 | } |
328 | 332 | ||
329 | void Checkbook::adjustBalance( float amount ) | 333 | void Checkbook::adjustBalance( float amount ) |
330 | { | 334 | { |
331 | currBalance += amount; | 335 | currBalance += amount; |
332 | balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) ); | 336 | balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) ); |
@@ -344,56 +348,61 @@ TranInfo *Checkbook::findTranByID( int id ) | |||
344 | } | 348 | } |
345 | 349 | ||
346 | void Checkbook::accept() | 350 | void Checkbook::accept() |
347 | { | 351 | { |
348 | QFile f( filename ); | 352 | QFile f( filename ); |
349 | if ( f.exists() ) | 353 | if ( f.exists() ) |
350 | { | 354 | { |
351 | f.remove(); | 355 | f.remove(); |
352 | } | 356 | } |
353 | 357 | ||
354 | Config *config = new Config(filename, Config::File); | 358 | Config *config = new Config(filename, Config::File); |
355 | 359 | ||
356 | // Save info | 360 | // Save info |
357 | config->setGroup( "Account" ); | 361 | config->setGroup( "Account" ); |
358 | config->writeEntry( "Type", typeList->currentText() ); | 362 | config->writeEntry( "Type", typeList->currentText() ); |
359 | config->writeEntry( "Bank", bankEdit->text() ); | 363 | config->writeEntry( "Bank", bankEdit->text() ); |
360 | config->writeEntry( "Number", acctNumEdit->text() ); | 364 | config->writeEntryCrypt( "Number", acctNumEdit->text() ); |
361 | config->writeEntry( "PINNumber", pinNumEdit->text() ); | 365 | config->writeEntryCrypt( "PINNumber", pinNumEdit->text() ); |
362 | config->writeEntry( "Balance", balanceEdit->text() ); | 366 | config->writeEntry( "Balance", balanceEdit->text() ); |
363 | config->writeEntry( "Notes", notesEdit->text() ); | 367 | config->writeEntry( "Notes", notesEdit->text() ); |
364 | 368 | ||
365 | // Save transactions | 369 | // Save transactions |
366 | TranInfo *tran = transactions.first(); | 370 | TranInfo *tran = transactions.first(); |
367 | int i = 1; | 371 | int i = 1; |
368 | while ( tran ) | 372 | while ( tran ) |
369 | { | 373 | { |
370 | tran->write( config, i ); | 374 | tran->write( config, i ); |
371 | tran = transactions.next(); | 375 | tran = transactions.next(); |
372 | i++; | 376 | i++; |
373 | } | 377 | } |
374 | config->write(); | 378 | config->write(); |
375 | 379 | ||
376 | QDialog::accept(); | 380 | QDialog::accept(); |
377 | } | 381 | } |
378 | 382 | ||
379 | void Checkbook::slotNameChanged( const QString &newname ) | 383 | void Checkbook::slotNameChanged( const QString &newname ) |
380 | { | 384 | { |
381 | name = newname; | 385 | name = newname; |
382 | filename = filedir + newname + ".qcb"; | 386 | filename = filedir; |
383 | setCaption( name + " - " + tr( "Checkbook" ) ); | 387 | filename.append( newname ); |
388 | filename.append( ".qcb" ); | ||
389 | QString tempstr = name; | ||
390 | tempstr.append( " - " ); | ||
391 | tempstr.append( tr( "Checkbook" ) ); | ||
392 | setCaption( tempstr ); | ||
384 | } | 393 | } |
385 | 394 | ||
386 | void Checkbook::slotStartingBalanceChanged( const QString &newbalance ) | 395 | void Checkbook::slotStartingBalanceChanged( const QString &newbalance ) |
387 | { | 396 | { |
388 | currBalance -= startBalance; | 397 | currBalance -= startBalance; |
389 | bool ok; | 398 | bool ok; |
390 | startBalance = newbalance.toFloat( &ok ); | 399 | startBalance = newbalance.toFloat( &ok ); |
391 | adjustBalance( startBalance ); | 400 | adjustBalance( startBalance ); |
392 | } | 401 | } |
393 | 402 | ||
394 | void Checkbook::slotNewTran() | 403 | void Checkbook::slotNewTran() |
395 | { | 404 | { |
396 | highTranNum++; | 405 | highTranNum++; |
397 | TranInfo *traninfo = new TranInfo( highTranNum ); | 406 | TranInfo *traninfo = new TranInfo( highTranNum ); |
398 | 407 | ||
399 | Transaction *currtran = new Transaction( this, name, | 408 | Transaction *currtran = new Transaction( this, name, |
@@ -401,39 +410,34 @@ void Checkbook::slotNewTran() | |||
401 | currencySymbol ); | 410 | currencySymbol ); |
402 | currtran->showMaximized(); | 411 | currtran->showMaximized(); |
403 | if ( currtran->exec() == QDialog::Accepted ) | 412 | if ( currtran->exec() == QDialog::Accepted ) |
404 | { | 413 | { |
405 | float amount = traninfo->amount(); | 414 | float amount = traninfo->amount(); |
406 | if ( traninfo->withdrawal() ) | 415 | if ( traninfo->withdrawal() ) |
407 | { | 416 | { |
408 | amount *= -1; | 417 | amount *= -1; |
409 | } | 418 | } |
410 | QString stramount; | 419 | QString stramount; |
411 | stramount.sprintf( "%c%.2f", currencySymbol, amount ); | 420 | stramount.sprintf( "%c%.2f", currencySymbol, amount ); |
412 | 421 | ||
413 | // Add to transaction list | 422 | // Add to transaction list |
414 | transactions.append( traninfo ); | 423 | transactions.append( traninfo ); |
415 | 424 | ||
416 | // Add to transaction table | 425 | // Add to transaction table |
417 | 426 | ( void ) new QListViewItem( tranTable, QString::number( highTranNum ), | |
418 | QDate date = traninfo->date(); | 427 | traninfo->datestr(), traninfo->desc(), stramount ); |
419 | QString datestr = QString::number( date.month() ) + "/" + | ||
420 | QString::number( date.day() ) + "/" + | ||
421 | QString::number( date.year() ); | ||
422 | ( void ) new QListViewItem( tranTable, QString::number( highTranNum ), datestr, | ||
423 | traninfo->desc(), stramount ); | ||
424 | 428 | ||
425 | adjustBalance( amount ); | 429 | adjustBalance( amount ); |
426 | } | 430 | } |
427 | else | 431 | else |
428 | { | 432 | { |
429 | highTranNum--; | 433 | highTranNum--; |
430 | delete traninfo; | 434 | delete traninfo; |
431 | } | 435 | } |
432 | } | 436 | } |
433 | 437 | ||
434 | void Checkbook::slotEditTran() | 438 | void Checkbook::slotEditTran() |
435 | { | 439 | { |
436 | bool ok; | 440 | bool ok; |
437 | QListViewItem *curritem = tranTable->currentItem(); | 441 | QListViewItem *curritem = tranTable->currentItem(); |
438 | if ( !curritem ) | 442 | if ( !curritem ) |
439 | { | 443 | { |
@@ -441,68 +445,63 @@ void Checkbook::slotEditTran() | |||
441 | } | 445 | } |
442 | 446 | ||
443 | int tranid = curritem->text( 0 ).toInt( &ok ); | 447 | int tranid = curritem->text( 0 ).toInt( &ok ); |
444 | TranInfo *traninfo = findTranByID( tranid ); | 448 | TranInfo *traninfo = findTranByID( tranid ); |
445 | float origamt = traninfo->amount(); | 449 | float origamt = traninfo->amount(); |
446 | if ( traninfo->withdrawal() ) | 450 | if ( traninfo->withdrawal() ) |
447 | { | 451 | { |
448 | origamt *= -1; | 452 | origamt *= -1; |
449 | } | 453 | } |
450 | 454 | ||
451 | Transaction *currtran = new Transaction( this, name, | 455 | Transaction *currtran = new Transaction( this, name, |
452 | traninfo, | 456 | traninfo, |
453 | currencySymbol ); | 457 | currencySymbol ); |
454 | currtran->showMaximized(); | 458 | currtran->showMaximized(); |
455 | if ( currtran->exec() == QDialog::Accepted ) | 459 | if ( currtran->exec() == QDialog::Accepted ) |
456 | { | 460 | { |
457 | QDate date = traninfo->date(); | 461 | curritem->setText( 1, traninfo->datestr() ); |
458 | QString datestr = QString::number( date.month() ) + "/" + | ||
459 | QString::number( date.day() ) + "/" + | ||
460 | QString::number( date.year() ); | ||
461 | curritem->setText( 1, datestr ); | ||
462 | 462 | ||
463 | curritem->setText( 2, traninfo->desc() ); | 463 | curritem->setText( 2, traninfo->desc() ); |
464 | 464 | ||
465 | float amount = traninfo->amount(); | 465 | float amount = traninfo->amount(); |
466 | if ( traninfo->withdrawal() ) | 466 | if ( traninfo->withdrawal() ) |
467 | { | 467 | { |
468 | amount *= -1; | 468 | amount *= -1; |
469 | } | 469 | } |
470 | adjustBalance( origamt * -1 ); | 470 | adjustBalance( origamt * -1 ); |
471 | adjustBalance( amount ); | 471 | adjustBalance( amount ); |
472 | QString stramount; | 472 | QString stramount; |
473 | stramount.sprintf( "%c%.2f", currencySymbol, amount ); | 473 | stramount.sprintf( "%c%.2f", currencySymbol, amount ); |
474 | curritem->setText( 3, stramount ); | 474 | curritem->setText( 3, stramount ); |
475 | 475 | ||
476 | balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) ); | 476 | balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) ); |
477 | 477 | ||
478 | delete currtran; | 478 | delete currtran; |
479 | } | 479 | } |
480 | } | 480 | } |
481 | 481 | ||
482 | void Checkbook::slotDeleteTran() | 482 | void Checkbook::slotDeleteTran() |
483 | { | 483 | { |
484 | QListViewItem *curritem = tranTable->currentItem(); | 484 | QListViewItem *curritem = tranTable->currentItem(); |
485 | if ( !curritem ) | 485 | if ( !curritem ) |
486 | { | 486 | { |
487 | return; | 487 | return; |
488 | } | 488 | } |
489 | 489 | ||
490 | bool ok; | 490 | bool ok; |
491 | int tranid = curritem->text( 0 ).toInt( &ok ); | 491 | int tranid = curritem->text( 0 ).toInt( &ok ); |
492 | //TranInfo *traninfo = transactions.at( tranid - 1 ); | ||
493 | TranInfo *traninfo = findTranByID( tranid ); | 492 | TranInfo *traninfo = findTranByID( tranid ); |
494 | 493 | ||
495 | if ( QPEMessageBox::confirmDelete ( this, tr( "Delete transaction" ), traninfo->desc() ) ) | 494 | if ( QPEMessageBox::confirmDelete ( this, tr( "Delete transaction" ), traninfo->desc() ) ) |
496 | { | 495 | { |
497 | float amount = traninfo->amount(); | 496 | float amount = traninfo->amount(); |
498 | if ( traninfo->withdrawal() ) | 497 | if ( traninfo->withdrawal() ) |
499 | { | 498 | { |
500 | amount *= -1; | 499 | amount *= -1; |
501 | } | 500 | } |
502 | 501 | ||
503 | transactions.remove( traninfo ); | 502 | transactions.remove( traninfo ); |
504 | delete traninfo; | 503 | delete traninfo; |
505 | delete curritem; | 504 | delete curritem; |
506 | 505 | ||
507 | adjustBalance( amount * -1 ); | 506 | adjustBalance( amount * -1 ); |
508 | } | 507 | } |
diff --git a/noncore/apps/checkbook/checkbook.h b/noncore/apps/checkbook/checkbook.h index a86c0f9..01f1115 100644 --- a/noncore/apps/checkbook/checkbook.h +++ b/noncore/apps/checkbook/checkbook.h | |||
@@ -22,32 +22,33 @@ | |||
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef CHECKBOOK_H | 29 | #ifndef CHECKBOOK_H |
30 | #define CHECKBOOK_H | 30 | #define CHECKBOOK_H |
31 | 31 | ||
32 | #include "traninfo.h" | 32 | #include "traninfo.h" |
33 | 33 | ||
34 | #include <qdialog.h> | 34 | #include <qdialog.h> |
35 | 35 | ||
36 | class OTabWidget; | 36 | class OTabWidget; |
37 | 37 | ||
38 | class Graph; | ||
38 | class QComboBox; | 39 | class QComboBox; |
39 | class QLabel; | 40 | class QLabel; |
40 | class QLineEdit; | 41 | class QLineEdit; |
41 | class QListView; | 42 | class QListView; |
42 | class QMultiLineEdit; | 43 | class QMultiLineEdit; |
43 | class QString; | 44 | class QString; |
44 | 45 | ||
45 | class Checkbook : public QDialog | 46 | class Checkbook : public QDialog |
46 | { | 47 | { |
47 | Q_OBJECT | 48 | Q_OBJECT |
48 | 49 | ||
49 | public: | 50 | public: |
50 | Checkbook( QWidget * = 0x0, const QString & = 0x0, const QString & = 0x0, char = '$' ); | 51 | Checkbook( QWidget * = 0x0, const QString & = 0x0, const QString & = 0x0, char = '$' ); |
51 | ~Checkbook(); | 52 | ~Checkbook(); |
52 | 53 | ||
53 | const QString &getName(); | 54 | const QString &getName(); |
@@ -70,33 +71,33 @@ class Checkbook : public QDialog | |||
70 | QLineEdit *nameEdit; | 71 | QLineEdit *nameEdit; |
71 | QComboBox *typeList; | 72 | QComboBox *typeList; |
72 | QLineEdit *bankEdit; | 73 | QLineEdit *bankEdit; |
73 | QLineEdit *acctNumEdit; | 74 | QLineEdit *acctNumEdit; |
74 | QLineEdit *pinNumEdit; | 75 | QLineEdit *pinNumEdit; |
75 | QLineEdit *balanceEdit; | 76 | QLineEdit *balanceEdit; |
76 | QMultiLineEdit *notesEdit; | 77 | QMultiLineEdit *notesEdit; |
77 | float startBalance; | 78 | float startBalance; |
78 | 79 | ||
79 | // Transactions tab | 80 | // Transactions tab |
80 | QWidget *initTransactions(); | 81 | QWidget *initTransactions(); |
81 | QListView *tranTable; | 82 | QListView *tranTable; |
82 | QLabel *balanceLabel; | 83 | QLabel *balanceLabel; |
83 | float currBalance; | 84 | float currBalance; |
84 | 85 | ||
85 | // Charts tab | 86 | // Charts tab |
86 | QWidget *initCharts(); | 87 | QWidget *initCharts(); |
87 | //QComboBox *graphList; | 88 | //QComboBox *graphList; |
88 | QWidget *graphWidget; | 89 | Graph *graphWidget; |
89 | 90 | ||
90 | protected slots: | 91 | protected slots: |
91 | void accept(); | 92 | void accept(); |
92 | 93 | ||
93 | private slots: | 94 | private slots: |
94 | void slotNameChanged( const QString & ); | 95 | void slotNameChanged( const QString & ); |
95 | void slotStartingBalanceChanged( const QString & ); | 96 | void slotStartingBalanceChanged( const QString & ); |
96 | void slotNewTran(); | 97 | void slotNewTran(); |
97 | void slotEditTran(); | 98 | void slotEditTran(); |
98 | void slotDeleteTran(); | 99 | void slotDeleteTran(); |
99 | void slotDrawGraph(); | 100 | void slotDrawGraph(); |
100 | }; | 101 | }; |
101 | 102 | ||
102 | #endif | 103 | #endif |
diff --git a/noncore/apps/checkbook/checkbook.pro b/noncore/apps/checkbook/checkbook.pro index 07cc012..bd69939 100644 --- a/noncore/apps/checkbook/checkbook.pro +++ b/noncore/apps/checkbook/checkbook.pro | |||
@@ -1,32 +1,36 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | CONFIG = qt warn_on release | 2 | CONFIG = qt warn_on release |
3 | HEADERS = mainwindow.h \ | 3 | HEADERS = mainwindow.h \ |
4 | traninfo.h \ | 4 | traninfo.h \ |
5 | checkbook.h \ | 5 | graphinfo.h \ |
6 | transaction.h | 6 | checkbook.h \ |
7 | SOURCES = main.cpp \ | 7 | transaction.h \ |
8 | mainwindow.cpp \ | 8 | graph.h |
9 | traninfo.cpp \ | 9 | SOURCES = main.cpp \ |
10 | checkbook.cpp \ | 10 | mainwindow.cpp \ |
11 | transaction.cpp | 11 | traninfo.cpp \ |
12 | graphinfo.cpp \ | ||
13 | checkbook.cpp \ | ||
14 | transaction.cpp \ | ||
15 | graph.cpp | ||
12 | INCLUDEPATH += $(OPIEDIR)/include | 16 | INCLUDEPATH += $(OPIEDIR)/include |
13 | DEPENDPATH += $(OPIEDIR)/include | 17 | DEPENDPATH += $(OPIEDIR)/include |
14 | LIBS += -lqpe -lopie | 18 | LIBS += -lqpe -lopie |
15 | TARGET = checkbook | 19 | TARGET = checkbook |
16 | DESTDIR = $(OPIEDIR)/bin | 20 | DESTDIR = $(OPIEDIR)/bin |
17 | 21 | ||
18 | TRANSLATIONS = ../../../i18n/de/checkbook.ts \ | 22 | TRANSLATIONS = ../../../i18n/de/checkbook.ts \ |
19 | ../../../i18n/en/checkbook.ts \ | 23 | ../../../i18n/en/checkbook.ts \ |
20 | ../../../i18n/es/checkbook.ts \ | 24 | ../../../i18n/es/checkbook.ts \ |
21 | ../../../i18n/fr/checkbook.ts \ | 25 | ../../../i18n/fr/checkbook.ts \ |
22 | ../../../i18n/hu/checkbook.ts \ | 26 | ../../../i18n/hu/checkbook.ts \ |
23 | ../../../i18n/ja/checkbook.ts \ | 27 | ../../../i18n/ja/checkbook.ts \ |
24 | ../../../i18n/ko/checkbook.ts \ | 28 | ../../../i18n/ko/checkbook.ts \ |
25 | ../../../i18n/no/checkbook.ts \ | 29 | ../../../i18n/no/checkbook.ts \ |
26 | ../../../i18n/pl/checkbook.ts \ | 30 | ../../../i18n/pl/checkbook.ts \ |
27 | ../../../i18n/pt/checkbook.ts \ | 31 | ../../../i18n/pt/checkbook.ts \ |
28 | ../../../i18n/pt_BR/checkbook.ts \ | 32 | ../../../i18n/pt_BR/checkbook.ts \ |
29 | ../../../i18n/sl/checkbook.ts \ | 33 | ../../../i18n/sl/checkbook.ts \ |
30 | ../../../i18n/zh_CN/checkbook.ts \ | 34 | ../../../i18n/zh_CN/checkbook.ts \ |
31 | ../../../i18n/zh_TW/checkbook.ts \ | 35 | ../../../i18n/zh_TW/checkbook.ts \ |
32 | ../../../i18n/it/checkbook.ts | 36 | ../../../i18n/it/checkbook.ts |
diff --git a/noncore/apps/checkbook/graph.cpp b/noncore/apps/checkbook/graph.cpp new file mode 100644 index 0000000..bae92da --- a/dev/null +++ b/noncore/apps/checkbook/graph.cpp | |||
@@ -0,0 +1,112 @@ | |||
1 | /* | ||
2 | This file is part of the OPIE Project | ||
3 | =. | ||
4 | .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> | ||
5 | .>+-= | ||
6 | _;:, .> :=|. This file is free software; you can | ||
7 | .> <`_, > . <= redistribute it and/or modify it under | ||
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
9 | .="- .-=="i, .._ License as published by the Free Software | ||
10 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
11 | ._= =} : or (at your option) any later version. | ||
12 | .%`+i> _;_. | ||
13 | .i_,=:_. -<s. This file is distributed in the hope that | ||
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
15 | : .. .:, . . . without even the implied warranty of | ||
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | ||
18 | ..}^=.= = ; Public License for more details. | ||
19 | ++= -. .` .: | ||
20 | : = ...= . :.=- You should have received a copy of the GNU | ||
21 | -. .:....=;==+<; General Public License along with this file; | ||
22 | -_. . . )=. = see the file COPYING. If not, write to the | ||
23 | -- :-=` Free Software Foundation, Inc., | ||
24 | 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | #include "graph.h" | ||
30 | #include "graphinfo.h" | ||
31 | |||
32 | #include <qpainter.h> | ||
33 | |||
34 | Graph::Graph( QWidget *parent, GraphInfo *d, const QString &name, int flags ) | ||
35 | : QWidget( parent, name, flags ) | ||
36 | { | ||
37 | setBackgroundMode( QWidget::PaletteBase ); | ||
38 | |||
39 | data = d; | ||
40 | |||
41 | graph.setOptimization( QPixmap::BestOptim ); | ||
42 | } | ||
43 | |||
44 | void Graph::setGraphInfo( GraphInfo *d ) | ||
45 | { | ||
46 | data = d; | ||
47 | } | ||
48 | |||
49 | void Graph::drawGraph( bool regen ) | ||
50 | { | ||
51 | if ( regen ) | ||
52 | { | ||
53 | initGraph(); | ||
54 | } | ||
55 | QPainter p( this ); | ||
56 | p.drawPixmap( 0, 0, graph ); | ||
57 | } | ||
58 | |||
59 | void Graph::paintEvent( QPaintEvent * ) | ||
60 | { | ||
61 | drawGraph( FALSE ); | ||
62 | } | ||
63 | |||
64 | void Graph::resizeEvent( QResizeEvent * ) | ||
65 | { | ||
66 | drawGraph( TRUE ); | ||
67 | } | ||
68 | |||
69 | void Graph::initGraph() | ||
70 | { | ||
71 | graph.resize( width(), height() ); | ||
72 | graph.fill( QColor( 255, 255, 255 ) ); | ||
73 | |||
74 | if ( !data ) | ||
75 | { | ||
76 | return; | ||
77 | } | ||
78 | |||
79 | // Any common stuff here (titles, ???) | ||
80 | |||
81 | switch ( data->graphType() ) | ||
82 | { | ||
83 | case GraphInfo::BarChart : | ||
84 | { | ||
85 | drawBarChart(); | ||
86 | } | ||
87 | break; | ||
88 | case GraphInfo::LineChart : | ||
89 | { | ||
90 | drawLineChart(); | ||
91 | } | ||
92 | break; | ||
93 | case GraphInfo::PieChart : | ||
94 | { | ||
95 | drawPieChart(); | ||
96 | } | ||
97 | }; | ||
98 | } | ||
99 | |||
100 | void Graph::drawBarChart() | ||
101 | { | ||
102 | //Find max value in GraphInfo->dataPoints() - make function in GraphInfo!!! | ||
103 | } | ||
104 | |||
105 | void Graph::drawLineChart() | ||
106 | { | ||
107 | } | ||
108 | |||
109 | void Graph::drawPieChart() | ||
110 | { | ||
111 | } | ||
112 | |||
diff --git a/noncore/apps/checkbook/graph.h b/noncore/apps/checkbook/graph.h new file mode 100644 index 0000000..7379be7 --- a/dev/null +++ b/noncore/apps/checkbook/graph.h | |||
@@ -0,0 +1,63 @@ | |||
1 | /* | ||
2 | This file is part of the OPIE Project | ||
3 | =. | ||
4 | .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> | ||
5 | .>+-= | ||
6 | _;:, .> :=|. This file is free software; you can | ||
7 | .> <`_, > . <= redistribute it and/or modify it under | ||
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
9 | .="- .-=="i, .._ License as published by the Free Software | ||
10 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
11 | ._= =} : or (at your option) any later version. | ||
12 | .%`+i> _;_. | ||
13 | .i_,=:_. -<s. This file is distributed in the hope that | ||
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
15 | : .. .:, . . . without even the implied warranty of | ||
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | ||
18 | ..}^=.= = ; Public License for more details. | ||
19 | ++= -. .` .: | ||
20 | : = ...= . :.=- You should have received a copy of the GNU | ||
21 | -. .:....=;==+<; General Public License along with this file; | ||
22 | -_. . . )=. = see the file COPYING. If not, write to the | ||
23 | -- :-=` Free Software Foundation, Inc., | ||
24 | 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | #ifndef GRAPH_H | ||
30 | #define GRAPH_H | ||
31 | |||
32 | #include <qpixmap.h> | ||
33 | #include <qwidget.h> | ||
34 | |||
35 | class GraphInfo; | ||
36 | |||
37 | class Graph : public QWidget | ||
38 | { | ||
39 | Q_OBJECT | ||
40 | |||
41 | public: | ||
42 | Graph( QWidget * = 0x0, GraphInfo * = 0x0, const QString & = 0x0, int = 0 ); | ||
43 | |||
44 | void setGraphInfo( GraphInfo * ); | ||
45 | |||
46 | void drawGraph( bool = FALSE ); | ||
47 | |||
48 | protected: | ||
49 | void paintEvent( QPaintEvent * ); | ||
50 | void resizeEvent( QResizeEvent * ); | ||
51 | |||
52 | private: | ||
53 | GraphInfo *data; | ||
54 | |||
55 | QPixmap graph; | ||
56 | |||
57 | void initGraph(); | ||
58 | void drawBarChart(); | ||
59 | void drawLineChart(); | ||
60 | void drawPieChart(); | ||
61 | }; | ||
62 | |||
63 | #endif | ||
diff --git a/noncore/apps/checkbook/graphinfo.cpp b/noncore/apps/checkbook/graphinfo.cpp new file mode 100644 index 0000000..7b06bdb --- a/dev/null +++ b/noncore/apps/checkbook/graphinfo.cpp | |||
@@ -0,0 +1,84 @@ | |||
1 | /* | ||
2 | This file is part of the OPIE Project | ||
3 | =. | ||
4 | .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> | ||
5 | .>+-= | ||
6 | _;:, .> :=|. This file is free software; you can | ||
7 | .> <`_, > . <= redistribute it and/or modify it under | ||
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
9 | .="- .-=="i, .._ License as published by the Free Software | ||
10 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
11 | ._= =} : or (at your option) any later version. | ||
12 | .%`+i> _;_. | ||
13 | .i_,=:_. -<s. This file is distributed in the hope that | ||
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
15 | : .. .:, . . . without even the implied warranty of | ||
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | ||
18 | ..}^=.= = ; Public License for more details. | ||
19 | ++= -. .` .: | ||
20 | : = ...= . :.=- You should have received a copy of the GNU | ||
21 | -. .:....=;==+<; General Public License along with this file; | ||
22 | -_. . . )=. = see the file COPYING. If not, write to the | ||
23 | -- :-=` Free Software Foundation, Inc., | ||
24 | 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | #include "graphinfo.h" | ||
30 | |||
31 | GraphInfo::GraphInfo( GraphType type, DataPointList *data, const QString &title, | ||
32 | const QString &xtitle, const QString &ytitle ) | ||
33 | { | ||
34 | t = type; | ||
35 | d = data; | ||
36 | gt = title; | ||
37 | xt = xtitle; | ||
38 | yt = ytitle; | ||
39 | } | ||
40 | |||
41 | GraphInfo::GraphType GraphInfo::graphType() | ||
42 | { | ||
43 | return t; | ||
44 | } | ||
45 | |||
46 | void GraphInfo::setGraphType( GraphType type ) | ||
47 | { | ||
48 | t = type; | ||
49 | } | ||
50 | |||
51 | DataPointList *GraphInfo::dataPoints() | ||
52 | { | ||
53 | return d; | ||
54 | } | ||
55 | |||
56 | void GraphInfo::setDataPoints( DataPointList *data ) | ||
57 | { | ||
58 | d = data; | ||
59 | } | ||
60 | |||
61 | float GraphInfo::maxValue() | ||
62 | { | ||
63 | float max; | ||
64 | |||
65 | } | ||
66 | |||
67 | float GraphInfo::minValue() | ||
68 | { | ||
69 | } | ||
70 | |||
71 | void GraphInfo::setGraphTitle( const QString &title ) | ||
72 | { | ||
73 | gt = title; | ||
74 | } | ||
75 | |||
76 | void GraphInfo::setXAxisTitle( const QString &xtitle ) | ||
77 | { | ||
78 | xt = xtitle; | ||
79 | } | ||
80 | |||
81 | void GraphInfo::setYAxisTitle( const QString &ytitle ) | ||
82 | { | ||
83 | yt = ytitle; | ||
84 | } | ||
diff --git a/noncore/apps/checkbook/graphinfo.h b/noncore/apps/checkbook/graphinfo.h new file mode 100644 index 0000000..4ad1dc9 --- a/dev/null +++ b/noncore/apps/checkbook/graphinfo.h | |||
@@ -0,0 +1,82 @@ | |||
1 | /* | ||
2 | This file is part of the OPIE Project | ||
3 | =. | ||
4 | .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> | ||
5 | .>+-= | ||
6 | _;:, .> :=|. This file is free software; you can | ||
7 | .> <`_, > . <= redistribute it and/or modify it under | ||
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
9 | .="- .-=="i, .._ License as published by the Free Software | ||
10 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
11 | ._= =} : or (at your option) any later version. | ||
12 | .%`+i> _;_. | ||
13 | .i_,=:_. -<s. This file is distributed in the hope that | ||
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
15 | : .. .:, . . . without even the implied warranty of | ||
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | ||
18 | ..}^=.= = ; Public License for more details. | ||
19 | ++= -. .` .: | ||
20 | : = ...= . :.=- You should have received a copy of the GNU | ||
21 | -. .:....=;==+<; General Public License along with this file; | ||
22 | -_. . . )=. = see the file COPYING. If not, write to the | ||
23 | -- :-=` Free Software Foundation, Inc., | ||
24 | 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | #ifndef GRAPHINFO_H | ||
30 | #define GRAPHINFO_H | ||
31 | |||
32 | #include <qlist.h> | ||
33 | #include <qstringlist.h> | ||
34 | |||
35 | class DataPointInfo | ||
36 | { | ||
37 | public: | ||
38 | DataPointInfo() | ||
39 | : l( 0x0 ), v( 0.0 ) {} | ||
40 | DataPointInfo( const QString &label, float value ) | ||
41 | : l( label ), v( value ) {} | ||
42 | |||
43 | const QString &label() { return l; } | ||
44 | float value() { return v; } | ||
45 | |||
46 | private: | ||
47 | QString l; | ||
48 | float v; | ||
49 | }; | ||
50 | |||
51 | typedef QList<DataPointInfo> DataPointList; | ||
52 | |||
53 | class GraphInfo | ||
54 | { | ||
55 | public: | ||
56 | enum GraphType { BarChart, LineChart, PieChart }; | ||
57 | |||
58 | GraphInfo( GraphType = BarChart, DataPointList * = 0x0, | ||
59 | const QString & = 0x0, const QString & = 0x0, const QString & = 0x0 ); | ||
60 | |||
61 | GraphInfo::GraphType graphType(); | ||
62 | void setGraphType( GraphType ); | ||
63 | |||
64 | DataPointList *dataPoints(); | ||
65 | void setDataPoints( DataPointList * ); | ||
66 | |||
67 | float maxValue(); | ||
68 | float minValue(); | ||
69 | |||
70 | void setGraphTitle( const QString & ); | ||
71 | void setXAxisTitle( const QString & ); | ||
72 | void setYAxisTitle( const QString & ); | ||
73 | |||
74 | private: | ||
75 | GraphType t; | ||
76 | DataPointList *d; | ||
77 | QString gt; | ||
78 | QString xt; | ||
79 | QString yt; | ||
80 | }; | ||
81 | |||
82 | #endif | ||
diff --git a/noncore/apps/checkbook/mainwindow.cpp b/noncore/apps/checkbook/mainwindow.cpp index ead17b4..2eb8396 100644 --- a/noncore/apps/checkbook/mainwindow.cpp +++ b/noncore/apps/checkbook/mainwindow.cpp | |||
@@ -124,40 +124,45 @@ void MainWindow::slotNew() | |||
124 | } | 124 | } |
125 | } | 125 | } |
126 | 126 | ||
127 | void MainWindow::slotEdit() | 127 | void MainWindow::slotEdit() |
128 | { | 128 | { |
129 | QString currname = cbList->currentText(); | 129 | QString currname = cbList->currentText(); |
130 | Checkbook *currcb = new Checkbook( this, currname, cbDir, currencySymbol ); | 130 | Checkbook *currcb = new Checkbook( this, currname, cbDir, currencySymbol ); |
131 | currcb->showMaximized(); | 131 | currcb->showMaximized(); |
132 | if ( currcb->exec() == QDialog::Accepted ) | 132 | if ( currcb->exec() == QDialog::Accepted ) |
133 | { | 133 | { |
134 | QString newname = currcb->getName(); | 134 | QString newname = currcb->getName(); |
135 | if ( currname != newname ) | 135 | if ( currname != newname ) |
136 | { | 136 | { |
137 | cbList->changeItem( newname, cbList->currentItem() ); | 137 | cbList->changeItem( newname, cbList->currentItem() ); |
138 | cbList->sort(); | 138 | cbList->sort(); |
139 | 139 | ||
140 | QFile f( cbDir + currname + ".qcb" ); | 140 | QString tempstr = cbDir; |
141 | tempstr.append( currname ); | ||
142 | tempstr.append( ".qcb" ); | ||
143 | QFile f( tempstr ); | ||
141 | if ( f.exists() ) | 144 | if ( f.exists() ) |
142 | { | 145 | { |
143 | f.remove(); | 146 | f.remove(); |
144 | } | 147 | } |
145 | } | 148 | } |
146 | delete currcb; | 149 | delete currcb; |
147 | } | 150 | } |
148 | } | 151 | } |
149 | 152 | ||
150 | void MainWindow::slotDelete() | 153 | void MainWindow::slotDelete() |
151 | { | 154 | { |
152 | if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), cbList->currentText() ) ) | 155 | if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), cbList->currentText() ) ) |
153 | { | 156 | { |
154 | QString name = cbDir + cbList->currentText() + ".qcb"; | 157 | QString tempstr = cbDir; |
155 | QFile f( name ); | 158 | tempstr.append( cbList->currentText() ); |
159 | tempstr.append( ".qcb" ); | ||
160 | QFile f( tempstr ); | ||
156 | if ( f.exists() ) | 161 | if ( f.exists() ) |
157 | { | 162 | { |
158 | f.remove(); | 163 | f.remove(); |
159 | } | 164 | } |
160 | 165 | ||
161 | cbList->removeItem( cbList->currentItem() ); | 166 | cbList->removeItem( cbList->currentItem() ); |
162 | } | 167 | } |
163 | } | 168 | } |
diff --git a/noncore/apps/checkbook/traninfo.cpp b/noncore/apps/checkbook/traninfo.cpp index 5a770b0..460466c 100644 --- a/noncore/apps/checkbook/traninfo.cpp +++ b/noncore/apps/checkbook/traninfo.cpp | |||
@@ -17,32 +17,34 @@ | |||
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "traninfo.h" | 29 | #include "traninfo.h" |
30 | 30 | ||
31 | #include <qpe/config.h> | 31 | #include <qpe/config.h> |
32 | 32 | ||
33 | QString tempstr; | ||
34 | |||
33 | TranInfo::TranInfo( int id, const QString &desc, const QDate &date, bool withdrawal, | 35 | TranInfo::TranInfo( int id, const QString &desc, const QDate &date, bool withdrawal, |
34 | const QString &type, const QString &category, float amount, | 36 | const QString &type, const QString &category, float amount, |
35 | float fee, const QString &number, const QString ¬es ) | 37 | float fee, const QString &number, const QString ¬es ) |
36 | { | 38 | { |
37 | i = id; | 39 | i = id; |
38 | d = desc; | 40 | d = desc; |
39 | td = date; | 41 | td = date; |
40 | w = withdrawal; | 42 | w = withdrawal; |
41 | t = type; | 43 | t = type; |
42 | c = category; | 44 | c = category; |
43 | a = amount; | 45 | a = amount; |
44 | f = fee; | 46 | f = fee; |
45 | cn = number; | 47 | cn = number; |
46 | n = notes; | 48 | n = notes; |
47 | } | 49 | } |
48 | 50 | ||
@@ -104,41 +106,58 @@ TranInfo::TranInfo( Config config, int entry ) | |||
104 | QString stramount = config.readEntry( "Amount", "0.00" ); | 106 | QString stramount = config.readEntry( "Amount", "0.00" ); |
105 | bool ok; | 107 | bool ok; |
106 | a = stramount.toFloat( &ok ); | 108 | a = stramount.toFloat( &ok ); |
107 | 109 | ||
108 | // Transaction fee | 110 | // Transaction fee |
109 | stramount = config.readEntry( "TransactionFee", "0.00" ); | 111 | stramount = config.readEntry( "TransactionFee", "0.00" ); |
110 | f = stramount.toFloat( &ok ); | 112 | f = stramount.toFloat( &ok ); |
111 | 113 | ||
112 | // Transaction number | 114 | // Transaction number |
113 | cn = config.readEntry( "CheckNumber", "" ); | 115 | cn = config.readEntry( "CheckNumber", "" ); |
114 | 116 | ||
115 | // Notes | 117 | // Notes |
116 | n = config.readEntry( "Comments", "" ); | 118 | n = config.readEntry( "Comments", "" ); |
117 | } | 119 | } |
118 | } | 120 | } |
119 | 121 | ||
122 | const QString &TranInfo::datestr() | ||
123 | { | ||
124 | tempstr = QString::number( td.year() ); | ||
125 | tempstr.append( '/' ); | ||
126 | int tempfield = td.month(); | ||
127 | if ( tempfield < 10 ) tempstr.append( '0' ); | ||
128 | tempstr.append( QString::number( tempfield ) ); | ||
129 | tempstr.append( '/' ); | ||
130 | tempfield = td.day(); | ||
131 | if ( tempfield < 10 ) tempstr.append( '0' ); | ||
132 | tempstr.append( QString::number( tempfield ) ); | ||
133 | |||
134 | return( tempstr ); | ||
135 | } | ||
136 | |||
120 | void TranInfo::write( Config *config, int entry ) | 137 | void TranInfo::write( Config *config, int entry ) |
121 | { | 138 | { |
122 | config->setGroup( QString::number( entry ) ); | 139 | config->setGroup( QString::number( entry ) ); |
123 | 140 | ||
124 | config->writeEntry( "Description", d ); | 141 | config->writeEntry( "Description", d ); |
125 | 142 | ||
126 | QString tempstr = QString::number( td.month() ) + "/" + | 143 | tempstr = QString::number( td.month() ); |
127 | QString::number( td.day() ) + "/" + | 144 | tempstr.append( '/' ); |
128 | QString::number( td.year() ); | 145 | tempstr.append( QString::number( td.day() ) ); |
146 | tempstr.append( '/' ); | ||
147 | tempstr.append( QString::number( td.year() ) ); | ||
129 | config->writeEntry( "Date", tempstr ); | 148 | config->writeEntry( "Date", tempstr ); |
130 | 149 | ||
131 | w ? tempstr = "true" | 150 | w ? tempstr = "true" |
132 | : tempstr = "false"; | 151 | : tempstr = "false"; |
133 | config->writeEntry( "Payment", tempstr ); | 152 | config->writeEntry( "Payment", tempstr ); |
134 | 153 | ||
135 | if ( t == "Debit Charge" || t == "Written Check" ) | 154 | if ( t == "Debit Charge" || t == "Written Check" ) |
136 | tempstr = "0"; | 155 | tempstr = "0"; |
137 | else if ( t == "Written Check" || t == "Automatic Payment" ) | 156 | else if ( t == "Written Check" || t == "Automatic Payment" ) |
138 | tempstr = "1"; | 157 | tempstr = "1"; |
139 | else if ( t == "Transfer" ) | 158 | else if ( t == "Transfer" ) |
140 | tempstr = "2"; | 159 | tempstr = "2"; |
141 | else if ( t == "Credit Card" || t == "Cash" ) | 160 | else if ( t == "Credit Card" || t == "Cash" ) |
142 | tempstr = "3"; | 161 | tempstr = "3"; |
143 | config->writeEntry( "Type", tempstr ); | 162 | config->writeEntry( "Type", tempstr ); |
144 | 163 | ||
diff --git a/noncore/apps/checkbook/traninfo.h b/noncore/apps/checkbook/traninfo.h index 1743ff7..e944c29 100644 --- a/noncore/apps/checkbook/traninfo.h +++ b/noncore/apps/checkbook/traninfo.h | |||
@@ -34,32 +34,33 @@ | |||
34 | #include <qstring.h> | 34 | #include <qstring.h> |
35 | 35 | ||
36 | class Config; | 36 | class Config; |
37 | 37 | ||
38 | class TranInfo | 38 | class TranInfo |
39 | { | 39 | { |
40 | public: | 40 | public: |
41 | TranInfo( int = 0, const QString & = 0x0, const QDate & = QDate::currentDate(), | 41 | TranInfo( int = 0, const QString & = 0x0, const QDate & = QDate::currentDate(), |
42 | bool = TRUE, const QString & = 0x0, const QString & = 0x0, | 42 | bool = TRUE, const QString & = 0x0, const QString & = 0x0, |
43 | float = 0.0, float = 0.0, | 43 | float = 0.0, float = 0.0, |
44 | const QString & = 0x0, const QString & = 0x0 ); | 44 | const QString & = 0x0, const QString & = 0x0 ); |
45 | TranInfo( Config, int ); | 45 | TranInfo( Config, int ); |
46 | 46 | ||
47 | int id() const { return i; } | 47 | int id() const { return i; } |
48 | const QString &desc() const { return d; } | 48 | const QString &desc() const { return d; } |
49 | const QDate &date() const { return td; } | 49 | const QDate &date() const { return td; } |
50 | const QString &datestr(); | ||
50 | bool withdrawal()const { return w; } | 51 | bool withdrawal()const { return w; } |
51 | const QString &type() const { return t; } | 52 | const QString &type() const { return t; } |
52 | const QString &category()const { return c; } | 53 | const QString &category()const { return c; } |
53 | float amount() const { return a; } | 54 | float amount() const { return a; } |
54 | float fee() const { return f; } | 55 | float fee() const { return f; } |
55 | const QString &number() const { return cn; } | 56 | const QString &number() const { return cn; } |
56 | const QString ¬es() const { return n; } | 57 | const QString ¬es() const { return n; } |
57 | 58 | ||
58 | void setDesc( const QString &desc ) { d = desc; } | 59 | void setDesc( const QString &desc ) { d = desc; } |
59 | void setDate( const QDate &date ) { td = date; } | 60 | void setDate( const QDate &date ) { td = date; } |
60 | void setWithdrawal( bool withdrawal ){ w = withdrawal; } | 61 | void setWithdrawal( bool withdrawal ){ w = withdrawal; } |
61 | void setType( const QString &type ) { t = type; } | 62 | void setType( const QString &type ) { t = type; } |
62 | void setCategory( const QString &cat ){ c = cat; } | 63 | void setCategory( const QString &cat ){ c = cat; } |
63 | void setAmount( float amount ) { a = amount; } | 64 | void setAmount( float amount ) { a = amount; } |
64 | void setFee( float fee ) { f = fee; } | 65 | void setFee( float fee ) { f = fee; } |
65 | void setNumber( const QString &num ){ cn = num; } | 66 | void setNumber( const QString &num ){ cn = num; } |
diff --git a/noncore/apps/checkbook/transaction.cpp b/noncore/apps/checkbook/transaction.cpp index 82baec9..a921491 100644 --- a/noncore/apps/checkbook/transaction.cpp +++ b/noncore/apps/checkbook/transaction.cpp | |||
@@ -36,33 +36,35 @@ | |||
36 | #include <qcombobox.h> | 36 | #include <qcombobox.h> |
37 | #include <qlabel.h> | 37 | #include <qlabel.h> |
38 | #include <qlayout.h> | 38 | #include <qlayout.h> |
39 | #include <qlineedit.h> | 39 | #include <qlineedit.h> |
40 | #include <qmultilineedit.h> | 40 | #include <qmultilineedit.h> |
41 | #include <qpopupmenu.h> | 41 | #include <qpopupmenu.h> |
42 | #include <qpushbutton.h> | 42 | #include <qpushbutton.h> |
43 | #include <qradiobutton.h> | 43 | #include <qradiobutton.h> |
44 | #include <qscrollview.h> | 44 | #include <qscrollview.h> |
45 | #include <qstring.h> | 45 | #include <qstring.h> |
46 | #include <qwhatsthis.h> | 46 | #include <qwhatsthis.h> |
47 | 47 | ||
48 | Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *info, | 48 | Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *info, |
49 | char symbol ) | 49 | char symbol ) |
50 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) | 50 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) |
51 | { | 51 | { |
52 | setCaption( tr( "Transaction for " ) + acctname ); | 52 | QString tempstr = tr( "Transaction for " ); |
53 | tempstr.append( acctname ); | ||
54 | setCaption( tempstr ); | ||
53 | 55 | ||
54 | tran = info; | 56 | tran = info; |
55 | currencySymbol = symbol; | 57 | currencySymbol = symbol; |
56 | 58 | ||
57 | QVBoxLayout *vb = new QVBoxLayout( this ); | 59 | QVBoxLayout *vb = new QVBoxLayout( this ); |
58 | 60 | ||
59 | QScrollView *sv = new QScrollView( this ); | 61 | QScrollView *sv = new QScrollView( this ); |
60 | vb->addWidget( sv, 0, 0 ); | 62 | vb->addWidget( sv, 0, 0 ); |
61 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 63 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
62 | sv->setFrameStyle( QFrame::NoFrame ); | 64 | sv->setFrameStyle( QFrame::NoFrame ); |
63 | 65 | ||
64 | QWidget *container = new QWidget( sv->viewport() ); | 66 | QWidget *container = new QWidget( sv->viewport() ); |
65 | sv->addChild( container ); | 67 | sv->addChild( container ); |
66 | 68 | ||
67 | QGridLayout *layout = new QGridLayout( container ); | 69 | QGridLayout *layout = new QGridLayout( container ); |
68 | layout->setSpacing( 2 ); | 70 | layout->setSpacing( 2 ); |