summaryrefslogtreecommitdiffabout
path: root/libkdepim/kdatepicker.cpp
Side-by-side diff
Diffstat (limited to 'libkdepim/kdatepicker.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libkdepim/kdatepicker.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/libkdepim/kdatepicker.cpp b/libkdepim/kdatepicker.cpp
index c13734f..77793c4 100644
--- a/libkdepim/kdatepicker.cpp
+++ b/libkdepim/kdatepicker.cpp
@@ -47,6 +47,7 @@ KDatePicker::KDatePicker(QWidget *parent, QDate dt, const char *name)
monthBackward(new QToolButton(this)),
selectMonth(new QToolButton(this)),
selectYear(new QToolButton(this)),
+ todayBut(new QToolButton(this)),
//line(new QLineEdit(this)),
val(new KDateValidator(this))
//table(new KDateTable(this)),
@@ -66,6 +67,7 @@ KDatePicker::KDatePicker(QWidget *parent, QDate dt, const char *name)
yearBackward->setPixmap(SmallIcon("2leftarrowB"));
monthForward->setPixmap(SmallIcon("1rightarrowB"));
monthBackward->setPixmap(SmallIcon("1leftarrowB"));
+ todayBut->setPixmap(SmallIcon("today"));
setDate(dt); // set button texts
connect(table, SIGNAL(dateChanged(QDate)), SLOT(dateChangedSlot(QDate)));
connect(table, SIGNAL(tableClicked()), SLOT(tableClickedSlot()));
@@ -75,6 +77,7 @@ KDatePicker::KDatePicker(QWidget *parent, QDate dt, const char *name)
connect(yearBackward, SIGNAL(clicked()), SLOT(yearBackwardClicked()));
connect(selectMonth, SIGNAL(clicked()), SLOT(selectMonthClicked()));
connect(selectYear, SIGNAL(clicked()), SLOT(selectYearClicked()));
+ connect(todayBut, SIGNAL(clicked()), SLOT(goToday()));
//connect(line, SIGNAL(returnPressed()), SLOT(lineEnterPressed()));
connect(lineDate, SIGNAL(dateChanged(QDate)), SLOT(slotSetDate(QDate)));
connect(lineDate, SIGNAL(returnPressed()), SLOT(lineEnterPressed()));
@@ -136,7 +139,9 @@ KDatePicker::resizeEvent(QResizeEvent*)
// ----- place the line edit for direct input:
sizes[0]=lineDate->sizeHint();
//line->setGeometry(0, height()-sizes[0].height(), width(), sizes[0].height());
- lineDate->setGeometry(0, height()-sizes[0].height(), width(), sizes[0].height());
+ int todaywid = todayBut->sizeHint().width();
+todayBut->setGeometry(0, height()-sizes[0].height(),todaywid, sizes[0].height());
+ lineDate->setGeometry(0+todaywid, height()-sizes[0].height(), width()-todaywid, sizes[0].height());
// ----- adjust the table:
table->setGeometry(0, buttonHeight, width(),
height()-buttonHeight-sizes[0].height());
@@ -170,6 +175,11 @@ KDatePicker::date() const
return table->getDate();
}
+void KDatePicker::goToday()
+{
+ slotSetDate( QDate::currentDate() );
+
+}
void KDatePicker::slotSetDate( QDate date )
{