diff --git a/src/LTMPlot.cpp b/src/LTMPlot.cpp index 534ca3479..d9f078794 100644 --- a/src/LTMPlot.cpp +++ b/src/LTMPlot.cpp @@ -1405,7 +1405,7 @@ class LTMPlotZoneLabel: public QwtPlotItem void LTMPlot::refreshMarkers(QDate from, QDate to, int groupby) { - // clear old markers + // clear old markers - if there are any foreach(QwtPlotMarker *m, markers) { m->detach(); delete m; @@ -1415,29 +1415,11 @@ LTMPlot::refreshMarkers(QDate from, QDate to, int groupby) double baseday = groupForDate(from, groupby); // seasons and season events - foreach (Season s, main->seasons->seasons) { + if (settings->events) { + foreach (Season s, main->seasons->seasons) { - if (s.type != Season::temporary && s.name != settings->title && s.getStart() >= from && s.getStart() < to) { + if (s.type != Season::temporary && s.name != settings->title && s.getStart() >= from && s.getStart() < to) { - QwtPlotMarker *mrk = new QwtPlotMarker; - markers.append(mrk); - mrk->attach(this); - mrk->setLineStyle(QwtPlotMarker::VLine); - mrk->setLabelAlignment(Qt::AlignRight | Qt::AlignTop); - mrk->setLinePen(QPen(GColor(CPLOTMARKER), 0, Qt::DashDotLine)); - - QwtText text(s.getName()); - text.setFont(QFont("Helvetica", 10, QFont::Bold)); - text.setColor(GColor(CPLOTMARKER)); - mrk->setValue(double(groupForDate(s.getStart(), groupby)) - baseday, 0.0); - mrk->setLabel(text); - } - - foreach (SeasonEvent event, s.events) { - - if (event.date > from && event.date < to) { - - // and the events... QwtPlotMarker *mrk = new QwtPlotMarker; markers.append(mrk); mrk->attach(this); @@ -1445,14 +1427,33 @@ LTMPlot::refreshMarkers(QDate from, QDate to, int groupby) mrk->setLabelAlignment(Qt::AlignRight | Qt::AlignTop); mrk->setLinePen(QPen(GColor(CPLOTMARKER), 0, Qt::DashDotLine)); - QwtText text(event.name); + QwtText text(s.getName()); text.setFont(QFont("Helvetica", 10, QFont::Bold)); text.setColor(GColor(CPLOTMARKER)); - mrk->setValue(double(groupForDate(event.date, groupby)) - baseday, 10.0); + mrk->setValue(double(groupForDate(s.getStart(), groupby)) - baseday, 0.0); mrk->setLabel(text); } - } + foreach (SeasonEvent event, s.events) { + + if (event.date > from && event.date < to) { + + // and the events... + QwtPlotMarker *mrk = new QwtPlotMarker; + markers.append(mrk); + mrk->attach(this); + mrk->setLineStyle(QwtPlotMarker::VLine); + mrk->setLabelAlignment(Qt::AlignRight | Qt::AlignTop); + mrk->setLinePen(QPen(GColor(CPLOTMARKER), 0, Qt::DashDotLine)); + + QwtText text(event.name); + text.setFont(QFont("Helvetica", 10, QFont::Bold)); + text.setColor(GColor(CPLOTMARKER)); + mrk->setValue(double(groupForDate(event.date, groupby)) - baseday, 10.0); + mrk->setLabel(text); + } + } + } } return; } diff --git a/src/LTMSettings.h b/src/LTMSettings.h index 292acffe6..467a60705 100644 --- a/src/LTMSettings.h +++ b/src/LTMSettings.h @@ -123,6 +123,7 @@ class LTMSettings { int groupBy; bool shadeZones; bool legend; + bool events; QList metrics; QList *data; QList *measures; diff --git a/src/LTMTool.cpp b/src/LTMTool.cpp index 0b5a6c258..e3720d839 100644 --- a/src/LTMTool.cpp +++ b/src/LTMTool.cpp @@ -102,6 +102,9 @@ LTMTool::LTMTool(MainWindow *parent, const QDir &home, bool multi) : QWidget(par showLegend = new QCheckBox("Show Legend"); basicsettingsLayout->addRow(new QLabel(""), showLegend); + showEvents = new QCheckBox("Show Events"); + basicsettingsLayout->addRow(new QLabel(""), showEvents); + // controls saveButton = new QPushButton(tr("Add")); manageButton = new QPushButton(tr("Manage")); diff --git a/src/LTMTool.h b/src/LTMTool.h index 3e25f7161..923e3a503 100644 --- a/src/LTMTool.h +++ b/src/LTMTool.h @@ -91,6 +91,7 @@ class LTMTool : public QWidget QComboBox *groupBy; QCheckBox *shadeZones; QCheckBox *showLegend; + QCheckBox *showEvents; QPushButton *saveButton; QPushButton *manageButton; diff --git a/src/LTMWindow.cpp b/src/LTMWindow.cpp index 8adf93908..ec6ca1ccd 100644 --- a/src/LTMWindow.cpp +++ b/src/LTMWindow.cpp @@ -99,6 +99,7 @@ LTMWindow::LTMWindow(MainWindow *parent, bool useMetricUnits, const QDir &home) settings.data = NULL; settings.groupBy = LTM_DAY; settings.legend = ltmTool->showLegend->isChecked(); + settings.events = ltmTool->showEvents->isChecked(); settings.shadeZones = ltmTool->shadeZones->isChecked(); cl->addWidget(ltmTool); @@ -111,6 +112,7 @@ LTMWindow::LTMWindow(MainWindow *parent, bool useMetricUnits, const QDir &home) connect(ltmTool->presetPicker, SIGNAL(currentIndexChanged(int)), this, SLOT(chartSelected(int))); connect(ltmTool->shadeZones, SIGNAL(stateChanged(int)), this, SLOT(shadeZonesClicked(int))); connect(ltmTool->showLegend, SIGNAL(stateChanged(int)), this, SLOT(showLegendClicked(int))); + connect(ltmTool->showEvents, SIGNAL(stateChanged(int)), this, SLOT(showEventsClicked(int))); connect(ltmTool, SIGNAL(useCustomRange(DateRange)), this, SLOT(useCustomRange(DateRange))); connect(ltmTool, SIGNAL(useThruToday()), this, SLOT(useThruToday())); connect(ltmTool, SIGNAL(useStandardRange()), this, SLOT(useStandardRange())); @@ -327,6 +329,13 @@ LTMWindow::showLegendClicked(int state) refreshPlot(); } +void +LTMWindow::showEventsClicked(int state) +{ + settings.events = state; + refreshPlot(); +} + void LTMWindow::chartSelected(int selected) { diff --git a/src/LTMWindow.h b/src/LTMWindow.h index 13cd3aa00..03e02ee68 100644 --- a/src/LTMWindow.h +++ b/src/LTMWindow.h @@ -93,6 +93,7 @@ class LTMWindow : public LTMPlotContainer Q_PROPERTY(int bin READ bin WRITE setBin USER true) Q_PROPERTY(bool shade READ shade WRITE setShade USER true) Q_PROPERTY(bool legend READ legend WRITE setLegend USER true) + Q_PROPERTY(bool events READ events WRITE setEvents USER true) #ifdef GC_HAVE_LUCENE Q_PROPERTY(QString filter READ filter WRITE setFilter USER true) #endif @@ -120,6 +121,8 @@ class LTMWindow : public LTMPlotContainer void setShade(bool x) { ltmTool->shadeZones->setChecked(x); } bool legend() const { return ltmTool->showLegend->isChecked(); } void setLegend(bool x) { ltmTool->showLegend->setChecked(x); } + bool events() const { return ltmTool->showEvents->isChecked(); } + void setEvents(bool x) { ltmTool->showEvents->setChecked(x); } int useSelected() { return ltmTool->dateSetting->mode(); } void setUseSelected(int x) { ltmTool->dateSetting->setMode(x); } @@ -155,6 +158,7 @@ class LTMWindow : public LTMPlotContainer void metricSelected(); void groupBySelected(int); void shadeZonesClicked(int); + void showEventsClicked(int); void showLegendClicked(int); void chartSelected(int); void saveClicked();