File indexing completed on 2024-12-15 03:45:00

0001 /*
0002     SPDX-FileCopyrightText: 2016 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: MIT
0005 */
0006 
0007 #ifndef KUSERFEEDBACK_CONSOLE_AGGREGATEDDATAMODEL_H
0008 #define KUSERFEEDBACK_CONSOLE_AGGREGATEDDATAMODEL_H
0009 
0010 #include <QAbstractTableModel>
0011 #include <QVector>
0012 
0013 namespace KUserFeedback {
0014 namespace Console {
0015 
0016 /** Joint model for all time-aggregated data, for user display and export. */
0017 class AggregatedDataModel : public QAbstractTableModel
0018 {
0019     Q_OBJECT
0020 public:
0021     explicit AggregatedDataModel(QObject *parent = nullptr);
0022     ~AggregatedDataModel() override;
0023 
0024     void addSourceModel(QAbstractItemModel *model, const QString &prefix = QString());
0025     void clear();
0026 
0027     int rowCount(const QModelIndex &parent) const override;
0028     int columnCount(const QModelIndex &parent) const override;
0029     QVariant data(const QModelIndex &index, int role) const override;
0030     QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
0031 
0032 private:
0033     void recreateColumnMapping();
0034 
0035     QVector<QAbstractItemModel*> m_models;
0036     QVector<QString> m_prefixes;
0037     QVector<int> m_columnMapping;
0038     QVector<int> m_columnOffset;
0039 };
0040 
0041 }
0042 }
0043 
0044 #endif // KUSERFEEDBACK_CONSOLE_AGGREGATEDDATAMODEL_H