File indexing completed on 2024-12-15 03:44:59

0001 /*
0002     SPDX-FileCopyrightText: 2016 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: MIT
0005 */
0006 
0007 #ifndef KUSERFEEDBACK_CONSOLE_ANALYTICSVIEW_H
0008 #define KUSERFEEDBACK_CONSOLE_ANALYTICSVIEW_H
0009 
0010 #include <core/product.h>
0011 
0012 #include <QVector>
0013 #include <QWidget>
0014 
0015 #include <memory>
0016 
0017 class QAbstractItemModel;
0018 
0019 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
0020 namespace QtCharts {
0021 class QChart;
0022 class QChartView;
0023 }
0024 using QtCharts::QChart;
0025 using QtCharts::QChartView;
0026 #else
0027 class QChart;
0028 #endif
0029 
0030 namespace KUserFeedback {
0031 namespace Console {
0032 
0033 class Aggregator;
0034 class AggregatedDataModel;
0035 class DataModel;
0036 class RESTClient;
0037 class TimeAggregationModel;
0038 
0039 namespace Ui
0040 {
0041 class AnalyticsView;
0042 }
0043 
0044 class AnalyticsView : public QWidget
0045 {
0046     Q_OBJECT
0047 public:
0048     explicit AnalyticsView(QWidget *parent = nullptr);
0049     ~AnalyticsView() override;
0050 
0051     void setProduct(const Product &product);
0052     void setRESTClient(RESTClient *client);
0053 
0054 Q_SIGNALS:
0055     void logMessage(const QString &msg);
0056 
0057 private:
0058     void chartSelected();
0059     void updateChart();
0060     void updateTimeSliderRange();
0061 
0062     Aggregator* createAggregator(const Aggregation &aggr) const;
0063 
0064     void exportData();
0065     void importData();
0066     void exportChart();
0067 
0068     std::unique_ptr<Ui::AnalyticsView> ui;
0069 
0070     RESTClient *m_client = nullptr;
0071     DataModel *m_dataModel;
0072     TimeAggregationModel *m_timeAggregationModel;
0073     AggregatedDataModel *m_aggregatedDataModel;
0074 
0075     QVector<Aggregator*> m_aggregators;
0076 
0077     std::unique_ptr<QChart> m_nullSingularChart;
0078     std::unique_ptr<QChart> m_nullTimelineChart;
0079 };
0080 }
0081 }
0082 
0083 #endif // KUSERFEEDBACK_CONSOLE_ANALYTICSVIEW_H