summaryrefslogtreecommitdiff
path: root/noncore/unsupported/qashmoney/datepicker.cpp
Unidiff
Diffstat (limited to 'noncore/unsupported/qashmoney/datepicker.cpp') (more/less context) (ignore whitespace changes)
-rwxr-xr-xnoncore/unsupported/qashmoney/datepicker.cpp95
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
3DatePicker::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
34void 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
43void 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
51void 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
67void DatePicker::setDay ( int index )
68 {
69 day = daybox->text ( index ).toInt();
70 }
71
72void DatePicker::setMonth ( int index )
73 {
74 month = monthbox->text( index ).toInt();
75 }
76
77void DatePicker::setYear ( int index )
78 {
79 year = yearbox->text ( index ).toInt();
80 }
81
82int DatePicker::getDay ()
83 { return day; }
84
85int DatePicker::getMonth ()
86 { return month; }
87
88int DatePicker::getYear ()
89 { return year; }
90
91
92
93
94
95