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/datepicker.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/datepicker.cpp') (more/less context) (ignore whitespace changes)
-rwxr-xr-x | noncore/unsupported/qashmoney/datepicker.cpp | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/noncore/unsupported/qashmoney/datepicker.cpp b/noncore/unsupported/qashmoney/datepicker.cpp new file mode 100755 index 0000000..7997c0b --- a/dev/null +++ b/noncore/unsupported/qashmoney/datepicker.cpp | |||
@@ -0,0 +1,95 @@ | |||
1 | #include "datepicker.h" | ||
2 | |||
3 | DatePicker::DatePicker ( QDate entrydate ) : QDialog ( 0, 0, TRUE ) | ||
4 | { | ||
5 | setCaption ( "Select Date" ); | ||
6 | date = entrydate; | ||
7 | day = date.day(); | ||
8 | month = date.month(); | ||
9 | year = date.year(); | ||
10 | |||
11 | daylabel = new QLabel ( "Day", this ); | ||
12 | monthlabel = new QLabel ( "Month", this ); | ||
13 | yearlabel = new QLabel ( "Year", this ); | ||
14 | |||
15 | daybox = new QComboBox ( this, "daybox" ); | ||
16 | connect ( daybox, SIGNAL ( activated(int) ), this, SLOT ( setDay(int) ) ); | ||
17 | displayDays ( daybox ); | ||
18 | monthbox = new QComboBox ( this, "monthbox" ); | ||
19 | connect ( monthbox, SIGNAL ( activated(int) ), this, SLOT ( setMonth(int) ) ); | ||
20 | displayMonths ( monthbox ); | ||
21 | yearbox = new QComboBox ( this, "yearbox" ); | ||
22 | connect ( yearbox, SIGNAL ( activated(int) ), this, SLOT ( setYear(int) ) ); | ||
23 | displayYears ( yearbox ); | ||
24 | |||
25 | layout = new QGridLayout ( this, 2, 3, 5, 5, "datepickerlayout" ); | ||
26 | layout->addWidget ( daylabel, 0, 2 ); | ||
27 | layout->addWidget ( monthlabel, 0, 1 ); | ||
28 | layout->addWidget ( yearlabel, 0, 0 ); | ||
29 | layout->addWidget ( daybox, 1, 2 ); | ||
30 | layout->addWidget ( monthbox, 1, 1 ); | ||
31 | layout->addWidget ( yearbox, 1, 0 ); | ||
32 | } | ||
33 | |||
34 | void DatePicker::displayDays ( QComboBox *daybox ) | ||
35 | { | ||
36 | int counter; | ||
37 | int days = date.daysInMonth(); | ||
38 | for ( counter = 1; counter <= days; counter++ ) | ||
39 | daybox->insertItem ( QString::number ( counter ) ); | ||
40 | daybox->setCurrentItem ( ( date.day() ) - 1 ); | ||
41 | } | ||
42 | |||
43 | void DatePicker::displayMonths ( QComboBox *monthbox ) | ||
44 | { | ||
45 | int counter; | ||
46 | for ( counter = 1; counter <= 12; counter++ ) | ||
47 | monthbox->insertItem ( QString::number ( counter ) ); | ||
48 | monthbox->setCurrentItem ( ( date.month() ) - 1 ); | ||
49 | } | ||
50 | |||
51 | void DatePicker::displayYears ( QComboBox *yearbox ) | ||
52 | { | ||
53 | int counter; | ||
54 | int indexcounter = 0; | ||
55 | int yearindex = 0; | ||
56 | int year = date.year(); | ||
57 | for ( counter = ( year - 1 ); counter <= ( year + 1 ); counter++ ) | ||
58 | { | ||
59 | yearbox->insertItem ( QString::number ( counter ) ); | ||
60 | if ( date.year() == counter ) | ||
61 | yearindex = indexcounter; | ||
62 | indexcounter ++; | ||
63 | } | ||
64 | yearbox->setCurrentItem ( yearindex ); | ||
65 | } | ||
66 | |||
67 | void DatePicker::setDay ( int index ) | ||
68 | { | ||
69 | day = daybox->text ( index ).toInt(); | ||
70 | } | ||
71 | |||
72 | void DatePicker::setMonth ( int index ) | ||
73 | { | ||
74 | month = monthbox->text( index ).toInt(); | ||
75 | } | ||
76 | |||
77 | void DatePicker::setYear ( int index ) | ||
78 | { | ||
79 | year = yearbox->text ( index ).toInt(); | ||
80 | } | ||
81 | |||
82 | int DatePicker::getDay () | ||
83 | { return day; } | ||
84 | |||
85 | int DatePicker::getMonth () | ||
86 | { return month; } | ||
87 | |||
88 | int DatePicker::getYear () | ||
89 | { return year; } | ||
90 | |||
91 | |||
92 | |||
93 | |||
94 | |||
95 | |||