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 @@ -1,196 +1,228 @@ /* 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 "cbinfo.h" #include "traninfo.h" #include <qpe/config.h> #include <qfile.h> +// --- CBInfo ----------------------------------------------------------------- CBInfo::CBInfo() { n = ""; fn = ""; pw = QString::null; t = ""; bn = ""; a = ""; p = ""; nt = ""; sb = 0.0; + _sLastTab=""; + _first=-1; + _last=-1; tl = new TranInfoList(); } + +// --- CBInfo ----------------------------------------------------------------- CBInfo::CBInfo( const QString &name, const QString &filename ) { Config config( filename, Config::File ); config.setGroup( "Account" ); n = name; fn = filename; pw = config.readEntryCrypt( "Password", QString::null ); t = config.readEntry( "Type" ); bn = config.readEntry( "Bank", "" ); a = config.readEntryCrypt( "Number", "" ); p = config.readEntryCrypt( "PINNumber", "" ); nt = config.readEntry( "Notes", "" ); + _sLastTab = config.readEntry("LastTab", ""); + _first=config.readNumEntry("First", -1); + _sSortOrder = config.readEntry( "SortOrder", QWidget::tr("Date") ); bool ok; sb = config.readEntry( "Balance", "0.0" ).toFloat( &ok ); loadTransactions(); } +// --- balance ---------------------------------------------------------------- float CBInfo::balance() { calcBalance(); return b; } +// --- write ------------------------------------------------------------------ void CBInfo::write() { QFile f( fn ); if ( f.exists() ) - { f.remove(); - } Config *config = new Config(fn, Config::File); - // 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" ); config->writeEntryCrypt( "Password", pw ); config->writeEntry( "Type", t ); config->writeEntry( "Bank", bn ); config->writeEntryCrypt( "Number", a ); config->writeEntryCrypt( "PINNumber", p ); config->writeEntry( "Notes", nt ); + config->writeEntry( "LastTab", _sLastTab ); QString balstr; balstr.setNum( sb, 'f', 2 ); config->writeEntry( "Balance", balstr ); + config->writeEntry( "First", _first ); + config->writeEntry( "SortOrder", _sSortOrder ); - // Save transactions - int i = 1; - for ( TranInfo *tran = tl->first(); tran; tran = tl->next() ) - { - tran->write( config, i ); - i++; - } - config->write(); - + config->write(); delete config; } -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); } void CBInfo::addTransaction( TranInfo *tran ) { - tl->inSort( tran ); + tl->append( tran ); calcBalance(); } void CBInfo::removeTransaction( TranInfo *tran ) { - tl->remove( tran ); - delete tran; + tl->removeRef( tran ); + delete tran; calcBalance(); } + +// --- loadTransactions ------------------------------------------------------- +// Reads the transactions. Either the old way 1-n or as linked list. void CBInfo::loadTransactions() { TranInfo *tran; QString trandesc = ""; tl = new TranInfoList(); Config config( fn, Config::File ); - - for ( int i = 1; trandesc != QString::null; i++ ) - { - 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() { float amount; b = sb; for ( TranInfo *tran = tl->first(); tran; tran = tl->next() ) { b -= tran->fee(); amount = tran->amount(); if ( tran->withdrawal() ) { amount *= -1; } b += amount; } } + int CBInfoList::compareItems( QCollection::Item item1, QCollection::Item item2 ) { QString n1 = ((CBInfo *)item1)->name(); QString n2 = ((CBInfo *)item2)->name(); int r = -1; if ( n1 < n2 ) r = -1; else if ( n1 == n2 ) r = 0; else if ( n1 > n2 ) r = 1; return( r ); } 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 @@ -1,97 +1,115 @@ /* 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 CBINFO_H #define CBINFO_H +#include <qwidget.h> #include <qlist.h> #include <qstring.h> class Config; class TranInfo; class TranInfoList; class CBInfo { public: CBInfo(); CBInfo( const QString &, const QString & ); const QString &name() const { return n; } const QString &filename() const { return fn; } const QString &password() const { return pw; } const QString &type() const { return t; } const QString &bank() const { return bn; } const QString &account() const { return a; } const QString &pin() const { return p; } const QString ¬es() const { return nt; } float startingBalance() const { return sb; } float balance(); void setName( const QString &name ) { n = name; } void setFilename( const QString &filename ) { fn = filename; } void setPassword( const QString &password ) { pw = password; } void setType( const QString &type ) { t = type; } void setBank( const QString &bank ) { bn = bank; } void setAccount( const QString &account ) { a = account; } void setPin( const QString &pin ) { p = pin; } void setNotes( const QString ¬es ) { nt = notes; } void setStartingBalance( float startbal ) { sb = startbal; } + // write void write(); + // transactions TranInfoList *transactions() const { return tl; } - TranInfo *findTransaction( const QString &, const QString &, const QString & ); - 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); } private: QString n; QString fn; QString pw; QString t; QString bn; QString a; QString p; QString nt; float sb; float b; + QString _sLastTab; + int _first; + int _last; + QString _sSortOrder; TranInfoList *tl; void loadTransactions(); void calcBalance(); }; class CBInfoList : public QList<CBInfo> { protected: int compareItems( QCollection::Item, QCollection::Item ); }; #endif 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 @@ -1,654 +1,730 @@ /* This file is part of the OPIE Project =. .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This file is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General ..}^=.= = ; Public License for more details. ++= -. .` .: : = ...= . :.=- You should have received a copy of the GNU -. .:....=;==+<; General Public License along with this file; -_. . . )=. = see the file COPYING. If not, write to the -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "checkbook.h" #include "cbinfo.h" #include "transaction.h" #include "traninfo.h" #include "graph.h" #include "graphinfo.h" #include "password.h" +#include "mainwindow.h" +#include "cfg.h" #include <opie/otabwidget.h> #include <qpe/qpeapplication.h> #include <qpe/qpemessagebox.h> #include <qpe/resource.h> #include <qcheckbox.h> #include <qcombobox.h> #include <qlabel.h> #include <qlayout.h> #include <qlineedit.h> #include <qmultilineedit.h> #include <qpushbutton.h> #include <qwhatsthis.h> -Checkbook::Checkbook( QWidget *parent, CBInfo *i, const QString &symbol ) +#define COL_ID 0 +#define COL_NUM 1 +#define COL_DATE 2 +#define COL_DESC 3 +#define COL_AMOUNT 4 +#define COL_BAL 5 + +// --- Checkbook -------------------------------------------------------------- +Checkbook::Checkbook( QWidget *parent, CBInfo *i, Cfg *cfg ) : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) { info = i; - currencySymbol = symbol; + _pCfg=cfg; + // Title bar if ( info->name() != "" ) { QString tempstr = info->name(); tempstr.append( " - " ); tempstr.append( tr( "Checkbook" ) ); setCaption( tempstr ); } else { setCaption( tr( "New checkbook" ) ); } + // Setup layout to make everything pretty QVBoxLayout *layout = new QVBoxLayout( this ); layout->setMargin( 2 ); layout->setSpacing( 4 ); // Setup tabs for all info mainWidget = new OTabWidget( this ); layout->addWidget( mainWidget ); - mainWidget->addTab( initInfo(), "checkbook/infotab", tr( "Info" ) ); mainWidget->addTab( initTransactions(), "checkbook/trantab", tr( "Transactions" ) ); mainWidget->addTab( initCharts(), "checkbook/charttab", tr( "Charts" ) ); - mainWidget->setCurrentTab( tr( "Info" ) ); + if( _pCfg->isShowLastTab() ) + mainWidget->setCurrentTab( info->getLastTab() ); + else + mainWidget->setCurrentTab( tr( "Info" ) ); + connect( mainWidget, SIGNAL( currentChanged(QWidget *) ), this, SLOT( slotTab(QWidget *) ) ); // Load checkbook information loadCheckbook(); } Checkbook::~Checkbook() { } +// --- initInfo --------------------------------------------------------------- QWidget *Checkbook::initInfo() { - QWidget *control = new QWidget( mainWidget ); + QWidget *control = new QWidget( mainWidget, tr("Info") ); QVBoxLayout *vb = new QVBoxLayout( control ); QScrollView *sv = new QScrollView( control ); vb->addWidget( sv, 0, 0 ); sv->setResizePolicy( QScrollView::AutoOneFit ); sv->setFrameStyle( QFrame::NoFrame ); QWidget *container = new QWidget( sv->viewport() ); sv->addChild( container ); QGridLayout *layout = new QGridLayout( container ); layout->setSpacing( 2 ); layout->setMargin( 4 ); // Password protection passwordCB = new QCheckBox( tr( "Password protect" ), container ); QWhatsThis::add( passwordCB, tr( "Click here to enable/disable password protection of this checkbook." ) ); connect( passwordCB, SIGNAL( clicked() ), this, SLOT( slotPasswordClicked() ) ); layout->addMultiCellWidget( passwordCB, 0, 0, 0, 1 ); // Account name QLabel *label = new QLabel( tr( "Name:" ), container ); QWhatsThis::add( label, tr( "Enter name of checkbook here." ) ); layout->addWidget( label, 1, 0 ); nameEdit = new QLineEdit( container ); QWhatsThis::add( nameEdit, tr( "Enter name of checkbook here." ) ); connect( nameEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( slotNameChanged( const QString & ) ) ); layout->addWidget( nameEdit, 1, 1 ); // Type of account label = new QLabel( tr( "Type:" ), container ); QWhatsThis::add( label, tr( "Select type of checkbook here." ) ); layout->addWidget( label, 2, 0 ); typeList = new QComboBox( container ); QWhatsThis::add( typeList, tr( "Select type of checkbook here." ) ); - typeList->insertItem( tr( "Savings" ) ); // 0 - typeList->insertItem( tr( "Checking" ) ); // 1 - typeList->insertItem( tr( "CD" ) ); // 2 - typeList->insertItem( tr( "Money market" ) ); // 3 - typeList->insertItem( tr( "Mutual fund" ) ); // 4 - typeList->insertItem( tr( "Other" ) ); // 5 - layout->addWidget( typeList, 2, 1 ); + typeList->insertStringList( _pCfg->getAccountTypes() ); + layout->addWidget( typeList, 2, 1 ); // Bank/institution name label = new QLabel( tr( "Bank:" ), container ); QWhatsThis::add( label, tr( "Enter name of the bank for this checkbook here." ) ); layout->addWidget( label, 3, 0 ); bankEdit = new QLineEdit( container ); QWhatsThis::add( bankEdit, tr( "Enter name of the bank for this checkbook here." ) ); layout->addWidget( bankEdit, 3, 1 ); // Account number label = new QLabel( tr( "Account number:" ), container ); QWhatsThis::add( label, tr( "Enter account number for this checkbook here." ) ); layout->addWidget( label, 4, 0 ); acctNumEdit = new QLineEdit( container ); QWhatsThis::add( acctNumEdit, tr( "Enter account number for this checkbook here." ) ); layout->addWidget( acctNumEdit, 4, 1 ); // PIN number label = new QLabel( tr( "PIN number:" ), container ); QWhatsThis::add( label, tr( "Enter PIN number for this checkbook here." ) ); layout->addWidget( label, 5, 0 ); pinNumEdit = new QLineEdit( container ); QWhatsThis::add( pinNumEdit, tr( "Enter PIN number for this checkbook here." ) ); layout->addWidget( pinNumEdit, 5, 1 ); // Starting balance label = new QLabel( tr( "Starting balance:" ), container ); QWhatsThis::add( label, tr( "Enter the initial balance for this checkbook here." ) ); layout->addWidget( label, 6, 0 ); balanceEdit = new QLineEdit( container ); QWhatsThis::add( balanceEdit, tr( "Enter the initial balance for this checkbook here." ) ); connect( balanceEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( slotStartingBalanceChanged( const QString & ) ) ); layout->addWidget( balanceEdit, 6, 1 ); // Notes label = new QLabel( tr( "Notes:" ), container ); QWhatsThis::add( label, tr( "Enter any additional information for this checkbook here." ) ); layout->addWidget( label, 7, 0 ); notesEdit = new QMultiLineEdit( container ); QWhatsThis::add( notesEdit, tr( "Enter any additional information for this checkbook here." ) ); notesEdit->setMinimumHeight( 25 ); notesEdit->setMaximumHeight( 65 ); layout->addMultiCellWidget( notesEdit, 8, 8, 0, 1 ); return control; } + +// --- initTransactions ------------------------------------------------------- QWidget *Checkbook::initTransactions() { - QWidget *control = new QWidget( mainWidget ); + QWidget *control = new QWidget( mainWidget, tr("Transactions") ); QGridLayout *layout = new QGridLayout( control ); layout->setSpacing( 2 ); layout->setMargin( 4 ); - balanceLabel = new QLabel( tr( "Current balance: %10.00" ).arg( currencySymbol ), - control ); - QWhatsThis::add( balanceLabel, tr( "This area shows the current balance in this checkbook." ) ); - layout->addMultiCellWidget( balanceLabel, 0, 0, 0, 2 ); - - 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" ) ); //tranTable->addColumn( tr( "Cleared" ) ); tranTable->addColumn( tr( "Description" ) ); - int colnum = tranTable->addColumn( tr( "Amount" ) ); - tranTable->setColumnAlignment( colnum, Qt::AlignRight ); + int column = tranTable->addColumn( tr( "Amount" ) ); + tranTable->setColumnAlignment( column, Qt::AlignRight ); + column=tranTable->addColumn( tr("Balance") ); + tranTable->setColumnAlignment( column, Qt::AlignRight ); tranTable->setAllColumnsShowFocus( TRUE ); - tranTable->setSorting( 1 ); + tranTable->setSorting( -1 ); layout->addMultiCellWidget( tranTable, 1, 1, 0, 2 ); QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold ); connect( tranTable, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), this, SLOT( slotEditTran() ) ); + _sortCol=COL_ID; + // Buttons QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), control ); QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) ); connect( btn, SIGNAL( clicked() ), this, SLOT( slotNewTran() ) ); layout->addWidget( btn, 2, 0 ); btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), control ); QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) ); connect( btn, SIGNAL( clicked() ), this, SLOT( slotEditTran() ) ); layout->addWidget( btn, 2, 1 ); btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), control ); QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) ); connect( btn, SIGNAL( clicked() ), this, SLOT( slotDeleteTran() ) ); layout->addWidget( btn, 2, 2 ); return( control ); } + +// --- initCharts ------------------------------------------------------------- QWidget *Checkbook::initCharts() { graphInfo = 0x0; - QWidget *control = new QWidget( mainWidget ); + QWidget *control = new QWidget( mainWidget, tr("Charts") ); QGridLayout *layout = new QGridLayout( control ); layout->setSpacing( 2 ); layout->setMargin( 4 ); graphWidget = new Graph( control ); QWhatsThis::add( graphWidget, tr( "Select the desired chart below and then click on the Draw button." ) ); layout->addMultiCellWidget( graphWidget, 0, 0, 0, 2 ); graphList = new QComboBox( control ); QWhatsThis::add( graphList, tr( "Click here to select the desired chart type." ) ); graphList->insertItem( tr( "Account balance" ) ); graphList->insertItem( tr( "Withdrawals by category" ) ); graphList->insertItem( tr( "Deposits by category" ) ); layout->addMultiCellWidget( graphList, 1, 1, 0, 1 ); QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/drawbtn" ), tr( "Draw" ), control ); QWhatsThis::add( btn, tr( "Click here to draw the selected chart." ) ); connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) ); layout->addWidget( btn, 1, 2 ); return control; } +// --- loadCheckbook ---------------------------------------------------------- void Checkbook::loadCheckbook() { if ( !info ) { return; } tranList = info->transactions(); passwordCB->setChecked( !info->password().isNull() ); nameEdit->setText( info->name() ); QString temptext = info->type(); int i = typeList->count(); while ( i > 0 ) { i--; typeList->setCurrentItem( i ); if ( typeList->currentText() == temptext ) { break; } } + if( i<=0 ) { + typeList->insertItem( temptext, 0 ); + typeList->setCurrentItem(0); + } bankEdit->setText( info->bank() ); acctNumEdit->setText( info->account() ); pinNumEdit->setText( info->pin() ); temptext.setNum( info->startingBalance(), 'f', 2 ); balanceEdit->setText( temptext ); notesEdit->setText( info->notes() ); // Load transactions float amount; - QString stramount; - - for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() ) + QString stramount; + for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() ) { amount = tran->amount(); if ( tran->withdrawal() ) { amount *= -1; } - stramount.sprintf( "%s%.2f", currencySymbol.latin1(), amount ); - ( void ) new CBListItem( tranTable, tran->number(), tran->datestr(), tran->desc(), stramount ); + stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); + ( void ) new CBListItem( tran, tranTable, tran->getIdStr(), tran->number(), tran->datestr(), tran->desc(), stramount ); } - balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( info->balance(), 0, 'f', 2 ) ); - - 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() { info->setName( nameEdit->text() ); info->setType( typeList->currentText() ); info->setBank( bankEdit->text() ); info->setAccount( acctNumEdit->text() ); info->setPin( pinNumEdit->text() ); bool ok; info->setStartingBalance( balanceEdit->text().toFloat( &ok ) ); info->setNotes( notesEdit->text() ); QDialog::accept(); } void Checkbook::slotPasswordClicked() { if ( info->password().isNull() && passwordCB->isChecked() ) { Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); if ( pw->exec() != QDialog::Accepted ) { passwordCB->setChecked( FALSE ); delete pw; return; } info->setPassword( pw->password ); delete pw; pw = new Password( this, tr( "Confirm password" ), tr( "Please confirm your password:" ) ); if ( pw->exec() != QDialog::Accepted || pw->password != info->password() ) { passwordCB->setChecked( FALSE ); info->setPassword( QString::null ); } delete pw; } else if ( !info->password().isNull() && !passwordCB->isChecked() ) { Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password to confirm removal of password protection:" ) ); if ( pw->exec() == QDialog::Accepted && pw->password == info->password() ) { info->setPassword( QString::null ); delete pw; return; } else { passwordCB->setChecked( TRUE ); } delete pw; } } void Checkbook::slotNameChanged( const QString &newname ) { info->setName( newname ); // TODO - need filedir // QString namestr = filedir; // namestr.append( newname ); // namestr.append( ".qcb" ); // info->setFilename( namestr ); QString namestr = newname; namestr.append( " - " ); namestr.append( tr( "Checkbook" ) ); setCaption( namestr ); } + +// ---slotStartingBalanceChanged ---------------------------------------------- void Checkbook::slotStartingBalanceChanged( const QString &newbalance ) { bool ok; info->setStartingBalance( newbalance.toFloat( &ok ) ); adjustBalance(); } + void Checkbook::slotNewTran() { - highTranNum++; - TranInfo *traninfo = new TranInfo( highTranNum ); + TranInfo *traninfo = new TranInfo( info->getNextNumber() ); + if( !_dLastNew.isNull() ) + traninfo->setDate(_dLastNew); Transaction *currtran = new Transaction( this, info->name(), traninfo, - currencySymbol ); + _pCfg ); currtran->showMaximized(); if ( currtran->exec() == QDialog::Accepted ) { // Add to transaction list info->addTransaction( traninfo ); // Add to transaction table float amount; QString stramount; - - amount = traninfo->amount(); - if ( traninfo->withdrawal() ) - { - amount *= -1; - } - stramount.sprintf( "%s%.2f", currencySymbol.latin1(), amount ); - - ( void ) new CBListItem( tranTable, traninfo->number(), traninfo->datestr(), traninfo->desc(), - 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(); } else { - highTranNum--; delete traninfo; } } void Checkbook::slotEditTran() { QListViewItem *curritem = tranTable->currentItem(); if ( !curritem ) - { return; - } - - TranInfo *traninfo = info->findTransaction( curritem->text( 0 ), curritem->text( 1 ), - curritem->text( 2 ) ); + + TranInfo *traninfo=info->findTransaction( curritem->text(COL_ID) ); Transaction *currtran = new Transaction( this, info->name(), traninfo, - currencySymbol ); + _pCfg ); currtran->showMaximized(); if ( currtran->exec() == QDialog::Accepted ) { - curritem->setText( 0, traninfo->number() ); - curritem->setText( 1, traninfo->datestr() ); - curritem->setText( 2, traninfo->desc() ); + curritem->setText( COL_NUM, traninfo->number() ); + curritem->setText( COL_DATE, traninfo->datestr() ); + curritem->setText( COL_DESC, traninfo->desc() ); float amount = traninfo->amount(); if ( traninfo->withdrawal() ) { amount *= -1; } QString stramount; - stramount.sprintf( "%s%.2f", currencySymbol.latin1(), amount ); - curritem->setText( 3, stramount ); - - adjustBalance(); + stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); + curritem->setText( COL_AMOUNT, stramount ); + resort(); + adjustBalance(); } delete currtran; } void Checkbook::slotDeleteTran() { QListViewItem *curritem = tranTable->currentItem(); if ( !curritem ) - { return; - } - TranInfo *traninfo = findTran( curritem->text( 0 ), curritem->text( 1 ), curritem->text( 2 ) ); + TranInfo *traninfo = info->findTransaction( curritem->text(COL_ID) ); if ( QPEMessageBox::confirmDelete ( this, tr( "Delete transaction" ), traninfo->desc() ) ) { info->removeTransaction( traninfo ); delete curritem; - adjustBalance(); + adjustBalance(); } } void Checkbook::slotDrawGraph() { if ( graphInfo ) { delete graphInfo; } switch ( graphList->currentItem() ) { case 0 : drawBalanceChart(); break; case 1 : drawCategoryChart( TRUE ); break; case 2 : drawCategoryChart( FALSE ); break; }; graphWidget->setGraphInfo( graphInfo ); graphWidget->drawGraph( TRUE ); } void Checkbook::drawBalanceChart() { DataPointList *list = new DataPointList(); float balance = info->startingBalance(); float amount; QString label; int i = 0; int count = tranList->count(); for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() ) { i++; balance -= tran->fee(); amount = tran->amount(); if ( tran->withdrawal() ) { amount *= -1; } balance += amount; if ( i == 1 || i == count / 2 || i == count ) { label = tran->datestr(); } else { label = ""; } list->append( new DataPointInfo( label, balance ) ); } graphInfo = new GraphInfo( GraphInfo::BarChart, list ); } void Checkbook::drawCategoryChart( bool withdrawals ) { DataPointList *list = new DataPointList(); TranInfo *tran = tranList->first(); if ( tran && tran->withdrawal() == withdrawals ) { list->append( new DataPointInfo( tran->category(), tran->amount() ) ); } tran = tranList->next(); DataPointInfo *cat; for ( ; tran; tran = tranList->next() ) { if ( tran->withdrawal() == withdrawals ) { // Find category in list for ( cat = list->first(); cat; cat = list->next() ) { if ( cat->label() == tran->category() ) { break; } } if ( cat && cat->label() == tran->category() ) { // Found category, add to transaction to category total cat->addToValue( tran->amount() ); } else { // Didn't find category, add category to list list->append( new DataPointInfo( tran->category(), tran->amount() ) ); } } } graphInfo = new GraphInfo( GraphInfo::PieChart, list ); } -CBListItem::CBListItem( QListView *parent, QString label1, QString label2, +CBListItem::CBListItem( TranInfo *pTran, QListView *parent, QString label1, QString label2, QString label3, QString label4, QString label5, QString label6, QString label7, QString label8 ) : QListViewItem( parent, label1, label2, label3, label4, label5, label6, label7, label8 ) { + _pTran=pTran; m_known = FALSE; owner = parent; } void CBListItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align ) { QColorGroup _cg = cg; const QPixmap *pm = listView()->viewport()->backgroundPixmap(); if ( pm && !pm->isNull() ) { _cg.setBrush( QColorGroup::Base, QBrush( cg.base(), *pm ) ); p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); } else if ( isAltBackground() ) _cg.setColor(QColorGroup::Base, cg.background() ); QListViewItem::paintCell(p, _cg, column, width, align); } bool CBListItem::isAltBackground() { QListView *lv = static_cast<QListView *>( listView() ); if ( lv ) { CBListItem *above = 0; above = (CBListItem *)( itemAbove() ); m_known = above ? above->m_known : true; if ( m_known ) { m_odd = above ? !above->m_odd : false; } else { CBListItem *item; bool previous = true; if ( parent() ) { item = (CBListItem *)( parent() ); if ( item ) previous = item->m_odd; item = (CBListItem *)( parent()->firstChild() ); } else { item = (CBListItem *)( lv->firstChild() ); } while(item) { item->m_odd = previous = !previous; item->m_known = true; item = (CBListItem *)( item->nextSibling() ); } } return m_odd; } return false; } + + +// --- 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 @@ -1,126 +1,142 @@ /* This file is part of the OPIE Project =. .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This file is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General ..}^=.= = ; Public License for more details. ++= -. .` .: : = ...= . :.=- You should have received a copy of the GNU -. .:....=;==+<; General Public License along with this file; -_. . . )=. = see the file COPYING. If not, write to the -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef CHECKBOOK_H #define CHECKBOOK_H +#include <qdatetime.h> #include <qdialog.h> #include <qlistview.h> class OTabWidget; class CBInfo; class Graph; class GraphInfo; class QCheckBox; class QComboBox; class QLabel; class QLineEdit; class QListView; class QMultiLineEdit; class QString; class TranInfo; class TranInfoList; +class Cfg; + +// --- Checkbook -------------------------------------------------------------- class Checkbook : public QDialog { Q_OBJECT public: - Checkbook( QWidget * = 0x0, CBInfo * = 0x0, const QString & = "$" ); + Checkbook( QWidget *, CBInfo *, Cfg *cfg ); ~Checkbook(); + // resort + void resort(); + private: - CBInfo *info; + CBInfo *info; TranInfoList *tranList; - QString currencySymbol; - int highTranNum; + Cfg *_pCfg; OTabWidget *mainWidget; void loadCheckbook(); void adjustBalance(); - TranInfo *findTran( const QString &, const QString &, const QString & ); // Info tab QWidget *initInfo(); QCheckBox *passwordCB; QLineEdit *nameEdit; QComboBox *typeList; QLineEdit *bankEdit; QLineEdit *acctNumEdit; QLineEdit *pinNumEdit; QLineEdit *balanceEdit; QMultiLineEdit *notesEdit; + int _sortCol; // Transactions tab - QWidget *initTransactions(); + QWidget *initTransactions(); QListView *tranTable; - QLabel *balanceLabel; + QComboBox *_cbSortType; + QDate _dLastNew; // Charts tab QWidget *initCharts(); GraphInfo *graphInfo; QComboBox *graphList; Graph *graphWidget; void drawBalanceChart(); void drawCategoryChart( bool = TRUE ); + protected slots: void accept(); + void slotTab(QWidget *tab); private slots: void slotPasswordClicked(); void slotNameChanged( const QString & ); void slotStartingBalanceChanged( const QString & ); void slotNewTran(); void slotEditTran(); void slotDeleteTran(); void slotDrawGraph(); + void slotSortChanged( const QString & ); }; +// --- CBListItem ------------------------------------------------------------- class CBListItem : public QListViewItem { //Q_OBJECT public: - CBListItem( QListView *, QString = QString::null, QString = QString::null, + CBListItem( TranInfo *, QListView *, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null ); void paintCell( QPainter *, const QColorGroup &, int, int, int ); + // --- members + TranInfo *getTranInfo() { return(_pTran); } + private: + TranInfo *_pTran; QListView *owner; bool m_known; bool m_odd; bool isAltBackground(); }; + #endif diff --git a/noncore/apps/checkbook/checkbook.pro b/noncore/apps/checkbook/checkbook.pro index 9a16a56..c574aff 100644 --- a/noncore/apps/checkbook/checkbook.pro +++ b/noncore/apps/checkbook/checkbook.pro @@ -1,49 +1,53 @@ -TEMPLATE = app -CONFIG = qt warn_on release +CONFIG = qt warn_on release quick-app HEADERS = mainwindow.h \ cbinfo.h \ traninfo.h \ graphinfo.h \ configuration.h \ password.h \ checkbook.h \ transaction.h \ + tabledef.h \ + listedit.h \ + cfg.h \ graph.h SOURCES = main.cpp \ mainwindow.cpp \ cbinfo.cpp \ traninfo.cpp \ graphinfo.cpp \ configuration.cpp \ password.cpp \ checkbook.cpp \ - transaction.cpp \ + transaction.cpp \ + tabledef.cpp \ + listedit.cpp \ + cfg.cpp \ graph.cpp INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lopie TARGET = checkbook -DESTDIR = $(OPIEDIR)/bin TRANSLATIONS = ../../../i18n/de/checkbook.ts \ ../../../i18n/nl/checkbook.ts \ ../../../i18n/da/checkbook.ts \ ../../../i18n/xx/checkbook.ts \ ../../../i18n/en/checkbook.ts \ ../../../i18n/es/checkbook.ts \ ../../../i18n/fr/checkbook.ts \ ../../../i18n/hu/checkbook.ts \ ../../../i18n/ja/checkbook.ts \ ../../../i18n/ko/checkbook.ts \ ../../../i18n/no/checkbook.ts \ ../../../i18n/pl/checkbook.ts \ ../../../i18n/pt/checkbook.ts \ ../../../i18n/pt_BR/checkbook.ts \ ../../../i18n/sl/checkbook.ts \ ../../../i18n/zh_CN/checkbook.ts \ ../../../i18n/zh_TW/checkbook.ts \ ../../../i18n/it/checkbook.ts include ( $(OPIEDIR)/include.pro ) 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 @@ -1,74 +1,161 @@ /* 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 "configuration.h" +#include "mainwindow.h" +#include "listedit.h" +#include "tabledef.h" #include <qcheckbox.h> #include <qlabel.h> #include <qlayout.h> #include <qlineedit.h> #include <qwhatsthis.h> +#include <qlistview.h> +#include <qpushbutton.h> +#include <qtabwidget.h> +#include <qpe/resource.h> -Configuration::Configuration( QWidget *parent, const QString &cs, bool sl, bool sb ) +Configuration::Configuration( QWidget *parent, Cfg &cfg ) : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) { setCaption( tr( "Configure Checkbook" ) ); - 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 ); layout->setMargin( 4 ); - QLabel *label = new QLabel( tr( "Enter currency symbol:" ), this ); + QLabel *label = new QLabel( tr( "Enter currency symbol:" ), container ); QWhatsThis::add( label, tr( "Enter your local currency symbol here." ) ); label->setMaximumHeight( fh + 3 ); layout->addWidget( label, 0, 0 ); - symbolEdit = new QLineEdit( cs, this ); + symbolEdit = new QLineEdit( cfg.getCurrencySymbol(), container ); QWhatsThis::add( symbolEdit, tr( "Enter your local currency symbol here." ) ); symbolEdit->setMaximumHeight( fh + 5 ); symbolEdit->setFocus(); layout->addWidget( symbolEdit, 0, 1 ); - lockCB = new QCheckBox( tr( "Show whether checkbook is password\nprotected" ), this ); + lockCB = new QCheckBox( tr( "Show whether checkbook is password\nprotected" ), container ); QWhatsThis::add( lockCB, tr( "Click here to select whether or not the main window will display that the checkbook is protected with a password." ) ); - lockCB->setChecked( sl ); + lockCB->setChecked( cfg.getShowLocks() ); layout->addMultiCellWidget( lockCB, 1, 1, 0, 1 ); - balCB = new QCheckBox( tr( "Show checkbook balances" ), this ); + balCB = new QCheckBox( tr( "Show checkbook balances" ), container ); QWhatsThis::add( balCB, tr( "Click here to select whether or not the main window will display the current balance for each checkbook." ) ); balCB->setMaximumHeight( fh + 5 ); - balCB->setChecked( sb ); + balCB->setChecked( cfg.getShowBalances() ); layout->addMultiCellWidget( balCB, 2, 2, 0, 1 ); + + openLastBookCB = new QCheckBox( tr("Open last checkbook" ), container ); + QWhatsThis::add( openLastBookCB, tr("Click here to select whether the last open checkbook will be opened at startup.") ); + openLastBookCB->setMaximumHeight(fh+5); + openLastBookCB->setChecked( cfg.isOpenLastBook() ); + layout->addMultiCellWidget( openLastBookCB, 3, 3, 0, 1 ); + + lastTabCB = new QCheckBox( tr("Show last checkbook tab" ), container ); + QWhatsThis::add( lastTabCB, tr("Click here to select whether the last tab in a checkbook should be displayed.") ); + lastTabCB->setMaximumHeight(fh+5); + lastTabCB->setChecked( cfg.isShowLastTab() ); + layout->addMultiCellWidget( lastTabCB, 4, 4, 0, 1 ); + + return(control); } -Configuration::~Configuration() +// --- saveConfig ------------------------------------------------------------- +void Configuration::saveConfig(Cfg &cfg) { + // Settings + cfg.setCurrencySymbol( symbolEdit->text() ); + cfg.setShowLocks( lockCB->isChecked() ); + cfg.setShowBalances( balCB->isChecked() ); + cfg.setOpenLastBook( openLastBookCB->isChecked() ); + cfg.setShowLastTab( lastTabCB->isChecked() ); + + // Typelist + _listEditTypes->storeInList( cfg.getAccountTypes() ); + + // Category list + QStringList lst; + _listEditCategories->storeInList( lst ); + cfg.setCategories( lst ); } diff --git a/noncore/apps/checkbook/configuration.h b/noncore/apps/checkbook/configuration.h index 9a8de02..5893502 100644 --- a/noncore/apps/checkbook/configuration.h +++ b/noncore/apps/checkbook/configuration.h @@ -1,51 +1,67 @@ /* 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 CONFIGURATION_H #define CONFIGURATION_H #include <qdialog.h> +#include "cfg.h" class QCheckBox; class QLineEdit; class QString; +class QTabWidget; +class ListEdit; class Configuration : public QDialog { Q_OBJECT public: - Configuration( QWidget * = 0x0, const QString & = "$", bool = FALSE, bool = FALSE ); + // Constructor + Configuration( QWidget *, Cfg &cfg); ~Configuration(); QLineEdit *symbolEdit; QCheckBox *lockCB; QCheckBox *balCB; + QCheckBox *openLastBookCB; + QCheckBox *lastTabCB; + QTabWidget *_mainWidget; + ListEdit *_listEditTypes; + ListEdit *_listEditCategories; + + // saves settings in config struct + void saveConfig(Cfg &cfg); + + protected: + // creates settings tap from configuration + QWidget *initSettings(Cfg &cfg); }; #endif diff --git a/noncore/apps/checkbook/listedit.cpp b/noncore/apps/checkbook/listedit.cpp new file mode 100644 index 0000000..99a6531 --- a/dev/null +++ b/noncore/apps/checkbook/listedit.cpp @@ -0,0 +1,340 @@ +/* + This file is part of the OPIE Project + =. + .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ + +#include "listedit.h" +#include <qlayout.h> +#include <qlineedit.h> +#include <qlistview.h> +#include <qwidgetstack.h> +#include <qcombobox.h> +#include <qpushbutton.h> +#include <qpe/resource.h> + + +// --- ListEdit --------------------------------------------------------------- +ListEdit::ListEdit( QWidget *parent, const char *sName ) + : QWidget(parent, sName), TableDef(sName) +{ + // get font height + int fh = fontMetrics().height(); + + // create layout + QGridLayout *layout=new QGridLayout(this); + layout->setSpacing( 2 ); + layout->setMargin( 4 ); + + // type table + _typeTable = new QListView( this ); + ColumnDef *def=first(); + while( def ) { + _typeTable->addColumn( def->getName() ); + def=next(); + } + connect( _typeTable, SIGNAL( clicked(QListViewItem *, const QPoint &, int) ), this, SLOT( slotClick(QListViewItem *, const QPoint &, int ) ) ); + layout->addMultiCellWidget(_typeTable, 0,4,0,4); + _currentItem=NULL; + + // edit field + _stack=new QWidgetStack( this ); + _stack->setMaximumHeight(fh+5); + layout->addMultiCellWidget(_stack, 5,5,0,2); + _typeEdit = new QLineEdit( _stack ); + _stack->raiseWidget(_typeEdit ); + connect( _typeEdit, SIGNAL( textChanged(const QString &) ), this, SLOT( slotEditChanged(const QString &) ) ); + + // combo box + _box=new QComboBox( _stack ); + connect( _box, SIGNAL( activated(const QString &) ), this, SLOT( slotActivated(const QString &) ) ); + + + // add button + QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/add" ), tr( "Add" ), this ); + connect( btn, SIGNAL( clicked() ), this, SLOT( slotAdd() ) ); + layout->addWidget( btn, 5, 3 ); + + // delete button + btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), this ); + connect( btn, SIGNAL( clicked() ), this, SLOT( slotDel() ) ); + layout->addWidget( btn, 5, 4 ); +} + +// --- ~ListEdit -------------------------------------------------------------- +ListEdit::~ListEdit() +{ +} + + +// --- slotEditTypeChanged ---------------------------------------------------- +void ListEdit::slotEditChanged(const QString &str) +{ + if( !_currentItem || _currentColumn<0 ) return; + _currentItem->setText(_currentColumn, str); +} + +// --- slotAddType ------------------------------------------------------------ +void ListEdit::slotAdd() +{ + // construct new row + QString args[8]; + ColumnDef *pCol=this->first(); + int i=0; + while( pCol && i<8 ) { + args[i++]=pCol->getNewValue(); + pCol=this->next(); + } + _currentItem=new QListViewItem(_typeTable, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7] ); + + // fix uniques + fixTypes(); + + // display col 0 of new value + QPoint pnt; + slotClick(_currentItem, pnt, 0); + _typeTable->setSelected( _currentItem, true ); +} + +// --- slotDel ------------------------------------------------------------- +void ListEdit::slotDel() +{ + if( !_currentItem ) return; + delete _currentItem; + _currentItem=NULL; + _typeEdit->setText(""); + _stack->raiseWidget(_typeEdit); +} + + +// --- fixTypes ---------------------------------------------------------------- +// Makes sure all entries have a unique name and empty entries are replaced +// by a generic string. The first version performs the operation on a particular +// column, whereas the 2nd does it for all unique columns. +class ColMap { + public: + ColMap(QString sValue, QListViewItem *pEntry) { + _sValue=sValue; + _pEntry=pEntry; + } + QString &getValue() { return(_sValue); } + QListViewItem *getItem() { return(_pEntry); } + + protected: + QString _sValue; + QListViewItem *_pEntry; +}; + +class ColList : public QList<QString> +{ + public: + ColList() : QList<QString>() { } + + protected: + int compareItems(QCollection::Item, QCollection::Item); +}; + +int ColList::compareItems(QCollection::Item i1, QCollection::Item i2) { + return( ((QString *)i1)->compare(*(QString *)i2) ); +} + +void ListEdit::fixTypes(int iColumn) +{ + // get column def + ColumnDef *pDef=this->at(iColumn); + + // create map of entries + if( !_typeTable->childCount() ) return; + ColMap **colMap=new (ColMap *)[_typeTable->childCount()]; + QListViewItem *cur=_typeTable->firstChild(); + ColList lst; + for(int i=0; i<_typeTable->childCount(); i++) { + colMap[i]=new ColMap(cur->text(iColumn), cur); + lst.append( &(colMap[i]->getValue()) ); + cur=cur->nextSibling(); + } + + // fix empty entries + int i=0; + for(QString *ptr=lst.first(); ptr; ptr=lst.next()) { + *ptr=ptr->stripWhiteSpace(); + if( ptr->isEmpty() ) { + i++; + if( i==1 ) *ptr=pDef->getNewValue(); + else ptr->sprintf("%s %d", (const char *)pDef->getNewValue(), i); + } + } + + // fix dups + lst.sort(); + QString repl; + for(uint iCur=0; iCur<lst.count()-1; iCur++) { + QString *current=lst.at(iCur); + for(uint iNext=iCur+1; iNext<lst.count(); iNext++ ) { + if( *current!=*lst.at(iNext) ) continue; + for(int i=2; ; i++) { + repl.sprintf("%s %d", (const char *)*current, i); + bool bDup=false; + uint iChk=iNext+1; + while( iChk<lst.count() ) { + QString *chk=lst.at(iChk); + if( !chk->startsWith(*current) ) break; + if( *chk==repl ) { + bDup=true; + break; + } + iChk++; + } + if( !bDup ) { + *lst.at(iNext)=repl; + break; + } + } + } + } + lst.sort(); + + // copy back clean up col map + for(int i=0; i<_typeTable->childCount(); i++) { + colMap[i]->getItem()->setText(iColumn, colMap[i]->getValue()); + delete colMap[i]; + } + delete colMap; +} + +void ListEdit::fixTypes() +{ + int i; + ColumnDef *pDef; + for(pDef=this->first(), i=0; pDef; pDef=this->next(), i++) { + if( pDef->hasFlag(ColumnDef::typeUnique) ) + fixTypes(i); + } + _typeTable->sort(); +} + + +// --- storeInList ------------------------------------------------------------ +void ListEdit::storeInList(QStringList &lst) +{ + // delete old content + lst.clear(); + + // add new one + fixTypes(); + QListViewItem *itm=_typeTable->firstChild(); + while( itm ) { + int i=0; + QString sAdd; + ColumnDef *pDef; + for(pDef=this->first(), i=0; pDef; pDef=this->next(), i++) { + if( i>=1 ) sAdd+=";"; + sAdd += itm->text(i); + } + lst.append( sAdd ); + itm=itm->nextSibling(); + } +} + + +// --- slotClicked ------------------------------------------------------------ +void ListEdit::slotClick(QListViewItem *itm, const QPoint &pnt, int col) +{ + (void)pnt; // get rid of unused warning; + + // save values + _currentItem=itm; + _currentColumn=col; + if( itm==NULL ) { + _typeEdit->setText(""); + _stack->raiseWidget(_typeEdit); + return; + } + + // display value + if( _currentColumn<0 ) _currentColumn=0; + ColumnDef *pDef=this->at(_currentColumn); + if( pDef->isType(ColumnDef::typeString) ) { + _typeEdit->setText( _currentItem->text(_currentColumn) ); + _stack->raiseWidget(_typeEdit); + } else if( pDef->isType(ColumnDef::typeList) ){ + _box->clear(); + _box->insertStringList( pDef->getValueList() ); + QStringList::Iterator itr; + int i=0; + for(itr=pDef->getValueList().begin(); itr!=pDef->getValueList().end(); itr++) { + if( (*itr)==_currentItem->text(_currentColumn) ) { + _box->setCurrentItem(i); + i=-1; + break; + } + i++; + } + if( i>=0 ) { + _box->insertItem( _currentItem->text(_currentColumn) ); + _box->setCurrentItem(i); + } + _stack->raiseWidget(_box); + } else { + qDebug( "Unsupported column type for column %s", (const char *)pDef->getName() ); + _typeEdit->setText(""); + _stack->raiseWidget(_typeEdit); + } +} + + +// --- addColumnDef ----------------------------------------------------------- +void ListEdit::addColumnDef(ColumnDef *pDef) +{ + _typeTable->addColumn( pDef->getName() ); + _vColumns.append(pDef); +} + +// --- addData ---------------------------------------------------------------- +void ListEdit::addData(QStringList &lst) +{ + // run through list + QStringList::Iterator itr; + for(itr=lst.begin(); itr!=lst.end(); itr++) { + QStringList split=QStringList::split(";", *itr, true); + QStringList::Iterator entry; + QString args[8]; + int i=0; + for(entry=split.begin(); entry!=split.end() && i<8; entry++, i++) { + args[i]= (*entry); + } + while(i<8) { + args[i++]=""; + } + new QListViewItem(_typeTable, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]); + } +} + +// --- slotActivated ---------------------------------------------------------- +void ListEdit::slotActivated(const QString &str) +{ + if( _currentItem==NULL || _currentColumn<0 ) return; + _currentItem->setText(_currentColumn, str); +} diff --git a/noncore/apps/checkbook/listedit.h b/noncore/apps/checkbook/listedit.h new file mode 100644 index 0000000..d2135ea --- a/dev/null +++ b/noncore/apps/checkbook/listedit.h @@ -0,0 +1,78 @@ +/* + This file is part of the OPIE Project + =. + .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ + +#ifndef LISTEDIT_H +#define LISTEDIT_H + +#include <qwidget.h> +#include "tabledef.h" +class QListView; +class QLineEdit; +class QListViewItem; +class QPoint; +class QWidgetStack; +class QComboBox; + +class ListEdit : public QWidget, public TableDef +{ + Q_OBJECT + + public: + ListEdit( QWidget *, const char *sName); + virtual ~ListEdit(); + + QListView *_typeTable; + QLineEdit *_typeEdit; + QWidgetStack *_stack; + QComboBox *_box; + QListViewItem *_currentItem; + int _currentColumn; + + // resolves dups and empty entries + void fixTypes(); + void fixTypes(int iColumn); + + // stores content in string list + void storeInList(QStringList &lst); + + // adds a column definition + virtual void addColumnDef(ColumnDef *pDef); + + // adds data to table + void addData(QStringList &lst); + + + public slots: + void slotClick(QListViewItem *, const QPoint &pnt, int col); + void slotEditChanged(const QString &); + void slotAdd(); + void slotDel(); + void slotActivated(const QString &); +}; + +#endif diff --git a/noncore/apps/checkbook/main.cpp b/noncore/apps/checkbook/main.cpp index abfa633..dcaab4a 100644 --- a/noncore/apps/checkbook/main.cpp +++ b/noncore/apps/checkbook/main.cpp @@ -1,42 +1,34 @@ /* This file is part of the OPIE Project =. .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This file is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General ..}^=.= = ; Public License for more details. ++= -. .` .: : = ...= . :.=- You should have received a copy of the GNU -. .:....=;==+<; General Public License along with this file; -_. . . )=. = see the file COPYING. If not, write to the -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "mainwindow.h" - #include <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 @@ -1,335 +1,360 @@ /* This file is part of the OPIE Project =. .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This file is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General ..}^=.= = ; Public License for more details. ++= -. .` .: : = ...= . :.=- You should have received a copy of the GNU -. .:....=;==+<; General Public License along with this file; -_. . . )=. = see the file COPYING. If not, write to the -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "mainwindow.h" #include "cbinfo.h" #include "configuration.h" #include "password.h" #include "checkbook.h" +#include "listedit.h" #include <qpe/config.h> #include <qpe/global.h> #include <qpe/qpeapplication.h> #include <qpe/qpemenubar.h> #include <qpe/qpemessagebox.h> #include <qpe/qpetoolbar.h> #include <qpe/resource.h> #include <qaction.h> #include <qcheckbox.h> #include <qdir.h> #include <qlineedit.h> #include <qwhatsthis.h> -MainWindow::MainWindow() - : QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) + +MainWindow::MainWindow( QWidget* parent, const char* name, WFlags fl ) + : QMainWindow( parent, name, fl || WStyle_ContextHelp ) { setCaption( tr( "Checkbook" ) ); cbDir = Global::applicationFileName( "checkbook", "" ); lockIcon = Resource::loadPixmap( "locked" ); // Load configuration options Config config( "checkbook" ); - config.setGroup( "Config" ); - currencySymbol = config.readEntry( "CurrencySymbol", "$" ); - showLocks = config.readBoolEntry( "ShowLocks", FALSE ); - showBalances = config.readBoolEntry( "ShowBalances", FALSE ); +qDebug( "Reading config" ); + _cfg.readConfig( config ); + // Build menu and tool bars setToolBarsMovable( FALSE ); QPEToolBar *bar = new QPEToolBar( this ); bar->setHorizontalStretchable( TRUE ); QPEMenuBar *mb = new QPEMenuBar( bar ); mb->setMargin( 0 ); QPopupMenu *popup = new QPopupMenu( this ); bar = new QPEToolBar( this ); QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); a->setWhatsThis( tr( "Click here to create a new checkbook.\n\nYou also can select New from the Checkbook menu." ) ); connect( a, SIGNAL( activated() ), this, SLOT( slotNew() ) ); a->addTo( popup ); a->addTo( bar ); actionOpen = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, 0, this, 0 ); actionOpen->setWhatsThis( tr( "Select a checkbook and then click here to edit it.\n\nYou also can select Edit from the Checkbook menu, or click and hold on a checkbook name." ) ); connect( actionOpen, SIGNAL( activated() ), this, SLOT( slotEdit() ) ); actionOpen->addTo( popup ); actionOpen->addTo( bar ); actionDelete = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); actionDelete->setWhatsThis( tr( "Select a checkbook and then click here delete it.\n\nYou also can select Delete from the Checkbook menu." ) ); connect( actionDelete, SIGNAL( activated() ), this, SLOT( slotDelete() ) ); actionDelete->addTo( popup ); actionDelete->addTo( bar ); popup->insertSeparator(); a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); a->setWhatsThis( tr( "Click here to configure this app." ) ); connect( a, SIGNAL( activated() ), this, SLOT( slotConfigure() ) ); a->addTo( popup ); a->addTo( bar ); mb->insertItem( tr( "Checkbook" ), popup ); // Load Checkbook selection list checkbooks = new CBInfoList(); QDir checkdir( cbDir ); if (checkdir.exists() == true) { QStringList cblist = checkdir.entryList( "*.qcb", QDir::Files|QDir::Readable|QDir::Writable, QDir::Time ); CBInfo *cb = 0x0; QString filename; for ( QStringList::Iterator it = cblist.begin(); it != cblist.end(); it++ ) { filename = cbDir; filename.append( (*it) ); cb = new CBInfo( (*it).remove( (*it).find('.'), (*it).length() ), filename ); checkbooks->inSort( cb ); } } // Build Checkbook selection list control cbList = 0x0; buildList(); + + // open last book? + if( _cfg.isOpenLastBook() ) { + this->show(); + this->showMaximized(); + QListViewItem *itm=cbList->firstChild(); + while( itm ) { + if( itm->text(posName)==_cfg.getLastBook() ) { + openBook( itm ); + break; + } + itm=itm->nextSibling(); + } + } } + +// --- ~MainWindow ------------------------------------------------------------ MainWindow::~MainWindow() { -// config.write(); + writeConfig(); } + +// --- buildList -------------------------------------------------------------- void MainWindow::buildList() { if ( cbList ) - { - delete cbList; - } + delete cbList; cbList = new QListView( this ); QWhatsThis::add( cbList, tr( "This is a listing of all checkbooks currently available." ) ); - if ( showLocks ) + if ( _cfg.getShowLocks() ) { cbList->addColumn( Resource::loadIconSet( "locked" ), "", 24 ); posName = 1; } else { posName = 0; } cbList->addColumn( tr( "Checkbook Name" ) ); - if ( showBalances ) + if ( _cfg.getShowBalances() ) { int colnum = cbList->addColumn( tr( "Balance" ) ); cbList->setColumnAlignment( colnum, Qt::AlignRight ); } cbList->setAllColumnsShowFocus( TRUE ); cbList->setSorting( posName ); QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold ); connect( cbList, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), this, SLOT( slotEdit() ) ); setCentralWidget( cbList ); for ( CBInfo *cb = checkbooks->first(); cb; cb = checkbooks->next() ) { addCheckbook( cb ); } } void MainWindow::addCheckbook( CBInfo *cb ) { QListViewItem *lvi = new QListViewItem( cbList ); - if ( showLocks && !cb->password().isNull() ) + if ( _cfg.getShowLocks() && !cb->password().isNull() ) { lvi->setPixmap( 0, lockIcon ); } lvi->setText( posName, cb->name() ); - if ( showBalances ) + if ( _cfg.getShowBalances() ) { QString balance; - balance.sprintf( "%s%.2f", currencySymbol.latin1(), cb->balance() ); + balance.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() ); lvi->setText( posName + 1, balance ); } } void MainWindow::buildFilename( const QString &name ) { tempFilename = cbDir; tempFilename.append( name ); tempFilename.append( ".qcb" ); } void MainWindow::slotNew() { CBInfo *cb = new CBInfo(); - Checkbook *currcb = new Checkbook( this, cb, currencySymbol ); + Checkbook *currcb = new Checkbook( this, cb, &_cfg ); currcb->showMaximized(); if ( currcb->exec() == QDialog::Accepted ) { // Save new checkbook buildFilename( cb->name() ); + _cfg.setLastBook( cb->name() ); cb->setFilename( tempFilename ); cb->write(); // Add to listbox checkbooks->inSort( cb ); addCheckbook( cb ); } delete currcb; } +// --- 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 ) break; cb = checkbooks->next(); } - if ( !cb ) - { - return; - } + if ( !cb ) return; + // buildFilename( currname ); float currbalance = cb->balance(); bool currlock = !cb->password().isNull(); if ( currlock ) { Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); if ( pw->exec() != QDialog::Accepted || pw->password != cb->password() ) { delete pw; return; } delete pw; } - Checkbook *currcb = new Checkbook( this, cb, currencySymbol ); + _cfg.setLastBook( currname ); + Checkbook *currcb = new Checkbook( this, cb, &_cfg ); currcb->showMaximized(); if ( currcb->exec() == QDialog::Accepted ) { QString newname = cb->name(); if ( currname != newname ) { // Update name if changed - curritem->setText( posName, newname ); - cbList->sort(); + if( curritem ) { + curritem->setText( posName, newname ); + cbList->sort(); + } + _cfg.setLastBook( newname ); // Remove old file QFile f( tempFilename ); if ( f.exists() ) - { f.remove(); - } // Get new filename buildFilename( newname ); cb->setFilename( tempFilename ); } cb->write(); // Update lock if changed - if ( showLocks && !cb->password().isNull() != currlock ) + if ( _cfg.getShowLocks() && !cb->password().isNull() != currlock ) { if ( !cb->password().isNull() ) curritem->setPixmap( 0, lockIcon ); else curritem->setPixmap( 0, nullIcon ); } // Update balance if changed - if ( showBalances && cb->balance() != currbalance ) + if ( _cfg.getShowBalances() && cb->balance() != currbalance ) { QString tempstr; - tempstr.sprintf( "%s%.2f", currencySymbol.latin1(), cb->balance() ); + tempstr.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() ); curritem->setText( posName + 1, tempstr ); } } delete currcb; } +// --- slotDelete ------------------------------------------------------------- void MainWindow::slotDelete() { QString currname = cbList->currentItem()->text( posName ); if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), currname ) ) { buildFilename( currname ); QFile f( tempFilename ); if ( f.exists() ) { f.remove(); } delete cbList->currentItem(); } } +// --- slotConfigure ---------------------------------------------------------- void MainWindow::slotConfigure() { - Configuration *cfgdlg = new Configuration( this, currencySymbol, showLocks, showBalances ); + Configuration *cfgdlg = new Configuration( this, _cfg ); cfgdlg->showMaximized(); if ( cfgdlg->exec() == QDialog::Accepted ) { - currencySymbol = cfgdlg->symbolEdit->text(); - showLocks = cfgdlg->lockCB->isChecked(); - showBalances = cfgdlg->balCB->isChecked(); - - Config config( "checkbook" ); - config.setGroup( "Config" ); - config.writeEntry( "CurrencySymbol", currencySymbol ); - config.writeEntry( "ShowLocks", showLocks ); - config.writeEntry( "ShowBalances", showBalances ); - config.write(); - + // read data from config dialog & save it + cfgdlg->saveConfig( _cfg ); + writeConfig(); buildList(); } delete cfgdlg; } + + +// --- writeConfig -------------------------------------------------------------- +void MainWindow::writeConfig() +{ + Config config("checkbook"); + _cfg.writeConfig( config ); +} diff --git a/noncore/apps/checkbook/mainwindow.h b/noncore/apps/checkbook/mainwindow.h index 2bc70b3..6275f94 100644 --- a/noncore/apps/checkbook/mainwindow.h +++ b/noncore/apps/checkbook/mainwindow.h @@ -1,76 +1,83 @@ /* This file is part of the OPIE Project =. .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This file is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General ..}^=.= = ; Public License for more details. ++= -. .` .: : = ...= . :.=- You should have received a copy of the GNU -. .:....=;==+<; General Public License along with this file; -_. . . )=. = see the file COPYING. If not, write to the -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <qmainwindow.h> #include <qpixmap.h> +#include "cfg.h" class CBInfo; class CBInfoList; class QAction; class QListView; class QString; +class QListViewItem; class MainWindow : public QMainWindow { Q_OBJECT public: - MainWindow(); + MainWindow(QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~MainWindow(); + static QString appName() { return QString::fromLatin1("checkbook"); }; + + // safe config + void writeConfig(); + + // open a check book + void openBook(QListViewItem *curr); private: QListView *cbList; QString cbDir; QAction *actionOpen; QAction *actionDelete; - QString currencySymbol; - bool showLocks; - bool showBalances; + Cfg _cfg; int posName; CBInfoList *checkbooks; QString tempFilename; QPixmap lockIcon; QPixmap nullIcon; void buildList(); void addCheckbook( CBInfo * ); void buildFilename( const QString & ); private slots: void slotNew(); void slotEdit(); void slotDelete(); void slotConfigure(); }; #endif 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 @@ -1,190 +1,212 @@ /* 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 "traninfo.h" #include <qpe/config.h> QString tempstr; TranInfo::TranInfo( int id, const QString &desc, const QDate &date, bool withdrawal, const QString &type, const QString &category, float amount, - float fee, const QString &number, const QString ¬es ) + float fee, const QString &number, const QString ¬es, int next ) { i = id; d = desc; td = date; w = withdrawal; t = type; c = category; a = amount; f = fee; cn = number; n = notes; + _next=next; } TranInfo::TranInfo( Config config, int entry ) { config.setGroup( QString::number( entry ) ); QString desc = config.readEntry( "Description", "Not Found" ); if ( desc != "Not Found" ) { // ID i = entry; // Description d = desc; // Transaction date int yr, mn, dy; QString datestr = config.readEntry( "Date", "" ); int begin, end; begin = datestr.find( '/' ); mn = datestr.left( begin ).toInt(); end = datestr.find( '/', ++begin ); dy = datestr.mid( begin, end - begin ).toInt(); yr = datestr.right( datestr.length() - end - 1).toInt(); td.setYMD( yr, mn, dy ); // Deposit/withdrawal indicator ( withdrawal == TRUE ) w = ( config.readEntry( "Payment", "false" ) == "true" ); // Type QString type = config.readEntry( "Type", "0" ); if ( w ) { // Withdrawal types if( type == "0" ) t = "Debit Charge"; else if( type == "1" ) t = "Written Check"; else if( type == "2" ) t = "Transfer"; else if( type == "3" ) t = "Credit Card"; } else { if( type == "0" ) t = "Written Check"; else if( type == "1" ) t = "Automatic Payment"; else if( type == "2" ) t = "Transfer"; else if( type == "3" ) t = "Cash"; } // Category c = config.readEntry( "Category", "" ); // Transaction amount QString stramount = config.readEntry( "Amount", "0.00" ); bool ok; a = stramount.toFloat( &ok ); // Transaction fee stramount = config.readEntry( "TransactionFee", "0.00" ); f = stramount.toFloat( &ok ); - // Transaction number + // Transaction number cn = config.readEntry( "CheckNumber", "" ); // Notes n = config.readEntry( "Comments", "" ); + + // next + _next = config.readNumEntry("Next", -1); } } +// --- datestr ---------------------------------------------------------------- const QString &TranInfo::datestr() { - tempstr = QString::number( td.year() ); - tempstr.append( '/' ); - int tempfield = td.month(); - if ( tempfield < 10 ) tempstr.append( '0' ); - tempstr.append( QString::number( tempfield ) ); - tempstr.append( '/' ); - tempfield = td.day(); - if ( tempfield < 10 ) tempstr.append( '0' ); - tempstr.append( QString::number( tempfield ) ); + int y=td.year(); + y= y>=2000 && y<=2099 ? y-2000 : y; + tempstr.sprintf( "%02d/%02d/%02d", y ,td.month(), td.day() ); + return( tempstr ); +} - return( tempstr ); +// --- getIdStr --------------------------------------------------------------- +const QString &TranInfo::getIdStr() +{ + tempstr.sprintf("%04d", i); + return( tempstr ); } -void TranInfo::write( Config *config, int entry ) +// --- write ------------------------------------------------------------------ +void TranInfo::write( Config *config ) { - config->setGroup( QString::number( entry ) ); + config->setGroup( QString::number( id() ) ); config->writeEntry( "Description", d ); tempstr = QString::number( td.month() ); tempstr.append( '/' ); tempstr.append( QString::number( td.day() ) ); tempstr.append( '/' ); tempstr.append( QString::number( td.year() ) ); config->writeEntry( "Date", tempstr ); w ? tempstr = "true" : tempstr = "false"; config->writeEntry( "Payment", tempstr ); if ( t == "Debit Charge" || t == "Written Check" ) tempstr = "0"; else if ( t == "Written Check" || t == "Automatic Payment" ) tempstr = "1"; else if ( t == "Transfer" ) tempstr = "2"; else if ( t == "Credit Card" || t == "Cash" ) tempstr = "3"; config->writeEntry( "Type", tempstr ); config->writeEntry( "Category", c ); tempstr.setNum( a, 'f', 2 ); config->writeEntry( "Amount", tempstr ); tempstr.setNum( f, 'f', 2 ); config->writeEntry( "TransactionFee", tempstr ); - config->writeEntry( "CheckNumber", cn ); - + config->writeEntry( "CheckNumber", cn ); config->writeEntry( "Comments", n ); + config->writeEntry( "Next", _next ); } + int TranInfoList::compareItems( QCollection::Item item1, QCollection::Item item2 ) { QDate d1 = ((TranInfo *)item1)->date(); QDate d2 = ((TranInfo *)item2)->date(); int r = -1; if ( d1 < d2 ) r = -1; else if ( d1 == d2 ) r = 0; else if ( d1 > d2 ) r = 1; return( r ); } + +// --- toString --------------------------------------------------------------- +QString TranInfo::toString() +{ + QString ret; + ret.sprintf("(%4d) %10s %4s %-10s %5.2f %5.2f", + id(), + (const char *)datestr(), + (const char *)number(), + (const char *)desc(), + (withdrawal() ? -1 : 1) * amount(), + fee() + ); + return(ret); +} diff --git a/noncore/apps/checkbook/traninfo.h b/noncore/apps/checkbook/traninfo.h index f6c5cae..0abdc61 100644 --- a/noncore/apps/checkbook/traninfo.h +++ b/noncore/apps/checkbook/traninfo.h @@ -1,89 +1,100 @@ /* 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 TRANINFO_H #define TRANINFO_H #include <qdatetime.h> #include <qlist.h> class Config; class TranInfo { public: TranInfo( int = 0, const QString & = 0x0, const QDate & = QDate::currentDate(), bool = TRUE, const QString & = 0x0, const QString & = 0x0, float = 0.0, float = 0.0, - const QString & = 0x0, const QString & = 0x0 ); + const QString & = 0x0, const QString & = 0x0, int =-1 ); TranInfo( Config, int ); + // getters int id() const { return i; } + const QString &getIdStr(); + const QString &desc() const { return d; } const QDate &date() const { return td; } const QString &datestr(); bool withdrawal() const { return w; } const QString &type() const { return t; } const QString &category() const { return c; } float amount() const { return a; } float fee() const { return f; } const QString &number() const { return cn; } const QString ¬es() const { return n; } + 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; } void setWithdrawal( bool withdrawal ) { w = withdrawal; } void setType( const QString &type ) { t = type; } void setCategory( const QString &cat ) { c = cat; } void setAmount( float amount ) { a = amount; } void setFee( float fee ) { f = fee; } void setNumber( const QString &num ) { cn = num; } void setNotes( const QString ¬es ) { n = notes; } + void setNext(int next) { _next=next; } + + // write + void write( Config * ); - void write( Config *, int ); + // toString + QString toString(); private: int i; QString d; QDate td; bool w; QString t; QString c; float a; float f; QString cn; QString n; + int _next; }; class TranInfoList : public QList<TranInfo> { protected: int compareItems( QCollection::Item, QCollection::Item ); }; #endif 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 @@ -1,274 +1,270 @@ /* This file is part of the OPIE Project =. .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This file is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General ..}^=.= = ; Public License for more details. ++= -. .` .: : = ...= . :.=- You should have received a copy of the GNU -. .:....=;==+<; General Public License along with this file; -_. . . )=. = see the file COPYING. If not, write to the -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "transaction.h" #include "traninfo.h" +#include "cfg.h" #include <qpe/datebookmonth.h> #include <qbuttongroup.h> #include <qcombobox.h> #include <qlabel.h> #include <qlayout.h> #include <qlineedit.h> #include <qmultilineedit.h> #include <qradiobutton.h> #include <qwhatsthis.h> Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *info, - const QString &symbol ) + Cfg *pCfg ) : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) { QString tempstr = tr( "Transaction for " ); tempstr.append( acctname ); setCaption( tempstr ); tran = info; - currencySymbol = symbol; + _pCfg=pCfg; QVBoxLayout *vb = new QVBoxLayout( this ); QScrollView *sv = new QScrollView( this ); vb->addWidget( sv, 0, 0 ); sv->setResizePolicy( QScrollView::AutoOneFit ); sv->setFrameStyle( QFrame::NoFrame ); QWidget *container = new QWidget( sv->viewport() ); sv->addChild( container ); QGridLayout *layout = new QGridLayout( container ); layout->setSpacing( 2 ); layout->setMargin( 4 ); // Withdrawal/Deposit QButtonGroup *btngrp = new QButtonGroup( container ); btngrp->setColumnLayout(0, Qt::Vertical ); btngrp->layout()->setSpacing( 0 ); btngrp->layout()->setMargin( 0 ); btngrp->setMaximumWidth( 220 ); QGridLayout *layout2 = new QGridLayout( btngrp->layout() ); layout2->setSpacing( 2 ); layout2->setMargin( 2 ); withBtn = new QRadioButton( tr( "Withdrawal" ), btngrp ); QWhatsThis::add( withBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) ); layout2->addWidget( withBtn, 0, 0 ); connect( withBtn, SIGNAL( clicked() ), this, SLOT( slotWithdrawalClicked() ) ); depBtn = new QRadioButton( tr( "Deposit" ), btngrp ); QWhatsThis::add( depBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) ); layout2->addWidget( depBtn, 0, 1 ); btngrp->setMaximumSize( 320, withBtn->height() ); connect( depBtn, SIGNAL( clicked() ), this, SLOT( slotDepositClicked() ) ); layout->addMultiCellWidget( btngrp, 0, 0, 0, 3 ); // Date QLabel *label = new QLabel( tr( "Date:" ), container ); QWhatsThis::add( label, tr( "Select date of transaction here." ) ); layout->addWidget( label, 1, 0 ); dateBtn = new QPushButton( TimeString::shortDate( QDate::currentDate() ), container ); QWhatsThis::add( dateBtn, tr( "Select date of transaction here." ) ); QPopupMenu *m1 = new QPopupMenu( container ); datePicker = new DateBookMonth( m1, 0, TRUE ); m1->insertItem( datePicker ); dateBtn->setPopup( m1 ); connect( datePicker, SIGNAL( dateClicked( int, int, int ) ), this, SLOT( slotDateChanged( int, int, int ) ) ); layout->addWidget( dateBtn, 1, 1 ); // Check number label = new QLabel( tr( "Number:" ), container ); QWhatsThis::add( label, tr( "Enter check number here." ) ); layout->addWidget( label, 1, 2 ); numEdit = new QLineEdit( container ); QWhatsThis::add( numEdit, tr( "Enter check number here." ) ); numEdit->setMaximumWidth( 40 ); layout->addWidget( numEdit, 1, 3 ); // Description label = new QLabel( tr( "Description:" ), container ); QWhatsThis::add( label, tr( "Enter description of transaction here." ) ); layout->addWidget( label, 2, 0 ); descEdit = new QLineEdit( container ); QWhatsThis::add( descEdit, tr( "Enter description of transaction here." ) ); layout->addMultiCellWidget( descEdit, 2, 2, 1, 3 ); // Category label = new QLabel( tr( "Category:" ), container ); QWhatsThis::add( label, tr( "Select transaction category here." ) ); layout->addWidget( label, 3, 0 ); catList = new QComboBox( container ); QWhatsThis::add( catList, tr( "Select transaction category here." ) ); layout->addMultiCellWidget( catList, 3, 3, 1, 3 ); // Type label = new QLabel( tr( "Type:" ), container ); QWhatsThis::add( label, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) ); layout->addWidget( label, 4, 0 ); typeList = new QComboBox( container ); QWhatsThis::add( typeList, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) ); layout->addMultiCellWidget( typeList, 4, 4, 1, 3 ); // Amount label = new QLabel( tr( "Amount:" ), container ); QWhatsThis::add( label, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) ); layout->addWidget( label, 5, 0 ); amtEdit = new QLineEdit( container ); QWhatsThis::add( amtEdit, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) ); layout->addMultiCellWidget( amtEdit, 5, 5, 1, 3 ); // Fee label = new QLabel( tr( "Fee:" ), container ); QWhatsThis::add( label, tr( "Enter any fee amount assoiciated with this transaction.\n\nThe value entered should always be positive." ) ); layout->addWidget( label, 6, 0 ); feeEdit = new QLineEdit( container ); QWhatsThis::add( feeEdit, tr( "Enter any fee amount assoiciated with this transaction.\n\nThe value entered should always be positive." ) ); layout->addMultiCellWidget( feeEdit, 6, 6, 1, 3 ); // Notes label = new QLabel( tr( "Notes:" ), container ); QWhatsThis::add( label, tr( "Enter any additional information for this transaction here." ) ); layout->addWidget( label, 7, 0 ); noteEdit = new QMultiLineEdit( container ); QWhatsThis::add( noteEdit, tr( "Enter any additional information for this transaction here." ) ); layout->addMultiCellWidget( noteEdit, 8, 8, 0, 3 ); // Populate current values if provided if ( info ) { if ( info->withdrawal() ) { withBtn->setChecked( TRUE ); slotWithdrawalClicked(); } else { depBtn->setChecked( TRUE ); slotDepositClicked(); } QDate dt = info->date(); slotDateChanged( dt.year(), dt.month(), dt.day() ); datePicker->setDate( dt ); numEdit->setText( info->number() ); descEdit->setText( info->desc() ); QString temptext = info->category(); int i = catList->count(); while ( i > 0 ) { i--; catList->setCurrentItem( i ); if ( catList->currentText() == temptext ) { break; } } temptext = info->type(); i = typeList->count(); while ( i > 0 ) { i--; typeList->setCurrentItem( i ); if ( typeList->currentText() == temptext ) { break; } } amtEdit->setText( QString( "%1" ).arg( info->amount(), 0, 'f', 2 ) ); feeEdit->setText( QString( "%1" ).arg( info->fee(), 0, 'f', 2 ) ); noteEdit->setText( info->notes() ); } else { withBtn->setChecked( TRUE ); } } Transaction::~Transaction() { } void Transaction::accept() { tran->setDesc( descEdit->text() ); tran->setDate( datePicker->selectedDate() ); tran->setWithdrawal( withBtn->isChecked() ); tran->setType( typeList->currentText() ); tran->setCategory( catList->currentText() ); bool ok; tran->setAmount( amtEdit->text().toFloat( &ok ) ); tran->setFee( feeEdit->text().toFloat( &ok ) ); tran->setNumber( numEdit->text() ); tran->setNotes( noteEdit->text() ); - + QDialog::accept(); } void Transaction::slotWithdrawalClicked() { catList->clear(); - catList->insertItem( tr( "Automobile" ) ); - catList->insertItem( tr( "Bills" ) ); - catList->insertItem( tr( "CDs" ) ); - catList->insertItem( tr( "Clothing" ) ); - 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(); typeList->insertItem( tr( "Debit Charge" ) ); typeList->insertItem( tr( "Written Check" ) ); typeList->insertItem( tr( "Transfer" ) ); typeList->insertItem( tr( "Credit Card" ) ); } void Transaction::slotDepositClicked() { catList->clear(); - catList->insertItem( tr( "Work" ) ); - catList->insertItem( tr( "Family Member" ) ); - catList->insertItem( tr( "Misc. Credit" ) ); - catList->setCurrentItem( 0 ); + CategoryList *pCatList=_pCfg->getCategoryList(); + for(Category *pCat=pCatList->first(); pCat; pCat=pCatList->next()) { + if( pCat->isIncome() ) + catList->insertItem( pCat->getName() ); + } + catList->setCurrentItem( 0 ); + typeList->clear(); typeList->insertItem( tr( "Written Check" ) ); typeList->insertItem( tr( "Automatic Payment" ) ); typeList->insertItem( tr( "Transfer" ) ); typeList->insertItem( tr( "Cash" ) ); } void Transaction::slotDateChanged( int y, int m, int d ) { QDate date; date.setYMD( y, m, d ); dateBtn->setText( TimeString::shortDate( date ) ); } diff --git a/noncore/apps/checkbook/transaction.h b/noncore/apps/checkbook/transaction.h index 000aee7..fbe9cd3 100644 --- a/noncore/apps/checkbook/transaction.h +++ b/noncore/apps/checkbook/transaction.h @@ -1,79 +1,79 @@ /* This file is part of the OPIE Project =. .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This file is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General ..}^=.= = ; Public License for more details. ++= -. .` .: : = ...= . :.=- You should have received a copy of the GNU -. .:....=;==+<; General Public License along with this file; -_. . . )=. = see the file COPYING. If not, write to the -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef TRANSACTION_H #define TRANSACTION_H #include <qdialog.h> class DateBookMonth; class QComboBox; class QLineEdit; class QMultiLineEdit; class QPushButton; class QRadioButton; class QString; class QWidget; class TranInfo; +class Cfg; class Transaction : public QDialog { Q_OBJECT public: - Transaction( QWidget * = 0x0, const QString & = 0x0, TranInfo * = 0x0, - const QString & = "$" ); + Transaction( QWidget *, const QString &, TranInfo *, Cfg *); ~Transaction(); private: TranInfo *tran; - QString currencySymbol; + Cfg *_pCfg; QRadioButton *withBtn; QRadioButton *depBtn; QPushButton *dateBtn; DateBookMonth *datePicker; QLineEdit *numEdit; QLineEdit *descEdit; QComboBox *catList; QComboBox *typeList; QLineEdit *amtEdit; QLineEdit *feeEdit; QMultiLineEdit *noteEdit; protected slots: void accept(); private slots: void slotWithdrawalClicked(); void slotDepositClicked(); void slotDateChanged( int, int, int ); }; #endif 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 @@ -1,29 +1,24 @@ /*************************************************************************** application: : ODict begin : December 2002 copyright : ( C ) 2002, 2003 by Carsten Niehaus email : cniehaus@handhelds.org **************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * ( at your option ) any later version. * * * **************************************************************************/ #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 @@ -1,220 +1,220 @@ /*************************************************************************** application: : ODict begin : December 2002 copyright : ( C ) 2002, 2003 by Carsten Niehaus email : cniehaus@handhelds.org **************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * ( at your option ) any later version. * * * **************************************************************************/ #include "odict.h" #include "configdlg.h" #include "dingwidget.h" #include <qlayout.h> #include <qpopupmenu.h> #include <qmenubar.h> #include <qmessagebox.h> #include <qhbox.h> #include <qvbox.h> #include <qlabel.h> #include <qpushbutton.h> #include <qlineedit.h> #include <qmainwindow.h> #include <qstring.h> #include <qaction.h> #include <qtextbrowser.h> #include <qcombobox.h> #include <qpe/resource.h> #include <qpe/config.h> -ODict::ODict() : QMainWindow() +ODict::ODict(QWidget* parent, const char* name, WFlags fl ) : QMainWindow(parent, name, fl ) { activated_name = QString::null; - + vbox = new QVBox( this ); setCaption( tr( "Opie-Dictionary" ) ); setupMenus(); QHBox *hbox = new QHBox( vbox ); - QLabel* query_label = new QLabel( tr( "Query:" ) , hbox ); + QLabel* query_label = new QLabel( tr( "Query:" ) , hbox ); query_label->show(); query_le = new QLineEdit( hbox ); query_co = new QComboBox( hbox ); connect( query_co , SIGNAL( activated(const QString&) ), this, SLOT( slotMethodChanged(const QString&) ) ); ok_button = new QPushButton( tr( "&Ok" ), hbox ); connect( ok_button, SIGNAL( released() ), this, SLOT( slotStartQuery() ) ); - + top_name = new QLabel( vbox ); top_name->setAlignment( AlignHCenter ); browser_top = new QTextBrowser( vbox ); bottom_name = new QLabel( vbox ); bottom_name->setAlignment( AlignHCenter ); browser_bottom = new QTextBrowser( vbox ); ding = new DingWidget(); loadConfig(); setCentralWidget( vbox ); } void ODict::loadConfig() { /* * the name of the last used dictionary */ QString lastname; - + Config cfg ( "odict" ); cfg.setGroup( "generalsettings" ); casesens = cfg.readEntry( "casesens" ).toInt(); QString lastDict = cfg.readEntry( "lastdict" ); int i = 0, e = 0; - + QStringList groupListCfg = cfg.groupList().grep( "Method_" ); query_co->clear(); for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it ) { QString name; cfg.setGroup( *it ); name = cfg.readEntry( "Name" ); query_co->insertItem( name ); /* * this check is to look up what dictionary has been used the * last time */ if ( lastDict == name ) { e = i; lastname = name; } i++; } /* * now set the two names of the dictionary and the correct QComboBox-Entry */ lookupLanguageNames( lastname ); ding->loadDict( lastname ); ding->loadValues(); query_co->setCurrentItem( e ); top_name->setText( top_name_content ); bottom_name->setText( bottom_name_content ); } void ODict::lookupLanguageNames( QString dictname ) { Config cfg ( "odict" ); 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" ); } void ODict::saveConfig() { Config cfg ( "odict" ); cfg.setGroup( "generalsettings" ); cfg.writeEntry( "casesens" , casesens ); cfg.writeEntry( "lastdict" , query_co->currentText() ); } void ODict::slotStartQuery() { QString querystring = query_le->text(); if ( !querystring.isEmpty() ) { /* * if the user has not yet defined a dictionary */ if ( !query_co->currentText() ) { switch ( QMessageBox::information( this, tr( "OPIE-Dictionary" ), tr( "No dictionary defined" ), - tr( "&Define one" ), + tr( "&Define one" ), tr( "&Cancel" ), 0, // Define a dict 1 ) ) // Cancel choosen - { + { case 0: slotSettings(); break; case 1: // stop here return; } - } + } /* * ok, the user has defined a dict */ - ding->setCaseSensitive( casesens ); + ding->setCaseSensitive( casesens ); BroswerContent test = ding->setText( querystring ); browser_top->setText( test.top ); browser_bottom->setText( test.bottom ); } } void ODict::slotSettings() { ConfigDlg dlg( this, "Config" , true); if ( dlg.exec() == QDialog::Accepted ) saveConfig(); } void ODict::slotSetParameter( int count ) { if ( count == 0 ) { if ( casesens ) casesens = false; else casesens = true; } saveConfig(); } void ODict::slotMethodChanged( const QString& methodnumber ) { activated_name = methodnumber; - + if ( activated_name != ding->loadedDict() ) { ding->loadDict(activated_name); - + lookupLanguageNames( activated_name ); top_name->setText( top_name_content ); bottom_name->setText( bottom_name_content ); } } void ODict::setupMenus() { menu = new QMenuBar( this ); - + settings = new QPopupMenu( menu ); setting_a = new QAction(tr( "Configuration" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); connect( setting_a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); setting_a->addTo( settings ); setting_b = new QAction(tr( "Searchmethods" ), Resource::loadPixmap( "edit" ), QString::null, 0, this, 0 ); - + parameter = new QPopupMenu( menu ); connect( parameter, SIGNAL( activated( int ) ), this, SLOT( slotSetParameter( int ) ) ); parameter->insertItem( tr( "C&ase sensitive" ), 0 ,0 ); parameter->insertSeparator(); - + menu->insertItem( tr( "Settings" ) , settings ); menu->insertItem( tr( "Parameter" ) , parameter ); } 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 @@ -1,70 +1,70 @@ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * ( at your option ) any later version. * * * **************************************************************************/ #include <qmainwindow.h> class QLabel; class QVBox; class QPopupMenu; class QMenuBar; class QHBox; class QPushButton; class QLineEdit; class QAction; class QVBoxLayout; class QActionGroup; class DingWidget; class QTextBrowser; class QComboBox; class DingWidget; class ODict : public QMainWindow { Q_OBJECT public: - ODict(); + ODict(QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); QVBox *vbox; QTextBrowser *browser_top, *browser_bottom; DingWidget *ding; - + static QString appName() { return QString::fromLatin1("odict"); } private: QPopupMenu *help, *settings, *parameter; QMenuBar *menu; QHBox *hbox; QLineEdit *query_le; QComboBox *query_co; QPushButton *ok_button; QVBoxLayout *vbox_layout; QAction *setting_a, *setting_b; void setupMenus(); bool casesens, completewords; void loadConfig(); void saveConfig(); QString activated_name; QLabel *bottom_name, *top_name; QString top_name_content, bottom_name_content; void lookupLanguageNames( QString ); private slots: void slotStartQuery(); void slotSettings(); void slotSetParameter( int ); void slotMethodChanged( const QString& ); }; 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,41 +1,38 @@ -TEMPLATE = app -CONFIG = qt warn_on debug -#CONFIG = qt warn_on release +CONFIG = qt warn_on release quick-app HEADERS = odict.h \ searchmethoddlg.h \ configdlg.h \ dingwidget.h SOURCES = main.cpp \ odict.cpp \ searchmethoddlg.cpp \ configdlg.cpp \ dingwidget.cpp INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lstdc++ -lopie TARGET = odict -DESTDIR = $(OPIEDIR)/bin TRANSLATIONS = ../../../i18n/de/odict.ts \ ../../../i18n/nl/odict.ts \ ../../../i18n/xx/odict.ts \ ../../../i18n/en/odict.ts \ ../../../i18n/es/odict.ts \ ../../../i18n/fr/odict.ts \ ../../../i18n/hu/odict.ts \ ../../../i18n/ja/odict.ts \ ../../../i18n/ko/odict.ts \ ../../../i18n/no/odict.ts \ ../../../i18n/pl/odict.ts \ ../../../i18n/pt/odict.ts \ ../../../i18n/pt_BR/odict.ts \ ../../../i18n/sl/odict.ts \ ../../../i18n/zh_CN/odict.ts \ ../../../i18n/zh_TW/odict.ts \ ../../../i18n/it/odict.ts \ ../../../i18n/da/odict.ts include ( $(OPIEDIR)/include.pro ) 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,11 +1,11 @@ Package: opie-console -Files: plugins/application/libopie-console.so* bin/opie-console apps/Applications/opie-console.desktop pics/console/* +Files: bin/opie-console apps/Applications/opie-console.desktop pics/console/* Priority: optional Section: opie/applications Maintainer: Opie team <opie@handhelds.org> Architecture: arm Version: 0.6-$SUB_VERSION Depends: qpe-base, libopie1, opie-console-help-en, lrzsz, opie-keytabs License: GPL Description: Opie terminal app 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,93 +1,92 @@ -TEMPLATE = app CONFIG = qt warn_on release HEADERS = Aportis.h \ Bkmks.h \ BuffDoc.h \ CAnnoEdit.h \ CBuffer.h \ CDrawBuffer.h \ CEncoding.h \ CEncoding_tables.h \ CExpander.h \ CFilter.h \ CloseDialog.h \ Filedata.h \ FixedFont.h \ FontControl.h \ GraphicWin.h \ Markups.h \ Navigation.h \ Palm2QImage.h \ Prefs.h \ QFloatBar.h \ QTReader.h \ QTReaderApp.h \ QtrListView.h \ Queue.h \ StateData.h \ StyleConsts.h \ ToolbarPrefs.h \ URLDialog.h \ ZText.h \ arith.h \ cbkmkselector.h \ config.h \ fileBrowser.h \ infowin.h \ linktype.h \ my_list.h \ names.h \ opie.h \ pdb.h \ plucker_base.h \ plucker.h \ ppm.h \ ppm_expander.h \ usenef.h \ useqpe.h \ ustring.h \ utypes.h \ version.h \ ztxt.h SOURCES = Aportis.cpp \ Bkmks.cpp \ BuffDoc.cpp \ CBuffer.cpp \ CDrawBuffer.cpp \ CEncoding.cpp \ CEncoding_tables.cpp \ CFilter.cpp \ CloseDialog.cpp \ FontControl.cpp \ Navigation.cpp \ Palm2QImage.cpp \ Prefs.cpp \ QTReader.cpp \ QTReaderApp.cpp \ QtrListView.cpp \ StyleConsts.cpp \ ToolbarPrefs.cpp \ URLDialog.cpp \ arith_d.cpp \ fileBrowser.cpp \ infowin.cpp \ main.cpp \ pdb.cpp \ plucker.cpp \ plucker_base.cpp \ ppm.cpp \ ppm_expander.cpp \ version.cpp \ ztxt.cpp -INTERFACES = -DESTDIR = $(OPIEDIR)/bin +DESTDIR = $(OPIEDIR)/bin +TARGET = reader + INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include -TARGET = reader LIBS += -lqpe include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/apps/opie-sheet/main.cpp b/noncore/apps/opie-sheet/main.cpp index e42b4a5..d0a2995 100644 --- a/noncore/apps/opie-sheet/main.cpp +++ b/noncore/apps/opie-sheet/main.cpp @@ -1,28 +1,22 @@ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ /* * Opie Sheet (formerly Sheet/Qt) * by Serdar Ozler <sozler@sitebest.com> */ #include <qpe/qpeapplication.h> #include "mainwindow.h" -int main(int argc, char **argv) -{ - QPEApplication application(argc, argv); +#include <opie/oapplicationfactory.h> - MainWindow windowMain; - windowMain.setHelpFile(application.qpeDir()+"/help/html/"+QString(argv[0])+".html"); - application.showMainDocumentWidget(&windowMain); +OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) - return application.exec(); -} diff --git a/noncore/apps/opie-sheet/mainwindow.cpp b/noncore/apps/opie-sheet/mainwindow.cpp index 43e5131..3915e52 100644 --- a/noncore/apps/opie-sheet/mainwindow.cpp +++ b/noncore/apps/opie-sheet/mainwindow.cpp @@ -1,559 +1,559 @@ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ /* * Opie Sheet (formerly Sheet/Qt) * by Serdar Ozler <sozler@sitebest.com> */ #include "mainwindow.h" #include <qpe/filemanager.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/resource.h> #include <qmessagebox.h> #include <qfile.h> #include <qtranslator.h> #include <qradiobutton.h> #include "cellformat.h" #include "numberdlg.h" #include "textdlg.h" #include "sortdlg.h" #include "finddlg.h" #include "func-plus.xpm" #include "func-minus.xpm" #include "func-cross.xpm" #include "func-divide.xpm" #include "func-paran-open.xpm" #include "func-paran-close.xpm" #include "func-comma.xpm" #include "func-func.xpm" #include "func-equal.xpm" #include "cell-select.xpm" #define DEFAULT_NUM_ROWS 199 #define DEFAULT_NUM_COLS (26*3) #define DEFAULT_NUM_SHEETS 3 -MainWindow::MainWindow() - :QMainWindow() +MainWindow::MainWindow(QWidget *parent, const char* n, WFlags fl) + :QMainWindow(parent, n, fl) { // initialize variables documentModified=FALSE; // construct objects currentDoc=0; fileSelector=new FileSelector("application/sheet-qt", this, QString::null); connect(fileSelector, SIGNAL(closeMe()), this, SLOT(selectorHide())); connect(fileSelector, SIGNAL(newSelected(const DocLnk &)), this, SLOT(selectorFileNew(const DocLnk &))); connect(fileSelector, SIGNAL(fileSelected(const DocLnk &)), this, SLOT(selectorFileOpen(const DocLnk &))); listSheets.setAutoDelete(TRUE); initActions(); initMenu(); initEditToolbar(); initFunctionsToolbar(); initStandardToolbar(); initSheet(); // set window title setCaption(tr("Opie Sheet")); // create sheets selectorFileNew(DocLnk()); } MainWindow::~MainWindow() { if (currentDoc) delete currentDoc; } void MainWindow::documentSave(DocLnk *lnkDoc) { FileManager fm; QByteArray streamBuffer; QDataStream stream(streamBuffer, IO_WriteOnly); typeSheet *currentSheet=findSheet(sheet->getName()); if (!currentSheet) { QMessageBox::critical(this, tr("Error"), tr("Inconsistency error!")); return; } sheet->copySheetData(¤tSheet->data); stream.writeRawBytes("SQT100", 6); stream << (Q_UINT32)listSheets.count(); for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) { stream << tempSheet->name << (Q_UINT32)tempSheet->data.count(); for (typeCellData *tempCell=tempSheet->data.first(); tempCell; tempCell=tempSheet->data.next()) stream << (Q_UINT32)tempCell->col << (Q_UINT32)tempCell->row << tempCell->borders.right << tempCell->borders.bottom << tempCell->background << (Q_UINT32)tempCell->alignment << tempCell->fontColor << tempCell->font << tempCell->data; } lnkDoc->setType("application/sheet-qt"); if (!fm.saveFile(*lnkDoc, streamBuffer)) { QMessageBox::critical(this, tr("Error"), tr("File cannot be saved!")); return; } documentModified=FALSE; } void MainWindow::documentOpen(const DocLnk &lnkDoc) { FileManager fm; QByteArray streamBuffer; if (!lnkDoc.isValid() || !fm.loadFile(lnkDoc, streamBuffer)) { QMessageBox::critical(this, tr("Error"), tr("File cannot be opened!")); documentModified=FALSE; selectorFileNew(DocLnk()); return; } QDataStream stream(streamBuffer, IO_ReadOnly); Q_UINT32 countSheet, countCell, i, j, row, col, alignment; typeSheet *newSheet; typeCellData *newCell; char fileFormat[7]; stream.readRawBytes(fileFormat, 6); fileFormat[6]=0; if ((QString)fileFormat!="SQT100") { QMessageBox::critical(this, tr("Error"), tr("Invalid file format!")); documentModified=FALSE; selectorFileNew(DocLnk()); return; } stream >> countSheet; for (i=0; i<countSheet; ++i) { newSheet=new typeSheet; newSheet->data.setAutoDelete(TRUE); stream >> newSheet->name >> countCell; comboSheets->insertItem(newSheet->name); for (j=0; j<countCell; ++j) { newCell=new typeCellData; stream >> col >> row >> newCell->borders.right >> newCell->borders.bottom >> newCell->background >> alignment >> newCell->fontColor >> newCell->font >> newCell->data; newCell->col=col; newCell->row=row; newCell->alignment=(Qt::AlignmentFlags)alignment; newSheet->data.append(newCell); } listSheets.append(newSheet); if (i==0) { sheet->setName(newSheet->name); sheet->setSheetData(&newSheet->data); } } } int MainWindow::saveCurrentFile(bool ask) { if (ask) { int result=QMessageBox::information(this, tr("Save File"), tr("Do you want to save the current file?"), QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel); if (result!=QMessageBox::Yes) return result; } if (!currentDoc->isValid()) { TextDialog dialogText(this); if (dialogText.exec(tr("Save File"), tr("&File Name:"), tr("UnnamedFile"))!=QDialog::Accepted || dialogText.getValue().isEmpty()) return QMessageBox::Cancel; currentDoc->setName(dialogText.getValue()); currentDoc->setFile(QString::null); currentDoc->setLinkFile(QString::null); } documentSave(currentDoc); return QMessageBox::Yes; } void MainWindow::selectorFileNew(const DocLnk &lnkDoc) { selectorHide(); if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; if (currentDoc) delete currentDoc; currentDoc = new DocLnk(lnkDoc); editData->clear(); listSheets.clear(); comboSheets->clear(); typeSheet *newSheet=createNewSheet(); newSheet->data.setAutoDelete(TRUE); sheet->setName(newSheet->name); sheet->setSheetData(&newSheet->data); for (int i=1; i<DEFAULT_NUM_SHEETS; ++i) createNewSheet(); documentModified=FALSE; } void MainWindow::closeEvent(QCloseEvent *e) { if (documentModified && saveCurrentFile()==QMessageBox::Cancel) e->ignore(); else e->accept(); } void MainWindow::selectorFileOpen(const DocLnk &lnkDoc) { selectorHide(); if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; if (currentDoc) delete currentDoc; currentDoc = new DocLnk(lnkDoc); listSheets.clear(); comboSheets->clear(); documentOpen(lnkDoc); documentModified=FALSE; } void MainWindow::selectorShow() { sheet->hide(); setCentralWidget(fileSelector); fileSelector->show(); fileSelector->reread(); } void MainWindow::selectorHide() { fileSelector->hide(); setCentralWidget(sheet); sheet->show(); } void MainWindow::slotFileNew() { selectorFileNew(DocLnk()); } void MainWindow::slotFileOpen() { selectorShow(); } void MainWindow::slotFileSave() { saveCurrentFile(FALSE); } void MainWindow::setDocument(const QString &applnk_filename) { selectorFileOpen(DocLnk(applnk_filename)); } void MainWindow::initActions() { fileNew=new QAction(tr("New File"), Resource::loadPixmap( "new" ), tr("&New"), 0, this); connect(fileNew, SIGNAL(activated()), this, SLOT(slotFileNew())); fileOpen=new QAction(tr("Open File"), Resource::loadPixmap( "fileopen" ), tr("&Open"), 0, this); connect(fileOpen, SIGNAL(activated()), this, SLOT(slotFileOpen())); fileSave=new QAction(tr("Save File"),Resource::loadPixmap( "save" ), tr("&Save"), 0, this); connect(fileSave, SIGNAL(activated()), this, SLOT(slotFileSave())); fileSaveAs=new QAction(tr("Save File As"), Resource::loadPixmap( "save" ), tr("Save &As"), 0, this); connect(fileSaveAs, SIGNAL(activated()), this, SLOT(slotFileSaveAs())); //fileQuit=new QAction(tr("Quit"), tr("&Quit"), 0, this); //connect(fileQuit, SIGNAL(activated()), this, SLOT(close())); // helpGeneral=new QAction(tr("General Help"), QPixmap(help_general_xpm), tr("&General"), 0, this); //connect(helpGeneral, SIGNAL(activated()), this, SLOT(slotHelpGeneral())); //helpAbout=new QAction(tr("About Opie Sheet"), tr("&About"), 0, this); //connect(helpAbout, SIGNAL(activated()), this, SLOT(slotHelpAbout())); editAccept=new QAction(tr("Accept"),Resource::loadPixmap( "enter" ) , tr("&Accept"), 0, this); connect(editAccept, SIGNAL(activated()), this, SLOT(slotEditAccept())); editCancel=new QAction(tr("Cancel"), Resource::loadPixmap( "close" ), tr("&Cancel"), 0, this); connect(editCancel, SIGNAL(activated()), this, SLOT(slotEditCancel())); editCellSelect=new QAction(tr("Cell Selector"), QPixmap(cell_select_xpm), tr("Cell &Selector"), 0, this); editCellSelect->setToggleAction(TRUE); connect(editCellSelect, SIGNAL(toggled(bool)), this, SLOT(slotCellSelect(bool))); editCut=new QAction(tr("Cut Cells"), tr("Cu&t"), 0, this); editCopy=new QAction(tr("Copy Cells"), tr("&Copy"), 0, this); editPaste=new QAction(tr("Paste Cells"), tr("&Paste"), 0, this); connect(editPaste, SIGNAL(activated()), this, SLOT(slotEditPaste())); editPasteContents=new QAction(tr("Paste Contents"), tr("Paste Cont&ents"), 0, this); connect(editPasteContents, SIGNAL(activated()), this, SLOT(slotEditPasteContents())); editClear=new QAction(tr("Clear Cells"), tr("C&lear"), 0, this); insertCells=new QAction(tr("Insert Cells"), tr("C&ells"), 0, this); connect(insertCells, SIGNAL(activated()), this, SLOT(slotInsertCells())); insertRows=new QAction(tr("Insert Rows"), tr("&Rows"), 0, this); connect(insertRows, SIGNAL(activated()), this, SLOT(slotInsertRows())); insertCols=new QAction(tr("Insert Columns"), tr("&Columns"), 0, this); connect(insertCols, SIGNAL(activated()), this, SLOT(slotInsertCols())); insertSheets=new QAction(tr("Add Sheets"), tr("&Sheets"), 0, this); connect(insertSheets, SIGNAL(activated()), this, SLOT(slotInsertSheets())); formatCells=new QAction(tr("Cells"), tr("&Cells"), 0, this); connect(formatCells, SIGNAL(activated()), this, SLOT(slotFormatCells())); rowHeight=new QAction(tr("Row Height"), tr("H&eight"), 0, this); connect(rowHeight, SIGNAL(activated()), this, SLOT(slotRowHeight())); rowAdjust=new QAction(tr("Adjust Row"), tr("&Adjust"), 0, this); connect(rowAdjust, SIGNAL(activated()), this, SLOT(slotRowAdjust())); rowShow=new QAction(tr("Show Row"), tr("&Show"), 0, this); connect(rowShow, SIGNAL(activated()), this, SLOT(slotRowShow())); rowHide=new QAction(tr("Hide Row"), tr("&Hide"), 0, this); connect(rowHide, SIGNAL(activated()), this, SLOT(slotRowHide())); colWidth=new QAction(tr("Column Width"), tr("&Width"), 0, this); connect(colWidth, SIGNAL(activated()), this, SLOT(slotColumnWidth())); colAdjust=new QAction(tr("Adjust Column"), tr("&Adjust"), 0, this); connect(colAdjust, SIGNAL(activated()), this, SLOT(slotColumnAdjust())); colShow=new QAction(tr("Show Column"), tr("&Show"), 0, this); connect(colShow, SIGNAL(activated()), this, SLOT(slotColumnShow())); colHide=new QAction(tr("Hide Column"), tr("&Hide"), 0, this); connect(colHide, SIGNAL(activated()), this, SLOT(slotColumnHide())); sheetRename=new QAction(tr("Rename Sheet"), tr("&Rename"), 0, this); connect(sheetRename, SIGNAL(activated()), this, SLOT(slotSheetRename())); sheetRemove=new QAction(tr("Remove Sheet"), tr("R&emove"), 0, this); connect(sheetRemove, SIGNAL(activated()), this, SLOT(slotSheetRemove())); dataSort=new QAction(tr("Sort Data"), tr("&Sort"), 0, this); connect(dataSort, SIGNAL(activated()), this, SLOT(slotDataSort())); dataFindReplace=new QAction(tr("Find && Replace"), tr("&Find && Replace"), 0, this); connect(dataFindReplace, SIGNAL(activated()), this, SLOT(slotDataFindReplace())); funcEqual=new QAction(tr("Equal To"), QPixmap(func_equal_xpm), tr("&Equal To"), 0, this); funcEqual->setToolTip("="); connect(funcEqual, SIGNAL(activated()), this, SLOT(slotFuncOutput())); funcPlus=new QAction(tr("Addition"), QPixmap(func_plus_xpm), tr("&Addition"), 0, this); funcPlus->setToolTip("+"); connect(funcPlus, SIGNAL(activated()), this, SLOT(slotFuncOutput())); funcMinus=new QAction(tr("Subtraction"), QPixmap(func_minus_xpm), tr("&Subtraction"), 0, this); funcMinus->setToolTip("-"); connect(funcMinus, SIGNAL(activated()), this, SLOT(slotFuncOutput())); funcCross=new QAction(tr("Multiplication"), QPixmap(func_cross_xpm), tr("&Multiplication"), 0, this); funcCross->setToolTip("*"); connect(funcCross, SIGNAL(activated()), this, SLOT(slotFuncOutput())); funcDivide=new QAction(tr("Division"), QPixmap(func_divide_xpm), tr("&Division"), 0, this); funcDivide->setToolTip("/"); connect(funcDivide, SIGNAL(activated()), this, SLOT(slotFuncOutput())); funcParanOpen=new QAction(tr("Open ParanthesistempCellData->row+row1, tempCellData->col+col1"), QPixmap(func_paran_open_xpm), tr("&Open Paranthesis"), 0, this); funcParanOpen->setToolTip("("); connect(funcParanOpen, SIGNAL(activated()), this, SLOT(slotFuncOutput())); funcParanClose=new QAction(tr("Close Paranthesis"), QPixmap(func_paran_close_xpm), tr("&Close Paranthesis"), 0, this); funcParanClose->setToolTip(")"); connect(funcParanClose, SIGNAL(activated()), this, SLOT(slotFuncOutput())); funcComma=new QAction(tr("Comma"), QPixmap(func_comma_xpm), tr("&Comma"), 0, this); funcComma->setToolTip(","); connect(funcComma, SIGNAL(activated()), this, SLOT(slotFuncOutput())); } void MainWindow::initMenu() { menu=new QPEMenuBar(this); menuFile=new QPopupMenu; fileNew->addTo(menuFile); fileOpen->addTo(menuFile); fileSave->addTo(menuFile); fileSaveAs->addTo(menuFile); // menuFile->insertSeparator(); // fileQuit->addTo(menuFile); menu->insertItem(tr("&File"), menuFile); menuEdit=new QPopupMenu; editAccept->addTo(menuEdit); editCancel->addTo(menuEdit); editCellSelect->addTo(menuEdit); menuEdit->insertSeparator(); editCut->addTo(menuEdit); editCopy->addTo(menuEdit); editPaste->addTo(menuEdit); editPasteContents->addTo(menuEdit); editClear->addTo(menuEdit); menu->insertItem(tr("&Edit"), menuEdit); menuInsert=new QPopupMenu; menu->insertItem(tr("&Insert"), menuInsert); menuFormat=new QPopupMenu; formatCells->addTo(menuFormat); menu->insertItem(tr("&Format"), menuFormat); menuData=new QPopupMenu; dataSort->addTo(menuData); dataFindReplace->addTo(menuData); menu->insertItem(tr("&Data"), menuData); // menuHelp=new QPopupMenu; // helpGeneral->addTo(menuHelp); // helpAbout->addTo(menuHelp); // menu->insertItem(tr("&Help"), menuHelp); submenuRow=new QPopupMenu; rowHeight->addTo(submenuRow); rowAdjust->addTo(submenuRow); rowShow->addTo(submenuRow); rowHide->addTo(submenuRow); menuFormat->insertItem(tr("&Row"), submenuRow); submenuCol=new QPopupMenu; colWidth->addTo(submenuCol); colAdjust->addTo(submenuCol); colShow->addTo(submenuCol); colHide->addTo(submenuCol); menuFormat->insertItem(tr("Colum&n"), submenuCol); submenuSheet=new QPopupMenu; sheetRename->addTo(submenuSheet); sheetRemove->addTo(submenuSheet); menuFormat->insertItem(tr("&Sheet"), submenuSheet); submenuFunc=new QPopupMenu; menuInsert->insertItem(tr("&Function"), submenuFunc); submenuFuncStd=new QPopupMenu; funcPlus->addTo(submenuFuncStd); funcMinus->addTo(submenuFuncStd); funcCross->addTo(submenuFuncStd); funcDivide->addTo(submenuFuncStd); submenuFunc->insertItem(tr("&Standard"), submenuFuncStd); submenuFuncMath=new QPopupMenu; addFlyAction(tr("Summation"), tr("&Summation"), "SUM(", submenuFuncMath); addFlyAction(tr("Absolute Value"), tr("&Absolute"), "ABS(", submenuFuncMath); submenuFuncMath->insertSeparator(); addFlyAction(tr("Sine"), tr("Si&ne"), "SIN(", submenuFuncMath); addFlyAction(tr("Arc Sine"), tr("A&rc Sine"), "ASIN(", submenuFuncMath); addFlyAction(tr("Cosine"), tr("&Cosine"), "COS(", submenuFuncMath); addFlyAction(tr("ArcCosine"), tr("Arc Cos&ine"), "COS(", submenuFuncMath); addFlyAction(tr("Tangent"), tr("&Tangent"), "TAN(", submenuFuncMath); addFlyAction(tr("Arc Tangent"), tr("Arc Tan&gent"), "ATAN(", submenuFuncMath); addFlyAction(tr("Arc Tangent of Coordinates"), tr("C&oor. Arc Tangent"), "ATAN2(", submenuFuncMath); submenuFuncMath->insertSeparator(); addFlyAction(tr("Exponential"), tr("&Exponential"), "EXP(", submenuFuncMath); addFlyAction(tr("Logarithm"), tr("&Logarithm"), "LOG(", submenuFuncMath); addFlyAction(tr("Power"), tr("&Power"), "POW(", submenuFuncMath); submenuFunc->insertItem(tr("&Mathematical"), submenuFuncMath); submenuFuncStat=new QPopupMenu; addFlyAction(tr("Average"), tr("&Average"), "AVG(", submenuFuncStat); addFlyAction(tr("Maximum"), tr("Ma&ximum"), "MAX(", submenuFuncStat); addFlyAction(tr("Minimum"), tr("&Minimum"), "MIN(", submenuFuncStat); addFlyAction(tr("Count"), tr("&Count"), "COUNT(", submenuFuncStat); submenuFunc->insertItem(tr("&Statistical"), submenuFuncStat); menuInsert->insertSeparator(); insertCells->addTo(menuInsert); insertRows->addTo(menuInsert); insertCols->addTo(menuInsert); insertSheets->addTo(menuInsert); } void MainWindow::initStandardToolbar() { toolbarStandard=new QPEToolBar(this); toolbarStandard->setHorizontalStretchable(TRUE); moveToolBar(toolbarStandard, Top); fileNew->addTo(toolbarStandard); fileOpen->addTo(toolbarStandard); fileSave->addTo(toolbarStandard); comboSheets=new QComboBox(toolbarStandard); toolbarStandard->setStretchableWidget(comboSheets); connect(comboSheets, SIGNAL(activated(const QString &)), this, SLOT(slotSheetChanged(const QString &))); } void MainWindow::initFunctionsToolbar() { toolbarFunctions=new QPEToolBar(this); toolbarFunctions->setHorizontalStretchable(TRUE); moveToolBar(toolbarFunctions, Bottom); funcEqual->addTo(toolbarFunctions); funcPlus->addTo(toolbarFunctions); funcMinus->addTo(toolbarFunctions); funcCross->addTo(toolbarFunctions); funcDivide->addTo(toolbarFunctions); funcParanOpen->addTo(toolbarFunctions); funcParanClose->addTo(toolbarFunctions); funcComma->addTo(toolbarFunctions); toolFunction=new QToolButton(toolbarFunctions); toolFunction->setPixmap(func_func_xpm); toolFunction->setTextLabel(tr("Functions")); toolFunction->setPopup(submenuFunc); toolFunction->setPopupDelay(0); } void MainWindow::initEditToolbar() { toolbarEdit=new QPEToolBar(this); toolbarEdit->setHorizontalStretchable(TRUE); moveToolBar(toolbarEdit, Bottom); editAccept->addTo(toolbarEdit); editCancel->addTo(toolbarEdit); editData=new QLineEdit(toolbarEdit); toolbarEdit->setStretchableWidget(editData); connect(editData, SIGNAL(returnPressed()), this, SLOT(slotEditAccept())); editCellSelect->addTo(toolbarEdit); } void MainWindow::slotHelpAbout() { QDialog dialogAbout(this, 0, TRUE); dialogAbout.resize(width()-40, height()-80); dialogAbout.setCaption(tr("About Opie Sheet")); QLabel label(tr("Opie Sheet\nSpreadsheet Software for Opie\nQWDC Beta Winner (as Sheet/Qt)\n\nDeveloped by: Serdar Ozler\nRelease 1.0.2\nRelease Date: October 08, 2002\n\nThis product is licensed under GPL. It is freely distributable. If you want to get the latest version and also the source code, please visit the web site.\n\nhttp://qtopia.sitebest.com"), &dialogAbout); label.setGeometry(dialogAbout.rect()); label.setAlignment(Qt::AlignCenter | Qt::WordBreak); dialogAbout.exec(); } void MainWindow::initSheet() { sheet=new Sheet(DEFAULT_NUM_ROWS, DEFAULT_NUM_COLS, this); setCentralWidget(sheet); connect(sheet, SIGNAL(currentDataChanged(const QString &)), editData, SLOT(setText(const QString &))); connect(sheet, SIGNAL(cellClicked(const QString &)), this, SLOT(slotCellClicked(const QString &))); connect(sheet, SIGNAL(sheetModified()), this, SLOT(slotDocModified())); connect(editCut, SIGNAL(activated()), sheet, SLOT(editCut())); connect(editCopy, SIGNAL(activated()), sheet, SLOT(editCopy())); connect(editClear, SIGNAL(activated()), sheet, SLOT(editClear())); } void MainWindow::slotEditAccept() { sheet->setData(editData->text()); } void MainWindow::slotEditCancel() { editData->setText(sheet->getData()); } void MainWindow::slotCellSelect(bool lock) { sheet->lockClicks(lock); } void MainWindow::addToData(const QString &data) 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 @@ -1,132 +1,133 @@ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ /* * Opie Sheet (formerly Sheet/Qt) * by Serdar Ozler <sozler@sitebest.com> */ #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <qpe/applnk.h> #include <qpe/fileselector.h> #include <qpe/qpemenubar.h> #include <qpe/qpetoolbar.h> #include <qmainwindow.h> #include <qaction.h> #include <qlineedit.h> #include <qbutton.h> #include <qcombobox.h> #include <qtoolbutton.h> #include "sheet.h" typedef struct typeSheet { QString name; QList<typeCellData> data; }; class MainWindow: public QMainWindow { Q_OBJECT // QPE objects DocLnk* currentDoc; QPEMenuBar *menu; QPEToolBar *toolbarFunctions, *toolbarEdit, *toolbarStandard; FileSelector *fileSelector; // QT objects QPopupMenu *menuFile, *menuEdit, *menuInsert, *menuFormat, *menuData, *menuHelp, *submenuFunc, *submenuFuncStd, *submenuFuncMath, *submenuFuncStat, *submenuRow, *submenuCol, *submenuSheet; QAction *fileNew, *fileOpen, *fileSave, *fileSaveAs, *fileQuit, *helpAbout, *editAccept, *editCancel, *formatCells, *funcPlus, *funcMinus, *funcCross, *funcDivide, *funcParanOpen, *funcParanClose, *funcComma, *funcEqual, *editCut, *editCopy, *editPaste, *editPasteContents, *editClear, *insertCols, *insertRows, *insertSheets, *insertCells, *rowHeight, *rowShow, *rowHide, *rowAdjust, *colWidth, *colShow, *colHide, *colAdjust, *sheetRename, *sheetRemove, *dataSort, *dataFindReplace, *editCellSelect, *helpGeneral; QLineEdit *editData; QButton *buttonUp, *buttonDown, *buttonLeft, *buttonRight; QComboBox *comboSheets; QToolButton *toolFunction; QList<typeSheet> listSheets; QString helpFile; // Other objects Sheet *sheet; // Variables bool documentModified; // Private functions void initMenu(); void initActions(); void initFunctionsToolbar(); void initEditToolbar(); void initStandardToolbar(); void initSheet(); void addToData(const QString &data); int saveCurrentFile(bool ask=TRUE); void documentOpen(const DocLnk &lnkDoc); void documentSave(DocLnk *lnkDoc); void closeEvent(QCloseEvent *e); void addFlyAction(const QString &text, const QString &menuText, const QString &tip, QWidget *w); typeSheet *createNewSheet(); typeSheet *findSheet(const QString &name); private slots: void slotFileNew(); void slotFileOpen(); void slotFileSave(); void slotFileSaveAs(); void slotHelpAbout(); void slotEditAccept(); void slotEditCancel(); void slotEditPaste(); void slotEditPasteContents(); void slotFormatCells(); void slotInsertCells(); void slotInsertRows(); void slotInsertCols(); void slotInsertSheets(); void slotDataSort(); void slotDataFindReplace(); void slotRowHeight(); void slotRowAdjust(); void slotRowShow(); void slotRowHide(); void slotColumnWidth(); void slotColumnAdjust(); void slotColumnShow(); void slotColumnHide(); void slotSheetRename(); void slotSheetRemove(); void slotFuncOutput(); void slotCellSelect(bool lock); void slotCellClicked(const QString &cell); void slotSheetChanged(const QString &name); void slotDocModified(); void selectorShow(); void selectorHide(); void selectorFileNew(const DocLnk &lnkDoc); void selectorFileOpen(const DocLnk &lnkDoc); public: - MainWindow(); + static QString appName() { return QString::fromLatin1("sheetqt"); } + MainWindow(QWidget *p, const char*, WFlags); ~MainWindow(); void setHelpFile(const QString &help_filename) { helpFile=help_filename; } public slots: void setDocument(const QString &applnk_filename); }; #endif 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,32 +1,30 @@ -TEMPLATE = app -CONFIG = qt warn_on release -DESTDIR = $(OPIEDIR)/bin +CONFIG = qt warn_on release quick-app HEADERS = mainwindow.h sheet.h cellformat.h finddlg.h numberdlg.h sortdlg.h textdlg.h SOURCES = main.cpp mainwindow.cpp sheet.cpp cellformat.cpp finddlg.cpp numberdlg.cpp sortdlg.cpp textdlg.cpp INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe TARGET = sheetqt TRANSLATIONS = ../../../i18n/de/sheetqt.ts \ ../../../i18n/nl/sheetqt.ts \ ../../../i18n/da/sheetqt.ts \ ../../../i18n/xx/sheetqt.ts \ ../../../i18n/en/sheetqt.ts \ ../../../i18n/es/sheetqt.ts \ ../../../i18n/fr/sheetqt.ts \ ../../../i18n/hu/sheetqt.ts \ ../../../i18n/ja/sheetqt.ts \ ../../../i18n/ko/sheetqt.ts \ ../../../i18n/no/sheetqt.ts \ ../../../i18n/pl/sheetqt.ts \ ../../../i18n/pt/sheetqt.ts \ ../../../i18n/pt_BR/sheetqt.ts \ ../../../i18n/sl/sheetqt.ts \ ../../../i18n/zh_CN/sheetqt.ts \ ../../../i18n/zh_TW/sheetqt.ts \ ../../../i18n/it/sheetqt.ts include ( $(OPIEDIR)/include.pro ) 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 @@ -1,37 +1,28 @@ /********************************************************************** ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** ** This file is part of the Qtopia Environment. ** ** Licensees holding valid Qtopia Developer license may use this ** file in accordance with the Qtopia Developer License Agreement ** provided with the Software. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING ** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR ** PURPOSE. ** ** email sales@trolltech.com for information about Qtopia License ** Agreements. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #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 @@ -1,574 +1,574 @@ /********************************************************************** ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** ** This file is part of the Qtopia Environment. ** ** Licensees holding valid Qtopia Developer license may use this ** file in accordance with the Qtopia Developer License Agreement ** provided with the Software. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING ** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR ** PURPOSE. ** ** email sales@trolltech.com for information about Qtopia License ** Agreements. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "mainwindow.h" #include <qpe/fileselector.h> #include <qpe/applnk.h> #include <qpe/resource.h> #include <qpe/fontdatabase.h> //#include "qspellchecker.h" #include "qtextedit.h" #include <qaction.h> #include <qtoolbar.h> #include <qtoolbutton.h> #include <qtabwidget.h> #include <qapplication.h> #include <qfontdatabase.h> #include <qcombobox.h> #include <qlineedit.h> #include <qfileinfo.h> #include <qfile.h> #include <qfiledialog.h> #include <qprinter.h> #include <qpaintdevicemetrics.h> #include <qmenubar.h> #include <qpopupmenu.h> #include <qcolordialog.h> #include <qpainter.h> #include <qstyle.h> class ButtonMenu : public QToolButton { Q_OBJECT public: ButtonMenu( QWidget *parent, const char *name=0 ) : QToolButton( parent, name ), current(0) { setPopup( new QPopupMenu( this ) ); setPopupDelay( 1 ); connect( popup(), SIGNAL(activated(int)), this, SLOT(selected(int)) ); } int insertItem(const QIconSet &icon, const QString &text, int id ) { if ( !popup()->count() ) { setIconSet( icon ); current = id; } return popup()->insertItem( icon, text, id ); } void setCurrentItem( int id ) { if ( id != current ) { current = id; setIconSet( *popup()->iconSet( id ) ); } } virtual QSize sizeHint() const { return QToolButton::sizeHint() + QSize( 4, 0 ); } signals: void activated( int id ); protected slots: void selected( int id ) { current = id; setIconSet( *popup()->iconSet( id ) ); emit activated( id ); } protected: virtual void drawButtonLabel( QPainter *p ) { p->translate( -4, 0 ); QToolButton::drawButtonLabel( p ); p->translate( 4, 0 ); } private: int current; }; //=========================================================================== -MainWindow::MainWindow( QWidget *parent, const char *name ) - : QMainWindow( parent, name ), +MainWindow::MainWindow( QWidget *parent, const char *name, WFlags fl ) + : QMainWindow( parent, name, fl ), doc( 0 ) { setRightJustification(TRUE); editorStack = new QWidgetStack( this ); fileSelector = new FileSelector( "text/html", editorStack, "fileselector" ); fileSelector->setCloseVisible( FALSE ); editorStack->addWidget( fileSelector, 0 ); editor = new Qt3::QTextEdit( editorStack ); editor->setTextFormat( Qt::RichText ); editorStack->addWidget( editor, 1 ); setupActions(); QObject::connect( fileSelector, SIGNAL(closeMe()), this, SLOT(showEditTools()) ); QObject::connect( fileSelector, SIGNAL(fileSelected(const DocLnk &)), this, SLOT(openFile(const DocLnk &)) ); QObject::connect( fileSelector, SIGNAL(newSelected(const DocLnk&)), this, SLOT(newFile(const DocLnk&)) ); if ( fileSelector->fileCount() < 1 ) fileNew(); else { fileOpen(); } doConnections( editor ); setCentralWidget( editorStack ); } MainWindow::~MainWindow() { save(); } void MainWindow::setupActions() { setToolBarsMovable(false); tbMenu = new QToolBar( this ); tbMenu->setHorizontalStretchable( TRUE ); QMenuBar *menu = new QMenuBar( tbMenu ); tbEdit = new QToolBar( this ); QPopupMenu *file = new QPopupMenu( this ); menu->insertItem( tr("File"), file ); QPopupMenu *edit = new QPopupMenu( this ); menu->insertItem( tr("Edit"), edit ); // ### perhaps these shortcut keys should have some // IPaq keys defined??? QAction *a; a = new QAction( tr( "New" ), Resource::loadPixmap("new"), QString::null, 0, this, 0 ); connect( a, SIGNAL(activated()), this, SLOT(fileNew()) ); a->addTo( file ); a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); connect( a, SIGNAL(activated()), this, SLOT(fileOpen()) ); a->addTo( file ); a = new QAction( tr( "Undo" ), Resource::loadIconSet("undo"), QString::null, 0, this, "editUndo" ); connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) ); connect( editor, SIGNAL(undoAvailable(bool)), a, SLOT(setEnabled(bool)) ); a->addTo( tbEdit ); a->addTo( edit ); a = new QAction( tr( "Redo" ), Resource::loadIconSet("redo"), QString::null, 0, this, "editRedo" ); connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) ); connect( editor, SIGNAL(redoAvailable(bool)), a, SLOT(setEnabled(bool)) ); a->addTo( tbEdit ); a->addTo( edit ); edit->insertSeparator(); a = new QAction( tr( "Copy" ), Resource::loadIconSet("copy"), QString::null, 0, this, "editCopy" ); connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); connect( editor, SIGNAL(copyAvailable(bool)), a, SLOT(setEnabled(bool)) ); a->addTo( tbEdit ); a->addTo( edit ); a = new QAction( tr( "Cut" ), Resource::loadIconSet("cut"), QString::null, 0, this, "editCut" ); connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); connect( editor, SIGNAL(copyAvailable(bool)), a, SLOT(setEnabled(bool)) ); a->addTo( tbEdit ); a->addTo( edit ); a = new QAction( tr( "Paste" ), Resource::loadPixmap("paste"), QString::null, 0, this, "editPaste" ); connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); a->addTo( tbEdit ); a->addTo( edit ); tbFont = new QToolBar( this ); tbFont->setLabel( "Font Actions" ); tbFont->setHorizontalStretchable(TRUE); comboFont = new QComboBox( FALSE, tbFont ); FontDatabase db; QStringList f= db.families(); comboFont->insertStringList( db.families() ); connect( comboFont, SIGNAL( activated( const QString & ) ), this, SLOT( textFamily( const QString & ) ) ); comboFont->setCurrentItem( comboFont->listBox()->index( comboFont->listBox()->findItem( QApplication::font().family() ) ) ); comboFont->setMaximumWidth(90); comboSize = new QComboBox( TRUE, tbFont ); QValueList<int> sizes = db.standardSizes(); QValueList<int>::Iterator it = sizes.begin(); for ( ; it != sizes.end(); ++it ) comboSize->insertItem( QString::number( *it ) ); connect( comboSize, SIGNAL( activated( const QString & ) ), this, SLOT( textSize( const QString & ) ) ); comboSize->lineEdit()->setText( QString::number( QApplication::font().pointSize() ) ); comboSize->setFixedWidth( 38 ); tbStyle = new QToolBar( this ); tbStyle->setLabel( "Style Actions" ); actionTextBold = new QAction( tr( "Bold" ), Resource::loadPixmap("bold"), QString::null, CTRL + Key_B, this, "textBold" ); connect( actionTextBold, SIGNAL( activated() ), this, SLOT( textBold() ) ); actionTextBold->addTo( tbStyle ); actionTextBold->setToggleAction( TRUE ); actionTextItalic = new QAction( tr( "Italic" ), Resource::loadPixmap("italic"), tr( "&Italic" ), CTRL + Key_I, this, "textItalic" ); connect( actionTextItalic, SIGNAL( activated() ), this, SLOT( textItalic() ) ); actionTextItalic->addTo( tbStyle ); actionTextItalic->setToggleAction( TRUE ); actionTextUnderline = new QAction( tr( "Underline" ), Resource::loadPixmap("underline"), tr( "&Underline" ), CTRL + Key_U, this, "textUnderline" ); connect( actionTextUnderline, SIGNAL( activated() ), this, SLOT( textUnderline() ) ); actionTextUnderline->addTo( tbStyle ); actionTextUnderline->setToggleAction( TRUE ); alignMenu = new ButtonMenu( tbStyle ); alignMenu->insertItem( Resource::loadPixmap("left"), tr("Left"), AlignLeft ); alignMenu->insertItem( Resource::loadPixmap("center"), tr("Center"), AlignCenter ); alignMenu->insertItem( Resource::loadPixmap("right"), tr("Right"), AlignRight ); alignMenu->insertItem( Resource::loadPixmap("opie-write/justify"), tr("Full"), Qt3::AlignJustify ); connect( alignMenu, SIGNAL(activated(int)), this, SLOT(textAlign(int)) ); } Qt3::QTextEdit *MainWindow::currentEditor() const { return editor; } void MainWindow::doConnections( Qt3::QTextEdit *e ) { connect( e, SIGNAL( currentFontChanged( const QFont & ) ), this, SLOT( fontChanged( const QFont & ) ) ); connect( e, SIGNAL( currentColorChanged( const QColor & ) ), this, SLOT( colorChanged( const QColor & ) ) ); connect( e, SIGNAL( currentAlignmentChanged( int ) ), this, SLOT( alignmentChanged( int ) ) ); } void MainWindow::updateFontSizeCombo( const QFont &f ) { comboSize->clear(); FontDatabase fdb; QValueList<int> sizes = fdb.pointSizes( f.family() ); QValueList<int>::Iterator it = sizes.begin(); for ( ; it != sizes.end(); ++it ) comboSize->insertItem( QString::number( *it ) ); } void MainWindow::editUndo() { if ( !currentEditor() ) return; currentEditor()->undo(); } void MainWindow::editRedo() { if ( !currentEditor() ) return; currentEditor()->redo(); } void MainWindow::editCut() { if ( !currentEditor() ) return; currentEditor()->cut(); } void MainWindow::editCopy() { if ( !currentEditor() ) return; currentEditor()->copy(); } void MainWindow::editPaste() { if ( !currentEditor() ) return; currentEditor()->paste(); } void MainWindow::textBold() { if ( !currentEditor() ) return; currentEditor()->setBold( actionTextBold->isOn() ); } void MainWindow::textUnderline() { if ( !currentEditor() ) return; currentEditor()->setUnderline( actionTextUnderline->isOn() ); } void MainWindow::textItalic() { if ( !currentEditor() ) return; currentEditor()->setItalic( actionTextItalic->isOn() ); } void MainWindow::textFamily( const QString &f ) { if ( !currentEditor() ) return; currentEditor()->setFamily( f ); currentEditor()->viewport()->setFocus(); } void MainWindow::textSize( const QString &p ) { if ( !currentEditor() ) return; currentEditor()->setPointSize( p.toInt() ); currentEditor()->viewport()->setFocus(); } void MainWindow::textStyle( int i ) { if ( !currentEditor() ) return; if ( i == 0 ) currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayBlock, Qt3::QStyleSheetItem::ListDisc ); else if ( i == 1 ) currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem, Qt3::QStyleSheetItem::ListDisc ); else if ( i == 2 ) currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem, Qt3::QStyleSheetItem::ListCircle ); else if ( i == 3 ) currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem, Qt3::QStyleSheetItem::ListSquare ); else if ( i == 4 ) currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem, Qt3::QStyleSheetItem::ListDecimal ); else if ( i == 5 ) currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem, Qt3::QStyleSheetItem::ListLowerAlpha ); else if ( i == 6 ) currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem, Qt3::QStyleSheetItem::ListUpperAlpha ); currentEditor()->viewport()->setFocus(); } void MainWindow::textAlign( int a ) { if ( !currentEditor() ) return; editor->setAlignment( a ); } void MainWindow::fontChanged( const QFont &f ) { comboFont->setCurrentItem( comboFont->listBox()->index( comboFont->listBox()->findItem( f.family() ) ) ); updateFontSizeCombo( f ); comboSize->lineEdit()->setText( QString::number( f.pointSize() ) ); actionTextBold->setOn( f.bold() ); actionTextItalic->setOn( f.italic() ); actionTextUnderline->setOn( f.underline() ); } void MainWindow::colorChanged( const QColor & ) { } void MainWindow::alignmentChanged( int a ) { if ( ( a == Qt3::AlignAuto ) || ( a & AlignLeft )) { alignMenu->setCurrentItem(AlignLeft); } else if ( ( a & AlignCenter ) ) { alignMenu->setCurrentItem(AlignCenter); } else if ( ( a & AlignRight ) ) { alignMenu->setCurrentItem(AlignRight); } else if ( ( a & Qt3::AlignJustify ) ) { alignMenu->setCurrentItem(Qt3::AlignJustify); } } void MainWindow::editorChanged( QWidget * ) { if ( !currentEditor() ) return; fontChanged( currentEditor()->font() ); colorChanged( currentEditor()->color() ); alignmentChanged( currentEditor()->alignment() ); } void MainWindow::fileOpen() { save(); editorStack->raiseWidget( fileSelector ); fileSelector->reread(); hideEditTools(); fileSelector->setNewVisible( TRUE ); clear(); updateCaption(); } void MainWindow::fileRevert() { qDebug( "QMainWindow::fileRevert needs to be done" ); } void MainWindow::fileNew() { editor->setTextFormat( Qt::RichText ); save(); newFile(DocLnk()); } void MainWindow::insertTable() { qDebug( "MainWindow::insertTable() needs to be done" ); } void MainWindow::newFile( const DocLnk &dl ) { DocLnk nf = dl; nf.setType( "text/html" ); clear(); editorStack->raiseWidget( editor ); editor->viewport()->setFocus(); doc = new DocLnk( nf ); updateCaption(); } void MainWindow::openFile( const DocLnk &dl ) { FileManager fm; QString txt; if ( !fm.loadFile( dl, txt ) ) qDebug( "couldn't open file" ); clear(); editorStack->raiseWidget( editor ); editor->viewport()->setFocus(); doc = new DocLnk( dl ); editor->setText( txt ); editor->setModified( FALSE ); updateCaption(); } void MainWindow::showEditTools( void ) { tbMenu->show(); tbEdit->show(); tbFont->show(); tbStyle->show(); } void MainWindow::hideEditTools( void ) { // let's reset the buttons... actionTextBold->setOn( FALSE ); actionTextItalic->setOn( FALSE ); actionTextUnderline->setOn( FALSE ); //comboFont->setCurrentText( QApplication::font().family() ); comboSize->lineEdit()->setText( QString::number(QApplication::font().pointSize() ) ); tbMenu->hide(); tbEdit->hide(); tbFont->hide(); tbStyle->hide(); } void MainWindow::save() { if ( !doc ) return; if ( !editor->isModified() ) return; QString rt = editor->text(); // quick hack to get around formatting... editor->setTextFormat( Qt::PlainText ); QString pt = editor->text(); editor->setTextFormat( Qt::RichText ); if ( doc->name().isEmpty() ) { unsigned ispace = pt.find( ' ' ); unsigned ienter = pt.find( '\n' ); int i = (ispace < ienter) ? ispace : ienter; QString docname; if ( i == -1 ) { if ( pt.isEmpty() ) docname = "Empty Text"; else docname = pt; } else { docname = pt.left( i ); } doc->setName(docname); } FileManager fm; fm.saveFile( *doc, rt ); } void MainWindow::clear() { delete doc; doc = 0; editor->clear(); } void MainWindow::updateCaption() { if ( !doc ) setCaption( tr("Rich Text Editor") ); else { QString s = doc->name(); if ( s.isEmpty() ) s = tr( "Unnamed" ); setCaption( s + " - " + tr("Rich Text Editor") ); } } void MainWindow::closeEvent( QCloseEvent *e ) { if ( editorStack->visibleWidget() == editor ) { // call fileOpen instead, don't close it fileOpen(); e->ignore(); } else { e->accept(); } } #include "mainwindow.moc" 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 @@ -1,113 +1,115 @@ /********************************************************************** ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** ** This file is part of the Qtopia Environment. ** ** Licensees holding valid Qtopia Developer license may use this ** file in accordance with the Qtopia Developer License Agreement ** provided with the Software. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING ** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR ** PURPOSE. ** ** email sales@trolltech.com for information about Qtopia License ** Agreements. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <qmainwindow.h> #include <qwidgetstack.h> #include <qmap.h> #include <qpe/filemanager.h> class QAction; class QComboBox; class FileSelectorView; class FileSelector; class QToolBar; class ButtonMenu; namespace Qt3 { class QTextEdit; } class MainWindow : public QMainWindow { Q_OBJECT public: - MainWindow( QWidget *parent = 0, const char *name = 0 ); + MainWindow( QWidget *parent = 0, const char *name = 0 , WFlags fl = 0); ~MainWindow(); + static QString appName() { return QString::fromLatin1("opie-write"); } + protected: void closeEvent( QCloseEvent *e ); private slots: // new file functions void fileOpen(); void fileRevert(); void fileNew(); void editUndo(); void editRedo(); void editCut(); void editCopy(); void editPaste(); void textBold(); void textUnderline(); void textItalic(); void textFamily( const QString &f ); void textSize( const QString &p ); void textStyle( int s ); void textAlign( int ); void fontChanged( const QFont &f ); void colorChanged( const QColor &c ); void alignmentChanged( int a ); void editorChanged( QWidget * ); // these are from textedit, we may need them void insertTable(); void newFile( const DocLnk & ); void openFile( const DocLnk & ); void showEditTools(); void hideEditTools(); private: void updateFontSizeCombo( const QFont &f ); void setupActions(); Qt3::QTextEdit *currentEditor() const; void doConnections( Qt3::QTextEdit *e ); void updateCaption(); void save(); void clear(); // added these from the textedit QWidgetStack *editorStack; FileSelector *fileSelector; QToolBar *tbMenu; QToolBar *tbEdit; QToolBar *tbFont; QToolBar *tbStyle; QAction *actionTextBold, *actionTextUnderline, *actionTextItalic; QComboBox *comboFont, *comboSize; ButtonMenu *alignMenu; DocLnk *doc; Qt3::QTextEdit* editor; }; #endif 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,46 +1,27 @@ -TEMPLATE = app -CONFIG += qt warn_on release -DESTDIR = $(OPIEDIR)/bin +CONFIG += qt warn on release quick-app + HEADERS = qcleanuphandler.h \ qcomplextext_p.h \ qrichtext_p.h \ qstylesheet.h \ qtextedit.h \ mainwindow.h SOURCES = qcomplextext.cpp \ qstylesheet.cpp \ qrichtext_p.cpp \ qrichtext.cpp \ qtextedit.cpp \ main.cpp \ mainwindow.cpp INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe TARGET = opie-write -TRANSLATIONS = ../../../i18n/de/opie-write.ts \ - ../../../i18n/nl/opie-write.ts \ - ../../../i18n/da/opie-write.ts \ - ../../../i18n/xx/opie-write.ts \ - ../../../i18n/en/opie-write.ts \ - ../../../i18n/es/opie-write.ts \ - ../../../i18n/fr/opie-write.ts \ - ../../../i18n/hu/opie-write.ts \ - ../../../i18n/ja/opie-write.ts \ - ../../../i18n/ko/opie-write.ts \ - ../../../i18n/no/opie-write.ts \ - ../../../i18n/pl/opie-write.ts \ - ../../../i18n/pt/opie-write.ts \ - ../../../i18n/pt_BR/opie-write.ts \ - ../../../i18n/sl/opie-write.ts \ - ../../../i18n/zh_CN/opie-write.ts \ - ../../../i18n/zh_TW/opie-write.ts - include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/apps/oxygen/main.cpp b/noncore/apps/oxygen/main.cpp index c8fcdb4..ac992aa 100644 --- a/noncore/apps/oxygen/main.cpp +++ b/noncore/apps/oxygen/main.cpp @@ -1,29 +1,24 @@ /*************************************************************************** application: : Oxygen begin : September 2002 copyright : ( C ) 2002 by Carsten Niehaus email : cniehaus@handhelds.org **************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * ( at your option ) any later version. * * * **************************************************************************/ #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 @@ -1,157 +1,157 @@ /*************************************************************************** application: : Oxygen begin : September 2002 copyright : ( C ) 2002 by Carsten Niehaus email : cniehaus@handhelds.org **************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * ( at your option ) any later version. * * * **************************************************************************/ #include "oxygen.h" #include <qapplication.h> #include <qtabwidget.h> #include "calcdlg.h" #include "calcdlgui.h" #include "datawidgetui.h" #include "psewidget.h" -Oxygen::Oxygen() : QMainWindow() +Oxygen::Oxygen( QWidget *parent, const char *name, WFlags f) : QMainWindow( parent, name, f ) { loadNames(); calcDlgUI *CalcDlgUI = new calcDlgUI(); PSEWidget *pse = new PSEWidget(names); dataWidgetUI *DataWidgetUI = new dataWidgetUI(names); - + setCaption( tr( "Oxygen" ) ); - + QTabWidget *tabw = new QTabWidget( this , "qtab" ); tabw->addTab( pse, tr( "PSE" )); tabw->addTab( DataWidgetUI , tr( "Data" ) ); tabw->addTab( CalcDlgUI, tr( "Calculations" ) ); setCentralWidget( tabw ); } void Oxygen::loadNames() { names.clear(); names.append( tr("Hydrogen") ); names.append( tr("Helium") ); names.append( tr("Lithium") ); names.append( tr("Beryllium") ); names.append( tr("Boron") ); names.append( tr("Carbon") ); names.append( tr("Nitrogen") ); names.append( tr("Oxygen") ); names.append( tr("Fluorine") ); names.append( tr("Neon") ); names.append( tr("Sodium") ); names.append( tr("Magnesium") ); names.append( tr("Aluminum") ); names.append( tr("Silicon") ); names.append( tr("Phosphorus") ); names.append( tr("Sulfur") ); names.append( tr("Chlorine") ); names.append( tr("Argon") ); names.append( tr("Potassium") ); names.append( tr("Calcium") ); names.append( tr("Scandium") ); names.append( tr("Titanium") ); names.append( tr("Vanadium") ); names.append( tr("Chromium") ); names.append( tr("Manganese") ); names.append( tr("Iron") ); names.append( tr("Cobalt") ); names.append( tr("Nickel") ); names.append( tr("Copper") ); names.append( tr("Zinc") ); names.append( tr("Gallium") ); names.append( tr("Germanium") ); names.append( tr("Arsenic") ); names.append( tr("Selenium") ); names.append( tr("Bromine") ); names.append( tr("Krypton") ); names.append( tr("Rubidium") ); names.append( tr("Strontium") ); names.append( tr("Yttrium") ); names.append( tr("Zirconium") ); names.append( tr("Niobium") ); names.append( tr("Molybdenum") ); names.append( tr("Technetium") ); names.append( tr("Ruthenium") ); names.append( tr("Rhodium") ); names.append( tr("Palladium") ); names.append( tr("Silver") ); names.append( tr("Cadmium") ); names.append( tr("Indium") ); names.append( tr("Tin") ); names.append( tr("Antimony") ); names.append( tr("Tellurium") ); names.append( tr("Iodine") ); names.append( tr("Xenon") ); names.append( tr("Cesium") ); names.append( tr("Barium") ); names.append( tr("Lanthanum") ); names.append( tr("Cerium") ); names.append( tr("Praseodymium") ); names.append( tr("Neodymium") ); names.append( tr("Promethium") ); names.append( tr("Samarium") ); names.append( tr("Europium") ); names.append( tr("Gadolinium") ); names.append( tr("Terbium") ); names.append( tr("Dysprosium") ); names.append( tr("Holmium") ); names.append( tr("Erbium") ); names.append( tr("Thulium") ); names.append( tr("Ytterbium") ); names.append( tr("Lutetium") ); names.append( tr("Hafnium") ); names.append( tr("Tantalum") ); names.append( tr("Tungsten") ); names.append( tr("Rhenium") ); names.append( tr("Osmium") ); names.append( tr("Iridium") ); names.append( tr("Platinum") ); names.append( tr("Gold") ); names.append( tr("Mercury") ); names.append( tr("Thallium") ); names.append( tr("Lead") ); names.append( tr("Bismuth") ); names.append( tr("Polonium") ); names.append( tr("Astatine") ); names.append( tr("Radon") ); names.append( tr("Francium") ); names.append( tr("Radium") ); names.append( tr("Actinium") ); names.append( tr("Thorium") ); names.append( tr("Protactinium") ); names.append( tr("Uranium") ); names.append( tr("Neptunium") ); names.append( tr("Plutonium") ); names.append( tr("Americium") ); names.append( tr("Curium") ); names.append( tr("Berkelium") ); names.append( tr("Californium") ); names.append( tr("Einsteinium") ); names.append( tr("Fermium") ); names.append( tr("Mendelevium") ); names.append( tr("Nobelium") ); names.append( tr("Lawrencium") ); names.append( tr("Rutherfordium") ); names.append( tr("Dubnium") ); names.append( tr("Seaborgium") ); names.append( tr("Bohrium") ); names.append( tr("Hassium") ); names.append( tr("Meitnerium") ); } 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 @@ -1,24 +1,25 @@ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * ( at your option ) any later version. * * * **************************************************************************/ class QStringList; #include <qmainwindow.h> 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,49 +1,27 @@ -TEMPLATE = app -CONFIG = qt warn_on release +CONFIG = qt warn_on release quick-app HEADERS = oxygen.h \ kmolcalc.h \ kmolelements.h \ calcdlgui.h \ dataTable.h \ psewidget.h \ oxyframe.h \ datawidgetui.h SOURCES = main.cpp \ oxygen.cpp \ kmolcalc.cpp \ calcdlgui.cpp \ kmolelements.cpp \ dataTable.cpp \ psewidget.cpp \ oxyframe.cpp \ datawidgetui.cpp INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include -LIBS += -lqpe -lstdc++ +LIBS += -lqpe INTERFACES = calcdlg.ui -TARGET = oxygen -DESTDIR = $(OPIEDIR)/bin - -TRANSLATIONS = ../../../i18n/de/oxygen.ts \ - ../../../i18n/nl/oxygen.ts \ - ../../../i18n/xx/oxygen.ts \ - ../../../i18n/en/oxygen.ts \ - ../../../i18n/es/oxygen.ts \ - ../../../i18n/fr/oxygen.ts \ - ../../../i18n/hu/oxygen.ts \ - ../../../i18n/ja/oxygen.ts \ - ../../../i18n/ko/oxygen.ts \ - ../../../i18n/no/oxygen.ts \ - ../../../i18n/pl/oxygen.ts \ - ../../../i18n/pt/oxygen.ts \ - ../../../i18n/pt_BR/oxygen.ts \ - ../../../i18n/sl/oxygen.ts \ - ../../../i18n/zh_CN/oxygen.ts \ - ../../../i18n/zh_TW/oxygen.ts \ - ../../../i18n/it/oxygen.ts \ - ../../../i18n/da/oxygen.ts - +TARGET = oxygen include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/apps/tableviewer/main.cpp b/noncore/apps/tableviewer/main.cpp index d17ee65..ce39c84 100644 --- a/noncore/apps/tableviewer/main.cpp +++ b/noncore/apps/tableviewer/main.cpp @@ -1,32 +1,25 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "tableviewer.h" #include <qpe/qpeapplication.h> +#include <opie/oapplicationfactory.h> -int main( int argc, char ** argv ) -{ - QPEApplication a( argc, argv ); +OPIE_EXPORT_APP( OApplicationFactory<TableViewerWindow> ) - TableViewerWindow mw; - mw.setCaption( TableViewerWindow::tr("Table Viewer") ); - a.showMainWidget(&mw); - - return a.exec(); -} diff --git a/noncore/apps/tableviewer/tableviewer.h b/noncore/apps/tableviewer/tableviewer.h index 817db21..f56a460 100644 --- a/noncore/apps/tableviewer/tableviewer.h +++ b/noncore/apps/tableviewer/tableviewer.h @@ -1,112 +1,113 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef Tableviewer_H #define Tableviewer_H #include <qmainwindow.h> #include "db/common.h" #include <qpe/fileselector.h> /* Forward class declarations */ class QWidgetStack; class QDialog; class QMenuBar; class TVListView; class TVBrowseView; class TVFilterView; class TVEditView; class DBStore; class TableViewerWindow: public QMainWindow { Q_OBJECT public: + static QString appName() { return QString::fromLatin1("tableviewer"); } TableViewerWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); ~TableViewerWindow(); public slots: void selectDocument(); void newDocument(); void saveDocument(); void setDocument(const QString &); void openDocument(const DocLnk &); void firstItem(); void lastItem(); void nextItem(); void previousItem(); void listViewSlot(); void browseViewSlot(); void filterViewSlot(); void editItemSlot(); void newItemSlot(); void deleteItemSlot(); void editKeysSlot(); /* reveiw the sig. for this function TODO */ void searchOnKey(int, TVVariant); void setPrimaryKey(int); /* TODO add new event */ protected: /* TODO add new slots */ private slots: /* TODO add other widgets used here */ private: bool dirty; QMenuBar *menu; QToolBar *navigation; TVListView *listView; TVBrowseView *browseView; TVFilterView *filterView; TVEditView *editView; FileSelector *fileSelector; DocLnk doc; QWidgetStack *cw; DBStore *ds; TableState ts; /* not a pointer.. this class keeps the state */ enum UserState { BrowseState = 0, ListState, FilterState, EditState, FileState, }; UserState current_view; void applyFilter(); }; #endif 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,60 +1,58 @@ -TEMPLATE = app -CONFIG = qt warn_on debug -DESTDIR = $(OPIEDIR)/bin +CONFIG = qt warn_on debug quick-app SUBDIRS = db ui HEADERS = tableviewer.h \ xmlencodeattr.h \ ui/commonwidgets.h \ ui/tvbrowseview.h \ ui/tvlistview.h \ ui/tvfilterview.h \ ui/tveditview.h \ ui/browsekeyentry.h \ ui/filterkeyentry.h \ ui/tvkeyedit.h \ db/datacache.h \ db/common.h \ db/xmlsource.h \ db/csvsource.h SOURCES = main.cpp \ tableviewer.cpp \ xmlencodeattr.cpp \ ui/commonwidgets.cpp \ ui/tvbrowseview.cpp \ ui/tvfilterview.cpp \ ui/browsekeyentry.cpp \ ui/filterkeyentry.cpp \ ui/tvlistview.cpp \ ui/tveditview.cpp \ ui/tvkeyedit.cpp \ db/datacache.cpp \ db/xmlsource.cpp \ db/csvsource.cpp \ db/common.cpp INTERFACES = ui/tvkeyedit_gen.ui TARGET = tableviewer INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe TRANSLATIONS = ../../../i18n/de/tableviewer.ts \ ../../../i18n/nl/tableviewer.ts \ ../../../i18n/da/tableviewer.ts \ ../../../i18n/xx/tableviewer.ts \ ../../../i18n/en/tableviewer.ts \ ../../../i18n/es/tableviewer.ts \ ../../../i18n/fr/tableviewer.ts \ ../../../i18n/hu/tableviewer.ts \ ../../../i18n/ja/tableviewer.ts \ ../../../i18n/ko/tableviewer.ts \ ../../../i18n/no/tableviewer.ts \ ../../../i18n/pl/tableviewer.ts \ ../../../i18n/pt/tableviewer.ts \ ../../../i18n/pt_BR/tableviewer.ts \ ../../../i18n/sl/tableviewer.ts \ ../../../i18n/zh_CN/tableviewer.ts \ ../../../i18n/zh_TW/tableviewer.ts include ( $(OPIEDIR)/include.pro ) 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 @@ -1,28 +1,22 @@ /*************************************************************************** main.cpp ------------------- begin : November 2002 copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org> ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation. * * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE * * * ***************************************************************************/ -#include <qpe/qpeapplication.h> #include <qmainwindow.h> #include "tinykate.h" +#include <opie/oapplicationfactory.h> -int main( int argc, char ** argv ) -{ - QPEApplication a( argc, argv ); +OPIE_EXPORT_APP( OApplicationFactory<TinyKate> ) - TinyKate m; - a.showMainWidget(&m ); - return a.exec(); -} diff --git a/noncore/apps/tinykate/opie-tinykate.control b/noncore/apps/tinykate/opie-tinykate.control index 1fde467..9bc0130 100644 --- a/noncore/apps/tinykate/opie-tinykate.control +++ b/noncore/apps/tinykate/opie-tinykate.control @@ -1,9 +1,9 @@ Package: opie-tinykate -Files: plugins/application/libtinykate.so* bin/tinykate apps/Applications/tinykate.desktop pics/tinykate $OPIEDIR/lib/libtinykate.so.1.0.0 $OPIEDIR/lib/libtinykate.so.1.0 $OPIEDIR/lib/libtinykate.so.1 +Files: plugins/application/libkate.so* bin/kate apps/Applications/tinykate.desktop pics/tinykate $OPIEDIR/lib/libtinykate.so.1.0.0 $OPIEDIR/lib/libtinykate.so.1.0 $OPIEDIR/lib/libtinykate.so.1 Priority: optional Section: opie/applications Maintainer: Opie Team <opie@handhelds.org> Architecture: arm Depends: task-opie-minimal Description: Kate for opie Version: $QPE_VERSION$EXTRAVERSION 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 @@ -1,64 +1,66 @@ /*************************************************************************** tinykate.h Tiny KATE mainwindow ------------------- begin : November 2002 copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org> ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation. * * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE * * * ***************************************************************************/ #ifndef __TINYKATE_H__ #define __TINYKATE_H__ #include <qmainwindow.h> #include <opie/otabwidget.h> #include <ktexteditor.h> class QToolButton; class QAction; class QPopupMenu; class TinyKate : public QMainWindow { Q_OBJECT public: TinyKate( QWidget *parent=0, const char *name=0, WFlags f = 0); ~TinyKate( ); + static QString appName() { return QString::fromLatin1( "kate" ); }; + public slots: void slotNew(); void setDocument(const QString& fileref); protected slots: void slotOpen(); void slotClose(); void slotCurrentChanged(QWidget *); void slotSave(); void slotSaveAs(); protected: void open(const QString&); private: QString currentFileName; OTabWidget *tabwidget; KTextEditor::View *currentView; bool shutDown; QToolButton *editCopy, *editCut, *editPaste, *editUndo, *editRedo, *editFindReplace; QAction *viewIncFontSizes, *viewDecFontSizes, *utilSettings; QPopupMenu *hlmenu; uint nextUnnamed; uint viewCount; }; #endif // __TINYKATE_H__ 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,22 +1,22 @@ TEMPLATE = app -CONFIG = qt warn_on release +CONFIG = qt warn_on release quick-app DESTDIR = $(OPIEDIR)/bin HEADERS = tinykate.h SOURCES = tinykate.cpp main.cpp INTERFACES = INCLUDEPATH += $(OPIEDIR)/include \ $(OPIEDIR)/noncore/apps/tinykate/libkate \ $(OPIEDIR)/noncore/apps/tinykate/libkate/microkde \ $(OPIEDIR)/noncore/apps/tinykate/libkate/document \ $(OPIEDIR)/noncore/apps/tinykate/libkate/view \ $(OPIEDIR)/noncore/apps/tinykate/libkate/interfaces \ $(OPIEDIR)/noncore/apps/tinykate/libkate/ktexteditor \ $(OPIEDIR)/noncore/apps/tinykate/libkate/qt3back DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -ltinykate -lopie -TARGET = tinykate +TARGET = kate include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/apps/zsafe/.cvsignore b/noncore/apps/zsafe/.cvsignore new file mode 100644 index 0000000..2f8556e --- a/dev/null +++ b/noncore/apps/zsafe/.cvsignore @@ -0,0 +1,3 @@ +Makefile +Makefile.in +moc* diff --git a/noncore/settings/aqpkg/.cvsignore b/noncore/settings/aqpkg/.cvsignore index 2888d4a..4183697 100644 --- a/noncore/settings/aqpkg/.cvsignore +++ b/noncore/settings/aqpkg/.cvsignore @@ -1,2 +1,3 @@ Makefile* moc* +.moc* diff --git a/noncore/settings/aqpkg/aqpkg.pro b/noncore/settings/aqpkg/aqpkg.pro index d241d1b..882cfd4 100644 --- a/noncore/settings/aqpkg/aqpkg.pro +++ b/noncore/settings/aqpkg/aqpkg.pro @@ -1,62 +1,40 @@ -TEMPLATE = app -CONFIG = qt warn_on release +CONFIG = qt warn_on release quick-app HEADERS = global.h \ mainwin.h \ datamgr.h \ settingsimpl.h \ ipkg.h \ packagewin.h \ package.h \ installdlgimpl.h \ instoptionsimpl.h \ destination.h \ utils.h \ server.h \ letterpushbutton.h \ inputdlg.h \ categoryfilterimpl.h SOURCES = mainwin.cpp \ datamgr.cpp \ mem.cpp \ settingsimpl.cpp \ ipkg.cpp \ main.cpp \ packagewin.cpp \ package.cpp \ installdlgimpl.cpp \ instoptionsimpl.cpp \ destination.cpp \ utils.cpp \ server.cpp \ letterpushbutton.cpp \ inputdlg.cpp \ version.cpp \ categoryfilterimpl.cpp -INTERFACES = TARGET = aqpkg INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lopie -lstdc++ -DESTDIR = $(OPIEDIR)/bin - -TRANSLATIONS = ../../../i18n/de/aqpkg.ts \ - ../../../i18n/nl/aqpkg.ts \ - ../../../i18n/xx/aqpkg.ts \ - ../../../i18n/en/aqpkg.ts \ - ../../../i18n/es/aqpkg.ts \ - ../../../i18n/fr/aqpkg.ts \ - ../../../i18n/hu/aqpkg.ts \ - ../../../i18n/ja/aqpkg.ts \ - ../../../i18n/ko/aqpkg.ts \ - ../../../i18n/no/aqpkg.ts \ - ../../../i18n/pl/aqpkg.ts \ - ../../../i18n/pt/aqpkg.ts \ - ../../../i18n/pt_BR/aqpkg.ts \ - ../../../i18n/sl/aqpkg.ts \ - ../../../i18n/zh_CN/aqpkg.ts \ - ../../../i18n/zh_TW/aqpkg.ts \ - ../../../i18n/it/aqpkg.ts \ - ../../../i18n/da/aqpkg.ts - include ( $(OPIEDIR)/include.pro ) + diff --git a/noncore/settings/aqpkg/main.cpp b/noncore/settings/aqpkg/main.cpp index b7f8b7b..179f8b7 100644 --- a/noncore/settings/aqpkg/main.cpp +++ b/noncore/settings/aqpkg/main.cpp @@ -1,78 +1,38 @@ /* This file is part of the OPIE Project =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> .=l. 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. */ -#ifdef QWS -#include <qpe/qpeapplication.h> -#include <qpe/qcopenvelope_qws.h> -#else -#include <qapplication.h> -#endif - -#include <qobjectdefs.h> - #include "mainwin.h" -#include "server.h" - -#include "global.h" +#include <opie/oapplicationfactory.h> /* be less intrusive for translation -zecke */ extern QString LOCAL_SERVER; extern QString LOCAL_IPKGS; -int main(int argc, char *argv[]) -{ -#ifdef QWS - QPEApplication a( argc, argv ); -#else - QApplication a( argc, argv ); -#endif - -#ifdef QWS - // Disable suspend mode - QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; -#endif - - LOCAL_SERVER = QObject::tr( "Installed packages" ); - LOCAL_IPKGS = QObject::tr( "Local packages" ); - - MainWindow *win = new MainWindow(); - a.setMainWidget(win); - win->showMaximized(); - - a.exec(); - -#ifdef QWS - // Reenable suspend mode - QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; -#endif - #ifdef _DEBUG - DumpUnfreed(); - #endif -} +OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp index 42093cf..dbe694e 100644 --- a/noncore/settings/aqpkg/mainwin.cpp +++ b/noncore/settings/aqpkg/mainwin.cpp @@ -1,1233 +1,1240 @@ /* This file is part of the OPIE Project - + =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> .=l. 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 <linux/limits.h> #include <unistd.h> #include <qpe/qcopenvelope_qws.h> #include <qmenubar.h> #include <qpe/qpeapplication.h> #include <qtoolbar.h> #include <qpe/config.h> #include <qpe/resource.h> #include <qaction.h> #include <qcombobox.h> #include <qfile.h> #include <qlabel.h> #include <qlayout.h> #include <qlineedit.h> #include <qlistview.h> #include <qmenubar.h> #include <qmessagebox.h> #include <qpopupmenu.h> #include <qprogressbar.h> #include <qtimer.h> #include <qwhatsthis.h> #include <qwidgetstack.h> #include "categoryfilterimpl.h" #include "datamgr.h" #include "global.h" #include "inputdlg.h" #include "ipkg.h" #include "installdlgimpl.h" #include "letterpushbutton.h" #include "mainwin.h" #include "packagewin.h" #include "settingsimpl.h" #include "utils.h" extern int compareVersions( const char *v1, const char *v2 ); -MainWindow :: MainWindow() - : QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) +MainWindow :: MainWindow( QWidget* parent, const char* name, WFlags fl ) + : QMainWindow( parent, name, fl || WStyle_ContextHelp ) { + // Disable suspend mode + QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; + + LOCAL_SERVER = QObject::tr( "Installed packages" ); + LOCAL_IPKGS = QObject::tr( "Local packages" ); + setCaption( tr( "AQPkg - Package Manager" ) ); // Create UI widgets initMainWidget(); initProgressWidget(); // Build menu and tool bars setToolBarsMovable( FALSE ); QToolBar *bar = new QToolBar( this ); bar->setHorizontalStretchable( TRUE ); QMenuBar *mb = new QMenuBar( bar ); mb->setMargin( 0 ); bar = new QToolBar( this ); // Find toolbar findBar = new QToolBar( this ); addToolBar( findBar, QMainWindow::Top, true ); findBar->setHorizontalStretchable( true ); findEdit = new QLineEdit( findBar ); QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) ); findBar->setStretchableWidget( findEdit ); connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) ); // Quick jump toolbar jumpBar = new QToolBar( this ); addToolBar( jumpBar, QMainWindow::Top, true ); jumpBar->setHorizontalStretchable( true ); QWidget *w = new QWidget( jumpBar ); jumpBar->setStretchableWidget( w ); QGridLayout *layout = new QGridLayout( w ); char text[2]; text[1] = '\0'; for ( int i = 0 ; i < 26 ; ++i ) { text[0] = 'A' + i; LetterPushButton *b = new LetterPushButton( text, w ); connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); layout->addWidget( b, i / 13, i % 13); } QAction *a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, w, 0 ); a->setWhatsThis( tr( "Click here to hide the Quick Jump toolbar." ) ); connect( a, SIGNAL( activated() ), this, SLOT( hideJumpBar() ) ); a->addTo( jumpBar ); jumpBar->hide(); // Packages menu QPopupMenu *popup = new QPopupMenu( this ); a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 ); a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) ); a->addTo( popup ); a->addTo( bar ); actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 ); actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) ); actionUpgrade->addTo( popup ); actionUpgrade->addTo( bar ); iconDownload = Resource::loadPixmap( "aqpkg/download" ); iconRemove = Resource::loadPixmap( "aqpkg/remove" ); actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) ); actionDownload->addTo( popup ); actionDownload->addTo( bar ); a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 ); a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) ); a->addTo( popup ); a->addTo( bar ); popup->insertSeparator(); a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); a->setWhatsThis( tr( "Click here to configure this application." ) ); connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) ); a->addTo( popup ); mb->insertItem( tr( "Actions" ), popup ); // View menu popup = new QPopupMenu( this ); actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); actionUninstalled->setToggleAction( TRUE ); actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) ); connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) ); actionUninstalled->addTo( popup ); actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); actionInstalled->setToggleAction( TRUE ); actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) ); connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) ); actionInstalled->addTo( popup ); actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); actionUpdated->setToggleAction( TRUE ); actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) ); connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) ); actionUpdated->addTo( popup ); popup->insertSeparator(); actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 ); actionFilter->setToggleAction( TRUE ); actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) ); connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) ); actionFilter->addTo( popup ); a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 ); a->setWhatsThis( tr( "Click here to change package category to used filter." ) ); connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) ); a->addTo( popup ); popup->insertSeparator(); a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); a->setWhatsThis( tr( "Click here to search for text in package names." ) ); connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) ); a->addTo( popup ); actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); actionFindNext->setEnabled( FALSE ); actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) ); connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) ); actionFindNext->addTo( popup ); actionFindNext->addTo( findBar ); popup->insertSeparator(); a = new QAction( tr( "Quick Jump keypad" ), Resource::loadPixmap( "aqpkg/keyboard" ), QString::null, 0, this, 0 ); a->setWhatsThis( tr( "Click here to display/hide keypad to allow quick movement through the package list." ) ); connect( a, SIGNAL( activated() ), this, SLOT( displayJumpBar() ) ); a->addTo( popup ); mb->insertItem( tr( "View" ), popup ); // Finish find toolbar creation a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) ); a->addTo( findBar ); findBar->hide(); // Create widget stack and add UI widgets stack = new QWidgetStack( this ); stack->addWidget( progressWindow, 2 ); stack->addWidget( networkPkgWindow, 1 ); setCentralWidget( stack ); stack->raiseWidget( progressWindow ); // Delayed call to finish initialization QTimer::singleShot( 100, this, SLOT( init() ) ); } MainWindow :: ~MainWindow() { delete mgr; + + // Reenable suspend mode + QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; } void MainWindow :: initMainWidget() { networkPkgWindow = new QWidget( this ); QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow ); serversList = new QComboBox( networkPkgWindow ); connect( serversList, SIGNAL(activated(int)), this, SLOT(serverSelected(int)) ); QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) ); installedIcon = Resource::loadPixmap( "installed" ); updatedIcon = Resource::loadPixmap( "aqpkg/updated" ); packagesList = new QListView( networkPkgWindow ); packagesList->addColumn( tr( "Packages" ), 225 ); QWhatsThis::add( packagesList, tr( "This is a listing of all packages for the server feed selected above.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) ); QPEApplication::setStylusOperation( packagesList->viewport(), QPEApplication::RightOnHold ); connect( packagesList, SIGNAL(rightButtonPressed(QListViewItem *,const QPoint &,int)), this, SLOT(slotDisplayPackage(QListViewItem *)) ); QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 ); QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); hbox1->addWidget( l ); hbox1->addWidget( serversList ); vbox->addWidget( packagesList ); downloadEnabled = TRUE; } void MainWindow :: initProgressWidget() { progressWindow = new QWidget( this ); QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 ); m_status = new QLabel( progressWindow ); m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); layout->addWidget( m_status ); m_progress = new QProgressBar( progressWindow ); layout->addWidget( m_progress ); } void MainWindow :: init() { #ifdef QWS // read download directory from config file Config cfg( "aqpkg" ); cfg.setGroup( "settings" ); currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); // showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); #endif stack->raiseWidget( progressWindow ); mgr = new DataManager(); connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) ); connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), this, SLOT( setProgressMessage( const QString & ) ) ); connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) ); mgr->loadServers(); showUninstalledPkgs = false; showInstalledPkgs = false; showUpgradedPkgs = false; categoryFilterEnabled = false; updateData(); stack->raiseWidget( networkPkgWindow ); } void MainWindow :: setDocument( const QString &doc ) { // Remove path from package QString package = Utils::getPackageNameFromIpkFilename( doc ); // First select local server for ( int i = 0 ; i < serversList->count() ; ++i ) { if ( serversList->text( i ) == LOCAL_IPKGS ) { serversList->setCurrentItem( i ); break; } } serverSelected( 0 ); // Now set the check box of the selected package for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); item != 0 ; item = (QCheckListItem *)item->nextSibling() ) { if ( item->text().startsWith( package ) ) { item->setOn( true ); break; } } } void MainWindow :: displaySettings() { SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); if ( dlg->showDlg() ) { stack->raiseWidget( progressWindow ); updateData(); stack->raiseWidget( networkPkgWindow ); } delete dlg; } void MainWindow :: closeEvent( QCloseEvent *e ) { // If install dialog is visible, return to main view, otherwise close app QWidget *widget = stack->visibleWidget(); if ( widget != networkPkgWindow && widget != progressWindow ) { if ( widget ) delete widget; stack->raiseWidget( networkPkgWindow ); e->ignore(); } else { e->accept(); } } void MainWindow :: displayFindBar() { findBar->show(); findEdit->setFocus(); } void MainWindow :: displayJumpBar() { jumpBar->show(); } void MainWindow :: repeatFind() { searchForPackage( findEdit->text() ); } void MainWindow :: findPackage( const QString &text ) { actionFindNext->setEnabled( !text.isEmpty() ); searchForPackage( text ); } void MainWindow :: hideFindBar() { findBar->hide(); } void MainWindow :: hideJumpBar() { jumpBar->hide(); } void MainWindow :: filterUninstalledPackages() { showUninstalledPkgs = actionUninstalled->isOn(); if ( showUninstalledPkgs ) { showInstalledPkgs = FALSE; showUpgradedPkgs = FALSE; } serverSelected( -1 ); actionInstalled->setOn( FALSE ); actionUpdated->setOn( FALSE ); } void MainWindow :: filterInstalledPackages() { showInstalledPkgs = actionInstalled->isOn(); if ( showInstalledPkgs ) { showUninstalledPkgs = FALSE; showUpgradedPkgs = FALSE; } serverSelected( -1 ); actionUninstalled->setOn( FALSE ); actionUpdated->setOn( FALSE ); } void MainWindow :: filterUpgradedPackages() { showUpgradedPkgs = actionUpdated->isOn(); if ( showUpgradedPkgs ) { showUninstalledPkgs = FALSE; showInstalledPkgs = FALSE; } serverSelected( -1 ); actionUninstalled->setOn( FALSE ); actionInstalled->setOn( FALSE ); } bool MainWindow :: setFilterCategory() { // Get categories; CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this ); if ( dlg.exec() == QDialog::Accepted ) { categoryFilter = dlg.getSelectedFilter(); if ( categoryFilter == "" ) return false; categoryFilterEnabled = true; serverSelected( -1 ); actionFilter->setOn( TRUE ); return true; } return false; } void MainWindow :: filterCategory() { if ( !actionFilter->isOn() ) { filterByCategory( FALSE ); } else { actionFilter->setOn( filterByCategory( TRUE ) ); } } bool MainWindow :: filterByCategory( bool val ) { if ( val ) { if ( categoryFilter == "" ) { if ( !setFilterCategory() ) return false; } categoryFilterEnabled = true; serverSelected( -1 ); return true; } else { // Turn off filter categoryFilterEnabled = false; serverSelected( -1 ); return false; } } void MainWindow :: raiseMainWidget() { stack->raiseWidget( networkPkgWindow ); } void MainWindow :: raiseProgressWidget() { stack->raiseWidget( progressWindow ); } void MainWindow :: enableUpgrade( bool enabled ) { actionUpgrade->setEnabled( enabled ); } void MainWindow :: enableDownload( bool enabled ) { if ( enabled ) { actionDownload->setIconSet( iconDownload ); actionDownload->setText( tr( "Download" ) ); actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); } else { actionDownload->setIconSet( iconRemove ); actionDownload->setText( tr( "Remove" ) ); actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) ); } } void MainWindow :: setProgressSteps( int numsteps ) { m_progress->setTotalSteps( numsteps ); } void MainWindow :: setProgressMessage( const QString &msg ) { m_status->setText( msg ); } void MainWindow :: updateProgress( int progress ) { m_progress->setProgress( progress ); } void MainWindow :: updateData() { m_progress->setTotalSteps( mgr->getServerList().count() ); serversList->clear(); packagesList->clear(); int activeItem = -1; int i = 0; QString serverName; QListIterator<Server> it( mgr->getServerList() ); Server *server; for ( ; it.current(); ++it, ++i ) { server = it.current(); serverName = server->getServerName(); m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) ); m_progress->setProgress( i ); qApp->processEvents(); if ( !server->isServerActive() ) { i--; continue; } serversList->insertItem( serverName ); if ( serverName == currentlySelectedServer ) activeItem = i; } // set selected server to be active server if ( activeItem != -1 ) serversList->setCurrentItem( activeItem ); serverSelected( 0, FALSE ); } void MainWindow :: serverSelected( int index ) { serverSelected( index, TRUE ); } void MainWindow :: serverSelected( int, bool raiseProgress ) { QPixmap nullIcon( installedIcon.size() ); nullIcon.fill( colorGroup().base() ); // display packages QString serverName = serversList->currentText(); currentlySelectedServer = serverName; Server *s = mgr->getServer( serverName ); QList<Package> &list = s->getPackageList(); QListIterator<Package> it( list ); // Display progress widget while loading list bool doProgress = ( list.count() > 200 ); if ( doProgress ) { if ( raiseProgress ) { stack->raiseWidget( progressWindow ); } m_progress->setTotalSteps( list.count() ); m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); } packagesList->clear(); #ifdef QWS // read download directory from config file Config cfg( "aqpkg" ); cfg.setGroup( "settings" ); cfg.writeEntry( "selectedServer", currentlySelectedServer ); #endif int i = 0; Package *package; for ( ; it.current(); ++it ) { // Update progress after every 100th package (arbitrary value, seems to give good balance) i++; if ( ( i % 100 ) == 0 ) { if ( doProgress ) { m_progress->setProgress( i ); } qApp->processEvents(); } QString text = ""; package = it.current(); // Apply show only uninstalled packages filter if ( showUninstalledPkgs && package->isInstalled() ) continue; // Apply show only installed packages filter if ( showInstalledPkgs && !package->isInstalled() ) continue; // Apply show only new installed packages filter if ( showUpgradedPkgs ) { if ( !package->isInstalled() || !package->getNewVersionAvailable() ) continue; } // Apply the section filter if ( categoryFilterEnabled && categoryFilter != "" ) { if ( package->getSection() == "" || categoryFilter.find( package->getSection().lower() ) == -1 ) continue; } // If the local server, only display installed packages if ( serverName == LOCAL_SERVER && !package->isInstalled() ) continue; QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(), QCheckListItem::CheckBox ); if ( package->isInstalled() ) { // If a different version of package is available, show update available icon // Otherwise, show installed icon if ( package->getNewVersionAvailable()) { item->setPixmap( 0, updatedIcon ); } else { item->setPixmap( 0, installedIcon ); } } else { item->setPixmap( 0, nullIcon ); } packagesList->insertItem( item ); } // If the local server or the local ipkgs server disable the download button if ( serverName == LOCAL_SERVER ) { downloadEnabled = TRUE; actionUpgrade->setEnabled( FALSE ); } else if ( serverName == LOCAL_IPKGS ) { downloadEnabled = FALSE; actionUpgrade->setEnabled( FALSE ); } else { downloadEnabled = TRUE; actionUpgrade->setEnabled( TRUE ); } enableDownload( downloadEnabled ); // Display this widget once everything is done if ( doProgress && raiseProgress ) { stack->raiseWidget( networkPkgWindow ); } } void MainWindow :: searchForPackage( const QString &text ) { if ( !text.isEmpty() ) { // look through package list for text startng at current position QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); if ( start == 0 ) start = (QCheckListItem *)packagesList->firstChild(); for ( QCheckListItem *item = start; item != 0 ; item = (QCheckListItem *)item->nextSibling() ) { if ( item->text().lower().find( text ) != -1 ) { packagesList->ensureItemVisible( item ); packagesList->setCurrentItem( item ); break; } } } } void MainWindow :: updateServer() { QString serverName = serversList->currentText(); // Update the current server // Display dialog // Disable buttons to stop silly people clicking lots on them :) // First, write out ipkg_conf file so that ipkg can use it mgr->writeOutIpkgConf(); Ipkg *ipkg = new Ipkg; ipkg->setOption( "update" ); InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ), tr( "Update lists" ) ); connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); reloadDocuments = FALSE; stack->addWidget( dlg, 3 ); stack->raiseWidget( dlg ); // delete progDlg; } void MainWindow :: upgradePackages() { // We're gonna do an upgrade of all packages // First warn user that this isn't recommended // TODO - ODevice???? QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" ); QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning, QMessageBox::Yes, QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , 0, this ); warn.adjustSize(); if ( warn.exec() == QMessageBox::Yes ) { // First, write out ipkg_conf file so that ipkg can use it mgr->writeOutIpkgConf(); // Now run upgrade Ipkg *ipkg = new Ipkg; ipkg->setOption( "upgrade" ); InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ), tr ( "Upgrade" ) ); connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); reloadDocuments = TRUE; stack->addWidget( dlg, 3 ); stack->raiseWidget( dlg ); } } void MainWindow :: downloadPackage() { bool doUpdate = true; if ( downloadEnabled ) { // See if any packages are selected bool found = false; if ( serversList->currentText() != LOCAL_SERVER ) { for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); item != 0 && !found; item = (QCheckListItem *)item->nextSibling() ) { if ( item->isOn() ) found = true; } } // If user selected some packages then download the and store the locally // otherwise, display dialog asking user what package to download from an http server // and whether to install it if ( found ) downloadSelectedPackages(); else downloadRemotePackage(); } else { doUpdate = false; for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); item != 0 ; item = (QCheckListItem *)item->nextSibling() ) { if ( item->isOn() ) { QString name = item->text(); int pos = name.find( "*" ); name.truncate( pos ); // if (there is a (installed), remove it pos = name.find( "(installed)" ); if ( pos > 0 ) name.truncate( pos - 1 ); Package *p = mgr->getServer( serversList->currentText() )->getPackage( name ); QString msgtext; msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() ); if ( QMessageBox::information( this, tr( "Are you sure?" ), msgtext, tr( "No" ), tr( "Yes" ) ) == 1 ) { doUpdate = true; QFile f( p->getFilename() ); f.remove(); } } } } if ( doUpdate ) { reloadData( 0x0 ); } } void MainWindow :: downloadSelectedPackages() { // First, write out ipkg_conf file so that ipkg can use it mgr->writeOutIpkgConf(); // Display dialog to user asking where to download the files to bool ok = FALSE; QString dir = ""; #ifdef QWS // read download directory from config file Config cfg( "aqpkg" ); cfg.setGroup( "settings" ); dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); #endif QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); if ( ok && !text.isEmpty() ) dir = text; // user entered something and pressed ok else return; // user entered nothing or pressed cancel #ifdef QWS // Store download directory in config file cfg.writeEntry( "downloadDir", dir ); #endif // Get starting directory char initDir[PATH_MAX]; getcwd( initDir, PATH_MAX ); // Download each package Ipkg ipkg; connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); ipkg.setOption( "download" ); ipkg.setRuntimeDirectory( dir ); for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); item != 0 ; item = (QCheckListItem *)item->nextSibling() ) { if ( item->isOn() ) { ipkg.setPackage( item->text() ); ipkg.runIpkg( ); } } } void MainWindow :: downloadRemotePackage() { // Display dialog bool ok; QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this ); if ( !ok || package.isEmpty() ) return; // DownloadRemoteDlgImpl dlg( this, "Install", true ); // if ( dlg.exec() == QDialog::Rejected ) // return; // grab details from dialog // QString package = dlg.getPackageLocation(); InstallData *item = new InstallData(); item->option = "I"; item->packageName = package; QList<InstallData> workingPackages; workingPackages.setAutoDelete( TRUE ); workingPackages.append( item ); InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) ); connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); reloadDocuments = TRUE; stack->addWidget( dlg, 3 ); stack->raiseWidget( dlg ); } void MainWindow :: applyChanges() { stickyOption = ""; // First, write out ipkg_conf file so that ipkg can use it mgr->writeOutIpkgConf(); // Now for each selected item // deal with it QList<InstallData> workingPackages; workingPackages.setAutoDelete( TRUE ); for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); item != 0 ; item = (QCheckListItem *)item->nextSibling() ) { if ( item->isOn() ) { InstallData *instdata = dealWithItem( item ); if ( instdata ) workingPackages.append( instdata ); else return; } } if ( workingPackages.count() == 0 ) { // Nothing to do QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) ); return; } // do the stuff InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) ); connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); reloadDocuments = TRUE; stack->addWidget( dlg, 3 ); stack->raiseWidget( dlg ); } // decide what to do - either remove, upgrade or install // Current rules: // If not installed - install // If installed and different version available - upgrade // If installed and version up to date - remove InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) { QString name = item->text(); // Get package Server *s = mgr->getServer( serversList->currentText() ); Package *p = s->getPackage( name ); // If the package has a filename then it is a local file if ( p->isPackageStoredLocally() ) name = p->getFilename(); QString option; QString dest = "root"; if ( !p->isInstalled() ) { InstallData *newitem = new InstallData(); newitem->option = "I"; newitem->packageName = name; return newitem; } else { InstallData *newitem = new InstallData(); newitem->option = "D"; - // If local file, remove using package name, not filename if ( p->isPackageStoredLocally() ) name = item->text(); if ( !p->isPackageStoredLocally() ) newitem->packageName = p->getInstalledPackageName(); else newitem->packageName = name; if ( p->getInstalledTo() ) { newitem->destination = p->getInstalledTo(); } else { newitem->destination = p->getLocalPackage()->getInstalledTo(); } // Now see if version is newer or not int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); // If the version requested is older and user selected a local ipk file, then reinstall the file if ( p->isPackageStoredLocally() && val == -1 ) val = 0; if ( val == -2 ) { // Error - should handle } else if ( val == -1 ) { // Version available is older - remove only newitem->option = "D"; - // If local file, remove using package name, not filename if ( p->isPackageStoredLocally() ) name = item->text(); } else { QString caption; QString text; QString secondButton; QString secondOption; if ( val == 0 ) { // Version available is the same - option to remove or reinstall caption = tr( "Do you wish to remove or reinstall\n%1?" ); text = tr( "Remove or ReInstall" ); secondButton = tr( "ReInstall" ); secondOption = "R"; // Internal action code, do not translate } else if ( val == 1 ) { // Version available is newer - option to remove or upgrade caption = tr( "Do you wish to remove or upgrade\n%1?" ); text = tr( "Remove or Upgrade" ); secondButton = tr( "Upgrade" ); secondOption = "U"; // Internal action code, do not translate } // Sticky option not implemented yet, but will eventually allow // the user to say something like 'remove all' if ( stickyOption == "" ) { QString msgtext; msgtext = caption.arg( ( const char * )name ); QuestionDlg dlg( text, msgtext, secondButton ); switch( dlg.exec() ) { case 0: // Cancel delete newitem; return 0x0; break; case 1: // Remove newitem->option = "D"; // If local file, remove using package name, not filename if ( p->isPackageStoredLocally() ) name = item->text(); break; case 2: // Reinstall or Upgrade newitem->option = secondOption; break; } } else { // newitem->option = stickyOption; } } // Check if we are reinstalling the same version if ( newitem->option != "R" ) newitem->recreateLinks = true; else newitem->recreateLinks = false; // User hit cancel (on dlg - assume remove) return newitem; } } void MainWindow :: reloadData( InstallDlgImpl *dlg ) { stack->raiseWidget( progressWindow ); if ( dlg ) { dlg->close(); delete dlg; } mgr->reloadServerData(); serverSelected( -1, FALSE ); #ifdef QWS if ( reloadDocuments ) { m_status->setText( tr( "Updating Launcher..." ) ); // Finally let the main system update itself QCopEnvelope e("QPE/System", "linkChanged(QString)"); QString lf = QString::null; e << lf; } #endif stack->raiseWidget( networkPkgWindow ); } void MainWindow :: letterPushed( QString t ) { QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); if ( packagesList->firstChild() == 0 ) return; QCheckListItem *item; if ( start == 0 ) { item = (QCheckListItem *)packagesList->firstChild(); start = top; } else item = (QCheckListItem *)start->nextSibling(); if ( item == 0 ) item = (QCheckListItem *)packagesList->firstChild(); do { if ( item->text().lower().startsWith( t.lower() ) ) { packagesList->setSelected( item, true ); packagesList->ensureItemVisible( item ); break; } item = (QCheckListItem *)item->nextSibling(); if ( !item ) item = (QCheckListItem *)packagesList->firstChild(); } while ( item != start); } void MainWindow :: slotDisplayPackage( QListViewItem *item ) { QString itemstr( ((QCheckListItem*)item)->text() ); PackageWindow *p = new PackageWindow( mgr->getServer( serversList->currentText() )->getPackage( itemstr ) ); p->showMaximized(); } QuestionDlg::QuestionDlg( const QString &caption, const QString &text, const QString &secondbtn ) : QWidget( 0x0, 0x0, WType_Modal | WType_TopLevel | WStyle_Dialog ) { setCaption( caption ); resize( 175, 100 ); - + QGridLayout *layout = new QGridLayout( this ); - + QLabel *l = new QLabel( text, this ); l->setAlignment( AlignCenter | WordBreak ); layout->addMultiCellWidget( l, 0, 0, 0, 1 ); - + btn1 = new QPushButton( tr( "Remove" ), this ); connect( btn1, SIGNAL(clicked()), this, SLOT(slotButtonPressed()) ); layout->addWidget( btn1, 1, 0 ); - + btn2 = new QPushButton( secondbtn, this ); connect( btn2, SIGNAL(clicked()), this, SLOT(slotButtonPressed()) ); layout->addWidget( btn2, 1, 1 ); - + executing = FALSE; } int QuestionDlg::exec() { show(); if ( !executing ) { executing = TRUE; qApp->enter_loop(); } - + return buttonpressed; } void QuestionDlg::slotButtonPressed() { if ( sender() == btn1 ) buttonpressed = 1; else if ( sender() == btn2 ) buttonpressed = 2; else 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 @@ -1,175 +1,176 @@ /* This file is part of the OPIE Project =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> .=l. 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 MAINWIN_H #define MAINWIN_H #include <qmainwindow.h> #include <qpixmap.h> class DataManager; class InstallData; class InstallDlgImpl; class QAction; class QCheckListItem; class QComboBox; class QLabel; class QLineEdit; class QListView; class QListViewItem; class QToolBar; class QProgressBar; class QPushButton; class QWidgetStack; 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" ); }; protected: void closeEvent( QCloseEvent* e ); private: DataManager *mgr; QWidgetStack *stack; QToolBar *findBar; QToolBar *jumpBar; QLineEdit *findEdit; QAction *actionFindNext; QAction *actionFilter; QAction *actionUpgrade; QAction *actionDownload; QAction *actionUninstalled; QAction *actionInstalled; QAction *actionUpdated; QPixmap iconDownload; QPixmap iconRemove; int mnuShowUninstalledPkgsId; int mnuShowInstalledPkgsId; int mnuShowUpgradedPkgsId; int mnuFilterByCategory; int mnuSetFilterCategory; // Main package list widget QWidget *networkPkgWindow; QComboBox *serversList; QListView *packagesList; QPixmap installedIcon; QPixmap updatedIcon; QString currentlySelectedServer; QString categoryFilter; QString stickyOption; bool categoryFilterEnabled; bool showJumpTo; bool showUninstalledPkgs; bool showInstalledPkgs; bool showUpgradedPkgs; bool downloadEnabled; bool reloadDocuments; void initMainWidget(); void updateData(); void serverSelected( int index, bool showProgress ); void searchForPackage( const QString & ); bool filterByCategory( bool val ); void downloadSelectedPackages(); void downloadRemotePackage(); InstallData *dealWithItem( QCheckListItem *item ); // Progress widget QWidget *progressWindow; QLabel *m_status; QProgressBar *m_progress; void initProgressWidget(); public slots: void setDocument( const QString &doc ); void displayFindBar(); void displayJumpBar(); void repeatFind(); void findPackage( const QString & ); void hideFindBar(); void hideJumpBar(); void displaySettings(); void filterUninstalledPackages(); void filterInstalledPackages(); void filterUpgradedPackages(); void filterCategory(); bool setFilterCategory(); void raiseMainWidget(); void raiseProgressWidget(); void enableUpgrade( bool ); void enableDownload( bool ); void reloadData( InstallDlgImpl * ); private slots: void init(); void setProgressSteps( int ); void setProgressMessage( const QString & ); void updateProgress( int ); void serverSelected( int index ); void updateServer(); void upgradePackages(); void downloadPackage(); void applyChanges(); void letterPushed( QString t ); void slotDisplayPackage( QListViewItem * ); }; class QuestionDlg : public QWidget { Q_OBJECT public: QuestionDlg( const QString &caption, const QString &text, const QString &secondbtn ); int exec(); private: QPushButton *btn1; QPushButton *btn2; bool executing; int buttonpressed; private slots: void slotButtonPressed(); }; #endif 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 @@ -1,34 +1,27 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "sysinfo.h" #include <qpe/qpeapplication.h> +#include <opie/oapplicationfactory.h> -int main( int argc, char *argv[] ) -{ - QPEApplication a( argc, argv ); - - SystemInfo *si = new SystemInfo(); - a.showMainWidget( si ); - - return a.exec(); -} +OPIE_EXPORT_APP( OApplicationFactory<SystemInfo> ) diff --git a/noncore/settings/sysinfo/storage.cpp b/noncore/settings/sysinfo/storage.cpp index c4474d5..4ef7122 100644 --- a/noncore/settings/sysinfo/storage.cpp +++ b/noncore/settings/sysinfo/storage.cpp @@ -1,187 +1,178 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ // additions copyright 2002 by L.J. Potter #include <qpe/storage.h> #include <qlabel.h> #include <qlayout.h> #include <qscrollview.h> #include <qtimer.h> #include <qwhatsthis.h> #include "graph.h" #include "storage.h" #include <stdio.h> #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) #include <sys/vfs.h> #include <mntent.h> #endif FileSysInfo::FileSysInfo( QWidget *parent, const char *name ) : QWidget( parent, name ) { QVBoxLayout *tmpvb = new QVBoxLayout( this ); QScrollView *sv = new QScrollView( this ); tmpvb->addWidget( sv, 0, 0 ); sv->setResizePolicy( QScrollView::AutoOneFit ); sv->setFrameStyle( QFrame::NoFrame ); container = new QWidget( sv->viewport() ); sv->addChild( container ); vb = 0x0; storage = new StorageInfo( this ); connect( storage, SIGNAL( disksChanged() ), this, SLOT( disksChanged() ) ); - + lines.setAutoDelete(TRUE); rebuildDisks = TRUE; updateMounts(); startTimer( 5000 ); } + void FileSysInfo::timerEvent(QTimerEvent*) { updateMounts(); } 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; vb = new QVBoxLayout( container/*, n > 3 ? 1 : 5*/ ); bool frst=TRUE; - + FileSystem *fs; for ( QListIterator<FileSystem> it(storage->fileSystems()); it.current(); ++it ) { fs = it.current(); - + if ( !frst ) { QFrame *f = new QFrame( container ); vb->addWidget(f); f->setFrameStyle( QFrame::HLine | QFrame::Sunken ); lines.append(f); f->show(); } frst = FALSE; - + MountInfo *mi = new MountInfo( fs, container ); vb->addWidget( mi ); disks.insert( fs->path(), mi ); mi->show(); QString tempstr = fs->name().left( 2 ); if ( tempstr == tr( "CF" ) ) QWhatsThis::add( mi, tr( "This graph represents how much memory is currently used on this Compact Flash memory card." ) ); else if ( tempstr == tr( "Ha" ) ) QWhatsThis::add( mi, tr( "This graph represents how much storage is currently used on this hard drive." ) ); else if ( tempstr == tr( "SD" ) ) QWhatsThis::add( mi, tr( "This graph represents how much memory is currently used on this Secure Digital memory card." ) ); else if ( tempstr == tr( "SC" ) ) QWhatsThis::add( mi, tr( "This graph represents how much storage is currently used on this hard drive." ) ); else if ( tempstr == tr( "In" ) ) QWhatsThis::add( mi, tr( "This graph represents how much memory is currently used of the built-in memory (i.e. Flash memory) on this handheld device." ) ); else if ( tempstr == tr( "RA" ) ) QWhatsThis::add( mi, tr( "This graph represents how much memory is currently used of the temporary RAM disk." ) ); } vb->addStretch(); } else { for (QDictIterator<MountInfo> i(disks); i.current(); ++i) i.current()->updateData(); } - + rebuildDisks = FALSE; } void FileSysInfo::disksChanged() { rebuildDisks = TRUE; } MountInfo::MountInfo( FileSystem *filesys, QWidget *parent, const char *name ) : QWidget( parent, name ) { QVBoxLayout *vb = new QVBoxLayout( this, 3 ); totalSize = new QLabel( this ); vb->addWidget( totalSize ); fs = filesys; title = fs->name(); - + data = new GraphData(); graph = new BarGraph( this ); graph->setFrameStyle( QFrame::Panel | QFrame::Sunken ); vb->addWidget( graph, 1 ); graph->setData( data ); legend = new GraphLegend( this ); legend->setOrientation(Horizontal); vb->addWidget( legend ); legend->setData( data ); updateData(); } MountInfo::~MountInfo() { delete data; - delete fs; } void MountInfo::updateData() { long mult = fs->blockSize() / 1024; long div = 1024 / fs->blockSize(); if ( !mult ) mult = 1; if ( !div ) div = 1; long total = fs->totalBlocks() * mult / div; long avail = fs->availBlocks() * mult / div; long used = total - avail; totalSize->setText( title + tr(" : %1 kB").arg( total ) ); data->clear(); data->addItem( tr("Used (%1 kB)").arg(used), used ); data->addItem( tr("Available (%1 kB)").arg(avail), avail ); graph->repaint( FALSE ); legend->update(); graph->show(); legend->show(); } 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 @@ -1,33 +1,34 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** ********************************************************************** ** ** Enhancements by: Dan Williams, <williamsdr@acm.org> ** **********************************************************************/ #include <qwidget.h> class SystemInfo : public QWidget { Q_OBJECT public: SystemInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); + static QString appName() { return QString::fromLatin1("sysinfo"); } }; diff --git a/noncore/settings/sysinfo/sysinfo.pro b/noncore/settings/sysinfo/sysinfo.pro index 2582ea2..2322989 100644 --- a/noncore/settings/sysinfo/sysinfo.pro +++ b/noncore/settings/sysinfo/sysinfo.pro @@ -1,49 +1,48 @@ -TEMPLATE = app -CONFIG = qt warn_on release -DESTDIR = $(OPIEDIR)/bin +CONFIG = qt warn_on release quick-app HEADERS = memory.h \ graph.h \ load.h \ storage.h \ processinfo.h \ modulesinfo.h \ detail.h \ versioninfo.h \ sysinfo.h SOURCES = main.cpp \ memory.cpp \ graph.cpp \ load.cpp \ storage.cpp \ processinfo.cpp \ modulesinfo.cpp \ detail.cpp \ versioninfo.cpp \ sysinfo.cpp -INTERFACES = + INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lopie -TARGET = sysinfo + +TARGET = sysinfo TRANSLATIONS = ../../../i18n/de/sysinfo.ts \ ../../../i18n/nl/sysinfo.ts \ ../../../i18n/xx/sysinfo.ts \ ../../../i18n/en/sysinfo.ts \ ../../../i18n/es/sysinfo.ts \ ../../../i18n/fr/sysinfo.ts \ ../../../i18n/hu/sysinfo.ts \ ../../../i18n/ja/sysinfo.ts \ ../../../i18n/ko/sysinfo.ts \ ../../../i18n/no/sysinfo.ts \ ../../../i18n/pl/sysinfo.ts \ ../../../i18n/pt/sysinfo.ts \ ../../../i18n/pt_BR/sysinfo.ts \ ../../../i18n/sl/sysinfo.ts \ ../../../i18n/zh_CN/sysinfo.ts \ ../../../i18n/zh_TW/sysinfo.ts \ ../../../i18n/da/sysinfo.ts include ( $(OPIEDIR)/include.pro ) |