File indexing completed on 2024-12-15 03:45:01
0001 /* 0002 SPDX-FileCopyrightText: 2016 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: MIT 0005 */ 0006 0007 #ifndef KUSERFEEDBACK_CONSOLE_CATEGORYAGGREGATIONMODEL_H 0008 #define KUSERFEEDBACK_CONSOLE_CATEGORYAGGREGATIONMODEL_H 0009 0010 #include <core/aggregation.h> 0011 0012 #include <QAbstractTableModel> 0013 #include <QVector> 0014 0015 namespace KUserFeedback { 0016 namespace Console { 0017 0018 class Sample; 0019 0020 /** Aggregate by time and one string category value (e.g. version. platform, etc). */ 0021 class CategoryAggregationModel : public QAbstractTableModel 0022 { 0023 Q_OBJECT 0024 public: 0025 explicit CategoryAggregationModel(QObject *parent = nullptr); 0026 ~CategoryAggregationModel() override; 0027 0028 void setSourceModel(QAbstractItemModel *model); 0029 void setAggregation(const Aggregation &aggr); 0030 /*! Limits depth to @p depth, even if the aggregation has a higher one. */ 0031 void setDepth(int depth); 0032 0033 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0034 int columnCount(const QModelIndex &parent = QModelIndex()) const override; 0035 QVariant data(const QModelIndex &index, int role) const override; 0036 QVariant headerData(int section, Qt::Orientation orientation, int role) const override; 0037 0038 private: 0039 void recompute(); 0040 QVariant sampleValue(const Sample &s, int depth) const; 0041 0042 QAbstractItemModel *m_sourceModel = nullptr; 0043 Aggregation m_aggr; 0044 QVector<QString> m_categories; 0045 int *m_data = nullptr; 0046 int m_maxValue; 0047 int m_depth; 0048 }; 0049 0050 } 0051 } 0052 0053 #endif // KUSERFEEDBACK_CONSOLE_CATEGORYAGGREGATIONMODEL_H