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