Changeset 5992909 in confclerk_git
- Timestamp:
- 01/22/10 13:31:10 (13 years ago)
- Branches:
- master, qt5
- Children:
- 49c5ad3
- Parents:
- 806b992
- Location:
- src/gui
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/gui/daynavigatorwidget.cpp
r806b992 r5992909 1 1 #include "daynavigatorwidget.h" 2 3 #include <QPainter> 4 #include <QFontMetrics> 5 #include <QLabel> 2 6 3 7 #include <QDebug> … … 12 16 connect(prevDayButton, SIGNAL(clicked()), SLOT(prevDayButtonClicked())); 13 17 connect(nextDayButton, SIGNAL(clicked()), SLOT(nextDayButtonClicked())); 18 19 mFontMetrics = new QFontMetrics(QLabel().font()); 14 20 } 15 21 … … 23 29 mCurDate = aStartDate; 24 30 25 currentDateLabel->setText(mCurDate.toString()); 31 QRect rect = mFontMetrics->boundingRect(mCurDate.toString("MMM dd yyyy")); 32 qDebug() << mCurDate.toString(); 33 26 34 if(mStartDate==mEndDate) // only one day conference 27 35 { … … 45 53 { 46 54 mCurDate = mCurDate.addDays(-1); 47 currentDateLabel->setText(mCurDate.toString());48 55 // check start date 49 56 if(mCurDate==mStartDate || mStartDate==mEndDate) … … 58 65 59 66 emit(dateChanged(mCurDate)); 67 selectedDate->update(); 60 68 } 61 69 } … … 67 75 { 68 76 mCurDate = mCurDate.addDays(1); 69 currentDateLabel->setText(mCurDate.toString());70 77 // check start date 71 78 if(mCurDate==mStartDate || mStartDate==mEndDate) … … 80 87 81 88 emit(dateChanged(mCurDate)); 89 selectedDate->update(); 82 90 } 83 91 } … … 88 96 } 89 97 98 void DayNavigatorWidget::paintEvent(QPaintEvent *aEvent) 99 { 100 QString selectedDateStr = mCurDate.toString("MMM dd yyyy"); 101 102 QPainter painter(this); 103 painter.save(); 104 QRect r = selectedDate->geometry(); 105 QRect s = mFontMetrics->boundingRect(selectedDateStr); 106 QPoint p = QPoint( 107 r.x() + r.width()/2 - s.height()/2 - mFontMetrics->descent(), 108 - 130 109 ); 110 111 painter.translate(r.width()/2, r.height()/2); 112 painter.rotate(270); 113 painter.drawText(p.y(), p.x(), selectedDateStr); // y,x,string 114 painter.restore(); 115 } 116 -
src/gui/daynavigatorwidget.h
r806b992 r5992909 5 5 #include <QObject> 6 6 #include <QDate> 7 8 /*#include <QPainter>*/ 9 /*#include <QLabel>*/ 10 11 /*class QFontMetrics;*/ 12 13 /*class VerticalLabel : public QWidget*/ 14 /*{*/ 15 16 /*public:*/ 17 /*VerticalLabel(QWidget *aParent = NULL)*/ 18 /*: QWidget(aParent)*/ 19 /*, mText("")*/ 20 /*{*/ 21 /*mFont = QLabel().font();*/ 22 /*} */ 23 24 /*void paintEvent(QPaintEvent *)*/ 25 /*{ */ 26 /*QPainter p(this);*/ 27 /*drawRotatedText(&p, 270, width()/2, height()/2, mText);*/ 28 /*} */ 29 30 /*void drawRotatedText(QPainter *aPainter, qreal aDegrees, int x, int y, const QString &aText)*/ 31 /*{ */ 32 33 /*aPainter->save();*/ 34 /*aPainter->setFont(mFont);*/ 35 /*aPainter->translate(x, y); */ 36 /*aPainter->rotate(aDegrees);*/ 37 /*QFontMetrics fm(mFont);*/ 38 /*QRect r = fm.boundingRect(aText);*/ 39 /*aPainter->drawText(-r.width()/2, fm.descent()/2, aText);*/ 40 /*aPainter->restore();*/ 41 /*} */ 42 43 /*void setText(const QString &aText)*/ 44 /*{*/ 45 /*mText = aText;*/ 46 /*update();*/ 47 /*}*/ 48 49 /*private:*/ 50 /*QString mText;*/ 51 /*QFont mFont;*/ 52 /*};*/ 7 53 8 54 class DayNavigatorWidget : public QWidget, private Ui::DayNavigatorWidget … … 14 60 void setDates(const QDate &aStartDate, const QDate &aEndDate); 15 61 QDate getCurrentDate(); 62 protected: 63 void paintEvent(QPaintEvent *); 16 64 private slots: 17 65 void prevDayButtonClicked(); … … 23 71 QDate mEndDate; 24 72 QDate mCurDate; 73 QFontMetrics *mFontMetrics; 25 74 }; 26 75 -
src/gui/daynavigatorwidget.ui
r806b992 r5992909 6 6 <x>0</x> 7 7 <y>0</y> 8 <width> 360</width>9 <height> 52</height>8 <width>52</width> 9 <height>198</height> 10 10 </rect> 11 </property> 12 <property name="sizePolicy" > 13 <sizepolicy vsizetype="Expanding" hsizetype="Minimum" > 14 <horstretch>0</horstretch> 15 <verstretch>0</verstretch> 16 </sizepolicy> 11 17 </property> 12 18 <property name="windowTitle" > 13 19 <string>Form</string> 14 20 </property> 21 <property name="layoutDirection" > 22 <enum>Qt::LeftToRight</enum> 23 </property> 15 24 <layout class="QGridLayout" name="gridLayout" > 16 <item row="0" column="0" > 17 <layout class="QHBoxLayout" name="horizontalLayout" > 25 <item row="1" column="0" > 26 <layout class="QVBoxLayout" name="verticalLayout" > 27 <item> 28 <widget class="QToolButton" name="nextDayButton" > 29 <property name="text" > 30 <string>...</string> 31 </property> 32 <property name="autoRaise" > 33 <bool>true</bool> 34 </property> 35 <property name="arrowType" > 36 <enum>Qt::UpArrow</enum> 37 </property> 38 </widget> 39 </item> 40 <item> 41 <widget class="QWidget" native="1" name="selectedDate" > 42 <property name="sizePolicy" > 43 <sizepolicy vsizetype="Expanding" hsizetype="Minimum" > 44 <horstretch>0</horstretch> 45 <verstretch>0</verstretch> 46 </sizepolicy> 47 </property> 48 </widget> 49 </item> 18 50 <item> 19 51 <widget class="QToolButton" name="prevDayButton" > … … 25 57 </property> 26 58 <property name="arrowType" > 27 <enum>Qt::LeftArrow</enum> 28 </property> 29 </widget> 30 </item> 31 <item> 32 <spacer name="horizontalSpacer" > 33 <property name="orientation" > 34 <enum>Qt::Horizontal</enum> 35 </property> 36 <property name="sizeHint" stdset="0" > 37 <size> 38 <width>40</width> 39 <height>20</height> 40 </size> 41 </property> 42 </spacer> 43 </item> 44 <item> 45 <widget class="QLabel" name="currentDateLabel" > 46 <property name="text" > 47 <string>Currently selected date</string> 48 </property> 49 </widget> 50 </item> 51 <item> 52 <spacer name="horizontalSpacer_2" > 53 <property name="orientation" > 54 <enum>Qt::Horizontal</enum> 55 </property> 56 <property name="sizeHint" stdset="0" > 57 <size> 58 <width>40</width> 59 <height>20</height> 60 </size> 61 </property> 62 </spacer> 63 </item> 64 <item> 65 <widget class="QToolButton" name="nextDayButton" > 66 <property name="text" > 67 <string>...</string> 68 </property> 69 <property name="autoRaise" > 70 <bool>true</bool> 71 </property> 72 <property name="arrowType" > 73 <enum>Qt::RightArrow</enum> 59 <enum>Qt::DownArrow</enum> 74 60 </property> 75 61 </widget> -
src/gui/mainwindow.ui
r806b992 r5992909 34 34 <layout class="QVBoxLayout" name="verticalLayout" > 35 35 <item> 36 <widget class="DayNavigatorWidget" native="1" name="dayNavigator" /> 37 </item> 38 <item> 39 <widget class="TreeView" name="dayTreeView" > 40 <property name="maximumSize" > 41 <size> 42 <width>16777215</width> 43 <height>16777215</height> 44 </size> 45 </property> 46 </widget> 36 <layout class="QHBoxLayout" name="horizontalLayout_2" > 37 <item> 38 <layout class="QVBoxLayout" name="verticalLayout_5" > 39 <item> 40 <widget class="QToolButton" name="toolButton" > 41 <property name="autoFillBackground" > 42 <bool>true</bool> 43 </property> 44 <property name="text" > 45 <string>H</string> 46 </property> 47 <property name="autoRaise" > 48 <bool>true</bool> 49 </property> 50 </widget> 51 </item> 52 <item> 53 <widget class="DayNavigatorWidget" native="1" name="dayNavigator" > 54 <property name="sizePolicy" > 55 <sizepolicy vsizetype="Expanding" hsizetype="Minimum" > 56 <horstretch>0</horstretch> 57 <verstretch>0</verstretch> 58 </sizepolicy> 59 </property> 60 </widget> 61 </item> 62 </layout> 63 </item> 64 <item> 65 <widget class="TreeView" name="dayTreeView" > 66 <property name="maximumSize" > 67 <size> 68 <width>16777215</width> 69 <height>16777215</height> 70 </size> 71 </property> 72 </widget> 73 </item> 74 </layout> 47 75 </item> 48 76 </layout> … … 55 83 </attribute> 56 84 <layout class="QGridLayout" name="gridLayout_3" > 57 <item row=" 0" column="0" >58 <layout class="Q VBoxLayout" name="verticalLayout_2" >85 <item row="1" column="0" > 86 <layout class="QHBoxLayout" name="horizontalLayout_4" > 59 87 <item> 60 88 <widget class="DayNavigatorWidget" native="1" name="favouriteDayNavigator" /> … … 73 101 <layout class="QGridLayout" name="gridLayout_4" > 74 102 <item row="0" column="0" > 75 <layout class="Q VBoxLayout" name="activitiesVerticalLayout" >103 <layout class="QHBoxLayout" name="horizontalLayout_3" > 76 104 <item> 77 105 <widget class="DayNavigatorWidget" native="1" name="trackDayNavigator" /> … … 342 370 <y>0</y> 343 371 <width>654</width> 344 <height>2 2</height>372 <height>26</height> 345 373 </rect> 346 374 </property>
Note: See TracChangeset
for help on using the changeset viewer.