author | mickeyl <mickeyl> | 2003-10-30 13:18:08 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-10-30 13:18:08 (UTC) |
commit | 37414f207b147af4cf6778b323a0aa23127901bd (patch) (side-by-side diff) | |
tree | b08c10043ab689b0a40425d268cd72226799b0cf /noncore/apps/checkbook/transaction.cpp | |
parent | d53637f46cf217fc760d7aac58b4596843a73803 (diff) | |
download | opie-37414f207b147af4cf6778b323a0aa23127901bd.zip opie-37414f207b147af4cf6778b323a0aa23127901bd.tar.gz opie-37414f207b147af4cf6778b323a0aa23127901bd.tar.bz2 |
apply patch to HEAD
Diffstat (limited to 'noncore/apps/checkbook/transaction.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/checkbook/transaction.cpp | 84 |
1 files changed, 76 insertions, 8 deletions
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 @@ -31,4 +31,6 @@ #include "cfg.h" +#include "checkbook.h" #include <qpe/datebookmonth.h> +#include <qpe/resource.h> @@ -43,4 +45,4 @@ -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 ) @@ -51,2 +53,3 @@ Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *in + _bNew=bNew; tran = info; @@ -116,5 +119,8 @@ Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *in 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 &) ) ); + @@ -136,2 +142,3 @@ Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *in + // Amount @@ -160,2 +167,18 @@ Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *in + // 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 @@ -173,2 +196,4 @@ Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *in } + + if( !bPopulateOld ) { QDate dt = info->date(); @@ -177,5 +202,17 @@ Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *in numEdit->setText( info->number() ); - descEdit->setText( info->desc() ); + } 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 ) @@ -210,2 +247,4 @@ Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *in + +// --- ~Transaction ----------------------------------------------------------- Transaction::~Transaction() @@ -214,5 +253,6 @@ Transaction::~Transaction() +// --- accept ----------------------------------------------------------------- void Transaction::accept() { - tran->setDesc( descEdit->text() ); + tran->setDesc( _cbDesc->currentText() ); tran->setDate( datePicker->selectedDate() ); @@ -264,2 +304,3 @@ void Transaction::slotDepositClicked() +// --- slotDateChanged -------------------------------------------------------- void Transaction::slotDateChanged( int y, int m, int d ) @@ -270 +311,28 @@ void Transaction::slotDateChanged( int y, int m, int d ) } + + + +// --- 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; +} |