Fixed ticket #26 (empty tabs after some actions).
[toast/confclerk.git] / src / gui / daynavigatorwidget.cpp
index 8db754df4df2df7d2923214ec00c84b6ba3622dc..48ce89a741929ffc48b58f66c742aa27667bc50c 100644 (file)
@@ -45,23 +45,13 @@ void DayNavigatorWidget::setDates(const QDate &aStartDate, const QDate &aEndDate
 
     mStartDate = aStartDate;
     mEndDate = aEndDate;
-    mCurDate = aStartDate;
+    if (!mCurDate.isValid()) mCurDate = mStartDate;
+    else if (mCurDate < mStartDate) mCurDate = mStartDate;
+    else if (mCurDate > mEndDate) mCurDate = mEndDate;
 
-    // QRect rect = mFontMetrics->boundingRect(mCurDate.toString("MMM dd yyyy"));
-
-    if(mStartDate==mEndDate) // only one day conference
-    {
-        prevDayButton->setDisabled(true);
-        nextDayButton->setDisabled(true);
-        emit(dateChanged(mCurDate));
-    }
-    else
-    {
-        // at least 2-days conference
-        prevDayButton->setDisabled(true);
-        nextDayButton->setDisabled(false);
-        emit(dateChanged(mCurDate));
-    }
+    prevDayButton->setDisabled(mCurDate == mStartDate);
+    nextDayButton->setDisabled(mCurDate == mEndDate);
+    emit(dateChanged(mCurDate));
 }
 
 void DayNavigatorWidget::configureNavigation()