Diffstat (limited to 'noncore/apps/qashmoney/transferdialog.cpp') (more/less context) (ignore whitespace changes)
-rwxr-xr-x | noncore/apps/qashmoney/transferdialog.cpp | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/noncore/apps/qashmoney/transferdialog.cpp b/noncore/apps/qashmoney/transferdialog.cpp new file mode 100755 index 0000000..7bc3eb0 --- a/dev/null +++ b/noncore/apps/qashmoney/transferdialog.cpp | |||
@@ -0,0 +1,114 @@ | |||
1 | #include "transferdialog.h" | ||
2 | #include "datepicker.h" | ||
3 | #include "calculator.h" | ||
4 | |||
5 | #include <qdatetime.h> | ||
6 | #include <qfont.h> | ||
7 | |||
8 | extern Preferences *preferences; | ||
9 | extern Account *account; | ||
10 | |||
11 | TransferDialog::TransferDialog ( QWidget *parent, int fromaccountid, int toaccountid ) : QDialog ( parent, 0, TRUE ) | ||
12 | { | ||
13 | dateedited = FALSE; | ||
14 | setCaption ( "Transfer" ); | ||
15 | |||
16 | fromaccountlabel = new QLabel ( "From account:", this ); | ||
17 | QFont f = this->font(); | ||
18 | f.setWeight ( QFont::Bold ); | ||
19 | fromaccountlabel->setFont ( f ); | ||
20 | fromaccount = new QLabel ( account->getAccountName ( fromaccountid ), this ); | ||
21 | |||
22 | toaccountlabel = new QLabel ( "To Account:", this ); | ||
23 | toaccountlabel->setFont ( f ); | ||
24 | toaccount = new QLabel ( account->getAccountName ( toaccountid ), this ); | ||
25 | |||
26 | datelabel = new QLabel ( "Date", this ); | ||
27 | |||
28 | datebox = new QHBox ( this ); | ||
29 | datebox->setSpacing ( 2 ); | ||
30 | date = new QLineEdit ( datebox ); | ||
31 | date->setAlignment ( Qt::AlignRight ); | ||
32 | date->setDisabled ( TRUE ); | ||
33 | datebutton = new QPushButton ( datebox ); | ||
34 | datebutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/date.png" ) ); | ||
35 | connect ( datebutton, SIGNAL ( released () ), this, SLOT ( showCalendar () ) ); | ||
36 | |||
37 | amounttlabel = new QLabel ( "Amount", this ); | ||
38 | |||
39 | amountbox = new QHBox ( this ); | ||
40 | amountbox->setSpacing ( 2 ); | ||
41 | amount = new QLineEdit ( amountbox ); | ||
42 | amount->setAlignment ( Qt::AlignRight ); | ||
43 | calculatorbutton = new QPushButton( amountbox ); | ||
44 | calculatorbutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/kcalc.png" ) ); | ||
45 | connect ( calculatorbutton, SIGNAL ( released() ), this, SLOT ( showCalculator() ) ); | ||
46 | |||
47 | clearedcheckbox = new QCheckBox ( "Cleared", this ); | ||
48 | |||
49 | layout = new QVBoxLayout ( this, 4, 2 ); | ||
50 | layout->addWidget ( fromaccountlabel, Qt::AlignLeft ); | ||
51 | layout->addWidget ( fromaccount, Qt::AlignLeft ); | ||
52 | layout->addWidget ( toaccountlabel, Qt::AlignLeft ); | ||
53 | layout->addWidget ( toaccount, Qt::AlignLeft ); | ||
54 | layout->addSpacing ( 5 ); | ||
55 | layout->addWidget ( datelabel, Qt::AlignLeft ); | ||
56 | layout->addWidget ( datebox, Qt::AlignLeft ); | ||
57 | layout->addWidget ( amounttlabel, Qt::AlignLeft ); | ||
58 | layout->addWidget ( amountbox, Qt::AlignLeft ); | ||
59 | layout->addWidget ( clearedcheckbox, Qt::AlignLeft ); | ||
60 | } | ||
61 | |||
62 | bool TransferDialog::getDateEdited () | ||
63 | { | ||
64 | return dateedited; | ||
65 | } | ||
66 | |||
67 | void TransferDialog::showCalendar () | ||
68 | { | ||
69 | QDate newDate = QDate::currentDate (); | ||
70 | DatePicker *dp = new DatePicker ( newDate ); | ||
71 | if ( dp->exec () == QDialog::Accepted ) | ||
72 | { | ||
73 | // Set date integers | ||
74 | year = dp->getYear(); | ||
75 | month = dp->getMonth(); | ||
76 | day = dp->getDay(); | ||
77 | |||
78 | // Set dateedited to TRUE | ||
79 | // This tells the accountdisplay object that the user edited an account | ||
80 | // and did change the date | ||
81 | dateedited = TRUE; | ||
82 | |||
83 | // Display date with our selected format | ||
84 | date->setText ( preferences->getDate ( year, month, day ) ); | ||
85 | } | ||
86 | } | ||
87 | |||
88 | int TransferDialog::getDay () | ||
89 | { | ||
90 | return day; | ||
91 | } | ||
92 | |||
93 | int TransferDialog::getMonth () | ||
94 | { | ||
95 | return month; | ||
96 | } | ||
97 | |||
98 | int TransferDialog::getYear () | ||
99 | { | ||
100 | return day; | ||
101 | } | ||
102 | |||
103 | void TransferDialog::showCalculator () | ||
104 | { | ||
105 | Calculator *calculator = new Calculator ( this ); | ||
106 | if ( calculator->exec () == QDialog::Accepted ) | ||
107 | amount->setText ( calculator->display->text() ); | ||
108 | } | ||
109 | |||
110 | |||
111 | |||
112 | |||
113 | |||
114 | |||