Changeset a6f4f3d


Ignore:
Timestamp:
07/24/11 13:41:14 (11 years ago)
Author:
gregor herrmann <gregoa@…>
Branches:
master, qt5
Children:
c7da828
Parents:
6c85b24
Message:

Add today button to date navigator.
TODO: date is not centered between prev/next arrows anymore.

Cf. #29

Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • NEWS

    r6c85b24 ra6f4f3d  
    44Version 0.5.3
    55//! TODO
     6* Add "jump to today" button to date navigator.
     7  Thanks to Michael Schutte for the patch.
    68
    79Version 0.5.2, 2011-07-23
  • src/gui/daynavigatorwidget.cpp

    r6c85b24 ra6f4f3d  
    3535    connect(prevDayButton, SIGNAL(clicked()), SLOT(prevDayButtonClicked()));
    3636    connect(nextDayButton, SIGNAL(clicked()), SLOT(nextDayButtonClicked()));
     37    connect(todayButton, SIGNAL(clicked()), SLOT(todayButtonClicked()));
    3738
    3839    mFontMetrics = new QFontMetrics(QLabel().font());
     
    6465}
    6566
     67void DayNavigatorWidget::configureNavigation()
     68{
     69    // check start date
     70    if(mCurDate==mStartDate || mStartDate==mEndDate)
     71        prevDayButton->setDisabled(true);
     72    else
     73        prevDayButton->setDisabled(false);
     74    // check end date
     75    if(mCurDate==mEndDate || mStartDate==mEndDate)
     76        nextDayButton->setDisabled(true);
     77    else
     78        nextDayButton->setDisabled(false);
     79}
     80
    6681void DayNavigatorWidget::prevDayButtonClicked()
    6782{
     
    6984    {
    7085        mCurDate = mCurDate.addDays(-1);
    71         // check start date
    72         if(mCurDate==mStartDate || mStartDate==mEndDate)
    73             prevDayButton->setDisabled(true);
    74         else
    75             prevDayButton->setDisabled(false);
    76         // check end date
    77         if(mCurDate==mEndDate || mStartDate==mEndDate)
    78             nextDayButton->setDisabled(true);
    79         else
    80             nextDayButton->setDisabled(false);
    81 
     86        configureNavigation();
    8287        emit(dateChanged(mCurDate));
    8388        selectedDate->update();
     
    9095    {
    9196        mCurDate = mCurDate.addDays(1);
    92         // check start date
    93         if(mCurDate==mStartDate || mStartDate==mEndDate)
    94             prevDayButton->setDisabled(true);
    95         else
    96             prevDayButton->setDisabled(false);
    97         // check end date
    98         if(mCurDate==mEndDate || mStartDate==mEndDate)
    99             nextDayButton->setDisabled(true);
    100         else
    101             nextDayButton->setDisabled(false);
     97        configureNavigation();
     98        emit(dateChanged(mCurDate));
     99        selectedDate->update();
     100    }
     101}
    102102
     103void DayNavigatorWidget::todayButtonClicked()
     104{
     105    QDate targetDate = QDate::currentDate();
     106    if (targetDate>mStartDate && targetDate<mEndDate)
     107    {
     108        mCurDate = targetDate;
     109        configureNavigation();
    103110        emit(dateChanged(mCurDate));
    104111        selectedDate->update();
  • src/gui/daynavigatorwidget.h

    r6c85b24 ra6f4f3d  
    8080    protected:
    8181        void paintEvent(QPaintEvent *);
     82        void configureNavigation();
    8283    private slots:
     84        void todayButtonClicked();
    8385        void prevDayButtonClicked();
    8486        void nextDayButtonClicked();
  • src/gui/daynavigatorwidget.ui

    r6c85b24 ra6f4f3d  
    6262      </widget>
    6363     </item>
     64     <item>
     65      <widget class="QToolButton" name="todayButton">
     66       <property name="text">
     67        <string>...</string>
     68       </property>
     69       <property name="icon">
     70        <iconset resource="../icons.qrc">
     71         <normaloff>:/icons/today.png</normaloff>:/icons/today.png</iconset>
     72       </property>
     73       <property name="autoRaise">
     74        <bool>true</bool>
     75       </property>
     76      </widget>
     77     </item>
    6478    </layout>
    6579   </item>
    6680  </layout>
    6781 </widget>
    68  <resources/>
     82 <resources>
     83  <include location="../icons.qrc"/>
     84 </resources>
    6985 <connections/>
    7086 <slots>
    7187  <slot>prevDayButtonClicked()</slot>
    7288  <slot>nextDayButtonClicked()</slot>
     89  <slot>todayButtonClicked()</slot>
    7390 </slots>
    7491</ui>
  • src/icons.qrc

    r6c85b24 ra6f4f3d  
    1010    <file>icons/dialog-warning.png</file>
    1111    <file>icons/search.png</file>
     12    <file>icons/today.png</file>
    1213  </qresource>
    1314</RCC>
Note: See TracChangeset for help on using the changeset viewer.