X-Git-Url: https://git.toastfreeware.priv.at/toast/confclerk.git/blobdiff_plain/f6300c7fc9947639c2b0a3ab32d420f8dc130fc1..04ea24076add77b80155cf7c91f69d73c6059264:/src/gui/daynavigatorwidget.cpp diff --git a/src/gui/daynavigatorwidget.cpp b/src/gui/daynavigatorwidget.cpp index 5c7b8d0..07d13bc 100644 --- a/src/gui/daynavigatorwidget.cpp +++ b/src/gui/daynavigatorwidget.cpp @@ -1,5 +1,28 @@ +/* + * Copyright (C) 2010 Ixonos Plc. + * Copyright (C) 2011 Philipp Spitzer, gregor herrmann + * + * This file is part of ConfClerk. + * + * ConfClerk is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 2 of the License, or (at your option) + * any later version. + * + * ConfClerk is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * ConfClerk. If not, see . + */ #include "daynavigatorwidget.h" +#include +#include +#include + #include DayNavigatorWidget::DayNavigatorWidget(QWidget *aParent) @@ -11,18 +34,20 @@ DayNavigatorWidget::DayNavigatorWidget(QWidget *aParent) setupUi(this); connect(prevDayButton, SIGNAL(clicked()), SLOT(prevDayButtonClicked())); connect(nextDayButton, SIGNAL(clicked()), SLOT(nextDayButtonClicked())); + + mFontMetrics = new QFontMetrics(QLabel().font()); } void DayNavigatorWidget::setDates(const QDate &aStartDate, const QDate &aEndDate) { Q_ASSERT(aStartDate<=aEndDate); - //qDebug() << "DayNavigatorWidget::setDates(): " << aStartDate << ", " << aEndDate; mStartDate = aStartDate; mEndDate = aEndDate; mCurDate = aStartDate; - currentDateLabel->setText(mCurDate.toString()); + // QRect rect = mFontMetrics->boundingRect(mCurDate.toString("MMM dd yyyy")); + if(mStartDate==mEndDate) // only one day conference { prevDayButton->setDisabled(true); @@ -40,11 +65,9 @@ void DayNavigatorWidget::setDates(const QDate &aStartDate, const QDate &aEndDate void DayNavigatorWidget::prevDayButtonClicked() { - //qDebug() << mStartDate << ":" << mCurDate << ":" << mEndDate; if(mCurDate>mStartDate) { mCurDate = mCurDate.addDays(-1); - currentDateLabel->setText(mCurDate.toString()); // check start date if(mCurDate==mStartDate || mStartDate==mEndDate) prevDayButton->setDisabled(true); @@ -57,16 +80,15 @@ void DayNavigatorWidget::prevDayButtonClicked() nextDayButton->setDisabled(false); emit(dateChanged(mCurDate)); + selectedDate->update(); } } void DayNavigatorWidget::nextDayButtonClicked() { - //qDebug() << mStartDate << ":" << mCurDate << ":" << mEndDate; if(mCurDatesetText(mCurDate.toString()); // check start date if(mCurDate==mStartDate || mStartDate==mEndDate) prevDayButton->setDisabled(true); @@ -79,11 +101,20 @@ void DayNavigatorWidget::nextDayButtonClicked() nextDayButton->setDisabled(false); emit(dateChanged(mCurDate)); + selectedDate->update(); } } -QDate DayNavigatorWidget::getCurrentDate() +void DayNavigatorWidget::paintEvent(QPaintEvent *aEvent) { - return mCurDate; + Q_UNUSED(aEvent); + + QString selectedDateStr = mCurDate.toString("dddd\nyyyy-MM-dd"); + QPainter painter(this); + painter.save(); + QRect q(y()-height(), x(), height(), width()); + painter.rotate(270); + painter.drawText(q, Qt::AlignCenter, selectedDateStr); + painter.restore(); }