Fixed ticket #26 (empty tabs after some actions).
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Tue, 6 Sep 2011 19:15:35 +0000 (19:15 +0000)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Tue, 6 Sep 2011 19:15:35 +0000 (19:15 +0000)
src/gui/daynavigatorwidget.cpp
src/gui/daynavigatorwidget.h
src/gui/tabcontainer.cpp
src/mvc/treeview.cpp

index 8db754d..48ce89a 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()
index d4ddcea..79d71f0 100644 (file)
@@ -77,6 +77,7 @@ class DayNavigatorWidget : public QWidget, private Ui::DayNavigatorWidget
         DayNavigatorWidget(QWidget *aParent = NULL);
         ~DayNavigatorWidget() {}
         void setDates(const QDate &aStartDate, const QDate &aEndDate);
+        QDate curDate() const {return mCurDate;}
     protected:
         void paintEvent(QPaintEvent *);
         void configureNavigation();
index 357ea35..c17eff2 100644 (file)
@@ -96,13 +96,13 @@ void TabContainer::updateTreeViewModel(int aEventId, bool aReloadModel)
     if(aReloadModel)
     {
         // requires special handling
-        // eg. in case of favourities - some favourities may have changed
+        // eg. in case of favourites - some favourites may have changed
         // and so we need to reload them
         int confId = Conference::activeConference();
         QDate startDate = Conference::getById(confId).start();
         QDate endDate = Conference::getById(confId).end();
         dayNavigator->setDates(startDate, endDate);
-        updateTreeView( Conference::getById(confId).start() );
+        updateTreeView(dayNavigator->curDate());
     }
     else
     {
index 8893351..6f514e9 100644 (file)
@@ -70,10 +70,7 @@ bool TreeView::testForControlClicked(const QModelIndex &aIndex, const QPoint &aP
                 Event event = Event::getById(aIndex.data().toInt(),confId);
 
                 QList<Event> conflicts = Event::conflictEvents(event.id(),Conference::activeConference());
-                if(event.isFavourite())
-                    event.setFavourite(false);
-                else
-                    event.setFavourite(true);
+                event.setFavourite(!event.isFavourite());
                 event.update("favourite");
 
                 if(event.isFavourite())