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_SURVEYMODEL_H 0008 #define KUSERFEEDBACK_CONSOLE_SURVEYMODEL_H 0009 0010 #include <core/product.h> 0011 #include <core/survey.h> 0012 0013 #include <QAbstractTableModel> 0014 0015 namespace KUserFeedback { 0016 namespace Console { 0017 0018 class RESTClient; 0019 0020 class SurveyModel : public QAbstractTableModel 0021 { 0022 Q_OBJECT 0023 public: 0024 enum Role { 0025 SurveyRole = Qt::UserRole + 1 0026 }; 0027 0028 explicit SurveyModel(QObject *parent = nullptr); 0029 ~SurveyModel() override; 0030 0031 void setRESTClient(RESTClient *client); 0032 void setProduct(const Product &product); 0033 void reload(); 0034 0035 int columnCount(const QModelIndex &parent = QModelIndex()) const override; 0036 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0037 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0038 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; 0039 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; 0040 Qt::ItemFlags flags(const QModelIndex &index) const override; 0041 0042 private: 0043 RESTClient *m_restClient = nullptr; 0044 Product m_product; 0045 QVector<Survey> m_surveys; 0046 }; 0047 0048 } 0049 } 0050 0051 #endif // KUSERFEEDBACK_CONSOLE_SURVEYMODEL_H