summaryrefslogtreecommitdiff
authordrw <drw>2002-11-30 22:51:39 (UTC)
committer drw <drw>2002-11-30 22:51:39 (UTC)
commit666313593479c03cdc88bd8fde926af181cb8423 (patch) (unidiff)
tree79f5334d7ec7918146469d567466607ebaea28a8
parent2e2bbf823ba532f349ad9ca3dd84cf7f758f36b0 (diff)
downloadopie-666313593479c03cdc88bd8fde926af181cb8423.zip
opie-666313593479c03cdc88bd8fde926af181cb8423.tar.gz
opie-666313593479c03cdc88bd8fde926af181cb8423.tar.bz2
Checkbook password protection
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/checkbook/checkbook.cpp96
-rw-r--r--noncore/apps/checkbook/checkbook.h9
-rw-r--r--noncore/apps/checkbook/checkbook.pro2
-rw-r--r--noncore/apps/checkbook/mainwindow.cpp26
-rw-r--r--noncore/apps/checkbook/mainwindow.h2
-rw-r--r--noncore/apps/checkbook/password.cpp99
-rw-r--r--noncore/apps/checkbook/password.h55
-rw-r--r--noncore/apps/checkbook/transaction.cpp2
-rw-r--r--noncore/apps/checkbook/transaction.h4
9 files changed, 264 insertions, 31 deletions
diff --git a/noncore/apps/checkbook/checkbook.cpp b/noncore/apps/checkbook/checkbook.cpp
index 09b0b46..5a6d607 100644
--- a/noncore/apps/checkbook/checkbook.cpp
+++ b/noncore/apps/checkbook/checkbook.cpp
@@ -1,661 +1,715 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 =. 3 =.
4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> 4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
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 "checkbook.h" 29#include "checkbook.h"
30#include "transaction.h" 30#include "transaction.h"
31#include "graph.h" 31#include "graph.h"
32#include "graphinfo.h" 32#include "graphinfo.h"
33#include "password.h"
33 34
34#include <opie/otabwidget.h> 35#include <opie/otabwidget.h>
35#include <qpe/config.h> 36#include <qpe/config.h>
36#include <qpe/qpeapplication.h> 37#include <qpe/qpeapplication.h>
37#include <qpe/qpemessagebox.h> 38#include <qpe/qpemessagebox.h>
38#include <qpe/resource.h> 39#include <qpe/resource.h>
39 40
41#include <qcheckbox.h>
40#include <qcombobox.h> 42#include <qcombobox.h>
41#include <qfile.h> 43#include <qfile.h>
42#include <qfontmetrics.h> 44#include <qfontmetrics.h>
43#include <qlabel.h> 45#include <qlabel.h>
44#include <qlayout.h> 46#include <qlayout.h>
45#include <qlineedit.h> 47#include <qlineedit.h>
46#include <qmultilineedit.h> 48#include <qmultilineedit.h>
47#include <qpushbutton.h> 49#include <qpushbutton.h>
48#include <qwhatsthis.h> 50#include <qwhatsthis.h>
49#include <qwidget.h> 51#include <qwidget.h>
50 52
51Checkbook::Checkbook( QWidget *parent, const QString &n, const QString &fd, char symbol ) 53Checkbook::Checkbook( QWidget *parent, const QString &n, const QString &fd, const QString &symbol )
52 : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) 54 : QDialog( parent, 0, TRUE, WStyle_ContextHelp )
53{ 55{
54 name = n; 56 name = n;
55 filename = fd; 57 filename = fd;
56 filename.append( name ); 58 filename.append( name );
57 filename.append( ".qcb" ); 59 filename.append( ".qcb" );
58 filedir = fd; 60 filedir = fd;
59 currencySymbol = symbol; 61 currencySymbol = symbol;
60 currBalance = 0.0; 62 currBalance = 0.0;
61 63
62 if ( name != "" ) 64 if ( name != "" )
63 { 65 {
64 QString tempstr = name; 66 QString tempstr = name;
65 tempstr.append( " - " ); 67 tempstr.append( " - " );
66 tempstr.append( tr( "Checkbook" ) ); 68 tempstr.append( tr( "Checkbook" ) );
67 setCaption( tempstr ); 69 setCaption( tempstr );
68 } 70 }
69 else 71 else
70 { 72 {
71 setCaption( tr( "New checkbook" ) ); 73 setCaption( tr( "New checkbook" ) );
72 } 74 }
73 75
74 // Setup layout to make everything pretty 76 // Setup layout to make everything pretty
75 QVBoxLayout *layout = new QVBoxLayout( this ); 77 QVBoxLayout *layout = new QVBoxLayout( this );
76 layout->setMargin( 2 ); 78 layout->setMargin( 2 );
77 layout->setSpacing( 4 ); 79 layout->setSpacing( 4 );
78 80
79 // Setup tabs for all info 81 // Setup tabs for all info
80 mainWidget = new OTabWidget( this ); 82 mainWidget = new OTabWidget( this );
81 layout->addWidget( mainWidget ); 83 layout->addWidget( mainWidget );
82 84
83 mainWidget->addTab( initInfo(), "checkbook/infotab", tr( "Info" ) ); 85 mainWidget->addTab( initInfo(), "checkbook/infotab", tr( "Info" ) );
84 mainWidget->addTab( initTransactions(), "checkbook/trantab", tr( "Transactions" ) ); 86 mainWidget->addTab( initTransactions(), "checkbook/trantab", tr( "Transactions" ) );
85 mainWidget->addTab( initCharts(), "checkbook/charttab", tr( "Charts" ) ); 87 mainWidget->addTab( initCharts(), "checkbook/charttab", tr( "Charts" ) );
86 mainWidget->setCurrentTab( tr( "Info" ) ); 88 mainWidget->setCurrentTab( tr( "Info" ) );
87 89
88 // Load checkbook information 90 // Load checkbook information
89 loadCheckbook(); 91 loadCheckbook();
90} 92}
91 93
92Checkbook::~Checkbook() 94Checkbook::~Checkbook()
93{ 95{
94} 96}
95 97
96const QString &Checkbook::getName() 98const QString &Checkbook::getName()
97{ 99{
98 return( name ); 100 return( name );
99} 101}
100 102
101QWidget *Checkbook::initInfo() 103QWidget *Checkbook::initInfo()
102{ 104{
103 QWidget *control = new QWidget( mainWidget ); 105 QWidget *control = new QWidget( mainWidget );
104 106
105 QVBoxLayout *vb = new QVBoxLayout( control ); 107 QVBoxLayout *vb = new QVBoxLayout( control );
106 108
107 QScrollView *sv = new QScrollView( control ); 109 QScrollView *sv = new QScrollView( control );
108 vb->addWidget( sv, 0, 0 ); 110 vb->addWidget( sv, 0, 0 );
109 sv->setResizePolicy( QScrollView::AutoOneFit ); 111 sv->setResizePolicy( QScrollView::AutoOneFit );
110 sv->setFrameStyle( QFrame::NoFrame ); 112 sv->setFrameStyle( QFrame::NoFrame );
111 113
112 QWidget *container = new QWidget( sv->viewport() ); 114 QWidget *container = new QWidget( sv->viewport() );
113 sv->addChild( container ); 115 sv->addChild( container );
114 116
115 QGridLayout *layout = new QGridLayout( container ); 117 QGridLayout *layout = new QGridLayout( container );
116 layout->setSpacing( 2 ); 118 layout->setSpacing( 2 );
117 layout->setMargin( 4 ); 119 layout->setMargin( 4 );
118 120
121 // Password protection
122 passwordCB = new QCheckBox( tr( "Password protect" ), container );
123 QWhatsThis::add( passwordCB, tr( "Click here to enable/disable password protection of this checkbook." ) );
124 connect( passwordCB, SIGNAL( clicked() ), this, SLOT( slotPasswordClicked() ) );
125 layout->addMultiCellWidget( passwordCB, 0, 0, 0, 1 );
126
119 // Account name 127 // Account name
120 QLabel *label = new QLabel( tr( "Name:" ), container ); 128 QLabel *label = new QLabel( tr( "Name:" ), container );
121 QWhatsThis::add( label, tr( "Enter name of checkbook here." ) ); 129 QWhatsThis::add( label, tr( "Enter name of checkbook here." ) );
122 layout->addWidget( label, 0, 0 ); 130 layout->addWidget( label, 1, 0 );
123 nameEdit = new QLineEdit( container ); 131 nameEdit = new QLineEdit( container );
124 QWhatsThis::add( nameEdit, tr( "Enter name of checkbook here." ) ); 132 QWhatsThis::add( nameEdit, tr( "Enter name of checkbook here." ) );
125 connect( nameEdit, SIGNAL( textChanged( const QString & ) ), 133 connect( nameEdit, SIGNAL( textChanged( const QString & ) ),
126 this, SLOT( slotNameChanged( const QString & ) ) ); 134 this, SLOT( slotNameChanged( const QString & ) ) );
127 layout->addWidget( nameEdit, 0, 1 ); 135 layout->addWidget( nameEdit, 1, 1 );
128 136
129 // Type of account 137 // Type of account
130 label = new QLabel( tr( "Type:" ), container ); 138 label = new QLabel( tr( "Type:" ), container );
131 QWhatsThis::add( label, tr( "Select type of checkbook here." ) ); 139 QWhatsThis::add( label, tr( "Select type of checkbook here." ) );
132 layout->addWidget( label, 1, 0 ); 140 layout->addWidget( label, 2, 0 );
133 typeList = new QComboBox( container ); 141 typeList = new QComboBox( container );
134 QWhatsThis::add( typeList, tr( "Select type of checkbook here." ) ); 142 QWhatsThis::add( typeList, tr( "Select type of checkbook here." ) );
135 typeList->insertItem( tr( "Savings" ) ); // 0 143 typeList->insertItem( tr( "Savings" ) ); // 0
136 typeList->insertItem( tr( "Checking" ) ); // 1 144 typeList->insertItem( tr( "Checking" ) ); // 1
137 typeList->insertItem( tr( "CD" ) ); // 2 145 typeList->insertItem( tr( "CD" ) ); // 2
138 typeList->insertItem( tr( "Money market" ) );// 3 146 typeList->insertItem( tr( "Money market" ) );// 3
139 typeList->insertItem( tr( "Mutual fund" ) );// 4 147 typeList->insertItem( tr( "Mutual fund" ) );// 4
140 typeList->insertItem( tr( "Other" ) ); // 5 148 typeList->insertItem( tr( "Other" ) ); // 5
141 layout->addWidget( typeList, 1, 1 ); 149 layout->addWidget( typeList, 2, 1 );
142 150
143 // Bank/institution name 151 // Bank/institution name
144 label = new QLabel( tr( "Bank:" ), container ); 152 label = new QLabel( tr( "Bank:" ), container );
145 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." ) );
146 layout->addWidget( label, 2, 0 ); 154 layout->addWidget( label, 3, 0 );
147 bankEdit = new QLineEdit( container ); 155 bankEdit = new QLineEdit( container );
148 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." ) );
149 layout->addWidget( bankEdit, 2, 1 ); 157 layout->addWidget( bankEdit, 3, 1 );
150 158
151 // Account number 159 // Account number
152 label = new QLabel( tr( "Account number:" ), container ); 160 label = new QLabel( tr( "Account number:" ), container );
153 QWhatsThis::add( label, tr( "Enter account number for this checkbook here." ) ); 161 QWhatsThis::add( label, tr( "Enter account number for this checkbook here." ) );
154 layout->addWidget( label, 3, 0 ); 162 layout->addWidget( label, 4, 0 );
155 acctNumEdit = new QLineEdit( container ); 163 acctNumEdit = new QLineEdit( container );
156 QWhatsThis::add( acctNumEdit, tr( "Enter account number for this checkbook here." ) ); 164 QWhatsThis::add( acctNumEdit, tr( "Enter account number for this checkbook here." ) );
157 layout->addWidget( acctNumEdit, 3, 1 ); 165 layout->addWidget( acctNumEdit, 4, 1 );
158 166
159 // PIN number 167 // PIN number
160 label = new QLabel( tr( "PIN number:" ), container ); 168 label = new QLabel( tr( "PIN number:" ), container );
161 QWhatsThis::add( label, tr( "Enter PIN number for this checkbook here." ) ); 169 QWhatsThis::add( label, tr( "Enter PIN number for this checkbook here." ) );
162 layout->addWidget( label, 4, 0 ); 170 layout->addWidget( label, 5, 0 );
163 pinNumEdit = new QLineEdit( container ); 171 pinNumEdit = new QLineEdit( container );
164 QWhatsThis::add( pinNumEdit, tr( "Enter PIN number for this checkbook here." ) ); 172 QWhatsThis::add( pinNumEdit, tr( "Enter PIN number for this checkbook here." ) );
165 layout->addWidget( pinNumEdit, 4, 1 ); 173 layout->addWidget( pinNumEdit, 5, 1 );
166 174
167 // Starting balance 175 // Starting balance
168 label = new QLabel( tr( "Starting balance:" ), container ); 176 label = new QLabel( tr( "Starting balance:" ), container );
169 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." ) );
170 layout->addWidget( label, 5, 0 ); 178 layout->addWidget( label, 6, 0 );
171 balanceEdit = new QLineEdit( container ); 179 balanceEdit = new QLineEdit( container );
172 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." ) );
173 connect( balanceEdit, SIGNAL( textChanged( const QString & ) ), 181 connect( balanceEdit, SIGNAL( textChanged( const QString & ) ),
174 this, SLOT( slotStartingBalanceChanged( const QString & ) ) ); 182 this, SLOT( slotStartingBalanceChanged( const QString & ) ) );
175 layout->addWidget( balanceEdit, 5, 1 ); 183 layout->addWidget( balanceEdit, 6, 1 );
176 184
177 // Notes 185 // Notes
178 label = new QLabel( tr( "Notes:" ), container ); 186 label = new QLabel( tr( "Notes:" ), container );
179 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." ) );
180 layout->addWidget( label, 6, 0 ); 188 layout->addWidget( label, 7, 0 );
181 notesEdit = new QMultiLineEdit( container ); 189 notesEdit = new QMultiLineEdit( container );
182 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." ) );
183 notesEdit->setMaximumHeight( 85 ); 191 notesEdit->setMinimumHeight( 25 );
184 layout->addMultiCellWidget( notesEdit, 7, 7, 0, 1 ); 192 notesEdit->setMaximumHeight( 65 );
193 layout->addMultiCellWidget( notesEdit, 8, 8, 0, 1 );
185 194
186 return control; 195 return control;
187} 196}
188 197
189QWidget *Checkbook::initTransactions() 198QWidget *Checkbook::initTransactions()
190{ 199{
191 QWidget *control = new QWidget( mainWidget ); 200 QWidget *control = new QWidget( mainWidget );
192 201
193 QGridLayout *layout = new QGridLayout( control ); 202 QGridLayout *layout = new QGridLayout( control );
194 layout->setSpacing( 2 ); 203 layout->setSpacing( 2 );
195 layout->setMargin( 4 ); 204 layout->setMargin( 4 );
196 205
197 balanceLabel = new QLabel( tr( "Current balance: %10.00" ).arg( currencySymbol ), 206 balanceLabel = new QLabel( tr( "Current balance: %10.00" ).arg( currencySymbol ),
198 control ); 207 control );
199 QWhatsThis::add( balanceLabel, tr( "This area shows the current balance in this checkbook." ) ); 208 QWhatsThis::add( balanceLabel, tr( "This area shows the current balance in this checkbook." ) );
200 layout->addMultiCellWidget( balanceLabel, 0, 0, 0, 2 ); 209 layout->addMultiCellWidget( balanceLabel, 0, 0, 0, 2 );
201 210
202 tranTable = new QListView( control ); 211 tranTable = new QListView( control );
203 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." ) ); 212 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." ) );
204 tranTable->addColumn( tr( "Num" ) ); 213 tranTable->addColumn( tr( "Num" ) );
205 tranTable->addColumn( tr( "Date" ) ); 214 tranTable->addColumn( tr( "Date" ) );
206 //tranTable->addColumn( tr( "Cleared" ) ); 215 //tranTable->addColumn( tr( "Cleared" ) );
207 tranTable->addColumn( tr( "Description" ) ); 216 tranTable->addColumn( tr( "Description" ) );
208 int colnum = tranTable->addColumn( tr( "Amount" ) ); 217 int colnum = tranTable->addColumn( tr( "Amount" ) );
209 tranTable->setColumnAlignment( colnum, Qt::AlignRight ); 218 tranTable->setColumnAlignment( colnum, Qt::AlignRight );
210 tranTable->setAllColumnsShowFocus( TRUE ); 219 tranTable->setAllColumnsShowFocus( TRUE );
211 tranTable->setSorting( 1 ); 220 tranTable->setSorting( 1 );
212 layout->addMultiCellWidget( tranTable, 1, 1, 0, 2 ); 221 layout->addMultiCellWidget( tranTable, 1, 1, 0, 2 );
213 QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold ); 222 QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold );
214 connect( tranTable, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), 223 connect( tranTable, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ),
215 this, SLOT( slotEditTran() ) ); 224 this, SLOT( slotEditTran() ) );
216 225
217 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), control ); 226 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), control );
218 QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) ); 227 QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) );
219 connect( btn, SIGNAL( clicked() ), this, SLOT( slotNewTran() ) ); 228 connect( btn, SIGNAL( clicked() ), this, SLOT( slotNewTran() ) );
220 layout->addWidget( btn, 2, 0 ); 229 layout->addWidget( btn, 2, 0 );
221 230
222 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), control ); 231 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), control );
223 QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) ); 232 QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) );
224 connect( btn, SIGNAL( clicked() ), this, SLOT( slotEditTran() ) ); 233 connect( btn, SIGNAL( clicked() ), this, SLOT( slotEditTran() ) );
225 layout->addWidget( btn, 2, 1 ); 234 layout->addWidget( btn, 2, 1 );
226 235
227 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), control ); 236 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), control );
228 QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) ); 237 QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) );
229 connect( btn, SIGNAL( clicked() ), this, SLOT( slotDeleteTran() ) ); 238 connect( btn, SIGNAL( clicked() ), this, SLOT( slotDeleteTran() ) );
230 layout->addWidget( btn, 2, 2 ); 239 layout->addWidget( btn, 2, 2 );
231 240
232 return( control ); 241 return( control );
233} 242}
234 243
235QWidget *Checkbook::initCharts() 244QWidget *Checkbook::initCharts()
236{ 245{
237 graphInfo = 0x0; 246 graphInfo = 0x0;
238 247
239 QWidget *control = new QWidget( mainWidget ); 248 QWidget *control = new QWidget( mainWidget );
240 249
241 QGridLayout *layout = new QGridLayout( control ); 250 QGridLayout *layout = new QGridLayout( control );
242 layout->setSpacing( 2 ); 251 layout->setSpacing( 2 );
243 layout->setMargin( 4 ); 252 layout->setMargin( 4 );
244 253
245 graphWidget = new Graph( control ); 254 graphWidget = new Graph( control );
246 QWhatsThis::add( graphWidget, tr( "Select the desired chart below and then click on the Draw button." ) ); 255 QWhatsThis::add( graphWidget, tr( "Select the desired chart below and then click on the Draw button." ) );
247 layout->addMultiCellWidget( graphWidget, 0, 0, 0, 2 ); 256 layout->addMultiCellWidget( graphWidget, 0, 0, 0, 2 );
248 257
249 graphList = new QComboBox( control ); 258 graphList = new QComboBox( control );
250 QWhatsThis::add( graphList, tr( "Click here to select the desired chart type." ) ); 259 QWhatsThis::add( graphList, tr( "Click here to select the desired chart type." ) );
251 graphList->insertItem( tr( "Account balance" ) ); 260 graphList->insertItem( tr( "Account balance" ) );
252 graphList->insertItem( tr( "Withdrawals by category" ) ); 261 graphList->insertItem( tr( "Withdrawals by category" ) );
253 graphList->insertItem( tr( "Deposits by category" ) ); 262 graphList->insertItem( tr( "Deposits by category" ) );
254 263
255 layout->addMultiCellWidget( graphList, 1, 1, 0, 1 ); 264 layout->addMultiCellWidget( graphList, 1, 1, 0, 1 );
256 265
257 QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/drawbtn" ), tr( "Draw" ), control ); 266 QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/drawbtn" ), tr( "Draw" ), control );
258 QWhatsThis::add( btn, tr( "Click here to draw the selected chart." ) ); 267 QWhatsThis::add( btn, tr( "Click here to draw the selected chart." ) );
259 connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) ); 268 connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) );
260 layout->addWidget( btn, 1, 2 ); 269 layout->addWidget( btn, 1, 2 );
261 270
262 return control; 271 return control;
263} 272}
264 273
265void Checkbook::loadCheckbook() 274void Checkbook::loadCheckbook()
266{ 275{
267 transactions.clear(); 276 transactions.clear();
268 277
269 Config config(filename, Config::File); 278 Config config( filename, Config::File );
270 279
271 // Load info 280 // Load info
272 config.setGroup( "Account" ); 281 config.setGroup( "Account" );
282
283 password = config.readEntryCrypt( "Password", "" );
284 passwordCB->setChecked( password != "" );
273 nameEdit->setText( name ); 285 nameEdit->setText( name );
274 QString temptext = config.readEntry( "Type" ); 286 QString temptext = config.readEntry( "Type" );
275 int i = typeList->count(); 287 int i = typeList->count();
276 while ( i > 0 ) 288 while ( i > 0 )
277 { 289 {
278 i--; 290 i--;
279 typeList->setCurrentItem( i ); 291 typeList->setCurrentItem( i );
280 if ( typeList->currentText() == temptext ) 292 if ( typeList->currentText() == temptext )
281 { 293 {
282 break; 294 break;
283 } 295 }
284 } 296 }
285 bankEdit->setText( config.readEntry( "Bank", "" ) ); 297 bankEdit->setText( config.readEntry( "Bank", "" ) );
286 acctNumEdit->setText( config.readEntryCrypt( "Number", "" ) ); 298 acctNumEdit->setText( config.readEntryCrypt( "Number", "" ) );
287 pinNumEdit->setText( config.readEntryCrypt( "PINNumber", "" ) ); 299 pinNumEdit->setText( config.readEntryCrypt( "PINNumber", "" ) );
288 balanceEdit->setText( config.readEntry( "Balance", "0.0" ) ); 300 balanceEdit->setText( config.readEntry( "Balance", "0.0" ) );
289 notesEdit->setText( config.readEntry( "Notes", "" ) ); 301 notesEdit->setText( config.readEntry( "Notes", "" ) );
290 302
291 bool ok; 303 bool ok;
292 currBalance = balanceEdit->text().toFloat( &ok ); 304 currBalance = balanceEdit->text().toFloat( &ok );
293 startBalance = currBalance; 305 startBalance = currBalance;
294 306
295 // Load transactions 307 // Load transactions
296 TranInfo *tran; 308 TranInfo *tran;
297 QString trandesc = ""; 309 QString trandesc = "";
298 float amount; 310 float amount;
299 QString stramount; 311 QString stramount;
300 for ( int i = 1; trandesc != QString::null; i++ ) 312 for ( int i = 1; trandesc != QString::null; i++ )
301 { 313 {
302 tran = new TranInfo( config, i ); 314 tran = new TranInfo( config, i );
303 trandesc = tran->desc(); 315 trandesc = tran->desc();
304 if ( trandesc != QString::null ) 316 if ( trandesc != QString::null )
305 { 317 {
306 currBalance -= tran->fee(); 318 currBalance -= tran->fee();
307 amount = tran->amount(); 319 amount = tran->amount();
308 if ( tran->withdrawal() ) 320 if ( tran->withdrawal() )
309 { 321 {
310 amount *= -1; 322 amount *= -1;
311 } 323 }
312 currBalance += amount; 324 currBalance += amount;
313 stramount.sprintf( "%c%.2f", currencySymbol, amount ); 325 stramount.sprintf( "%s%.2f", currencySymbol.latin1(), amount );
314 326
315 // Add to transaction list 327 // Add to transaction list
316 transactions.inSort( tran ); 328 transactions.inSort( tran );
317 329
318 // Add to transaction table 330 // Add to transaction table
319 ( void ) new CBListItem( tranTable, tran->number(), tran->datestr(), trandesc, stramount ); 331 ( void ) new CBListItem( tranTable, tran->number(), tran->datestr(), trandesc, stramount );
320 } 332 }
321 else 333 else
322 { 334 {
323 delete tran; 335 delete tran;
324 } 336 }
325 } 337 }
326 balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) ); 338 balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) );
327 339
328 highTranNum = transactions.count(); 340 highTranNum = transactions.count();
329} 341}
330 342
331void Checkbook::adjustBalance( float amount ) 343void Checkbook::adjustBalance( float amount )
332{ 344{
333 currBalance += amount; 345 currBalance += amount;
334 balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) ); 346 balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) );
335 347
336} 348}
337 349
338TranInfo *Checkbook::findTran( const QString &checknum, const QString &date, const QString &desc ) 350TranInfo *Checkbook::findTran( const QString &checknum, const QString &date, const QString &desc )
339{ 351{
340 TranInfo *traninfo = transactions.first(); 352 TranInfo *traninfo = transactions.first();
341 while ( traninfo ) 353 while ( traninfo )
342 { 354 {
343 if ( traninfo->number() == checknum && traninfo->datestr() == date && 355 if ( traninfo->number() == checknum && traninfo->datestr() == date &&
344 traninfo->desc() == desc ) 356 traninfo->desc() == desc )
345 break; 357 break;
346 traninfo = transactions.next(); 358 traninfo = transactions.next();
347 } 359 }
348 return( traninfo ); 360 return( traninfo );
349} 361}
350 362
351void Checkbook::accept() 363void Checkbook::accept()
352{ 364{
353 QFile f( filename ); 365 QFile f( filename );
354 if ( f.exists() ) 366 if ( f.exists() )
355 { 367 {
356 f.remove(); 368 f.remove();
357 } 369 }
358 370
359 Config *config = new Config(filename, Config::File); 371 Config *config = new Config(filename, Config::File);
360 372
361 // Save info 373 // Save info
362 config->setGroup( "Account" ); 374 config->setGroup( "Account" );
375 config->writeEntryCrypt( "Password", password );
363 config->writeEntry( "Type", typeList->currentText() ); 376 config->writeEntry( "Type", typeList->currentText() );
364 config->writeEntry( "Bank", bankEdit->text() ); 377 config->writeEntry( "Bank", bankEdit->text() );
365 config->writeEntryCrypt( "Number", acctNumEdit->text() ); 378 config->writeEntryCrypt( "Number", acctNumEdit->text() );
366 config->writeEntryCrypt( "PINNumber", pinNumEdit->text() ); 379 config->writeEntryCrypt( "PINNumber", pinNumEdit->text() );
367 config->writeEntry( "Balance", balanceEdit->text() ); 380 config->writeEntry( "Balance", balanceEdit->text() );
368 config->writeEntry( "Notes", notesEdit->text() ); 381 config->writeEntry( "Notes", notesEdit->text() );
369 382
370 // Save transactions 383 // Save transactions
371 int i = 1; 384 int i = 1;
372 for ( TranInfo *tran = transactions.first(); tran; tran = transactions.next() ) 385 for ( TranInfo *tran = transactions.first(); tran; tran = transactions.next() )
373 { 386 {
374 tran->write( config, i ); 387 tran->write( config, i );
375 i++; 388 i++;
376 } 389 }
377 config->write(); 390 config->write();
378 391
379 QDialog::accept(); 392 QDialog::accept();
380} 393}
381 394
395void Checkbook::slotPasswordClicked()
396{
397 if ( password == "" && passwordCB->isChecked() )
398 {
399 Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) );
400 if ( pw->exec() != QDialog::Accepted )
401 {
402 passwordCB->setChecked( FALSE );
403 delete pw;
404 return;
405 }
406 password = pw->password;
407 delete pw;
408
409 pw = new Password( this, tr( "Confirm password" ), tr( "Please confirm your password:" ) );
410 if ( pw->exec() != QDialog::Accepted || pw->password != password )
411 {
412 passwordCB->setChecked( FALSE );
413 password = "";
414 }
415
416 delete pw;
417 }
418 else if ( password != "" && !passwordCB->isChecked() )
419 {
420 Password *pw = new Password( this, tr( "Enter password" ),
421 tr( "Please enter your password to confirm removal of password protection:" ) );
422 if ( pw->exec() == QDialog::Accepted && pw->password == password )
423 {
424 password = "";
425 delete pw;
426 return;
427 }
428 else
429 {
430 passwordCB->setChecked( TRUE );
431 }
432
433 delete pw;
434 }
435}
436
382void Checkbook::slotNameChanged( const QString &newname ) 437void Checkbook::slotNameChanged( const QString &newname )
383{ 438{
384 name = newname; 439 name = newname;
385 filename = filedir; 440 filename = filedir;
386 filename.append( newname ); 441 filename.append( newname );
387 filename.append( ".qcb" ); 442 filename.append( ".qcb" );
388 QString tempstr = name; 443 QString tempstr = name;
389 tempstr.append( " - " ); 444 tempstr.append( " - " );
390 tempstr.append( tr( "Checkbook" ) ); 445 tempstr.append( tr( "Checkbook" ) );
391 setCaption( tempstr ); 446 setCaption( tempstr );
392} 447}
393 448
394void Checkbook::slotStartingBalanceChanged( const QString &newbalance ) 449void Checkbook::slotStartingBalanceChanged( const QString &newbalance )
395{ 450{
396 currBalance -= startBalance; 451 currBalance -= startBalance;
397 bool ok; 452 bool ok;
398 startBalance = newbalance.toFloat( &ok ); 453 startBalance = newbalance.toFloat( &ok );
399 adjustBalance( startBalance ); 454 adjustBalance( startBalance );
400} 455}
401 456
402void Checkbook::slotNewTran() 457void Checkbook::slotNewTran()
403{ 458{
404 highTranNum++; 459 highTranNum++;
405 TranInfo *traninfo = new TranInfo( highTranNum ); 460 TranInfo *traninfo = new TranInfo( highTranNum );
406 461
407 Transaction *currtran = new Transaction( this, name, 462 Transaction *currtran = new Transaction( this, name,
408 traninfo, 463 traninfo,
409 currencySymbol ); 464 currencySymbol );
410 currtran->showMaximized(); 465 currtran->showMaximized();
411 if ( currtran->exec() == QDialog::Accepted ) 466 if ( currtran->exec() == QDialog::Accepted )
412 { 467 {
413 float amount = traninfo->amount(); 468 float amount = traninfo->amount();
414 if ( traninfo->withdrawal() ) 469 if ( traninfo->withdrawal() )
415 { 470 {
416 amount *= -1; 471 amount *= -1;
417 } 472 }
418 QString stramount; 473 QString stramount;
419 stramount.sprintf( "%c%.2f", currencySymbol, amount ); 474 stramount.sprintf( "%s%.2f", currencySymbol.latin1(), amount );
420 475
421 // Add to transaction list 476 // Add to transaction list
422 transactions.inSort( traninfo ); 477 transactions.inSort( traninfo );
423 478
424 // Add to transaction table 479 // Add to transaction table
425 ( void ) new CBListItem( tranTable, traninfo->number(), traninfo->datestr(), traninfo->desc(), 480 ( void ) new CBListItem( tranTable, traninfo->number(), traninfo->datestr(), traninfo->desc(),
426 stramount ); 481 stramount );
427 482
428 adjustBalance( amount ); 483 adjustBalance( amount );
429 } 484 }
430 else 485 else
431 { 486 {
432 highTranNum--; 487 highTranNum--;
433 delete traninfo; 488 delete traninfo;
434 } 489 }
435} 490}
436 491
437void Checkbook::slotEditTran() 492void Checkbook::slotEditTran()
438{ 493{
439 bool ok;
440 QListViewItem *curritem = tranTable->currentItem(); 494 QListViewItem *curritem = tranTable->currentItem();
441 if ( !curritem ) 495 if ( !curritem )
442 { 496 {
443 return; 497 return;
444 } 498 }
445 499
446 TranInfo *traninfo = findTran( curritem->text( 0 ), curritem->text( 1 ), curritem->text( 2 ) ); 500 TranInfo *traninfo = findTran( curritem->text( 0 ), curritem->text( 1 ), curritem->text( 2 ) );
447 float origamt = traninfo->amount(); 501 float origamt = traninfo->amount();
448 if ( traninfo->withdrawal() ) 502 if ( traninfo->withdrawal() )
449 { 503 {
450 origamt *= -1; 504 origamt *= -1;
451 } 505 }
452 506
453 Transaction *currtran = new Transaction( this, name, 507 Transaction *currtran = new Transaction( this, name,
454 traninfo, 508 traninfo,
455 currencySymbol ); 509 currencySymbol );
456 currtran->showMaximized(); 510 currtran->showMaximized();
457 if ( currtran->exec() == QDialog::Accepted ) 511 if ( currtran->exec() == QDialog::Accepted )
458 { 512 {
459 curritem->setText( 1, traninfo->datestr() ); 513 curritem->setText( 1, traninfo->datestr() );
460 514
461 curritem->setText( 2, traninfo->desc() ); 515 curritem->setText( 2, traninfo->desc() );
462 516
463 float amount = traninfo->amount(); 517 float amount = traninfo->amount();
464 if ( traninfo->withdrawal() ) 518 if ( traninfo->withdrawal() )
465 { 519 {
466 amount *= -1; 520 amount *= -1;
467 } 521 }
468 adjustBalance( origamt * -1 ); 522 adjustBalance( origamt * -1 );
469 adjustBalance( amount ); 523 adjustBalance( amount );
470 QString stramount; 524 QString stramount;
471 stramount.sprintf( "%c%.2f", currencySymbol, amount ); 525 stramount.sprintf( "%s%.2f", currencySymbol.latin1(), amount );
472 curritem->setText( 3, stramount ); 526 curritem->setText( 3, stramount );
473 527
474 balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) ); 528 balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) );
475 529
476 delete currtran; 530 delete currtran;
477 } 531 }
478} 532}
479 533
480void Checkbook::slotDeleteTran() 534void Checkbook::slotDeleteTran()
481{ 535{
482 QListViewItem *curritem = tranTable->currentItem(); 536 QListViewItem *curritem = tranTable->currentItem();
483 if ( !curritem ) 537 if ( !curritem )
484 { 538 {
485 return; 539 return;
486 } 540 }
487 541
488 TranInfo *traninfo = findTran( curritem->text( 0 ), curritem->text( 1 ), curritem->text( 2 ) ); 542 TranInfo *traninfo = findTran( curritem->text( 0 ), curritem->text( 1 ), curritem->text( 2 ) );
489 543
490 if ( QPEMessageBox::confirmDelete ( this, tr( "Delete transaction" ), traninfo->desc() ) ) 544 if ( QPEMessageBox::confirmDelete ( this, tr( "Delete transaction" ), traninfo->desc() ) )
491 { 545 {
492 float amount = traninfo->amount(); 546 float amount = traninfo->amount();
493 if ( traninfo->withdrawal() ) 547 if ( traninfo->withdrawal() )
494 { 548 {
495 amount *= -1; 549 amount *= -1;
496 } 550 }
497 551
498 transactions.remove( traninfo ); 552 transactions.remove( traninfo );
499 delete traninfo; 553 delete traninfo;
500 delete curritem; 554 delete curritem;
501 555
502 adjustBalance( amount * -1 ); 556 adjustBalance( amount * -1 );
503 } 557 }
504} 558}
505 559
506void Checkbook::slotDrawGraph() 560void Checkbook::slotDrawGraph()
507{ 561{
508 if ( graphInfo ) 562 if ( graphInfo )
509 { 563 {
510 delete graphInfo; 564 delete graphInfo;
511 } 565 }
512 566
513 switch ( graphList->currentItem() ) 567 switch ( graphList->currentItem() )
514 { 568 {
515 case 0 : drawBalanceChart(); 569 case 0 : drawBalanceChart();
516 break; 570 break;
517 case 1 : drawCategoryChart( TRUE ); 571 case 1 : drawCategoryChart( TRUE );
518 break; 572 break;
519 case 2 : drawCategoryChart( FALSE ); 573 case 2 : drawCategoryChart( FALSE );
520 break; 574 break;
521 }; 575 };
522 576
523 graphWidget->setGraphInfo( graphInfo ); 577 graphWidget->setGraphInfo( graphInfo );
524 graphWidget->drawGraph( TRUE ); 578 graphWidget->drawGraph( TRUE );
525} 579}
526 580
527void Checkbook::drawBalanceChart() 581void Checkbook::drawBalanceChart()
528{ 582{
529 DataPointList *list = new DataPointList(); 583 DataPointList *list = new DataPointList();
530 584
531 float balance = startBalance; 585 float balance = startBalance;
532 float amount; 586 float amount;
533 QString label; 587 QString label;
534 int i = 0; 588 int i = 0;
535 int count = transactions.count(); 589 int count = transactions.count();
536 590
537 for ( TranInfo *tran = transactions.first(); tran; tran = transactions.next() ) 591 for ( TranInfo *tran = transactions.first(); tran; tran = transactions.next() )
538 { 592 {
539 i++; 593 i++;
540 balance -= tran->fee(); 594 balance -= tran->fee();
541 amount = tran->amount(); 595 amount = tran->amount();
542 if ( tran->withdrawal() ) 596 if ( tran->withdrawal() )
543 { 597 {
544 amount *= -1; 598 amount *= -1;
545 } 599 }
546 balance += amount; 600 balance += amount;
547 if ( i == 1 || i == count / 2 || i == count ) 601 if ( i == 1 || i == count / 2 || i == count )
548 { 602 {
549 label = tran->datestr(); 603 label = tran->datestr();
550 } 604 }
551 else 605 else
552 { 606 {
553 label = ""; 607 label = "";
554 } 608 }
555 list->append( new DataPointInfo( label, balance ) ); 609 list->append( new DataPointInfo( label, balance ) );
556 } 610 }
557 611
558 graphInfo = new GraphInfo( GraphInfo::BarChart, list ); 612 graphInfo = new GraphInfo( GraphInfo::BarChart, list );
559} 613}
560 614
561void Checkbook::drawCategoryChart( bool withdrawals ) 615void Checkbook::drawCategoryChart( bool withdrawals )
562{ 616{
563 DataPointList *list = new DataPointList(); 617 DataPointList *list = new DataPointList();
564 618
565 TranInfo *tran = transactions.first(); 619 TranInfo *tran = transactions.first();
566 if ( tran && tran->withdrawal() == withdrawals ) 620 if ( tran && tran->withdrawal() == withdrawals )
567 { 621 {
568 list->append( new DataPointInfo( tran->category(), tran->amount() ) ); 622 list->append( new DataPointInfo( tran->category(), tran->amount() ) );
569 } 623 }
570 tran = transactions.next(); 624 tran = transactions.next();
571 625
572 DataPointInfo *cat; 626 DataPointInfo *cat;
573 for ( ; tran; tran = transactions.next() ) 627 for ( ; tran; tran = transactions.next() )
574 { 628 {
575 if ( tran->withdrawal() == withdrawals ) 629 if ( tran->withdrawal() == withdrawals )
576 { 630 {
577 // Find category in list 631 // Find category in list
578 for ( cat = list->first(); cat; cat = list->next() ) 632 for ( cat = list->first(); cat; cat = list->next() )
579 { 633 {
580 if ( cat->label() == tran->category() ) 634 if ( cat->label() == tran->category() )
581 { 635 {
582 break; 636 break;
583 } 637 }
584 } 638 }
585 if ( cat && cat->label() == tran->category() ) 639 if ( cat && cat->label() == tran->category() )
586 { // Found category, add to transaction to category total 640 { // Found category, add to transaction to category total
587 cat->addToValue( tran->amount() ); 641 cat->addToValue( tran->amount() );
588 } 642 }
589 else 643 else
590 { // Didn't find category, add category to list 644 { // Didn't find category, add category to list
591 list->append( new DataPointInfo( tran->category(), tran->amount() ) ); 645 list->append( new DataPointInfo( tran->category(), tran->amount() ) );
592 } 646 }
593 } 647 }
594 } 648 }
595 649
596 graphInfo = new GraphInfo( GraphInfo::PieChart, list ); 650 graphInfo = new GraphInfo( GraphInfo::PieChart, list );
597} 651}
598 652
599CBListItem::CBListItem( QListView *parent, QString label1, QString label2, 653CBListItem::CBListItem( QListView *parent, QString label1, QString label2,
600 QString label3, QString label4, QString label5, QString label6, QString label7, 654 QString label3, QString label4, QString label5, QString label6, QString label7,
601 QString label8 ) 655 QString label8 )
602 : QListViewItem( parent, label1, label2, label3, label4, label5, label6, label7, label8 ) 656 : QListViewItem( parent, label1, label2, label3, label4, label5, label6, label7, label8 )
603{ 657{
604 m_known = FALSE; 658 m_known = FALSE;
605 owner = parent; 659 owner = parent;
606} 660}
607 661
608void CBListItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align ) 662void CBListItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align )
609{ 663{
610 QColorGroup _cg = cg; 664 QColorGroup _cg = cg;
611 const QPixmap *pm = listView()->viewport()->backgroundPixmap(); 665 const QPixmap *pm = listView()->viewport()->backgroundPixmap();
612 if ( pm && !pm->isNull() ) 666 if ( pm && !pm->isNull() )
613 { 667 {
614 _cg.setBrush( QColorGroup::Base, QBrush( cg.base(), *pm ) ); 668 _cg.setBrush( QColorGroup::Base, QBrush( cg.base(), *pm ) );
615 p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); 669 p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() );
616 } 670 }
617 else if ( isAltBackground() ) 671 else if ( isAltBackground() )
618 _cg.setColor(QColorGroup::Base, QColor( 200, 255, 200 ) ); 672 _cg.setColor(QColorGroup::Base, QColor( 200, 255, 200 ) );
619 673
620 QListViewItem::paintCell(p, _cg, column, width, align); 674 QListViewItem::paintCell(p, _cg, column, width, align);
621} 675}
622 676
623bool CBListItem::isAltBackground() 677bool CBListItem::isAltBackground()
624{ 678{
625 QListView *lv = static_cast<QListView *>( listView() ); 679 QListView *lv = static_cast<QListView *>( listView() );
626 if ( lv ) 680 if ( lv )
627 { 681 {
628 CBListItem *above = 0; 682 CBListItem *above = 0;
629 above = (CBListItem *)( itemAbove() ); 683 above = (CBListItem *)( itemAbove() );
630 m_known = above ? above->m_known : true; 684 m_known = above ? above->m_known : true;
631 if ( m_known ) 685 if ( m_known )
632 { 686 {
633 m_odd = above ? !above->m_odd : false; 687 m_odd = above ? !above->m_odd : false;
634 } 688 }
635 else 689 else
636 { 690 {
637 CBListItem *item; 691 CBListItem *item;
638 bool previous = true; 692 bool previous = true;
639 if ( parent() ) 693 if ( parent() )
640 { 694 {
641 item = (CBListItem *)( parent() ); 695 item = (CBListItem *)( parent() );
642 if ( item ) 696 if ( item )
643 previous = item->m_odd; 697 previous = item->m_odd;
644 item = (CBListItem *)( parent()->firstChild() ); 698 item = (CBListItem *)( parent()->firstChild() );
645 } 699 }
646 else 700 else
647 { 701 {
648 item = (CBListItem *)( lv->firstChild() ); 702 item = (CBListItem *)( lv->firstChild() );
649 } 703 }
650 704
651 while(item) 705 while(item)
652 { 706 {
653 item->m_odd = previous = !previous; 707 item->m_odd = previous = !previous;
654 item->m_known = true; 708 item->m_known = true;
655 item = (CBListItem *)( item->nextSibling() ); 709 item = (CBListItem *)( item->nextSibling() );
656 } 710 }
657 } 711 }
658 return m_odd; 712 return m_odd;
659 } 713 }
660 return false; 714 return false;
661} \ No newline at end of file 715} \ No newline at end of file
diff --git a/noncore/apps/checkbook/checkbook.h b/noncore/apps/checkbook/checkbook.h
index 0260b43..27658ff 100644
--- a/noncore/apps/checkbook/checkbook.h
+++ b/noncore/apps/checkbook/checkbook.h
@@ -1,128 +1,133 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 =. 3 =.
4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> 4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
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#ifndef CHECKBOOK_H 29#ifndef CHECKBOOK_H
30#define CHECKBOOK_H 30#define CHECKBOOK_H
31 31
32#include "traninfo.h" 32#include "traninfo.h"
33 33
34#include <qdialog.h> 34#include <qdialog.h>
35#include <qlistview.h> 35#include <qlistview.h>
36 36
37class OTabWidget; 37class OTabWidget;
38 38
39class Graph; 39class Graph;
40class GraphInfo; 40class GraphInfo;
41class QCheckBox;
41class QComboBox; 42class QComboBox;
42class QLabel; 43class QLabel;
43class QLineEdit; 44class QLineEdit;
44class QListView; 45class QListView;
45class QMultiLineEdit; 46class QMultiLineEdit;
46class QString; 47class QString;
47 48
48class Checkbook : public QDialog 49class Checkbook : public QDialog
49{ 50{
50 Q_OBJECT 51 Q_OBJECT
51 52
52 public: 53 public:
53 Checkbook( QWidget * = 0x0, const QString & = 0x0, const QString & = 0x0, char = '$' ); 54 Checkbook( QWidget * = 0x0, const QString & = 0x0, const QString & = 0x0,
55 const QString & = "$" );
54 ~Checkbook(); 56 ~Checkbook();
55 57
56 const QString &getName(); 58 const QString &getName();
57 59
58 private: 60 private:
59 TranInfoList transactions; 61 TranInfoList transactions;
60 QString name; 62 QString name;
61 QString filename; 63 QString filename;
62 QString filedir; 64 QString filedir;
63 char currencySymbol; 65 QString currencySymbol;
66 QString password;
64 int highTranNum; 67 int highTranNum;
65 68
66 OTabWidget *mainWidget; 69 OTabWidget *mainWidget;
67 void loadCheckbook(); 70 void loadCheckbook();
68 void adjustBalance( float ); 71 void adjustBalance( float );
69 TranInfo *findTran( const QString &, const QString &, const QString & ); 72 TranInfo *findTran( const QString &, const QString &, const QString & );
70 73
71 // Info tab 74 // Info tab
72 QWidget *initInfo(); 75 QWidget *initInfo();
76 QCheckBox *passwordCB;
73 QLineEdit *nameEdit; 77 QLineEdit *nameEdit;
74 QComboBox *typeList; 78 QComboBox *typeList;
75 QLineEdit *bankEdit; 79 QLineEdit *bankEdit;
76 QLineEdit *acctNumEdit; 80 QLineEdit *acctNumEdit;
77 QLineEdit *pinNumEdit; 81 QLineEdit *pinNumEdit;
78 QLineEdit *balanceEdit; 82 QLineEdit *balanceEdit;
79 QMultiLineEdit *notesEdit; 83 QMultiLineEdit *notesEdit;
80 float startBalance; 84 float startBalance;
81 85
82 // Transactions tab 86 // Transactions tab
83 QWidget *initTransactions(); 87 QWidget *initTransactions();
84 QListView *tranTable; 88 QListView *tranTable;
85 QLabel *balanceLabel; 89 QLabel *balanceLabel;
86 float currBalance; 90 float currBalance;
87 91
88 // Charts tab 92 // Charts tab
89 QWidget *initCharts(); 93 QWidget *initCharts();
90 GraphInfo *graphInfo; 94 GraphInfo *graphInfo;
91 QComboBox *graphList; 95 QComboBox *graphList;
92 Graph *graphWidget; 96 Graph *graphWidget;
93 97
94 void drawBalanceChart(); 98 void drawBalanceChart();
95 void drawCategoryChart( bool = TRUE ); 99 void drawCategoryChart( bool = TRUE );
96 100
97 protected slots: 101 protected slots:
98 void accept(); 102 void accept();
99 103
100 private slots: 104 private slots:
105 void slotPasswordClicked();
101 void slotNameChanged( const QString & ); 106 void slotNameChanged( const QString & );
102 void slotStartingBalanceChanged( const QString & ); 107 void slotStartingBalanceChanged( const QString & );
103 void slotNewTran(); 108 void slotNewTran();
104 void slotEditTran(); 109 void slotEditTran();
105 void slotDeleteTran(); 110 void slotDeleteTran();
106 void slotDrawGraph(); 111 void slotDrawGraph();
107}; 112};
108 113
109class CBListItem : public QListViewItem 114class CBListItem : public QListViewItem
110{ 115{
111 //Q_OBJECT 116 //Q_OBJECT
112 117
113 public: 118 public:
114 CBListItem( QListView *, QString = QString::null, QString = QString::null, 119 CBListItem( QListView *, QString = QString::null, QString = QString::null,
115 QString = QString::null, QString = QString::null, QString = QString::null, 120 QString = QString::null, QString = QString::null, QString = QString::null,
116 QString = QString::null, QString = QString::null, QString = QString::null ); 121 QString = QString::null, QString = QString::null, QString = QString::null );
117 122
118 void paintCell( QPainter *, const QColorGroup &, int, int, int ); 123 void paintCell( QPainter *, const QColorGroup &, int, int, int );
119 124
120 private: 125 private:
121 QListView *owner; 126 QListView *owner;
122 bool m_known; 127 bool m_known;
123 bool m_odd; 128 bool m_odd;
124 129
125 bool isAltBackground(); 130 bool isAltBackground();
126}; 131};
127 132
128#endif 133#endif
diff --git a/noncore/apps/checkbook/checkbook.pro b/noncore/apps/checkbook/checkbook.pro
index bd69939..53b5ff4 100644
--- a/noncore/apps/checkbook/checkbook.pro
+++ b/noncore/apps/checkbook/checkbook.pro
@@ -1,36 +1,38 @@
1TEMPLATE = app 1TEMPLATE = app
2CONFIG = qt warn_on release 2CONFIG = qt warn_on release
3HEADERS = mainwindow.h \ 3HEADERS = mainwindow.h \
4 traninfo.h \ 4 traninfo.h \
5 graphinfo.h \ 5 graphinfo.h \
6 password.h \
6 checkbook.h \ 7 checkbook.h \
7 transaction.h \ 8 transaction.h \
8 graph.h 9 graph.h
9SOURCES = main.cpp \ 10SOURCES = main.cpp \
10 mainwindow.cpp \ 11 mainwindow.cpp \
11 traninfo.cpp \ 12 traninfo.cpp \
12 graphinfo.cpp \ 13 graphinfo.cpp \
14 password.cpp \
13 checkbook.cpp \ 15 checkbook.cpp \
14 transaction.cpp \ 16 transaction.cpp \
15 graph.cpp 17 graph.cpp
16INCLUDEPATH += $(OPIEDIR)/include 18INCLUDEPATH += $(OPIEDIR)/include
17DEPENDPATH += $(OPIEDIR)/include 19DEPENDPATH += $(OPIEDIR)/include
18LIBS += -lqpe -lopie 20LIBS += -lqpe -lopie
19TARGET = checkbook 21TARGET = checkbook
20DESTDIR = $(OPIEDIR)/bin 22DESTDIR = $(OPIEDIR)/bin
21 23
22TRANSLATIONS = ../../../i18n/de/checkbook.ts \ 24TRANSLATIONS = ../../../i18n/de/checkbook.ts \
23 ../../../i18n/en/checkbook.ts \ 25 ../../../i18n/en/checkbook.ts \
24 ../../../i18n/es/checkbook.ts \ 26 ../../../i18n/es/checkbook.ts \
25 ../../../i18n/fr/checkbook.ts \ 27 ../../../i18n/fr/checkbook.ts \
26 ../../../i18n/hu/checkbook.ts \ 28 ../../../i18n/hu/checkbook.ts \
27 ../../../i18n/ja/checkbook.ts \ 29 ../../../i18n/ja/checkbook.ts \
28 ../../../i18n/ko/checkbook.ts \ 30 ../../../i18n/ko/checkbook.ts \
29 ../../../i18n/no/checkbook.ts \ 31 ../../../i18n/no/checkbook.ts \
30 ../../../i18n/pl/checkbook.ts \ 32 ../../../i18n/pl/checkbook.ts \
31 ../../../i18n/pt/checkbook.ts \ 33 ../../../i18n/pt/checkbook.ts \
32 ../../../i18n/pt_BR/checkbook.ts \ 34 ../../../i18n/pt_BR/checkbook.ts \
33 ../../../i18n/sl/checkbook.ts \ 35 ../../../i18n/sl/checkbook.ts \
34 ../../../i18n/zh_CN/checkbook.ts \ 36 ../../../i18n/zh_CN/checkbook.ts \
35 ../../../i18n/zh_TW/checkbook.ts \ 37 ../../../i18n/zh_TW/checkbook.ts \
36 ../../../i18n/it/checkbook.ts 38 ../../../i18n/it/checkbook.ts
diff --git a/noncore/apps/checkbook/mainwindow.cpp b/noncore/apps/checkbook/mainwindow.cpp
index 567b8ad..2c0abf1 100644
--- a/noncore/apps/checkbook/mainwindow.cpp
+++ b/noncore/apps/checkbook/mainwindow.cpp
@@ -1,168 +1,186 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 =. 3 =.
4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> 4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
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 "mainwindow.h" 29#include "mainwindow.h"
30#include "password.h"
30#include "checkbook.h" 31#include "checkbook.h"
31 32
33#include <qpe/config.h>
32#include <qpe/global.h> 34#include <qpe/global.h>
33#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
34#include <qpe/qpemenubar.h> 36#include <qpe/qpemenubar.h>
35#include <qpe/qpemessagebox.h> 37#include <qpe/qpemessagebox.h>
36#include <qpe/qpetoolbar.h> 38#include <qpe/qpetoolbar.h>
37#include <qpe/resource.h> 39#include <qpe/resource.h>
38 40
39#include <qaction.h> 41#include <qaction.h>
40#include <qdir.h> 42#include <qdir.h>
41#include <qlistbox.h> 43#include <qlistbox.h>
42#include <qpopupmenu.h> 44#include <qpopupmenu.h>
43#include <qstring.h> 45#include <qstring.h>
44#include <qwhatsthis.h> 46#include <qwhatsthis.h>
45 47
46MainWindow::MainWindow() 48MainWindow::MainWindow()
47 : QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) 49 : QMainWindow( 0x0, 0x0, WStyle_ContextHelp )
48{ 50{
49 setCaption( tr( "Checkbook" ) ); 51 setCaption( tr( "Checkbook" ) );
50 52
51 cbDir = Global::applicationFileName( "checkbook", "" ); 53 cbDir = Global::applicationFileName( "checkbook", "" );
52 54
53 // Build menu and tool bars 55 // Build menu and tool bars
54 setToolBarsMovable( FALSE ); 56 setToolBarsMovable( FALSE );
55 57
56 QPEToolBar *bar = new QPEToolBar( this ); 58 QPEToolBar *bar = new QPEToolBar( this );
57 bar->setHorizontalStretchable( TRUE ); 59 bar->setHorizontalStretchable( TRUE );
58 QPEMenuBar *mb = new QPEMenuBar( bar ); 60 QPEMenuBar *mb = new QPEMenuBar( bar );
59 mb->setMargin( 0 ); 61 mb->setMargin( 0 );
60 QPopupMenu *popup = new QPopupMenu( this ); 62 QPopupMenu *popup = new QPopupMenu( this );
61 63
62 bar = new QPEToolBar( this ); 64 bar = new QPEToolBar( this );
63 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); 65 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
64 a->setWhatsThis( tr( "Click here to create a new checkbook.\n\nYou also can select New from the Checkbook menu." ) ); 66 a->setWhatsThis( tr( "Click here to create a new checkbook.\n\nYou also can select New from the Checkbook menu." ) );
65 connect( a, SIGNAL( activated() ), this, SLOT( slotNew() ) ); 67 connect( a, SIGNAL( activated() ), this, SLOT( slotNew() ) );
66 a->addTo( popup ); 68 a->addTo( popup );
67 a->addTo( bar ); 69 a->addTo( bar );
68 70
69 actionOpen = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, 71 actionOpen = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null,
70 0, this, 0 ); 72 0, this, 0 );
71 actionOpen->setWhatsThis( tr( "Select a checkbook and then click here to edit it.\n\nYou also can select Edit from the Checkbook menu, or click and hold on a checkbook name." ) ); 73 actionOpen->setWhatsThis( tr( "Select a checkbook and then click here to edit it.\n\nYou also can select Edit from the Checkbook menu, or click and hold on a checkbook name." ) );
72 connect( actionOpen, SIGNAL( activated() ), this, SLOT( slotEdit() ) ); 74 connect( actionOpen, SIGNAL( activated() ), this, SLOT( slotEdit() ) );
73 actionOpen->addTo( popup ); 75 actionOpen->addTo( popup );
74 actionOpen->addTo( bar ); 76 actionOpen->addTo( bar );
75 77
76 actionDelete = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 78 actionDelete = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null,
77 0, this, 0 ); 79 0, this, 0 );
78 actionDelete->setWhatsThis( tr( "Select a checkbook and then click here delete it.\n\nYou also can select Delete from the Checkbook menu." ) ); 80 actionDelete->setWhatsThis( tr( "Select a checkbook and then click here delete it.\n\nYou also can select Delete from the Checkbook menu." ) );
79 connect( actionDelete, SIGNAL( activated() ), this, SLOT( slotDelete() ) ); 81 connect( actionDelete, SIGNAL( activated() ), this, SLOT( slotDelete() ) );
80 actionDelete->addTo( popup ); 82 actionDelete->addTo( popup );
81 actionDelete->addTo( bar ); 83 actionDelete->addTo( bar );
82 84
83 mb->insertItem( tr( "Checkbook" ), popup ); 85 mb->insertItem( tr( "Checkbook" ), popup );
84 86
85 // Build Checkbook selection list control 87 // Build Checkbook selection list control
86 cbList = new QListBox( this ); 88 cbList = new QListBox( this );
87 QWhatsThis::add( cbList, tr( "This is a listing of all checkbooks currently available." ) ); 89 QWhatsThis::add( cbList, tr( "This is a listing of all checkbooks currently available." ) );
88 QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold ); 90 QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold );
89 connect( cbList, SIGNAL( rightButtonPressed( QListBoxItem *, const QPoint & ) ), 91 connect( cbList, SIGNAL( rightButtonPressed( QListBoxItem *, const QPoint & ) ),
90 this, SLOT( slotEdit() ) ); 92 this, SLOT( slotEdit() ) );
91 setCentralWidget( cbList ); 93 setCentralWidget( cbList );
92 94
93 // Load Checkbook selection list 95 // Load Checkbook selection list
94 QDir checkdir( cbDir ); 96 QDir checkdir( cbDir );
95 if (checkdir.exists() == true) 97 if (checkdir.exists() == true)
96 { 98 {
97 QStringList checkbooks = checkdir.entryList( "*.qcb", QDir::Files|QDir::Readable|QDir::Writable, 99 QStringList checkbooks = checkdir.entryList( "*.qcb", QDir::Files|QDir::Readable|QDir::Writable,
98 QDir::Time ); 100 QDir::Time );
99 for ( QStringList::Iterator it = checkbooks.begin(); it != checkbooks.end(); it++ ) 101 for ( QStringList::Iterator it = checkbooks.begin(); it != checkbooks.end(); it++ )
100 { 102 {
101 (*it) = (*it).remove( (*it).find('.'), (*it).length() ); 103 (*it) = (*it).remove( (*it).find('.'), (*it).length() );
102 } 104 }
103 cbList->insertStringList( checkbooks ); 105 cbList->insertStringList( checkbooks );
104 } 106 }
105 cbList->sort(); 107 cbList->sort();
106 cbList->setSelected( 0, TRUE ); 108 cbList->setSelected( 0, TRUE );
107 109
108 currencySymbol = '$'; 110 currencySymbol = "$";
109} 111}
110 112
111MainWindow::~MainWindow() 113MainWindow::~MainWindow()
112{ 114{
113} 115}
114 116
115void MainWindow::slotNew() 117void MainWindow::slotNew()
116{ 118{
117 Checkbook *currcb = new Checkbook( this, "", cbDir, currencySymbol ); 119 Checkbook *currcb = new Checkbook( this, "", cbDir, currencySymbol );
118 currcb->showMaximized(); 120 currcb->showMaximized();
119 if ( currcb->exec() == QDialog::Accepted ) 121 if ( currcb->exec() == QDialog::Accepted )
120 { 122 {
121 cbList->insertItem( currcb->getName() ); 123 cbList->insertItem( currcb->getName() );
122 cbList->sort(); 124 cbList->sort();
123 delete currcb; 125 delete currcb;
124 } 126 }
125} 127}
126 128
127void MainWindow::slotEdit() 129void MainWindow::slotEdit()
128{ 130{
129 QString currname = cbList->currentText(); 131 QString currname = cbList->currentText();
132
133 QString tempstr = cbDir;
134 tempstr.append( currname );
135 tempstr.append( ".qcb" );
136
137 Config config( tempstr, Config::File );
138 config.setGroup( "Account" );
139 QString password = config.readEntryCrypt( "Password", "" );
140 if ( password != "" )
141 {
142 Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) );
143 if ( pw->exec() != QDialog::Accepted || pw->password != password )
144 {
145 delete pw;
146 return;
147 }
148 delete pw;
149 }
150
130 Checkbook *currcb = new Checkbook( this, currname, cbDir, currencySymbol ); 151 Checkbook *currcb = new Checkbook( this, currname, cbDir, currencySymbol );
131 currcb->showMaximized(); 152 currcb->showMaximized();
132 if ( currcb->exec() == QDialog::Accepted ) 153 if ( currcb->exec() == QDialog::Accepted )
133 { 154 {
134 QString newname = currcb->getName(); 155 QString newname = currcb->getName();
135 if ( currname != newname ) 156 if ( currname != newname )
136 { 157 {
137 cbList->changeItem( newname, cbList->currentItem() ); 158 cbList->changeItem( newname, cbList->currentItem() );
138 cbList->sort(); 159 cbList->sort();
139 160
140 QString tempstr = cbDir;
141 tempstr.append( currname );
142 tempstr.append( ".qcb" );
143 QFile f( tempstr ); 161 QFile f( tempstr );
144 if ( f.exists() ) 162 if ( f.exists() )
145 { 163 {
146 f.remove(); 164 f.remove();
147 } 165 }
148 } 166 }
149 delete currcb; 167 delete currcb;
150 } 168 }
151} 169}
152 170
153void MainWindow::slotDelete() 171void MainWindow::slotDelete()
154{ 172{
155 if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), cbList->currentText() ) ) 173 if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), cbList->currentText() ) )
156 { 174 {
157 QString tempstr = cbDir; 175 QString tempstr = cbDir;
158 tempstr.append( cbList->currentText() ); 176 tempstr.append( cbList->currentText() );
159 tempstr.append( ".qcb" ); 177 tempstr.append( ".qcb" );
160 QFile f( tempstr ); 178 QFile f( tempstr );
161 if ( f.exists() ) 179 if ( f.exists() )
162 { 180 {
163 f.remove(); 181 f.remove();
164 } 182 }
165 183
166 cbList->removeItem( cbList->currentItem() ); 184 cbList->removeItem( cbList->currentItem() );
167 } 185 }
168} 186}
diff --git a/noncore/apps/checkbook/mainwindow.h b/noncore/apps/checkbook/mainwindow.h
index 1b460fa..11a3343 100644
--- a/noncore/apps/checkbook/mainwindow.h
+++ b/noncore/apps/checkbook/mainwindow.h
@@ -1,60 +1,60 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 =. 3 =.
4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> 4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
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#ifndef MAINWINDOW_H 29#ifndef MAINWINDOW_H
30#define MAINWINDOW_H 30#define MAINWINDOW_H
31 31
32#include <qmainwindow.h> 32#include <qmainwindow.h>
33 33
34class QAction; 34class QAction;
35class QListBox; 35class QListBox;
36class QListBoxItem; 36class QListBoxItem;
37class QString; 37class QString;
38 38
39class MainWindow : public QMainWindow 39class MainWindow : public QMainWindow
40{ 40{
41 Q_OBJECT 41 Q_OBJECT
42 42
43 public: 43 public:
44 MainWindow(); 44 MainWindow();
45 ~MainWindow(); 45 ~MainWindow();
46 46
47 private: 47 private:
48 QListBox *cbList; 48 QListBox *cbList;
49 QString cbDir; 49 QString cbDir;
50 QAction *actionOpen; 50 QAction *actionOpen;
51 QAction *actionDelete; 51 QAction *actionDelete;
52 char currencySymbol; 52 QString currencySymbol;
53 53
54 private slots: 54 private slots:
55 void slotNew(); 55 void slotNew();
56 void slotEdit(); 56 void slotEdit();
57 void slotDelete(); 57 void slotDelete();
58}; 58};
59 59
60#endif 60#endif
diff --git a/noncore/apps/checkbook/password.cpp b/noncore/apps/checkbook/password.cpp
new file mode 100644
index 0000000..82020d5
--- a/dev/null
+++ b/noncore/apps/checkbook/password.cpp
@@ -0,0 +1,99 @@
1/*
2                This file is part of the OPIE Project
3 =.
4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#include "password.h"
30
31#include <qlabel.h>
32#include <qlayout.h>
33#include <qlineedit.h>
34#include <qpixmap.h>
35#include <qpushbutton.h>
36#include <qwidget.h>
37
38static const char* const showhideimage_data[] = {
39"16 16 2 1",
40". c None",
41"# c #000000",
42"................",
43"...#...###...##.",
44"..#.#..#..#.##..",
45"..###..###.##...",
46".#...#.#..##....",
47".#...#.#.##.....",
48"........##.#..#.",
49"..##...##...##..",
50".#..#.###...##..",
51".#...##..#.#..#.",
52".#..##..........",
53".#.##.#..#.#..#.",
54"..##...##...##..",
55".##....##...##..",
56".#....#..#.#..#.",
57"................"};
58
59Password::Password( QWidget *parent, const char *caption, const char *prompt )
60 : QDialog( parent, 0x0, TRUE, 0x0 )
61{
62 setCaption( caption );
63
64 QGridLayout *layout = new QGridLayout( this );
65 layout->setSpacing( 2 );
66 layout->setMargin( 4 );
67
68 QLabel *label = new QLabel( prompt, this );
69 label->setAlignment( AlignLeft | AlignTop | WordBreak );
70 layout->addMultiCellWidget( label, 0, 0, 0, 1 );
71
72 pw = new QLineEdit( this );
73 pw->setEchoMode( QLineEdit::Password );
74 layout->addWidget( pw, 1, 0 );
75
76 QPixmap *pic = new QPixmap( ( const char** ) showhideimage_data );
77 QPushButton *btn = new QPushButton( ( QIconSet ) *pic, QString::null, this );
78 btn->setMaximumSize( pic->width() + 10, pic->height() + 10 );
79 btn->setToggleButton( TRUE );
80 connect( btn, SIGNAL( toggled( bool ) ), this, SLOT( slotTogglePassword( bool ) ) );
81 layout->addWidget( btn, 1, 1 );
82
83 password == "";
84}
85
86Password::~Password()
87{
88}
89
90void Password::accept()
91{
92 password = pw->text();
93 QDialog::accept();
94}
95
96void Password::slotTogglePassword( bool showPW )
97{
98 showPW ? pw->setEchoMode( QLineEdit::Normal ) : pw->setEchoMode( QLineEdit::Password );
99}
diff --git a/noncore/apps/checkbook/password.h b/noncore/apps/checkbook/password.h
new file mode 100644
index 0000000..87d64d9
--- a/dev/null
+++ b/noncore/apps/checkbook/password.h
@@ -0,0 +1,55 @@
1/*
2                This file is part of the OPIE Project
3 =.
4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#ifndef PASSWORD_H
30#define PASSWORD_H
31
32#include <qdialog.h>
33
34class QLineEdit;
35class QWidget;
36
37class Password : public QDialog
38{
39 Q_OBJECT
40
41 public:
42 Password( QWidget *, const char *, const char * );
43 ~Password();
44
45 QString password;
46
47 private:
48 QLineEdit *pw;
49
50 protected slots:
51 void accept();
52 void slotTogglePassword( bool );
53};
54
55#endif
diff --git a/noncore/apps/checkbook/transaction.cpp b/noncore/apps/checkbook/transaction.cpp
index 122c8d6..17be669 100644
--- a/noncore/apps/checkbook/transaction.cpp
+++ b/noncore/apps/checkbook/transaction.cpp
@@ -1,279 +1,279 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 =. 3 =.
4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> 4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
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 31
32#include <qpe/datebookmonth.h> 32#include <qpe/datebookmonth.h>
33#include <qpe/timestring.h> 33#include <qpe/timestring.h>
34 34
35#include <qbuttongroup.h> 35#include <qbuttongroup.h>
36#include <qcombobox.h> 36#include <qcombobox.h>
37#include <qlabel.h> 37#include <qlabel.h>
38#include <qlayout.h> 38#include <qlayout.h>
39#include <qlineedit.h> 39#include <qlineedit.h>
40#include <qmultilineedit.h> 40#include <qmultilineedit.h>
41#include <qpopupmenu.h> 41#include <qpopupmenu.h>
42#include <qpushbutton.h> 42#include <qpushbutton.h>
43#include <qradiobutton.h> 43#include <qradiobutton.h>
44#include <qscrollview.h> 44#include <qscrollview.h>
45#include <qstring.h> 45#include <qstring.h>
46#include <qwhatsthis.h> 46#include <qwhatsthis.h>
47 47
48Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *info, 48Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *info,
49 char symbol ) 49 const QString &symbol )
50 : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) 50 : QDialog( parent, 0, TRUE, WStyle_ContextHelp )
51{ 51{
52 QString tempstr = tr( "Transaction for " ); 52 QString tempstr = tr( "Transaction for " );
53 tempstr.append( acctname ); 53 tempstr.append( acctname );
54 setCaption( tempstr ); 54 setCaption( tempstr );
55 55
56 tran = info; 56 tran = info;
57 currencySymbol = symbol; 57 currencySymbol = symbol;
58 58
59 QVBoxLayout *vb = new QVBoxLayout( this ); 59 QVBoxLayout *vb = new QVBoxLayout( this );
60 60
61 QScrollView *sv = new QScrollView( this ); 61 QScrollView *sv = new QScrollView( this );
62 vb->addWidget( sv, 0, 0 ); 62 vb->addWidget( sv, 0, 0 );
63 sv->setResizePolicy( QScrollView::AutoOneFit ); 63 sv->setResizePolicy( QScrollView::AutoOneFit );
64 sv->setFrameStyle( QFrame::NoFrame ); 64 sv->setFrameStyle( QFrame::NoFrame );
65 65
66 QWidget *container = new QWidget( sv->viewport() ); 66 QWidget *container = new QWidget( sv->viewport() );
67 sv->addChild( container ); 67 sv->addChild( container );
68 68
69 QGridLayout *layout = new QGridLayout( container ); 69 QGridLayout *layout = new QGridLayout( container );
70 layout->setSpacing( 2 ); 70 layout->setSpacing( 2 );
71 layout->setMargin( 4 ); 71 layout->setMargin( 4 );
72 72
73 // Withdrawal/Deposit 73 // Withdrawal/Deposit
74 QButtonGroup *btngrp = new QButtonGroup( container ); 74 QButtonGroup *btngrp = new QButtonGroup( container );
75 btngrp->setColumnLayout(0, Qt::Vertical ); 75 btngrp->setColumnLayout(0, Qt::Vertical );
76 btngrp->layout()->setSpacing( 0 ); 76 btngrp->layout()->setSpacing( 0 );
77 btngrp->layout()->setMargin( 0 ); 77 btngrp->layout()->setMargin( 0 );
78 btngrp->setMaximumWidth( 220 ); 78 btngrp->setMaximumWidth( 220 );
79 QGridLayout *layout2 = new QGridLayout( btngrp->layout() ); 79 QGridLayout *layout2 = new QGridLayout( btngrp->layout() );
80 layout2->setSpacing( 2 ); 80 layout2->setSpacing( 2 );
81 layout2->setMargin( 2 ); 81 layout2->setMargin( 2 );
82 withBtn = new QRadioButton( tr( "Withdrawal" ), btngrp ); 82 withBtn = new QRadioButton( tr( "Withdrawal" ), btngrp );
83 QWhatsThis::add( withBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) ); 83 QWhatsThis::add( withBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) );
84 layout2->addWidget( withBtn, 0, 0 ); 84 layout2->addWidget( withBtn, 0, 0 );
85 connect( withBtn, SIGNAL( clicked() ), this, SLOT( slotWithdrawalClicked() ) ); 85 connect( withBtn, SIGNAL( clicked() ), this, SLOT( slotWithdrawalClicked() ) );
86 depBtn = new QRadioButton( tr( "Deposit" ), btngrp ); 86 depBtn = new QRadioButton( tr( "Deposit" ), btngrp );
87 QWhatsThis::add( depBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) ); 87 QWhatsThis::add( depBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) );
88 layout2->addWidget( depBtn, 0, 1 ); 88 layout2->addWidget( depBtn, 0, 1 );
89 btngrp->setMaximumSize( 320, withBtn->height() ); 89 btngrp->setMaximumSize( 320, withBtn->height() );
90 connect( depBtn, SIGNAL( clicked() ), this, SLOT( slotDepositClicked() ) ); 90 connect( depBtn, SIGNAL( clicked() ), this, SLOT( slotDepositClicked() ) );
91 layout->addMultiCellWidget( btngrp, 0, 0, 0, 3 ); 91 layout->addMultiCellWidget( btngrp, 0, 0, 0, 3 );
92 92
93 // Date 93 // Date
94 QLabel *label = new QLabel( tr( "Date:" ), container ); 94 QLabel *label = new QLabel( tr( "Date:" ), container );
95 QWhatsThis::add( label, tr( "Select date of transaction here." ) ); 95 QWhatsThis::add( label, tr( "Select date of transaction here." ) );
96 layout->addWidget( label, 1, 0 ); 96 layout->addWidget( label, 1, 0 );
97 dateBtn = new QPushButton( TimeString::shortDate( QDate::currentDate() ), 97 dateBtn = new QPushButton( TimeString::shortDate( QDate::currentDate() ),
98 container ); 98 container );
99 QWhatsThis::add( dateBtn, tr( "Select date of transaction here." ) ); 99 QWhatsThis::add( dateBtn, tr( "Select date of transaction here." ) );
100 QPopupMenu *m1 = new QPopupMenu( container ); 100 QPopupMenu *m1 = new QPopupMenu( container );
101 datePicker = new DateBookMonth( m1, 0, TRUE ); 101 datePicker = new DateBookMonth( m1, 0, TRUE );
102 m1->insertItem( datePicker ); 102 m1->insertItem( datePicker );
103 dateBtn->setPopup( m1 ); 103 dateBtn->setPopup( m1 );
104 connect( datePicker, SIGNAL( dateClicked( int, int, int ) ), 104 connect( datePicker, SIGNAL( dateClicked( int, int, int ) ),
105 this, SLOT( slotDateChanged( int, int, int ) ) ); 105 this, SLOT( slotDateChanged( int, int, int ) ) );
106 layout->addWidget( dateBtn, 1, 1 ); 106 layout->addWidget( dateBtn, 1, 1 );
107 107
108 // Check number 108 // Check number
109 label = new QLabel( tr( "Number:" ), container ); 109 label = new QLabel( tr( "Number:" ), container );
110 QWhatsThis::add( label, tr( "Enter check number here." ) ); 110 QWhatsThis::add( label, tr( "Enter check number here." ) );
111 layout->addWidget( label, 1, 2 ); 111 layout->addWidget( label, 1, 2 );
112 numEdit = new QLineEdit( container ); 112 numEdit = new QLineEdit( container );
113 QWhatsThis::add( numEdit, tr( "Enter check number here." ) ); 113 QWhatsThis::add( numEdit, tr( "Enter check number here." ) );
114 numEdit->setMaximumWidth( 40 ); 114 numEdit->setMaximumWidth( 40 );
115 layout->addWidget( numEdit, 1, 3 ); 115 layout->addWidget( numEdit, 1, 3 );
116 116
117 // Description 117 // Description
118 label = new QLabel( tr( "Description:" ), container ); 118 label = new QLabel( tr( "Description:" ), container );
119 QWhatsThis::add( label, tr( "Enter description of transaction here." ) ); 119 QWhatsThis::add( label, tr( "Enter description of transaction here." ) );
120 layout->addWidget( label, 2, 0 ); 120 layout->addWidget( label, 2, 0 );
121 descEdit = new QLineEdit( container ); 121 descEdit = new QLineEdit( container );
122 QWhatsThis::add( descEdit, tr( "Enter description of transaction here." ) ); 122 QWhatsThis::add( descEdit, tr( "Enter description of transaction here." ) );
123 layout->addMultiCellWidget( descEdit, 2, 2, 1, 3 ); 123 layout->addMultiCellWidget( descEdit, 2, 2, 1, 3 );
124 124
125 // Category 125 // Category
126 label = new QLabel( tr( "Category:" ), container ); 126 label = new QLabel( tr( "Category:" ), container );
127 QWhatsThis::add( label, tr( "Select transaction category here." ) ); 127 QWhatsThis::add( label, tr( "Select transaction category here." ) );
128 layout->addWidget( label, 3, 0 ); 128 layout->addWidget( label, 3, 0 );
129 catList = new QComboBox( container ); 129 catList = new QComboBox( container );
130 QWhatsThis::add( catList, tr( "Select transaction category here." ) ); 130 QWhatsThis::add( catList, tr( "Select transaction category here." ) );
131 layout->addMultiCellWidget( catList, 3, 3, 1, 3 ); 131 layout->addMultiCellWidget( catList, 3, 3, 1, 3 );
132 132
133 // Type 133 // Type
134 label = new QLabel( tr( "Type:" ), container ); 134 label = new QLabel( tr( "Type:" ), container );
135 QWhatsThis::add( label, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) ); 135 QWhatsThis::add( label, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) );
136 layout->addWidget( label, 4, 0 ); 136 layout->addWidget( label, 4, 0 );
137 typeList = new QComboBox( container ); 137 typeList = new QComboBox( container );
138 QWhatsThis::add( typeList, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) ); 138 QWhatsThis::add( typeList, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) );
139 layout->addMultiCellWidget( typeList, 4, 4, 1, 3 ); 139 layout->addMultiCellWidget( typeList, 4, 4, 1, 3 );
140 140
141 // Amount 141 // Amount
142 label = new QLabel( tr( "Amount:" ), container ); 142 label = new QLabel( tr( "Amount:" ), container );
143 QWhatsThis::add( label, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) ); 143 QWhatsThis::add( label, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) );
144 layout->addWidget( label, 5, 0 ); 144 layout->addWidget( label, 5, 0 );
145 amtEdit = new QLineEdit( container ); 145 amtEdit = new QLineEdit( container );
146 QWhatsThis::add( amtEdit, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) ); 146 QWhatsThis::add( amtEdit, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) );
147 layout->addMultiCellWidget( amtEdit, 5, 5, 1, 3 ); 147 layout->addMultiCellWidget( amtEdit, 5, 5, 1, 3 );
148 148
149 // Fee 149 // Fee
150 label = new QLabel( tr( "Fee:" ), container ); 150 label = new QLabel( tr( "Fee:" ), container );
151 QWhatsThis::add( label, tr( "Enter any fee amount assoiciated with this transaction.\n\nThe value entered should always be positive." ) ); 151 QWhatsThis::add( label, tr( "Enter any fee amount assoiciated with this transaction.\n\nThe value entered should always be positive." ) );
152 layout->addWidget( label, 6, 0 ); 152 layout->addWidget( label, 6, 0 );
153 feeEdit = new QLineEdit( container ); 153 feeEdit = new QLineEdit( container );
154 QWhatsThis::add( feeEdit, tr( "Enter any fee amount assoiciated with this transaction.\n\nThe value entered should always be positive." ) ); 154 QWhatsThis::add( feeEdit, tr( "Enter any fee amount assoiciated with this transaction.\n\nThe value entered should always be positive." ) );
155 layout->addMultiCellWidget( feeEdit, 6, 6, 1, 3 ); 155 layout->addMultiCellWidget( feeEdit, 6, 6, 1, 3 );
156 156
157 // Notes 157 // Notes
158 label = new QLabel( tr( "Notes:" ), container ); 158 label = new QLabel( tr( "Notes:" ), container );
159 QWhatsThis::add( label, tr( "Enter any additional information for this transaction here." ) ); 159 QWhatsThis::add( label, tr( "Enter any additional information for this transaction here." ) );
160 layout->addWidget( label, 7, 0 ); 160 layout->addWidget( label, 7, 0 );
161 noteEdit = new QMultiLineEdit( container ); 161 noteEdit = new QMultiLineEdit( container );
162 QWhatsThis::add( noteEdit, tr( "Enter any additional information for this transaction here." ) ); 162 QWhatsThis::add( noteEdit, tr( "Enter any additional information for this transaction here." ) );
163 layout->addMultiCellWidget( noteEdit, 8, 8, 0, 3 ); 163 layout->addMultiCellWidget( noteEdit, 8, 8, 0, 3 );
164 164
165 // Populate current values if provided 165 // Populate current values if provided
166 if ( info ) 166 if ( info )
167 { 167 {
168 if ( info->withdrawal() ) 168 if ( info->withdrawal() )
169 { 169 {
170 withBtn->setChecked( TRUE ); 170 withBtn->setChecked( TRUE );
171 slotWithdrawalClicked(); 171 slotWithdrawalClicked();
172 } 172 }
173 else 173 else
174 { 174 {
175 depBtn->setChecked( TRUE ); 175 depBtn->setChecked( TRUE );
176 slotDepositClicked(); 176 slotDepositClicked();
177 } 177 }
178 QDate dt = info->date(); 178 QDate dt = info->date();
179 slotDateChanged( dt.year(), dt.month(), dt.day() ); 179 slotDateChanged( dt.year(), dt.month(), dt.day() );
180 datePicker->setDate( dt ); 180 datePicker->setDate( dt );
181 numEdit->setText( info->number() ); 181 numEdit->setText( info->number() );
182 descEdit->setText( info->desc() ); 182 descEdit->setText( info->desc() );
183 QString temptext = info->category(); 183 QString temptext = info->category();
184 int i = catList->count(); 184 int i = catList->count();
185 while ( i > 0 ) 185 while ( i > 0 )
186 { 186 {
187 i--; 187 i--;
188 catList->setCurrentItem( i ); 188 catList->setCurrentItem( i );
189 if ( catList->currentText() == temptext ) 189 if ( catList->currentText() == temptext )
190 { 190 {
191 break; 191 break;
192 } 192 }
193 } 193 }
194 temptext = info->type(); 194 temptext = info->type();
195 i = typeList->count(); 195 i = typeList->count();
196 while ( i > 0 ) 196 while ( i > 0 )
197 { 197 {
198 i--; 198 i--;
199 typeList->setCurrentItem( i ); 199 typeList->setCurrentItem( i );
200 if ( typeList->currentText() == temptext ) 200 if ( typeList->currentText() == temptext )
201 { 201 {
202 break; 202 break;
203 } 203 }
204 } 204 }
205 amtEdit->setText( QString( "%1" ).arg( info->amount(), 0, 'f', 2 ) ); 205 amtEdit->setText( QString( "%1" ).arg( info->amount(), 0, 'f', 2 ) );
206 feeEdit->setText( QString( "%1" ).arg( info->fee(), 0, 'f', 2 ) ); 206 feeEdit->setText( QString( "%1" ).arg( info->fee(), 0, 'f', 2 ) );
207 noteEdit->setText( info->notes() ); 207 noteEdit->setText( info->notes() );
208 } 208 }
209 else 209 else
210 { 210 {
211 withBtn->setChecked( TRUE ); 211 withBtn->setChecked( TRUE );
212 } 212 }
213} 213}
214 214
215Transaction::~Transaction() 215Transaction::~Transaction()
216{ 216{
217} 217}
218 218
219void Transaction::accept() 219void Transaction::accept()
220{ 220{
221 tran->setDesc( descEdit->text() ); 221 tran->setDesc( descEdit->text() );
222 tran->setDate( datePicker->selectedDate() ); 222 tran->setDate( datePicker->selectedDate() );
223 tran->setWithdrawal( withBtn->isChecked() ); 223 tran->setWithdrawal( withBtn->isChecked() );
224 tran->setType( typeList->currentText() ); 224 tran->setType( typeList->currentText() );
225 tran->setCategory( catList->currentText() ); 225 tran->setCategory( catList->currentText() );
226 bool ok; 226 bool ok;
227 tran->setAmount( amtEdit->text().toFloat( &ok ) ); 227 tran->setAmount( amtEdit->text().toFloat( &ok ) );
228 tran->setFee( feeEdit->text().toFloat( &ok ) ); 228 tran->setFee( feeEdit->text().toFloat( &ok ) );
229 tran->setNumber( numEdit->text() ); 229 tran->setNumber( numEdit->text() );
230 tran->setNotes( noteEdit->text() ); 230 tran->setNotes( noteEdit->text() );
231 231
232 QDialog::accept(); 232 QDialog::accept();
233} 233}
234 234
235void Transaction::slotWithdrawalClicked() 235void Transaction::slotWithdrawalClicked()
236{ 236{
237 catList->clear(); 237 catList->clear();
238 catList->insertItem( tr( "Automobile" ) ); 238 catList->insertItem( tr( "Automobile" ) );
239 catList->insertItem( tr( "Bills" ) ); 239 catList->insertItem( tr( "Bills" ) );
240 catList->insertItem( tr( "CDs" ) ); 240 catList->insertItem( tr( "CDs" ) );
241 catList->insertItem( tr( "Clothing" ) ); 241 catList->insertItem( tr( "Clothing" ) );
242 catList->insertItem( tr( "Computer" ) ); 242 catList->insertItem( tr( "Computer" ) );
243 catList->insertItem( tr( "DVDs" ) ); 243 catList->insertItem( tr( "DVDs" ) );
244 catList->insertItem( tr( "Eletronics" ) ); 244 catList->insertItem( tr( "Eletronics" ) );
245 catList->insertItem( tr( "Entertainment" ) ); 245 catList->insertItem( tr( "Entertainment" ) );
246 catList->insertItem( tr( "Food" ) ); 246 catList->insertItem( tr( "Food" ) );
247 catList->insertItem( tr( "Gasoline" ) ); 247 catList->insertItem( tr( "Gasoline" ) );
248 catList->insertItem( tr( "Misc" ) ); 248 catList->insertItem( tr( "Misc" ) );
249 catList->insertItem( tr( "Movies" ) ); 249 catList->insertItem( tr( "Movies" ) );
250 catList->insertItem( tr( "Rent" ) ); 250 catList->insertItem( tr( "Rent" ) );
251 catList->insertItem( tr( "Travel" ) ); 251 catList->insertItem( tr( "Travel" ) );
252 catList->setCurrentItem( 0 ); 252 catList->setCurrentItem( 0 );
253 typeList->clear(); 253 typeList->clear();
254 typeList->insertItem( tr( "Debit Charge" ) ); 254 typeList->insertItem( tr( "Debit Charge" ) );
255 typeList->insertItem( tr( "Written Check" ) ); 255 typeList->insertItem( tr( "Written Check" ) );
256 typeList->insertItem( tr( "Transfer" ) ); 256 typeList->insertItem( tr( "Transfer" ) );
257 typeList->insertItem( tr( "Credit Card" ) ); 257 typeList->insertItem( tr( "Credit Card" ) );
258} 258}
259 259
260void Transaction::slotDepositClicked() 260void Transaction::slotDepositClicked()
261{ 261{
262 catList->clear(); 262 catList->clear();
263 catList->insertItem( tr( "Work" ) ); 263 catList->insertItem( tr( "Work" ) );
264 catList->insertItem( tr( "Family Member" ) ); 264 catList->insertItem( tr( "Family Member" ) );
265 catList->insertItem( tr( "Misc. Credit" ) ); 265 catList->insertItem( tr( "Misc. Credit" ) );
266 catList->setCurrentItem( 0 ); 266 catList->setCurrentItem( 0 );
267 typeList->clear(); 267 typeList->clear();
268 typeList->insertItem( tr( "Written Check" ) ); 268 typeList->insertItem( tr( "Written Check" ) );
269 typeList->insertItem( tr( "Automatic Payment" ) ); 269 typeList->insertItem( tr( "Automatic Payment" ) );
270 typeList->insertItem( tr( "Transfer" ) ); 270 typeList->insertItem( tr( "Transfer" ) );
271 typeList->insertItem( tr( "Cash" ) ); 271 typeList->insertItem( tr( "Cash" ) );
272} 272}
273 273
274void Transaction::slotDateChanged( int y, int m, int d ) 274void Transaction::slotDateChanged( int y, int m, int d )
275{ 275{
276 QDate date; 276 QDate date;
277 date.setYMD( y, m, d ); 277 date.setYMD( y, m, d );
278 dateBtn->setText( TimeString::shortDate( date ) ); 278 dateBtn->setText( TimeString::shortDate( date ) );
279} 279}
diff --git a/noncore/apps/checkbook/transaction.h b/noncore/apps/checkbook/transaction.h
index 89ca8e4..000aee7 100644
--- a/noncore/apps/checkbook/transaction.h
+++ b/noncore/apps/checkbook/transaction.h
@@ -1,79 +1,79 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 =. 3 =.
4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> 4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
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#ifndef TRANSACTION_H 29#ifndef TRANSACTION_H
30#define TRANSACTION_H 30#define TRANSACTION_H
31 31
32#include <qdialog.h> 32#include <qdialog.h>
33 33
34class DateBookMonth; 34class DateBookMonth;
35class QComboBox; 35class QComboBox;
36class QLineEdit; 36class QLineEdit;
37class QMultiLineEdit; 37class QMultiLineEdit;
38class QPushButton; 38class QPushButton;
39class QRadioButton; 39class QRadioButton;
40class QString; 40class QString;
41class QWidget; 41class QWidget;
42class TranInfo; 42class TranInfo;
43 43
44class Transaction : public QDialog 44class Transaction : public QDialog
45{ 45{
46 Q_OBJECT 46 Q_OBJECT
47 47
48 public: 48 public:
49 Transaction( QWidget * = 0x0, const QString & = 0x0, TranInfo * = 0x0, 49 Transaction( QWidget * = 0x0, const QString & = 0x0, TranInfo * = 0x0,
50 char = '$' ); 50 const QString & = "$" );
51 ~Transaction(); 51 ~Transaction();
52 52
53 private: 53 private:
54 TranInfo *tran; 54 TranInfo *tran;
55 55
56 char currencySymbol; 56 QString currencySymbol;
57 57
58 QRadioButton *withBtn; 58 QRadioButton *withBtn;
59 QRadioButton *depBtn; 59 QRadioButton *depBtn;
60 QPushButton *dateBtn; 60 QPushButton *dateBtn;
61 DateBookMonth *datePicker; 61 DateBookMonth *datePicker;
62 QLineEdit *numEdit; 62 QLineEdit *numEdit;
63 QLineEdit *descEdit; 63 QLineEdit *descEdit;
64 QComboBox *catList; 64 QComboBox *catList;
65 QComboBox *typeList; 65 QComboBox *typeList;
66 QLineEdit *amtEdit; 66 QLineEdit *amtEdit;
67 QLineEdit *feeEdit; 67 QLineEdit *feeEdit;
68 QMultiLineEdit *noteEdit; 68 QMultiLineEdit *noteEdit;
69 69
70 protected slots: 70 protected slots:
71 void accept(); 71 void accept();
72 72
73 private slots: 73 private slots:
74 void slotWithdrawalClicked(); 74 void slotWithdrawalClicked();
75 void slotDepositClicked(); 75 void slotDepositClicked();
76 void slotDateChanged( int, int, int ); 76 void slotDateChanged( int, int, int );
77}; 77};
78 78
79#endif 79#endif