File indexing completed on 2024-04-28 07:41:27

0001 /*
0002     SPDX-FileCopyrightText: 2007, 2006 Rafael Fernández López <ereslibre@kde.org>
0003     SPDX-FileCopyrightText: 2002-2003 Matthias Kretz <kretz@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-only
0006 */
0007 
0008 #ifndef KPLUGINWIDGET_P_H
0009 #define KPLUGINWIDGET_P_H
0010 
0011 #include <QAbstractListModel>
0012 
0013 #include <KCategorizedSortFilterProxyModel>
0014 #include <KConfigGroup>
0015 #include <kwidgetitemdelegate.h>
0016 
0017 #include <kcmutils_export.h>
0018 
0019 #include "kpluginmodel.h"
0020 
0021 class QAbstractItemView;
0022 class QCheckBox;
0023 class QLabel;
0024 class QLineEdit;
0025 class QPushButton;
0026 
0027 class KCategorizedView;
0028 class KCategoryDrawer;
0029 class KCModuleProxy;
0030 
0031 class KPluginProxyModel;
0032 class PluginDelegate;
0033 class PluginEntry;
0034 
0035 class KPluginWidgetPrivate
0036 {
0037 public:
0038     int dependantLayoutValue(int value, int width, int totalWidth) const;
0039 
0040 public:
0041     QLineEdit *lineEdit = nullptr;
0042     KCategorizedView *listView = nullptr;
0043     KCategoryDrawer *categoryDrawer = nullptr;
0044     KPluginModel *pluginModel = nullptr;
0045     KPluginProxyModel *proxyModel = nullptr;
0046     QVariantList kcmArguments;
0047     bool showDefaultIndicator = false;
0048 };
0049 
0050 class PluginDelegate : public KWidgetItemDelegate
0051 {
0052     Q_OBJECT
0053 
0054 public:
0055     explicit PluginDelegate(KPluginWidgetPrivate *pluginSelector_d, QObject *parent = nullptr);
0056     ~PluginDelegate();
0057 
0058     void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
0059     QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
0060     void configure(const QModelIndex &idx);
0061 
0062 Q_SIGNALS:
0063     void changed(const QString &pluginId, bool enabled);
0064     void configCommitted(const QString &pluginId);
0065 
0066 protected:
0067     QList<QWidget *> createItemWidgets(const QModelIndex &index) const override;
0068     void updateItemWidgets(const QList<QWidget *> &widgets, const QStyleOptionViewItem &option, const QPersistentModelIndex &index) const override;
0069 
0070 private Q_SLOTS:
0071     void slotStateChanged(bool state);
0072     void slotAboutClicked();
0073     void slotConfigureClicked();
0074 
0075 private:
0076     QFont titleFont(const QFont &baseFont) const;
0077 
0078     QCheckBox *checkBox;
0079     QPushButton *pushButton;
0080 
0081     KPluginWidgetPrivate *pluginSelector_d;
0082 
0083 public:
0084     std::function<QPushButton *(const KPluginMetaData &)> handler;
0085 };
0086 
0087 #endif // KPLUGINSELECTOR_P_H