Commit 5e07543c authored by Volker Krause's avatar Volker Krause
Browse files

Add null charts, QtCharts can't handle null or deleted charts

parent 790dac48
......@@ -20,6 +20,7 @@
#include "aggregator.h"
#include "categoryaggregator.h"
#include "chartutil.h"
#include "numericaggregator.h"
#include "ratiosetaggregator.h"
#include "totalaggregator.h"
......@@ -31,6 +32,8 @@
#include <core/aggregation.h>
#include <core/sample.h>
#include <QtCharts/QChart>
#include <QFile>
#include <QFileDialog>
#include <QMenu>
......@@ -45,10 +48,17 @@ AnalyticsView::AnalyticsView(QWidget* parent) :
ui(new Ui::AnalyticsView),
m_dataModel(new DataModel(this)),
m_timeAggregationModel(new TimeAggregationModel(this)),
m_aggregatedDataModel(new AggregatedDataModel(this))
m_aggregatedDataModel(new AggregatedDataModel(this)),
m_nullSingularChart(new QtCharts::QChart),
m_nullTimelineChart(new QtCharts::QChart)
{
ui->setupUi(this);
ChartUtil::applyTheme(m_nullSingularChart.get());
ChartUtil::applyTheme(m_nullTimelineChart.get());
ui->singularChartView->setChart(m_nullSingularChart.get());
ui->timelineChartView->setChart(m_nullTimelineChart.get());
ui->dataView->setModel(m_dataModel);
ui->aggregatedDataView->setModel(m_aggregatedDataModel);
......@@ -133,6 +143,10 @@ void AnalyticsView::setRESTClient(RESTClient* client)
void AnalyticsView::setProduct(const Product& product)
{
// the chart views can't handle null or deleted charts, so set them to something safe
ui->singularChartView->setChart(m_nullSingularChart.get());
ui->timelineChartView->setChart(m_nullTimelineChart.get());
m_dataModel->setProduct(product);
ui->chartType->clear();
......
......@@ -27,6 +27,10 @@
class QAbstractItemModel;
namespace QtCharts {
class QChart;
}
namespace UserFeedback {
namespace Analyzer {
......@@ -72,6 +76,9 @@ private:
AggregatedDataModel *m_aggregatedDataModel;
QVector<Aggregator*> m_aggregators;
std::unique_ptr<QtCharts::QChart> m_nullSingularChart;
std::unique_ptr<QtCharts::QChart> m_nullTimelineChart;
};
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment