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