55 files changed, 1595 insertions, 513 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 @@ -35,2 +35,3 @@ +// --- CBInfo ----------------------------------------------------------------- CBInfo::CBInfo() @@ -46,2 +47,5 @@ CBInfo::CBInfo() sb = 0.0; + _sLastTab=""; + _first=-1; + _last=-1; @@ -50,2 +54,4 @@ CBInfo::CBInfo() + +// --- CBInfo ----------------------------------------------------------------- CBInfo::CBInfo( const QString &name, const QString &filename ) @@ -64,2 +70,5 @@ CBInfo::CBInfo( const QString &name, const QString &filename ) nt = config.readEntry( "Notes", "" ); + _sLastTab = config.readEntry("LastTab", ""); + _first=config.readNumEntry("First", -1); + _sSortOrder = config.readEntry( "SortOrder", QWidget::tr("Date") ); @@ -71,2 +80,3 @@ CBInfo::CBInfo( const QString &name, const QString &filename ) +// --- balance ---------------------------------------------------------------- float CBInfo::balance() @@ -77,2 +87,3 @@ float CBInfo::balance() +// --- write ------------------------------------------------------------------ void CBInfo::write() @@ -81,5 +92,3 @@ void CBInfo::write() if ( f.exists() ) - { f.remove(); - } @@ -87,3 +96,20 @@ void CBInfo::write() - // Save info + + // 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" ); @@ -95,2 +121,3 @@ void CBInfo::write() config->writeEntry( "Notes", nt ); + config->writeEntry( "LastTab", _sLastTab ); QString balstr; @@ -98,12 +125,6 @@ void CBInfo::write() 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(); - + config->write(); delete config; @@ -111,14 +132,16 @@ void CBInfo::write() -TranInfo *CBInfo::findTransaction( const QString &checknum, const QString &date, - const QString &desc ) + +// --- findTransaction -------------------------------------------------------- +TranInfo *CBInfo::findTransaction( const QString &sId ) { - TranInfo *traninfo = tl->first(); - while ( traninfo ) - { - if ( traninfo->number() == checknum && traninfo->datestr() == date && - traninfo->desc() == desc ) - break; - traninfo = tl->next(); - } - return( traninfo ); + 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; + } + return(traninfo); } @@ -127,3 +150,3 @@ void CBInfo::addTransaction( TranInfo *tran ) { - tl->inSort( tran ); + tl->append( tran ); calcBalance(); @@ -133,4 +156,4 @@ void CBInfo::removeTransaction( TranInfo *tran ) { - tl->remove( tran ); - delete tran; + tl->removeRef( tran ); + delete tran; calcBalance(); @@ -138,2 +161,5 @@ void CBInfo::removeTransaction( TranInfo *tran ) + +// --- loadTransactions ------------------------------------------------------- +// Reads the transactions. Either the old way 1-n or as linked list. void CBInfo::loadTransactions() @@ -146,20 +172,25 @@ void CBInfo::loadTransactions() Config config( fn, Config::File ); - - for ( int i = 1; trandesc != QString::null; i++ ) - { - tran = new TranInfo( config, i ); - trandesc = tran->desc(); - if ( trandesc != QString::null ) - { - tl->inSort( tran ); - } - else - { - delete tran; - } - } - - calcBalance(); + 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 ) { + delete tran; + break; + } + tl->append(tran); + i= bOld ? i+1 : tran->getNext(); + } + + calcBalance(); } + +// --- calcBalance ------------------------------------------------------------ void CBInfo::calcBalance() @@ -182,2 +213,3 @@ void CBInfo::calcBalance() + int CBInfoList::compareItems( QCollection::Item item1, QCollection::Item item2 ) 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 @@ -31,2 +31,3 @@ +#include <qwidget.h> #include <qlist.h> @@ -65,8 +66,21 @@ class CBInfo + // write void write(); + // transactions TranInfoList *transactions() const { return tl; } - TranInfo *findTransaction( const QString &, const QString &, const QString & ); - void addTransaction( TranInfo * ); - void removeTransaction( TranInfo * ); + 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); } @@ -83,2 +97,6 @@ class CBInfo float b; + QString _sLastTab; + int _first; + int _last; + QString _sSortOrder; 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 @@ -35,2 +35,4 @@ #include "password.h" +#include "mainwindow.h" +#include "cfg.h" @@ -50,3 +52,11 @@ -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 ) @@ -54,4 +64,5 @@ Checkbook::Checkbook( QWidget *parent, CBInfo *i, const QString &symbol ) info = i; - currencySymbol = symbol; + _pCfg=cfg; + // Title bar if ( info->name() != "" ) @@ -68,2 +79,3 @@ Checkbook::Checkbook( QWidget *parent, CBInfo *i, const QString &symbol ) + // Setup layout to make everything pretty @@ -76,3 +88,2 @@ Checkbook::Checkbook( QWidget *parent, CBInfo *i, const QString &symbol ) layout->addWidget( mainWidget ); - mainWidget->addTab( initInfo(), "checkbook/infotab", tr( "Info" ) ); @@ -80,3 +91,7 @@ Checkbook::Checkbook( QWidget *parent, CBInfo *i, const QString &symbol ) mainWidget->addTab( initCharts(), "checkbook/charttab", tr( "Charts" ) ); - mainWidget->setCurrentTab( tr( "Info" ) ); + if( _pCfg->isShowLastTab() ) + mainWidget->setCurrentTab( info->getLastTab() ); + else + mainWidget->setCurrentTab( tr( "Info" ) ); + connect( mainWidget, SIGNAL( currentChanged(QWidget *) ), this, SLOT( slotTab(QWidget *) ) ); @@ -90,5 +105,6 @@ Checkbook::~Checkbook() +// --- initInfo --------------------------------------------------------------- QWidget *Checkbook::initInfo() { - QWidget *control = new QWidget( mainWidget ); + QWidget *control = new QWidget( mainWidget, tr("Info") ); @@ -130,9 +146,4 @@ QWidget *Checkbook::initInfo() QWhatsThis::add( typeList, tr( "Select type of checkbook here." ) ); - typeList->insertItem( tr( "Savings" ) ); // 0 - typeList->insertItem( tr( "Checking" ) ); // 1 - typeList->insertItem( tr( "CD" ) ); // 2 - typeList->insertItem( tr( "Money market" ) ); // 3 - typeList->insertItem( tr( "Mutual fund" ) ); // 4 - typeList->insertItem( tr( "Other" ) ); // 5 - layout->addWidget( typeList, 2, 1 ); + typeList->insertStringList( _pCfg->getAccountTypes() ); + layout->addWidget( typeList, 2, 1 ); @@ -185,5 +196,7 @@ QWidget *Checkbook::initInfo() + +// --- initTransactions ------------------------------------------------------- QWidget *Checkbook::initTransactions() { - QWidget *control = new QWidget( mainWidget ); + QWidget *control = new QWidget( mainWidget, tr("Transactions") ); @@ -193,10 +206,23 @@ QWidget *Checkbook::initTransactions() - balanceLabel = new QLabel( tr( "Current balance: %10.00" ).arg( currencySymbol ), - control ); - QWhatsThis::add( balanceLabel, tr( "This area shows the current balance in this checkbook." ) ); - layout->addMultiCellWidget( balanceLabel, 0, 0, 0, 2 ); - - tranTable = new QListView( control ); + // 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( "Num" ) ); + tranTable->addColumn( tr( "Id" ) ); + tranTable->setColumnWidthMode( COL_ID, QListView::Manual ); + tranTable->setColumnWidth( COL_ID, 0); + tranTable->addColumn( tr( "Num" ) ); tranTable->addColumn( tr( "Date" ) ); @@ -204,6 +230,8 @@ QWidget *Checkbook::initTransactions() 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 ); @@ -212,3 +240,5 @@ QWidget *Checkbook::initTransactions() this, SLOT( slotEditTran() ) ); + _sortCol=COL_ID; + // Buttons QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), control ); @@ -231,2 +261,4 @@ QWidget *Checkbook::initTransactions() + +// --- initCharts ------------------------------------------------------------- QWidget *Checkbook::initCharts() @@ -235,3 +267,3 @@ QWidget *Checkbook::initCharts() - QWidget *control = new QWidget( mainWidget ); + QWidget *control = new QWidget( mainWidget, tr("Charts") ); @@ -261,2 +293,3 @@ QWidget *Checkbook::initCharts() +// --- loadCheckbook ---------------------------------------------------------- void Checkbook::loadCheckbook() @@ -283,2 +316,6 @@ void Checkbook::loadCheckbook() } + if( i<=0 ) { + typeList->insertItem( temptext, 0 ); + typeList->setCurrentItem(0); + } bankEdit->setText( info->bank() ); @@ -292,5 +329,4 @@ void Checkbook::loadCheckbook() float amount; - QString stramount; - - for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() ) + QString stramount; + for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() ) { @@ -301,29 +337,49 @@ void Checkbook::loadCheckbook() } - 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 ) ); - - highTranNum = tranList->count(); + // 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() ); + } + + // 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 ) +// --- resort ----------------------------------------------------------------- +void Checkbook::resort() { - TranInfo *traninfo = tranList->first(); - while ( traninfo ) - { - 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() @@ -400,2 +456,4 @@ void Checkbook::slotNameChanged( const QString &newname ) + +// ---slotStartingBalanceChanged ---------------------------------------------- void Checkbook::slotStartingBalanceChanged( const QString &newbalance ) @@ -407,6 +465,8 @@ void Checkbook::slotStartingBalanceChanged( const QString &newbalance ) + void Checkbook::slotNewTran() { - highTranNum++; - TranInfo *traninfo = new TranInfo( highTranNum ); + TranInfo *traninfo = new TranInfo( info->getNextNumber() ); + if( !_dLastNew.isNull() ) + traninfo->setDate(_dLastNew); @@ -414,3 +474,3 @@ void Checkbook::slotNewTran() traninfo, - currencySymbol ); + _pCfg ); currtran->showMaximized(); @@ -424,14 +484,12 @@ void Checkbook::slotNewTran() 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(), - stramount ); - + 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(); } @@ -439,3 +497,2 @@ void Checkbook::slotNewTran() { - highTranNum--; delete traninfo; @@ -448,8 +505,5 @@ void Checkbook::slotEditTran() if ( !curritem ) - { return; - } - - TranInfo *traninfo = info->findTransaction( curritem->text( 0 ), curritem->text( 1 ), - curritem->text( 2 ) ); + + TranInfo *traninfo=info->findTransaction( curritem->text(COL_ID) ); @@ -457,3 +511,3 @@ void Checkbook::slotEditTran() traninfo, - currencySymbol ); + _pCfg ); currtran->showMaximized(); @@ -461,5 +515,5 @@ void Checkbook::slotEditTran() { - 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() ); @@ -471,6 +525,6 @@ void Checkbook::slotEditTran() QString stramount; - stramount.sprintf( "%s%.2f", currencySymbol.latin1(), amount ); - curritem->setText( 3, stramount ); - - adjustBalance(); + stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); + curritem->setText( COL_AMOUNT, stramount ); + resort(); + adjustBalance(); } @@ -484,7 +538,5 @@ void Checkbook::slotDeleteTran() if ( !curritem ) - { return; - } - TranInfo *traninfo = findTran( curritem->text( 0 ), curritem->text( 1 ), curritem->text( 2 ) ); + TranInfo *traninfo = info->findTransaction( curritem->text(COL_ID) ); @@ -494,3 +546,3 @@ void Checkbook::slotDeleteTran() delete curritem; - adjustBalance(); + adjustBalance(); } @@ -591,3 +643,3 @@ void Checkbook::drawCategoryChart( bool withdrawals ) -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, @@ -596,2 +648,3 @@ CBListItem::CBListItem( QListView *parent, QString label1, QString label2, { + _pTran=pTran; m_known = FALSE; @@ -654 +707,24 @@ bool CBListItem::isAltBackground() } + + +// --- 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 @@ -31,2 +31,3 @@ +#include <qdatetime.h> #include <qdialog.h> @@ -48,3 +49,6 @@ class TranInfo; class TranInfoList; +class Cfg; + +// --- Checkbook -------------------------------------------------------------- class Checkbook : public QDialog @@ -54,10 +58,12 @@ class Checkbook : public QDialog public: - Checkbook( QWidget * = 0x0, CBInfo * = 0x0, const QString & = "$" ); + Checkbook( QWidget *, CBInfo *, Cfg *cfg ); ~Checkbook(); + // resort + void resort(); + private: - CBInfo *info; + CBInfo *info; TranInfoList *tranList; - QString currencySymbol; - int highTranNum; + Cfg *_pCfg; @@ -66,3 +72,2 @@ class Checkbook : public QDialog void adjustBalance(); - TranInfo *findTran( const QString &, const QString &, const QString & ); @@ -78,7 +83,9 @@ class Checkbook : public QDialog QMultiLineEdit *notesEdit; + int _sortCol; // Transactions tab - QWidget *initTransactions(); + QWidget *initTransactions(); QListView *tranTable; - QLabel *balanceLabel; + QComboBox *_cbSortType; + QDate _dLastNew; @@ -93,4 +100,6 @@ class Checkbook : public QDialog + protected slots: void accept(); + void slotTab(QWidget *tab); @@ -104,4 +113,6 @@ class Checkbook : public QDialog void slotDrawGraph(); + void slotSortChanged( const QString & ); }; +// --- CBListItem ------------------------------------------------------------- class CBListItem : public QListViewItem @@ -111,3 +122,3 @@ class CBListItem : public QListViewItem 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, @@ -117,3 +128,7 @@ class CBListItem : public QListViewItem + // --- members + TranInfo *getTranInfo() { return(_pTran); } + private: + TranInfo *_pTran; QListView *owner; @@ -125,2 +140,3 @@ class CBListItem : public QListViewItem + #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,3 +1,2 @@ -TEMPLATE = app -CONFIG = qt warn_on release +CONFIG = qt warn_on release quick-app HEADERS = mainwindow.h \ @@ -10,2 +9,5 @@ HEADERS = mainwindow.h \ transaction.h \ + tabledef.h \ + listedit.h \ + cfg.h \ graph.h @@ -19,3 +21,6 @@ SOURCES = main.cpp \ checkbook.cpp \ - transaction.cpp \ + transaction.cpp \ + tabledef.cpp \ + listedit.cpp \ + cfg.cpp \ graph.cpp @@ -25,3 +30,2 @@ LIBS += -lqpe -lopie TARGET = checkbook -DESTDIR = $(OPIEDIR)/bin 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 @@ -29,2 +29,5 @@ #include "configuration.h" +#include "mainwindow.h" +#include "listedit.h" +#include "tabledef.h" @@ -35,4 +38,8 @@ #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 ) @@ -41,6 +48,57 @@ Configuration::Configuration( QWidget *parent, const QString &cs, bool sl, bool - QFontMetrics fm = fontMetrics(); + // 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 ); @@ -48,3 +106,3 @@ Configuration::Configuration( QWidget *parent, const QString &cs, bool sl, bool - 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." ) ); @@ -53,3 +111,3 @@ Configuration::Configuration( QWidget *parent, const QString &cs, bool sl, bool - symbolEdit = new QLineEdit( cs, this ); + symbolEdit = new QLineEdit( cfg.getCurrencySymbol(), container ); QWhatsThis::add( symbolEdit, tr( "Enter your local currency symbol here." ) ); @@ -59,16 +117,45 @@ Configuration::Configuration( QWidget *parent, const QString &cs, bool sl, bool - 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 @@ -32,2 +32,3 @@ #include <qdialog.h> +#include "cfg.h" @@ -36,2 +37,4 @@ class QLineEdit; class QString; +class QTabWidget; +class ListEdit; @@ -42,3 +45,4 @@ class Configuration : public QDialog public: - Configuration( QWidget * = 0x0, const QString & = "$", bool = FALSE, bool = FALSE ); + // Constructor + Configuration( QWidget *, Cfg &cfg); ~Configuration(); @@ -48,2 +52,14 @@ class Configuration : public QDialog 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); }; 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 @@ -28,15 +28,7 @@ -#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 @@ -33,2 +33,3 @@ #include "checkbook.h" +#include "listedit.h" @@ -48,4 +49,5 @@ -MainWindow::MainWindow() - : QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) + +MainWindow::MainWindow( QWidget* parent, const char* name, WFlags fl ) + : QMainWindow( parent, name, fl || WStyle_ContextHelp ) { @@ -58,6 +60,5 @@ MainWindow::MainWindow() 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 ); + @@ -127,9 +128,27 @@ MainWindow::MainWindow() 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() @@ -137,5 +156,3 @@ void MainWindow::buildList() if ( cbList ) - { - delete cbList; - } + delete cbList; @@ -144,3 +161,3 @@ void MainWindow::buildList() - if ( showLocks ) + if ( _cfg.getShowLocks() ) { @@ -154,3 +171,3 @@ void MainWindow::buildList() cbList->addColumn( tr( "Checkbook Name" ) ); - if ( showBalances ) + if ( _cfg.getShowBalances() ) { @@ -175,3 +192,3 @@ void MainWindow::addCheckbook( CBInfo *cb ) QListViewItem *lvi = new QListViewItem( cbList ); - if ( showLocks && !cb->password().isNull() ) + if ( _cfg.getShowLocks() && !cb->password().isNull() ) { @@ -180,6 +197,6 @@ void MainWindow::addCheckbook( CBInfo *cb ) 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 ); @@ -199,3 +216,3 @@ void MainWindow::slotNew() - Checkbook *currcb = new Checkbook( this, cb, currencySymbol ); + Checkbook *currcb = new Checkbook( this, cb, &_cfg ); currcb->showMaximized(); @@ -205,2 +222,3 @@ void MainWindow::slotNew() buildFilename( cb->name() ); + _cfg.setLastBook( cb->name() ); cb->setFilename( tempFilename ); @@ -215,15 +233,20 @@ void MainWindow::slotNew() +// --- slotEdit --------------------------------------------------------------- void MainWindow::slotEdit() { - + // get name and open it QListViewItem *curritem = cbList->currentItem(); if ( !curritem ) - { return; - } - QString currname = curritem->text( posName ); + openBook( curritem ); +} - 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 ) @@ -232,7 +255,5 @@ void MainWindow::slotEdit() } - if ( !cb ) - { - return; - } + if ( !cb ) return; + // buildFilename( currname ); @@ -252,3 +273,4 @@ void MainWindow::slotEdit() - Checkbook *currcb = new Checkbook( this, cb, currencySymbol ); + _cfg.setLastBook( currname ); + Checkbook *currcb = new Checkbook( this, cb, &_cfg ); currcb->showMaximized(); @@ -260,4 +282,7 @@ void MainWindow::slotEdit() // Update name if changed - curritem->setText( posName, newname ); - cbList->sort(); + if( curritem ) { + curritem->setText( posName, newname ); + cbList->sort(); + } + _cfg.setLastBook( newname ); @@ -266,5 +291,3 @@ void MainWindow::slotEdit() if ( f.exists() ) - { f.remove(); - } @@ -278,3 +301,3 @@ void MainWindow::slotEdit() // Update lock if changed - if ( showLocks && !cb->password().isNull() != currlock ) + if ( _cfg.getShowLocks() && !cb->password().isNull() != currlock ) { @@ -287,6 +310,6 @@ void MainWindow::slotEdit() // 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 ); @@ -297,2 +320,3 @@ void MainWindow::slotEdit() +// --- slotDelete ------------------------------------------------------------- void MainWindow::slotDelete() @@ -314,5 +338,6 @@ void MainWindow::slotDelete() +// --- slotConfigure ---------------------------------------------------------- void MainWindow::slotConfigure() { - Configuration *cfgdlg = new Configuration( this, currencySymbol, showLocks, showBalances ); + Configuration *cfgdlg = new Configuration( this, _cfg ); cfgdlg->showMaximized(); @@ -320,13 +345,5 @@ void MainWindow::slotConfigure() { - 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(); @@ -335 +352,9 @@ void MainWindow::slotConfigure() } + + +// --- 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 @@ -33,2 +33,3 @@ #include <qpixmap.h> +#include "cfg.h" @@ -39,2 +40,3 @@ class QListView; class QString; +class QListViewItem; @@ -45,4 +47,11 @@ class MainWindow : public QMainWindow 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); @@ -54,5 +63,3 @@ class MainWindow : public QMainWindow - QString currencySymbol; - bool showLocks; - bool showBalances; + Cfg _cfg; int posName; 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 @@ -36,3 +36,3 @@ TranInfo::TranInfo( int id, const QString &desc, const QDate &date, bool withdra 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 ) { @@ -48,2 +48,3 @@ TranInfo::TranInfo( int id, const QString &desc, const QDate &date, bool withdra n = notes; + _next=next; } @@ -113,3 +114,3 @@ TranInfo::TranInfo( Config config, int entry ) - // Transaction number + // Transaction number cn = config.readEntry( "CheckNumber", "" ); @@ -118,2 +119,5 @@ TranInfo::TranInfo( Config config, int entry ) n = config.readEntry( "Comments", "" ); + + // next + _next = config.readNumEntry("Next", -1); } @@ -121,20 +125,22 @@ TranInfo::TranInfo( Config config, int entry ) +// --- 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 ); +} - 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() ) ); @@ -171,7 +177,8 @@ void TranInfo::write( Config *config, int entry ) - config->writeEntry( "CheckNumber", cn ); - + config->writeEntry( "CheckNumber", cn ); config->writeEntry( "Comments", n ); + config->writeEntry( "Next", _next ); } + int TranInfoList::compareItems( QCollection::Item item1, QCollection::Item item2 ) @@ -190 +197,16 @@ int TranInfoList::compareItems( QCollection::Item item1, QCollection::Item item2 } + +// --- 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 @@ -42,6 +42,9 @@ class TranInfo 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; } @@ -56,4 +59,6 @@ class TranInfo const QString ¬es() const { return n; } + int getNext() { return(_next); } - void setDesc( const QString &desc ) { d = desc; } + // setters + void setDesc( const QString &desc ) { d = desc; } void setDate( const QDate &date ) { td = date; } @@ -66,4 +71,9 @@ class TranInfo void setNotes( const QString ¬es ) { n = notes; } + void setNext(int next) { _next=next; } + + // write + void write( Config * ); - void write( Config *, int ); + // toString + QString toString(); @@ -80,2 +90,3 @@ class TranInfo QString n; + int _next; }; 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 @@ -30,2 +30,3 @@ #include "traninfo.h" +#include "cfg.h" @@ -43,3 +44,3 @@ Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *info, - const QString &symbol ) + Cfg *pCfg ) : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) @@ -51,3 +52,3 @@ Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *in tran = info; - currencySymbol = symbol; + _pCfg=pCfg; @@ -225,3 +226,3 @@ void Transaction::accept() tran->setNotes( noteEdit->text() ); - + QDialog::accept(); @@ -232,17 +233,9 @@ 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" ) ); - catList->setCurrentItem( 0 ); + 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(); @@ -257,6 +250,9 @@ void Transaction::slotDepositClicked() catList->clear(); - catList->insertItem( tr( "Work" ) ); - catList->insertItem( tr( "Family Member" ) ); - catList->insertItem( tr( "Misc. Credit" ) ); - catList->setCurrentItem( 0 ); + 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(); 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 @@ -42,2 +42,3 @@ class QWidget; class TranInfo; +class Cfg; @@ -48,4 +49,3 @@ class Transaction : public QDialog public: - Transaction( QWidget * = 0x0, const QString & = 0x0, TranInfo * = 0x0, - const QString & = "$" ); + Transaction( QWidget *, const QString &, TranInfo *, Cfg *); ~Transaction(); @@ -55,3 +55,3 @@ class Transaction : public QDialog - QString currencySymbol; + Cfg *_pCfg; 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 @@ -19,11 +19,6 @@ #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 @@ -38,6 +38,6 @@ -ODict::ODict() : QMainWindow() +ODict::ODict(QWidget* parent, const char* name, WFlags fl ) : QMainWindow(parent, name, fl ) { activated_name = QString::null; - + vbox = new QVBox( this ); @@ -47,3 +47,3 @@ ODict::ODict() : QMainWindow() QHBox *hbox = new QHBox( vbox ); - QLabel* query_label = new QLabel( tr( "Query:" ) , hbox ); + QLabel* query_label = new QLabel( tr( "Query:" ) , hbox ); query_label->show(); @@ -54,3 +54,3 @@ ODict::ODict() : QMainWindow() connect( ok_button, SIGNAL( released() ), this, SLOT( slotStartQuery() ) ); - + top_name = new QLabel( vbox ); @@ -74,3 +74,3 @@ void ODict::loadConfig() QString lastname; - + Config cfg ( "odict" ); @@ -81,3 +81,3 @@ void ODict::loadConfig() int i = 0, e = 0; - + QStringList groupListCfg = cfg.groupList().grep( "Method_" ); @@ -119,4 +119,4 @@ void ODict::lookupLanguageNames( QString dictname ) cfg.setGroup( "Method_"+dictname ); - top_name_content = cfg.readEntry( "Lang1" ); - bottom_name_content = cfg.readEntry( "Lang2" ); + top_name_content = cfg.readEntry( "Lang1" ); + bottom_name_content = cfg.readEntry( "Lang2" ); } @@ -143,3 +143,3 @@ void ODict::slotStartQuery() tr( "No dictionary defined" ), - tr( "&Define one" ), + tr( "&Define one" ), tr( "&Cancel" ), @@ -147,3 +147,3 @@ void ODict::slotStartQuery() 1 ) ) // Cancel choosen - { + { case 0: @@ -154,3 +154,3 @@ void ODict::slotStartQuery() } - } + } @@ -159,3 +159,3 @@ void ODict::slotStartQuery() */ - ding->setCaseSensitive( casesens ); + ding->setCaseSensitive( casesens ); @@ -191,3 +191,3 @@ void ODict::slotMethodChanged( const QString& methodnumber ) activated_name = methodnumber; - + if ( activated_name != ding->loadedDict() ) @@ -195,3 +195,3 @@ void ODict::slotMethodChanged( const QString& methodnumber ) ding->loadDict(activated_name); - + lookupLanguageNames( activated_name ); @@ -205,3 +205,3 @@ void ODict::setupMenus() menu = new QMenuBar( this ); - + settings = new QPopupMenu( menu ); @@ -211,3 +211,3 @@ void ODict::setupMenus() setting_b = new QAction(tr( "Searchmethods" ), Resource::loadPixmap( "edit" ), QString::null, 0, this, 0 ); - + parameter = new QPopupMenu( menu ); @@ -216,3 +216,3 @@ void ODict::setupMenus() parameter->insertSeparator(); - + menu->insertItem( tr( "Settings" ) , settings ); 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 @@ -31,3 +31,3 @@ class ODict : public QMainWindow public: - ODict(); + ODict(QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); QVBox *vbox; @@ -36,3 +36,3 @@ class ODict : public QMainWindow DingWidget *ding; - + static QString appName() { return QString::fromLatin1("odict"); } private: 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,4 +1,2 @@ -TEMPLATE = app -CONFIG = qt warn_on debug -#CONFIG = qt warn_on release +CONFIG = qt warn_on release quick-app HEADERS = odict.h \ @@ -17,3 +15,2 @@ LIBS += -lqpe -lstdc++ -lopie TARGET = odict -DESTDIR = $(OPIEDIR)/bin 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,3 +1,3 @@ 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 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,2 +1 @@ -TEMPLATE = app CONFIG = qt warn_on release @@ -83,7 +82,7 @@ SOURCES = Aportis.cpp \ -INTERFACES = -DESTDIR = $(OPIEDIR)/bin +DESTDIR = $(OPIEDIR)/bin +TARGET = reader + INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include -TARGET = reader LIBS += -lqpe 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 @@ -18,11 +18,5 @@ -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 @@ -45,4 +45,4 @@ -MainWindow::MainWindow() - :QMainWindow() +MainWindow::MainWindow(QWidget *parent, const char* n, WFlags fl) + :QMainWindow(parent, n, fl) { 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 @@ -122,3 +122,4 @@ class MainWindow: public QMainWindow public: - MainWindow(); + static QString appName() { return QString::fromLatin1("sheetqt"); } + MainWindow(QWidget *p, const char*, WFlags); ~MainWindow(); 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,4 +1,2 @@ -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 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 @@ -22,16 +22,7 @@ #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 @@ -102,4 +102,4 @@ 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 ) 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 @@ -47,5 +47,7 @@ class MainWindow : public QMainWindow 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: 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,5 +1,4 @@ -TEMPLATE = app -CONFIG += qt warn_on release -DESTDIR = $(OPIEDIR)/bin +CONFIG += qt warn on release quick-app + @@ -26,20 +25,2 @@ 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 - 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 @@ -19,11 +19,6 @@ #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 @@ -27,3 +27,3 @@ -Oxygen::Oxygen() : QMainWindow() +Oxygen::Oxygen( QWidget *parent, const char *name, WFlags f) : QMainWindow( parent, name, f ) { @@ -33,5 +33,5 @@ Oxygen::Oxygen() : QMainWindow() dataWidgetUI *DataWidgetUI = new dataWidgetUI(names); - + setCaption( tr( "Oxygen" ) ); - + QTabWidget *tabw = new QTabWidget( this , "qtab" ); 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,10 +15,11 @@ class Oxygen : public QMainWindow { - Q_OBJECT + Q_OBJECT - public: - Oxygen(); - - private: - void loadNames(); - QStringList names; + public: + 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,3 +1,2 @@ -TEMPLATE = app -CONFIG = qt warn_on release +CONFIG = qt warn_on release quick-app HEADERS = oxygen.h \ @@ -22,27 +21,6 @@ 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 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 @@ -21,12 +21,5 @@ #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 @@ -42,2 +42,3 @@ class TableViewerWindow: public QMainWindow public: + static QString appName() { return QString::fromLatin1("tableviewer"); } TableViewerWindow( QWidget *parent = 0, 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,4 +1,2 @@ -TEMPLATE = app -CONFIG = qt warn_on debug -DESTDIR = $(OPIEDIR)/bin +CONFIG = qt warn_on debug quick-app SUBDIRS = db ui 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 @@ -15,3 +15,2 @@ ***************************************************************************/ -#include <qpe/qpeapplication.h> #include <qmainwindow.h> @@ -19,10 +18,5 @@ +#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,3 +1,3 @@ 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 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 @@ -35,2 +35,4 @@ public: ~TinyKate( ); + static QString appName() { return QString::fromLatin1( "kate" ); }; + 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,3 +1,3 @@ TEMPLATE = app -CONFIG = qt warn_on release +CONFIG = qt warn_on release quick-app DESTDIR = $(OPIEDIR)/bin @@ -17,3 +17,3 @@ DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -ltinykate -lopie -TARGET = tinykate +TARGET = kate 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 @@ -2 +2,2 @@ 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,3 +1,2 @@ -TEMPLATE = app -CONFIG = qt warn_on release +CONFIG = qt warn_on release quick-app HEADERS = global.h \ @@ -34,3 +33,2 @@ SOURCES = mainwin.cpp \ categoryfilterimpl.cpp -INTERFACES = TARGET = aqpkg @@ -39,24 +37,4 @@ 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 @@ -29,16 +29,5 @@ -#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> @@ -48,31 +37,2 @@ 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 @@ -2,3 +2,3 @@ This file is part of the OPIE Project - + =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> @@ -68,5 +68,11 @@ 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" ) ); @@ -236,2 +242,5 @@ MainWindow :: ~MainWindow() delete mgr; + + // Reenable suspend mode + QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; } @@ -1014,3 +1023,2 @@ InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) newitem->option = "D"; - // If local file, remove using package name, not filename @@ -1048,3 +1056,2 @@ InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) newitem->option = "D"; - // If local file, remove using package name, not filename @@ -1191,5 +1198,5 @@ QuestionDlg::QuestionDlg( const QString &caption, const QString &text, const QSt resize( 175, 100 ); - + QGridLayout *layout = new QGridLayout( this ); - + QLabel *l = new QLabel( text, this ); @@ -1197,3 +1204,3 @@ QuestionDlg::QuestionDlg( const QString &caption, const QString &text, const QSt layout->addMultiCellWidget( l, 0, 0, 0, 1 ); - + btn1 = new QPushButton( tr( "Remove" ), this ); @@ -1201,3 +1208,3 @@ QuestionDlg::QuestionDlg( const QString &caption, const QString &text, const QSt layout->addWidget( btn1, 1, 0 ); - + btn2 = new QPushButton( secondbtn, this ); @@ -1205,3 +1212,3 @@ QuestionDlg::QuestionDlg( const QString &caption, const QString &text, const QSt layout->addWidget( btn2, 1, 1 ); - + executing = FALSE; @@ -1218,3 +1225,3 @@ int QuestionDlg::exec() } - + return buttonpressed; @@ -1230,3 +1237,3 @@ void QuestionDlg::slotButtonPressed() buttonpressed = 0; - + qApp->exit_loop(); 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,7 +53,8 @@ class MainWindow :public QMainWindow { - Q_OBJECT + Q_OBJECT public: - MainWindow(); + MainWindow( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~MainWindow(); + static QString appName() { return QString::fromLatin1( "aqpkg" ); }; 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 @@ -23,12 +23,5 @@ #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 @@ -52,3 +52,3 @@ FileSysInfo::FileSysInfo( QWidget *parent, const char *name ) connect( storage, SIGNAL( disksChanged() ), this, SLOT( disksChanged() ) ); - + lines.setAutoDelete(TRUE); @@ -60,2 +60,3 @@ FileSysInfo::FileSysInfo( QWidget *parent, const char *name ) + void FileSysInfo::timerEvent(QTimerEvent*) @@ -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; @@ -87,3 +79,3 @@ void FileSysInfo::updateMounts() bool frst=TRUE; - + FileSystem *fs; @@ -92,3 +84,3 @@ void FileSysInfo::updateMounts() fs = it.current(); - + if ( !frst ) @@ -102,3 +94,3 @@ void FileSysInfo::updateMounts() frst = FALSE; - + MountInfo *mi = new MountInfo( fs, container ); @@ -128,3 +120,3 @@ void FileSysInfo::updateMounts() } - + rebuildDisks = FALSE; @@ -147,3 +139,3 @@ MountInfo::MountInfo( FileSystem *filesys, QWidget *parent, const char *name ) title = fs->name(); - + data = new GraphData(); @@ -165,3 +157,2 @@ MountInfo::~MountInfo() delete data; - delete fs; } 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 @@ -31,2 +31,3 @@ 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,4 +1,2 @@ -TEMPLATE = app -CONFIG = qt warn_on release -DESTDIR = $(OPIEDIR)/bin +CONFIG = qt warn_on release quick-app HEADERS = memory.h \ @@ -22,3 +20,3 @@ SOURCES = main.cpp \ sysinfo.cpp -INTERFACES = + INCLUDEPATH += $(OPIEDIR)/include @@ -26,3 +24,4 @@ DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lopie -TARGET = sysinfo + +TARGET = sysinfo |