Diffstat (limited to 'noncore/apps/checkbook/transaction.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/checkbook/transaction.cpp | 92 |
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 | |||
@@ -8,68 +8,71 @@ | |||
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This file is distributed in the hope that | 13 | .i_,=:_. -<s. This file is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "transaction.h" | 29 | #include "transaction.h" |
30 | #include "traninfo.h" | 30 | #include "traninfo.h" |
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 | ||
35 | #include <qbuttongroup.h> | 37 | #include <qbuttongroup.h> |
36 | #include <qcombobox.h> | 38 | #include <qcombobox.h> |
37 | #include <qlabel.h> | 39 | #include <qlabel.h> |
38 | #include <qlayout.h> | 40 | #include <qlayout.h> |
39 | #include <qlineedit.h> | 41 | #include <qlineedit.h> |
40 | #include <qmultilineedit.h> | 42 | #include <qmultilineedit.h> |
41 | #include <qradiobutton.h> | 43 | #include <qradiobutton.h> |
42 | #include <qwhatsthis.h> | 44 | #include <qwhatsthis.h> |
43 | 45 | ||
44 | Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *info, | 46 | Transaction::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 ) |
47 | { | 49 | { |
48 | QString tempstr = tr( "Transaction for " ); | 50 | QString tempstr = tr( "Transaction for " ); |
49 | tempstr.append( acctname ); | 51 | tempstr.append( acctname ); |
50 | setCaption( tempstr ); | 52 | setCaption( tempstr ); |
51 | 53 | ||
54 | _bNew=bNew; | ||
52 | tran = info; | 55 | tran = info; |
53 | _pCfg=pCfg; | 56 | _pCfg=pCfg; |
54 | 57 | ||
55 | QVBoxLayout *vb = new QVBoxLayout( this ); | 58 | QVBoxLayout *vb = new QVBoxLayout( this ); |
56 | 59 | ||
57 | QScrollView *sv = new QScrollView( this ); | 60 | QScrollView *sv = new QScrollView( this ); |
58 | vb->addWidget( sv, 0, 0 ); | 61 | vb->addWidget( sv, 0, 0 ); |
59 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 62 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
60 | sv->setFrameStyle( QFrame::NoFrame ); | 63 | sv->setFrameStyle( QFrame::NoFrame ); |
61 | 64 | ||
62 | QWidget *container = new QWidget( sv->viewport() ); | 65 | QWidget *container = new QWidget( sv->viewport() ); |
63 | sv->addChild( container ); | 66 | sv->addChild( container ); |
64 | 67 | ||
65 | QGridLayout *layout = new QGridLayout( container ); | 68 | QGridLayout *layout = new QGridLayout( container ); |
66 | layout->setSpacing( 2 ); | 69 | layout->setSpacing( 2 ); |
67 | layout->setMargin( 4 ); | 70 | layout->setMargin( 4 ); |
68 | 71 | ||
69 | // Withdrawal/Deposit | 72 | // Withdrawal/Deposit |
70 | QButtonGroup *btngrp = new QButtonGroup( container ); | 73 | QButtonGroup *btngrp = new QButtonGroup( container ); |
71 | btngrp->setColumnLayout(0, Qt::Vertical ); | 74 | btngrp->setColumnLayout(0, Qt::Vertical ); |
72 | btngrp->layout()->setSpacing( 0 ); | 75 | btngrp->layout()->setSpacing( 0 ); |
73 | btngrp->layout()->setMargin( 0 ); | 76 | btngrp->layout()->setMargin( 0 ); |
74 | btngrp->setMaximumWidth( 220 ); | 77 | btngrp->setMaximumWidth( 220 ); |
75 | QGridLayout *layout2 = new QGridLayout( btngrp->layout() ); | 78 | QGridLayout *layout2 = new QGridLayout( btngrp->layout() ); |
@@ -93,178 +96,243 @@ Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *in | |||
93 | dateBtn = new QPushButton( TimeString::shortDate( QDate::currentDate() ), | 96 | dateBtn = new QPushButton( TimeString::shortDate( QDate::currentDate() ), |
94 | container ); | 97 | container ); |
95 | QWhatsThis::add( dateBtn, tr( "Select date of transaction here." ) ); | 98 | QWhatsThis::add( dateBtn, tr( "Select date of transaction here." ) ); |
96 | QPopupMenu *m1 = new QPopupMenu( container ); | 99 | QPopupMenu *m1 = new QPopupMenu( container ); |
97 | datePicker = new DateBookMonth( m1, 0, TRUE ); | 100 | datePicker = new DateBookMonth( m1, 0, TRUE ); |
98 | m1->insertItem( datePicker ); | 101 | m1->insertItem( datePicker ); |
99 | dateBtn->setPopup( m1 ); | 102 | dateBtn->setPopup( m1 ); |
100 | connect( datePicker, SIGNAL( dateClicked( int, int, int ) ), | 103 | connect( datePicker, SIGNAL( dateClicked( int, int, int ) ), |
101 | this, SLOT( slotDateChanged( int, int, int ) ) ); | 104 | this, SLOT( slotDateChanged( int, int, int ) ) ); |
102 | layout->addWidget( dateBtn, 1, 1 ); | 105 | layout->addWidget( dateBtn, 1, 1 ); |
103 | 106 | ||
104 | // Check number | 107 | // Check number |
105 | label = new QLabel( tr( "Number:" ), container ); | 108 | label = new QLabel( tr( "Number:" ), container ); |
106 | QWhatsThis::add( label, tr( "Enter check number here." ) ); | 109 | QWhatsThis::add( label, tr( "Enter check number here." ) ); |
107 | layout->addWidget( label, 1, 2 ); | 110 | layout->addWidget( label, 1, 2 ); |
108 | numEdit = new QLineEdit( container ); | 111 | numEdit = new QLineEdit( container ); |
109 | QWhatsThis::add( numEdit, tr( "Enter check number here." ) ); | 112 | QWhatsThis::add( numEdit, tr( "Enter check number here." ) ); |
110 | numEdit->setMaximumWidth( 40 ); | 113 | numEdit->setMaximumWidth( 40 ); |
111 | layout->addWidget( numEdit, 1, 3 ); | 114 | layout->addWidget( numEdit, 1, 3 ); |
112 | 115 | ||
113 | // Description | 116 | // Description |
114 | label = new QLabel( tr( "Description:" ), container ); | 117 | label = new QLabel( tr( "Description:" ), container ); |
115 | QWhatsThis::add( label, tr( "Enter description of transaction here." ) ); | 118 | QWhatsThis::add( label, tr( "Enter description of transaction here." ) ); |
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 | ||
121 | // Category | 127 | // Category |
122 | label = new QLabel( tr( "Category:" ), container ); | 128 | label = new QLabel( tr( "Category:" ), container ); |
123 | QWhatsThis::add( label, tr( "Select transaction category here." ) ); | 129 | QWhatsThis::add( label, tr( "Select transaction category here." ) ); |
124 | layout->addWidget( label, 3, 0 ); | 130 | layout->addWidget( label, 3, 0 ); |
125 | catList = new QComboBox( container ); | 131 | catList = new QComboBox( container ); |
126 | QWhatsThis::add( catList, tr( "Select transaction category here." ) ); | 132 | QWhatsThis::add( catList, tr( "Select transaction category here." ) ); |
127 | layout->addMultiCellWidget( catList, 3, 3, 1, 3 ); | 133 | layout->addMultiCellWidget( catList, 3, 3, 1, 3 ); |
128 | 134 | ||
129 | // Type | 135 | // Type |
130 | label = new QLabel( tr( "Type:" ), container ); | 136 | label = new QLabel( tr( "Type:" ), container ); |
131 | QWhatsThis::add( label, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) ); | 137 | QWhatsThis::add( label, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) ); |
132 | layout->addWidget( label, 4, 0 ); | 138 | layout->addWidget( label, 4, 0 ); |
133 | typeList = new QComboBox( container ); | 139 | typeList = new QComboBox( container ); |
134 | QWhatsThis::add( typeList, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) ); | 140 | QWhatsThis::add( typeList, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) ); |
135 | layout->addMultiCellWidget( typeList, 4, 4, 1, 3 ); | 141 | layout->addMultiCellWidget( typeList, 4, 4, 1, 3 ); |
136 | 142 | ||
143 | |||
137 | // Amount | 144 | // Amount |
138 | label = new QLabel( tr( "Amount:" ), container ); | 145 | label = new QLabel( tr( "Amount:" ), container ); |
139 | QWhatsThis::add( label, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) ); | 146 | QWhatsThis::add( label, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) ); |
140 | layout->addWidget( label, 5, 0 ); | 147 | layout->addWidget( label, 5, 0 ); |
141 | amtEdit = new QLineEdit( container ); | 148 | amtEdit = new QLineEdit( container ); |
142 | QWhatsThis::add( amtEdit, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) ); | 149 | QWhatsThis::add( amtEdit, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) ); |
143 | layout->addMultiCellWidget( amtEdit, 5, 5, 1, 3 ); | 150 | layout->addMultiCellWidget( amtEdit, 5, 5, 1, 3 ); |
144 | 151 | ||
145 | // Fee | 152 | // Fee |
146 | label = new QLabel( tr( "Fee:" ), container ); | 153 | label = new QLabel( tr( "Fee:" ), container ); |
147 | QWhatsThis::add( label, tr( "Enter any fee amount assoiciated with this transaction.\n\nThe value entered should always be positive." ) ); | 154 | QWhatsThis::add( label, tr( "Enter any fee amount assoiciated with this transaction.\n\nThe value entered should always be positive." ) ); |
148 | layout->addWidget( label, 6, 0 ); | 155 | layout->addWidget( label, 6, 0 ); |
149 | feeEdit = new QLineEdit( container ); | 156 | feeEdit = new QLineEdit( container ); |
150 | QWhatsThis::add( feeEdit, tr( "Enter any fee amount assoiciated with this transaction.\n\nThe value entered should always be positive." ) ); | 157 | QWhatsThis::add( feeEdit, tr( "Enter any fee amount assoiciated with this transaction.\n\nThe value entered should always be positive." ) ); |
151 | layout->addMultiCellWidget( feeEdit, 6, 6, 1, 3 ); | 158 | layout->addMultiCellWidget( feeEdit, 6, 6, 1, 3 ); |
152 | 159 | ||
153 | // Notes | 160 | // Notes |
154 | label = new QLabel( tr( "Notes:" ), container ); | 161 | label = new QLabel( tr( "Notes:" ), container ); |
155 | QWhatsThis::add( label, tr( "Enter any additional information for this transaction here." ) ); | 162 | QWhatsThis::add( label, tr( "Enter any additional information for this transaction here." ) ); |
156 | layout->addWidget( label, 7, 0 ); | 163 | layout->addWidget( label, 7, 0 ); |
157 | noteEdit = new QMultiLineEdit( container ); | 164 | noteEdit = new QMultiLineEdit( container ); |
158 | QWhatsThis::add( noteEdit, tr( "Enter any additional information for this transaction here." ) ); | 165 | QWhatsThis::add( noteEdit, tr( "Enter any additional information for this transaction here." ) ); |
159 | layout->addMultiCellWidget( noteEdit, 8, 8, 0, 3 ); | 166 | layout->addMultiCellWidget( noteEdit, 8, 8, 0, 3 ); |
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 ----------------------------------------------------------- | ||
182 | void Transaction::initFromInfo(TranInfo *info, bool bPopulateOld) | ||
183 | { | ||
161 | // Populate current values if provided | 184 | // Populate current values if provided |
162 | if ( info ) | 185 | if ( info ) |
163 | { | 186 | { |
164 | if ( info->withdrawal() ) | 187 | if ( info->withdrawal() ) |
165 | { | 188 | { |
166 | withBtn->setChecked( TRUE ); | 189 | withBtn->setChecked( TRUE ); |
167 | slotWithdrawalClicked(); | 190 | slotWithdrawalClicked(); |
168 | } | 191 | } |
169 | else | 192 | else |
170 | { | 193 | { |
171 | depBtn->setChecked( TRUE ); | 194 | depBtn->setChecked( TRUE ); |
172 | slotDepositClicked(); | 195 | slotDepositClicked(); |
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 ) |
182 | { | 219 | { |
183 | i--; | 220 | i--; |
184 | catList->setCurrentItem( i ); | 221 | catList->setCurrentItem( i ); |
185 | if ( catList->currentText() == temptext ) | 222 | if ( catList->currentText() == temptext ) |
186 | { | 223 | { |
187 | break; | 224 | break; |
188 | } | 225 | } |
189 | } | 226 | } |
190 | temptext = info->type(); | 227 | temptext = info->type(); |
191 | i = typeList->count(); | 228 | i = typeList->count(); |
192 | while ( i > 0 ) | 229 | while ( i > 0 ) |
193 | { | 230 | { |
194 | i--; | 231 | i--; |
195 | typeList->setCurrentItem( i ); | 232 | typeList->setCurrentItem( i ); |
196 | if ( typeList->currentText() == temptext ) | 233 | if ( typeList->currentText() == temptext ) |
197 | { | 234 | { |
198 | break; | 235 | break; |
199 | } | 236 | } |
200 | } | 237 | } |
201 | amtEdit->setText( QString( "%1" ).arg( info->amount(), 0, 'f', 2 ) ); | 238 | amtEdit->setText( QString( "%1" ).arg( info->amount(), 0, 'f', 2 ) ); |
202 | feeEdit->setText( QString( "%1" ).arg( info->fee(), 0, 'f', 2 ) ); | 239 | feeEdit->setText( QString( "%1" ).arg( info->fee(), 0, 'f', 2 ) ); |
203 | noteEdit->setText( info->notes() ); | 240 | noteEdit->setText( info->notes() ); |
204 | } | 241 | } |
205 | else | 242 | else |
206 | { | 243 | { |
207 | withBtn->setChecked( TRUE ); | 244 | withBtn->setChecked( TRUE ); |
208 | } | 245 | } |
209 | } | 246 | } |
210 | 247 | ||
248 | |||
249 | // --- ~Transaction ----------------------------------------------------------- | ||
211 | Transaction::~Transaction() | 250 | Transaction::~Transaction() |
212 | { | 251 | { |
213 | } | 252 | } |
214 | 253 | ||
254 | // --- accept ----------------------------------------------------------------- | ||
215 | void Transaction::accept() | 255 | void Transaction::accept() |
216 | { | 256 | { |
217 | tran->setDesc( descEdit->text() ); | 257 | tran->setDesc( _cbDesc->currentText() ); |
218 | tran->setDate( datePicker->selectedDate() ); | 258 | tran->setDate( datePicker->selectedDate() ); |
219 | tran->setWithdrawal( withBtn->isChecked() ); | 259 | tran->setWithdrawal( withBtn->isChecked() ); |
220 | tran->setType( typeList->currentText() ); | 260 | tran->setType( typeList->currentText() ); |
221 | tran->setCategory( catList->currentText() ); | 261 | tran->setCategory( catList->currentText() ); |
222 | bool ok; | 262 | bool ok; |
223 | tran->setAmount( amtEdit->text().toFloat( &ok ) ); | 263 | tran->setAmount( amtEdit->text().toFloat( &ok ) ); |
224 | tran->setFee( feeEdit->text().toFloat( &ok ) ); | 264 | tran->setFee( feeEdit->text().toFloat( &ok ) ); |
225 | tran->setNumber( numEdit->text() ); | 265 | tran->setNumber( numEdit->text() ); |
226 | tran->setNotes( noteEdit->text() ); | 266 | tran->setNotes( noteEdit->text() ); |
227 | 267 | ||
228 | QDialog::accept(); | 268 | QDialog::accept(); |
229 | } | 269 | } |
230 | 270 | ||
231 | void Transaction::slotWithdrawalClicked() | 271 | void Transaction::slotWithdrawalClicked() |
232 | { | 272 | { |
233 | catList->clear(); | 273 | catList->clear(); |
234 | CategoryList *pCatList=_pCfg->getCategoryList(); | 274 | CategoryList *pCatList=_pCfg->getCategoryList(); |
235 | for(Category *pCat=pCatList->first(); pCat; pCat=pCatList->next()) { | 275 | for(Category *pCat=pCatList->first(); pCat; pCat=pCatList->next()) { |
236 | if( !pCat->isIncome() ) | 276 | if( !pCat->isIncome() ) |
237 | catList->insertItem( pCat->getName() ); | 277 | catList->insertItem( pCat->getName() ); |
238 | } | 278 | } |
239 | catList->setCurrentItem(0); | 279 | catList->setCurrentItem(0); |
240 | 280 | ||
241 | typeList->clear(); | 281 | typeList->clear(); |
242 | typeList->insertItem( tr( "Debit Charge" ) ); | 282 | typeList->insertItem( tr( "Debit Charge" ) ); |
243 | typeList->insertItem( tr( "Written Check" ) ); | 283 | typeList->insertItem( tr( "Written Check" ) ); |
244 | typeList->insertItem( tr( "Transfer" ) ); | 284 | typeList->insertItem( tr( "Transfer" ) ); |
245 | typeList->insertItem( tr( "Credit Card" ) ); | 285 | typeList->insertItem( tr( "Credit Card" ) ); |
246 | } | 286 | } |
247 | 287 | ||
248 | void Transaction::slotDepositClicked() | 288 | void Transaction::slotDepositClicked() |
249 | { | 289 | { |
250 | catList->clear(); | 290 | catList->clear(); |
251 | CategoryList *pCatList=_pCfg->getCategoryList(); | 291 | CategoryList *pCatList=_pCfg->getCategoryList(); |
252 | for(Category *pCat=pCatList->first(); pCat; pCat=pCatList->next()) { | 292 | for(Category *pCat=pCatList->first(); pCat; pCat=pCatList->next()) { |
253 | if( pCat->isIncome() ) | 293 | if( pCat->isIncome() ) |
254 | catList->insertItem( pCat->getName() ); | 294 | catList->insertItem( pCat->getName() ); |
255 | } | 295 | } |
256 | catList->setCurrentItem( 0 ); | 296 | catList->setCurrentItem( 0 ); |
257 | 297 | ||
258 | typeList->clear(); | 298 | typeList->clear(); |
259 | typeList->insertItem( tr( "Written Check" ) ); | 299 | typeList->insertItem( tr( "Written Check" ) ); |
260 | typeList->insertItem( tr( "Automatic Payment" ) ); | 300 | typeList->insertItem( tr( "Automatic Payment" ) ); |
261 | typeList->insertItem( tr( "Transfer" ) ); | 301 | typeList->insertItem( tr( "Transfer" ) ); |
262 | typeList->insertItem( tr( "Cash" ) ); | 302 | typeList->insertItem( tr( "Cash" ) ); |
263 | } | 303 | } |
264 | 304 | ||
305 | // --- slotDateChanged -------------------------------------------------------- | ||
265 | void Transaction::slotDateChanged( int y, int m, int d ) | 306 | void Transaction::slotDateChanged( int y, int m, int d ) |
266 | { | 307 | { |
267 | QDate date; | 308 | QDate date; |
268 | date.setYMD( y, m, d ); | 309 | date.setYMD( y, m, d ); |
269 | dateBtn->setText( TimeString::shortDate( date ) ); | 310 | dateBtn->setText( TimeString::shortDate( date ) ); |
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 | ||
318 | void 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 ----------------------------------------------------------------- | ||
334 | void Transaction::slotNotNew() | ||
335 | { | ||
336 | qDebug("Not new"); | ||
337 | _bNew=false; | ||
338 | } | ||