Skip to content

Commit

Permalink
Tidy up perspective selection
Browse files Browse the repository at this point in the history
.. and setting current ride / date ranges. fixing a regression
   introduced with the recent perspective changes.
  • Loading branch information
liversedge committed Jun 22, 2021
1 parent e448aa1 commit 8753032
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions src/Gui/TabView.cpp
Expand Up @@ -673,6 +673,9 @@ TabView::setPerspectives(QComboBox *perspectiveSelector)
if (!loaded) {
loaded = true;
perspectiveSelected(0);

// due to visibility optimisation we need to force the first tab to be selected in tab mode
if (page_->currentStyle == 0 && page_->charts.count()) page_->tabSelected(0);
}
}

Expand All @@ -683,10 +686,13 @@ TabView::perspectiveSelected(int index)
if (perspectiveactive || index <0) return;

// switch the stack to show the one selected
// set page to the one we want
setUpdatesEnabled(false);
// and set the date / ride property to help
// it catch up with what it missed whilst we
// were looking at another perspective
if (index < pages_.count()) {

setUpdatesEnabled(false);

page_ = pages_[index];

// switch to this perspective's charts and controls
Expand All @@ -698,19 +704,9 @@ TabView::perspectiveSelected(int index)
// set properties on the perspective as they propagate to charts
RideItem *notconst = (RideItem*)context->currentRideItem();
page_->setProperty("ride", QVariant::fromValue<RideItem*>(notconst));
page_->setProperty("dateRange", property("dateRange"));

// set to whatever we have currently selected
// bit of spooky updates at a distance here... xxx fixme back to Perspective class
for(int i = 0; i < page_->charts.count(); i++) {

page_->charts[i]->setProperty("ride", QVariant::fromValue<RideItem*>(notconst));
page_->charts[i]->setProperty("dateRange", QVariant::fromValue<DateRange>(context->currentDateRange()));
if (page_->currentStyle != 0) page_->charts[i]->show();
}
page_->setProperty("dateRange", QVariant::fromValue<DateRange>(context->currentDateRange()));

setUpdatesEnabled(true);
//if (page_->currentStyle == 0 && page_->charts.count()) page_->tabSelected(0);
}
}

Expand Down

0 comments on commit 8753032

Please sign in to comment.