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 | |
parent | ec58c37763a97306543a3f18052d37291b1cdf83 (diff) | |
download | opie-3dc25703dbf961f86bc25378113ffafb18ee192e.zip opie-3dc25703dbf961f86bc25378113ffafb18ee192e.tar.gz opie-3dc25703dbf961f86bc25378113ffafb18ee192e.tar.bz2 |
Whats This and a couple fixes
-rw-r--r-- | noncore/apps/checkbook/checkbook.cpp | 26 | ||||
-rw-r--r-- | noncore/apps/checkbook/mainwindow.cpp | 59 | ||||
-rw-r--r-- | noncore/apps/checkbook/mainwindow.h | 2 | ||||
-rw-r--r-- | noncore/apps/checkbook/transaction.cpp | 23 |
4 files changed, 74 insertions, 36 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 | |||
@@ -1,491 +1,513 @@ | |||
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 <williamsdr@acm.org> | 4 | .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This file is free software; you can | 6 | _;:, .> :=|. This file is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This file is distributed in the hope that | 13 | .i_,=:_. -<s. This file is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "checkbook.h" | 29 | #include "checkbook.h" |
30 | #include "transaction.h" | 30 | #include "transaction.h" |
31 | 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 ); |
74 | 75 | ||
75 | mainWidget->addTab( initInfo(), "help_icon", tr( "Info" ) ); | 76 | mainWidget->addTab( initInfo(), "help_icon", tr( "Info" ) ); |
76 | mainWidget->addTab( initTransactions(), "Spreadsheet", tr( "Transactions" ) ); | 77 | mainWidget->addTab( initTransactions(), "Spreadsheet", tr( "Transactions" ) ); |
77 | mainWidget->addTab( initCharts(), "DocumentTypePowerPoint", tr( "Charts" ) ); | 78 | mainWidget->addTab( initCharts(), "DocumentTypePowerPoint", tr( "Charts" ) ); |
78 | mainWidget->setCurrentTab( tr( "Info" ) ); | 79 | mainWidget->setCurrentTab( tr( "Info" ) ); |
79 | 80 | ||
80 | // Load checkbook information | 81 | // Load checkbook information |
81 | loadCheckbook(); | 82 | loadCheckbook(); |
82 | } | 83 | } |
83 | 84 | ||
84 | Checkbook::~Checkbook() | 85 | Checkbook::~Checkbook() |
85 | { | 86 | { |
86 | } | 87 | } |
87 | 88 | ||
88 | const QString &Checkbook::getName() | 89 | 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; |
254 | } | 276 | } |
255 | } | 277 | } |
256 | bankEdit->setText( config.readEntry( "Bank", "" ) ); | 278 | bankEdit->setText( config.readEntry( "Bank", "" ) ); |
257 | acctNumEdit->setText( config.readEntry( "Number", "" ) ); | 279 | acctNumEdit->setText( config.readEntry( "Number", "" ) ); |
258 | pinNumEdit->setText( config.readEntry( "PINNumber", "" ) ); | 280 | pinNumEdit->setText( config.readEntry( "PINNumber", "" ) ); |
259 | balanceEdit->setText( config.readEntry( "Balance", "0.0" ) ); | 281 | balanceEdit->setText( config.readEntry( "Balance", "0.0" ) ); |
260 | notesEdit->setText( config.readEntry( "Notes", "" ) ); | 282 | notesEdit->setText( config.readEntry( "Notes", "" ) ); |
261 | 283 | ||
262 | bool ok; | 284 | bool ok; |
263 | currBalance = balanceEdit->text().toFloat( &ok ); | 285 | currBalance = balanceEdit->text().toFloat( &ok ); |
264 | startBalance = currBalance; | 286 | startBalance = currBalance; |
265 | 287 | ||
266 | // Load transactions | 288 | // Load transactions |
267 | TranInfo *tran; | 289 | TranInfo *tran; |
268 | QString trandesc = ""; | 290 | QString trandesc = ""; |
269 | float amount; | 291 | float amount; |
270 | QString stramount; | 292 | QString stramount; |
271 | for ( int i = 1; trandesc != QString::null; i++ ) | 293 | for ( int i = 1; trandesc != QString::null; i++ ) |
272 | { | 294 | { |
273 | tran = new TranInfo( config, i ); | 295 | tran = new TranInfo( config, i ); |
274 | trandesc = tran->desc(); | 296 | trandesc = tran->desc(); |
275 | if ( trandesc != QString::null ) | 297 | if ( trandesc != QString::null ) |
276 | { | 298 | { |
277 | currBalance -= tran->fee(); | 299 | currBalance -= tran->fee(); |
278 | amount = tran->amount(); | 300 | amount = tran->amount(); |
279 | if ( tran->withdrawal() ) | 301 | if ( tran->withdrawal() ) |
280 | { | 302 | { |
281 | amount *= -1; | 303 | amount *= -1; |
282 | } | 304 | } |
283 | currBalance += amount; | 305 | currBalance += amount; |
284 | stramount.sprintf( "%c%.2f", currencySymbol, amount ); | 306 | stramount.sprintf( "%c%.2f", currencySymbol, amount ); |
285 | 307 | ||
286 | // Add to transaction list | 308 | // Add to transaction list |
287 | transactions.append( tran ); | 309 | transactions.append( tran ); |
288 | 310 | ||
289 | // Add to transaction table | 311 | // Add to transaction table |
290 | QDate date = tran->date(); | 312 | QDate date = tran->date(); |
291 | QString datestr = QString::number( date.month() ) + "/" + | 313 | QString datestr = QString::number( date.month() ) + "/" + |
292 | QString::number( date.day() ) + "/" + | 314 | QString::number( date.day() ) + "/" + |
293 | QString::number( date.year() ); | 315 | QString::number( date.year() ); |
294 | ( void ) new QListViewItem( tranTable, QString::number( i ), datestr, | 316 | ( void ) new QListViewItem( tranTable, QString::number( i ), datestr, |
295 | trandesc, stramount ); | 317 | trandesc, stramount ); |
296 | } | 318 | } |
297 | else | 319 | else |
298 | { | 320 | { |
299 | delete tran; | 321 | delete tran; |
300 | } | 322 | } |
301 | } | 323 | } |
302 | balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) ); | 324 | balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) ); |
303 | 325 | ||
304 | highTranNum = transactions.count(); | 326 | highTranNum = transactions.count(); |
305 | } | 327 | } |
306 | 328 | ||
307 | void Checkbook::adjustBalance( float amount ) | 329 | void Checkbook::adjustBalance( float amount ) |
308 | { | 330 | { |
309 | currBalance += amount; | 331 | currBalance += amount; |
310 | balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) ); | 332 | balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) ); |
311 | 333 | ||
312 | } | 334 | } |
313 | 335 | ||
314 | TranInfo *Checkbook::findTranByID( int id ) | 336 | TranInfo *Checkbook::findTranByID( int id ) |
315 | { | 337 | { |
316 | TranInfo *traninfo = transactions.first(); | 338 | TranInfo *traninfo = transactions.first(); |
317 | while ( traninfo && traninfo->id() != id ) | 339 | while ( traninfo && traninfo->id() != id ) |
318 | { | 340 | { |
319 | traninfo = transactions.next(); | 341 | traninfo = transactions.next(); |
320 | } | 342 | } |
321 | return( traninfo ); | 343 | return( traninfo ); |
322 | } | 344 | } |
323 | 345 | ||
324 | void Checkbook::accept() | 346 | void Checkbook::accept() |
325 | { | 347 | { |
326 | QFile f( filename ); | 348 | QFile f( filename ); |
327 | if ( f.exists() ) | 349 | if ( f.exists() ) |
328 | { | 350 | { |
329 | f.remove(); | 351 | f.remove(); |
330 | } | 352 | } |
331 | 353 | ||
332 | Config *config = new Config(filename, Config::File); | 354 | Config *config = new Config(filename, Config::File); |
333 | 355 | ||
334 | // Save info | 356 | // Save info |
335 | config->setGroup( "Account" ); | 357 | config->setGroup( "Account" ); |
336 | config->writeEntry( "Type", typeList->currentText() ); | 358 | config->writeEntry( "Type", typeList->currentText() ); |
337 | config->writeEntry( "Bank", bankEdit->text() ); | 359 | config->writeEntry( "Bank", bankEdit->text() ); |
338 | config->writeEntry( "Number", acctNumEdit->text() ); | 360 | config->writeEntry( "Number", acctNumEdit->text() ); |
339 | config->writeEntry( "PINNumber", pinNumEdit->text() ); | 361 | config->writeEntry( "PINNumber", pinNumEdit->text() ); |
340 | config->writeEntry( "Balance", balanceEdit->text() ); | 362 | config->writeEntry( "Balance", balanceEdit->text() ); |
341 | config->writeEntry( "Notes", notesEdit->text() ); | 363 | config->writeEntry( "Notes", notesEdit->text() ); |
342 | 364 | ||
343 | // Save transactions | 365 | // Save transactions |
344 | TranInfo *tran = transactions.first(); | 366 | TranInfo *tran = transactions.first(); |
345 | int i = 1; | 367 | int i = 1; |
346 | while ( tran ) | 368 | while ( tran ) |
347 | { | 369 | { |
348 | tran->write( config, i ); | 370 | tran->write( config, i ); |
349 | tran = transactions.next(); | 371 | tran = transactions.next(); |
350 | i++; | 372 | i++; |
351 | } | 373 | } |
352 | config->write(); | 374 | config->write(); |
353 | 375 | ||
354 | QDialog::accept(); | 376 | QDialog::accept(); |
355 | } | 377 | } |
356 | 378 | ||
357 | void Checkbook::slotNameChanged( const QString &newname ) | 379 | void Checkbook::slotNameChanged( const QString &newname ) |
358 | { | 380 | { |
359 | name = newname; | 381 | name = newname; |
360 | filename = filedir + newname + ".qcb"; | 382 | filename = filedir + newname + ".qcb"; |
361 | setCaption( name + " - " + tr( "Checkbook" ) ); | 383 | setCaption( name + " - " + tr( "Checkbook" ) ); |
362 | } | 384 | } |
363 | 385 | ||
364 | void Checkbook::slotStartingBalanceChanged( const QString &newbalance ) | 386 | void Checkbook::slotStartingBalanceChanged( const QString &newbalance ) |
365 | { | 387 | { |
366 | currBalance -= startBalance; | 388 | currBalance -= startBalance; |
367 | bool ok; | 389 | bool ok; |
368 | startBalance = newbalance.toFloat( &ok ); | 390 | startBalance = newbalance.toFloat( &ok ); |
369 | adjustBalance( startBalance ); | 391 | adjustBalance( startBalance ); |
370 | } | 392 | } |
371 | 393 | ||
372 | void Checkbook::slotNewTran() | 394 | void Checkbook::slotNewTran() |
373 | { | 395 | { |
374 | highTranNum++; | 396 | highTranNum++; |
375 | TranInfo *traninfo = new TranInfo( highTranNum ); | 397 | TranInfo *traninfo = new TranInfo( highTranNum ); |
376 | 398 | ||
377 | Transaction *currtran = new Transaction( this, name, | 399 | Transaction *currtran = new Transaction( this, name, |
378 | traninfo, | 400 | traninfo, |
379 | currencySymbol ); | 401 | currencySymbol ); |
380 | currtran->showMaximized(); | 402 | currtran->showMaximized(); |
381 | if ( currtran->exec() == QDialog::Accepted ) | 403 | if ( currtran->exec() == QDialog::Accepted ) |
382 | { | 404 | { |
383 | float amount = traninfo->amount(); | 405 | float amount = traninfo->amount(); |
384 | if ( traninfo->withdrawal() ) | 406 | if ( traninfo->withdrawal() ) |
385 | { | 407 | { |
386 | amount *= -1; | 408 | amount *= -1; |
387 | } | 409 | } |
388 | QString stramount; | 410 | QString stramount; |
389 | stramount.sprintf( "%c%.2f", currencySymbol, amount ); | 411 | stramount.sprintf( "%c%.2f", currencySymbol, amount ); |
390 | 412 | ||
391 | // Add to transaction list | 413 | // Add to transaction list |
392 | transactions.append( traninfo ); | 414 | transactions.append( traninfo ); |
393 | 415 | ||
394 | // Add to transaction table | 416 | // Add to transaction table |
395 | 417 | ||
396 | QDate date = traninfo->date(); | 418 | QDate date = traninfo->date(); |
397 | QString datestr = QString::number( date.month() ) + "/" + | 419 | QString datestr = QString::number( date.month() ) + "/" + |
398 | QString::number( date.day() ) + "/" + | 420 | QString::number( date.day() ) + "/" + |
399 | QString::number( date.year() ); | 421 | QString::number( date.year() ); |
400 | ( void ) new QListViewItem( tranTable, QString::number( highTranNum ), datestr, | 422 | ( void ) new QListViewItem( tranTable, QString::number( highTranNum ), datestr, |
401 | traninfo->desc(), stramount ); | 423 | traninfo->desc(), stramount ); |
402 | 424 | ||
403 | adjustBalance( amount ); | 425 | adjustBalance( amount ); |
404 | } | 426 | } |
405 | else | 427 | else |
406 | { | 428 | { |
407 | highTranNum--; | 429 | highTranNum--; |
408 | delete traninfo; | 430 | delete traninfo; |
409 | } | 431 | } |
410 | } | 432 | } |
411 | 433 | ||
412 | void Checkbook::slotEditTran() | 434 | void Checkbook::slotEditTran() |
413 | { | 435 | { |
414 | bool ok; | 436 | bool ok; |
415 | QListViewItem *curritem = tranTable->currentItem(); | 437 | QListViewItem *curritem = tranTable->currentItem(); |
416 | if ( !curritem ) | 438 | if ( !curritem ) |
417 | { | 439 | { |
418 | return; | 440 | return; |
419 | } | 441 | } |
420 | 442 | ||
421 | int tranid = curritem->text( 0 ).toInt( &ok ); | 443 | int tranid = curritem->text( 0 ).toInt( &ok ); |
422 | TranInfo *traninfo = findTranByID( tranid ); | 444 | TranInfo *traninfo = findTranByID( tranid ); |
423 | float origamt = traninfo->amount(); | 445 | float origamt = traninfo->amount(); |
424 | if ( traninfo->withdrawal() ) | 446 | if ( traninfo->withdrawal() ) |
425 | { | 447 | { |
426 | origamt *= -1; | 448 | origamt *= -1; |
427 | } | 449 | } |
428 | 450 | ||
429 | Transaction *currtran = new Transaction( this, name, | 451 | Transaction *currtran = new Transaction( this, name, |
430 | traninfo, | 452 | traninfo, |
431 | currencySymbol ); | 453 | currencySymbol ); |
432 | currtran->showMaximized(); | 454 | currtran->showMaximized(); |
433 | if ( currtran->exec() == QDialog::Accepted ) | 455 | if ( currtran->exec() == QDialog::Accepted ) |
434 | { | 456 | { |
435 | QDate date = traninfo->date(); | 457 | QDate date = traninfo->date(); |
436 | QString datestr = QString::number( date.month() ) + "/" + | 458 | QString datestr = QString::number( date.month() ) + "/" + |
437 | QString::number( date.day() ) + "/" + | 459 | QString::number( date.day() ) + "/" + |
438 | QString::number( date.year() ); | 460 | QString::number( date.year() ); |
439 | curritem->setText( 1, datestr ); | 461 | curritem->setText( 1, datestr ); |
440 | 462 | ||
441 | curritem->setText( 2, traninfo->desc() ); | 463 | curritem->setText( 2, traninfo->desc() ); |
442 | 464 | ||
443 | float amount = traninfo->amount(); | 465 | float amount = traninfo->amount(); |
444 | if ( traninfo->withdrawal() ) | 466 | if ( traninfo->withdrawal() ) |
445 | { | 467 | { |
446 | amount *= -1; | 468 | amount *= -1; |
447 | } | 469 | } |
448 | adjustBalance( origamt * -1 ); | 470 | adjustBalance( origamt * -1 ); |
449 | adjustBalance( amount ); | 471 | adjustBalance( amount ); |
450 | QString stramount; | 472 | QString stramount; |
451 | stramount.sprintf( "%c%.2f", currencySymbol, amount ); | 473 | stramount.sprintf( "%c%.2f", currencySymbol, amount ); |
452 | curritem->setText( 3, stramount ); | 474 | curritem->setText( 3, stramount ); |
453 | 475 | ||
454 | balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) ); | 476 | balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) ); |
455 | 477 | ||
456 | delete currtran; | 478 | delete currtran; |
457 | } | 479 | } |
458 | } | 480 | } |
459 | 481 | ||
460 | void Checkbook::slotDeleteTran() | 482 | void Checkbook::slotDeleteTran() |
461 | { | 483 | { |
462 | QListViewItem *curritem = tranTable->currentItem(); | 484 | QListViewItem *curritem = tranTable->currentItem(); |
463 | if ( !curritem ) | 485 | if ( !curritem ) |
464 | { | 486 | { |
465 | return; | 487 | return; |
466 | } | 488 | } |
467 | 489 | ||
468 | bool ok; | 490 | bool ok; |
469 | int tranid = curritem->text( 0 ).toInt( &ok ); | 491 | int tranid = curritem->text( 0 ).toInt( &ok ); |
470 | //TranInfo *traninfo = transactions.at( tranid - 1 ); | 492 | //TranInfo *traninfo = transactions.at( tranid - 1 ); |
471 | TranInfo *traninfo = findTranByID( tranid ); | 493 | TranInfo *traninfo = findTranByID( tranid ); |
472 | 494 | ||
473 | if ( QPEMessageBox::confirmDelete ( this, tr( "Delete transaction" ), traninfo->desc() ) ) | 495 | if ( QPEMessageBox::confirmDelete ( this, tr( "Delete transaction" ), traninfo->desc() ) ) |
474 | { | 496 | { |
475 | float amount = traninfo->amount(); | 497 | float amount = traninfo->amount(); |
476 | if ( traninfo->withdrawal() ) | 498 | if ( traninfo->withdrawal() ) |
477 | { | 499 | { |
478 | amount *= -1; | 500 | amount *= -1; |
479 | } | 501 | } |
480 | 502 | ||
481 | transactions.remove( traninfo ); | 503 | transactions.remove( traninfo ); |
482 | delete traninfo; | 504 | delete traninfo; |
483 | delete curritem; | 505 | delete curritem; |
484 | 506 | ||
485 | adjustBalance( amount * -1 ); | 507 | adjustBalance( amount * -1 ); |
486 | } | 508 | } |
487 | } | 509 | } |
488 | 510 | ||
489 | void Checkbook::slotDrawGraph() | 511 | void Checkbook::slotDrawGraph() |
490 | { | 512 | { |
491 | } | 513 | } |
diff --git a/noncore/apps/checkbook/mainwindow.cpp b/noncore/apps/checkbook/mainwindow.cpp index 9410536..ead17b4 100644 --- a/noncore/apps/checkbook/mainwindow.cpp +++ b/noncore/apps/checkbook/mainwindow.cpp | |||
@@ -1,164 +1,163 @@ | |||
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 <williamsdr@acm.org> | 4 | .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.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 "checkbook.h" | 30 | #include "checkbook.h" |
31 | 31 | ||
32 | #include <qpe/global.h> | 32 | #include <qpe/global.h> |
33 | #include <qpe/qpeapplication.h> | 33 | #include <qpe/qpeapplication.h> |
34 | #include <qpe/qpemenubar.h> | 34 | #include <qpe/qpemenubar.h> |
35 | #include <qpe/qpemessagebox.h> | 35 | #include <qpe/qpemessagebox.h> |
36 | #include <qpe/qpetoolbar.h> | 36 | #include <qpe/qpetoolbar.h> |
37 | #include <qpe/resource.h> | 37 | #include <qpe/resource.h> |
38 | 38 | ||
39 | #include <qaction.h> | 39 | #include <qaction.h> |
40 | #include <qdir.h> | 40 | #include <qdir.h> |
41 | #include <qlistbox.h> | 41 | #include <qlistbox.h> |
42 | #include <qpopupmenu.h> | 42 | #include <qpopupmenu.h> |
43 | #include <qstring.h> | 43 | #include <qstring.h> |
44 | #include <qwhatsthis.h> | ||
44 | 45 | ||
45 | MainWindow::MainWindow() | 46 | MainWindow::MainWindow() |
46 | : QMainWindow() | 47 | : QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) |
47 | { | 48 | { |
48 | setCaption( tr( "Checkbook" ) ); | 49 | setCaption( tr( "Checkbook" ) ); |
49 | 50 | ||
50 | cbDir = Global::applicationFileName( "checkbook", "" ); | 51 | cbDir = Global::applicationFileName( "checkbook", "" ); |
51 | 52 | ||
52 | // Build menu and tool bars | 53 | // Build menu and tool bars |
53 | setToolBarsMovable( FALSE ); | 54 | setToolBarsMovable( FALSE ); |
54 | 55 | ||
55 | QPEToolBar *bar = new QPEToolBar( this ); | 56 | QPEToolBar *bar = new QPEToolBar( this ); |
56 | bar->setHorizontalStretchable( TRUE ); | 57 | bar->setHorizontalStretchable( TRUE ); |
57 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 58 | QPEMenuBar *mb = new QPEMenuBar( bar ); |
58 | mb->setMargin( 0 ); | 59 | mb->setMargin( 0 ); |
59 | QPopupMenu *popup = new QPopupMenu( this ); | 60 | QPopupMenu *popup = new QPopupMenu( this ); |
60 | 61 | ||
61 | bar = new QPEToolBar( this ); | 62 | bar = new QPEToolBar( this ); |
62 | actionOpen = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, | ||
63 | 0, this, 0 ); | ||
64 | connect( actionOpen, SIGNAL( activated() ), this, SLOT( slotOpen() ) ); | ||
65 | actionOpen->addTo( popup ); | ||
66 | actionOpen->addTo( bar ); | ||
67 | |||
68 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); | 63 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
64 | a->setWhatsThis( tr( "Click here to create a new checkbook.\n\nYou also can select New from the Checkbook menu." ) ); | ||
69 | connect( a, SIGNAL( activated() ), this, SLOT( slotNew() ) ); | 65 | connect( a, SIGNAL( activated() ), this, SLOT( slotNew() ) ); |
70 | a->addTo( popup ); | 66 | a->addTo( popup ); |
71 | a->addTo( bar ); | 67 | a->addTo( bar ); |
72 | 68 | ||
73 | actionDelete = new QAction( tr( "Delete" ), Resource::loadPixmap( "editdelete" ), QString::null, | 69 | actionOpen = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, |
70 | 0, this, 0 ); | ||
71 | actionOpen->setWhatsThis( tr( "Select a checkbook and then click here to edit it.\n\nYou also can select Edit from the Checkbook menu, or click and hold on a checkbook name." ) ); | ||
72 | connect( actionOpen, SIGNAL( activated() ), this, SLOT( slotEdit() ) ); | ||
73 | actionOpen->addTo( popup ); | ||
74 | actionOpen->addTo( bar ); | ||
75 | |||
76 | actionDelete = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, | ||
74 | 0, this, 0 ); | 77 | 0, this, 0 ); |
78 | actionDelete->setWhatsThis( tr( "Select a checkbook and then click here delete it.\n\nYou also can select Delete from the Checkbook menu." ) ); | ||
75 | connect( actionDelete, SIGNAL( activated() ), this, SLOT( slotDelete() ) ); | 79 | connect( actionDelete, SIGNAL( activated() ), this, SLOT( slotDelete() ) ); |
76 | actionDelete->addTo( popup ); | 80 | actionDelete->addTo( popup ); |
77 | actionDelete->addTo( bar ); | 81 | actionDelete->addTo( bar ); |
78 | 82 | ||
79 | popup->insertSeparator(); | ||
80 | |||
81 | a = new QAction( tr( "Exit" ), QString::null, 0, this, 0 ); | ||
82 | connect( a, SIGNAL( activated() ), this, SLOT( close() ) ); | ||
83 | a->addTo( popup ); | ||
84 | |||
85 | mb->insertItem( tr( "Checkbook" ), popup ); | 83 | mb->insertItem( tr( "Checkbook" ), popup ); |
86 | 84 | ||
87 | // Build Checkbook selection list control | 85 | // Build Checkbook selection list control |
88 | cbList = new QListBox( this ); | 86 | cbList = new QListBox( this ); |
87 | QWhatsThis::add( cbList, tr( "This is a listing of all checkbooks currently available." ) ); | ||
89 | QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold ); | 88 | QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold ); |
90 | connect( cbList, SIGNAL( rightButtonPressed( QListBoxItem *, const QPoint & ) ), | 89 | connect( cbList, SIGNAL( rightButtonPressed( QListBoxItem *, const QPoint & ) ), |
91 | this, SLOT( slotOpen() ) ); | 90 | this, SLOT( slotEdit() ) ); |
92 | setCentralWidget( cbList ); | 91 | setCentralWidget( cbList ); |
93 | 92 | ||
94 | // Load Checkbook selection list | 93 | // Load Checkbook selection list |
95 | QDir checkdir( cbDir ); | 94 | QDir checkdir( cbDir ); |
96 | if (checkdir.exists() == true) | 95 | if (checkdir.exists() == true) |
97 | { | 96 | { |
98 | QStringList checkbooks = checkdir.entryList( "*.qcb", QDir::Files|QDir::Readable|QDir::Writable, | 97 | QStringList checkbooks = checkdir.entryList( "*.qcb", QDir::Files|QDir::Readable|QDir::Writable, |
99 | QDir::Time ); | 98 | QDir::Time ); |
100 | for ( QStringList::Iterator it = checkbooks.begin(); it != checkbooks.end(); it++ ) | 99 | for ( QStringList::Iterator it = checkbooks.begin(); it != checkbooks.end(); it++ ) |
101 | { | 100 | { |
102 | (*it) = (*it).remove( (*it).find('.'), (*it).length() ); | 101 | (*it) = (*it).remove( (*it).find('.'), (*it).length() ); |
103 | } | 102 | } |
104 | cbList->insertStringList( checkbooks ); | 103 | cbList->insertStringList( checkbooks ); |
105 | } | 104 | } |
106 | cbList->sort(); | 105 | cbList->sort(); |
107 | cbList->setSelected( 0, TRUE ); | 106 | cbList->setSelected( 0, TRUE ); |
108 | 107 | ||
109 | currencySymbol = '$'; | 108 | currencySymbol = '$'; |
110 | } | 109 | } |
111 | 110 | ||
112 | MainWindow::~MainWindow() | 111 | MainWindow::~MainWindow() |
113 | { | 112 | { |
114 | } | 113 | } |
115 | 114 | ||
116 | void MainWindow::slotOpen() | 115 | void MainWindow::slotNew() |
116 | { | ||
117 | Checkbook *currcb = new Checkbook( this, "", cbDir, currencySymbol ); | ||
118 | currcb->showMaximized(); | ||
119 | if ( currcb->exec() == QDialog::Accepted ) | ||
120 | { | ||
121 | cbList->insertItem( currcb->getName() ); | ||
122 | cbList->sort(); | ||
123 | delete currcb; | ||
124 | } | ||
125 | } | ||
126 | |||
127 | void MainWindow::slotEdit() | ||
117 | { | 128 | { |
118 | QString currname = cbList->currentText(); | 129 | QString currname = cbList->currentText(); |
119 | Checkbook *currcb = new Checkbook( this, currname, cbDir, currencySymbol ); | 130 | Checkbook *currcb = new Checkbook( this, currname, cbDir, currencySymbol ); |
120 | currcb->showMaximized(); | 131 | currcb->showMaximized(); |
121 | if ( currcb->exec() == QDialog::Accepted ) | 132 | if ( currcb->exec() == QDialog::Accepted ) |
122 | { | 133 | { |
123 | QString newname = currcb->getName(); | 134 | QString newname = currcb->getName(); |
124 | if ( currname != newname ) | 135 | if ( currname != newname ) |
125 | { | 136 | { |
126 | cbList->changeItem( newname, cbList->currentItem() ); | 137 | cbList->changeItem( newname, cbList->currentItem() ); |
127 | cbList->sort(); | 138 | cbList->sort(); |
128 | 139 | ||
129 | QFile f( cbDir + currname + ".qcb" ); | 140 | QFile f( cbDir + currname + ".qcb" ); |
130 | if ( f.exists() ) | 141 | if ( f.exists() ) |
131 | { | 142 | { |
132 | f.remove(); | 143 | f.remove(); |
133 | } | 144 | } |
134 | } | 145 | } |
135 | delete currcb; | 146 | delete currcb; |
136 | } | 147 | } |
137 | } | 148 | } |
138 | 149 | ||
139 | void MainWindow::slotNew() | ||
140 | { | ||
141 | Checkbook *currcb = new Checkbook( this, "", cbDir, currencySymbol ); | ||
142 | currcb->showMaximized(); | ||
143 | if ( currcb->exec() == QDialog::Accepted ) | ||
144 | { | ||
145 | cbList->insertItem( currcb->getName() ); | ||
146 | cbList->sort(); | ||
147 | delete currcb; | ||
148 | } | ||
149 | } | ||
150 | |||
151 | void MainWindow::slotDelete() | 150 | void MainWindow::slotDelete() |
152 | { | 151 | { |
153 | if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), cbList->currentText() ) ) | 152 | if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), cbList->currentText() ) ) |
154 | { | 153 | { |
155 | cbList->removeItem( cbList->currentItem() ); | ||
156 | |||
157 | QString name = cbDir + cbList->currentText() + ".qcb"; | 154 | QString name = cbDir + cbList->currentText() + ".qcb"; |
158 | QFile f( name ); | 155 | QFile f( name ); |
159 | if ( f.exists() ) | 156 | if ( f.exists() ) |
160 | { | 157 | { |
161 | f.remove(); | 158 | f.remove(); |
162 | } | 159 | } |
160 | |||
161 | cbList->removeItem( cbList->currentItem() ); | ||
163 | } | 162 | } |
164 | } | 163 | } |
diff --git a/noncore/apps/checkbook/mainwindow.h b/noncore/apps/checkbook/mainwindow.h index 54fbba6..2c5d93b 100644 --- a/noncore/apps/checkbook/mainwindow.h +++ b/noncore/apps/checkbook/mainwindow.h | |||
@@ -1,60 +1,60 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | =. | 3 | =. |
4 | .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> | 4 | .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This file is free software; you can | 6 | _;:, .> :=|. This file is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This file is distributed in the hope that | 13 | .i_,=:_. -<s. This file is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef MAINWINDOW_H | 29 | #ifndef MAINWINDOW_H |
30 | #define MAINWINDOW_H | 30 | #define MAINWINDOW_H |
31 | 31 | ||
32 | #include <qmainwindow.h> | 32 | #include <qmainwindow.h> |
33 | 33 | ||
34 | class QAction; | 34 | class QAction; |
35 | class QListBox; | 35 | class QListBox; |
36 | class QListBoxItem; | 36 | class QListBoxItem; |
37 | class QString; | 37 | class QString; |
38 | 38 | ||
39 | class MainWindow : public QMainWindow | 39 | class MainWindow : public QMainWindow |
40 | { | 40 | { |
41 | Q_OBJECT | 41 | Q_OBJECT |
42 | 42 | ||
43 | public: | 43 | public: |
44 | MainWindow(); | 44 | MainWindow(); |
45 | ~MainWindow(); | 45 | ~MainWindow(); |
46 | 46 | ||
47 | private: | 47 | private: |
48 | QListBox *cbList; | 48 | QListBox *cbList; |
49 | QString cbDir; | 49 | QString cbDir; |
50 | QAction *actionOpen; | 50 | QAction *actionOpen; |
51 | QAction *actionDelete; | 51 | QAction *actionDelete; |
52 | char currencySymbol; | 52 | char currencySymbol; |
53 | 53 | ||
54 | private slots: | 54 | private slots: |
55 | void slotOpen(); | ||
56 | void slotNew(); | 55 | void slotNew(); |
56 | void slotEdit(); | ||
57 | void slotDelete(); | 57 | void slotDelete(); |
58 | }; | 58 | }; |
59 | 59 | ||
60 | #endif | 60 | #endif |
diff --git a/noncore/apps/checkbook/transaction.cpp b/noncore/apps/checkbook/transaction.cpp index 7d1781b..82baec9 100644 --- a/noncore/apps/checkbook/transaction.cpp +++ b/noncore/apps/checkbook/transaction.cpp | |||
@@ -1,260 +1,277 @@ | |||
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 <williamsdr@acm.org> | 4 | .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This file is free software; you can | 6 | _;:, .> :=|. This file is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This file is distributed in the hope that | 13 | .i_,=:_. -<s. This file is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "transaction.h" | 29 | #include "transaction.h" |
30 | #include "traninfo.h" | 30 | #include "traninfo.h" |
31 | 31 | ||
32 | #include <qpe/datebookmonth.h> | 32 | #include <qpe/datebookmonth.h> |
33 | #include <qpe/timestring.h> | 33 | #include <qpe/timestring.h> |
34 | 34 | ||
35 | #include <qbuttongroup.h> | 35 | #include <qbuttongroup.h> |
36 | #include <qcombobox.h> | 36 | #include <qcombobox.h> |
37 | #include <qlabel.h> | 37 | #include <qlabel.h> |
38 | #include <qlayout.h> | 38 | #include <qlayout.h> |
39 | #include <qlineedit.h> | 39 | #include <qlineedit.h> |
40 | #include <qmultilineedit.h> | 40 | #include <qmultilineedit.h> |
41 | #include <qpopupmenu.h> | 41 | #include <qpopupmenu.h> |
42 | #include <qpushbutton.h> | 42 | #include <qpushbutton.h> |
43 | #include <qradiobutton.h> | 43 | #include <qradiobutton.h> |
44 | #include <qscrollview.h> | 44 | #include <qscrollview.h> |
45 | #include <qstring.h> | 45 | #include <qstring.h> |
46 | 46 | #include <qwhatsthis.h> | |
47 | #include <stdio.h> | ||
48 | 47 | ||
49 | Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *info, | 48 | Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *info, |
50 | char symbol ) | 49 | char symbol ) |
51 | : QDialog( parent, 0, TRUE, 0 ) | 50 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) |
52 | { | 51 | { |
53 | setCaption( tr( "Transaction for " ) + acctname ); | 52 | setCaption( tr( "Transaction for " ) + acctname ); |
54 | 53 | ||
55 | tran = info; | 54 | tran = info; |
56 | currencySymbol = symbol; | 55 | currencySymbol = symbol; |
57 | 56 | ||
58 | QVBoxLayout *vb = new QVBoxLayout( this ); | 57 | QVBoxLayout *vb = new QVBoxLayout( this ); |
59 | 58 | ||
60 | QScrollView *sv = new QScrollView( this ); | 59 | QScrollView *sv = new QScrollView( this ); |
61 | vb->addWidget( sv, 0, 0 ); | 60 | vb->addWidget( sv, 0, 0 ); |
62 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 61 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
63 | sv->setFrameStyle( QFrame::NoFrame ); | 62 | sv->setFrameStyle( QFrame::NoFrame ); |
64 | 63 | ||
65 | QWidget *container = new QWidget( sv->viewport() ); | 64 | QWidget *container = new QWidget( sv->viewport() ); |
66 | sv->addChild( container ); | 65 | sv->addChild( container ); |
67 | 66 | ||
68 | QGridLayout *layout = new QGridLayout( container ); | 67 | QGridLayout *layout = new QGridLayout( container ); |
69 | layout->setSpacing( 2 ); | 68 | layout->setSpacing( 2 ); |
70 | layout->setMargin( 4 ); | 69 | layout->setMargin( 4 ); |
71 | 70 | ||
72 | // Withdrawal/Deposit | 71 | // Withdrawal/Deposit |
73 | QButtonGroup *btngrp = new QButtonGroup( container ); | 72 | QButtonGroup *btngrp = new QButtonGroup( container ); |
74 | btngrp->setColumnLayout(0, Qt::Vertical ); | 73 | btngrp->setColumnLayout(0, Qt::Vertical ); |
75 | btngrp->layout()->setSpacing( 0 ); | 74 | btngrp->layout()->setSpacing( 0 ); |
76 | btngrp->layout()->setMargin( 0 ); | 75 | btngrp->layout()->setMargin( 0 ); |
77 | btngrp->setMaximumWidth( 220 ); | 76 | btngrp->setMaximumWidth( 220 ); |
78 | QGridLayout *layout2 = new QGridLayout( btngrp->layout() ); | 77 | QGridLayout *layout2 = new QGridLayout( btngrp->layout() ); |
79 | layout2->setSpacing( 2 ); | 78 | layout2->setSpacing( 2 ); |
80 | layout2->setMargin( 2 ); | 79 | layout2->setMargin( 2 ); |
81 | withBtn = new QRadioButton( tr( "Withdrawal" ), btngrp ); | 80 | withBtn = new QRadioButton( tr( "Withdrawal" ), btngrp ); |
81 | QWhatsThis::add( withBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) ); | ||
82 | layout2->addWidget( withBtn, 0, 0 ); | 82 | layout2->addWidget( withBtn, 0, 0 ); |
83 | connect( withBtn, SIGNAL( clicked() ), this, SLOT( slotWithdrawalClicked() ) ); | 83 | connect( withBtn, SIGNAL( clicked() ), this, SLOT( slotWithdrawalClicked() ) ); |
84 | depBtn = new QRadioButton( tr( "Deposit" ), btngrp ); | 84 | depBtn = new QRadioButton( tr( "Deposit" ), btngrp ); |
85 | QWhatsThis::add( depBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) ); | ||
85 | layout2->addWidget( depBtn, 0, 1 ); | 86 | layout2->addWidget( depBtn, 0, 1 ); |
86 | btngrp->setMaximumSize( 320, withBtn->height() ); | 87 | btngrp->setMaximumSize( 320, withBtn->height() ); |
87 | connect( depBtn, SIGNAL( clicked() ), this, SLOT( slotDepositClicked() ) ); | 88 | connect( depBtn, SIGNAL( clicked() ), this, SLOT( slotDepositClicked() ) ); |
88 | layout->addMultiCellWidget( btngrp, 0, 0, 0, 3 ); | 89 | layout->addMultiCellWidget( btngrp, 0, 0, 0, 3 ); |
89 | 90 | ||
90 | // Date | 91 | // Date |
91 | QLabel *label = new QLabel( tr( "Date:" ), container ); | 92 | QLabel *label = new QLabel( tr( "Date:" ), container ); |
93 | QWhatsThis::add( label, tr( "Select date of transaction here." ) ); | ||
92 | layout->addWidget( label, 1, 0 ); | 94 | layout->addWidget( label, 1, 0 ); |
93 | dateBtn = new QPushButton( TimeString::shortDate( QDate::currentDate() ), | 95 | dateBtn = new QPushButton( TimeString::shortDate( QDate::currentDate() ), |
94 | container ); | 96 | container ); |
97 | QWhatsThis::add( dateBtn, tr( "Select date of transaction here." ) ); | ||
95 | QPopupMenu *m1 = new QPopupMenu( container ); | 98 | QPopupMenu *m1 = new QPopupMenu( container ); |
96 | datePicker = new DateBookMonth( m1, 0, TRUE ); | 99 | datePicker = new DateBookMonth( m1, 0, TRUE ); |
97 | m1->insertItem( datePicker ); | 100 | m1->insertItem( datePicker ); |
98 | dateBtn->setPopup( m1 ); | 101 | dateBtn->setPopup( m1 ); |
99 | connect( datePicker, SIGNAL( dateClicked( int, int, int ) ), | 102 | connect( datePicker, SIGNAL( dateClicked( int, int, int ) ), |
100 | this, SLOT( slotDateChanged( int, int, int ) ) ); | 103 | this, SLOT( slotDateChanged( int, int, int ) ) ); |
101 | layout->addWidget( dateBtn, 1, 1 ); | 104 | layout->addWidget( dateBtn, 1, 1 ); |
102 | 105 | ||
103 | // Check number | 106 | // Check number |
104 | label = new QLabel( tr( "Number:" ), container ); | 107 | label = new QLabel( tr( "Number:" ), container ); |
108 | QWhatsThis::add( label, tr( "Enter check number here." ) ); | ||
105 | layout->addWidget( label, 1, 2 ); | 109 | layout->addWidget( label, 1, 2 ); |
106 | numEdit = new QLineEdit( container ); | 110 | numEdit = new QLineEdit( container ); |
111 | QWhatsThis::add( numEdit, tr( "Enter check number here." ) ); | ||
107 | numEdit->setMaximumWidth( 40 ); | 112 | numEdit->setMaximumWidth( 40 ); |
108 | layout->addWidget( numEdit, 1, 3 ); | 113 | layout->addWidget( numEdit, 1, 3 ); |
109 | 114 | ||
110 | // Description | 115 | // Description |
111 | label = new QLabel( tr( "Description:" ), container ); | 116 | label = new QLabel( tr( "Description:" ), container ); |
117 | QWhatsThis::add( label, tr( "Enter description of transaction here." ) ); | ||
112 | layout->addWidget( label, 2, 0 ); | 118 | layout->addWidget( label, 2, 0 ); |
113 | descEdit = new QLineEdit( container ); | 119 | descEdit = new QLineEdit( container ); |
120 | QWhatsThis::add( descEdit, tr( "Enter description of transaction here." ) ); | ||
114 | layout->addMultiCellWidget( descEdit, 2, 2, 1, 3 ); | 121 | layout->addMultiCellWidget( descEdit, 2, 2, 1, 3 ); |
115 | 122 | ||
116 | // Category | 123 | // Category |
117 | label = new QLabel( tr( "Category:" ), container ); | 124 | label = new QLabel( tr( "Category:" ), container ); |
125 | QWhatsThis::add( label, tr( "Select transaction category here." ) ); | ||
118 | layout->addWidget( label, 3, 0 ); | 126 | layout->addWidget( label, 3, 0 ); |
119 | catList = new QComboBox( container ); | 127 | catList = new QComboBox( container ); |
128 | QWhatsThis::add( catList, tr( "Select transaction category here." ) ); | ||
120 | layout->addMultiCellWidget( catList, 3, 3, 1, 3 ); | 129 | layout->addMultiCellWidget( catList, 3, 3, 1, 3 ); |
121 | 130 | ||
122 | // Type | 131 | // Type |
123 | label = new QLabel( tr( "Type:" ), container ); | 132 | label = new QLabel( tr( "Type:" ), container ); |
133 | QWhatsThis::add( label, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) ); | ||
124 | layout->addWidget( label, 4, 0 ); | 134 | layout->addWidget( label, 4, 0 ); |
125 | typeList = new QComboBox( container ); | 135 | typeList = new QComboBox( container ); |
136 | QWhatsThis::add( typeList, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) ); | ||
126 | layout->addMultiCellWidget( typeList, 4, 4, 1, 3 ); | 137 | layout->addMultiCellWidget( typeList, 4, 4, 1, 3 ); |
127 | 138 | ||
128 | // Amount | 139 | // Amount |
129 | label = new QLabel( tr( "Amount:" ), container ); | 140 | label = new QLabel( tr( "Amount:" ), container ); |
141 | QWhatsThis::add( label, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) ); | ||
130 | layout->addWidget( label, 5, 0 ); | 142 | layout->addWidget( label, 5, 0 ); |
131 | amtEdit = new QLineEdit( container ); | 143 | amtEdit = new QLineEdit( container ); |
144 | QWhatsThis::add( amtEdit, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) ); | ||
132 | layout->addMultiCellWidget( amtEdit, 5, 5, 1, 3 ); | 145 | layout->addMultiCellWidget( amtEdit, 5, 5, 1, 3 ); |
133 | 146 | ||
134 | // Fee | 147 | // Fee |
135 | label = new QLabel( tr( "Fee:" ), container ); | 148 | label = new QLabel( tr( "Fee:" ), container ); |
149 | QWhatsThis::add( label, tr( "Enter any fee amount assoiciated with this transaction.\n\nThe value entered should always be positive." ) ); | ||
136 | layout->addWidget( label, 6, 0 ); | 150 | layout->addWidget( label, 6, 0 ); |
137 | feeEdit = new QLineEdit( container ); | 151 | feeEdit = new QLineEdit( container ); |
152 | QWhatsThis::add( feeEdit, tr( "Enter any fee amount assoiciated with this transaction.\n\nThe value entered should always be positive." ) ); | ||
138 | layout->addMultiCellWidget( feeEdit, 6, 6, 1, 3 ); | 153 | layout->addMultiCellWidget( feeEdit, 6, 6, 1, 3 ); |
139 | 154 | ||
140 | // Notes | 155 | // Notes |
141 | label = new QLabel( tr( "Notes:" ), container ); | 156 | label = new QLabel( tr( "Notes:" ), container ); |
157 | QWhatsThis::add( label, tr( "Enter any additional information for this transaction here." ) ); | ||
142 | layout->addWidget( label, 7, 0 ); | 158 | layout->addWidget( label, 7, 0 ); |
143 | noteEdit = new QMultiLineEdit( container ); | 159 | noteEdit = new QMultiLineEdit( container ); |
160 | QWhatsThis::add( noteEdit, tr( "Enter any additional information for this transaction here." ) ); | ||
144 | layout->addMultiCellWidget( noteEdit, 8, 8, 0, 3 ); | 161 | layout->addMultiCellWidget( noteEdit, 8, 8, 0, 3 ); |
145 | 162 | ||
146 | // Populate current values if provided | 163 | // Populate current values if provided |
147 | if ( info ) | 164 | if ( info ) |
148 | { | 165 | { |
149 | if ( info->withdrawal() ) | 166 | if ( info->withdrawal() ) |
150 | { | 167 | { |
151 | withBtn->setChecked( TRUE ); | 168 | withBtn->setChecked( TRUE ); |
152 | slotWithdrawalClicked(); | 169 | slotWithdrawalClicked(); |
153 | } | 170 | } |
154 | else | 171 | else |
155 | { | 172 | { |
156 | depBtn->setChecked( TRUE ); | 173 | depBtn->setChecked( TRUE ); |
157 | slotDepositClicked(); | 174 | slotDepositClicked(); |
158 | } | 175 | } |
159 | QDate dt = info->date(); | 176 | QDate dt = info->date(); |
160 | slotDateChanged( dt.year(), dt.month(), dt.day() ); | 177 | slotDateChanged( dt.year(), dt.month(), dt.day() ); |
161 | datePicker->setDate( dt ); | 178 | datePicker->setDate( dt ); |
162 | numEdit->setText( info->number() ); | 179 | numEdit->setText( info->number() ); |
163 | descEdit->setText( info->desc() ); | 180 | descEdit->setText( info->desc() ); |
164 | QString temptext = info->category(); | 181 | QString temptext = info->category(); |
165 | int i = catList->count(); | 182 | int i = catList->count(); |
166 | while ( i > 0 ) | 183 | while ( i > 0 ) |
167 | { | 184 | { |
168 | i--; | 185 | i--; |
169 | catList->setCurrentItem( i ); | 186 | catList->setCurrentItem( i ); |
170 | if ( catList->currentText() == temptext ) | 187 | if ( catList->currentText() == temptext ) |
171 | { | 188 | { |
172 | break; | 189 | break; |
173 | } | 190 | } |
174 | } | 191 | } |
175 | temptext = info->type(); | 192 | temptext = info->type(); |
176 | i = typeList->count(); | 193 | i = typeList->count(); |
177 | while ( i > 0 ) | 194 | while ( i > 0 ) |
178 | { | 195 | { |
179 | i--; | 196 | i--; |
180 | typeList->setCurrentItem( i ); | 197 | typeList->setCurrentItem( i ); |
181 | if ( typeList->currentText() == temptext ) | 198 | if ( typeList->currentText() == temptext ) |
182 | { | 199 | { |
183 | break; | 200 | break; |
184 | } | 201 | } |
185 | } | 202 | } |
186 | amtEdit->setText( QString( "%1" ).arg( info->amount(), 0, 'f', 2 ) ); | 203 | amtEdit->setText( QString( "%1" ).arg( info->amount(), 0, 'f', 2 ) ); |
187 | feeEdit->setText( QString( "%1" ).arg( info->fee(), 0, 'f', 2 ) ); | 204 | feeEdit->setText( QString( "%1" ).arg( info->fee(), 0, 'f', 2 ) ); |
188 | noteEdit->setText( info->notes() ); | 205 | noteEdit->setText( info->notes() ); |
189 | } | 206 | } |
190 | else | 207 | else |
191 | { | 208 | { |
192 | withBtn->setChecked( TRUE ); | 209 | withBtn->setChecked( TRUE ); |
193 | } | 210 | } |
194 | } | 211 | } |
195 | 212 | ||
196 | Transaction::~Transaction() | 213 | Transaction::~Transaction() |
197 | { | 214 | { |
198 | } | 215 | } |
199 | 216 | ||
200 | void Transaction::accept() | 217 | void Transaction::accept() |
201 | { | 218 | { |
202 | tran->setDesc( descEdit->text() ); | 219 | tran->setDesc( descEdit->text() ); |
203 | tran->setDate( datePicker->selectedDate() ); | 220 | tran->setDate( datePicker->selectedDate() ); |
204 | tran->setWithdrawal( withBtn->isChecked() ); | 221 | tran->setWithdrawal( withBtn->isChecked() ); |
205 | tran->setType( typeList->currentText() ); | 222 | tran->setType( typeList->currentText() ); |
206 | tran->setCategory( catList->currentText() ); | 223 | tran->setCategory( catList->currentText() ); |
207 | bool ok; | 224 | bool ok; |
208 | tran->setAmount( amtEdit->text().toFloat( &ok ) ); | 225 | tran->setAmount( amtEdit->text().toFloat( &ok ) ); |
209 | tran->setFee( feeEdit->text().toFloat( &ok ) ); | 226 | tran->setFee( feeEdit->text().toFloat( &ok ) ); |
210 | tran->setNumber( numEdit->text() ); | 227 | tran->setNumber( numEdit->text() ); |
211 | tran->setNotes( noteEdit->text() ); | 228 | tran->setNotes( noteEdit->text() ); |
212 | 229 | ||
213 | QDialog::accept(); | 230 | QDialog::accept(); |
214 | } | 231 | } |
215 | 232 | ||
216 | void Transaction::slotWithdrawalClicked() | 233 | void Transaction::slotWithdrawalClicked() |
217 | { | 234 | { |
218 | catList->clear(); | 235 | catList->clear(); |
219 | catList->insertItem( tr( "Automobile" ) ); | 236 | catList->insertItem( tr( "Automobile" ) ); |
220 | catList->insertItem( tr( "Bills" ) ); | 237 | catList->insertItem( tr( "Bills" ) ); |
221 | catList->insertItem( tr( "CDs" ) ); | 238 | catList->insertItem( tr( "CDs" ) ); |
222 | catList->insertItem( tr( "Clothing" ) ); | 239 | catList->insertItem( tr( "Clothing" ) ); |
223 | catList->insertItem( tr( "Computer" ) ); | 240 | catList->insertItem( tr( "Computer" ) ); |
224 | catList->insertItem( tr( "DVDs" ) ); | 241 | catList->insertItem( tr( "DVDs" ) ); |
225 | catList->insertItem( tr( "Eletronics" ) ); | 242 | catList->insertItem( tr( "Eletronics" ) ); |
226 | catList->insertItem( tr( "Entertainment" ) ); | 243 | catList->insertItem( tr( "Entertainment" ) ); |
227 | catList->insertItem( tr( "Food" ) ); | 244 | catList->insertItem( tr( "Food" ) ); |
228 | catList->insertItem( tr( "Gasoline" ) ); | 245 | catList->insertItem( tr( "Gasoline" ) ); |
229 | catList->insertItem( tr( "Misc" ) ); | 246 | catList->insertItem( tr( "Misc" ) ); |
230 | catList->insertItem( tr( "Movies" ) ); | 247 | catList->insertItem( tr( "Movies" ) ); |
231 | catList->insertItem( tr( "Rent" ) ); | 248 | catList->insertItem( tr( "Rent" ) ); |
232 | catList->insertItem( tr( "Travel" ) ); | 249 | catList->insertItem( tr( "Travel" ) ); |
233 | catList->setCurrentItem( 0 ); | 250 | catList->setCurrentItem( 0 ); |
234 | typeList->clear(); | 251 | typeList->clear(); |
235 | typeList->insertItem( tr( "Debit Charge" ) ); | 252 | typeList->insertItem( tr( "Debit Charge" ) ); |
236 | typeList->insertItem( tr( "Written Check" ) ); | 253 | typeList->insertItem( tr( "Written Check" ) ); |
237 | typeList->insertItem( tr( "Transfer" ) ); | 254 | typeList->insertItem( tr( "Transfer" ) ); |
238 | typeList->insertItem( tr( "Credit Card" ) ); | 255 | typeList->insertItem( tr( "Credit Card" ) ); |
239 | } | 256 | } |
240 | 257 | ||
241 | void Transaction::slotDepositClicked() | 258 | void Transaction::slotDepositClicked() |
242 | { | 259 | { |
243 | catList->clear(); | 260 | catList->clear(); |
244 | catList->insertItem( tr( "Work" ) ); | 261 | catList->insertItem( tr( "Work" ) ); |
245 | catList->insertItem( tr( "Family Member" ) ); | 262 | catList->insertItem( tr( "Family Member" ) ); |
246 | catList->insertItem( tr( "Misc. Credit" ) ); | 263 | catList->insertItem( tr( "Misc. Credit" ) ); |
247 | catList->setCurrentItem( 0 ); | 264 | catList->setCurrentItem( 0 ); |
248 | typeList->clear(); | 265 | typeList->clear(); |
249 | typeList->insertItem( tr( "Written Check" ) ); | 266 | typeList->insertItem( tr( "Written Check" ) ); |
250 | typeList->insertItem( tr( "Automatic Payment" ) ); | 267 | typeList->insertItem( tr( "Automatic Payment" ) ); |
251 | typeList->insertItem( tr( "Transfer" ) ); | 268 | typeList->insertItem( tr( "Transfer" ) ); |
252 | typeList->insertItem( tr( "Cash" ) ); | 269 | typeList->insertItem( tr( "Cash" ) ); |
253 | } | 270 | } |
254 | 271 | ||
255 | void Transaction::slotDateChanged( int y, int m, int d ) | 272 | void Transaction::slotDateChanged( int y, int m, int d ) |
256 | { | 273 | { |
257 | QDate date; | 274 | QDate date; |
258 | date.setYMD( y, m, d ); | 275 | date.setYMD( y, m, d ); |
259 | dateBtn->setText( TimeString::shortDate( date ) ); | 276 | dateBtn->setText( TimeString::shortDate( date ) ); |
260 | } | 277 | } |