summaryrefslogtreecommitdiff
path: root/noncore/apps/qashmoney/newaccount.cpp
Unidiff
Diffstat (limited to 'noncore/apps/qashmoney/newaccount.cpp') (more/less context) (ignore whitespace changes)
-rwxr-xr-xnoncore/apps/qashmoney/newaccount.cpp209
1 files changed, 209 insertions, 0 deletions
diff --git a/noncore/apps/qashmoney/newaccount.cpp b/noncore/apps/qashmoney/newaccount.cpp
new file mode 100755
index 0000000..2ad8f60
--- a/dev/null
+++ b/noncore/apps/qashmoney/newaccount.cpp
@@ -0,0 +1,209 @@
1#include "newaccount.h"
2#include "calculator.h"
3#include "datepicker.h"
4#include "transaction.h"
5#include "preferences.h"
6#include <qdatetime.h>
7#include <qmultilineedit.h>
8
9extern Preferences *preferences;
10
11NewAccount::NewAccount ( QWidget *parent, const char *name, bool modal ) : QDialog ( parent, name, modal )
12 {
13 accountdescription = "";
14 dateedited = FALSE;
15 setCaption( tr( "Account" ) );
16
17 namelabel = new QLabel ( "Account Name", this );
18
19 accountbox = new QHBox ( this );
20 accountname = new QLineEdit ( accountbox );
21 descriptionbutton = new QPushButton ( accountbox );
22 descriptionbutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/info.png" ) );
23
24 datelabel = new QLabel ( "Date", this );
25
26 datebox = new QHBox ( this );
27 startdate = new QLineEdit ( datebox );
28 startdate->setDisabled ( TRUE );
29 datebutton = new QPushButton ( datebox );
30 datebutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/date.png" ) );
31
32 childcheckbox = new QCheckBox ( this );
33 childcheckbox->setText( tr ( "Child Account" ) );
34
35 childlabel = new QLabel ( "Child of", this );
36 childbox = new QComboBox ( FALSE, this );
37 hideChildPulldownMenu ();
38
39 balancelabel = new QLabel ( "Balance", this );
40
41 balancebox = new QHBox ( this );
42 accountbalance = new QLineEdit ( balancebox );
43 accountbalance->setText ( "0.00" );
44 balancecalculator = new QPushButton( balancebox );
45 balancecalculator->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/kcalc.png" ) );
46
47 creditlimitlabel = new QLabel ( "Credit Limit", this );
48
49 creditlimitbox = new QHBox ( this );
50 creditlimit = new QLineEdit ( creditlimitbox );
51 creditlimitbox->setEnabled ( FALSE );
52 creditlimitcalculator = new QPushButton( creditlimitbox );
53 creditlimitcalculator->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/kcalc.png" ) );
54
55 currencybox = new Currency ( this );
56
57 typelabel = new QLabel ( "Type", this );
58 accounttype = new QComboBox ( FALSE, this );
59 accounttype->insertItem( tr( "Bank" ) );
60 accounttype->insertItem( tr( "Cash" ) );
61 accounttype->insertItem( tr( "Credit Card" ) );
62 accounttype->insertItem( tr( "Equity" ) );
63 accounttype->insertItem( tr( "Asset" ) );
64 accounttype->insertItem( tr( "Liability" ) );
65
66 layout = new QGridLayout ( this, 7, 2, 4, 2 );
67 layout->addWidget ( namelabel , 0, 0, Qt::AlignLeft );
68 layout->addWidget ( accountbox, 1, 0, Qt::AlignLeft );
69 layout->addWidget ( datelabel, 2, 0, Qt::AlignLeft );
70 layout->addWidget ( datebox, 3, 0, Qt::AlignLeft );
71 layout->addWidget ( childcheckbox, 4, 0, Qt::AlignLeft );
72 layout->addWidget ( childlabel, 5, 0, Qt::AlignLeft );
73 layout->addWidget ( childbox, 6, 0, Qt::AlignLeft );
74 layout->addWidget ( balancelabel, 0, 1, Qt::AlignLeft );
75 layout->addWidget ( balancebox, 1, 1, Qt::AlignLeft );
76 layout->addWidget ( creditlimitlabel, 2, 1, Qt::AlignLeft );
77 layout->addWidget ( creditlimitbox, 3, 1, Qt::AlignLeft );
78 layout->addWidget ( currencybox, 4, 1, Qt::AlignLeft );
79 layout->addWidget ( typelabel, 5, 1, Qt::AlignLeft );
80 layout->addWidget ( accounttype, 6, 1, Qt::AlignLeft );
81
82 connect ( childcheckbox, SIGNAL ( clicked () ), this, SLOT ( showChildPulldownMenu() ) );
83 connect ( balancecalculator, SIGNAL ( released() ), this, SLOT ( showCalculator() ) );
84 connect ( creditlimitcalculator, SIGNAL ( released() ), this, SLOT ( showCreditLimitCalculator() ) );
85 connect ( accounttype, SIGNAL ( activated ( int ) ), this, SLOT ( activateCreditLimit ( int ) ) );
86 connect ( datebutton, SIGNAL ( released () ), this, SLOT ( showCalendar () ) );
87 connect ( descriptionbutton, SIGNAL ( released () ), this, SLOT ( addAccountDescription() ) );
88}
89
90NewAccount::~NewAccount ()
91 {
92 }
93
94void NewAccount::showChildPulldownMenu ()
95 {
96 if ( childcheckbox->isChecked() == TRUE )
97 {
98 childlabel->setEnabled ( TRUE );
99 childbox->setEnabled ( TRUE );
100 }
101 else
102 hideChildPulldownMenu();
103 }
104
105void NewAccount::hideChildPulldownMenu ()
106 {
107 childlabel->setEnabled ( FALSE );
108 childbox->setEnabled ( FALSE );
109 }
110
111void NewAccount::showCalculator ()
112 {
113 Calculator *calculator = new Calculator ( this );
114 calculator->setMaximumWidth ( ( int ) ( this->size().width() * 0.9 ) );
115 if ( calculator->exec () == QDialog::Accepted )
116 accountbalance->setText ( calculator->display->text() );
117 }
118
119void NewAccount::showCreditLimitCalculator ()
120 {
121 Calculator *calculator = new Calculator ( this );
122 calculator->setMaximumWidth ( ( int ) ( this->size().width() * 0.9 ) );
123 if ( calculator->exec () == QDialog::Accepted )
124 creditlimit->setText ( calculator->display->text() );
125 }
126
127void NewAccount::activateCreditLimit ( int index )
128 {
129 if ( index == 2 || index == 5 )
130 creditlimitbox->setEnabled ( TRUE );
131 else
132 {
133 creditlimit->clear ();
134 creditlimitbox->setEnabled ( FALSE );
135 }
136 }
137
138void NewAccount::showCalendar ()
139 {
140 QDate newDate = QDate::currentDate ();
141 DatePicker *dp = new DatePicker ( newDate );
142 dp->setMaximumWidth ( ( int ) ( this->size().width() * 0.9 ) );
143
144 int response = dp->exec();
145 if ( response == QDialog::Accepted )
146 {
147 // Set date integers
148 year = dp->getYear();
149 month = dp->getMonth();
150 day = dp->getDay();
151
152 // Set dateedited to TRUE
153 // This tells the accountdisplay object that the user edited an account
154 // and did change the date
155 dateedited = TRUE;
156
157 // Display date with our selected format
158 startdate->setText ( preferences->getDate ( year, month, day ) );
159 }
160 }
161
162bool NewAccount::getDateEdited ()
163 {
164 return dateedited;
165 }
166
167int NewAccount::getDay ()
168 {
169 return day;
170 }
171
172int NewAccount::getMonth ()
173 {
174 return month;
175 }
176
177int NewAccount::getYear ()
178 {
179 return year;
180 }
181
182QString NewAccount::getDescription ()
183 {
184 return accountdescription;
185 }
186
187void NewAccount::setDescription ( QString description )
188 {
189 accountdescription = description;
190 }
191
192void NewAccount::addAccountDescription ()
193 {
194 // Function for adding or editing an account description.
195 QDialog *description = new QDialog ( this, "description", TRUE );
196 description->setCaption ( "Notes" );
197 QMultiLineEdit *enter = new QMultiLineEdit ( description );
198 enter->setFixedSize ( ( int ) (this->width() * 0.75 ), ( int ) ( this->height() * 0.5 ) );
199 enter->setWrapColumnOrWidth ( ( int ) (this->width() * 0.75 ) );
200 enter->setWordWrap ( QMultiLineEdit::WidgetWidth );
201 if ( accountdescription != "(NULL)" )
202 enter->setText ( accountdescription );
203 if ( description->exec () == QDialog::Accepted )
204 accountdescription = enter->text ();
205 }
206
207
208
209