summaryrefslogtreecommitdiff
authorallenforsythe <allenforsythe>2003-05-16 10:01:09 (UTC)
committer allenforsythe <allenforsythe>2003-05-16 10:01:09 (UTC)
commitc6de8acfd02b24dead5a1ff815c3f167a578a48b (patch) (unidiff)
tree6d5749b781a70741eb51e84d36974e30c3ffc1a6
parent822414b8ac44ddc8c79aaffa630b45a13015d51a (diff)
downloadopie-c6de8acfd02b24dead5a1ff815c3f167a578a48b.zip
opie-c6de8acfd02b24dead5a1ff815c3f167a578a48b.tar.gz
opie-c6de8acfd02b24dead5a1ff815c3f167a578a48b.tar.bz2
Fixed edit transfer and edit account/view account bugs
Diffstat (more/less context) (ignore whitespace changes)
-rwxr-xr-xnoncore/apps/qashmoney/accountdisplay.cpp12
-rwxr-xr-xnoncore/apps/qashmoney/qmaccounts.dbbin4096 -> 4096 bytes
-rwxr-xr-xnoncore/apps/qashmoney/qmmemory.dbbin4096 -> 4096 bytes
-rwxr-xr-xnoncore/apps/qashmoney/qmtransactions.dbbin4096 -> 4096 bytes
-rwxr-xr-xnoncore/apps/qashmoney/qmtransfers.dbbin3072 -> 3072 bytes
-rwxr-xr-xnoncore/apps/qashmoney/transactiondisplay.cpp2
6 files changed, 13 insertions, 1 deletions
diff --git a/noncore/apps/qashmoney/accountdisplay.cpp b/noncore/apps/qashmoney/accountdisplay.cpp
index 46ab1db..b2c0838 100755
--- a/noncore/apps/qashmoney/accountdisplay.cpp
+++ b/noncore/apps/qashmoney/accountdisplay.cpp
@@ -1,432 +1,444 @@
1#include <qdatetime.h> 1#include <qdatetime.h>
2#include <qmessagebox.h> 2#include <qmessagebox.h>
3#include <qheader.h> 3#include <qheader.h>
4 4
5#include "accountdisplay.h" 5#include "accountdisplay.h"
6#include "newaccount.h" 6#include "newaccount.h"
7#include "transaction.h" 7#include "transaction.h"
8#include "transferdialog.h" 8#include "transferdialog.h"
9#include "preferences.h" 9#include "preferences.h"
10#include "transfer.h" 10#include "transfer.h"
11 11
12extern Account *account; 12extern Account *account;
13extern Transaction *transaction; 13extern Transaction *transaction;
14extern Transfer *transfer; 14extern Transfer *transfer;
15extern Preferences *preferences; 15extern Preferences *preferences;
16 16
17AccountDisplay::AccountDisplay ( QWidget *parent ) : QWidget ( parent ) 17AccountDisplay::AccountDisplay ( QWidget *parent ) : QWidget ( parent )
18 { 18 {
19 cleared = 0; 19 cleared = 0;
20 20
21 firstline = new QHBox ( this ); 21 firstline = new QHBox ( this );
22 firstline->setSpacing ( 2 ); 22 firstline->setSpacing ( 2 );
23 23
24 newaccount = new QPushButton ( firstline ); 24 newaccount = new QPushButton ( firstline );
25 newaccount->setPixmap ( QPixmap ("/opt/QtPalmtop/pics/new.png") ); 25 newaccount->setPixmap ( QPixmap ("/opt/QtPalmtop/pics/new.png") );
26 connect ( newaccount, SIGNAL ( released () ), this, SLOT ( addAccount () ) ); 26 connect ( newaccount, SIGNAL ( released () ), this, SLOT ( addAccount () ) );
27 27
28 editaccount = new QPushButton ( firstline ); 28 editaccount = new QPushButton ( firstline );
29 editaccount->setPixmap ( QPixmap ("/opt/QtPalmtop/pics/edit.png") ); 29 editaccount->setPixmap ( QPixmap ("/opt/QtPalmtop/pics/edit.png") );
30 connect ( editaccount, SIGNAL ( released () ), this, SLOT ( editAccount () ) ); 30 connect ( editaccount, SIGNAL ( released () ), this, SLOT ( editAccount () ) );
31 31
32 deleteaccount = new QPushButton ( firstline ); 32 deleteaccount = new QPushButton ( firstline );
33 deleteaccount->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/delete.png") ); 33 deleteaccount->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/delete.png") );
34 connect ( deleteaccount, SIGNAL ( released () ), this, SLOT ( deleteAccount () ) ); 34 connect ( deleteaccount, SIGNAL ( released () ), this, SLOT ( deleteAccount () ) );
35 35
36 transferbutton = new QPushButton ( firstline ); 36 transferbutton = new QPushButton ( firstline );
37 transferbutton->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/transfer.png") ); 37 transferbutton->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/transfer.png") );
38 transferbutton->setToggleButton ( TRUE ); 38 transferbutton->setToggleButton ( TRUE );
39 connect ( transferbutton, SIGNAL ( toggled ( bool ) ), this, SLOT ( accountTransfer ( bool ) ) ); 39 connect ( transferbutton, SIGNAL ( toggled ( bool ) ), this, SLOT ( accountTransfer ( bool ) ) );
40 40
41 listview = new QListView ( this ); 41 listview = new QListView ( this );
42 listview->setAllColumnsShowFocus ( TRUE ); 42 listview->setAllColumnsShowFocus ( TRUE );
43 listview->setShowSortIndicator ( TRUE ); 43 listview->setShowSortIndicator ( TRUE );
44 listview->setRootIsDecorated ( TRUE ); 44 listview->setRootIsDecorated ( TRUE );
45 listview->setMultiSelection ( FALSE ); 45 listview->setMultiSelection ( FALSE );
46 connect ( listview, SIGNAL ( expanded ( QListViewItem * ) ), this, SLOT ( setAccountExpanded ( QListViewItem * ) ) ); 46 connect ( listview, SIGNAL ( expanded ( QListViewItem * ) ), this, SLOT ( setAccountExpanded ( QListViewItem * ) ) );
47 connect ( listview, SIGNAL ( collapsed ( QListViewItem * ) ), this, SLOT ( setAccountCollapsed ( QListViewItem * ) ) ); 47 connect ( listview, SIGNAL ( collapsed ( QListViewItem * ) ), this, SLOT ( setAccountCollapsed ( QListViewItem * ) ) );
48 48
49 listview->header()->setTracking ( FALSE ); 49 listview->header()->setTracking ( FALSE );
50 connect ( listview->header(), SIGNAL ( sizeChange ( int, int, int ) ), this, SLOT ( saveColumnSize ( int, int, int ) ) ); 50 connect ( listview->header(), SIGNAL ( sizeChange ( int, int, int ) ), this, SLOT ( saveColumnSize ( int, int, int ) ) );
51 51
52 layout = new QVBoxLayout ( this, 2, 5 ); 52 layout = new QVBoxLayout ( this, 2, 5 );
53 layout->addWidget ( firstline ); 53 layout->addWidget ( firstline );
54 layout->addWidget ( listview ); 54 layout->addWidget ( listview );
55 } 55 }
56 56
57void AccountDisplay::setTabs ( QWidget *newtab2, QTabWidget *newtabs ) 57void AccountDisplay::setTabs ( QWidget *newtab2, QTabWidget *newtabs )
58 { 58 {
59 tab2 = newtab2; 59 tab2 = newtab2;
60 maintabs = newtabs; 60 maintabs = newtabs;
61 } 61 }
62 62
63void AccountDisplay::addAccount () 63void AccountDisplay::addAccount ()
64 { 64 {
65 // initialize local variables 65 // initialize local variables
66 int parentid = 0; 66 int parentid = 0;
67 type = 0; 67 type = 0;
68 QString parentlist [ listview->childCount() + 1 ] [ 3 ] ; 68 QString parentlist [ listview->childCount() + 1 ] [ 3 ] ;
69 69
70 // create new account window for entering data 70 // create new account window for entering data
71 NewAccount *newaccount = new NewAccount ( this ); 71 NewAccount *newaccount = new NewAccount ( this );
72 int width = this->width(); 72 int width = this->width();
73 newaccount->accountbox->setMaximumWidth ( ( int ) ( width * 0.5 ) ); 73 newaccount->accountbox->setMaximumWidth ( ( int ) ( width * 0.5 ) );
74 newaccount->datebox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); 74 newaccount->datebox->setMaximumWidth ( ( int ) ( width * 0.4 ) );
75 newaccount->childbox->setMaximumWidth ( ( int ) ( width * 0.5 ) ); 75 newaccount->childbox->setMaximumWidth ( ( int ) ( width * 0.5 ) );
76 newaccount->balancebox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); 76 newaccount->balancebox->setMaximumWidth ( ( int ) ( width * 0.4 ) );
77 newaccount->creditlimitbox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); 77 newaccount->creditlimitbox->setMaximumWidth ( ( int ) ( width * 0.4 ) );
78 78
79 // if there are no accounts, disable the child check box 79 // if there are no accounts, disable the child check box
80 if ( account->getNumberOfAccounts () == 0 ) 80 if ( account->getNumberOfAccounts () == 0 )
81 newaccount->childcheckbox->setEnabled ( FALSE ); 81 newaccount->childcheckbox->setEnabled ( FALSE );
82 82
83 // if there are accounts, fill up the pulldown menu for 83 // if there are accounts, fill up the pulldown menu for
84 // selecting a parent account. We should only add those parents without transactions 84 // selecting a parent account. We should only add those parents without transactions
85 else 85 else
86 { 86 {
87 int c = 0; 87 int c = 0;
88 QListViewItemIterator it ( listview ); 88 QListViewItemIterator it ( listview );
89 for ( ; it.current(); ++it ) 89 for ( ; it.current(); ++it )
90 { 90 {
91 int id = it.current()->text ( getIDColumn() ).toInt(); 91 int id = it.current()->text ( getIDColumn() ).toInt();
92 // iterate through accountdisplay listview and add parents with no transactions 92 // iterate through accountdisplay listview and add parents with no transactions
93 // add this item to the list box only if it is a parent and has no transactions 93 // add this item to the list box only if it is a parent and has no transactions
94 if ( transfer->getNumberOfTransfers ( id ) == 0 && transaction->getNumberOfTransactions ( id ) == 0 && it.current()->parent() == 0 ) 94 if ( transfer->getNumberOfTransfers ( id ) == 0 && transaction->getNumberOfTransactions ( id ) == 0 && it.current()->parent() == 0 )
95 { 95 {
96 newaccount->childbox->insertItem ( it.current()->text ( 0 ) ); 96 newaccount->childbox->insertItem ( it.current()->text ( 0 ) );
97 parentlist [ c ] [ 0 ] = it.current()->text ( 0 ); 97 parentlist [ c ] [ 0 ] = it.current()->text ( 0 );
98 parentlist [ c ] [ 1 ] = it.current()->text ( getIDColumn() ); 98 parentlist [ c ] [ 1 ] = it.current()->text ( getIDColumn() );
99 parentlist [ c ] [ 2 ] = QString::number ( c ); 99 parentlist [ c ] [ 2 ] = QString::number ( c );
100 c++; 100 c++;
101 } 101 }
102 } 102 }
103 } 103 }
104 104
105 if ( preferences->getPreference ( 4 ) == 0 ) 105 if ( preferences->getPreference ( 4 ) == 0 )
106 newaccount->currencybox->setEnabled ( FALSE ); 106 newaccount->currencybox->setEnabled ( FALSE );
107 107
108 // enter today's date in the date box as default 108 // enter today's date in the date box as default
109 QDate today = QDate::currentDate (); 109 QDate today = QDate::currentDate ();
110 int defaultday = today.day(); 110 int defaultday = today.day();
111 int defaultmonth = today.month(); 111 int defaultmonth = today.month();
112 int defaultyear = today.year(); 112 int defaultyear = today.year();
113 newaccount->startdate->setText ( preferences->getDate ( defaultyear, defaultmonth, defaultday ) ); 113 newaccount->startdate->setText ( preferences->getDate ( defaultyear, defaultmonth, defaultday ) );
114 114
115 //add account information if user pushes OK button 115 //add account information if user pushes OK button
116 if ( newaccount->exec() == QDialog::Accepted ) 116 if ( newaccount->exec() == QDialog::Accepted )
117 { 117 {
118 if ( newaccount->childcheckbox->isChecked () == TRUE ) // set a parent id and type for a child account 118 if ( newaccount->childcheckbox->isChecked () == TRUE ) // set a parent id and type for a child account
119 { 119 {
120 // go through the parentlist we created and determine the parent accountid 120 // go through the parentlist we created and determine the parent accountid
121 // we can't use the name of the account because there may be two accounts 121 // we can't use the name of the account because there may be two accounts
122 // with the same name. This function does it all by accountid 122 // with the same name. This function does it all by accountid
123 int counter; 123 int counter;
124 for ( counter = 0; counter < listview->childCount() + 1; counter++ ) 124 for ( counter = 0; counter < listview->childCount() + 1; counter++ )
125 if ( ( parentlist [ counter ] [ 2 ].toInt() ) == newaccount->childbox->currentItem() ) 125 if ( ( parentlist [ counter ] [ 2 ].toInt() ) == newaccount->childbox->currentItem() )
126 { 126 {
127 parentid = parentlist [ counter ] [ 1 ].toInt(); 127 parentid = parentlist [ counter ] [ 1 ].toInt();
128 break; 128 break;
129 } 129 }
130 type = ( newaccount->accounttype->currentItem() ) + 6; // sets account ids for child accounts. See accountdisplay.h for types 130 type = ( newaccount->accounttype->currentItem() ) + 6; // sets account ids for child accounts. See accountdisplay.h for types
131 } 131 }
132 else 132 else
133 { 133 {
134 parentid = -1; 134 parentid = -1;
135 type = newaccount->accounttype->currentItem(); // sets account ids for parent accounts 135 type = newaccount->accounttype->currentItem(); // sets account ids for parent accounts
136 } 136 }
137 137
138 // add the new account 138 // add the new account
139 if ( newaccount->getDateEdited () == TRUE ) 139 if ( newaccount->getDateEdited () == TRUE )
140 account->addAccount ( newaccount->accountname->text(), parentid, newaccount->accountbalance->text().toFloat(), type, 140 account->addAccount ( newaccount->accountname->text(), parentid, newaccount->accountbalance->text().toFloat(), type,
141 newaccount->getDescription(), newaccount->creditlimit->text().toFloat(), newaccount->getYear(), 141 newaccount->getDescription(), newaccount->creditlimit->text().toFloat(), newaccount->getYear(),
142 newaccount->getMonth(), newaccount->getDay(), newaccount->accountbalance->text().toFloat(), newaccount->currencybox->currencybox->currentText() ); 142 newaccount->getMonth(), newaccount->getDay(), newaccount->accountbalance->text().toFloat(), newaccount->currencybox->currencybox->currentText() );
143 else 143 else
144 account->addAccount ( newaccount->accountname->text (), parentid, newaccount->accountbalance->text().toFloat(), type, 144 account->addAccount ( newaccount->accountname->text (), parentid, newaccount->accountbalance->text().toFloat(), type,
145 newaccount->getDescription(), newaccount->creditlimit->text().toFloat(), defaultyear, 145 newaccount->getDescription(), newaccount->creditlimit->text().toFloat(), defaultyear,
146 defaultmonth, defaultday, newaccount->accountbalance->text().toFloat(), newaccount->currencybox->currencybox->currentText() ); 146 defaultmonth, defaultday, newaccount->accountbalance->text().toFloat(), newaccount->currencybox->currencybox->currentText() );
147 147
148 if ( parentid != -1 ) 148 if ( parentid != -1 )
149 account->changeParentAccountBalance ( parentid ); 149 account->changeParentAccountBalance ( parentid );
150 150
151 // redisplay accounts 151 // redisplay accounts
152 // this function clears the account display first 152 // this function clears the account display first
153 account->displayAccounts ( listview ); 153 account->displayAccounts ( listview );
154 setToggleButton(); 154 setToggleButton();
155 } 155 }
156 maintabs->setTabEnabled ( tab2, FALSE ); 156 maintabs->setTabEnabled ( tab2, FALSE );
157 } 157 }
158 158
159void AccountDisplay::deleteAccount () 159void AccountDisplay::deleteAccount ()
160 { 160 {
161 if ( listview->selectedItem() == 0 ) 161 if ( listview->selectedItem() == 0 )
162 QMessageBox::warning ( this, "QashMoney", "Please select an account\nto delete."); 162 QMessageBox::warning ( this, "QashMoney", "Please select an account\nto delete.");
163 else if ( listview->selectedItem()->parent() == 0 && listview->selectedItem()->childCount() != 0 ) 163 else if ( listview->selectedItem()->parent() == 0 && listview->selectedItem()->childCount() != 0 )
164 QMessageBox::warning ( this, "QashMoney", "Can't delete parent accounts\nwith children"); 164 QMessageBox::warning ( this, "QashMoney", "Can't delete parent accounts\nwith children");
165 else 165 else
166 { 166 {
167 QMessageBox mb ( "Delete Account", "This will delete all transactions\nand transfers for this account.", QMessageBox::Information, QMessageBox::Ok, QMessageBox::Cancel, QMessageBox::NoButton ); 167 QMessageBox mb ( "Delete Account", "This will delete all transactions\nand transfers for this account.", QMessageBox::Information, QMessageBox::Ok, QMessageBox::Cancel, QMessageBox::NoButton );
168 if ( mb.exec() == QMessageBox::Ok ) 168 if ( mb.exec() == QMessageBox::Ok )
169 { 169 {
170 int accountid = listview->selectedItem()->text ( getIDColumn() ).toInt (); 170 int accountid = listview->selectedItem()->text ( getIDColumn() ).toInt ();
171 int parentid = account->getParentAccountID ( accountid ); 171 int parentid = account->getParentAccountID ( accountid );
172 172
173 // delete all the transactions and transfers for the account 173 // delete all the transactions and transfers for the account
174 transaction->deleteAllTransactions ( accountid ); 174 transaction->deleteAllTransactions ( accountid );
175 transfer->deleteAllTransfers ( accountid ); 175 transfer->deleteAllTransfers ( accountid );
176 176
177 // delete the account 177 // delete the account
178 account->deleteAccount ( accountid ); 178 account->deleteAccount ( accountid );
179 179
180 // update account balances 180 // update account balances
181 if ( parentid != -1 ) 181 if ( parentid != -1 )
182 account->changeParentAccountBalance ( parentid ); 182 account->changeParentAccountBalance ( parentid );
183 183
184 //redisplay accounts 184 //redisplay accounts
185 account->displayAccounts ( listview ); 185 account->displayAccounts ( listview );
186 186
187 //remove all the columns from the accountdisplay if there are not any accounts 187 //remove all the columns from the accountdisplay if there are not any accounts
188 if ( account->getNumberOfAccounts() == 0 ) 188 if ( account->getNumberOfAccounts() == 0 )
189 { 189 {
190 int columns = listview->columns(); 190 int columns = listview->columns();
191 int counter; 191 int counter;
192 for ( counter = 0; counter <= columns; counter++ ) 192 for ( counter = 0; counter <= columns; counter++ )
193 listview->removeColumn ( 0 ); 193 listview->removeColumn ( 0 );
194 } 194 }
195 195
196 setToggleButton(); 196 setToggleButton();
197 } 197 }
198 } 198 }
199 maintabs->setTabEnabled ( tab2, FALSE ); 199 maintabs->setTabEnabled ( tab2, FALSE );
200 } 200 }
201 201
202void AccountDisplay::setToggleButton () 202void AccountDisplay::setToggleButton ()
203 { 203 {
204 // iterate through account display and determine how many "transferable" accounts we have 204 // iterate through account display and determine how many "transferable" accounts we have
205 // if there are less than two, disable the transfer button 205 // if there are less than two, disable the transfer button
206 QListViewItemIterator it ( listview ); 206 QListViewItemIterator it ( listview );
207 int counter = 0; 207 int counter = 0;
208 for ( ; it.current(); ++it ) 208 for ( ; it.current(); ++it )
209 { 209 {
210 // add one to counter if we find a transferable account 210 // add one to counter if we find a transferable account
211 if ( it.current()->parent() != 0 || ( it.current()->childCount() ) == 0 ) 211 if ( it.current()->parent() != 0 || ( it.current()->childCount() ) == 0 )
212 counter++; 212 counter++;
213 } 213 }
214 if ( counter > 1 ) 214 if ( counter > 1 )
215 transferbutton->show(); 215 transferbutton->show();
216 else 216 else
217 transferbutton->hide(); 217 transferbutton->hide();
218 } 218 }
219 219
220void AccountDisplay::accountTransfer ( bool state ) 220void AccountDisplay::accountTransfer ( bool state )
221 { 221 {
222 if ( state == TRUE ) 222 if ( state == TRUE )
223 { 223 {
224 firstaccountid = -1; 224 firstaccountid = -1;
225 secondaccountid = -1; 225 secondaccountid = -1;
226 listview->clearSelection (); 226 listview->clearSelection ();
227 listview->setMultiSelection ( TRUE ); 227 listview->setMultiSelection ( TRUE );
228 disableParentsWithChildren (); 228 disableParentsWithChildren ();
229 connect ( listview, SIGNAL ( clicked ( QListViewItem * ) ), this, SLOT ( getTransferAccounts ( QListViewItem * ) ) ); 229 connect ( listview, SIGNAL ( clicked ( QListViewItem * ) ), this, SLOT ( getTransferAccounts ( QListViewItem * ) ) );
230 } 230 }
231 else 231 else
232 { 232 {
233 firstaccountid = -1; 233 firstaccountid = -1;
234 secondaccountid = -1; 234 secondaccountid = -1;
235 listview->clearSelection (); 235 listview->clearSelection ();
236 listview->setMultiSelection ( FALSE ); 236 listview->setMultiSelection ( FALSE );
237 enableAccounts (); 237 enableAccounts ();
238 disconnect ( listview, SIGNAL ( clicked ( QListViewItem * ) ), this, SLOT ( getTransferAccounts ( QListViewItem * ) ) ); 238 disconnect ( listview, SIGNAL ( clicked ( QListViewItem * ) ), this, SLOT ( getTransferAccounts ( QListViewItem * ) ) );
239 } 239 }
240 } 240 }
241 241
242void AccountDisplay::getTransferAccounts ( QListViewItem * item ) 242void AccountDisplay::getTransferAccounts ( QListViewItem * item )
243 { 243 {
244 if ( item->parent() != 0 || item->childCount() == 0 ) // only set an account for transfer if its a child or parent with no children 244 if ( item->parent() != 0 || item->childCount() == 0 ) // only set an account for transfer if its a child or parent with no children
245 { 245 {
246 if ( firstaccountid == -1 ) 246 if ( firstaccountid == -1 )
247 firstaccountid = item->text ( getIDColumn() ).toInt(); // set first account if we've selected a valid account 247 firstaccountid = item->text ( getIDColumn() ).toInt(); // set first account if we've selected a valid account
248 else 248 else
249 if ( item->text ( getIDColumn() ).toInt() != firstaccountid ) // set the second account if its not equal to the first 249 if ( item->text ( getIDColumn() ).toInt() != firstaccountid ) // set the second account if its not equal to the first
250 secondaccountid = item->text ( getIDColumn() ).toInt(); 250 secondaccountid = item->text ( getIDColumn() ).toInt();
251 } 251 }
252 252
253 // open transfer window if both accounts are set 253 // open transfer window if both accounts are set
254 if ( firstaccountid != -1 && secondaccountid != -1 ) 254 if ( firstaccountid != -1 && secondaccountid != -1 )
255 { 255 {
256 // construct the transferdialog window 256 // construct the transferdialog window
257 TransferDialog *td = new TransferDialog ( this, firstaccountid, secondaccountid ); 257 TransferDialog *td = new TransferDialog ( this, firstaccountid, secondaccountid );
258 258
259 // enter today's date in the date box as default 259 // enter today's date in the date box as default
260 QDate today = QDate::currentDate (); 260 QDate today = QDate::currentDate ();
261 int defaultday = today.day(); 261 int defaultday = today.day();
262 int defaultmonth = today.month(); 262 int defaultmonth = today.month();
263 int defaultyear = today.year(); 263 int defaultyear = today.year();
264 td->date->setText ( preferences->getDate ( defaultyear, defaultmonth, defaultday ) ); 264 td->date->setText ( preferences->getDate ( defaultyear, defaultmonth, defaultday ) );
265 265
266 if ( td->exec() == QDialog::Accepted ) 266 if ( td->exec() == QDialog::Accepted )
267 { 267 {
268 // set the cleared integer if the checkbox is checked 268 // set the cleared integer if the checkbox is checked
269 if ( td->clearedcheckbox->isChecked() == TRUE ) 269 if ( td->clearedcheckbox->isChecked() == TRUE )
270 cleared = 1; 270 cleared = 1;
271 271
272 // add the transfer with a new date if its been edited or use the default date 272 // add the transfer with a new date if its been edited or use the default date
273 if ( td->getDateEdited () == TRUE ) 273 if ( td->getDateEdited () == TRUE )
274 transfer->addTransfer ( firstaccountid, account->getParentAccountID ( firstaccountid ), secondaccountid, 274 transfer->addTransfer ( firstaccountid, account->getParentAccountID ( firstaccountid ), secondaccountid,
275 account->getParentAccountID ( secondaccountid ), td->getDay(), td->getMonth(), td->getYear(), td->amount->text().toFloat(), cleared ); 275 account->getParentAccountID ( secondaccountid ), td->getDay(), td->getMonth(), td->getYear(), td->amount->text().toFloat(), cleared );
276 else 276 else
277 transfer->addTransfer ( firstaccountid, account->getParentAccountID ( firstaccountid ), secondaccountid, 277 transfer->addTransfer ( firstaccountid, account->getParentAccountID ( firstaccountid ), secondaccountid,
278 account->getParentAccountID ( secondaccountid ), defaultday, defaultmonth, defaultyear, td->amount->text().toFloat(), cleared ); 278 account->getParentAccountID ( secondaccountid ), defaultday, defaultmonth, defaultyear, td->amount->text().toFloat(), cleared );
279 279
280 // update account balances of both accounts and parents if necessary 280 // update account balances of both accounts and parents if necessary
281 account->updateAccountBalance ( firstaccountid ); 281 account->updateAccountBalance ( firstaccountid );
282 if ( account->getParentAccountID ( firstaccountid ) != -1 ) 282 if ( account->getParentAccountID ( firstaccountid ) != -1 )
283 account->changeParentAccountBalance ( account->getParentAccountID ( firstaccountid ) ); 283 account->changeParentAccountBalance ( account->getParentAccountID ( firstaccountid ) );
284 account->updateAccountBalance ( secondaccountid ); 284 account->updateAccountBalance ( secondaccountid );
285 if ( account->getParentAccountID ( secondaccountid ) != -1 ) 285 if ( account->getParentAccountID ( secondaccountid ) != -1 )
286 account->changeParentAccountBalance ( account->getParentAccountID ( secondaccountid ) ); 286 account->changeParentAccountBalance ( account->getParentAccountID ( secondaccountid ) );
287 287
288 // redisplay accounts 288 // redisplay accounts
289 account->displayAccounts ( listview ); 289 account->displayAccounts ( listview );
290 } 290 }
291 else 291 else
292 { 292 {
293 firstaccountid = -1; 293 firstaccountid = -1;
294 secondaccountid = -1; 294 secondaccountid = -1;
295 listview->clearSelection (); 295 listview->clearSelection ();
296 listview->setMultiSelection ( FALSE ); 296 listview->setMultiSelection ( FALSE );
297 disconnect ( listview, SIGNAL ( clicked ( QListViewItem * ) ), this, SLOT ( getTransferAccounts ( QListViewItem * ) ) ); 297 disconnect ( listview, SIGNAL ( clicked ( QListViewItem * ) ), this, SLOT ( getTransferAccounts ( QListViewItem * ) ) );
298 } 298 }
299 299
300 // reset the accounts display window 300 // reset the accounts display window
301 transferbutton->toggle(); // toggling this button with clear the window as well 301 transferbutton->toggle(); // toggling this button with clear the window as well
302 302
303 // reenable all the accounts so the transaction tab will be properly set 303 // reenable all the accounts so the transaction tab will be properly set
304 enableAccounts (); 304 enableAccounts ();
305 } 305 }
306 } 306 }
307 307
308void AccountDisplay::disableParentsWithChildren () 308void AccountDisplay::disableParentsWithChildren ()
309 { 309 {
310 // iterate through accountdisplay listview and disable all the parents that have children 310 // iterate through accountdisplay listview and disable all the parents that have children
311 QListViewItemIterator it ( listview ); 311 QListViewItemIterator it ( listview );
312 for ( ; it.current(); ++it ) 312 for ( ; it.current(); ++it )
313 { 313 {
314 if ( it.current()->parent() == 0 && it.current()->childCount() != 0 ) 314 if ( it.current()->parent() == 0 && it.current()->childCount() != 0 )
315 it.current()->setSelectable ( FALSE ); 315 it.current()->setSelectable ( FALSE );
316 } 316 }
317 } 317 }
318 318
319void AccountDisplay::enableAccounts () 319void AccountDisplay::enableAccounts ()
320 { 320 {
321 // iterate through accountdisplay listview and enable all accounts 321 // iterate through accountdisplay listview and enable all accounts
322 QListViewItemIterator it ( listview ); 322 QListViewItemIterator it ( listview );
323 for ( ; it.current(); ++it ) 323 for ( ; it.current(); ++it )
324 it.current()->setSelectable ( TRUE ); 324 it.current()->setSelectable ( TRUE );
325 } 325 }
326 326
327void AccountDisplay::saveColumnSize ( int column, int oldsize, int newsize ) 327void AccountDisplay::saveColumnSize ( int column, int oldsize, int newsize )
328 { 328 {
329 switch ( column ) 329 switch ( column )
330 { 330 {
331 case 0: 331 case 0:
332 if ( listview->columns() == 3 ) 332 if ( listview->columns() == 3 )
333 preferences->changeColumnPreference ( 1, newsize ); 333 preferences->changeColumnPreference ( 1, newsize );
334 else 334 else
335 preferences->changeColumnPreference ( 10, newsize ); 335 preferences->changeColumnPreference ( 10, newsize );
336 break; 336 break;
337 case 1: 337 case 1:
338 if ( listview->columns() == 3 ) 338 if ( listview->columns() == 3 )
339 preferences->changeColumnPreference ( 2, newsize ); 339 preferences->changeColumnPreference ( 2, newsize );
340 else 340 else
341 preferences->changeColumnPreference ( 11, newsize ); 341 preferences->changeColumnPreference ( 11, newsize );
342 break; 342 break;
343 case 2: 343 case 2:
344 preferences->changeColumnPreference ( 12, newsize ); 344 preferences->changeColumnPreference ( 12, newsize );
345 break; 345 break;
346 } 346 }
347 347
348 } 348 }
349 349
350int AccountDisplay::getIDColumn () 350int AccountDisplay::getIDColumn ()
351 { 351 {
352 int counter; 352 int counter;
353 int columns = listview->columns(); 353 int columns = listview->columns();
354 for ( counter = 0; counter <= columns; counter++ ) 354 for ( counter = 0; counter <= columns; counter++ )
355 if ( listview->header()->label ( counter ).length() == 0 ) 355 if ( listview->header()->label ( counter ).length() == 0 )
356 return counter; 356 return counter;
357 } 357 }
358 358
359void AccountDisplay::editAccount () 359void AccountDisplay::editAccount ()
360 { 360 {
361 if ( listview->selectedItem() == 0 ) 361 if ( listview->selectedItem() == 0 )
362 QMessageBox::warning ( this, "QashMoney", "Please select an account\nto edit."); 362 QMessageBox::warning ( this, "QashMoney", "Please select an account\nto edit.");
363 else 363 else
364 { 364 {
365 // set the accountid 365 // set the accountid
366 int accountid = listview->selectedItem()->text ( getIDColumn() ).toInt(); 366 int accountid = listview->selectedItem()->text ( getIDColumn() ).toInt();
367 367
368 //construct new dialog box 368 //construct new dialog box
369 QDialog *editaccountwindow = new QDialog ( this, 0, TRUE ); 369 QDialog *editaccountwindow = new QDialog ( this, 0, TRUE );
370 editaccountwindow->setCaption ( "Edit Account" ); 370 editaccountwindow->setCaption ( "Edit Account" );
371 371
372 // construct the items which will go in the dialog bix 372 // construct the items which will go in the dialog bix
373 QLabel *namelabel = new QLabel ( "Account Name", editaccountwindow ); 373 QLabel *namelabel = new QLabel ( "Account Name", editaccountwindow );
374 QLineEdit *accountname = new QLineEdit ( editaccountwindow ); 374 QLineEdit *accountname = new QLineEdit ( editaccountwindow );
375 QLabel *descriptionlabel = new QLabel ( "Account Description", editaccountwindow ); 375 QLabel *descriptionlabel = new QLabel ( "Account Description", editaccountwindow );
376 QLineEdit *accountdescription = new QLineEdit ( editaccountwindow ); 376 QLineEdit *accountdescription = new QLineEdit ( editaccountwindow );
377 Currency *currencybox = new Currency ( editaccountwindow ); 377 Currency *currencybox = new Currency ( editaccountwindow );
378 378
379 QVBoxLayout *layout = new QVBoxLayout ( editaccountwindow, 5, 2 ); 379 QVBoxLayout *layout = new QVBoxLayout ( editaccountwindow, 5, 2 );
380 layout->addWidget ( namelabel ); 380 layout->addWidget ( namelabel );
381 layout->addWidget ( accountname ); 381 layout->addWidget ( accountname );
382 layout->addWidget ( descriptionlabel ); 382 layout->addWidget ( descriptionlabel );
383 layout->addWidget ( accountdescription ); 383 layout->addWidget ( accountdescription );
384 layout->addWidget ( currencybox ); 384 layout->addWidget ( currencybox );
385 385
386 //set the account name 386 //set the account name
387 accountname->setText ( listview->selectedItem()->text ( 0 ) ); 387 accountname->setText ( listview->selectedItem()->text ( 0 ) );
388 388
389 //set the account description 389 //set the account description
390 accountdescription->setText ( account->getAccountDescription ( accountid ) ); 390 accountdescription->setText ( account->getAccountDescription ( accountid ) );
391 391
392 if ( preferences->getPreference ( 4 ) == 1 ) 392 if ( preferences->getPreference ( 4 ) == 1 )
393 { 393 {
394 // get currency code for this account then iterate through the currency box 394 // get currency code for this account then iterate through the currency box
395 // to find the one we want 395 // to find the one we want
396 int count = currencybox->currencybox->count(); 396 int count = currencybox->currencybox->count();
397 QString code = account->getCurrencyCode ( accountid ); 397 QString code = account->getCurrencyCode ( accountid );
398 for ( int counter = 0; count - 1; counter++ ) 398 for ( int counter = 0; count - 1; counter++ )
399 { 399 {
400 if ( QString::compare ( currencybox->currencybox->text ( counter ), code ) == 0 ) 400 if ( QString::compare ( currencybox->currencybox->text ( counter ), code ) == 0 )
401 { 401 {
402 currencybox->currencybox->setCurrentItem ( counter ); 402 currencybox->currencybox->setCurrentItem ( counter );
403 break; 403 break;
404 } 404 }
405 } 405 }
406 } 406 }
407 else 407 else
408 currencybox->setEnabled ( FALSE ); 408 currencybox->setEnabled ( FALSE );
409 409
410 //execute the dialog box 410 //execute the dialog box
411 int response = editaccountwindow->exec(); 411 int response = editaccountwindow->exec();
412 if ( response == 1 ) 412 if ( response == 1 )
413 { 413 {
414 account->updateAccount ( accountname->text(), accountdescription->text(), currencybox->currencybox->currentText(), accountid ); 414 account->updateAccount ( accountname->text(), accountdescription->text(), currencybox->currencybox->currentText(), accountid );
415 account->displayAccounts ( listview ); 415 account->displayAccounts ( listview );
416
417 // Try and select the same account that was just edited
418 QListViewItemIterator it ( listview );
419 for ( ; it.current(); ++it )
420 {
421 if ( it.current()->text ( 0 ) == accountname->text() )
422 {
423 listview->setSelected ( it.current(), TRUE );
424 return;
425 }
426 }
427 maintabs->setTabEnabled ( tab2, FALSE );
416 } 428 }
417 } 429 }
418 } 430 }
419 431
420void AccountDisplay::setAccountExpanded ( QListViewItem *item ) 432void AccountDisplay::setAccountExpanded ( QListViewItem *item )
421 { 433 {
422 int accountid = item->text ( getIDColumn() ).toInt(); 434 int accountid = item->text ( getIDColumn() ).toInt();
423 account->setAccountExpanded ( 1, accountid ); 435 account->setAccountExpanded ( 1, accountid );
424 } 436 }
425 437
426void AccountDisplay::setAccountCollapsed ( QListViewItem *item ) 438void AccountDisplay::setAccountCollapsed ( QListViewItem *item )
427 { 439 {
428 int accountid = item->text ( getIDColumn() ).toInt(); 440 int accountid = item->text ( getIDColumn() ).toInt();
429 account->setAccountExpanded ( 0, accountid ); 441 account->setAccountExpanded ( 0, accountid );
430 } 442 }
431 443
432 444
diff --git a/noncore/apps/qashmoney/qmaccounts.db b/noncore/apps/qashmoney/qmaccounts.db
index 1c6f024..449bcab 100755
--- a/noncore/apps/qashmoney/qmaccounts.db
+++ b/noncore/apps/qashmoney/qmaccounts.db
Binary files differ
diff --git a/noncore/apps/qashmoney/qmmemory.db b/noncore/apps/qashmoney/qmmemory.db
index be33cd4..5c23122 100755
--- a/noncore/apps/qashmoney/qmmemory.db
+++ b/noncore/apps/qashmoney/qmmemory.db
Binary files differ
diff --git a/noncore/apps/qashmoney/qmtransactions.db b/noncore/apps/qashmoney/qmtransactions.db
index 1b05561..9e4acc9 100755
--- a/noncore/apps/qashmoney/qmtransactions.db
+++ b/noncore/apps/qashmoney/qmtransactions.db
Binary files differ
diff --git a/noncore/apps/qashmoney/qmtransfers.db b/noncore/apps/qashmoney/qmtransfers.db
index 4c04b5f..c31df1a 100755
--- a/noncore/apps/qashmoney/qmtransfers.db
+++ b/noncore/apps/qashmoney/qmtransfers.db
Binary files differ
diff --git a/noncore/apps/qashmoney/transactiondisplay.cpp b/noncore/apps/qashmoney/transactiondisplay.cpp
index 6e5c4f6..14f5641 100755
--- a/noncore/apps/qashmoney/transactiondisplay.cpp
+++ b/noncore/apps/qashmoney/transactiondisplay.cpp
@@ -1,586 +1,586 @@
1#include "transactiondisplay.h" 1#include "transactiondisplay.h"
2#include "newtransaction.h" 2#include "newtransaction.h"
3#include "account.h" 3#include "account.h"
4#include "budget.h" 4#include "budget.h"
5#include "memory.h" 5#include "memory.h"
6#include "transfer.h" 6#include "transfer.h"
7#include "preferences.h" 7#include "preferences.h"
8#include "calculator.h" 8#include "calculator.h"
9#include "datepicker.h" 9#include "datepicker.h"
10 10
11#include <qdatetime.h> 11#include <qdatetime.h>
12#include <qmessagebox.h> 12#include <qmessagebox.h>
13#include <qheader.h> 13#include <qheader.h>
14#include <qmultilineedit.h> 14#include <qmultilineedit.h>
15#include <iostream.h> 15#include <iostream.h>
16#include <qdatetime.h> 16#include <qdatetime.h>
17 17
18extern Transaction *transaction; 18extern Transaction *transaction;
19extern Budget *budget; 19extern Budget *budget;
20extern Account *account; 20extern Account *account;
21extern Preferences *preferences; 21extern Preferences *preferences;
22extern Memory *memory; 22extern Memory *memory;
23extern Transfer *transfer; 23extern Transfer *transfer;
24 24
25TransactionDisplay::TransactionDisplay ( QWidget* parent ) : QWidget ( parent ) 25TransactionDisplay::TransactionDisplay ( QWidget* parent ) : QWidget ( parent )
26 { 26 {
27 // set transactiondisplay variables; 27 // set transactiondisplay variables;
28 accountid = 0; 28 accountid = 0;
29 children = TRUE; 29 children = TRUE;
30 30
31 firstline = new QHBox ( this ); 31 firstline = new QHBox ( this );
32 firstline->setSpacing ( 2 ); 32 firstline->setSpacing ( 2 );
33 33
34 newtransaction = new QPushButton ( firstline ); 34 newtransaction = new QPushButton ( firstline );
35 newtransaction->setPixmap ( QPixmap ("/opt/QtPalmtop/pics/new.png") ); 35 newtransaction->setPixmap ( QPixmap ("/opt/QtPalmtop/pics/new.png") );
36 connect ( newtransaction, SIGNAL ( released () ), this, SLOT ( addTransaction () ) ); 36 connect ( newtransaction, SIGNAL ( released () ), this, SLOT ( addTransaction () ) );
37 37
38 edittransaction = new QPushButton ( firstline ); 38 edittransaction = new QPushButton ( firstline );
39 edittransaction->setPixmap( QPixmap ("/opt/QtPalmtop/pics/edit.png") ); 39 edittransaction->setPixmap( QPixmap ("/opt/QtPalmtop/pics/edit.png") );
40 connect ( edittransaction, SIGNAL ( released () ), this, SLOT ( checkListViewEdit () ) ); 40 connect ( edittransaction, SIGNAL ( released () ), this, SLOT ( checkListViewEdit () ) );
41 41
42 deletetransaction = new QPushButton ( firstline ); 42 deletetransaction = new QPushButton ( firstline );
43 deletetransaction->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/delete.png") ); 43 deletetransaction->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/delete.png") );
44 connect ( deletetransaction, SIGNAL ( released () ), this, SLOT ( checkListViewDelete () ) ); 44 connect ( deletetransaction, SIGNAL ( released () ), this, SLOT ( checkListViewDelete () ) );
45 45
46 toggletransaction = new QPushButton ( firstline ); 46 toggletransaction = new QPushButton ( firstline );
47 toggletransaction->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/redo.png") ); 47 toggletransaction->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/redo.png") );
48 connect ( toggletransaction, SIGNAL ( released () ), this, SLOT ( checkListViewToggle () ) ); 48 connect ( toggletransaction, SIGNAL ( released () ), this, SLOT ( checkListViewToggle () ) );
49 49
50 viewtransactionnotes = new QPushButton ( firstline ); 50 viewtransactionnotes = new QPushButton ( firstline );
51 viewtransactionnotes->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/info.png") ); 51 viewtransactionnotes->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/info.png") );
52 connect ( viewtransactionnotes, SIGNAL ( released () ), this, SLOT ( showTransactionNotes () ) ); 52 connect ( viewtransactionnotes, SIGNAL ( released () ), this, SLOT ( showTransactionNotes () ) );
53 53
54 secondline = new QHBox ( this ); 54 secondline = new QHBox ( this );
55 secondline->setSpacing ( 5 ); 55 secondline->setSpacing ( 5 );
56 56
57 name = new QLabel ( secondline ); 57 name = new QLabel ( secondline );
58 balance = new QLabel ( secondline ); 58 balance = new QLabel ( secondline );
59 59
60 QLabel *limit = new QLabel ( "Limit", secondline ); 60 QLabel *limit = new QLabel ( "Limit", secondline );
61 limitbox = new QLineEdit ( secondline ); 61 limitbox = new QLineEdit ( secondline );
62 limitbox->setMinimumWidth ( ( int ) ( this->width() / 6 ) ); 62 limitbox->setMinimumWidth ( ( int ) ( this->width() / 6 ) );
63 connect ( limitbox, SIGNAL ( textChanged ( const QString & ) ), this, SLOT ( limitDisplay ( const QString & ) ) ); 63 connect ( limitbox, SIGNAL ( textChanged ( const QString & ) ), this, SLOT ( limitDisplay ( const QString & ) ) );
64 64
65 listview = new QListView ( this ); 65 listview = new QListView ( this );
66 listview->setAllColumnsShowFocus ( TRUE ); 66 listview->setAllColumnsShowFocus ( TRUE );
67 listview->setShowSortIndicator ( TRUE ); 67 listview->setShowSortIndicator ( TRUE );
68 listview->header()->setTracking ( FALSE ); 68 listview->header()->setTracking ( FALSE );
69 connect ( listview->header(), SIGNAL ( sizeChange ( int, int, int ) ), this, SLOT ( saveColumnSize ( int, int, int ) ) ); 69 connect ( listview->header(), SIGNAL ( sizeChange ( int, int, int ) ), this, SLOT ( saveColumnSize ( int, int, int ) ) );
70 70
71 layout = new QVBoxLayout ( this, 2, 2 ); 71 layout = new QVBoxLayout ( this, 2, 2 );
72 layout->addWidget ( firstline ); 72 layout->addWidget ( firstline );
73 layout->addWidget ( secondline ); 73 layout->addWidget ( secondline );
74 layout->addWidget ( listview ); 74 layout->addWidget ( listview );
75 } 75 }
76 76
77void TransactionDisplay::addTransaction () 77void TransactionDisplay::addTransaction ()
78 { 78 {
79 // create local variables 79 // create local variables
80 int cleared = -1; 80 int cleared = -1;
81 81
82 // create new transaction window 82 // create new transaction window
83 NewTransaction *newtransaction = new NewTransaction ( this ); 83 NewTransaction *newtransaction = new NewTransaction ( this );
84 int width = this->size().width(); 84 int width = this->size().width();
85 newtransaction->transactionname->setMaximumWidth ( ( int ) ( width * 0.45 ) ); 85 newtransaction->transactionname->setMaximumWidth ( ( int ) ( width * 0.45 ) );
86 newtransaction->transactionname->setMinimumWidth ( ( int ) ( width * 0.35 ) ); 86 newtransaction->transactionname->setMinimumWidth ( ( int ) ( width * 0.35 ) );
87 newtransaction->lineitembox->setMaximumWidth ( ( int ) ( width * 0.45 ) ); 87 newtransaction->lineitembox->setMaximumWidth ( ( int ) ( width * 0.45 ) );
88 newtransaction->transactiondatebox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); 88 newtransaction->transactiondatebox->setMaximumWidth ( ( int ) ( width * 0.4 ) );
89 newtransaction->transactionamountbox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); 89 newtransaction->transactionamountbox->setMaximumWidth ( ( int ) ( width * 0.4 ) );
90 newtransaction->transactionnumber->setMaximumWidth ( ( int ) ( width * 0.25 ) ); 90 newtransaction->transactionnumber->setMaximumWidth ( ( int ) ( width * 0.25 ) );
91 91
92 // enter today's date in the date box as defaul 92 // enter today's date in the date box as defaul
93 QDate today = QDate::currentDate (); 93 QDate today = QDate::currentDate ();
94 int defaultday = today.day(); 94 int defaultday = today.day();
95 int defaultmonth = today.month(); 95 int defaultmonth = today.month();
96 int defaultyear = today.year(); 96 int defaultyear = today.year();
97 newtransaction->transactiondate->setText ( preferences->getDate ( defaultyear, defaultmonth, defaultday ) ); 97 newtransaction->transactiondate->setText ( preferences->getDate ( defaultyear, defaultmonth, defaultday ) );
98 98
99 // add memory items to the transactionname combobox 99 // add memory items to the transactionname combobox
100 memory->displayMemoryItems ( newtransaction->transactionname ); 100 memory->displayMemoryItems ( newtransaction->transactionname );
101 newtransaction->transactionname->insertItem ( "", 0 ); 101 newtransaction->transactionname->insertItem ( "", 0 );
102 102
103 if ( newtransaction->exec () == QDialog::Accepted ) 103 if ( newtransaction->exec () == QDialog::Accepted )
104 { 104 {
105 if ( newtransaction->clearedcheckbox->isChecked () == TRUE ) // set a parent id and type for a child transaction 105 if ( newtransaction->clearedcheckbox->isChecked () == TRUE ) // set a parent id and type for a child transaction
106 cleared = 1; 106 cleared = 1;
107 else 107 else
108 cleared = 0; 108 cleared = 0;
109 109
110 float amount = newtransaction->transactionamount->text().toFloat(); 110 float amount = newtransaction->transactionamount->text().toFloat();
111 if ( newtransaction->depositbox->isChecked() == FALSE ) 111 if ( newtransaction->depositbox->isChecked() == FALSE )
112 amount = amount * -1; 112 amount = amount * -1;
113 113
114 // add the transaction name to the memory items 114 // add the transaction name to the memory items
115 memory->addMemoryItem ( newtransaction->transactionname->currentText() ); 115 memory->addMemoryItem ( newtransaction->transactionname->currentText() );
116 116
117 // add the transaction 117 // add the transaction
118 if ( newtransaction->getDateEdited () == TRUE ) 118 if ( newtransaction->getDateEdited () == TRUE )
119 transaction->addTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), accountid, account->getParentAccountID ( accountid ), 119 transaction->addTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), accountid, account->getParentAccountID ( accountid ),
120 newtransaction->transactionnumber->text().toInt(), newtransaction->getDay(), newtransaction->getMonth(), newtransaction->getYear(), amount, cleared, newtransaction->getCurrentBudget(), 120 newtransaction->transactionnumber->text().toInt(), newtransaction->getDay(), newtransaction->getMonth(), newtransaction->getYear(), amount, cleared, newtransaction->getCurrentBudget(),
121 newtransaction->getCurrentLineItem() ); 121 newtransaction->getCurrentLineItem() );
122 else 122 else
123 transaction->addTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), accountid, account->getParentAccountID ( accountid ), 123 transaction->addTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), accountid, account->getParentAccountID ( accountid ),
124 newtransaction->transactionnumber->text().toInt(), defaultday, defaultmonth, defaultyear, amount, cleared, newtransaction->getCurrentBudget(), newtransaction->getCurrentLineItem() ); 124 newtransaction->transactionnumber->text().toInt(), defaultday, defaultmonth, defaultyear, amount, cleared, newtransaction->getCurrentBudget(), newtransaction->getCurrentLineItem() );
125 125
126 // redisplay transactions 126 // redisplay transactions
127 listview->clear(); 127 listview->clear();
128 QString displaytext = "%"; 128 QString displaytext = "%";
129 displaytext.prepend ( limitbox->text() ); 129 displaytext.prepend ( limitbox->text() );
130 if ( transaction->getNumberOfTransactions() > 0 ) 130 if ( transaction->getNumberOfTransactions() > 0 )
131 transaction->displayTransactions ( listview, accountid, children, displaytext ); 131 transaction->displayTransactions ( listview, accountid, children, displaytext );
132 132
133 // redisplay transfers 133 // redisplay transfers
134 if ( transfer->getNumberOfTransfers() > 0 ) 134 if ( transfer->getNumberOfTransfers() > 0 )
135 transfer->displayTransfers ( listview, accountid, children ); 135 transfer->displayTransfers ( listview, accountid, children );
136 136
137 // add the transaction amount to the account it's associated with 137 // add the transaction amount to the account it's associated with
138 // and update its parent account balance if necessary 138 // and update its parent account balance if necessary
139 account->updateAccountBalance ( accountid ); 139 account->updateAccountBalance ( accountid );
140 if ( account->getParentAccountID ( accountid ) != -1 ) 140 if ( account->getParentAccountID ( accountid ) != -1 )
141 account->changeParentAccountBalance ( account->getParentAccountID ( accountid ) ); 141 account->changeParentAccountBalance ( account->getParentAccountID ( accountid ) );
142 142
143 // format then reset the account balance 143 // format then reset the account balance
144 redisplayAccountBalance (); 144 redisplayAccountBalance ();
145 } 145 }
146 } 146 }
147 147
148void TransactionDisplay::checkListViewEdit () 148void TransactionDisplay::checkListViewEdit ()
149 { 149 {
150 if ( listview->selectedItem() == 0 ) 150 if ( listview->selectedItem() == 0 )
151 QMessageBox::warning ( this, "QashMoney", "Please select a transaction\nto edit."); 151 QMessageBox::warning ( this, "QashMoney", "Please select a transaction\nto edit.");
152 else if ( listview->currentItem()->text ( getIDColumn() ).toInt() < 0 ) 152 else if ( listview->currentItem()->text ( getIDColumn() ).toInt() < 0 )
153 editTransfer (); 153 editTransfer ();
154 else 154 else
155 editTransaction(); 155 editTransaction();
156 } 156 }
157 157
158void TransactionDisplay::showCalculator () 158void TransactionDisplay::showCalculator ()
159 { 159 {
160 Calculator *calculator = new Calculator ( this ); 160 Calculator *calculator = new Calculator ( this );
161 if ( calculator->exec () == QDialog::Accepted ) 161 if ( calculator->exec () == QDialog::Accepted )
162 amount->setText ( calculator->display->text() ); 162 amount->setText ( calculator->display->text() );
163 } 163 }
164 164
165void TransactionDisplay::showCalendar () 165void TransactionDisplay::showCalendar ()
166 { 166 {
167 QDate newDate = QDate::currentDate (); 167 QDate newDate = QDate::currentDate ();
168 DatePicker *dp = new DatePicker ( newDate ); 168 DatePicker *dp = new DatePicker ( newDate );
169 if ( dp->exec () == QDialog::Accepted ) 169 if ( dp->exec () == QDialog::Accepted )
170 { 170 {
171 year = dp->getYear(); 171 year = dp->getYear();
172 month = dp->getMonth(); 172 month = dp->getMonth();
173 day = dp->getDay(); 173 day = dp->getDay();
174 date->setText ( preferences->getDate ( year, month, day ) ); 174 date->setText ( preferences->getDate ( year, month, day ) );
175 } 175 }
176 } 176 }
177 177
178void TransactionDisplay::editTransfer () 178void TransactionDisplay::editTransfer ()
179 { 179 {
180 transferid = listview->currentItem()->text ( getIDColumn() ).toInt(); 180 transferid = listview->currentItem()->text ( getIDColumn() ).toInt();
181 fromaccount = transfer->getFromAccountID ( transferid ); 181 fromaccount = transfer->getFromAccountID ( transferid );
182 toaccount = transfer->getToAccountID ( transferid ); 182 toaccount = transfer->getToAccountID ( transferid );
183 year = transfer->getYear ( transferid ); 183 year = transfer->getYear ( transferid );
184 month = transfer->getMonth ( transferid ); 184 month = transfer->getMonth ( transferid );
185 day = transfer->getDay ( transferid ); 185 day = transfer->getDay ( transferid );
186 186
187 QDialog *editransfer = new QDialog ( this, "edittransfer", TRUE ); 187 QDialog *editransfer = new QDialog ( this, "edittransfer", TRUE );
188 editransfer->setCaption ( "Transfer" ); 188 editransfer->setCaption ( "Transfer" );
189 189
190 QStringList accountnames = account->getAccountNames(); 190 QStringList accountnames = account->getAccountNames();
191 QStringList accountids = account->getAccountIDs(); 191 QStringList accountids = account->getAccountIDs();
192 192
193 QLabel *fromaccountlabel = new QLabel ( "From Account:", editransfer ); 193 QLabel *fromaccountlabel = new QLabel ( "From Account:", editransfer );
194 QFont f = this->font(); 194 QFont f = this->font();
195 f.setWeight ( QFont::Bold ); 195 f.setWeight ( QFont::Bold );
196 fromaccountlabel->setFont ( f ); 196 fromaccountlabel->setFont ( f );
197 197
198 QComboBox *fromaccountbox = new QComboBox ( editransfer ); 198 QComboBox *fromaccountbox = new QComboBox ( editransfer );
199 fromaccountbox->insertStringList ( accountnames ); 199 fromaccountbox->insertStringList ( accountnames );
200 fromaccountbox->setCurrentItem ( accountids.findIndex ( QString::number ( fromaccount ) ) ); 200 fromaccountbox->setCurrentItem ( accountids.findIndex ( QString::number ( fromaccount ) ) );
201 201
202 QLabel *toaccountlabel = new QLabel ( "To Account:", editransfer ); 202 QLabel *toaccountlabel = new QLabel ( "To Account:", editransfer );
203 toaccountlabel->setFont ( f ); 203 toaccountlabel->setFont ( f );
204 204
205 QComboBox *toaccountbox = new QComboBox ( editransfer ); 205 QComboBox *toaccountbox = new QComboBox ( editransfer );
206 toaccountbox->insertStringList ( accountnames ); 206 toaccountbox->insertStringList ( accountnames );
207 toaccountbox->setCurrentItem ( accountids.findIndex ( QString::number ( toaccount ) ) ); 207 toaccountbox->setCurrentItem ( accountids.findIndex ( QString::number ( toaccount ) ) );
208 208
209 QLabel *datelabel = new QLabel ( "Date", editransfer ); 209 QLabel *datelabel = new QLabel ( "Date", editransfer );
210 QHBox *datebox = new QHBox ( editransfer ); 210 QHBox *datebox = new QHBox ( editransfer );
211 datebox->setSpacing ( 2 ); 211 datebox->setSpacing ( 2 );
212 date = new QLineEdit ( datebox ); 212 date = new QLineEdit ( datebox );
213 date->setAlignment ( Qt::AlignRight ); 213 date->setAlignment ( Qt::AlignRight );
214 date->setDisabled ( TRUE ); 214 date->setDisabled ( TRUE );
215 date->setText ( preferences->getDate ( year, month, day ) ); 215 date->setText ( preferences->getDate ( year, month, day ) );
216 QPushButton *datebutton = new QPushButton ( datebox ); 216 QPushButton *datebutton = new QPushButton ( datebox );
217 datebutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/date.png" ) ); 217 datebutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/date.png" ) );
218 connect ( datebutton, SIGNAL ( released () ), this, SLOT ( showCalendar () ) ); 218 connect ( datebutton, SIGNAL ( released () ), this, SLOT ( showCalendar () ) );
219 219
220 QLabel *amounttlabel = new QLabel ( "Amount", editransfer ); 220 QLabel *amounttlabel = new QLabel ( "Amount", editransfer );
221 221
222 QHBox *amountbox = new QHBox ( editransfer ); 222 QHBox *amountbox = new QHBox ( editransfer );
223 amountbox->setSpacing ( 2 ); 223 amountbox->setSpacing ( 2 );
224 amount = new QLineEdit ( amountbox ); 224 amount = new QLineEdit ( amountbox );
225 amount->setAlignment ( Qt::AlignRight ); 225 amount->setAlignment ( Qt::AlignRight );
226 amount->setText ( transfer->getAmount ( transferid ) ); 226 amount->setText ( transfer->getAmount ( transferid ) );
227 QPushButton *calculatorbutton = new QPushButton( amountbox ); 227 QPushButton *calculatorbutton = new QPushButton( amountbox );
228 calculatorbutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/kcalc.png" ) ); 228 calculatorbutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/kcalc.png" ) );
229 connect ( calculatorbutton, SIGNAL ( released() ), this, SLOT ( showCalculator() ) ); 229 connect ( calculatorbutton, SIGNAL ( released() ), this, SLOT ( showCalculator() ) );
230 230
231 QCheckBox *clearedcheckbox = new QCheckBox ( "Cleared", editransfer ); 231 QCheckBox *clearedcheckbox = new QCheckBox ( "Cleared", editransfer );
232 232
233 QBoxLayout *layout = new QVBoxLayout ( editransfer, 4, 2 ); 233 QBoxLayout *layout = new QVBoxLayout ( editransfer, 4, 2 );
234 layout->addWidget ( fromaccountlabel, Qt::AlignLeft ); 234 layout->addWidget ( fromaccountlabel, Qt::AlignLeft );
235 layout->addWidget ( fromaccountbox, Qt::AlignLeft ); 235 layout->addWidget ( fromaccountbox, Qt::AlignLeft );
236 layout->addWidget ( toaccountlabel, Qt::AlignLeft ); 236 layout->addWidget ( toaccountlabel, Qt::AlignLeft );
237 layout->addWidget ( toaccountbox, Qt::AlignLeft ); 237 layout->addWidget ( toaccountbox, Qt::AlignLeft );
238 layout->addSpacing ( 5 ); 238 layout->addSpacing ( 5 );
239 layout->addWidget ( datelabel, Qt::AlignLeft ); 239 layout->addWidget ( datelabel, Qt::AlignLeft );
240 layout->addWidget ( datebox, Qt::AlignLeft ); 240 layout->addWidget ( datebox, Qt::AlignLeft );
241 layout->addWidget ( amounttlabel, Qt::AlignLeft ); 241 layout->addWidget ( amounttlabel, Qt::AlignLeft );
242 layout->addWidget ( amountbox, Qt::AlignLeft ); 242 layout->addWidget ( amountbox, Qt::AlignLeft );
243 layout->addWidget ( clearedcheckbox, Qt::AlignLeft ); 243 layout->addWidget ( clearedcheckbox, Qt::AlignLeft );
244 244
245 if ( editransfer->exec() == QDialog::Accepted ) 245 if ( editransfer->exec() == QDialog::Accepted )
246 { 246 {
247 //get fromaccount 247 //get fromaccount
248 fromaccount = ( accountids.operator[] ( fromaccountbox->currentItem() ) ).toInt(); 248 fromaccount = ( accountids.operator[] ( fromaccountbox->currentItem() ) ).toInt();
249 249
250 //get to account 250 //get to account
251 toaccount = ( accountids.operator[] ( toaccountbox->currentItem() ) ).toInt(); 251 toaccount = ( accountids.operator[] ( toaccountbox->currentItem() ) ).toInt();
252 252
253 //set cleared flag 253 //set cleared flag
254 int cleared = 0; 254 int cleared = 0;
255 if ( clearedcheckbox->isChecked() == TRUE ) 255 if ( clearedcheckbox->isChecked() == TRUE )
256 cleared = 1; 256 cleared = 1;
257 257
258 //update transfer 258 //update transfer
259 transfer->updateTransfer ( fromaccount, account->getParentAccountID ( fromaccount ), toaccount, account->getParentAccountID ( toaccount ), 259 transfer->updateTransfer ( fromaccount, account->getParentAccountID ( fromaccount ), toaccount, account->getParentAccountID ( toaccount ),
260 day, month, year, amount->text().toFloat(), cleared, transferid ); 260 day, month, year, amount->text().toFloat(), cleared, transferid );
261 261
262 account->updateAccountBalance ( fromaccount ); 262 account->updateAccountBalance ( fromaccount );
263 if ( account->getParentAccountID ( fromaccount ) != -1 ) 263 if ( account->getParentAccountID ( fromaccount ) != -1 )
264 account->changeParentAccountBalance ( fromaccount ); 264 account->changeParentAccountBalance ( account->getParentAccountID ( fromaccount ) );
265 265
266 updateAndDisplay ( toaccount ); 266 updateAndDisplay ( toaccount );
267 } 267 }
268 } 268 }
269 269
270void TransactionDisplay::editTransaction () 270void TransactionDisplay::editTransaction ()
271 { 271 {
272 int cleared; 272 int cleared;
273 273
274 // set the transaction id and budgetid 274 // set the transaction id and budgetid
275 int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt(); 275 int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt();
276 int budgetid = transaction->getBudgetID ( transactionid ); 276 int budgetid = transaction->getBudgetID ( transactionid );
277 int lineitemid = transaction->getLineItemID ( transactionid ); 277 int lineitemid = transaction->getLineItemID ( transactionid );
278 278
279 // create edit transaction window 279 // create edit transaction window
280 NewTransaction *newtransaction = new NewTransaction ( this ); 280 NewTransaction *newtransaction = new NewTransaction ( this );
281 int width = this->width(); 281 int width = this->width();
282 newtransaction->transactionname->setMaximumWidth ( ( int ) ( width * 0.45 ) ); 282 newtransaction->transactionname->setMaximumWidth ( ( int ) ( width * 0.45 ) );
283 newtransaction->transactionname->setMinimumWidth ( ( int ) ( width * 0.35 ) ); 283 newtransaction->transactionname->setMinimumWidth ( ( int ) ( width * 0.35 ) );
284 newtransaction->lineitembox->setMaximumWidth ( ( int ) ( width * 0.45 ) ); 284 newtransaction->lineitembox->setMaximumWidth ( ( int ) ( width * 0.45 ) );
285 newtransaction->transactiondatebox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); 285 newtransaction->transactiondatebox->setMaximumWidth ( ( int ) ( width * 0.4 ) );
286 newtransaction->transactionamountbox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); 286 newtransaction->transactionamountbox->setMaximumWidth ( ( int ) ( width * 0.4 ) );
287 newtransaction->transactionnumber->setMaximumWidth ( ( int ) ( width * 0.25 ) ); 287 newtransaction->transactionnumber->setMaximumWidth ( ( int ) ( width * 0.25 ) );
288 288
289 // enter the date in the date box 289 // enter the date in the date box
290 newtransaction->year = transaction->getYear ( transactionid ); 290 newtransaction->year = transaction->getYear ( transactionid );
291 newtransaction->month = transaction->getMonth ( transactionid ); 291 newtransaction->month = transaction->getMonth ( transactionid );
292 newtransaction->day = transaction->getDay ( transactionid ); 292 newtransaction->day = transaction->getDay ( transactionid );
293 newtransaction->transactiondate->setText ( preferences->getDate ( newtransaction->year, newtransaction->month, newtransaction->day ) ); 293 newtransaction->transactiondate->setText ( preferences->getDate ( newtransaction->year, newtransaction->month, newtransaction->day ) );
294 294
295 // set the description 295 // set the description
296 newtransaction->setDescription ( transaction->getTransactionDescription ( transactionid ) ); 296 newtransaction->setDescription ( transaction->getTransactionDescription ( transactionid ) );
297 297
298 // add memory items to the transactionname combobox 298 // add memory items to the transactionname combobox
299 memory->displayMemoryItems ( newtransaction->transactionname ); 299 memory->displayMemoryItems ( newtransaction->transactionname );
300 300
301 // add correct transaction name 301 // add correct transaction name
302 newtransaction->transactionname->setEditText ( transaction->getPayee ( transactionid ) ); 302 newtransaction->transactionname->setEditText ( transaction->getPayee ( transactionid ) );
303 303
304 // add transaction number 304 // add transaction number
305 newtransaction->transactionnumber->setText ( transaction->getNumber ( transactionid ) ); 305 newtransaction->transactionnumber->setText ( transaction->getNumber ( transactionid ) );
306 306
307 // add transaction amount 307 // add transaction amount
308 newtransaction->transactionamount->setText ( transaction->getAbsoluteAmount ( transactionid ) ); 308 newtransaction->transactionamount->setText ( transaction->getAbsoluteAmount ( transactionid ) );
309 309
310 // check for and set the correct budget 310 // check for and set the correct budget
311 if ( budgetid >= 1 ) // only do it if this transaction has a budget and line item 311 if ( budgetid >= 1 ) // only do it if this transaction has a budget and line item
312 { 312 {
313 newtransaction->budgetbox->setCurrentItem ( newtransaction->getBudgetIndex ( budgetid ) + 1 ); 313 newtransaction->budgetbox->setCurrentItem ( newtransaction->getBudgetIndex ( budgetid ) + 1 );
314 if ( lineitemid >= 1 ) 314 if ( lineitemid >= 1 )
315 { 315 {
316 newtransaction->setLineItems (); 316 newtransaction->setLineItems ();
317 newtransaction->lineitembox->setCurrentItem ( newtransaction->getLineItemIndex ( lineitemid ) ); 317 newtransaction->lineitembox->setCurrentItem ( newtransaction->getLineItemIndex ( lineitemid ) );
318 } 318 }
319 else 319 else
320 { 320 {
321 newtransaction->lineitemlabel->setEnabled ( FALSE ); 321 newtransaction->lineitemlabel->setEnabled ( FALSE );
322 newtransaction->lineitembox->setEnabled ( FALSE ); 322 newtransaction->lineitembox->setEnabled ( FALSE );
323 } 323 }
324 } 324 }
325 else 325 else
326 { 326 {
327 newtransaction->lineitemlabel->setEnabled ( FALSE ); 327 newtransaction->lineitemlabel->setEnabled ( FALSE );
328 newtransaction->lineitembox->setEnabled ( FALSE ); 328 newtransaction->lineitembox->setEnabled ( FALSE );
329 } 329 }
330 330
331 // check cleared checkbox if necessary 331 // check cleared checkbox if necessary
332 if ( transaction->getCleared ( transactionid ) == 1 ) 332 if ( transaction->getCleared ( transactionid ) == 1 )
333 newtransaction->clearedcheckbox->setChecked ( TRUE ); 333 newtransaction->clearedcheckbox->setChecked ( TRUE );
334 334
335 // check deposit box if necessary 335 // check deposit box if necessary
336 if ( transaction->getAmount ( transactionid ).toFloat() > 0 ) 336 if ( transaction->getAmount ( transactionid ).toFloat() > 0 )
337 newtransaction->depositbox->setChecked ( TRUE ); 337 newtransaction->depositbox->setChecked ( TRUE );
338 338
339 if ( newtransaction->exec () == QDialog::Accepted ) 339 if ( newtransaction->exec () == QDialog::Accepted )
340 { 340 {
341 if ( newtransaction->clearedcheckbox->isChecked () == TRUE ) 341 if ( newtransaction->clearedcheckbox->isChecked () == TRUE )
342 cleared = 1; 342 cleared = 1;
343 else 343 else
344 cleared = 0; 344 cleared = 0;
345 345
346 float amount = newtransaction->transactionamount->text().toFloat(); 346 float amount = newtransaction->transactionamount->text().toFloat();
347 if ( newtransaction->depositbox->isChecked() == FALSE ) 347 if ( newtransaction->depositbox->isChecked() == FALSE )
348 amount = amount * -1; 348 amount = amount * -1;
349 349
350 // add the transaction name to the memory items 350 // add the transaction name to the memory items
351 memory->addMemoryItem ( newtransaction->transactionname->currentText() ); 351 memory->addMemoryItem ( newtransaction->transactionname->currentText() );
352 352
353 // update the transaction 353 // update the transaction
354 transaction->updateTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), newtransaction->transactionnumber->text().toInt(), 354 transaction->updateTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), newtransaction->transactionnumber->text().toInt(),
355 newtransaction->getDay(), newtransaction->getMonth(), newtransaction->getYear(), 355 newtransaction->getDay(), newtransaction->getMonth(), newtransaction->getYear(),
356 amount, cleared, newtransaction->getCurrentBudget(), newtransaction->getCurrentLineItem(), transactionid ); 356 amount, cleared, newtransaction->getCurrentBudget(), newtransaction->getCurrentLineItem(), transactionid );
357 357
358 updateAndDisplay ( transaction->getAccountID ( transactionid ) ); 358 updateAndDisplay ( transaction->getAccountID ( transactionid ) );
359 } 359 }
360 } 360 }
361 361
362void TransactionDisplay::updateAndDisplay ( int id ) 362void TransactionDisplay::updateAndDisplay ( int id )
363 { 363 {
364 // redisplay transactions 364 // redisplay transactions
365 listview->clear(); 365 listview->clear();
366 QString displaytext = "%"; 366 QString displaytext = "%";
367 displaytext.prepend ( limitbox->text() ); 367 displaytext.prepend ( limitbox->text() );
368 if ( transaction->getNumberOfTransactions() > 0 ) 368 if ( transaction->getNumberOfTransactions() > 0 )
369 transaction->displayTransactions ( listview, accountid, children, displaytext ); 369 transaction->displayTransactions ( listview, accountid, children, displaytext );
370 370
371 // redisplay transfers 371 // redisplay transfers
372 if ( transfer->getNumberOfTransfers() > 0 ) 372 if ( transfer->getNumberOfTransfers() > 0 )
373 transfer->displayTransfers ( listview, accountid, children ); 373 transfer->displayTransfers ( listview, accountid, children );
374 374
375 // add the transaction amount to the account it's associated with 375 // add the transaction amount to the account it's associated with
376 // and update its parent account balance if necessary 376 // and update its parent account balance if necessary
377 account->updateAccountBalance ( id ); 377 account->updateAccountBalance ( id );
378 if ( account->getParentAccountID ( id ) != -1 ) 378 if ( account->getParentAccountID ( id ) != -1 )
379 account->changeParentAccountBalance ( account->getParentAccountID ( id ) ); 379 account->changeParentAccountBalance ( account->getParentAccountID ( id ) );
380 380
381 // format then reset the account balance 381 // format then reset the account balance
382 redisplayAccountBalance (); 382 redisplayAccountBalance ();
383 } 383 }
384 384
385void TransactionDisplay::checkListViewDelete () 385void TransactionDisplay::checkListViewDelete ()
386 { 386 {
387 if ( listview->selectedItem() == 0 ) 387 if ( listview->selectedItem() == 0 )
388 QMessageBox::warning ( this, "QashMoney", "Please select a transaction to\ndelete."); 388 QMessageBox::warning ( this, "QashMoney", "Please select a transaction to\ndelete.");
389 else 389 else
390 deleteTransaction (); 390 deleteTransaction ();
391 } 391 }
392 392
393void TransactionDisplay::deleteTransaction () 393void TransactionDisplay::deleteTransaction ()
394 { 394 {
395 int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt(); 395 int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt();
396 396
397 if ( transactionid > 0 ) // takes care of deleting transactions 397 if ( transactionid > 0 ) // takes care of deleting transactions
398 { 398 {
399 // check if we are viewing child transactions through a parent 399 // check if we are viewing child transactions through a parent
400 // in that case we will have to update balances for the parent 400 // in that case we will have to update balances for the parent
401 // which is represented by accountid and the child account 401 // which is represented by accountid and the child account
402 // which will be represented by childaccountid 402 // which will be represented by childaccountid
403 int childaccountid = -1; 403 int childaccountid = -1;
404 if ( listview->columns() == 5 ) 404 if ( listview->columns() == 5 )
405 childaccountid = transaction->getAccountID ( transactionid ); 405 childaccountid = transaction->getAccountID ( transactionid );
406 406
407 transaction->deleteTransaction ( transactionid ); 407 transaction->deleteTransaction ( transactionid );
408 408
409 listview->clear(); 409 listview->clear();
410 QString displaytext = "%"; 410 QString displaytext = "%";
411 displaytext.prepend ( limitbox->text() ); 411 displaytext.prepend ( limitbox->text() );
412 if ( transaction->getNumberOfTransactions() > 0 ) 412 if ( transaction->getNumberOfTransactions() > 0 )
413 transaction->displayTransactions ( listview, accountid, children, displaytext ); 413 transaction->displayTransactions ( listview, accountid, children, displaytext );
414 414
415 if ( transfer->getNumberOfTransfers() > 0 ) 415 if ( transfer->getNumberOfTransfers() > 0 )
416 transfer->displayTransfers ( listview, accountid, children ); 416 transfer->displayTransfers ( listview, accountid, children );
417 417
418 // if we are viewing different child accounts through the parent account 418 // if we are viewing different child accounts through the parent account
419 // ie if there are five columns and the parentid is -1 419 // ie if there are five columns and the parentid is -1
420 // update the accountid ( which is the parent ) and update the child account 420 // update the accountid ( which is the parent ) and update the child account
421 // balance. Get its accountid from the transactionid 421 // balance. Get its accountid from the transactionid
422 account->updateAccountBalance ( accountid ); // will update either a parent or child 422 account->updateAccountBalance ( accountid ); // will update either a parent or child
423 if ( account->getParentAccountID ( accountid ) != -1 ) // update its parent if there is one 423 if ( account->getParentAccountID ( accountid ) != -1 ) // update its parent if there is one
424 account->changeParentAccountBalance ( account->getParentAccountID ( accountid ) ); 424 account->changeParentAccountBalance ( account->getParentAccountID ( accountid ) );
425 if ( childaccountid != -1 ) // we've set childaccountid 425 if ( childaccountid != -1 ) // we've set childaccountid
426 account->updateAccountBalance ( childaccountid ); 426 account->updateAccountBalance ( childaccountid );
427 427
428 // format then reset the account balance 428 // format then reset the account balance
429 redisplayAccountBalance (); 429 redisplayAccountBalance ();
430 } 430 }
431 else // takes care of deleting transfers 431 else // takes care of deleting transfers
432 { 432 {
433 // get the accountids before we delete the transfer 433 // get the accountids before we delete the transfer
434 int fromaccountid = transfer->getFromAccountID ( transactionid ); 434 int fromaccountid = transfer->getFromAccountID ( transactionid );
435 int toaccountid = transfer->getToAccountID ( transactionid ); 435 int toaccountid = transfer->getToAccountID ( transactionid );
436 436
437 // delete the transfer and redisplay transactions 437 // delete the transfer and redisplay transactions
438 transfer->deleteTransfer ( transactionid ); 438 transfer->deleteTransfer ( transactionid );
439 439
440 listview->clear(); 440 listview->clear();
441 QString displaytext = "%"; 441 QString displaytext = "%";
442 displaytext.prepend ( limitbox->text() ); 442 displaytext.prepend ( limitbox->text() );
443 if ( transaction->getNumberOfTransactions() > 0 ) 443 if ( transaction->getNumberOfTransactions() > 0 )
444 transaction->displayTransactions ( listview, accountid, children, displaytext ); 444 transaction->displayTransactions ( listview, accountid, children, displaytext );
445 445
446 if ( transfer->getNumberOfTransfers() > 0 ) 446 if ( transfer->getNumberOfTransfers() > 0 )
447 transfer->displayTransfers ( listview, accountid, children ); 447 transfer->displayTransfers ( listview, accountid, children );
448 448
449 // for the from account 449 // for the from account
450 account->updateAccountBalance ( fromaccountid ); 450 account->updateAccountBalance ( fromaccountid );
451 if ( account->getParentAccountID ( fromaccountid ) != -1 ) 451 if ( account->getParentAccountID ( fromaccountid ) != -1 )
452 account->changeParentAccountBalance ( account->getParentAccountID ( fromaccountid ) ); 452 account->changeParentAccountBalance ( account->getParentAccountID ( fromaccountid ) );
453 453
454 // for the to account 454 // for the to account
455 account->updateAccountBalance ( toaccountid ); 455 account->updateAccountBalance ( toaccountid );
456 if ( account->getParentAccountID ( toaccountid ) != -1 ) 456 if ( account->getParentAccountID ( toaccountid ) != -1 )
457 account->changeParentAccountBalance ( account->getParentAccountID ( toaccountid ) ); 457 account->changeParentAccountBalance ( account->getParentAccountID ( toaccountid ) );
458 458
459 // format then reset the account balance 459 // format then reset the account balance
460 redisplayAccountBalance (); 460 redisplayAccountBalance ();
461 } 461 }
462 } 462 }
463 463
464void TransactionDisplay::checkListViewToggle () 464void TransactionDisplay::checkListViewToggle ()
465 { 465 {
466 if ( listview->selectedItem() == 0 ) 466 if ( listview->selectedItem() == 0 )
467 QMessageBox::warning ( this, "QashMoney", "Please select a transaction to\nclear or reset."); 467 QMessageBox::warning ( this, "QashMoney", "Please select a transaction to\nclear or reset.");
468 else 468 else
469 toggleTransaction (); 469 toggleTransaction ();
470 } 470 }
471 471
472void TransactionDisplay::toggleTransaction () 472void TransactionDisplay::toggleTransaction ()
473 { 473 {
474 //get the transaction of the selected transaction to determine if its a transaction or transfer 474 //get the transaction of the selected transaction to determine if its a transaction or transfer
475 int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt(); 475 int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt();
476 476
477 if ( transactionid > 0 ) // if this is a transaction 477 if ( transactionid > 0 ) // if this is a transaction
478 { 478 {
479 if ( transaction->getCleared ( transactionid ) == 0 ) 479 if ( transaction->getCleared ( transactionid ) == 0 )
480 transaction->setCleared ( transactionid, 1 ); 480 transaction->setCleared ( transactionid, 1 );
481 else 481 else
482 transaction->setCleared ( transactionid, 0 ); 482 transaction->setCleared ( transactionid, 0 );
483 } 483 }
484 else 484 else
485 { 485 {
486 if ( transfer->getCleared ( transactionid ) == 0 ) 486 if ( transfer->getCleared ( transactionid ) == 0 )
487 transfer->setCleared ( transactionid, 1 ); 487 transfer->setCleared ( transactionid, 1 );
488 else 488 else
489 transfer->setCleared ( transactionid, 0 ); 489 transfer->setCleared ( transactionid, 0 );
490 } 490 }
491 491
492 listview->clear(); 492 listview->clear();
493 QString displaytext = "%"; 493 QString displaytext = "%";
494 displaytext.prepend ( limitbox->text() ); 494 displaytext.prepend ( limitbox->text() );
495 if ( transaction->getNumberOfTransactions() > 0 ) 495 if ( transaction->getNumberOfTransactions() > 0 )
496 transaction->displayTransactions ( listview, accountid, children, displaytext ); 496 transaction->displayTransactions ( listview, accountid, children, displaytext );
497 497
498 if ( transfer->getNumberOfTransfers() != 0 ) 498 if ( transfer->getNumberOfTransfers() != 0 )
499 transfer->displayTransfers ( listview, accountid, children ); 499 transfer->displayTransfers ( listview, accountid, children );
500 } 500 }
501 501
502void TransactionDisplay::redisplayAccountBalance () 502void TransactionDisplay::redisplayAccountBalance ()
503 { 503 {
504 QString accountbalance = account->getAccountBalance ( accountid ); 504 QString accountbalance = account->getAccountBalance ( accountid );
505 balance->setText ( accountbalance ); 505 balance->setText ( accountbalance );
506 } 506 }
507 507
508void TransactionDisplay::setChildren ( bool c ) 508void TransactionDisplay::setChildren ( bool c )
509 { 509 {
510 children = c; 510 children = c;
511 } 511 }
512 512
513void TransactionDisplay::setAccountID ( int id ) 513void TransactionDisplay::setAccountID ( int id )
514 { 514 {
515 accountid = id; 515 accountid = id;
516 } 516 }
517 517
518ColorListItem::ColorListItem ( QListView *parent ) : QListViewItem ( parent ) 518ColorListItem::ColorListItem ( QListView *parent ) : QListViewItem ( parent )
519 { 519 {
520 } 520 }
521 521
522ColorListItem::ColorListItem ( QListView *parent, QString label1, QString label2, QString label3, QString label4 ) 522ColorListItem::ColorListItem ( QListView *parent, QString label1, QString label2, QString label3, QString label4 )
523 : QListViewItem ( parent, label1, label2, label3, label4 ) 523 : QListViewItem ( parent, label1, label2, label3, label4 )
524 { 524 {
525 } 525 }
526 526
527ColorListItem::ColorListItem ( QListView *parent, QString label1, QString label2, QString label3, QString label4, QString label5 ) 527ColorListItem::ColorListItem ( QListView *parent, QString label1, QString label2, QString label3, QString label4, QString label5 )
528 : QListViewItem ( parent, label1, label2, label3, label4, label5 ) 528 : QListViewItem ( parent, label1, label2, label3, label4, label5 )
529 { 529 {
530 } 530 }
531 531
532void ColorListItem::paintCell ( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ) 532void ColorListItem::paintCell ( QPainter *p, const QColorGroup &cg, int column, int width, int alignment )
533 { 533 {
534 QColorGroup _cg ( cg ); 534 QColorGroup _cg ( cg );
535 _cg.setColor ( QColorGroup::Text, Qt::red ); 535 _cg.setColor ( QColorGroup::Text, Qt::red );
536 QListViewItem::paintCell ( p, _cg, column, width, alignment ); 536 QListViewItem::paintCell ( p, _cg, column, width, alignment );
537 } 537 }
538 538
539void TransactionDisplay::saveColumnSize ( int column, int oldsize, int newsize ) 539void TransactionDisplay::saveColumnSize ( int column, int oldsize, int newsize )
540 { 540 {
541 if ( listview->columns() == 4 ) 541 if ( listview->columns() == 4 )
542 preferences->changeColumnPreference ( column + 3, newsize ); 542 preferences->changeColumnPreference ( column + 3, newsize );
543 else if ( listview->columns() == 5 && column != 4 ) 543 else if ( listview->columns() == 5 && column != 4 )
544 preferences->changeColumnPreference ( column + 6, newsize ); 544 preferences->changeColumnPreference ( column + 6, newsize );
545 else 545 else
546 preferences->changeColumnPreference ( 9, newsize ); 546 preferences->changeColumnPreference ( 9, newsize );
547 } 547 }
548 548
549void TransactionDisplay::limitDisplay ( const QString &text ) 549void TransactionDisplay::limitDisplay ( const QString &text )
550 { 550 {
551 listview->clear (); 551 listview->clear ();
552 QString displaytext = "%"; 552 QString displaytext = "%";
553 displaytext.prepend ( text ); 553 displaytext.prepend ( text );
554 transaction->displayTransactions ( listview, accountid, children, displaytext ); 554 transaction->displayTransactions ( listview, accountid, children, displaytext );
555 if ( displaytext.length() == 1 || preferences->getPreference ( 6 ) == 1 ) 555 if ( displaytext.length() == 1 || preferences->getPreference ( 6 ) == 1 )
556 transfer->displayTransfers ( listview, accountid, children ); 556 transfer->displayTransfers ( listview, accountid, children );
557 } 557 }
558 558
559int TransactionDisplay::getIDColumn () 559int TransactionDisplay::getIDColumn ()
560 { 560 {
561 int counter; 561 int counter;
562 int columns = listview->columns(); 562 int columns = listview->columns();
563 for ( counter = 0; counter <= columns; counter++ ) 563 for ( counter = 0; counter <= columns; counter++ )
564 if ( listview->header()->label ( counter ).length() == 0 ) 564 if ( listview->header()->label ( counter ).length() == 0 )
565 return counter; 565 return counter;
566 } 566 }
567 567
568void TransactionDisplay::showTransactionNotes () 568void TransactionDisplay::showTransactionNotes ()
569 { 569 {
570 if ( listview->selectedItem() == 0 || listview->currentItem()->text ( getIDColumn() ).toInt() < 0 ) 570 if ( listview->selectedItem() == 0 || listview->currentItem()->text ( getIDColumn() ).toInt() < 0 )
571 QMessageBox::warning ( this, "QashMoney", "Please select a valid\ntransaction to view notes."); 571 QMessageBox::warning ( this, "QashMoney", "Please select a valid\ntransaction to view notes.");
572 else 572 else
573 { 573 {
574 int transactionid = listview->selectedItem()->text ( getIDColumn() ).toInt (); 574 int transactionid = listview->selectedItem()->text ( getIDColumn() ).toInt ();
575 QDialog *description = new QDialog ( this, "description", TRUE ); 575 QDialog *description = new QDialog ( this, "description", TRUE );
576 description->setCaption ( "Notes" ); 576 description->setCaption ( "Notes" );
577 QMultiLineEdit *notes = new QMultiLineEdit ( description ); 577 QMultiLineEdit *notes = new QMultiLineEdit ( description );
578 notes->setFixedSize ( ( int ) (this->width() * 0.75 ), ( int ) ( this->height() * 0.5 ) ); 578 notes->setFixedSize ( ( int ) (this->width() * 0.75 ), ( int ) ( this->height() * 0.5 ) );
579 notes->setWrapColumnOrWidth ( ( int ) (this->width() * 0.75 ) ); 579 notes->setWrapColumnOrWidth ( ( int ) (this->width() * 0.75 ) );
580 notes->setWordWrap ( QMultiLineEdit::WidgetWidth ); 580 notes->setWordWrap ( QMultiLineEdit::WidgetWidth );
581 notes->setEnabled ( FALSE ); 581 notes->setEnabled ( FALSE );
582 notes->setText ( transaction->getTransactionDescription ( transactionid ) ); 582 notes->setText ( transaction->getTransactionDescription ( transactionid ) );
583 description->show(); 583 description->show();
584 } 584 }
585 } 585 }
586 586