author | alwin <alwin> | 2004-03-02 12:21:11 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-02 12:21:11 (UTC) |
commit | b6b1c97559c0ed9f2e33632272426bf98f289232 (patch) (unidiff) | |
tree | d3a9987704770cdf5eb14e1136f6e3ecb2f36a04 /noncore/apps/qashmoney/transactiondisplay.cpp | |
parent | 0d59c780513da78033f4d9040475dee9db0256d4 (diff) | |
download | opie-b6b1c97559c0ed9f2e33632272426bf98f289232.zip opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.gz opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.bz2 |
applied the patch generated by the optimize_connect script from
TT.
Diffstat (limited to 'noncore/apps/qashmoney/transactiondisplay.cpp') (more/less context) (ignore whitespace changes)
-rwxr-xr-x | noncore/apps/qashmoney/transactiondisplay.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/noncore/apps/qashmoney/transactiondisplay.cpp b/noncore/apps/qashmoney/transactiondisplay.cpp index 474f11e..0b94d62 100755 --- a/noncore/apps/qashmoney/transactiondisplay.cpp +++ b/noncore/apps/qashmoney/transactiondisplay.cpp | |||
@@ -1,114 +1,114 @@ | |||
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 "calculator.h" | 7 | #include "calculator.h" |
8 | #include "datepicker.h" | 8 | #include "datepicker.h" |
9 | 9 | ||
10 | #include <qmessagebox.h> | 10 | #include <qmessagebox.h> |
11 | #include <qheader.h> | 11 | #include <qheader.h> |
12 | #include <qmultilineedit.h> | 12 | #include <qmultilineedit.h> |
13 | 13 | ||
14 | extern Transaction *transaction; | 14 | extern Transaction *transaction; |
15 | extern Budget *budget; | 15 | extern Budget *budget; |
16 | extern Account *account; | 16 | extern Account *account; |
17 | extern Preferences *preferences; | 17 | extern Preferences *preferences; |
18 | extern Memory *memory; | 18 | extern Memory *memory; |
19 | extern Transfer *transfer; | 19 | extern Transfer *transfer; |
20 | 20 | ||
21 | TransactionDisplay::TransactionDisplay ( QWidget* parent ) : QWidget ( parent ) | 21 | TransactionDisplay::TransactionDisplay ( QWidget* parent ) : QWidget ( parent ) |
22 | { | 22 | { |
23 | // set transactiondisplay variables; | 23 | // set transactiondisplay variables; |
24 | accountid = 0; | 24 | accountid = 0; |
25 | children = TRUE; | 25 | children = TRUE; |
26 | 26 | ||
27 | firstline = new QHBox ( this ); | 27 | firstline = new QHBox ( this ); |
28 | firstline->setSpacing ( 2 ); | 28 | firstline->setSpacing ( 2 ); |
29 | 29 | ||
30 | newtransaction = new QPushButton ( firstline ); | 30 | newtransaction = new QPushButton ( firstline ); |
31 | newtransaction->setPixmap ( QPixmap ("/opt/QtPalmtop/pics/new.png") ); | 31 | newtransaction->setPixmap ( QPixmap ("/opt/QtPalmtop/pics/new.png") ); |
32 | connect ( newtransaction, SIGNAL ( released () ), this, SLOT ( addTransaction () ) ); | 32 | connect ( newtransaction, SIGNAL ( released() ), this, SLOT ( addTransaction() ) ); |
33 | 33 | ||
34 | edittransaction = new QPushButton ( firstline ); | 34 | edittransaction = new QPushButton ( firstline ); |
35 | edittransaction->setPixmap( QPixmap ("/opt/QtPalmtop/pics/edit.png") ); | 35 | edittransaction->setPixmap( QPixmap ("/opt/QtPalmtop/pics/edit.png") ); |
36 | connect ( edittransaction, SIGNAL ( released () ), this, SLOT ( checkListViewEdit () ) ); | 36 | connect ( edittransaction, SIGNAL ( released() ), this, SLOT ( checkListViewEdit() ) ); |
37 | 37 | ||
38 | deletetransaction = new QPushButton ( firstline ); | 38 | deletetransaction = new QPushButton ( firstline ); |
39 | deletetransaction->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/delete.png") ); | 39 | deletetransaction->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/delete.png") ); |
40 | connect ( deletetransaction, SIGNAL ( released () ), this, SLOT ( checkListViewDelete () ) ); | 40 | connect ( deletetransaction, SIGNAL ( released() ), this, SLOT ( checkListViewDelete() ) ); |
41 | 41 | ||
42 | toggletransaction = new QPushButton ( firstline ); | 42 | toggletransaction = new QPushButton ( firstline ); |
43 | toggletransaction->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/redo.png") ); | 43 | toggletransaction->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/redo.png") ); |
44 | connect ( toggletransaction, SIGNAL ( released () ), this, SLOT ( checkListViewToggle () ) ); | 44 | connect ( toggletransaction, SIGNAL ( released() ), this, SLOT ( checkListViewToggle() ) ); |
45 | 45 | ||
46 | viewtransactionnotes = new QPushButton ( firstline ); | 46 | viewtransactionnotes = new QPushButton ( firstline ); |
47 | viewtransactionnotes->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/info.png") ); | 47 | viewtransactionnotes->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/info.png") ); |
48 | connect ( viewtransactionnotes, SIGNAL ( released () ), this, SLOT ( showTransactionNotes () ) ); | 48 | connect ( viewtransactionnotes, SIGNAL ( released() ), this, SLOT ( showTransactionNotes() ) ); |
49 | 49 | ||
50 | secondline = new QHBox ( this ); | 50 | secondline = new QHBox ( this ); |
51 | secondline->setSpacing ( 5 ); | 51 | secondline->setSpacing ( 5 ); |
52 | 52 | ||
53 | name = new QLabel ( secondline ); | 53 | name = new QLabel ( secondline ); |
54 | balance = new QLabel ( secondline ); | 54 | balance = new QLabel ( secondline ); |
55 | 55 | ||
56 | QLabel *limit = new QLabel ( "Limit", secondline ); | 56 | QLabel *limit = new QLabel ( "Limit", secondline ); |
57 | limitbox = new QLineEdit ( secondline ); | 57 | limitbox = new QLineEdit ( secondline ); |
58 | limitbox->setMinimumWidth ( ( int ) ( this->width() / 6 ) ); | 58 | limitbox->setMinimumWidth ( ( int ) ( this->width() / 6 ) ); |
59 | connect ( limitbox, SIGNAL ( textChanged ( const QString & ) ), this, SLOT ( limitDisplay ( const QString & ) ) ); | 59 | connect ( limitbox, SIGNAL ( textChanged(const QString&) ), this, SLOT ( limitDisplay(const QString&) ) ); |
60 | 60 | ||
61 | listview = new QListView ( this ); | 61 | listview = new QListView ( this ); |
62 | listview->setAllColumnsShowFocus ( TRUE ); | 62 | listview->setAllColumnsShowFocus ( TRUE ); |
63 | listview->setShowSortIndicator ( TRUE ); | 63 | listview->setShowSortIndicator ( TRUE ); |
64 | listview->header()->setTracking ( FALSE ); | 64 | listview->header()->setTracking ( FALSE ); |
65 | connect ( listview->header(), SIGNAL ( sizeChange ( int, int, int ) ), this, SLOT ( saveColumnSize ( int, int, int ) ) ); | 65 | connect ( listview->header(), SIGNAL ( sizeChange(int,int,int) ), this, SLOT ( saveColumnSize(int,int,int) ) ); |
66 | connect ( listview->header(), SIGNAL ( clicked ( int ) ), this, SLOT ( saveSortingPreference ( int ) ) ); | 66 | connect ( listview->header(), SIGNAL ( clicked(int) ), this, SLOT ( saveSortingPreference(int) ) ); |
67 | 67 | ||
68 | layout = new QVBoxLayout ( this, 2, 2 ); | 68 | layout = new QVBoxLayout ( this, 2, 2 ); |
69 | layout->addWidget ( firstline ); | 69 | layout->addWidget ( firstline ); |
70 | layout->addWidget ( secondline ); | 70 | layout->addWidget ( secondline ); |
71 | layout->addWidget ( listview ); | 71 | layout->addWidget ( listview ); |
72 | } | 72 | } |
73 | 73 | ||
74 | void TransactionDisplay::addTransaction () | 74 | void TransactionDisplay::addTransaction () |
75 | { | 75 | { |
76 | // create local variables | 76 | // create local variables |
77 | int cleared = -1; | 77 | int cleared = -1; |
78 | 78 | ||
79 | // create new transaction window | 79 | // create new transaction window |
80 | NewTransaction *newtransaction = new NewTransaction ( this ); | 80 | NewTransaction *newtransaction = new NewTransaction ( this ); |
81 | int width = this->size().width(); | 81 | int width = this->size().width(); |
82 | newtransaction->transactionname->setMaximumWidth ( ( int ) ( width * 0.45 ) ); | 82 | newtransaction->transactionname->setMaximumWidth ( ( int ) ( width * 0.45 ) ); |
83 | newtransaction->transactionname->setMinimumWidth ( ( int ) ( width * 0.35 ) ); | 83 | newtransaction->transactionname->setMinimumWidth ( ( int ) ( width * 0.35 ) ); |
84 | newtransaction->lineitembox->setMaximumWidth ( ( int ) ( width * 0.45 ) ); | 84 | newtransaction->lineitembox->setMaximumWidth ( ( int ) ( width * 0.45 ) ); |
85 | newtransaction->transactiondatebox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); | 85 | newtransaction->transactiondatebox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); |
86 | newtransaction->transactionamountbox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); | 86 | newtransaction->transactionamountbox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); |
87 | newtransaction->transactionnumber->setMaximumWidth ( ( int ) ( width * 0.25 ) ); | 87 | newtransaction->transactionnumber->setMaximumWidth ( ( int ) ( width * 0.25 ) ); |
88 | 88 | ||
89 | // enter today's date in the date box as defaul | 89 | // enter today's date in the date box as defaul |
90 | QDate today = QDate::currentDate (); | 90 | QDate today = QDate::currentDate (); |
91 | int defaultday = today.day(); | 91 | int defaultday = today.day(); |
92 | int defaultmonth = today.month(); | 92 | int defaultmonth = today.month(); |
93 | int defaultyear = today.year(); | 93 | int defaultyear = today.year(); |
94 | newtransaction->transactiondate->setText ( preferences->getDate ( defaultyear, defaultmonth, defaultday ) ); | 94 | newtransaction->transactiondate->setText ( preferences->getDate ( defaultyear, defaultmonth, defaultday ) ); |
95 | 95 | ||
96 | // add memory items to the transactionname combobox | 96 | // add memory items to the transactionname combobox |
97 | memory->displayMemoryItems ( newtransaction->transactionname ); | 97 | memory->displayMemoryItems ( newtransaction->transactionname ); |
98 | newtransaction->transactionname->insertItem ( "", 0 ); | 98 | newtransaction->transactionname->insertItem ( "", 0 ); |
99 | 99 | ||
100 | if ( newtransaction->exec () == QDialog::Accepted ) | 100 | if ( newtransaction->exec () == QDialog::Accepted ) |
101 | { | 101 | { |
102 | if ( newtransaction->clearedcheckbox->isChecked () == TRUE ) // set a parent id and type for a child transaction | 102 | if ( newtransaction->clearedcheckbox->isChecked () == TRUE ) // set a parent id and type for a child transaction |
103 | cleared = 1; | 103 | cleared = 1; |
104 | else | 104 | else |
105 | cleared = 0; | 105 | cleared = 0; |
106 | 106 | ||
107 | float amount = newtransaction->transactionamount->text().toFloat(); | 107 | float amount = newtransaction->transactionamount->text().toFloat(); |
108 | if ( newtransaction->depositbox->isChecked() == FALSE ) | 108 | if ( newtransaction->depositbox->isChecked() == FALSE ) |
109 | amount = amount * -1; | 109 | amount = amount * -1; |
110 | 110 | ||
111 | // add the transaction name to the memory items | 111 | // add the transaction name to the memory items |
112 | memory->addMemoryItem ( newtransaction->transactionname->currentText() ); | 112 | memory->addMemoryItem ( newtransaction->transactionname->currentText() ); |
113 | 113 | ||
114 | // add the transaction | 114 | // add the transaction |
@@ -168,97 +168,97 @@ void TransactionDisplay::showCalendar () | |||
168 | { | 168 | { |
169 | year = dp->getYear(); | 169 | year = dp->getYear(); |
170 | month = dp->getMonth(); | 170 | month = dp->getMonth(); |
171 | day = dp->getDay(); | 171 | day = dp->getDay(); |
172 | date->setText ( preferences->getDate ( year, month, day ) ); | 172 | date->setText ( preferences->getDate ( year, month, day ) ); |
173 | } | 173 | } |
174 | } | 174 | } |
175 | 175 | ||
176 | void TransactionDisplay::editTransfer () | 176 | void TransactionDisplay::editTransfer () |
177 | { | 177 | { |
178 | transferid = listview->currentItem()->text ( getIDColumn() ).toInt(); | 178 | transferid = listview->currentItem()->text ( getIDColumn() ).toInt(); |
179 | fromaccount = transfer->getFromAccountID ( transferid ); | 179 | fromaccount = transfer->getFromAccountID ( transferid ); |
180 | toaccount = transfer->getToAccountID ( transferid ); | 180 | toaccount = transfer->getToAccountID ( transferid ); |
181 | year = transfer->getYear ( transferid ); | 181 | year = transfer->getYear ( transferid ); |
182 | month = transfer->getMonth ( transferid ); | 182 | month = transfer->getMonth ( transferid ); |
183 | day = transfer->getDay ( transferid ); | 183 | day = transfer->getDay ( transferid ); |
184 | 184 | ||
185 | QDialog *editransfer = new QDialog ( this, "edittransfer", TRUE ); | 185 | QDialog *editransfer = new QDialog ( this, "edittransfer", TRUE ); |
186 | editransfer->setCaption ( "Transfer" ); | 186 | editransfer->setCaption ( "Transfer" ); |
187 | 187 | ||
188 | QStringList accountnames = account->getAccountNames(); | 188 | QStringList accountnames = account->getAccountNames(); |
189 | QStringList accountids = account->getAccountIDs(); | 189 | QStringList accountids = account->getAccountIDs(); |
190 | 190 | ||
191 | QLabel *fromaccountlabel = new QLabel ( "From Account:", editransfer ); | 191 | QLabel *fromaccountlabel = new QLabel ( "From Account:", editransfer ); |
192 | QFont f = this->font(); | 192 | QFont f = this->font(); |
193 | f.setWeight ( QFont::Bold ); | 193 | f.setWeight ( QFont::Bold ); |
194 | fromaccountlabel->setFont ( f ); | 194 | fromaccountlabel->setFont ( f ); |
195 | 195 | ||
196 | QComboBox *fromaccountbox = new QComboBox ( editransfer ); | 196 | QComboBox *fromaccountbox = new QComboBox ( editransfer ); |
197 | fromaccountbox->insertStringList ( accountnames ); | 197 | fromaccountbox->insertStringList ( accountnames ); |
198 | fromaccountbox->setCurrentItem ( accountids.findIndex ( QString::number ( fromaccount ) ) ); | 198 | fromaccountbox->setCurrentItem ( accountids.findIndex ( QString::number ( fromaccount ) ) ); |
199 | 199 | ||
200 | QLabel *toaccountlabel = new QLabel ( "To Account:", editransfer ); | 200 | QLabel *toaccountlabel = new QLabel ( "To Account:", editransfer ); |
201 | toaccountlabel->setFont ( f ); | 201 | toaccountlabel->setFont ( f ); |
202 | 202 | ||
203 | QComboBox *toaccountbox = new QComboBox ( editransfer ); | 203 | QComboBox *toaccountbox = new QComboBox ( editransfer ); |
204 | toaccountbox->insertStringList ( accountnames ); | 204 | toaccountbox->insertStringList ( accountnames ); |
205 | toaccountbox->setCurrentItem ( accountids.findIndex ( QString::number ( toaccount ) ) ); | 205 | toaccountbox->setCurrentItem ( accountids.findIndex ( QString::number ( toaccount ) ) ); |
206 | 206 | ||
207 | QLabel *datelabel = new QLabel ( "Date", editransfer ); | 207 | QLabel *datelabel = new QLabel ( "Date", editransfer ); |
208 | QHBox *datebox = new QHBox ( editransfer ); | 208 | QHBox *datebox = new QHBox ( editransfer ); |
209 | datebox->setSpacing ( 2 ); | 209 | datebox->setSpacing ( 2 ); |
210 | date = new QLineEdit ( datebox ); | 210 | date = new QLineEdit ( datebox ); |
211 | date->setAlignment ( Qt::AlignRight ); | 211 | date->setAlignment ( Qt::AlignRight ); |
212 | date->setDisabled ( TRUE ); | 212 | date->setDisabled ( TRUE ); |
213 | date->setText ( preferences->getDate ( year, month, day ) ); | 213 | date->setText ( preferences->getDate ( year, month, day ) ); |
214 | QPushButton *datebutton = new QPushButton ( datebox ); | 214 | QPushButton *datebutton = new QPushButton ( datebox ); |
215 | datebutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/date.png" ) ); | 215 | datebutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/date.png" ) ); |
216 | connect ( datebutton, SIGNAL ( released () ), this, SLOT ( showCalendar () ) ); | 216 | connect ( datebutton, SIGNAL ( released() ), this, SLOT ( showCalendar() ) ); |
217 | 217 | ||
218 | QLabel *amounttlabel = new QLabel ( "Amount", editransfer ); | 218 | QLabel *amounttlabel = new QLabel ( "Amount", editransfer ); |
219 | 219 | ||
220 | QHBox *amountbox = new QHBox ( editransfer ); | 220 | QHBox *amountbox = new QHBox ( editransfer ); |
221 | amountbox->setSpacing ( 2 ); | 221 | amountbox->setSpacing ( 2 ); |
222 | amount = new QLineEdit ( amountbox ); | 222 | amount = new QLineEdit ( amountbox ); |
223 | amount->setAlignment ( Qt::AlignRight ); | 223 | amount->setAlignment ( Qt::AlignRight ); |
224 | amount->setText ( transfer->getAmount ( transferid ) ); | 224 | amount->setText ( transfer->getAmount ( transferid ) ); |
225 | QPushButton *calculatorbutton = new QPushButton( amountbox ); | 225 | QPushButton *calculatorbutton = new QPushButton( amountbox ); |
226 | calculatorbutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/kcalc.png" ) ); | 226 | calculatorbutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/kcalc.png" ) ); |
227 | connect ( calculatorbutton, SIGNAL ( released() ), this, SLOT ( showCalculator() ) ); | 227 | connect ( calculatorbutton, SIGNAL ( released() ), this, SLOT ( showCalculator() ) ); |
228 | 228 | ||
229 | QCheckBox *clearedcheckbox = new QCheckBox ( "Cleared", editransfer ); | 229 | QCheckBox *clearedcheckbox = new QCheckBox ( "Cleared", editransfer ); |
230 | 230 | ||
231 | QBoxLayout *layout = new QVBoxLayout ( editransfer, 4, 2 ); | 231 | QBoxLayout *layout = new QVBoxLayout ( editransfer, 4, 2 ); |
232 | layout->addWidget ( fromaccountlabel, Qt::AlignLeft ); | 232 | layout->addWidget ( fromaccountlabel, Qt::AlignLeft ); |
233 | layout->addWidget ( fromaccountbox, Qt::AlignLeft ); | 233 | layout->addWidget ( fromaccountbox, Qt::AlignLeft ); |
234 | layout->addWidget ( toaccountlabel, Qt::AlignLeft ); | 234 | layout->addWidget ( toaccountlabel, Qt::AlignLeft ); |
235 | layout->addWidget ( toaccountbox, Qt::AlignLeft ); | 235 | layout->addWidget ( toaccountbox, Qt::AlignLeft ); |
236 | layout->addSpacing ( 5 ); | 236 | layout->addSpacing ( 5 ); |
237 | layout->addWidget ( datelabel, Qt::AlignLeft ); | 237 | layout->addWidget ( datelabel, Qt::AlignLeft ); |
238 | layout->addWidget ( datebox, Qt::AlignLeft ); | 238 | layout->addWidget ( datebox, Qt::AlignLeft ); |
239 | layout->addWidget ( amounttlabel, Qt::AlignLeft ); | 239 | layout->addWidget ( amounttlabel, Qt::AlignLeft ); |
240 | layout->addWidget ( amountbox, Qt::AlignLeft ); | 240 | layout->addWidget ( amountbox, Qt::AlignLeft ); |
241 | layout->addWidget ( clearedcheckbox, Qt::AlignLeft ); | 241 | layout->addWidget ( clearedcheckbox, Qt::AlignLeft ); |
242 | 242 | ||
243 | if ( editransfer->exec() == QDialog::Accepted ) | 243 | if ( editransfer->exec() == QDialog::Accepted ) |
244 | { | 244 | { |
245 | //get fromaccount | 245 | //get fromaccount |
246 | fromaccount = ( accountids.operator[] ( fromaccountbox->currentItem() ) ).toInt(); | 246 | fromaccount = ( accountids.operator[] ( fromaccountbox->currentItem() ) ).toInt(); |
247 | 247 | ||
248 | //get to account | 248 | //get to account |
249 | toaccount = ( accountids.operator[] ( toaccountbox->currentItem() ) ).toInt(); | 249 | toaccount = ( accountids.operator[] ( toaccountbox->currentItem() ) ).toInt(); |
250 | 250 | ||
251 | //set cleared flag | 251 | //set cleared flag |
252 | int cleared = 0; | 252 | int cleared = 0; |
253 | if ( clearedcheckbox->isChecked() == TRUE ) | 253 | if ( clearedcheckbox->isChecked() == TRUE ) |
254 | cleared = 1; | 254 | cleared = 1; |
255 | 255 | ||
256 | //update transfer | 256 | //update transfer |
257 | transfer->updateTransfer ( fromaccount, account->getParentAccountID ( fromaccount ), toaccount, account->getParentAccountID ( toaccount ), | 257 | transfer->updateTransfer ( fromaccount, account->getParentAccountID ( fromaccount ), toaccount, account->getParentAccountID ( toaccount ), |
258 | day, month, year, amount->text().toFloat(), cleared, transferid ); | 258 | day, month, year, amount->text().toFloat(), cleared, transferid ); |
259 | 259 | ||
260 | account->updateAccountBalance ( fromaccount ); | 260 | account->updateAccountBalance ( fromaccount ); |
261 | if ( account->getParentAccountID ( fromaccount ) != -1 ) | 261 | if ( account->getParentAccountID ( fromaccount ) != -1 ) |
262 | account->changeParentAccountBalance ( account->getParentAccountID ( fromaccount ) ); | 262 | account->changeParentAccountBalance ( account->getParentAccountID ( fromaccount ) ); |
263 | 263 | ||
264 | updateAndDisplay ( toaccount ); | 264 | updateAndDisplay ( toaccount ); |