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,312 +1,312 @@ | |||
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 |
115 | if ( newtransaction->getDateEdited () == TRUE ) | 115 | if ( newtransaction->getDateEdited () == TRUE ) |
116 | transaction->addTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), accountid, account->getParentAccountID ( accountid ), | 116 | transaction->addTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), accountid, account->getParentAccountID ( accountid ), |
117 | newtransaction->transactionnumber->text().toInt(), newtransaction->getDay(), newtransaction->getMonth(), newtransaction->getYear(), amount, cleared, newtransaction->getCurrentBudget(), | 117 | newtransaction->transactionnumber->text().toInt(), newtransaction->getDay(), newtransaction->getMonth(), newtransaction->getYear(), amount, cleared, newtransaction->getCurrentBudget(), |
118 | newtransaction->getCurrentLineItem() ); | 118 | newtransaction->getCurrentLineItem() ); |
119 | else | 119 | else |
120 | transaction->addTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), accountid, account->getParentAccountID ( accountid ), | 120 | transaction->addTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), accountid, account->getParentAccountID ( accountid ), |
121 | newtransaction->transactionnumber->text().toInt(), defaultday, defaultmonth, defaultyear, amount, cleared, newtransaction->getCurrentBudget(), newtransaction->getCurrentLineItem() ); | 121 | newtransaction->transactionnumber->text().toInt(), defaultday, defaultmonth, defaultyear, amount, cleared, newtransaction->getCurrentBudget(), newtransaction->getCurrentLineItem() ); |
122 | 122 | ||
123 | // redisplay transactions | 123 | // redisplay transactions |
124 | listview->clear(); | 124 | listview->clear(); |
125 | QString displaytext = "%"; | 125 | QString displaytext = "%"; |
126 | displaytext.prepend ( limitbox->text() ); | 126 | displaytext.prepend ( limitbox->text() ); |
127 | setTransactionDisplayDate (); | 127 | setTransactionDisplayDate (); |
128 | if ( transaction->getNumberOfTransactions() > 0 ) | 128 | if ( transaction->getNumberOfTransactions() > 0 ) |
129 | transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate ); | 129 | transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate ); |
130 | 130 | ||
131 | // redisplay transfers | 131 | // redisplay transfers |
132 | if ( transfer->getNumberOfTransfers() > 0 ) | 132 | if ( transfer->getNumberOfTransfers() > 0 ) |
133 | transfer->displayTransfers ( listview, accountid, children, displaydate ); | 133 | transfer->displayTransfers ( listview, accountid, children, displaydate ); |
134 | 134 | ||
135 | // add the transaction amount to the account it's associated with | 135 | // add the transaction amount to the account it's associated with |
136 | // and update its parent account balance if necessary | 136 | // and update its parent account balance if necessary |
137 | account->updateAccountBalance ( accountid ); | 137 | account->updateAccountBalance ( accountid ); |
138 | if ( account->getParentAccountID ( accountid ) != -1 ) | 138 | if ( account->getParentAccountID ( accountid ) != -1 ) |
139 | account->changeParentAccountBalance ( account->getParentAccountID ( accountid ) ); | 139 | account->changeParentAccountBalance ( account->getParentAccountID ( accountid ) ); |
140 | 140 | ||
141 | // format then reset the account balance | 141 | // format then reset the account balance |
142 | redisplayAccountBalance (); | 142 | redisplayAccountBalance (); |
143 | } | 143 | } |
144 | } | 144 | } |
145 | 145 | ||
146 | void TransactionDisplay::checkListViewEdit () | 146 | void TransactionDisplay::checkListViewEdit () |
147 | { | 147 | { |
148 | if ( listview->selectedItem() == 0 ) | 148 | if ( listview->selectedItem() == 0 ) |
149 | QMessageBox::warning ( this, "QashMoney", "Please select a transaction\nto edit."); | 149 | QMessageBox::warning ( this, "QashMoney", "Please select a transaction\nto edit."); |
150 | else if ( listview->currentItem()->text ( getIDColumn() ).toInt() < 0 ) | 150 | else if ( listview->currentItem()->text ( getIDColumn() ).toInt() < 0 ) |
151 | editTransfer (); | 151 | editTransfer (); |
152 | else | 152 | else |
153 | editTransaction(); | 153 | editTransaction(); |
154 | } | 154 | } |
155 | 155 | ||
156 | void TransactionDisplay::showCalculator () | 156 | void TransactionDisplay::showCalculator () |
157 | { | 157 | { |
158 | Calculator *calculator = new Calculator ( this ); | 158 | Calculator *calculator = new Calculator ( this ); |
159 | if ( calculator->exec () == QDialog::Accepted ) | 159 | if ( calculator->exec () == QDialog::Accepted ) |
160 | amount->setText ( calculator->display->text() ); | 160 | amount->setText ( calculator->display->text() ); |
161 | } | 161 | } |
162 | 162 | ||
163 | void TransactionDisplay::showCalendar () | 163 | void TransactionDisplay::showCalendar () |
164 | { | 164 | { |
165 | QDate newDate = QDate::currentDate (); | 165 | QDate newDate = QDate::currentDate (); |
166 | DatePicker *dp = new DatePicker ( newDate ); | 166 | DatePicker *dp = new DatePicker ( newDate ); |
167 | if ( dp->exec () == QDialog::Accepted ) | 167 | if ( dp->exec () == QDialog::Accepted ) |
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 ); |
265 | } | 265 | } |
266 | } | 266 | } |
267 | 267 | ||
268 | void TransactionDisplay::editTransaction () | 268 | void TransactionDisplay::editTransaction () |
269 | { | 269 | { |
270 | int cleared; | 270 | int cleared; |
271 | 271 | ||
272 | // set the transaction id and budgetid | 272 | // set the transaction id and budgetid |
273 | int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt(); | 273 | int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt(); |
274 | int budgetid = transaction->getBudgetID ( transactionid ); | 274 | int budgetid = transaction->getBudgetID ( transactionid ); |
275 | int lineitemid = transaction->getLineItemID ( transactionid ); | 275 | int lineitemid = transaction->getLineItemID ( transactionid ); |
276 | 276 | ||
277 | // create edit transaction window | 277 | // create edit transaction window |
278 | NewTransaction *newtransaction = new NewTransaction ( this ); | 278 | NewTransaction *newtransaction = new NewTransaction ( this ); |
279 | int width = this->width(); | 279 | int width = this->width(); |
280 | newtransaction->transactionname->setMaximumWidth ( ( int ) ( width * 0.45 ) ); | 280 | newtransaction->transactionname->setMaximumWidth ( ( int ) ( width * 0.45 ) ); |
281 | newtransaction->transactionname->setMinimumWidth ( ( int ) ( width * 0.35 ) ); | 281 | newtransaction->transactionname->setMinimumWidth ( ( int ) ( width * 0.35 ) ); |
282 | newtransaction->lineitembox->setMaximumWidth ( ( int ) ( width * 0.45 ) ); | 282 | newtransaction->lineitembox->setMaximumWidth ( ( int ) ( width * 0.45 ) ); |
283 | newtransaction->transactiondatebox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); | 283 | newtransaction->transactiondatebox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); |
284 | newtransaction->transactionamountbox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); | 284 | newtransaction->transactionamountbox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); |
285 | newtransaction->transactionnumber->setMaximumWidth ( ( int ) ( width * 0.25 ) ); | 285 | newtransaction->transactionnumber->setMaximumWidth ( ( int ) ( width * 0.25 ) ); |
286 | 286 | ||
287 | // enter the date in the date box | 287 | // enter the date in the date box |
288 | newtransaction->year = transaction->getYear ( transactionid ); | 288 | newtransaction->year = transaction->getYear ( transactionid ); |
289 | newtransaction->month = transaction->getMonth ( transactionid ); | 289 | newtransaction->month = transaction->getMonth ( transactionid ); |
290 | newtransaction->day = transaction->getDay ( transactionid ); | 290 | newtransaction->day = transaction->getDay ( transactionid ); |
291 | newtransaction->transactiondate->setText ( preferences->getDate ( newtransaction->year, newtransaction->month, newtransaction->day ) ); | 291 | newtransaction->transactiondate->setText ( preferences->getDate ( newtransaction->year, newtransaction->month, newtransaction->day ) ); |
292 | 292 | ||
293 | // set the description | 293 | // set the description |
294 | newtransaction->setDescription ( transaction->getTransactionDescription ( transactionid ) ); | 294 | newtransaction->setDescription ( transaction->getTransactionDescription ( transactionid ) ); |
295 | 295 | ||
296 | // add memory items to the transactionname combobox | 296 | // add memory items to the transactionname combobox |
297 | memory->displayMemoryItems ( newtransaction->transactionname ); | 297 | memory->displayMemoryItems ( newtransaction->transactionname ); |
298 | 298 | ||
299 | // add correct transaction name | 299 | // add correct transaction name |
300 | newtransaction->transactionname->setEditText ( transaction->getPayee ( transactionid ) ); | 300 | newtransaction->transactionname->setEditText ( transaction->getPayee ( transactionid ) ); |
301 | 301 | ||
302 | // add transaction number | 302 | // add transaction number |
303 | newtransaction->transactionnumber->setText ( transaction->getNumber ( transactionid ) ); | 303 | newtransaction->transactionnumber->setText ( transaction->getNumber ( transactionid ) ); |
304 | 304 | ||
305 | // add transaction amount | 305 | // add transaction amount |
306 | newtransaction->transactionamount->setText ( transaction->getAbsoluteAmount ( transactionid ) ); | 306 | newtransaction->transactionamount->setText ( transaction->getAbsoluteAmount ( transactionid ) ); |
307 | 307 | ||
308 | // check for and set the correct budget | 308 | // check for and set the correct budget |
309 | if ( budgetid >= 1 ) // only do it if this transaction has a budget and line item | 309 | if ( budgetid >= 1 ) // only do it if this transaction has a budget and line item |
310 | { | 310 | { |
311 | newtransaction->budgetbox->setCurrentItem ( newtransaction->getBudgetIndex ( budgetid ) + 1 ); | 311 | newtransaction->budgetbox->setCurrentItem ( newtransaction->getBudgetIndex ( budgetid ) + 1 ); |
312 | if ( lineitemid >= 1 ) | 312 | if ( lineitemid >= 1 ) |