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