summaryrefslogtreecommitdiff
path: root/noncore/apps/checkbook/transaction.cpp
Unidiff
Diffstat (limited to 'noncore/apps/checkbook/transaction.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/checkbook/transaction.cpp92
1 files changed, 80 insertions, 12 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 @@
31#include "cfg.h" 31#include "cfg.h"
32#include "checkbook.h"
32 33
33#include <qpe/datebookmonth.h> 34#include <qpe/datebookmonth.h>
35#include <qpe/resource.h>
34 36
@@ -43,4 +45,4 @@
43 45
44Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *info, 46Transaction::Transaction( QWidget *parent, bool bNew, const QString &acctname,
45 Cfg *pCfg ) 47 TranInfo *info, Cfg *pCfg )
46 : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) 48 : QDialog( parent, 0, TRUE, WStyle_ContextHelp )
@@ -51,2 +53,3 @@ Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *in
51 53
54 _bNew=bNew;
52 tran = info; 55 tran = info;
@@ -116,5 +119,8 @@ Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *in
116 layout->addWidget( label, 2, 0 ); 119 layout->addWidget( label, 2, 0 );
117 descEdit = new QLineEdit( container ); 120 _cbDesc=new QComboBox( true, container );
118 QWhatsThis::add( descEdit, tr( "Enter description of transaction here." ) ); 121 _cbDesc->insertStringList( _pCfg->getPayees() );
119 layout->addMultiCellWidget( descEdit, 2, 2, 1, 3 ); 122 QWhatsThis::add( _cbDesc, tr( "Enter description of transaction here." ) );
123 layout->addMultiCellWidget( _cbDesc, 2, 2, 1, 3 );
124 connect( _cbDesc, SIGNAL( activated(const QString &) ), this, SLOT( slotActivated(const QString &) ) );
125
120 126
@@ -136,2 +142,3 @@ Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *in
136 142
143
137 // Amount 144 // Amount
@@ -160,2 +167,18 @@ Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *in
160 167
168 // init date
169 initFromInfo( info );
170
171 // not new handlers
172 connect( withBtn, SIGNAL( toggled(bool) ), this, SLOT( slotNotNew() ) );
173 connect( depBtn, SIGNAL( toggled(bool) ), this, SLOT( slotNotNew() ) );
174 connect( catList, SIGNAL(activated(const QString &)), this, SLOT( slotNotNew() ) );
175 connect( typeList, SIGNAL(activated(const QString &)), this, SLOT( slotNotNew() ) );
176 connect( amtEdit, SIGNAL(textChanged(const QString &)), this, SLOT( slotNotNew() ) );
177 connect( feeEdit, SIGNAL(textChanged(const QString &)), this, SLOT( slotNotNew() ) );
178 connect( noteEdit, SIGNAL(textChanged()), this, SLOT( slotNotNew() ) );
179}
180
181// --- initFromInfo -----------------------------------------------------------
182void Transaction::initFromInfo(TranInfo *info, bool bPopulateOld)
183{
161 // Populate current values if provided 184 // Populate current values if provided
@@ -173,9 +196,23 @@ Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *in
173 } 196 }
174 QDate dt = info->date(); 197
175 slotDateChanged( dt.year(), dt.month(), dt.day() ); 198 if( !bPopulateOld ) {
176 datePicker->setDate( dt ); 199 QDate dt = info->date();
177 numEdit->setText( info->number() ); 200 slotDateChanged( dt.year(), dt.month(), dt.day() );
178 descEdit->setText( info->desc() ); 201 datePicker->setDate( dt );
202 numEdit->setText( info->number() );
203 }
179 QString temptext = info->category(); 204 QString temptext = info->category();
180 int i = catList->count(); 205
206 // set description field
207 int i;
208 for(i=_cbDesc->count()-1; i>=0; i--) {
209 if( _cbDesc->text(i)==info->desc() ) {
210 _cbDesc->setCurrentItem(i);
211 break;
212 }
213 }
214 if( i<=0 )
215 _cbDesc->setEditText( info->desc() );
216
217 i = catList->count();
181 while ( i > 0 ) 218 while ( i > 0 )
@@ -210,2 +247,4 @@ Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *in
210 247
248
249// --- ~Transaction -----------------------------------------------------------
211Transaction::~Transaction() 250Transaction::~Transaction()
@@ -214,5 +253,6 @@ Transaction::~Transaction()
214 253
254// --- accept -----------------------------------------------------------------
215void Transaction::accept() 255void Transaction::accept()
216{ 256{
217 tran->setDesc( descEdit->text() ); 257 tran->setDesc( _cbDesc->currentText() );
218 tran->setDate( datePicker->selectedDate() ); 258 tran->setDate( datePicker->selectedDate() );
@@ -264,2 +304,3 @@ void Transaction::slotDepositClicked()
264 304
305// --- slotDateChanged --------------------------------------------------------
265void Transaction::slotDateChanged( int y, int m, int d ) 306void Transaction::slotDateChanged( int y, int m, int d )
@@ -270 +311,28 @@ void Transaction::slotDateChanged( int y, int m, int d )
270} 311}
312
313
314
315// --- slotActivated ----------------------------------------------------------
316// Search for the most recent transaction with this description/payee and
317// fill amount etc here, as long the new flag is set
318void Transaction::slotActivated(const QString &arg )
319{
320 if( !_bNew ) return;
321 TranInfoList *pTl=((Checkbook *)parentWidget())->getTranList();
322 if( pTl ) {
323 TranInfo *pTi=pTl->findMostRecentByDesc( arg );
324 if( pTi ) {
325 initFromInfo( pTi, true );
326 amtEdit->setFocus();
327 amtEdit->setSelection(0, amtEdit->text().length() );
328 amtEdit->setCursorPosition(0);
329 }
330 }
331}
332
333// slotNotNew -----------------------------------------------------------------
334void Transaction::slotNotNew()
335{
336 qDebug("Not new");
337 _bNew=false;
338}