summaryrefslogtreecommitdiff
authordrw <drw>2004-02-22 00:08:21 (UTC)
committer drw <drw>2004-02-22 00:08:21 (UTC)
commite8aa81decb9a22828dcdbbaf3d08e2c6f1d2217f (patch) (unidiff)
tree2ebc546b4cf84d014eae25b9753f2cb40be37b48
parent58f490cf6fd94ec27eec01c0ffc9d0411be594e8 (diff)
downloadopie-e8aa81decb9a22828dcdbbaf3d08e2c6f1d2217f.zip
opie-e8aa81decb9a22828dcdbbaf3d08e2c6f1d2217f.tar.gz
opie-e8aa81decb9a22828dcdbbaf3d08e2c6f1d2217f.tar.bz2
Checkbook: libopie->libopie2
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/checkbook/checkbook.cpp917
-rw-r--r--noncore/apps/checkbook/checkbook.h110
-rw-r--r--noncore/apps/checkbook/checkbook.pro2
-rw-r--r--noncore/apps/checkbook/main.cpp3
-rw-r--r--noncore/apps/checkbook/opie-checkbook.control2
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
@@ -15,772 +15,771 @@
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .: 19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include "checkbook.h" 29#include "checkbook.h"
30#include "cbinfo.h" 30#include "cbinfo.h"
31#include "transaction.h" 31#include "transaction.h"
32#include "traninfo.h" 32#include "traninfo.h"
33#include "graph.h" 33#include "graph.h"
34#include "graphinfo.h" 34#include "graphinfo.h"
35#include "password.h" 35#include "password.h"
36#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>
43 42
44#include <qcheckbox.h> 43#include <qcheckbox.h>
45#include <qcombobox.h> 44#include <qcombobox.h>
46#include <qlabel.h> 45#include <qlabel.h>
47#include <qlayout.h> 46#include <qlayout.h>
48#include <qlineedit.h> 47#include <qlineedit.h>
49#include <qmultilineedit.h> 48#include <qmultilineedit.h>
50#include <qpushbutton.h> 49#include <qpushbutton.h>
51#include <qwhatsthis.h> 50#include <qwhatsthis.h>
52#include <qpopupmenu.h> 51#include <qpopupmenu.h>
53 52
54#define COL_ID 0 53#define COL_ID 0
55#define COL_SORTDATE 1 54#define COL_SORTDATE 1
56#define COL_NUM 2 55#define COL_NUM 2
57#define COL_DATE 3 56#define COL_DATE 3
58#define COL_DESC 4 57#define COL_DESC 4
59#define COL_AMOUNT 5 58#define COL_AMOUNT 5
60#define COL_BAL 6 59#define COL_BAL 6
61 60
62// --- Checkbook -------------------------------------------------------------- 61// --- Checkbook --------------------------------------------------------------
63Checkbook::Checkbook( QWidget *parent, CBInfo *i, Cfg *cfg ) 62Checkbook::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
104Checkbook::~Checkbook() 103Checkbook::~Checkbook()
105{ 104{
106} 105}
107 106
108// --- initInfo --------------------------------------------------------------- 107// --- initInfo ---------------------------------------------------------------
109QWidget *Checkbook::initInfo() 108QWidget *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 -------------------------------------------------------
201QWidget *Checkbook::initTransactions() 200QWidget *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") );
216 _cbSortType->insertItem( tr("Number") ); 215 _cbSortType->insertItem( tr("Number") );
217 layout->addMultiCellWidget( _cbSortType, 0, 0, 1, 2 ); 216 layout->addMultiCellWidget( _cbSortType, 0, 0, 1, 2 );
218 connect( _cbSortType, SIGNAL( activated(const QString &) ), this, SLOT( slotSortChanged( const QString & ) ) ); 217 connect( _cbSortType, SIGNAL( activated(const QString &) ), this, SLOT( slotSortChanged( const QString & ) ) );
219 218
220 // Table 219 // Table
221 tranTable = new QListView( control ); 220 tranTable = new QListView( control );
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);
229 tranTable->addColumn( tr( "SortDate" ) ); 228 tranTable->addColumn( tr( "SortDate" ) );
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 -------------------------------------------------------------
271QWidget *Checkbook::initCharts() 270QWidget *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 ----------------------------------------------------------
302void Checkbook::loadCheckbook() 301void 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;
351 for(int i=0; i<_cbSortType->count(); i++) { 350 for(int i=0; i<_cbSortType->count(); i++) {
352 if( _cbSortType->text(i)==info->getSortOrder() ) { 351 if( _cbSortType->text(i)==info->getSortOrder() ) {
353 _cbSortType->setCurrentItem(i); 352 _cbSortType->setCurrentItem(i);
354 slotSortChanged( info->getSortOrder() ); 353 slotSortChanged( info->getSortOrder() );
355 bOk=true; 354 bOk=true;
356 break; 355 break;
357 } 356 }
358 } 357 }
359 if( !bOk ) { 358 if( !bOk ) {
360 _cbSortType->setCurrentItem(0); 359 _cbSortType->setCurrentItem(0);
361 slotSortChanged( _cbSortType->currentText() ); 360 slotSortChanged( _cbSortType->currentText() );
362 } 361 }
363 362
364 // calc running balance 363 // calc running balance
365 adjustBalance(); 364 adjustBalance();
366} 365}
367 366
368 367
369// --- adjustBalance ---------------------------------------------------------- 368// --- adjustBalance ----------------------------------------------------------
370void Checkbook::adjustBalance() 369void 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() ) {
376 TranInfo *tran=item->getTranInfo(); 375 TranInfo *tran=item->getTranInfo();
377 bal=bal + (tran->withdrawal() ? -1 : 1)*tran->amount() - tran->fee(); 376 bal=bal + (tran->withdrawal() ? -1 : 1)*tran->amount() - tran->fee();
378 sRunning.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), bal ); 377 sRunning.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), bal );
379 item->setText( COL_BAL, sRunning); 378 item->setText( COL_BAL, sRunning);
380 } 379 }
381} 380}
382 381
383// --- resort ----------------------------------------------------------------- 382// --- resort -----------------------------------------------------------------
384void Checkbook::resort() 383void Checkbook::resort()
385{ 384{
386 tranTable->setSorting(_sortCol); 385 tranTable->setSorting(_sortCol);
387 tranTable->sort(); 386 tranTable->sort();
388 tranTable->setSorting(-1); 387 tranTable->setSorting(-1);
389} 388}
390 389
391 390
392// --- accept ----------------------------------------------------------------- 391// --- accept -----------------------------------------------------------------
393void Checkbook::accept() 392void 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 ----------------------------------------------------
408void Checkbook::slotPasswordClicked() 407void 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
450void Checkbook::slotNameChanged( const QString &newname ) 449void 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 ----------------------------------------------
468void Checkbook::slotStartingBalanceChanged( const QString &newbalance ) 467void 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 ------------------------------------------------------------
477void Checkbook::slotNewTran() 476void 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();
504 503
505 // save description in list of payees, if not in there 504 // save description in list of payees, if not in there
506 QStringList *pLst=&_pCfg->getPayees(); 505 QStringList *pLst=&_pCfg->getPayees();
507 if( _pCfg->getSavePayees() && pLst->contains(traninfo->desc())==0 ) { 506 if( _pCfg->getSavePayees() && pLst->contains(traninfo->desc())==0 ) {
508 pLst->append( traninfo->desc() ); 507 pLst->append( traninfo->desc() );
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 -----------------------------------------------------------
521void Checkbook::slotEditTran() 520void 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
550 // save description in list of payees, if not in there 549 // save description in list of payees, if not in there
551 QStringList *pLst=&_pCfg->getPayees(); 550 QStringList *pLst=&_pCfg->getPayees();
552 if( _pCfg->getSavePayees() && pLst->contains(traninfo->desc())==0 ) { 551 if( _pCfg->getSavePayees() && pLst->contains(traninfo->desc())==0 ) {
553 pLst->append( traninfo->desc() ); 552 pLst->append( traninfo->desc() );
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 -----------------------------------------------------------
563void Checkbook::slotMenuTran(QListViewItem *item, const QPoint &pnt) 562void Checkbook::slotMenuTran(QListViewItem *item, const QPoint &pnt)
564{ 563{
565 // active item? 564 // active item?
566 if( !item ) 565 if( !item )
567 return; 566 return;
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();
578 break; 577 break;
579 case 2: 578 case 2:
580 slotNewTran(); 579 slotNewTran();
581 break; 580 break;
582 case 3: 581 case 3:
583 slotDeleteTran(); 582 slotDeleteTran();
584 break; 583 break;
585 } 584 }
586} 585}
587 586
588 587
589// --- slotDeleteTran --------------------------------------------------------- 588// --- slotDeleteTran ---------------------------------------------------------
590void Checkbook::slotDeleteTran() 589void 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
606void Checkbook::slotDrawGraph() 605void 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
627void Checkbook::drawBalanceChart() 626void 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
661void Checkbook::drawCategoryChart( bool withdrawals ) 660void 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
699CBListItem::CBListItem( TranInfo *pTran, QListView *parent, QString label1, QString label2, 698CBListItem::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
709void CBListItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align ) 708void 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 --------------------------------------------
725bool CBListItem::isAltBackground() 724bool 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
766// --- slotTab ---------------------------------------------------------------- 765// --- slotTab ----------------------------------------------------------------
767void Checkbook::slotTab(QWidget *tab) 766void Checkbook::slotTab(QWidget *tab)
768{ 767{
769 if( !tab || !info ) return; 768 if( !tab || !info ) return;
770 info->setLastTab( tab->name() ); 769 info->setLastTab( tab->name() );
771} 770}
772 771
773 772
774// --- slotSortChanged --------------------------------------------------------- 773// --- slotSortChanged ---------------------------------------------------------
775void Checkbook::slotSortChanged( const QString &selc ) 774void Checkbook::slotSortChanged( const QString &selc )
776{ 775{
777 if( selc==tr("Entry Order") ) { 776 if( selc==tr("Entry Order") ) {
778 _sortCol=COL_ID; 777 _sortCol=COL_ID;
779 } else if( selc==tr("Number") ) { 778 } else if( selc==tr("Number") ) {
780 _sortCol=COL_NUM; 779 _sortCol=COL_NUM;
781 } else if( selc==tr("Date") ) { 780 } else if( selc==tr("Date") ) {
782 _sortCol=COL_SORTDATE; 781 _sortCol=COL_SORTDATE;
783 } 782 }
784 info->setSortOrder( selc ); 783 info->setSortOrder( selc );
785 resort(); 784 resort();
786} 785}
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
@@ -8,141 +8,143 @@
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 <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
36class OTabWidget; 38using Opie::OTabWidget;
37 39
38class CBInfo; 40class CBInfo;
39class Graph; 41class Graph;
40class GraphInfo; 42class GraphInfo;
41class QCheckBox; 43class QCheckBox;
42class QComboBox; 44class QComboBox;
43class QLabel; 45class QLabel;
44class QLineEdit; 46class QLineEdit;
45class QListView; 47class QListView;
46class QMultiLineEdit; 48class QMultiLineEdit;
47class QString; 49class QString;
48class TranInfo; 50class TranInfo;
49class TranInfoList; 51class TranInfoList;
50class Cfg; 52class Cfg;
51class QMouseEvent; 53class QMouseEvent;
52 54
53 55
54// --- Checkbook -------------------------------------------------------------- 56// --- Checkbook --------------------------------------------------------------
55class Checkbook : public QDialog 57class 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();
65 67
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
122 124
123// --- CBListItem ------------------------------------------------------------- 125// --- CBListItem -------------------------------------------------------------
124class CBListItem : public QListViewItem 126class 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
148#endif 150#endif
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
@@ -5,28 +5,28 @@ HEADERS = mainwindow.h \
5 graphinfo.h \ 5 graphinfo.h \
6 configuration.h \ 6 configuration.h \
7 password.h \ 7 password.h \
8 checkbook.h \ 8 checkbook.h \
9 transaction.h \ 9 transaction.h \
10 tabledef.h \ 10 tabledef.h \
11 listedit.h \ 11 listedit.h \
12 cfg.h \ 12 cfg.h \
13 graph.h 13 graph.h
14SOURCES = main.cpp \ 14SOURCES = main.cpp \
15 mainwindow.cpp \ 15 mainwindow.cpp \
16 cbinfo.cpp \ 16 cbinfo.cpp \
17 traninfo.cpp \ 17 traninfo.cpp \
18 graphinfo.cpp \ 18 graphinfo.cpp \
19 configuration.cpp \ 19 configuration.cpp \
20 password.cpp \ 20 password.cpp \
21 checkbook.cpp \ 21 checkbook.cpp \
22 transaction.cpp \ 22 transaction.cpp \
23 tabledef.cpp \ 23 tabledef.cpp \
24 listedit.cpp \ 24 listedit.cpp \
25 cfg.cpp \ 25 cfg.cpp \
26 graph.cpp 26 graph.cpp
27INCLUDEPATH += $(OPIEDIR)/include 27INCLUDEPATH += $(OPIEDIR)/include
28DEPENDPATH += $(OPIEDIR)/include 28DEPENDPATH += $(OPIEDIR)/include
29LIBS += -lqpe -lopie 29LIBS += -lqpe -lopiecore2 -lopieui2
30TARGET = checkbook 30TARGET = checkbook
31 31
32include ( $(OPIEDIR)/include.pro ) 32include ( $(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
@@ -5,30 +5,29 @@
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 <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
34OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) 33OPIE_EXPORT_APP( OApplicationFactory<MainWindow> )
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
@@ -1,10 +1,10 @@
1Package: opie-checkbook 1Package: opie-checkbook
2Files: plugins/application/libcheckbook.so* bin/checkbook apps/Applications/checkbook.desktop pics/checkbook 2Files: plugins/application/libcheckbook.so* bin/checkbook apps/Applications/checkbook.desktop pics/checkbook
3Priority: optional 3Priority: optional
4Section: opie/applications 4Section: opie/applications
5Maintainer: Dan Williams <drw@handhelds.org> 5Maintainer: Dan Williams <drw@handhelds.org>
6Architecture: arm 6Architecture: arm
7Depends: task-opie-minimal, libopie1 7Depends: task-opie-minimal, libopiecore2, libopieui2
8Description: Checkbook keeping program. 8Description: Checkbook keeping program.
9 The checkbook accounting program for the Opie environment. 9 The checkbook accounting program for the Opie environment.
10Version: $QPE_VERSION$EXTRAVERSION 10Version: $QPE_VERSION$EXTRAVERSION