summaryrefslogtreecommitdiff
path: root/noncore
authormickeyl <mickeyl>2003-10-30 13:18:08 (UTC)
committer mickeyl <mickeyl>2003-10-30 13:18:08 (UTC)
commit37414f207b147af4cf6778b323a0aa23127901bd (patch) (side-by-side diff)
treeb08c10043ab689b0a40425d268cd72226799b0cf /noncore
parentd53637f46cf217fc760d7aac58b4596843a73803 (diff)
downloadopie-37414f207b147af4cf6778b323a0aa23127901bd.zip
opie-37414f207b147af4cf6778b323a0aa23127901bd.tar.gz
opie-37414f207b147af4cf6778b323a0aa23127901bd.tar.bz2
apply patch to HEAD
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/checkbook/cfg.cpp15
-rw-r--r--noncore/apps/checkbook/cfg.h16
-rw-r--r--noncore/apps/checkbook/checkbook.cpp91
-rw-r--r--noncore/apps/checkbook/checkbook.h8
-rw-r--r--noncore/apps/checkbook/configuration.cpp16
-rw-r--r--noncore/apps/checkbook/configuration.h2
-rw-r--r--noncore/apps/checkbook/listedit.cpp4
-rw-r--r--noncore/apps/checkbook/mainwindow.cpp7
-rw-r--r--noncore/apps/checkbook/traninfo.cpp25
-rw-r--r--noncore/apps/checkbook/traninfo.h5
-rw-r--r--noncore/apps/checkbook/transaction.cpp92
-rw-r--r--noncore/apps/checkbook/transaction.h12
12 files changed, 249 insertions, 44 deletions
diff --git a/noncore/apps/checkbook/cfg.cpp b/noncore/apps/checkbook/cfg.cpp
index 1e0ec5c..0d5d9ed 100644
--- a/noncore/apps/checkbook/cfg.cpp
+++ b/noncore/apps/checkbook/cfg.cpp
@@ -44,4 +44,5 @@ Cfg::Cfg()
_showBalances=FALSE;
_pCategories=new CategoryList();
+ _bDirty=false;
}
@@ -53,6 +54,4 @@ Cfg::Cfg()
void Cfg::readStringList(Config &cfg, const char *sKey, QStringList &lst)
{
-qDebug( "%s", sKey );
-
QString sEntry;
int iCount;
@@ -87,4 +86,5 @@ void Cfg::readConfig(Config &config)
_sLastBook = config.readEntry("LastBook", "");
_showLastTab = config.readBoolEntry( "ShowLastTab", FALSE );
+ _bSavePayees = config.readBoolEntry( "SavePayees", FALSE );
// Account types
@@ -101,4 +101,7 @@ void Cfg::readConfig(Config &config)
}
+ // Payees
+ readStringList(config, "Payee", _Payees);
+
// Read Categories
QStringList lst;
@@ -132,4 +135,7 @@ void Cfg::readConfig(Config &config)
setCategories(lst);
}
+
+ // not dirty
+ _bDirty=false;
}
@@ -167,8 +173,12 @@ void Cfg::writeConfig(Config &config)
config.writeEntry( "LastBook", _sLastBook );
config.writeEntry( "ShowLastTab", _showLastTab );
+ config.writeEntry( "SavePayees", _bSavePayees );
// write account types
writeStringList(config, "AccType", _AccountTypes);
+ // write payees
+ writeStringList(config, "Payee", _Payees);
+
// write categories
QStringList lst=getCategories();
@@ -177,4 +187,5 @@ void Cfg::writeConfig(Config &config)
// commit write
config.write();
+ _bDirty=false;
}
diff --git a/noncore/apps/checkbook/cfg.h b/noncore/apps/checkbook/cfg.h
index 2b69368..20692b4 100644
--- a/noncore/apps/checkbook/cfg.h
+++ b/noncore/apps/checkbook/cfg.h
@@ -78,4 +78,9 @@ class Cfg
QStringList &getAccountTypes() { return(_AccountTypes); }
+ // --- Payees
+ QStringList &getPayees() { return(_Payees); }
+ bool getSavePayees() { return(_bSavePayees); }
+ void setSavePayees(bool bSave) { _bSavePayees=bSave; }
+
// --- Categories
QStringList getCategories();
@@ -99,4 +104,9 @@ class Cfg
void writeConfig(Config &cfg);
+ // --- dirty flag
+ bool isDirty() { return(_bDirty); }
+ void setDirty(bool bDirty) { _bDirty=bDirty; }
+
+ protected:
// --- reads list from config file
static void readStringList(Config &cfg, const char *sKey, QStringList &lst);
@@ -105,6 +115,4 @@ class Cfg
static void writeStringList(Config &cfg, const char *sKey, QStringList &lst);
-
-
private:
QString _currencySymbol;
@@ -113,7 +121,11 @@ class Cfg
bool _openLastBook;
bool _showLastTab;
+ bool _bDirty;
+ bool _bSavePayees;
QString _sLastBook;
QStringList _AccountTypes;
CategoryList *_pCategories;
+ QStringList _Payees;
+
};
diff --git a/noncore/apps/checkbook/checkbook.cpp b/noncore/apps/checkbook/checkbook.cpp
index c53e889..a42c824 100644
--- a/noncore/apps/checkbook/checkbook.cpp
+++ b/noncore/apps/checkbook/checkbook.cpp
@@ -50,11 +50,13 @@
#include <qpushbutton.h>
#include <qwhatsthis.h>
+#include <qpopupmenu.h>
-#define COL_ID 0
-#define COL_NUM 1
-#define COL_DATE 2
-#define COL_DESC 3
-#define COL_AMOUNT 4
-#define COL_BAL 5
+#define COL_ID 0
+#define COL_SORTDATE 1
+#define COL_NUM 2
+#define COL_DATE 3
+#define COL_DESC 4
+#define COL_AMOUNT 5
+#define COL_BAL 6
// --- Checkbook --------------------------------------------------------------
@@ -225,4 +227,7 @@ QWidget *Checkbook::initTransactions()
tranTable->setColumnWidthMode( COL_ID, QListView::Manual );
tranTable->setColumnWidth( COL_ID, 0);
+ tranTable->addColumn( tr( "SortDate" ) );
+ tranTable->setColumnWidthMode( COL_SORTDATE, QListView::Manual );
+ tranTable->setColumnWidth( COL_SORTDATE, 0);
tranTable->addColumn( tr( "Num" ) );
tranTable->addColumn( tr( "Date" ) );
@@ -238,5 +243,7 @@ QWidget *Checkbook::initTransactions()
QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold );
connect( tranTable, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ),
- this, SLOT( slotEditTran() ) );
+ this, SLOT( slotMenuTran(QListViewItem *, const QPoint &) ) );
+ connect( tranTable, SIGNAL( doubleClicked( QListViewItem * ) ),
+ this, SLOT( slotEditTran() ) );
_sortCol=COL_ID;
@@ -337,5 +344,5 @@ void Checkbook::loadCheckbook()
}
stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount );
- ( void ) new CBListItem( tran, tranTable, tran->getIdStr(), tran->number(), tran->datestr(), tran->desc(), stramount );
+ ( void ) new CBListItem( tran, tranTable, tran->getIdStr(), tran->datestr(false), tran->number(), tran->datestr(true), tran->desc(), stramount );
}
@@ -359,4 +366,5 @@ void Checkbook::loadCheckbook()
}
+
// --- adjustBalance ----------------------------------------------------------
void Checkbook::adjustBalance()
@@ -397,4 +405,5 @@ void Checkbook::accept()
}
+// --- slotPasswordClicked ----------------------------------------------------
void Checkbook::slotPasswordClicked()
{
@@ -465,4 +474,5 @@ void Checkbook::slotStartingBalanceChanged( const QString &newbalance )
+// --- slotNewTran ------------------------------------------------------------
void Checkbook::slotNewTran()
{
@@ -471,5 +481,5 @@ void Checkbook::slotNewTran()
traninfo->setDate(_dLastNew);
- Transaction *currtran = new Transaction( this, info->name(),
+ Transaction *currtran = new Transaction( this, true, info->name(),
traninfo,
_pCfg );
@@ -485,6 +495,6 @@ void Checkbook::slotNewTran()
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(),
+ ( void ) new CBListItem( traninfo, tranTable, traninfo->getIdStr(), traninfo->datestr(false),
+ traninfo->number(), traninfo->datestr(true), traninfo->desc(),
stramount );
resort();
@@ -493,4 +503,12 @@ void Checkbook::slotNewTran()
// save last date
_dLastNew = traninfo->date();
+
+ // save description in list of payees, if not in there
+ QStringList *pLst=&_pCfg->getPayees();
+ if( _pCfg->getSavePayees() && pLst->contains(traninfo->desc())==0 ) {
+ pLst->append( traninfo->desc() );
+ pLst->sort();
+ _pCfg->setDirty(true);
+ }
}
else
@@ -500,4 +518,6 @@ void Checkbook::slotNewTran()
}
+
+// --- slotEditTran -----------------------------------------------------------
void Checkbook::slotEditTran()
{
@@ -505,8 +525,8 @@ void Checkbook::slotEditTran()
if ( !curritem )
return;
-
+
TranInfo *traninfo=info->findTransaction( curritem->text(COL_ID) );
- Transaction *currtran = new Transaction( this, info->name(),
+ Transaction *currtran = new Transaction( this, false, info->name(),
traninfo,
_pCfg );
@@ -515,5 +535,6 @@ void Checkbook::slotEditTran()
{
curritem->setText( COL_NUM, traninfo->number() );
- curritem->setText( COL_DATE, traninfo->datestr() );
+ curritem->setText( COL_SORTDATE, traninfo->datestr(false) );
+ curritem->setText( COL_DATE, traninfo->datestr(true) );
curritem->setText( COL_DESC, traninfo->desc() );
@@ -528,4 +549,12 @@ void Checkbook::slotEditTran()
resort();
adjustBalance();
+
+ // save description in list of payees, if not in there
+ QStringList *pLst=&_pCfg->getPayees();
+ if( _pCfg->getSavePayees() && pLst->contains(traninfo->desc())==0 ) {
+ pLst->append( traninfo->desc() );
+ pLst->sort();
+ _pCfg->setDirty(true);
+ }
}
@@ -533,4 +562,32 @@ void Checkbook::slotEditTran()
}
+// --- slotMenuTran -----------------------------------------------------------
+void Checkbook::slotMenuTran(QListViewItem *item, const QPoint &pnt)
+{
+ // active item?
+ if( !item )
+ return;
+
+ // Display menu
+ QPopupMenu m;
+ m.insertItem( QWidget::tr( "Edit" ), 1 );
+ m.insertItem( QWidget::tr( "New" ), 2 );
+ m.insertItem( QWidget::tr( "Delete" ), 3 );
+ int r = m.exec( pnt );
+ switch(r) {
+ case 1:
+ slotEditTran();
+ break;
+ case 2:
+ slotNewTran();
+ break;
+ case 3:
+ slotDeleteTran();
+ break;
+ }
+}
+
+
+// --- slotDeleteTran ---------------------------------------------------------
void Checkbook::slotDeleteTran()
{
@@ -592,5 +649,5 @@ void Checkbook::drawBalanceChart()
if ( i == 1 || i == count / 2 || i == count )
{
- label = tran->datestr();
+ label = tran->datestr(true);
}
else
@@ -667,4 +724,5 @@ void CBListItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int
}
+// --- CBListItem::isAltBackground --------------------------------------------
bool CBListItem::isAltBackground()
{
@@ -724,7 +782,8 @@ void Checkbook::slotSortChanged( const QString &selc )
_sortCol=COL_NUM;
} else if( selc==tr("Date") ) {
- _sortCol=COL_DATE;
+ _sortCol=COL_SORTDATE;
}
info->setSortOrder( selc );
resort();
}
+
diff --git a/noncore/apps/checkbook/checkbook.h b/noncore/apps/checkbook/checkbook.h
index 1b6a2d3..e18f00c 100644
--- a/noncore/apps/checkbook/checkbook.h
+++ b/noncore/apps/checkbook/checkbook.h
@@ -49,4 +49,5 @@ class TranInfo;
class TranInfoList;
class Cfg;
+class QMouseEvent;
@@ -63,4 +64,7 @@ class Checkbook : public QDialog
void resort();
+ // members
+ TranInfoList *getTranList() { return(tranList); }
+
private:
CBInfo *info;
@@ -110,4 +114,5 @@ class Checkbook : public QDialog
void slotNewTran();
void slotEditTran();
+ void slotMenuTran(QListViewItem *, const QPoint &);
void slotDeleteTran();
void slotDrawGraph();
@@ -115,4 +120,5 @@ class Checkbook : public QDialog
};
+
// --- CBListItem -------------------------------------------------------------
class CBListItem : public QListViewItem
@@ -130,5 +136,5 @@ class CBListItem : public QListViewItem
TranInfo *getTranInfo() { return(_pTran); }
- private:
+ private:
TranInfo *_pTran;
QListView *owner;
diff --git a/noncore/apps/checkbook/configuration.cpp b/noncore/apps/checkbook/configuration.cpp
index 3f5662d..dfae446 100644
--- a/noncore/apps/checkbook/configuration.cpp
+++ b/noncore/apps/checkbook/configuration.cpp
@@ -77,4 +77,10 @@ Configuration::Configuration( QWidget *parent, Cfg &cfg )
_listEditCategories->addData( lst );
_mainWidget->addTab( _listEditCategories, tr( "&Categories" ) );
+
+ // Payees tab
+ _listEditPayees=new ListEdit(_mainWidget, "PAYEES");
+ _listEditPayees->addColumnDef( new ColumnDef( tr("Payee"), (ColumnDef::ColumnType)(ColumnDef::typeString | ColumnDef::typeUnique), tr("New Payee")) );
+ _listEditPayees->addData( cfg.getPayees() );
+ _mainWidget->addTab( _listEditPayees, tr("&Payees") );
}
@@ -139,4 +145,10 @@ QWidget *Configuration::initSettings(Cfg &cfg)
layout->addMultiCellWidget( lastTabCB, 4, 4, 0, 1 );
+ savePayees = new QCheckBox( tr("Save new description as payee"), container );
+ QWhatsThis::add( savePayees, tr("Click here to save new descriptions in the list of payess.") );
+ savePayees->setMaximumHeight(fh+5);
+ savePayees->setChecked( cfg.getSavePayees() );
+ layout->addMultiCellWidget( savePayees, 5, 5, 0, 1 );
+
return(control);
}
@@ -151,4 +163,5 @@ void Configuration::saveConfig(Cfg &cfg)
cfg.setOpenLastBook( openLastBookCB->isChecked() );
cfg.setShowLastTab( lastTabCB->isChecked() );
+ cfg.setSavePayees( savePayees->isChecked() );
// Typelist
@@ -159,3 +172,6 @@ void Configuration::saveConfig(Cfg &cfg)
_listEditCategories->storeInList( lst );
cfg.setCategories( lst );
+
+ // Payees
+ _listEditPayees->storeInList( cfg.getPayees() );
}
diff --git a/noncore/apps/checkbook/configuration.h b/noncore/apps/checkbook/configuration.h
index 5893502..663514d 100644
--- a/noncore/apps/checkbook/configuration.h
+++ b/noncore/apps/checkbook/configuration.h
@@ -53,7 +53,9 @@ class Configuration : public QDialog
QCheckBox *openLastBookCB;
QCheckBox *lastTabCB;
+ QCheckBox *savePayees;
QTabWidget *_mainWidget;
ListEdit *_listEditTypes;
ListEdit *_listEditCategories;
+ ListEdit *_listEditPayees;
// saves settings in config struct
diff --git a/noncore/apps/checkbook/listedit.cpp b/noncore/apps/checkbook/listedit.cpp
index 99a6531..37f05f0 100644
--- a/noncore/apps/checkbook/listedit.cpp
+++ b/noncore/apps/checkbook/listedit.cpp
@@ -117,4 +117,8 @@ void ListEdit::slotAdd()
slotClick(_currentItem, pnt, 0);
_typeTable->setSelected( _currentItem, true );
+
+ // make it selected
+ _typeEdit->setCursorPosition(0);
+ _typeEdit->setSelection(0, _typeEdit->text().length() );
}
diff --git a/noncore/apps/checkbook/mainwindow.cpp b/noncore/apps/checkbook/mainwindow.cpp
index 8d64cad..bf00102 100644
--- a/noncore/apps/checkbook/mainwindow.cpp
+++ b/noncore/apps/checkbook/mainwindow.cpp
@@ -59,5 +59,4 @@ MainWindow::MainWindow( QWidget* parent, const char* name, WFlags fl )
// Load configuration options
Config config( "checkbook" );
-qDebug( "Reading config" );
_cfg.readConfig( config );
@@ -315,4 +314,10 @@ void MainWindow::openBook(QListViewItem *curritem)
curritem->setText( posName + 1, tempstr );
}
+
+ // write config, if needed
+ if( _cfg.isDirty() ) {
+ Config config("checkbook");
+ _cfg.writeConfig( config );
+ }
}
delete currcb;
diff --git a/noncore/apps/checkbook/traninfo.cpp b/noncore/apps/checkbook/traninfo.cpp
index d880bb4..506f567 100644
--- a/noncore/apps/checkbook/traninfo.cpp
+++ b/noncore/apps/checkbook/traninfo.cpp
@@ -30,4 +30,5 @@
#include <qpe/config.h>
+#include <qpe/timestring.h>
QString tempstr;
@@ -125,12 +126,15 @@ TranInfo::TranInfo( Config config, int entry )
// --- datestr ----------------------------------------------------------------
-const QString &TranInfo::datestr()
+const QString &TranInfo::datestr(bool bDisplayDate)
{
- int y=td.year();
- y= y>=2000 && y<=2099 ? y-2000 : y;
- tempstr.sprintf( "%02d/%02d/%02d", y ,td.month(), td.day() );
- return( tempstr );
+ if( bDisplayDate ) {
+ tempstr=TimeString::numberDateString( td );
+ } else {
+ tempstr.sprintf( "%04d-%02d-%02d", td.year() ,td.month(), td.day() );
+ }
+ return(tempstr);
}
+
// --- getIdStr ---------------------------------------------------------------
const QString &TranInfo::getIdStr()
@@ -211,2 +215,13 @@ QString TranInfo::toString()
return(ret);
}
+
+
+// --- findMostRecentByDesc ---------------------------------------------------
+TranInfo *TranInfoList::findMostRecentByDesc( const QString &desc )
+{
+ for(TranInfo *cur=last(); cur; cur=prev()) {
+ if( cur->desc()==desc )
+ return( cur );
+ }
+ return(NULL);
+} \ No newline at end of file
diff --git a/noncore/apps/checkbook/traninfo.h b/noncore/apps/checkbook/traninfo.h
index 0abdc61..cbe0238 100644
--- a/noncore/apps/checkbook/traninfo.h
+++ b/noncore/apps/checkbook/traninfo.h
@@ -50,5 +50,5 @@ class TranInfo
const QString &desc() const { return d; }
const QDate &date() const { return td; }
- const QString &datestr();
+ const QString &datestr(bool = false);
bool withdrawal() const { return w; }
const QString &type() const { return t; }
@@ -94,4 +94,7 @@ class TranInfo
class TranInfoList : public QList<TranInfo>
{
+ public:
+ TranInfo *findMostRecentByDesc( const QString &desc );
+
protected:
int compareItems( QCollection::Item, QCollection::Item );
diff --git a/noncore/apps/checkbook/transaction.cpp b/noncore/apps/checkbook/transaction.cpp
index 138d0e6..9379da0 100644
--- a/noncore/apps/checkbook/transaction.cpp
+++ b/noncore/apps/checkbook/transaction.cpp
@@ -30,6 +30,8 @@
#include "traninfo.h"
#include "cfg.h"
+#include "checkbook.h"
#include <qpe/datebookmonth.h>
+#include <qpe/resource.h>
#include <qbuttongroup.h>
@@ -42,6 +44,6 @@
#include <qwhatsthis.h>
-Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *info,
- Cfg *pCfg )
+Transaction::Transaction( QWidget *parent, bool bNew, const QString &acctname,
+ TranInfo *info, Cfg *pCfg )
: QDialog( parent, 0, TRUE, WStyle_ContextHelp )
{
@@ -50,4 +52,5 @@ Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *in
setCaption( tempstr );
+ _bNew=bNew;
tran = info;
_pCfg=pCfg;
@@ -115,7 +118,10 @@ Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *in
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 );
+ _cbDesc=new QComboBox( true, container );
+ _cbDesc->insertStringList( _pCfg->getPayees() );
+ QWhatsThis::add( _cbDesc, tr( "Enter description of transaction here." ) );
+ layout->addMultiCellWidget( _cbDesc, 2, 2, 1, 3 );
+ connect( _cbDesc, SIGNAL( activated(const QString &) ), this, SLOT( slotActivated(const QString &) ) );
+
// Category
@@ -135,4 +141,5 @@ Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *in
layout->addMultiCellWidget( typeList, 4, 4, 1, 3 );
+
// Amount
label = new QLabel( tr( "Amount:" ), container );
@@ -159,4 +166,20 @@ Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *in
layout->addMultiCellWidget( noteEdit, 8, 8, 0, 3 );
+ // init date
+ initFromInfo( info );
+
+ // not new handlers
+ connect( withBtn, SIGNAL( toggled(bool) ), this, SLOT( slotNotNew() ) );
+ connect( depBtn, SIGNAL( toggled(bool) ), this, SLOT( slotNotNew() ) );
+ connect( catList, SIGNAL(activated(const QString &)), this, SLOT( slotNotNew() ) );
+ connect( typeList, SIGNAL(activated(const QString &)), this, SLOT( slotNotNew() ) );
+ connect( amtEdit, SIGNAL(textChanged(const QString &)), this, SLOT( slotNotNew() ) );
+ connect( feeEdit, SIGNAL(textChanged(const QString &)), this, SLOT( slotNotNew() ) );
+ connect( noteEdit, SIGNAL(textChanged()), this, SLOT( slotNotNew() ) );
+}
+
+// --- initFromInfo -----------------------------------------------------------
+void Transaction::initFromInfo(TranInfo *info, bool bPopulateOld)
+{
// Populate current values if provided
if ( info )
@@ -172,11 +195,25 @@ Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *in
slotDepositClicked();
}
- QDate dt = info->date();
- slotDateChanged( dt.year(), dt.month(), dt.day() );
- datePicker->setDate( dt );
- numEdit->setText( info->number() );
- descEdit->setText( info->desc() );
+
+ if( !bPopulateOld ) {
+ QDate dt = info->date();
+ slotDateChanged( dt.year(), dt.month(), dt.day() );
+ datePicker->setDate( dt );
+ numEdit->setText( info->number() );
+ }
QString temptext = info->category();
- int i = catList->count();
+
+ // set description field
+ int i;
+ for(i=_cbDesc->count()-1; i>=0; i--) {
+ if( _cbDesc->text(i)==info->desc() ) {
+ _cbDesc->setCurrentItem(i);
+ break;
+ }
+ }
+ if( i<=0 )
+ _cbDesc->setEditText( info->desc() );
+
+ i = catList->count();
while ( i > 0 )
{
@@ -209,11 +246,14 @@ Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *in
}
+
+// --- ~Transaction -----------------------------------------------------------
Transaction::~Transaction()
{
}
+// --- accept -----------------------------------------------------------------
void Transaction::accept()
{
- tran->setDesc( descEdit->text() );
+ tran->setDesc( _cbDesc->currentText() );
tran->setDate( datePicker->selectedDate() );
tran->setWithdrawal( withBtn->isChecked() );
@@ -263,4 +303,5 @@ void Transaction::slotDepositClicked()
}
+// --- slotDateChanged --------------------------------------------------------
void Transaction::slotDateChanged( int y, int m, int d )
{
@@ -269,2 +310,29 @@ void Transaction::slotDateChanged( int y, int m, int d )
dateBtn->setText( TimeString::shortDate( date ) );
}
+
+
+
+// --- slotActivated ----------------------------------------------------------
+// Search for the most recent transaction with this description/payee and
+// fill amount etc here, as long the new flag is set
+void Transaction::slotActivated(const QString &arg )
+{
+ if( !_bNew ) return;
+ TranInfoList *pTl=((Checkbook *)parentWidget())->getTranList();
+ if( pTl ) {
+ TranInfo *pTi=pTl->findMostRecentByDesc( arg );
+ if( pTi ) {
+ initFromInfo( pTi, true );
+ amtEdit->setFocus();
+ amtEdit->setSelection(0, amtEdit->text().length() );
+ amtEdit->setCursorPosition(0);
+ }
+ }
+}
+
+// slotNotNew -----------------------------------------------------------------
+void Transaction::slotNotNew()
+{
+ qDebug("Not new");
+ _bNew=false;
+}
diff --git a/noncore/apps/checkbook/transaction.h b/noncore/apps/checkbook/transaction.h
index fbe9cd3..130d769 100644
--- a/noncore/apps/checkbook/transaction.h
+++ b/noncore/apps/checkbook/transaction.h
@@ -48,10 +48,12 @@ class Transaction : public QDialog
public:
- Transaction( QWidget *, const QString &, TranInfo *, Cfg *);
+ Transaction( QWidget *, bool, const QString &, TranInfo *, Cfg *);
~Transaction();
- private:
- TranInfo *tran;
+ void initFromInfo(TranInfo *, bool=false);
+ private:
+ TranInfo *tran;
+ bool _bNew;
Cfg *_pCfg;
@@ -61,5 +63,5 @@ class Transaction : public QDialog
DateBookMonth *datePicker;
QLineEdit *numEdit;
- QLineEdit *descEdit;
+ QComboBox *_cbDesc;
QComboBox *catList;
QComboBox *typeList;
@@ -75,4 +77,6 @@ class Transaction : public QDialog
void slotDepositClicked();
void slotDateChanged( int, int, int );
+ void slotActivated(const QString & );
+ void slotNotNew();
};