summaryrefslogtreecommitdiff
authordrw <drw>2002-11-30 22:51:39 (UTC)
committer drw <drw>2002-11-30 22:51:39 (UTC)
commit666313593479c03cdc88bd8fde926af181cb8423 (patch) (side-by-side diff)
tree79f5334d7ec7918146469d567466607ebaea28a8
parent2e2bbf823ba532f349ad9ca3dd84cf7f758f36b0 (diff)
downloadopie-666313593479c03cdc88bd8fde926af181cb8423.zip
opie-666313593479c03cdc88bd8fde926af181cb8423.tar.gz
opie-666313593479c03cdc88bd8fde926af181cb8423.tar.bz2
Checkbook password protection
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/checkbook/checkbook.cpp96
-rw-r--r--noncore/apps/checkbook/checkbook.h9
-rw-r--r--noncore/apps/checkbook/checkbook.pro2
-rw-r--r--noncore/apps/checkbook/mainwindow.cpp26
-rw-r--r--noncore/apps/checkbook/mainwindow.h2
-rw-r--r--noncore/apps/checkbook/password.cpp99
-rw-r--r--noncore/apps/checkbook/password.h55
-rw-r--r--noncore/apps/checkbook/transaction.cpp2
-rw-r--r--noncore/apps/checkbook/transaction.h4
9 files changed, 264 insertions, 31 deletions
diff --git a/noncore/apps/checkbook/checkbook.cpp b/noncore/apps/checkbook/checkbook.cpp
index 09b0b46..5a6d607 100644
--- a/noncore/apps/checkbook/checkbook.cpp
+++ b/noncore/apps/checkbook/checkbook.cpp
@@ -1,661 +1,715 @@
/*
                This file is part of the OPIE Project
=.
             .=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>       _;_.
    .i_,=:_.      -<s. This file is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
..}^=.=       =       ; Public License for more details.
++=   -.     .`     .:
 :     =  ...= . :.=- You should have received a copy of the GNU
 -.   .:....=;==+<; General Public License along with this file;
  -_. . .   )=.  = see the file COPYING. If not, write to the
    --        :-=` Free Software Foundation, Inc.,
59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "checkbook.h"
#include "transaction.h"
#include "graph.h"
#include "graphinfo.h"
+#include "password.h"
#include <opie/otabwidget.h>
#include <qpe/config.h>
#include <qpe/qpeapplication.h>
#include <qpe/qpemessagebox.h>
#include <qpe/resource.h>
+#include <qcheckbox.h>
#include <qcombobox.h>
#include <qfile.h>
#include <qfontmetrics.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qlineedit.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 )
+Checkbook::Checkbook( QWidget *parent, const QString &n, const QString &fd, const QString &symbol )
: QDialog( parent, 0, TRUE, WStyle_ContextHelp )
{
name = n;
filename = fd;
filename.append( name );
filename.append( ".qcb" );
filedir = fd;
currencySymbol = symbol;
currBalance = 0.0;
if ( name != "" )
{
QString tempstr = name;
tempstr.append( " - " );
tempstr.append( tr( "Checkbook" ) );
setCaption( tempstr );
}
else
{
setCaption( tr( "New checkbook" ) );
}
// Setup layout to make everything pretty
QVBoxLayout *layout = new QVBoxLayout( this );
layout->setMargin( 2 );
layout->setSpacing( 4 );
// Setup tabs for all info
mainWidget = new OTabWidget( this );
layout->addWidget( mainWidget );
mainWidget->addTab( initInfo(), "checkbook/infotab", tr( "Info" ) );
mainWidget->addTab( initTransactions(), "checkbook/trantab", tr( "Transactions" ) );
mainWidget->addTab( initCharts(), "checkbook/charttab", tr( "Charts" ) );
mainWidget->setCurrentTab( tr( "Info" ) );
// Load checkbook information
loadCheckbook();
}
Checkbook::~Checkbook()
{
}
const QString &Checkbook::getName()
{
return( name );
}
QWidget *Checkbook::initInfo()
{
QWidget *control = new QWidget( mainWidget );
QVBoxLayout *vb = new QVBoxLayout( control );
QScrollView *sv = new QScrollView( control );
vb->addWidget( sv, 0, 0 );
sv->setResizePolicy( QScrollView::AutoOneFit );
sv->setFrameStyle( QFrame::NoFrame );
QWidget *container = new QWidget( sv->viewport() );
sv->addChild( container );
QGridLayout *layout = new QGridLayout( container );
layout->setSpacing( 2 );
layout->setMargin( 4 );
+ // Password protection
+ passwordCB = new QCheckBox( tr( "Password protect" ), container );
+ QWhatsThis::add( passwordCB, tr( "Click here to enable/disable password protection of this checkbook." ) );
+ connect( passwordCB, SIGNAL( clicked() ), this, SLOT( slotPasswordClicked() ) );
+ layout->addMultiCellWidget( passwordCB, 0, 0, 0, 1 );
+
// Account name
QLabel *label = new QLabel( tr( "Name:" ), container );
QWhatsThis::add( label, tr( "Enter name of checkbook here." ) );
- layout->addWidget( label, 0, 0 );
+ layout->addWidget( label, 1, 0 );
nameEdit = new QLineEdit( container );
QWhatsThis::add( nameEdit, tr( "Enter name of checkbook here." ) );
connect( nameEdit, SIGNAL( textChanged( const QString & ) ),
this, SLOT( slotNameChanged( const QString & ) ) );
- layout->addWidget( nameEdit, 0, 1 );
+ layout->addWidget( nameEdit, 1, 1 );
// Type of account
label = new QLabel( tr( "Type:" ), container );
QWhatsThis::add( label, tr( "Select type of checkbook here." ) );
- layout->addWidget( label, 1, 0 );
+ layout->addWidget( label, 2, 0 );
typeList = new QComboBox( container );
QWhatsThis::add( typeList, tr( "Select type of checkbook here." ) );
typeList->insertItem( tr( "Savings" ) ); // 0
typeList->insertItem( tr( "Checking" ) ); // 1
typeList->insertItem( tr( "CD" ) ); // 2
typeList->insertItem( tr( "Money market" ) ); // 3
typeList->insertItem( tr( "Mutual fund" ) ); // 4
typeList->insertItem( tr( "Other" ) ); // 5
- layout->addWidget( typeList, 1, 1 );
+ layout->addWidget( typeList, 2, 1 );
// Bank/institution name
label = new QLabel( tr( "Bank:" ), container );
QWhatsThis::add( label, tr( "Enter name of the bank for this checkbook here." ) );
- layout->addWidget( label, 2, 0 );
+ layout->addWidget( label, 3, 0 );
bankEdit = new QLineEdit( container );
QWhatsThis::add( bankEdit, tr( "Enter name of the bank for this checkbook here." ) );
- layout->addWidget( bankEdit, 2, 1 );
+ layout->addWidget( bankEdit, 3, 1 );
// Account number
label = new QLabel( tr( "Account number:" ), container );
QWhatsThis::add( label, tr( "Enter account number for this checkbook here." ) );
- layout->addWidget( label, 3, 0 );
+ layout->addWidget( label, 4, 0 );
acctNumEdit = new QLineEdit( container );
QWhatsThis::add( acctNumEdit, tr( "Enter account number for this checkbook here." ) );
- layout->addWidget( acctNumEdit, 3, 1 );
+ layout->addWidget( acctNumEdit, 4, 1 );
// PIN number
label = new QLabel( tr( "PIN number:" ), container );
QWhatsThis::add( label, tr( "Enter PIN number for this checkbook here." ) );
- layout->addWidget( label, 4, 0 );
+ layout->addWidget( label, 5, 0 );
pinNumEdit = new QLineEdit( container );
QWhatsThis::add( pinNumEdit, tr( "Enter PIN number for this checkbook here." ) );
- layout->addWidget( pinNumEdit, 4, 1 );
+ layout->addWidget( pinNumEdit, 5, 1 );
// Starting balance
label = new QLabel( tr( "Starting balance:" ), container );
QWhatsThis::add( label, tr( "Enter the initial balance for this checkbook here." ) );
- layout->addWidget( label, 5, 0 );
+ layout->addWidget( label, 6, 0 );
balanceEdit = new QLineEdit( container );
QWhatsThis::add( balanceEdit, tr( "Enter the initial balance for this checkbook here." ) );
connect( balanceEdit, SIGNAL( textChanged( const QString & ) ),
this, SLOT( slotStartingBalanceChanged( const QString & ) ) );
- layout->addWidget( balanceEdit, 5, 1 );
+ layout->addWidget( balanceEdit, 6, 1 );
// Notes
label = new QLabel( tr( "Notes:" ), container );
QWhatsThis::add( label, tr( "Enter any additional information for this checkbook here." ) );
- layout->addWidget( label, 6, 0 );
+ layout->addWidget( label, 7, 0 );
notesEdit = new QMultiLineEdit( container );
QWhatsThis::add( notesEdit, tr( "Enter any additional information for this checkbook here." ) );
- notesEdit->setMaximumHeight( 85 );
- layout->addMultiCellWidget( notesEdit, 7, 7, 0, 1 );
+ notesEdit->setMinimumHeight( 25 );
+ notesEdit->setMaximumHeight( 65 );
+ layout->addMultiCellWidget( notesEdit, 8, 8, 0, 1 );
return control;
}
QWidget *Checkbook::initTransactions()
{
QWidget *control = new QWidget( mainWidget );
QGridLayout *layout = new QGridLayout( control );
layout->setSpacing( 2 );
layout->setMargin( 4 );
balanceLabel = new QLabel( tr( "Current balance: %10.00" ).arg( currencySymbol ),
control );
QWhatsThis::add( balanceLabel, tr( "This area shows the current balance in this checkbook." ) );
layout->addMultiCellWidget( balanceLabel, 0, 0, 0, 2 );
tranTable = new QListView( control );
QWhatsThis::add( tranTable, tr( "This is a listing of all transactions entered for this checkbook.\n\nTo sort entries by a specific field, click on the column name." ) );
tranTable->addColumn( tr( "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() ) );
layout->addWidget( btn, 2, 0 );
btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), control );
QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) );
connect( btn, SIGNAL( clicked() ), this, SLOT( slotEditTran() ) );
layout->addWidget( btn, 2, 1 );
btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), control );
QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) );
connect( btn, SIGNAL( clicked() ), this, SLOT( slotDeleteTran() ) );
layout->addWidget( btn, 2, 2 );
return( control );
}
QWidget *Checkbook::initCharts()
{
graphInfo = 0x0;
QWidget *control = new QWidget( mainWidget );
QGridLayout *layout = new QGridLayout( control );
layout->setSpacing( 2 );
layout->setMargin( 4 );
graphWidget = new Graph( control );
QWhatsThis::add( graphWidget, tr( "Select the desired chart below and then click on the Draw button." ) );
layout->addMultiCellWidget( graphWidget, 0, 0, 0, 2 );
graphList = new QComboBox( control );
QWhatsThis::add( graphList, tr( "Click here to select the desired chart type." ) );
graphList->insertItem( tr( "Account balance" ) );
graphList->insertItem( tr( "Withdrawals by category" ) );
graphList->insertItem( tr( "Deposits by category" ) );
layout->addMultiCellWidget( graphList, 1, 1, 0, 1 );
QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/drawbtn" ), tr( "Draw" ), control );
QWhatsThis::add( btn, tr( "Click here to draw the selected chart." ) );
connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) );
layout->addWidget( btn, 1, 2 );
return control;
}
void Checkbook::loadCheckbook()
{
transactions.clear();
- Config config(filename, Config::File);
+ Config config( filename, Config::File );
// Load info
config.setGroup( "Account" );
+
+ password = config.readEntryCrypt( "Password", "" );
+ passwordCB->setChecked( password != "" );
nameEdit->setText( name );
QString temptext = config.readEntry( "Type" );
int i = typeList->count();
while ( i > 0 )
{
i--;
typeList->setCurrentItem( i );
if ( typeList->currentText() == temptext )
{
break;
}
}
bankEdit->setText( config.readEntry( "Bank", "" ) );
acctNumEdit->setText( config.readEntryCrypt( "Number", "" ) );
pinNumEdit->setText( config.readEntryCrypt( "PINNumber", "" ) );
balanceEdit->setText( config.readEntry( "Balance", "0.0" ) );
notesEdit->setText( config.readEntry( "Notes", "" ) );
bool ok;
currBalance = balanceEdit->text().toFloat( &ok );
startBalance = currBalance;
// Load transactions
TranInfo *tran;
QString trandesc = "";
float amount;
QString stramount;
for ( int i = 1; trandesc != QString::null; i++ )
{
tran = new TranInfo( config, i );
trandesc = tran->desc();
if ( trandesc != QString::null )
{
currBalance -= tran->fee();
amount = tran->amount();
if ( tran->withdrawal() )
{
amount *= -1;
}
currBalance += amount;
- stramount.sprintf( "%c%.2f", currencySymbol, amount );
+ stramount.sprintf( "%s%.2f", currencySymbol.latin1(), amount );
// Add to transaction list
transactions.inSort( tran );
// Add to transaction table
( 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 ) );
highTranNum = transactions.count();
}
void Checkbook::adjustBalance( float amount )
{
currBalance += amount;
balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) );
}
TranInfo *Checkbook::findTran( const QString &checknum, const QString &date, const QString &desc )
{
TranInfo *traninfo = transactions.first();
while ( traninfo )
{
if ( traninfo->number() == checknum && traninfo->datestr() == date &&
traninfo->desc() == desc )
break;
traninfo = transactions.next();
}
return( traninfo );
}
void Checkbook::accept()
{
QFile f( filename );
if ( f.exists() )
{
f.remove();
}
Config *config = new Config(filename, Config::File);
// Save info
config->setGroup( "Account" );
+ config->writeEntryCrypt( "Password", password );
config->writeEntry( "Type", typeList->currentText() );
config->writeEntry( "Bank", bankEdit->text() );
config->writeEntryCrypt( "Number", acctNumEdit->text() );
config->writeEntryCrypt( "PINNumber", pinNumEdit->text() );
config->writeEntry( "Balance", balanceEdit->text() );
config->writeEntry( "Notes", notesEdit->text() );
// Save transactions
int i = 1;
for ( TranInfo *tran = transactions.first(); tran; tran = transactions.next() )
{
tran->write( config, i );
i++;
}
config->write();
QDialog::accept();
}
+void Checkbook::slotPasswordClicked()
+{
+ if ( password == "" && passwordCB->isChecked() )
+ {
+ Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) );
+ if ( pw->exec() != QDialog::Accepted )
+ {
+ passwordCB->setChecked( FALSE );
+ delete pw;
+ return;
+ }
+ password = pw->password;
+ delete pw;
+
+ pw = new Password( this, tr( "Confirm password" ), tr( "Please confirm your password:" ) );
+ if ( pw->exec() != QDialog::Accepted || pw->password != password )
+ {
+ passwordCB->setChecked( FALSE );
+ password = "";
+ }
+
+ delete pw;
+ }
+ else if ( password != "" && !passwordCB->isChecked() )
+ {
+ Password *pw = new Password( this, tr( "Enter password" ),
+ tr( "Please enter your password to confirm removal of password protection:" ) );
+ if ( pw->exec() == QDialog::Accepted && pw->password == password )
+ {
+ password = "";
+ delete pw;
+ return;
+ }
+ else
+ {
+ passwordCB->setChecked( TRUE );
+ }
+
+ delete pw;
+ }
+}
+
void Checkbook::slotNameChanged( const QString &newname )
{
name = newname;
filename = filedir;
filename.append( newname );
filename.append( ".qcb" );
QString tempstr = name;
tempstr.append( " - " );
tempstr.append( tr( "Checkbook" ) );
setCaption( tempstr );
}
void Checkbook::slotStartingBalanceChanged( const QString &newbalance )
{
currBalance -= startBalance;
bool ok;
startBalance = newbalance.toFloat( &ok );
adjustBalance( startBalance );
}
void Checkbook::slotNewTran()
{
highTranNum++;
TranInfo *traninfo = new TranInfo( highTranNum );
Transaction *currtran = new Transaction( this, name,
traninfo,
currencySymbol );
currtran->showMaximized();
if ( currtran->exec() == QDialog::Accepted )
{
float amount = traninfo->amount();
if ( traninfo->withdrawal() )
{
amount *= -1;
}
QString stramount;
- stramount.sprintf( "%c%.2f", currencySymbol, amount );
+ stramount.sprintf( "%s%.2f", currencySymbol.latin1(), amount );
// Add to transaction list
transactions.inSort( traninfo );
// Add to transaction table
( void ) new CBListItem( tranTable, traninfo->number(), traninfo->datestr(), traninfo->desc(),
stramount );
adjustBalance( amount );
}
else
{
highTranNum--;
delete traninfo;
}
}
void Checkbook::slotEditTran()
{
- bool ok;
QListViewItem *curritem = tranTable->currentItem();
if ( !curritem )
{
return;
}
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,
currencySymbol );
currtran->showMaximized();
if ( currtran->exec() == QDialog::Accepted )
{
curritem->setText( 1, traninfo->datestr() );
curritem->setText( 2, traninfo->desc() );
float amount = traninfo->amount();
if ( traninfo->withdrawal() )
{
amount *= -1;
}
adjustBalance( origamt * -1 );
adjustBalance( amount );
QString stramount;
- stramount.sprintf( "%c%.2f", currencySymbol, amount );
+ stramount.sprintf( "%s%.2f", currencySymbol.latin1(), amount );
curritem->setText( 3, stramount );
balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) );
delete currtran;
}
}
void Checkbook::slotDeleteTran()
{
QListViewItem *curritem = tranTable->currentItem();
if ( !curritem )
{
return;
}
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;
}
transactions.remove( traninfo );
delete traninfo;
delete curritem;
adjustBalance( amount * -1 );
}
}
void Checkbook::slotDrawGraph()
{
if ( graphInfo )
{
delete graphInfo;
}
switch ( graphList->currentItem() )
{
case 0 : drawBalanceChart();
break;
case 1 : drawCategoryChart( TRUE );
break;
case 2 : drawCategoryChart( FALSE );
break;
};
graphWidget->setGraphInfo( graphInfo );
graphWidget->drawGraph( TRUE );
}
void Checkbook::drawBalanceChart()
{
DataPointList *list = new DataPointList();
float balance = startBalance;
float amount;
QString label;
int i = 0;
int count = transactions.count();
for ( TranInfo *tran = transactions.first(); tran; tran = transactions.next() )
{
i++;
balance -= tran->fee();
amount = tran->amount();
if ( tran->withdrawal() )
{
amount *= -1;
}
balance += amount;
if ( i == 1 || i == count / 2 || i == count )
{
label = tran->datestr();
}
else
{
label = "";
}
list->append( new DataPointInfo( label, balance ) );
}
graphInfo = new GraphInfo( GraphInfo::BarChart, list );
}
void Checkbook::drawCategoryChart( bool withdrawals )
{
DataPointList *list = new DataPointList();
TranInfo *tran = transactions.first();
if ( tran && tran->withdrawal() == withdrawals )
{
list->append( new DataPointInfo( tran->category(), tran->amount() ) );
}
tran = transactions.next();
DataPointInfo *cat;
for ( ; tran; tran = transactions.next() )
{
if ( tran->withdrawal() == withdrawals )
{
// Find category in list
for ( cat = list->first(); cat; cat = list->next() )
{
if ( cat->label() == tran->category() )
{
break;
}
}
if ( cat && cat->label() == tran->category() )
{ // Found category, add to transaction to category total
cat->addToValue( tran->amount() );
}
else
{ // 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 0260b43..27658ff 100644
--- a/noncore/apps/checkbook/checkbook.h
+++ b/noncore/apps/checkbook/checkbook.h
@@ -1,128 +1,133 @@
/*
                This file is part of the OPIE Project
=.
             .=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>       _;_.
    .i_,=:_.      -<s. This file is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
..}^=.=       =       ; Public License for more details.
++=   -.     .`     .:
 :     =  ...= . :.=- You should have received a copy of the GNU
 -.   .:....=;==+<; General Public License along with this file;
  -_. . .   )=.  = see the file COPYING. If not, write to the
    --        :-=` Free Software Foundation, Inc.,
59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef CHECKBOOK_H
#define CHECKBOOK_H
#include "traninfo.h"
#include <qdialog.h>
#include <qlistview.h>
class OTabWidget;
class Graph;
class GraphInfo;
+class QCheckBox;
class QComboBox;
class QLabel;
class QLineEdit;
class QListView;
class QMultiLineEdit;
class QString;
class Checkbook : public QDialog
{
Q_OBJECT
public:
- Checkbook( QWidget * = 0x0, const QString & = 0x0, const QString & = 0x0, char = '$' );
+ Checkbook( QWidget * = 0x0, const QString & = 0x0, const QString & = 0x0,
+ const QString & = "$" );
~Checkbook();
const QString &getName();
private:
TranInfoList transactions;
QString name;
QString filename;
QString filedir;
- char currencySymbol;
+ QString currencySymbol;
+ QString password;
int highTranNum;
OTabWidget *mainWidget;
void loadCheckbook();
void adjustBalance( float );
TranInfo *findTran( const QString &, const QString &, const QString & );
// Info tab
QWidget *initInfo();
+ QCheckBox *passwordCB;
QLineEdit *nameEdit;
QComboBox *typeList;
QLineEdit *bankEdit;
QLineEdit *acctNumEdit;
QLineEdit *pinNumEdit;
QLineEdit *balanceEdit;
QMultiLineEdit *notesEdit;
float startBalance;
// Transactions tab
QWidget *initTransactions();
QListView *tranTable;
QLabel *balanceLabel;
float currBalance;
// Charts tab
QWidget *initCharts();
GraphInfo *graphInfo;
QComboBox *graphList;
Graph *graphWidget;
void drawBalanceChart();
void drawCategoryChart( bool = TRUE );
protected slots:
void accept();
private slots:
+ void slotPasswordClicked();
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/checkbook.pro b/noncore/apps/checkbook/checkbook.pro
index bd69939..53b5ff4 100644
--- a/noncore/apps/checkbook/checkbook.pro
+++ b/noncore/apps/checkbook/checkbook.pro
@@ -1,36 +1,38 @@
TEMPLATE = app
CONFIG = qt warn_on release
HEADERS = mainwindow.h \
traninfo.h \
graphinfo.h \
+ password.h \
checkbook.h \
transaction.h \
graph.h
SOURCES = main.cpp \
mainwindow.cpp \
traninfo.cpp \
graphinfo.cpp \
+ password.cpp \
checkbook.cpp \
transaction.cpp \
graph.cpp
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -lopie
TARGET = checkbook
DESTDIR = $(OPIEDIR)/bin
TRANSLATIONS = ../../../i18n/de/checkbook.ts \
../../../i18n/en/checkbook.ts \
../../../i18n/es/checkbook.ts \
../../../i18n/fr/checkbook.ts \
../../../i18n/hu/checkbook.ts \
../../../i18n/ja/checkbook.ts \
../../../i18n/ko/checkbook.ts \
../../../i18n/no/checkbook.ts \
../../../i18n/pl/checkbook.ts \
../../../i18n/pt/checkbook.ts \
../../../i18n/pt_BR/checkbook.ts \
../../../i18n/sl/checkbook.ts \
../../../i18n/zh_CN/checkbook.ts \
../../../i18n/zh_TW/checkbook.ts \
../../../i18n/it/checkbook.ts
diff --git a/noncore/apps/checkbook/mainwindow.cpp b/noncore/apps/checkbook/mainwindow.cpp
index 567b8ad..2c0abf1 100644
--- a/noncore/apps/checkbook/mainwindow.cpp
+++ b/noncore/apps/checkbook/mainwindow.cpp
@@ -1,168 +1,186 @@
/*
                This file is part of the OPIE Project
=.
             .=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>       _;_.
    .i_,=:_.      -<s. This file is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
..}^=.=       =       ; Public License for more details.
++=   -.     .`     .:
 :     =  ...= . :.=- You should have received a copy of the GNU
 -.   .:....=;==+<; General Public License along with this file;
  -_. . .   )=.  = see the file COPYING. If not, write to the
    --        :-=` Free Software Foundation, Inc.,
59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "mainwindow.h"
+#include "password.h"
#include "checkbook.h"
+#include <qpe/config.h>
#include <qpe/global.h>
#include <qpe/qpeapplication.h>
#include <qpe/qpemenubar.h>
#include <qpe/qpemessagebox.h>
#include <qpe/qpetoolbar.h>
#include <qpe/resource.h>
#include <qaction.h>
#include <qdir.h>
#include <qlistbox.h>
#include <qpopupmenu.h>
#include <qstring.h>
#include <qwhatsthis.h>
MainWindow::MainWindow()
: QMainWindow( 0x0, 0x0, WStyle_ContextHelp )
{
setCaption( tr( "Checkbook" ) );
cbDir = Global::applicationFileName( "checkbook", "" );
// Build menu and tool bars
setToolBarsMovable( FALSE );
QPEToolBar *bar = new QPEToolBar( this );
bar->setHorizontalStretchable( TRUE );
QPEMenuBar *mb = new QPEMenuBar( bar );
mb->setMargin( 0 );
QPopupMenu *popup = new QPopupMenu( this );
bar = new QPEToolBar( this );
QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to create a new checkbook.\n\nYou also can select New from the Checkbook menu." ) );
connect( a, SIGNAL( activated() ), this, SLOT( slotNew() ) );
a->addTo( popup );
a->addTo( bar );
actionOpen = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null,
0, this, 0 );
actionOpen->setWhatsThis( tr( "Select a checkbook and then click here to edit it.\n\nYou also can select Edit from the Checkbook menu, or click and hold on a checkbook name." ) );
connect( actionOpen, SIGNAL( activated() ), this, SLOT( slotEdit() ) );
actionOpen->addTo( popup );
actionOpen->addTo( bar );
actionDelete = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null,
0, this, 0 );
actionDelete->setWhatsThis( tr( "Select a checkbook and then click here delete it.\n\nYou also can select Delete from the Checkbook menu." ) );
connect( actionDelete, SIGNAL( activated() ), this, SLOT( slotDelete() ) );
actionDelete->addTo( popup );
actionDelete->addTo( bar );
mb->insertItem( tr( "Checkbook" ), popup );
// Build Checkbook selection list control
cbList = new QListBox( this );
QWhatsThis::add( cbList, tr( "This is a listing of all checkbooks currently available." ) );
QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold );
connect( cbList, SIGNAL( rightButtonPressed( QListBoxItem *, const QPoint & ) ),
this, SLOT( slotEdit() ) );
setCentralWidget( cbList );
// Load Checkbook selection list
QDir checkdir( cbDir );
if (checkdir.exists() == true)
{
QStringList checkbooks = checkdir.entryList( "*.qcb", QDir::Files|QDir::Readable|QDir::Writable,
QDir::Time );
for ( QStringList::Iterator it = checkbooks.begin(); it != checkbooks.end(); it++ )
{
(*it) = (*it).remove( (*it).find('.'), (*it).length() );
}
cbList->insertStringList( checkbooks );
}
cbList->sort();
cbList->setSelected( 0, TRUE );
- currencySymbol = '$';
+ currencySymbol = "$";
}
MainWindow::~MainWindow()
{
}
void MainWindow::slotNew()
{
Checkbook *currcb = new Checkbook( this, "", cbDir, currencySymbol );
currcb->showMaximized();
if ( currcb->exec() == QDialog::Accepted )
{
cbList->insertItem( currcb->getName() );
cbList->sort();
delete currcb;
}
}
void MainWindow::slotEdit()
{
QString currname = cbList->currentText();
+
+ QString tempstr = cbDir;
+ tempstr.append( currname );
+ tempstr.append( ".qcb" );
+
+ Config config( tempstr, Config::File );
+ config.setGroup( "Account" );
+ QString password = config.readEntryCrypt( "Password", "" );
+ if ( password != "" )
+ {
+ Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) );
+ if ( pw->exec() != QDialog::Accepted || pw->password != password )
+ {
+ delete pw;
+ return;
+ }
+ delete pw;
+ }
+
Checkbook *currcb = new Checkbook( this, currname, cbDir, currencySymbol );
currcb->showMaximized();
if ( currcb->exec() == QDialog::Accepted )
{
QString newname = currcb->getName();
if ( currname != newname )
{
cbList->changeItem( newname, cbList->currentItem() );
cbList->sort();
- QString tempstr = cbDir;
- tempstr.append( currname );
- tempstr.append( ".qcb" );
QFile f( tempstr );
if ( f.exists() )
{
f.remove();
}
}
delete currcb;
}
}
void MainWindow::slotDelete()
{
if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), cbList->currentText() ) )
{
QString tempstr = cbDir;
tempstr.append( cbList->currentText() );
tempstr.append( ".qcb" );
QFile f( tempstr );
if ( f.exists() )
{
f.remove();
}
cbList->removeItem( cbList->currentItem() );
}
}
diff --git a/noncore/apps/checkbook/mainwindow.h b/noncore/apps/checkbook/mainwindow.h
index 1b460fa..11a3343 100644
--- a/noncore/apps/checkbook/mainwindow.h
+++ b/noncore/apps/checkbook/mainwindow.h
@@ -1,60 +1,60 @@
/*
                This file is part of the OPIE Project
=.
             .=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>       _;_.
    .i_,=:_.      -<s. This file is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
..}^=.=       =       ; Public License for more details.
++=   -.     .`     .:
 :     =  ...= . :.=- You should have received a copy of the GNU
 -.   .:....=;==+<; General Public License along with this file;
  -_. . .   )=.  = see the file COPYING. If not, write to the
    --        :-=` Free Software Foundation, Inc.,
59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <qmainwindow.h>
class QAction;
class QListBox;
class QListBoxItem;
class QString;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow();
~MainWindow();
private:
QListBox *cbList;
QString cbDir;
QAction *actionOpen;
QAction *actionDelete;
- char currencySymbol;
+ QString currencySymbol;
private slots:
void slotNew();
void slotEdit();
void slotDelete();
};
#endif
diff --git a/noncore/apps/checkbook/password.cpp b/noncore/apps/checkbook/password.cpp
new file mode 100644
index 0000000..82020d5
--- a/dev/null
+++ b/noncore/apps/checkbook/password.cpp
@@ -0,0 +1,99 @@
+/*
+                This file is part of the OPIE Project
+ =.
+             .=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>       _;_.
+    .i_,=:_.      -<s. This file is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
+..}^=.=       =       ; Public License for more details.
+++=   -.     .`     .:
+ :     =  ...= . :.=- You should have received a copy of the GNU
+ -.   .:....=;==+<; General Public License along with this file;
+  -_. . .   )=.  = see the file COPYING. If not, write to the
+    --        :-=` Free Software Foundation, Inc.,
+ 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+*/
+
+#include "password.h"
+
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qpixmap.h>
+#include <qpushbutton.h>
+#include <qwidget.h>
+
+static const char* const showhideimage_data[] = {
+"16 16 2 1",
+". c None",
+"# c #000000",
+"................",
+"...#...###...##.",
+"..#.#..#..#.##..",
+"..###..###.##...",
+".#...#.#..##....",
+".#...#.#.##.....",
+"........##.#..#.",
+"..##...##...##..",
+".#..#.###...##..",
+".#...##..#.#..#.",
+".#..##..........",
+".#.##.#..#.#..#.",
+"..##...##...##..",
+".##....##...##..",
+".#....#..#.#..#.",
+"................"};
+
+Password::Password( QWidget *parent, const char *caption, const char *prompt )
+ : QDialog( parent, 0x0, TRUE, 0x0 )
+{
+ setCaption( caption );
+
+ QGridLayout *layout = new QGridLayout( this );
+ layout->setSpacing( 2 );
+ layout->setMargin( 4 );
+
+ QLabel *label = new QLabel( prompt, this );
+ label->setAlignment( AlignLeft | AlignTop | WordBreak );
+ layout->addMultiCellWidget( label, 0, 0, 0, 1 );
+
+ pw = new QLineEdit( this );
+ pw->setEchoMode( QLineEdit::Password );
+ layout->addWidget( pw, 1, 0 );
+
+ QPixmap *pic = new QPixmap( ( const char** ) showhideimage_data );
+ QPushButton *btn = new QPushButton( ( QIconSet ) *pic, QString::null, this );
+ btn->setMaximumSize( pic->width() + 10, pic->height() + 10 );
+ btn->setToggleButton( TRUE );
+ connect( btn, SIGNAL( toggled( bool ) ), this, SLOT( slotTogglePassword( bool ) ) );
+ layout->addWidget( btn, 1, 1 );
+
+ password == "";
+}
+
+Password::~Password()
+{
+}
+
+void Password::accept()
+{
+ password = pw->text();
+ QDialog::accept();
+}
+
+void Password::slotTogglePassword( bool showPW )
+{
+ showPW ? pw->setEchoMode( QLineEdit::Normal ) : pw->setEchoMode( QLineEdit::Password );
+}
diff --git a/noncore/apps/checkbook/password.h b/noncore/apps/checkbook/password.h
new file mode 100644
index 0000000..87d64d9
--- a/dev/null
+++ b/noncore/apps/checkbook/password.h
@@ -0,0 +1,55 @@
+/*
+                This file is part of the OPIE Project
+ =.
+             .=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>       _;_.
+    .i_,=:_.      -<s. This file is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
+..}^=.=       =       ; Public License for more details.
+++=   -.     .`     .:
+ :     =  ...= . :.=- You should have received a copy of the GNU
+ -.   .:....=;==+<; General Public License along with this file;
+  -_. . .   )=.  = see the file COPYING. If not, write to the
+    --        :-=` Free Software Foundation, Inc.,
+ 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+*/
+
+#ifndef PASSWORD_H
+#define PASSWORD_H
+
+#include <qdialog.h>
+
+class QLineEdit;
+class QWidget;
+
+class Password : public QDialog
+{
+ Q_OBJECT
+
+ public:
+ Password( QWidget *, const char *, const char * );
+ ~Password();
+
+ QString password;
+
+ private:
+ QLineEdit *pw;
+
+ protected slots:
+ void accept();
+ void slotTogglePassword( bool );
+};
+
+#endif
diff --git a/noncore/apps/checkbook/transaction.cpp b/noncore/apps/checkbook/transaction.cpp
index 122c8d6..17be669 100644
--- a/noncore/apps/checkbook/transaction.cpp
+++ b/noncore/apps/checkbook/transaction.cpp
@@ -1,241 +1,241 @@
/*
                This file is part of the OPIE Project
=.
             .=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>       _;_.
    .i_,=:_.      -<s. This file is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
..}^=.=       =       ; Public License for more details.
++=   -.     .`     .:
 :     =  ...= . :.=- You should have received a copy of the GNU
 -.   .:....=;==+<; General Public License along with this file;
  -_. . .   )=.  = see the file COPYING. If not, write to the
    --        :-=` Free Software Foundation, Inc.,
59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "transaction.h"
#include "traninfo.h"
#include <qpe/datebookmonth.h>
#include <qpe/timestring.h>
#include <qbuttongroup.h>
#include <qcombobox.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qmultilineedit.h>
#include <qpopupmenu.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
#include <qscrollview.h>
#include <qstring.h>
#include <qwhatsthis.h>
Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *info,
- char symbol )
+ const QString &symbol )
: QDialog( parent, 0, TRUE, WStyle_ContextHelp )
{
QString tempstr = tr( "Transaction for " );
tempstr.append( acctname );
setCaption( tempstr );
tran = info;
currencySymbol = symbol;
QVBoxLayout *vb = new QVBoxLayout( this );
QScrollView *sv = new QScrollView( this );
vb->addWidget( sv, 0, 0 );
sv->setResizePolicy( QScrollView::AutoOneFit );
sv->setFrameStyle( QFrame::NoFrame );
QWidget *container = new QWidget( sv->viewport() );
sv->addChild( container );
QGridLayout *layout = new QGridLayout( container );
layout->setSpacing( 2 );
layout->setMargin( 4 );
// Withdrawal/Deposit
QButtonGroup *btngrp = new QButtonGroup( container );
btngrp->setColumnLayout(0, Qt::Vertical );
btngrp->layout()->setSpacing( 0 );
btngrp->layout()->setMargin( 0 );
btngrp->setMaximumWidth( 220 );
QGridLayout *layout2 = new QGridLayout( btngrp->layout() );
layout2->setSpacing( 2 );
layout2->setMargin( 2 );
withBtn = new QRadioButton( tr( "Withdrawal" ), btngrp );
QWhatsThis::add( withBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) );
layout2->addWidget( withBtn, 0, 0 );
connect( withBtn, SIGNAL( clicked() ), this, SLOT( slotWithdrawalClicked() ) );
depBtn = new QRadioButton( tr( "Deposit" ), btngrp );
QWhatsThis::add( depBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) );
layout2->addWidget( depBtn, 0, 1 );
btngrp->setMaximumSize( 320, withBtn->height() );
connect( depBtn, SIGNAL( clicked() ), this, SLOT( slotDepositClicked() ) );
layout->addMultiCellWidget( btngrp, 0, 0, 0, 3 );
// Date
QLabel *label = new QLabel( tr( "Date:" ), container );
QWhatsThis::add( label, tr( "Select date of transaction here." ) );
layout->addWidget( label, 1, 0 );
dateBtn = new QPushButton( TimeString::shortDate( QDate::currentDate() ),
container );
QWhatsThis::add( dateBtn, tr( "Select date of transaction here." ) );
QPopupMenu *m1 = new QPopupMenu( container );
datePicker = new DateBookMonth( m1, 0, TRUE );
m1->insertItem( datePicker );
dateBtn->setPopup( m1 );
connect( datePicker, SIGNAL( dateClicked( int, int, int ) ),
this, SLOT( slotDateChanged( int, int, int ) ) );
layout->addWidget( dateBtn, 1, 1 );
// Check number
label = new QLabel( tr( "Number:" ), container );
QWhatsThis::add( label, tr( "Enter check number here." ) );
layout->addWidget( label, 1, 2 );
numEdit = new QLineEdit( container );
QWhatsThis::add( numEdit, tr( "Enter check number here." ) );
numEdit->setMaximumWidth( 40 );
layout->addWidget( numEdit, 1, 3 );
// Description
label = new QLabel( tr( "Description:" ), container );
QWhatsThis::add( label, tr( "Enter description of transaction here." ) );
layout->addWidget( label, 2, 0 );
descEdit = new QLineEdit( container );
QWhatsThis::add( descEdit, tr( "Enter description of transaction here." ) );
layout->addMultiCellWidget( descEdit, 2, 2, 1, 3 );
// Category
label = new QLabel( tr( "Category:" ), container );
QWhatsThis::add( label, tr( "Select transaction category here." ) );
layout->addWidget( label, 3, 0 );
catList = new QComboBox( container );
QWhatsThis::add( catList, tr( "Select transaction category here." ) );
layout->addMultiCellWidget( catList, 3, 3, 1, 3 );
// Type
label = new QLabel( tr( "Type:" ), container );
QWhatsThis::add( label, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) );
layout->addWidget( label, 4, 0 );
typeList = new QComboBox( container );
QWhatsThis::add( typeList, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) );
layout->addMultiCellWidget( typeList, 4, 4, 1, 3 );
// Amount
label = new QLabel( tr( "Amount:" ), container );
QWhatsThis::add( label, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) );
layout->addWidget( label, 5, 0 );
amtEdit = new QLineEdit( container );
QWhatsThis::add( amtEdit, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) );
layout->addMultiCellWidget( amtEdit, 5, 5, 1, 3 );
// Fee
label = new QLabel( tr( "Fee:" ), container );
QWhatsThis::add( label, tr( "Enter any fee amount assoiciated with this transaction.\n\nThe value entered should always be positive." ) );
layout->addWidget( label, 6, 0 );
feeEdit = new QLineEdit( container );
QWhatsThis::add( feeEdit, tr( "Enter any fee amount assoiciated with this transaction.\n\nThe value entered should always be positive." ) );
layout->addMultiCellWidget( feeEdit, 6, 6, 1, 3 );
// Notes
label = new QLabel( tr( "Notes:" ), container );
QWhatsThis::add( label, tr( "Enter any additional information for this transaction here." ) );
layout->addWidget( label, 7, 0 );
noteEdit = new QMultiLineEdit( container );
QWhatsThis::add( noteEdit, tr( "Enter any additional information for this transaction here." ) );
layout->addMultiCellWidget( noteEdit, 8, 8, 0, 3 );
// Populate current values if provided
if ( info )
{
if ( info->withdrawal() )
{
withBtn->setChecked( TRUE );
slotWithdrawalClicked();
}
else
{
depBtn->setChecked( TRUE );
slotDepositClicked();
}
QDate dt = info->date();
slotDateChanged( dt.year(), dt.month(), dt.day() );
datePicker->setDate( dt );
numEdit->setText( info->number() );
descEdit->setText( info->desc() );
QString temptext = info->category();
int i = catList->count();
while ( i > 0 )
{
i--;
catList->setCurrentItem( i );
if ( catList->currentText() == temptext )
{
break;
}
}
temptext = info->type();
i = typeList->count();
while ( i > 0 )
{
i--;
typeList->setCurrentItem( i );
if ( typeList->currentText() == temptext )
{
break;
}
}
amtEdit->setText( QString( "%1" ).arg( info->amount(), 0, 'f', 2 ) );
feeEdit->setText( QString( "%1" ).arg( info->fee(), 0, 'f', 2 ) );
noteEdit->setText( info->notes() );
}
else
{
withBtn->setChecked( TRUE );
}
}
Transaction::~Transaction()
{
}
void Transaction::accept()
{
tran->setDesc( descEdit->text() );
tran->setDate( datePicker->selectedDate() );
tran->setWithdrawal( withBtn->isChecked() );
tran->setType( typeList->currentText() );
tran->setCategory( catList->currentText() );
bool ok;
tran->setAmount( amtEdit->text().toFloat( &ok ) );
tran->setFee( feeEdit->text().toFloat( &ok ) );
tran->setNumber( numEdit->text() );
tran->setNotes( noteEdit->text() );
QDialog::accept();
}
void Transaction::slotWithdrawalClicked()
{
catList->clear();
catList->insertItem( tr( "Automobile" ) );
catList->insertItem( tr( "Bills" ) );
catList->insertItem( tr( "CDs" ) );
catList->insertItem( tr( "Clothing" ) );
diff --git a/noncore/apps/checkbook/transaction.h b/noncore/apps/checkbook/transaction.h
index 89ca8e4..000aee7 100644
--- a/noncore/apps/checkbook/transaction.h
+++ b/noncore/apps/checkbook/transaction.h
@@ -1,79 +1,79 @@
/*
                This file is part of the OPIE Project
=.
             .=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>       _;_.
    .i_,=:_.      -<s. This file is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
..}^=.=       =       ; Public License for more details.
++=   -.     .`     .:
 :     =  ...= . :.=- You should have received a copy of the GNU
 -.   .:....=;==+<; General Public License along with this file;
  -_. . .   )=.  = see the file COPYING. If not, write to the
    --        :-=` Free Software Foundation, Inc.,
59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef TRANSACTION_H
#define TRANSACTION_H
#include <qdialog.h>
class DateBookMonth;
class QComboBox;
class QLineEdit;
class QMultiLineEdit;
class QPushButton;
class QRadioButton;
class QString;
class QWidget;
class TranInfo;
class Transaction : public QDialog
{
Q_OBJECT
public:
Transaction( QWidget * = 0x0, const QString & = 0x0, TranInfo * = 0x0,
- char = '$' );
+ const QString & = "$" );
~Transaction();
private:
TranInfo *tran;
- char currencySymbol;
+ QString currencySymbol;
QRadioButton *withBtn;
QRadioButton *depBtn;
QPushButton *dateBtn;
DateBookMonth *datePicker;
QLineEdit *numEdit;
QLineEdit *descEdit;
QComboBox *catList;
QComboBox *typeList;
QLineEdit *amtEdit;
QLineEdit *feeEdit;
QMultiLineEdit *noteEdit;
protected slots:
void accept();
private slots:
void slotWithdrawalClicked();
void slotDepositClicked();
void slotDateChanged( int, int, int );
};
#endif