diff --git a/src/Charts/Aerolab.cpp b/src/Charts/Aerolab.cpp index 4e82d8f283..6056a7fc6b 100644 --- a/src/Charts/Aerolab.cpp +++ b/src/Charts/Aerolab.cpp @@ -26,6 +26,7 @@ #include "Settings.h" #include "Units.h" #include "Colors.h" +#include "TimeUtils.h" #include #include @@ -267,6 +268,11 @@ Aerolab::configChanged(qint32) intervalHighlighterCurve->setBrush(ihlbrush); // fill below the line //XXX broken this->legend()->remove( intervalHighlighterCurve ); // don't show in legend + QPalette palette; + palette.setColor(QPalette::WindowText, GColor(CPLOTMARKER)); + palette.setColor(QPalette::Text, GColor(CPLOTMARKER)); + axisWidget(QwtPlot::xBottom)->setPalette(palette); + axisWidget(QwtPlot::yLeft)->setPalette(palette); } void @@ -723,13 +729,14 @@ void Aerolab::refreshIntervalMarkers() } d_mrk.clear(); - QRegExp wkoAuto("^(Peak *[0-9]*(s|min)|Entire workout|Find #[0-9]*) *\\([^)]*\\)$"); + //QRegExp wkoAuto("^(Peak *[0-9]*(s|min)|Entire workout|Find #[0-9]*) *\\([^)]*\\)$"); if ( rideItem->ride() ) { foreach(IntervalItem *interval, rideItem->intervals()) { - // skip WKO autogenerated peak intervals - if (wkoAuto.exactMatch(interval->name)) - continue; + + // only plot user intervals + if (interval->type != RideFileInterval::USER) continue; + QwtPlotMarker *mrk = new QwtPlotMarker; d_mrk.append(mrk); mrk->attach(this); diff --git a/src/Charts/AerolabWindow.cpp b/src/Charts/AerolabWindow.cpp index eb534d9661..dd98bc502d 100644 --- a/src/Charts/AerolabWindow.cpp +++ b/src/Charts/AerolabWindow.cpp @@ -21,6 +21,7 @@ #include "Context.h" #include "AerolabWindow.h" #include "Aerolab.h" +#include "TabView.h" #include "IntervalItem.h" #include "RideItem.h" #include "Colors.h" @@ -29,7 +30,7 @@ #include AerolabWindow::AerolabWindow(Context *context) : - GcWindow(context), context(context) { + GcChartWindow(context), context(context) { setControls(NULL); // Aerolab tab layout: @@ -49,7 +50,7 @@ AerolabWindow::AerolabWindow(Context *context) : // Crr: QHBoxLayout *crrLayout = new QHBoxLayout; - QLabel *crrLabel = new QLabel(tr("Crr"), this); + crrLabel = new QLabel(tr("Crr"), this); crrLabel->setFixedWidth(labelWidth1); crrLineEdit = new QLineEdit(); crrLineEdit->setFixedWidth(75); @@ -72,7 +73,7 @@ AerolabWindow::AerolabWindow(Context *context) : // CdA: QHBoxLayout *cdaLayout = new QHBoxLayout; - QLabel *cdaLabel = new QLabel(tr("CdA"), this); + cdaLabel = new QLabel(tr("CdA"), this); cdaLabel->setFixedWidth(labelWidth1); cdaLineEdit = new QLineEdit(); cdaLineEdit->setFixedWidth(75); @@ -95,7 +96,7 @@ AerolabWindow::AerolabWindow(Context *context) : // Eta: QHBoxLayout *etaLayout = new QHBoxLayout; - QLabel *etaLabel = new QLabel(tr("Eta"), this); + etaLabel = new QLabel(tr("Eta"), this); etaLabel->setFixedWidth(labelWidth1); etaLineEdit = new QLineEdit(); etaLineEdit->setFixedWidth(75); @@ -128,7 +129,7 @@ AerolabWindow::AerolabWindow(Context *context) : // Total mass: QHBoxLayout *mLayout = new QHBoxLayout; - QLabel *mLabel = new QLabel(tr("Total Mass (kg)"), this); + mLabel = new QLabel(tr("Total Mass (kg)"), this); mLabel->setFixedWidth(labelWidth2); mLineEdit = new QLineEdit(); mLineEdit->setFixedWidth(70); @@ -151,7 +152,7 @@ AerolabWindow::AerolabWindow(Context *context) : // Rho: QHBoxLayout *rhoLayout = new QHBoxLayout; - QLabel *rhoLabel = new QLabel(tr("Rho (kg/m^3)"), this); + rhoLabel = new QLabel(tr("Rho (kg/m^3)"), this); rhoLabel->setFixedWidth(labelWidth2); rhoLineEdit = new QLineEdit(); rhoLineEdit->setFixedWidth(70); @@ -174,7 +175,7 @@ AerolabWindow::AerolabWindow(Context *context) : // Elevation offset: QHBoxLayout *eoffsetLayout = new QHBoxLayout; - QLabel *eoffsetLabel = new QLabel(tr("Eoffset (m)"), this); + eoffsetLabel = new QLabel(tr("Eoffset (m)"), this); eoffsetLabel->setFixedWidth(labelWidth2); eoffsetLineEdit = new QLineEdit(); eoffsetLineEdit->setFixedWidth(70); @@ -196,11 +197,11 @@ AerolabWindow::AerolabWindow(Context *context) : eoffsetLayout->addWidget( eoffsetSlider ); QVBoxLayout *checkboxLayout = new QVBoxLayout; - QCheckBox *eoffsetAuto = new QCheckBox(tr("eoffset auto"), this); + eoffsetAuto = new QCheckBox(tr("eoffset auto"), this); eoffsetAuto->setCheckState(Qt::Checked); checkboxLayout->addWidget(eoffsetAuto); - QCheckBox *constantAlt = new QCheckBox(tr("Constant altitude (velodrome,...)"), this); + constantAlt = new QCheckBox(tr("Constant altitude (velodrome,...)"), this); checkboxLayout->addWidget(constantAlt); eoffsetLayout->addLayout(checkboxLayout); @@ -264,7 +265,7 @@ AerolabWindow::AerolabWindow(Context *context) : // Build the tab layout: vLayout->addWidget(aerolab); vLayout->addLayout(cLayout); - setLayout(vLayout); + setChartLayout(vLayout); // tooltip on hover over point @@ -307,16 +308,47 @@ AerolabWindow::configChanged(qint32) setProperty("color", GColor(CPLOTBACKGROUND)); QPalette palette; - palette.setBrush(QPalette::Window, QBrush(GColor(CPLOTBACKGROUND))); - palette.setBrush(QPalette::Background, QBrush(GColor(CPLOTBACKGROUND))); - palette.setBrush(QPalette::Base, QBrush(GColor(CPLOTBACKGROUND))); + + palette.setColor(QPalette::Window, GColor(CPLOTBACKGROUND)); + palette.setColor(QPalette::Background, GColor(CPLOTBACKGROUND)); + + // only change base if moved away from white plots + // which is a Mac thing +#ifndef Q_OS_MAC + if (GColor(CPLOTBACKGROUND) != Qt::white) +#endif + { + palette.setColor(QPalette::Base, GCColor::alternateColor(GColor(CPLOTBACKGROUND))); + palette.setColor(QPalette::Window, GColor(CPLOTBACKGROUND)); + } + palette.setColor(QPalette::WindowText, GCColor::invertColor(GColor(CPLOTBACKGROUND))); palette.setColor(QPalette::Text, GCColor::invertColor(GColor(CPLOTBACKGROUND))); - palette.setColor(QPalette::Normal, QPalette::Window, GCColor::invertColor(GColor(CPLOTBACKGROUND))); setPalette(palette); - setStyleSheet(QString("background-color: %1; color: %2; border: %1") - .arg(GColor(CPLOTBACKGROUND).name()) - .arg(GCColor::invertColor(GColor(CPLOTBACKGROUND)).name())); + aerolab->setPalette(palette); + crrLabel->setPalette(palette); + cdaLabel->setPalette(palette); + etaLabel->setPalette(palette); + mLabel->setPalette(palette); + rhoLabel->setPalette(palette); + eoffsetLabel->setPalette(palette); + crrSlider->setPalette(palette); + crrLineEdit->setPalette(palette); + cdaSlider->setPalette(palette); + cdaLineEdit->setPalette(palette); + mSlider->setPalette(palette); + mLineEdit->setPalette(palette); + rhoSlider->setPalette(palette); + rhoLineEdit->setPalette(palette); + etaSlider->setPalette(palette); + etaLineEdit->setPalette(palette); + eoffsetLineEdit->setPalette(palette); + eoffsetAuto->setPalette(palette); + constantAlt->setPalette(palette); + +#ifndef Q_OS_MAC + aerolab->setStyleSheet(TabView::ourStyleSheet()); +#endif } void diff --git a/src/Charts/AerolabWindow.h b/src/Charts/AerolabWindow.h index 8f34b32559..4734ad6553 100644 --- a/src/Charts/AerolabWindow.h +++ b/src/Charts/AerolabWindow.h @@ -33,7 +33,7 @@ class QLCDNumber; class RideItem; class IntervalItem; -class AerolabWindow : public GcWindow { +class AerolabWindow : public GcChartWindow { Q_OBJECT G_OBJECT @@ -77,6 +77,16 @@ class AerolabWindow : public GcWindow { Aerolab *aerolab; QwtPlotZoomer *allZoomer; + // labels + QLabel *crrLabel; + QLabel *cdaLabel; + QLabel *etaLabel; + QLabel *mLabel; + QLabel *rhoLabel; + QLabel *eoffsetLabel; + + QCheckBox *eoffsetAuto, *constantAlt; + // Bike parameter controls: QSlider *crrSlider; QLineEdit *crrLineEdit; diff --git a/src/Charts/ChartBar.cpp b/src/Charts/ChartBar.cpp index ea234d5776..46eba950f0 100644 --- a/src/Charts/ChartBar.cpp +++ b/src/Charts/ChartBar.cpp @@ -124,8 +124,8 @@ ChartBar::ChartBar(Context *context) : QWidget(context->mainWindow), context(con chartMenu = barMenu->addMenu(tr("Add Chart")); #ifdef GC_HAS_CLOUD_DB - QAction *cloudAction = barMenu->addAction(tr("Download Chart...")); - connect(cloudAction, SIGNAL(triggered(bool)), context->mainWindow, SLOT(addChartFromCloudDB())); + barMenu->addAction(tr("Upload Chart..."), context->mainWindow, SLOT(exportChartToCloudDB())); + barMenu->addAction(tr("Download Chart..."), context->mainWindow, SLOT(addChartFromCloudDB())); #endif // menu connect(menuButton, SIGNAL(clicked()), this, SLOT(menuPopup())); diff --git a/src/Charts/DiaryWindow.cpp b/src/Charts/DiaryWindow.cpp index 193b577cd1..8de76e3ec9 100644 --- a/src/Charts/DiaryWindow.cpp +++ b/src/Charts/DiaryWindow.cpp @@ -27,14 +27,15 @@ #include "HelpWhatsThis.h" DiaryWindow::DiaryWindow(Context *context) : - GcWindow(context), context(context), active(false) + GcChartWindow(context), context(context), active(false) { setControls(NULL); // get config fieldDefinitions = context->athlete->rideMetadata()->getFields(); - QVBoxLayout *vlayout = new QVBoxLayout(this); + QVBoxLayout *vlayout = new QVBoxLayout; + setChartLayout(vlayout); // controls QHBoxLayout *controls = new QHBoxLayout; diff --git a/src/Charts/DiaryWindow.h b/src/Charts/DiaryWindow.h index 177efe0292..42e3a2207a 100644 --- a/src/Charts/DiaryWindow.h +++ b/src/Charts/DiaryWindow.h @@ -39,7 +39,7 @@ #include "RideSummaryWindow.h" -class DiaryWindow : public GcWindow +class DiaryWindow : public GcChartWindow { Q_OBJECT G_OBJECT diff --git a/src/Charts/GoldenCheetah.cpp b/src/Charts/GoldenCheetah.cpp index b6c7696143..62dee010ed 100644 --- a/src/Charts/GoldenCheetah.cpp +++ b/src/Charts/GoldenCheetah.cpp @@ -695,6 +695,9 @@ GcChartWindow::GcChartWindow(Context *context) : GcWindow(context), context(cont _mainWidget = new QWidget(this); _mainWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + _chart = new QWidget(this); + _chart->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + _chart->hide(); _blank = new QWidget(this); _blank->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); @@ -703,11 +706,13 @@ GcChartWindow::GcChartWindow(Context *context) : GcWindow(context), context(cont _layout->setCurrentWidget(_mainWidget); // Main layout - _mainLayout = new QGridLayout(); + _mainLayout = new QStackedLayout(_mainWidget); + _mainLayout->setStackingMode(QStackedLayout::StackAll); _mainLayout->setContentsMargins(2,2,2,2); // reveal widget - _revealControls = new QWidget(); + _revealControls = new QWidget(this); + _revealControls->hide(); _revealControls->setFixedHeight(50); _revealControls->setStyleSheet("background-color: rgba(100%, 100%, 100%, 80%)"); _revealControls->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); @@ -729,10 +734,8 @@ GcChartWindow::GcChartWindow(Context *context) : GcWindow(context), context(cont _unrevealTimer = new QTimer(); connect(_unrevealTimer, SIGNAL(timeout()), this, SLOT(hideRevealControls())); - _revealControls->hide(); - - _mainLayout->addWidget(_revealControls,0,0, Qt::AlignTop); - _mainWidget->setLayout(_mainLayout); + _mainLayout->addWidget(_chart); + _mainLayout->addWidget(_revealControls); connect(this, SIGNAL(colorChanged(QColor)), this, SLOT(colorChanged(QColor))); @@ -790,7 +793,8 @@ void GcChartWindow:: setChartLayout(QLayout *layout) { _chartLayout = layout; - _mainLayout->addLayout(_chartLayout,0,0, Qt::AlignTop); + _chart->setLayout(_chartLayout); + _chart->show(); } void @@ -798,6 +802,7 @@ GcChartWindow:: setRevealLayout(QLayout *layout) { _revealLayout = layout; _revealControls->setLayout(_revealLayout); + _revealControls->hide(); } void diff --git a/src/Charts/GoldenCheetah.h b/src/Charts/GoldenCheetah.h index 01906810b6..1651dc9874 100644 --- a/src/Charts/GoldenCheetah.h +++ b/src/Charts/GoldenCheetah.h @@ -223,7 +223,7 @@ class GcChartWindow : public GcWindow Q_OBJECT QStackedLayout *_layout; - QGridLayout *_mainLayout; + QStackedLayout *_mainLayout; QVBoxLayout *_defaultBlankLayout; QLayout *_chartLayout, @@ -241,6 +241,8 @@ class GcChartWindow : public GcWindow QTimer *_unrevealTimer; Context *context; +public: + // reveal bool virtual hasReveal() { return false; } void reveal(); @@ -254,7 +256,6 @@ class GcChartWindow : public GcWindow void serializeChartToQTextStream(QTextStream& out); -public: GcChartWindow(Context *context); // parse a .gchart file / or string and return a list of charts expressed diff --git a/src/Charts/HomeWindow.cpp b/src/Charts/HomeWindow.cpp index fc0e5881b4..970e875767 100644 --- a/src/Charts/HomeWindow.cpp +++ b/src/Charts/HomeWindow.cpp @@ -211,7 +211,7 @@ HomeWindow::importChart(QMapproperties, bool select) // what type? GcWinID type = static_cast(properties.value("TYPE","1").toInt()); - GcWindow *chart = GcWindowRegistry::newGcWindow(type, context); + GcChartWindow *chart = GcWindowRegistry::newGcWindow(type, context); // bad chart file ! if (chart == NULL) { @@ -421,7 +421,7 @@ void HomeWindow::tabMoved(int to, int from) { // re-order the tabs - GcWindow *orig = charts[to]; + GcChartWindow *orig = charts[to]; charts[to] = charts[from]; charts[from] = orig; @@ -532,7 +532,7 @@ HomeWindow::dragEnterEvent(QDragEnterEvent *) void HomeWindow::appendChart(GcWinID id) { - GcWindow *newone = NULL; + GcChartWindow *newone = NULL; // GcWindowDialog is delete on close, so no need to delete GcWindowDialog *f = new GcWindowDialog(id, context, &newone); @@ -592,7 +592,7 @@ HomeWindow::showControls() } void -HomeWindow::addChart(GcWindow* newone) +HomeWindow::addChart(GcChartWindow* newone) { int chartnum = charts.count(); @@ -601,7 +601,7 @@ HomeWindow::addChart(GcWindow* newone) if (newone) { // add the controls - QWidget *x = dynamic_cast(newone)->controls(); + QWidget *x = dynamic_cast(newone)->controls(); QWidget *c = (x != NULL) ? x : new QWidget(this); // link settings button to show controls @@ -742,8 +742,8 @@ HomeWindow::removeChart(int num, bool confirm) default: break; // never reached } - ((GcWindow*)(charts[num]))->close(); // disconnect - ((GcWindow*)(charts[num]))->deleteLater(); + ((GcChartWindow*)(charts[num]))->close(); // disconnect + ((GcChartWindow*)(charts[num]))->deleteLater(); charts.removeAt(num); update(); @@ -772,7 +772,7 @@ HomeWindow::showEvent(QShowEvent *) void HomeWindow::resizeEvent(QResizeEvent * /* e */) { - foreach (GcWindow *x, charts) { + foreach (GcChartWindow *x, charts) { switch (currentStyle) { @@ -835,7 +835,7 @@ HomeWindow::eventFilter(QObject *object, QEvent *e) if (tabbed->currentIndex() >= charts.count()) return false; QPoint pos = tabbed->widget(tabbed->currentIndex())->mapFromGlobal(QCursor::pos()); - GcWindow *us = charts[tabbed->currentIndex()]; + GcChartWindow *us = charts[tabbed->currentIndex()]; // lots of nested if statements to breakout as quickly as possible // this code gets called A LOT, since mouse events are from the @@ -1043,11 +1043,11 @@ HomeWindow::windowMoved(GcWindow*w) if (chartCursor >= 0) { controlStack->insertWidget(chartCursor, c); winFlow->insert(chartCursor, m); - charts.insert(chartCursor, dynamic_cast(l)); + charts.insert(chartCursor, dynamic_cast(l)); } else { controlStack->addWidget(c); winFlow->addWidget(m); - charts.append(dynamic_cast(l)); + charts.append(dynamic_cast(l)); } break; } @@ -1125,7 +1125,7 @@ HomeWindow::drawCursor() } } -GcWindowDialog::GcWindowDialog(GcWinID type, Context *context, GcWindow **here, bool sidebar, LTMSettings *use) : context(context), type(type), here(here), sidebar(sidebar) +GcWindowDialog::GcWindowDialog(GcWinID type, Context *context, GcChartWindow **here, bool sidebar, LTMSettings *use) : context(context), type(type), here(here), sidebar(sidebar) { //setAttribute(Qt::WA_DeleteOnClose); setWindowFlags(windowFlags()); @@ -1250,7 +1250,7 @@ HomeWindow::saveState() out<<"\n"; // iterate over charts - foreach (GcWindow *chart, charts) { + foreach (GcChartWindow *chart, charts) { GcWinID type = chart->property("type").value(); out<<"\t(type)<<"\" " @@ -1403,7 +1403,7 @@ HomeWindow::restoreState(bool useDefault) // layout the results styleChanged(handler.style); - foreach(GcWindow *chart, handler.charts) addChart(chart); + foreach(GcChartWindow *chart, handler.charts) addChart(chart); } // set to whatever we have selected @@ -1507,10 +1507,11 @@ bool ViewParser::endDocument() void HomeWindow::closeWindow(GcWindow*thisone) { - if (charts.contains(thisone)) removeChart(charts.indexOf(thisone)); + if (charts.contains(static_cast(thisone))) + removeChart(charts.indexOf(static_cast(thisone))); } -void HomeWindow::translateChartTitles(QList charts) +void HomeWindow::translateChartTitles(QList charts) { // Map default (english) title to external (Localized) name, new default // charts in *layout.xml need to be added to this list to be translated @@ -1554,7 +1555,7 @@ void HomeWindow::translateChartTitles(QList charts) titleMap.insert("Library", tr("Library")); titleMap.insert("CV", tr("CV")); - foreach(GcWindow *chart, charts) { + foreach(GcChartWindow *chart, charts) { QString chartTitle = chart->property("title").toString(); chart->setProperty("title", titleMap.value(chartTitle, chartTitle)); } diff --git a/src/Charts/HomeWindow.h b/src/Charts/HomeWindow.h index b09d89b5b0..b68c36e0a2 100644 --- a/src/Charts/HomeWindow.h +++ b/src/Charts/HomeWindow.h @@ -61,6 +61,11 @@ class HomeWindow : public GcWindow void setStyle(int style) { styleChanged(style); } int currentStyle; + int currentTab() { return currentStyle ? -1 : style->currentIndex(); } + GcChartWindow *currentChart() { + return currentTab() >= 0 ? charts[currentTab()] : NULL; + } + public slots: // GC signals @@ -81,7 +86,7 @@ class HomeWindow : public GcWindow // My widget signals and events void styleChanged(int); - void addChart(GcWindow* newone); + void addChart(GcChartWindow* newone); void addChartFromMenu(QAction*action); // called with an action void appendChart(GcWinID id); // called from Context *to inset chart bool removeChart(int, bool confirm = true); @@ -113,7 +118,7 @@ class HomeWindow : public GcWindow Context *context; QString name; bool active; // ignore gui signals when changing views - GcWindow *clicked; // keep track of selected charts + GcChartWindow *clicked; // keep track of selected charts bool dropPending; // top bar @@ -137,12 +142,12 @@ class HomeWindow : public GcWindow GcWindowLayout *winFlow; // the charts! - QList charts; + QList charts; int chartCursor; bool loaded; - void translateChartTitles(QList charts); + void translateChartTitles(QList charts); }; // setup the chart @@ -151,7 +156,7 @@ class GcWindowDialog : public QDialog Q_OBJECT public: - GcWindowDialog(GcWinID, Context *, GcWindow **, bool sidebar=false, LTMSettings *use=NULL); + GcWindowDialog(GcWinID, Context *, GcChartWindow **, bool sidebar=false, LTMSettings *use=NULL); int exec(); // return pointer to window, or NULL if cancelled public slots: @@ -161,7 +166,7 @@ class GcWindowDialog : public QDialog protected: Context *context; GcWinID type; - GcWindow **here; + GcChartWindow **here; bool sidebar; // we remove from the layout at the end @@ -171,7 +176,7 @@ class GcWindowDialog : public QDialog QFormLayout *controlLayout; QPushButton *ok, *cancel; - GcWindow *win; + GcChartWindow *win; QLineEdit *title; QDoubleSpinBox *height, *width; }; @@ -183,7 +188,7 @@ class ViewParser : public QXmlDefaultHandler ViewParser(Context *context) : style(2), context(context) {} // the results! - QList charts; + QList charts; int style; // unmarshall @@ -195,7 +200,7 @@ class ViewParser : public QXmlDefaultHandler protected: Context *context; - GcWindow *chart; + GcChartWindow *chart; }; diff --git a/src/Charts/RideWindow.cpp b/src/Charts/RideWindow.cpp index 1be12f4b4d..4520552be6 100644 --- a/src/Charts/RideWindow.cpp +++ b/src/Charts/RideWindow.cpp @@ -60,14 +60,14 @@ void RideWindow::loadRide() } RideWindow::RideWindow(Context *context) : - GcWindow(context), + GcChartWindow(context), rideLoaded(false), context(context) { view = new QWebView(); QVBoxLayout *layout = new QVBoxLayout(); layout->addWidget(view); - setLayout(layout); + setChartLayout(layout); connect(this, SIGNAL(rideItemChanged(RideItem*)), this, SLOT(rideSelected())); } diff --git a/src/Charts/RideWindow.h b/src/Charts/RideWindow.h index 6c185b4be2..1b372db295 100644 --- a/src/Charts/RideWindow.h +++ b/src/Charts/RideWindow.h @@ -323,7 +323,7 @@ public slots: } }; -class RideWindow : public GcWindow +class RideWindow : public GcChartWindow { Q_OBJECT diff --git a/src/Charts/RouteWindow.cpp b/src/Charts/RouteWindow.cpp index d5b040fdec..b19aa10570 100644 --- a/src/Charts/RouteWindow.cpp +++ b/src/Charts/RouteWindow.cpp @@ -29,7 +29,7 @@ using namespace std; #define GOOGLE_KEY "ABQIAAAAS9Z2oFR8vUfLGYSzz40VwRQ69UCJw2HkJgivzGoninIyL8-QPBTtnR-6pM84ljHLEk3PDql0e2nJmg" -RouteWindow::RouteWindow(Context *context) : GcWindow(context) +RouteWindow::RouteWindow(Context *context) : GcChartWindow(context) { this->context = context; this->routeItem = NULL; @@ -89,7 +89,7 @@ RouteWindow::RouteWindow(Context *context) : GcWindow(context) layoutV->addLayout(layoutH); //layoutV->addWidget(rideTable); - setLayout(layoutV); + setChartLayout(layoutV); diff --git a/src/Charts/RouteWindow.h b/src/Charts/RouteWindow.h index 1fb6f1d8b0..74478c6e04 100644 --- a/src/Charts/RouteWindow.h +++ b/src/Charts/RouteWindow.h @@ -63,7 +63,7 @@ class WebBridgeForRoute : public QObject void drawIntervals(); }; -class RouteWindow : public GcWindow +class RouteWindow : public GcChartWindow { Q_OBJECT G_OBJECT diff --git a/src/Charts/SummaryWindow.cpp b/src/Charts/SummaryWindow.cpp index 622c12da37..55f7be518e 100644 --- a/src/Charts/SummaryWindow.cpp +++ b/src/Charts/SummaryWindow.cpp @@ -19,17 +19,18 @@ #include "SummaryWindow.h" SummaryWindow::SummaryWindow(Context *context) : - GcWindow(context), context(context) + GcChartWindow(context), context(context) { setControls(NULL); setRideItem(NULL); splitter = new QSplitter(Qt::Vertical, this); splitter->setHandleWidth(1); - QVBoxLayout *vlayout = new QVBoxLayout(this); + QVBoxLayout *vlayout = new QVBoxLayout; vlayout->setSpacing(0); vlayout->setContentsMargins(1,1,1,1); vlayout->addWidget(splitter); + setChartLayout(vlayout); rideSummary = new RideSummaryWindow(context); rideMetadata = new RideMetadata(context); diff --git a/src/Charts/SummaryWindow.h b/src/Charts/SummaryWindow.h index 36dc4c9519..2889383af5 100644 --- a/src/Charts/SummaryWindow.h +++ b/src/Charts/SummaryWindow.h @@ -27,7 +27,7 @@ class Context; -class SummaryWindow : public GcWindow +class SummaryWindow : public GcChartWindow { Q_OBJECT G_OBJECT diff --git a/src/Charts/TreeMapPlot.cpp b/src/Charts/TreeMapPlot.cpp index d7002d83ba..e172a25e62 100644 --- a/src/Charts/TreeMapPlot.cpp +++ b/src/Charts/TreeMapPlot.cpp @@ -79,6 +79,7 @@ TreeMapPlot::setData(TMSettings *settings) // layout and paint resizeEvent(NULL); + repaint(); } @@ -238,6 +239,5 @@ TreeMapPlot::eventFilter(QObject *, QEvent *e) } } } - return false; } diff --git a/src/Charts/TreeMapWindow.cpp b/src/Charts/TreeMapWindow.cpp index 052dd15382..726a766d0c 100644 --- a/src/Charts/TreeMapWindow.cpp +++ b/src/Charts/TreeMapWindow.cpp @@ -27,6 +27,7 @@ #include "cmath" #include "Units.h" // for MILES_PER_KM #include "HelpWhatsThis.h" +#include "GoldenCheetah.h" #include #include @@ -37,26 +38,30 @@ #include TreeMapWindow::TreeMapWindow(Context *context) : - GcWindow(context), context(context), active(false), dirty(true), useCustom(false), useToToday(false) + GcChartWindow(context), context(context), active(false), dirty(true), useCustom(false), useToToday(false) { + // the controls + QWidget *c = new QWidget; + HelpWhatsThis *helpConfig = new HelpWhatsThis(c); + c->setWhatsThis(helpConfig->getWhatsThisText(HelpWhatsThis::ChartTrends_CollectionTreeMap)); + QFormLayout *cl = new QFormLayout(c); + setControls(c); + // the plot mainLayout = new QVBoxLayout; + ltmPlot = new TreeMapPlot(this, context); + ltmPlot->setVisible(true); mainLayout->addWidget(ltmPlot); mainLayout->setSpacing(0); mainLayout->setContentsMargins(0,0,0,0); - setLayout(mainLayout); + setChartLayout(mainLayout); + + setIsBlank(false); HelpWhatsThis *helpLTMPlot = new HelpWhatsThis(ltmPlot); ltmPlot->setWhatsThis(helpLTMPlot->getWhatsThisText(HelpWhatsThis::ChartTrends_CollectionTreeMap)); - // the controls - QWidget *c = new QWidget; - HelpWhatsThis *helpConfig = new HelpWhatsThis(c); - c->setWhatsThis(helpConfig->getWhatsThisText(HelpWhatsThis::ChartTrends_CollectionTreeMap)); - QFormLayout *cl = new QFormLayout(c); - setControls(c); - // read metadata.xml QString filename = context->athlete->home->config().absolutePath()+"/metadata.xml"; QString colorfield; diff --git a/src/Charts/TreeMapWindow.h b/src/Charts/TreeMapWindow.h index 721f50ec76..b1bbd9e5df 100644 --- a/src/Charts/TreeMapWindow.h +++ b/src/Charts/TreeMapWindow.h @@ -44,7 +44,7 @@ class TMSettings }; class TreeMapPlot; -class TreeMapWindow : public GcWindow +class TreeMapWindow : public GcChartWindow { Q_OBJECT G_OBJECT diff --git a/src/Gui/GcWindowRegistry.cpp b/src/Gui/GcWindowRegistry.cpp index 9a475e3142..b30fb39d67 100644 --- a/src/Gui/GcWindowRegistry.cpp +++ b/src/Gui/GcWindowRegistry.cpp @@ -148,10 +148,10 @@ QList idsForType(int type) } // instantiate a new window -GcWindow * +GcChartWindow * GcWindowRegistry::newGcWindow(GcWinID id, Context *context) { - GcWindow *returning = NULL; + GcChartWindow *returning = NULL; switch(id) { case GcWindowTypes::Aerolab: returning = new AerolabWindow(context); break; @@ -161,15 +161,15 @@ GcWindowRegistry::newGcWindow(GcWinID id, Context *context) #ifdef GC_HAVE_ICAL case GcWindowTypes::Diary: returning = new DiaryWindow(context); break; #else - case GcWindowTypes::Diary: returning = new GcWindow(); break; + case GcWindowTypes::Diary: returning = new GcChartWindow(context); break; #endif case GcWindowTypes::Histogram: returning = new HistogramWindow(context); break; #ifdef GC_WANT_R case GcWindowTypes::RConsole: returning = new RChart(context, true); break; case GcWindowTypes::RConsoleSeason: returning = new RChart(context, false); break; #else - case GcWindowTypes::RConsole: returning = new GcWindow(); break; - case GcWindowTypes::RConsoleSeason: returning = new GcWindow(); break; + case GcWindowTypes::RConsole: returning = new GcChartWindow(context); break; + case GcWindowTypes::RConsoleSeason: returning = new GcChartWindow(context); break; #endif case GcWindowTypes::Distribution: returning = new HistogramWindow(context, true); break; case GcWindowTypes::PerformanceManager: @@ -193,7 +193,7 @@ GcWindowRegistry::newGcWindow(GcWinID id, Context *context) #ifdef GC_HAVE_QWTPLOT3D case GcWindowTypes::Model: returning = new ModelWindow(context); break; #else - case GcWindowTypes::Model: returning = new GcWindow(); break; + case GcWindowTypes::Model: returning = new GcChartWindow(context); break; #endif case GcWindowTypes::PfPv: returning = new PfPvWindow(context); break; case GcWindowTypes::HrPw: returning = new HrPwWindow(context); break; @@ -205,20 +205,20 @@ GcWindowRegistry::newGcWindow(GcWinID id, Context *context) case GcWindowTypes::TreeMap: returning = new TreeMapWindow(context); break; case GcWindowTypes::WeeklySummary: returning = new SummaryWindow(context); break; // deprecated #ifdef GC_VIDEO_NONE - case GcWindowTypes::VideoPlayer: returning = new GcWindow(); break; + case GcWindowTypes::VideoPlayer: returning = new GcChartWindow(context); break; #else case GcWindowTypes::VideoPlayer: returning = new VideoWindow(context); break; #endif case GcWindowTypes::DialWindow: returning = new DialWindow(context); break; case GcWindowTypes::MetadataWindow: returning = new MetadataWindow(context); break; - case GcWindowTypes::RealtimeControls: returning = new GcWindow(); break; + case GcWindowTypes::RealtimeControls: returning = new GcChartWindow(context); break; case GcWindowTypes::RealtimePlot: returning = new RealtimePlotWindow(context); break; case GcWindowTypes::SpinScanPlot: returning = new SpinScanPlotWindow(context); break; case GcWindowTypes::WorkoutPlot: returning = new WorkoutPlotWindow(context); break; #ifdef NOWEBKIT case GcWindowTypes::MapWindow: case GcWindowTypes::StreetViewWindow: - returning = new GcWindow(); break; + returning = new GcChartWindow(context); break; break; #else case GcWindowTypes::MapWindow: returning = new MapWindow(context); break; @@ -235,7 +235,7 @@ GcWindowRegistry::newGcWindow(GcWinID id, Context *context) #if 0 // not till v4.0 case GcWindowTypes::RouteSegment: returning = new RouteWindow(context); break; #else - case GcWindowTypes::RouteSegment: returning = new GcWindow(); break; + case GcWindowTypes::RouteSegment: returning = new GcChartWindow(context); break; #endif default: return NULL; break; } diff --git a/src/Gui/GcWindowRegistry.h b/src/Gui/GcWindowRegistry.h index afa555598b..8d4635d5b2 100644 --- a/src/Gui/GcWindowRegistry.h +++ b/src/Gui/GcWindowRegistry.h @@ -78,6 +78,7 @@ Q_DECLARE_METATYPE(GcWinID) #define VIEW_HOME 0x08 #define VIEW_INTERVAL 0x16 +class GcChartWindow; class GcWindowRegistry { Q_DECLARE_TR_FUNCTIONS(GcWindowRegistry) public: @@ -87,7 +88,7 @@ class GcWindowRegistry { GcWinID id; static void initialize(); // initialize global registry - static GcWindow *newGcWindow(GcWinID id, Context *context); + static GcChartWindow *newGcWindow(GcWinID id, Context *context); static QStringList windowsForType(int type); static QList idsForType(int type); static QString title(GcWinID id); diff --git a/src/Gui/LTMSidebar.cpp b/src/Gui/LTMSidebar.cpp index 7cbcbab6b3..d82492eebb 100644 --- a/src/Gui/LTMSidebar.cpp +++ b/src/Gui/LTMSidebar.cpp @@ -1588,7 +1588,7 @@ LTMSidebar::presetMoved(QTreeWidgetItem *, int, int) void LTMSidebar::addPreset() { - GcWindow *newone = NULL; + GcChartWindow *newone = NULL; // GcWindowDialog is delete on close, so no need to delete GcWindowDialog *f = new GcWindowDialog(GcWindowTypes::LTM, context, &newone, true); @@ -1617,7 +1617,7 @@ LTMSidebar::addPreset() void LTMSidebar::editPreset() { - GcWindow *newone = NULL; + GcChartWindow *newone = NULL; int index = allCharts->indexOfChild(chartTree->selectedItems()[0]); diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp index 62aae50ace..c681714f34 100644 --- a/src/Gui/MainWindow.cpp +++ b/src/Gui/MainWindow.cpp @@ -912,6 +912,17 @@ MainWindow::addChart(QAction*action) } #ifdef GC_HAS_CLOUD_DB + +void +MainWindow::exportChartToCloudDB() +{ + // upload the current chart selected to the chart db + // called from the sidebar menu + HomeWindow *page=currentTab->view(currentTab->currentView())->page(); + if (page->currentStyle == 0 && page->currentChart()) + page->currentChart()->exportChartToCloudDB(); +} + void MainWindow::addChartFromCloudDB() { diff --git a/src/Gui/MainWindow.h b/src/Gui/MainWindow.h index 17ffea3d1a..a2ef84bd72 100644 --- a/src/Gui/MainWindow.h +++ b/src/Gui/MainWindow.h @@ -234,6 +234,7 @@ class MainWindow : public QMainWindow void cloudDBcuratorEditChart(); void cloudDBshowStatus(); void addChartFromCloudDB(); + void exportChartToCloudDB(); #endif // save and restore state to context void saveGCState(Context *); diff --git a/src/Gui/RideNavigator.cpp b/src/Gui/RideNavigator.cpp index 7ea38bfcb0..9a06cd4929 100644 --- a/src/Gui/RideNavigator.cpp +++ b/src/Gui/RideNavigator.cpp @@ -35,7 +35,7 @@ #include #include -RideNavigator::RideNavigator(Context *context, bool mainwindow) : context(context), active(false), _groupBy(-1) +RideNavigator::RideNavigator(Context *context, bool mainwindow) : GcChartWindow(context), context(context), active(false), _groupBy(-1) { // get column headings // default column layouts etc @@ -53,7 +53,8 @@ RideNavigator::RideNavigator(Context *context, bool mainwindow) : context(contex init = false; - mainLayout = new QVBoxLayout(this); + mainLayout = new QVBoxLayout; + setChartLayout(mainLayout); mainLayout->setSpacing(0); if (mainwindow) mainLayout->setContentsMargins(0,0,0,0); else mainLayout->setContentsMargins(2,2,2,2); // so we can resize! diff --git a/src/Gui/RideNavigator.h b/src/Gui/RideNavigator.h index 346a721933..247fcbffc8 100644 --- a/src/Gui/RideNavigator.h +++ b/src/Gui/RideNavigator.h @@ -56,7 +56,7 @@ class EditUserMetricDialog; // a QSQLTableModel which reads from the "metrics" table // via the DBAccess database connection // -class RideNavigator : public GcWindow +class RideNavigator : public GcChartWindow { Q_OBJECT G_OBJECT diff --git a/src/Train/DialWindow.cpp b/src/Train/DialWindow.cpp index 80b8bf3c4b..78ce88d187 100644 --- a/src/Train/DialWindow.cpp +++ b/src/Train/DialWindow.cpp @@ -22,7 +22,7 @@ #include "Context.h" DialWindow::DialWindow(Context *context) : - GcWindow(context), context(context), average(1), isNewLap(false) + GcChartWindow(context), context(context), average(1), isNewLap(false) { rolling.resize(150); // enough for 30 seconds at 5hz @@ -70,12 +70,13 @@ DialWindow::DialWindow(Context *context) : controlsLayout->addRow(averageLabel, averageLayout); // display label... - QVBoxLayout *layout = new QVBoxLayout(this); + QVBoxLayout *layout = new QVBoxLayout; layout->setSpacing(0); layout->setContentsMargins(3,3,3,3); valueLabel = new QLabel(this); valueLabel->setAlignment(Qt::AlignCenter | Qt::AlignVCenter); layout->addWidget(valueLabel); + setChartLayout(layout); // get updates.. connect(context, SIGNAL(telemetryUpdate(RealtimeData)), this, SLOT(telemetryUpdate(RealtimeData))); diff --git a/src/Train/DialWindow.h b/src/Train/DialWindow.h index a5e5ff0ac8..f1aa724c49 100644 --- a/src/Train/DialWindow.h +++ b/src/Train/DialWindow.h @@ -36,7 +36,7 @@ #include "Units.h" // for realtimedata structure #include "Colors.h" // for realtimedata structure -class DialWindow : public GcWindow +class DialWindow : public GcChartWindow { Q_OBJECT G_OBJECT diff --git a/src/Train/RealtimePlotWindow.cpp b/src/Train/RealtimePlotWindow.cpp index 241e86197a..773d5195f8 100644 --- a/src/Train/RealtimePlotWindow.cpp +++ b/src/Train/RealtimePlotWindow.cpp @@ -21,7 +21,7 @@ #include "Athlete.h" RealtimePlotWindow::RealtimePlotWindow(Context *context) : - GcWindow(context), context(context), active(false) + GcChartWindow(context), context(context), active(false) { setContentsMargins(0,0,0,0); setProperty("color", GColor(CTRAINPLOTBACKGROUND)); @@ -91,9 +91,10 @@ RealtimePlotWindow::RealtimePlotWindow(Context *context) : cl->addWidget(smoothSlider); cl->addStretch(); - QVBoxLayout *layout = new QVBoxLayout(this); + QVBoxLayout *layout = new QVBoxLayout; rtPlot = new RealtimePlot(context); layout->addWidget(rtPlot); + setChartLayout(layout); // common controls connect(showPower, SIGNAL(stateChanged(int)), this, SLOT(setShowPower(int))); diff --git a/src/Train/RealtimePlotWindow.h b/src/Train/RealtimePlotWindow.h index 9db7fc4267..45af4aa690 100644 --- a/src/Train/RealtimePlotWindow.h +++ b/src/Train/RealtimePlotWindow.h @@ -36,7 +36,7 @@ #include "Units.h" #include "Colors.h" -class RealtimePlotWindow : public GcWindow +class RealtimePlotWindow : public GcChartWindow { Q_OBJECT G_OBJECT diff --git a/src/Train/SpinScanPlotWindow.cpp b/src/Train/SpinScanPlotWindow.cpp index a09ffd1988..7ee8c347a6 100644 --- a/src/Train/SpinScanPlotWindow.cpp +++ b/src/Train/SpinScanPlotWindow.cpp @@ -21,7 +21,7 @@ #include "Context.h" SpinScanPlotWindow::SpinScanPlotWindow(Context *context) : - GcWindow(context), context(context), active(false) + GcChartWindow(context), context(context), active(false) { setContentsMargins(0,0,0,0); setProperty("color", GColor(CTRAINPLOTBACKGROUND)); @@ -62,7 +62,8 @@ SpinScanPlotWindow::SpinScanPlotWindow(Context *context) : history[14] = set15; history[15] = set16; - QVBoxLayout *layout = new QVBoxLayout(this); + QVBoxLayout *layout = new QVBoxLayout; + setChartLayout(layout); stack = new QStackedWidget(this); rtPlot = new SpinScanPlot(this, spinData); diff --git a/src/Train/SpinScanPlotWindow.h b/src/Train/SpinScanPlotWindow.h index 511d749fe2..ac97dcc0c3 100644 --- a/src/Train/SpinScanPlotWindow.h +++ b/src/Train/SpinScanPlotWindow.h @@ -35,7 +35,7 @@ #include "Settings.h" #include "Colors.h" -class SpinScanPlotWindow : public GcWindow +class SpinScanPlotWindow : public GcChartWindow { Q_OBJECT G_OBJECT diff --git a/src/Train/VideoWindow.cpp b/src/Train/VideoWindow.cpp index 6b5d88230a..4f7cd3e550 100644 --- a/src/Train/VideoWindow.cpp +++ b/src/Train/VideoWindow.cpp @@ -27,13 +27,13 @@ VideoWindow::VideoWindow(Context *context) : - GcWindow(context), context(context), m_MediaChanged(false) + GcChartWindow(context), context(context), m_MediaChanged(false) { setControls(NULL); setProperty("color", QColor(Qt::black)); QHBoxLayout *layout = new QHBoxLayout(); - setLayout(layout); + setChartLayout(layout); curPosition = 1; diff --git a/src/Train/VideoWindow.h b/src/Train/VideoWindow.h index a5cdcbc107..2772a0200b 100644 --- a/src/Train/VideoWindow.h +++ b/src/Train/VideoWindow.h @@ -154,7 +154,7 @@ class MediaHelper #endif }; -class VideoWindow : public GcWindow +class VideoWindow : public GcChartWindow { Q_OBJECT G_OBJECT diff --git a/src/Train/WorkoutPlotWindow.cpp b/src/Train/WorkoutPlotWindow.cpp index f3bc931925..f46984031b 100644 --- a/src/Train/WorkoutPlotWindow.cpp +++ b/src/Train/WorkoutPlotWindow.cpp @@ -21,13 +21,14 @@ #include "Context.h" WorkoutPlotWindow::WorkoutPlotWindow(Context *context) : - GcWindow(context), context(context) + GcChartWindow(context), context(context) { setContentsMargins(0,0,0,0); setControls(NULL); setProperty("color", GColor(CTRAINPLOTBACKGROUND)); - QVBoxLayout *layout = new QVBoxLayout(this); + QVBoxLayout *layout = new QVBoxLayout; + setChartLayout(layout); layout->setSpacing(0); layout->setContentsMargins(2,2,2,2); ergPlot = new ErgFilePlot(context); diff --git a/src/Train/WorkoutPlotWindow.h b/src/Train/WorkoutPlotWindow.h index 0f986d8ffb..6280d3d79a 100644 --- a/src/Train/WorkoutPlotWindow.h +++ b/src/Train/WorkoutPlotWindow.h @@ -32,7 +32,7 @@ #include "Settings.h" #include "Colors.h" -class WorkoutPlotWindow : public GcWindow +class WorkoutPlotWindow : public GcChartWindow { Q_OBJECT G_OBJECT diff --git a/src/Train/WorkoutWindow.cpp b/src/Train/WorkoutWindow.cpp index 9ab4e21c9a..5655f34498 100644 --- a/src/Train/WorkoutWindow.cpp +++ b/src/Train/WorkoutWindow.cpp @@ -24,7 +24,7 @@ static int MINTOOLHEIGHT = 350; // smaller than this, lose the toolbar WorkoutWindow::WorkoutWindow(Context *context) : - GcWindow(context), draw(true), context(context), active(false), recording(false) + GcChartWindow(context), draw(true), context(context), active(false), recording(false) { setContentsMargins(0,0,0,0); setProperty("color", GColor(CTRAINPLOTBACKGROUND)); @@ -32,9 +32,10 @@ WorkoutWindow::WorkoutWindow(Context *context) : setControls(NULL); ergFile = NULL; - QVBoxLayout *main = new QVBoxLayout(this); + QVBoxLayout *main = new QVBoxLayout; QHBoxLayout *layout = new QHBoxLayout; QVBoxLayout *editor = new QVBoxLayout; + setChartLayout(main); connect(context, SIGNAL(configChanged(qint32)), this, SLOT(configChanged(qint32))); diff --git a/src/Train/WorkoutWindow.h b/src/Train/WorkoutWindow.h index fadb15bcc4..b4c96a7fa8 100644 --- a/src/Train/WorkoutWindow.h +++ b/src/Train/WorkoutWindow.h @@ -58,7 +58,7 @@ class WWLap; class WWNow; class WWTelemetry; -class WorkoutWindow : public GcWindow +class WorkoutWindow : public GcChartWindow { Q_OBJECT