]> ToastFreeware Gitweb - toast/confclerk.git/blobdiff - src/gui/daynavigatorwidget.cpp
Add .pro.user.* to svn:ignore and remove it in the release target.
[toast/confclerk.git] / src / gui / daynavigatorwidget.cpp
index f8674af60234d48ae134c1c90e4000ee33215eb6..3e6a033930d69d7ff4ebb11956bda208f6153017 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2010 Ixonos Plc.
- * Copyright (C) 2011 Philipp Spitzer, gregor herrmann
+ * Copyright (C) 2011-2012 Philipp Spitzer, gregor herrmann, Stefan Stahl
  *
  * This file is part of ConfClerk.
  *
@@ -28,7 +28,8 @@ DayNavigatorWidget::DayNavigatorWidget(QWidget *aParent): QWidget(aParent) {
 
     connect(prevDayButton, SIGNAL(clicked()), SLOT(prevDayButtonClicked()));
     connect(nextDayButton, SIGNAL(clicked()), SLOT(nextDayButtonClicked()));
-    connect(todayButton, SIGNAL(clicked()), SLOT(todayButtonClicked()));
+
+    configureNavigation();
 }
 
 
@@ -69,9 +70,20 @@ void DayNavigatorWidget::setCurDate(const QDate& curDate) {
 }
 
 
+void DayNavigatorWidget::unsetDates() {
+    mStartDate= QDate();
+    mEndDate = QDate();
+    mCurDate = QDate();
+
+    configureNavigation();
+    emit(dateChanged(mCurDate));
+    this->update();
+}
+
+
 void DayNavigatorWidget::configureNavigation() {
-    prevDayButton->setDisabled(mCurDate == mStartDate);
-    nextDayButton->setDisabled(mCurDate == mEndDate);
+    prevDayButton->setDisabled(!mStartDate.isValid() || mCurDate == mStartDate);
+    nextDayButton->setDisabled(!mEndDate.isValid() || mCurDate == mEndDate);
 }
 
 
@@ -93,27 +105,15 @@ void DayNavigatorWidget::nextDayButtonClicked() {
 }
 
 
-void DayNavigatorWidget::todayButtonClicked() {
-    setCurDate(QDate::currentDate());
-}
-
-
-void DayNavigatorWidget::paintEvent(QPaintEvent *aEvent)
-{
+void DayNavigatorWidget::paintEvent(QPaintEvent *aEvent) {
     Q_UNUSED(aEvent);
 
-    QString selectedDateStr = mCurDate.toString("dddd\nyyyy-MM-dd");
+    QString selectedDateStr = mCurDate.isValid() ? mCurDate.toString("dddd\nyyyy-MM-dd") : tr("No date");
     QPainter painter(this);
     painter.save();
 
     // rectangle only for the text
-    int marginSize = 9;
-    int buttonSize = 32;
-#ifdef MAEMO
-    QRect q(y()-height()+1*marginSize+2.5*buttonSize, x(), height()-2*marginSize-2.5*buttonSize, width());
-#else
-    QRect q(y()-height()+1*marginSize+2*buttonSize, x(), height()-2*marginSize-3*buttonSize, width());
-#endif
+    QRect q(-selectedDate->height()-selectedDate->y(), selectedDate->x(), selectedDate->height(), selectedDate->width());
     painter.rotate(270);
 
     // font size adjustion, static on maemo, dynamically otherwise