author | allenforsythe <allenforsythe> | 2003-05-04 22:02:48 (UTC) |
---|---|---|
committer | allenforsythe <allenforsythe> | 2003-05-04 22:02:48 (UTC) |
commit | 4593e3cf4eca4867e34b3220007c24523cf642b6 (patch) (side-by-side diff) | |
tree | bd8071834dec2a5008b1b270c7953f5cfd65754d /noncore/apps/qashmoney/datepicker.cpp | |
parent | 2894d0b14c0b3efa3ce259214b5aa597a6abfed1 (diff) | |
download | opie-4593e3cf4eca4867e34b3220007c24523cf642b6.zip opie-4593e3cf4eca4867e34b3220007c24523cf642b6.tar.gz opie-4593e3cf4eca4867e34b3220007c24523cf642b6.tar.bz2 |
Initial revision
Diffstat (limited to 'noncore/apps/qashmoney/datepicker.cpp') (more/less context) (show whitespace changes)
-rwxr-xr-x | noncore/apps/qashmoney/datepicker.cpp | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/noncore/apps/qashmoney/datepicker.cpp b/noncore/apps/qashmoney/datepicker.cpp new file mode 100755 index 0000000..02fbcf3 --- a/dev/null +++ b/noncore/apps/qashmoney/datepicker.cpp @@ -0,0 +1,95 @@ +#include "datepicker.h" + +DatePicker::DatePicker ( QDate entrydate ) : QDialog ( 0, 0, TRUE ) + { + setCaption ( "Select Date" ); + date = entrydate; + day = date.day(); + month = date.month(); + year = date.year(); + + daylabel = new QLabel ( "Day", this ); + monthlabel = new QLabel ( "Month", this ); + yearlabel = new QLabel ( "Year", this ); + + daybox = new QComboBox ( this, "daybox" ); + connect ( daybox, SIGNAL ( activated ( int ) ), this, SLOT ( setDay ( int ) ) ); + displayDays ( daybox ); + monthbox = new QComboBox ( this, "monthbox" ); + connect ( monthbox, SIGNAL ( activated ( int ) ), this, SLOT ( setMonth ( int ) ) ); + displayMonths ( monthbox ); + yearbox = new QComboBox ( this, "yearbox" ); + connect ( yearbox, SIGNAL ( activated ( int ) ), this, SLOT ( setYear ( int ) ) ); + displayYears ( yearbox ); + + layout = new QGridLayout ( this, 2, 3, 5, 5, "datepickerlayout" ); + layout->addWidget ( daylabel, 0, 2 ); + layout->addWidget ( monthlabel, 0, 1 ); + layout->addWidget ( yearlabel, 0, 0 ); + layout->addWidget ( daybox, 1, 2 ); + layout->addWidget ( monthbox, 1, 1 ); + layout->addWidget ( yearbox, 1, 0 ); + } + +void DatePicker::displayDays ( QComboBox *daybox ) + { + int counter; + int days = date.daysInMonth(); + for ( counter = 1; counter <= days; counter++ ) + daybox->insertItem ( QString::number ( counter ) ); + daybox->setCurrentItem ( ( date.day() ) - 1 ); + } + +void DatePicker::displayMonths ( QComboBox *monthbox ) + { + int counter; + for ( counter = 1; counter <= 12; counter++ ) + monthbox->insertItem ( QString::number ( counter ) ); + monthbox->setCurrentItem ( ( date.month() ) - 1 ); + } + +void DatePicker::displayYears ( QComboBox *yearbox ) + { + int counter; + int indexcounter = 0; + int yearindex = 0; + int year = date.year(); + for ( counter = ( year - 1 ); counter <= ( year + 1 ); counter++ ) + { + yearbox->insertItem ( QString::number ( counter ) ); + if ( date.year() == counter ) + yearindex = indexcounter; + indexcounter ++; + } + yearbox->setCurrentItem ( yearindex ); + } + +void DatePicker::setDay ( int index ) + { + day = daybox->text ( index ).toInt(); + } + +void DatePicker::setMonth ( int index ) + { + month = monthbox->text( index ).toInt(); + } + +void DatePicker::setYear ( int index ) + { + year = yearbox->text ( index ).toInt(); + } + +int DatePicker::getDay () + { return day; } + +int DatePicker::getMonth () + { return month; } + +int DatePicker::getYear () + { return year; } + + + + + + |