1 /* 2 SPDX-FileCopyrightText: 2018 Friedrich W. H. Kossebau <kossebau@kde.org> 3 4 SPDX-License-Identifier: GPL-2.0-or-later 5 */ 6 7 #ifndef CLANGTIDY_CHECKLISTMODEL_H 8 #define CLANGTIDY_CHECKLISTMODEL_H 9 10 // plugin 11 #include "checkgroup.h" 12 // Qt 13 #include <QAbstractItemModel> 14 15 namespace ClangTidy 16 { 17 18 class CheckSet; 19 20 class CheckListModel : public QAbstractItemModel 21 { 22 Q_OBJECT 23 24 public: 25 enum Roles { 26 EffectiveEnabledStateRole = Qt::UserRole+1, 27 HasExplicitEnabledStateRole 28 }; 29 30 enum ColumIds { 31 NameColumnId = 0, 32 CountColumnId = 1 33 }; 34 35 public: 36 explicit CheckListModel(QObject* parent = nullptr); 37 ~CheckListModel() override; 38 39 public: // QAbstractItemModel API 40 QVariant data(const QModelIndex& index, int role) const override; 41 int columnCount(const QModelIndex& parent) const override; 42 int rowCount(const QModelIndex& parent) const override; 43 QModelIndex parent(const QModelIndex& child) const override; 44 QModelIndex index(int row, int column, const QModelIndex& parent) const override; 45 Qt::ItemFlags flags(const QModelIndex& index) const override; 46 bool setData(const QModelIndex& index, const QVariant& value, int role) override; 47 48 public: 49 void setCheckSet(const CheckSet* checkSet); 50 void setEnabledChecks(const QStringList& enabledChecks); 51 QStringList enabledChecks() const; 52 void setEditable(bool editable); 53 54 Q_SIGNALS: 55 void enabledChecksChanged(); 56 57 private: 58 int childCount(const CheckGroup* checkGroup) const; 59 CheckGroup* checkGroup(const QModelIndex& index) const; 60 void emitSubGroupDataChanged(const QModelIndex& subGroupIndex); 61 62 private: 63 const CheckSet* m_checkSet = nullptr; 64 65 QScopedPointer<CheckGroup> m_rootCheckGroup; 66 bool m_isDefault = true; 67 bool m_isEditable = true; 68 }; 69 70 } 71 72 #endif // CHECKLISTMODEL_H 73