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_CHECKSELECTION_H
8 #define CLANGTIDY_CHECKSELECTION_H
9 
10 // Qt
11 #include <QWidget>
12 
13 class QTreeView;
14 class QSortFilterProxyModel;
15 
16 namespace ClangTidy
17 {
18 
19 class CheckSet;
20 class CheckListModel;
21 class CheckListItemProxyStyle;
22 
23 class CheckSelection : public QWidget
24 {
25     Q_OBJECT
26     Q_PROPERTY(QString checks READ checks WRITE setChecks NOTIFY checksChanged USER true)
27 
28 public:
29     explicit CheckSelection(QWidget* parent = nullptr);
30     ~CheckSelection() override;
31 
32 public:
33     void setCheckSet(const CheckSet* checkSet);
34 
35     void setChecks(const QString& checks);
36     QString checks() const;
37 
38     void setEditable(bool editable);
39 
40 protected: // QObject API
41     bool event(QEvent *event) override;
42 
43 Q_SIGNALS:
44     void checksChanged(const QString& checks);
45 
46 private:
47     void expandSubGroupsWithExplicitlyEnabledStates();
48     void expandSubGroupsWithExplicitlyEnabledStates(const QModelIndex& groupIndex);
49 
50 private Q_SLOTS:
51     void onEnabledChecksChanged();
52 
53 private:
54     const CheckSet* m_checkSet = nullptr;
55     CheckListModel* m_checkListModel;
56     QSortFilterProxyModel* m_checksFilterProxyModel;
57     QTreeView* m_checkListView;
58     CheckListItemProxyStyle* m_proxyStyle;
59 };
60 
61 }
62 #endif
63