From: pavelpa Date: Fri, 22 Jan 2010 12:31:10 +0000 (+0000) Subject: day navigator widget changes X-Git-Tag: 0.5.0~211 X-Git-Url: https://git.toastfreeware.priv.at/toast/confclerk.git/commitdiff_plain/5992909c0c44890e77dd274542014af7e2a543a2 day navigator widget changes - changed from Horizontal to Vertical --- diff --git a/src/gui/daynavigatorwidget.cpp b/src/gui/daynavigatorwidget.cpp index 5c7b8d0..c554c1d 100644 --- a/src/gui/daynavigatorwidget.cpp +++ b/src/gui/daynavigatorwidget.cpp @@ -1,5 +1,9 @@ #include "daynavigatorwidget.h" +#include +#include +#include + #include DayNavigatorWidget::DayNavigatorWidget(QWidget *aParent) @@ -11,6 +15,8 @@ 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) @@ -22,7 +28,9 @@ void DayNavigatorWidget::setDates(const QDate &aStartDate, const QDate &aEndDate mEndDate = aEndDate; mCurDate = aStartDate; - currentDateLabel->setText(mCurDate.toString()); + QRect rect = mFontMetrics->boundingRect(mCurDate.toString("MMM dd yyyy")); + qDebug() << mCurDate.toString(); + if(mStartDate==mEndDate) // only one day conference { prevDayButton->setDisabled(true); @@ -44,7 +52,6 @@ void DayNavigatorWidget::prevDayButtonClicked() if(mCurDate>mStartDate) { mCurDate = mCurDate.addDays(-1); - currentDateLabel->setText(mCurDate.toString()); // check start date if(mCurDate==mStartDate || mStartDate==mEndDate) prevDayButton->setDisabled(true); @@ -57,6 +64,7 @@ void DayNavigatorWidget::prevDayButtonClicked() nextDayButton->setDisabled(false); emit(dateChanged(mCurDate)); + selectedDate->update(); } } @@ -66,7 +74,6 @@ void DayNavigatorWidget::nextDayButtonClicked() if(mCurDatesetText(mCurDate.toString()); // check start date if(mCurDate==mStartDate || mStartDate==mEndDate) prevDayButton->setDisabled(true); @@ -79,6 +86,7 @@ void DayNavigatorWidget::nextDayButtonClicked() nextDayButton->setDisabled(false); emit(dateChanged(mCurDate)); + selectedDate->update(); } } @@ -87,3 +95,22 @@ QDate DayNavigatorWidget::getCurrentDate() return mCurDate; } +void DayNavigatorWidget::paintEvent(QPaintEvent *aEvent) +{ + QString selectedDateStr = mCurDate.toString("MMM dd yyyy"); + + QPainter painter(this); + painter.save(); + QRect r = selectedDate->geometry(); + QRect s = mFontMetrics->boundingRect(selectedDateStr); + QPoint p = QPoint( + r.x() + r.width()/2 - s.height()/2 - mFontMetrics->descent(), + - 130 + ); + + painter.translate(r.width()/2, r.height()/2); + painter.rotate(270); + painter.drawText(p.y(), p.x(), selectedDateStr); // y,x,string + painter.restore(); +} + diff --git a/src/gui/daynavigatorwidget.h b/src/gui/daynavigatorwidget.h index bf4b43d..a4a104d 100644 --- a/src/gui/daynavigatorwidget.h +++ b/src/gui/daynavigatorwidget.h @@ -5,6 +5,52 @@ #include #include +/*#include */ +/*#include */ + +/*class QFontMetrics;*/ + +/*class VerticalLabel : public QWidget*/ +/*{*/ + +/*public:*/ +/*VerticalLabel(QWidget *aParent = NULL)*/ +/*: QWidget(aParent)*/ +/*, mText("")*/ +/*{*/ +/*mFont = QLabel().font();*/ +/*} */ + +/*void paintEvent(QPaintEvent *)*/ +/*{ */ +/*QPainter p(this);*/ +/*drawRotatedText(&p, 270, width()/2, height()/2, mText);*/ +/*} */ + +/*void drawRotatedText(QPainter *aPainter, qreal aDegrees, int x, int y, const QString &aText)*/ +/*{ */ + +/*aPainter->save();*/ +/*aPainter->setFont(mFont);*/ +/*aPainter->translate(x, y); */ +/*aPainter->rotate(aDegrees);*/ +/*QFontMetrics fm(mFont);*/ +/*QRect r = fm.boundingRect(aText);*/ +/*aPainter->drawText(-r.width()/2, fm.descent()/2, aText);*/ +/*aPainter->restore();*/ +/*} */ + +/*void setText(const QString &aText)*/ +/*{*/ +/*mText = aText;*/ +/*update();*/ +/*}*/ + +/*private:*/ +/*QString mText;*/ +/*QFont mFont;*/ +/*};*/ + class DayNavigatorWidget : public QWidget, private Ui::DayNavigatorWidget { Q_OBJECT @@ -13,6 +59,8 @@ class DayNavigatorWidget : public QWidget, private Ui::DayNavigatorWidget ~DayNavigatorWidget() {} void setDates(const QDate &aStartDate, const QDate &aEndDate); QDate getCurrentDate(); + protected: + void paintEvent(QPaintEvent *); private slots: void prevDayButtonClicked(); void nextDayButtonClicked(); @@ -22,6 +70,7 @@ class DayNavigatorWidget : public QWidget, private Ui::DayNavigatorWidget QDate mStartDate; QDate mEndDate; QDate mCurDate; + QFontMetrics *mFontMetrics; }; #endif /* DAYNAVIGATORWIDGET_H */ diff --git a/src/gui/daynavigatorwidget.ui b/src/gui/daynavigatorwidget.ui index 9de6ba1..c5eae24 100644 --- a/src/gui/daynavigatorwidget.ui +++ b/src/gui/daynavigatorwidget.ui @@ -5,18 +5,27 @@ 0 0 - 360 - 52 + 52 + 198 + + + 0 + 0 + + Form + + Qt::LeftToRight + - - + + - + ... @@ -24,45 +33,22 @@ true - Qt::LeftArrow + Qt::UpArrow - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Currently selected date + + + + 0 + 0 + - - - Qt::Horizontal - - - - 40 - 20 - - - - - - + ... @@ -70,7 +56,7 @@ true - Qt::RightArrow + Qt::DownArrow diff --git a/src/gui/mainwindow.ui b/src/gui/mainwindow.ui index 4346117..0089627 100644 --- a/src/gui/mainwindow.ui +++ b/src/gui/mainwindow.ui @@ -33,17 +33,45 @@ - - - - - - - 16777215 - 16777215 - - - + + + + + + + true + + + H + + + true + + + + + + + + 0 + 0 + + + + + + + + + + + 16777215 + 16777215 + + + + + @@ -54,8 +82,8 @@ Favourites - - + + @@ -72,7 +100,7 @@ - + @@ -341,7 +369,7 @@ 0 0 654 - 22 + 26