40 files changed, 1444 insertions, 3820 deletions
diff --git a/noncore/apps/checkbook/TODO b/noncore/apps/checkbook/TODO deleted file mode 100644 index adc9665..0000000 --- a/noncore/apps/checkbook/TODO +++ b/dev/null @@ -1,5 +0,0 @@ -TODO: - * Date widget - * Various bug fixes - * Fix "the" crash - * Fix graph's legend not showing up
\ No newline at end of file diff --git a/noncore/apps/checkbook/checkbook.cpp b/noncore/apps/checkbook/checkbook.cpp new file mode 100644 index 0000000..2919927 --- a/dev/null +++ b/noncore/apps/checkbook/checkbook.cpp @@ -0,0 +1,491 @@ +/* + This file is part of the OPIE Project + =. + .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.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 <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 <qlabel.h> +#include <qlayout.h> +#include <qlineedit.h> +#include <qlistview.h> +#include <qmultilineedit.h> +#include <qpushbutton.h> +#include <qwidget.h> + +Checkbook::Checkbook( QWidget *parent, const QString &n, const QString &fd, char symbol ) + : QDialog( parent, 0, TRUE, 0 ) +{ + name = n; + filename = fd + name + ".qcb"; + filedir = fd; + currencySymbol = symbol; + currBalance = 0.0; + + if ( name != "" ) + { + setCaption( name + " - " + tr( "Checkbook" ) ); + } + 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(), "help_icon", tr( "Info" ) ); + mainWidget->addTab( initTransactions(), "Spreadsheet", tr( "Transactions" ) ); + mainWidget->addTab( initCharts(), "DocumentTypePowerPoint", 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 ); + + // Account name + QLabel *label = new QLabel( tr( "Name:" ), container ); + layout->addWidget( label, 0, 0 ); + nameEdit = new QLineEdit( container ); + connect( nameEdit, SIGNAL( textChanged( const QString & ) ), + this, SLOT( slotNameChanged( const QString & ) ) ); + layout->addWidget( nameEdit, 0, 1 ); + + // Type of account + label = new QLabel( tr( "Type:" ), container ); + layout->addWidget( label, 1, 0 ); + typeList = new QComboBox( container ); + 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 ); + + // Bank/institution name + label = new QLabel( tr( "Bank:" ), container ); + layout->addWidget( label, 2, 0 ); + bankEdit = new QLineEdit( container ); + layout->addWidget( bankEdit, 2, 1 ); + + // Account number + label = new QLabel( tr( "Account number:" ), container ); + layout->addWidget( label, 3, 0 ); + acctNumEdit = new QLineEdit( container ); + layout->addWidget( acctNumEdit, 3, 1 ); + + // PIN number + label = new QLabel( tr( "PIN number:" ), container ); + layout->addWidget( label, 4, 0 ); + pinNumEdit = new QLineEdit( container ); + layout->addWidget( pinNumEdit, 4, 1 ); + + // Starting balance + label = new QLabel( tr( "Starting balance:" ), container ); + layout->addWidget( label, 5, 0 ); + balanceEdit = new QLineEdit( container ); + connect( balanceEdit, SIGNAL( textChanged( const QString & ) ), + this, SLOT( slotStartingBalanceChanged( const QString & ) ) ); + layout->addWidget( balanceEdit, 5, 1 ); + + // Notes + label = new QLabel( tr( "Notes:" ), container ); + layout->addWidget( label, 6, 0 ); + notesEdit = new QMultiLineEdit( container ); + notesEdit->setMaximumHeight( 85 ); + layout->addMultiCellWidget( notesEdit, 7, 7, 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 ); + layout->addMultiCellWidget( balanceLabel, 0, 0, 0, 2 ); + + tranTable = new QListView( control ); + tranTable->addColumn( tr( "ID" ) ); + tranTable->addColumn( tr( "Date" ) ); + tranTable->addColumn( tr( "Description" ) ); + int colnum = tranTable->addColumn( tr( "Amount" ) ); + tranTable->setColumnAlignment( colnum, Qt::AlignRight ); + tranTable->setAllColumnsShowFocus( TRUE ); + 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 ); + connect( btn, SIGNAL( clicked() ), this, SLOT( slotNewTran() ) ); + layout->addWidget( btn, 2, 0 ); + + btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), control ); + connect( btn, SIGNAL( clicked() ), this, SLOT( slotEditTran() ) ); + layout->addWidget( btn, 2, 1 ); + + btn = new QPushButton( Resource::loadPixmap( "editdelete" ), tr( "Delete" ), control ); + connect( btn, SIGNAL( clicked() ), this, SLOT( slotDeleteTran() ) ); + layout->addWidget( btn, 2, 2 ); + + return( control ); +} + +QWidget *Checkbook::initCharts() +{ + QWidget *control = new QWidget( mainWidget ); + + QGridLayout *layout = new QGridLayout( control ); + layout->setSpacing( 2 ); + layout->setMargin( 4 ); + +/* + QLabel *label = new QLabel( control ); + label->setText( tr( "Graph type:" ) ); + layout->addWidget( label, 0, 0 ); + graphList = new QComboBox( control ); + graphList->insertItem( tr( "By category" ) ); + graphList->insertItem( tr( "..." ) ); + graphList->insertItem( tr( "..." ) ); + layout->addWidget( graphList, 0, 1 ); +*/ + + QWidget *graphWidget = new QWidget( control ); + layout->addMultiCellWidget( graphWidget, 0, 0, 0, 1 ); + graphWidget->setBackgroundMode( QWidget::PaletteBase ); + + QPushButton *btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Draw" ), control ); + connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) ); + layout->addWidget( btn, 1, 1 ); + + return control; +} + +void Checkbook::loadCheckbook() +{ + transactions.clear(); + + Config config(filename, Config::File); + + // Load info + config.setGroup( "Account" ); + 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.readEntry( "Number", "" ) ); + pinNumEdit->setText( config.readEntry( "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 ); + + // Add to transaction list + transactions.append( tran ); + + // Add to transaction table + QDate date = tran->date(); + QString datestr = QString::number( date.month() ) + "/" + + QString::number( date.day() ) + "/" + + QString::number( date.year() ); + ( void ) new QListViewItem( tranTable, QString::number( i ), 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::findTranByID( int id ) +{ + TranInfo *traninfo = transactions.first(); + while ( traninfo && traninfo->id() != id ) + { + 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->writeEntry( "Type", typeList->currentText() ); + config->writeEntry( "Bank", bankEdit->text() ); + config->writeEntry( "Number", acctNumEdit->text() ); + config->writeEntry( "PINNumber", pinNumEdit->text() ); + config->writeEntry( "Balance", balanceEdit->text() ); + config->writeEntry( "Notes", notesEdit->text() ); + + // Save transactions + TranInfo *tran = transactions.first(); + int i = 1; + while ( tran ) + { + tran->write( config, i ); + tran = transactions.next(); + i++; + } + config->write(); + + QDialog::accept(); +} + +void Checkbook::slotNameChanged( const QString &newname ) +{ + name = newname; + filename = filedir + newname + ".qcb"; + setCaption( name + " - " + tr( "Checkbook" ) ); +} + +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 ); + + // Add to transaction list + transactions.append( traninfo ); + + // Add to transaction table + + QDate date = traninfo->date(); + QString datestr = QString::number( date.month() ) + "/" + + QString::number( date.day() ) + "/" + + QString::number( date.year() ); + ( void ) new QListViewItem( tranTable, QString::number( highTranNum ), datestr, + traninfo->desc(), stramount ); + + adjustBalance( amount ); + } + else + { + highTranNum--; + delete traninfo; + } +} + +void Checkbook::slotEditTran() +{ + bool ok; + QListViewItem *curritem = tranTable->currentItem(); + if ( !curritem ) + { + return; + } + + int tranid = curritem->text( 0 ).toInt( &ok ); + TranInfo *traninfo = findTranByID( tranid ); + float origamt = traninfo->amount(); + if ( traninfo->withdrawal() ) + { + origamt *= -1; + } + + Transaction *currtran = new Transaction( this, name, + traninfo, + currencySymbol ); + currtran->showMaximized(); + if ( currtran->exec() == QDialog::Accepted ) + { + QDate date = traninfo->date(); + QString datestr = QString::number( date.month() ) + "/" + + QString::number( date.day() ) + "/" + + QString::number( date.year() ); + curritem->setText( 1, 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 ); + 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; + } + + bool ok; + int tranid = curritem->text( 0 ).toInt( &ok ); + //TranInfo *traninfo = transactions.at( tranid - 1 ); + TranInfo *traninfo = findTranByID( tranid ); + + 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() +{ +} diff --git a/noncore/apps/checkbook/checkbook.h b/noncore/apps/checkbook/checkbook.h new file mode 100644 index 0000000..a86c0f9 --- a/dev/null +++ b/noncore/apps/checkbook/checkbook.h @@ -0,0 +1,102 @@ +/* + This file is part of the OPIE Project + =. + .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.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> + +class OTabWidget; + +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(); + + const QString &getName(); + + private: + TranInfoList transactions; + QString name; + QString filename; + QString filedir; + char currencySymbol; + int highTranNum; + + OTabWidget *mainWidget; + void loadCheckbook(); + void adjustBalance( float ); + TranInfo *findTranByID( int ); + + // Info tab + QWidget *initInfo(); + 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(); + //QComboBox *graphList; + QWidget *graphWidget; + + protected slots: + void accept(); + + private slots: + void slotNameChanged( const QString & ); + void slotStartingBalanceChanged( const QString & ); + void slotNewTran(); + void slotEditTran(); + void slotDeleteTran(); + void slotDrawGraph(); +}; + +#endif diff --git a/noncore/apps/checkbook/checkbook.pro b/noncore/apps/checkbook/checkbook.pro index cf78739..07cc012 100644 --- a/noncore/apps/checkbook/checkbook.pro +++ b/noncore/apps/checkbook/checkbook.pro @@ -1,37 +1,18 @@ TEMPLATE = app CONFIG = qt warn_on release -HEADERS = config.h \ - qcheckbook.h \ - qcheckdetails.h \ - qcheckentry.h \ - qcheckgraph.h \ - qcheckmainmenu.h \ - qcheckname.h \ - qcheckview.h \ - qchecknamebase.h \ - qrestrictedcombo.h \ - qrestrictedline.h -SOURCES = config.cpp \ - main.cpp \ - qcheckbook.cpp \ - qcheckdetails.cpp \ - qcheckentry.cpp \ - qcheckgraph.cpp \ - qcheckmainmenu.cpp \ - qcheckname.cpp \ - qcheckview.cpp \ - qrestrictedcombo.cpp \ - qchecknamebase.cpp \ - qrestrictedline.cpp -INTERFACES = qcheckdetailsbase.ui \ - qcheckentrybase.ui \ - qcheckgraphbase.ui \ - qcheckmmbase.ui \ - qcheckviewbase.ui +HEADERS = mainwindow.h \ + traninfo.h \ + checkbook.h \ + transaction.h +SOURCES = main.cpp \ + mainwindow.cpp \ + traninfo.cpp \ + checkbook.cpp \ + transaction.cpp INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include -LIBS += -lqpe +LIBS += -lqpe -lopie TARGET = checkbook DESTDIR = $(OPIEDIR)/bin TRANSLATIONS = ../../../i18n/de/checkbook.ts \ diff --git a/noncore/apps/checkbook/config.cpp b/noncore/apps/checkbook/config.cpp deleted file mode 100644 index e6c6dcc..0000000 --- a/noncore/apps/checkbook/config.cpp +++ b/dev/null @@ -1,560 +0,0 @@ -/********************************************************************** -** Copyright (C) 2000 Trolltech AS. All rights reserved. -** -** This file is part of Qtopia Environment. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#include <qdir.h> -#include <qfile.h> -#include <qfileinfo.h> -#include <qmessagebox.h> -#if QT_VERSION <= 230 && defined(QT_NO_CODECS) -#include <qtextcodec.h> -#endif -#include <qtextstream.h> - -#include <sys/stat.h> -#include <sys/types.h> -#include <fcntl.h> -#include <stdlib.h> -#include <unistd.h> - -#include "config.h" - - -/*! - \internal -*/ -QString Config::configFilename(const QString& name, Domain d) -{ - switch (d) { - case File: - return name; - case User: { - QDir dir = (QString(getenv("HOME")) + "/Settings"); - if ( !dir.exists() ) - mkdir(dir.path().local8Bit(),0700); - return dir.path() + "/" + name + ".conf"; - } - } - return name; -} - -/*! - \class Config config.h - \brief The Config class provides for saving application cofniguration state. - - You should keep a Config in existence only while you do not want others - to be able to change the state. There is no locking currently, but there - may be in the future. -*/ - -/*! - \enum Config::ConfigGroup - \internal -*/ - -/*! - \enum Config::Domain - - \value File - \value User - - See Config for details. -*/ - -/*! - Constructs a config that will load or create a configuration with the - given \a name in the given \a domain. - - You must call setGroup() before doing much else with the Config. - - In the default Domain, \e User, - the configuration is user-specific. \a name should not contain "/" in - this case, and in general should be the name of the C++ class that is - primarily responsible for maintaining the configuration. - - In the File Domain, \a name is an absolute filename. -*/ -Config::Config( const QString &name, Domain domain ) - : filename( configFilename(name,domain) ) -{ - git = groups.end(); - read(); - - lang = getenv("LANG"); - int i = lang.find("."); - if ( i > 0 ) - lang = lang.left( i ); - i = lang.find( "_" ); - if ( i > 0 ) - glang = lang.left(i); -} - -/*! - Writes any changes to disk and destroys the in-memory object. -*/ -Config::~Config() -{ - if ( changed ) - write(); -} - -/*! - Returns whether the current group has an entry called \a key. -*/ -bool Config::hasKey( const QString &key ) const -{ - if ( groups.end() == git ) - return FALSE; - ConfigGroup::ConstIterator it = ( *git ).find( key ); - return it != ( *git ).end(); -} - -/*! - Sets the current group for subsequent reading and writing of - entries to \a gname. Grouping allows the application to partition the namespace. - - This function must be called prior to any reading or writing - of entries. - - The \a gname must not be empty. -*/ -void Config::setGroup( const QString &gname ) -{ - QMap< QString, ConfigGroup>::Iterator it = groups.find( gname ); - if ( it == groups.end() ) { - git = groups.insert( gname, ConfigGroup() ); - changed = TRUE; - return; - } - git = it; -} - -/*! - Writes a (\a key, \a value) entry to the current group. - - \sa readEntry() -*/ -void Config::writeEntry( const QString &key, const char* value ) -{ - writeEntry(key,QString(value)); -} - -/*! - Writes a (\a key, \a value) entry to the current group. - - \sa readEntry() -*/ -void Config::writeEntry( const QString &key, const QString &value ) -{ - if ( git == groups.end() ) { - qWarning( "no group set" ); - return; - } - if ( (*git)[key] != value ) { - ( *git ).insert( key, value ); - changed = TRUE; - } -} - -/* - Note that the degree of protection offered by the encryption here is - only sufficient to avoid the most casual observation of the configuration - files. People with access to the files can write down the contents and - decrypt it using this source code. - - Conceivably, and at some burden to the user, this encryption could - be improved. -*/ -static QString encipher(const QString& plain) -{ - // mainly, we make it long - QString cipher; - int mix=28730492; - for (int i=0; i<(int)plain.length(); i++) { - int u = plain[i].unicode(); - int c = u ^ mix; - QString x = QString::number(c,36); - cipher.append(QChar('a'+x.length())); - cipher.append(x); - mix *= u; - } - return cipher; -} - -static QString decipher(const QString& cipher) -{ - QString plain; - int mix=28730492; - for (int i=0; i<(int)cipher.length();) { - int l = cipher[i].unicode()-'a'; - QString x = cipher.mid(i+1,l); i+=l+1; - int u = x.toInt(0,36) ^ mix; - plain.append(QChar(u)); - mix *= u; - } - return plain; -} - -/*! - Writes an encrypted (\a key, \a value) entry to the current group. - - Note that the degree of protection offered by the encryption is - only sufficient to avoid the most casual observation of the configuration - files. - - \sa readEntry() -*/ -void Config::writeEntryCrypt( const QString &key, const QString &value ) -{ - if ( git == groups.end() ) { - qWarning( "no group set" ); - return; - } - QString evalue = encipher(value); - if ( (*git)[key] != evalue ) { - ( *git ).insert( key, evalue ); - changed = TRUE; - } -} - -/*! - Writes a (\a key, \a num) entry to the current group. - - \sa readNumEntry() -*/ -void Config::writeEntry( const QString &key, int num ) -{ - QString s; - s.setNum( num ); - writeEntry( key, s ); -} - -#ifdef Q_HAS_BOOL_TYPE -/*! - Writes a (\a key, \a b) entry to the current group. This is equivalent - to writing a 0 or 1 as an integer entry. - - \sa readBoolEntry() -*/ -void Config::writeEntry( const QString &key, bool b ) -{ - QString s; - s.setNum( ( int )b ); - writeEntry( key, s ); -} -#endif - -/*! - Writes a (\a key, \a lst) entry to the current group. The list - is separated by \a sep, so the strings must not contain that character. - - \sa readListEntry() -*/ -void Config::writeEntry( const QString &key, const QStringList &lst, const QChar &sep ) -{ - QString s; - QStringList::ConstIterator it = lst.begin(); - for ( ; it != lst.end(); ++it ) - s += *it + sep; - writeEntry( key, s ); -} - -/*! - Removes the \a key entry from the current group. Does nothing if - there is no such entry. -*/ - -void Config::removeEntry( const QString &key ) -{ - if ( git == groups.end() ) { - qWarning( "no group set" ); - return; - } - ( *git ).remove( key ); - changed = TRUE; -} - -/*! - \fn bool Config::operator == ( const Config & other ) const - - Tests for equality with \a other. Config objects are equal if they refer to the same filename. -*/ - -/*! - \fn bool Config::operator != ( const Config & other ) const - - Tests for inequality with \a other. Config objects are equal if they refer to the same filename. -*/ - -/*! - \fn QString Config::readEntry( const QString &key, const QString &deflt ) const - - Reads a string entry stored with \a key, defaulting to \a deflt if there is no entry. -*/ - -/*! - \internal - For compatibility, non-const version. -*/ -QString Config::readEntry( const QString &key, const QString &deflt ) -{ - QString res = readEntryDirect( key+"["+lang+"]" ); - if ( !res.isNull() ) - return res; - if ( !glang.isEmpty() ) { - res = readEntryDirect( key+"["+glang+"]" ); - if ( !res.isNull() ) - return res; - } - return readEntryDirect( key, deflt ); -} - -/*! - \fn QString Config::readEntryCrypt( const QString &key, const QString &deflt ) const - - Reads an encrypted string entry stored with \a key, defaulting to \a deflt if there is no entry. -*/ - -/*! - \internal - For compatibility, non-const version. -*/ -QString Config::readEntryCrypt( const QString &key, const QString &deflt ) -{ - QString res = readEntryDirect( key+"["+lang+"]" ); - if ( res.isNull() && glang.isEmpty() ) - res = readEntryDirect( key+"["+glang+"]" ); - if ( res.isNull() ) - res = readEntryDirect( key, QString::null ); - if ( res.isNull() ) - return deflt; - return decipher(res); -} - -/*! - \fn QString Config::readEntryDirect( const QString &key, const QString &deflt ) const - \internal -*/ - -/*! - \internal - For compatibility, non-const version. -*/ -QString Config::readEntryDirect( const QString &key, const QString &deflt ) -{ - if ( git == groups.end() ) { - //qWarning( "no group set" ); - return deflt; - } - ConfigGroup::ConstIterator it = ( *git ).find( key ); - if ( it != ( *git ).end() ) - return *it; - else - return deflt; -} - -/*! - \fn int Config::readNumEntry( const QString &key, int deflt ) const - Reads a numeric entry stored with \a key, defaulting to \a deflt if there is no entry. -*/ - -/*! - \internal - For compatibility, non-const version. -*/ -int Config::readNumEntry( const QString &key, int deflt ) -{ - QString s = readEntry( key ); - if ( s.isEmpty() ) - return deflt; - else - return s.toInt(); -} - -/*! - \fn bool Config::readBoolEntry( const QString &key, bool deflt ) const - Reads a bool entry stored with \a key, defaulting to \a deflt if there is no entry. -*/ - -/*! - \internal - For compatibility, non-const version. -*/ -bool Config::readBoolEntry( const QString &key, bool deflt ) -{ - QString s = readEntry( key ); - if ( s.isEmpty() ) - return deflt; - else - return (bool)s.toInt(); -} - -/*! - \fn QStringList Config::readListEntry( const QString &key, const QChar &sep ) const - Reads a string list entry stored with \a key, and with \a sep as the separator. -*/ - -/*! - \internal - For compatibility, non-const version. -*/ - -/*! - Removes all entries from the current group. -*/ -void Config::clearGroup() -{ - if ( git == groups.end() ) { - qWarning( "no group set" ); - return; - } - if ( !(*git).isEmpty() ) { - ( *git ).clear(); - changed = TRUE; - } -} - -void Config::removeGroup() -{ - if ( git == groups.end() ) { - qWarning( "no group set" ); - return; - } - - groups.remove(git); - changed = TRUE; -} - -/*! - \internal -*/ -void Config::write( const QString &fn ) -{ - QString strNewFile; - if ( !fn.isEmpty() ) - filename = fn; - strNewFile = filename + ".new"; - - QFile f( strNewFile ); - if ( !f.open( IO_WriteOnly|IO_Raw ) ) { - qWarning( "could not open for writing `%s'", strNewFile.latin1() ); - git = groups.end(); - return; - } - - QString str; - QCString cstr; - QMap< QString, ConfigGroup >::Iterator g_it = groups.begin(); - - for ( ; g_it != groups.end(); ++g_it ) { - str += "[" + g_it.key() + "]\n"; - ConfigGroup::Iterator e_it = ( *g_it ).begin(); - for ( ; e_it != ( *g_it ).end(); ++e_it ) - str += e_it.key() + " = " + *e_it + "\n"; - } - cstr = str.utf8(); - - int total_length; - total_length = f.writeBlock( cstr.data(), cstr.length() ); - if ( total_length != int(cstr.length()) ) { - QMessageBox::critical( 0, QObject::tr("Out of Space"), - QObject::tr("There was a problem creating\nConfiguration Information \nfor this program.\n\nPlease free up some space and\ntry again.") ); - f.close(); - QFile::remove( strNewFile ); - return; - } - - f.close(); - // now rename the file... - if ( rename( strNewFile, filename ) < 0 ) { - qWarning( "problem renaming the file %s to %s", strNewFile.latin1(), - filename.latin1() ); - QFile::remove( strNewFile ); - } -} - -/*! - Returns whether the Config is in a valid state. -*/ -bool Config::isValid() const -{ - return groups.end() != git; -} - -/*! - \internal -*/ -void Config::read() -{ - changed = FALSE; - - if ( !QFileInfo( filename ).exists() ) { - git = groups.end(); - return; - } - - QFile f( filename ); - if ( !f.open( IO_ReadOnly ) ) { - git = groups.end(); - return; - } - - QTextStream s( &f ); -#if QT_VERSION <= 230 && defined(QT_NO_CODECS) - // The below should work, but doesn't in Qt 2.3.0 - s.setCodec( QTextCodec::codecForMib( 106 ) ); -#else - s.setEncoding( QTextStream::UnicodeUTF8 ); -#endif - - QStringList list = QStringList::split('\n', s.read() ); - f.close(); - - for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { - if ( !parse( *it ) ) { - git = groups.end(); - return; - } - } -} - -/*! - \internal -*/ -bool Config::parse( const QString &l ) -{ - QString line = l.stripWhiteSpace(); - if ( line[ 0 ] == QChar( '[' ) ) { - QString gname = line; - gname = gname.remove( 0, 1 ); - if ( gname[ (int)gname.length() - 1 ] == QChar( ']' ) ) - gname = gname.remove( gname.length() - 1, 1 ); - git = groups.insert( gname, ConfigGroup() ); - } else if ( !line.isEmpty() ) { - if ( git == groups.end() ) - return FALSE; - int eq = line.find( '=' ); - if ( eq == -1 ) - return FALSE; - QString key = line.left(eq).stripWhiteSpace(); - QString value = line.mid(eq+1).stripWhiteSpace(); - ( *git ).insert( key, value ); - } - return TRUE; -} diff --git a/noncore/apps/checkbook/config.h b/noncore/apps/checkbook/config.h deleted file mode 100644 index b3a8561..0000000 --- a/noncore/apps/checkbook/config.h +++ b/dev/null @@ -1,99 +0,0 @@ -/********************************************************************** -** Copyright (C) 2000 Trolltech AS. All rights reserved. -** -** This file is part of Qtopia Environment. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#ifndef CONFIG_H -#define CONFIG_H - -// ##### could use QSettings with Qt 3.0 - -#include <qmap.h> -#include <qstringlist.h> - -class ConfigPrivate; -class Config -{ -public: - typedef QMap< QString, QString > ConfigGroup; - - enum Domain { File, User }; - Config( const QString &name, Domain domain=User ); - ~Config(); - - bool operator == ( const Config & other ) const { return (filename == other.filename); } - bool operator != ( const Config & other ) const { return (filename != other.filename); } - - bool isValid() const; - bool hasKey( const QString &key ) const; - - void setGroup( const QString &gname ); - void writeEntry( const QString &key, const char* value ); - void writeEntry( const QString &key, const QString &value ); - void writeEntryCrypt( const QString &key, const QString &value ); - void writeEntry( const QString &key, int num ); -#ifdef Q_HAS_BOOL_TYPE - void writeEntry( const QString &key, bool b ); -#endif - void writeEntry( const QString &key, const QStringList &lst, const QChar &sep ); - void removeEntry( const QString &key ); - - QString readEntry( const QString &key, const QString &deflt = QString::null ) const; - QString readEntryCrypt( const QString &key, const QString &deflt = QString::null ) const; - QString readEntryDirect( const QString &key, const QString &deflt = QString::null ) const; - int readNumEntry( const QString &key, int deflt = -1 ) const; - bool readBoolEntry( const QString &key, bool deflt = FALSE ) const; - - // For compatibility, non-const versions. - QString readEntry( const QString &key, const QString &deflt ); - QString readEntryCrypt( const QString &key, const QString &deflt ); - QString readEntryDirect( const QString &key, const QString &deflt ); - int readNumEntry( const QString &key, int deflt ); - bool readBoolEntry( const QString &key, bool deflt ); - - void clearGroup(); - void removeGroup(); - - void write( const QString &fn = QString::null ); - -protected: - void read(); - bool parse( const QString &line ); - - QMap< QString, ConfigGroup > groups; - QMap< QString, ConfigGroup >::Iterator git; - QString filename; - QString lang; - QString glang; - bool changed; - ConfigPrivate *d; - static QString configFilename(const QString& name, Domain); -}; - -inline QString Config::readEntry( const QString &key, const QString &deflt ) const -{ return ((Config*)this)->readEntry(key,deflt); } -inline QString Config::readEntryCrypt( const QString &key, const QString &deflt ) const -{ return ((Config*)this)->readEntryCrypt(key,deflt); } -inline QString Config::readEntryDirect( const QString &key, const QString &deflt ) const -{ return ((Config*)this)->readEntryDirect(key,deflt); } -inline int Config::readNumEntry( const QString &key, int deflt ) const -{ return ((Config*)this)->readNumEntry(key,deflt); } -inline bool Config::readBoolEntry( const QString &key, bool deflt ) const -{ return ((Config*)this)->readBoolEntry(key,deflt); } - -#endif diff --git a/noncore/apps/checkbook/main.cpp b/noncore/apps/checkbook/main.cpp index 68f00e6..832bd09 100644 --- a/noncore/apps/checkbook/main.cpp +++ b/noncore/apps/checkbook/main.cpp @@ -1,11 +1,42 @@ +/* + This file is part of the OPIE Project + =. + .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.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 <qpe/qpeapplication.h> -#include "qcheckbook.h" int main(int argc, char **argv) { QPEApplication app(argc, argv); - QCheckBook *qcb = new QCheckBook(); - app.setMainWidget(qcb); - qcb->showMaximized(); + + MainWindow *cb = new MainWindow(); + app.setMainWidget(cb); + cb->showMaximized(); + return app.exec(); } diff --git a/noncore/apps/checkbook/mainwindow.cpp b/noncore/apps/checkbook/mainwindow.cpp new file mode 100644 index 0000000..9410536 --- a/dev/null +++ b/noncore/apps/checkbook/mainwindow.cpp @@ -0,0 +1,164 @@ +/* + This file is part of the OPIE Project + =. + .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.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 "checkbook.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> + +MainWindow::MainWindow() + : QMainWindow() +{ + 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 ); + actionOpen = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, + 0, this, 0 ); + connect( actionOpen, SIGNAL( activated() ), this, SLOT( slotOpen() ) ); + actionOpen->addTo( popup ); + actionOpen->addTo( bar ); + + QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); + connect( a, SIGNAL( activated() ), this, SLOT( slotNew() ) ); + a->addTo( popup ); + a->addTo( bar ); + + actionDelete = new QAction( tr( "Delete" ), Resource::loadPixmap( "editdelete" ), QString::null, + 0, this, 0 ); + connect( actionDelete, SIGNAL( activated() ), this, SLOT( slotDelete() ) ); + actionDelete->addTo( popup ); + actionDelete->addTo( bar ); + + popup->insertSeparator(); + + a = new QAction( tr( "Exit" ), QString::null, 0, this, 0 ); + connect( a, SIGNAL( activated() ), this, SLOT( close() ) ); + a->addTo( popup ); + + mb->insertItem( tr( "Checkbook" ), popup ); + + // Build Checkbook selection list control + cbList = new QListBox( this ); + QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold ); + connect( cbList, SIGNAL( rightButtonPressed( QListBoxItem *, const QPoint & ) ), + this, SLOT( slotOpen() ) ); + 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 = '$'; +} + +MainWindow::~MainWindow() +{ +} + +void MainWindow::slotOpen() +{ + QString currname = cbList->currentText(); + 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(); + + QFile f( cbDir + currname + ".qcb" ); + if ( f.exists() ) + { + f.remove(); + } + } + delete currcb; + } +} + +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::slotDelete() +{ + if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), cbList->currentText() ) ) + { + cbList->removeItem( cbList->currentItem() ); + + QString name = cbDir + cbList->currentText() + ".qcb"; + QFile f( name ); + if ( f.exists() ) + { + f.remove(); + } + } +} diff --git a/noncore/apps/checkbook/mainwindow.h b/noncore/apps/checkbook/mainwindow.h new file mode 100644 index 0000000..54fbba6 --- a/dev/null +++ b/noncore/apps/checkbook/mainwindow.h @@ -0,0 +1,60 @@ +/* + This file is part of the OPIE Project + =. + .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.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; + + private slots: + void slotOpen(); + void slotNew(); + void slotDelete(); +}; + +#endif diff --git a/noncore/apps/checkbook/opie-checkbook.control b/noncore/apps/checkbook/opie-checkbook.control index 9784206..f8e14ca 100644 --- a/noncore/apps/checkbook/opie-checkbook.control +++ b/noncore/apps/checkbook/opie-checkbook.control @@ -1,9 +1,9 @@ Files: bin/checkbook apps/Applications/checkbook.desktop pics/checkbook/checkbook.png Priority: optional Section: applications -Maintainer: ljp <llornkcor@handhelds.org> +Maintainer: drw <drw@handhelds.org> Architecture: arm Version: $QPE_VERSION-$SUB_VERSION -Depends: opie-base ($QPE_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/qcheckbook.cpp b/noncore/apps/checkbook/qcheckbook.cpp deleted file mode 100644 index 26caad9..0000000 --- a/noncore/apps/checkbook/qcheckbook.cpp +++ b/dev/null @@ -1,153 +0,0 @@ -#include "qcheckbook.h" - -#include <qmenubar.h> -#include <qstatusbar.h> -#include <qpopupmenu.h> -#include <qapplication.h> -#include <qfile.h> -#include <qdir.h> - -QCheckBook::QCheckBook() - : QMainWindow(), - m_view(), - m_view2(), - m_view3() -{ - initCheck = false; - initMM = false; - setCaption("Checking"); - statusBar()->hide(); - menuBar()->hide(); - - bar = new QToolBar(this); - bar->setHorizontalStretchable( TRUE ); - - addToolBar(bar); - - Config config("qcheckbook"); - config.setGroup("Global"); - QString lastCheck = config.readEntry("LastCheckBook", QString("")); - - QString checkdirname = QDir::homeDirPath(); - checkdirname.append("/.checkbooks/"); - checkdirname.append(lastCheck); - QFile f(checkdirname); - - - if (lastCheck.isEmpty() == false && lastCheck != "" && f.exists() == true) - { - newCheck(lastCheck); - } else { - initMainMenus(); - } - - setToolBarsMovable( FALSE ); -} - -void QCheckBook::newCheck(const QString &filename) -{ - if (filename.isEmpty() == false) - { - initCheck = true; - if (m_view != 0) - { - m_view=0; - delete m_view; - } - m_view = new QCheckView(this, filename); - m_view->hide(); - connect(m_view, SIGNAL(reload(const QString &)), this, SLOT(newCheck(const QString &))); - if (initMM == true) - { - delete nb1; - } - bar->clear(); - mbar = new QMenuBar(bar); - mbar->setMargin(0); - - QPixmap newIcon = Resource::loadPixmap( "new" ); - nb2 = new QToolButton( newIcon, "New", QString::null, m_view, SLOT(newClicked()), bar, "new item" ); - QPixmap pixmap = Resource::loadPixmap( "pixmap" ); - m_filename = filename; - nb3 = new QToolButton( pixmap, "Graph", QString::null, this, SLOT(newGraph()), bar, "new graph" ); - - QPixmap closeIcon = Resource::loadPixmap( "close" ); - nb4 = new QToolButton( closeIcon, "Close", QString::null, this, SLOT(initMainMenus()), bar, "close graph" ); - - popup = new QPopupMenu(m_view); - popup->insertItem("&New Entry", m_view, SLOT(newClicked())); - popup->insertItem("&Graph Checkbook", this, SLOT(newGraph())); - popup->insertItem("&Close Checkbook", this, SLOT(initMainMenus())); - popup->insertItem("&Exit", this, SLOT(close())); - mbar->insertItem("&File", popup); - - setCentralWidget(m_view); - m_view->show(); - - Config config("qcheckbook"); - config.setGroup("Global"); - config.writeEntry("LastCheckBook", filename); - initMM = false; - } -} - -void QCheckBook::deleteCheck(const QString &filename) -{ - qDebug("Deleting "+filename); -} - -void QCheckBook::close() -{ - QApplication::exit(); -} - -void QCheckBook::newGraph() -{ - if (m_filename.isEmpty() == false) - { - m_view2 = new QCheckGraph(m_filename); - m_view2->showMaximized(); - } -} - -void QCheckBook::initMainMenus() -{ - Config config("qcheckbook"); - config.setGroup("Global"); - config.writeEntry("LastCheckBook", QString("")); - initMM = true; - m_filename = ""; - if (m_view3 != 0) - { - delete m_view3; - } - m_view3 = new QCheckMainMenu(this); - m_view3->hide(); - - if (initCheck == true) - { - delete nb2; - delete nb3; - delete nb4; - } - - bar->clear(); - - mbar = new QMenuBar(bar); - mbar->setMargin(0); - - QPixmap newIcon = Resource::loadPixmap( "new" ); - nb1 = new QToolButton( newIcon, "New", QString::null, m_view3, SLOT(newClicked()), bar, "new book" ); - - popup = new QPopupMenu(); - popup->insertItem("&New", m_view3, SLOT(newClicked())); - popup->insertItem("&Delete", m_view3, SLOT(deleteClicked())); - popup->insertItem("&Exit", this, SLOT(close())); - mbar->insertItem("&File", popup); - - setCentralWidget(m_view3); - m_view3->show(); - - connect(m_view3, SIGNAL(itemSelected(const QString &)), this, SLOT(newCheck(const QString &))); - initCheck = false; -} diff --git a/noncore/apps/checkbook/qcheckbook.h b/noncore/apps/checkbook/qcheckbook.h deleted file mode 100644 index 64b6628..0000000 --- a/noncore/apps/checkbook/qcheckbook.h +++ b/dev/null @@ -1,38 +0,0 @@ -#include "qcheckview.h" -#include "qcheckgraph.h" -#include "qcheckmainmenu.h" - -#include <qpe/resource.h> -#include <qmainwindow.h> -#include <qtoolbar.h> -#include <qstring.h> -#include "config.h" -#include <qpopupmenu.h> - -class QCheckBook : public QMainWindow -{ - Q_OBJECT - public: - QCheckBook(); - private slots: - void newCheck(const QString &filename); - void deleteCheck(const QString &filename); - void newGraph(); - void close(); - void initMainMenus(); - private: - QCheckView *m_view; - QCheckGraph *m_view2; - QCheckMainMenu *m_view3; - QToolBar *bar; - QMenuBar *mbar; - int filemenuid; - QString m_filename; - QToolButton *nb1; - QToolButton *nb2; - QToolButton *nb3; - QToolButton *nb4; - bool initCheck; - bool initMM; - QPopupMenu *popup; -}; diff --git a/noncore/apps/checkbook/qcheckdetails.cpp b/noncore/apps/checkbook/qcheckdetails.cpp deleted file mode 100644 index 19a5e82..0000000 --- a/noncore/apps/checkbook/qcheckdetails.cpp +++ b/dev/null @@ -1,119 +0,0 @@ -#include "qcheckdetails.h" - -QCheckDetails::QCheckDetails(int row, int col, const QStringList item) - : QMainWindow(), - m_view() -{ - m_view = new QCheckDetailsBase(this); - setCentralWidget(m_view); - - m_row = row; - m_col = col; - - QToolBar *bar = new QToolBar(this); - bar->setHorizontalStretchable( TRUE ); - - QPixmap newIcon = Resource::loadPixmap( "edit" ); - QPixmap trashIcon = Resource::loadPixmap( "trash" ); - QToolButton *nb1 = new QToolButton( newIcon, "Edit", QString::null, this, SLOT(editCheck()), bar, "edit transaction" ); - QToolButton *nb2 = new QToolButton( trashIcon, "Delete", QString::null, this, SLOT(deleteCheck()), bar, "delete transaction" ); - addToolBar(bar); - - QString text = ""; - if (item[0] == "true") - { - text.append("<b>Payment</b> to <b>"); - text.append(item[1]); - } - if (item[0] == "false") - { - text.append("<b>Deposit</b> from <b>"); - text.append(item[1]); - } - text.append("</b> on <b>"); - text.append(item[7]); - text.append("</b> for <b>"); - text.append(QString("$" + item[5])); - - text.append("</b>, to make your balance <b>$"); - text.append(item[9]); - text.append("</b>."); - - text.append("<br><br>"); - text.append("<b>Category: </b>"); - text.append(item[2]); - text.append("<br>"); - text.append("<b>Type: </b>"); - - QString type = "No Type"; - if (item[0] == "true") - { - if(item[3] == "0") - { - type = "Debit Charge"; - } - if(item[3] == "1") - { - type = "Written Check"; - } - if(item[3] == "2") - { - type = "Transfer"; - } - if(item[3] == "3") - { - type = "Credit Card"; - } - } - - if (item[0] == "false") - { - if(item[3] == "0") - { - type = "Written Check"; - } - if(item[3] == "1") - { - type = "Automatic Payment"; - } - if(item[3] == "2") - { - type = "Transfer"; - } - if(item[3] == "3") - { - type = "Cash"; - } - } - - text.append(type); - text.append("<br>"); - if (item[4] != "0") - { - text.append("<b>Check Number: </b>"); - text.append(item[4]); - text.append("<br>"); - } - if (item[6] != ".00") - { - text.append("<b>Extra Fee: </b>"); - text.append(QString("$" + item[6])); - m_view->checkDetails->setText(text); - } - if (item[8] != "") - { - text.append("<br><b>Additional Comments: </b>"); - text.append(item[8]); - } - m_view->checkDetails->setText(text); -} - -void QCheckDetails::editCheck() -{ - emit editClicked(m_row, m_col); -} - -void QCheckDetails::deleteCheck() -{ - emit deleteClicked(m_row, m_col); -} diff --git a/noncore/apps/checkbook/qcheckdetails.h b/noncore/apps/checkbook/qcheckdetails.h deleted file mode 100644 index fe5fe1a..0000000 --- a/noncore/apps/checkbook/qcheckdetails.h +++ b/dev/null @@ -1,27 +0,0 @@ -#include "qcheckdetailsbase.h" -#include <qstring.h> -#include <qtextview.h> -#include <qtoolbar.h> -#include <qpe/resource.h> -#include <qpixmap.h> -#include <qdialog.h> -#include <qmainwindow.h> -#include <qtoolbutton.h> -#include <qwidget.h> - -class QCheckDetails : public QMainWindow -{ - Q_OBJECT - public: - QCheckDetails(int row, int col, const QStringList item); - signals: - void editClicked(int, int); - void deleteClicked(int, int); - public slots: - void editCheck(); - void deleteCheck(); - private: - int m_row; - int m_col; - QCheckDetailsBase *m_view; -}; diff --git a/noncore/apps/checkbook/qcheckdetailsbase.ui b/noncore/apps/checkbook/qcheckdetailsbase.ui deleted file mode 100644 index d94ba5e..0000000 --- a/noncore/apps/checkbook/qcheckdetailsbase.ui +++ b/dev/null @@ -1,62 +0,0 @@ -<!DOCTYPE UI><UI> -<class>QCheckDetailsBase</class> -<widget> - <class>QWidget</class> - <property stdset="1"> - <name>name</name> - <cstring>QCheckDetailsBase</cstring> - </property> - <property stdset="1"> - <name>geometry</name> - <rect> - <x>0</x> - <y>0</y> - <width>240</width> - <height>265</height> - </rect> - </property> - <property stdset="1"> - <name>caption</name> - <string>Transaction Details</string> - </property> - <grid> - <property stdset="1"> - <name>margin</name> - <number>4</number> - </property> - <property stdset="1"> - <name>spacing</name> - <number>0</number> - </property> - <widget row="0" column="0" > - <class>QTextView</class> - <property stdset="1"> - <name>name</name> - <cstring>checkDetails</cstring> - </property> - </widget> - </grid> -</widget> -<customwidgets> - <customwidget> - <class>QWidget</class> - <header location="global">qwidget.h</header> - <sizehint> - <width>-1</width> - <height>-1</height> - </sizehint> - <container>0</container> - <sizepolicy> - <hordata>5</hordata> - <verdata>5</verdata> - </sizepolicy> - <pixmap>image0</pixmap> - </customwidget> -</customwidgets> -<images> - <image> - <name>image0</name> - <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1ddec44f503c0ae2a154410f53d0ed20e2bf6bdb656dd6861dd23d9a66591b0587fd1654235ebded6f0edcd53e419d87ae7b1f4f9b8f906d0bfe012317426a70b07bdc2f3ec77f8ed6b89559061a0343d06a124cc105596482585094bc0ae599b04646c9018926491b2205e140c485cace25755c175d0a967b622ff900b8cc9c7d29af594ea722d589167f813aa852ba07d94b9dce296e883fe7bb163f23896753</data> - </image> -</images> -</UI> diff --git a/noncore/apps/checkbook/qcheckentry.cpp b/noncore/apps/checkbook/qcheckentry.cpp deleted file mode 100644 index 2e8da1c..0000000 --- a/noncore/apps/checkbook/qcheckentry.cpp +++ b/dev/null @@ -1,256 +0,0 @@ -#include "qcheckentry.h" - -QCheckEntry::QCheckEntry() - : QCheckEntryBase() -{ - connect(transAmount, SIGNAL(textChanged(const QString &)), this, SLOT(amountChanged(const QString &))); - connect(transFee, SIGNAL(textChanged(const QString &)), this, SLOT(transFeeChanged(const QString &))); - connect(payment, SIGNAL(clicked()), this, SLOT(paymentClicked())); - connect(deposit, SIGNAL(clicked()), this, SLOT(depositClicked())); - - QString todaysdate = QString::number(QDate::currentDate().month()); - todaysdate.append("/"); - todaysdate.append(QString::number(QDate::currentDate().day())); - todaysdate.append("/"); - todaysdate.append(QString::number(QDate::currentDate().year())); - dateEdit->setText(todaysdate); - - descriptionCombo->setFocus(); - - dateEdit->setValidChars("0123456789./-"); - dateEdit->setMaxLength(10); - - descriptionCombo->lineEdit()->setMaxLength(30); - - checkNumber->setValidChars("0123456789-"); - checkNumber->setMaxLength(10); - - transAmount->setValidChars("0123456789."); - - transFee->setMaxLength(5); - transFee->setValidChars("0123456789."); - setTabOrder(transType,checkNumber); - setTabOrder(checkNumber,transAmount); - setTabOrder(transAmount,transFee); - setTabOrder(transFee,dateEdit); - setTabOrder(dateEdit, additionalNotes ); -} - -void QCheckEntry::paymentClicked() -{ - cmbCategory->clear(); - cmbCategory->insertItem( tr( "Automobile" ) ); - cmbCategory->insertItem( tr( "Bills" ) ); - cmbCategory->insertItem( tr( "CDs" ) ); - cmbCategory->insertItem( tr( "Clothing" ) ); - cmbCategory->insertItem( tr( "Computer" ) ); - cmbCategory->insertItem( tr( "DVDs" ) ); - cmbCategory->insertItem( tr( "Eletronics" ) ); - cmbCategory->insertItem( tr( "Entertainment" ) ); - cmbCategory->insertItem( tr( "Food" ) ); - cmbCategory->insertItem( tr( "Gasoline" ) ); - cmbCategory->insertItem( tr( "Misc" ) ); - cmbCategory->insertItem( tr( "Movies" ) ); - cmbCategory->insertItem( tr( "Rent" ) ); - cmbCategory->insertItem( tr( "Travel" ) ); - cmbCategory->setCurrentItem( 0 ); - transType->clear(); - transType->insertItem( tr( "Debit Charge" ) ); - transType->insertItem( tr( "Written Check" ) ); - transType->insertItem( tr( "Transfer" ) ); - transType->insertItem( tr( "Credit Card" ) ); -} - -void QCheckEntry::depositClicked() -{ - cmbCategory->clear(); - cmbCategory->insertItem( tr( "Work" ) ); - cmbCategory->insertItem( tr( "Family Member" ) ); - cmbCategory->insertItem( tr( "Misc. Credit" ) ); - cmbCategory->setCurrentItem( 0 ); - transType->clear(); - transType->insertItem( tr( "Written Check" ) ); - transType->insertItem( tr( "Automatic Payment" ) ); - transType->insertItem( tr( "Transfer" ) ); - transType->insertItem( tr( "Cash" ) ); -} - -QStringList QCheckEntry::popupEntry(const QStringList &originaldata) -{ - QCheckEntry qce; - - // This is how the list looks: - // 0: true or false, true == payment, false == deposit - // 1: description of the transaction - // 2: category name - // 3: transaction type (stores the integer value of the index of the combobox) - // 4: check number of the transaction (if any) - // 5: transaction amount - // 6: transaction fee (e.g. service charge, or ATM charge). - // 7: date of the transaction - // 8: additional notes - // 9: recently used descriptions - if (originaldata.count() > 1) - { - if (originaldata[0] == "true") - { - qce.payment->setChecked(true); - qce.paymentClicked(); - } else { - if (originaldata[0] == "false") - { - qce.deposit->setChecked(true); - qce.depositClicked(); - } - } - qce.descriptionCombo->lineEdit()->setText(originaldata[1]); - qce.cmbCategory->lineEdit()->setText(originaldata[2]); - qce.transType->setCurrentItem(originaldata[3].toInt()); - qce.checkNumber->setText(originaldata[4]); - qce.transAmount->setText(originaldata[5]); - qce.transFee->setText(originaldata[6]); - qce.dateEdit->setText(originaldata[7]); - qce.additionalNotes->setText(originaldata[8]); - QStringList recentlist; - if (!originaldata[9].isEmpty()) - { - recentlist = QStringList::split(',', originaldata[9], false); - } - if (!recentlist.isEmpty()) - { - qce.descriptionCombo->insertStringList(recentlist); - } - } else { - QStringList recentlist; - if (!originaldata[0].isEmpty()) - { - recentlist = QStringList::split(',', originaldata[0], false); - } - if (!recentlist.isEmpty()) - { - qce.descriptionCombo->insertStringList(recentlist); - } - } - - qce.setWFlags(Qt::WType_Modal); - qce.showMaximized(); - - qce.descriptionCombo->lineEdit()->clear(); - - if (qce.exec() == QDialog::Accepted) - { - // Validate that the user has inputed a valid dollar amount - if (qce.transFee->text().contains('.') == 0) - { - QString text = qce.transFee->text(); - text.append(".00"); - qce.transFee->setText(text); - } else { - QString tmp = qce.transFee->text(); - if (tmp.mid(tmp.find('.'), tmp.length()).length() == 1) - { - tmp.append("00"); - qce.transFee->setText(tmp); - } else { - if (tmp.mid(tmp.find('.'), tmp.length()).length() == 2) - { - tmp.append("0"); - qce.transFee->setText(tmp); - } - } - } - if (qce.transAmount->text().contains('.') == 0) - { - QString text = qce.transAmount->text(); - text.append(".00"); - qce.transAmount->setText(text); - } else { - QString tmp = qce.transAmount->text(); - if (tmp.mid(tmp.find('.'), tmp.length()).length() == 1) - { - tmp.append("00"); - qce.transAmount->setText(tmp); - } else { - if (tmp.mid(tmp.find('.'), tmp.length()).length() == 2) - { - tmp.append("0"); - qce.transAmount->setText(tmp); - } - } - } - - QString recent; - if (qce.descriptionCombo->count() != 0) - { - QStringList recentlist = QStringList::split(',', originaldata[9], false); - if (recentlist.count() >= 10) - { - recentlist.remove(recentlist.last()); - } - recentlist.prepend(qce.descriptionCombo->lineEdit()->text()); - recent = recentlist.join(","); - } else { - recent = qce.descriptionCombo->lineEdit()->text(); - } - - QString checkNumberString = qce.checkNumber->text(); - if (checkNumberString.isEmpty() == true) - { - checkNumberString = "0"; - } - - QString paymentChecked = "true"; - if (qce.payment->isChecked() == false) - { - paymentChecked = "false"; - } - QStringList returnvalue; - returnvalue << paymentChecked << qce.descriptionCombo->lineEdit()->text() << qce.cmbCategory->lineEdit()->text() << QString::number(qce.transType->currentItem()) << checkNumberString << qce.transAmount->text() << qce.transFee->text() << qce.dateEdit->text() << qce.additionalNotes->text() << recent; - return returnvalue; - } else { - QStringList blank; - return blank; - } -} - -void QCheckEntry::transFeeChanged(const QString &input) -{ - QString tmpinput = input; - if (tmpinput.contains('.') > 1) - { - int first = tmpinput.find('.'); - tmpinput = tmpinput.remove(tmpinput.find('.', (first + 1)), 1); - } - if (tmpinput.contains(QRegExp("\\.[0-9][0-9]{2}$")) >= 1) - { - tmpinput = tmpinput.remove((tmpinput.length() - 1), 1); - } - transFee->setText(tmpinput); -} - -void QCheckEntry::amountChanged(const QString &input) -{ - QString tmpinput = input; - if (tmpinput.contains('.') > 1) - { - int first = tmpinput.find('.'); - tmpinput = tmpinput.remove(tmpinput.find('.', (first + 1)), 1); - } - if (tmpinput.contains(QRegExp("\\.[0-9][0-9]{2}$")) >= 1) - { - tmpinput = tmpinput.remove((tmpinput.length() - 1), 1); - } - transAmount->setText(tmpinput); -} - -void QCheckEntry::accept() -{ - // Does the description combo not have any text in it? Do something if it doesn't! - if (descriptionCombo->lineEdit()->text().isEmpty() == true) - { - QMessageBox::critical(this, "Field Missing.", "<qt>You didn't enter a description for this transaction. Please fill out the \"Transaction Description\" field and try again.</qt>"); - descriptionCombo->setFocus(); - return; - } - QDialog::accept(); -} diff --git a/noncore/apps/checkbook/qcheckentry.h b/noncore/apps/checkbook/qcheckentry.h deleted file mode 100644 index f361bbf..0000000 --- a/noncore/apps/checkbook/qcheckentry.h +++ b/dev/null @@ -1,31 +0,0 @@ -#include <qstring.h> -#include <qcombobox.h> -#include "qrestrictedline.h" -#include <qcombobox.h> -#include <qstringlist.h> -#include <qlabel.h> -#include <qmultilineedit.h> -#include "qcheckentrybase.h" -#include <qdialog.h> -#include <qregexp.h> -#include <qmessagebox.h> -#include <qwidget.h> -#include <qevent.h> -#include <qdatetime.h> -#include <qradiobutton.h> -#include "config.h" - -class QCheckEntry : public QCheckEntryBase -{ - Q_OBJECT - public: - QCheckEntry(); - static QStringList popupEntry(const QStringList &originaldata); - private slots: - void amountChanged(const QString &); - void transFeeChanged(const QString &); - void paymentClicked(); - void depositClicked(); - protected slots: - virtual void accept(); -}; diff --git a/noncore/apps/checkbook/qcheckentrybase.ui b/noncore/apps/checkbook/qcheckentrybase.ui deleted file mode 100644 index efc35ff..0000000 --- a/noncore/apps/checkbook/qcheckentrybase.ui +++ b/dev/null @@ -1,610 +0,0 @@ -<!DOCTYPE UI><UI> -<class>QCheckEntryBase</class> -<widget> - <class>QDialog</class> - <property stdset="1"> - <name>name</name> - <cstring>QCheckEntryBase</cstring> - </property> - <property stdset="1"> - <name>geometry</name> - <rect> - <x>0</x> - <y>0</y> - <width>224</width> - <height>291</height> - </rect> - </property> - <property stdset="1"> - <name>caption</name> - <string>Account Transaction</string> - </property> - <property> - <name>layoutMargin</name> - </property> - <property> - <name>layoutSpacing</name> - </property> - <grid> - <property stdset="1"> - <name>margin</name> - <number>5</number> - </property> - <property stdset="1"> - <name>spacing</name> - <number>2</number> - </property> - <spacer row="7" column="8" rowspan="1" colspan="4" > - <property> - <name>name</name> - <cstring>Spacer3</cstring> - </property> - <property stdset="1"> - <name>orientation</name> - <enum>Horizontal</enum> - </property> - <property stdset="1"> - <name>sizeType</name> - <enum>Expanding</enum> - </property> - <property> - <name>sizeHint</name> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - <spacer row="3" column="1" rowspan="1" colspan="4" > - <property> - <name>name</name> - <cstring>Spacer5</cstring> - </property> - <property stdset="1"> - <name>orientation</name> - <enum>Horizontal</enum> - </property> - <property stdset="1"> - <name>sizeType</name> - <enum>Expanding</enum> - </property> - <property> - <name>sizeHint</name> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - <widget row="5" column="5" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel6</cstring> - </property> - <property stdset="1"> - <name>font</name> - <font> - <family>adobe-helvetica</family> - <bold>1</bold> - </font> - </property> - <property stdset="1"> - <name>text</name> - <string>$</string> - </property> - </widget> - <spacer row="4" column="6" > - <property> - <name>name</name> - <cstring>Spacer8</cstring> - </property> - <property stdset="1"> - <name>orientation</name> - <enum>Horizontal</enum> - </property> - <property stdset="1"> - <name>sizeType</name> - <enum>Expanding</enum> - </property> - <property> - <name>sizeHint</name> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - <widget row="2" column="0" rowspan="1" colspan="3" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel2</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Category:</string> - </property> - </widget> - <spacer row="5" column="2" rowspan="1" colspan="3" > - <property> - <name>name</name> - <cstring>Spacer7</cstring> - </property> - <property stdset="1"> - <name>orientation</name> - <enum>Horizontal</enum> - </property> - <property stdset="1"> - <name>sizeType</name> - <enum>Expanding</enum> - </property> - <property> - <name>sizeHint</name> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - <spacer row="5" column="11" > - <property> - <name>name</name> - <cstring>Spacer4</cstring> - </property> - <property stdset="1"> - <name>orientation</name> - <enum>Horizontal</enum> - </property> - <property stdset="1"> - <name>sizeType</name> - <enum>Expanding</enum> - </property> - <property> - <name>sizeHint</name> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - <spacer row="2" column="3" rowspan="1" colspan="2" > - <property> - <name>name</name> - <cstring>Spacer6</cstring> - </property> - <property stdset="1"> - <name>orientation</name> - <enum>Horizontal</enum> - </property> - <property stdset="1"> - <name>sizeType</name> - <enum>Expanding</enum> - </property> - <property> - <name>sizeHint</name> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - <widget row="5" column="6" rowspan="1" colspan="5" > - <class>QRestrictedLine</class> - <property stdset="1"> - <name>name</name> - <cstring>transAmount</cstring> - </property> - </widget> - <widget row="1" column="0" rowspan="1" colspan="5" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel1</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Description:</string> - </property> - </widget> - <widget row="3" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel3</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Type:</string> - </property> - </widget> - <widget row="5" column="0" rowspan="1" colspan="2" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel5</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Amount:</string> - </property> - </widget> - <widget row="2" column="5" rowspan="1" colspan="7" > - <class>QComboBox</class> - <item> - <property> - <name>text</name> - <string>Automobile</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>Bills</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>CDs</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>Clothing</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>Computer</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>DVDs</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>Eletronics</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>Entertainment</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>Food</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>Gasoline</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>Misc</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>Movies</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>Rent</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>Travel</string> - </property> - </item> - <property stdset="1"> - <name>name</name> - <cstring>cmbCategory</cstring> - </property> - <property stdset="1"> - <name>editable</name> - <bool>true</bool> - </property> - <property stdset="1"> - <name>currentItem</name> - <number>0</number> - </property> - <property stdset="1"> - <name>autoCompletion</name> - <bool>true</bool> - </property> - <property stdset="1"> - <name>duplicatesEnabled</name> - <bool>false</bool> - </property> - </widget> - <widget row="4" column="0" rowspan="1" colspan="6" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel4</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Check Number:</string> - </property> - </widget> - <widget row="6" column="4" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel6_2</cstring> - </property> - <property stdset="1"> - <name>font</name> - <font> - <family>adobe-helvetica</family> - <bold>1</bold> - </font> - </property> - <property stdset="1"> - <name>text</name> - <string>$</string> - </property> - </widget> - <widget row="6" column="5" rowspan="1" colspan="4" > - <class>QRestrictedLine</class> - <property stdset="1"> - <name>name</name> - <cstring>transFee</cstring> - </property> - </widget> - <widget row="6" column="0" rowspan="1" colspan="4" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel7</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Extra Fee:</string> - </property> - </widget> - <widget row="7" column="0" rowspan="1" colspan="8" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel8</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Additional Notes:</string> - </property> - </widget> - <widget row="1" column="5" rowspan="1" colspan="7" > - <class>QComboBox</class> - <property stdset="1"> - <name>name</name> - <cstring>descriptionCombo</cstring> - </property> - <property stdset="1"> - <name>editable</name> - <bool>true</bool> - </property> - <property stdset="1"> - <name>maxCount</name> - <number>10</number> - </property> - <property stdset="1"> - <name>insertionPolicy</name> - <enum>BeforeCurrent</enum> - </property> - <property stdset="1"> - <name>autoCompletion</name> - <bool>true</bool> - </property> - <property stdset="1"> - <name>duplicatesEnabled</name> - <bool>false</bool> - </property> - </widget> - <widget row="6" column="9" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel9</cstring> - </property> - <property stdset="1"> - <name>minimumSize</name> - <size> - <width>0</width> - <height>0</height> - </size> - </property> - <property stdset="1"> - <name>maximumSize</name> - <size> - <width>32767</width> - <height>32767</height> - </size> - </property> - <property stdset="1"> - <name>caption</name> - <string></string> - </property> - <property stdset="1"> - <name>text</name> - <string>Date:</string> - </property> - </widget> - <widget row="6" column="10" rowspan="1" colspan="2" > - <class>QRestrictedLine</class> - <property stdset="1"> - <name>name</name> - <cstring>dateEdit</cstring> - </property> - </widget> - <widget row="4" column="7" rowspan="1" colspan="5" > - <class>QRestrictedLine</class> - <property stdset="1"> - <name>name</name> - <cstring>checkNumber</cstring> - </property> - </widget> - <widget row="3" column="5" rowspan="1" colspan="7" > - <class>QComboBox</class> - <item> - <property> - <name>text</name> - <string>Debit Charge</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>Written Check</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>Transfer</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>Credit Card</string> - </property> - </item> - <property stdset="1"> - <name>name</name> - <cstring>transType</cstring> - </property> - </widget> - <widget row="8" column="0" rowspan="1" colspan="12" > - <class>QMultiLineEdit</class> - <property stdset="1"> - <name>name</name> - <cstring>additionalNotes</cstring> - </property> - </widget> - <widget row="0" column="0" rowspan="1" colspan="12" > - <class>QButtonGroup</class> - <property stdset="1"> - <name>name</name> - <cstring>ButtonGroup3</cstring> - </property> - <property stdset="1"> - <name>sizePolicy</name> - <sizepolicy> - <hsizetype>7</hsizetype> - <vsizetype>7</vsizetype> - </sizepolicy> - </property> - <property stdset="1"> - <name>title</name> - <string></string> - </property> - <property> - <name>layoutMargin</name> - </property> - <property> - <name>layoutSpacing</name> - </property> - <grid> - <property stdset="1"> - <name>margin</name> - <number>4</number> - </property> - <property stdset="1"> - <name>spacing</name> - <number>0</number> - </property> - <widget row="0" column="1" > - <class>QRadioButton</class> - <property stdset="1"> - <name>name</name> - <cstring>deposit</cstring> - </property> - <property stdset="1"> - <name>sizePolicy</name> - <sizepolicy> - <hsizetype>1</hsizetype> - <vsizetype>1</vsizetype> - </sizepolicy> - </property> - <property stdset="1"> - <name>text</name> - <string>Deposit</string> - </property> - </widget> - <widget row="0" column="0" > - <class>QRadioButton</class> - <property stdset="1"> - <name>name</name> - <cstring>payment</cstring> - </property> - <property stdset="1"> - <name>sizePolicy</name> - <sizepolicy> - <hsizetype>1</hsizetype> - <vsizetype>1</vsizetype> - </sizepolicy> - </property> - <property stdset="1"> - <name>text</name> - <string>Payment</string> - </property> - <property stdset="1"> - <name>checked</name> - <bool>true</bool> - </property> - </widget> - </grid> - </widget> - </grid> -</widget> -<customwidgets> - <customwidget> - <class>QRestrictedLine</class> - <header location="local">qrestrictedline.h</header> - <sizehint> - <width>-1</width> - <height>-1</height> - </sizehint> - <container>0</container> - <sizepolicy> - <hordata>5</hordata> - <verdata>5</verdata> - </sizepolicy> - <pixmap>image0</pixmap> - </customwidget> -</customwidgets> -<images> - <image> - <name>image0</name> - <data format="XPM.GZ" length="649">789c6dd23b0ec2300c00d03da7b0e22d42e9476c88232031222186c80c3074813220c4dd214dddd84dac0e759fe2386e1a07a7e3015c639e6318ef04740b0f70d7d730bccf97fdc7d8be87f8406737c62210606869dbb531f531a57f4a299d03a7e06c11cca1055508412c2889acc2ef425423b34840a645f28244936860d2c265d7923bae8b2f05cb35a91739002d2b5727d535cbe954a43ad1e22f700755caf7407cf4799fe286c47dbe3bf303014167a2</data> - </image> -</images> -<tabstops> - <tabstop>payment</tabstop> - <tabstop>descriptionCombo</tabstop> - <tabstop>cmbCategory</tabstop> - <tabstop>transType</tabstop> - <tabstop>additionalNotes</tabstop> -</tabstops> -</UI> diff --git a/noncore/apps/checkbook/qcheckgraph.cpp b/noncore/apps/checkbook/qcheckgraph.cpp deleted file mode 100644 index 5b21ad8..0000000 --- a/noncore/apps/checkbook/qcheckgraph.cpp +++ b/dev/null @@ -1,258 +0,0 @@ -#include "qcheckgraph.h" - -#include <qpainter.h> -#include <qmessagebox.h> -#include <qfontmetrics.h> -#include <qdir.h> -#include <qfile.h> -#include <qstringlist.h> -#include <qdatetime.h> -#include <qmenubar.h> -#include <qpopupmenu.h> - -QCheckGraph::QCheckGraph(const QString filename) - : QCheckGraphBase() -{ - QMenuBar *bar = new QMenuBar(this); - bar->setMargin(0); - QPopupMenu *popup = new QPopupMenu; - popup->insertItem("&Save Graph...", this, SLOT(saveGraphAsPicture())); - bar->insertItem("&File", popup); - - pixmapready = false; - config = new Config(filename, Config::File); - QString forresult = ""; - QString forresult2 = ""; - int i = 1; - for (; forresult != "Not Found"; i++) - { - config->setGroup(QString::number(i)); - forresult = config->readEntry("Description", QString("Not Found")); - forresult2 = config->readEntry("Category", QString("Not Found")); - if (forresult != "Not Found") - { - if (list.contains(forresult2) == 0) - { - config->setGroup("Totals"); - QString larger = config->readEntry("Spent", QString("no")); - QString smaller = config->readEntry(forresult2, QString("no")); - if (larger != "no" && smaller != "no") - { - list << forresult2; - QString percentage = calculator(smaller, larger, true); - - // Here we calculate how many pixels tall it will be by multiplying it by 200. - QString pixels = calculator(percentage, QString("200"), false); - - // This is done because it really doesn't need to have a decimal... just an int, and - // QString rounds doubles up to the nearest whole number in order to convert - // to an int (which is correct). - pixels = pixels.remove(pixels.find('.'), pixels.length()); - - if (pixels.toInt() <= 5) - { - pixels = "6"; - } - - list2 << pixels; - } - } - } else { - continue; - } - // We want to break this loop on the 7th (remember, starts at 0->6 == 7) item. - if (list.count() == 6) - { - break; - } - } - for (QStringList::Iterator it = list.begin(); it != list.end(); it++) - { - if ((*it).length() > 11) - { - (*it).truncate(8); - (*it).append("..."); - } - } - graphPixmap(); -} - -void QCheckGraph::graphPixmap() -{ - pixmapready = false; - graph = QPixmap(240,250); - QPainter p; - p.begin(&graph); - p.fillRect(0, 0, 240, 300, QColor(255,255,255)); - // Draw the graph lines - - // Y - p.drawLine( 40, 50, 40, 252 ); - - // X - p.drawLine( 40, 252, 203, 252 ); - - // Y stepup lines - p.drawLine( 40, 50, 37, 50); - p.drawLine( 40, 70, 37, 70); - p.drawLine( 40, 90, 37, 90); - p.drawLine( 40, 110, 37, 110); - p.drawLine( 40, 130, 37, 130); - p.drawLine( 40, 150, 37, 150); - p.drawLine( 40, 170, 37, 170); - p.drawLine( 40, 190, 37, 190); - p.drawLine( 40, 210, 37, 210); - p.drawLine( 40, 230, 37, 230); - p.drawLine( 40, 245, 37, 245); - - - // Y stepup values - p.drawText((35 - p.fontMetrics().width("100")), (50 + (p.fontMetrics().height() / 2)), "100"); - p.drawText((35 - p.fontMetrics().width("90")), (70 + (p.fontMetrics().height() / 2)), "90"); - p.drawText((35 - p.fontMetrics().width("80")), (90 + (p.fontMetrics().height() / 2)), "80"); - p.drawText((35 - p.fontMetrics().width("70")), (110 + (p.fontMetrics().height() / 2)), "70"); - p.drawText((35 - p.fontMetrics().width("60")), (130 + (p.fontMetrics().height() / 2)), "60"); - p.drawText((35 - p.fontMetrics().width("50")), (150 + (p.fontMetrics().height() / 2)), "50"); - p.drawText((35 - p.fontMetrics().width("40")), (170 + (p.fontMetrics().height() / 2)), "40"); - p.drawText((35 - p.fontMetrics().width("30")), (190 + (p.fontMetrics().height() / 2)), "30"); - p.drawText((35 - p.fontMetrics().width("20")), (210 + (p.fontMetrics().height() / 2)), "20"); - p.drawText((35 - p.fontMetrics().width("10")), (230 + (p.fontMetrics().height() / 2)), "10"); - p.drawText((35 - p.fontMetrics().width("<10")), (245 + (p.fontMetrics().height() / 2)), "<10"); - - // Draw the axis[sic?] labels - QString ylabel = "Percentage"; - int pixel = 100; - for (unsigned int i = 0; i != ylabel.length(); i++) - { - p.setBrush(QColor(0,0,0)); - p.drawText(5,pixel, QString(ylabel[i])); - pixel = pixel + p.fontMetrics().height(); - } - p.drawText(95, 265, "Category"); - - int i = 0; - // Hack: Using if()'s... switch was acting all wierd :{ - QStringList::Iterator it2 = list2.begin(); - for (QStringList::Iterator it = list.begin(); it != list.end(); it++) - { - qWarning(QString::number(i)); - if (i ==0) - { - // For the color code: - p.setBrush(QColor(255,0,0)); - p.drawRect(8,12, 8, 8); - - // Now the text: - p.setBrush(QColor(0,0,0)); - p.drawText(18,20, (*it)); - - // Last, but not least, we have the actual bar graph height. - p.setBrush(QColor(255,0,0)); - p.drawRect(47, ((202 - (*it2).toInt()) + 50), 15, (*it2).toInt()); - } - if (i ==1) - { - p.setBrush(QColor(255,255,0)); - p.drawRect(78,12, 8, 8); - - p.setBrush(QColor(0,0,0)); - p.drawText(88,20, (*it)); - - p.setBrush(QColor(255,255,0)); - p.drawRect(70, ((202 - (*it2).toInt()) + 50), 15, (*it2).toInt()); - } - if (i==2) - { - p.setBrush(QColor(0,255,0)); - p.drawRect(153,12, 8, 8); - p.setBrush(QColor(0,0,0)); - p.drawText(163,20, (*it)); - - p.setBrush(QColor(0,255,0)); - p.drawRect(98, ((202 - (*it2).toInt()) + 50), 15, (*it2).toInt()); - } - if (i==3) - { - p.setBrush(QColor(89,12,54)); - p.drawRect(8,27, 8, 8); - p.setBrush(QColor(0,0,0)); - p.drawText(18,35, (*it)); - - p.setBrush(QColor(89,12,54)); - p.drawRect(126, ((202 - (*it2).toInt()) + 50), 15, (*it2).toInt()); - } - if (i==4) - { - p.setBrush(QColor(0,0,255)); - p.drawRect(78,27, 8, 8); - p.setBrush(QColor(0,0,0)); - p.drawText(88,35, (*it)); - p.setBrush(QColor(0,0,255)); - p.drawRect(154, ((202 - (*it2).toInt()) + 50), 15, (*it2).toInt()); - } - if (i==5) - { - p.setBrush(QColor(100,40,0)); - p.drawRect(153,27, 8, 8); - p.setBrush(QColor(0,0,0)); - p.drawText(163,35, (*it)); - p.setBrush(QColor(100,40,0)); - p.drawRect(182, ((202 - (*it2).toInt()) + 50), 15, (*it2).toInt()); - } - i++; - it2++; - } - - p.end(); - pixmapready = true; - graphWidget->setBackgroundPixmap(graph); -} - -QString QCheckGraph::calculator(QString largervalue, QString smallervalue, bool divide) -{ -// largervalue = largervalue.remove(largervalue.find(".", 0, false), 1); -// smallervalue = smallervalue.remove(smallervalue.find(".", 0, false), 1); - - double largercents = largervalue.toDouble(); - double smallercents = smallervalue.toDouble(); - - double finalammount = 0; - - if (divide == true) - { - finalammount = (largercents / smallercents); - } else { - finalammount = (largercents * smallercents); - } - - qWarning(QString::number(finalammount)); - - return QString::number(finalammount); -} - -/*void QCheckGraph::paintEvent(QPaintEvent *e) -{ - if (pixmapready == true) - { - bitBlt((QPaintDevice *)(graphWidget), 0, 0, graph, 0,0); - QWidget::paintEvent(e); - } -} -*/ -void QCheckGraph::saveGraphAsPicture() -{ - QString homedir = QDir::homeDirPath(); - QDate current = QDate::currentDate(); - QString datestring = QString::number(current.month()); - datestring.append(QString::number(current.day())); - datestring.append(QString::number(current.year())); - QString filename = homedir; - filename.append("/Documents/graph"); - filename.append(datestring); - filename.append(".png"); - graph.save(filename, "PNG", 85); - QString graphmessage = "<qt>The graph was saved as graph"; - graphmessage.append(datestring); - graphmessage.append(".png. You may access it by returning to your home screen and clicking on the \"Documents\" tab in the upper right hand screen</qt>"); - QMessageBox::information(0, "File Saved", graphmessage); -} diff --git a/noncore/apps/checkbook/qcheckgraph.h b/noncore/apps/checkbook/qcheckgraph.h deleted file mode 100644 index 1cafef8..0000000 --- a/noncore/apps/checkbook/qcheckgraph.h +++ b/dev/null @@ -1,25 +0,0 @@ -#include <qstring.h> -#include <qmainwindow.h> -#include <qwidget.h> -#include <qstringlist.h> -#include <qpixmap.h> -#include "config.h" - -#include "qcheckgraphbase.h" - -class QCheckGraph : public QCheckGraphBase -{ - Q_OBJECT - public: - QCheckGraph(const QString); - private: - QStringList list; - QStringList list2; - QString calculator(QString larger, QString smaller, bool divide); - QPixmap graph; - void graphPixmap(); - bool pixmapready; - Config *config; - private slots: - void saveGraphAsPicture(); -}; diff --git a/noncore/apps/checkbook/qcheckgraphbase.ui b/noncore/apps/checkbook/qcheckgraphbase.ui deleted file mode 100644 index 2763839..0000000 --- a/noncore/apps/checkbook/qcheckgraphbase.ui +++ b/dev/null @@ -1,62 +0,0 @@ -<!DOCTYPE UI><UI> -<class>QCheckGraphBase</class> -<widget> - <class>QDialog</class> - <property stdset="1"> - <name>name</name> - <cstring>QCheckGraphBase</cstring> - </property> - <property stdset="1"> - <name>geometry</name> - <rect> - <x>0</x> - <y>0</y> - <width>236</width> - <height>285</height> - </rect> - </property> - <property stdset="1"> - <name>caption</name> - <string>Account Graph</string> - </property> - <grid> - <property stdset="1"> - <name>margin</name> - <number>0</number> - </property> - <property stdset="1"> - <name>spacing</name> - <number>0</number> - </property> - <widget row="0" column="0" > - <class>QWidget</class> - <property stdset="1"> - <name>name</name> - <cstring>graphWidget</cstring> - </property> - </widget> - </grid> -</widget> -<customwidgets> - <customwidget> - <class>QWidget</class> - <header location="global">qwidget.h</header> - <sizehint> - <width>-1</width> - <height>-1</height> - </sizehint> - <container>0</container> - <sizepolicy> - <hordata>5</hordata> - <verdata>5</verdata> - </sizepolicy> - <pixmap>image0</pixmap> - </customwidget> -</customwidgets> -<images> - <image> - <name>image0</name> - <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1ddec44f503c0ae2a154410f53d0ed20e2bf6bdb656dd6861dd23d9a66591b0587fd1654235ebded6f0edcd53e419d87ae7b1f4f9b8f906d0bfe012317426a70b07bdc2f3ec77f8ed6b89559061a0343d06a124cc105596482585094bc0ae599b04646c9018926491b2205e140c485cace25755c175d0a967b622ff900b8cc9c7d29af594ea722d589167f813aa852ba07d94b9dce296e883fe7bb163f23896753</data> - </image> -</images> -</UI> diff --git a/noncore/apps/checkbook/qcheckmainmenu.cpp b/noncore/apps/checkbook/qcheckmainmenu.cpp deleted file mode 100644 index 1aead88..0000000 --- a/noncore/apps/checkbook/qcheckmainmenu.cpp +++ b/dev/null @@ -1,105 +0,0 @@ -#include "qcheckmainmenu.h" -#include "qcheckname.h" - -QCheckMainMenu::QCheckMainMenu(QWidget *parent) - : QCheckMMBase(parent) -{ - init(); -} - -void QCheckMainMenu::init() -{ - lstCheckBooks->clear(); - QString checkdirname = QDir::homeDirPath(); - checkdirname.append("/.checkbooks"); - QDir checkdir(checkdirname); - 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()); - } - lstCheckBooks->insertStringList(checkbooks); - } - lstCheckBooks->clearSelection(); - connect(lstCheckBooks, SIGNAL(clicked(QListBoxItem *)), this, SLOT(slotSelected(QListBoxItem *))); - lstCheckBooks->clearSelection(); -} - -void QCheckMainMenu::slotSelected(QListBoxItem *item) -{ - if (item != 0) - { - QString text = item->text(); - if (text.isEmpty() == false) - { - text.append(".qcb"); - QString checkdirname = QDir::homeDirPath(); - checkdirname.append("/.checkbooks/"); - text.prepend(checkdirname); - emit itemSelected(text); - } - } -} - -void QCheckMainMenu::newClicked() -{ - QString checkname = QCheckName::getName(); - if (checkname.isEmpty() == false) - { - QString checkdirname = QDir::homeDirPath(); - checkdirname.append("/.checkbooks"); - QDir checkdir(checkdirname); - if (checkdir.exists() == false) - { - checkdir.mkdir(checkdirname); - } - checkdirname.append("/"); - checkdirname.append(checkname); - checkdirname.append(".qcb"); - QFile file(checkdirname); - if (file.exists() == false) - { - file.open(IO_WriteOnly); - QTextStream os(&file); - os << ""; - file.close(); - } - QFileInfo fi(file); - QString noextension = fi.fileName(); - noextension = noextension.remove(noextension.find('.'), noextension.length()); - lstCheckBooks->insertItem(noextension); - } -} - -void QCheckMainMenu::deleteClicked() -{ - QString checkname = lstCheckBooks->currentText(); - if (checkname.isEmpty() == false) { - switch ( QMessageBox::warning(this,tr("Delete Account"),tr("Really delete the\n") - +checkname+tr(" account?") - ,tr("Yes"),tr("No"),0,1,1) ) { - case 0: { - - QString checkdirname = QDir::homeDirPath(); - checkdirname.append("/.checkbooks"); - QDir checkdir(checkdirname); - QString checkDir=checkdirname; - - checkdirname.append("/"); - checkdirname.append(checkname); - checkdirname.append(".qcb"); - QFile file(checkdirname); - if (file.exists() == true) { - if(!file.remove()) { - QMessageBox::message(tr("Checkbook"),tr("Could not remove account")); - return; - } else - lstCheckBooks->removeItem(lstCheckBooks->currentItem()); - } - } - break; - } - } -} diff --git a/noncore/apps/checkbook/qcheckmainmenu.h b/noncore/apps/checkbook/qcheckmainmenu.h deleted file mode 100644 index 24d601b..0000000 --- a/noncore/apps/checkbook/qcheckmainmenu.h +++ b/dev/null @@ -1,28 +0,0 @@ -#include <qwidget.h> -#include <qtoolbutton.h> -#include <qpopupmenu.h> -#include <qfile.h> -#include <qdir.h> -#include <qtextstream.h> -#include <qstring.h> -#include <qlistbox.h> -#include <qmessagebox.h> - -#include "qcheckmmbase.h" - -class QCheckMainMenu : public QCheckMMBase -{ - Q_OBJECT - public: - QCheckMainMenu(QWidget *); - signals: - void itemSelected(const QString &); - private: - void init(); - private slots: - void slotSelected(QListBoxItem *); - public slots: - void newClicked(); - void deleteClicked(); -}; - diff --git a/noncore/apps/checkbook/qcheckmmbase.ui b/noncore/apps/checkbook/qcheckmmbase.ui deleted file mode 100644 index efde990..0000000 --- a/noncore/apps/checkbook/qcheckmmbase.ui +++ b/dev/null @@ -1,80 +0,0 @@ -<!DOCTYPE UI><UI> -<class>QCheckMMBase</class> -<widget> - <class>QWidget</class> - <property stdset="1"> - <name>name</name> - <cstring>QCheckMMBase</cstring> - </property> - <property stdset="1"> - <name>geometry</name> - <rect> - <x>0</x> - <y>0</y> - <width>256</width> - <height>311</height> - </rect> - </property> - <property stdset="1"> - <name>caption</name> - <string>Main Menu</string> - </property> - <grid> - <property stdset="1"> - <name>margin</name> - <number>7</number> - </property> - <property stdset="1"> - <name>spacing</name> - <number>3</number> - </property> - <widget row="0" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel2</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Select from the check books below or click the "New" icon in the toolbar.</string> - </property> - <property stdset="1"> - <name>alignment</name> - <set>WordBreak|AlignVCenter|AlignLeft</set> - </property> - <property> - <name>wordwrap</name> - </property> - </widget> - <widget row="1" column="0" > - <class>QListBox</class> - <property stdset="1"> - <name>name</name> - <cstring>lstCheckBooks</cstring> - </property> - </widget> - </grid> -</widget> -<customwidgets> - <customwidget> - <class>QWidget</class> - <header location="global">qwidget.h</header> - <sizehint> - <width>-1</width> - <height>-1</height> - </sizehint> - <container>0</container> - <sizepolicy> - <hordata>5</hordata> - <verdata>5</verdata> - </sizepolicy> - <pixmap>image0</pixmap> - </customwidget> -</customwidgets> -<images> - <image> - <name>image0</name> - <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1ddec44f503c0ae2a154410f53d0ed20e2bf6bdb656dd6861dd23d9a66591b0587fd1654235ebded6f0edcd53e419d87ae7b1f4f9b8f906d0bfe012317426a70b07bdc2f3ec77f8ed6b89559061a0343d06a124cc105596482585094bc0ae599b04646c9018926491b2205e140c485cace25755c175d0a967b622ff900b8cc9c7d29af594ea722d589167f813aa852ba07d94b9dce296e883fe7bb163f23896753</data> - </image> -</images> -</UI> diff --git a/noncore/apps/checkbook/qcheckname.cpp b/noncore/apps/checkbook/qcheckname.cpp deleted file mode 100644 index 0e4d71c..0000000 --- a/noncore/apps/checkbook/qcheckname.cpp +++ b/dev/null @@ -1,36 +0,0 @@ -#include "qcheckname.h" -#include <qmessagebox.h> -#include <qdialog.h> -#include <qpushbutton.h> -#include <qlineedit.h> -#include "qrestrictedline.h" - -QCheckName::QCheckName() - : QCheckNameBase() -{ - connect(cmdDone, SIGNAL(clicked()), this, SLOT(clicked())); -} - -QString QCheckName::getName() -{ - QCheckName qcn; - qcn.setWFlags(Qt::WType_Modal); - qcn.leText->setValidChars("abcdefghijklmnopqrstuvwxyz0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"); - if (qcn.exec() == QDialog::Accepted) - { - return qcn.leText->text(); - } else { - return QString(""); - } -} - -void QCheckName::clicked() -{ - if (leText->text().isEmpty() == false) - { - hide(); - accept(); - } else { - QMessageBox::critical(this, "Missing Information", "<qt>Please enter the name of your Check Book and try again.</qt>"); - } -} diff --git a/noncore/apps/checkbook/qcheckname.h b/noncore/apps/checkbook/qcheckname.h deleted file mode 100644 index c47c4f9..0000000 --- a/noncore/apps/checkbook/qcheckname.h +++ b/dev/null @@ -1,15 +0,0 @@ -#include "qchecknamebase.h" -#include <qstring.h> -#include <qwidget.h> - -class QCheckName : public QCheckNameBase -{ - Q_OBJECT - public: - QCheckName(); - static QString getName(); - private: - QWidget *m_parent; - private slots: - void clicked(); -}; diff --git a/noncore/apps/checkbook/qchecknamebase.cpp b/noncore/apps/checkbook/qchecknamebase.cpp deleted file mode 100644 index 27bebc1..0000000 --- a/noncore/apps/checkbook/qchecknamebase.cpp +++ b/dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** Form implementation generated from reading ui file 'qchecknamebase.ui' -** -** Created: Wed Sep 18 09:40:57 2002 -** by: The User Interface Compiler (uic) -** -** WARNING! All changes made in this file will be lost! -****************************************************************************/ -#include "qchecknamebase.h" - -#include <qlabel.h> -#include <qpushbutton.h> -#include "qrestrictedline.h" -#include <qlayout.h> -#include <qvariant.h> -#include <qtooltip.h> -#include <qwhatsthis.h> - -/* - * Constructs a QCheckNameBase which is a child of 'parent', with the - * name 'name' and widget flags set to 'f' - * - * The dialog will by default be modeless, unless you set 'modal' to - * TRUE to construct a modal dialog. - */ -QCheckNameBase::QCheckNameBase( QWidget* parent, const char* name, bool modal, WFlags fl ) - : QDialog( parent, name, modal, fl ) -{ - if ( !name ) - setName( "QCheckNameBase" ); - resize( 228, 108 ); - setCaption( tr( "Check Book Name" ) ); - - TextLabel3 = new QLabel( this, "TextLabel3" ); - TextLabel3->setGeometry( QRect( 10, 5, 70, 16 ) ); - QFont TextLabel3_font( TextLabel3->font() ); - TextLabel3_font.setFamily( "BDF-helvetica" ); - TextLabel3_font.setPointSize( 19 ); - TextLabel3_font.setBold( TRUE ); - TextLabel3->setFont( TextLabel3_font ); - TextLabel3->setText( tr( "Name..." ) ); - - TextLabel4 = new QLabel( this, "TextLabel4" ); - TextLabel4->setGeometry( QRect( 10, 25, 210, 25 ) ); - TextLabel4->setText( tr( "Please name your check book.\n(limit: 15 characters):" ) ); - TextLabel4->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter | QLabel::AlignLeft ) ); - - cmdDone = new QPushButton( this, "cmdDone" ); - cmdDone->setGeometry( QRect( 75, 80, 75, 25 ) ); - cmdDone->setText( tr( "&Done" ) ); - - leText = new QRestrictedLine( this, "leText" ); - leText->setGeometry( QRect( 5, 51, 216, 25 ) ); - leText->setFocus(); -} - -/* - * Destroys the object and frees any allocated resources - */ -QCheckNameBase::~QCheckNameBase() -{ - // no need to delete child widgets, Qt does it all for us -} - -/* - * Main event handler. Reimplemented to handle application - * font changes - */ -bool QCheckNameBase::event( QEvent* ev ) -{ - bool ret = QDialog::event( ev ); - if ( ev->type() == QEvent::ApplicationFontChange ) { - QFont TextLabel3_font( TextLabel3->font() ); - TextLabel3_font.setFamily( "BDF-helvetica" ); - TextLabel3_font.setPointSize( 19 ); - TextLabel3_font.setBold( TRUE ); - TextLabel3->setFont( TextLabel3_font ); - } - return ret; -} - diff --git a/noncore/apps/checkbook/qchecknamebase.h b/noncore/apps/checkbook/qchecknamebase.h deleted file mode 100644 index 864ecd6..0000000 --- a/noncore/apps/checkbook/qchecknamebase.h +++ b/dev/null @@ -1,38 +0,0 @@ -/**************************************************************************** -** Form interface generated from reading ui file 'qchecknamebase.ui' -** -** Created: Wed Sep 18 09:40:11 2002 -** by: The User Interface Compiler (uic) -** -** WARNING! All changes made in this file will be lost! -****************************************************************************/ -#ifndef QCHECKNAMEBASE_H -#define QCHECKNAMEBASE_H - -#include <qvariant.h> -#include <qdialog.h> -class QVBoxLayout; -class QHBoxLayout; -class QGridLayout; -class QLabel; -class QPushButton; -class QRestrictedLine; - -class QCheckNameBase : public QDialog -{ - Q_OBJECT - -public: - QCheckNameBase( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); - ~QCheckNameBase(); - - QLabel* TextLabel3; - QLabel* TextLabel4; - QPushButton* cmdDone; - QRestrictedLine* leText; - -protected: - bool event( QEvent* ); -}; - -#endif // QCHECKNAMEBASE_H diff --git a/noncore/apps/checkbook/qchecknamebase.ui b/noncore/apps/checkbook/qchecknamebase.ui deleted file mode 100644 index b9bda19..0000000 --- a/noncore/apps/checkbook/qchecknamebase.ui +++ b/dev/null @@ -1,136 +0,0 @@ -<!DOCTYPE UI><UI> -<class>QCheckNameBase</class> -<widget> - <class>QDialog</class> - <property stdset="1"> - <name>name</name> - <cstring>QCheckNameBase</cstring> - </property> - <property stdset="1"> - <name>geometry</name> - <rect> - <x>0</x> - <y>0</y> - <width>228</width> - <height>108</height> - </rect> - </property> - <property stdset="1"> - <name>caption</name> - <string>Check Book Name</string> - </property> - <widget> - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel3</cstring> - </property> - <property stdset="1"> - <name>geometry</name> - <rect> - <x>10</x> - <y>5</y> - <width>70</width> - <height>16</height> - </rect> - </property> - <property stdset="1"> - <name>font</name> - <font> - <family>BDF-helvetica</family> - <pointsize>19</pointsize> - <bold>1</bold> - </font> - </property> - <property stdset="1"> - <name>text</name> - <string>Name...</string> - </property> - </widget> - <widget> - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel4</cstring> - </property> - <property stdset="1"> - <name>geometry</name> - <rect> - <x>10</x> - <y>25</y> - <width>210</width> - <height>25</height> - </rect> - </property> - <property stdset="1"> - <name>text</name> - <string>Please name your check book (limit: 15 characters):</string> - </property> - <property stdset="1"> - <name>alignment</name> - <set>WordBreak|AlignVCenter|AlignLeft</set> - </property> - <property> - <name>wordwrap</name> - </property> - </widget> - <widget> - <class>QPushButton</class> - <property stdset="1"> - <name>name</name> - <cstring>cmdDone</cstring> - </property> - <property stdset="1"> - <name>geometry</name> - <rect> - <x>75</x> - <y>80</y> - <width>75</width> - <height>25</height> - </rect> - </property> - <property stdset="1"> - <name>text</name> - <string>&Done</string> - </property> - </widget> - <widget> - <class>QRestrictedLine</class> - <property stdset="1"> - <name>name</name> - <cstring>leText</cstring> - </property> - <property stdset="1"> - <name>geometry</name> - <rect> - <x>5</x> - <y>51</y> - <width>216</width> - <height>25</height> - </rect> - </property> - </widget> -</widget> -<customwidgets> - <customwidget> - <class>QRestrictedLine</class> - <header location="local">qrestrictedline.h</header> - <sizehint> - <width>-1</width> - <height>-1</height> - </sizehint> - <container>0</container> - <sizepolicy> - <hordata>5</hordata> - <verdata>5</verdata> - </sizepolicy> - <pixmap>image0</pixmap> - </customwidget> -</customwidgets> -<images> - <image> - <name>image0</name> - <data format="XPM.GZ" length="649">789c6dd23b0ec2300c00d03da7b0e22d42e9476c88232031222186c80c3074813220c4dd214dddd84dac0e759fe2386e1a07a7e3015c639e6318ef04740b0f70d7d730bccf97fdc7d8be87f8406737c62210606869dbb531f531a57f4a299d03a7e06c11cca1055508412c2889acc2ef425423b34840a645f28244936860d2c265d7923bae8b2f05cb35a91739002d2b5727d535cbe954a43ad1e22f700755caf7407cf4799fe286c47dbe3bf303014167a2</data> - </image> -</images> -</UI> diff --git a/noncore/apps/checkbook/qcheckview.cpp b/noncore/apps/checkbook/qcheckview.cpp deleted file mode 100644 index ddc3fa9..0000000 --- a/noncore/apps/checkbook/qcheckview.cpp +++ b/dev/null @@ -1,458 +0,0 @@ -#include "qcheckview.h" - -#include <qpe/resource.h> -#include <qregexp.h> -#include <qlineedit.h> -#include <qradiobutton.h> -#include <qcombobox.h> -#include <qapplication.h> -#include <qpushbutton.h> -#include <qdir.h> -#include <qlabel.h> -#include <qdatetime.h> -#include <qmessagebox.h> -#include <qcheckbox.h> -#include <qfile.h> -#include <qtextstream.h> -#include <qbuttongroup.h> -#include <qradiobutton.h> -#include <qheader.h> - -QCheckView::QCheckView(QWidget *parent, QString filename) - : QCheckViewBase(parent) -{ - tblTransactions->setHScrollBarMode( QTable::AlwaysOff ); - tblTransactions->setNumRows( 0 ); - tblTransactions->setNumCols( 4 ); - tblTransactions->setShowGrid( FALSE ); - tblTransactions->horizontalHeader()->setLabel(0, "Num", 29); - tblTransactions->horizontalHeader()->setLabel(1, "Description", 81); - tblTransactions->horizontalHeader()->setLabel(2, "Date", 57); - tblTransactions->horizontalHeader()->setLabel(3, "Amount", 59); - tblTransactions->verticalHeader()->hide(); - tblTransactions->setLeftMargin( 0 ); - tblTransactions->setSelectionMode(QTable::NoSelection); - - m_filename = filename; - load(filename); -} - -void QCheckView::deleteClicked(int row, int col) -{ - QStringList existing; - QString rowText = tblTransactions->text(row, 0); - config->setGroup(rowText); - QString originalamount = config->readEntry("Amount", "0.00"); - - config->setGroup("Data"); - int lastCheck = config->readNumEntry("LastCheck", 0); - - qWarning(rowText); - config->setGroup(rowText); - QString payment = config->readEntry("Payment", "true"); - if ( payment == QString("true") && rowText.toInt() <= lastCheck) - { - for(int i = row; i != (lastCheck); i++) - { - config->setGroup(tblTransactions->text(i, 0)); - QString ibalance = config->readEntry("Balance", "0.00"); - // this adds the old amount on to the transaction and then takes the new amount away - QString newbalance = calculator(ibalance, originalamount, false); - config->writeEntry("Balance", newbalance); - - if (i == (lastCheck - 1)) - { - config->setGroup("Totals"); - config->writeEntry("Balance", newbalance); - break; - } - } - QString category = config->readEntry("Category", "Error"); - if (category != QString("Error")) - { - config->setGroup("Totals"); - config->writeEntry("Spent", calculator(config->readEntry("Spent", QString("0")), originalamount, true)); - QString categorytotal = config->readEntry(category, QString("0")); - categorytotal = calculator(categorytotal, originalamount, true); - config->writeEntry(category, categorytotal); - } - } - if ( payment == QString("false") && rowText.toInt() <= lastCheck) - { - for(int i = row; i != (lastCheck); i++) - { - config->setGroup(tblTransactions->text(i, 0)); - QString ibalance = config->readEntry("Balance", "0.00"); - // this subtracts the old amount on to the transaction and then adds the new amount on - QString newbalance = calculator(ibalance, originalamount, true); - config->writeEntry("Balance", newbalance); - - if (i == lastCheck - 1) - { - config->setGroup("Totals"); - config->writeEntry("Balance", newbalance); - break; - } - } - config->setGroup("Totals"); - config->writeEntry("Deposited", calculator(config->readEntry("Deposited", QString("0")), originalamount, true)); - } - for (int i = rowText.toInt(); i != lastCheck; i++) - { - qWarning(QString::number(i +1)); - config->setGroup(QString::number(i +1)); - QString origamount = config->readEntry("Amount", "0"); - qWarning(origamount); - QString origbalance = config->readEntry("Balance", "0"); - QString origchecknumber = config->readEntry("CheckNumber", "0"); - QString origcomments = config->readEntry("Comments", ""); - QString origdate = config->readEntry("Date", "01/01/2000"); - QString origdescription = config->readEntry("Description", "No Description"); - QString origpayment = config->readEntry("Payment", "true"); - QString origtransactionfee = config->readEntry("TransactionFee", "0"); - QString origtype = config->readEntry("Type", "0"); - - if (config->hasKey("Category")) - { - QString origcategory = config->readEntry("Category", "No Category"); - config->removeGroup(); - config->setGroup(QString::number(i)); - config->clearGroup(); - config->writeEntry("Category", origcategory); - } else { - config->removeGroup(); - config->setGroup(QString::number(i)); - config->clearGroup(); - } - config->writeEntry("Amount", origamount); - config->writeEntry("Balance", origbalance); - config->writeEntry("CheckNumber", origchecknumber); - config->writeEntry("Comments", origcomments); - config->writeEntry("Date", origdate); - config->writeEntry("Description", origdescription); - config->writeEntry("Payment", origpayment); - config->writeEntry("TransactionFee", origtransactionfee); - config->writeEntry("Type", origtype); - } - tblTransactions->clearCell(row, col); - labelBalance->setText(QString("$" + config->readEntry("Balance", QString("0.00")))); - config->setGroup("Data"); - config->writeEntry("LastCheck", QString::number(QString(config->readEntry("LastCheck", 0)).toInt() -1)); - config->write(); - delete qcd; - emit reload(m_filename); - -} - -void QCheckView::load(const QString filename) -{ - config = new Config(filename, Config::File); - - connect(tblTransactions, SIGNAL(clicked(int, int, int, const QPoint &)), this, SLOT(tableClicked(int, int, int, const QPoint &))); - - config->setGroup("Totals"); - labelBalance->setText(QString("$" + config->readEntry("Balance", QString("0.00")))); - - config->setGroup("Data"); - int lastCheck = config->readNumEntry("LastCheck", 1); - for (int i = 1; i != (lastCheck + 1); i++) - { - config->setGroup(QString::number(i)); - QString item = config->readEntry("Description", QString("Not Found")); - if (item != "Not Found") - { - QTableItem *qti = new QTableItem(tblTransactions, QTableItem::Never, QString::number(i)); - QTableItem *qti1 = new QTableItem(tblTransactions, QTableItem::Never, config->readEntry("Description", QString("None"))); - QTableItem *qti2 = new QTableItem(tblTransactions, QTableItem::Never, config->readEntry("Date", QString("None"))); - QTableItem *qti3 = new QTableItem(tblTransactions, QTableItem::Never, QString("$" + config->readEntry("Amount", QString("0.00")))); - int row = tblTransactions->numRows(); - tblTransactions->setNumRows(row + 1); - tblTransactions->setItem(row,0, qti); - tblTransactions->setItem(row,1, qti1); - tblTransactions->setItem(row,2, qti2); - tblTransactions->setItem(row,3, qti3); - tblTransactions->updateCell(row, 0); - tblTransactions->updateCell(row, 1); - tblTransactions->updateCell(row, 2); - tblTransactions->updateCell(row, 3); - } - } -} - -void QCheckView::editClicked(int row, int col) -{ - delete qcd; - QStringList existing; - QString rowText = tblTransactions->text(row, 0); - config->setGroup("Data"); - QString recent = config->readEntry("Recent", ""); - - config->setGroup(rowText); - //We need the original amount to add or subtract to check's blanaces written after this edited check - QString originalamount = config->readEntry("Amount", "0.00"); - QString originalcategory = config->readEntry("Category", "None"); - - existing << config->readEntry("Payment", "true") << config->readEntry("Description", "No Description Found") << config->readEntry("Category", "Misc.") << config->readEntry("Type", "0") << config->readEntry("CheckNumber", "0") << originalamount << config->readEntry("TransactionFee", "") << config->readEntry("Date", "01/01/2001") << config->readEntry("Comments", "") << recent; - QStringList result = QCheckEntry::popupEntry(existing); - if (result.isEmpty() == false) - { - config->setGroup("Data"); - int lastCheck = config->readNumEntry("LastCheck", 0); - config->writeEntry("Recent", result[9]); - - config->setGroup(rowText); - - tblTransactions->setText(row, 1, result[1]); - tblTransactions->updateCell(row, 1); - - tblTransactions->setText(row, 2, result[7]); - tblTransactions->updateCell(row, 2); - - tblTransactions->setText(row, 3, QString("$" + result[5])); - tblTransactions->updateCell(row, 3); - - // This is how the list looks: - // 0: true or false, true == payment, false == deposit - // 1: description of the transaction - // 2: category name - // 3: transaction type (stores the integer value of the index of the combobox) - // 4: check number of the transaction (if any) - // 5: transaction amount - // 6: transaction fee (e.g. service charge, or ATM charge). - // 7: date of the transaction - // 8: additional comments - config->writeEntry("Payment", result[0]); - config->writeEntry("Description", result[1]); - if (result[0] == QString("true")) - { - config->writeEntry("Category", result[2]); - } - config->writeEntry("Type", result[3]); - config->writeEntry("CheckNumber", result[4]); - config->writeEntry("Amount", result[5]); - config->writeEntry("TransactionFee", result[6]); - config->writeEntry("Date", result[7]); - config->writeEntry("Comments", result[8]); - if (result[0] == QString("true")) - { - if (rowText.toInt() <= lastCheck) - { - for(int i = (rowText.toInt() - 1); i != (lastCheck); i++) - { - config->setGroup(tblTransactions->text(i, 0)); - QString ibalance = config->readEntry("Balance", "0.00"); - - // this adds the old amount on to the transaction and then takes the new amount away - QString newbalance = calculator(calculator(ibalance, originalamount, false), result[5], true); - config->writeEntry("Balance", newbalance); - if (i == (lastCheck - 1)) - { - config->setGroup("Totals"); - config->writeEntry("Balance", newbalance); - break; - } - } - } - config->setGroup("Totals"); - config->writeEntry("Spent", calculator(config->readEntry("Spent", QString("0")), originalamount, true)); - config->writeEntry("Spent", calculator(config->readEntry("Spent", QString("0")), result[5], false)); - - if (result[2] == originalcategory) - { - QString categorytotal = config->readEntry(result[2], QString("0")); - categorytotal = calculator(categorytotal, originalamount, true); - categorytotal = calculator(categorytotal, result[5], false); - config->writeEntry(result[2], categorytotal); - } else { - QString origtotal = config->readEntry(originalcategory, QString("0")); - QString origfinal = calculator(origtotal, result[5], true); - if (origfinal == "0" || origfinal == "0.00") - { - config->removeEntry(originalcategory); - } else { - config->writeEntry(originalcategory, origfinal); - } - QString categorytotal = config->readEntry(result[2], QString("0")); - categorytotal = calculator(categorytotal, originalamount, false); - config->writeEntry(result[2],categorytotal); - } - } - if (result[0] == QString("false")) - { - if (rowText.toInt() <= lastCheck) - { - for(int i = (rowText.toInt() - 1 ); i != (lastCheck); i++) - { - config->setGroup(tblTransactions->text(i, 0)); - QString ibalance = config->readEntry("Balance", "0.00"); - - // this subtracts the old amount on to the transaction and then adds the new amount on - QString newbalance = calculator(calculator(ibalance, originalamount, true), result[5], false); - config->writeEntry("Balance", newbalance); - if (i == lastCheck - 1) - { - config->setGroup("Totals"); - config->writeEntry("Balance", newbalance); - break; - } - } - } - config->setGroup("Totals"); - config->writeEntry("Deposited", calculator(config->readEntry("Deposited", QString("0")), originalamount, true)); - config->writeEntry("Deposited", calculator(config->readEntry("Deposited", QString("0")), result[5], false)); - } - labelBalance->setText(QString("$" + config->readEntry("Balance", QString("0.00")))); - config->write(); - } -} -void QCheckView::tableClicked(int row, int col, int mouseButton, const QPoint &mousePos) -{ - if (tblTransactions->text(row, col).isEmpty() == false) - { - QStringList existing; - config->setGroup(tblTransactions->text(row, 0)); - existing << config->readEntry("Payment", "true") << config->readEntry("Description", "No Description Found") << config->readEntry("Category", "Misc.") << config->readEntry("Type", "0") << config->readEntry("CheckNumber", "0") << config->readEntry("Amount", "0.00") << config->readEntry("TransactionFee", "0.00") << config->readEntry("Date", "01/01/2001") << config->readEntry("Comments", "") << config->readEntry("Balance", "0.00"); - qcd = new QCheckDetails(row, col, existing); - qcd->showMaximized(); - connect(qcd, SIGNAL(editClicked(int, int)), this, SLOT(editClicked(int, int))); - connect(qcd, SIGNAL(deleteClicked(int, int)), this, SLOT(deleteClicked(int, int))); - } -} - -void QCheckView::newClicked() -{ - config->setGroup("Data"); - QString recent = config->readEntry("Recent", ""); - QStringList kindablank; - kindablank << recent; - QStringList result = QCheckEntry::popupEntry(kindablank); - if (result.count() > 1) - { - QTableItem *qti = new QTableItem(tblTransactions, QTableItem::Never, result[1]); - int row = tblTransactions->numRows(); - tblTransactions->setNumRows(row + 1); - tblTransactions->setItem(row,1, qti); - tblTransactions->updateCell(row, 1); - config->setGroup("Data"); - config->writeEntry("Recent", result[9]); - int lastCheck = config->readNumEntry("LastCheck", 0); - if (lastCheck == 0) - { - config->writeEntry("LastCheck", 1); - } else { - config->writeEntry("LastCheck", (lastCheck + 1)); - } - QString number = QString::number(lastCheck + 1); - config->setGroup(number); - - QTableItem *qti1 = new QTableItem(tblTransactions, QTableItem::Never, number); - tblTransactions->setItem(row, 0, qti1); - tblTransactions->updateCell(row, 0); - - QTableItem *qti2 = new QTableItem(tblTransactions, QTableItem::Never, result[7]); - tblTransactions->setItem(row, 2, qti2); - tblTransactions->updateCell(row, 2); - - QTableItem *qti3 = new QTableItem(tblTransactions, QTableItem::Never, QString("$" + result[5])); - tblTransactions->setItem(row, 3, qti3); - tblTransactions->updateCell(row, 3); - - // This is how the list looks: - // 0: true or false, true == payment, false == deposit - // 1: description of the transaction - // 2: category name - // 3: transaction type (stores the integer value of the index of the combobox) - // 4: check number of the transaction (if any) - // 5: transaction amount - // 6: transaction fee (e.g. service charge, or ATM charge). - // 7: date of the transaction - config->writeEntry("Payment", result[0]); - config->writeEntry("Description", result[1]); - if (result[0] == QString("true")) - { - config->writeEntry("Category", result[2]); - } - config->writeEntry("Type", result[3]); - config->writeEntry("CheckNumber", result[4]); - config->writeEntry("Amount", result[5]); - config->writeEntry("TransactionFee", result[6]); - config->writeEntry("Date", result[7]); - config->writeEntry("Comments", result[8]); - config->setGroup("Totals"); - if (result[0] == QString("true")) - { - QString totalspent = config->readEntry("Spent", QString("0")); - totalspent = calculator(totalspent, result[5], false); - config->writeEntry("Spent", totalspent); - QString balance = config->readEntry("Balance", QString("0")); - balance = calculator(balance, result[5], true); - - // Make sure to add the fee on, if any - balance = calculator(balance, result[6], true); - - config->writeEntry("Balance", balance); - - config->setGroup(number); - config->writeEntry("Balance", balance); - - config->setGroup("Totals"); - QString categorytotal = config->readEntry(result[2], QString("0")); - categorytotal = calculator(categorytotal, result[5], false); - config->writeEntry(result[2], categorytotal); - } - if (result[0] == QString("false")) - { - QString totaldeposited = config->readEntry("Deposited", QString("0")); - totaldeposited = calculator(totaldeposited, result[5], false); - config->writeEntry("Deposited", totaldeposited); - QString balance = config->readEntry("Balance", QString("0")); - balance = calculator(balance, result[5], false); - - // Make sure to add the fee on, if any - balance = calculator(balance, result[6], true); - - config->writeEntry("Balance", balance); - - config->setGroup(number); - config->writeEntry("Balance", balance); - } - } - config->setGroup("Totals"); - labelBalance->setText(QString("$" + config->readEntry("Balance", QString("0.00")))); - config->write(); -} - -QString QCheckView::calculator(QString largervalue, QString smallervalue, bool subtract) -{ - // This class provides a way to eliminate the ARM processor problem of not being able to handle - // decimals. I just take the two QString'ed numbers and find the decimal point, then I remove the decimal - // point seperating the number into two. Then I convert it to cents (times it times 100) and add/ - // substract the two together. Put the decimals back in, and return. - - largervalue = largervalue.remove(largervalue.find(".", 0, false), 1); - smallervalue = smallervalue.remove(smallervalue.find(".", 0, false), 1); - - int largercents = largervalue.toInt(); - int smallercents = smallervalue.toInt(); - - int finalammount = 0; - - if (subtract == true) - { - finalammount = largercents - smallercents; - } else { - finalammount = largercents + smallercents; - } - - QString returnvalue = QString::number(finalammount); - if (returnvalue.length() >= 2) - { - returnvalue.insert((returnvalue.length() - 2), "."); - } else { - if (returnvalue.length() == 1) - { - returnvalue.prepend("0.0"); - } - } - return returnvalue; -} diff --git a/noncore/apps/checkbook/qcheckview.h b/noncore/apps/checkbook/qcheckview.h deleted file mode 100644 index 840dc8b..0000000 --- a/noncore/apps/checkbook/qcheckview.h +++ b/dev/null @@ -1,33 +0,0 @@ -#include "qcheckviewbase.h" -#include "qrestrictedline.h" -#include "qcheckentry.h" -#include "qcheckdetails.h" - -#include <qstring.h> -#include "config.h" -#include <qtable.h> -#include <qpoint.h> -#include <qlayout.h> - -class QCheckView : public QCheckViewBase -{ - Q_OBJECT - public: - QCheckView(QWidget *, QString filename); - void load(const QString filename); - private: - Config *config; - QString calculator(QString largervalue, QString smallervalue, bool subtract); - int lastSortCol; - bool ascend; - QCheckDetails *qcd; - QString m_filename; - private slots: -// void entryActivated(int); - void newClicked(); - void tableClicked(int, int, int, const QPoint &mousePos); - void editClicked(int, int); - void deleteClicked(int, int); - signals: - void reload(const QString &filename); -}; diff --git a/noncore/apps/checkbook/qcheckviewbase.ui b/noncore/apps/checkbook/qcheckviewbase.ui deleted file mode 100644 index 00ed7dd..0000000 --- a/noncore/apps/checkbook/qcheckviewbase.ui +++ b/dev/null @@ -1,122 +0,0 @@ -<!DOCTYPE UI><UI> -<class>QCheckViewBase</class> -<widget> - <class>QWidget</class> - <property stdset="1"> - <name>name</name> - <cstring>QCheckViewBase</cstring> - </property> - <property stdset="1"> - <name>geometry</name> - <rect> - <x>0</x> - <y>0</y> - <width>242</width> - <height>312</height> - </rect> - </property> - <property stdset="1"> - <name>caption</name> - <string>Account Transactions</string> - </property> - <grid> - <property stdset="1"> - <name>margin</name> - <number>5</number> - </property> - <property stdset="1"> - <name>spacing</name> - <number>1</number> - </property> - <widget row="0" column="1" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>labelBalance</cstring> - </property> - <property stdset="1"> - <name>frameShape</name> - <enum>MShape</enum> - </property> - <property stdset="1"> - <name>frameShadow</name> - <enum>MShadow</enum> - </property> - <property stdset="1"> - <name>text</name> - <string>$0.00</string> - </property> - <property stdset="1"> - <name>alignment</name> - <set>AlignCenter</set> - </property> - <property> - <name>hAlign</name> - </property> - </widget> - <widget row="1" column="0" rowspan="1" colspan="2" > - <class>QTable</class> - <property stdset="1"> - <name>name</name> - <cstring>tblTransactions</cstring> - </property> - <property stdset="1"> - <name>hScrollBarMode</name> - <enum>AlwaysOff</enum> - </property> - <property stdset="1"> - <name>numRows</name> - <number>0</number> - </property> - <property stdset="1"> - <name>numCols</name> - <number>4</number> - </property> - <property stdset="1"> - <name>showGrid</name> - <bool>false</bool> - </property> - </widget> - <widget row="0" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel3</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Balance:</string> - </property> - <property stdset="1"> - <name>alignment</name> - <set>AlignVCenter|AlignRight</set> - </property> - <property> - <name>hAlign</name> - </property> - </widget> - </grid> -</widget> -<customwidgets> - <customwidget> - <class>QWidget</class> - <header location="global">qwidget.h</header> - <sizehint> - <width>-1</width> - <height>-1</height> - </sizehint> - <container>0</container> - <sizepolicy> - <hordata>5</hordata> - <verdata>5</verdata> - </sizepolicy> - <pixmap>image0</pixmap> - </customwidget> -</customwidgets> -<images> - <image> - <name>image0</name> - <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1ddec44f503c0ae2a154410f53d0ed20e2bf6bdb656dd6861dd23d9a66591b0587fd1654235ebded6f0edcd53e419d87ae7b1f4f9b8f906d0bfe012317426a70b07bdc2f3ec77f8ed6b89559061a0343d06a124cc105596482585094bc0ae599b04646c9018926491b2205e140c485cace25755c175d0a967b622ff900b8cc9c7d29af594ea722d589167f813aa852ba07d94b9dce296e883fe7bb163f23896753</data> - </image> -</images> -</UI> diff --git a/noncore/apps/checkbook/qrestrictedcombo.cpp b/noncore/apps/checkbook/qrestrictedcombo.cpp deleted file mode 100644 index e1533f6..0000000 --- a/noncore/apps/checkbook/qrestrictedcombo.cpp +++ b/dev/null @@ -1,78 +0,0 @@ -/* - * - * $Id$ - * - * Implementation of QRestrictedCombo - * - * Copyright (C) 1997 Michael Wiedmann, <mw@miwie.in-berlin.de> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include <qkeycode.h> - -#include "qrestrictedcombo.h" - -QRestrictedCombo::QRestrictedCombo( QWidget *parent, - const char *name, - const QString& valid ) - : QComboBox( parent, name ) -{ - qsValidChars = valid; -} - -QRestrictedCombo::~QRestrictedCombo() -{ - ; -} - - -void QRestrictedCombo::keyPressEvent( QKeyEvent *e ) -{ - // let QLineEdit process "special" keys and return/enter - // so that we still can use the default key binding - if (e->key() == Key_Enter || e->key() == Key_Return || e->key() == Key_Delete || e->ascii() < 32) - { - QComboBox::keyPressEvent(e); - return; - } - - // do we have a list of valid chars && - // is the pressed key in the list of valid chars? - if (!qsValidChars.isEmpty() && !qsValidChars.contains(e->ascii())) - { - // invalid char, emit signal and return - emit (invalidChar(e->key())); - return; - } - else - // valid char: let QLineEdit process this key as usual - QComboBox::keyPressEvent(e); - - return; -} - - -void QRestrictedCombo::setValidChars( const QString& valid) -{ - qsValidChars = valid; -} - -QString QRestrictedCombo::validChars() const -{ - return qsValidChars; -} - diff --git a/noncore/apps/checkbook/qrestrictedcombo.h b/noncore/apps/checkbook/qrestrictedcombo.h deleted file mode 100644 index 50ea59f..0000000 --- a/noncore/apps/checkbook/qrestrictedcombo.h +++ b/dev/null @@ -1,96 +0,0 @@ -/* - * - * Definition of QRestrictedCombo - * - * Copyright (C) 1997 Michael Wiedmann, <mw@miwie.in-berlin.de> - * - * Edited 2001 by Nick Betcher <nbetcher@usinternet.com> to work - * with Qt-only. Changed class name from LRestrictedLine to - * QRestrictedCombo in order to accomidate Combo Boxes. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef QRESTRICTEDCOMBO_H -#define QRESTRICTEDCOMBO_H - -#include <qcombobox.h> - -/** - * The QRestrictedCombo widget is a variant of @ref QComboBox which - * accepts only a restricted set of characters as input. - * All other characters will be discarded and the signal @ref #invalidChar() - * will be emitted for each of them. - * - * Valid characters can be passed as a QString to the constructor - * or set afterwards via @ref #setValidChars(). - * The default key bindings of @ref QComboBox are still in effect. - * - * @short A line editor for restricted character sets. - * @author Michael Wiedmann <mw@miwie.in-berlin.de> - * @version 0.0.1 - */ -class QRestrictedCombo : public QComboBox -{ - Q_OBJECT - Q_PROPERTY( QString validChars READ validChars WRITE setValidChars ) - -public: - - /** - * Constructor: This contructor takes three - optional - arguments. - * The first two parameters are simply passed on to @ref QLineEdit. - * @param parent pointer to the parent widget - * @param name pointer to the name of this widget - * @param valid pointer to set of valid characters - */ - QRestrictedCombo( QWidget *parent=0, const char *name=0, - const QString& valid = QString::null); - - /** - * Destructs the restricted line editor. - */ - ~QRestrictedCombo(); - - /** - * All characters in the string valid are treated as - * acceptable characters. - */ - void setValidChars(const QString& valid); - /** - * @return the string of acceptable characters. - */ - QString validChars() const; - -signals: - - /** - * Emitted when an invalid character was typed. - */ - void invalidChar(int); - -protected: - /** - * @reimplemented - */ - void keyPressEvent( QKeyEvent *e ); - -private: - /// QString of valid characters for this line - QString qsValidChars; -}; - -#endif // QRESTRICTEDCOMBO_H diff --git a/noncore/apps/checkbook/qrestrictedline.cpp b/noncore/apps/checkbook/qrestrictedline.cpp deleted file mode 100644 index 8508c33..0000000 --- a/noncore/apps/checkbook/qrestrictedline.cpp +++ b/dev/null @@ -1,78 +0,0 @@ -/* - * - * $Id$ - * - * Implementation of QRestrictedLine - * - * Copyright (C) 1997 Michael Wiedmann, <mw@miwie.in-berlin.de> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include <qkeycode.h> - -#include "qrestrictedline.h" - -QRestrictedLine::QRestrictedLine( QWidget *parent, - const char *name, - const QString& valid ) - : QLineEdit( parent, name ) -{ - qsValidChars = valid; -} - -QRestrictedLine::~QRestrictedLine() -{ - ; -} - - -void QRestrictedLine::keyPressEvent( QKeyEvent *e ) -{ - // let QLineEdit process "special" keys and return/enter - // so that we still can use the default key binding - if (e->key() == Key_Enter || e->key() == Key_Return || e->key() == Key_Delete || e->ascii() < 32) - { - QLineEdit::keyPressEvent(e); - return; - } - - // do we have a list of valid chars && - // is the pressed key in the list of valid chars? - if (!qsValidChars.isEmpty() && !qsValidChars.contains(e->ascii())) - { - // invalid char, emit signal and return - emit (invalidChar(e->key())); - return; - } - else - // valid char: let QLineEdit process this key as usual - QLineEdit::keyPressEvent(e); - - return; -} - - -void QRestrictedLine::setValidChars( const QString& valid) -{ - qsValidChars = valid; -} - -QString QRestrictedLine::validChars() const -{ - return qsValidChars; -} - diff --git a/noncore/apps/checkbook/qrestrictedline.h b/noncore/apps/checkbook/qrestrictedline.h deleted file mode 100644 index 7e41cd9..0000000 --- a/noncore/apps/checkbook/qrestrictedline.h +++ b/dev/null @@ -1,96 +0,0 @@ -/* - * - * Definition of QRestrictedLine - * - * Copyright (C) 1997 Michael Wiedmann, <mw@miwie.in-berlin.de> - * - * Edited 2001 by Nick Betcher <nbetcher@usinternet.com> to work - * with Qt-only. Changed class name from QRestrictedLine to - * QRestrictedLine. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef QRESTRICTEDLINE_H -#define QRESTRICTEDLINE_H - -#include <qlineedit.h> - -/** - * The QRestrictedLine widget is a variant of @ref QLineEdit which - * accepts only a restricted set of characters as input. - * All other characters will be discarded and the signal @ref #invalidChar() - * will be emitted for each of them. - * - * Valid characters can be passed as a QString to the constructor - * or set afterwards via @ref #setValidChars(). - * The default key bindings of @ref QLineEdit are still in effect. - * - * @short A line editor for restricted character sets. - * @author Michael Wiedmann <mw@miwie.in-berlin.de> - * @version 0.0.1 - */ -class QRestrictedLine : public QLineEdit -{ - Q_OBJECT - Q_PROPERTY( QString validChars READ validChars WRITE setValidChars ) - -public: - - /** - * Constructor: This contructor takes three - optional - arguments. - * The first two parameters are simply passed on to @ref QLineEdit. - * @param parent pointer to the parent widget - * @param name pointer to the name of this widget - * @param valid pointer to set of valid characters - */ - QRestrictedLine( QWidget *parent=0, const char *name=0, - const QString& valid = QString::null); - - /** - * Destructs the restricted line editor. - */ - ~QRestrictedLine(); - - /** - * All characters in the string valid are treated as - * acceptable characters. - */ - void setValidChars(const QString& valid); - /** - * @return the string of acceptable characters. - */ - QString validChars() const; - -signals: - - /** - * Emitted when an invalid character was typed. - */ - void invalidChar(int); - -protected: - /** - * @reimplemented - */ - void keyPressEvent( QKeyEvent *e ); - -private: - /// QString of valid characters for this line - QString qsValidChars; -}; - -#endif // QRESTRICTEDLINE_H diff --git a/noncore/apps/checkbook/traninfo.cpp b/noncore/apps/checkbook/traninfo.cpp new file mode 100644 index 0000000..5a770b0 --- a/dev/null +++ b/noncore/apps/checkbook/traninfo.cpp @@ -0,0 +1,156 @@ +/* + This file is part of the OPIE Project + =. + .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.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 "traninfo.h" + +#include <qpe/config.h> + +TranInfo::TranInfo( int id, const QString &desc, const QDate &date, bool withdrawal, + const QString &type, const QString &category, float amount, + float fee, const QString &number, const QString ¬es ) +{ + i = id; + d = desc; + td = date; + w = withdrawal; + t = type; + c = category; + a = amount; + f = fee; + cn = number; + n = notes; +} + +TranInfo::TranInfo( Config config, int entry ) +{ + config.setGroup( QString::number( entry ) ); + QString desc = config.readEntry( "Description", "Not Found" ); + if ( desc != "Not Found" ) + { + // ID + i = entry; + + // Description + d = desc; + + // Transaction date + int yr, mn, dy; + QString datestr = config.readEntry( "Date", "" ); + int begin, end; + begin = datestr.find( '/' ); + mn = datestr.left( begin ).toInt(); + end = datestr.find( '/', ++begin ); + dy = datestr.mid( begin, end - begin ).toInt(); + yr = datestr.right( datestr.length() - end - 1).toInt(); + td.setYMD( yr, mn, dy ); + + // Deposit/withdrawal indicator ( withdrawal == TRUE ) + w = ( config.readEntry( "Payment", "false" ) == "true" ); + + // Type + QString type = config.readEntry( "Type", "0" ); + if ( w ) + { // Withdrawal types + if( type == "0" ) + t = "Debit Charge"; + else if( type == "1" ) + t = "Written Check"; + else if( type == "2" ) + t = "Transfer"; + else if( type == "3" ) + t = "Credit Card"; + } + else + { + if( type == "0" ) + t = "Written Check"; + else if( type == "1" ) + t = "Automatic Payment"; + else if( type == "2" ) + t = "Transfer"; + else if( type == "3" ) + t = "Cash"; + } + + // Category + c = config.readEntry( "Category", "" ); + + // Transaction amount + QString stramount = config.readEntry( "Amount", "0.00" ); + bool ok; + a = stramount.toFloat( &ok ); + + // Transaction fee + stramount = config.readEntry( "TransactionFee", "0.00" ); + f = stramount.toFloat( &ok ); + + // Transaction number + cn = config.readEntry( "CheckNumber", "" ); + + // Notes + n = config.readEntry( "Comments", "" ); + } +} + +void TranInfo::write( Config *config, int entry ) +{ + config->setGroup( QString::number( entry ) ); + + config->writeEntry( "Description", d ); + + QString tempstr = QString::number( td.month() ) + "/" + + QString::number( td.day() ) + "/" + + QString::number( td.year() ); + config->writeEntry( "Date", tempstr ); + + w ? tempstr = "true" + : tempstr = "false"; + config->writeEntry( "Payment", tempstr ); + + if ( t == "Debit Charge" || t == "Written Check" ) + tempstr = "0"; + else if ( t == "Written Check" || t == "Automatic Payment" ) + tempstr = "1"; + else if ( t == "Transfer" ) + tempstr = "2"; + else if ( t == "Credit Card" || t == "Cash" ) + tempstr = "3"; + config->writeEntry( "Type", tempstr ); + + config->writeEntry( "Category", c ); + + tempstr.setNum( a, 'f', 2 ); + config->writeEntry( "Amount", tempstr ); + + tempstr.setNum( f, 'f', 2 ); + config->writeEntry( "TransactionFee", tempstr ); + + config->writeEntry( "CheckNumber", cn ); + + config->writeEntry( "Comments", n ); +} diff --git a/noncore/apps/checkbook/traninfo.h b/noncore/apps/checkbook/traninfo.h new file mode 100644 index 0000000..1743ff7 --- a/dev/null +++ b/noncore/apps/checkbook/traninfo.h @@ -0,0 +1,85 @@ +/* + This file is part of the OPIE Project + =. + .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.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 TRANINFO_H +#define TRANINFO_H + +#include <qdatetime.h> +#include <qlist.h> +#include <qstring.h> + +class Config; + +class TranInfo +{ + public: + TranInfo( int = 0, const QString & = 0x0, const QDate & = QDate::currentDate(), + bool = TRUE, const QString & = 0x0, const QString & = 0x0, + float = 0.0, float = 0.0, + const QString & = 0x0, const QString & = 0x0 ); + TranInfo( Config, int ); + + int id() const { return i; } + const QString &desc() const { return d; } + const QDate &date() const { return td; } + bool withdrawal() const { return w; } + const QString &type() const { return t; } + const QString &category() const { return c; } + float amount() const { return a; } + float fee() const { return f; } + const QString &number() const { return cn; } + const QString ¬es() const { return n; } + + void setDesc( const QString &desc ) { d = desc; } + void setDate( const QDate &date ) { td = date; } + void setWithdrawal( bool withdrawal ) { w = withdrawal; } + void setType( const QString &type ) { t = type; } + void setCategory( const QString &cat ) { c = cat; } + void setAmount( float amount ) { a = amount; } + void setFee( float fee ) { f = fee; } + void setNumber( const QString &num ) { cn = num; } + void setNotes( const QString ¬es ) { n = notes; } + + void write( Config *, int ); + + private: + int i; + QString d; + QDate td; + bool w; + QString t; + QString c; + float a; + float f; + QString cn; + QString n; +}; + +typedef QList<TranInfo> TranInfoList; + +#endif diff --git a/noncore/apps/checkbook/transaction.cpp b/noncore/apps/checkbook/transaction.cpp new file mode 100644 index 0000000..7d1781b --- a/dev/null +++ b/noncore/apps/checkbook/transaction.cpp @@ -0,0 +1,260 @@ +/* + This file is part of the OPIE Project + =. + .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.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 <stdio.h> + +Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *info, + char symbol ) + : QDialog( parent, 0, TRUE, 0 ) +{ + setCaption( tr( "Transaction for " ) + acctname ); + + 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 ); + layout2->addWidget( withBtn, 0, 0 ); + connect( withBtn, SIGNAL( clicked() ), this, SLOT( slotWithdrawalClicked() ) ); + depBtn = new QRadioButton( tr( "Deposit" ), btngrp ); + 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 ); + layout->addWidget( label, 1, 0 ); + dateBtn = new QPushButton( TimeString::shortDate( QDate::currentDate() ), + container ); + 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 ); + layout->addWidget( label, 1, 2 ); + numEdit = new QLineEdit( container ); + numEdit->setMaximumWidth( 40 ); + layout->addWidget( numEdit, 1, 3 ); + + // Description + label = new QLabel( tr( "Description:" ), container ); + layout->addWidget( label, 2, 0 ); + descEdit = new QLineEdit( container ); + layout->addMultiCellWidget( descEdit, 2, 2, 1, 3 ); + + // Category + label = new QLabel( tr( "Category:" ), container ); + layout->addWidget( label, 3, 0 ); + catList = new QComboBox( container ); + layout->addMultiCellWidget( catList, 3, 3, 1, 3 ); + + // Type + label = new QLabel( tr( "Type:" ), container ); + layout->addWidget( label, 4, 0 ); + typeList = new QComboBox( container ); + layout->addMultiCellWidget( typeList, 4, 4, 1, 3 ); + + // Amount + label = new QLabel( tr( "Amount:" ), container ); + layout->addWidget( label, 5, 0 ); + amtEdit = new QLineEdit( container ); + layout->addMultiCellWidget( amtEdit, 5, 5, 1, 3 ); + + // Fee + label = new QLabel( tr( "Fee:" ), container ); + layout->addWidget( label, 6, 0 ); + feeEdit = new QLineEdit( container ); + layout->addMultiCellWidget( feeEdit, 6, 6, 1, 3 ); + + // Notes + label = new QLabel( tr( "Notes:" ), container ); + layout->addWidget( label, 7, 0 ); + noteEdit = new QMultiLineEdit( container ); + 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" ) ); + catList->insertItem( tr( "Computer" ) ); + catList->insertItem( tr( "DVDs" ) ); + catList->insertItem( tr( "Eletronics" ) ); + catList->insertItem( tr( "Entertainment" ) ); + catList->insertItem( tr( "Food" ) ); + catList->insertItem( tr( "Gasoline" ) ); + catList->insertItem( tr( "Misc" ) ); + catList->insertItem( tr( "Movies" ) ); + catList->insertItem( tr( "Rent" ) ); + catList->insertItem( tr( "Travel" ) ); + catList->setCurrentItem( 0 ); + typeList->clear(); + typeList->insertItem( tr( "Debit Charge" ) ); + typeList->insertItem( tr( "Written Check" ) ); + typeList->insertItem( tr( "Transfer" ) ); + typeList->insertItem( tr( "Credit Card" ) ); +} + +void Transaction::slotDepositClicked() +{ + catList->clear(); + catList->insertItem( tr( "Work" ) ); + catList->insertItem( tr( "Family Member" ) ); + catList->insertItem( tr( "Misc. Credit" ) ); + catList->setCurrentItem( 0 ); + typeList->clear(); + typeList->insertItem( tr( "Written Check" ) ); + typeList->insertItem( tr( "Automatic Payment" ) ); + typeList->insertItem( tr( "Transfer" ) ); + typeList->insertItem( tr( "Cash" ) ); +} + +void Transaction::slotDateChanged( int y, int m, int d ) +{ + QDate date; + date.setYMD( y, m, d ); + dateBtn->setText( TimeString::shortDate( date ) ); +} diff --git a/noncore/apps/checkbook/transaction.h b/noncore/apps/checkbook/transaction.h new file mode 100644 index 0000000..274e1f2 --- a/dev/null +++ b/noncore/apps/checkbook/transaction.h @@ -0,0 +1,79 @@ +/* + This file is part of the OPIE Project + =. + .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.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 = '$' ); + ~Transaction(); + + private: + TranInfo *tran; + + char 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 |