summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/checkbook/qcheckentry.cpp435
-rw-r--r--noncore/apps/checkbook/qcheckentrybase.ui9
2 files changed, 228 insertions, 216 deletions
diff --git a/noncore/apps/checkbook/qcheckentry.cpp b/noncore/apps/checkbook/qcheckentry.cpp
index 9ff02c9..2e8da1c 100644
--- a/noncore/apps/checkbook/qcheckentry.cpp
+++ b/noncore/apps/checkbook/qcheckentry.cpp
@@ -1,251 +1,256 @@
1#include "qcheckentry.h" 1#include "qcheckentry.h"
2 2
3QCheckEntry::QCheckEntry() 3QCheckEntry::QCheckEntry()
4 : QCheckEntryBase() 4 : QCheckEntryBase()
5{ 5{
6 connect(transAmount, SIGNAL(textChanged(const QString &)), this, SLOT(amountChanged(const QString &))); 6 connect(transAmount, SIGNAL(textChanged(const QString &)), this, SLOT(amountChanged(const QString &)));
7 connect(transFee, SIGNAL(textChanged(const QString &)), this, SLOT(transFeeChanged(const QString &))); 7 connect(transFee, SIGNAL(textChanged(const QString &)), this, SLOT(transFeeChanged(const QString &)));
8 connect(payment, SIGNAL(clicked()), this, SLOT(paymentClicked())); 8 connect(payment, SIGNAL(clicked()), this, SLOT(paymentClicked()));
9 connect(deposit, SIGNAL(clicked()), this, SLOT(depositClicked())); 9 connect(deposit, SIGNAL(clicked()), this, SLOT(depositClicked()));
10 10
11 QString todaysdate = QString::number(QDate::currentDate().month()); 11 QString todaysdate = QString::number(QDate::currentDate().month());
12 todaysdate.append("/"); 12 todaysdate.append("/");
13 todaysdate.append(QString::number(QDate::currentDate().day())); 13 todaysdate.append(QString::number(QDate::currentDate().day()));
14 todaysdate.append("/"); 14 todaysdate.append("/");
15 todaysdate.append(QString::number(QDate::currentDate().year())); 15 todaysdate.append(QString::number(QDate::currentDate().year()));
16 dateEdit->setText(todaysdate); 16 dateEdit->setText(todaysdate);
17 17
18 descriptionCombo->setFocus(); 18 descriptionCombo->setFocus();
19 19
20 dateEdit->setValidChars("0123456789./-"); 20 dateEdit->setValidChars("0123456789./-");
21 dateEdit->setMaxLength(10); 21 dateEdit->setMaxLength(10);
22 22
23 descriptionCombo->lineEdit()->setMaxLength(30); 23 descriptionCombo->lineEdit()->setMaxLength(30);
24 24
25 checkNumber->setValidChars("0123456789-"); 25 checkNumber->setValidChars("0123456789-");
26 checkNumber->setMaxLength(10); 26 checkNumber->setMaxLength(10);
27 27
28 transAmount->setValidChars("0123456789."); 28 transAmount->setValidChars("0123456789.");
29 29
30 transFee->setMaxLength(5); 30 transFee->setMaxLength(5);
31 transFee->setValidChars("0123456789."); 31 transFee->setValidChars("0123456789.");
32 setTabOrder(transType,checkNumber);
33 setTabOrder(checkNumber,transAmount);
34 setTabOrder(transAmount,transFee);
35 setTabOrder(transFee,dateEdit);
36 setTabOrder(dateEdit, additionalNotes );
32} 37}
33 38
34void QCheckEntry::paymentClicked() 39void QCheckEntry::paymentClicked()
35{ 40{
36 cmbCategory->clear(); 41 cmbCategory->clear();
37 cmbCategory->insertItem( tr( "Automobile" ) ); 42 cmbCategory->insertItem( tr( "Automobile" ) );
38 cmbCategory->insertItem( tr( "Bills" ) ); 43 cmbCategory->insertItem( tr( "Bills" ) );
39 cmbCategory->insertItem( tr( "CDs" ) ); 44 cmbCategory->insertItem( tr( "CDs" ) );
40 cmbCategory->insertItem( tr( "Clothing" ) ); 45 cmbCategory->insertItem( tr( "Clothing" ) );
41 cmbCategory->insertItem( tr( "Computer" ) ); 46 cmbCategory->insertItem( tr( "Computer" ) );
42 cmbCategory->insertItem( tr( "DVDs" ) ); 47 cmbCategory->insertItem( tr( "DVDs" ) );
43 cmbCategory->insertItem( tr( "Eletronics" ) ); 48 cmbCategory->insertItem( tr( "Eletronics" ) );
44 cmbCategory->insertItem( tr( "Entertainment" ) ); 49 cmbCategory->insertItem( tr( "Entertainment" ) );
45 cmbCategory->insertItem( tr( "Food" ) ); 50 cmbCategory->insertItem( tr( "Food" ) );
46 cmbCategory->insertItem( tr( "Gasoline" ) ); 51 cmbCategory->insertItem( tr( "Gasoline" ) );
47 cmbCategory->insertItem( tr( "Misc" ) ); 52 cmbCategory->insertItem( tr( "Misc" ) );
48 cmbCategory->insertItem( tr( "Movies" ) ); 53 cmbCategory->insertItem( tr( "Movies" ) );
49 cmbCategory->insertItem( tr( "Rent" ) ); 54 cmbCategory->insertItem( tr( "Rent" ) );
50 cmbCategory->insertItem( tr( "Travel" ) ); 55 cmbCategory->insertItem( tr( "Travel" ) );
51 cmbCategory->setCurrentItem( 0 ); 56 cmbCategory->setCurrentItem( 0 );
52 transType->clear(); 57 transType->clear();
53 transType->insertItem( tr( "Debit Charge" ) ); 58 transType->insertItem( tr( "Debit Charge" ) );
54 transType->insertItem( tr( "Written Check" ) ); 59 transType->insertItem( tr( "Written Check" ) );
55 transType->insertItem( tr( "Transfer" ) ); 60 transType->insertItem( tr( "Transfer" ) );
56 transType->insertItem( tr( "Credit Card" ) ); 61 transType->insertItem( tr( "Credit Card" ) );
57} 62}
58 63
59void QCheckEntry::depositClicked() 64void QCheckEntry::depositClicked()
60{ 65{
61 cmbCategory->clear(); 66 cmbCategory->clear();
62 cmbCategory->insertItem( tr( "Work" ) ); 67 cmbCategory->insertItem( tr( "Work" ) );
63 cmbCategory->insertItem( tr( "Family Member" ) ); 68 cmbCategory->insertItem( tr( "Family Member" ) );
64 cmbCategory->insertItem( tr( "Misc. Credit" ) ); 69 cmbCategory->insertItem( tr( "Misc. Credit" ) );
65 cmbCategory->setCurrentItem( 0 ); 70 cmbCategory->setCurrentItem( 0 );
66 transType->clear(); 71 transType->clear();
67 transType->insertItem( tr( "Written Check" ) ); 72 transType->insertItem( tr( "Written Check" ) );
68 transType->insertItem( tr( "Automatic Payment" ) ); 73 transType->insertItem( tr( "Automatic Payment" ) );
69 transType->insertItem( tr( "Transfer" ) ); 74 transType->insertItem( tr( "Transfer" ) );
70 transType->insertItem( tr( "Cash" ) ); 75 transType->insertItem( tr( "Cash" ) );
71} 76}
72 77
73QStringList QCheckEntry::popupEntry(const QStringList &originaldata) 78QStringList QCheckEntry::popupEntry(const QStringList &originaldata)
74{ 79{
75 QCheckEntry qce; 80 QCheckEntry qce;
76 81
77 // This is how the list looks: 82 // This is how the list looks:
78 // 0: true or false, true == payment, false == deposit 83 // 0: true or false, true == payment, false == deposit
79 // 1: description of the transaction 84 // 1: description of the transaction
80 // 2: category name 85 // 2: category name
81 // 3: transaction type (stores the integer value of the index of the combobox) 86 // 3: transaction type (stores the integer value of the index of the combobox)
82 // 4: check number of the transaction (if any) 87 // 4: check number of the transaction (if any)
83 // 5: transaction amount 88 // 5: transaction amount
84 // 6: transaction fee (e.g. service charge, or ATM charge). 89 // 6: transaction fee (e.g. service charge, or ATM charge).
85 // 7: date of the transaction 90 // 7: date of the transaction
86 // 8: additional notes 91 // 8: additional notes
87 // 9: recently used descriptions 92 // 9: recently used descriptions
88 if (originaldata.count() > 1) 93 if (originaldata.count() > 1)
89 { 94 {
90 if (originaldata[0] == "true") 95 if (originaldata[0] == "true")
91 { 96 {
92 qce.payment->setChecked(true); 97 qce.payment->setChecked(true);
93 qce.paymentClicked(); 98 qce.paymentClicked();
94 } else { 99 } else {
95 if (originaldata[0] == "false") 100 if (originaldata[0] == "false")
96 { 101 {
97 qce.deposit->setChecked(true); 102 qce.deposit->setChecked(true);
98 qce.depositClicked(); 103 qce.depositClicked();
99 } 104 }
100 } 105 }
101 qce.descriptionCombo->lineEdit()->setText(originaldata[1]); 106 qce.descriptionCombo->lineEdit()->setText(originaldata[1]);
102 qce.cmbCategory->lineEdit()->setText(originaldata[2]); 107 qce.cmbCategory->lineEdit()->setText(originaldata[2]);
103 qce.transType->setCurrentItem(originaldata[3].toInt()); 108 qce.transType->setCurrentItem(originaldata[3].toInt());
104 qce.checkNumber->setText(originaldata[4]); 109 qce.checkNumber->setText(originaldata[4]);
105 qce.transAmount->setText(originaldata[5]); 110 qce.transAmount->setText(originaldata[5]);
106 qce.transFee->setText(originaldata[6]); 111 qce.transFee->setText(originaldata[6]);
107 qce.dateEdit->setText(originaldata[7]); 112 qce.dateEdit->setText(originaldata[7]);
108 qce.additionalNotes->setText(originaldata[8]); 113 qce.additionalNotes->setText(originaldata[8]);
109 QStringList recentlist; 114 QStringList recentlist;
110 if (!originaldata[9].isEmpty()) 115 if (!originaldata[9].isEmpty())
111 { 116 {
112 recentlist = QStringList::split(',', originaldata[9], false); 117 recentlist = QStringList::split(',', originaldata[9], false);
113 } 118 }
114 if (!recentlist.isEmpty()) 119 if (!recentlist.isEmpty())
115 { 120 {
116 qce.descriptionCombo->insertStringList(recentlist); 121 qce.descriptionCombo->insertStringList(recentlist);
117 } 122 }
118 } else { 123 } else {
119 QStringList recentlist; 124 QStringList recentlist;
120 if (!originaldata[0].isEmpty()) 125 if (!originaldata[0].isEmpty())
121 { 126 {
122 recentlist = QStringList::split(',', originaldata[0], false); 127 recentlist = QStringList::split(',', originaldata[0], false);
123 } 128 }
124 if (!recentlist.isEmpty()) 129 if (!recentlist.isEmpty())
125 { 130 {
126 qce.descriptionCombo->insertStringList(recentlist); 131 qce.descriptionCombo->insertStringList(recentlist);
127 } 132 }
128 } 133 }
129 134
130 qce.setWFlags(Qt::WType_Modal); 135 qce.setWFlags(Qt::WType_Modal);
131 qce.showMaximized(); 136 qce.showMaximized();
132 137
133 qce.descriptionCombo->lineEdit()->clear(); 138 qce.descriptionCombo->lineEdit()->clear();
134 139
135 if (qce.exec() == QDialog::Accepted) 140 if (qce.exec() == QDialog::Accepted)
136 { 141 {
137 // Validate that the user has inputed a valid dollar amount 142 // Validate that the user has inputed a valid dollar amount
138 if (qce.transFee->text().contains('.') == 0) 143 if (qce.transFee->text().contains('.') == 0)
139 { 144 {
140 QString text = qce.transFee->text(); 145 QString text = qce.transFee->text();
141 text.append(".00"); 146 text.append(".00");
142 qce.transFee->setText(text); 147 qce.transFee->setText(text);
143 } else { 148 } else {
144 QString tmp = qce.transFee->text(); 149 QString tmp = qce.transFee->text();
145 if (tmp.mid(tmp.find('.'), tmp.length()).length() == 1) 150 if (tmp.mid(tmp.find('.'), tmp.length()).length() == 1)
146 { 151 {
147 tmp.append("00"); 152 tmp.append("00");
148 qce.transFee->setText(tmp); 153 qce.transFee->setText(tmp);
149 } else { 154 } else {
150 if (tmp.mid(tmp.find('.'), tmp.length()).length() == 2) 155 if (tmp.mid(tmp.find('.'), tmp.length()).length() == 2)
151 { 156 {
152 tmp.append("0"); 157 tmp.append("0");
153 qce.transFee->setText(tmp); 158 qce.transFee->setText(tmp);
154 } 159 }
155 } 160 }
156 } 161 }
157 if (qce.transAmount->text().contains('.') == 0) 162 if (qce.transAmount->text().contains('.') == 0)
158 { 163 {
159 QString text = qce.transAmount->text(); 164 QString text = qce.transAmount->text();
160 text.append(".00"); 165 text.append(".00");
161 qce.transAmount->setText(text); 166 qce.transAmount->setText(text);
162 } else { 167 } else {
163 QString tmp = qce.transAmount->text(); 168 QString tmp = qce.transAmount->text();
164 if (tmp.mid(tmp.find('.'), tmp.length()).length() == 1) 169 if (tmp.mid(tmp.find('.'), tmp.length()).length() == 1)
165 { 170 {
166 tmp.append("00"); 171 tmp.append("00");
167 qce.transAmount->setText(tmp); 172 qce.transAmount->setText(tmp);
168 } else { 173 } else {
169 if (tmp.mid(tmp.find('.'), tmp.length()).length() == 2) 174 if (tmp.mid(tmp.find('.'), tmp.length()).length() == 2)
170 { 175 {
171 tmp.append("0"); 176 tmp.append("0");
172 qce.transAmount->setText(tmp); 177 qce.transAmount->setText(tmp);
173 } 178 }
174 } 179 }
175 } 180 }
176 181
177 QString recent; 182 QString recent;
178 if (qce.descriptionCombo->count() != 0) 183 if (qce.descriptionCombo->count() != 0)
179 { 184 {
180 QStringList recentlist = QStringList::split(',', originaldata[9], false); 185 QStringList recentlist = QStringList::split(',', originaldata[9], false);
181 if (recentlist.count() >= 10) 186 if (recentlist.count() >= 10)
182 { 187 {
183 recentlist.remove(recentlist.last()); 188 recentlist.remove(recentlist.last());
184 } 189 }
185 recentlist.prepend(qce.descriptionCombo->lineEdit()->text()); 190 recentlist.prepend(qce.descriptionCombo->lineEdit()->text());
186 recent = recentlist.join(","); 191 recent = recentlist.join(",");
187 } else { 192 } else {
188 recent = qce.descriptionCombo->lineEdit()->text(); 193 recent = qce.descriptionCombo->lineEdit()->text();
189 } 194 }
190 195
191 QString checkNumberString = qce.checkNumber->text(); 196 QString checkNumberString = qce.checkNumber->text();
192 if (checkNumberString.isEmpty() == true) 197 if (checkNumberString.isEmpty() == true)
193 { 198 {
194 checkNumberString = "0"; 199 checkNumberString = "0";
195 } 200 }
196 201
197 QString paymentChecked = "true"; 202 QString paymentChecked = "true";
198 if (qce.payment->isChecked() == false) 203 if (qce.payment->isChecked() == false)
199 { 204 {
200 paymentChecked = "false"; 205 paymentChecked = "false";
201 } 206 }
202 QStringList returnvalue; 207 QStringList returnvalue;
203 returnvalue << paymentChecked << qce.descriptionCombo->lineEdit()->text() << qce.cmbCategory->lineEdit()->text() << QString::number(qce.transType->currentItem()) << checkNumberString << qce.transAmount->text() << qce.transFee->text() << qce.dateEdit->text() << qce.additionalNotes->text() << recent; 208 returnvalue << paymentChecked << qce.descriptionCombo->lineEdit()->text() << qce.cmbCategory->lineEdit()->text() << QString::number(qce.transType->currentItem()) << checkNumberString << qce.transAmount->text() << qce.transFee->text() << qce.dateEdit->text() << qce.additionalNotes->text() << recent;
204 return returnvalue; 209 return returnvalue;
205 } else { 210 } else {
206 QStringList blank; 211 QStringList blank;
207 return blank; 212 return blank;
208 } 213 }
209} 214}
210 215
211void QCheckEntry::transFeeChanged(const QString &input) 216void QCheckEntry::transFeeChanged(const QString &input)
212{ 217{
213 QString tmpinput = input; 218 QString tmpinput = input;
214 if (tmpinput.contains('.') > 1) 219 if (tmpinput.contains('.') > 1)
215 { 220 {
216 int first = tmpinput.find('.'); 221 int first = tmpinput.find('.');
217 tmpinput = tmpinput.remove(tmpinput.find('.', (first + 1)), 1); 222 tmpinput = tmpinput.remove(tmpinput.find('.', (first + 1)), 1);
218 } 223 }
219 if (tmpinput.contains(QRegExp("\\.[0-9][0-9]{2}$")) >= 1) 224 if (tmpinput.contains(QRegExp("\\.[0-9][0-9]{2}$")) >= 1)
220 { 225 {
221 tmpinput = tmpinput.remove((tmpinput.length() - 1), 1); 226 tmpinput = tmpinput.remove((tmpinput.length() - 1), 1);
222 } 227 }
223 transFee->setText(tmpinput); 228 transFee->setText(tmpinput);
224} 229}
225 230
226void QCheckEntry::amountChanged(const QString &input) 231void QCheckEntry::amountChanged(const QString &input)
227{ 232{
228 QString tmpinput = input; 233 QString tmpinput = input;
229 if (tmpinput.contains('.') > 1) 234 if (tmpinput.contains('.') > 1)
230 { 235 {
231 int first = tmpinput.find('.'); 236 int first = tmpinput.find('.');
232 tmpinput = tmpinput.remove(tmpinput.find('.', (first + 1)), 1); 237 tmpinput = tmpinput.remove(tmpinput.find('.', (first + 1)), 1);
233 } 238 }
234 if (tmpinput.contains(QRegExp("\\.[0-9][0-9]{2}$")) >= 1) 239 if (tmpinput.contains(QRegExp("\\.[0-9][0-9]{2}$")) >= 1)
235 { 240 {
236 tmpinput = tmpinput.remove((tmpinput.length() - 1), 1); 241 tmpinput = tmpinput.remove((tmpinput.length() - 1), 1);
237 } 242 }
238 transAmount->setText(tmpinput); 243 transAmount->setText(tmpinput);
239} 244}
240 245
241void QCheckEntry::accept() 246void QCheckEntry::accept()
242{ 247{
243 // Does the description combo not have any text in it? Do something if it doesn't! 248 // Does the description combo not have any text in it? Do something if it doesn't!
244 if (descriptionCombo->lineEdit()->text().isEmpty() == true) 249 if (descriptionCombo->lineEdit()->text().isEmpty() == true)
245 { 250 {
246 QMessageBox::critical(this, "Field Missing.", "<qt>You didn't enter a description for this transaction. Please fill out the \"Transaction Description\" field and try again.</qt>"); 251 QMessageBox::critical(this, "Field Missing.", "<qt>You didn't enter a description for this transaction. Please fill out the \"Transaction Description\" field and try again.</qt>");
247 descriptionCombo->setFocus(); 252 descriptionCombo->setFocus();
248 return; 253 return;
249 } 254 }
250 QDialog::accept(); 255 QDialog::accept();
251} 256}
diff --git a/noncore/apps/checkbook/qcheckentrybase.ui b/noncore/apps/checkbook/qcheckentrybase.ui
index a57d761..efc35ff 100644
--- a/noncore/apps/checkbook/qcheckentrybase.ui
+++ b/noncore/apps/checkbook/qcheckentrybase.ui
@@ -11,7 +11,7 @@
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>228</width> 14 <width>224</width>
15 <height>291</height> 15 <height>291</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
@@ -600,4 +600,11 @@
600 <data format="XPM.GZ" length="649">789c6dd23b0ec2300c00d03da7b0e22d42e9476c88232031222186c80c3074813220c4dd214dddd84dac0e759fe2386e1a07a7e3015c639e6318ef04740b0f70d7d730bccf97fdc7d8be87f8406737c62210606869dbb531f531a57f4a299d03a7e06c11cca1055508412c2889acc2ef425423b34840a645f28244936860d2c265d7923bae8b2f05cb35a91739002d2b5727d535cbe954a43ad1e22f700755caf7407cf4799fe286c47dbe3bf303014167a2</data> 600 <data format="XPM.GZ" length="649">789c6dd23b0ec2300c00d03da7b0e22d42e9476c88232031222186c80c3074813220c4dd214dddd84dac0e759fe2386e1a07a7e3015c639e6318ef04740b0f70d7d730bccf97fdc7d8be87f8406737c62210606869dbb531f531a57f4a299d03a7e06c11cca1055508412c2889acc2ef425423b34840a645f28244936860d2c265d7923bae8b2f05cb35a91739002d2b5727d535cbe954a43ad1e22f700755caf7407cf4799fe286c47dbe3bf303014167a2</data>
601 </image> 601 </image>
602</images> 602</images>
603<tabstops>
604 <tabstop>payment</tabstop>
605 <tabstop>descriptionCombo</tabstop>
606 <tabstop>cmbCategory</tabstop>
607 <tabstop>transType</tabstop>
608 <tabstop>additionalNotes</tabstop>
609</tabstops>
603</UI> 610</UI>