| 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 | |
| 21 | class QAbstractItemView; |
| 22 | class QCheckBox; |
| 23 | class QLabel; |
| 24 | class QLineEdit; |
| 25 | class QPushButton; |
| 26 | |
| 27 | class KCategorizedView; |
| 28 | class KCategoryDrawer; |
| 29 | class KCModuleProxy; |
| 30 | |
| 31 | class KPluginProxyModel; |
| 32 | class PluginDelegate; |
| 33 | class PluginEntry; |
| 34 | |
| 35 | class KPluginWidgetPrivate |
| 36 | { |
| 37 | public: |
| 38 | int dependantLayoutValue(int value, int width, int totalWidth) const; |
| 39 | |
| 40 | public: |
| 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 | |
| 50 | class PluginDelegate : public KWidgetItemDelegate |
| 51 | { |
| 52 | Q_OBJECT |
| 53 | |
| 54 | public: |
| 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 | |
| 62 | Q_SIGNALS: |
| 63 | void changed(const QString &pluginId, bool enabled); |
| 64 | void configCommitted(const QString &pluginId); |
| 65 | |
| 66 | protected: |
| 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 | |
| 70 | private Q_SLOTS: |
| 71 | void slotStateChanged(bool state); |
| 72 | void slotAboutClicked(); |
| 73 | void slotConfigureClicked(); |
| 74 | |
| 75 | private: |
| 76 | QFont titleFont(const QFont &baseFont) const; |
| 77 | |
| 78 | QCheckBox *checkBox; |
| 79 | QPushButton *pushButton; |
| 80 | |
| 81 | KPluginWidgetPrivate *pluginSelector_d; |
| 82 | |
| 83 | public: |
| 84 | std::function<QPushButton *(const KPluginMetaData &)> handler; |
| 85 | }; |
| 86 | |
| 87 | #endif // KPLUGINSELECTOR_P_H |
| 88 | |