summaryrefslogtreecommitdiffabout
path: root/libkdepim
authorzautrix <zautrix>2005-02-16 22:38:07 (UTC)
committer zautrix <zautrix>2005-02-16 22:38:07 (UTC)
commit0eca506b6b4c7d7ef52bcecc5ad64193698dc3f3 (patch) (side-by-side diff)
tree5bc6d924f1a71cc04cb8f1ee0001fce7cde0fa71 /libkdepim
parentf33a37a0f7c9b37cfea1346ed373ce1c27c1d6ba (diff)
downloadkdepimpi-0eca506b6b4c7d7ef52bcecc5ad64193698dc3f3.zip
kdepimpi-0eca506b6b4c7d7ef52bcecc5ad64193698dc3f3.tar.gz
kdepimpi-0eca506b6b4c7d7ef52bcecc5ad64193698dc3f3.tar.bz2
added today but to datepicker
Diffstat (limited to 'libkdepim') (more/less context) (show whitespace changes)
-rw-r--r--libkdepim/kdatepicker.cpp12
-rw-r--r--libkdepim/kdatepicker.h2
2 files changed, 13 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 )
{
diff --git a/libkdepim/kdatepicker.h b/libkdepim/kdatepicker.h
index 6625357..3db9a89 100644
--- a/libkdepim/kdatepicker.h
+++ b/libkdepim/kdatepicker.h
@@ -107,6 +107,7 @@ public:
protected:
/// the resize event
void resizeEvent(QResizeEvent*);
+ QToolButton *todayBut;
/// the year forward button
QToolButton *yearForward;
/// the year backward button
@@ -141,6 +142,7 @@ protected slots:
void selectYearClicked();
void lineEnterPressed();
void slotSetDate(QDate);
+ void goToday();
signals:
/** This signal is emitted each time the selected date is changed.
* Usually, this does not mean that the date has been entered,