File indexing completed on 2025-01-19 03:55:36

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2018-12-31
0007  * Description : configuration view for external plugin
0008  *
0009  * SPDX-FileCopyrightText: 2018-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0010  *
0011  * SPDX-License-Identifier: GPL-2.0-or-later
0012  *
0013  * ============================================================ */
0014 
0015 #ifndef DIGIKAM_DPLUGIN_CONF_VIEW_H
0016 #define DIGIKAM_DPLUGIN_CONF_VIEW_H
0017 
0018 // Qt includes
0019 
0020 #include <QString>
0021 #include <QTreeWidgetItem>
0022 #include <QTreeWidget>
0023 
0024 // Local includes
0025 
0026 #include "dpluginloader.h"
0027 #include "digikam_export.h"
0028 #include "dpluginaction.h"
0029 
0030 namespace Digikam
0031 {
0032 
0033 class DIGIKAM_EXPORT DPluginConfView : public QTreeWidget
0034 {
0035     Q_OBJECT
0036 
0037 public:
0038 
0039     /**
0040      * Default constructor.
0041      */
0042     explicit DPluginConfView(QWidget* const parent = nullptr);
0043     ~DPluginConfView()                                 override;
0044 
0045     /**
0046      * Apply all changes about plugins selected to be hosted in host application.
0047      */
0048     void apply();
0049 
0050     /**
0051      * Return the number of plugins active in the list.
0052      */
0053     int actived()                                const;
0054 
0055     /**
0056      * Return the total number of plugins in the list.
0057      */
0058     int count()                                  const;
0059 
0060     /**
0061      * Return the number of visible plugins in the list.
0062      */
0063     int itemsVisible()                           const;
0064 
0065     /**
0066      * Return the number of plugins in the list with visibly properties available.
0067      */
0068     int itemsWithVisiblyProperty()               const;
0069 
0070     /**
0071      * Select all plugins in the list.
0072      */
0073     void selectAll()                                   override;
0074 
0075     /**
0076      * Clear all selected plugins in the list.
0077      */
0078     void clearAll();
0079 
0080     /**
0081      * Set the string used to filter the plugins list. signalSearchResult() is emitted when all is done.
0082      */
0083     void setFilter(const QString& filter, Qt::CaseSensitivity cs);
0084 
0085     /**
0086      * Return the current string used to filter the plugins list.
0087      */
0088     QString filter()                             const;
0089 
0090     DPlugin* plugin(QTreeWidgetItem* const item) const;
0091 
0092 protected:
0093 
0094     QTreeWidgetItem* appendPlugin(DPlugin* const);
0095 
0096     virtual void loadPlugins() = 0;
0097 
0098 Q_SIGNALS:
0099 
0100     /**
0101      * Signal emitted when filtering is done through slotSetFilter().
0102      * Number of plugins found is sent when item relevant of filtering match the query.
0103      */
0104     void signalSearchResult(int);
0105 
0106 private:
0107 
0108     class Private;
0109     Private* const d;
0110 };
0111 
0112 } // namespace Digikam
0113 
0114 #endif // DIGIKAM_DPLUGIN_CONF_VIEW_H