author | drw <drw> | 2002-10-26 18:23:34 (UTC) |
---|---|---|
committer | drw <drw> | 2002-10-26 18:23:34 (UTC) |
commit | 3dc25703dbf961f86bc25378113ffafb18ee192e (patch) (unidiff) | |
tree | 75436ace2b4c524ea29de5cbd8ac6cbbbcf7ec4e /noncore/apps/checkbook/checkbook.cpp | |
parent | ec58c37763a97306543a3f18052d37291b1cdf83 (diff) | |
download | opie-3dc25703dbf961f86bc25378113ffafb18ee192e.zip opie-3dc25703dbf961f86bc25378113ffafb18ee192e.tar.gz opie-3dc25703dbf961f86bc25378113ffafb18ee192e.tar.bz2 |
Whats This and a couple fixes
Diffstat (limited to 'noncore/apps/checkbook/checkbook.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/checkbook/checkbook.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/noncore/apps/checkbook/checkbook.cpp b/noncore/apps/checkbook/checkbook.cpp index 2919927..ee65784 100644 --- a/noncore/apps/checkbook/checkbook.cpp +++ b/noncore/apps/checkbook/checkbook.cpp | |||
@@ -22,52 +22,53 @@ | |||
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "checkbook.h" | 29 | #include "checkbook.h" |
30 | #include "transaction.h" | 30 | #include "transaction.h" |
31 | 31 | ||
32 | #include <opie/otabwidget.h> | 32 | #include <opie/otabwidget.h> |
33 | #include <qpe/config.h> | 33 | #include <qpe/config.h> |
34 | #include <qpe/qpeapplication.h> | 34 | #include <qpe/qpeapplication.h> |
35 | #include <qpe/qpemessagebox.h> | 35 | #include <qpe/qpemessagebox.h> |
36 | #include <qpe/resource.h> | 36 | #include <qpe/resource.h> |
37 | 37 | ||
38 | #include <qcombobox.h> | 38 | #include <qcombobox.h> |
39 | #include <qfile.h> | 39 | #include <qfile.h> |
40 | #include <qlabel.h> | 40 | #include <qlabel.h> |
41 | #include <qlayout.h> | 41 | #include <qlayout.h> |
42 | #include <qlineedit.h> | 42 | #include <qlineedit.h> |
43 | #include <qlistview.h> | 43 | #include <qlistview.h> |
44 | #include <qmultilineedit.h> | 44 | #include <qmultilineedit.h> |
45 | #include <qpushbutton.h> | 45 | #include <qpushbutton.h> |
46 | #include <qwhatsthis.h> | ||
46 | #include <qwidget.h> | 47 | #include <qwidget.h> |
47 | 48 | ||
48 | Checkbook::Checkbook( QWidget *parent, const QString &n, const QString &fd, char symbol ) | 49 | Checkbook::Checkbook( QWidget *parent, const QString &n, const QString &fd, char symbol ) |
49 | : QDialog( parent, 0, TRUE, 0 ) | 50 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) |
50 | { | 51 | { |
51 | name = n; | 52 | name = n; |
52 | filename = fd + name + ".qcb"; | 53 | filename = fd + name + ".qcb"; |
53 | filedir = fd; | 54 | filedir = fd; |
54 | currencySymbol = symbol; | 55 | currencySymbol = symbol; |
55 | currBalance = 0.0; | 56 | currBalance = 0.0; |
56 | 57 | ||
57 | if ( name != "" ) | 58 | if ( name != "" ) |
58 | { | 59 | { |
59 | setCaption( name + " - " + tr( "Checkbook" ) ); | 60 | setCaption( name + " - " + tr( "Checkbook" ) ); |
60 | } | 61 | } |
61 | else | 62 | else |
62 | { | 63 | { |
63 | setCaption( tr( "New checkbook" ) ); | 64 | setCaption( tr( "New checkbook" ) ); |
64 | } | 65 | } |
65 | 66 | ||
66 | // Setup layout to make everything pretty | 67 | // Setup layout to make everything pretty |
67 | QVBoxLayout *layout = new QVBoxLayout( this ); | 68 | QVBoxLayout *layout = new QVBoxLayout( this ); |
68 | layout->setMargin( 2 ); | 69 | layout->setMargin( 2 ); |
69 | layout->setSpacing( 4 ); | 70 | layout->setSpacing( 4 ); |
70 | 71 | ||
71 | // Setup tabs for all info | 72 | // Setup tabs for all info |
72 | mainWidget = new OTabWidget( this ); | 73 | mainWidget = new OTabWidget( this ); |
73 | layout->addWidget( mainWidget ); | 74 | layout->addWidget( mainWidget ); |
@@ -89,165 +90,186 @@ const QString &Checkbook::getName() | |||
89 | { | 90 | { |
90 | return( name ); | 91 | return( name ); |
91 | } | 92 | } |
92 | 93 | ||
93 | QWidget *Checkbook::initInfo() | 94 | QWidget *Checkbook::initInfo() |
94 | { | 95 | { |
95 | QWidget *control = new QWidget( mainWidget ); | 96 | QWidget *control = new QWidget( mainWidget ); |
96 | 97 | ||
97 | QVBoxLayout *vb = new QVBoxLayout( control ); | 98 | QVBoxLayout *vb = new QVBoxLayout( control ); |
98 | 99 | ||
99 | QScrollView *sv = new QScrollView( control ); | 100 | QScrollView *sv = new QScrollView( control ); |
100 | vb->addWidget( sv, 0, 0 ); | 101 | vb->addWidget( sv, 0, 0 ); |
101 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 102 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
102 | sv->setFrameStyle( QFrame::NoFrame ); | 103 | sv->setFrameStyle( QFrame::NoFrame ); |
103 | 104 | ||
104 | QWidget *container = new QWidget( sv->viewport() ); | 105 | QWidget *container = new QWidget( sv->viewport() ); |
105 | sv->addChild( container ); | 106 | sv->addChild( container ); |
106 | 107 | ||
107 | QGridLayout *layout = new QGridLayout( container ); | 108 | QGridLayout *layout = new QGridLayout( container ); |
108 | layout->setSpacing( 2 ); | 109 | layout->setSpacing( 2 ); |
109 | layout->setMargin( 4 ); | 110 | layout->setMargin( 4 ); |
110 | 111 | ||
111 | // Account name | 112 | // Account name |
112 | QLabel *label = new QLabel( tr( "Name:" ), container ); | 113 | QLabel *label = new QLabel( tr( "Name:" ), container ); |
114 | QWhatsThis::add( label, tr( "Enter name of checkbook here." ) ); | ||
113 | layout->addWidget( label, 0, 0 ); | 115 | layout->addWidget( label, 0, 0 ); |
114 | nameEdit = new QLineEdit( container ); | 116 | nameEdit = new QLineEdit( container ); |
117 | QWhatsThis::add( nameEdit, tr( "Enter name of checkbook here." ) ); | ||
115 | connect( nameEdit, SIGNAL( textChanged( const QString & ) ), | 118 | connect( nameEdit, SIGNAL( textChanged( const QString & ) ), |
116 | this, SLOT( slotNameChanged( const QString & ) ) ); | 119 | this, SLOT( slotNameChanged( const QString & ) ) ); |
117 | layout->addWidget( nameEdit, 0, 1 ); | 120 | layout->addWidget( nameEdit, 0, 1 ); |
118 | 121 | ||
119 | // Type of account | 122 | // Type of account |
120 | label = new QLabel( tr( "Type:" ), container ); | 123 | label = new QLabel( tr( "Type:" ), container ); |
124 | QWhatsThis::add( label, tr( "Select type of checkbook here." ) ); | ||
121 | layout->addWidget( label, 1, 0 ); | 125 | layout->addWidget( label, 1, 0 ); |
122 | typeList = new QComboBox( container ); | 126 | typeList = new QComboBox( container ); |
127 | QWhatsThis::add( typeList, tr( "Select type of checkbook here." ) ); | ||
123 | typeList->insertItem( tr( "Savings" ) ); // 0 | 128 | typeList->insertItem( tr( "Savings" ) ); // 0 |
124 | typeList->insertItem( tr( "Checking" ) ); // 1 | 129 | typeList->insertItem( tr( "Checking" ) ); // 1 |
125 | typeList->insertItem( tr( "CD" ) ); // 2 | 130 | typeList->insertItem( tr( "CD" ) ); // 2 |
126 | typeList->insertItem( tr( "Money market" ) );// 3 | 131 | typeList->insertItem( tr( "Money market" ) );// 3 |
127 | typeList->insertItem( tr( "Mutual fund" ) );// 4 | 132 | typeList->insertItem( tr( "Mutual fund" ) );// 4 |
128 | typeList->insertItem( tr( "Other" ) ); // 5 | 133 | typeList->insertItem( tr( "Other" ) ); // 5 |
129 | layout->addWidget( typeList, 1, 1 ); | 134 | layout->addWidget( typeList, 1, 1 ); |
130 | 135 | ||
131 | // Bank/institution name | 136 | // Bank/institution name |
132 | label = new QLabel( tr( "Bank:" ), container ); | 137 | label = new QLabel( tr( "Bank:" ), container ); |
138 | QWhatsThis::add( label, tr( "Enter name of the bank for this checkbook here." ) ); | ||
133 | layout->addWidget( label, 2, 0 ); | 139 | layout->addWidget( label, 2, 0 ); |
134 | bankEdit = new QLineEdit( container ); | 140 | bankEdit = new QLineEdit( container ); |
141 | QWhatsThis::add( bankEdit, tr( "Enter name of the bank for this checkbook here." ) ); | ||
135 | layout->addWidget( bankEdit, 2, 1 ); | 142 | layout->addWidget( bankEdit, 2, 1 ); |
136 | 143 | ||
137 | // Account number | 144 | // Account number |
138 | label = new QLabel( tr( "Account number:" ), container ); | 145 | label = new QLabel( tr( "Account number:" ), container ); |
146 | QWhatsThis::add( label, tr( "Enter account number for this checkbook here." ) ); | ||
139 | layout->addWidget( label, 3, 0 ); | 147 | layout->addWidget( label, 3, 0 ); |
140 | acctNumEdit = new QLineEdit( container ); | 148 | acctNumEdit = new QLineEdit( container ); |
149 | QWhatsThis::add( acctNumEdit, tr( "Enter account number for this checkbook here." ) ); | ||
141 | layout->addWidget( acctNumEdit, 3, 1 ); | 150 | layout->addWidget( acctNumEdit, 3, 1 ); |
142 | 151 | ||
143 | // PIN number | 152 | // PIN number |
144 | label = new QLabel( tr( "PIN number:" ), container ); | 153 | label = new QLabel( tr( "PIN number:" ), container ); |
154 | QWhatsThis::add( label, tr( "Enter PIN number for this checkbook here." ) ); | ||
145 | layout->addWidget( label, 4, 0 ); | 155 | layout->addWidget( label, 4, 0 ); |
146 | pinNumEdit = new QLineEdit( container ); | 156 | pinNumEdit = new QLineEdit( container ); |
157 | QWhatsThis::add( pinNumEdit, tr( "Enter PIN number for this checkbook here." ) ); | ||
147 | layout->addWidget( pinNumEdit, 4, 1 ); | 158 | layout->addWidget( pinNumEdit, 4, 1 ); |
148 | 159 | ||
149 | // Starting balance | 160 | // Starting balance |
150 | label = new QLabel( tr( "Starting balance:" ), container ); | 161 | label = new QLabel( tr( "Starting balance:" ), container ); |
162 | QWhatsThis::add( label, tr( "Enter the initial balance for this checkbook here." ) ); | ||
151 | layout->addWidget( label, 5, 0 ); | 163 | layout->addWidget( label, 5, 0 ); |
152 | balanceEdit = new QLineEdit( container ); | 164 | balanceEdit = new QLineEdit( container ); |
165 | QWhatsThis::add( balanceEdit, tr( "Enter the initial balance for this checkbook here." ) ); | ||
153 | connect( balanceEdit, SIGNAL( textChanged( const QString & ) ), | 166 | connect( balanceEdit, SIGNAL( textChanged( const QString & ) ), |
154 | this, SLOT( slotStartingBalanceChanged( const QString & ) ) ); | 167 | this, SLOT( slotStartingBalanceChanged( const QString & ) ) ); |
155 | layout->addWidget( balanceEdit, 5, 1 ); | 168 | layout->addWidget( balanceEdit, 5, 1 ); |
156 | 169 | ||
157 | // Notes | 170 | // Notes |
158 | label = new QLabel( tr( "Notes:" ), container ); | 171 | label = new QLabel( tr( "Notes:" ), container ); |
172 | QWhatsThis::add( label, tr( "Enter any additional information for this checkbook here." ) ); | ||
159 | layout->addWidget( label, 6, 0 ); | 173 | layout->addWidget( label, 6, 0 ); |
160 | notesEdit = new QMultiLineEdit( container ); | 174 | notesEdit = new QMultiLineEdit( container ); |
175 | QWhatsThis::add( notesEdit, tr( "Enter any additional information for this checkbook here." ) ); | ||
161 | notesEdit->setMaximumHeight( 85 ); | 176 | notesEdit->setMaximumHeight( 85 ); |
162 | layout->addMultiCellWidget( notesEdit, 7, 7, 0, 1 ); | 177 | layout->addMultiCellWidget( notesEdit, 7, 7, 0, 1 ); |
163 | 178 | ||
164 | return control; | 179 | return control; |
165 | } | 180 | } |
166 | 181 | ||
167 | QWidget *Checkbook::initTransactions() | 182 | QWidget *Checkbook::initTransactions() |
168 | { | 183 | { |
169 | QWidget *control = new QWidget( mainWidget ); | 184 | QWidget *control = new QWidget( mainWidget ); |
170 | 185 | ||
171 | QGridLayout *layout = new QGridLayout( control ); | 186 | QGridLayout *layout = new QGridLayout( control ); |
172 | layout->setSpacing( 2 ); | 187 | layout->setSpacing( 2 ); |
173 | layout->setMargin( 4 ); | 188 | layout->setMargin( 4 ); |
174 | 189 | ||
175 | balanceLabel = new QLabel( tr( "Current balance: %10.00" ).arg( currencySymbol ), | 190 | balanceLabel = new QLabel( tr( "Current balance: %10.00" ).arg( currencySymbol ), |
176 | control ); | 191 | control ); |
192 | QWhatsThis::add( balanceLabel, tr( "This area shows the current balance in this checkbook." ) ); | ||
177 | layout->addMultiCellWidget( balanceLabel, 0, 0, 0, 2 ); | 193 | layout->addMultiCellWidget( balanceLabel, 0, 0, 0, 2 ); |
178 | 194 | ||
179 | tranTable = new QListView( control ); | 195 | tranTable = new QListView( control ); |
196 | 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." ) ); | ||
180 | tranTable->addColumn( tr( "ID" ) ); | 197 | tranTable->addColumn( tr( "ID" ) ); |
181 | tranTable->addColumn( tr( "Date" ) ); | 198 | tranTable->addColumn( tr( "Date" ) ); |
182 | tranTable->addColumn( tr( "Description" ) ); | 199 | tranTable->addColumn( tr( "Description" ) ); |
183 | int colnum = tranTable->addColumn( tr( "Amount" ) ); | 200 | int colnum = tranTable->addColumn( tr( "Amount" ) ); |
184 | tranTable->setColumnAlignment( colnum, Qt::AlignRight ); | 201 | tranTable->setColumnAlignment( colnum, Qt::AlignRight ); |
185 | tranTable->setAllColumnsShowFocus( TRUE ); | 202 | tranTable->setAllColumnsShowFocus( TRUE ); |
186 | layout->addMultiCellWidget( tranTable, 1, 1, 0, 2 ); | 203 | layout->addMultiCellWidget( tranTable, 1, 1, 0, 2 ); |
187 | QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold ); | 204 | QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold ); |
188 | connect( tranTable, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), | 205 | connect( tranTable, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), |
189 | this, SLOT( slotEditTran() ) ); | 206 | this, SLOT( slotEditTran() ) ); |
190 | 207 | ||
191 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), control ); | 208 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), control ); |
209 | QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) ); | ||
192 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotNewTran() ) ); | 210 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotNewTran() ) ); |
193 | layout->addWidget( btn, 2, 0 ); | 211 | layout->addWidget( btn, 2, 0 ); |
194 | 212 | ||
195 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), control ); | 213 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), control ); |
214 | QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) ); | ||
196 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotEditTran() ) ); | 215 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotEditTran() ) ); |
197 | layout->addWidget( btn, 2, 1 ); | 216 | layout->addWidget( btn, 2, 1 ); |
198 | 217 | ||
199 | btn = new QPushButton( Resource::loadPixmap( "editdelete" ), tr( "Delete" ), control ); | 218 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), control ); |
219 | QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) ); | ||
200 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDeleteTran() ) ); | 220 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDeleteTran() ) ); |
201 | layout->addWidget( btn, 2, 2 ); | 221 | layout->addWidget( btn, 2, 2 ); |
202 | 222 | ||
203 | return( control ); | 223 | return( control ); |
204 | } | 224 | } |
205 | 225 | ||
206 | QWidget *Checkbook::initCharts() | 226 | QWidget *Checkbook::initCharts() |
207 | { | 227 | { |
208 | QWidget *control = new QWidget( mainWidget ); | 228 | QWidget *control = new QWidget( mainWidget ); |
209 | 229 | ||
210 | QGridLayout *layout = new QGridLayout( control ); | 230 | QGridLayout *layout = new QGridLayout( control ); |
211 | layout->setSpacing( 2 ); | 231 | layout->setSpacing( 2 ); |
212 | layout->setMargin( 4 ); | 232 | layout->setMargin( 4 ); |
213 | 233 | ||
214 | /* | 234 | /* |
215 | QLabel *label = new QLabel( control ); | 235 | QLabel *label = new QLabel( control ); |
216 | label->setText( tr( "Graph type:" ) ); | 236 | label->setText( tr( "Graph type:" ) ); |
217 | layout->addWidget( label, 0, 0 ); | 237 | layout->addWidget( label, 0, 0 ); |
218 | graphList = new QComboBox( control ); | 238 | graphList = new QComboBox( control ); |
219 | graphList->insertItem( tr( "By category" ) ); | 239 | graphList->insertItem( tr( "By category" ) ); |
220 | graphList->insertItem( tr( "..." ) ); | 240 | graphList->insertItem( tr( "..." ) ); |
221 | graphList->insertItem( tr( "..." ) ); | 241 | graphList->insertItem( tr( "..." ) ); |
222 | layout->addWidget( graphList, 0, 1 ); | 242 | layout->addWidget( graphList, 0, 1 ); |
223 | */ | 243 | */ |
224 | 244 | ||
225 | QWidget *graphWidget = new QWidget( control ); | 245 | QWidget *graphWidget = new QWidget( control ); |
246 | QWhatsThis::add( graphWidget, tr( "Graph not implemented yet." ) ); | ||
226 | layout->addMultiCellWidget( graphWidget, 0, 0, 0, 1 ); | 247 | layout->addMultiCellWidget( graphWidget, 0, 0, 0, 1 ); |
227 | graphWidget->setBackgroundMode( QWidget::PaletteBase ); | 248 | graphWidget->setBackgroundMode( QWidget::PaletteBase ); |
228 | 249 | ||
229 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Draw" ), control ); | 250 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Draw" ), control ); |
251 | QWhatsThis::add( btn, tr( "Click here to draw the graph." ) ); | ||
230 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) ); | 252 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) ); |
231 | layout->addWidget( btn, 1, 1 ); | 253 | layout->addWidget( btn, 1, 1 ); |
232 | 254 | ||
233 | return control; | 255 | return control; |
234 | } | 256 | } |
235 | 257 | ||
236 | void Checkbook::loadCheckbook() | 258 | void Checkbook::loadCheckbook() |
237 | { | 259 | { |
238 | transactions.clear(); | 260 | transactions.clear(); |
239 | 261 | ||
240 | Config config(filename, Config::File); | 262 | Config config(filename, Config::File); |
241 | 263 | ||
242 | // Load info | 264 | // Load info |
243 | config.setGroup( "Account" ); | 265 | config.setGroup( "Account" ); |
244 | nameEdit->setText( name ); | 266 | nameEdit->setText( name ); |
245 | QString temptext = config.readEntry( "Type" ); | 267 | QString temptext = config.readEntry( "Type" ); |
246 | int i = typeList->count(); | 268 | int i = typeList->count(); |
247 | while ( i > 0 ) | 269 | while ( i > 0 ) |
248 | { | 270 | { |
249 | i--; | 271 | i--; |
250 | typeList->setCurrentItem( i ); | 272 | typeList->setCurrentItem( i ); |
251 | if ( typeList->currentText() == temptext ) | 273 | if ( typeList->currentText() == temptext ) |
252 | { | 274 | { |
253 | break; | 275 | break; |