-rw-r--r-- | noncore/apps/checkbook/checkbook.cpp | 93 | ||||
-rw-r--r-- | noncore/apps/checkbook/checkbook.h | 24 | ||||
-rw-r--r-- | noncore/apps/checkbook/graph.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/checkbook/graph.h | 2 | ||||
-rw-r--r-- | noncore/apps/checkbook/graphinfo.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/checkbook/graphinfo.h | 2 | ||||
-rw-r--r-- | noncore/apps/checkbook/main.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/checkbook/mainwindow.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/checkbook/mainwindow.h | 2 | ||||
-rw-r--r-- | noncore/apps/checkbook/opie-checkbook.control | 2 | ||||
-rw-r--r-- | noncore/apps/checkbook/traninfo.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/checkbook/traninfo.h | 2 | ||||
-rw-r--r-- | noncore/apps/checkbook/transaction.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/checkbook/transaction.h | 2 |
14 files changed, 114 insertions, 29 deletions
diff --git a/noncore/apps/checkbook/checkbook.cpp b/noncore/apps/checkbook/checkbook.cpp index ab25516..09b0b46 100644 --- a/noncore/apps/checkbook/checkbook.cpp +++ b/noncore/apps/checkbook/checkbook.cpp @@ -1,12 +1,12 @@ /* This file is part of the OPIE Project =. - .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> + .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. @@ -34,20 +34,20 @@ #include <opie/otabwidget.h> #include <qpe/config.h> #include <qpe/qpeapplication.h> #include <qpe/qpemessagebox.h> #include <qpe/resource.h> #include <qcombobox.h> #include <qfile.h> +#include <qfontmetrics.h> #include <qlabel.h> #include <qlayout.h> #include <qlineedit.h> -#include <qlistview.h> #include <qmultilineedit.h> #include <qpushbutton.h> #include <qwhatsthis.h> #include <qwidget.h> Checkbook::Checkbook( QWidget *parent, const QString &n, const QString &fd, char symbol ) : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) { @@ -196,22 +196,24 @@ QWidget *Checkbook::initTransactions() balanceLabel = new QLabel( tr( "Current balance: %10.00" ).arg( currencySymbol ), control ); QWhatsThis::add( balanceLabel, tr( "This area shows the current balance in this checkbook." ) ); layout->addMultiCellWidget( balanceLabel, 0, 0, 0, 2 ); tranTable = new QListView( control ); QWhatsThis::add( tranTable, tr( "This is a listing of all transactions entered for this checkbook.\n\nTo sort entries by a specific field, click on the column name." ) ); - tranTable->addColumn( tr( "ID" ) ); + tranTable->addColumn( tr( "Num" ) ); tranTable->addColumn( tr( "Date" ) ); + //tranTable->addColumn( tr( "Cleared" ) ); tranTable->addColumn( tr( "Description" ) ); int colnum = tranTable->addColumn( tr( "Amount" ) ); tranTable->setColumnAlignment( colnum, Qt::AlignRight ); tranTable->setAllColumnsShowFocus( TRUE ); + tranTable->setSorting( 1 ); layout->addMultiCellWidget( tranTable, 1, 1, 0, 2 ); QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold ); connect( tranTable, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), this, SLOT( slotEditTran() ) ); QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), control ); QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) ); connect( btn, SIGNAL( clicked() ), this, SLOT( slotNewTran() ) ); @@ -309,18 +311,17 @@ void Checkbook::loadCheckbook() } currBalance += amount; stramount.sprintf( "%c%.2f", currencySymbol, amount ); // Add to transaction list transactions.inSort( tran ); // Add to transaction table - ( void ) new QListViewItem( tranTable, QString::number( i ), tran->datestr(), - trandesc, stramount ); + ( void ) new CBListItem( tranTable, tran->number(), tran->datestr(), trandesc, stramount ); } else { delete tran; } } balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) ); @@ -329,21 +330,24 @@ void Checkbook::loadCheckbook() void Checkbook::adjustBalance( float amount ) { currBalance += amount; balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) ); } -TranInfo *Checkbook::findTranByID( int id ) +TranInfo *Checkbook::findTran( const QString &checknum, const QString &date, const QString &desc ) { TranInfo *traninfo = transactions.first(); - while ( traninfo && traninfo->id() != id ) + while ( traninfo ) { + if ( traninfo->number() == checknum && traninfo->datestr() == date && + traninfo->desc() == desc ) + break; traninfo = transactions.next(); } return( traninfo ); } void Checkbook::accept() { QFile f( filename ); @@ -413,18 +417,18 @@ void Checkbook::slotNewTran() } QString stramount; stramount.sprintf( "%c%.2f", currencySymbol, amount ); // Add to transaction list transactions.inSort( traninfo ); // Add to transaction table - ( void ) new QListViewItem( tranTable, QString::number( highTranNum ), - traninfo->datestr(), traninfo->desc(), stramount ); + ( void ) new CBListItem( tranTable, traninfo->number(), traninfo->datestr(), traninfo->desc(), + stramount ); adjustBalance( amount ); } else { highTranNum--; delete traninfo; } @@ -434,18 +438,17 @@ void Checkbook::slotEditTran() { bool ok; QListViewItem *curritem = tranTable->currentItem(); if ( !curritem ) { return; } - int tranid = curritem->text( 0 ).toInt( &ok ); - TranInfo *traninfo = findTranByID( tranid ); + TranInfo *traninfo = findTran( curritem->text( 0 ), curritem->text( 1 ), curritem->text( 2 ) ); float origamt = traninfo->amount(); if ( traninfo->withdrawal() ) { origamt *= -1; } Transaction *currtran = new Transaction( this, name, traninfo, @@ -477,19 +480,17 @@ void Checkbook::slotEditTran() void Checkbook::slotDeleteTran() { QListViewItem *curritem = tranTable->currentItem(); if ( !curritem ) { return; } - bool ok; - int tranid = curritem->text( 0 ).toInt( &ok ); - TranInfo *traninfo = findTranByID( tranid ); + TranInfo *traninfo = findTran( curritem->text( 0 ), curritem->text( 1 ), curritem->text( 2 ) ); if ( QPEMessageBox::confirmDelete ( this, tr( "Delete transaction" ), traninfo->desc() ) ) { float amount = traninfo->amount(); if ( traninfo->withdrawal() ) { amount *= -1; } @@ -589,8 +590,72 @@ void Checkbook::drawCategoryChart( bool withdrawals ) { // Didn't find category, add category to list list->append( new DataPointInfo( tran->category(), tran->amount() ) ); } } } graphInfo = new GraphInfo( GraphInfo::PieChart, list ); } + +CBListItem::CBListItem( QListView *parent, QString label1, QString label2, + QString label3, QString label4, QString label5, QString label6, QString label7, + QString label8 ) + : QListViewItem( parent, label1, label2, label3, label4, label5, label6, label7, label8 ) +{ + m_known = FALSE; + owner = parent; +} + +void CBListItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align ) +{ + QColorGroup _cg = cg; + const QPixmap *pm = listView()->viewport()->backgroundPixmap(); + if ( pm && !pm->isNull() ) + { + _cg.setBrush( QColorGroup::Base, QBrush( cg.base(), *pm ) ); + p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); + } + else if ( isAltBackground() ) + _cg.setColor(QColorGroup::Base, QColor( 200, 255, 200 ) ); + + QListViewItem::paintCell(p, _cg, column, width, align); +} + +bool CBListItem::isAltBackground() +{ + QListView *lv = static_cast<QListView *>( listView() ); + if ( lv ) + { + CBListItem *above = 0; + above = (CBListItem *)( itemAbove() ); + m_known = above ? above->m_known : true; + if ( m_known ) + { + m_odd = above ? !above->m_odd : false; + } + else + { + CBListItem *item; + bool previous = true; + if ( parent() ) + { + item = (CBListItem *)( parent() ); + if ( item ) + previous = item->m_odd; + item = (CBListItem *)( parent()->firstChild() ); + } + else + { + item = (CBListItem *)( lv->firstChild() ); + } + + while(item) + { + item->m_odd = previous = !previous; + item->m_known = true; + item = (CBListItem *)( item->nextSibling() ); + } + } + return m_odd; + } + return false; +}
\ No newline at end of file diff --git a/noncore/apps/checkbook/checkbook.h b/noncore/apps/checkbook/checkbook.h index 287788a..0260b43 100644 --- a/noncore/apps/checkbook/checkbook.h +++ b/noncore/apps/checkbook/checkbook.h @@ -1,12 +1,12 @@ /* This file is part of the OPIE Project =. - .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> + .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. @@ -27,16 +27,17 @@ */ #ifndef CHECKBOOK_H #define CHECKBOOK_H #include "traninfo.h" #include <qdialog.h> +#include <qlistview.h> class OTabWidget; class Graph; class GraphInfo; class QComboBox; class QLabel; class QLineEdit; @@ -60,17 +61,17 @@ class Checkbook : public QDialog QString filename; QString filedir; char currencySymbol; int highTranNum; OTabWidget *mainWidget; void loadCheckbook(); void adjustBalance( float ); - TranInfo *findTranByID( int ); + TranInfo *findTran( const QString &, const QString &, const QString & ); // Info tab QWidget *initInfo(); QLineEdit *nameEdit; QComboBox *typeList; QLineEdit *bankEdit; QLineEdit *acctNumEdit; QLineEdit *pinNumEdit; @@ -100,9 +101,28 @@ class Checkbook : public QDialog void slotNameChanged( const QString & ); void slotStartingBalanceChanged( const QString & ); void slotNewTran(); void slotEditTran(); void slotDeleteTran(); void slotDrawGraph(); }; +class CBListItem : public QListViewItem +{ + //Q_OBJECT + + public: + CBListItem( QListView *, QString = QString::null, QString = QString::null, + QString = QString::null, QString = QString::null, QString = QString::null, + QString = QString::null, QString = QString::null, QString = QString::null ); + + void paintCell( QPainter *, const QColorGroup &, int, int, int ); + + private: + QListView *owner; + bool m_known; + bool m_odd; + + bool isAltBackground(); +}; + #endif diff --git a/noncore/apps/checkbook/graph.cpp b/noncore/apps/checkbook/graph.cpp index 0f25453..8ae835c 100644 --- a/noncore/apps/checkbook/graph.cpp +++ b/noncore/apps/checkbook/graph.cpp @@ -1,12 +1,12 @@ /* This file is part of the OPIE Project =. - .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> + .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. diff --git a/noncore/apps/checkbook/graph.h b/noncore/apps/checkbook/graph.h index 40b23cd..0361718 100644 --- a/noncore/apps/checkbook/graph.h +++ b/noncore/apps/checkbook/graph.h @@ -1,12 +1,12 @@ /* This file is part of the OPIE Project =. - .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> + .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. diff --git a/noncore/apps/checkbook/graphinfo.cpp b/noncore/apps/checkbook/graphinfo.cpp index ec6a465..fec6896 100644 --- a/noncore/apps/checkbook/graphinfo.cpp +++ b/noncore/apps/checkbook/graphinfo.cpp @@ -1,12 +1,12 @@ /* This file is part of the OPIE Project =. - .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> + .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. diff --git a/noncore/apps/checkbook/graphinfo.h b/noncore/apps/checkbook/graphinfo.h index 620da74..3bcf676 100644 --- a/noncore/apps/checkbook/graphinfo.h +++ b/noncore/apps/checkbook/graphinfo.h @@ -1,12 +1,12 @@ /* This file is part of the OPIE Project =. - .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> + .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. diff --git a/noncore/apps/checkbook/main.cpp b/noncore/apps/checkbook/main.cpp index 832bd09..abfa633 100644 --- a/noncore/apps/checkbook/main.cpp +++ b/noncore/apps/checkbook/main.cpp @@ -1,12 +1,12 @@ /* This file is part of the OPIE Project =. - .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> + .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. diff --git a/noncore/apps/checkbook/mainwindow.cpp b/noncore/apps/checkbook/mainwindow.cpp index 2eb8396..567b8ad 100644 --- a/noncore/apps/checkbook/mainwindow.cpp +++ b/noncore/apps/checkbook/mainwindow.cpp @@ -1,12 +1,12 @@ /* This file is part of the OPIE Project =. - .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> + .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. diff --git a/noncore/apps/checkbook/mainwindow.h b/noncore/apps/checkbook/mainwindow.h index 2c5d93b..1b460fa 100644 --- a/noncore/apps/checkbook/mainwindow.h +++ b/noncore/apps/checkbook/mainwindow.h @@ -1,12 +1,12 @@ /* This file is part of the OPIE Project =. - .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> + .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. diff --git a/noncore/apps/checkbook/opie-checkbook.control b/noncore/apps/checkbook/opie-checkbook.control index 7bde1db..817426c 100644 --- a/noncore/apps/checkbook/opie-checkbook.control +++ b/noncore/apps/checkbook/opie-checkbook.control @@ -1,9 +1,9 @@ Files: bin/checkbook apps/Applications/checkbook.desktop pics/checkbook Priority: optional Section: applications -Maintainer: Dan Williams <williamsdr@acm.org> +Maintainer: Dan Williams <drw@handhelds.org> Architecture: arm Version: $QPE_VERSION-$SUB_VERSION Depends: opie-base ($QPE_VERSION), libopie ($QPE_VERSION) Description: Checkbook keeping program. The checkbook accounting program for the Opie environment. diff --git a/noncore/apps/checkbook/traninfo.cpp b/noncore/apps/checkbook/traninfo.cpp index dcba869..65c190c 100644 --- a/noncore/apps/checkbook/traninfo.cpp +++ b/noncore/apps/checkbook/traninfo.cpp @@ -1,12 +1,12 @@ /* This file is part of the OPIE Project =. - .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> + .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. @@ -182,9 +182,9 @@ int TranInfoList::compareItems( QCollection::Item item1, QCollection::Item item2 if ( d1 < d2 ) r = -1; else if ( d1 == d2 ) r = 0; else if ( d1 > d2 ) r = 1; return( r ); -}
\ No newline at end of file +} diff --git a/noncore/apps/checkbook/traninfo.h b/noncore/apps/checkbook/traninfo.h index e488816..59cfe14 100644 --- a/noncore/apps/checkbook/traninfo.h +++ b/noncore/apps/checkbook/traninfo.h @@ -1,12 +1,12 @@ /* This file is part of the OPIE Project =. - .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> + .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. diff --git a/noncore/apps/checkbook/transaction.cpp b/noncore/apps/checkbook/transaction.cpp index a921491..122c8d6 100644 --- a/noncore/apps/checkbook/transaction.cpp +++ b/noncore/apps/checkbook/transaction.cpp @@ -1,12 +1,12 @@ /* This file is part of the OPIE Project =. - .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> + .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. diff --git a/noncore/apps/checkbook/transaction.h b/noncore/apps/checkbook/transaction.h index 274e1f2..89ca8e4 100644 --- a/noncore/apps/checkbook/transaction.h +++ b/noncore/apps/checkbook/transaction.h @@ -1,12 +1,12 @@ /* This file is part of the OPIE Project =. - .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> + .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. |