author | llornkcor <llornkcor> | 2003-07-17 15:00:34 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-07-17 15:00:34 (UTC) |
commit | 6140e0d6a131ac127ebfc583990cb6ceefdd30ad (patch) (unidiff) | |
tree | 7b0f5f856dc16b535454f9737b59dff18d7b3626 | |
parent | 53237dd02577d118e1ad19a18819f86f1a4ea207 (diff) | |
download | opie-6140e0d6a131ac127ebfc583990cb6ceefdd30ad.zip opie-6140e0d6a131ac127ebfc583990cb6ceefdd30ad.tar.gz opie-6140e0d6a131ac127ebfc583990cb6ceefdd30ad.tar.bz2 |
fixincludes
-rw-r--r-- | noncore/apps/checkbook/checkbook.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/checkbook/configuration.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/checkbook/graph.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/checkbook/mainwindow.cpp | 3 | ||||
-rw-r--r-- | noncore/apps/checkbook/password.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/checkbook/traninfo.h | 1 | ||||
-rw-r--r-- | noncore/apps/checkbook/transaction.cpp | 5 |
7 files changed, 0 insertions, 19 deletions
diff --git a/noncore/apps/checkbook/checkbook.cpp b/noncore/apps/checkbook/checkbook.cpp index 5fe660c..653ee4a 100644 --- a/noncore/apps/checkbook/checkbook.cpp +++ b/noncore/apps/checkbook/checkbook.cpp | |||
@@ -1,437 +1,433 @@ | |||
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 "cbinfo.h" | 30 | #include "cbinfo.h" |
31 | #include "transaction.h" | 31 | #include "transaction.h" |
32 | #include "traninfo.h" | 32 | #include "traninfo.h" |
33 | #include "graph.h" | 33 | #include "graph.h" |
34 | #include "graphinfo.h" | 34 | #include "graphinfo.h" |
35 | #include "password.h" | 35 | #include "password.h" |
36 | 36 | ||
37 | #include <opie/otabwidget.h> | 37 | #include <opie/otabwidget.h> |
38 | #include <qpe/config.h> | ||
39 | #include <qpe/qpeapplication.h> | 38 | #include <qpe/qpeapplication.h> |
40 | #include <qpe/qpemessagebox.h> | 39 | #include <qpe/qpemessagebox.h> |
41 | #include <qpe/resource.h> | 40 | #include <qpe/resource.h> |
42 | 41 | ||
43 | #include <qcheckbox.h> | 42 | #include <qcheckbox.h> |
44 | #include <qcombobox.h> | 43 | #include <qcombobox.h> |
45 | #include <qfile.h> | ||
46 | #include <qfontmetrics.h> | ||
47 | #include <qlabel.h> | 44 | #include <qlabel.h> |
48 | #include <qlayout.h> | 45 | #include <qlayout.h> |
49 | #include <qlineedit.h> | 46 | #include <qlineedit.h> |
50 | #include <qmultilineedit.h> | 47 | #include <qmultilineedit.h> |
51 | #include <qpushbutton.h> | 48 | #include <qpushbutton.h> |
52 | #include <qwhatsthis.h> | 49 | #include <qwhatsthis.h> |
53 | #include <qwidget.h> | ||
54 | 50 | ||
55 | Checkbook::Checkbook( QWidget *parent, CBInfo *i, const QString &symbol ) | 51 | Checkbook::Checkbook( QWidget *parent, CBInfo *i, const QString &symbol ) |
56 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) | 52 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) |
57 | { | 53 | { |
58 | info = i; | 54 | info = i; |
59 | currencySymbol = symbol; | 55 | currencySymbol = symbol; |
60 | 56 | ||
61 | if ( info->name() != "" ) | 57 | if ( info->name() != "" ) |
62 | { | 58 | { |
63 | QString tempstr = info->name(); | 59 | QString tempstr = info->name(); |
64 | tempstr.append( " - " ); | 60 | tempstr.append( " - " ); |
65 | tempstr.append( tr( "Checkbook" ) ); | 61 | tempstr.append( tr( "Checkbook" ) ); |
66 | setCaption( tempstr ); | 62 | setCaption( tempstr ); |
67 | } | 63 | } |
68 | else | 64 | else |
69 | { | 65 | { |
70 | setCaption( tr( "New checkbook" ) ); | 66 | setCaption( tr( "New checkbook" ) ); |
71 | } | 67 | } |
72 | 68 | ||
73 | // Setup layout to make everything pretty | 69 | // Setup layout to make everything pretty |
74 | QVBoxLayout *layout = new QVBoxLayout( this ); | 70 | QVBoxLayout *layout = new QVBoxLayout( this ); |
75 | layout->setMargin( 2 ); | 71 | layout->setMargin( 2 ); |
76 | layout->setSpacing( 4 ); | 72 | layout->setSpacing( 4 ); |
77 | 73 | ||
78 | // Setup tabs for all info | 74 | // Setup tabs for all info |
79 | mainWidget = new OTabWidget( this ); | 75 | mainWidget = new OTabWidget( this ); |
80 | layout->addWidget( mainWidget ); | 76 | layout->addWidget( mainWidget ); |
81 | 77 | ||
82 | mainWidget->addTab( initInfo(), "checkbook/infotab", tr( "Info" ) ); | 78 | mainWidget->addTab( initInfo(), "checkbook/infotab", tr( "Info" ) ); |
83 | mainWidget->addTab( initTransactions(), "checkbook/trantab", tr( "Transactions" ) ); | 79 | mainWidget->addTab( initTransactions(), "checkbook/trantab", tr( "Transactions" ) ); |
84 | mainWidget->addTab( initCharts(), "checkbook/charttab", tr( "Charts" ) ); | 80 | mainWidget->addTab( initCharts(), "checkbook/charttab", tr( "Charts" ) ); |
85 | mainWidget->setCurrentTab( tr( "Info" ) ); | 81 | mainWidget->setCurrentTab( tr( "Info" ) ); |
86 | 82 | ||
87 | // Load checkbook information | 83 | // Load checkbook information |
88 | loadCheckbook(); | 84 | loadCheckbook(); |
89 | } | 85 | } |
90 | 86 | ||
91 | Checkbook::~Checkbook() | 87 | Checkbook::~Checkbook() |
92 | { | 88 | { |
93 | } | 89 | } |
94 | 90 | ||
95 | QWidget *Checkbook::initInfo() | 91 | QWidget *Checkbook::initInfo() |
96 | { | 92 | { |
97 | QWidget *control = new QWidget( mainWidget ); | 93 | QWidget *control = new QWidget( mainWidget ); |
98 | 94 | ||
99 | QVBoxLayout *vb = new QVBoxLayout( control ); | 95 | QVBoxLayout *vb = new QVBoxLayout( control ); |
100 | 96 | ||
101 | QScrollView *sv = new QScrollView( control ); | 97 | QScrollView *sv = new QScrollView( control ); |
102 | vb->addWidget( sv, 0, 0 ); | 98 | vb->addWidget( sv, 0, 0 ); |
103 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 99 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
104 | sv->setFrameStyle( QFrame::NoFrame ); | 100 | sv->setFrameStyle( QFrame::NoFrame ); |
105 | 101 | ||
106 | QWidget *container = new QWidget( sv->viewport() ); | 102 | QWidget *container = new QWidget( sv->viewport() ); |
107 | sv->addChild( container ); | 103 | sv->addChild( container ); |
108 | 104 | ||
109 | QGridLayout *layout = new QGridLayout( container ); | 105 | QGridLayout *layout = new QGridLayout( container ); |
110 | layout->setSpacing( 2 ); | 106 | layout->setSpacing( 2 ); |
111 | layout->setMargin( 4 ); | 107 | layout->setMargin( 4 ); |
112 | 108 | ||
113 | // Password protection | 109 | // Password protection |
114 | passwordCB = new QCheckBox( tr( "Password protect" ), container ); | 110 | passwordCB = new QCheckBox( tr( "Password protect" ), container ); |
115 | QWhatsThis::add( passwordCB, tr( "Click here to enable/disable password protection of this checkbook." ) ); | 111 | QWhatsThis::add( passwordCB, tr( "Click here to enable/disable password protection of this checkbook." ) ); |
116 | connect( passwordCB, SIGNAL( clicked() ), this, SLOT( slotPasswordClicked() ) ); | 112 | connect( passwordCB, SIGNAL( clicked() ), this, SLOT( slotPasswordClicked() ) ); |
117 | layout->addMultiCellWidget( passwordCB, 0, 0, 0, 1 ); | 113 | layout->addMultiCellWidget( passwordCB, 0, 0, 0, 1 ); |
118 | 114 | ||
119 | // Account name | 115 | // Account name |
120 | QLabel *label = new QLabel( tr( "Name:" ), container ); | 116 | QLabel *label = new QLabel( tr( "Name:" ), container ); |
121 | QWhatsThis::add( label, tr( "Enter name of checkbook here." ) ); | 117 | QWhatsThis::add( label, tr( "Enter name of checkbook here." ) ); |
122 | layout->addWidget( label, 1, 0 ); | 118 | layout->addWidget( label, 1, 0 ); |
123 | nameEdit = new QLineEdit( container ); | 119 | nameEdit = new QLineEdit( container ); |
124 | QWhatsThis::add( nameEdit, tr( "Enter name of checkbook here." ) ); | 120 | QWhatsThis::add( nameEdit, tr( "Enter name of checkbook here." ) ); |
125 | connect( nameEdit, SIGNAL( textChanged( const QString & ) ), | 121 | connect( nameEdit, SIGNAL( textChanged( const QString & ) ), |
126 | this, SLOT( slotNameChanged( const QString & ) ) ); | 122 | this, SLOT( slotNameChanged( const QString & ) ) ); |
127 | layout->addWidget( nameEdit, 1, 1 ); | 123 | layout->addWidget( nameEdit, 1, 1 ); |
128 | 124 | ||
129 | // Type of account | 125 | // Type of account |
130 | label = new QLabel( tr( "Type:" ), container ); | 126 | label = new QLabel( tr( "Type:" ), container ); |
131 | QWhatsThis::add( label, tr( "Select type of checkbook here." ) ); | 127 | QWhatsThis::add( label, tr( "Select type of checkbook here." ) ); |
132 | layout->addWidget( label, 2, 0 ); | 128 | layout->addWidget( label, 2, 0 ); |
133 | typeList = new QComboBox( container ); | 129 | typeList = new QComboBox( container ); |
134 | QWhatsThis::add( typeList, tr( "Select type of checkbook here." ) ); | 130 | QWhatsThis::add( typeList, tr( "Select type of checkbook here." ) ); |
135 | typeList->insertItem( tr( "Savings" ) ); // 0 | 131 | typeList->insertItem( tr( "Savings" ) ); // 0 |
136 | typeList->insertItem( tr( "Checking" ) ); // 1 | 132 | typeList->insertItem( tr( "Checking" ) ); // 1 |
137 | typeList->insertItem( tr( "CD" ) ); // 2 | 133 | typeList->insertItem( tr( "CD" ) ); // 2 |
138 | typeList->insertItem( tr( "Money market" ) );// 3 | 134 | typeList->insertItem( tr( "Money market" ) );// 3 |
139 | typeList->insertItem( tr( "Mutual fund" ) );// 4 | 135 | typeList->insertItem( tr( "Mutual fund" ) );// 4 |
140 | typeList->insertItem( tr( "Other" ) ); // 5 | 136 | typeList->insertItem( tr( "Other" ) ); // 5 |
141 | layout->addWidget( typeList, 2, 1 ); | 137 | layout->addWidget( typeList, 2, 1 ); |
142 | 138 | ||
143 | // Bank/institution name | 139 | // Bank/institution name |
144 | label = new QLabel( tr( "Bank:" ), container ); | 140 | label = new QLabel( tr( "Bank:" ), container ); |
145 | QWhatsThis::add( label, tr( "Enter name of the bank for this checkbook here." ) ); | 141 | QWhatsThis::add( label, tr( "Enter name of the bank for this checkbook here." ) ); |
146 | layout->addWidget( label, 3, 0 ); | 142 | layout->addWidget( label, 3, 0 ); |
147 | bankEdit = new QLineEdit( container ); | 143 | bankEdit = new QLineEdit( container ); |
148 | QWhatsThis::add( bankEdit, tr( "Enter name of the bank for this checkbook here." ) ); | 144 | QWhatsThis::add( bankEdit, tr( "Enter name of the bank for this checkbook here." ) ); |
149 | layout->addWidget( bankEdit, 3, 1 ); | 145 | layout->addWidget( bankEdit, 3, 1 ); |
150 | 146 | ||
151 | // Account number | 147 | // Account number |
152 | label = new QLabel( tr( "Account number:" ), container ); | 148 | label = new QLabel( tr( "Account number:" ), container ); |
153 | QWhatsThis::add( label, tr( "Enter account number for this checkbook here." ) ); | 149 | QWhatsThis::add( label, tr( "Enter account number for this checkbook here." ) ); |
154 | layout->addWidget( label, 4, 0 ); | 150 | layout->addWidget( label, 4, 0 ); |
155 | acctNumEdit = new QLineEdit( container ); | 151 | acctNumEdit = new QLineEdit( container ); |
156 | QWhatsThis::add( acctNumEdit, tr( "Enter account number for this checkbook here." ) ); | 152 | QWhatsThis::add( acctNumEdit, tr( "Enter account number for this checkbook here." ) ); |
157 | layout->addWidget( acctNumEdit, 4, 1 ); | 153 | layout->addWidget( acctNumEdit, 4, 1 ); |
158 | 154 | ||
159 | // PIN number | 155 | // PIN number |
160 | label = new QLabel( tr( "PIN number:" ), container ); | 156 | label = new QLabel( tr( "PIN number:" ), container ); |
161 | QWhatsThis::add( label, tr( "Enter PIN number for this checkbook here." ) ); | 157 | QWhatsThis::add( label, tr( "Enter PIN number for this checkbook here." ) ); |
162 | layout->addWidget( label, 5, 0 ); | 158 | layout->addWidget( label, 5, 0 ); |
163 | pinNumEdit = new QLineEdit( container ); | 159 | pinNumEdit = new QLineEdit( container ); |
164 | QWhatsThis::add( pinNumEdit, tr( "Enter PIN number for this checkbook here." ) ); | 160 | QWhatsThis::add( pinNumEdit, tr( "Enter PIN number for this checkbook here." ) ); |
165 | layout->addWidget( pinNumEdit, 5, 1 ); | 161 | layout->addWidget( pinNumEdit, 5, 1 ); |
166 | 162 | ||
167 | // Starting balance | 163 | // Starting balance |
168 | label = new QLabel( tr( "Starting balance:" ), container ); | 164 | label = new QLabel( tr( "Starting balance:" ), container ); |
169 | QWhatsThis::add( label, tr( "Enter the initial balance for this checkbook here." ) ); | 165 | QWhatsThis::add( label, tr( "Enter the initial balance for this checkbook here." ) ); |
170 | layout->addWidget( label, 6, 0 ); | 166 | layout->addWidget( label, 6, 0 ); |
171 | balanceEdit = new QLineEdit( container ); | 167 | balanceEdit = new QLineEdit( container ); |
172 | QWhatsThis::add( balanceEdit, tr( "Enter the initial balance for this checkbook here." ) ); | 168 | QWhatsThis::add( balanceEdit, tr( "Enter the initial balance for this checkbook here." ) ); |
173 | connect( balanceEdit, SIGNAL( textChanged( const QString & ) ), | 169 | connect( balanceEdit, SIGNAL( textChanged( const QString & ) ), |
174 | this, SLOT( slotStartingBalanceChanged( const QString & ) ) ); | 170 | this, SLOT( slotStartingBalanceChanged( const QString & ) ) ); |
175 | layout->addWidget( balanceEdit, 6, 1 ); | 171 | layout->addWidget( balanceEdit, 6, 1 ); |
176 | 172 | ||
177 | // Notes | 173 | // Notes |
178 | label = new QLabel( tr( "Notes:" ), container ); | 174 | label = new QLabel( tr( "Notes:" ), container ); |
179 | QWhatsThis::add( label, tr( "Enter any additional information for this checkbook here." ) ); | 175 | QWhatsThis::add( label, tr( "Enter any additional information for this checkbook here." ) ); |
180 | layout->addWidget( label, 7, 0 ); | 176 | layout->addWidget( label, 7, 0 ); |
181 | notesEdit = new QMultiLineEdit( container ); | 177 | notesEdit = new QMultiLineEdit( container ); |
182 | QWhatsThis::add( notesEdit, tr( "Enter any additional information for this checkbook here." ) ); | 178 | QWhatsThis::add( notesEdit, tr( "Enter any additional information for this checkbook here." ) ); |
183 | notesEdit->setMinimumHeight( 25 ); | 179 | notesEdit->setMinimumHeight( 25 ); |
184 | notesEdit->setMaximumHeight( 65 ); | 180 | notesEdit->setMaximumHeight( 65 ); |
185 | layout->addMultiCellWidget( notesEdit, 8, 8, 0, 1 ); | 181 | layout->addMultiCellWidget( notesEdit, 8, 8, 0, 1 ); |
186 | 182 | ||
187 | return control; | 183 | return control; |
188 | } | 184 | } |
189 | 185 | ||
190 | QWidget *Checkbook::initTransactions() | 186 | QWidget *Checkbook::initTransactions() |
191 | { | 187 | { |
192 | QWidget *control = new QWidget( mainWidget ); | 188 | QWidget *control = new QWidget( mainWidget ); |
193 | 189 | ||
194 | QGridLayout *layout = new QGridLayout( control ); | 190 | QGridLayout *layout = new QGridLayout( control ); |
195 | layout->setSpacing( 2 ); | 191 | layout->setSpacing( 2 ); |
196 | layout->setMargin( 4 ); | 192 | layout->setMargin( 4 ); |
197 | 193 | ||
198 | balanceLabel = new QLabel( tr( "Current balance: %10.00" ).arg( currencySymbol ), | 194 | balanceLabel = new QLabel( tr( "Current balance: %10.00" ).arg( currencySymbol ), |
199 | control ); | 195 | control ); |
200 | QWhatsThis::add( balanceLabel, tr( "This area shows the current balance in this checkbook." ) ); | 196 | QWhatsThis::add( balanceLabel, tr( "This area shows the current balance in this checkbook." ) ); |
201 | layout->addMultiCellWidget( balanceLabel, 0, 0, 0, 2 ); | 197 | layout->addMultiCellWidget( balanceLabel, 0, 0, 0, 2 ); |
202 | 198 | ||
203 | tranTable = new QListView( control ); | 199 | tranTable = new QListView( control ); |
204 | 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." ) ); | 200 | 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." ) ); |
205 | tranTable->addColumn( tr( "Num" ) ); | 201 | tranTable->addColumn( tr( "Num" ) ); |
206 | tranTable->addColumn( tr( "Date" ) ); | 202 | tranTable->addColumn( tr( "Date" ) ); |
207 | //tranTable->addColumn( tr( "Cleared" ) ); | 203 | //tranTable->addColumn( tr( "Cleared" ) ); |
208 | tranTable->addColumn( tr( "Description" ) ); | 204 | tranTable->addColumn( tr( "Description" ) ); |
209 | int colnum = tranTable->addColumn( tr( "Amount" ) ); | 205 | int colnum = tranTable->addColumn( tr( "Amount" ) ); |
210 | tranTable->setColumnAlignment( colnum, Qt::AlignRight ); | 206 | tranTable->setColumnAlignment( colnum, Qt::AlignRight ); |
211 | tranTable->setAllColumnsShowFocus( TRUE ); | 207 | tranTable->setAllColumnsShowFocus( TRUE ); |
212 | tranTable->setSorting( 1 ); | 208 | tranTable->setSorting( 1 ); |
213 | layout->addMultiCellWidget( tranTable, 1, 1, 0, 2 ); | 209 | layout->addMultiCellWidget( tranTable, 1, 1, 0, 2 ); |
214 | QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold ); | 210 | QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold ); |
215 | connect( tranTable, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), | 211 | connect( tranTable, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), |
216 | this, SLOT( slotEditTran() ) ); | 212 | this, SLOT( slotEditTran() ) ); |
217 | 213 | ||
218 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), control ); | 214 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), control ); |
219 | QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) ); | 215 | QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) ); |
220 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotNewTran() ) ); | 216 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotNewTran() ) ); |
221 | layout->addWidget( btn, 2, 0 ); | 217 | layout->addWidget( btn, 2, 0 ); |
222 | 218 | ||
223 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), control ); | 219 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), control ); |
224 | QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) ); | 220 | QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) ); |
225 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotEditTran() ) ); | 221 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotEditTran() ) ); |
226 | layout->addWidget( btn, 2, 1 ); | 222 | layout->addWidget( btn, 2, 1 ); |
227 | 223 | ||
228 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), control ); | 224 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), control ); |
229 | QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) ); | 225 | QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) ); |
230 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDeleteTran() ) ); | 226 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDeleteTran() ) ); |
231 | layout->addWidget( btn, 2, 2 ); | 227 | layout->addWidget( btn, 2, 2 ); |
232 | 228 | ||
233 | return( control ); | 229 | return( control ); |
234 | } | 230 | } |
235 | 231 | ||
236 | QWidget *Checkbook::initCharts() | 232 | QWidget *Checkbook::initCharts() |
237 | { | 233 | { |
238 | graphInfo = 0x0; | 234 | graphInfo = 0x0; |
239 | 235 | ||
240 | QWidget *control = new QWidget( mainWidget ); | 236 | QWidget *control = new QWidget( mainWidget ); |
241 | 237 | ||
242 | QGridLayout *layout = new QGridLayout( control ); | 238 | QGridLayout *layout = new QGridLayout( control ); |
243 | layout->setSpacing( 2 ); | 239 | layout->setSpacing( 2 ); |
244 | layout->setMargin( 4 ); | 240 | layout->setMargin( 4 ); |
245 | 241 | ||
246 | graphWidget = new Graph( control ); | 242 | graphWidget = new Graph( control ); |
247 | QWhatsThis::add( graphWidget, tr( "Select the desired chart below and then click on the Draw button." ) ); | 243 | QWhatsThis::add( graphWidget, tr( "Select the desired chart below and then click on the Draw button." ) ); |
248 | layout->addMultiCellWidget( graphWidget, 0, 0, 0, 2 ); | 244 | layout->addMultiCellWidget( graphWidget, 0, 0, 0, 2 ); |
249 | 245 | ||
250 | graphList = new QComboBox( control ); | 246 | graphList = new QComboBox( control ); |
251 | QWhatsThis::add( graphList, tr( "Click here to select the desired chart type." ) ); | 247 | QWhatsThis::add( graphList, tr( "Click here to select the desired chart type." ) ); |
252 | graphList->insertItem( tr( "Account balance" ) ); | 248 | graphList->insertItem( tr( "Account balance" ) ); |
253 | graphList->insertItem( tr( "Withdrawals by category" ) ); | 249 | graphList->insertItem( tr( "Withdrawals by category" ) ); |
254 | graphList->insertItem( tr( "Deposits by category" ) ); | 250 | graphList->insertItem( tr( "Deposits by category" ) ); |
255 | 251 | ||
256 | layout->addMultiCellWidget( graphList, 1, 1, 0, 1 ); | 252 | layout->addMultiCellWidget( graphList, 1, 1, 0, 1 ); |
257 | 253 | ||
258 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/drawbtn" ), tr( "Draw" ), control ); | 254 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/drawbtn" ), tr( "Draw" ), control ); |
259 | QWhatsThis::add( btn, tr( "Click here to draw the selected chart." ) ); | 255 | QWhatsThis::add( btn, tr( "Click here to draw the selected chart." ) ); |
260 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) ); | 256 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) ); |
261 | layout->addWidget( btn, 1, 2 ); | 257 | layout->addWidget( btn, 1, 2 ); |
262 | 258 | ||
263 | return control; | 259 | return control; |
264 | } | 260 | } |
265 | 261 | ||
266 | void Checkbook::loadCheckbook() | 262 | void Checkbook::loadCheckbook() |
267 | { | 263 | { |
268 | if ( !info ) | 264 | if ( !info ) |
269 | { | 265 | { |
270 | return; | 266 | return; |
271 | } | 267 | } |
272 | 268 | ||
273 | tranList = info->transactions(); | 269 | tranList = info->transactions(); |
274 | 270 | ||
275 | passwordCB->setChecked( !info->password().isNull() ); | 271 | passwordCB->setChecked( !info->password().isNull() ); |
276 | nameEdit->setText( info->name() ); | 272 | nameEdit->setText( info->name() ); |
277 | QString temptext = info->type(); | 273 | QString temptext = info->type(); |
278 | int i = typeList->count(); | 274 | int i = typeList->count(); |
279 | while ( i > 0 ) | 275 | while ( i > 0 ) |
280 | { | 276 | { |
281 | i--; | 277 | i--; |
282 | typeList->setCurrentItem( i ); | 278 | typeList->setCurrentItem( i ); |
283 | if ( typeList->currentText() == temptext ) | 279 | if ( typeList->currentText() == temptext ) |
284 | { | 280 | { |
285 | break; | 281 | break; |
286 | } | 282 | } |
287 | } | 283 | } |
288 | bankEdit->setText( info->bank() ); | 284 | bankEdit->setText( info->bank() ); |
289 | acctNumEdit->setText( info->account() ); | 285 | acctNumEdit->setText( info->account() ); |
290 | pinNumEdit->setText( info->pin() ); | 286 | pinNumEdit->setText( info->pin() ); |
291 | temptext.setNum( info->startingBalance(), 'f', 2 ); | 287 | temptext.setNum( info->startingBalance(), 'f', 2 ); |
292 | balanceEdit->setText( temptext ); | 288 | balanceEdit->setText( temptext ); |
293 | notesEdit->setText( info->notes() ); | 289 | notesEdit->setText( info->notes() ); |
294 | 290 | ||
295 | // Load transactions | 291 | // Load transactions |
296 | float amount; | 292 | float amount; |
297 | QString stramount; | 293 | QString stramount; |
298 | 294 | ||
299 | for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() ) | 295 | for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() ) |
300 | { | 296 | { |
301 | amount = tran->amount(); | 297 | amount = tran->amount(); |
302 | if ( tran->withdrawal() ) | 298 | if ( tran->withdrawal() ) |
303 | { | 299 | { |
304 | amount *= -1; | 300 | amount *= -1; |
305 | } | 301 | } |
306 | stramount.sprintf( "%s%.2f", currencySymbol.latin1(), amount ); | 302 | stramount.sprintf( "%s%.2f", currencySymbol.latin1(), amount ); |
307 | ( void ) new CBListItem( tranTable, tran->number(), tran->datestr(), tran->desc(), stramount ); | 303 | ( void ) new CBListItem( tranTable, tran->number(), tran->datestr(), tran->desc(), stramount ); |
308 | } | 304 | } |
309 | 305 | ||
310 | balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( info->balance(), 0, 'f', 2 ) ); | 306 | balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( info->balance(), 0, 'f', 2 ) ); |
311 | 307 | ||
312 | highTranNum = tranList->count(); | 308 | highTranNum = tranList->count(); |
313 | } | 309 | } |
314 | 310 | ||
315 | void Checkbook::adjustBalance() | 311 | void Checkbook::adjustBalance() |
316 | { | 312 | { |
317 | balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( info->balance(), 0, 'f', 2 ) ); | 313 | balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( info->balance(), 0, 'f', 2 ) ); |
318 | } | 314 | } |
319 | 315 | ||
320 | TranInfo *Checkbook::findTran( const QString &checknum, const QString &date, const QString &desc ) | 316 | TranInfo *Checkbook::findTran( const QString &checknum, const QString &date, const QString &desc ) |
321 | { | 317 | { |
322 | TranInfo *traninfo = tranList->first(); | 318 | TranInfo *traninfo = tranList->first(); |
323 | while ( traninfo ) | 319 | while ( traninfo ) |
324 | { | 320 | { |
325 | if ( traninfo->number() == checknum && traninfo->datestr() == date && | 321 | if ( traninfo->number() == checknum && traninfo->datestr() == date && |
326 | traninfo->desc() == desc ) | 322 | traninfo->desc() == desc ) |
327 | break; | 323 | break; |
328 | traninfo = tranList->next(); | 324 | traninfo = tranList->next(); |
329 | } | 325 | } |
330 | return( traninfo ); | 326 | return( traninfo ); |
331 | } | 327 | } |
332 | 328 | ||
333 | void Checkbook::accept() | 329 | void Checkbook::accept() |
334 | { | 330 | { |
335 | info->setName( nameEdit->text() ); | 331 | info->setName( nameEdit->text() ); |
336 | info->setType( typeList->currentText() ); | 332 | info->setType( typeList->currentText() ); |
337 | info->setBank( bankEdit->text() ); | 333 | info->setBank( bankEdit->text() ); |
338 | info->setAccount( acctNumEdit->text() ); | 334 | info->setAccount( acctNumEdit->text() ); |
339 | info->setPin( pinNumEdit->text() ); | 335 | info->setPin( pinNumEdit->text() ); |
340 | bool ok; | 336 | bool ok; |
341 | info->setStartingBalance( balanceEdit->text().toFloat( &ok ) ); | 337 | info->setStartingBalance( balanceEdit->text().toFloat( &ok ) ); |
342 | info->setNotes( notesEdit->text() ); | 338 | info->setNotes( notesEdit->text() ); |
343 | 339 | ||
344 | QDialog::accept(); | 340 | QDialog::accept(); |
345 | } | 341 | } |
346 | 342 | ||
347 | void Checkbook::slotPasswordClicked() | 343 | void Checkbook::slotPasswordClicked() |
348 | { | 344 | { |
349 | if ( info->password().isNull() && passwordCB->isChecked() ) | 345 | if ( info->password().isNull() && passwordCB->isChecked() ) |
350 | { | 346 | { |
351 | Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); | 347 | Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); |
352 | if ( pw->exec() != QDialog::Accepted ) | 348 | if ( pw->exec() != QDialog::Accepted ) |
353 | { | 349 | { |
354 | passwordCB->setChecked( FALSE ); | 350 | passwordCB->setChecked( FALSE ); |
355 | delete pw; | 351 | delete pw; |
356 | return; | 352 | return; |
357 | } | 353 | } |
358 | info->setPassword( pw->password ); | 354 | info->setPassword( pw->password ); |
359 | delete pw; | 355 | delete pw; |
360 | 356 | ||
361 | pw = new Password( this, tr( "Confirm password" ), tr( "Please confirm your password:" ) ); | 357 | pw = new Password( this, tr( "Confirm password" ), tr( "Please confirm your password:" ) ); |
362 | if ( pw->exec() != QDialog::Accepted || pw->password != info->password() ) | 358 | if ( pw->exec() != QDialog::Accepted || pw->password != info->password() ) |
363 | { | 359 | { |
364 | passwordCB->setChecked( FALSE ); | 360 | passwordCB->setChecked( FALSE ); |
365 | info->setPassword( QString::null ); | 361 | info->setPassword( QString::null ); |
366 | } | 362 | } |
367 | 363 | ||
368 | delete pw; | 364 | delete pw; |
369 | } | 365 | } |
370 | else if ( !info->password().isNull() && !passwordCB->isChecked() ) | 366 | else if ( !info->password().isNull() && !passwordCB->isChecked() ) |
371 | { | 367 | { |
372 | Password *pw = new Password( this, tr( "Enter password" ), | 368 | Password *pw = new Password( this, tr( "Enter password" ), |
373 | tr( "Please enter your password to confirm removal of password protection:" ) ); | 369 | tr( "Please enter your password to confirm removal of password protection:" ) ); |
374 | if ( pw->exec() == QDialog::Accepted && pw->password == info->password() ) | 370 | if ( pw->exec() == QDialog::Accepted && pw->password == info->password() ) |
375 | { | 371 | { |
376 | info->setPassword( QString::null ); | 372 | info->setPassword( QString::null ); |
377 | delete pw; | 373 | delete pw; |
378 | return; | 374 | return; |
379 | } | 375 | } |
380 | else | 376 | else |
381 | { | 377 | { |
382 | passwordCB->setChecked( TRUE ); | 378 | passwordCB->setChecked( TRUE ); |
383 | } | 379 | } |
384 | 380 | ||
385 | delete pw; | 381 | delete pw; |
386 | } | 382 | } |
387 | } | 383 | } |
388 | 384 | ||
389 | void Checkbook::slotNameChanged( const QString &newname ) | 385 | void Checkbook::slotNameChanged( const QString &newname ) |
390 | { | 386 | { |
391 | info->setName( newname ); | 387 | info->setName( newname ); |
392 | 388 | ||
393 | // TODO - need filedir | 389 | // TODO - need filedir |
394 | //QString namestr = filedir; | 390 | //QString namestr = filedir; |
395 | //namestr.append( newname ); | 391 | //namestr.append( newname ); |
396 | //namestr.append( ".qcb" ); | 392 | //namestr.append( ".qcb" ); |
397 | //info->setFilename( namestr ); | 393 | //info->setFilename( namestr ); |
398 | 394 | ||
399 | QString namestr = newname; | 395 | QString namestr = newname; |
400 | namestr.append( " - " ); | 396 | namestr.append( " - " ); |
401 | namestr.append( tr( "Checkbook" ) ); | 397 | namestr.append( tr( "Checkbook" ) ); |
402 | setCaption( namestr ); | 398 | setCaption( namestr ); |
403 | } | 399 | } |
404 | 400 | ||
405 | void Checkbook::slotStartingBalanceChanged( const QString &newbalance ) | 401 | void Checkbook::slotStartingBalanceChanged( const QString &newbalance ) |
406 | { | 402 | { |
407 | bool ok; | 403 | bool ok; |
408 | info->setStartingBalance( newbalance.toFloat( &ok ) ); | 404 | info->setStartingBalance( newbalance.toFloat( &ok ) ); |
409 | adjustBalance(); | 405 | adjustBalance(); |
410 | } | 406 | } |
411 | 407 | ||
412 | void Checkbook::slotNewTran() | 408 | void Checkbook::slotNewTran() |
413 | { | 409 | { |
414 | highTranNum++; | 410 | highTranNum++; |
415 | TranInfo *traninfo = new TranInfo( highTranNum ); | 411 | TranInfo *traninfo = new TranInfo( highTranNum ); |
416 | 412 | ||
417 | Transaction *currtran = new Transaction( this, info->name(), | 413 | Transaction *currtran = new Transaction( this, info->name(), |
418 | traninfo, | 414 | traninfo, |
419 | currencySymbol ); | 415 | currencySymbol ); |
420 | currtran->showMaximized(); | 416 | currtran->showMaximized(); |
421 | if ( currtran->exec() == QDialog::Accepted ) | 417 | if ( currtran->exec() == QDialog::Accepted ) |
422 | { | 418 | { |
423 | // Add to transaction list | 419 | // Add to transaction list |
424 | info->addTransaction( traninfo ); | 420 | info->addTransaction( traninfo ); |
425 | 421 | ||
426 | // Add to transaction table | 422 | // Add to transaction table |
427 | float amount; | 423 | float amount; |
428 | QString stramount; | 424 | QString stramount; |
429 | 425 | ||
430 | amount = traninfo->amount(); | 426 | amount = traninfo->amount(); |
431 | if ( traninfo->withdrawal() ) | 427 | if ( traninfo->withdrawal() ) |
432 | { | 428 | { |
433 | amount *= -1; | 429 | amount *= -1; |
434 | } | 430 | } |
435 | stramount.sprintf( "%s%.2f", currencySymbol.latin1(), amount ); | 431 | stramount.sprintf( "%s%.2f", currencySymbol.latin1(), amount ); |
436 | 432 | ||
437 | ( void ) new CBListItem( tranTable, traninfo->number(), traninfo->datestr(), traninfo->desc(), | 433 | ( void ) new CBListItem( tranTable, traninfo->number(), traninfo->datestr(), traninfo->desc(), |
diff --git a/noncore/apps/checkbook/configuration.cpp b/noncore/apps/checkbook/configuration.cpp index 37208da..7731cf3 100644 --- a/noncore/apps/checkbook/configuration.cpp +++ b/noncore/apps/checkbook/configuration.cpp | |||
@@ -1,76 +1,74 @@ | |||
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 "configuration.h" | 29 | #include "configuration.h" |
30 | 30 | ||
31 | #include <qcheckbox.h> | 31 | #include <qcheckbox.h> |
32 | #include <qfontmetrics.h> | ||
33 | #include <qlabel.h> | 32 | #include <qlabel.h> |
34 | #include <qlayout.h> | 33 | #include <qlayout.h> |
35 | #include <qlineedit.h> | 34 | #include <qlineedit.h> |
36 | #include <qstring.h> | ||
37 | #include <qwhatsthis.h> | 35 | #include <qwhatsthis.h> |
38 | 36 | ||
39 | Configuration::Configuration( QWidget *parent, const QString &cs, bool sl, bool sb ) | 37 | Configuration::Configuration( QWidget *parent, const QString &cs, bool sl, bool sb ) |
40 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) | 38 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) |
41 | { | 39 | { |
42 | setCaption( tr( "Configure Checkbook" ) ); | 40 | setCaption( tr( "Configure Checkbook" ) ); |
43 | 41 | ||
44 | QFontMetrics fm = fontMetrics(); | 42 | QFontMetrics fm = fontMetrics(); |
45 | int fh = fm.height(); | 43 | int fh = fm.height(); |
46 | 44 | ||
47 | QGridLayout *layout = new QGridLayout( this ); | 45 | QGridLayout *layout = new QGridLayout( this ); |
48 | layout->setSpacing( 4 ); | 46 | layout->setSpacing( 4 ); |
49 | layout->setMargin( 4 ); | 47 | layout->setMargin( 4 ); |
50 | 48 | ||
51 | QLabel *label = new QLabel( tr( "Enter currency symbol:" ), this ); | 49 | QLabel *label = new QLabel( tr( "Enter currency symbol:" ), this ); |
52 | QWhatsThis::add( label, tr( "Enter your local currency symbol here." ) ); | 50 | QWhatsThis::add( label, tr( "Enter your local currency symbol here." ) ); |
53 | label->setMaximumHeight( fh + 3 ); | 51 | label->setMaximumHeight( fh + 3 ); |
54 | layout->addWidget( label, 0, 0 ); | 52 | layout->addWidget( label, 0, 0 ); |
55 | 53 | ||
56 | symbolEdit = new QLineEdit( cs, this ); | 54 | symbolEdit = new QLineEdit( cs, this ); |
57 | QWhatsThis::add( symbolEdit, tr( "Enter your local currency symbol here." ) ); | 55 | QWhatsThis::add( symbolEdit, tr( "Enter your local currency symbol here." ) ); |
58 | symbolEdit->setMaximumHeight( fh + 5 ); | 56 | symbolEdit->setMaximumHeight( fh + 5 ); |
59 | symbolEdit->setFocus(); | 57 | symbolEdit->setFocus(); |
60 | layout->addWidget( symbolEdit, 0, 1 ); | 58 | layout->addWidget( symbolEdit, 0, 1 ); |
61 | 59 | ||
62 | lockCB = new QCheckBox( tr( "Show whether checkbook is password\nprotected" ), this ); | 60 | lockCB = new QCheckBox( tr( "Show whether checkbook is password\nprotected" ), this ); |
63 | QWhatsThis::add( lockCB, tr( "Click here to select whether or not the main window will display that the checkbook is protected with a password." ) ); | 61 | QWhatsThis::add( lockCB, tr( "Click here to select whether or not the main window will display that the checkbook is protected with a password." ) ); |
64 | lockCB->setChecked( sl ); | 62 | lockCB->setChecked( sl ); |
65 | layout->addMultiCellWidget( lockCB, 1, 1, 0, 1 ); | 63 | layout->addMultiCellWidget( lockCB, 1, 1, 0, 1 ); |
66 | 64 | ||
67 | balCB = new QCheckBox( tr( "Show checkbook balances" ), this ); | 65 | balCB = new QCheckBox( tr( "Show checkbook balances" ), this ); |
68 | QWhatsThis::add( balCB, tr( "Click here to select whether or not the main window will display the current balance for each checkbook." ) ); | 66 | QWhatsThis::add( balCB, tr( "Click here to select whether or not the main window will display the current balance for each checkbook." ) ); |
69 | balCB->setMaximumHeight( fh + 5 ); | 67 | balCB->setMaximumHeight( fh + 5 ); |
70 | balCB->setChecked( sb ); | 68 | balCB->setChecked( sb ); |
71 | layout->addMultiCellWidget( balCB, 2, 2, 0, 1 ); | 69 | layout->addMultiCellWidget( balCB, 2, 2, 0, 1 ); |
72 | } | 70 | } |
73 | 71 | ||
74 | Configuration::~Configuration() | 72 | Configuration::~Configuration() |
75 | { | 73 | { |
76 | } | 74 | } |
diff --git a/noncore/apps/checkbook/graph.cpp b/noncore/apps/checkbook/graph.cpp index acdb846..389972e 100644 --- a/noncore/apps/checkbook/graph.cpp +++ b/noncore/apps/checkbook/graph.cpp | |||
@@ -1,172 +1,170 @@ | |||
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 "graph.h" | 29 | #include "graph.h" |
30 | #include "graphinfo.h" | 30 | #include "graphinfo.h" |
31 | 31 | ||
32 | #include <qcolor.h> | ||
33 | #include <qfontmetrics.h> | ||
34 | #include <qpainter.h> | 32 | #include <qpainter.h> |
35 | 33 | ||
36 | #include <math.h> | 34 | #include <math.h> |
37 | 35 | ||
38 | Graph::Graph( QWidget *parent, GraphInfo *d, const QString &name, int flags ) | 36 | Graph::Graph( QWidget *parent, GraphInfo *d, const QString &name, int flags ) |
39 | : QWidget( parent, name, flags ) | 37 | : QWidget( parent, name, flags ) |
40 | { | 38 | { |
41 | data = d; | 39 | data = d; |
42 | 40 | ||
43 | graph.setOptimization( QPixmap::BestOptim ); | 41 | graph.setOptimization( QPixmap::BestOptim ); |
44 | } | 42 | } |
45 | 43 | ||
46 | void Graph::setGraphInfo( GraphInfo *d ) | 44 | void Graph::setGraphInfo( GraphInfo *d ) |
47 | { | 45 | { |
48 | data = d; | 46 | data = d; |
49 | } | 47 | } |
50 | 48 | ||
51 | void Graph::drawGraph( bool regen ) | 49 | void Graph::drawGraph( bool regen ) |
52 | { | 50 | { |
53 | if ( regen ) | 51 | if ( regen ) |
54 | { | 52 | { |
55 | initGraph(); | 53 | initGraph(); |
56 | } | 54 | } |
57 | QPainter p( this ); | 55 | QPainter p( this ); |
58 | p.drawPixmap( 0, 0, graph ); | 56 | p.drawPixmap( 0, 0, graph ); |
59 | } | 57 | } |
60 | 58 | ||
61 | void Graph::paintEvent( QPaintEvent * ) | 59 | void Graph::paintEvent( QPaintEvent * ) |
62 | { | 60 | { |
63 | drawGraph( FALSE ); | 61 | drawGraph( FALSE ); |
64 | } | 62 | } |
65 | 63 | ||
66 | void Graph::resizeEvent( QResizeEvent * ) | 64 | void Graph::resizeEvent( QResizeEvent * ) |
67 | { | 65 | { |
68 | drawGraph( TRUE ); | 66 | drawGraph( TRUE ); |
69 | } | 67 | } |
70 | 68 | ||
71 | void Graph::initGraph() | 69 | void Graph::initGraph() |
72 | { | 70 | { |
73 | graph.resize( width(), height() ); | 71 | graph.resize( width(), height() ); |
74 | graph.fill( QColor( 255, 255, 255 ) ); | 72 | graph.fill( QColor( 255, 255, 255 ) ); |
75 | 73 | ||
76 | if ( !data ) | 74 | if ( !data ) |
77 | { | 75 | { |
78 | return; | 76 | return; |
79 | } | 77 | } |
80 | 78 | ||
81 | // Any common stuff here (titles, ???) | 79 | // Any common stuff here (titles, ???) |
82 | 80 | ||
83 | switch ( data->graphType() ) | 81 | switch ( data->graphType() ) |
84 | { | 82 | { |
85 | case GraphInfo::BarChart : | 83 | case GraphInfo::BarChart : |
86 | { | 84 | { |
87 | drawBarChart( width(), height(), data->maxValue() ); | 85 | drawBarChart( width(), height(), data->maxValue() ); |
88 | } | 86 | } |
89 | break; | 87 | break; |
90 | case GraphInfo::PieChart : | 88 | case GraphInfo::PieChart : |
91 | { | 89 | { |
92 | drawPieChart( width(), height(), data->totalValue() ); | 90 | drawPieChart( width(), height(), data->totalValue() ); |
93 | } | 91 | } |
94 | }; | 92 | }; |
95 | } | 93 | } |
96 | 94 | ||
97 | void Graph::drawBarChart( int width, int height, float max ) | 95 | void Graph::drawBarChart( int width, int height, float max ) |
98 | { | 96 | { |
99 | QPainter p( &graph ); | 97 | QPainter p( &graph ); |
100 | 98 | ||
101 | // Try to set the font size smaller for text | 99 | // Try to set the font size smaller for text |
102 | QFont f = font(); | 100 | QFont f = font(); |
103 | f.setPointSize( 8 ); | 101 | f.setPointSize( 8 ); |
104 | p.setFont( f ); | 102 | p.setFont( f ); |
105 | 103 | ||
106 | int x = 0; | 104 | int x = 0; |
107 | int i = 0; | 105 | int i = 0; |
108 | int n = data->numberDataPoints(); | 106 | int n = data->numberDataPoints(); |
109 | QFontMetrics fm=fontMetrics(); | 107 | QFontMetrics fm=fontMetrics(); |
110 | int fh = fm.height(); | 108 | int fh = fm.height(); |
111 | int fw; | 109 | int fw; |
112 | 110 | ||
113 | QColor c( 0, 0, 255); | 111 | QColor c( 0, 0, 255); |
114 | p.setBrush( c ); | 112 | p.setBrush( c ); |
115 | 113 | ||
116 | for (DataPointInfo *dp = data->firstDataPoint(); dp; dp = data->nextDataPoint() ) | 114 | for (DataPointInfo *dp = data->firstDataPoint(); dp; dp = data->nextDataPoint() ) |
117 | { | 115 | { |
118 | int bw = ( width - width / 4 - x ) / ( n - i ); | 116 | int bw = ( width - width / 4 - x ) / ( n - i ); |
119 | int bh = int( ( height - height / 4 - 1 ) * dp->value() / max ); | 117 | int bh = int( ( height - height / 4 - 1 ) * dp->value() / max ); |
120 | p.drawRect( width / 8 + x, height - height / 8 - 1 - bh, bw, bh ); | 118 | p.drawRect( width / 8 + x, height - height / 8 - 1 - bh, bw, bh ); |
121 | fw = fm.width( dp->label() ); | 119 | fw = fm.width( dp->label() ); |
122 | p.drawText( width / 8 + x - fw / 2 + bw / 2, height - height / 8, fw, | 120 | p.drawText( width / 8 + x - fw / 2 + bw / 2, height - height / 8, fw, |
123 | fh + height / 8, AlignTop | AlignHCenter, dp->label() ); | 121 | fh + height / 8, AlignTop | AlignHCenter, dp->label() ); |
124 | // WordBreak | AlignTop | AlignHCenter, dp->label() ); | 122 | // WordBreak | AlignTop | AlignHCenter, dp->label() ); |
125 | i++; | 123 | i++; |
126 | x += bw; | 124 | x += bw; |
127 | } | 125 | } |
128 | } | 126 | } |
129 | 127 | ||
130 | void Graph::drawPieChart( int width, int height, float sum ) | 128 | void Graph::drawPieChart( int width, int height, float sum ) |
131 | { | 129 | { |
132 | QPainter p( &graph ); | 130 | QPainter p( &graph ); |
133 | 131 | ||
134 | // Try to set the font size smaller for text | 132 | // Try to set the font size smaller for text |
135 | QFont f = font(); | 133 | QFont f = font(); |
136 | f.setPointSize( 8 ); | 134 | f.setPointSize( 8 ); |
137 | p.setFont( f ); | 135 | p.setFont( f ); |
138 | 136 | ||
139 | int n = data->numberDataPoints(); | 137 | int n = data->numberDataPoints(); |
140 | 138 | ||
141 | int apos = -90 * 16; | 139 | int apos = -90 * 16; |
142 | 140 | ||
143 | int xd = width - width / 5; | 141 | int xd = width - width / 5; |
144 | int yd = height - height / 5; | 142 | int yd = height - height / 5; |
145 | 143 | ||
146 | int i = 0; | 144 | int i = 0; |
147 | 145 | ||
148 | QColor c; | 146 | QColor c; |
149 | 147 | ||
150 | for (DataPointInfo *dp = data->firstDataPoint(); dp; dp = data->nextDataPoint() ) | 148 | for (DataPointInfo *dp = data->firstDataPoint(); dp; dp = data->nextDataPoint() ) |
151 | { | 149 | { |
152 | c.setHsv( ( i *255) / n, 255, 255 ); | 150 | c.setHsv( ( i *255) / n, 255, 255 ); |
153 | p.setBrush( c ); | 151 | p.setBrush( c ); |
154 | 152 | ||
155 | int a = int( ( dp->value() * 360.0 ) / sum * 16.0 + 0.5 ); | 153 | int a = int( ( dp->value() * 360.0 ) / sum * 16.0 + 0.5 ); |
156 | p.drawPie( width/10, height/10, xd, yd, -apos, -a ); | 154 | p.drawPie( width/10, height/10, xd, yd, -apos, -a ); |
157 | apos += a; | 155 | apos += a; |
158 | i++; | 156 | i++; |
159 | } | 157 | } |
160 | 158 | ||
161 | double apos2 = -90 * 3.14159 / 180; | 159 | double apos2 = -90 * 3.14159 / 180; |
162 | for (DataPointInfo *dp = data->firstDataPoint(); dp; dp = data->nextDataPoint() ) | 160 | for (DataPointInfo *dp = data->firstDataPoint(); dp; dp = data->nextDataPoint() ) |
163 | { | 161 | { |
164 | double a = dp->value() *360 / sum * 3.14159 / 180; | 162 | double a = dp->value() *360 / sum * 3.14159 / 180; |
165 | int x = int( cos( apos2 + a/2 ) * width * 5/16 + width/2 + 0.5 ); | 163 | int x = int( cos( apos2 + a/2 ) * width * 5/16 + width/2 + 0.5 ); |
166 | int y = int( sin( apos2 + a/2 ) * height * 5/16 + height/2 + 0.5 ); | 164 | int y = int( sin( apos2 + a/2 ) * height * 5/16 + height/2 + 0.5 ); |
167 | p.drawText( x - width/8, y - height/8, width/4, height/4, WordBreak | AlignCenter, | 165 | p.drawText( x - width/8, y - height/8, width/4, height/4, WordBreak | AlignCenter, |
168 | dp->label() ); | 166 | dp->label() ); |
169 | apos2 += a; | 167 | apos2 += a; |
170 | } | 168 | } |
171 | } | 169 | } |
172 | 170 | ||
diff --git a/noncore/apps/checkbook/mainwindow.cpp b/noncore/apps/checkbook/mainwindow.cpp index ab1ceef..6d1d7b9 100644 --- a/noncore/apps/checkbook/mainwindow.cpp +++ b/noncore/apps/checkbook/mainwindow.cpp | |||
@@ -1,338 +1,335 @@ | |||
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 "cbinfo.h" | 30 | #include "cbinfo.h" |
31 | #include "configuration.h" | 31 | #include "configuration.h" |
32 | #include "password.h" | 32 | #include "password.h" |
33 | #include "checkbook.h" | 33 | #include "checkbook.h" |
34 | 34 | ||
35 | #include <qpe/config.h> | 35 | #include <qpe/config.h> |
36 | #include <qpe/global.h> | 36 | #include <qpe/global.h> |
37 | #include <qpe/qpeapplication.h> | 37 | #include <qpe/qpeapplication.h> |
38 | #include <qpe/qpemenubar.h> | 38 | #include <qpe/qpemenubar.h> |
39 | #include <qpe/qpemessagebox.h> | 39 | #include <qpe/qpemessagebox.h> |
40 | #include <qpe/qpetoolbar.h> | 40 | #include <qpe/qpetoolbar.h> |
41 | #include <qpe/resource.h> | 41 | #include <qpe/resource.h> |
42 | 42 | ||
43 | #include <qaction.h> | 43 | #include <qaction.h> |
44 | #include <qcheckbox.h> | 44 | #include <qcheckbox.h> |
45 | #include <qdir.h> | 45 | #include <qdir.h> |
46 | #include <qlineedit.h> | 46 | #include <qlineedit.h> |
47 | #include <qlistview.h> | ||
48 | #include <qpopupmenu.h> | ||
49 | #include <qstring.h> | ||
50 | #include <qwhatsthis.h> | 47 | #include <qwhatsthis.h> |
51 | 48 | ||
52 | MainWindow::MainWindow() | 49 | MainWindow::MainWindow() |
53 | : QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) | 50 | : QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) |
54 | { | 51 | { |
55 | setCaption( tr( "Checkbook" ) ); | 52 | setCaption( tr( "Checkbook" ) ); |
56 | 53 | ||
57 | cbDir = Global::applicationFileName( "checkbook", "" ); | 54 | cbDir = Global::applicationFileName( "checkbook", "" ); |
58 | lockIcon = Resource::loadPixmap( "locked" ); | 55 | lockIcon = Resource::loadPixmap( "locked" ); |
59 | 56 | ||
60 | // Load configuration options | 57 | // Load configuration options |
61 | Config config( "checkbook" ); | 58 | Config config( "checkbook" ); |
62 | config.setGroup( "Config" ); | 59 | config.setGroup( "Config" ); |
63 | currencySymbol = config.readEntry( "CurrencySymbol", "$" ); | 60 | currencySymbol = config.readEntry( "CurrencySymbol", "$" ); |
64 | showLocks = config.readBoolEntry( "ShowLocks", FALSE ); | 61 | showLocks = config.readBoolEntry( "ShowLocks", FALSE ); |
65 | showBalances = config.readBoolEntry( "ShowBalances", FALSE ); | 62 | showBalances = config.readBoolEntry( "ShowBalances", FALSE ); |
66 | 63 | ||
67 | // Build menu and tool bars | 64 | // Build menu and tool bars |
68 | setToolBarsMovable( FALSE ); | 65 | setToolBarsMovable( FALSE ); |
69 | 66 | ||
70 | QPEToolBar *bar = new QPEToolBar( this ); | 67 | QPEToolBar *bar = new QPEToolBar( this ); |
71 | bar->setHorizontalStretchable( TRUE ); | 68 | bar->setHorizontalStretchable( TRUE ); |
72 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 69 | QPEMenuBar *mb = new QPEMenuBar( bar ); |
73 | mb->setMargin( 0 ); | 70 | mb->setMargin( 0 ); |
74 | QPopupMenu *popup = new QPopupMenu( this ); | 71 | QPopupMenu *popup = new QPopupMenu( this ); |
75 | 72 | ||
76 | bar = new QPEToolBar( this ); | 73 | bar = new QPEToolBar( this ); |
77 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); | 74 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
78 | a->setWhatsThis( tr( "Click here to create a new checkbook.\n\nYou also can select New from the Checkbook menu." ) ); | 75 | a->setWhatsThis( tr( "Click here to create a new checkbook.\n\nYou also can select New from the Checkbook menu." ) ); |
79 | connect( a, SIGNAL( activated() ), this, SLOT( slotNew() ) ); | 76 | connect( a, SIGNAL( activated() ), this, SLOT( slotNew() ) ); |
80 | a->addTo( popup ); | 77 | a->addTo( popup ); |
81 | a->addTo( bar ); | 78 | a->addTo( bar ); |
82 | 79 | ||
83 | actionOpen = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, | 80 | actionOpen = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, |
84 | 0, this, 0 ); | 81 | 0, this, 0 ); |
85 | 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." ) ); | 82 | 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." ) ); |
86 | connect( actionOpen, SIGNAL( activated() ), this, SLOT( slotEdit() ) ); | 83 | connect( actionOpen, SIGNAL( activated() ), this, SLOT( slotEdit() ) ); |
87 | actionOpen->addTo( popup ); | 84 | actionOpen->addTo( popup ); |
88 | actionOpen->addTo( bar ); | 85 | actionOpen->addTo( bar ); |
89 | 86 | ||
90 | actionDelete = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, | 87 | actionDelete = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, |
91 | 0, this, 0 ); | 88 | 0, this, 0 ); |
92 | actionDelete->setWhatsThis( tr( "Select a checkbook and then click here delete it.\n\nYou also can select Delete from the Checkbook menu." ) ); | 89 | actionDelete->setWhatsThis( tr( "Select a checkbook and then click here delete it.\n\nYou also can select Delete from the Checkbook menu." ) ); |
93 | connect( actionDelete, SIGNAL( activated() ), this, SLOT( slotDelete() ) ); | 90 | connect( actionDelete, SIGNAL( activated() ), this, SLOT( slotDelete() ) ); |
94 | actionDelete->addTo( popup ); | 91 | actionDelete->addTo( popup ); |
95 | actionDelete->addTo( bar ); | 92 | actionDelete->addTo( bar ); |
96 | 93 | ||
97 | popup->insertSeparator(); | 94 | popup->insertSeparator(); |
98 | 95 | ||
99 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); | 96 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); |
100 | a->setWhatsThis( tr( "Click here to configure this app." ) ); | 97 | a->setWhatsThis( tr( "Click here to configure this app." ) ); |
101 | connect( a, SIGNAL( activated() ), this, SLOT( slotConfigure() ) ); | 98 | connect( a, SIGNAL( activated() ), this, SLOT( slotConfigure() ) ); |
102 | a->addTo( popup ); | 99 | a->addTo( popup ); |
103 | a->addTo( bar ); | 100 | a->addTo( bar ); |
104 | 101 | ||
105 | mb->insertItem( tr( "Checkbook" ), popup ); | 102 | mb->insertItem( tr( "Checkbook" ), popup ); |
106 | 103 | ||
107 | // Load Checkbook selection list | 104 | // Load Checkbook selection list |
108 | checkbooks = new CBInfoList(); | 105 | checkbooks = new CBInfoList(); |
109 | 106 | ||
110 | QDir checkdir( cbDir ); | 107 | QDir checkdir( cbDir ); |
111 | if (checkdir.exists() == true) | 108 | if (checkdir.exists() == true) |
112 | { | 109 | { |
113 | QStringList cblist = checkdir.entryList( "*.qcb", QDir::Files|QDir::Readable|QDir::Writable, | 110 | QStringList cblist = checkdir.entryList( "*.qcb", QDir::Files|QDir::Readable|QDir::Writable, |
114 | QDir::Time ); | 111 | QDir::Time ); |
115 | CBInfo *cb = 0x0; | 112 | CBInfo *cb = 0x0; |
116 | QString filename; | 113 | QString filename; |
117 | 114 | ||
118 | for ( QStringList::Iterator it = cblist.begin(); it != cblist.end(); it++ ) | 115 | for ( QStringList::Iterator it = cblist.begin(); it != cblist.end(); it++ ) |
119 | { | 116 | { |
120 | filename = cbDir; | 117 | filename = cbDir; |
121 | filename.append( (*it) ); | 118 | filename.append( (*it) ); |
122 | 119 | ||
123 | cb = new CBInfo( (*it).remove( (*it).find('.'), (*it).length() ), filename ); | 120 | cb = new CBInfo( (*it).remove( (*it).find('.'), (*it).length() ), filename ); |
124 | checkbooks->inSort( cb ); | 121 | checkbooks->inSort( cb ); |
125 | } | 122 | } |
126 | } | 123 | } |
127 | 124 | ||
128 | // Build Checkbook selection list control | 125 | // Build Checkbook selection list control |
129 | cbList = 0x0; | 126 | cbList = 0x0; |
130 | buildList(); | 127 | buildList(); |
131 | } | 128 | } |
132 | 129 | ||
133 | MainWindow::~MainWindow() | 130 | MainWindow::~MainWindow() |
134 | { | 131 | { |
135 | //config.write(); | 132 | //config.write(); |
136 | } | 133 | } |
137 | 134 | ||
138 | void MainWindow::buildList() | 135 | void MainWindow::buildList() |
139 | { | 136 | { |
140 | if ( cbList ) | 137 | if ( cbList ) |
141 | { | 138 | { |
142 | delete cbList; | 139 | delete cbList; |
143 | } | 140 | } |
144 | 141 | ||
145 | cbList = new QListView( this ); | 142 | cbList = new QListView( this ); |
146 | QWhatsThis::add( cbList, tr( "This is a listing of all checkbooks currently available." ) ); | 143 | QWhatsThis::add( cbList, tr( "This is a listing of all checkbooks currently available." ) ); |
147 | 144 | ||
148 | if ( showLocks ) | 145 | if ( showLocks ) |
149 | { | 146 | { |
150 | cbList->addColumn( Resource::loadIconSet( "locked" ), "", 24 ); | 147 | cbList->addColumn( Resource::loadIconSet( "locked" ), "", 24 ); |
151 | posName = 1; | 148 | posName = 1; |
152 | } | 149 | } |
153 | else | 150 | else |
154 | { | 151 | { |
155 | posName = 0; | 152 | posName = 0; |
156 | } | 153 | } |
157 | cbList->addColumn( tr( "Checkbook Name" ) ); | 154 | cbList->addColumn( tr( "Checkbook Name" ) ); |
158 | if ( showBalances ) | 155 | if ( showBalances ) |
159 | { | 156 | { |
160 | int colnum = cbList->addColumn( tr( "Balance" ) ); | 157 | int colnum = cbList->addColumn( tr( "Balance" ) ); |
161 | cbList->setColumnAlignment( colnum, Qt::AlignRight ); | 158 | cbList->setColumnAlignment( colnum, Qt::AlignRight ); |
162 | } | 159 | } |
163 | cbList->setAllColumnsShowFocus( TRUE ); | 160 | cbList->setAllColumnsShowFocus( TRUE ); |
164 | cbList->setSorting( posName ); | 161 | cbList->setSorting( posName ); |
165 | QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold ); | 162 | QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold ); |
166 | connect( cbList, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), | 163 | connect( cbList, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), |
167 | this, SLOT( slotEdit() ) ); | 164 | this, SLOT( slotEdit() ) ); |
168 | setCentralWidget( cbList ); | 165 | setCentralWidget( cbList ); |
169 | 166 | ||
170 | for ( CBInfo *cb = checkbooks->first(); cb; cb = checkbooks->next() ) | 167 | for ( CBInfo *cb = checkbooks->first(); cb; cb = checkbooks->next() ) |
171 | { | 168 | { |
172 | addCheckbook( cb ); | 169 | addCheckbook( cb ); |
173 | } | 170 | } |
174 | } | 171 | } |
175 | 172 | ||
176 | void MainWindow::addCheckbook( CBInfo *cb ) | 173 | void MainWindow::addCheckbook( CBInfo *cb ) |
177 | { | 174 | { |
178 | QListViewItem *lvi = new QListViewItem( cbList ); | 175 | QListViewItem *lvi = new QListViewItem( cbList ); |
179 | if ( showLocks && !cb->password().isNull() ) | 176 | if ( showLocks && !cb->password().isNull() ) |
180 | { | 177 | { |
181 | lvi->setPixmap( 0, lockIcon ); | 178 | lvi->setPixmap( 0, lockIcon ); |
182 | } | 179 | } |
183 | lvi->setText( posName, cb->name() ); | 180 | lvi->setText( posName, cb->name() ); |
184 | if ( showBalances ) | 181 | if ( showBalances ) |
185 | { | 182 | { |
186 | QString balance; | 183 | QString balance; |
187 | balance.sprintf( "%s%.2f", currencySymbol.latin1(), cb->balance() ); | 184 | balance.sprintf( "%s%.2f", currencySymbol.latin1(), cb->balance() ); |
188 | lvi->setText( posName + 1, balance ); | 185 | lvi->setText( posName + 1, balance ); |
189 | } | 186 | } |
190 | } | 187 | } |
191 | 188 | ||
192 | void MainWindow::buildFilename( const QString &name ) | 189 | void MainWindow::buildFilename( const QString &name ) |
193 | { | 190 | { |
194 | tempFilename = cbDir; | 191 | tempFilename = cbDir; |
195 | tempFilename.append( name ); | 192 | tempFilename.append( name ); |
196 | tempFilename.append( ".qcb" ); | 193 | tempFilename.append( ".qcb" ); |
197 | } | 194 | } |
198 | 195 | ||
199 | void MainWindow::slotNew() | 196 | void MainWindow::slotNew() |
200 | { | 197 | { |
201 | CBInfo *cb = new CBInfo(); | 198 | CBInfo *cb = new CBInfo(); |
202 | 199 | ||
203 | Checkbook *currcb = new Checkbook( this, cb, currencySymbol ); | 200 | Checkbook *currcb = new Checkbook( this, cb, currencySymbol ); |
204 | currcb->showMaximized(); | 201 | currcb->showMaximized(); |
205 | if ( currcb->exec() == QDialog::Accepted ) | 202 | if ( currcb->exec() == QDialog::Accepted ) |
206 | { | 203 | { |
207 | // Save new checkbook | 204 | // Save new checkbook |
208 | buildFilename( cb->name() ); | 205 | buildFilename( cb->name() ); |
209 | cb->setFilename( tempFilename ); | 206 | cb->setFilename( tempFilename ); |
210 | cb->write(); | 207 | cb->write(); |
211 | 208 | ||
212 | // Add to listbox | 209 | // Add to listbox |
213 | checkbooks->inSort( cb ); | 210 | checkbooks->inSort( cb ); |
214 | addCheckbook( cb ); | 211 | addCheckbook( cb ); |
215 | } | 212 | } |
216 | delete currcb; | 213 | delete currcb; |
217 | } | 214 | } |
218 | 215 | ||
219 | void MainWindow::slotEdit() | 216 | void MainWindow::slotEdit() |
220 | { | 217 | { |
221 | 218 | ||
222 | QListViewItem *curritem = cbList->currentItem(); | 219 | QListViewItem *curritem = cbList->currentItem(); |
223 | if ( !curritem ) | 220 | if ( !curritem ) |
224 | { | 221 | { |
225 | return; | 222 | return; |
226 | } | 223 | } |
227 | QString currname = curritem->text( posName ); | 224 | QString currname = curritem->text( posName ); |
228 | 225 | ||
229 | CBInfo *cb = checkbooks->first(); | 226 | CBInfo *cb = checkbooks->first(); |
230 | while ( cb ) | 227 | while ( cb ) |
231 | { | 228 | { |
232 | if ( cb->name() == currname ) | 229 | if ( cb->name() == currname ) |
233 | break; | 230 | break; |
234 | cb = checkbooks->next(); | 231 | cb = checkbooks->next(); |
235 | } | 232 | } |
236 | if ( !cb ) | 233 | if ( !cb ) |
237 | { | 234 | { |
238 | return; | 235 | return; |
239 | } | 236 | } |
240 | 237 | ||
241 | buildFilename( currname ); | 238 | buildFilename( currname ); |
242 | float currbalance = cb->balance(); | 239 | float currbalance = cb->balance(); |
243 | bool currlock = !cb->password().isNull(); | 240 | bool currlock = !cb->password().isNull(); |
244 | 241 | ||
245 | if ( currlock ) | 242 | if ( currlock ) |
246 | { | 243 | { |
247 | Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); | 244 | Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); |
248 | if ( pw->exec() != QDialog::Accepted || pw->password != cb->password() ) | 245 | if ( pw->exec() != QDialog::Accepted || pw->password != cb->password() ) |
249 | { | 246 | { |
250 | delete pw; | 247 | delete pw; |
251 | return; | 248 | return; |
252 | } | 249 | } |
253 | delete pw; | 250 | delete pw; |
254 | } | 251 | } |
255 | 252 | ||
256 | Checkbook *currcb = new Checkbook( this, cb, currencySymbol ); | 253 | Checkbook *currcb = new Checkbook( this, cb, currencySymbol ); |
257 | currcb->showMaximized(); | 254 | currcb->showMaximized(); |
258 | if ( currcb->exec() == QDialog::Accepted ) | 255 | if ( currcb->exec() == QDialog::Accepted ) |
259 | { | 256 | { |
260 | QString newname = cb->name(); | 257 | QString newname = cb->name(); |
261 | if ( currname != newname ) | 258 | if ( currname != newname ) |
262 | { | 259 | { |
263 | // Update name if changed | 260 | // Update name if changed |
264 | curritem->setText( posName, newname ); | 261 | curritem->setText( posName, newname ); |
265 | cbList->sort(); | 262 | cbList->sort(); |
266 | 263 | ||
267 | // Remove old file | 264 | // Remove old file |
268 | QFile f( tempFilename ); | 265 | QFile f( tempFilename ); |
269 | if ( f.exists() ) | 266 | if ( f.exists() ) |
270 | { | 267 | { |
271 | f.remove(); | 268 | f.remove(); |
272 | } | 269 | } |
273 | 270 | ||
274 | // Get new filename | 271 | // Get new filename |
275 | buildFilename( newname ); | 272 | buildFilename( newname ); |
276 | cb->setFilename( tempFilename ); | 273 | cb->setFilename( tempFilename ); |
277 | } | 274 | } |
278 | 275 | ||
279 | cb->write(); | 276 | cb->write(); |
280 | 277 | ||
281 | // Update lock if changed | 278 | // Update lock if changed |
282 | if ( showLocks && !cb->password().isNull() != currlock ) | 279 | if ( showLocks && !cb->password().isNull() != currlock ) |
283 | { | 280 | { |
284 | if ( !cb->password().isNull() ) | 281 | if ( !cb->password().isNull() ) |
285 | curritem->setPixmap( 0, lockIcon ); | 282 | curritem->setPixmap( 0, lockIcon ); |
286 | else | 283 | else |
287 | curritem->setPixmap( 0, nullIcon ); | 284 | curritem->setPixmap( 0, nullIcon ); |
288 | } | 285 | } |
289 | 286 | ||
290 | // Update balance if changed | 287 | // Update balance if changed |
291 | if ( showBalances && cb->balance() != currbalance ) | 288 | if ( showBalances && cb->balance() != currbalance ) |
292 | { | 289 | { |
293 | QString tempstr; | 290 | QString tempstr; |
294 | tempstr.sprintf( "%s%.2f", currencySymbol.latin1(), cb->balance() ); | 291 | tempstr.sprintf( "%s%.2f", currencySymbol.latin1(), cb->balance() ); |
295 | curritem->setText( posName + 1, tempstr ); | 292 | curritem->setText( posName + 1, tempstr ); |
296 | } | 293 | } |
297 | } | 294 | } |
298 | delete currcb; | 295 | delete currcb; |
299 | } | 296 | } |
300 | 297 | ||
301 | void MainWindow::slotDelete() | 298 | void MainWindow::slotDelete() |
302 | { | 299 | { |
303 | QString currname = cbList->currentItem()->text( posName ); | 300 | QString currname = cbList->currentItem()->text( posName ); |
304 | 301 | ||
305 | if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), currname ) ) | 302 | if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), currname ) ) |
306 | { | 303 | { |
307 | buildFilename( currname ); | 304 | buildFilename( currname ); |
308 | QFile f( tempFilename ); | 305 | QFile f( tempFilename ); |
309 | if ( f.exists() ) | 306 | if ( f.exists() ) |
310 | { | 307 | { |
311 | f.remove(); | 308 | f.remove(); |
312 | } | 309 | } |
313 | 310 | ||
314 | delete cbList->currentItem(); | 311 | delete cbList->currentItem(); |
315 | } | 312 | } |
316 | } | 313 | } |
317 | 314 | ||
318 | void MainWindow::slotConfigure() | 315 | void MainWindow::slotConfigure() |
319 | { | 316 | { |
320 | Configuration *cfgdlg = new Configuration( this, currencySymbol, showLocks, showBalances ); | 317 | Configuration *cfgdlg = new Configuration( this, currencySymbol, showLocks, showBalances ); |
321 | cfgdlg->showMaximized(); | 318 | cfgdlg->showMaximized(); |
322 | if ( cfgdlg->exec() == QDialog::Accepted ) | 319 | if ( cfgdlg->exec() == QDialog::Accepted ) |
323 | { | 320 | { |
324 | currencySymbol = cfgdlg->symbolEdit->text(); | 321 | currencySymbol = cfgdlg->symbolEdit->text(); |
325 | showLocks = cfgdlg->lockCB->isChecked(); | 322 | showLocks = cfgdlg->lockCB->isChecked(); |
326 | showBalances = cfgdlg->balCB->isChecked(); | 323 | showBalances = cfgdlg->balCB->isChecked(); |
327 | 324 | ||
328 | Config config( "checkbook" ); | 325 | Config config( "checkbook" ); |
329 | config.setGroup( "Config" ); | 326 | config.setGroup( "Config" ); |
330 | config.writeEntry( "CurrencySymbol", currencySymbol ); | 327 | config.writeEntry( "CurrencySymbol", currencySymbol ); |
331 | config.writeEntry( "ShowLocks", showLocks ); | 328 | config.writeEntry( "ShowLocks", showLocks ); |
332 | config.writeEntry( "ShowBalances", showBalances ); | 329 | config.writeEntry( "ShowBalances", showBalances ); |
333 | config.write(); | 330 | config.write(); |
334 | 331 | ||
335 | buildList(); | 332 | buildList(); |
336 | } | 333 | } |
337 | delete cfgdlg; | 334 | delete cfgdlg; |
338 | } | 335 | } |
diff --git a/noncore/apps/checkbook/password.cpp b/noncore/apps/checkbook/password.cpp index 82020d5..f381271 100644 --- a/noncore/apps/checkbook/password.cpp +++ b/noncore/apps/checkbook/password.cpp | |||
@@ -1,99 +1,97 @@ | |||
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 "password.h" | 29 | #include "password.h" |
30 | 30 | ||
31 | #include <qlabel.h> | 31 | #include <qlabel.h> |
32 | #include <qlayout.h> | 32 | #include <qlayout.h> |
33 | #include <qlineedit.h> | 33 | #include <qlineedit.h> |
34 | #include <qpixmap.h> | ||
35 | #include <qpushbutton.h> | 34 | #include <qpushbutton.h> |
36 | #include <qwidget.h> | ||
37 | 35 | ||
38 | static const char* const showhideimage_data[] = { | 36 | static const char* const showhideimage_data[] = { |
39 | "16 16 2 1", | 37 | "16 16 2 1", |
40 | ". c None", | 38 | ". c None", |
41 | "# c #000000", | 39 | "# c #000000", |
42 | "................", | 40 | "................", |
43 | "...#...###...##.", | 41 | "...#...###...##.", |
44 | "..#.#..#..#.##..", | 42 | "..#.#..#..#.##..", |
45 | "..###..###.##...", | 43 | "..###..###.##...", |
46 | ".#...#.#..##....", | 44 | ".#...#.#..##....", |
47 | ".#...#.#.##.....", | 45 | ".#...#.#.##.....", |
48 | "........##.#..#.", | 46 | "........##.#..#.", |
49 | "..##...##...##..", | 47 | "..##...##...##..", |
50 | ".#..#.###...##..", | 48 | ".#..#.###...##..", |
51 | ".#...##..#.#..#.", | 49 | ".#...##..#.#..#.", |
52 | ".#..##..........", | 50 | ".#..##..........", |
53 | ".#.##.#..#.#..#.", | 51 | ".#.##.#..#.#..#.", |
54 | "..##...##...##..", | 52 | "..##...##...##..", |
55 | ".##....##...##..", | 53 | ".##....##...##..", |
56 | ".#....#..#.#..#.", | 54 | ".#....#..#.#..#.", |
57 | "................"}; | 55 | "................"}; |
58 | 56 | ||
59 | Password::Password( QWidget *parent, const char *caption, const char *prompt ) | 57 | Password::Password( QWidget *parent, const char *caption, const char *prompt ) |
60 | : QDialog( parent, 0x0, TRUE, 0x0 ) | 58 | : QDialog( parent, 0x0, TRUE, 0x0 ) |
61 | { | 59 | { |
62 | setCaption( caption ); | 60 | setCaption( caption ); |
63 | 61 | ||
64 | QGridLayout *layout = new QGridLayout( this ); | 62 | QGridLayout *layout = new QGridLayout( this ); |
65 | layout->setSpacing( 2 ); | 63 | layout->setSpacing( 2 ); |
66 | layout->setMargin( 4 ); | 64 | layout->setMargin( 4 ); |
67 | 65 | ||
68 | QLabel *label = new QLabel( prompt, this ); | 66 | QLabel *label = new QLabel( prompt, this ); |
69 | label->setAlignment( AlignLeft | AlignTop | WordBreak ); | 67 | label->setAlignment( AlignLeft | AlignTop | WordBreak ); |
70 | layout->addMultiCellWidget( label, 0, 0, 0, 1 ); | 68 | layout->addMultiCellWidget( label, 0, 0, 0, 1 ); |
71 | 69 | ||
72 | pw = new QLineEdit( this ); | 70 | pw = new QLineEdit( this ); |
73 | pw->setEchoMode( QLineEdit::Password ); | 71 | pw->setEchoMode( QLineEdit::Password ); |
74 | layout->addWidget( pw, 1, 0 ); | 72 | layout->addWidget( pw, 1, 0 ); |
75 | 73 | ||
76 | QPixmap *pic = new QPixmap( ( const char** ) showhideimage_data ); | 74 | QPixmap *pic = new QPixmap( ( const char** ) showhideimage_data ); |
77 | QPushButton *btn = new QPushButton( ( QIconSet ) *pic, QString::null, this ); | 75 | QPushButton *btn = new QPushButton( ( QIconSet ) *pic, QString::null, this ); |
78 | btn->setMaximumSize( pic->width() + 10, pic->height() + 10 ); | 76 | btn->setMaximumSize( pic->width() + 10, pic->height() + 10 ); |
79 | btn->setToggleButton( TRUE ); | 77 | btn->setToggleButton( TRUE ); |
80 | connect( btn, SIGNAL( toggled( bool ) ), this, SLOT( slotTogglePassword( bool ) ) ); | 78 | connect( btn, SIGNAL( toggled( bool ) ), this, SLOT( slotTogglePassword( bool ) ) ); |
81 | layout->addWidget( btn, 1, 1 ); | 79 | layout->addWidget( btn, 1, 1 ); |
82 | 80 | ||
83 | password == ""; | 81 | password == ""; |
84 | } | 82 | } |
85 | 83 | ||
86 | Password::~Password() | 84 | Password::~Password() |
87 | { | 85 | { |
88 | } | 86 | } |
89 | 87 | ||
90 | void Password::accept() | 88 | void Password::accept() |
91 | { | 89 | { |
92 | password = pw->text(); | 90 | password = pw->text(); |
93 | QDialog::accept(); | 91 | QDialog::accept(); |
94 | } | 92 | } |
95 | 93 | ||
96 | void Password::slotTogglePassword( bool showPW ) | 94 | void Password::slotTogglePassword( bool showPW ) |
97 | { | 95 | { |
98 | showPW ? pw->setEchoMode( QLineEdit::Normal ) : pw->setEchoMode( QLineEdit::Password ); | 96 | showPW ? pw->setEchoMode( QLineEdit::Normal ) : pw->setEchoMode( QLineEdit::Password ); |
99 | } | 97 | } |
diff --git a/noncore/apps/checkbook/traninfo.h b/noncore/apps/checkbook/traninfo.h index 5f67262..f6c5cae 100644 --- a/noncore/apps/checkbook/traninfo.h +++ b/noncore/apps/checkbook/traninfo.h | |||
@@ -1,90 +1,89 @@ | |||
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 TRANINFO_H | 29 | #ifndef TRANINFO_H |
30 | #define TRANINFO_H | 30 | #define TRANINFO_H |
31 | 31 | ||
32 | #include <qdatetime.h> | 32 | #include <qdatetime.h> |
33 | #include <qlist.h> | 33 | #include <qlist.h> |
34 | #include <qstring.h> | ||
35 | 34 | ||
36 | class Config; | 35 | class Config; |
37 | 36 | ||
38 | class TranInfo | 37 | class TranInfo |
39 | { | 38 | { |
40 | public: | 39 | public: |
41 | TranInfo( int = 0, const QString & = 0x0, const QDate & = QDate::currentDate(), | 40 | TranInfo( int = 0, const QString & = 0x0, const QDate & = QDate::currentDate(), |
42 | bool = TRUE, const QString & = 0x0, const QString & = 0x0, | 41 | bool = TRUE, const QString & = 0x0, const QString & = 0x0, |
43 | float = 0.0, float = 0.0, | 42 | float = 0.0, float = 0.0, |
44 | const QString & = 0x0, const QString & = 0x0 ); | 43 | const QString & = 0x0, const QString & = 0x0 ); |
45 | TranInfo( Config, int ); | 44 | TranInfo( Config, int ); |
46 | 45 | ||
47 | int id() const { return i; } | 46 | int id() const { return i; } |
48 | const QString &desc() const { return d; } | 47 | const QString &desc() const { return d; } |
49 | const QDate &date() const { return td; } | 48 | const QDate &date() const { return td; } |
50 | const QString &datestr(); | 49 | const QString &datestr(); |
51 | bool withdrawal()const { return w; } | 50 | bool withdrawal()const { return w; } |
52 | const QString &type() const { return t; } | 51 | const QString &type() const { return t; } |
53 | const QString &category()const { return c; } | 52 | const QString &category()const { return c; } |
54 | float amount() const { return a; } | 53 | float amount() const { return a; } |
55 | float fee() const { return f; } | 54 | float fee() const { return f; } |
56 | const QString &number()const { return cn; } | 55 | const QString &number()const { return cn; } |
57 | const QString ¬es() const { return n; } | 56 | const QString ¬es() const { return n; } |
58 | 57 | ||
59 | void setDesc( const QString &desc ) { d = desc; } | 58 | void setDesc( const QString &desc ) { d = desc; } |
60 | void setDate( const QDate &date ) { td = date; } | 59 | void setDate( const QDate &date ) { td = date; } |
61 | void setWithdrawal( bool withdrawal ) { w = withdrawal; } | 60 | void setWithdrawal( bool withdrawal ) { w = withdrawal; } |
62 | void setType( const QString &type ) { t = type; } | 61 | void setType( const QString &type ) { t = type; } |
63 | void setCategory( const QString &cat ){ c = cat; } | 62 | void setCategory( const QString &cat ){ c = cat; } |
64 | void setAmount( float amount ) { a = amount; } | 63 | void setAmount( float amount ) { a = amount; } |
65 | void setFee( float fee ) { f = fee; } | 64 | void setFee( float fee ) { f = fee; } |
66 | void setNumber( const QString &num ) { cn = num; } | 65 | void setNumber( const QString &num ) { cn = num; } |
67 | void setNotes( const QString ¬es ) { n = notes; } | 66 | void setNotes( const QString ¬es ) { n = notes; } |
68 | 67 | ||
69 | void write( Config *, int ); | 68 | void write( Config *, int ); |
70 | 69 | ||
71 | private: | 70 | private: |
72 | int i; | 71 | int i; |
73 | QString d; | 72 | QString d; |
74 | QDate td; | 73 | QDate td; |
75 | bool w; | 74 | bool w; |
76 | QString t; | 75 | QString t; |
77 | QString c; | 76 | QString c; |
78 | float a; | 77 | float a; |
79 | float f; | 78 | float f; |
80 | QString cn; | 79 | QString cn; |
81 | QString n; | 80 | QString n; |
82 | }; | 81 | }; |
83 | 82 | ||
84 | class TranInfoList : public QList<TranInfo> | 83 | class TranInfoList : public QList<TranInfo> |
85 | { | 84 | { |
86 | protected: | 85 | protected: |
87 | int compareItems( QCollection::Item, QCollection::Item ); | 86 | int compareItems( QCollection::Item, QCollection::Item ); |
88 | }; | 87 | }; |
89 | 88 | ||
90 | #endif | 89 | #endif |
diff --git a/noncore/apps/checkbook/transaction.cpp b/noncore/apps/checkbook/transaction.cpp index 17be669..07d5ae1 100644 --- a/noncore/apps/checkbook/transaction.cpp +++ b/noncore/apps/checkbook/transaction.cpp | |||
@@ -1,279 +1,274 @@ | |||
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> | ||
34 | 33 | ||
35 | #include <qbuttongroup.h> | 34 | #include <qbuttongroup.h> |
36 | #include <qcombobox.h> | 35 | #include <qcombobox.h> |
37 | #include <qlabel.h> | 36 | #include <qlabel.h> |
38 | #include <qlayout.h> | 37 | #include <qlayout.h> |
39 | #include <qlineedit.h> | 38 | #include <qlineedit.h> |
40 | #include <qmultilineedit.h> | 39 | #include <qmultilineedit.h> |
41 | #include <qpopupmenu.h> | ||
42 | #include <qpushbutton.h> | ||
43 | #include <qradiobutton.h> | 40 | #include <qradiobutton.h> |
44 | #include <qscrollview.h> | ||
45 | #include <qstring.h> | ||
46 | #include <qwhatsthis.h> | 41 | #include <qwhatsthis.h> |
47 | 42 | ||
48 | Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *info, | 43 | Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *info, |
49 | const QString &symbol ) | 44 | const QString &symbol ) |
50 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) | 45 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) |
51 | { | 46 | { |
52 | QString tempstr = tr( "Transaction for " ); | 47 | QString tempstr = tr( "Transaction for " ); |
53 | tempstr.append( acctname ); | 48 | tempstr.append( acctname ); |
54 | setCaption( tempstr ); | 49 | setCaption( tempstr ); |
55 | 50 | ||
56 | tran = info; | 51 | tran = info; |
57 | currencySymbol = symbol; | 52 | currencySymbol = symbol; |
58 | 53 | ||
59 | QVBoxLayout *vb = new QVBoxLayout( this ); | 54 | QVBoxLayout *vb = new QVBoxLayout( this ); |
60 | 55 | ||
61 | QScrollView *sv = new QScrollView( this ); | 56 | QScrollView *sv = new QScrollView( this ); |
62 | vb->addWidget( sv, 0, 0 ); | 57 | vb->addWidget( sv, 0, 0 ); |
63 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 58 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
64 | sv->setFrameStyle( QFrame::NoFrame ); | 59 | sv->setFrameStyle( QFrame::NoFrame ); |
65 | 60 | ||
66 | QWidget *container = new QWidget( sv->viewport() ); | 61 | QWidget *container = new QWidget( sv->viewport() ); |
67 | sv->addChild( container ); | 62 | sv->addChild( container ); |
68 | 63 | ||
69 | QGridLayout *layout = new QGridLayout( container ); | 64 | QGridLayout *layout = new QGridLayout( container ); |
70 | layout->setSpacing( 2 ); | 65 | layout->setSpacing( 2 ); |
71 | layout->setMargin( 4 ); | 66 | layout->setMargin( 4 ); |
72 | 67 | ||
73 | // Withdrawal/Deposit | 68 | // Withdrawal/Deposit |
74 | QButtonGroup *btngrp = new QButtonGroup( container ); | 69 | QButtonGroup *btngrp = new QButtonGroup( container ); |
75 | btngrp->setColumnLayout(0, Qt::Vertical ); | 70 | btngrp->setColumnLayout(0, Qt::Vertical ); |
76 | btngrp->layout()->setSpacing( 0 ); | 71 | btngrp->layout()->setSpacing( 0 ); |
77 | btngrp->layout()->setMargin( 0 ); | 72 | btngrp->layout()->setMargin( 0 ); |
78 | btngrp->setMaximumWidth( 220 ); | 73 | btngrp->setMaximumWidth( 220 ); |
79 | QGridLayout *layout2 = new QGridLayout( btngrp->layout() ); | 74 | QGridLayout *layout2 = new QGridLayout( btngrp->layout() ); |
80 | layout2->setSpacing( 2 ); | 75 | layout2->setSpacing( 2 ); |
81 | layout2->setMargin( 2 ); | 76 | layout2->setMargin( 2 ); |
82 | withBtn = new QRadioButton( tr( "Withdrawal" ), btngrp ); | 77 | withBtn = new QRadioButton( tr( "Withdrawal" ), btngrp ); |
83 | QWhatsThis::add( withBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) ); | 78 | QWhatsThis::add( withBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) ); |
84 | layout2->addWidget( withBtn, 0, 0 ); | 79 | layout2->addWidget( withBtn, 0, 0 ); |
85 | connect( withBtn, SIGNAL( clicked() ), this, SLOT( slotWithdrawalClicked() ) ); | 80 | connect( withBtn, SIGNAL( clicked() ), this, SLOT( slotWithdrawalClicked() ) ); |
86 | depBtn = new QRadioButton( tr( "Deposit" ), btngrp ); | 81 | depBtn = new QRadioButton( tr( "Deposit" ), btngrp ); |
87 | QWhatsThis::add( depBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) ); | 82 | QWhatsThis::add( depBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) ); |
88 | layout2->addWidget( depBtn, 0, 1 ); | 83 | layout2->addWidget( depBtn, 0, 1 ); |
89 | btngrp->setMaximumSize( 320, withBtn->height() ); | 84 | btngrp->setMaximumSize( 320, withBtn->height() ); |
90 | connect( depBtn, SIGNAL( clicked() ), this, SLOT( slotDepositClicked() ) ); | 85 | connect( depBtn, SIGNAL( clicked() ), this, SLOT( slotDepositClicked() ) ); |
91 | layout->addMultiCellWidget( btngrp, 0, 0, 0, 3 ); | 86 | layout->addMultiCellWidget( btngrp, 0, 0, 0, 3 ); |
92 | 87 | ||
93 | // Date | 88 | // Date |
94 | QLabel *label = new QLabel( tr( "Date:" ), container ); | 89 | QLabel *label = new QLabel( tr( "Date:" ), container ); |
95 | QWhatsThis::add( label, tr( "Select date of transaction here." ) ); | 90 | QWhatsThis::add( label, tr( "Select date of transaction here." ) ); |
96 | layout->addWidget( label, 1, 0 ); | 91 | layout->addWidget( label, 1, 0 ); |
97 | dateBtn = new QPushButton( TimeString::shortDate( QDate::currentDate() ), | 92 | dateBtn = new QPushButton( TimeString::shortDate( QDate::currentDate() ), |
98 | container ); | 93 | container ); |
99 | QWhatsThis::add( dateBtn, tr( "Select date of transaction here." ) ); | 94 | QWhatsThis::add( dateBtn, tr( "Select date of transaction here." ) ); |
100 | QPopupMenu *m1 = new QPopupMenu( container ); | 95 | QPopupMenu *m1 = new QPopupMenu( container ); |
101 | datePicker = new DateBookMonth( m1, 0, TRUE ); | 96 | datePicker = new DateBookMonth( m1, 0, TRUE ); |
102 | m1->insertItem( datePicker ); | 97 | m1->insertItem( datePicker ); |
103 | dateBtn->setPopup( m1 ); | 98 | dateBtn->setPopup( m1 ); |
104 | connect( datePicker, SIGNAL( dateClicked( int, int, int ) ), | 99 | connect( datePicker, SIGNAL( dateClicked( int, int, int ) ), |
105 | this, SLOT( slotDateChanged( int, int, int ) ) ); | 100 | this, SLOT( slotDateChanged( int, int, int ) ) ); |
106 | layout->addWidget( dateBtn, 1, 1 ); | 101 | layout->addWidget( dateBtn, 1, 1 ); |
107 | 102 | ||
108 | // Check number | 103 | // Check number |
109 | label = new QLabel( tr( "Number:" ), container ); | 104 | label = new QLabel( tr( "Number:" ), container ); |
110 | QWhatsThis::add( label, tr( "Enter check number here." ) ); | 105 | QWhatsThis::add( label, tr( "Enter check number here." ) ); |
111 | layout->addWidget( label, 1, 2 ); | 106 | layout->addWidget( label, 1, 2 ); |
112 | numEdit = new QLineEdit( container ); | 107 | numEdit = new QLineEdit( container ); |
113 | QWhatsThis::add( numEdit, tr( "Enter check number here." ) ); | 108 | QWhatsThis::add( numEdit, tr( "Enter check number here." ) ); |
114 | numEdit->setMaximumWidth( 40 ); | 109 | numEdit->setMaximumWidth( 40 ); |
115 | layout->addWidget( numEdit, 1, 3 ); | 110 | layout->addWidget( numEdit, 1, 3 ); |
116 | 111 | ||
117 | // Description | 112 | // Description |
118 | label = new QLabel( tr( "Description:" ), container ); | 113 | label = new QLabel( tr( "Description:" ), container ); |
119 | QWhatsThis::add( label, tr( "Enter description of transaction here." ) ); | 114 | QWhatsThis::add( label, tr( "Enter description of transaction here." ) ); |
120 | layout->addWidget( label, 2, 0 ); | 115 | layout->addWidget( label, 2, 0 ); |
121 | descEdit = new QLineEdit( container ); | 116 | descEdit = new QLineEdit( container ); |
122 | QWhatsThis::add( descEdit, tr( "Enter description of transaction here." ) ); | 117 | QWhatsThis::add( descEdit, tr( "Enter description of transaction here." ) ); |
123 | layout->addMultiCellWidget( descEdit, 2, 2, 1, 3 ); | 118 | layout->addMultiCellWidget( descEdit, 2, 2, 1, 3 ); |
124 | 119 | ||
125 | // Category | 120 | // Category |
126 | label = new QLabel( tr( "Category:" ), container ); | 121 | label = new QLabel( tr( "Category:" ), container ); |
127 | QWhatsThis::add( label, tr( "Select transaction category here." ) ); | 122 | QWhatsThis::add( label, tr( "Select transaction category here." ) ); |
128 | layout->addWidget( label, 3, 0 ); | 123 | layout->addWidget( label, 3, 0 ); |
129 | catList = new QComboBox( container ); | 124 | catList = new QComboBox( container ); |
130 | QWhatsThis::add( catList, tr( "Select transaction category here." ) ); | 125 | QWhatsThis::add( catList, tr( "Select transaction category here." ) ); |
131 | layout->addMultiCellWidget( catList, 3, 3, 1, 3 ); | 126 | layout->addMultiCellWidget( catList, 3, 3, 1, 3 ); |
132 | 127 | ||
133 | // Type | 128 | // Type |
134 | label = new QLabel( tr( "Type:" ), container ); | 129 | 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." ) ); | 130 | 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 ); | 131 | layout->addWidget( label, 4, 0 ); |
137 | typeList = new QComboBox( container ); | 132 | 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." ) ); | 133 | 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 ); | 134 | layout->addMultiCellWidget( typeList, 4, 4, 1, 3 ); |
140 | 135 | ||
141 | // Amount | 136 | // Amount |
142 | label = new QLabel( tr( "Amount:" ), container ); | 137 | 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." ) ); | 138 | QWhatsThis::add( label, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) ); |
144 | layout->addWidget( label, 5, 0 ); | 139 | layout->addWidget( label, 5, 0 ); |
145 | amtEdit = new QLineEdit( container ); | 140 | amtEdit = new QLineEdit( container ); |
146 | QWhatsThis::add( amtEdit, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) ); | 141 | 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 ); | 142 | layout->addMultiCellWidget( amtEdit, 5, 5, 1, 3 ); |
148 | 143 | ||
149 | // Fee | 144 | // Fee |
150 | label = new QLabel( tr( "Fee:" ), container ); | 145 | 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." ) ); | 146 | 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 ); | 147 | layout->addWidget( label, 6, 0 ); |
153 | feeEdit = new QLineEdit( container ); | 148 | 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." ) ); | 149 | 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 ); | 150 | layout->addMultiCellWidget( feeEdit, 6, 6, 1, 3 ); |
156 | 151 | ||
157 | // Notes | 152 | // Notes |
158 | label = new QLabel( tr( "Notes:" ), container ); | 153 | label = new QLabel( tr( "Notes:" ), container ); |
159 | QWhatsThis::add( label, tr( "Enter any additional information for this transaction here." ) ); | 154 | QWhatsThis::add( label, tr( "Enter any additional information for this transaction here." ) ); |
160 | layout->addWidget( label, 7, 0 ); | 155 | layout->addWidget( label, 7, 0 ); |
161 | noteEdit = new QMultiLineEdit( container ); | 156 | noteEdit = new QMultiLineEdit( container ); |
162 | QWhatsThis::add( noteEdit, tr( "Enter any additional information for this transaction here." ) ); | 157 | QWhatsThis::add( noteEdit, tr( "Enter any additional information for this transaction here." ) ); |
163 | layout->addMultiCellWidget( noteEdit, 8, 8, 0, 3 ); | 158 | layout->addMultiCellWidget( noteEdit, 8, 8, 0, 3 ); |
164 | 159 | ||
165 | // Populate current values if provided | 160 | // Populate current values if provided |
166 | if ( info ) | 161 | if ( info ) |
167 | { | 162 | { |
168 | if ( info->withdrawal() ) | 163 | if ( info->withdrawal() ) |
169 | { | 164 | { |
170 | withBtn->setChecked( TRUE ); | 165 | withBtn->setChecked( TRUE ); |
171 | slotWithdrawalClicked(); | 166 | slotWithdrawalClicked(); |
172 | } | 167 | } |
173 | else | 168 | else |
174 | { | 169 | { |
175 | depBtn->setChecked( TRUE ); | 170 | depBtn->setChecked( TRUE ); |
176 | slotDepositClicked(); | 171 | slotDepositClicked(); |
177 | } | 172 | } |
178 | QDate dt = info->date(); | 173 | QDate dt = info->date(); |
179 | slotDateChanged( dt.year(), dt.month(), dt.day() ); | 174 | slotDateChanged( dt.year(), dt.month(), dt.day() ); |
180 | datePicker->setDate( dt ); | 175 | datePicker->setDate( dt ); |
181 | numEdit->setText( info->number() ); | 176 | numEdit->setText( info->number() ); |
182 | descEdit->setText( info->desc() ); | 177 | descEdit->setText( info->desc() ); |
183 | QString temptext = info->category(); | 178 | QString temptext = info->category(); |
184 | int i = catList->count(); | 179 | int i = catList->count(); |
185 | while ( i > 0 ) | 180 | while ( i > 0 ) |
186 | { | 181 | { |
187 | i--; | 182 | i--; |
188 | catList->setCurrentItem( i ); | 183 | catList->setCurrentItem( i ); |
189 | if ( catList->currentText() == temptext ) | 184 | if ( catList->currentText() == temptext ) |
190 | { | 185 | { |
191 | break; | 186 | break; |
192 | } | 187 | } |
193 | } | 188 | } |
194 | temptext = info->type(); | 189 | temptext = info->type(); |
195 | i = typeList->count(); | 190 | i = typeList->count(); |
196 | while ( i > 0 ) | 191 | while ( i > 0 ) |
197 | { | 192 | { |
198 | i--; | 193 | i--; |
199 | typeList->setCurrentItem( i ); | 194 | typeList->setCurrentItem( i ); |
200 | if ( typeList->currentText() == temptext ) | 195 | if ( typeList->currentText() == temptext ) |
201 | { | 196 | { |
202 | break; | 197 | break; |
203 | } | 198 | } |
204 | } | 199 | } |
205 | amtEdit->setText( QString( "%1" ).arg( info->amount(), 0, 'f', 2 ) ); | 200 | amtEdit->setText( QString( "%1" ).arg( info->amount(), 0, 'f', 2 ) ); |
206 | feeEdit->setText( QString( "%1" ).arg( info->fee(), 0, 'f', 2 ) ); | 201 | feeEdit->setText( QString( "%1" ).arg( info->fee(), 0, 'f', 2 ) ); |
207 | noteEdit->setText( info->notes() ); | 202 | noteEdit->setText( info->notes() ); |
208 | } | 203 | } |
209 | else | 204 | else |
210 | { | 205 | { |
211 | withBtn->setChecked( TRUE ); | 206 | withBtn->setChecked( TRUE ); |
212 | } | 207 | } |
213 | } | 208 | } |
214 | 209 | ||
215 | Transaction::~Transaction() | 210 | Transaction::~Transaction() |
216 | { | 211 | { |
217 | } | 212 | } |
218 | 213 | ||
219 | void Transaction::accept() | 214 | void Transaction::accept() |
220 | { | 215 | { |
221 | tran->setDesc( descEdit->text() ); | 216 | tran->setDesc( descEdit->text() ); |
222 | tran->setDate( datePicker->selectedDate() ); | 217 | tran->setDate( datePicker->selectedDate() ); |
223 | tran->setWithdrawal( withBtn->isChecked() ); | 218 | tran->setWithdrawal( withBtn->isChecked() ); |
224 | tran->setType( typeList->currentText() ); | 219 | tran->setType( typeList->currentText() ); |
225 | tran->setCategory( catList->currentText() ); | 220 | tran->setCategory( catList->currentText() ); |
226 | bool ok; | 221 | bool ok; |
227 | tran->setAmount( amtEdit->text().toFloat( &ok ) ); | 222 | tran->setAmount( amtEdit->text().toFloat( &ok ) ); |
228 | tran->setFee( feeEdit->text().toFloat( &ok ) ); | 223 | tran->setFee( feeEdit->text().toFloat( &ok ) ); |
229 | tran->setNumber( numEdit->text() ); | 224 | tran->setNumber( numEdit->text() ); |
230 | tran->setNotes( noteEdit->text() ); | 225 | tran->setNotes( noteEdit->text() ); |
231 | 226 | ||
232 | QDialog::accept(); | 227 | QDialog::accept(); |
233 | } | 228 | } |
234 | 229 | ||
235 | void Transaction::slotWithdrawalClicked() | 230 | void Transaction::slotWithdrawalClicked() |
236 | { | 231 | { |
237 | catList->clear(); | 232 | catList->clear(); |
238 | catList->insertItem( tr( "Automobile" ) ); | 233 | catList->insertItem( tr( "Automobile" ) ); |
239 | catList->insertItem( tr( "Bills" ) ); | 234 | catList->insertItem( tr( "Bills" ) ); |
240 | catList->insertItem( tr( "CDs" ) ); | 235 | catList->insertItem( tr( "CDs" ) ); |
241 | catList->insertItem( tr( "Clothing" ) ); | 236 | catList->insertItem( tr( "Clothing" ) ); |
242 | catList->insertItem( tr( "Computer" ) ); | 237 | catList->insertItem( tr( "Computer" ) ); |
243 | catList->insertItem( tr( "DVDs" ) ); | 238 | catList->insertItem( tr( "DVDs" ) ); |
244 | catList->insertItem( tr( "Eletronics" ) ); | 239 | catList->insertItem( tr( "Eletronics" ) ); |
245 | catList->insertItem( tr( "Entertainment" ) ); | 240 | catList->insertItem( tr( "Entertainment" ) ); |
246 | catList->insertItem( tr( "Food" ) ); | 241 | catList->insertItem( tr( "Food" ) ); |
247 | catList->insertItem( tr( "Gasoline" ) ); | 242 | catList->insertItem( tr( "Gasoline" ) ); |
248 | catList->insertItem( tr( "Misc" ) ); | 243 | catList->insertItem( tr( "Misc" ) ); |
249 | catList->insertItem( tr( "Movies" ) ); | 244 | catList->insertItem( tr( "Movies" ) ); |
250 | catList->insertItem( tr( "Rent" ) ); | 245 | catList->insertItem( tr( "Rent" ) ); |
251 | catList->insertItem( tr( "Travel" ) ); | 246 | catList->insertItem( tr( "Travel" ) ); |
252 | catList->setCurrentItem( 0 ); | 247 | catList->setCurrentItem( 0 ); |
253 | typeList->clear(); | 248 | typeList->clear(); |
254 | typeList->insertItem( tr( "Debit Charge" ) ); | 249 | typeList->insertItem( tr( "Debit Charge" ) ); |
255 | typeList->insertItem( tr( "Written Check" ) ); | 250 | typeList->insertItem( tr( "Written Check" ) ); |
256 | typeList->insertItem( tr( "Transfer" ) ); | 251 | typeList->insertItem( tr( "Transfer" ) ); |
257 | typeList->insertItem( tr( "Credit Card" ) ); | 252 | typeList->insertItem( tr( "Credit Card" ) ); |
258 | } | 253 | } |
259 | 254 | ||
260 | void Transaction::slotDepositClicked() | 255 | void Transaction::slotDepositClicked() |
261 | { | 256 | { |
262 | catList->clear(); | 257 | catList->clear(); |
263 | catList->insertItem( tr( "Work" ) ); | 258 | catList->insertItem( tr( "Work" ) ); |
264 | catList->insertItem( tr( "Family Member" ) ); | 259 | catList->insertItem( tr( "Family Member" ) ); |
265 | catList->insertItem( tr( "Misc. Credit" ) ); | 260 | catList->insertItem( tr( "Misc. Credit" ) ); |
266 | catList->setCurrentItem( 0 ); | 261 | catList->setCurrentItem( 0 ); |
267 | typeList->clear(); | 262 | typeList->clear(); |
268 | typeList->insertItem( tr( "Written Check" ) ); | 263 | typeList->insertItem( tr( "Written Check" ) ); |
269 | typeList->insertItem( tr( "Automatic Payment" ) ); | 264 | typeList->insertItem( tr( "Automatic Payment" ) ); |
270 | typeList->insertItem( tr( "Transfer" ) ); | 265 | typeList->insertItem( tr( "Transfer" ) ); |
271 | typeList->insertItem( tr( "Cash" ) ); | 266 | typeList->insertItem( tr( "Cash" ) ); |
272 | } | 267 | } |
273 | 268 | ||
274 | void Transaction::slotDateChanged( int y, int m, int d ) | 269 | void Transaction::slotDateChanged( int y, int m, int d ) |
275 | { | 270 | { |
276 | QDate date; | 271 | QDate date; |
277 | date.setYMD( y, m, d ); | 272 | date.setYMD( y, m, d ); |
278 | dateBtn->setText( TimeString::shortDate( date ) ); | 273 | dateBtn->setText( TimeString::shortDate( date ) ); |
279 | } | 274 | } |