author | mickeyl <mickeyl> | 2003-10-27 19:51:32 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-10-27 19:51:32 (UTC) |
commit | 951d1d4125a80dc814f95d2956853bf53ca52e9a (patch) (side-by-side diff) | |
tree | 46c7a70b80a7eebb54cd59c46204c28335f3821c | |
parent | f0a15a9866f9eddfe10596e63a1e6300b92b9e3f (diff) | |
download | opie-951d1d4125a80dc814f95d2956853bf53ca52e9a.zip opie-951d1d4125a80dc814f95d2956853bf53ca52e9a.tar.gz opie-951d1d4125a80dc814f95d2956853bf53ca52e9a.tar.bz2 |
merge noncore/apps/* except
- advancedfm (ljp, please...)
- odict (tille, please...)
55 files changed, 1510 insertions, 428 deletions
diff --git a/noncore/apps/checkbook/cbinfo.cpp b/noncore/apps/checkbook/cbinfo.cpp index 9fdc6b2..36dde04 100644 --- a/noncore/apps/checkbook/cbinfo.cpp +++ b/noncore/apps/checkbook/cbinfo.cpp @@ -32,8 +32,9 @@ #include <qpe/config.h> #include <qfile.h> +// --- CBInfo ----------------------------------------------------------------- CBInfo::CBInfo() { n = ""; fn = ""; @@ -43,12 +44,17 @@ CBInfo::CBInfo() a = ""; p = ""; nt = ""; sb = 0.0; + _sLastTab=""; + _first=-1; + _last=-1; tl = new TranInfoList(); } + +// --- CBInfo ----------------------------------------------------------------- CBInfo::CBInfo( const QString &name, const QString &filename ) { Config config( filename, Config::File ); config.setGroup( "Account" ); @@ -61,108 +67,133 @@ CBInfo::CBInfo( const QString &name, const QString &filename ) bn = config.readEntry( "Bank", "" ); a = config.readEntryCrypt( "Number", "" ); p = config.readEntryCrypt( "PINNumber", "" ); nt = config.readEntry( "Notes", "" ); + _sLastTab = config.readEntry("LastTab", ""); + _first=config.readNumEntry("First", -1); + _sSortOrder = config.readEntry( "SortOrder", QWidget::tr("Date") ); bool ok; sb = config.readEntry( "Balance", "0.0" ).toFloat( &ok ); loadTransactions(); } +// --- balance ---------------------------------------------------------------- float CBInfo::balance() { calcBalance(); return b; } +// --- write ------------------------------------------------------------------ void CBInfo::write() { QFile f( fn ); if ( f.exists() ) - { f.remove(); - } Config *config = new Config(fn, Config::File); + + // fix transaction numbers + _first=-1; + TranInfo *prev=NULL; + for ( TranInfo *tran = tl->first(); tran; tran = tl->next() ) { + if( _first<0 ) _first=tran->id(); + if( prev ) prev->setNext( tran->id() ); + tran->setNext(-1); + prev=tran; + } + + // Save transactions + for ( TranInfo *tran = tl->first(); tran; tran = tl->next() ) { + tran->write(config); + } + // Save info + if( _first<0 && _last>=0 ) _first=_last; config->setGroup( "Account" ); config->writeEntryCrypt( "Password", pw ); config->writeEntry( "Type", t ); config->writeEntry( "Bank", bn ); config->writeEntryCrypt( "Number", a ); config->writeEntryCrypt( "PINNumber", p ); config->writeEntry( "Notes", nt ); + config->writeEntry( "LastTab", _sLastTab ); QString balstr; balstr.setNum( sb, 'f', 2 ); config->writeEntry( "Balance", balstr ); + config->writeEntry( "First", _first ); + config->writeEntry( "SortOrder", _sSortOrder ); - // Save transactions - int i = 1; - for ( TranInfo *tran = tl->first(); tran; tran = tl->next() ) - { - tran->write( config, i ); - i++; - } config->write(); - delete config; } -TranInfo *CBInfo::findTransaction( const QString &checknum, const QString &date, - const QString &desc ) -{ - TranInfo *traninfo = tl->first(); - while ( traninfo ) + +// --- findTransaction -------------------------------------------------------- +TranInfo *CBInfo::findTransaction( const QString &sId ) { - if ( traninfo->number() == checknum && traninfo->datestr() == date && - traninfo->desc() == desc ) + bool bOk; + int id=sId.toInt( &bOk ); + if( !bOk ) + return(false); + TranInfo *traninfo; + for(traninfo=tl->first(); traninfo; traninfo=tl->next()) { + if( traninfo->id() == id ) break; - traninfo = tl->next(); } return( traninfo ); } void CBInfo::addTransaction( TranInfo *tran ) { - tl->inSort( tran ); + tl->append( tran ); calcBalance(); } void CBInfo::removeTransaction( TranInfo *tran ) { - tl->remove( tran ); + tl->removeRef( tran ); delete tran; calcBalance(); } + +// --- loadTransactions ------------------------------------------------------- +// Reads the transactions. Either the old way 1-n or as linked list. void CBInfo::loadTransactions() { TranInfo *tran; QString trandesc = ""; tl = new TranInfoList(); Config config( fn, Config::File ); - - for ( int i = 1; trandesc != QString::null; i++ ) - { + int i=_first; + bool bOld=false; + if( i==-1 ) { + i=1; + bOld=true; + } + while( i>=0 ) { + _last=i; tran = new TranInfo( config, i ); trandesc = tran->desc(); - if ( trandesc != QString::null ) - { - tl->inSort( tran ); - } - else - { + if( trandesc==QString::null ) { delete tran; + break; } + tl->append(tran); + i= bOld ? i+1 : tran->getNext(); } calcBalance(); } + +// --- calcBalance ------------------------------------------------------------ void CBInfo::calcBalance() { float amount; @@ -179,8 +210,9 @@ void CBInfo::calcBalance() b += amount; } } + int CBInfoList::compareItems( QCollection::Item item1, QCollection::Item item2 ) { QString n1 = ((CBInfo *)item1)->name(); QString n2 = ((CBInfo *)item2)->name(); diff --git a/noncore/apps/checkbook/cbinfo.h b/noncore/apps/checkbook/cbinfo.h index 5e65db2..0b5b818 100644 --- a/noncore/apps/checkbook/cbinfo.h +++ b/noncore/apps/checkbook/cbinfo.h @@ -28,8 +28,9 @@ #ifndef CBINFO_H #define CBINFO_H +#include <qwidget.h> #include <qlist.h> #include <qstring.h> class Config; @@ -62,15 +63,28 @@ class CBInfo void setPin( const QString &pin ) { p = pin; } void setNotes( const QString ¬es ) { nt = notes; } void setStartingBalance( float startbal ) { sb = startbal; } + // write void write(); + // transactions TranInfoList *transactions() const { return tl; } - TranInfo *findTransaction( const QString &, const QString &, const QString & ); + TranInfo *findTransaction( const QString & ); void addTransaction( TranInfo * ); void removeTransaction( TranInfo * ); + // lastTab + void setLastTab(const QString &sLastTab) { _sLastTab=sLastTab; } + QString &getLastTab() { return(_sLastTab); } + + // getNextNumber + int getNextNumber() { return( ++_last ); } + + // sortOrder + void setSortOrder(const QString &sSortOrder) { _sSortOrder=sSortOrder; } + QString &getSortOrder() { return(_sSortOrder); } + private: QString n; QString fn; QString pw; @@ -80,8 +94,12 @@ class CBInfo QString p; QString nt; float sb; float b; + QString _sLastTab; + int _first; + int _last; + QString _sSortOrder; TranInfoList *tl; void loadTransactions(); diff --git a/noncore/apps/checkbook/cfg.cpp b/noncore/apps/checkbook/cfg.cpp new file mode 100644 index 0000000..1e0ec5c --- a/dev/null +++ b/noncore/apps/checkbook/cfg.cpp @@ -0,0 +1,213 @@ +/* + This file is part of the OPIE Project + =. + .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ + +#include <stdio.h> + +#include <qstring.h> +#include <qstringlist.h> +#include <qwidget.h> +#include <qpe/resource.h> +#include <qpe/config.h> + +#include "cfg.h" + +// --- Cfg -------------------------------------------------------------------- +Cfg::Cfg() +{ + _currencySymbol="$"; + _showLocks=FALSE; + _showBalances=FALSE; + _pCategories=new CategoryList(); +} + +// --- readStringList --------------------------------------------------------- +// Reads the entries for the control from a configuration file and returns +// them in a StringList. Later this list can be used to create the control. It +// is assumed, that the group is already set. Key is used to enumerate the +// entries. +void Cfg::readStringList(Config &cfg, const char *sKey, QStringList &lst) +{ +qDebug( "%s", sKey ); + + QString sEntry; + int iCount; + + // read count of elements + sEntry.sprintf("%s_Count", sKey); + iCount=cfg.readNumEntry(sEntry, 0); + + // read entries + for(int i=1; i<=iCount; i++) { + sEntry.sprintf("%s%d", sKey, i); + QString sType=cfg.readEntry(sEntry); + if( sType!=NULL ) + lst.append(sType); + } +} + + +// --- readConfig ------------------------------------------------------------- +// Reads the member data from the given config file. It will also set the group +// "Config" +void Cfg::readConfig(Config &config) +{ + // set group + config.setGroup( "Config" ); + + // read scalars + _currencySymbol = config.readEntry( "CurrencySymbol", "$" ); + _showLocks = config.readBoolEntry( "ShowLocks", FALSE ); + _showBalances = config.readBoolEntry( "ShowBalances", FALSE ); + _openLastBook = config.readBoolEntry( "OpenLastBook", FALSE ); + _sLastBook = config.readEntry("LastBook", ""); + _showLastTab = config.readBoolEntry( "ShowLastTab", FALSE ); + + // Account types + readStringList(config, "AccType", _AccountTypes); + if( _AccountTypes.isEmpty() ) { + _AccountTypes+= (const char *)QWidget::tr("Savings"); + _AccountTypes+= (const char *)QWidget::tr("Checking"); + _AccountTypes+= (const char *)QWidget::tr("CD"); + _AccountTypes+= (const char *)QWidget::tr("Money market"); + _AccountTypes+= (const char *)QWidget::tr("Mutual fund"); + _AccountTypes+= (const char *)QWidget::tr("Other"); + writeStringList(config, "AccType", _AccountTypes); + config.write(); + } + + // Read Categories + QStringList lst; + readStringList(config, "Category", lst); + if( lst.isEmpty() ) { + QString type=QWidget::tr("Expense"); + lst += QWidget::tr( "Automobile" )+";"+type; + lst += QWidget::tr( "Bills" )+";"+type; + lst += QWidget::tr( "CDs" )+";"+type; + lst += QWidget::tr( "Clothing" )+";"+type; + lst += QWidget::tr( "Computer" )+";"+type; + lst += QWidget::tr( "DVDs" )+";"+type; + lst += QWidget::tr( "Electronics" )+";"+type; + lst += QWidget::tr( "Entertainment" )+";"+type; + lst += QWidget::tr( "Food" )+";"+type; + lst += QWidget::tr( "Gasoline" )+";"+type; + lst += QWidget::tr( "Misc" )+";"+type; + lst += QWidget::tr( "Movies" )+";"+type; + lst += QWidget::tr( "Rent" )+";"+type; + lst += QWidget::tr( "Travel" )+";"+type; + + type=QWidget::tr( "Income" ); + lst += QWidget::tr( "Work" )+";"+type; + lst += QWidget::tr( "Family Member" )+";"+type; + lst += QWidget::tr( "Misc. Credit" )+";"+type; + + setCategories(lst); + writeStringList(config, "Category", lst); + config.write(); + } else { + setCategories(lst); + } +} + + +// --- writeStringList -------------------------------------------------------- +// Writes the entries in the control in a configuration file. It is assumed, +// that the group is already set. Key is used to enumerate the entries +void Cfg::writeStringList(Config &cfg, const char *sKey, QStringList &lst) +{ + QString sEntry; + int iCount=0; + QStringList::Iterator itr; + for(itr=lst.begin(); itr!=lst.end(); itr++) { + sEntry.sprintf("%s%d", sKey, ++iCount); + cfg.writeEntry(sEntry, *itr ); + } + sEntry.sprintf("%s_Count", sKey); + cfg.writeEntry(sEntry, iCount); +} + + +// --- writeConfig ----------------------------------------------------------- +// Writes all config data back to the config file. The group will be set to +// "Config" and the write be commited +void Cfg::writeConfig(Config &config) +{ + // set the group + config.setGroup( "Config" ); + + // write scalars + config.writeEntry( "CurrencySymbol", _currencySymbol ); + config.writeEntry( "ShowLocks", _showLocks ); + config.writeEntry( "ShowBalances", _showBalances ); + config.writeEntry( "OpenLastBook", _openLastBook ); + config.writeEntry( "LastBook", _sLastBook ); + config.writeEntry( "ShowLastTab", _showLastTab ); + + // write account types + writeStringList(config, "AccType", _AccountTypes); + + // write categories + QStringList lst=getCategories(); + writeStringList(config, "Category", lst ); + + // commit write + config.write(); +} + + +// --- getCategories ---------------------------------------------------------- +QStringList Cfg::getCategories() +{ + QStringList ret; + for(Category *itr=_pCategories->first(); itr; itr=_pCategories->next() ) { + QString sEntry; + sEntry.sprintf("%s;%s", (const char *)itr->getName(), (const char *)(itr->isIncome() ? QWidget::tr("Income") : QWidget::tr("Expense")) ); + ret.append(sEntry); + } + return(ret); +} + + +// --- setCategories ---------------------------------------------------------- +void Cfg::setCategories(QStringList &lst) +{ + _pCategories->clear(); + QStringList::Iterator itr; + for(itr=lst.begin(); itr!=lst.end(); itr++) { + QStringList split=QStringList::split(";", *itr, true); + if( split.count()<2 ) continue; + bool bIncome= (split[1]==QWidget::tr("Income")); + _pCategories->append( new Category(split[0], bIncome) ); + } +} + + +// --- CategoryList ------------------------------------------------------------ +CategoryList::CategoryList() : QList<Category>() +{ + setAutoDelete(true); +} diff --git a/noncore/apps/checkbook/cfg.h b/noncore/apps/checkbook/cfg.h new file mode 100644 index 0000000..2b69368 --- a/dev/null +++ b/noncore/apps/checkbook/cfg.h @@ -0,0 +1,120 @@ +/* + This file is part of the OPIE Project + =. + .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ + +#ifndef CFG_H +#define CFG_H + +#include <qstring.h> +#include <qlist.h> +#include <qstringlist.h> +class Config; + +// --- Category --------------------------------------------------------------- +class Category +{ + public: + // --- Constructor: + Category(QString &sName, bool bIncome=false) { _sName=sName; _bIncome=bIncome; } + + // members + QString &getName() { return(_sName); } + bool isIncome() { return(_bIncome); } + void setName(QString &sName) { _sName=sName; } + void setIncome(bool bIncome) { _bIncome=bIncome; } + + private: + QString _sName; + bool _bIncome; +}; + +class CategoryList : public QList<Category> +{ + public: + // --- Constructor + CategoryList(); +}; + + +// --- Cfg -------------------------------------------------------------------- +class Cfg +{ + public: + // --- Constructor + Cfg(); + + // --- members + bool getShowLocks() { return(_showLocks); } + void setShowLocks(bool n) { _showLocks=n; } + bool getShowBalances() { return(_showBalances); } + void setShowBalances(bool n) { _showBalances=n; } + QString &getCurrencySymbol() { return(_currencySymbol); } + void setCurrencySymbol(QString n) {_currencySymbol= n; } + void setCurrencySymbol(const char *n) { _currencySymbol=n; } + QStringList &getAccountTypes() { return(_AccountTypes); } + + // --- Categories + QStringList getCategories(); + void setCategories(QStringList &lst); + CategoryList *getCategoryList() { return(_pCategories); } + + // --- last book + void setOpenLastBook(bool openLastBook) { _openLastBook=openLastBook; } + bool isOpenLastBook() { return(_openLastBook); } + void setLastBook(const QString &lastBook) { _sLastBook=lastBook; } + QString &getLastBook() { return(_sLastBook); } + + // --- last tab + void setShowLastTab(bool showLastTab) { _showLastTab=showLastTab; } + bool isShowLastTab() { return(_showLastTab); } + + // --- reads data from config file + void readConfig(Config &cfg); + + // --- writes data to config file + void writeConfig(Config &cfg); + + // --- reads list from config file + static void readStringList(Config &cfg, const char *sKey, QStringList &lst); + + // --- writes list in configuration file + static void writeStringList(Config &cfg, const char *sKey, QStringList &lst); + + + + private: + QString _currencySymbol; + bool _showLocks; + bool _showBalances; + bool _openLastBook; + bool _showLastTab; + QString _sLastBook; + QStringList _AccountTypes; + CategoryList *_pCategories; +}; + +#endif diff --git a/noncore/apps/checkbook/checkbook.cpp b/noncore/apps/checkbook/checkbook.cpp index 653ee4a..c53e889 100644 --- a/noncore/apps/checkbook/checkbook.cpp +++ b/noncore/apps/checkbook/checkbook.cpp @@ -32,8 +32,10 @@ #include "traninfo.h" #include "graph.h" #include "graphinfo.h" #include "password.h" +#include "mainwindow.h" +#include "cfg.h" #include <opie/otabwidget.h> #include <qpe/qpeapplication.h> #include <qpe/qpemessagebox.h> @@ -47,14 +49,23 @@ #include <qmultilineedit.h> #include <qpushbutton.h> #include <qwhatsthis.h> -Checkbook::Checkbook( QWidget *parent, CBInfo *i, const QString &symbol ) +#define COL_ID 0 +#define COL_NUM 1 +#define COL_DATE 2 +#define COL_DESC 3 +#define COL_AMOUNT 4 +#define COL_BAL 5 + +// --- Checkbook -------------------------------------------------------------- +Checkbook::Checkbook( QWidget *parent, CBInfo *i, Cfg *cfg ) : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) { info = i; - currencySymbol = symbol; + _pCfg=cfg; + // Title bar if ( info->name() != "" ) { QString tempstr = info->name(); tempstr.append( " - " ); @@ -65,21 +76,25 @@ Checkbook::Checkbook( QWidget *parent, CBInfo *i, const QString &symbol ) { setCaption( tr( "New checkbook" ) ); } + // Setup layout to make everything pretty QVBoxLayout *layout = new QVBoxLayout( this ); layout->setMargin( 2 ); layout->setSpacing( 4 ); // Setup tabs for all info mainWidget = new OTabWidget( this ); layout->addWidget( mainWidget ); - mainWidget->addTab( initInfo(), "checkbook/infotab", tr( "Info" ) ); mainWidget->addTab( initTransactions(), "checkbook/trantab", tr( "Transactions" ) ); mainWidget->addTab( initCharts(), "checkbook/charttab", tr( "Charts" ) ); + if( _pCfg->isShowLastTab() ) + mainWidget->setCurrentTab( info->getLastTab() ); + else mainWidget->setCurrentTab( tr( "Info" ) ); + connect( mainWidget, SIGNAL( currentChanged(QWidget *) ), this, SLOT( slotTab(QWidget *) ) ); // Load checkbook information loadCheckbook(); } @@ -87,11 +102,12 @@ Checkbook::Checkbook( QWidget *parent, CBInfo *i, const QString &symbol ) Checkbook::~Checkbook() { } +// --- initInfo --------------------------------------------------------------- QWidget *Checkbook::initInfo() { - QWidget *control = new QWidget( mainWidget ); + QWidget *control = new QWidget( mainWidget, tr("Info") ); QVBoxLayout *vb = new QVBoxLayout( control ); QScrollView *sv = new QScrollView( control ); @@ -127,14 +143,9 @@ QWidget *Checkbook::initInfo() QWhatsThis::add( label, tr( "Select type of checkbook here." ) ); layout->addWidget( label, 2, 0 ); typeList = new QComboBox( container ); QWhatsThis::add( typeList, tr( "Select type of checkbook here." ) ); - typeList->insertItem( tr( "Savings" ) ); // 0 - typeList->insertItem( tr( "Checking" ) ); // 1 - typeList->insertItem( tr( "CD" ) ); // 2 - typeList->insertItem( tr( "Money market" ) ); // 3 - typeList->insertItem( tr( "Mutual fund" ) ); // 4 - typeList->insertItem( tr( "Other" ) ); // 5 + typeList->insertStringList( _pCfg->getAccountTypes() ); layout->addWidget( typeList, 2, 1 ); // Bank/institution name label = new QLabel( tr( "Bank:" ), container ); @@ -182,36 +193,55 @@ QWidget *Checkbook::initInfo() return control; } + +// --- initTransactions ------------------------------------------------------- QWidget *Checkbook::initTransactions() { - QWidget *control = new QWidget( mainWidget ); + QWidget *control = new QWidget( mainWidget, tr("Transactions") ); QGridLayout *layout = new QGridLayout( control ); layout->setSpacing( 2 ); layout->setMargin( 4 ); - balanceLabel = new QLabel( tr( "Current balance: %10.00" ).arg( currencySymbol ), - control ); - QWhatsThis::add( balanceLabel, tr( "This area shows the current balance in this checkbook." ) ); - layout->addMultiCellWidget( balanceLabel, 0, 0, 0, 2 ); - + // Sort selector + QLabel *label = new QLabel( tr( "Sort by:" ), control ); + QWhatsThis::add( label, tr( "Select checkbook sorting here." ) ); + layout->addMultiCellWidget( label, 0, 0, 0, 1 ); + _cbSortType=new QComboBox( control ); + _cbSortType->insertItem( tr("Entry Order") ); + _cbSortType->insertItem( tr("Date") ); + _cbSortType->insertItem( tr("Number") ); + layout->addMultiCellWidget( _cbSortType, 0, 0, 1, 2 ); + connect( _cbSortType, SIGNAL( activated(const QString &) ), this, SLOT( slotSortChanged( const QString & ) ) ); + + // Table tranTable = new QListView( control ); + QFont fnt(QPEApplication::font()); + fnt.setPointSize( fnt.pointSize()-1 ); + tranTable->setFont( fnt ); QWhatsThis::add( tranTable, tr( "This is a listing of all transactions entered for this checkbook.\n\nTo sort entries by a specific field, click on the column name." ) ); + tranTable->addColumn( tr( "Id" ) ); + tranTable->setColumnWidthMode( COL_ID, QListView::Manual ); + tranTable->setColumnWidth( COL_ID, 0); tranTable->addColumn( tr( "Num" ) ); tranTable->addColumn( tr( "Date" ) ); //tranTable->addColumn( tr( "Cleared" ) ); tranTable->addColumn( tr( "Description" ) ); - int colnum = tranTable->addColumn( tr( "Amount" ) ); - tranTable->setColumnAlignment( colnum, Qt::AlignRight ); + int column = tranTable->addColumn( tr( "Amount" ) ); + tranTable->setColumnAlignment( column, Qt::AlignRight ); + column=tranTable->addColumn( tr("Balance") ); + tranTable->setColumnAlignment( column, Qt::AlignRight ); tranTable->setAllColumnsShowFocus( TRUE ); - tranTable->setSorting( 1 ); + tranTable->setSorting( -1 ); layout->addMultiCellWidget( tranTable, 1, 1, 0, 2 ); QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold ); connect( tranTable, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), this, SLOT( slotEditTran() ) ); + _sortCol=COL_ID; + // Buttons QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), control ); QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) ); connect( btn, SIGNAL( clicked() ), this, SLOT( slotNewTran() ) ); layout->addWidget( btn, 2, 0 ); @@ -228,13 +258,15 @@ QWidget *Checkbook::initTransactions() return( control ); } + +// --- initCharts ------------------------------------------------------------- QWidget *Checkbook::initCharts() { graphInfo = 0x0; - QWidget *control = new QWidget( mainWidget ); + QWidget *control = new QWidget( mainWidget, tr("Charts") ); QGridLayout *layout = new QGridLayout( control ); layout->setSpacing( 2 ); layout->setMargin( 4 ); @@ -258,8 +290,9 @@ QWidget *Checkbook::initCharts() return control; } +// --- loadCheckbook ---------------------------------------------------------- void Checkbook::loadCheckbook() { if ( !info ) { @@ -280,8 +313,12 @@ void Checkbook::loadCheckbook() { break; } } + if( i<=0 ) { + typeList->insertItem( temptext, 0 ); + typeList->setCurrentItem(0); + } bankEdit->setText( info->bank() ); acctNumEdit->setText( info->account() ); pinNumEdit->setText( info->pin() ); temptext.setNum( info->startingBalance(), 'f', 2 ); @@ -290,43 +327,62 @@ void Checkbook::loadCheckbook() // Load transactions float amount; QString stramount; - for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() ) { amount = tran->amount(); if ( tran->withdrawal() ) { amount *= -1; } - stramount.sprintf( "%s%.2f", currencySymbol.latin1(), amount ); - ( void ) new CBListItem( tranTable, tran->number(), tran->datestr(), tran->desc(), stramount ); + stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); + ( void ) new CBListItem( tran, tranTable, tran->getIdStr(), tran->number(), tran->datestr(), tran->desc(), stramount ); } - balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( info->balance(), 0, 'f', 2 ) ); + // set sort order + bool bOk=false; + for(int i=0; i<_cbSortType->count(); i++) { + if( _cbSortType->text(i)==info->getSortOrder() ) { + _cbSortType->setCurrentItem(i); + slotSortChanged( info->getSortOrder() ); + bOk=true; + break; + } + } + if( !bOk ) { + _cbSortType->setCurrentItem(0); + slotSortChanged( _cbSortType->currentText() ); + } - highTranNum = tranList->count(); + // calc running balance + adjustBalance(); } +// --- adjustBalance ---------------------------------------------------------- void Checkbook::adjustBalance() { - balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( info->balance(), 0, 'f', 2 ) ); + // update running balance in register + QString sRunning; + float bal=info->startingBalance(); + for(CBListItem *item=(CBListItem *)tranTable->firstChild(); item; item=(CBListItem *)item->nextSibling() ) { + TranInfo *tran=item->getTranInfo(); + bal=bal + (tran->withdrawal() ? -1 : 1)*tran->amount() - tran->fee(); + sRunning.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), bal ); + item->setText( COL_BAL, sRunning); + } } -TranInfo *Checkbook::findTran( const QString &checknum, const QString &date, const QString &desc ) -{ - TranInfo *traninfo = tranList->first(); - while ( traninfo ) +// --- resort ----------------------------------------------------------------- +void Checkbook::resort() { - if ( traninfo->number() == checknum && traninfo->datestr() == date && - traninfo->desc() == desc ) - break; - traninfo = tranList->next(); - } - return( traninfo ); + tranTable->setSorting(_sortCol); + tranTable->sort(); + tranTable->setSorting(-1); } + +// --- accept ----------------------------------------------------------------- void Checkbook::accept() { info->setName( nameEdit->text() ); info->setType( typeList->currentText() ); @@ -397,23 +453,27 @@ void Checkbook::slotNameChanged( const QString &newname ) namestr.append( tr( "Checkbook" ) ); setCaption( namestr ); } + +// ---slotStartingBalanceChanged ---------------------------------------------- void Checkbook::slotStartingBalanceChanged( const QString &newbalance ) { bool ok; info->setStartingBalance( newbalance.toFloat( &ok ) ); adjustBalance(); } + void Checkbook::slotNewTran() { - highTranNum++; - TranInfo *traninfo = new TranInfo( highTranNum ); + TranInfo *traninfo = new TranInfo( info->getNextNumber() ); + if( !_dLastNew.isNull() ) + traninfo->setDate(_dLastNew); Transaction *currtran = new Transaction( this, info->name(), traninfo, - currencySymbol ); + _pCfg ); currtran->showMaximized(); if ( currtran->exec() == QDialog::Accepted ) { // Add to transaction list @@ -421,58 +481,52 @@ void Checkbook::slotNewTran() // Add to transaction table float amount; QString stramount; - - amount = traninfo->amount(); - if ( traninfo->withdrawal() ) - { - amount *= -1; - } - stramount.sprintf( "%s%.2f", currencySymbol.latin1(), amount ); - - ( void ) new CBListItem( tranTable, traninfo->number(), traninfo->datestr(), traninfo->desc(), + amount = (traninfo->withdrawal() ? -1 : 1)*traninfo->amount(); + stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); + ( void ) new CBListItem( traninfo, tranTable, traninfo->getIdStr(), + traninfo->number(), traninfo->datestr(), traninfo->desc(), stramount ); - + resort(); adjustBalance(); + + // save last date + _dLastNew = traninfo->date(); } else { - highTranNum--; delete traninfo; } } void Checkbook::slotEditTran() { QListViewItem *curritem = tranTable->currentItem(); if ( !curritem ) - { return; - } - TranInfo *traninfo = info->findTransaction( curritem->text( 0 ), curritem->text( 1 ), - curritem->text( 2 ) ); + TranInfo *traninfo=info->findTransaction( curritem->text(COL_ID) ); Transaction *currtran = new Transaction( this, info->name(), traninfo, - currencySymbol ); + _pCfg ); currtran->showMaximized(); if ( currtran->exec() == QDialog::Accepted ) { - curritem->setText( 0, traninfo->number() ); - curritem->setText( 1, traninfo->datestr() ); - curritem->setText( 2, traninfo->desc() ); + curritem->setText( COL_NUM, traninfo->number() ); + curritem->setText( COL_DATE, traninfo->datestr() ); + curritem->setText( COL_DESC, traninfo->desc() ); float amount = traninfo->amount(); if ( traninfo->withdrawal() ) { amount *= -1; } QString stramount; - stramount.sprintf( "%s%.2f", currencySymbol.latin1(), amount ); - curritem->setText( 3, stramount ); - + stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); + curritem->setText( COL_AMOUNT, stramount ); + resort(); adjustBalance(); } delete currtran; @@ -481,13 +535,11 @@ void Checkbook::slotEditTran() void Checkbook::slotDeleteTran() { QListViewItem *curritem = tranTable->currentItem(); if ( !curritem ) - { return; - } - TranInfo *traninfo = findTran( curritem->text( 0 ), curritem->text( 1 ), curritem->text( 2 ) ); + TranInfo *traninfo = info->findTransaction( curritem->text(COL_ID) ); if ( QPEMessageBox::confirmDelete ( this, tr( "Delete transaction" ), traninfo->desc() ) ) { info->removeTransaction( traninfo ); @@ -588,13 +640,14 @@ void Checkbook::drawCategoryChart( bool withdrawals ) graphInfo = new GraphInfo( GraphInfo::PieChart, list ); } -CBListItem::CBListItem( QListView *parent, QString label1, QString label2, +CBListItem::CBListItem( TranInfo *pTran, QListView *parent, QString label1, QString label2, QString label3, QString label4, QString label5, QString label6, QString label7, QString label8 ) : QListViewItem( parent, label1, label2, label3, label4, label5, label6, label7, label8 ) { + _pTran=pTran; m_known = FALSE; owner = parent; } @@ -651,4 +704,27 @@ bool CBListItem::isAltBackground() return m_odd; } return false; } + + +// --- slotTab ---------------------------------------------------------------- +void Checkbook::slotTab(QWidget *tab) +{ + if( !tab || !info ) return; + info->setLastTab( tab->name() ); +} + + +// --- slotSortChanged --------------------------------------------------------- +void Checkbook::slotSortChanged( const QString &selc ) +{ + if( selc==tr("Entry Order") ) { + _sortCol=COL_ID; + } else if( selc==tr("Number") ) { + _sortCol=COL_NUM; + } else if( selc==tr("Date") ) { + _sortCol=COL_DATE; + } + info->setSortOrder( selc ); + resort(); +} diff --git a/noncore/apps/checkbook/checkbook.h b/noncore/apps/checkbook/checkbook.h index 4a5011b..1b6a2d3 100644 --- a/noncore/apps/checkbook/checkbook.h +++ b/noncore/apps/checkbook/checkbook.h @@ -28,8 +28,9 @@ #ifndef CHECKBOOK_H #define CHECKBOOK_H +#include <qdatetime.h> #include <qdialog.h> #include <qlistview.h> class OTabWidget; @@ -45,27 +46,31 @@ class QListView; class QMultiLineEdit; class QString; class TranInfo; class TranInfoList; +class Cfg; + +// --- Checkbook -------------------------------------------------------------- class Checkbook : public QDialog { Q_OBJECT public: - Checkbook( QWidget * = 0x0, CBInfo * = 0x0, const QString & = "$" ); + Checkbook( QWidget *, CBInfo *, Cfg *cfg ); ~Checkbook(); + // resort + void resort(); + private: CBInfo *info; TranInfoList *tranList; - QString currencySymbol; - int highTranNum; + Cfg *_pCfg; OTabWidget *mainWidget; void loadCheckbook(); void adjustBalance(); - TranInfo *findTran( const QString &, const QString &, const QString & ); // Info tab QWidget *initInfo(); QCheckBox *passwordCB; @@ -75,13 +80,15 @@ class Checkbook : public QDialog QLineEdit *acctNumEdit; QLineEdit *pinNumEdit; QLineEdit *balanceEdit; QMultiLineEdit *notesEdit; + int _sortCol; // Transactions tab QWidget *initTransactions(); QListView *tranTable; - QLabel *balanceLabel; + QComboBox *_cbSortType; + QDate _dLastNew; // Charts tab QWidget *initCharts(); GraphInfo *graphInfo; @@ -90,10 +97,12 @@ class Checkbook : public QDialog void drawBalanceChart(); void drawCategoryChart( bool = TRUE ); + protected slots: void accept(); + void slotTab(QWidget *tab); private slots: void slotPasswordClicked(); void slotNameChanged( const QString & ); @@ -101,26 +110,33 @@ class Checkbook : public QDialog void slotNewTran(); void slotEditTran(); void slotDeleteTran(); void slotDrawGraph(); + void slotSortChanged( const QString & ); }; +// --- CBListItem ------------------------------------------------------------- class CBListItem : public QListViewItem { //Q_OBJECT public: - CBListItem( QListView *, QString = QString::null, QString = QString::null, + CBListItem( TranInfo *, QListView *, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null ); void paintCell( QPainter *, const QColorGroup &, int, int, int ); + // --- members + TranInfo *getTranInfo() { return(_pTran); } + private: + TranInfo *_pTran; QListView *owner; bool m_known; bool m_odd; bool isAltBackground(); }; + #endif diff --git a/noncore/apps/checkbook/checkbook.pro b/noncore/apps/checkbook/checkbook.pro index 9a16a56..c574aff 100644 --- a/noncore/apps/checkbook/checkbook.pro +++ b/noncore/apps/checkbook/checkbook.pro @@ -1,14 +1,16 @@ -TEMPLATE = app -CONFIG = qt warn_on release +CONFIG = qt warn_on release quick-app HEADERS = mainwindow.h \ cbinfo.h \ traninfo.h \ graphinfo.h \ configuration.h \ password.h \ checkbook.h \ transaction.h \ + tabledef.h \ + listedit.h \ + cfg.h \ graph.h SOURCES = main.cpp \ mainwindow.cpp \ cbinfo.cpp \ @@ -17,14 +19,16 @@ SOURCES = main.cpp \ configuration.cpp \ password.cpp \ checkbook.cpp \ transaction.cpp \ + tabledef.cpp \ + listedit.cpp \ + cfg.cpp \ graph.cpp INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lopie TARGET = checkbook -DESTDIR = $(OPIEDIR)/bin TRANSLATIONS = ../../../i18n/de/checkbook.ts \ ../../../i18n/nl/checkbook.ts \ ../../../i18n/da/checkbook.ts \ diff --git a/noncore/apps/checkbook/configuration.cpp b/noncore/apps/checkbook/configuration.cpp index 7731cf3..3f5662d 100644 --- a/noncore/apps/checkbook/configuration.cpp +++ b/noncore/apps/checkbook/configuration.cpp @@ -26,49 +26,136 @@ */ #include "configuration.h" +#include "mainwindow.h" +#include "listedit.h" +#include "tabledef.h" #include <qcheckbox.h> #include <qlabel.h> #include <qlayout.h> #include <qlineedit.h> #include <qwhatsthis.h> +#include <qlistview.h> +#include <qpushbutton.h> +#include <qtabwidget.h> +#include <qpe/resource.h> -Configuration::Configuration( QWidget *parent, const QString &cs, bool sl, bool sb ) +Configuration::Configuration( QWidget *parent, Cfg &cfg ) : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) { setCaption( tr( "Configure 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 QTabWidget( this ); + layout->addWidget( _mainWidget ); + + // Settings tab + _mainWidget->addTab( initSettings(cfg), tr( "&Settings" ) ); + + // Account Types tab + ColumnDef *d; + _listEditTypes=new ListEdit(_mainWidget, "TYPES" ); + d=new ColumnDef( tr("Type"), (ColumnDef::ColumnType)(ColumnDef::typeString | ColumnDef::typeUnique), tr("New Account Type")); + _listEditTypes->addColumnDef( d ); + _listEditTypes->addData( cfg.getAccountTypes() ); + _mainWidget->addTab( _listEditTypes, tr( "&Account Types" ) ); + + // Categories tab + _listEditCategories=new ListEdit(_mainWidget, "CATEGORIES" ); + _listEditCategories->addColumnDef( new ColumnDef( tr("Category"), (ColumnDef::ColumnType)(ColumnDef::typeString | ColumnDef::typeUnique), tr("New Category")) ); + d=new ColumnDef( tr("Type"), ColumnDef::typeList, tr("Expense") ); + d->addColumnValue( tr("Expense") ); + d->addColumnValue( tr("Income") ); + _listEditCategories->addColumnDef( d ); + QStringList lst=cfg.getCategories(); + _listEditCategories->addData( lst ); + _mainWidget->addTab( _listEditCategories, tr( "&Categories" ) ); +} + +Configuration::~Configuration() +{ +} + +// ---- initSettings ---------------------------------------------------------- +QWidget *Configuration::initSettings(Cfg &cfg) +{ + QWidget *control = new QWidget( _mainWidget ); + QFontMetrics fm = fontMetrics(); int fh = fm.height(); - QGridLayout *layout = new QGridLayout( this ); + 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( 4 ); layout->setMargin( 4 ); - QLabel *label = new QLabel( tr( "Enter currency symbol:" ), this ); + QLabel *label = new QLabel( tr( "Enter currency symbol:" ), container ); QWhatsThis::add( label, tr( "Enter your local currency symbol here." ) ); label->setMaximumHeight( fh + 3 ); layout->addWidget( label, 0, 0 ); - symbolEdit = new QLineEdit( cs, this ); + symbolEdit = new QLineEdit( cfg.getCurrencySymbol(), container ); QWhatsThis::add( symbolEdit, tr( "Enter your local currency symbol here." ) ); symbolEdit->setMaximumHeight( fh + 5 ); symbolEdit->setFocus(); layout->addWidget( symbolEdit, 0, 1 ); - lockCB = new QCheckBox( tr( "Show whether checkbook is password\nprotected" ), this ); + lockCB = new QCheckBox( tr( "Show whether checkbook is password\nprotected" ), container ); QWhatsThis::add( lockCB, tr( "Click here to select whether or not the main window will display that the checkbook is protected with a password." ) ); - lockCB->setChecked( sl ); + lockCB->setChecked( cfg.getShowLocks() ); layout->addMultiCellWidget( lockCB, 1, 1, 0, 1 ); - balCB = new QCheckBox( tr( "Show checkbook balances" ), this ); + balCB = new QCheckBox( tr( "Show checkbook balances" ), container ); QWhatsThis::add( balCB, tr( "Click here to select whether or not the main window will display the current balance for each checkbook." ) ); balCB->setMaximumHeight( fh + 5 ); - balCB->setChecked( sb ); + balCB->setChecked( cfg.getShowBalances() ); layout->addMultiCellWidget( balCB, 2, 2, 0, 1 ); + + openLastBookCB = new QCheckBox( tr("Open last checkbook" ), container ); + QWhatsThis::add( openLastBookCB, tr("Click here to select whether the last open checkbook will be opened at startup.") ); + openLastBookCB->setMaximumHeight(fh+5); + openLastBookCB->setChecked( cfg.isOpenLastBook() ); + layout->addMultiCellWidget( openLastBookCB, 3, 3, 0, 1 ); + + lastTabCB = new QCheckBox( tr("Show last checkbook tab" ), container ); + QWhatsThis::add( lastTabCB, tr("Click here to select whether the last tab in a checkbook should be displayed.") ); + lastTabCB->setMaximumHeight(fh+5); + lastTabCB->setChecked( cfg.isShowLastTab() ); + layout->addMultiCellWidget( lastTabCB, 4, 4, 0, 1 ); + + return(control); } -Configuration::~Configuration() +// --- saveConfig ------------------------------------------------------------- +void Configuration::saveConfig(Cfg &cfg) { + // Settings + cfg.setCurrencySymbol( symbolEdit->text() ); + cfg.setShowLocks( lockCB->isChecked() ); + cfg.setShowBalances( balCB->isChecked() ); + cfg.setOpenLastBook( openLastBookCB->isChecked() ); + cfg.setShowLastTab( lastTabCB->isChecked() ); + + // Typelist + _listEditTypes->storeInList( cfg.getAccountTypes() ); + + // Category list + QStringList lst; + _listEditCategories->storeInList( lst ); + cfg.setCategories( lst ); } diff --git a/noncore/apps/checkbook/configuration.h b/noncore/apps/checkbook/configuration.h index 9a8de02..5893502 100644 --- a/noncore/apps/checkbook/configuration.h +++ b/noncore/apps/checkbook/configuration.h @@ -29,23 +29,39 @@ #ifndef CONFIGURATION_H #define CONFIGURATION_H #include <qdialog.h> +#include "cfg.h" class QCheckBox; class QLineEdit; class QString; +class QTabWidget; +class ListEdit; class Configuration : public QDialog { Q_OBJECT public: - Configuration( QWidget * = 0x0, const QString & = "$", bool = FALSE, bool = FALSE ); + // Constructor + Configuration( QWidget *, Cfg &cfg); ~Configuration(); QLineEdit *symbolEdit; QCheckBox *lockCB; QCheckBox *balCB; + QCheckBox *openLastBookCB; + QCheckBox *lastTabCB; + QTabWidget *_mainWidget; + ListEdit *_listEditTypes; + ListEdit *_listEditCategories; + + // saves settings in config struct + void saveConfig(Cfg &cfg); + + protected: + // creates settings tap from configuration + QWidget *initSettings(Cfg &cfg); }; #endif diff --git a/noncore/apps/checkbook/listedit.cpp b/noncore/apps/checkbook/listedit.cpp new file mode 100644 index 0000000..99a6531 --- a/dev/null +++ b/noncore/apps/checkbook/listedit.cpp @@ -0,0 +1,340 @@ +/* + This file is part of the OPIE Project + =. + .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ + +#include "listedit.h" +#include <qlayout.h> +#include <qlineedit.h> +#include <qlistview.h> +#include <qwidgetstack.h> +#include <qcombobox.h> +#include <qpushbutton.h> +#include <qpe/resource.h> + + +// --- ListEdit --------------------------------------------------------------- +ListEdit::ListEdit( QWidget *parent, const char *sName ) + : QWidget(parent, sName), TableDef(sName) +{ + // get font height + int fh = fontMetrics().height(); + + // create layout + QGridLayout *layout=new QGridLayout(this); + layout->setSpacing( 2 ); + layout->setMargin( 4 ); + + // type table + _typeTable = new QListView( this ); + ColumnDef *def=first(); + while( def ) { + _typeTable->addColumn( def->getName() ); + def=next(); + } + connect( _typeTable, SIGNAL( clicked(QListViewItem *, const QPoint &, int) ), this, SLOT( slotClick(QListViewItem *, const QPoint &, int ) ) ); + layout->addMultiCellWidget(_typeTable, 0,4,0,4); + _currentItem=NULL; + + // edit field + _stack=new QWidgetStack( this ); + _stack->setMaximumHeight(fh+5); + layout->addMultiCellWidget(_stack, 5,5,0,2); + _typeEdit = new QLineEdit( _stack ); + _stack->raiseWidget(_typeEdit ); + connect( _typeEdit, SIGNAL( textChanged(const QString &) ), this, SLOT( slotEditChanged(const QString &) ) ); + + // combo box + _box=new QComboBox( _stack ); + connect( _box, SIGNAL( activated(const QString &) ), this, SLOT( slotActivated(const QString &) ) ); + + + // add button + QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/add" ), tr( "Add" ), this ); + connect( btn, SIGNAL( clicked() ), this, SLOT( slotAdd() ) ); + layout->addWidget( btn, 5, 3 ); + + // delete button + btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), this ); + connect( btn, SIGNAL( clicked() ), this, SLOT( slotDel() ) ); + layout->addWidget( btn, 5, 4 ); +} + +// --- ~ListEdit -------------------------------------------------------------- +ListEdit::~ListEdit() +{ +} + + +// --- slotEditTypeChanged ---------------------------------------------------- +void ListEdit::slotEditChanged(const QString &str) +{ + if( !_currentItem || _currentColumn<0 ) return; + _currentItem->setText(_currentColumn, str); +} + +// --- slotAddType ------------------------------------------------------------ +void ListEdit::slotAdd() +{ + // construct new row + QString args[8]; + ColumnDef *pCol=this->first(); + int i=0; + while( pCol && i<8 ) { + args[i++]=pCol->getNewValue(); + pCol=this->next(); + } + _currentItem=new QListViewItem(_typeTable, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7] ); + + // fix uniques + fixTypes(); + + // display col 0 of new value + QPoint pnt; + slotClick(_currentItem, pnt, 0); + _typeTable->setSelected( _currentItem, true ); +} + +// --- slotDel ------------------------------------------------------------- +void ListEdit::slotDel() +{ + if( !_currentItem ) return; + delete _currentItem; + _currentItem=NULL; + _typeEdit->setText(""); + _stack->raiseWidget(_typeEdit); +} + + +// --- fixTypes ---------------------------------------------------------------- +// Makes sure all entries have a unique name and empty entries are replaced +// by a generic string. The first version performs the operation on a particular +// column, whereas the 2nd does it for all unique columns. +class ColMap { + public: + ColMap(QString sValue, QListViewItem *pEntry) { + _sValue=sValue; + _pEntry=pEntry; + } + QString &getValue() { return(_sValue); } + QListViewItem *getItem() { return(_pEntry); } + + protected: + QString _sValue; + QListViewItem *_pEntry; +}; + +class ColList : public QList<QString> +{ + public: + ColList() : QList<QString>() { } + + protected: + int compareItems(QCollection::Item, QCollection::Item); +}; + +int ColList::compareItems(QCollection::Item i1, QCollection::Item i2) { + return( ((QString *)i1)->compare(*(QString *)i2) ); +} + +void ListEdit::fixTypes(int iColumn) +{ + // get column def + ColumnDef *pDef=this->at(iColumn); + + // create map of entries + if( !_typeTable->childCount() ) return; + ColMap **colMap=new (ColMap *)[_typeTable->childCount()]; + QListViewItem *cur=_typeTable->firstChild(); + ColList lst; + for(int i=0; i<_typeTable->childCount(); i++) { + colMap[i]=new ColMap(cur->text(iColumn), cur); + lst.append( &(colMap[i]->getValue()) ); + cur=cur->nextSibling(); + } + + // fix empty entries + int i=0; + for(QString *ptr=lst.first(); ptr; ptr=lst.next()) { + *ptr=ptr->stripWhiteSpace(); + if( ptr->isEmpty() ) { + i++; + if( i==1 ) *ptr=pDef->getNewValue(); + else ptr->sprintf("%s %d", (const char *)pDef->getNewValue(), i); + } + } + + // fix dups + lst.sort(); + QString repl; + for(uint iCur=0; iCur<lst.count()-1; iCur++) { + QString *current=lst.at(iCur); + for(uint iNext=iCur+1; iNext<lst.count(); iNext++ ) { + if( *current!=*lst.at(iNext) ) continue; + for(int i=2; ; i++) { + repl.sprintf("%s %d", (const char *)*current, i); + bool bDup=false; + uint iChk=iNext+1; + while( iChk<lst.count() ) { + QString *chk=lst.at(iChk); + if( !chk->startsWith(*current) ) break; + if( *chk==repl ) { + bDup=true; + break; + } + iChk++; + } + if( !bDup ) { + *lst.at(iNext)=repl; + break; + } + } + } + } + lst.sort(); + + // copy back clean up col map + for(int i=0; i<_typeTable->childCount(); i++) { + colMap[i]->getItem()->setText(iColumn, colMap[i]->getValue()); + delete colMap[i]; + } + delete colMap; +} + +void ListEdit::fixTypes() +{ + int i; + ColumnDef *pDef; + for(pDef=this->first(), i=0; pDef; pDef=this->next(), i++) { + if( pDef->hasFlag(ColumnDef::typeUnique) ) + fixTypes(i); + } + _typeTable->sort(); +} + + +// --- storeInList ------------------------------------------------------------ +void ListEdit::storeInList(QStringList &lst) +{ + // delete old content + lst.clear(); + + // add new one + fixTypes(); + QListViewItem *itm=_typeTable->firstChild(); + while( itm ) { + int i=0; + QString sAdd; + ColumnDef *pDef; + for(pDef=this->first(), i=0; pDef; pDef=this->next(), i++) { + if( i>=1 ) sAdd+=";"; + sAdd += itm->text(i); + } + lst.append( sAdd ); + itm=itm->nextSibling(); + } +} + + +// --- slotClicked ------------------------------------------------------------ +void ListEdit::slotClick(QListViewItem *itm, const QPoint &pnt, int col) +{ + (void)pnt; // get rid of unused warning; + + // save values + _currentItem=itm; + _currentColumn=col; + if( itm==NULL ) { + _typeEdit->setText(""); + _stack->raiseWidget(_typeEdit); + return; + } + + // display value + if( _currentColumn<0 ) _currentColumn=0; + ColumnDef *pDef=this->at(_currentColumn); + if( pDef->isType(ColumnDef::typeString) ) { + _typeEdit->setText( _currentItem->text(_currentColumn) ); + _stack->raiseWidget(_typeEdit); + } else if( pDef->isType(ColumnDef::typeList) ){ + _box->clear(); + _box->insertStringList( pDef->getValueList() ); + QStringList::Iterator itr; + int i=0; + for(itr=pDef->getValueList().begin(); itr!=pDef->getValueList().end(); itr++) { + if( (*itr)==_currentItem->text(_currentColumn) ) { + _box->setCurrentItem(i); + i=-1; + break; + } + i++; + } + if( i>=0 ) { + _box->insertItem( _currentItem->text(_currentColumn) ); + _box->setCurrentItem(i); + } + _stack->raiseWidget(_box); + } else { + qDebug( "Unsupported column type for column %s", (const char *)pDef->getName() ); + _typeEdit->setText(""); + _stack->raiseWidget(_typeEdit); + } +} + + +// --- addColumnDef ----------------------------------------------------------- +void ListEdit::addColumnDef(ColumnDef *pDef) +{ + _typeTable->addColumn( pDef->getName() ); + _vColumns.append(pDef); +} + +// --- addData ---------------------------------------------------------------- +void ListEdit::addData(QStringList &lst) +{ + // run through list + QStringList::Iterator itr; + for(itr=lst.begin(); itr!=lst.end(); itr++) { + QStringList split=QStringList::split(";", *itr, true); + QStringList::Iterator entry; + QString args[8]; + int i=0; + for(entry=split.begin(); entry!=split.end() && i<8; entry++, i++) { + args[i]= (*entry); + } + while(i<8) { + args[i++]=""; + } + new QListViewItem(_typeTable, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]); + } +} + +// --- slotActivated ---------------------------------------------------------- +void ListEdit::slotActivated(const QString &str) +{ + if( _currentItem==NULL || _currentColumn<0 ) return; + _currentItem->setText(_currentColumn, str); +} diff --git a/noncore/apps/checkbook/listedit.h b/noncore/apps/checkbook/listedit.h new file mode 100644 index 0000000..d2135ea --- a/dev/null +++ b/noncore/apps/checkbook/listedit.h @@ -0,0 +1,78 @@ +/* + This file is part of the OPIE Project + =. + .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ + +#ifndef LISTEDIT_H +#define LISTEDIT_H + +#include <qwidget.h> +#include "tabledef.h" +class QListView; +class QLineEdit; +class QListViewItem; +class QPoint; +class QWidgetStack; +class QComboBox; + +class ListEdit : public QWidget, public TableDef +{ + Q_OBJECT + + public: + ListEdit( QWidget *, const char *sName); + virtual ~ListEdit(); + + QListView *_typeTable; + QLineEdit *_typeEdit; + QWidgetStack *_stack; + QComboBox *_box; + QListViewItem *_currentItem; + int _currentColumn; + + // resolves dups and empty entries + void fixTypes(); + void fixTypes(int iColumn); + + // stores content in string list + void storeInList(QStringList &lst); + + // adds a column definition + virtual void addColumnDef(ColumnDef *pDef); + + // adds data to table + void addData(QStringList &lst); + + + public slots: + void slotClick(QListViewItem *, const QPoint &pnt, int col); + void slotEditChanged(const QString &); + void slotAdd(); + void slotDel(); + void slotActivated(const QString &); +}; + +#endif diff --git a/noncore/apps/checkbook/main.cpp b/noncore/apps/checkbook/main.cpp index abfa633..dcaab4a 100644 --- a/noncore/apps/checkbook/main.cpp +++ b/noncore/apps/checkbook/main.cpp @@ -25,18 +25,10 @@ Boston, MA 02111-1307, USA. */ -#include "mainwindow.h" - #include <qpe/qpeapplication.h> +#include <opie/oapplicationfactory.h> -int main(int argc, char **argv) -{ - QPEApplication app(argc, argv); - - MainWindow *cb = new MainWindow(); - app.setMainWidget(cb); - cb->showMaximized(); +#include "mainwindow.h" - return app.exec(); -} +OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) diff --git a/noncore/apps/checkbook/mainwindow.cpp b/noncore/apps/checkbook/mainwindow.cpp index 6d1d7b9..8d64cad 100644 --- a/noncore/apps/checkbook/mainwindow.cpp +++ b/noncore/apps/checkbook/mainwindow.cpp @@ -30,8 +30,9 @@ #include "cbinfo.h" #include "configuration.h" #include "password.h" #include "checkbook.h" +#include "listedit.h" #include <qpe/config.h> #include <qpe/global.h> #include <qpe/qpeapplication.h> @@ -45,22 +46,22 @@ #include <qdir.h> #include <qlineedit.h> #include <qwhatsthis.h> -MainWindow::MainWindow() - : QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) + +MainWindow::MainWindow( QWidget* parent, const char* name, WFlags fl ) + : QMainWindow( parent, name, fl || WStyle_ContextHelp ) { setCaption( tr( "Checkbook" ) ); cbDir = Global::applicationFileName( "checkbook", "" ); lockIcon = Resource::loadPixmap( "locked" ); // Load configuration options Config config( "checkbook" ); - config.setGroup( "Config" ); - currencySymbol = config.readEntry( "CurrencySymbol", "$" ); - showLocks = config.readBoolEntry( "ShowLocks", FALSE ); - showBalances = config.readBoolEntry( "ShowBalances", FALSE ); +qDebug( "Reading config" ); + _cfg.readConfig( config ); + // Build menu and tool bars setToolBarsMovable( FALSE ); @@ -124,26 +125,42 @@ MainWindow::MainWindow() // Build Checkbook selection list control cbList = 0x0; buildList(); + + // open last book? + if( _cfg.isOpenLastBook() ) { + this->show(); + this->showMaximized(); + QListViewItem *itm=cbList->firstChild(); + while( itm ) { + if( itm->text(posName)==_cfg.getLastBook() ) { + openBook( itm ); + break; } + itm=itm->nextSibling(); + } + } +} + +// --- ~MainWindow ------------------------------------------------------------ MainWindow::~MainWindow() { -// config.write(); + writeConfig(); } + +// --- buildList -------------------------------------------------------------- void MainWindow::buildList() { if ( cbList ) - { delete cbList; - } cbList = new QListView( this ); QWhatsThis::add( cbList, tr( "This is a listing of all checkbooks currently available." ) ); - if ( showLocks ) + if ( _cfg.getShowLocks() ) { cbList->addColumn( Resource::loadIconSet( "locked" ), "", 24 ); posName = 1; } @@ -151,9 +168,9 @@ void MainWindow::buildList() { posName = 0; } cbList->addColumn( tr( "Checkbook Name" ) ); - if ( showBalances ) + if ( _cfg.getShowBalances() ) { int colnum = cbList->addColumn( tr( "Balance" ) ); cbList->setColumnAlignment( colnum, Qt::AlignRight ); } @@ -172,17 +189,17 @@ void MainWindow::buildList() void MainWindow::addCheckbook( CBInfo *cb ) { QListViewItem *lvi = new QListViewItem( cbList ); - if ( showLocks && !cb->password().isNull() ) + if ( _cfg.getShowLocks() && !cb->password().isNull() ) { lvi->setPixmap( 0, lockIcon ); } lvi->setText( posName, cb->name() ); - if ( showBalances ) + if ( _cfg.getShowBalances() ) { QString balance; - balance.sprintf( "%s%.2f", currencySymbol.latin1(), cb->balance() ); + balance.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() ); lvi->setText( posName + 1, balance ); } } @@ -196,14 +213,15 @@ void MainWindow::buildFilename( const QString &name ) void MainWindow::slotNew() { CBInfo *cb = new CBInfo(); - Checkbook *currcb = new Checkbook( this, cb, currencySymbol ); + Checkbook *currcb = new Checkbook( this, cb, &_cfg ); currcb->showMaximized(); if ( currcb->exec() == QDialog::Accepted ) { // Save new checkbook buildFilename( cb->name() ); + _cfg.setLastBook( cb->name() ); cb->setFilename( tempFilename ); cb->write(); // Add to listbox @@ -212,30 +230,33 @@ void MainWindow::slotNew() } delete currcb; } +// --- slotEdit --------------------------------------------------------------- void MainWindow::slotEdit() { - + // get name and open it QListViewItem *curritem = cbList->currentItem(); if ( !curritem ) - { return; + openBook( curritem ); } - QString currname = curritem->text( posName ); - CBInfo *cb = checkbooks->first(); - while ( cb ) + +// --- openBook --------------------------------------------------------------- +void MainWindow::openBook(QListViewItem *curritem) { + // find book in List + QString currname=curritem->text(posName); + CBInfo *cb = checkbooks->first(); + while ( cb ) { if ( cb->name() == currname ) break; cb = checkbooks->next(); } - if ( !cb ) - { - return; - } + if ( !cb ) return; + // buildFilename( currname ); float currbalance = cb->balance(); bool currlock = !cb->password().isNull(); @@ -249,25 +270,27 @@ void MainWindow::slotEdit() } delete pw; } - Checkbook *currcb = new Checkbook( this, cb, currencySymbol ); + _cfg.setLastBook( currname ); + Checkbook *currcb = new Checkbook( this, cb, &_cfg ); currcb->showMaximized(); if ( currcb->exec() == QDialog::Accepted ) { QString newname = cb->name(); if ( currname != newname ) { // Update name if changed + if( curritem ) { curritem->setText( posName, newname ); cbList->sort(); + } + _cfg.setLastBook( newname ); // Remove old file QFile f( tempFilename ); if ( f.exists() ) - { f.remove(); - } // Get new filename buildFilename( newname ); cb->setFilename( tempFilename ); @@ -275,27 +298,28 @@ void MainWindow::slotEdit() cb->write(); // Update lock if changed - if ( showLocks && !cb->password().isNull() != currlock ) + if ( _cfg.getShowLocks() && !cb->password().isNull() != currlock ) { if ( !cb->password().isNull() ) curritem->setPixmap( 0, lockIcon ); else curritem->setPixmap( 0, nullIcon ); } // Update balance if changed - if ( showBalances && cb->balance() != currbalance ) + if ( _cfg.getShowBalances() && cb->balance() != currbalance ) { QString tempstr; - tempstr.sprintf( "%s%.2f", currencySymbol.latin1(), cb->balance() ); + tempstr.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() ); curritem->setText( posName + 1, tempstr ); } } delete currcb; } +// --- slotDelete ------------------------------------------------------------- void MainWindow::slotDelete() { QString currname = cbList->currentItem()->text( posName ); @@ -311,25 +335,26 @@ void MainWindow::slotDelete() delete cbList->currentItem(); } } +// --- slotConfigure ---------------------------------------------------------- void MainWindow::slotConfigure() { - Configuration *cfgdlg = new Configuration( this, currencySymbol, showLocks, showBalances ); + Configuration *cfgdlg = new Configuration( this, _cfg ); cfgdlg->showMaximized(); if ( cfgdlg->exec() == QDialog::Accepted ) { - currencySymbol = cfgdlg->symbolEdit->text(); - showLocks = cfgdlg->lockCB->isChecked(); - showBalances = cfgdlg->balCB->isChecked(); - - Config config( "checkbook" ); - config.setGroup( "Config" ); - config.writeEntry( "CurrencySymbol", currencySymbol ); - config.writeEntry( "ShowLocks", showLocks ); - config.writeEntry( "ShowBalances", showBalances ); - config.write(); - + // read data from config dialog & save it + cfgdlg->saveConfig( _cfg ); + writeConfig(); buildList(); } delete cfgdlg; } + + +// --- writeConfig -------------------------------------------------------------- +void MainWindow::writeConfig() +{ + Config config("checkbook"); + _cfg.writeConfig( config ); +} diff --git a/noncore/apps/checkbook/mainwindow.h b/noncore/apps/checkbook/mainwindow.h index 2bc70b3..6275f94 100644 --- a/noncore/apps/checkbook/mainwindow.h +++ b/noncore/apps/checkbook/mainwindow.h @@ -30,32 +30,39 @@ #define MAINWINDOW_H #include <qmainwindow.h> #include <qpixmap.h> +#include "cfg.h" class CBInfo; class CBInfoList; class QAction; class QListView; class QString; +class QListViewItem; class MainWindow : public QMainWindow { Q_OBJECT public: - MainWindow(); + MainWindow(QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~MainWindow(); + static QString appName() { return QString::fromLatin1("checkbook"); }; + + // safe config + void writeConfig(); + + // open a check book + void openBook(QListViewItem *curr); private: QListView *cbList; QString cbDir; QAction *actionOpen; QAction *actionDelete; - QString currencySymbol; - bool showLocks; - bool showBalances; + Cfg _cfg; int posName; CBInfoList *checkbooks; QString tempFilename; diff --git a/noncore/apps/checkbook/tabledef.cpp b/noncore/apps/checkbook/tabledef.cpp new file mode 100644 index 0000000..13edded --- a/dev/null +++ b/noncore/apps/checkbook/tabledef.cpp @@ -0,0 +1,76 @@ +/* + This file is part of the OPIE Project + =. + .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ + +#include "tabledef.h" + +#include <qstring.h> +#include <qpe/resource.h> + +// --- ColumnDef -------------------------------------------------------------- +ColumnDef::ColumnDef(const char *sName, ColumnType type, const char *sNewValue) +{ + _sName=sName; + _type=type; + _sNewValue=sNewValue; +} + + +// --- addColumnValue --------------------------------------------------------- +void ColumnDef::addColumnValue(const QString &sValue) +{ + if( (_type & 0x00ffffff) !=typeList ) + qDebug("Column %s is not a list", (const char *)_sName); + else + _valueList.append(sValue); +} +void ColumnDef::addColumnValue(const char *sValue) +{ + if( (_type & 0x00ffffff)!=typeList ) + qDebug("Column %s is not a list", (const char *)_sName); + else + _valueList.append(sValue); +} + +// --- TableDef --------------------------------------------------------------- +TableDef::TableDef(const char *sName) +{ + _sName=sName; + _vColumns.setAutoDelete(TRUE); +} + + +// --- ~TableDef -------------------------------------------------------------- +TableDef::~TableDef() +{ +} + +// --- addColumnDef ----------------------------------------------------------- +void TableDef::addColumnDef(ColumnDef *pDef) +{ + _vColumns.append(pDef); +} diff --git a/noncore/apps/checkbook/tabledef.h b/noncore/apps/checkbook/tabledef.h new file mode 100644 index 0000000..5891ad7 --- a/dev/null +++ b/noncore/apps/checkbook/tabledef.h @@ -0,0 +1,99 @@ +/* + This file is part of the OPIE Project + =. + .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ + +#ifndef TABLEDEF_H +#define TABLEDEF_H + +#include <qstring.h> +#include <qstringlist.h> +#include <qlist.h> + + + +// --- ColumnDef ------------------------------------------------------------- +class ColumnDef +{ + public: + enum ColumnType { + typeString=0x1, + typeList=0x2, + typeUnique=0x80000000 + }; + + // Constructor + ColumnDef(const char *sName, ColumnType type, const char *sNewValue); + + // add column value + void addColumnValue(const QString &Value); + void addColumnValue(const char *sValue); + + // member functions + const QString getName() { return(_sName); } + const QString getNewValue() { return(_sNewValue); } + + // test for type + int isType(ColumnType x) { return( (_type & 0x00ffffff)==x ); } + int hasFlag(ColumnType x) { return( (_type & x) ); } + + // get value list + QStringList &getValueList() { return(_valueList); } + + private: + QString _sName; + QString _sNewValue; + enum ColumnType _type; + QStringList _valueList; +}; + +typedef QList<ColumnDef> ColumnDefList; + + +// --- TableDef --------------------------------------------------------------- +class TableDef +{ + public: + // Constructor & Destructor + TableDef(const char *sName); + virtual ~TableDef(); + + // adds a column definition + virtual void addColumnDef(ColumnDef *pDef); + + // movement operators + ColumnDef *first() { return(_vColumns.first() ); } + ColumnDef *last() { return(_vColumns.last() ); } + ColumnDef *next() { return(_vColumns.next() ); } + ColumnDef *prev() { return(_vColumns.prev() ); } + ColumnDef *at(int i) { return(_vColumns.at(i)); } + + protected: + QString _sName; + ColumnDefList _vColumns; +}; + +#endif diff --git a/noncore/apps/checkbook/traninfo.cpp b/noncore/apps/checkbook/traninfo.cpp index 65c190c..d880bb4 100644 --- a/noncore/apps/checkbook/traninfo.cpp +++ b/noncore/apps/checkbook/traninfo.cpp @@ -33,9 +33,9 @@ QString tempstr; 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 ) + float fee, const QString &number, const QString ¬es, int next ) { i = id; d = desc; td = date; @@ -45,8 +45,9 @@ TranInfo::TranInfo( int id, const QString &desc, const QDate &date, bool withdra a = amount; f = fee; cn = number; n = notes; + _next=next; } TranInfo::TranInfo( Config config, int entry ) { @@ -115,29 +116,34 @@ TranInfo::TranInfo( Config config, int entry ) cn = config.readEntry( "CheckNumber", "" ); // Notes n = config.readEntry( "Comments", "" ); + + // next + _next = config.readNumEntry("Next", -1); } } +// --- datestr ---------------------------------------------------------------- const QString &TranInfo::datestr() { - tempstr = QString::number( td.year() ); - tempstr.append( '/' ); - int tempfield = td.month(); - if ( tempfield < 10 ) tempstr.append( '0' ); - tempstr.append( QString::number( tempfield ) ); - tempstr.append( '/' ); - tempfield = td.day(); - if ( tempfield < 10 ) tempstr.append( '0' ); - tempstr.append( QString::number( tempfield ) ); + int y=td.year(); + y= y>=2000 && y<=2099 ? y-2000 : y; + tempstr.sprintf( "%02d/%02d/%02d", y ,td.month(), td.day() ); + return( tempstr ); +} +// --- getIdStr --------------------------------------------------------------- +const QString &TranInfo::getIdStr() +{ + tempstr.sprintf("%04d", i); return( tempstr ); } -void TranInfo::write( Config *config, int entry ) +// --- write ------------------------------------------------------------------ +void TranInfo::write( Config *config ) { - config->setGroup( QString::number( entry ) ); + config->setGroup( QString::number( id() ) ); config->writeEntry( "Description", d ); tempstr = QString::number( td.month() ); @@ -169,12 +175,13 @@ void TranInfo::write( Config *config, int entry ) tempstr.setNum( f, 'f', 2 ); config->writeEntry( "TransactionFee", tempstr ); config->writeEntry( "CheckNumber", cn ); - config->writeEntry( "Comments", n ); + config->writeEntry( "Next", _next ); } + int TranInfoList::compareItems( QCollection::Item item1, QCollection::Item item2 ) { QDate d1 = ((TranInfo *)item1)->date(); QDate d2 = ((TranInfo *)item2)->date(); @@ -187,4 +194,19 @@ int TranInfoList::compareItems( QCollection::Item item1, QCollection::Item item2 else if ( d1 > d2 ) r = 1; return( r ); } + +// --- toString --------------------------------------------------------------- +QString TranInfo::toString() +{ + QString ret; + ret.sprintf("(%4d) %10s %4s %-10s %5.2f %5.2f", + id(), + (const char *)datestr(), + (const char *)number(), + (const char *)desc(), + (withdrawal() ? -1 : 1) * amount(), + fee() + ); + return(ret); +} diff --git a/noncore/apps/checkbook/traninfo.h b/noncore/apps/checkbook/traninfo.h index f6c5cae..0abdc61 100644 --- a/noncore/apps/checkbook/traninfo.h +++ b/noncore/apps/checkbook/traninfo.h @@ -39,12 +39,15 @@ 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 ); + const QString & = 0x0, const QString & = 0x0, int =-1 ); TranInfo( Config, int ); + // getters int id() const { return i; } + const QString &getIdStr(); + const QString &desc() const { return d; } const QDate &date() const { return td; } const QString &datestr(); bool withdrawal() const { return w; } @@ -53,9 +56,11 @@ class TranInfo float amount() const { return a; } float fee() const { return f; } const QString &number() const { return cn; } const QString ¬es() const { return n; } + int getNext() { return(_next); } + // setters 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; } @@ -63,10 +68,15 @@ class TranInfo 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 setNext(int next) { _next=next; } + + // write + void write( Config * ); - void write( Config *, int ); + // toString + QString toString(); private: int i; QString d; @@ -77,8 +87,9 @@ class TranInfo float a; float f; QString cn; QString n; + int _next; }; class TranInfoList : public QList<TranInfo> { diff --git a/noncore/apps/checkbook/transaction.cpp b/noncore/apps/checkbook/transaction.cpp index c94b989..138d0e6 100644 --- a/noncore/apps/checkbook/transaction.cpp +++ b/noncore/apps/checkbook/transaction.cpp @@ -27,8 +27,9 @@ */ #include "transaction.h" #include "traninfo.h" +#include "cfg.h" #include <qpe/datebookmonth.h> #include <qbuttongroup.h> @@ -40,17 +41,17 @@ #include <qradiobutton.h> #include <qwhatsthis.h> Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *info, - const QString &symbol ) + Cfg *pCfg ) : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) { QString tempstr = tr( "Transaction for " ); tempstr.append( acctname ); setCaption( tempstr ); tran = info; - currencySymbol = symbol; + _pCfg=pCfg; QVBoxLayout *vb = new QVBoxLayout( this ); QScrollView *sv = new QScrollView( this ); @@ -229,23 +230,15 @@ void Transaction::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( "Electronics" ) ); - 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" ) ); + CategoryList *pCatList=_pCfg->getCategoryList(); + for(Category *pCat=pCatList->first(); pCat; pCat=pCatList->next()) { + if( !pCat->isIncome() ) + catList->insertItem( pCat->getName() ); + } catList->setCurrentItem( 0 ); + typeList->clear(); typeList->insertItem( tr( "Debit Charge" ) ); typeList->insertItem( tr( "Written Check" ) ); typeList->insertItem( tr( "Transfer" ) ); @@ -254,12 +247,15 @@ void Transaction::slotWithdrawalClicked() void Transaction::slotDepositClicked() { catList->clear(); - catList->insertItem( tr( "Work" ) ); - catList->insertItem( tr( "Family Member" ) ); - catList->insertItem( tr( "Misc. Credit" ) ); + CategoryList *pCatList=_pCfg->getCategoryList(); + for(Category *pCat=pCatList->first(); pCat; pCat=pCatList->next()) { + if( pCat->isIncome() ) + catList->insertItem( pCat->getName() ); + } catList->setCurrentItem( 0 ); + typeList->clear(); typeList->insertItem( tr( "Written Check" ) ); typeList->insertItem( tr( "Automatic Payment" ) ); typeList->insertItem( tr( "Transfer" ) ); diff --git a/noncore/apps/checkbook/transaction.h b/noncore/apps/checkbook/transaction.h index 000aee7..fbe9cd3 100644 --- a/noncore/apps/checkbook/transaction.h +++ b/noncore/apps/checkbook/transaction.h @@ -39,22 +39,22 @@ class QPushButton; class QRadioButton; class QString; class QWidget; class TranInfo; +class Cfg; class Transaction : public QDialog { Q_OBJECT public: - Transaction( QWidget * = 0x0, const QString & = 0x0, TranInfo * = 0x0, - const QString & = "$" ); + Transaction( QWidget *, const QString &, TranInfo *, Cfg *); ~Transaction(); private: TranInfo *tran; - QString currencySymbol; + Cfg *_pCfg; QRadioButton *withBtn; QRadioButton *depBtn; QPushButton *dateBtn; diff --git a/noncore/apps/odict/main.cpp b/noncore/apps/odict/main.cpp index c68253f..0642022 100644 --- a/noncore/apps/odict/main.cpp +++ b/noncore/apps/odict/main.cpp @@ -16,14 +16,9 @@ **************************************************************************/ #include <qpe/qpeapplication.h> +#include <opie/oapplicationfactory.h> #include "odict.h" -int main(int argc, char **argv) -{ - QPEApplication app(argc, argv); - ODict *odict= new ODict(); - app.setMainWidget(odict); - odict->showMaximized(); - return app.exec(); -} + +OPIE_EXPORT_APP( OApplicationFactory<ODict> ) diff --git a/noncore/apps/odict/odict.cpp b/noncore/apps/odict/odict.cpp index 010545e..9718c5c 100644 --- a/noncore/apps/odict/odict.cpp +++ b/noncore/apps/odict/odict.cpp @@ -35,9 +35,9 @@ #include <qpe/resource.h> #include <qpe/config.h> -ODict::ODict() : QMainWindow() +ODict::ODict(QWidget* parent, const char* name, WFlags fl ) : QMainWindow(parent, name, fl ) { activated_name = QString::null; vbox = new QVBox( this ); diff --git a/noncore/apps/odict/odict.h b/noncore/apps/odict/odict.h index be2a532..68a8f95 100644 --- a/noncore/apps/odict/odict.h +++ b/noncore/apps/odict/odict.h @@ -28,14 +28,14 @@ class ODict : public QMainWindow { Q_OBJECT public: - ODict(); + ODict(QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); QVBox *vbox; QTextBrowser *browser_top, *browser_bottom; DingWidget *ding; - + static QString appName() { return QString::fromLatin1("odict"); } private: QPopupMenu *help, *settings, *parameter; QMenuBar *menu; QHBox *hbox; diff --git a/noncore/apps/odict/odict.pro b/noncore/apps/odict/odict.pro index 82f6a41..4ad287b 100644 --- a/noncore/apps/odict/odict.pro +++ b/noncore/apps/odict/odict.pro @@ -1,7 +1,5 @@ -TEMPLATE = app -CONFIG = qt warn_on debug -#CONFIG = qt warn_on release +CONFIG = qt warn_on release quick-app HEADERS = odict.h \ searchmethoddlg.h \ configdlg.h \ dingwidget.h @@ -14,9 +12,8 @@ SOURCES = main.cpp \ INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lstdc++ -lopie TARGET = odict -DESTDIR = $(OPIEDIR)/bin TRANSLATIONS = ../../../i18n/de/odict.ts \ ../../../i18n/nl/odict.ts \ ../../../i18n/xx/odict.ts \ diff --git a/noncore/apps/opie-console/opie-console.control b/noncore/apps/opie-console/opie-console.control index 3934fa1..504de85 100644 --- a/noncore/apps/opie-console/opie-console.control +++ b/noncore/apps/opie-console/opie-console.control @@ -1,6 +1,6 @@ Package: opie-console -Files: plugins/application/libopie-console.so* bin/opie-console apps/Applications/opie-console.desktop pics/console/* +Files: bin/opie-console apps/Applications/opie-console.desktop pics/console/* Priority: optional Section: opie/applications Maintainer: Opie team <opie@handhelds.org> Architecture: arm diff --git a/noncore/apps/opie-reader/opie-reader.pro b/noncore/apps/opie-reader/opie-reader.pro index 62113c3..686f083 100644 --- a/noncore/apps/opie-reader/opie-reader.pro +++ b/noncore/apps/opie-reader/opie-reader.pro @@ -1,5 +1,4 @@ -TEMPLATE = app CONFIG = qt warn_on release HEADERS = Aportis.h \ Bkmks.h \ BuffDoc.h \ @@ -80,13 +79,13 @@ SOURCES = Aportis.cpp \ ppm_expander.cpp \ version.cpp \ ztxt.cpp -INTERFACES = DESTDIR = $(OPIEDIR)/bin +TARGET = reader + INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include -TARGET = reader LIBS += -lqpe include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/apps/opie-sheet/main.cpp b/noncore/apps/opie-sheet/main.cpp index e42b4a5..d0a2995 100644 --- a/noncore/apps/opie-sheet/main.cpp +++ b/noncore/apps/opie-sheet/main.cpp @@ -15,14 +15,8 @@ #include <qpe/qpeapplication.h> #include "mainwindow.h" -int main(int argc, char **argv) -{ - QPEApplication application(argc, argv); +#include <opie/oapplicationfactory.h> - MainWindow windowMain; - windowMain.setHelpFile(application.qpeDir()+"/help/html/"+QString(argv[0])+".html"); - application.showMainDocumentWidget(&windowMain); +OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) - return application.exec(); -} diff --git a/noncore/apps/opie-sheet/mainwindow.cpp b/noncore/apps/opie-sheet/mainwindow.cpp index 43e5131..3915e52 100644 --- a/noncore/apps/opie-sheet/mainwindow.cpp +++ b/noncore/apps/opie-sheet/mainwindow.cpp @@ -42,10 +42,10 @@ #define DEFAULT_NUM_ROWS 199 #define DEFAULT_NUM_COLS (26*3) #define DEFAULT_NUM_SHEETS 3 -MainWindow::MainWindow() - :QMainWindow() +MainWindow::MainWindow(QWidget *parent, const char* n, WFlags fl) + :QMainWindow(parent, n, fl) { // initialize variables documentModified=FALSE; diff --git a/noncore/apps/opie-sheet/mainwindow.h b/noncore/apps/opie-sheet/mainwindow.h index 10d6650..370d82e 100644 --- a/noncore/apps/opie-sheet/mainwindow.h +++ b/noncore/apps/opie-sheet/mainwindow.h @@ -119,9 +119,10 @@ class MainWindow: public QMainWindow void selectorFileNew(const DocLnk &lnkDoc); void selectorFileOpen(const DocLnk &lnkDoc); public: - MainWindow(); + static QString appName() { return QString::fromLatin1("sheetqt"); } + MainWindow(QWidget *p, const char*, WFlags); ~MainWindow(); void setHelpFile(const QString &help_filename) { helpFile=help_filename; } diff --git a/noncore/apps/opie-sheet/opie-sheet.pro b/noncore/apps/opie-sheet/opie-sheet.pro index 1435af6..acd5fa0 100644 --- a/noncore/apps/opie-sheet/opie-sheet.pro +++ b/noncore/apps/opie-sheet/opie-sheet.pro @@ -1,7 +1,5 @@ -TEMPLATE = app -CONFIG = qt warn_on release -DESTDIR = $(OPIEDIR)/bin +CONFIG = qt warn_on release quick-app HEADERS = mainwindow.h sheet.h cellformat.h finddlg.h numberdlg.h sortdlg.h textdlg.h SOURCES = main.cpp mainwindow.cpp sheet.cpp cellformat.cpp finddlg.cpp numberdlg.cpp sortdlg.cpp textdlg.cpp INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include diff --git a/noncore/apps/opie-write/main.cpp b/noncore/apps/opie-write/main.cpp index 027af38..2cdfa55 100644 --- a/noncore/apps/opie-write/main.cpp +++ b/noncore/apps/opie-write/main.cpp @@ -19,19 +19,10 @@ ** **********************************************************************/ #include <qpe/qpeapplication.h> -#include <qpe/fileselector.h> +#include <opie/oapplicationfactory.h> #include "mainwindow.h" -int main( int argc, char ** argv ) -{ - QPEApplication a( argc, argv ); +OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) - MainWindow e; - a.showMainDocumentWidget(&e); - QObject::connect( &a, SIGNAL( lastWindowClosed() ), - &a, SLOT( quit() ) ); - - a.exec(); -} diff --git a/noncore/apps/opie-write/mainwindow.cpp b/noncore/apps/opie-write/mainwindow.cpp index 4a49abf..6bb524f 100644 --- a/noncore/apps/opie-write/mainwindow.cpp +++ b/noncore/apps/opie-write/mainwindow.cpp @@ -99,10 +99,10 @@ private: }; //=========================================================================== -MainWindow::MainWindow( QWidget *parent, const char *name ) - : QMainWindow( parent, name ), +MainWindow::MainWindow( QWidget *parent, const char *name, WFlags fl ) + : QMainWindow( parent, name, fl ), doc( 0 ) { setRightJustification(TRUE); diff --git a/noncore/apps/opie-write/mainwindow.h b/noncore/apps/opie-write/mainwindow.h index 565ad05..17713d8 100644 --- a/noncore/apps/opie-write/mainwindow.h +++ b/noncore/apps/opie-write/mainwindow.h @@ -44,11 +44,13 @@ class MainWindow : public QMainWindow { Q_OBJECT public: - MainWindow( QWidget *parent = 0, const char *name = 0 ); + MainWindow( QWidget *parent = 0, const char *name = 0 , WFlags fl = 0); ~MainWindow(); + static QString appName() { return QString::fromLatin1("opie-write"); } + protected: void closeEvent( QCloseEvent *e ); private slots: diff --git a/noncore/apps/opie-write/opie-write.pro b/noncore/apps/opie-write/opie-write.pro index 21a3c3a..bbaacd3 100644 --- a/noncore/apps/opie-write/opie-write.pro +++ b/noncore/apps/opie-write/opie-write.pro @@ -1,8 +1,7 @@ -TEMPLATE = app -CONFIG += qt warn_on release -DESTDIR = $(OPIEDIR)/bin +CONFIG += qt warn on release quick-app + HEADERS = qcleanuphandler.h \ qcomplextext_p.h \ qrichtext_p.h \ @@ -23,24 +22,6 @@ DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe TARGET = opie-write -TRANSLATIONS = ../../../i18n/de/opie-write.ts \ - ../../../i18n/nl/opie-write.ts \ - ../../../i18n/da/opie-write.ts \ - ../../../i18n/xx/opie-write.ts \ - ../../../i18n/en/opie-write.ts \ - ../../../i18n/es/opie-write.ts \ - ../../../i18n/fr/opie-write.ts \ - ../../../i18n/hu/opie-write.ts \ - ../../../i18n/ja/opie-write.ts \ - ../../../i18n/ko/opie-write.ts \ - ../../../i18n/no/opie-write.ts \ - ../../../i18n/pl/opie-write.ts \ - ../../../i18n/pt/opie-write.ts \ - ../../../i18n/pt_BR/opie-write.ts \ - ../../../i18n/sl/opie-write.ts \ - ../../../i18n/zh_CN/opie-write.ts \ - ../../../i18n/zh_TW/opie-write.ts - include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/apps/oxygen/main.cpp b/noncore/apps/oxygen/main.cpp index c8fcdb4..ac992aa 100644 --- a/noncore/apps/oxygen/main.cpp +++ b/noncore/apps/oxygen/main.cpp @@ -16,14 +16,9 @@ **************************************************************************/ #include <qpe/qpeapplication.h> +#include <opie/oapplicationfactory.h> #include "oxygen.h" -int main(int argc, char **argv) -{ - QPEApplication app(argc, argv); - Oxygen *oxi = new Oxygen(); - app.setMainWidget(oxi); - oxi->showMaximized(); - return app.exec(); -} + +OPIE_EXPORT_APP( OApplicationFactory<Oxygen> ) diff --git a/noncore/apps/oxygen/oxygen.cpp b/noncore/apps/oxygen/oxygen.cpp index 5999cb0..5bdc2aa 100644 --- a/noncore/apps/oxygen/oxygen.cpp +++ b/noncore/apps/oxygen/oxygen.cpp @@ -24,9 +24,9 @@ #include "datawidgetui.h" #include "psewidget.h" -Oxygen::Oxygen() : QMainWindow() +Oxygen::Oxygen( QWidget *parent, const char *name, WFlags f) : QMainWindow( parent, name, f ) { loadNames(); calcDlgUI *CalcDlgUI = new calcDlgUI(); PSEWidget *pse = new PSEWidget(names); diff --git a/noncore/apps/oxygen/oxygen.h b/noncore/apps/oxygen/oxygen.h index 57fe9fe..c59662d 100644 --- a/noncore/apps/oxygen/oxygen.h +++ b/noncore/apps/oxygen/oxygen.h @@ -15,9 +15,10 @@ class Oxygen : public QMainWindow { Q_OBJECT public: - Oxygen(); + Oxygen(QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); + static QString appName() { return QString::fromLatin1("oxygen"); } private: void loadNames(); QStringList names; diff --git a/noncore/apps/oxygen/oxygen.pro b/noncore/apps/oxygen/oxygen.pro index a41bf7b..71d4dac 100644 --- a/noncore/apps/oxygen/oxygen.pro +++ b/noncore/apps/oxygen/oxygen.pro @@ -1,6 +1,5 @@ -TEMPLATE = app -CONFIG = qt warn_on release +CONFIG = qt warn_on release quick-app HEADERS = oxygen.h \ kmolcalc.h \ kmolelements.h \ calcdlgui.h \ @@ -19,31 +18,10 @@ SOURCES = main.cpp \ oxyframe.cpp \ datawidgetui.cpp INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include -LIBS += -lqpe -lstdc++ +LIBS += -lqpe INTERFACES = calcdlg.ui -TARGET = oxygen -DESTDIR = $(OPIEDIR)/bin - -TRANSLATIONS = ../../../i18n/de/oxygen.ts \ - ../../../i18n/nl/oxygen.ts \ - ../../../i18n/xx/oxygen.ts \ - ../../../i18n/en/oxygen.ts \ - ../../../i18n/es/oxygen.ts \ - ../../../i18n/fr/oxygen.ts \ - ../../../i18n/hu/oxygen.ts \ - ../../../i18n/ja/oxygen.ts \ - ../../../i18n/ko/oxygen.ts \ - ../../../i18n/no/oxygen.ts \ - ../../../i18n/pl/oxygen.ts \ - ../../../i18n/pt/oxygen.ts \ - ../../../i18n/pt_BR/oxygen.ts \ - ../../../i18n/sl/oxygen.ts \ - ../../../i18n/zh_CN/oxygen.ts \ - ../../../i18n/zh_TW/oxygen.ts \ - ../../../i18n/it/oxygen.ts \ - ../../../i18n/da/oxygen.ts - +TARGET = oxygen include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/apps/tableviewer/main.cpp b/noncore/apps/tableviewer/main.cpp index d17ee65..ce39c84 100644 --- a/noncore/apps/tableviewer/main.cpp +++ b/noncore/apps/tableviewer/main.cpp @@ -18,15 +18,8 @@ ** **********************************************************************/ #include "tableviewer.h" #include <qpe/qpeapplication.h> +#include <opie/oapplicationfactory.h> -int main( int argc, char ** argv ) -{ - QPEApplication a( argc, argv ); +OPIE_EXPORT_APP( OApplicationFactory<TableViewerWindow> ) - TableViewerWindow mw; - mw.setCaption( TableViewerWindow::tr("Table Viewer") ); - a.showMainWidget(&mw); - - return a.exec(); -} diff --git a/noncore/apps/tableviewer/tableviewer.h b/noncore/apps/tableviewer/tableviewer.h index 817db21..f56a460 100644 --- a/noncore/apps/tableviewer/tableviewer.h +++ b/noncore/apps/tableviewer/tableviewer.h @@ -39,8 +39,9 @@ class DBStore; class TableViewerWindow: public QMainWindow { Q_OBJECT public: + static QString appName() { return QString::fromLatin1("tableviewer"); } TableViewerWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); ~TableViewerWindow(); diff --git a/noncore/apps/tableviewer/tableviewer.pro b/noncore/apps/tableviewer/tableviewer.pro index f047e0b..c6d9e68 100644 --- a/noncore/apps/tableviewer/tableviewer.pro +++ b/noncore/apps/tableviewer/tableviewer.pro @@ -1,7 +1,5 @@ -TEMPLATE = app -CONFIG = qt warn_on debug -DESTDIR = $(OPIEDIR)/bin +CONFIG = qt warn_on debug quick-app SUBDIRS = db ui HEADERS = tableviewer.h \ xmlencodeattr.h \ ui/commonwidgets.h \ diff --git a/noncore/apps/tinykate/main.cpp b/noncore/apps/tinykate/main.cpp index e06668a..e21c040 100644 --- a/noncore/apps/tinykate/main.cpp +++ b/noncore/apps/tinykate/main.cpp @@ -12,17 +12,11 @@ * the Free Software Foundation. * * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE * * * ***************************************************************************/ -#include <qpe/qpeapplication.h> #include <qmainwindow.h> #include "tinykate.h" +#include <opie/oapplicationfactory.h> -int main( int argc, char ** argv ) -{ - QPEApplication a( argc, argv ); +OPIE_EXPORT_APP( OApplicationFactory<TinyKate> ) - TinyKate m; - a.showMainWidget(&m ); - return a.exec(); -} diff --git a/noncore/apps/tinykate/opie-tinykate.control b/noncore/apps/tinykate/opie-tinykate.control index 1fde467..9bc0130 100644 --- a/noncore/apps/tinykate/opie-tinykate.control +++ b/noncore/apps/tinykate/opie-tinykate.control @@ -1,6 +1,6 @@ Package: opie-tinykate -Files: plugins/application/libtinykate.so* bin/tinykate apps/Applications/tinykate.desktop pics/tinykate $OPIEDIR/lib/libtinykate.so.1.0.0 $OPIEDIR/lib/libtinykate.so.1.0 $OPIEDIR/lib/libtinykate.so.1 +Files: plugins/application/libkate.so* bin/kate apps/Applications/tinykate.desktop pics/tinykate $OPIEDIR/lib/libtinykate.so.1.0.0 $OPIEDIR/lib/libtinykate.so.1.0 $OPIEDIR/lib/libtinykate.so.1 Priority: optional Section: opie/applications Maintainer: Opie Team <opie@handhelds.org> Architecture: arm diff --git a/noncore/apps/tinykate/tinykate.h b/noncore/apps/tinykate/tinykate.h index 2bf4de6..a5ee9b9 100644 --- a/noncore/apps/tinykate/tinykate.h +++ b/noncore/apps/tinykate/tinykate.h @@ -32,8 +32,10 @@ class TinyKate : public QMainWindow Q_OBJECT public: TinyKate( QWidget *parent=0, const char *name=0, WFlags f = 0); ~TinyKate( ); + static QString appName() { return QString::fromLatin1( "kate" ); }; + public slots: void slotNew(); void setDocument(const QString& fileref); diff --git a/noncore/apps/tinykate/tinykate.pro b/noncore/apps/tinykate/tinykate.pro index 632bd49..91d4230 100644 --- a/noncore/apps/tinykate/tinykate.pro +++ b/noncore/apps/tinykate/tinykate.pro @@ -1,6 +1,6 @@ TEMPLATE = app -CONFIG = qt warn_on release +CONFIG = qt warn_on release quick-app DESTDIR = $(OPIEDIR)/bin HEADERS = tinykate.h SOURCES = tinykate.cpp main.cpp INTERFACES = @@ -14,9 +14,9 @@ INCLUDEPATH += $(OPIEDIR)/include \ $(OPIEDIR)/noncore/apps/tinykate/libkate/qt3back DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -ltinykate -lopie -TARGET = tinykate +TARGET = kate include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/apps/zsafe/.cvsignore b/noncore/apps/zsafe/.cvsignore new file mode 100644 index 0000000..2f8556e --- a/dev/null +++ b/noncore/apps/zsafe/.cvsignore @@ -0,0 +1,3 @@ +Makefile +Makefile.in +moc* diff --git a/noncore/settings/aqpkg/.cvsignore b/noncore/settings/aqpkg/.cvsignore index 2888d4a..4183697 100644 --- a/noncore/settings/aqpkg/.cvsignore +++ b/noncore/settings/aqpkg/.cvsignore @@ -1,2 +1,3 @@ Makefile* moc* +.moc* diff --git a/noncore/settings/aqpkg/aqpkg.pro b/noncore/settings/aqpkg/aqpkg.pro index d241d1b..882cfd4 100644 --- a/noncore/settings/aqpkg/aqpkg.pro +++ b/noncore/settings/aqpkg/aqpkg.pro @@ -1,6 +1,5 @@ -TEMPLATE = app -CONFIG = qt warn_on release +CONFIG = qt warn_on release quick-app HEADERS = global.h \ mainwin.h \ datamgr.h \ settingsimpl.h \ @@ -31,32 +30,11 @@ SOURCES = mainwin.cpp \ letterpushbutton.cpp \ inputdlg.cpp \ version.cpp \ categoryfilterimpl.cpp -INTERFACES = TARGET = aqpkg INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lopie -lstdc++ -DESTDIR = $(OPIEDIR)/bin - -TRANSLATIONS = ../../../i18n/de/aqpkg.ts \ - ../../../i18n/nl/aqpkg.ts \ - ../../../i18n/xx/aqpkg.ts \ - ../../../i18n/en/aqpkg.ts \ - ../../../i18n/es/aqpkg.ts \ - ../../../i18n/fr/aqpkg.ts \ - ../../../i18n/hu/aqpkg.ts \ - ../../../i18n/ja/aqpkg.ts \ - ../../../i18n/ko/aqpkg.ts \ - ../../../i18n/no/aqpkg.ts \ - ../../../i18n/pl/aqpkg.ts \ - ../../../i18n/pt/aqpkg.ts \ - ../../../i18n/pt_BR/aqpkg.ts \ - ../../../i18n/sl/aqpkg.ts \ - ../../../i18n/zh_CN/aqpkg.ts \ - ../../../i18n/zh_TW/aqpkg.ts \ - ../../../i18n/it/aqpkg.ts \ - ../../../i18n/da/aqpkg.ts - include ( $(OPIEDIR)/include.pro ) + diff --git a/noncore/settings/aqpkg/main.cpp b/noncore/settings/aqpkg/main.cpp index b7f8b7b..179f8b7 100644 --- a/noncore/settings/aqpkg/main.cpp +++ b/noncore/settings/aqpkg/main.cpp @@ -26,53 +26,13 @@ Boston, MA 02111-1307, USA. */ -#ifdef QWS -#include <qpe/qpeapplication.h> -#include <qpe/qcopenvelope_qws.h> -#else -#include <qapplication.h> -#endif - -#include <qobjectdefs.h> - #include "mainwin.h" -#include "server.h" - -#include "global.h" +#include <opie/oapplicationfactory.h> /* be less intrusive for translation -zecke */ extern QString LOCAL_SERVER; extern QString LOCAL_IPKGS; -int main(int argc, char *argv[]) -{ -#ifdef QWS - QPEApplication a( argc, argv ); -#else - QApplication a( argc, argv ); -#endif - -#ifdef QWS - // Disable suspend mode - QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; -#endif - - LOCAL_SERVER = QObject::tr( "Installed packages" ); - LOCAL_IPKGS = QObject::tr( "Local packages" ); - - MainWindow *win = new MainWindow(); - a.setMainWidget(win); - win->showMaximized(); - - a.exec(); - -#ifdef QWS - // Reenable suspend mode - QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; -#endif - #ifdef _DEBUG - DumpUnfreed(); - #endif -} +OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp index 42093cf..dbe694e 100644 --- a/noncore/settings/aqpkg/mainwin.cpp +++ b/noncore/settings/aqpkg/mainwin.cpp @@ -65,11 +65,17 @@ #include "utils.h" extern int compareVersions( const char *v1, const char *v2 ); -MainWindow :: MainWindow() - : QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) +MainWindow :: MainWindow( QWidget* parent, const char* name, WFlags fl ) + : QMainWindow( parent, name, fl || WStyle_ContextHelp ) { + // Disable suspend mode + QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; + + LOCAL_SERVER = QObject::tr( "Installed packages" ); + LOCAL_IPKGS = QObject::tr( "Local packages" ); + setCaption( tr( "AQPkg - Package Manager" ) ); // Create UI widgets initMainWidget(); @@ -233,8 +239,11 @@ MainWindow :: MainWindow() MainWindow :: ~MainWindow() { delete mgr; + + // Reenable suspend mode + QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; } void MainWindow :: initMainWidget() { @@ -1011,9 +1020,8 @@ InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) else { InstallData *newitem = new InstallData(); newitem->option = "D"; - // If local file, remove using package name, not filename if ( p->isPackageStoredLocally() ) name = item->text(); @@ -1045,9 +1053,8 @@ InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) else if ( val == -1 ) { // Version available is older - remove only newitem->option = "D"; - // If local file, remove using package name, not filename if ( p->isPackageStoredLocally() ) name = item->text(); } diff --git a/noncore/settings/aqpkg/mainwin.h b/noncore/settings/aqpkg/mainwin.h index 615ff8b..b8e1c98 100644 --- a/noncore/settings/aqpkg/mainwin.h +++ b/noncore/settings/aqpkg/mainwin.h @@ -53,10 +53,11 @@ class MainWindow :public QMainWindow { Q_OBJECT public: - MainWindow(); + MainWindow( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~MainWindow(); + static QString appName() { return QString::fromLatin1( "aqpkg" ); }; protected: void closeEvent( QCloseEvent* e ); diff --git a/noncore/settings/sysinfo/main.cpp b/noncore/settings/sysinfo/main.cpp index 6e889db..02b1098 100644 --- a/noncore/settings/sysinfo/main.cpp +++ b/noncore/settings/sysinfo/main.cpp @@ -20,15 +20,8 @@ #include "sysinfo.h" #include <qpe/qpeapplication.h> +#include <opie/oapplicationfactory.h> -int main( int argc, char *argv[] ) -{ - QPEApplication a( argc, argv ); - - SystemInfo *si = new SystemInfo(); - a.showMainWidget( si ); - - return a.exec(); -} +OPIE_EXPORT_APP( OApplicationFactory<SystemInfo> ) diff --git a/noncore/settings/sysinfo/storage.cpp b/noncore/settings/sysinfo/storage.cpp index c4474d5..4ef7122 100644 --- a/noncore/settings/sysinfo/storage.cpp +++ b/noncore/settings/sysinfo/storage.cpp @@ -57,8 +57,9 @@ FileSysInfo::FileSysInfo( QWidget *parent, const char *name ) updateMounts(); startTimer( 5000 ); } + void FileSysInfo::timerEvent(QTimerEvent*) { updateMounts(); } @@ -68,17 +69,8 @@ void FileSysInfo::updateMounts() storage->update(); if ( rebuildDisks ) { - // Cannot auto delete QDict<MountInfo> disks because it seems to delete - // the filesystem object as well causing a segfault - MountInfo *mi; - for ( QDictIterator<MountInfo> delit(disks); delit.current(); ++delit ) - { - mi = delit.current(); - mi->fs = 0x0; - delete mi; - } disks.clear(); lines.clear(); delete vb; @@ -162,9 +154,8 @@ MountInfo::MountInfo( FileSystem *filesys, QWidget *parent, const char *name ) MountInfo::~MountInfo() { delete data; - delete fs; } void MountInfo::updateData() { diff --git a/noncore/settings/sysinfo/sysinfo.h b/noncore/settings/sysinfo/sysinfo.h index d69346a..94c3876 100644 --- a/noncore/settings/sysinfo/sysinfo.h +++ b/noncore/settings/sysinfo/sysinfo.h @@ -28,6 +28,7 @@ class SystemInfo : public QWidget { Q_OBJECT public: SystemInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); + static QString appName() { return QString::fromLatin1("sysinfo"); } }; diff --git a/noncore/settings/sysinfo/sysinfo.pro b/noncore/settings/sysinfo/sysinfo.pro index 2582ea2..2322989 100644 --- a/noncore/settings/sysinfo/sysinfo.pro +++ b/noncore/settings/sysinfo/sysinfo.pro @@ -1,7 +1,5 @@ -TEMPLATE = app -CONFIG = qt warn_on release -DESTDIR = $(OPIEDIR)/bin +CONFIG = qt warn_on release quick-app HEADERS = memory.h \ graph.h \ load.h \ storage.h \ @@ -19,12 +17,13 @@ SOURCES = main.cpp \ modulesinfo.cpp \ detail.cpp \ versioninfo.cpp \ sysinfo.cpp -INTERFACES = + INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lopie + TARGET = sysinfo TRANSLATIONS = ../../../i18n/de/sysinfo.ts \ ../../../i18n/nl/sysinfo.ts \ |