Diffstat (limited to 'noncore/apps/checkbook/transaction.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/checkbook/transaction.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/noncore/apps/checkbook/transaction.cpp b/noncore/apps/checkbook/transaction.cpp index a72a48b..1b08b24 100644 --- a/noncore/apps/checkbook/transaction.cpp +++ b/noncore/apps/checkbook/transaction.cpp | |||
@@ -54,171 +54,171 @@ Transaction::Transaction( QWidget *parent, bool bNew, const QString &acctname, | |||
54 | tran = info; | 54 | tran = info; |
55 | _pCfg=pCfg; | 55 | _pCfg=pCfg; |
56 | 56 | ||
57 | QVBoxLayout *vb = new QVBoxLayout( this ); | 57 | QVBoxLayout *vb = new QVBoxLayout( this ); |
58 | 58 | ||
59 | QScrollView *sv = new QScrollView( this ); | 59 | QScrollView *sv = new QScrollView( this ); |
60 | vb->addWidget( sv, 0, 0 ); | 60 | vb->addWidget( sv, 0, 0 ); |
61 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 61 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
62 | sv->setFrameStyle( QFrame::NoFrame ); | 62 | sv->setFrameStyle( QFrame::NoFrame ); |
63 | 63 | ||
64 | QWidget *container = new QWidget( sv->viewport() ); | 64 | QWidget *container = new QWidget( sv->viewport() ); |
65 | sv->addChild( container ); | 65 | sv->addChild( container ); |
66 | 66 | ||
67 | QGridLayout *layout = new QGridLayout( container ); | 67 | QGridLayout *layout = new QGridLayout( container ); |
68 | layout->setSpacing( 2 ); | 68 | layout->setSpacing( 2 ); |
69 | layout->setMargin( 4 ); | 69 | layout->setMargin( 4 ); |
70 | 70 | ||
71 | // Withdrawal/Deposit | 71 | // Withdrawal/Deposit |
72 | QButtonGroup *btngrp = new QButtonGroup( container ); | 72 | QButtonGroup *btngrp = new QButtonGroup( container ); |
73 | btngrp->setColumnLayout(0, Qt::Vertical ); | 73 | btngrp->setColumnLayout(0, Qt::Vertical ); |
74 | btngrp->layout()->setSpacing( 0 ); | 74 | btngrp->layout()->setSpacing( 0 ); |
75 | btngrp->layout()->setMargin( 0 ); | 75 | btngrp->layout()->setMargin( 0 ); |
76 | btngrp->setMaximumWidth( 220 ); | 76 | btngrp->setMaximumWidth( 220 ); |
77 | QGridLayout *layout2 = new QGridLayout( btngrp->layout() ); | 77 | QGridLayout *layout2 = new QGridLayout( btngrp->layout() ); |
78 | layout2->setSpacing( 2 ); | 78 | layout2->setSpacing( 2 ); |
79 | layout2->setMargin( 2 ); | 79 | layout2->setMargin( 2 ); |
80 | withBtn = new QRadioButton( tr( "Withdrawal" ), btngrp ); | 80 | withBtn = new QRadioButton( tr( "Withdrawal" ), btngrp ); |
81 | QWhatsThis::add( withBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) ); | 81 | QWhatsThis::add( withBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) ); |
82 | layout2->addWidget( withBtn, 0, 0 ); | 82 | layout2->addWidget( withBtn, 0, 0 ); |
83 | connect( withBtn, SIGNAL( clicked() ), this, SLOT( slotWithdrawalClicked() ) ); | 83 | connect( withBtn, SIGNAL( clicked() ), this, SLOT( slotWithdrawalClicked() ) ); |
84 | depBtn = new QRadioButton( tr( "Deposit" ), btngrp ); | 84 | depBtn = new QRadioButton( tr( "Deposit" ), btngrp ); |
85 | QWhatsThis::add( depBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) ); | 85 | QWhatsThis::add( depBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) ); |
86 | layout2->addWidget( depBtn, 0, 1 ); | 86 | layout2->addWidget( depBtn, 0, 1 ); |
87 | btngrp->setMaximumSize( 320, withBtn->height() ); | 87 | btngrp->setMaximumSize( 320, withBtn->height() ); |
88 | connect( depBtn, SIGNAL( clicked() ), this, SLOT( slotDepositClicked() ) ); | 88 | connect( depBtn, SIGNAL( clicked() ), this, SLOT( slotDepositClicked() ) ); |
89 | layout->addMultiCellWidget( btngrp, 0, 0, 0, 3 ); | 89 | layout->addMultiCellWidget( btngrp, 0, 0, 0, 3 ); |
90 | 90 | ||
91 | // Date | 91 | // Date |
92 | QLabel *label = new QLabel( tr( "Date:" ), container ); | 92 | QLabel *label = new QLabel( tr( "Date:" ), container ); |
93 | QWhatsThis::add( label, tr( "Select date of transaction here." ) ); | 93 | QWhatsThis::add( label, tr( "Select date of transaction here." ) ); |
94 | layout->addWidget( label, 1, 0 ); | 94 | layout->addWidget( label, 1, 0 ); |
95 | dateBtn = new QPushButton( TimeString::shortDate( QDate::currentDate() ), | 95 | dateBtn = new QPushButton( TimeString::shortDate( QDate::currentDate() ), |
96 | container ); | 96 | container ); |
97 | QWhatsThis::add( dateBtn, tr( "Select date of transaction here." ) ); | 97 | QWhatsThis::add( dateBtn, tr( "Select date of transaction here." ) ); |
98 | QPopupMenu *m1 = new QPopupMenu( container ); | 98 | QPopupMenu *m1 = new QPopupMenu( container ); |
99 | datePicker = new DateBookMonth( m1, 0, TRUE ); | 99 | datePicker = new DateBookMonth( m1, 0, TRUE ); |
100 | m1->insertItem( datePicker ); | 100 | m1->insertItem( datePicker ); |
101 | dateBtn->setPopup( m1 ); | 101 | dateBtn->setPopup( m1 ); |
102 | connect( datePicker, SIGNAL( dateClicked( int, int, int ) ), | 102 | connect( datePicker, SIGNAL( dateClicked(int,int,int) ), |
103 | this, SLOT( slotDateChanged( int, int, int ) ) ); | 103 | this, SLOT( slotDateChanged(int,int,int) ) ); |
104 | layout->addWidget( dateBtn, 1, 1 ); | 104 | layout->addWidget( dateBtn, 1, 1 ); |
105 | 105 | ||
106 | // Check number | 106 | // Check number |
107 | label = new QLabel( tr( "Number:" ), container ); | 107 | label = new QLabel( tr( "Number:" ), container ); |
108 | QWhatsThis::add( label, tr( "Enter check number here." ) ); | 108 | QWhatsThis::add( label, tr( "Enter check number here." ) ); |
109 | layout->addWidget( label, 1, 2 ); | 109 | layout->addWidget( label, 1, 2 ); |
110 | numEdit = new QLineEdit( container ); | 110 | numEdit = new QLineEdit( container ); |
111 | QWhatsThis::add( numEdit, tr( "Enter check number here." ) ); | 111 | QWhatsThis::add( numEdit, tr( "Enter check number here." ) ); |
112 | numEdit->setMaximumWidth( 40 ); | 112 | numEdit->setMaximumWidth( 40 ); |
113 | layout->addWidget( numEdit, 1, 3 ); | 113 | layout->addWidget( numEdit, 1, 3 ); |
114 | 114 | ||
115 | // Description | 115 | // Description |
116 | label = new QLabel( tr( "Description:" ), container ); | 116 | label = new QLabel( tr( "Description:" ), container ); |
117 | QWhatsThis::add( label, tr( "Enter description of transaction here." ) ); | 117 | QWhatsThis::add( label, tr( "Enter description of transaction here." ) ); |
118 | layout->addWidget( label, 2, 0 ); | 118 | layout->addWidget( label, 2, 0 ); |
119 | _cbDesc=new QComboBox( true, container ); | 119 | _cbDesc=new QComboBox( true, container ); |
120 | _cbDesc->insertStringList( _pCfg->getPayees() ); | 120 | _cbDesc->insertStringList( _pCfg->getPayees() ); |
121 | QWhatsThis::add( _cbDesc, tr( "Enter description of transaction here." ) ); | 121 | QWhatsThis::add( _cbDesc, tr( "Enter description of transaction here." ) ); |
122 | layout->addMultiCellWidget( _cbDesc, 2, 2, 1, 3 ); | 122 | layout->addMultiCellWidget( _cbDesc, 2, 2, 1, 3 ); |
123 | connect( _cbDesc, SIGNAL( activated(const QString &) ), this, SLOT( slotActivated(const QString &) ) ); | 123 | connect( _cbDesc, SIGNAL( activated(const QString&) ), this, SLOT( slotActivated(const QString&) ) ); |
124 | 124 | ||
125 | 125 | ||
126 | // Category | 126 | // Category |
127 | label = new QLabel( tr( "Category:" ), container ); | 127 | label = new QLabel( tr( "Category:" ), container ); |
128 | QWhatsThis::add( label, tr( "Select transaction category here." ) ); | 128 | QWhatsThis::add( label, tr( "Select transaction category here." ) ); |
129 | layout->addWidget( label, 3, 0 ); | 129 | layout->addWidget( label, 3, 0 ); |
130 | catList = new QComboBox( container ); | 130 | catList = new QComboBox( container ); |
131 | QWhatsThis::add( catList, tr( "Select transaction category here." ) ); | 131 | QWhatsThis::add( catList, tr( "Select transaction category here." ) ); |
132 | layout->addMultiCellWidget( catList, 3, 3, 1, 3 ); | 132 | layout->addMultiCellWidget( catList, 3, 3, 1, 3 ); |
133 | 133 | ||
134 | // Type | 134 | // Type |
135 | label = new QLabel( tr( "Type:" ), container ); | 135 | label = new QLabel( tr( "Type:" ), container ); |
136 | QWhatsThis::add( label, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) ); | 136 | QWhatsThis::add( label, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) ); |
137 | layout->addWidget( label, 4, 0 ); | 137 | layout->addWidget( label, 4, 0 ); |
138 | typeList = new QComboBox( container ); | 138 | typeList = new QComboBox( container ); |
139 | QWhatsThis::add( typeList, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) ); | 139 | QWhatsThis::add( typeList, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) ); |
140 | layout->addMultiCellWidget( typeList, 4, 4, 1, 3 ); | 140 | layout->addMultiCellWidget( typeList, 4, 4, 1, 3 ); |
141 | 141 | ||
142 | 142 | ||
143 | // Amount | 143 | // Amount |
144 | label = new QLabel( tr( "Amount:" ), container ); | 144 | label = new QLabel( tr( "Amount:" ), container ); |
145 | QWhatsThis::add( label, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) ); | 145 | QWhatsThis::add( label, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) ); |
146 | layout->addWidget( label, 5, 0 ); | 146 | layout->addWidget( label, 5, 0 ); |
147 | amtEdit = new QLineEdit( container ); | 147 | amtEdit = new QLineEdit( container ); |
148 | QWhatsThis::add( amtEdit, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) ); | 148 | QWhatsThis::add( amtEdit, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) ); |
149 | layout->addMultiCellWidget( amtEdit, 5, 5, 1, 3 ); | 149 | layout->addMultiCellWidget( amtEdit, 5, 5, 1, 3 ); |
150 | 150 | ||
151 | // Fee | 151 | // Fee |
152 | label = new QLabel( tr( "Fee:" ), container ); | 152 | label = new QLabel( tr( "Fee:" ), container ); |
153 | QWhatsThis::add( label, tr( "Enter any fee amount assoiciated with this transaction.\n\nThe value entered should always be positive." ) ); | 153 | QWhatsThis::add( label, tr( "Enter any fee amount assoiciated with this transaction.\n\nThe value entered should always be positive." ) ); |
154 | layout->addWidget( label, 6, 0 ); | 154 | layout->addWidget( label, 6, 0 ); |
155 | feeEdit = new QLineEdit( container ); | 155 | feeEdit = new QLineEdit( container ); |
156 | QWhatsThis::add( feeEdit, tr( "Enter any fee amount assoiciated with this transaction.\n\nThe value entered should always be positive." ) ); | 156 | QWhatsThis::add( feeEdit, tr( "Enter any fee amount assoiciated with this transaction.\n\nThe value entered should always be positive." ) ); |
157 | layout->addMultiCellWidget( feeEdit, 6, 6, 1, 3 ); | 157 | layout->addMultiCellWidget( feeEdit, 6, 6, 1, 3 ); |
158 | 158 | ||
159 | // Notes | 159 | // Notes |
160 | label = new QLabel( tr( "Notes:" ), container ); | 160 | label = new QLabel( tr( "Notes:" ), container ); |
161 | QWhatsThis::add( label, tr( "Enter any additional information for this transaction here." ) ); | 161 | QWhatsThis::add( label, tr( "Enter any additional information for this transaction here." ) ); |
162 | layout->addWidget( label, 7, 0 ); | 162 | layout->addWidget( label, 7, 0 ); |
163 | noteEdit = new QMultiLineEdit( container ); | 163 | noteEdit = new QMultiLineEdit( container ); |
164 | QWhatsThis::add( noteEdit, tr( "Enter any additional information for this transaction here." ) ); | 164 | QWhatsThis::add( noteEdit, tr( "Enter any additional information for this transaction here." ) ); |
165 | layout->addMultiCellWidget( noteEdit, 8, 8, 0, 3 ); | 165 | layout->addMultiCellWidget( noteEdit, 8, 8, 0, 3 ); |
166 | 166 | ||
167 | // init date | 167 | // init date |
168 | initFromInfo( info ); | 168 | initFromInfo( info ); |
169 | 169 | ||
170 | // not new handlers | 170 | // not new handlers |
171 | connect( withBtn, SIGNAL( toggled(bool) ), this, SLOT( slotNotNew() ) ); | 171 | connect( withBtn, SIGNAL( toggled(bool) ), this, SLOT( slotNotNew() ) ); |
172 | connect( depBtn, SIGNAL( toggled(bool) ), this, SLOT( slotNotNew() ) ); | 172 | connect( depBtn, SIGNAL( toggled(bool) ), this, SLOT( slotNotNew() ) ); |
173 | connect( catList, SIGNAL(activated(const QString &)), this, SLOT( slotNotNew() ) ); | 173 | connect( catList, SIGNAL(activated(const QString&)), this, SLOT( slotNotNew() ) ); |
174 | connect( typeList, SIGNAL(activated(const QString &)), this, SLOT( slotNotNew() ) ); | 174 | connect( typeList, SIGNAL(activated(const QString&)), this, SLOT( slotNotNew() ) ); |
175 | connect( amtEdit, SIGNAL(textChanged(const QString &)), this, SLOT( slotNotNew() ) ); | 175 | connect( amtEdit, SIGNAL(textChanged(const QString&)), this, SLOT( slotNotNew() ) ); |
176 | connect( feeEdit, SIGNAL(textChanged(const QString &)), this, SLOT( slotNotNew() ) ); | 176 | connect( feeEdit, SIGNAL(textChanged(const QString&)), this, SLOT( slotNotNew() ) ); |
177 | connect( noteEdit, SIGNAL(textChanged()), this, SLOT( slotNotNew() ) ); | 177 | connect( noteEdit, SIGNAL(textChanged()), this, SLOT( slotNotNew() ) ); |
178 | } | 178 | } |
179 | 179 | ||
180 | // --- initFromInfo ----------------------------------------------------------- | 180 | // --- initFromInfo ----------------------------------------------------------- |
181 | void Transaction::initFromInfo(TranInfo *info, bool bPopulateOld) | 181 | void Transaction::initFromInfo(TranInfo *info, bool bPopulateOld) |
182 | { | 182 | { |
183 | // Populate current values if provided | 183 | // Populate current values if provided |
184 | if ( info ) | 184 | if ( info ) |
185 | { | 185 | { |
186 | if ( info->withdrawal() ) | 186 | if ( info->withdrawal() ) |
187 | { | 187 | { |
188 | withBtn->setChecked( TRUE ); | 188 | withBtn->setChecked( TRUE ); |
189 | slotWithdrawalClicked(); | 189 | slotWithdrawalClicked(); |
190 | } | 190 | } |
191 | else | 191 | else |
192 | { | 192 | { |
193 | depBtn->setChecked( TRUE ); | 193 | depBtn->setChecked( TRUE ); |
194 | slotDepositClicked(); | 194 | slotDepositClicked(); |
195 | } | 195 | } |
196 | 196 | ||
197 | if( !bPopulateOld ) { | 197 | if( !bPopulateOld ) { |
198 | QDate dt = info->date(); | 198 | QDate dt = info->date(); |
199 | slotDateChanged( dt.year(), dt.month(), dt.day() ); | 199 | slotDateChanged( dt.year(), dt.month(), dt.day() ); |
200 | datePicker->setDate( dt ); | 200 | datePicker->setDate( dt ); |
201 | numEdit->setText( info->number() ); | 201 | numEdit->setText( info->number() ); |
202 | } | 202 | } |
203 | QString temptext = info->category(); | 203 | QString temptext = info->category(); |
204 | 204 | ||
205 | // set description field | 205 | // set description field |
206 | int i; | 206 | int i; |
207 | for(i=_cbDesc->count()-1; i>=0; i--) { | 207 | for(i=_cbDesc->count()-1; i>=0; i--) { |
208 | if( _cbDesc->text(i)==info->desc() ) { | 208 | if( _cbDesc->text(i)==info->desc() ) { |
209 | _cbDesc->setCurrentItem(i); | 209 | _cbDesc->setCurrentItem(i); |
210 | break; | 210 | break; |
211 | } | 211 | } |
212 | } | 212 | } |
213 | if( i<=0 ) | 213 | if( i<=0 ) |
214 | _cbDesc->setEditText( info->desc() ); | 214 | _cbDesc->setEditText( info->desc() ); |
215 | 215 | ||
216 | i = catList->count(); | 216 | i = catList->count(); |
217 | while ( i > 0 ) | 217 | while ( i > 0 ) |
218 | { | 218 | { |
219 | i--; | 219 | i--; |
220 | catList->setCurrentItem( i ); | 220 | catList->setCurrentItem( i ); |
221 | if ( catList->currentText() == temptext ) | 221 | if ( catList->currentText() == temptext ) |
222 | { | 222 | { |
223 | break; | 223 | break; |
224 | } | 224 | } |