Skip to content

Commit

Permalink
Select 'Library' chart automagically
Browse files Browse the repository at this point in the history
.. when a preset is selected in the trend view sidebar
   we automatically switch to the library chart to
   show it.
  • Loading branch information
liversedge committed Jul 28, 2015
1 parent 6c671ed commit 5fc0a96
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/HomeWindow.cpp
Expand Up @@ -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);
}
Expand Down Expand Up @@ -1498,3 +1501,35 @@ void HomeWindow::translateChartTitles(QList<GcWindow*> 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<GcWinID>();

// not on a 'library' chart
if (type != GcWindowTypes::LTM || static_cast<LTMWindow*>(charts[index])->preset() == false) {

// find a 'library' chart
for(int n=0; n<charts.count(); n++) {
GcWinID type = charts[n]->property("type").value<GcWinID>();
if (type == GcWindowTypes::LTM) {
if (static_cast<LTMWindow*>(charts[n])->preset() == true) {
chartbar->setCurrentIndex(n);
break;
}
}
}
}
}
}
}
1 change: 1 addition & 0 deletions src/HomeWindow.h
Expand Up @@ -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);
Expand Down

0 comments on commit 5fc0a96

Please sign in to comment.