summaryrefslogtreecommitdiff
path: root/noncore/apps/checkbook/checkbook.cpp
Unidiff
Diffstat (limited to 'noncore/apps/checkbook/checkbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/checkbook/checkbook.cpp917
1 files changed, 458 insertions, 459 deletions
diff --git a/noncore/apps/checkbook/checkbook.cpp b/noncore/apps/checkbook/checkbook.cpp
index a5492e4..4ca764f 100644
--- a/noncore/apps/checkbook/checkbook.cpp
+++ b/noncore/apps/checkbook/checkbook.cpp
@@ -38,3 +38,2 @@
38 38
39#include <opie/otabwidget.h>
40#include <qpe/qpeapplication.h> 39#include <qpe/qpeapplication.h>
@@ -63,5 +62,5 @@
63Checkbook::Checkbook( QWidget *parent, CBInfo *i, Cfg *cfg ) 62Checkbook::Checkbook( QWidget *parent, CBInfo *i, Cfg *cfg )
64 : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) 63 : QDialog( parent, 0, TRUE, WStyle_ContextHelp )
65{ 64{
66 info = i; 65 info = i;
67 _pCfg=cfg; 66 _pCfg=cfg;
@@ -69,26 +68,26 @@ Checkbook::Checkbook( QWidget *parent, CBInfo *i, Cfg *cfg )
69 // Title bar 68 // Title bar
70 if ( info->name() != "" ) 69 if ( info->name() != "" )
71 { 70 {
72 QString tempstr = info->name(); 71 QString tempstr = info->name();
73 tempstr.append( " - " ); 72 tempstr.append( " - " );
74 tempstr.append( tr( "Checkbook" ) ); 73 tempstr.append( tr( "Checkbook" ) );
75 setCaption( tempstr ); 74 setCaption( tempstr );
76 } 75 }
77 else 76 else
78 { 77 {
79 setCaption( tr( "New checkbook" ) ); 78 setCaption( tr( "New checkbook" ) );
80 } 79 }
81 80
82 81
83 // Setup layout to make everything pretty 82 // Setup layout to make everything pretty
84 QVBoxLayout *layout = new QVBoxLayout( this ); 83 QVBoxLayout *layout = new QVBoxLayout( this );
85 layout->setMargin( 2 ); 84 layout->setMargin( 2 );
86 layout->setSpacing( 4 ); 85 layout->setSpacing( 4 );
87 86
88 // Setup tabs for all info 87 // Setup tabs for all info
89 mainWidget = new OTabWidget( this ); 88 mainWidget = new OTabWidget( this );
90 layout->addWidget( mainWidget ); 89 layout->addWidget( mainWidget );
91 mainWidget->addTab( initInfo(), "checkbook/infotab", tr( "Info" ) ); 90 mainWidget->addTab( initInfo(), "checkbook/infotab", tr( "Info" ) );
92 mainWidget->addTab( initTransactions(), "checkbook/trantab", tr( "Transactions" ) ); 91 mainWidget->addTab( initTransactions(), "checkbook/trantab", tr( "Transactions" ) );
93 mainWidget->addTab( initCharts(), "checkbook/charttab", tr( "Charts" ) ); 92 mainWidget->addTab( initCharts(), "checkbook/charttab", tr( "Charts" ) );
94 if( _pCfg->isShowLastTab() ) 93 if( _pCfg->isShowLastTab() )
@@ -96,7 +95,7 @@ Checkbook::Checkbook( QWidget *parent, CBInfo *i, Cfg *cfg )
96 else 95 else
97 mainWidget->setCurrentTab( tr( "Info" ) ); 96 mainWidget->setCurrentTab( tr( "Info" ) );
98 connect( mainWidget, SIGNAL( currentChanged(QWidget *) ), this, SLOT( slotTab(QWidget *) ) ); 97 connect( mainWidget, SIGNAL( currentChanged(QWidget *) ), this, SLOT( slotTab(QWidget *) ) );
99 98
100 // Load checkbook information 99 // Load checkbook information
101 loadCheckbook(); 100 loadCheckbook();
102} 101}
@@ -112,38 +111,38 @@ QWidget *Checkbook::initInfo()
112 111
113 QVBoxLayout *vb = new QVBoxLayout( control ); 112 QVBoxLayout *vb = new QVBoxLayout( control );
114 113
115 QScrollView *sv = new QScrollView( control ); 114 QScrollView *sv = new QScrollView( control );
116 vb->addWidget( sv, 0, 0 ); 115 vb->addWidget( sv, 0, 0 );
117 sv->setResizePolicy( QScrollView::AutoOneFit ); 116 sv->setResizePolicy( QScrollView::AutoOneFit );
118 sv->setFrameStyle( QFrame::NoFrame ); 117 sv->setFrameStyle( QFrame::NoFrame );
119 118
120 QWidget *container = new QWidget( sv->viewport() ); 119 QWidget *container = new QWidget( sv->viewport() );
121 sv->addChild( container ); 120 sv->addChild( container );
122 121
123 QGridLayout *layout = new QGridLayout( container ); 122 QGridLayout *layout = new QGridLayout( container );
124 layout->setSpacing( 2 ); 123 layout->setSpacing( 2 );
125 layout->setMargin( 4 ); 124 layout->setMargin( 4 );
126 125
127 // Password protection 126 // Password protection
128 passwordCB = new QCheckBox( tr( "Password protect" ), container ); 127 passwordCB = new QCheckBox( tr( "Password protect" ), container );
129 QWhatsThis::add( passwordCB, tr( "Click here to enable/disable password protection of this checkbook." ) ); 128 QWhatsThis::add( passwordCB, tr( "Click here to enable/disable password protection of this checkbook." ) );
130 connect( passwordCB, SIGNAL( clicked() ), this, SLOT( slotPasswordClicked() ) ); 129 connect( passwordCB, SIGNAL( clicked() ), this, SLOT( slotPasswordClicked() ) );
131 layout->addMultiCellWidget( passwordCB, 0, 0, 0, 1 ); 130 layout->addMultiCellWidget( passwordCB, 0, 0, 0, 1 );
132 131
133 // Account name 132 // Account name
134 QLabel *label = new QLabel( tr( "Name:" ), container ); 133 QLabel *label = new QLabel( tr( "Name:" ), container );
135 QWhatsThis::add( label, tr( "Enter name of checkbook here." ) ); 134 QWhatsThis::add( label, tr( "Enter name of checkbook here." ) );
136 layout->addWidget( label, 1, 0 ); 135 layout->addWidget( label, 1, 0 );
137 nameEdit = new QLineEdit( container ); 136 nameEdit = new QLineEdit( container );
138 QWhatsThis::add( nameEdit, tr( "Enter name of checkbook here." ) ); 137 QWhatsThis::add( nameEdit, tr( "Enter name of checkbook here." ) );
139 connect( nameEdit, SIGNAL( textChanged( const QString & ) ), 138 connect( nameEdit, SIGNAL( textChanged( const QString & ) ),
140 this, SLOT( slotNameChanged( const QString & ) ) ); 139 this, SLOT( slotNameChanged( const QString & ) ) );
141 layout->addWidget( nameEdit, 1, 1 ); 140 layout->addWidget( nameEdit, 1, 1 );
142 141
143 // Type of account 142 // Type of account
144 label = new QLabel( tr( "Type:" ), container ); 143 label = new QLabel( tr( "Type:" ), container );
145 QWhatsThis::add( label, tr( "Select type of checkbook here." ) ); 144 QWhatsThis::add( label, tr( "Select type of checkbook here." ) );
146 layout->addWidget( label, 2, 0 ); 145 layout->addWidget( label, 2, 0 );
147 typeList = new QComboBox( container ); 146 typeList = new QComboBox( container );
148 QWhatsThis::add( typeList, tr( "Select type of checkbook here." ) ); 147 QWhatsThis::add( typeList, tr( "Select type of checkbook here." ) );
149 typeList->insertStringList( _pCfg->getAccountTypes() ); 148 typeList->insertStringList( _pCfg->getAccountTypes() );
@@ -151,47 +150,47 @@ QWidget *Checkbook::initInfo()
151 150
152 // Bank/institution name 151 // Bank/institution name
153 label = new QLabel( tr( "Bank:" ), container ); 152 label = new QLabel( tr( "Bank:" ), container );
154 QWhatsThis::add( label, tr( "Enter name of the bank for this checkbook here." ) ); 153 QWhatsThis::add( label, tr( "Enter name of the bank for this checkbook here." ) );
155 layout->addWidget( label, 3, 0 ); 154 layout->addWidget( label, 3, 0 );
156 bankEdit = new QLineEdit( container ); 155 bankEdit = new QLineEdit( container );
157 QWhatsThis::add( bankEdit, tr( "Enter name of the bank for this checkbook here." ) ); 156 QWhatsThis::add( bankEdit, tr( "Enter name of the bank for this checkbook here." ) );
158 layout->addWidget( bankEdit, 3, 1 ); 157 layout->addWidget( bankEdit, 3, 1 );
159 158
160 // Account number 159 // Account number
161 label = new QLabel( tr( "Account number:" ), container ); 160 label = new QLabel( tr( "Account number:" ), container );
162 QWhatsThis::add( label, tr( "Enter account number for this checkbook here." ) ); 161 QWhatsThis::add( label, tr( "Enter account number for this checkbook here." ) );
163 layout->addWidget( label, 4, 0 ); 162 layout->addWidget( label, 4, 0 );
164 acctNumEdit = new QLineEdit( container ); 163 acctNumEdit = new QLineEdit( container );
165 QWhatsThis::add( acctNumEdit, tr( "Enter account number for this checkbook here." ) ); 164 QWhatsThis::add( acctNumEdit, tr( "Enter account number for this checkbook here." ) );
166 layout->addWidget( acctNumEdit, 4, 1 ); 165 layout->addWidget( acctNumEdit, 4, 1 );
167 166
168 // PIN number 167 // PIN number
169 label = new QLabel( tr( "PIN number:" ), container ); 168 label = new QLabel( tr( "PIN number:" ), container );
170 QWhatsThis::add( label, tr( "Enter PIN number for this checkbook here." ) ); 169 QWhatsThis::add( label, tr( "Enter PIN number for this checkbook here." ) );
171 layout->addWidget( label, 5, 0 ); 170 layout->addWidget( label, 5, 0 );
172 pinNumEdit = new QLineEdit( container ); 171 pinNumEdit = new QLineEdit( container );
173 QWhatsThis::add( pinNumEdit, tr( "Enter PIN number for this checkbook here." ) ); 172 QWhatsThis::add( pinNumEdit, tr( "Enter PIN number for this checkbook here." ) );
174 layout->addWidget( pinNumEdit, 5, 1 ); 173 layout->addWidget( pinNumEdit, 5, 1 );
175 174
176 // Starting balance 175 // Starting balance
177 label = new QLabel( tr( "Starting balance:" ), container ); 176 label = new QLabel( tr( "Starting balance:" ), container );
178 QWhatsThis::add( label, tr( "Enter the initial balance for this checkbook here." ) ); 177 QWhatsThis::add( label, tr( "Enter the initial balance for this checkbook here." ) );
179 layout->addWidget( label, 6, 0 ); 178 layout->addWidget( label, 6, 0 );
180 balanceEdit = new QLineEdit( container ); 179 balanceEdit = new QLineEdit( container );
181 QWhatsThis::add( balanceEdit, tr( "Enter the initial balance for this checkbook here." ) ); 180 QWhatsThis::add( balanceEdit, tr( "Enter the initial balance for this checkbook here." ) );
182 connect( balanceEdit, SIGNAL( textChanged( const QString & ) ), 181 connect( balanceEdit, SIGNAL( textChanged( const QString & ) ),
183 this, SLOT( slotStartingBalanceChanged( const QString & ) ) ); 182 this, SLOT( slotStartingBalanceChanged( const QString & ) ) );
184 layout->addWidget( balanceEdit, 6, 1 ); 183 layout->addWidget( balanceEdit, 6, 1 );
185 184
186 // Notes 185 // Notes
187 label = new QLabel( tr( "Notes:" ), container ); 186 label = new QLabel( tr( "Notes:" ), container );
188 QWhatsThis::add( label, tr( "Enter any additional information for this checkbook here." ) ); 187 QWhatsThis::add( label, tr( "Enter any additional information for this checkbook here." ) );
189 layout->addWidget( label, 7, 0 ); 188 layout->addWidget( label, 7, 0 );
190 notesEdit = new QMultiLineEdit( container ); 189 notesEdit = new QMultiLineEdit( container );
191 QWhatsThis::add( notesEdit, tr( "Enter any additional information for this checkbook here." ) ); 190 QWhatsThis::add( notesEdit, tr( "Enter any additional information for this checkbook here." ) );
192 notesEdit->setMinimumHeight( 25 ); 191 notesEdit->setMinimumHeight( 25 );
193 notesEdit->setMaximumHeight( 65 ); 192 notesEdit->setMaximumHeight( 65 );
194 layout->addMultiCellWidget( notesEdit, 8, 8, 0, 1 ); 193 layout->addMultiCellWidget( notesEdit, 8, 8, 0, 1 );
195 194
196 return control; 195 return control;
197} 196}
@@ -202,7 +201,7 @@ QWidget *Checkbook::initTransactions()
202{ 201{
203 QWidget *control = new QWidget( mainWidget, tr("Transactions") ); 202 QWidget *control = new QWidget( mainWidget, tr("Transactions") );
204 203
205 QGridLayout *layout = new QGridLayout( control ); 204 QGridLayout *layout = new QGridLayout( control );
206 layout->setSpacing( 2 ); 205 layout->setSpacing( 2 );
207 layout->setMargin( 4 ); 206 layout->setMargin( 4 );
208 207
@@ -210,4 +209,4 @@ QWidget *Checkbook::initTransactions()
210 QLabel *label = new QLabel( tr( "Sort by:" ), control ); 209 QLabel *label = new QLabel( tr( "Sort by:" ), control );
211 QWhatsThis::add( label, tr( "Select checkbook sorting here." ) ); 210 QWhatsThis::add( label, tr( "Select checkbook sorting here." ) );
212 layout->addMultiCellWidget( label, 0, 0, 0, 1 ); 211 layout->addMultiCellWidget( label, 0, 0, 0, 1 );
213 _cbSortType=new QComboBox( control ); 212 _cbSortType=new QComboBox( control );
@@ -224,3 +223,3 @@ QWidget *Checkbook::initTransactions()
224 tranTable->setFont( fnt ); 223 tranTable->setFont( fnt );
225 QWhatsThis::add( tranTable, tr( "This is a listing of all transactions entered for this checkbook.\n\nTo sort entries by a specific field, click on the column name." ) ); 224 QWhatsThis::add( tranTable, tr( "This is a listing of all transactions entered for this checkbook.\n\nTo sort entries by a specific field, click on the column name." ) );
226 tranTable->addColumn( tr( "Id" ) ); 225 tranTable->addColumn( tr( "Id" ) );
@@ -232,17 +231,17 @@ QWidget *Checkbook::initTransactions()
232 tranTable->addColumn( tr( "Num" ) ); 231 tranTable->addColumn( tr( "Num" ) );
233 tranTable->addColumn( tr( "Date" ) ); 232 tranTable->addColumn( tr( "Date" ) );
234 //tranTable->addColumn( tr( "Cleared" ) ); 233 //tranTable->addColumn( tr( "Cleared" ) );
235 tranTable->addColumn( tr( "Description" ) ); 234 tranTable->addColumn( tr( "Description" ) );
236 int column = tranTable->addColumn( tr( "Amount" ) ); 235 int column = tranTable->addColumn( tr( "Amount" ) );
237 tranTable->setColumnAlignment( column, Qt::AlignRight ); 236 tranTable->setColumnAlignment( column, Qt::AlignRight );
238 column=tranTable->addColumn( tr("Balance") ); 237 column=tranTable->addColumn( tr("Balance") );
239 tranTable->setColumnAlignment( column, Qt::AlignRight ); 238 tranTable->setColumnAlignment( column, Qt::AlignRight );
240 tranTable->setAllColumnsShowFocus( TRUE ); 239 tranTable->setAllColumnsShowFocus( TRUE );
241 tranTable->setSorting( -1 ); 240 tranTable->setSorting( -1 );
242 layout->addMultiCellWidget( tranTable, 1, 1, 0, 2 ); 241 layout->addMultiCellWidget( tranTable, 1, 1, 0, 2 );
243 QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold ); 242 QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold );
244 connect( tranTable, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), 243 connect( tranTable, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ),
245 this, SLOT( slotMenuTran(QListViewItem *, const QPoint &) ) ); 244 this, SLOT( slotMenuTran(QListViewItem *, const QPoint &) ) );
246 connect( tranTable, SIGNAL( doubleClicked( QListViewItem * ) ), 245 connect( tranTable, SIGNAL( doubleClicked( QListViewItem * ) ),
247 this, SLOT( slotEditTran() ) ); 246 this, SLOT( slotEditTran() ) );
248 _sortCol=COL_ID; 247 _sortCol=COL_ID;
@@ -250,18 +249,18 @@ QWidget *Checkbook::initTransactions()
250 // Buttons 249 // Buttons
251 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), control ); 250 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), control );
252 QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) ); 251 QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) );
253 connect( btn, SIGNAL( clicked() ), this, SLOT( slotNewTran() ) ); 252 connect( btn, SIGNAL( clicked() ), this, SLOT( slotNewTran() ) );
254 layout->addWidget( btn, 2, 0 ); 253 layout->addWidget( btn, 2, 0 );
255 254
256 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), control ); 255 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), control );
257 QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) ); 256 QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) );
258 connect( btn, SIGNAL( clicked() ), this, SLOT( slotEditTran() ) ); 257 connect( btn, SIGNAL( clicked() ), this, SLOT( slotEditTran() ) );
259 layout->addWidget( btn, 2, 1 ); 258 layout->addWidget( btn, 2, 1 );
260 259
261 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), control ); 260 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), control );
262 QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) ); 261 QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) );
263 connect( btn, SIGNAL( clicked() ), this, SLOT( slotDeleteTran() ) ); 262 connect( btn, SIGNAL( clicked() ), this, SLOT( slotDeleteTran() ) );
264 layout->addWidget( btn, 2, 2 ); 263 layout->addWidget( btn, 2, 2 );
265 264
266 return( control ); 265 return( control );
267} 266}
@@ -272,28 +271,28 @@ QWidget *Checkbook::initCharts()
272{ 271{
273 graphInfo = 0x0; 272 graphInfo = 0x0;
274 273
275 QWidget *control = new QWidget( mainWidget, tr("Charts") ); 274 QWidget *control = new QWidget( mainWidget, tr("Charts") );
276 275
277 QGridLayout *layout = new QGridLayout( control ); 276 QGridLayout *layout = new QGridLayout( control );
278 layout->setSpacing( 2 ); 277 layout->setSpacing( 2 );
279 layout->setMargin( 4 ); 278 layout->setMargin( 4 );
280 279
281 graphWidget = new Graph( control ); 280 graphWidget = new Graph( control );
282 QWhatsThis::add( graphWidget, tr( "Select the desired chart below and then click on the Draw button." ) ); 281 QWhatsThis::add( graphWidget, tr( "Select the desired chart below and then click on the Draw button." ) );
283 layout->addMultiCellWidget( graphWidget, 0, 0, 0, 2 ); 282 layout->addMultiCellWidget( graphWidget, 0, 0, 0, 2 );
284 283
285 graphList = new QComboBox( control ); 284 graphList = new QComboBox( control );
286 QWhatsThis::add( graphList, tr( "Click here to select the desired chart type." ) ); 285 QWhatsThis::add( graphList, tr( "Click here to select the desired chart type." ) );
287 graphList->insertItem( tr( "Account balance" ) ); 286 graphList->insertItem( tr( "Account balance" ) );
288 graphList->insertItem( tr( "Withdrawals by category" ) ); 287 graphList->insertItem( tr( "Withdrawals by category" ) );
289 graphList->insertItem( tr( "Deposits by category" ) ); 288 graphList->insertItem( tr( "Deposits by category" ) );
290 289
291 layout->addMultiCellWidget( graphList, 1, 1, 0, 1 ); 290 layout->addMultiCellWidget( graphList, 1, 1, 0, 1 );
292 291
293 QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/drawbtn" ), tr( "Draw" ), control ); 292 QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/drawbtn" ), tr( "Draw" ), control );
294 QWhatsThis::add( btn, tr( "Click here to draw the selected chart." ) ); 293 QWhatsThis::add( btn, tr( "Click here to draw the selected chart." ) );
295 connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) ); 294 connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) );
296 layout->addWidget( btn, 1, 2 ); 295 layout->addWidget( btn, 1, 2 );
297 296
298 return control; 297 return control;
299} 298}
@@ -303,22 +302,22 @@ void Checkbook::loadCheckbook()
303{ 302{
304 if ( !info ) 303 if ( !info )
305 { 304 {
306 return; 305 return;
307 } 306 }
308 307
309 tranList = info->transactions(); 308 tranList = info->transactions();
310 309
311 passwordCB->setChecked( !info->password().isNull() ); 310 passwordCB->setChecked( !info->password().isNull() );
312 nameEdit->setText( info->name() ); 311 nameEdit->setText( info->name() );
313 QString temptext = info->type(); 312 QString temptext = info->type();
314 int i = typeList->count(); 313 int i = typeList->count();
315 while ( i > 0 ) 314 while ( i > 0 )
316 { 315 {
317 i--; 316 i--;
318 typeList->setCurrentItem( i ); 317 typeList->setCurrentItem( i );
319 if ( typeList->currentText() == temptext ) 318 if ( typeList->currentText() == temptext )
320 { 319 {
321 break; 320 break;
322 } 321 }
323 } 322 }
324 if( i<=0 ) { 323 if( i<=0 ) {
@@ -327,22 +326,22 @@ void Checkbook::loadCheckbook()
327 } 326 }
328 bankEdit->setText( info->bank() ); 327 bankEdit->setText( info->bank() );
329 acctNumEdit->setText( info->account() ); 328 acctNumEdit->setText( info->account() );
330 pinNumEdit->setText( info->pin() ); 329 pinNumEdit->setText( info->pin() );
331 temptext.setNum( info->startingBalance(), 'f', 2 ); 330 temptext.setNum( info->startingBalance(), 'f', 2 );
332 balanceEdit->setText( temptext ); 331 balanceEdit->setText( temptext );
333 notesEdit->setText( info->notes() ); 332 notesEdit->setText( info->notes() );
334 333
335 // Load transactions 334 // Load transactions
336 float amount; 335 float amount;
337 QString stramount; 336 QString stramount;
338 for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() ) 337 for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() )
339 { 338 {
340 amount = tran->amount(); 339 amount = tran->amount();
341 if ( tran->withdrawal() ) 340 if ( tran->withdrawal() )
342 { 341 {
343 amount *= -1; 342 amount *= -1;
344 } 343 }
345 stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); 344 stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount );
346 ( void ) new CBListItem( tran, tranTable, tran->getIdStr(), tran->datestr(false), tran->number(), tran->datestr(true), tran->desc(), stramount ); 345 ( void ) new CBListItem( tran, tranTable, tran->getIdStr(), tran->datestr(false), tran->number(), tran->datestr(true), tran->desc(), stramount );
347 } 346 }
348 347
@@ -371,3 +370,3 @@ void Checkbook::adjustBalance()
371{ 370{
372 // update running balance in register 371 // update running balance in register
373 QString sRunning; 372 QString sRunning;
@@ -394,12 +393,12 @@ void Checkbook::accept()
394{ 393{
395 info->setName( nameEdit->text() ); 394 info->setName( nameEdit->text() );
396 info->setType( typeList->currentText() ); 395 info->setType( typeList->currentText() );
397 info->setBank( bankEdit->text() ); 396 info->setBank( bankEdit->text() );
398 info->setAccount( acctNumEdit->text() ); 397 info->setAccount( acctNumEdit->text() );
399 info->setPin( pinNumEdit->text() ); 398 info->setPin( pinNumEdit->text() );
400 bool ok; 399 bool ok;
401 info->setStartingBalance( balanceEdit->text().toFloat( &ok ) ); 400 info->setStartingBalance( balanceEdit->text().toFloat( &ok ) );
402 info->setNotes( notesEdit->text() ); 401 info->setNotes( notesEdit->text() );
403 402
404 QDialog::accept(); 403 QDialog::accept();
405} 404}
@@ -409,40 +408,40 @@ void Checkbook::slotPasswordClicked()
409{ 408{
410 if ( info->password().isNull() && passwordCB->isChecked() ) 409 if ( info->password().isNull() && passwordCB->isChecked() )
411 { 410 {
412 Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); 411 Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) );
413 if ( pw->exec() != QDialog::Accepted ) 412 if ( pw->exec() != QDialog::Accepted )
414 { 413 {
415 passwordCB->setChecked( FALSE ); 414 passwordCB->setChecked( FALSE );
416 delete pw; 415 delete pw;
417 return; 416 return;
418 } 417 }
419 info->setPassword( pw->password ); 418 info->setPassword( pw->password );
420 delete pw; 419 delete pw;
421 420
422 pw = new Password( this, tr( "Confirm password" ), tr( "Please confirm your password:" ) ); 421 pw = new Password( this, tr( "Confirm password" ), tr( "Please confirm your password:" ) );
423 if ( pw->exec() != QDialog::Accepted || pw->password != info->password() ) 422 if ( pw->exec() != QDialog::Accepted || pw->password != info->password() )
424 { 423 {
425 passwordCB->setChecked( FALSE ); 424 passwordCB->setChecked( FALSE );
426 info->setPassword( QString::null ); 425 info->setPassword( QString::null );
427 } 426 }
428 427
429 delete pw; 428 delete pw;
430 } 429 }
431 else if ( !info->password().isNull() && !passwordCB->isChecked() ) 430 else if ( !info->password().isNull() && !passwordCB->isChecked() )
432 { 431 {
433 Password *pw = new Password( this, tr( "Enter password" ), 432 Password *pw = new Password( this, tr( "Enter password" ),
434 tr( "Please enter your password to confirm removal of password protection:" ) ); 433 tr( "Please enter your password to confirm removal of password protection:" ) );
435 if ( pw->exec() == QDialog::Accepted && pw->password == info->password() ) 434 if ( pw->exec() == QDialog::Accepted && pw->password == info->password() )
436 { 435 {
437 info->setPassword( QString::null ); 436 info->setPassword( QString::null );
438 delete pw; 437 delete pw;
439 return; 438 return;
440 } 439 }
441 else 440 else
442 { 441 {
443 passwordCB->setChecked( TRUE ); 442 passwordCB->setChecked( TRUE );
444 } 443 }
445 444
446 delete pw; 445 delete pw;
447 } 446 }
448} 447}
@@ -451,14 +450,14 @@ void Checkbook::slotNameChanged( const QString &newname )
451{ 450{
452 info->setName( newname ); 451 info->setName( newname );
453 452
454 // TODO - need filedir 453 // TODO - need filedir
455 //QString namestr = filedir; 454// QString namestr = filedir;
456 //namestr.append( newname ); 455// namestr.append( newname );
457 //namestr.append( ".qcb" ); 456// namestr.append( ".qcb" );
458 //info->setFilename( namestr ); 457// info->setFilename( namestr );
459 458
460 QString namestr = newname; 459 QString namestr = newname;
461 namestr.append( " - " ); 460 namestr.append( " - " );
462 namestr.append( tr( "Checkbook" ) ); 461 namestr.append( tr( "Checkbook" ) );
463 setCaption( namestr ); 462 setCaption( namestr );
464} 463}
@@ -469,5 +468,5 @@ void Checkbook::slotStartingBalanceChanged( const QString &newbalance )
469{ 468{
470 bool ok; 469 bool ok;
471 info->setStartingBalance( newbalance.toFloat( &ok ) ); 470 info->setStartingBalance( newbalance.toFloat( &ok ) );
472 adjustBalance(); 471 adjustBalance();
473} 472}
@@ -478,3 +477,3 @@ void Checkbook::slotNewTran()
478{ 477{
479 TranInfo *traninfo = new TranInfo( info->getNextNumber() ); 478 TranInfo *traninfo = new TranInfo( info->getNextNumber() );
480 if( !_dLastNew.isNull() ) 479 if( !_dLastNew.isNull() )
@@ -482,20 +481,20 @@ void Checkbook::slotNewTran()
482 481
483 Transaction *currtran = new Transaction( this, true, info->name(), 482 Transaction *currtran = new Transaction( this, true, info->name(),
484 traninfo, 483 traninfo,
485 _pCfg ); 484 _pCfg );
486 if ( QPEApplication::execDialog( currtran ) == QDialog::Accepted ) 485 if ( QPEApplication::execDialog( currtran ) == QDialog::Accepted )
487 { 486 {
488 // Add to transaction list 487 // Add to transaction list
489 info->addTransaction( traninfo ); 488 info->addTransaction( traninfo );
490 489
491 // Add to transaction table 490 // Add to transaction table
492 float amount; 491 float amount;
493 QString stramount; 492 QString stramount;
494 amount = (traninfo->withdrawal() ? -1 : 1)*traninfo->amount(); 493 amount = (traninfo->withdrawal() ? -1 : 1)*traninfo->amount();
495 stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); 494 stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount );
496 ( void ) new CBListItem( traninfo, tranTable, traninfo->getIdStr(), traninfo->datestr(false), 495 ( void ) new CBListItem( traninfo, tranTable, traninfo->getIdStr(), traninfo->datestr(false),
497 traninfo->number(), traninfo->datestr(true), traninfo->desc(), 496 traninfo->number(), traninfo->datestr(true), traninfo->desc(),
498 stramount ); 497 stramount );
499 resort(); 498 resort();
500 adjustBalance(); 499 adjustBalance();
501 500
@@ -511,7 +510,7 @@ void Checkbook::slotNewTran()
511 } 510 }
512 } 511 }
513 else 512 else
514 { 513 {
515 delete traninfo; 514 delete traninfo;
516 } 515 }
517} 516}
@@ -522,26 +521,26 @@ void Checkbook::slotEditTran()
522{ 521{
523 QListViewItem *curritem = tranTable->currentItem(); 522 QListViewItem *curritem = tranTable->currentItem();
524 if ( !curritem ) 523 if ( !curritem )
525 return; 524 return;
526 525
527 TranInfo *traninfo=info->findTransaction( curritem->text(COL_ID) ); 526 TranInfo *traninfo=info->findTransaction( curritem->text(COL_ID) );
528 527
529 Transaction *currtran = new Transaction( this, false, info->name(), 528 Transaction *currtran = new Transaction( this, false, info->name(),
530 traninfo, 529 traninfo,
531 _pCfg ); 530 _pCfg );
532 if ( QPEApplication::execDialog( currtran ) == QDialog::Accepted ) 531 if ( QPEApplication::execDialog( currtran ) == QDialog::Accepted )
533 { 532 {
534 curritem->setText( COL_NUM, traninfo->number() ); 533 curritem->setText( COL_NUM, traninfo->number() );
535 curritem->setText( COL_SORTDATE, traninfo->datestr(false) ); 534 curritem->setText( COL_SORTDATE, traninfo->datestr(false) );
536 curritem->setText( COL_DATE, traninfo->datestr(true) ); 535 curritem->setText( COL_DATE, traninfo->datestr(true) );
537 curritem->setText( COL_DESC, traninfo->desc() ); 536 curritem->setText( COL_DESC, traninfo->desc() );
538 537
539 float amount = traninfo->amount(); 538 float amount = traninfo->amount();
540 if ( traninfo->withdrawal() ) 539 if ( traninfo->withdrawal() )
541 { 540 {
542 amount *= -1; 541 amount *= -1;
543 } 542 }
544 QString stramount; 543 QString stramount;
545 stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); 544 stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount );
546 curritem->setText( COL_AMOUNT, stramount ); 545 curritem->setText( COL_AMOUNT, stramount );
547 resort(); 546 resort();
@@ -556,5 +555,5 @@ void Checkbook::slotEditTran()
556 } 555 }
557 } 556 }
558 557
559 delete currtran; 558 delete currtran;
560} 559}
@@ -570,6 +569,6 @@ void Checkbook::slotMenuTran(QListViewItem *item, const QPoint &pnt)
570 QPopupMenu m; 569 QPopupMenu m;
571 m.insertItem( QWidget::tr( "Edit" ), 1 ); 570 m.insertItem( QWidget::tr( "Edit" ), 1 );
572 m.insertItem( QWidget::tr( "New" ), 2 ); 571 m.insertItem( QWidget::tr( "New" ), 2 );
573 m.insertItem( QWidget::tr( "Delete" ), 3 ); 572 m.insertItem( QWidget::tr( "Delete" ), 3 );
574 int r = m.exec( pnt ); 573 int r = m.exec( pnt );
575 switch(r) { 574 switch(r) {
@@ -591,14 +590,14 @@ void Checkbook::slotDeleteTran()
591{ 590{
592 QListViewItem *curritem = tranTable->currentItem(); 591 QListViewItem *curritem = tranTable->currentItem();
593 if ( !curritem ) 592 if ( !curritem )
594 return; 593 return;
595 594
596 TranInfo *traninfo = info->findTransaction( curritem->text(COL_ID) ); 595 TranInfo *traninfo = info->findTransaction( curritem->text(COL_ID) );
597 596
598 if ( QPEMessageBox::confirmDelete ( this, tr( "Delete transaction" ), traninfo->desc() ) ) 597 if ( QPEMessageBox::confirmDelete ( this, tr( "Delete transaction" ), traninfo->desc() ) )
599 { 598 {
600 info->removeTransaction( traninfo ); 599 info->removeTransaction( traninfo );
601 delete curritem; 600 delete curritem;
602 adjustBalance(); 601 adjustBalance();
603 } 602 }
604} 603}
@@ -607,19 +606,19 @@ void Checkbook::slotDrawGraph()
607{ 606{
608 if ( graphInfo ) 607 if ( graphInfo )
609 { 608 {
610 delete graphInfo; 609 delete graphInfo;
611 } 610 }
612 611
613 switch ( graphList->currentItem() ) 612 switch ( graphList->currentItem() )
614 { 613 {
615 case 0 : drawBalanceChart(); 614 case 0 : drawBalanceChart();
616 break; 615 break;
617 case 1 : drawCategoryChart( TRUE ); 616 case 1 : drawCategoryChart( TRUE );
618 break; 617 break;
619 case 2 : drawCategoryChart( FALSE ); 618 case 2 : drawCategoryChart( FALSE );
620 break; 619 break;
621 }; 620 };
622 621
623 graphWidget->setGraphInfo( graphInfo ); 622 graphWidget->setGraphInfo( graphInfo );
624 graphWidget->drawGraph( TRUE ); 623 graphWidget->drawGraph( TRUE );
625} 624}
@@ -628,32 +627,32 @@ void Checkbook::drawBalanceChart()
628{ 627{
629 DataPointList *list = new DataPointList(); 628 DataPointList *list = new DataPointList();
630 629
631 float balance = info->startingBalance(); 630 float balance = info->startingBalance();
632 float amount; 631 float amount;
633 QString label; 632 QString label;
634 int i = 0; 633 int i = 0;
635 int count = tranList->count(); 634 int count = tranList->count();
636 635
637 for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() ) 636 for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() )
638 { 637 {
639 i++; 638 i++;
640 balance -= tran->fee(); 639 balance -= tran->fee();
641 amount = tran->amount(); 640 amount = tran->amount();
642 if ( tran->withdrawal() ) 641 if ( tran->withdrawal() )
643 { 642 {
644 amount *= -1; 643 amount *= -1;
645 } 644 }
646 balance += amount; 645 balance += amount;
647 if ( i == 1 || i == count / 2 || i == count ) 646 if ( i == 1 || i == count / 2 || i == count )
648 { 647 {
649 label = tran->datestr(true); 648 label = tran->datestr(true);
650 } 649 }
651 else 650 else
652 { 651 {
653 label = ""; 652 label = "";
654 } 653 }
655 list->append( new DataPointInfo( label, balance ) ); 654 list->append( new DataPointInfo( label, balance ) );
656 } 655 }
657 656
658 graphInfo = new GraphInfo( GraphInfo::BarChart, list ); 657 graphInfo = new GraphInfo( GraphInfo::BarChart, list );
659} 658}
@@ -662,36 +661,36 @@ void Checkbook::drawCategoryChart( bool withdrawals )
662{ 661{
663 DataPointList *list = new DataPointList(); 662 DataPointList *list = new DataPointList();
664 663
665 TranInfo *tran = tranList->first(); 664 TranInfo *tran = tranList->first();
666 if ( tran && tran->withdrawal() == withdrawals ) 665 if ( tran && tran->withdrawal() == withdrawals )
667 { 666 {
668 list->append( new DataPointInfo( tran->category(), tran->amount() ) ); 667 list->append( new DataPointInfo( tran->category(), tran->amount() ) );
669 } 668 }
670 tran = tranList->next(); 669 tran = tranList->next();
671 670
672 DataPointInfo *cat; 671 DataPointInfo *cat;
673 for ( ; tran; tran = tranList->next() ) 672 for ( ; tran; tran = tranList->next() )
674 { 673 {
675 if ( tran->withdrawal() == withdrawals ) 674 if ( tran->withdrawal() == withdrawals )
676 { 675 {
677 // Find category in list 676 // Find category in list
678 for ( cat = list->first(); cat; cat = list->next() ) 677 for ( cat = list->first(); cat; cat = list->next() )
679 { 678 {
680 if ( cat->label() == tran->category() ) 679 if ( cat->label() == tran->category() )
681 { 680 {
682 break; 681 break;
683 } 682 }
684 } 683 }
685 if ( cat && cat->label() == tran->category() ) 684 if ( cat && cat->label() == tran->category() )
686 { // Found category, add to transaction to category total 685 { // Found category, add to transaction to category total
687 cat->addToValue( tran->amount() ); 686 cat->addToValue( tran->amount() );
688 } 687 }
689 else 688 else
690 { // Didn't find category, add category to list 689 { // Didn't find category, add category to list
691 list->append( new DataPointInfo( tran->category(), tran->amount() ) ); 690 list->append( new DataPointInfo( tran->category(), tran->amount() ) );
692 } 691 }
693 } 692 }
694 } 693 }
695 694
696 graphInfo = new GraphInfo( GraphInfo::PieChart, list ); 695 graphInfo = new GraphInfo( GraphInfo::PieChart, list );
697} 696}
@@ -699,9 +698,9 @@ void Checkbook::drawCategoryChart( bool withdrawals )
699CBListItem::CBListItem( TranInfo *pTran, QListView *parent, QString label1, QString label2, 698CBListItem::CBListItem( TranInfo *pTran, QListView *parent, QString label1, QString label2,
700 QString label3, QString label4, QString label5, QString label6, QString label7, 699 QString label3, QString label4, QString label5, QString label6, QString label7,
701 QString label8 ) 700 QString label8 )
702 : QListViewItem( parent, label1, label2, label3, label4, label5, label6, label7, label8 ) 701 : QListViewItem( parent, label1, label2, label3, label4, label5, label6, label7, label8 )
703{ 702{
704 _pTran=pTran; 703 _pTran=pTran;
705 m_known = FALSE; 704 m_known = FALSE;
706 owner = parent; 705 owner = parent;
707} 706}
@@ -710,13 +709,13 @@ void CBListItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int
710{ 709{
711 QColorGroup _cg = cg; 710 QColorGroup _cg = cg;
712 const QPixmap *pm = listView()->viewport()->backgroundPixmap(); 711 const QPixmap *pm = listView()->viewport()->backgroundPixmap();
713 if ( pm && !pm->isNull() ) 712 if ( pm && !pm->isNull() )
714 { 713 {
715 _cg.setBrush( QColorGroup::Base, QBrush( cg.base(), *pm ) ); 714 _cg.setBrush( QColorGroup::Base, QBrush( cg.base(), *pm ) );
716 p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); 715 p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() );
717 } 716 }
718 else if ( isAltBackground() ) 717 else if ( isAltBackground() )
719 _cg.setColor(QColorGroup::Base, cg.background() ); 718 _cg.setColor(QColorGroup::Base, cg.background() );
720 719
721 QListViewItem::paintCell(p, _cg, column, width, align); 720 QListViewItem::paintCell(p, _cg, column, width, align);
722} 721}
@@ -726,38 +725,38 @@ bool CBListItem::isAltBackground()
726{ 725{
727 QListView *lv = static_cast<QListView *>( listView() ); 726 QListView *lv = static_cast<QListView *>( listView() );
728 if ( lv ) 727 if ( lv )
729 { 728 {
730 CBListItem *above = 0; 729 CBListItem *above = 0;
731 above = (CBListItem *)( itemAbove() ); 730 above = (CBListItem *)( itemAbove() );
732 m_known = above ? above->m_known : true; 731 m_known = above ? above->m_known : true;
733 if ( m_known ) 732 if ( m_known )
734 { 733 {
735 m_odd = above ? !above->m_odd : false; 734 m_odd = above ? !above->m_odd : false;
736 } 735 }
737 else 736 else
738 { 737 {
739 CBListItem *item; 738 CBListItem *item;
740 bool previous = true; 739 bool previous = true;
741 if ( parent() ) 740 if ( parent() )
742 { 741 {
743 item = (CBListItem *)( parent() ); 742 item = (CBListItem *)( parent() );
744 if ( item ) 743 if ( item )
745 previous = item->m_odd; 744 previous = item->m_odd;
746 item = (CBListItem *)( parent()->firstChild() ); 745 item = (CBListItem *)( parent()->firstChild() );
747 } 746 }
748 else 747 else
749 { 748 {
750 item = (CBListItem *)( lv->firstChild() ); 749 item = (CBListItem *)( lv->firstChild() );
751 } 750 }
752 751
753 while(item) 752 while(item)
754 { 753 {
755 item->m_odd = previous = !previous; 754 item->m_odd = previous = !previous;
756 item->m_known = true; 755 item->m_known = true;
757 item = (CBListItem *)( item->nextSibling() ); 756 item = (CBListItem *)( item->nextSibling() );
758 } 757 }
759 } 758 }
760 return m_odd; 759 return m_odd;
761 } 760 }
762 return false; 761 return false;
763} 762}