1 /* 2 Copyright (C) 2016 Volker Krause <vkrause@kde.org> 3 4 Permission is hereby granted, free of charge, to any person obtaining 5 a copy of this software and associated documentation files (the 6 "Software"), to deal in the Software without restriction, including 7 without limitation the rights to use, copy, modify, merge, publish, 8 distribute, sublicense, and/or sell copies of the Software, and to 9 permit persons to whom the Software is furnished to do so, subject to 10 the following conditions: 11 12 The above copyright notice and this permission notice shall be included 13 in all copies or substantial portions of the Software. 14 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 19 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 20 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 21 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 */ 23 24 #ifndef KUSERFEEDBACK_CONSOLE_ANALYTICSVIEW_H 25 #define KUSERFEEDBACK_CONSOLE_ANALYTICSVIEW_H 26 27 #include <core/product.h> 28 29 #include <QVector> 30 #include <QWidget> 31 32 #include <memory> 33 34 class QAbstractItemModel; 35 36 namespace QtCharts { 37 class QChart; 38 } 39 40 namespace KUserFeedback { 41 namespace Console { 42 43 class Aggregator; 44 class AggregatedDataModel; 45 class DataModel; 46 class RESTClient; 47 class TimeAggregationModel; 48 49 namespace Ui 50 { 51 class AnalyticsView; 52 } 53 54 class AnalyticsView : public QWidget 55 { 56 Q_OBJECT 57 public: 58 explicit AnalyticsView(QWidget *parent = nullptr); 59 ~AnalyticsView(); 60 61 void setProduct(const Product &product); 62 void setRESTClient(RESTClient *client); 63 64 signals: 65 void logMessage(const QString &msg); 66 67 private: 68 void chartSelected(); 69 void updateChart(); 70 void updateTimeSliderRange(); 71 72 Aggregator* createAggregator(const Aggregation &aggr) const; 73 74 void exportData(); 75 void importData(); 76 void exportChart(); 77 78 std::unique_ptr<Ui::AnalyticsView> ui; 79 80 RESTClient *m_client = nullptr; 81 DataModel *m_dataModel; 82 TimeAggregationModel *m_timeAggregationModel; 83 AggregatedDataModel *m_aggregatedDataModel; 84 85 QVector<Aggregator*> m_aggregators; 86 87 std::unique_ptr<QtCharts::QChart> m_nullSingularChart; 88 std::unique_ptr<QtCharts::QChart> m_nullTimelineChart; 89 }; 90 } 91 } 92 93 #endif // KUSERFEEDBACK_CONSOLE_ANALYTICSVIEW_H 94