diff --git a/src/HomeWindow.cpp b/src/HomeWindow.cpp index 9b72d04717..020849fd28 100644 --- a/src/HomeWindow.cpp +++ b/src/HomeWindow.cpp @@ -162,6 +162,9 @@ HomeWindow::HomeWindow(Context *context, QString name, QString /* windowtitle */ connect(chartbar, SIGNAL(currentIndexChanged(int)), this, SLOT(tabSelected(int))); connect(titleEdit, SIGNAL(textChanged(const QString&)), SLOT(titleChanged())); + // trends view we should select a library chart when a chart is selected. + if (name == "home") connect(context, SIGNAL(presetSelected(int)), this, SLOT(presetSelected(int))); + installEventFilter(this); qApp->installEventFilter(this); } @@ -1498,3 +1501,35 @@ void HomeWindow::translateChartTitles(QList charts) chart->setProperty("title", titleMap.value(chartTitle, chartTitle)); } } + +void +HomeWindow::presetSelected(int n) +{ + if (n > 0) { + + // if we are in tabbed mode and we are not on a 'library' LTM chart + // then we need to select a library chart to show the selection + + // tabbed is an LTM? + if (!currentStyle && tabbed->currentIndex() >= 0 && charts.count() > 0) { + + int index = tabbed->currentIndex(); + GcWinID type = charts[index]->property("type").value(); + + // not on a 'library' chart + if (type != GcWindowTypes::LTM || static_cast(charts[index])->preset() == false) { + + // find a 'library' chart + for(int n=0; nproperty("type").value(); + if (type == GcWindowTypes::LTM) { + if (static_cast(charts[n])->preset() == true) { + chartbar->setCurrentIndex(n); + break; + } + } + } + } + } + } +} diff --git a/src/HomeWindow.h b/src/HomeWindow.h index 24cee239fb..a96a963f5a 100644 --- a/src/HomeWindow.h +++ b/src/HomeWindow.h @@ -64,6 +64,7 @@ class HomeWindow : public GcWindow void rideSelected(); void dateRangeChanged(DateRange); void configChanged(qint32); + void presetSelected(int n); // QT Widget events and signals void tabSelected(int id);