1/*
2 SPDX-FileCopyrightText: 2007, 2006 Rafael Fernández López <ereslibre@kde.org>
3 SPDX-FileCopyrightText: 2002-2003 Matthias Kretz <kretz@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-only
6*/
7
8#ifndef KPLUGINWIDGET_P_H
9#define KPLUGINWIDGET_P_H
10
11#include <QAbstractListModel>
12
13#include <KCategorizedSortFilterProxyModel>
14#include <KConfigGroup>
15#include <kwidgetitemdelegate.h>
16
17#include <kcmutils_export.h>
18
19#include "kpluginmodel.h"
20
21class QAbstractItemView;
22class QCheckBox;
23class QLabel;
24class QLineEdit;
25class QPushButton;
26
27class KCategorizedView;
28class KCategoryDrawer;
29class KCModuleProxy;
30
31class KPluginProxyModel;
32class PluginDelegate;
33class PluginEntry;
34
35class KPluginWidgetPrivate
36{
37public:
38 int dependantLayoutValue(int value, int width, int totalWidth) const;
39
40public:
41 QLineEdit *lineEdit = nullptr;
42 KCategorizedView *listView = nullptr;
43 KCategoryDrawer *categoryDrawer = nullptr;
44 KPluginModel *pluginModel = nullptr;
45 KPluginProxyModel *proxyModel = nullptr;
46 QVariantList kcmArguments;
47 bool showDefaultIndicator = false;
48};
49
50class PluginDelegate : public KWidgetItemDelegate
51{
52 Q_OBJECT
53
54public:
55 explicit PluginDelegate(KPluginWidgetPrivate *pluginSelector_d, QObject *parent = nullptr);
56 ~PluginDelegate();
57
58 void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
59 QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
60 void configure(const QModelIndex &idx);
61
62Q_SIGNALS:
63 void changed(const QString &pluginId, bool enabled);
64 void configCommitted(const QString &pluginId);
65
66protected:
67 QList<QWidget *> createItemWidgets(const QModelIndex &index) const override;
68 void updateItemWidgets(const QList<QWidget *> &widgets, const QStyleOptionViewItem &option, const QPersistentModelIndex &index) const override;
69
70private Q_SLOTS:
71 void slotStateChanged(bool state);
72 void slotAboutClicked();
73 void slotConfigureClicked();
74
75private:
76 QFont titleFont(const QFont &baseFont) const;
77
78 QCheckBox *checkBox;
79 QPushButton *pushButton;
80
81 KPluginWidgetPrivate *pluginSelector_d;
82
83public:
84 std::function<QPushButton *(const KPluginMetaData &)> handler;
85};
86
87#endif // KPLUGINSELECTOR_P_H
88

source code of kcmutils/src/kpluginwidget_p.h