author | drw <drw> | 2002-11-02 01:29:30 (UTC) |
---|---|---|
committer | drw <drw> | 2002-11-02 01:29:30 (UTC) |
commit | bf9388acdebf6e55345dff3bd1cd652b45a2202a (patch) (unidiff) | |
tree | 737ca55c9a30a1dde3aa289fd99cac7e4c30a3f7 | |
parent | 6e9225388baa9dfac4ed09f22189cfa98a610d39 (diff) | |
download | opie-bf9388acdebf6e55345dff3bd1cd652b45a2202a.zip opie-bf9388acdebf6e55345dff3bd1cd652b45a2202a.tar.gz opie-bf9388acdebf6e55345dff3bd1cd652b45a2202a.tar.bz2 |
Code updates/fixes
-rw-r--r-- | noncore/apps/checkbook/checkbook.cpp | 59 | ||||
-rw-r--r-- | noncore/apps/checkbook/checkbook.h | 5 | ||||
-rw-r--r-- | noncore/apps/checkbook/checkbook.pro | 42 | ||||
-rw-r--r-- | noncore/apps/checkbook/graph.cpp | 112 | ||||
-rw-r--r-- | noncore/apps/checkbook/graph.h | 63 | ||||
-rw-r--r-- | noncore/apps/checkbook/graphinfo.cpp | 84 | ||||
-rw-r--r-- | noncore/apps/checkbook/graphinfo.h | 82 | ||||
-rw-r--r-- | noncore/apps/checkbook/mainwindow.cpp | 11 | ||||
-rw-r--r-- | noncore/apps/checkbook/traninfo.cpp | 25 | ||||
-rw-r--r-- | noncore/apps/checkbook/traninfo.h | 1 | ||||
-rw-r--r-- | noncore/apps/checkbook/transaction.cpp | 4 |
11 files changed, 430 insertions, 58 deletions
diff --git a/noncore/apps/checkbook/checkbook.cpp b/noncore/apps/checkbook/checkbook.cpp index 4b81c6d..20b42b5 100644 --- a/noncore/apps/checkbook/checkbook.cpp +++ b/noncore/apps/checkbook/checkbook.cpp | |||
@@ -1,513 +1,512 @@ | |||
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 | #include "graph.h" | ||
32 | #include "graphinfo.h" | ||
31 | 33 | ||
32 | #include <opie/otabwidget.h> | 34 | #include <opie/otabwidget.h> |
33 | #include <qpe/config.h> | 35 | #include <qpe/config.h> |
34 | #include <qpe/qpeapplication.h> | 36 | #include <qpe/qpeapplication.h> |
35 | #include <qpe/qpemessagebox.h> | 37 | #include <qpe/qpemessagebox.h> |
36 | #include <qpe/resource.h> | 38 | #include <qpe/resource.h> |
37 | 39 | ||
38 | #include <qcombobox.h> | 40 | #include <qcombobox.h> |
39 | #include <qfile.h> | 41 | #include <qfile.h> |
40 | #include <qlabel.h> | 42 | #include <qlabel.h> |
41 | #include <qlayout.h> | 43 | #include <qlayout.h> |
42 | #include <qlineedit.h> | 44 | #include <qlineedit.h> |
43 | #include <qlistview.h> | 45 | #include <qlistview.h> |
44 | #include <qmultilineedit.h> | 46 | #include <qmultilineedit.h> |
45 | #include <qpushbutton.h> | 47 | #include <qpushbutton.h> |
46 | #include <qwhatsthis.h> | 48 | #include <qwhatsthis.h> |
47 | #include <qwidget.h> | 49 | #include <qwidget.h> |
48 | 50 | ||
49 | Checkbook::Checkbook( QWidget *parent, const QString &n, const QString &fd, char symbol ) | 51 | Checkbook::Checkbook( QWidget *parent, const QString &n, const QString &fd, char symbol ) |
50 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) | 52 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) |
51 | { | 53 | { |
52 | name = n; | 54 | name = n; |
53 | filename = fd + name + ".qcb"; | 55 | filename = fd; |
56 | filename.append( name ); | ||
57 | filename.append( ".qcb" ); | ||
54 | filedir = fd; | 58 | filedir = fd; |
55 | currencySymbol = symbol; | 59 | currencySymbol = symbol; |
56 | currBalance = 0.0; | 60 | currBalance = 0.0; |
57 | 61 | ||
58 | if ( name != "" ) | 62 | if ( name != "" ) |
59 | { | 63 | { |
60 | setCaption( name + " - " + tr( "Checkbook" ) ); | 64 | QString tempstr = name; |
65 | tempstr.append( " - " ); | ||
66 | tempstr.append( tr( "Checkbook" ) ); | ||
67 | setCaption( tempstr ); | ||
61 | } | 68 | } |
62 | else | 69 | else |
63 | { | 70 | { |
64 | setCaption( tr( "New checkbook" ) ); | 71 | setCaption( tr( "New checkbook" ) ); |
65 | } | 72 | } |
66 | 73 | ||
67 | // Setup layout to make everything pretty | 74 | // Setup layout to make everything pretty |
68 | QVBoxLayout *layout = new QVBoxLayout( this ); | 75 | QVBoxLayout *layout = new QVBoxLayout( this ); |
69 | layout->setMargin( 2 ); | 76 | layout->setMargin( 2 ); |
70 | layout->setSpacing( 4 ); | 77 | layout->setSpacing( 4 ); |
71 | 78 | ||
72 | // Setup tabs for all info | 79 | // Setup tabs for all info |
73 | mainWidget = new OTabWidget( this ); | 80 | mainWidget = new OTabWidget( this ); |
74 | layout->addWidget( mainWidget ); | 81 | layout->addWidget( mainWidget ); |
75 | 82 | ||
76 | mainWidget->addTab( initInfo(), "checkbook/infotab", tr( "Info" ) ); | 83 | mainWidget->addTab( initInfo(), "checkbook/infotab", tr( "Info" ) ); |
77 | mainWidget->addTab( initTransactions(), "checkbook/trantab", tr( "Transactions" ) ); | 84 | mainWidget->addTab( initTransactions(), "checkbook/trantab", tr( "Transactions" ) ); |
78 | mainWidget->addTab( initCharts(), "checkbook/charttab", tr( "Charts" ) ); | 85 | mainWidget->addTab( initCharts(), "checkbook/charttab", tr( "Charts" ) ); |
79 | mainWidget->setCurrentTab( tr( "Info" ) ); | 86 | mainWidget->setCurrentTab( tr( "Info" ) ); |
80 | 87 | ||
81 | // Load checkbook information | 88 | // Load checkbook information |
82 | loadCheckbook(); | 89 | loadCheckbook(); |
83 | } | 90 | } |
84 | 91 | ||
85 | Checkbook::~Checkbook() | 92 | Checkbook::~Checkbook() |
86 | { | 93 | { |
87 | } | 94 | } |
88 | 95 | ||
89 | const QString &Checkbook::getName() | 96 | const QString &Checkbook::getName() |
90 | { | 97 | { |
91 | return( name ); | 98 | return( name ); |
92 | } | 99 | } |
93 | 100 | ||
94 | QWidget *Checkbook::initInfo() | 101 | QWidget *Checkbook::initInfo() |
95 | { | 102 | { |
96 | QWidget *control = new QWidget( mainWidget ); | 103 | QWidget *control = new QWidget( mainWidget ); |
97 | 104 | ||
98 | QVBoxLayout *vb = new QVBoxLayout( control ); | 105 | QVBoxLayout *vb = new QVBoxLayout( control ); |
99 | 106 | ||
100 | QScrollView *sv = new QScrollView( control ); | 107 | QScrollView *sv = new QScrollView( control ); |
101 | vb->addWidget( sv, 0, 0 ); | 108 | vb->addWidget( sv, 0, 0 ); |
102 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 109 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
103 | sv->setFrameStyle( QFrame::NoFrame ); | 110 | sv->setFrameStyle( QFrame::NoFrame ); |
104 | 111 | ||
105 | QWidget *container = new QWidget( sv->viewport() ); | 112 | QWidget *container = new QWidget( sv->viewport() ); |
106 | sv->addChild( container ); | 113 | sv->addChild( container ); |
107 | 114 | ||
108 | QGridLayout *layout = new QGridLayout( container ); | 115 | QGridLayout *layout = new QGridLayout( container ); |
109 | layout->setSpacing( 2 ); | 116 | layout->setSpacing( 2 ); |
110 | layout->setMargin( 4 ); | 117 | layout->setMargin( 4 ); |
111 | 118 | ||
112 | // Account name | 119 | // Account name |
113 | QLabel *label = new QLabel( tr( "Name:" ), container ); | 120 | QLabel *label = new QLabel( tr( "Name:" ), container ); |
114 | QWhatsThis::add( label, tr( "Enter name of checkbook here." ) ); | 121 | QWhatsThis::add( label, tr( "Enter name of checkbook here." ) ); |
115 | layout->addWidget( label, 0, 0 ); | 122 | layout->addWidget( label, 0, 0 ); |
116 | nameEdit = new QLineEdit( container ); | 123 | nameEdit = new QLineEdit( container ); |
117 | QWhatsThis::add( nameEdit, tr( "Enter name of checkbook here." ) ); | 124 | QWhatsThis::add( nameEdit, tr( "Enter name of checkbook here." ) ); |
118 | connect( nameEdit, SIGNAL( textChanged( const QString & ) ), | 125 | connect( nameEdit, SIGNAL( textChanged( const QString & ) ), |
119 | this, SLOT( slotNameChanged( const QString & ) ) ); | 126 | this, SLOT( slotNameChanged( const QString & ) ) ); |
120 | layout->addWidget( nameEdit, 0, 1 ); | 127 | layout->addWidget( nameEdit, 0, 1 ); |
121 | 128 | ||
122 | // Type of account | 129 | // Type of account |
123 | label = new QLabel( tr( "Type:" ), container ); | 130 | label = new QLabel( tr( "Type:" ), container ); |
124 | QWhatsThis::add( label, tr( "Select type of checkbook here." ) ); | 131 | QWhatsThis::add( label, tr( "Select type of checkbook here." ) ); |
125 | layout->addWidget( label, 1, 0 ); | 132 | layout->addWidget( label, 1, 0 ); |
126 | typeList = new QComboBox( container ); | 133 | typeList = new QComboBox( container ); |
127 | QWhatsThis::add( typeList, tr( "Select type of checkbook here." ) ); | 134 | QWhatsThis::add( typeList, tr( "Select type of checkbook here." ) ); |
128 | typeList->insertItem( tr( "Savings" ) ); // 0 | 135 | typeList->insertItem( tr( "Savings" ) ); // 0 |
129 | typeList->insertItem( tr( "Checking" ) ); // 1 | 136 | typeList->insertItem( tr( "Checking" ) ); // 1 |
130 | typeList->insertItem( tr( "CD" ) ); // 2 | 137 | typeList->insertItem( tr( "CD" ) ); // 2 |
131 | typeList->insertItem( tr( "Money market" ) );// 3 | 138 | typeList->insertItem( tr( "Money market" ) );// 3 |
132 | typeList->insertItem( tr( "Mutual fund" ) );// 4 | 139 | typeList->insertItem( tr( "Mutual fund" ) );// 4 |
133 | typeList->insertItem( tr( "Other" ) ); // 5 | 140 | typeList->insertItem( tr( "Other" ) ); // 5 |
134 | layout->addWidget( typeList, 1, 1 ); | 141 | layout->addWidget( typeList, 1, 1 ); |
135 | 142 | ||
136 | // Bank/institution name | 143 | // Bank/institution name |
137 | label = new QLabel( tr( "Bank:" ), container ); | 144 | label = new QLabel( tr( "Bank:" ), container ); |
138 | QWhatsThis::add( label, tr( "Enter name of the bank for this checkbook here." ) ); | 145 | QWhatsThis::add( label, tr( "Enter name of the bank for this checkbook here." ) ); |
139 | layout->addWidget( label, 2, 0 ); | 146 | layout->addWidget( label, 2, 0 ); |
140 | bankEdit = new QLineEdit( container ); | 147 | bankEdit = new QLineEdit( container ); |
141 | QWhatsThis::add( bankEdit, tr( "Enter name of the bank for this checkbook here." ) ); | 148 | QWhatsThis::add( bankEdit, tr( "Enter name of the bank for this checkbook here." ) ); |
142 | layout->addWidget( bankEdit, 2, 1 ); | 149 | layout->addWidget( bankEdit, 2, 1 ); |
143 | 150 | ||
144 | // Account number | 151 | // Account number |
145 | label = new QLabel( tr( "Account number:" ), container ); | 152 | label = new QLabel( tr( "Account number:" ), container ); |
146 | QWhatsThis::add( label, tr( "Enter account number for this checkbook here." ) ); | 153 | QWhatsThis::add( label, tr( "Enter account number for this checkbook here." ) ); |
147 | layout->addWidget( label, 3, 0 ); | 154 | layout->addWidget( label, 3, 0 ); |
148 | acctNumEdit = new QLineEdit( container ); | 155 | acctNumEdit = new QLineEdit( container ); |
149 | QWhatsThis::add( acctNumEdit, tr( "Enter account number for this checkbook here." ) ); | 156 | QWhatsThis::add( acctNumEdit, tr( "Enter account number for this checkbook here." ) ); |
150 | layout->addWidget( acctNumEdit, 3, 1 ); | 157 | layout->addWidget( acctNumEdit, 3, 1 ); |
151 | 158 | ||
152 | // PIN number | 159 | // PIN number |
153 | label = new QLabel( tr( "PIN number:" ), container ); | 160 | label = new QLabel( tr( "PIN number:" ), container ); |
154 | QWhatsThis::add( label, tr( "Enter PIN number for this checkbook here." ) ); | 161 | QWhatsThis::add( label, tr( "Enter PIN number for this checkbook here." ) ); |
155 | layout->addWidget( label, 4, 0 ); | 162 | layout->addWidget( label, 4, 0 ); |
156 | pinNumEdit = new QLineEdit( container ); | 163 | pinNumEdit = new QLineEdit( container ); |
157 | QWhatsThis::add( pinNumEdit, tr( "Enter PIN number for this checkbook here." ) ); | 164 | QWhatsThis::add( pinNumEdit, tr( "Enter PIN number for this checkbook here." ) ); |
158 | layout->addWidget( pinNumEdit, 4, 1 ); | 165 | layout->addWidget( pinNumEdit, 4, 1 ); |
159 | 166 | ||
160 | // Starting balance | 167 | // Starting balance |
161 | label = new QLabel( tr( "Starting balance:" ), container ); | 168 | label = new QLabel( tr( "Starting balance:" ), container ); |
162 | QWhatsThis::add( label, tr( "Enter the initial balance for this checkbook here." ) ); | 169 | QWhatsThis::add( label, tr( "Enter the initial balance for this checkbook here." ) ); |
163 | layout->addWidget( label, 5, 0 ); | 170 | layout->addWidget( label, 5, 0 ); |
164 | balanceEdit = new QLineEdit( container ); | 171 | balanceEdit = new QLineEdit( container ); |
165 | QWhatsThis::add( balanceEdit, tr( "Enter the initial balance for this checkbook here." ) ); | 172 | QWhatsThis::add( balanceEdit, tr( "Enter the initial balance for this checkbook here." ) ); |
166 | connect( balanceEdit, SIGNAL( textChanged( const QString & ) ), | 173 | connect( balanceEdit, SIGNAL( textChanged( const QString & ) ), |
167 | this, SLOT( slotStartingBalanceChanged( const QString & ) ) ); | 174 | this, SLOT( slotStartingBalanceChanged( const QString & ) ) ); |
168 | layout->addWidget( balanceEdit, 5, 1 ); | 175 | layout->addWidget( balanceEdit, 5, 1 ); |
169 | 176 | ||
170 | // Notes | 177 | // Notes |
171 | label = new QLabel( tr( "Notes:" ), container ); | 178 | label = new QLabel( tr( "Notes:" ), container ); |
172 | QWhatsThis::add( label, tr( "Enter any additional information for this checkbook here." ) ); | 179 | QWhatsThis::add( label, tr( "Enter any additional information for this checkbook here." ) ); |
173 | layout->addWidget( label, 6, 0 ); | 180 | layout->addWidget( label, 6, 0 ); |
174 | notesEdit = new QMultiLineEdit( container ); | 181 | notesEdit = new QMultiLineEdit( container ); |
175 | QWhatsThis::add( notesEdit, tr( "Enter any additional information for this checkbook here." ) ); | 182 | QWhatsThis::add( notesEdit, tr( "Enter any additional information for this checkbook here." ) ); |
176 | notesEdit->setMaximumHeight( 85 ); | 183 | notesEdit->setMaximumHeight( 85 ); |
177 | layout->addMultiCellWidget( notesEdit, 7, 7, 0, 1 ); | 184 | layout->addMultiCellWidget( notesEdit, 7, 7, 0, 1 ); |
178 | 185 | ||
179 | return control; | 186 | return control; |
180 | } | 187 | } |
181 | 188 | ||
182 | QWidget *Checkbook::initTransactions() | 189 | QWidget *Checkbook::initTransactions() |
183 | { | 190 | { |
184 | QWidget *control = new QWidget( mainWidget ); | 191 | QWidget *control = new QWidget( mainWidget ); |
185 | 192 | ||
186 | QGridLayout *layout = new QGridLayout( control ); | 193 | QGridLayout *layout = new QGridLayout( control ); |
187 | layout->setSpacing( 2 ); | 194 | layout->setSpacing( 2 ); |
188 | layout->setMargin( 4 ); | 195 | layout->setMargin( 4 ); |
189 | 196 | ||
190 | balanceLabel = new QLabel( tr( "Current balance: %10.00" ).arg( currencySymbol ), | 197 | balanceLabel = new QLabel( tr( "Current balance: %10.00" ).arg( currencySymbol ), |
191 | control ); | 198 | control ); |
192 | QWhatsThis::add( balanceLabel, tr( "This area shows the current balance in this checkbook." ) ); | 199 | QWhatsThis::add( balanceLabel, tr( "This area shows the current balance in this checkbook." ) ); |
193 | layout->addMultiCellWidget( balanceLabel, 0, 0, 0, 2 ); | 200 | layout->addMultiCellWidget( balanceLabel, 0, 0, 0, 2 ); |
194 | 201 | ||
195 | tranTable = new QListView( control ); | 202 | 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." ) ); | 203 | QWhatsThis::add( tranTable, tr( "This is a listing of all transactions entered for this checkbook.\n\nTo sort entries by a specific field, click on the column name." ) ); |
197 | tranTable->addColumn( tr( "ID" ) ); | 204 | tranTable->addColumn( tr( "ID" ) ); |
198 | tranTable->addColumn( tr( "Date" ) ); | 205 | tranTable->addColumn( tr( "Date" ) ); |
199 | tranTable->addColumn( tr( "Description" ) ); | 206 | tranTable->addColumn( tr( "Description" ) ); |
200 | int colnum = tranTable->addColumn( tr( "Amount" ) ); | 207 | int colnum = tranTable->addColumn( tr( "Amount" ) ); |
201 | tranTable->setColumnAlignment( colnum, Qt::AlignRight ); | 208 | tranTable->setColumnAlignment( colnum, Qt::AlignRight ); |
202 | tranTable->setAllColumnsShowFocus( TRUE ); | 209 | tranTable->setAllColumnsShowFocus( TRUE ); |
203 | layout->addMultiCellWidget( tranTable, 1, 1, 0, 2 ); | 210 | layout->addMultiCellWidget( tranTable, 1, 1, 0, 2 ); |
204 | QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold ); | 211 | QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold ); |
205 | connect( tranTable, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), | 212 | connect( tranTable, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), |
206 | this, SLOT( slotEditTran() ) ); | 213 | this, SLOT( slotEditTran() ) ); |
207 | 214 | ||
208 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), control ); | 215 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), control ); |
209 | QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) ); | 216 | QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) ); |
210 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotNewTran() ) ); | 217 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotNewTran() ) ); |
211 | layout->addWidget( btn, 2, 0 ); | 218 | layout->addWidget( btn, 2, 0 ); |
212 | 219 | ||
213 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), control ); | 220 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), control ); |
214 | QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) ); | 221 | QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) ); |
215 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotEditTran() ) ); | 222 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotEditTran() ) ); |
216 | layout->addWidget( btn, 2, 1 ); | 223 | layout->addWidget( btn, 2, 1 ); |
217 | 224 | ||
218 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), control ); | 225 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), control ); |
219 | QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) ); | 226 | QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) ); |
220 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDeleteTran() ) ); | 227 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDeleteTran() ) ); |
221 | layout->addWidget( btn, 2, 2 ); | 228 | layout->addWidget( btn, 2, 2 ); |
222 | 229 | ||
223 | return( control ); | 230 | return( control ); |
224 | } | 231 | } |
225 | 232 | ||
226 | QWidget *Checkbook::initCharts() | 233 | QWidget *Checkbook::initCharts() |
227 | { | 234 | { |
228 | QWidget *control = new QWidget( mainWidget ); | 235 | QWidget *control = new QWidget( mainWidget ); |
229 | 236 | ||
230 | QGridLayout *layout = new QGridLayout( control ); | 237 | QGridLayout *layout = new QGridLayout( control ); |
231 | layout->setSpacing( 2 ); | 238 | layout->setSpacing( 2 ); |
232 | layout->setMargin( 4 ); | 239 | layout->setMargin( 4 ); |
233 | 240 | ||
234 | /* | 241 | /* |
235 | QLabel *label = new QLabel( control ); | 242 | QLabel *label = new QLabel( control ); |
236 | label->setText( tr( "Graph type:" ) ); | 243 | label->setText( tr( "Graph type:" ) ); |
237 | layout->addWidget( label, 0, 0 ); | 244 | layout->addWidget( label, 0, 0 ); |
238 | graphList = new QComboBox( control ); | 245 | graphList = new QComboBox( control ); |
239 | graphList->insertItem( tr( "By category" ) ); | 246 | graphList->insertItem( tr( "By category" ) ); |
240 | graphList->insertItem( tr( "..." ) ); | 247 | graphList->insertItem( tr( "..." ) ); |
241 | graphList->insertItem( tr( "..." ) ); | 248 | graphList->insertItem( tr( "..." ) ); |
242 | layout->addWidget( graphList, 0, 1 ); | 249 | layout->addWidget( graphList, 0, 1 ); |
243 | */ | 250 | */ |
244 | 251 | ||
245 | QWidget *graphWidget = new QWidget( control ); | 252 | GraphInfo* info = new GraphInfo( GraphInfo::BarChart, 0x0, tr( "Graph Title" ), |
246 | QWhatsThis::add( graphWidget, tr( "Graph not implemented yet." ) ); | 253 | tr( "X-Axis" ), tr( "Y-Axis" ) ); |
254 | graphWidget = new Graph( control, info ); | ||
255 | QWhatsThis::add( graphWidget, tr( "Charting is not implemented yet." ) ); | ||
247 | layout->addMultiCellWidget( graphWidget, 0, 0, 0, 1 ); | 256 | layout->addMultiCellWidget( graphWidget, 0, 0, 0, 1 ); |
248 | graphWidget->setBackgroundMode( QWidget::PaletteBase ); | ||
249 | 257 | ||
250 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/drawbtn" ), tr( "Draw" ), control ); | 258 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/drawbtn" ), tr( "Draw" ), control ); |
251 | QWhatsThis::add( btn, tr( "Click here to draw the graph." ) ); | 259 | QWhatsThis::add( btn, tr( "Click here to draw the chart." ) ); |
252 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) ); | 260 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) ); |
253 | layout->addWidget( btn, 1, 1 ); | 261 | layout->addWidget( btn, 1, 1 ); |
254 | 262 | ||
255 | return control; | 263 | return control; |
256 | } | 264 | } |
257 | 265 | ||
258 | void Checkbook::loadCheckbook() | 266 | void Checkbook::loadCheckbook() |
259 | { | 267 | { |
260 | transactions.clear(); | 268 | transactions.clear(); |
261 | 269 | ||
262 | Config config(filename, Config::File); | 270 | Config config(filename, Config::File); |
263 | 271 | ||
264 | // Load info | 272 | // Load info |
265 | config.setGroup( "Account" ); | 273 | config.setGroup( "Account" ); |
266 | nameEdit->setText( name ); | 274 | nameEdit->setText( name ); |
267 | QString temptext = config.readEntry( "Type" ); | 275 | QString temptext = config.readEntry( "Type" ); |
268 | int i = typeList->count(); | 276 | int i = typeList->count(); |
269 | while ( i > 0 ) | 277 | while ( i > 0 ) |
270 | { | 278 | { |
271 | i--; | 279 | i--; |
272 | typeList->setCurrentItem( i ); | 280 | typeList->setCurrentItem( i ); |
273 | if ( typeList->currentText() == temptext ) | 281 | if ( typeList->currentText() == temptext ) |
274 | { | 282 | { |
275 | break; | 283 | break; |
276 | } | 284 | } |
277 | } | 285 | } |
278 | bankEdit->setText( config.readEntry( "Bank", "" ) ); | 286 | bankEdit->setText( config.readEntry( "Bank", "" ) ); |
279 | acctNumEdit->setText( config.readEntry( "Number", "" ) ); | 287 | acctNumEdit->setText( config.readEntryCrypt( "Number", "" ) ); |
280 | pinNumEdit->setText( config.readEntry( "PINNumber", "" ) ); | 288 | pinNumEdit->setText( config.readEntryCrypt( "PINNumber", "" ) ); |
281 | balanceEdit->setText( config.readEntry( "Balance", "0.0" ) ); | 289 | balanceEdit->setText( config.readEntry( "Balance", "0.0" ) ); |
282 | notesEdit->setText( config.readEntry( "Notes", "" ) ); | 290 | notesEdit->setText( config.readEntry( "Notes", "" ) ); |
283 | 291 | ||
284 | bool ok; | 292 | bool ok; |
285 | currBalance = balanceEdit->text().toFloat( &ok ); | 293 | currBalance = balanceEdit->text().toFloat( &ok ); |
286 | startBalance = currBalance; | 294 | startBalance = currBalance; |
287 | 295 | ||
288 | // Load transactions | 296 | // Load transactions |
289 | TranInfo *tran; | 297 | TranInfo *tran; |
290 | QString trandesc = ""; | 298 | QString trandesc = ""; |
291 | float amount; | 299 | float amount; |
292 | QString stramount; | 300 | QString stramount; |
293 | for ( int i = 1; trandesc != QString::null; i++ ) | 301 | for ( int i = 1; trandesc != QString::null; i++ ) |
294 | { | 302 | { |
295 | tran = new TranInfo( config, i ); | 303 | tran = new TranInfo( config, i ); |
296 | trandesc = tran->desc(); | 304 | trandesc = tran->desc(); |
297 | if ( trandesc != QString::null ) | 305 | if ( trandesc != QString::null ) |
298 | { | 306 | { |
299 | currBalance -= tran->fee(); | 307 | currBalance -= tran->fee(); |
300 | amount = tran->amount(); | 308 | amount = tran->amount(); |
301 | if ( tran->withdrawal() ) | 309 | if ( tran->withdrawal() ) |
302 | { | 310 | { |
303 | amount *= -1; | 311 | amount *= -1; |
304 | } | 312 | } |
305 | currBalance += amount; | 313 | currBalance += amount; |
306 | stramount.sprintf( "%c%.2f", currencySymbol, amount ); | 314 | stramount.sprintf( "%c%.2f", currencySymbol, amount ); |
307 | 315 | ||
308 | // Add to transaction list | 316 | // Add to transaction list |
309 | transactions.append( tran ); | 317 | transactions.append( tran ); |
310 | 318 | ||
311 | // Add to transaction table | 319 | // Add to transaction table |
312 | QDate date = tran->date(); | 320 | ( void ) new QListViewItem( tranTable, QString::number( i ), tran->datestr(), |
313 | QString datestr = QString::number( date.month() ) + "/" + | ||
314 | QString::number( date.day() ) + "/" + | ||
315 | QString::number( date.year() ); | ||
316 | ( void ) new QListViewItem( tranTable, QString::number( i ), datestr, | ||
317 | trandesc, stramount ); | 321 | trandesc, stramount ); |
318 | } | 322 | } |
319 | else | 323 | else |
320 | { | 324 | { |
321 | delete tran; | 325 | delete tran; |
322 | } | 326 | } |
323 | } | 327 | } |
324 | balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) ); | 328 | balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) ); |
325 | 329 | ||
326 | highTranNum = transactions.count(); | 330 | highTranNum = transactions.count(); |
327 | } | 331 | } |
328 | 332 | ||
329 | void Checkbook::adjustBalance( float amount ) | 333 | void Checkbook::adjustBalance( float amount ) |
330 | { | 334 | { |
331 | currBalance += amount; | 335 | currBalance += amount; |
332 | balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) ); | 336 | balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( currBalance, 0, 'f', 2 ) ); |
333 | 337 | ||
334 | } | 338 | } |
335 | 339 | ||
336 | TranInfo *Checkbook::findTranByID( int id ) | 340 | TranInfo *Checkbook::findTranByID( int id ) |
337 | { | 341 | { |
338 | TranInfo *traninfo = transactions.first(); | 342 | TranInfo *traninfo = transactions.first(); |
339 | while ( traninfo && traninfo->id() != id ) | 343 | while ( traninfo && traninfo->id() != id ) |
340 | { | 344 | { |
341 | traninfo = transactions.next(); | 345 | traninfo = transactions.next(); |
342 | } | 346 | } |
343 | return( traninfo ); | 347 | return( traninfo ); |
344 | } | 348 | } |
345 | 349 | ||
346 | void Checkbook::accept() | 350 | void Checkbook::accept() |
347 | { | 351 | { |
348 | QFile f( filename ); | 352 | QFile f( filename ); |
349 | if ( f.exists() ) | 353 | if ( f.exists() ) |
350 | { | 354 | { |
351 | f.remove(); | 355 | f.remove(); |
352 | } | 356 | } |
353 | 357 | ||
354 | Config *config = new Config(filename, Config::File); | 358 | Config *config = new Config(filename, Config::File); |
355 | 359 | ||
356 | // Save info | 360 | // Save info |
357 | config->setGroup( "Account" ); | 361 | config->setGroup( "Account" ); |
358 | config->writeEntry( "Type", typeList->currentText() ); | 362 | config->writeEntry( "Type", typeList->currentText() ); |
359 | config->writeEntry( "Bank", bankEdit->text() ); | 363 | config->writeEntry( "Bank", bankEdit->text() ); |
360 | config->writeEntry( "Number", acctNumEdit->text() ); | 364 | config->writeEntryCrypt( "Number", acctNumEdit->text() ); |
361 | config->writeEntry( "PINNumber", pinNumEdit->text() ); | 365 | config->writeEntryCrypt( "PINNumber", pinNumEdit->text() ); |
362 | config->writeEntry( "Balance", balanceEdit->text() ); | 366 | config->writeEntry( "Balance", balanceEdit->text() ); |
363 | config->writeEntry( "Notes", notesEdit->text() ); | 367 | config->writeEntry( "Notes", notesEdit->text() ); |
364 | 368 | ||
365 | // Save transactions | 369 | // Save transactions |
366 | TranInfo *tran = transactions.first(); | 370 | TranInfo *tran = transactions.first(); |
367 | int i = 1; | 371 | int i = 1; |
368 | while ( tran ) | 372 | while ( tran ) |
369 | { | 373 | { |
370 | tran->write( config, i ); | 374 | tran->write( config, i ); |
371 | tran = transactions.next(); | 375 | tran = transactions.next(); |
372 | i++; | 376 | i++; |
373 | } | 377 | } |
374 | config->write(); | 378 | config->write(); |
375 | 379 | ||
376 | QDialog::accept(); | 380 | QDialog::accept(); |
377 | } | 381 | } |
378 | 382 | ||
379 | void Checkbook::slotNameChanged( const QString &newname ) | 383 | void Checkbook::slotNameChanged( const QString &newname ) |
380 | { | 384 | { |
381 | name = newname; | 385 | name = newname; |
382 | filename = filedir + newname + ".qcb"; | 386 | filename = filedir; |
383 | setCaption( name + " - " + tr( "Checkbook" ) ); | 387 | filename.append( newname ); |
388 | filename.append( ".qcb" ); | ||
389 | QString tempstr = name; | ||
390 | tempstr.append( " - " ); | ||
391 | tempstr.append( tr( "Checkbook" ) ); | ||
392 | setCaption( tempstr ); | ||
384 | } | 393 | } |
385 | 394 | ||
386 | void Checkbook::slotStartingBalanceChanged( const QString &newbalance ) | 395 | void Checkbook::slotStartingBalanceChanged( const QString &newbalance ) |
387 | { | 396 | { |
388 | currBalance -= startBalance; | 397 | currBalance -= startBalance; |
389 | bool ok; | 398 | bool ok; |
390 | startBalance = newbalance.toFloat( &ok ); | 399 | startBalance = newbalance.toFloat( &ok ); |
391 | adjustBalance( startBalance ); | 400 | adjustBalance( startBalance ); |
392 | } | 401 | } |
393 | 402 | ||
394 | void Checkbook::slotNewTran() | 403 | void Checkbook::slotNewTran() |
395 | { | 404 | { |
396 | highTranNum++; | 405 | highTranNum++; |
397 | TranInfo *traninfo = new TranInfo( highTranNum ); | 406 | TranInfo *traninfo = new TranInfo( highTranNum ); |
398 | 407 | ||
399 | Transaction *currtran = new Transaction( this, name, | 408 | Transaction *currtran = new Transaction( this, name, |
400 | traninfo, | 409 | traninfo, |
401 | currencySymbol ); | 410 | currencySymbol ); |
402 | currtran->showMaximized(); | 411 | currtran->showMaximized(); |
403 | if ( currtran->exec() == QDialog::Accepted ) | 412 | if ( currtran->exec() == QDialog::Accepted ) |
404 | { | 413 | { |
405 | float amount = traninfo->amount(); | 414 | float amount = traninfo->amount(); |
406 | if ( traninfo->withdrawal() ) | 415 | if ( traninfo->withdrawal() ) |
407 | { | 416 | { |
408 | amount *= -1; | 417 | amount *= -1; |
409 | } | 418 | } |
410 | QString stramount; | 419 | QString stramount; |
411 | stramount.sprintf( "%c%.2f", currencySymbol, amount ); | 420 | stramount.sprintf( "%c%.2f", currencySymbol, amount ); |
412 | 421 | ||
413 | // Add to transaction list | 422 | // Add to transaction list |
414 | transactions.append( traninfo ); | 423 | transactions.append( traninfo ); |
415 | 424 | ||
416 | // Add to transaction table | 425 | // Add to transaction table |
417 | 426 | ( void ) new QListViewItem( tranTable, QString::number( highTranNum ), | |
418 | QDate date = traninfo->date(); | 427 | traninfo->datestr(), traninfo->desc(), stramount ); |
419 | QString datestr = QString::number( date.month() ) + "/" + | ||
420 | QString::number( date.day() ) + "/" + | ||
421 | QString::number( date.year() ); | ||
422 | ( void ) new QListViewItem( tranTable, QString::number( highTranNum ), datestr, | ||
423 | traninfo->desc(), stramount ); | ||
424 | 428 | ||
425 | adjustBalance( amount ); | 429 | adjustBalance( amount ); |
426 | } | 430 | } |
427 | else | 431 | else |
428 | { | 432 | { |
429 | highTranNum--; | 433 | highTranNum--; |
430 | delete traninfo; | 434 | delete traninfo; |
431 | } | 435 | } |
432 | } | 436 | } |
433 | 437 | ||
434 | void Checkbook::slotEditTran() | 438 | void Checkbook::slotEditTran() |
435 | { | 439 | { |
436 | bool ok; | 440 | bool ok; |
437 | QListViewItem *curritem = tranTable->currentItem(); | 441 | QListViewItem *curritem = tranTable->currentItem(); |
438 | if ( !curritem ) | 442 | if ( !curritem ) |
439 | { | 443 | { |
440 | return; | 444 | return; |
441 | } | 445 | } |
442 | 446 | ||
443 | int tranid = curritem->text( 0 ).toInt( &ok ); | 447 | int tranid = curritem->text( 0 ).toInt( &ok ); |
444 | TranInfo *traninfo = findTranByID( tranid ); | 448 | TranInfo *traninfo = findTranByID( tranid ); |
445 | float origamt = traninfo->amount(); | 449 | float origamt = traninfo->amount(); |
446 | if ( traninfo->withdrawal() ) | 450 | if ( traninfo->withdrawal() ) |
447 | { | 451 | { |
448 | origamt *= -1; | 452 | origamt *= -1; |
449 | } | 453 | } |
450 | 454 | ||
451 | Transaction *currtran = new Transaction( this, name, | 455 | Transaction *currtran = new Transaction( this, name, |
452 | traninfo, | 456 | traninfo, |
453 | currencySymbol ); | 457 | currencySymbol ); |
454 | currtran->showMaximized(); | 458 | currtran->showMaximized(); |
455 | if ( currtran->exec() == QDialog::Accepted ) | 459 | if ( currtran->exec() == QDialog::Accepted ) |
456 | { | 460 | { |
457 | QDate date = traninfo->date(); | 461 | curritem->setText( 1, traninfo->datestr() ); |
458 | QString datestr = QString::number( date.month() ) + "/" + | ||
459 | QString::number( date.day() ) + "/" + | ||
460 | QString::number( date.year() ); | ||
461 | curritem->setText( 1, datestr ); | ||
462 | 462 | ||
463 | curritem->setText( 2, traninfo->desc() ); | 463 | curritem->setText( 2, traninfo->desc() ); |
464 | 464 | ||
465 | float amount = traninfo->amount(); | 465 | float amount = traninfo->amount(); |
466 | if ( traninfo->withdrawal() ) | 466 | if ( traninfo->withdrawal() ) |
467 | { | 467 | { |
468 | amount *= -1; | 468 | amount *= -1; |
469 | } | 469 | } |
470 | adjustBalance( origamt * -1 ); | 470 | adjustBalance( origamt * -1 ); |
471 | adjustBalance( amount ); | 471 | adjustBalance( amount ); |
472 | QString stramount; | 472 | QString stramount; |
473 | stramount.sprintf( "%c%.2f", currencySymbol, amount ); | 473 | stramount.sprintf( "%c%.2f", currencySymbol, amount ); |
474 | curritem->setText( 3, stramount ); | 474 | curritem->setText( 3, stramount ); |
475 | 475 | ||
476 | 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 ) ); |
477 | 477 | ||
478 | delete currtran; | 478 | delete currtran; |
479 | } | 479 | } |
480 | } | 480 | } |
481 | 481 | ||
482 | void Checkbook::slotDeleteTran() | 482 | void Checkbook::slotDeleteTran() |
483 | { | 483 | { |
484 | QListViewItem *curritem = tranTable->currentItem(); | 484 | QListViewItem *curritem = tranTable->currentItem(); |
485 | if ( !curritem ) | 485 | if ( !curritem ) |
486 | { | 486 | { |
487 | return; | 487 | return; |
488 | } | 488 | } |
489 | 489 | ||
490 | bool ok; | 490 | bool ok; |
491 | int tranid = curritem->text( 0 ).toInt( &ok ); | 491 | int tranid = curritem->text( 0 ).toInt( &ok ); |
492 | //TranInfo *traninfo = transactions.at( tranid - 1 ); | ||
493 | TranInfo *traninfo = findTranByID( tranid ); | 492 | TranInfo *traninfo = findTranByID( tranid ); |
494 | 493 | ||
495 | if ( QPEMessageBox::confirmDelete ( this, tr( "Delete transaction" ), traninfo->desc() ) ) | 494 | if ( QPEMessageBox::confirmDelete ( this, tr( "Delete transaction" ), traninfo->desc() ) ) |
496 | { | 495 | { |
497 | float amount = traninfo->amount(); | 496 | float amount = traninfo->amount(); |
498 | if ( traninfo->withdrawal() ) | 497 | if ( traninfo->withdrawal() ) |
499 | { | 498 | { |
500 | amount *= -1; | 499 | amount *= -1; |
501 | } | 500 | } |
502 | 501 | ||
503 | transactions.remove( traninfo ); | 502 | transactions.remove( traninfo ); |
504 | delete traninfo; | 503 | delete traninfo; |
505 | delete curritem; | 504 | delete curritem; |
506 | 505 | ||
507 | adjustBalance( amount * -1 ); | 506 | adjustBalance( amount * -1 ); |
508 | } | 507 | } |
509 | } | 508 | } |
510 | 509 | ||
511 | void Checkbook::slotDrawGraph() | 510 | void Checkbook::slotDrawGraph() |
512 | { | 511 | { |
513 | } | 512 | } |
diff --git a/noncore/apps/checkbook/checkbook.h b/noncore/apps/checkbook/checkbook.h index a86c0f9..01f1115 100644 --- a/noncore/apps/checkbook/checkbook.h +++ b/noncore/apps/checkbook/checkbook.h | |||
@@ -1,102 +1,103 @@ | |||
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 CHECKBOOK_H | 29 | #ifndef CHECKBOOK_H |
30 | #define CHECKBOOK_H | 30 | #define CHECKBOOK_H |
31 | 31 | ||
32 | #include "traninfo.h" | 32 | #include "traninfo.h" |
33 | 33 | ||
34 | #include <qdialog.h> | 34 | #include <qdialog.h> |
35 | 35 | ||
36 | class OTabWidget; | 36 | class OTabWidget; |
37 | 37 | ||
38 | class Graph; | ||
38 | class QComboBox; | 39 | class QComboBox; |
39 | class QLabel; | 40 | class QLabel; |
40 | class QLineEdit; | 41 | class QLineEdit; |
41 | class QListView; | 42 | class QListView; |
42 | class QMultiLineEdit; | 43 | class QMultiLineEdit; |
43 | class QString; | 44 | class QString; |
44 | 45 | ||
45 | class Checkbook : public QDialog | 46 | class Checkbook : public QDialog |
46 | { | 47 | { |
47 | Q_OBJECT | 48 | Q_OBJECT |
48 | 49 | ||
49 | public: | 50 | public: |
50 | Checkbook( QWidget * = 0x0, const QString & = 0x0, const QString & = 0x0, char = '$' ); | 51 | Checkbook( QWidget * = 0x0, const QString & = 0x0, const QString & = 0x0, char = '$' ); |
51 | ~Checkbook(); | 52 | ~Checkbook(); |
52 | 53 | ||
53 | const QString &getName(); | 54 | const QString &getName(); |
54 | 55 | ||
55 | private: | 56 | private: |
56 | TranInfoList transactions; | 57 | TranInfoList transactions; |
57 | QString name; | 58 | QString name; |
58 | QString filename; | 59 | QString filename; |
59 | QString filedir; | 60 | QString filedir; |
60 | char currencySymbol; | 61 | char currencySymbol; |
61 | int highTranNum; | 62 | int highTranNum; |
62 | 63 | ||
63 | OTabWidget *mainWidget; | 64 | OTabWidget *mainWidget; |
64 | void loadCheckbook(); | 65 | void loadCheckbook(); |
65 | void adjustBalance( float ); | 66 | void adjustBalance( float ); |
66 | TranInfo *findTranByID( int ); | 67 | TranInfo *findTranByID( int ); |
67 | 68 | ||
68 | // Info tab | 69 | // Info tab |
69 | QWidget *initInfo(); | 70 | QWidget *initInfo(); |
70 | QLineEdit *nameEdit; | 71 | QLineEdit *nameEdit; |
71 | QComboBox *typeList; | 72 | QComboBox *typeList; |
72 | QLineEdit *bankEdit; | 73 | QLineEdit *bankEdit; |
73 | QLineEdit *acctNumEdit; | 74 | QLineEdit *acctNumEdit; |
74 | QLineEdit *pinNumEdit; | 75 | QLineEdit *pinNumEdit; |
75 | QLineEdit *balanceEdit; | 76 | QLineEdit *balanceEdit; |
76 | QMultiLineEdit *notesEdit; | 77 | QMultiLineEdit *notesEdit; |
77 | float startBalance; | 78 | float startBalance; |
78 | 79 | ||
79 | // Transactions tab | 80 | // Transactions tab |
80 | QWidget *initTransactions(); | 81 | QWidget *initTransactions(); |
81 | QListView *tranTable; | 82 | QListView *tranTable; |
82 | QLabel *balanceLabel; | 83 | QLabel *balanceLabel; |
83 | float currBalance; | 84 | float currBalance; |
84 | 85 | ||
85 | // Charts tab | 86 | // Charts tab |
86 | QWidget *initCharts(); | 87 | QWidget *initCharts(); |
87 | //QComboBox *graphList; | 88 | //QComboBox *graphList; |
88 | QWidget *graphWidget; | 89 | Graph *graphWidget; |
89 | 90 | ||
90 | protected slots: | 91 | protected slots: |
91 | void accept(); | 92 | void accept(); |
92 | 93 | ||
93 | private slots: | 94 | private slots: |
94 | void slotNameChanged( const QString & ); | 95 | void slotNameChanged( const QString & ); |
95 | void slotStartingBalanceChanged( const QString & ); | 96 | void slotStartingBalanceChanged( const QString & ); |
96 | void slotNewTran(); | 97 | void slotNewTran(); |
97 | void slotEditTran(); | 98 | void slotEditTran(); |
98 | void slotDeleteTran(); | 99 | void slotDeleteTran(); |
99 | void slotDrawGraph(); | 100 | void slotDrawGraph(); |
100 | }; | 101 | }; |
101 | 102 | ||
102 | #endif | 103 | #endif |
diff --git a/noncore/apps/checkbook/checkbook.pro b/noncore/apps/checkbook/checkbook.pro index 07cc012..bd69939 100644 --- a/noncore/apps/checkbook/checkbook.pro +++ b/noncore/apps/checkbook/checkbook.pro | |||
@@ -1,32 +1,36 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | CONFIG = qt warn_on release | 2 | CONFIG = qt warn_on release |
3 | HEADERS = mainwindow.h \ | 3 | HEADERS = mainwindow.h \ |
4 | traninfo.h \ | 4 | traninfo.h \ |
5 | checkbook.h \ | 5 | graphinfo.h \ |
6 | transaction.h | 6 | checkbook.h \ |
7 | SOURCES = main.cpp \ | 7 | transaction.h \ |
8 | mainwindow.cpp \ | 8 | graph.h |
9 | traninfo.cpp \ | 9 | SOURCES = main.cpp \ |
10 | checkbook.cpp \ | 10 | mainwindow.cpp \ |
11 | transaction.cpp | 11 | traninfo.cpp \ |
12 | graphinfo.cpp \ | ||
13 | checkbook.cpp \ | ||
14 | transaction.cpp \ | ||
15 | graph.cpp | ||
12 | INCLUDEPATH += $(OPIEDIR)/include | 16 | INCLUDEPATH += $(OPIEDIR)/include |
13 | DEPENDPATH += $(OPIEDIR)/include | 17 | DEPENDPATH += $(OPIEDIR)/include |
14 | LIBS += -lqpe -lopie | 18 | LIBS += -lqpe -lopie |
15 | TARGET = checkbook | 19 | TARGET = checkbook |
16 | DESTDIR = $(OPIEDIR)/bin | 20 | DESTDIR = $(OPIEDIR)/bin |
17 | 21 | ||
18 | TRANSLATIONS = ../../../i18n/de/checkbook.ts \ | 22 | TRANSLATIONS = ../../../i18n/de/checkbook.ts \ |
19 | ../../../i18n/en/checkbook.ts \ | 23 | ../../../i18n/en/checkbook.ts \ |
20 | ../../../i18n/es/checkbook.ts \ | 24 | ../../../i18n/es/checkbook.ts \ |
21 | ../../../i18n/fr/checkbook.ts \ | 25 | ../../../i18n/fr/checkbook.ts \ |
22 | ../../../i18n/hu/checkbook.ts \ | 26 | ../../../i18n/hu/checkbook.ts \ |
23 | ../../../i18n/ja/checkbook.ts \ | 27 | ../../../i18n/ja/checkbook.ts \ |
24 | ../../../i18n/ko/checkbook.ts \ | 28 | ../../../i18n/ko/checkbook.ts \ |
25 | ../../../i18n/no/checkbook.ts \ | 29 | ../../../i18n/no/checkbook.ts \ |
26 | ../../../i18n/pl/checkbook.ts \ | 30 | ../../../i18n/pl/checkbook.ts \ |
27 | ../../../i18n/pt/checkbook.ts \ | 31 | ../../../i18n/pt/checkbook.ts \ |
28 | ../../../i18n/pt_BR/checkbook.ts \ | 32 | ../../../i18n/pt_BR/checkbook.ts \ |
29 | ../../../i18n/sl/checkbook.ts \ | 33 | ../../../i18n/sl/checkbook.ts \ |
30 | ../../../i18n/zh_CN/checkbook.ts \ | 34 | ../../../i18n/zh_CN/checkbook.ts \ |
31 | ../../../i18n/zh_TW/checkbook.ts \ | 35 | ../../../i18n/zh_TW/checkbook.ts \ |
32 | ../../../i18n/it/checkbook.ts | 36 | ../../../i18n/it/checkbook.ts |
diff --git a/noncore/apps/checkbook/graph.cpp b/noncore/apps/checkbook/graph.cpp new file mode 100644 index 0000000..bae92da --- a/dev/null +++ b/noncore/apps/checkbook/graph.cpp | |||
@@ -0,0 +1,112 @@ | |||
1 | /* | ||
2 | This file is part of the OPIE Project | ||
3 | =. | ||
4 | .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> | ||
5 | .>+-= | ||
6 | _;:, .> :=|. This file is free software; you can | ||
7 | .> <`_, > . <= redistribute it and/or modify it under | ||
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
9 | .="- .-=="i, .._ License as published by the Free Software | ||
10 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
11 | ._= =} : or (at your option) any later version. | ||
12 | .%`+i> _;_. | ||
13 | .i_,=:_. -<s. This file is distributed in the hope that | ||
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
15 | : .. .:, . . . without even the implied warranty of | ||
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | ||
18 | ..}^=.= = ; Public License for more details. | ||
19 | ++= -. .` .: | ||
20 | : = ...= . :.=- You should have received a copy of the GNU | ||
21 | -. .:....=;==+<; General Public License along with this file; | ||
22 | -_. . . )=. = see the file COPYING. If not, write to the | ||
23 | -- :-=` Free Software Foundation, Inc., | ||
24 | 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | #include "graph.h" | ||
30 | #include "graphinfo.h" | ||
31 | |||
32 | #include <qpainter.h> | ||
33 | |||
34 | Graph::Graph( QWidget *parent, GraphInfo *d, const QString &name, int flags ) | ||
35 | : QWidget( parent, name, flags ) | ||
36 | { | ||
37 | setBackgroundMode( QWidget::PaletteBase ); | ||
38 | |||
39 | data = d; | ||
40 | |||
41 | graph.setOptimization( QPixmap::BestOptim ); | ||
42 | } | ||
43 | |||
44 | void Graph::setGraphInfo( GraphInfo *d ) | ||
45 | { | ||
46 | data = d; | ||
47 | } | ||
48 | |||
49 | void Graph::drawGraph( bool regen ) | ||
50 | { | ||
51 | if ( regen ) | ||
52 | { | ||
53 | initGraph(); | ||
54 | } | ||
55 | QPainter p( this ); | ||
56 | p.drawPixmap( 0, 0, graph ); | ||
57 | } | ||
58 | |||
59 | void Graph::paintEvent( QPaintEvent * ) | ||
60 | { | ||
61 | drawGraph( FALSE ); | ||
62 | } | ||
63 | |||
64 | void Graph::resizeEvent( QResizeEvent * ) | ||
65 | { | ||
66 | drawGraph( TRUE ); | ||
67 | } | ||
68 | |||
69 | void Graph::initGraph() | ||
70 | { | ||
71 | graph.resize( width(), height() ); | ||
72 | graph.fill( QColor( 255, 255, 255 ) ); | ||
73 | |||
74 | if ( !data ) | ||
75 | { | ||
76 | return; | ||
77 | } | ||
78 | |||
79 | // Any common stuff here (titles, ???) | ||
80 | |||
81 | switch ( data->graphType() ) | ||
82 | { | ||
83 | case GraphInfo::BarChart : | ||
84 | { | ||
85 | drawBarChart(); | ||
86 | } | ||
87 | break; | ||
88 | case GraphInfo::LineChart : | ||
89 | { | ||
90 | drawLineChart(); | ||
91 | } | ||
92 | break; | ||
93 | case GraphInfo::PieChart : | ||
94 | { | ||
95 | drawPieChart(); | ||
96 | } | ||
97 | }; | ||
98 | } | ||
99 | |||
100 | void Graph::drawBarChart() | ||
101 | { | ||
102 | //Find max value in GraphInfo->dataPoints() - make function in GraphInfo!!! | ||
103 | } | ||
104 | |||
105 | void Graph::drawLineChart() | ||
106 | { | ||
107 | } | ||
108 | |||
109 | void Graph::drawPieChart() | ||
110 | { | ||
111 | } | ||
112 | |||
diff --git a/noncore/apps/checkbook/graph.h b/noncore/apps/checkbook/graph.h new file mode 100644 index 0000000..7379be7 --- a/dev/null +++ b/noncore/apps/checkbook/graph.h | |||
@@ -0,0 +1,63 @@ | |||
1 | /* | ||
2 | This file is part of the OPIE Project | ||
3 | =. | ||
4 | .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> | ||
5 | .>+-= | ||
6 | _;:, .> :=|. This file is free software; you can | ||
7 | .> <`_, > . <= redistribute it and/or modify it under | ||
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
9 | .="- .-=="i, .._ License as published by the Free Software | ||
10 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
11 | ._= =} : or (at your option) any later version. | ||
12 | .%`+i> _;_. | ||
13 | .i_,=:_. -<s. This file is distributed in the hope that | ||
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
15 | : .. .:, . . . without even the implied warranty of | ||
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | ||
18 | ..}^=.= = ; Public License for more details. | ||
19 | ++= -. .` .: | ||
20 | : = ...= . :.=- You should have received a copy of the GNU | ||
21 | -. .:....=;==+<; General Public License along with this file; | ||
22 | -_. . . )=. = see the file COPYING. If not, write to the | ||
23 | -- :-=` Free Software Foundation, Inc., | ||
24 | 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | #ifndef GRAPH_H | ||
30 | #define GRAPH_H | ||
31 | |||
32 | #include <qpixmap.h> | ||
33 | #include <qwidget.h> | ||
34 | |||
35 | class GraphInfo; | ||
36 | |||
37 | class Graph : public QWidget | ||
38 | { | ||
39 | Q_OBJECT | ||
40 | |||
41 | public: | ||
42 | Graph( QWidget * = 0x0, GraphInfo * = 0x0, const QString & = 0x0, int = 0 ); | ||
43 | |||
44 | void setGraphInfo( GraphInfo * ); | ||
45 | |||
46 | void drawGraph( bool = FALSE ); | ||
47 | |||
48 | protected: | ||
49 | void paintEvent( QPaintEvent * ); | ||
50 | void resizeEvent( QResizeEvent * ); | ||
51 | |||
52 | private: | ||
53 | GraphInfo *data; | ||
54 | |||
55 | QPixmap graph; | ||
56 | |||
57 | void initGraph(); | ||
58 | void drawBarChart(); | ||
59 | void drawLineChart(); | ||
60 | void drawPieChart(); | ||
61 | }; | ||
62 | |||
63 | #endif | ||
diff --git a/noncore/apps/checkbook/graphinfo.cpp b/noncore/apps/checkbook/graphinfo.cpp new file mode 100644 index 0000000..7b06bdb --- a/dev/null +++ b/noncore/apps/checkbook/graphinfo.cpp | |||
@@ -0,0 +1,84 @@ | |||
1 | /* | ||
2 | This file is part of the OPIE Project | ||
3 | =. | ||
4 | .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> | ||
5 | .>+-= | ||
6 | _;:, .> :=|. This file is free software; you can | ||
7 | .> <`_, > . <= redistribute it and/or modify it under | ||
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
9 | .="- .-=="i, .._ License as published by the Free Software | ||
10 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
11 | ._= =} : or (at your option) any later version. | ||
12 | .%`+i> _;_. | ||
13 | .i_,=:_. -<s. This file is distributed in the hope that | ||
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
15 | : .. .:, . . . without even the implied warranty of | ||
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | ||
18 | ..}^=.= = ; Public License for more details. | ||
19 | ++= -. .` .: | ||
20 | : = ...= . :.=- You should have received a copy of the GNU | ||
21 | -. .:....=;==+<; General Public License along with this file; | ||
22 | -_. . . )=. = see the file COPYING. If not, write to the | ||
23 | -- :-=` Free Software Foundation, Inc., | ||
24 | 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | #include "graphinfo.h" | ||
30 | |||
31 | GraphInfo::GraphInfo( GraphType type, DataPointList *data, const QString &title, | ||
32 | const QString &xtitle, const QString &ytitle ) | ||
33 | { | ||
34 | t = type; | ||
35 | d = data; | ||
36 | gt = title; | ||
37 | xt = xtitle; | ||
38 | yt = ytitle; | ||
39 | } | ||
40 | |||
41 | GraphInfo::GraphType GraphInfo::graphType() | ||
42 | { | ||
43 | return t; | ||
44 | } | ||
45 | |||
46 | void GraphInfo::setGraphType( GraphType type ) | ||
47 | { | ||
48 | t = type; | ||
49 | } | ||
50 | |||
51 | DataPointList *GraphInfo::dataPoints() | ||
52 | { | ||
53 | return d; | ||
54 | } | ||
55 | |||
56 | void GraphInfo::setDataPoints( DataPointList *data ) | ||
57 | { | ||
58 | d = data; | ||
59 | } | ||
60 | |||
61 | float GraphInfo::maxValue() | ||
62 | { | ||
63 | float max; | ||
64 | |||
65 | } | ||
66 | |||
67 | float GraphInfo::minValue() | ||
68 | { | ||
69 | } | ||
70 | |||
71 | void GraphInfo::setGraphTitle( const QString &title ) | ||
72 | { | ||
73 | gt = title; | ||
74 | } | ||
75 | |||
76 | void GraphInfo::setXAxisTitle( const QString &xtitle ) | ||
77 | { | ||
78 | xt = xtitle; | ||
79 | } | ||
80 | |||
81 | void GraphInfo::setYAxisTitle( const QString &ytitle ) | ||
82 | { | ||
83 | yt = ytitle; | ||
84 | } | ||
diff --git a/noncore/apps/checkbook/graphinfo.h b/noncore/apps/checkbook/graphinfo.h new file mode 100644 index 0000000..4ad1dc9 --- a/dev/null +++ b/noncore/apps/checkbook/graphinfo.h | |||
@@ -0,0 +1,82 @@ | |||
1 | /* | ||
2 | This file is part of the OPIE Project | ||
3 | =. | ||
4 | .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> | ||
5 | .>+-= | ||
6 | _;:, .> :=|. This file is free software; you can | ||
7 | .> <`_, > . <= redistribute it and/or modify it under | ||
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
9 | .="- .-=="i, .._ License as published by the Free Software | ||
10 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
11 | ._= =} : or (at your option) any later version. | ||
12 | .%`+i> _;_. | ||
13 | .i_,=:_. -<s. This file is distributed in the hope that | ||
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
15 | : .. .:, . . . without even the implied warranty of | ||
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | ||
18 | ..}^=.= = ; Public License for more details. | ||
19 | ++= -. .` .: | ||
20 | : = ...= . :.=- You should have received a copy of the GNU | ||
21 | -. .:....=;==+<; General Public License along with this file; | ||
22 | -_. . . )=. = see the file COPYING. If not, write to the | ||
23 | -- :-=` Free Software Foundation, Inc., | ||
24 | 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | #ifndef GRAPHINFO_H | ||
30 | #define GRAPHINFO_H | ||
31 | |||
32 | #include <qlist.h> | ||
33 | #include <qstringlist.h> | ||
34 | |||
35 | class DataPointInfo | ||
36 | { | ||
37 | public: | ||
38 | DataPointInfo() | ||
39 | : l( 0x0 ), v( 0.0 ) {} | ||
40 | DataPointInfo( const QString &label, float value ) | ||
41 | : l( label ), v( value ) {} | ||
42 | |||
43 | const QString &label() { return l; } | ||
44 | float value() { return v; } | ||
45 | |||
46 | private: | ||
47 | QString l; | ||
48 | float v; | ||
49 | }; | ||
50 | |||
51 | typedef QList<DataPointInfo> DataPointList; | ||
52 | |||
53 | class GraphInfo | ||
54 | { | ||
55 | public: | ||
56 | enum GraphType { BarChart, LineChart, PieChart }; | ||
57 | |||
58 | GraphInfo( GraphType = BarChart, DataPointList * = 0x0, | ||
59 | const QString & = 0x0, const QString & = 0x0, const QString & = 0x0 ); | ||
60 | |||
61 | GraphInfo::GraphType graphType(); | ||
62 | void setGraphType( GraphType ); | ||
63 | |||
64 | DataPointList *dataPoints(); | ||
65 | void setDataPoints( DataPointList * ); | ||
66 | |||
67 | float maxValue(); | ||
68 | float minValue(); | ||
69 | |||
70 | void setGraphTitle( const QString & ); | ||
71 | void setXAxisTitle( const QString & ); | ||
72 | void setYAxisTitle( const QString & ); | ||
73 | |||
74 | private: | ||
75 | GraphType t; | ||
76 | DataPointList *d; | ||
77 | QString gt; | ||
78 | QString xt; | ||
79 | QString yt; | ||
80 | }; | ||
81 | |||
82 | #endif | ||
diff --git a/noncore/apps/checkbook/mainwindow.cpp b/noncore/apps/checkbook/mainwindow.cpp index ead17b4..2eb8396 100644 --- a/noncore/apps/checkbook/mainwindow.cpp +++ b/noncore/apps/checkbook/mainwindow.cpp | |||
@@ -44,120 +44,125 @@ | |||
44 | #include <qwhatsthis.h> | 44 | #include <qwhatsthis.h> |
45 | 45 | ||
46 | MainWindow::MainWindow() | 46 | MainWindow::MainWindow() |
47 | : QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) | 47 | : QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) |
48 | { | 48 | { |
49 | setCaption( tr( "Checkbook" ) ); | 49 | setCaption( tr( "Checkbook" ) ); |
50 | 50 | ||
51 | cbDir = Global::applicationFileName( "checkbook", "" ); | 51 | cbDir = Global::applicationFileName( "checkbook", "" ); |
52 | 52 | ||
53 | // Build menu and tool bars | 53 | // Build menu and tool bars |
54 | setToolBarsMovable( FALSE ); | 54 | setToolBarsMovable( FALSE ); |
55 | 55 | ||
56 | QPEToolBar *bar = new QPEToolBar( this ); | 56 | QPEToolBar *bar = new QPEToolBar( this ); |
57 | bar->setHorizontalStretchable( TRUE ); | 57 | bar->setHorizontalStretchable( TRUE ); |
58 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 58 | QPEMenuBar *mb = new QPEMenuBar( bar ); |
59 | mb->setMargin( 0 ); | 59 | mb->setMargin( 0 ); |
60 | QPopupMenu *popup = new QPopupMenu( this ); | 60 | QPopupMenu *popup = new QPopupMenu( this ); |
61 | 61 | ||
62 | bar = new QPEToolBar( this ); | 62 | bar = new QPEToolBar( this ); |
63 | 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." ) ); | 64 | a->setWhatsThis( tr( "Click here to create a new checkbook.\n\nYou also can select New from the Checkbook menu." ) ); |
65 | connect( a, SIGNAL( activated() ), this, SLOT( slotNew() ) ); | 65 | connect( a, SIGNAL( activated() ), this, SLOT( slotNew() ) ); |
66 | a->addTo( popup ); | 66 | a->addTo( popup ); |
67 | a->addTo( bar ); | 67 | a->addTo( bar ); |
68 | 68 | ||
69 | actionOpen = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, | 69 | actionOpen = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, |
70 | 0, this, 0 ); | 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." ) ); | 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() ) ); | 72 | connect( actionOpen, SIGNAL( activated() ), this, SLOT( slotEdit() ) ); |
73 | actionOpen->addTo( popup ); | 73 | actionOpen->addTo( popup ); |
74 | actionOpen->addTo( bar ); | 74 | actionOpen->addTo( bar ); |
75 | 75 | ||
76 | actionDelete = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, | 76 | actionDelete = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, |
77 | 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." ) ); | 78 | actionDelete->setWhatsThis( tr( "Select a checkbook and then click here delete it.\n\nYou also can select Delete from the Checkbook menu." ) ); |
79 | connect( actionDelete, SIGNAL( activated() ), this, SLOT( slotDelete() ) ); | 79 | connect( actionDelete, SIGNAL( activated() ), this, SLOT( slotDelete() ) ); |
80 | actionDelete->addTo( popup ); | 80 | actionDelete->addTo( popup ); |
81 | actionDelete->addTo( bar ); | 81 | actionDelete->addTo( bar ); |
82 | 82 | ||
83 | mb->insertItem( tr( "Checkbook" ), popup ); | 83 | mb->insertItem( tr( "Checkbook" ), popup ); |
84 | 84 | ||
85 | // Build Checkbook selection list control | 85 | // Build Checkbook selection list control |
86 | cbList = new QListBox( this ); | 86 | cbList = new QListBox( this ); |
87 | QWhatsThis::add( cbList, tr( "This is a listing of all checkbooks currently available." ) ); | 87 | QWhatsThis::add( cbList, tr( "This is a listing of all checkbooks currently available." ) ); |
88 | QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold ); | 88 | QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold ); |
89 | connect( cbList, SIGNAL( rightButtonPressed( QListBoxItem *, const QPoint & ) ), | 89 | connect( cbList, SIGNAL( rightButtonPressed( QListBoxItem *, const QPoint & ) ), |
90 | this, SLOT( slotEdit() ) ); | 90 | this, SLOT( slotEdit() ) ); |
91 | setCentralWidget( cbList ); | 91 | setCentralWidget( cbList ); |
92 | 92 | ||
93 | // Load Checkbook selection list | 93 | // Load Checkbook selection list |
94 | QDir checkdir( cbDir ); | 94 | QDir checkdir( cbDir ); |
95 | if (checkdir.exists() == true) | 95 | if (checkdir.exists() == true) |
96 | { | 96 | { |
97 | QStringList checkbooks = checkdir.entryList( "*.qcb", QDir::Files|QDir::Readable|QDir::Writable, | 97 | QStringList checkbooks = checkdir.entryList( "*.qcb", QDir::Files|QDir::Readable|QDir::Writable, |
98 | QDir::Time ); | 98 | QDir::Time ); |
99 | for ( QStringList::Iterator it = checkbooks.begin(); it != checkbooks.end(); it++ ) | 99 | for ( QStringList::Iterator it = checkbooks.begin(); it != checkbooks.end(); it++ ) |
100 | { | 100 | { |
101 | (*it) = (*it).remove( (*it).find('.'), (*it).length() ); | 101 | (*it) = (*it).remove( (*it).find('.'), (*it).length() ); |
102 | } | 102 | } |
103 | cbList->insertStringList( checkbooks ); | 103 | cbList->insertStringList( checkbooks ); |
104 | } | 104 | } |
105 | cbList->sort(); | 105 | cbList->sort(); |
106 | cbList->setSelected( 0, TRUE ); | 106 | cbList->setSelected( 0, TRUE ); |
107 | 107 | ||
108 | currencySymbol = '$'; | 108 | currencySymbol = '$'; |
109 | } | 109 | } |
110 | 110 | ||
111 | MainWindow::~MainWindow() | 111 | MainWindow::~MainWindow() |
112 | { | 112 | { |
113 | } | 113 | } |
114 | 114 | ||
115 | void MainWindow::slotNew() | 115 | void MainWindow::slotNew() |
116 | { | 116 | { |
117 | Checkbook *currcb = new Checkbook( this, "", cbDir, currencySymbol ); | 117 | Checkbook *currcb = new Checkbook( this, "", cbDir, currencySymbol ); |
118 | currcb->showMaximized(); | 118 | currcb->showMaximized(); |
119 | if ( currcb->exec() == QDialog::Accepted ) | 119 | if ( currcb->exec() == QDialog::Accepted ) |
120 | { | 120 | { |
121 | cbList->insertItem( currcb->getName() ); | 121 | cbList->insertItem( currcb->getName() ); |
122 | cbList->sort(); | 122 | cbList->sort(); |
123 | delete currcb; | 123 | delete currcb; |
124 | } | 124 | } |
125 | } | 125 | } |
126 | 126 | ||
127 | void MainWindow::slotEdit() | 127 | void MainWindow::slotEdit() |
128 | { | 128 | { |
129 | QString currname = cbList->currentText(); | 129 | QString currname = cbList->currentText(); |
130 | Checkbook *currcb = new Checkbook( this, currname, cbDir, currencySymbol ); | 130 | Checkbook *currcb = new Checkbook( this, currname, cbDir, currencySymbol ); |
131 | currcb->showMaximized(); | 131 | currcb->showMaximized(); |
132 | if ( currcb->exec() == QDialog::Accepted ) | 132 | if ( currcb->exec() == QDialog::Accepted ) |
133 | { | 133 | { |
134 | QString newname = currcb->getName(); | 134 | QString newname = currcb->getName(); |
135 | if ( currname != newname ) | 135 | if ( currname != newname ) |
136 | { | 136 | { |
137 | cbList->changeItem( newname, cbList->currentItem() ); | 137 | cbList->changeItem( newname, cbList->currentItem() ); |
138 | cbList->sort(); | 138 | cbList->sort(); |
139 | 139 | ||
140 | QFile f( cbDir + currname + ".qcb" ); | 140 | QString tempstr = cbDir; |
141 | tempstr.append( currname ); | ||
142 | tempstr.append( ".qcb" ); | ||
143 | QFile f( tempstr ); | ||
141 | if ( f.exists() ) | 144 | if ( f.exists() ) |
142 | { | 145 | { |
143 | f.remove(); | 146 | f.remove(); |
144 | } | 147 | } |
145 | } | 148 | } |
146 | delete currcb; | 149 | delete currcb; |
147 | } | 150 | } |
148 | } | 151 | } |
149 | 152 | ||
150 | void MainWindow::slotDelete() | 153 | void MainWindow::slotDelete() |
151 | { | 154 | { |
152 | if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), cbList->currentText() ) ) | 155 | if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), cbList->currentText() ) ) |
153 | { | 156 | { |
154 | QString name = cbDir + cbList->currentText() + ".qcb"; | 157 | QString tempstr = cbDir; |
155 | QFile f( name ); | 158 | tempstr.append( cbList->currentText() ); |
159 | tempstr.append( ".qcb" ); | ||
160 | QFile f( tempstr ); | ||
156 | if ( f.exists() ) | 161 | if ( f.exists() ) |
157 | { | 162 | { |
158 | f.remove(); | 163 | f.remove(); |
159 | } | 164 | } |
160 | 165 | ||
161 | cbList->removeItem( cbList->currentItem() ); | 166 | cbList->removeItem( cbList->currentItem() ); |
162 | } | 167 | } |
163 | } | 168 | } |
diff --git a/noncore/apps/checkbook/traninfo.cpp b/noncore/apps/checkbook/traninfo.cpp index 5a770b0..460466c 100644 --- a/noncore/apps/checkbook/traninfo.cpp +++ b/noncore/apps/checkbook/traninfo.cpp | |||
@@ -1,156 +1,175 @@ | |||
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 "traninfo.h" | 29 | #include "traninfo.h" |
30 | 30 | ||
31 | #include <qpe/config.h> | 31 | #include <qpe/config.h> |
32 | 32 | ||
33 | QString tempstr; | ||
34 | |||
33 | TranInfo::TranInfo( int id, const QString &desc, const QDate &date, bool withdrawal, | 35 | TranInfo::TranInfo( int id, const QString &desc, const QDate &date, bool withdrawal, |
34 | const QString &type, const QString &category, float amount, | 36 | const QString &type, const QString &category, float amount, |
35 | float fee, const QString &number, const QString ¬es ) | 37 | float fee, const QString &number, const QString ¬es ) |
36 | { | 38 | { |
37 | i = id; | 39 | i = id; |
38 | d = desc; | 40 | d = desc; |
39 | td = date; | 41 | td = date; |
40 | w = withdrawal; | 42 | w = withdrawal; |
41 | t = type; | 43 | t = type; |
42 | c = category; | 44 | c = category; |
43 | a = amount; | 45 | a = amount; |
44 | f = fee; | 46 | f = fee; |
45 | cn = number; | 47 | cn = number; |
46 | n = notes; | 48 | n = notes; |
47 | } | 49 | } |
48 | 50 | ||
49 | TranInfo::TranInfo( Config config, int entry ) | 51 | TranInfo::TranInfo( Config config, int entry ) |
50 | { | 52 | { |
51 | config.setGroup( QString::number( entry ) ); | 53 | config.setGroup( QString::number( entry ) ); |
52 | QString desc = config.readEntry( "Description", "Not Found" ); | 54 | QString desc = config.readEntry( "Description", "Not Found" ); |
53 | if ( desc != "Not Found" ) | 55 | if ( desc != "Not Found" ) |
54 | { | 56 | { |
55 | // ID | 57 | // ID |
56 | i = entry; | 58 | i = entry; |
57 | 59 | ||
58 | // Description | 60 | // Description |
59 | d = desc; | 61 | d = desc; |
60 | 62 | ||
61 | // Transaction date | 63 | // Transaction date |
62 | int yr, mn, dy; | 64 | int yr, mn, dy; |
63 | QString datestr = config.readEntry( "Date", "" ); | 65 | QString datestr = config.readEntry( "Date", "" ); |
64 | int begin, end; | 66 | int begin, end; |
65 | begin = datestr.find( '/' ); | 67 | begin = datestr.find( '/' ); |
66 | mn = datestr.left( begin ).toInt(); | 68 | mn = datestr.left( begin ).toInt(); |
67 | end = datestr.find( '/', ++begin ); | 69 | end = datestr.find( '/', ++begin ); |
68 | dy = datestr.mid( begin, end - begin ).toInt(); | 70 | dy = datestr.mid( begin, end - begin ).toInt(); |
69 | yr = datestr.right( datestr.length() - end - 1).toInt(); | 71 | yr = datestr.right( datestr.length() - end - 1).toInt(); |
70 | td.setYMD( yr, mn, dy ); | 72 | td.setYMD( yr, mn, dy ); |
71 | 73 | ||
72 | // Deposit/withdrawal indicator ( withdrawal == TRUE ) | 74 | // Deposit/withdrawal indicator ( withdrawal == TRUE ) |
73 | w = ( config.readEntry( "Payment", "false" ) == "true" ); | 75 | w = ( config.readEntry( "Payment", "false" ) == "true" ); |
74 | 76 | ||
75 | // Type | 77 | // Type |
76 | QString type = config.readEntry( "Type", "0" ); | 78 | QString type = config.readEntry( "Type", "0" ); |
77 | if ( w ) | 79 | if ( w ) |
78 | { // Withdrawal types | 80 | { // Withdrawal types |
79 | if( type == "0" ) | 81 | if( type == "0" ) |
80 | t = "Debit Charge"; | 82 | t = "Debit Charge"; |
81 | else if( type == "1" ) | 83 | else if( type == "1" ) |
82 | t = "Written Check"; | 84 | t = "Written Check"; |
83 | else if( type == "2" ) | 85 | else if( type == "2" ) |
84 | t = "Transfer"; | 86 | t = "Transfer"; |
85 | else if( type == "3" ) | 87 | else if( type == "3" ) |
86 | t = "Credit Card"; | 88 | t = "Credit Card"; |
87 | } | 89 | } |
88 | else | 90 | else |
89 | { | 91 | { |
90 | if( type == "0" ) | 92 | if( type == "0" ) |
91 | t = "Written Check"; | 93 | t = "Written Check"; |
92 | else if( type == "1" ) | 94 | else if( type == "1" ) |
93 | t = "Automatic Payment"; | 95 | t = "Automatic Payment"; |
94 | else if( type == "2" ) | 96 | else if( type == "2" ) |
95 | t = "Transfer"; | 97 | t = "Transfer"; |
96 | else if( type == "3" ) | 98 | else if( type == "3" ) |
97 | t = "Cash"; | 99 | t = "Cash"; |
98 | } | 100 | } |
99 | 101 | ||
100 | // Category | 102 | // Category |
101 | c = config.readEntry( "Category", "" ); | 103 | c = config.readEntry( "Category", "" ); |
102 | 104 | ||
103 | // Transaction amount | 105 | // Transaction amount |
104 | QString stramount = config.readEntry( "Amount", "0.00" ); | 106 | QString stramount = config.readEntry( "Amount", "0.00" ); |
105 | bool ok; | 107 | bool ok; |
106 | a = stramount.toFloat( &ok ); | 108 | a = stramount.toFloat( &ok ); |
107 | 109 | ||
108 | // Transaction fee | 110 | // Transaction fee |
109 | stramount = config.readEntry( "TransactionFee", "0.00" ); | 111 | stramount = config.readEntry( "TransactionFee", "0.00" ); |
110 | f = stramount.toFloat( &ok ); | 112 | f = stramount.toFloat( &ok ); |
111 | 113 | ||
112 | // Transaction number | 114 | // Transaction number |
113 | cn = config.readEntry( "CheckNumber", "" ); | 115 | cn = config.readEntry( "CheckNumber", "" ); |
114 | 116 | ||
115 | // Notes | 117 | // Notes |
116 | n = config.readEntry( "Comments", "" ); | 118 | n = config.readEntry( "Comments", "" ); |
117 | } | 119 | } |
118 | } | 120 | } |
119 | 121 | ||
122 | const QString &TranInfo::datestr() | ||
123 | { | ||
124 | tempstr = QString::number( td.year() ); | ||
125 | tempstr.append( '/' ); | ||
126 | int tempfield = td.month(); | ||
127 | if ( tempfield < 10 ) tempstr.append( '0' ); | ||
128 | tempstr.append( QString::number( tempfield ) ); | ||
129 | tempstr.append( '/' ); | ||
130 | tempfield = td.day(); | ||
131 | if ( tempfield < 10 ) tempstr.append( '0' ); | ||
132 | tempstr.append( QString::number( tempfield ) ); | ||
133 | |||
134 | return( tempstr ); | ||
135 | } | ||
136 | |||
120 | void TranInfo::write( Config *config, int entry ) | 137 | void TranInfo::write( Config *config, int entry ) |
121 | { | 138 | { |
122 | config->setGroup( QString::number( entry ) ); | 139 | config->setGroup( QString::number( entry ) ); |
123 | 140 | ||
124 | config->writeEntry( "Description", d ); | 141 | config->writeEntry( "Description", d ); |
125 | 142 | ||
126 | QString tempstr = QString::number( td.month() ) + "/" + | 143 | tempstr = QString::number( td.month() ); |
127 | QString::number( td.day() ) + "/" + | 144 | tempstr.append( '/' ); |
128 | QString::number( td.year() ); | 145 | tempstr.append( QString::number( td.day() ) ); |
146 | tempstr.append( '/' ); | ||
147 | tempstr.append( QString::number( td.year() ) ); | ||
129 | config->writeEntry( "Date", tempstr ); | 148 | config->writeEntry( "Date", tempstr ); |
130 | 149 | ||
131 | w ? tempstr = "true" | 150 | w ? tempstr = "true" |
132 | : tempstr = "false"; | 151 | : tempstr = "false"; |
133 | config->writeEntry( "Payment", tempstr ); | 152 | config->writeEntry( "Payment", tempstr ); |
134 | 153 | ||
135 | if ( t == "Debit Charge" || t == "Written Check" ) | 154 | if ( t == "Debit Charge" || t == "Written Check" ) |
136 | tempstr = "0"; | 155 | tempstr = "0"; |
137 | else if ( t == "Written Check" || t == "Automatic Payment" ) | 156 | else if ( t == "Written Check" || t == "Automatic Payment" ) |
138 | tempstr = "1"; | 157 | tempstr = "1"; |
139 | else if ( t == "Transfer" ) | 158 | else if ( t == "Transfer" ) |
140 | tempstr = "2"; | 159 | tempstr = "2"; |
141 | else if ( t == "Credit Card" || t == "Cash" ) | 160 | else if ( t == "Credit Card" || t == "Cash" ) |
142 | tempstr = "3"; | 161 | tempstr = "3"; |
143 | config->writeEntry( "Type", tempstr ); | 162 | config->writeEntry( "Type", tempstr ); |
144 | 163 | ||
145 | config->writeEntry( "Category", c ); | 164 | config->writeEntry( "Category", c ); |
146 | 165 | ||
147 | tempstr.setNum( a, 'f', 2 ); | 166 | tempstr.setNum( a, 'f', 2 ); |
148 | config->writeEntry( "Amount", tempstr ); | 167 | config->writeEntry( "Amount", tempstr ); |
149 | 168 | ||
150 | tempstr.setNum( f, 'f', 2 ); | 169 | tempstr.setNum( f, 'f', 2 ); |
151 | config->writeEntry( "TransactionFee", tempstr ); | 170 | config->writeEntry( "TransactionFee", tempstr ); |
152 | 171 | ||
153 | config->writeEntry( "CheckNumber", cn ); | 172 | config->writeEntry( "CheckNumber", cn ); |
154 | 173 | ||
155 | config->writeEntry( "Comments", n ); | 174 | config->writeEntry( "Comments", n ); |
156 | } | 175 | } |
diff --git a/noncore/apps/checkbook/traninfo.h b/noncore/apps/checkbook/traninfo.h index 1743ff7..e944c29 100644 --- a/noncore/apps/checkbook/traninfo.h +++ b/noncore/apps/checkbook/traninfo.h | |||
@@ -1,85 +1,86 @@ | |||
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 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> | 34 | #include <qstring.h> |
35 | 35 | ||
36 | class Config; | 36 | class Config; |
37 | 37 | ||
38 | class TranInfo | 38 | class TranInfo |
39 | { | 39 | { |
40 | public: | 40 | public: |
41 | TranInfo( int = 0, const QString & = 0x0, const QDate & = QDate::currentDate(), | 41 | TranInfo( int = 0, const QString & = 0x0, const QDate & = QDate::currentDate(), |
42 | bool = TRUE, const QString & = 0x0, const QString & = 0x0, | 42 | bool = TRUE, const QString & = 0x0, const QString & = 0x0, |
43 | float = 0.0, float = 0.0, | 43 | float = 0.0, float = 0.0, |
44 | const QString & = 0x0, const QString & = 0x0 ); | 44 | const QString & = 0x0, const QString & = 0x0 ); |
45 | TranInfo( Config, int ); | 45 | TranInfo( Config, int ); |
46 | 46 | ||
47 | int id() const { return i; } | 47 | int id() const { return i; } |
48 | const QString &desc() const { return d; } | 48 | const QString &desc() const { return d; } |
49 | const QDate &date() const { return td; } | 49 | const QDate &date() const { return td; } |
50 | const QString &datestr(); | ||
50 | bool withdrawal()const { return w; } | 51 | bool withdrawal()const { return w; } |
51 | const QString &type() const { return t; } | 52 | const QString &type() const { return t; } |
52 | const QString &category()const { return c; } | 53 | const QString &category()const { return c; } |
53 | float amount() const { return a; } | 54 | float amount() const { return a; } |
54 | float fee() const { return f; } | 55 | float fee() const { return f; } |
55 | const QString &number() const { return cn; } | 56 | const QString &number() const { return cn; } |
56 | const QString ¬es() const { return n; } | 57 | const QString ¬es() const { return n; } |
57 | 58 | ||
58 | void setDesc( const QString &desc ) { d = desc; } | 59 | void setDesc( const QString &desc ) { d = desc; } |
59 | void setDate( const QDate &date ) { td = date; } | 60 | void setDate( const QDate &date ) { td = date; } |
60 | void setWithdrawal( bool withdrawal ){ w = withdrawal; } | 61 | void setWithdrawal( bool withdrawal ){ w = withdrawal; } |
61 | void setType( const QString &type ) { t = type; } | 62 | void setType( const QString &type ) { t = type; } |
62 | void setCategory( const QString &cat ){ c = cat; } | 63 | void setCategory( const QString &cat ){ c = cat; } |
63 | void setAmount( float amount ) { a = amount; } | 64 | void setAmount( float amount ) { a = amount; } |
64 | void setFee( float fee ) { f = fee; } | 65 | void setFee( float fee ) { f = fee; } |
65 | void setNumber( const QString &num ){ cn = num; } | 66 | void setNumber( const QString &num ){ cn = num; } |
66 | void setNotes( const QString ¬es ){ n = notes; } | 67 | void setNotes( const QString ¬es ){ n = notes; } |
67 | 68 | ||
68 | void write( Config *, int ); | 69 | void write( Config *, int ); |
69 | 70 | ||
70 | private: | 71 | private: |
71 | int i; | 72 | int i; |
72 | QString d; | 73 | QString d; |
73 | QDate td; | 74 | QDate td; |
74 | bool w; | 75 | bool w; |
75 | QString t; | 76 | QString t; |
76 | QString c; | 77 | QString c; |
77 | float a; | 78 | float a; |
78 | float f; | 79 | float f; |
79 | QString cn; | 80 | QString cn; |
80 | QString n; | 81 | QString n; |
81 | }; | 82 | }; |
82 | 83 | ||
83 | typedef QList<TranInfo> TranInfoList; | 84 | typedef QList<TranInfo> TranInfoList; |
84 | 85 | ||
85 | #endif | 86 | #endif |
diff --git a/noncore/apps/checkbook/transaction.cpp b/noncore/apps/checkbook/transaction.cpp index 82baec9..a921491 100644 --- a/noncore/apps/checkbook/transaction.cpp +++ b/noncore/apps/checkbook/transaction.cpp | |||
@@ -1,148 +1,150 @@ | |||
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 | #include <qwhatsthis.h> | 46 | #include <qwhatsthis.h> |
47 | 47 | ||
48 | Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *info, | 48 | Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *info, |
49 | char symbol ) | 49 | char symbol ) |
50 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) | 50 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) |
51 | { | 51 | { |
52 | setCaption( tr( "Transaction for " ) + acctname ); | 52 | QString tempstr = tr( "Transaction for " ); |
53 | tempstr.append( acctname ); | ||
54 | setCaption( tempstr ); | ||
53 | 55 | ||
54 | tran = info; | 56 | tran = info; |
55 | currencySymbol = symbol; | 57 | currencySymbol = symbol; |
56 | 58 | ||
57 | QVBoxLayout *vb = new QVBoxLayout( this ); | 59 | QVBoxLayout *vb = new QVBoxLayout( this ); |
58 | 60 | ||
59 | QScrollView *sv = new QScrollView( this ); | 61 | QScrollView *sv = new QScrollView( this ); |
60 | vb->addWidget( sv, 0, 0 ); | 62 | vb->addWidget( sv, 0, 0 ); |
61 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 63 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
62 | sv->setFrameStyle( QFrame::NoFrame ); | 64 | sv->setFrameStyle( QFrame::NoFrame ); |
63 | 65 | ||
64 | QWidget *container = new QWidget( sv->viewport() ); | 66 | QWidget *container = new QWidget( sv->viewport() ); |
65 | sv->addChild( container ); | 67 | sv->addChild( container ); |
66 | 68 | ||
67 | QGridLayout *layout = new QGridLayout( container ); | 69 | QGridLayout *layout = new QGridLayout( container ); |
68 | layout->setSpacing( 2 ); | 70 | layout->setSpacing( 2 ); |
69 | layout->setMargin( 4 ); | 71 | layout->setMargin( 4 ); |
70 | 72 | ||
71 | // Withdrawal/Deposit | 73 | // Withdrawal/Deposit |
72 | QButtonGroup *btngrp = new QButtonGroup( container ); | 74 | QButtonGroup *btngrp = new QButtonGroup( container ); |
73 | btngrp->setColumnLayout(0, Qt::Vertical ); | 75 | btngrp->setColumnLayout(0, Qt::Vertical ); |
74 | btngrp->layout()->setSpacing( 0 ); | 76 | btngrp->layout()->setSpacing( 0 ); |
75 | btngrp->layout()->setMargin( 0 ); | 77 | btngrp->layout()->setMargin( 0 ); |
76 | btngrp->setMaximumWidth( 220 ); | 78 | btngrp->setMaximumWidth( 220 ); |
77 | QGridLayout *layout2 = new QGridLayout( btngrp->layout() ); | 79 | QGridLayout *layout2 = new QGridLayout( btngrp->layout() ); |
78 | layout2->setSpacing( 2 ); | 80 | layout2->setSpacing( 2 ); |
79 | layout2->setMargin( 2 ); | 81 | layout2->setMargin( 2 ); |
80 | withBtn = new QRadioButton( tr( "Withdrawal" ), btngrp ); | 82 | withBtn = new QRadioButton( tr( "Withdrawal" ), btngrp ); |
81 | QWhatsThis::add( withBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) ); | 83 | QWhatsThis::add( withBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) ); |
82 | layout2->addWidget( withBtn, 0, 0 ); | 84 | layout2->addWidget( withBtn, 0, 0 ); |
83 | connect( withBtn, SIGNAL( clicked() ), this, SLOT( slotWithdrawalClicked() ) ); | 85 | connect( withBtn, SIGNAL( clicked() ), this, SLOT( slotWithdrawalClicked() ) ); |
84 | depBtn = new QRadioButton( tr( "Deposit" ), btngrp ); | 86 | depBtn = new QRadioButton( tr( "Deposit" ), btngrp ); |
85 | QWhatsThis::add( depBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) ); | 87 | QWhatsThis::add( depBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) ); |
86 | layout2->addWidget( depBtn, 0, 1 ); | 88 | layout2->addWidget( depBtn, 0, 1 ); |
87 | btngrp->setMaximumSize( 320, withBtn->height() ); | 89 | btngrp->setMaximumSize( 320, withBtn->height() ); |
88 | connect( depBtn, SIGNAL( clicked() ), this, SLOT( slotDepositClicked() ) ); | 90 | connect( depBtn, SIGNAL( clicked() ), this, SLOT( slotDepositClicked() ) ); |
89 | layout->addMultiCellWidget( btngrp, 0, 0, 0, 3 ); | 91 | layout->addMultiCellWidget( btngrp, 0, 0, 0, 3 ); |
90 | 92 | ||
91 | // Date | 93 | // Date |
92 | QLabel *label = new QLabel( tr( "Date:" ), container ); | 94 | QLabel *label = new QLabel( tr( "Date:" ), container ); |
93 | QWhatsThis::add( label, tr( "Select date of transaction here." ) ); | 95 | QWhatsThis::add( label, tr( "Select date of transaction here." ) ); |
94 | layout->addWidget( label, 1, 0 ); | 96 | layout->addWidget( label, 1, 0 ); |
95 | dateBtn = new QPushButton( TimeString::shortDate( QDate::currentDate() ), | 97 | dateBtn = new QPushButton( TimeString::shortDate( QDate::currentDate() ), |
96 | container ); | 98 | container ); |
97 | QWhatsThis::add( dateBtn, tr( "Select date of transaction here." ) ); | 99 | QWhatsThis::add( dateBtn, tr( "Select date of transaction here." ) ); |
98 | QPopupMenu *m1 = new QPopupMenu( container ); | 100 | QPopupMenu *m1 = new QPopupMenu( container ); |
99 | datePicker = new DateBookMonth( m1, 0, TRUE ); | 101 | datePicker = new DateBookMonth( m1, 0, TRUE ); |
100 | m1->insertItem( datePicker ); | 102 | m1->insertItem( datePicker ); |
101 | dateBtn->setPopup( m1 ); | 103 | dateBtn->setPopup( m1 ); |
102 | connect( datePicker, SIGNAL( dateClicked( int, int, int ) ), | 104 | connect( datePicker, SIGNAL( dateClicked( int, int, int ) ), |
103 | this, SLOT( slotDateChanged( int, int, int ) ) ); | 105 | this, SLOT( slotDateChanged( int, int, int ) ) ); |
104 | layout->addWidget( dateBtn, 1, 1 ); | 106 | layout->addWidget( dateBtn, 1, 1 ); |
105 | 107 | ||
106 | // Check number | 108 | // Check number |
107 | label = new QLabel( tr( "Number:" ), container ); | 109 | label = new QLabel( tr( "Number:" ), container ); |
108 | QWhatsThis::add( label, tr( "Enter check number here." ) ); | 110 | QWhatsThis::add( label, tr( "Enter check number here." ) ); |
109 | layout->addWidget( label, 1, 2 ); | 111 | layout->addWidget( label, 1, 2 ); |
110 | numEdit = new QLineEdit( container ); | 112 | numEdit = new QLineEdit( container ); |
111 | QWhatsThis::add( numEdit, tr( "Enter check number here." ) ); | 113 | QWhatsThis::add( numEdit, tr( "Enter check number here." ) ); |
112 | numEdit->setMaximumWidth( 40 ); | 114 | numEdit->setMaximumWidth( 40 ); |
113 | layout->addWidget( numEdit, 1, 3 ); | 115 | layout->addWidget( numEdit, 1, 3 ); |
114 | 116 | ||
115 | // Description | 117 | // Description |
116 | label = new QLabel( tr( "Description:" ), container ); | 118 | label = new QLabel( tr( "Description:" ), container ); |
117 | QWhatsThis::add( label, tr( "Enter description of transaction here." ) ); | 119 | QWhatsThis::add( label, tr( "Enter description of transaction here." ) ); |
118 | layout->addWidget( label, 2, 0 ); | 120 | layout->addWidget( label, 2, 0 ); |
119 | descEdit = new QLineEdit( container ); | 121 | descEdit = new QLineEdit( container ); |
120 | QWhatsThis::add( descEdit, tr( "Enter description of transaction here." ) ); | 122 | QWhatsThis::add( descEdit, tr( "Enter description of transaction here." ) ); |
121 | layout->addMultiCellWidget( descEdit, 2, 2, 1, 3 ); | 123 | layout->addMultiCellWidget( descEdit, 2, 2, 1, 3 ); |
122 | 124 | ||
123 | // Category | 125 | // Category |
124 | label = new QLabel( tr( "Category:" ), container ); | 126 | label = new QLabel( tr( "Category:" ), container ); |
125 | QWhatsThis::add( label, tr( "Select transaction category here." ) ); | 127 | QWhatsThis::add( label, tr( "Select transaction category here." ) ); |
126 | layout->addWidget( label, 3, 0 ); | 128 | layout->addWidget( label, 3, 0 ); |
127 | catList = new QComboBox( container ); | 129 | catList = new QComboBox( container ); |
128 | QWhatsThis::add( catList, tr( "Select transaction category here." ) ); | 130 | QWhatsThis::add( catList, tr( "Select transaction category here." ) ); |
129 | layout->addMultiCellWidget( catList, 3, 3, 1, 3 ); | 131 | layout->addMultiCellWidget( catList, 3, 3, 1, 3 ); |
130 | 132 | ||
131 | // Type | 133 | // Type |
132 | label = new QLabel( tr( "Type:" ), container ); | 134 | 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." ) ); | 135 | QWhatsThis::add( label, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) ); |
134 | layout->addWidget( label, 4, 0 ); | 136 | layout->addWidget( label, 4, 0 ); |
135 | typeList = new QComboBox( container ); | 137 | 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." ) ); | 138 | QWhatsThis::add( typeList, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) ); |
137 | layout->addMultiCellWidget( typeList, 4, 4, 1, 3 ); | 139 | layout->addMultiCellWidget( typeList, 4, 4, 1, 3 ); |
138 | 140 | ||
139 | // Amount | 141 | // Amount |
140 | label = new QLabel( tr( "Amount:" ), container ); | 142 | 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." ) ); | 143 | QWhatsThis::add( label, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) ); |
142 | layout->addWidget( label, 5, 0 ); | 144 | layout->addWidget( label, 5, 0 ); |
143 | amtEdit = new QLineEdit( container ); | 145 | amtEdit = new QLineEdit( container ); |
144 | QWhatsThis::add( amtEdit, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) ); | 146 | QWhatsThis::add( amtEdit, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) ); |
145 | layout->addMultiCellWidget( amtEdit, 5, 5, 1, 3 ); | 147 | layout->addMultiCellWidget( amtEdit, 5, 5, 1, 3 ); |
146 | 148 | ||
147 | // Fee | 149 | // Fee |
148 | label = new QLabel( tr( "Fee:" ), container ); | 150 | label = new QLabel( tr( "Fee:" ), container ); |