Changeset a6f4f3d in confclerk_git for src/gui/daynavigatorwidget.cpp


Ignore:
Timestamp:
07/24/11 13:41:14 (12 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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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();
Note: See TracChangeset for help on using the changeset viewer.