/*
* 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.
*
connect(prevDayButton, SIGNAL(clicked()), SLOT(prevDayButtonClicked()));
connect(nextDayButton, SIGNAL(clicked()), SLOT(nextDayButtonClicked()));
- connect(todayButton, SIGNAL(clicked()), SLOT(todayButtonClicked()));
+
+ configureNavigation();
}
}
+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);
}
}
-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