author | drw <drw> | 2004-02-22 00:08:21 (UTC) |
---|---|---|
committer | drw <drw> | 2004-02-22 00:08:21 (UTC) |
commit | e8aa81decb9a22828dcdbbaf3d08e2c6f1d2217f (patch) (unidiff) | |
tree | 2ebc546b4cf84d014eae25b9753f2cb40be37b48 | |
parent | 58f490cf6fd94ec27eec01c0ffc9d0411be594e8 (diff) | |
download | opie-e8aa81decb9a22828dcdbbaf3d08e2c6f1d2217f.zip opie-e8aa81decb9a22828dcdbbaf3d08e2c6f1d2217f.tar.gz opie-e8aa81decb9a22828dcdbbaf3d08e2c6f1d2217f.tar.bz2 |
Checkbook: libopie->libopie2
-rw-r--r-- | noncore/apps/checkbook/checkbook.cpp | 917 | ||||
-rw-r--r-- | noncore/apps/checkbook/checkbook.h | 110 | ||||
-rw-r--r-- | noncore/apps/checkbook/checkbook.pro | 2 | ||||
-rw-r--r-- | noncore/apps/checkbook/main.cpp | 3 | ||||
-rw-r--r-- | noncore/apps/checkbook/opie-checkbook.control | 2 |
5 files changed, 517 insertions, 517 deletions
diff --git a/noncore/apps/checkbook/checkbook.cpp b/noncore/apps/checkbook/checkbook.cpp index a5492e4..4ca764f 100644 --- a/noncore/apps/checkbook/checkbook.cpp +++ b/noncore/apps/checkbook/checkbook.cpp | |||
@@ -36,7 +36,6 @@ | |||
36 | #include "mainwindow.h" | 36 | #include "mainwindow.h" |
37 | #include "cfg.h" | 37 | #include "cfg.h" |
38 | 38 | ||
39 | #include <opie/otabwidget.h> | ||
40 | #include <qpe/qpeapplication.h> | 39 | #include <qpe/qpeapplication.h> |
41 | #include <qpe/qpemessagebox.h> | 40 | #include <qpe/qpemessagebox.h> |
42 | #include <qpe/resource.h> | 41 | #include <qpe/resource.h> |
@@ -61,44 +60,44 @@ | |||
61 | 60 | ||
62 | // --- Checkbook -------------------------------------------------------------- | 61 | // --- Checkbook -------------------------------------------------------------- |
63 | Checkbook::Checkbook( QWidget *parent, CBInfo *i, Cfg *cfg ) | 62 | Checkbook::Checkbook( QWidget *parent, CBInfo *i, Cfg *cfg ) |
64 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) | 63 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) |
65 | { | 64 | { |
66 | info = i; | 65 | info = i; |
67 | _pCfg=cfg; | 66 | _pCfg=cfg; |
68 | 67 | ||
69 | // Title bar | 68 | // Title bar |
70 | if ( info->name() != "" ) | 69 | if ( info->name() != "" ) |
71 | { | 70 | { |
72 | QString tempstr = info->name(); | 71 | QString tempstr = info->name(); |
73 | tempstr.append( " - " ); | 72 | tempstr.append( " - " ); |
74 | tempstr.append( tr( "Checkbook" ) ); | 73 | tempstr.append( tr( "Checkbook" ) ); |
75 | setCaption( tempstr ); | 74 | setCaption( tempstr ); |
76 | } | 75 | } |
77 | else | 76 | else |
78 | { | 77 | { |
79 | setCaption( tr( "New checkbook" ) ); | 78 | setCaption( tr( "New checkbook" ) ); |
80 | } | 79 | } |
81 | 80 | ||
82 | 81 | ||
83 | // Setup layout to make everything pretty | 82 | // Setup layout to make everything pretty |
84 | QVBoxLayout *layout = new QVBoxLayout( this ); | 83 | QVBoxLayout *layout = new QVBoxLayout( this ); |
85 | layout->setMargin( 2 ); | 84 | layout->setMargin( 2 ); |
86 | layout->setSpacing( 4 ); | 85 | layout->setSpacing( 4 ); |
87 | 86 | ||
88 | // Setup tabs for all info | 87 | // Setup tabs for all info |
89 | mainWidget = new OTabWidget( this ); | 88 | mainWidget = new OTabWidget( this ); |
90 | layout->addWidget( mainWidget ); | 89 | layout->addWidget( mainWidget ); |
91 | mainWidget->addTab( initInfo(), "checkbook/infotab", tr( "Info" ) ); | 90 | mainWidget->addTab( initInfo(), "checkbook/infotab", tr( "Info" ) ); |
92 | mainWidget->addTab( initTransactions(), "checkbook/trantab", tr( "Transactions" ) ); | 91 | mainWidget->addTab( initTransactions(), "checkbook/trantab", tr( "Transactions" ) ); |
93 | mainWidget->addTab( initCharts(), "checkbook/charttab", tr( "Charts" ) ); | 92 | mainWidget->addTab( initCharts(), "checkbook/charttab", tr( "Charts" ) ); |
94 | if( _pCfg->isShowLastTab() ) | 93 | if( _pCfg->isShowLastTab() ) |
95 | mainWidget->setCurrentTab( info->getLastTab() ); | 94 | mainWidget->setCurrentTab( info->getLastTab() ); |
96 | else | 95 | else |
97 | mainWidget->setCurrentTab( tr( "Info" ) ); | 96 | mainWidget->setCurrentTab( tr( "Info" ) ); |
98 | connect( mainWidget, SIGNAL( currentChanged(QWidget *) ), this, SLOT( slotTab(QWidget *) ) ); | 97 | connect( mainWidget, SIGNAL( currentChanged(QWidget *) ), this, SLOT( slotTab(QWidget *) ) ); |
99 | 98 | ||
100 | // Load checkbook information | 99 | // Load checkbook information |
101 | loadCheckbook(); | 100 | loadCheckbook(); |
102 | } | 101 | } |
103 | 102 | ||
104 | Checkbook::~Checkbook() | 103 | Checkbook::~Checkbook() |
@@ -110,106 +109,106 @@ QWidget *Checkbook::initInfo() | |||
110 | { | 109 | { |
111 | QWidget *control = new QWidget( mainWidget, tr("Info") ); | 110 | QWidget *control = new QWidget( mainWidget, tr("Info") ); |
112 | 111 | ||
113 | QVBoxLayout *vb = new QVBoxLayout( control ); | 112 | QVBoxLayout *vb = new QVBoxLayout( control ); |
114 | 113 | ||
115 | QScrollView *sv = new QScrollView( control ); | 114 | QScrollView *sv = new QScrollView( control ); |
116 | vb->addWidget( sv, 0, 0 ); | 115 | vb->addWidget( sv, 0, 0 ); |
117 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 116 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
118 | sv->setFrameStyle( QFrame::NoFrame ); | 117 | sv->setFrameStyle( QFrame::NoFrame ); |
119 | 118 | ||
120 | QWidget *container = new QWidget( sv->viewport() ); | 119 | QWidget *container = new QWidget( sv->viewport() ); |
121 | sv->addChild( container ); | 120 | sv->addChild( container ); |
122 | 121 | ||
123 | QGridLayout *layout = new QGridLayout( container ); | 122 | QGridLayout *layout = new QGridLayout( container ); |
124 | layout->setSpacing( 2 ); | 123 | layout->setSpacing( 2 ); |
125 | layout->setMargin( 4 ); | 124 | layout->setMargin( 4 ); |
126 | 125 | ||
127 | // Password protection | 126 | // Password protection |
128 | passwordCB = new QCheckBox( tr( "Password protect" ), container ); | 127 | passwordCB = new QCheckBox( tr( "Password protect" ), container ); |
129 | QWhatsThis::add( passwordCB, tr( "Click here to enable/disable password protection of this checkbook." ) ); | 128 | QWhatsThis::add( passwordCB, tr( "Click here to enable/disable password protection of this checkbook." ) ); |
130 | connect( passwordCB, SIGNAL( clicked() ), this, SLOT( slotPasswordClicked() ) ); | 129 | connect( passwordCB, SIGNAL( clicked() ), this, SLOT( slotPasswordClicked() ) ); |
131 | layout->addMultiCellWidget( passwordCB, 0, 0, 0, 1 ); | 130 | layout->addMultiCellWidget( passwordCB, 0, 0, 0, 1 ); |
132 | 131 | ||
133 | // Account name | 132 | // Account name |
134 | QLabel *label = new QLabel( tr( "Name:" ), container ); | 133 | QLabel *label = new QLabel( tr( "Name:" ), container ); |
135 | QWhatsThis::add( label, tr( "Enter name of checkbook here." ) ); | 134 | QWhatsThis::add( label, tr( "Enter name of checkbook here." ) ); |
136 | layout->addWidget( label, 1, 0 ); | 135 | layout->addWidget( label, 1, 0 ); |
137 | nameEdit = new QLineEdit( container ); | 136 | nameEdit = new QLineEdit( container ); |
138 | QWhatsThis::add( nameEdit, tr( "Enter name of checkbook here." ) ); | 137 | QWhatsThis::add( nameEdit, tr( "Enter name of checkbook here." ) ); |
139 | connect( nameEdit, SIGNAL( textChanged( const QString & ) ), | 138 | connect( nameEdit, SIGNAL( textChanged( const QString & ) ), |
140 | this, SLOT( slotNameChanged( const QString & ) ) ); | 139 | this, SLOT( slotNameChanged( const QString & ) ) ); |
141 | layout->addWidget( nameEdit, 1, 1 ); | 140 | layout->addWidget( nameEdit, 1, 1 ); |
142 | 141 | ||
143 | // Type of account | 142 | // Type of account |
144 | label = new QLabel( tr( "Type:" ), container ); | 143 | label = new QLabel( tr( "Type:" ), container ); |
145 | QWhatsThis::add( label, tr( "Select type of checkbook here." ) ); | 144 | QWhatsThis::add( label, tr( "Select type of checkbook here." ) ); |
146 | layout->addWidget( label, 2, 0 ); | 145 | layout->addWidget( label, 2, 0 ); |
147 | typeList = new QComboBox( container ); | 146 | typeList = new QComboBox( container ); |
148 | QWhatsThis::add( typeList, tr( "Select type of checkbook here." ) ); | 147 | QWhatsThis::add( typeList, tr( "Select type of checkbook here." ) ); |
149 | typeList->insertStringList( _pCfg->getAccountTypes() ); | 148 | typeList->insertStringList( _pCfg->getAccountTypes() ); |
150 | layout->addWidget( typeList, 2, 1 ); | 149 | layout->addWidget( typeList, 2, 1 ); |
151 | 150 | ||
152 | // Bank/institution name | 151 | // Bank/institution name |
153 | label = new QLabel( tr( "Bank:" ), container ); | 152 | label = new QLabel( tr( "Bank:" ), container ); |
154 | QWhatsThis::add( label, tr( "Enter name of the bank for this checkbook here." ) ); | 153 | QWhatsThis::add( label, tr( "Enter name of the bank for this checkbook here." ) ); |
155 | layout->addWidget( label, 3, 0 ); | 154 | layout->addWidget( label, 3, 0 ); |
156 | bankEdit = new QLineEdit( container ); | 155 | bankEdit = new QLineEdit( container ); |
157 | QWhatsThis::add( bankEdit, tr( "Enter name of the bank for this checkbook here." ) ); | 156 | QWhatsThis::add( bankEdit, tr( "Enter name of the bank for this checkbook here." ) ); |
158 | layout->addWidget( bankEdit, 3, 1 ); | 157 | layout->addWidget( bankEdit, 3, 1 ); |
159 | 158 | ||
160 | // Account number | 159 | // Account number |
161 | label = new QLabel( tr( "Account number:" ), container ); | 160 | label = new QLabel( tr( "Account number:" ), container ); |
162 | QWhatsThis::add( label, tr( "Enter account number for this checkbook here." ) ); | 161 | QWhatsThis::add( label, tr( "Enter account number for this checkbook here." ) ); |
163 | layout->addWidget( label, 4, 0 ); | 162 | layout->addWidget( label, 4, 0 ); |
164 | acctNumEdit = new QLineEdit( container ); | 163 | acctNumEdit = new QLineEdit( container ); |
165 | QWhatsThis::add( acctNumEdit, tr( "Enter account number for this checkbook here." ) ); | 164 | QWhatsThis::add( acctNumEdit, tr( "Enter account number for this checkbook here." ) ); |
166 | layout->addWidget( acctNumEdit, 4, 1 ); | 165 | layout->addWidget( acctNumEdit, 4, 1 ); |
167 | 166 | ||
168 | // PIN number | 167 | // PIN number |
169 | label = new QLabel( tr( "PIN number:" ), container ); | 168 | label = new QLabel( tr( "PIN number:" ), container ); |
170 | QWhatsThis::add( label, tr( "Enter PIN number for this checkbook here." ) ); | 169 | QWhatsThis::add( label, tr( "Enter PIN number for this checkbook here." ) ); |
171 | layout->addWidget( label, 5, 0 ); | 170 | layout->addWidget( label, 5, 0 ); |
172 | pinNumEdit = new QLineEdit( container ); | 171 | pinNumEdit = new QLineEdit( container ); |
173 | QWhatsThis::add( pinNumEdit, tr( "Enter PIN number for this checkbook here." ) ); | 172 | QWhatsThis::add( pinNumEdit, tr( "Enter PIN number for this checkbook here." ) ); |
174 | layout->addWidget( pinNumEdit, 5, 1 ); | 173 | layout->addWidget( pinNumEdit, 5, 1 ); |
175 | 174 | ||
176 | // Starting balance | 175 | // Starting balance |
177 | label = new QLabel( tr( "Starting balance:" ), container ); | 176 | label = new QLabel( tr( "Starting balance:" ), container ); |
178 | QWhatsThis::add( label, tr( "Enter the initial balance for this checkbook here." ) ); | 177 | QWhatsThis::add( label, tr( "Enter the initial balance for this checkbook here." ) ); |
179 | layout->addWidget( label, 6, 0 ); | 178 | layout->addWidget( label, 6, 0 ); |
180 | balanceEdit = new QLineEdit( container ); | 179 | balanceEdit = new QLineEdit( container ); |
181 | QWhatsThis::add( balanceEdit, tr( "Enter the initial balance for this checkbook here." ) ); | 180 | QWhatsThis::add( balanceEdit, tr( "Enter the initial balance for this checkbook here." ) ); |
182 | connect( balanceEdit, SIGNAL( textChanged( const QString & ) ), | 181 | connect( balanceEdit, SIGNAL( textChanged( const QString & ) ), |
183 | this, SLOT( slotStartingBalanceChanged( const QString & ) ) ); | 182 | this, SLOT( slotStartingBalanceChanged( const QString & ) ) ); |
184 | layout->addWidget( balanceEdit, 6, 1 ); | 183 | layout->addWidget( balanceEdit, 6, 1 ); |
185 | 184 | ||
186 | // Notes | 185 | // Notes |
187 | label = new QLabel( tr( "Notes:" ), container ); | 186 | label = new QLabel( tr( "Notes:" ), container ); |
188 | QWhatsThis::add( label, tr( "Enter any additional information for this checkbook here." ) ); | 187 | QWhatsThis::add( label, tr( "Enter any additional information for this checkbook here." ) ); |
189 | layout->addWidget( label, 7, 0 ); | 188 | layout->addWidget( label, 7, 0 ); |
190 | notesEdit = new QMultiLineEdit( container ); | 189 | notesEdit = new QMultiLineEdit( container ); |
191 | QWhatsThis::add( notesEdit, tr( "Enter any additional information for this checkbook here." ) ); | 190 | QWhatsThis::add( notesEdit, tr( "Enter any additional information for this checkbook here." ) ); |
192 | notesEdit->setMinimumHeight( 25 ); | 191 | notesEdit->setMinimumHeight( 25 ); |
193 | notesEdit->setMaximumHeight( 65 ); | 192 | notesEdit->setMaximumHeight( 65 ); |
194 | layout->addMultiCellWidget( notesEdit, 8, 8, 0, 1 ); | 193 | layout->addMultiCellWidget( notesEdit, 8, 8, 0, 1 ); |
195 | 194 | ||
196 | return control; | 195 | return control; |
197 | } | 196 | } |
198 | 197 | ||
199 | 198 | ||
200 | // --- initTransactions ------------------------------------------------------- | 199 | // --- initTransactions ------------------------------------------------------- |
201 | QWidget *Checkbook::initTransactions() | 200 | QWidget *Checkbook::initTransactions() |
202 | { | 201 | { |
203 | QWidget *control = new QWidget( mainWidget, tr("Transactions") ); | 202 | QWidget *control = new QWidget( mainWidget, tr("Transactions") ); |
204 | 203 | ||
205 | QGridLayout *layout = new QGridLayout( control ); | 204 | QGridLayout *layout = new QGridLayout( control ); |
206 | layout->setSpacing( 2 ); | 205 | layout->setSpacing( 2 ); |
207 | layout->setMargin( 4 ); | 206 | layout->setMargin( 4 ); |
208 | 207 | ||
209 | // Sort selector | 208 | // Sort selector |
210 | QLabel *label = new QLabel( tr( "Sort by:" ), control ); | 209 | QLabel *label = new QLabel( tr( "Sort by:" ), control ); |
211 | QWhatsThis::add( label, tr( "Select checkbook sorting here." ) ); | 210 | QWhatsThis::add( label, tr( "Select checkbook sorting here." ) ); |
212 | layout->addMultiCellWidget( label, 0, 0, 0, 1 ); | 211 | layout->addMultiCellWidget( label, 0, 0, 0, 1 ); |
213 | _cbSortType=new QComboBox( control ); | 212 | _cbSortType=new QComboBox( control ); |
214 | _cbSortType->insertItem( tr("Entry Order") ); | 213 | _cbSortType->insertItem( tr("Entry Order") ); |
215 | _cbSortType->insertItem( tr("Date") ); | 214 | _cbSortType->insertItem( tr("Date") ); |
@@ -222,7 +221,7 @@ QWidget *Checkbook::initTransactions() | |||
222 | QFont fnt(QPEApplication::font()); | 221 | QFont fnt(QPEApplication::font()); |
223 | fnt.setPointSize( fnt.pointSize()-1 ); | 222 | fnt.setPointSize( fnt.pointSize()-1 ); |
224 | tranTable->setFont( fnt ); | 223 | tranTable->setFont( fnt ); |
225 | 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." ) ); | 224 | 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." ) ); |
226 | tranTable->addColumn( tr( "Id" ) ); | 225 | tranTable->addColumn( tr( "Id" ) ); |
227 | tranTable->setColumnWidthMode( COL_ID, QListView::Manual ); | 226 | tranTable->setColumnWidthMode( COL_ID, QListView::Manual ); |
228 | tranTable->setColumnWidth( COL_ID, 0); | 227 | tranTable->setColumnWidth( COL_ID, 0); |
@@ -230,121 +229,121 @@ QWidget *Checkbook::initTransactions() | |||
230 | tranTable->setColumnWidthMode( COL_SORTDATE, QListView::Manual ); | 229 | tranTable->setColumnWidthMode( COL_SORTDATE, QListView::Manual ); |
231 | tranTable->setColumnWidth( COL_SORTDATE, 0); | 230 | tranTable->setColumnWidth( COL_SORTDATE, 0); |
232 | tranTable->addColumn( tr( "Num" ) ); | 231 | tranTable->addColumn( tr( "Num" ) ); |
233 | tranTable->addColumn( tr( "Date" ) ); | 232 | tranTable->addColumn( tr( "Date" ) ); |
234 | //tranTable->addColumn( tr( "Cleared" ) ); | 233 | //tranTable->addColumn( tr( "Cleared" ) ); |
235 | tranTable->addColumn( tr( "Description" ) ); | 234 | tranTable->addColumn( tr( "Description" ) ); |
236 | int column = tranTable->addColumn( tr( "Amount" ) ); | 235 | int column = tranTable->addColumn( tr( "Amount" ) ); |
237 | tranTable->setColumnAlignment( column, Qt::AlignRight ); | 236 | tranTable->setColumnAlignment( column, Qt::AlignRight ); |
238 | column=tranTable->addColumn( tr("Balance") ); | 237 | column=tranTable->addColumn( tr("Balance") ); |
239 | tranTable->setColumnAlignment( column, Qt::AlignRight ); | 238 | tranTable->setColumnAlignment( column, Qt::AlignRight ); |
240 | tranTable->setAllColumnsShowFocus( TRUE ); | 239 | tranTable->setAllColumnsShowFocus( TRUE ); |
241 | tranTable->setSorting( -1 ); | 240 | tranTable->setSorting( -1 ); |
242 | layout->addMultiCellWidget( tranTable, 1, 1, 0, 2 ); | 241 | layout->addMultiCellWidget( tranTable, 1, 1, 0, 2 ); |
243 | QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold ); | 242 | QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold ); |
244 | connect( tranTable, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), | 243 | connect( tranTable, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), |
245 | this, SLOT( slotMenuTran(QListViewItem *, const QPoint &) ) ); | 244 | this, SLOT( slotMenuTran(QListViewItem *, const QPoint &) ) ); |
246 | connect( tranTable, SIGNAL( doubleClicked( QListViewItem * ) ), | 245 | connect( tranTable, SIGNAL( doubleClicked( QListViewItem * ) ), |
247 | this, SLOT( slotEditTran() ) ); | 246 | this, SLOT( slotEditTran() ) ); |
248 | _sortCol=COL_ID; | 247 | _sortCol=COL_ID; |
249 | 248 | ||
250 | // Buttons | 249 | // Buttons |
251 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), control ); | 250 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), control ); |
252 | QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) ); | 251 | QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) ); |
253 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotNewTran() ) ); | 252 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotNewTran() ) ); |
254 | layout->addWidget( btn, 2, 0 ); | 253 | layout->addWidget( btn, 2, 0 ); |
255 | 254 | ||
256 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), control ); | 255 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), control ); |
257 | QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) ); | 256 | QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) ); |
258 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotEditTran() ) ); | 257 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotEditTran() ) ); |
259 | layout->addWidget( btn, 2, 1 ); | 258 | layout->addWidget( btn, 2, 1 ); |
260 | 259 | ||
261 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), control ); | 260 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), control ); |
262 | QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) ); | 261 | QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) ); |
263 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDeleteTran() ) ); | 262 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDeleteTran() ) ); |
264 | layout->addWidget( btn, 2, 2 ); | 263 | layout->addWidget( btn, 2, 2 ); |
265 | 264 | ||
266 | return( control ); | 265 | return( control ); |
267 | } | 266 | } |
268 | 267 | ||
269 | 268 | ||
270 | // --- initCharts ------------------------------------------------------------- | 269 | // --- initCharts ------------------------------------------------------------- |
271 | QWidget *Checkbook::initCharts() | 270 | QWidget *Checkbook::initCharts() |
272 | { | 271 | { |
273 | graphInfo = 0x0; | 272 | graphInfo = 0x0; |
274 | 273 | ||
275 | QWidget *control = new QWidget( mainWidget, tr("Charts") ); | 274 | QWidget *control = new QWidget( mainWidget, tr("Charts") ); |
276 | 275 | ||
277 | QGridLayout *layout = new QGridLayout( control ); | 276 | QGridLayout *layout = new QGridLayout( control ); |
278 | layout->setSpacing( 2 ); | 277 | layout->setSpacing( 2 ); |
279 | layout->setMargin( 4 ); | 278 | layout->setMargin( 4 ); |
280 | 279 | ||
281 | graphWidget = new Graph( control ); | 280 | graphWidget = new Graph( control ); |
282 | QWhatsThis::add( graphWidget, tr( "Select the desired chart below and then click on the Draw button." ) ); | 281 | QWhatsThis::add( graphWidget, tr( "Select the desired chart below and then click on the Draw button." ) ); |
283 | layout->addMultiCellWidget( graphWidget, 0, 0, 0, 2 ); | 282 | layout->addMultiCellWidget( graphWidget, 0, 0, 0, 2 ); |
284 | 283 | ||
285 | graphList = new QComboBox( control ); | 284 | graphList = new QComboBox( control ); |
286 | QWhatsThis::add( graphList, tr( "Click here to select the desired chart type." ) ); | 285 | QWhatsThis::add( graphList, tr( "Click here to select the desired chart type." ) ); |
287 | graphList->insertItem( tr( "Account balance" ) ); | 286 | graphList->insertItem( tr( "Account balance" ) ); |
288 | graphList->insertItem( tr( "Withdrawals by category" ) ); | 287 | graphList->insertItem( tr( "Withdrawals by category" ) ); |
289 | graphList->insertItem( tr( "Deposits by category" ) ); | 288 | graphList->insertItem( tr( "Deposits by category" ) ); |
290 | 289 | ||
291 | layout->addMultiCellWidget( graphList, 1, 1, 0, 1 ); | 290 | layout->addMultiCellWidget( graphList, 1, 1, 0, 1 ); |
292 | 291 | ||
293 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/drawbtn" ), tr( "Draw" ), control ); | 292 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/drawbtn" ), tr( "Draw" ), control ); |
294 | QWhatsThis::add( btn, tr( "Click here to draw the selected chart." ) ); | 293 | QWhatsThis::add( btn, tr( "Click here to draw the selected chart." ) ); |
295 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) ); | 294 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) ); |
296 | layout->addWidget( btn, 1, 2 ); | 295 | layout->addWidget( btn, 1, 2 ); |
297 | 296 | ||
298 | return control; | 297 | return control; |
299 | } | 298 | } |
300 | 299 | ||
301 | // --- loadCheckbook ---------------------------------------------------------- | 300 | // --- loadCheckbook ---------------------------------------------------------- |
302 | void Checkbook::loadCheckbook() | 301 | void Checkbook::loadCheckbook() |
303 | { | 302 | { |
304 | if ( !info ) | 303 | if ( !info ) |
305 | { | 304 | { |
306 | return; | 305 | return; |
307 | } | 306 | } |
308 | 307 | ||
309 | tranList = info->transactions(); | 308 | tranList = info->transactions(); |
310 | 309 | ||
311 | passwordCB->setChecked( !info->password().isNull() ); | 310 | passwordCB->setChecked( !info->password().isNull() ); |
312 | nameEdit->setText( info->name() ); | 311 | nameEdit->setText( info->name() ); |
313 | QString temptext = info->type(); | 312 | QString temptext = info->type(); |
314 | int i = typeList->count(); | 313 | int i = typeList->count(); |
315 | while ( i > 0 ) | 314 | while ( i > 0 ) |
316 | { | 315 | { |
317 | i--; | 316 | i--; |
318 | typeList->setCurrentItem( i ); | 317 | typeList->setCurrentItem( i ); |
319 | if ( typeList->currentText() == temptext ) | 318 | if ( typeList->currentText() == temptext ) |
320 | { | 319 | { |
321 | break; | 320 | break; |
322 | } | 321 | } |
323 | } | 322 | } |
324 | if( i<=0 ) { | 323 | if( i<=0 ) { |
325 | typeList->insertItem( temptext, 0 ); | 324 | typeList->insertItem( temptext, 0 ); |
326 | typeList->setCurrentItem(0); | 325 | typeList->setCurrentItem(0); |
327 | } | 326 | } |
328 | bankEdit->setText( info->bank() ); | 327 | bankEdit->setText( info->bank() ); |
329 | acctNumEdit->setText( info->account() ); | 328 | acctNumEdit->setText( info->account() ); |
330 | pinNumEdit->setText( info->pin() ); | 329 | pinNumEdit->setText( info->pin() ); |
331 | temptext.setNum( info->startingBalance(), 'f', 2 ); | 330 | temptext.setNum( info->startingBalance(), 'f', 2 ); |
332 | balanceEdit->setText( temptext ); | 331 | balanceEdit->setText( temptext ); |
333 | notesEdit->setText( info->notes() ); | 332 | notesEdit->setText( info->notes() ); |
334 | 333 | ||
335 | // Load transactions | 334 | // Load transactions |
336 | float amount; | 335 | float amount; |
337 | QString stramount; | 336 | QString stramount; |
338 | for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() ) | 337 | for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() ) |
339 | { | 338 | { |
340 | amount = tran->amount(); | 339 | amount = tran->amount(); |
341 | if ( tran->withdrawal() ) | 340 | if ( tran->withdrawal() ) |
342 | { | 341 | { |
343 | amount *= -1; | 342 | amount *= -1; |
344 | } | 343 | } |
345 | stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); | 344 | stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); |
346 | ( void ) new CBListItem( tran, tranTable, tran->getIdStr(), tran->datestr(false), tran->number(), tran->datestr(true), tran->desc(), stramount ); | 345 | ( void ) new CBListItem( tran, tranTable, tran->getIdStr(), tran->datestr(false), tran->number(), tran->datestr(true), tran->desc(), stramount ); |
347 | } | 346 | } |
348 | 347 | ||
349 | // set sort order | 348 | // set sort order |
350 | bool bOk=false; | 349 | bool bOk=false; |
@@ -369,7 +368,7 @@ void Checkbook::loadCheckbook() | |||
369 | // --- adjustBalance ---------------------------------------------------------- | 368 | // --- adjustBalance ---------------------------------------------------------- |
370 | void Checkbook::adjustBalance() | 369 | void Checkbook::adjustBalance() |
371 | { | 370 | { |
372 | // update running balance in register | 371 | // update running balance in register |
373 | QString sRunning; | 372 | QString sRunning; |
374 | float bal=info->startingBalance(); | 373 | float bal=info->startingBalance(); |
375 | for(CBListItem *item=(CBListItem *)tranTable->firstChild(); item; item=(CBListItem *)item->nextSibling() ) { | 374 | for(CBListItem *item=(CBListItem *)tranTable->firstChild(); item; item=(CBListItem *)item->nextSibling() ) { |
@@ -392,112 +391,112 @@ void Checkbook::resort() | |||
392 | // --- accept ----------------------------------------------------------------- | 391 | // --- accept ----------------------------------------------------------------- |
393 | void Checkbook::accept() | 392 | void Checkbook::accept() |
394 | { | 393 | { |
395 | info->setName( nameEdit->text() ); | 394 | info->setName( nameEdit->text() ); |
396 | info->setType( typeList->currentText() ); | 395 | info->setType( typeList->currentText() ); |
397 | info->setBank( bankEdit->text() ); | 396 | info->setBank( bankEdit->text() ); |
398 | info->setAccount( acctNumEdit->text() ); | 397 | info->setAccount( acctNumEdit->text() ); |
399 | info->setPin( pinNumEdit->text() ); | 398 | info->setPin( pinNumEdit->text() ); |
400 | bool ok; | 399 | bool ok; |
401 | info->setStartingBalance( balanceEdit->text().toFloat( &ok ) ); | 400 | info->setStartingBalance( balanceEdit->text().toFloat( &ok ) ); |
402 | info->setNotes( notesEdit->text() ); | 401 | info->setNotes( notesEdit->text() ); |
403 | 402 | ||
404 | QDialog::accept(); | 403 | QDialog::accept(); |
405 | } | 404 | } |
406 | 405 | ||
407 | // --- slotPasswordClicked ---------------------------------------------------- | 406 | // --- slotPasswordClicked ---------------------------------------------------- |
408 | void Checkbook::slotPasswordClicked() | 407 | void Checkbook::slotPasswordClicked() |
409 | { | 408 | { |
410 | if ( info->password().isNull() && passwordCB->isChecked() ) | 409 | if ( info->password().isNull() && passwordCB->isChecked() ) |
411 | { | 410 | { |
412 | Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); | 411 | Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); |
413 | if ( pw->exec() != QDialog::Accepted ) | 412 | if ( pw->exec() != QDialog::Accepted ) |
414 | { | 413 | { |
415 | passwordCB->setChecked( FALSE ); | 414 | passwordCB->setChecked( FALSE ); |
416 | delete pw; | 415 | delete pw; |
417 | return; | 416 | return; |
418 | } | 417 | } |
419 | info->setPassword( pw->password ); | 418 | info->setPassword( pw->password ); |
420 | delete pw; | 419 | delete pw; |
421 | 420 | ||
422 | pw = new Password( this, tr( "Confirm password" ), tr( "Please confirm your password:" ) ); | 421 | pw = new Password( this, tr( "Confirm password" ), tr( "Please confirm your password:" ) ); |
423 | if ( pw->exec() != QDialog::Accepted || pw->password != info->password() ) | 422 | if ( pw->exec() != QDialog::Accepted || pw->password != info->password() ) |
424 | { | 423 | { |
425 | passwordCB->setChecked( FALSE ); | 424 | passwordCB->setChecked( FALSE ); |
426 | info->setPassword( QString::null ); | 425 | info->setPassword( QString::null ); |
427 | } | 426 | } |
428 | 427 | ||
429 | delete pw; | 428 | delete pw; |
430 | } | 429 | } |
431 | else if ( !info->password().isNull() && !passwordCB->isChecked() ) | 430 | else if ( !info->password().isNull() && !passwordCB->isChecked() ) |
432 | { | 431 | { |
433 | Password *pw = new Password( this, tr( "Enter password" ), | 432 | Password *pw = new Password( this, tr( "Enter password" ), |
434 | tr( "Please enter your password to confirm removal of password protection:" ) ); | 433 | tr( "Please enter your password to confirm removal of password protection:" ) ); |
435 | if ( pw->exec() == QDialog::Accepted && pw->password == info->password() ) | 434 | if ( pw->exec() == QDialog::Accepted && pw->password == info->password() ) |
436 | { | 435 | { |
437 | info->setPassword( QString::null ); | 436 | info->setPassword( QString::null ); |
438 | delete pw; | 437 | delete pw; |
439 | return; | 438 | return; |
440 | } | 439 | } |
441 | else | 440 | else |
442 | { | 441 | { |
443 | passwordCB->setChecked( TRUE ); | 442 | passwordCB->setChecked( TRUE ); |
444 | } | 443 | } |
445 | 444 | ||
446 | delete pw; | 445 | delete pw; |
447 | } | 446 | } |
448 | } | 447 | } |
449 | 448 | ||
450 | void Checkbook::slotNameChanged( const QString &newname ) | 449 | void Checkbook::slotNameChanged( const QString &newname ) |
451 | { | 450 | { |
452 | info->setName( newname ); | 451 | info->setName( newname ); |
453 | 452 | ||
454 | // TODO - need filedir | 453 | // TODO - need filedir |
455 | //QString namestr = filedir; | 454 | // QString namestr = filedir; |
456 | //namestr.append( newname ); | 455 | // namestr.append( newname ); |
457 | //namestr.append( ".qcb" ); | 456 | // namestr.append( ".qcb" ); |
458 | //info->setFilename( namestr ); | 457 | // info->setFilename( namestr ); |
459 | 458 | ||
460 | QString namestr = newname; | 459 | QString namestr = newname; |
461 | namestr.append( " - " ); | 460 | namestr.append( " - " ); |
462 | namestr.append( tr( "Checkbook" ) ); | 461 | namestr.append( tr( "Checkbook" ) ); |
463 | setCaption( namestr ); | 462 | setCaption( namestr ); |
464 | } | 463 | } |
465 | 464 | ||
466 | 465 | ||
467 | // ---slotStartingBalanceChanged ---------------------------------------------- | 466 | // ---slotStartingBalanceChanged ---------------------------------------------- |
468 | void Checkbook::slotStartingBalanceChanged( const QString &newbalance ) | 467 | void Checkbook::slotStartingBalanceChanged( const QString &newbalance ) |
469 | { | 468 | { |
470 | bool ok; | 469 | bool ok; |
471 | info->setStartingBalance( newbalance.toFloat( &ok ) ); | 470 | info->setStartingBalance( newbalance.toFloat( &ok ) ); |
472 | adjustBalance(); | 471 | adjustBalance(); |
473 | } | 472 | } |
474 | 473 | ||
475 | 474 | ||
476 | // --- slotNewTran ------------------------------------------------------------ | 475 | // --- slotNewTran ------------------------------------------------------------ |
477 | void Checkbook::slotNewTran() | 476 | void Checkbook::slotNewTran() |
478 | { | 477 | { |
479 | TranInfo *traninfo = new TranInfo( info->getNextNumber() ); | 478 | TranInfo *traninfo = new TranInfo( info->getNextNumber() ); |
480 | if( !_dLastNew.isNull() ) | 479 | if( !_dLastNew.isNull() ) |
481 | traninfo->setDate(_dLastNew); | 480 | traninfo->setDate(_dLastNew); |
482 | 481 | ||
483 | Transaction *currtran = new Transaction( this, true, info->name(), | 482 | Transaction *currtran = new Transaction( this, true, info->name(), |
484 | traninfo, | 483 | traninfo, |
485 | _pCfg ); | 484 | _pCfg ); |
486 | if ( QPEApplication::execDialog( currtran ) == QDialog::Accepted ) | 485 | if ( QPEApplication::execDialog( currtran ) == QDialog::Accepted ) |
487 | { | 486 | { |
488 | // Add to transaction list | 487 | // Add to transaction list |
489 | info->addTransaction( traninfo ); | 488 | info->addTransaction( traninfo ); |
490 | 489 | ||
491 | // Add to transaction table | 490 | // Add to transaction table |
492 | float amount; | 491 | float amount; |
493 | QString stramount; | 492 | QString stramount; |
494 | amount = (traninfo->withdrawal() ? -1 : 1)*traninfo->amount(); | 493 | amount = (traninfo->withdrawal() ? -1 : 1)*traninfo->amount(); |
495 | stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); | 494 | stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); |
496 | ( void ) new CBListItem( traninfo, tranTable, traninfo->getIdStr(), traninfo->datestr(false), | 495 | ( void ) new CBListItem( traninfo, tranTable, traninfo->getIdStr(), traninfo->datestr(false), |
497 | traninfo->number(), traninfo->datestr(true), traninfo->desc(), | 496 | traninfo->number(), traninfo->datestr(true), traninfo->desc(), |
498 | stramount ); | 497 | stramount ); |
499 | resort(); | 498 | resort(); |
500 | adjustBalance(); | 499 | adjustBalance(); |
501 | 500 | ||
502 | // save last date | 501 | // save last date |
503 | _dLastNew = traninfo->date(); | 502 | _dLastNew = traninfo->date(); |
@@ -509,41 +508,41 @@ void Checkbook::slotNewTran() | |||
509 | pLst->sort(); | 508 | pLst->sort(); |
510 | _pCfg->setDirty(true); | 509 | _pCfg->setDirty(true); |
511 | } | 510 | } |
512 | } | 511 | } |
513 | else | 512 | else |
514 | { | 513 | { |
515 | delete traninfo; | 514 | delete traninfo; |
516 | } | 515 | } |
517 | } | 516 | } |
518 | 517 | ||
519 | 518 | ||
520 | // --- slotEditTran ----------------------------------------------------------- | 519 | // --- slotEditTran ----------------------------------------------------------- |
521 | void Checkbook::slotEditTran() | 520 | void Checkbook::slotEditTran() |
522 | { | 521 | { |
523 | QListViewItem *curritem = tranTable->currentItem(); | 522 | QListViewItem *curritem = tranTable->currentItem(); |
524 | if ( !curritem ) | 523 | if ( !curritem ) |
525 | return; | 524 | return; |
526 | 525 | ||
527 | TranInfo *traninfo=info->findTransaction( curritem->text(COL_ID) ); | 526 | TranInfo *traninfo=info->findTransaction( curritem->text(COL_ID) ); |
528 | 527 | ||
529 | Transaction *currtran = new Transaction( this, false, info->name(), | 528 | Transaction *currtran = new Transaction( this, false, info->name(), |
530 | traninfo, | 529 | traninfo, |
531 | _pCfg ); | 530 | _pCfg ); |
532 | if ( QPEApplication::execDialog( currtran ) == QDialog::Accepted ) | 531 | if ( QPEApplication::execDialog( currtran ) == QDialog::Accepted ) |
533 | { | 532 | { |
534 | curritem->setText( COL_NUM, traninfo->number() ); | 533 | curritem->setText( COL_NUM, traninfo->number() ); |
535 | curritem->setText( COL_SORTDATE, traninfo->datestr(false) ); | 534 | curritem->setText( COL_SORTDATE, traninfo->datestr(false) ); |
536 | curritem->setText( COL_DATE, traninfo->datestr(true) ); | 535 | curritem->setText( COL_DATE, traninfo->datestr(true) ); |
537 | curritem->setText( COL_DESC, traninfo->desc() ); | 536 | curritem->setText( COL_DESC, traninfo->desc() ); |
538 | 537 | ||
539 | float amount = traninfo->amount(); | 538 | float amount = traninfo->amount(); |
540 | if ( traninfo->withdrawal() ) | 539 | if ( traninfo->withdrawal() ) |
541 | { | 540 | { |
542 | amount *= -1; | 541 | amount *= -1; |
543 | } | 542 | } |
544 | QString stramount; | 543 | QString stramount; |
545 | stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); | 544 | stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); |
546 | curritem->setText( COL_AMOUNT, stramount ); | 545 | curritem->setText( COL_AMOUNT, stramount ); |
547 | resort(); | 546 | resort(); |
548 | adjustBalance(); | 547 | adjustBalance(); |
549 | 548 | ||
@@ -554,9 +553,9 @@ void Checkbook::slotEditTran() | |||
554 | pLst->sort(); | 553 | pLst->sort(); |
555 | _pCfg->setDirty(true); | 554 | _pCfg->setDirty(true); |
556 | } | 555 | } |
557 | } | 556 | } |
558 | 557 | ||
559 | delete currtran; | 558 | delete currtran; |
560 | } | 559 | } |
561 | 560 | ||
562 | // --- slotMenuTran ----------------------------------------------------------- | 561 | // --- slotMenuTran ----------------------------------------------------------- |
@@ -568,10 +567,10 @@ void Checkbook::slotMenuTran(QListViewItem *item, const QPoint &pnt) | |||
568 | 567 | ||
569 | // Display menu | 568 | // Display menu |
570 | QPopupMenu m; | 569 | QPopupMenu m; |
571 | m.insertItem( QWidget::tr( "Edit" ), 1 ); | 570 | m.insertItem( QWidget::tr( "Edit" ), 1 ); |
572 | m.insertItem( QWidget::tr( "New" ), 2 ); | 571 | m.insertItem( QWidget::tr( "New" ), 2 ); |
573 | m.insertItem( QWidget::tr( "Delete" ), 3 ); | 572 | m.insertItem( QWidget::tr( "Delete" ), 3 ); |
574 | int r = m.exec( pnt ); | 573 | int r = m.exec( pnt ); |
575 | switch(r) { | 574 | switch(r) { |
576 | case 1: | 575 | case 1: |
577 | slotEditTran(); | 576 | slotEditTran(); |
@@ -589,177 +588,177 @@ void Checkbook::slotMenuTran(QListViewItem *item, const QPoint &pnt) | |||
589 | // --- slotDeleteTran --------------------------------------------------------- | 588 | // --- slotDeleteTran --------------------------------------------------------- |
590 | void Checkbook::slotDeleteTran() | 589 | void Checkbook::slotDeleteTran() |
591 | { | 590 | { |
592 | QListViewItem *curritem = tranTable->currentItem(); | 591 | QListViewItem *curritem = tranTable->currentItem(); |
593 | if ( !curritem ) | 592 | if ( !curritem ) |
594 | return; | 593 | return; |
595 | 594 | ||
596 | TranInfo *traninfo = info->findTransaction( curritem->text(COL_ID) ); | 595 | TranInfo *traninfo = info->findTransaction( curritem->text(COL_ID) ); |
597 | 596 | ||
598 | if ( QPEMessageBox::confirmDelete ( this, tr( "Delete transaction" ), traninfo->desc() ) ) | 597 | if ( QPEMessageBox::confirmDelete ( this, tr( "Delete transaction" ), traninfo->desc() ) ) |
599 | { | 598 | { |
600 | info->removeTransaction( traninfo ); | 599 | info->removeTransaction( traninfo ); |
601 | delete curritem; | 600 | delete curritem; |
602 | adjustBalance(); | 601 | adjustBalance(); |
603 | } | 602 | } |
604 | } | 603 | } |
605 | 604 | ||
606 | void Checkbook::slotDrawGraph() | 605 | void Checkbook::slotDrawGraph() |
607 | { | 606 | { |
608 | if ( graphInfo ) | 607 | if ( graphInfo ) |
609 | { | 608 | { |
610 | delete graphInfo; | 609 | delete graphInfo; |
611 | } | 610 | } |
612 | 611 | ||
613 | switch ( graphList->currentItem() ) | 612 | switch ( graphList->currentItem() ) |
614 | { | 613 | { |
615 | case 0 : drawBalanceChart(); | 614 | case 0 : drawBalanceChart(); |
616 | break; | 615 | break; |
617 | case 1 : drawCategoryChart( TRUE ); | 616 | case 1 : drawCategoryChart( TRUE ); |
618 | break; | 617 | break; |
619 | case 2 : drawCategoryChart( FALSE ); | 618 | case 2 : drawCategoryChart( FALSE ); |
620 | break; | 619 | break; |
621 | }; | 620 | }; |
622 | 621 | ||
623 | graphWidget->setGraphInfo( graphInfo ); | 622 | graphWidget->setGraphInfo( graphInfo ); |
624 | graphWidget->drawGraph( TRUE ); | 623 | graphWidget->drawGraph( TRUE ); |
625 | } | 624 | } |
626 | 625 | ||
627 | void Checkbook::drawBalanceChart() | 626 | void Checkbook::drawBalanceChart() |
628 | { | 627 | { |
629 | DataPointList *list = new DataPointList(); | 628 | DataPointList *list = new DataPointList(); |
630 | 629 | ||
631 | float balance = info->startingBalance(); | 630 | float balance = info->startingBalance(); |
632 | float amount; | 631 | float amount; |
633 | QString label; | 632 | QString label; |
634 | int i = 0; | 633 | int i = 0; |
635 | int count = tranList->count(); | 634 | int count = tranList->count(); |
636 | 635 | ||
637 | for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() ) | 636 | for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() ) |
638 | { | 637 | { |
639 | i++; | 638 | i++; |
640 | balance -= tran->fee(); | 639 | balance -= tran->fee(); |
641 | amount = tran->amount(); | 640 | amount = tran->amount(); |
642 | if ( tran->withdrawal() ) | 641 | if ( tran->withdrawal() ) |
643 | { | 642 | { |
644 | amount *= -1; | 643 | amount *= -1; |
645 | } | 644 | } |
646 | balance += amount; | 645 | balance += amount; |
647 | if ( i == 1 || i == count / 2 || i == count ) | 646 | if ( i == 1 || i == count / 2 || i == count ) |
648 | { | 647 | { |
649 | label = tran->datestr(true); | 648 | label = tran->datestr(true); |
650 | } | 649 | } |
651 | else | 650 | else |
652 | { | 651 | { |
653 | label = ""; | 652 | label = ""; |
654 | } | 653 | } |
655 | list->append( new DataPointInfo( label, balance ) ); | 654 | list->append( new DataPointInfo( label, balance ) ); |
656 | } | 655 | } |
657 | 656 | ||
658 | graphInfo = new GraphInfo( GraphInfo::BarChart, list ); | 657 | graphInfo = new GraphInfo( GraphInfo::BarChart, list ); |
659 | } | 658 | } |
660 | 659 | ||
661 | void Checkbook::drawCategoryChart( bool withdrawals ) | 660 | void Checkbook::drawCategoryChart( bool withdrawals ) |
662 | { | 661 | { |
663 | DataPointList *list = new DataPointList(); | 662 | DataPointList *list = new DataPointList(); |
664 | 663 | ||
665 | TranInfo *tran = tranList->first(); | 664 | TranInfo *tran = tranList->first(); |
666 | if ( tran && tran->withdrawal() == withdrawals ) | 665 | if ( tran && tran->withdrawal() == withdrawals ) |
667 | { | 666 | { |
668 | list->append( new DataPointInfo( tran->category(), tran->amount() ) ); | 667 | list->append( new DataPointInfo( tran->category(), tran->amount() ) ); |
669 | } | 668 | } |
670 | tran = tranList->next(); | 669 | tran = tranList->next(); |
671 | 670 | ||
672 | DataPointInfo *cat; | 671 | DataPointInfo *cat; |
673 | for ( ; tran; tran = tranList->next() ) | 672 | for ( ; tran; tran = tranList->next() ) |
674 | { | 673 | { |
675 | if ( tran->withdrawal() == withdrawals ) | 674 | if ( tran->withdrawal() == withdrawals ) |
676 | { | 675 | { |
677 | // Find category in list | 676 | // Find category in list |
678 | for ( cat = list->first(); cat; cat = list->next() ) | 677 | for ( cat = list->first(); cat; cat = list->next() ) |
679 | { | 678 | { |
680 | if ( cat->label() == tran->category() ) | 679 | if ( cat->label() == tran->category() ) |
681 | { | 680 | { |
682 | break; | 681 | break; |
683 | } | 682 | } |
684 | } | 683 | } |
685 | if ( cat && cat->label() == tran->category() ) | 684 | if ( cat && cat->label() == tran->category() ) |
686 | { // Found category, add to transaction to category total | 685 | { // Found category, add to transaction to category total |
687 | cat->addToValue( tran->amount() ); | 686 | cat->addToValue( tran->amount() ); |
688 | } | 687 | } |
689 | else | 688 | else |
690 | { // Didn't find category, add category to list | 689 | { // Didn't find category, add category to list |
691 | list->append( new DataPointInfo( tran->category(), tran->amount() ) ); | 690 | list->append( new DataPointInfo( tran->category(), tran->amount() ) ); |
692 | } | 691 | } |
693 | } | 692 | } |
694 | } | 693 | } |
695 | 694 | ||
696 | graphInfo = new GraphInfo( GraphInfo::PieChart, list ); | 695 | graphInfo = new GraphInfo( GraphInfo::PieChart, list ); |
697 | } | 696 | } |
698 | 697 | ||
699 | CBListItem::CBListItem( TranInfo *pTran, QListView *parent, QString label1, QString label2, | 698 | CBListItem::CBListItem( TranInfo *pTran, QListView *parent, QString label1, QString label2, |
700 | QString label3, QString label4, QString label5, QString label6, QString label7, | 699 | QString label3, QString label4, QString label5, QString label6, QString label7, |
701 | QString label8 ) | 700 | QString label8 ) |
702 | : QListViewItem( parent, label1, label2, label3, label4, label5, label6, label7, label8 ) | 701 | : QListViewItem( parent, label1, label2, label3, label4, label5, label6, label7, label8 ) |
703 | { | 702 | { |
704 | _pTran=pTran; | 703 | _pTran=pTran; |
705 | m_known = FALSE; | 704 | m_known = FALSE; |
706 | owner = parent; | 705 | owner = parent; |
707 | } | 706 | } |
708 | 707 | ||
709 | void CBListItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align ) | 708 | void CBListItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align ) |
710 | { | 709 | { |
711 | QColorGroup _cg = cg; | 710 | QColorGroup _cg = cg; |
712 | const QPixmap *pm = listView()->viewport()->backgroundPixmap(); | 711 | const QPixmap *pm = listView()->viewport()->backgroundPixmap(); |
713 | if ( pm && !pm->isNull() ) | 712 | if ( pm && !pm->isNull() ) |
714 | { | 713 | { |
715 | _cg.setBrush( QColorGroup::Base, QBrush( cg.base(), *pm ) ); | 714 | _cg.setBrush( QColorGroup::Base, QBrush( cg.base(), *pm ) ); |
716 | p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); | 715 | p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); |
717 | } | 716 | } |
718 | else if ( isAltBackground() ) | 717 | else if ( isAltBackground() ) |
719 | _cg.setColor(QColorGroup::Base, cg.background() ); | 718 | _cg.setColor(QColorGroup::Base, cg.background() ); |
720 | 719 | ||
721 | QListViewItem::paintCell(p, _cg, column, width, align); | 720 | QListViewItem::paintCell(p, _cg, column, width, align); |
722 | } | 721 | } |
723 | 722 | ||
724 | // --- CBListItem::isAltBackground -------------------------------------------- | 723 | // --- CBListItem::isAltBackground -------------------------------------------- |
725 | bool CBListItem::isAltBackground() | 724 | bool CBListItem::isAltBackground() |
726 | { | 725 | { |
727 | QListView *lv = static_cast<QListView *>( listView() ); | 726 | QListView *lv = static_cast<QListView *>( listView() ); |
728 | if ( lv ) | 727 | if ( lv ) |
729 | { | 728 | { |
730 | CBListItem *above = 0; | 729 | CBListItem *above = 0; |
731 | above = (CBListItem *)( itemAbove() ); | 730 | above = (CBListItem *)( itemAbove() ); |
732 | m_known = above ? above->m_known : true; | 731 | m_known = above ? above->m_known : true; |
733 | if ( m_known ) | 732 | if ( m_known ) |
734 | { | 733 | { |
735 | m_odd = above ? !above->m_odd : false; | 734 | m_odd = above ? !above->m_odd : false; |
736 | } | 735 | } |
737 | else | 736 | else |
738 | { | 737 | { |
739 | CBListItem *item; | 738 | CBListItem *item; |
740 | bool previous = true; | 739 | bool previous = true; |
741 | if ( parent() ) | 740 | if ( parent() ) |
742 | { | 741 | { |
743 | item = (CBListItem *)( parent() ); | 742 | item = (CBListItem *)( parent() ); |
744 | if ( item ) | 743 | if ( item ) |
745 | previous = item->m_odd; | 744 | previous = item->m_odd; |
746 | item = (CBListItem *)( parent()->firstChild() ); | 745 | item = (CBListItem *)( parent()->firstChild() ); |
747 | } | 746 | } |
748 | else | 747 | else |
749 | { | 748 | { |
750 | item = (CBListItem *)( lv->firstChild() ); | 749 | item = (CBListItem *)( lv->firstChild() ); |
751 | } | 750 | } |
752 | 751 | ||
753 | while(item) | 752 | while(item) |
754 | { | 753 | { |
755 | item->m_odd = previous = !previous; | 754 | item->m_odd = previous = !previous; |
756 | item->m_known = true; | 755 | item->m_known = true; |
757 | item = (CBListItem *)( item->nextSibling() ); | 756 | item = (CBListItem *)( item->nextSibling() ); |
758 | } | 757 | } |
759 | } | 758 | } |
760 | return m_odd; | 759 | return m_odd; |
761 | } | 760 | } |
762 | return false; | 761 | return false; |
763 | } | 762 | } |
764 | 763 | ||
765 | 764 | ||
diff --git a/noncore/apps/checkbook/checkbook.h b/noncore/apps/checkbook/checkbook.h index e18f00c..e2f0e56 100644 --- a/noncore/apps/checkbook/checkbook.h +++ b/noncore/apps/checkbook/checkbook.h | |||
@@ -29,11 +29,13 @@ | |||
29 | #ifndef CHECKBOOK_H | 29 | #ifndef CHECKBOOK_H |
30 | #define CHECKBOOK_H | 30 | #define CHECKBOOK_H |
31 | 31 | ||
32 | #include <opie2/otabwidget.h> | ||
33 | |||
32 | #include <qdatetime.h> | 34 | #include <qdatetime.h> |
33 | #include <qdialog.h> | 35 | #include <qdialog.h> |
34 | #include <qlistview.h> | 36 | #include <qlistview.h> |
35 | 37 | ||
36 | class OTabWidget; | 38 | using Opie::OTabWidget; |
37 | 39 | ||
38 | class CBInfo; | 40 | class CBInfo; |
39 | class Graph; | 41 | class Graph; |
@@ -54,11 +56,11 @@ class QMouseEvent; | |||
54 | // --- Checkbook -------------------------------------------------------------- | 56 | // --- Checkbook -------------------------------------------------------------- |
55 | class Checkbook : public QDialog | 57 | class Checkbook : public QDialog |
56 | { | 58 | { |
57 | Q_OBJECT | 59 | Q_OBJECT |
58 | 60 | ||
59 | public: | 61 | public: |
60 | Checkbook( QWidget *, CBInfo *, Cfg *cfg ); | 62 | Checkbook( QWidget *, CBInfo *, Cfg *cfg ); |
61 | ~Checkbook(); | 63 | ~Checkbook(); |
62 | 64 | ||
63 | // resort | 65 | // resort |
64 | void resort(); | 66 | void resort(); |
@@ -66,56 +68,56 @@ class Checkbook : public QDialog | |||
66 | // members | 68 | // members |
67 | TranInfoList *getTranList() { return(tranList); } | 69 | TranInfoList *getTranList() { return(tranList); } |
68 | 70 | ||
69 | private: | 71 | private: |
70 | CBInfo *info; | 72 | CBInfo *info; |
71 | TranInfoList *tranList; | 73 | TranInfoList *tranList; |
72 | Cfg *_pCfg; | 74 | Cfg *_pCfg; |
73 | 75 | ||
74 | OTabWidget *mainWidget; | 76 | OTabWidget *mainWidget; |
75 | void loadCheckbook(); | 77 | void loadCheckbook(); |
76 | void adjustBalance(); | 78 | void adjustBalance(); |
77 | 79 | ||
78 | // Info tab | 80 | // Info tab |
79 | QWidget *initInfo(); | 81 | QWidget *initInfo(); |
80 | QCheckBox *passwordCB; | 82 | QCheckBox *passwordCB; |
81 | QLineEdit *nameEdit; | 83 | QLineEdit *nameEdit; |
82 | QComboBox *typeList; | 84 | QComboBox *typeList; |
83 | QLineEdit *bankEdit; | 85 | QLineEdit *bankEdit; |
84 | QLineEdit *acctNumEdit; | 86 | QLineEdit *acctNumEdit; |
85 | QLineEdit *pinNumEdit; | 87 | QLineEdit *pinNumEdit; |
86 | QLineEdit *balanceEdit; | 88 | QLineEdit *balanceEdit; |
87 | QMultiLineEdit *notesEdit; | 89 | QMultiLineEdit *notesEdit; |
88 | int _sortCol; | 90 | int _sortCol; |
89 | 91 | ||
90 | // Transactions tab | 92 | // Transactions tab |
91 | QWidget *initTransactions(); | 93 | QWidget *initTransactions(); |
92 | QListView *tranTable; | 94 | QListView *tranTable; |
93 | QComboBox *_cbSortType; | 95 | QComboBox *_cbSortType; |
94 | QDate _dLastNew; | 96 | QDate _dLastNew; |
95 | 97 | ||
96 | // Charts tab | 98 | // Charts tab |
97 | QWidget *initCharts(); | 99 | QWidget *initCharts(); |
98 | GraphInfo *graphInfo; | 100 | GraphInfo *graphInfo; |
99 | QComboBox *graphList; | 101 | QComboBox *graphList; |
100 | Graph *graphWidget; | 102 | Graph *graphWidget; |
101 | 103 | ||
102 | void drawBalanceChart(); | 104 | void drawBalanceChart(); |
103 | void drawCategoryChart( bool = TRUE ); | 105 | void drawCategoryChart( bool = TRUE ); |
104 | 106 | ||
105 | 107 | ||
106 | protected slots: | 108 | protected slots: |
107 | void accept(); | 109 | void accept(); |
108 | void slotTab(QWidget *tab); | 110 | void slotTab(QWidget *tab); |
109 | 111 | ||
110 | private slots: | 112 | private slots: |
111 | void slotPasswordClicked(); | 113 | void slotPasswordClicked(); |
112 | void slotNameChanged( const QString & ); | 114 | void slotNameChanged( const QString & ); |
113 | void slotStartingBalanceChanged( const QString & ); | 115 | void slotStartingBalanceChanged( const QString & ); |
114 | void slotNewTran(); | 116 | void slotNewTran(); |
115 | void slotEditTran(); | 117 | void slotEditTran(); |
116 | void slotMenuTran(QListViewItem *, const QPoint &); | 118 | void slotMenuTran(QListViewItem *, const QPoint &); |
117 | void slotDeleteTran(); | 119 | void slotDeleteTran(); |
118 | void slotDrawGraph(); | 120 | void slotDrawGraph(); |
119 | void slotSortChanged( const QString & ); | 121 | void slotSortChanged( const QString & ); |
120 | }; | 122 | }; |
121 | 123 | ||
@@ -123,25 +125,25 @@ class Checkbook : public QDialog | |||
123 | // --- CBListItem ------------------------------------------------------------- | 125 | // --- CBListItem ------------------------------------------------------------- |
124 | class CBListItem : public QListViewItem | 126 | class CBListItem : public QListViewItem |
125 | { | 127 | { |
126 | //Q_OBJECT | 128 | //Q_OBJECT |
127 | 129 | ||
128 | public: | 130 | public: |
129 | CBListItem( TranInfo *, QListView *, QString = QString::null, QString = QString::null, | 131 | CBListItem( TranInfo *, QListView *, QString = QString::null, QString = QString::null, |
130 | QString = QString::null, QString = QString::null, QString = QString::null, | 132 | QString = QString::null, QString = QString::null, QString = QString::null, |
131 | QString = QString::null, QString = QString::null, QString = QString::null ); | 133 | QString = QString::null, QString = QString::null, QString = QString::null ); |
132 | 134 | ||
133 | void paintCell( QPainter *, const QColorGroup &, int, int, int ); | 135 | void paintCell( QPainter *, const QColorGroup &, int, int, int ); |
134 | 136 | ||
135 | // --- members | 137 | // --- members |
136 | TranInfo *getTranInfo() { return(_pTran); } | 138 | TranInfo *getTranInfo() { return(_pTran); } |
137 | 139 | ||
138 | private: | 140 | private: |
139 | TranInfo *_pTran; | 141 | TranInfo *_pTran; |
140 | QListView *owner; | 142 | QListView *owner; |
141 | bool m_known; | 143 | bool m_known; |
142 | bool m_odd; | 144 | bool m_odd; |
143 | 145 | ||
144 | bool isAltBackground(); | 146 | bool isAltBackground(); |
145 | }; | 147 | }; |
146 | 148 | ||
147 | 149 | ||
diff --git a/noncore/apps/checkbook/checkbook.pro b/noncore/apps/checkbook/checkbook.pro index 58e4af1..421ce3e 100644 --- a/noncore/apps/checkbook/checkbook.pro +++ b/noncore/apps/checkbook/checkbook.pro | |||
@@ -26,7 +26,7 @@ SOURCES = main.cpp \ | |||
26 | graph.cpp | 26 | graph.cpp |
27 | INCLUDEPATH += $(OPIEDIR)/include | 27 | INCLUDEPATH += $(OPIEDIR)/include |
28 | DEPENDPATH += $(OPIEDIR)/include | 28 | DEPENDPATH += $(OPIEDIR)/include |
29 | LIBS += -lqpe -lopie | 29 | LIBS += -lqpe -lopiecore2 -lopieui2 |
30 | TARGET = checkbook | 30 | TARGET = checkbook |
31 | 31 | ||
32 | include ( $(OPIEDIR)/include.pro ) | 32 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/apps/checkbook/main.cpp b/noncore/apps/checkbook/main.cpp index dcaab4a..0384620 100644 --- a/noncore/apps/checkbook/main.cpp +++ b/noncore/apps/checkbook/main.cpp | |||
@@ -26,8 +26,7 @@ | |||
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <qpe/qpeapplication.h> | 29 | #include <opie2/oapplicationfactory.h> |
30 | #include <opie/oapplicationfactory.h> | ||
31 | 30 | ||
32 | #include "mainwindow.h" | 31 | #include "mainwindow.h" |
33 | 32 | ||
diff --git a/noncore/apps/checkbook/opie-checkbook.control b/noncore/apps/checkbook/opie-checkbook.control index 95da438..a0df839 100644 --- a/noncore/apps/checkbook/opie-checkbook.control +++ b/noncore/apps/checkbook/opie-checkbook.control | |||
@@ -4,7 +4,7 @@ Priority: optional | |||
4 | Section: opie/applications | 4 | Section: opie/applications |
5 | Maintainer: Dan Williams <drw@handhelds.org> | 5 | Maintainer: Dan Williams <drw@handhelds.org> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Depends: task-opie-minimal, libopie1 | 7 | Depends: task-opie-minimal, libopiecore2, libopieui2 |
8 | Description: Checkbook keeping program. | 8 | Description: Checkbook keeping program. |
9 | The checkbook accounting program for the Opie environment. | 9 | The checkbook accounting program for the Opie environment. |
10 | Version: $QPE_VERSION$EXTRAVERSION | 10 | Version: $QPE_VERSION$EXTRAVERSION |