day navigator widget changes
authorpavelpa <pavelpa@localhost>
Fri, 22 Jan 2010 12:31:10 +0000 (12:31 +0000)
committerpavelpa <pavelpa@localhost>
Fri, 22 Jan 2010 12:31:10 +0000 (12:31 +0000)
 - changed from Horizontal to Vertical

src/gui/daynavigatorwidget.cpp
src/gui/daynavigatorwidget.h
src/gui/daynavigatorwidget.ui
src/gui/mainwindow.ui

index 5c7b8d03d3d6e049826423c58f2cc9bc2acbff13..c554c1dc33e1ccbaf8f64a4b28db79a40019aa00 100644 (file)
@@ -1,5 +1,9 @@
 #include "daynavigatorwidget.h"
 
+#include <QPainter>
+#include <QFontMetrics>
+#include <QLabel>
+
 #include <QDebug>
 
 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(mCurDate<mEndDate)
     {
         mCurDate = mCurDate.addDays(1);
-        currentDateLabel->setText(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();
+}
+
index bf4b43df0974c66ed19e2497e2b0ec87f0234f18..a4a104dcd5cde9abca2dfcb9186ad84929c9af4c 100644 (file)
@@ -5,6 +5,52 @@
 #include <QObject>
 #include <QDate>
 
+/*#include <QPainter>*/
+/*#include <QLabel>*/
+
+/*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 */
index 9de6ba106c0417f49abde0897438c073a6853c94..c5eae24cb844f9c01d9d235abbaa0ef0f05e7dab 100644 (file)
@@ -5,18 +5,27 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>360</width>
-    <height>52</height>
+    <width>52</width>
+    <height>198</height>
    </rect>
   </property>
+  <property name="sizePolicy" >
+   <sizepolicy vsizetype="Expanding" hsizetype="Minimum" >
+    <horstretch>0</horstretch>
+    <verstretch>0</verstretch>
+   </sizepolicy>
+  </property>
   <property name="windowTitle" >
    <string>Form</string>
   </property>
+  <property name="layoutDirection" >
+   <enum>Qt::LeftToRight</enum>
+  </property>
   <layout class="QGridLayout" name="gridLayout" >
-   <item row="0" column="0" >
-    <layout class="QHBoxLayout" name="horizontalLayout" >
+   <item row="1" column="0" >
+    <layout class="QVBoxLayout" name="verticalLayout" >
      <item>
-      <widget class="QToolButton" name="prevDayButton" >
+      <widget class="QToolButton" name="nextDayButton" >
        <property name="text" >
         <string>...</string>
        </property>
         <bool>true</bool>
        </property>
        <property name="arrowType" >
-        <enum>Qt::LeftArrow</enum>
+        <enum>Qt::UpArrow</enum>
        </property>
       </widget>
      </item>
      <item>
-      <spacer name="horizontalSpacer" >
-       <property name="orientation" >
-        <enum>Qt::Horizontal</enum>
-       </property>
-       <property name="sizeHint" stdset="0" >
-        <size>
-         <width>40</width>
-         <height>20</height>
-        </size>
-       </property>
-      </spacer>
-     </item>
-     <item>
-      <widget class="QLabel" name="currentDateLabel" >
-       <property name="text" >
-        <string>Currently selected date</string>
+      <widget class="QWidget" native="1" name="selectedDate" >
+       <property name="sizePolicy" >
+        <sizepolicy vsizetype="Expanding" hsizetype="Minimum" >
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
        </property>
       </widget>
      </item>
      <item>
-      <spacer name="horizontalSpacer_2" >
-       <property name="orientation" >
-        <enum>Qt::Horizontal</enum>
-       </property>
-       <property name="sizeHint" stdset="0" >
-        <size>
-         <width>40</width>
-         <height>20</height>
-        </size>
-       </property>
-      </spacer>
-     </item>
-     <item>
-      <widget class="QToolButton" name="nextDayButton" >
+      <widget class="QToolButton" name="prevDayButton" >
        <property name="text" >
         <string>...</string>
        </property>
@@ -70,7 +56,7 @@
         <bool>true</bool>
        </property>
        <property name="arrowType" >
-        <enum>Qt::RightArrow</enum>
+        <enum>Qt::DownArrow</enum>
        </property>
       </widget>
      </item>
index 4346117a2e3a21d9e3deb7fa021fc1f5308ece99..0089627754dc82b0e77e966b0e5d0f517ce75ffe 100644 (file)
         <item row="0" column="0" >
          <layout class="QVBoxLayout" name="verticalLayout" >
           <item>
-           <widget class="DayNavigatorWidget" native="1" name="dayNavigator" />
-          </item>
-          <item>
-           <widget class="TreeView" name="dayTreeView" >
-            <property name="maximumSize" >
-             <size>
-              <width>16777215</width>
-              <height>16777215</height>
-             </size>
-            </property>
-           </widget>
+           <layout class="QHBoxLayout" name="horizontalLayout_2" >
+            <item>
+             <layout class="QVBoxLayout" name="verticalLayout_5" >
+              <item>
+               <widget class="QToolButton" name="toolButton" >
+                <property name="autoFillBackground" >
+                 <bool>true</bool>
+                </property>
+                <property name="text" >
+                 <string>H</string>
+                </property>
+                <property name="autoRaise" >
+                 <bool>true</bool>
+                </property>
+               </widget>
+              </item>
+              <item>
+               <widget class="DayNavigatorWidget" native="1" name="dayNavigator" >
+                <property name="sizePolicy" >
+                 <sizepolicy vsizetype="Expanding" hsizetype="Minimum" >
+                  <horstretch>0</horstretch>
+                  <verstretch>0</verstretch>
+                 </sizepolicy>
+                </property>
+               </widget>
+              </item>
+             </layout>
+            </item>
+            <item>
+             <widget class="TreeView" name="dayTreeView" >
+              <property name="maximumSize" >
+               <size>
+                <width>16777215</width>
+                <height>16777215</height>
+               </size>
+              </property>
+             </widget>
+            </item>
+           </layout>
           </item>
          </layout>
         </item>
@@ -54,8 +82,8 @@
         <string>Favourites</string>
        </attribute>
        <layout class="QGridLayout" name="gridLayout_3" >
-        <item row="0" column="0" >
-         <layout class="QVBoxLayout" name="verticalLayout_2" >
+        <item row="1" column="0" >
+         <layout class="QHBoxLayout" name="horizontalLayout_4" >
           <item>
            <widget class="DayNavigatorWidget" native="1" name="favouriteDayNavigator" />
           </item>
        </attribute>
        <layout class="QGridLayout" name="gridLayout_4" >
         <item row="0" column="0" >
-         <layout class="QVBoxLayout" name="activitiesVerticalLayout" >
+         <layout class="QHBoxLayout" name="horizontalLayout_3" >
           <item>
            <widget class="DayNavigatorWidget" native="1" name="trackDayNavigator" />
           </item>
      <x>0</x>
      <y>0</y>
      <width>654</width>
-     <height>22</height>
+     <height>26</height>
     </rect>
    </property>
    <widget class="QMenu" name="menuFile" >