File indexing completed on 2025-03-09 03:58:53
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2008-11-24 0007 * Description : Available batch tools list. 0008 * 0009 * SPDX-FileCopyrightText: 2008-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_BQM_TOOLS_LIST_VIEW_H 0016 #define DIGIKAM_BQM_TOOLS_LIST_VIEW_H 0017 0018 // Qt includes 0019 0020 #include <QTreeWidget> 0021 #include <QWidget> 0022 #include <QPixmap> 0023 #include <QMap> 0024 #include <QString> 0025 #include <QList> 0026 0027 // Local includes 0028 0029 #include "batchtool.h" 0030 #include "batchtoolsfactory.h" 0031 0032 namespace Digikam 0033 { 0034 0035 class ToolListViewGroup : public QTreeWidgetItem 0036 { 0037 0038 public: 0039 0040 ToolListViewGroup(QTreeWidget* const parent, 0041 BatchTool::BatchToolGroup group); 0042 ~ToolListViewGroup() override; 0043 0044 BatchTool::BatchToolGroup toolGroup() const; 0045 0046 private: 0047 0048 BatchTool::BatchToolGroup m_group; 0049 0050 private: 0051 0052 Q_DISABLE_COPY(ToolListViewGroup) 0053 }; 0054 0055 // ------------------------------------------------------------------------- 0056 0057 class ToolListViewItem : public QTreeWidgetItem 0058 { 0059 0060 public: 0061 0062 ToolListViewItem(ToolListViewGroup* const parent, 0063 BatchTool* const tool); 0064 ~ToolListViewItem() override; 0065 0066 BatchTool* tool() const; 0067 0068 private: 0069 0070 BatchTool* m_tool; 0071 0072 private: 0073 0074 Q_DISABLE_COPY(ToolListViewItem) 0075 }; 0076 0077 // ------------------------------------------------------------------------- 0078 0079 class ToolsListView : public QTreeWidget 0080 { 0081 Q_OBJECT 0082 0083 public: 0084 0085 explicit ToolsListView(QWidget* const parent); 0086 ~ToolsListView() override; 0087 0088 BatchToolsList toolsList(); 0089 0090 void addTool(BatchTool* const tool); 0091 bool removeTool(BatchTool* const tool); 0092 0093 Q_SIGNALS: 0094 0095 void signalAssignTools(const QMultiMap<int, QString>&); 0096 0097 private Q_SLOTS: 0098 0099 void slotContextMenu(); 0100 void slotAssignTools(); 0101 void slotToolVisible(bool); 0102 0103 private: 0104 0105 bool hasTool(BatchTool* const tool); 0106 ToolListViewItem* findTool(BatchTool* const tool); 0107 ToolListViewGroup* findToolGroup(BatchTool::BatchToolGroup group); 0108 0109 void startDrag(Qt::DropActions supportedActions) override; 0110 QStringList mimeTypes() const override; 0111 0112 #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) 0113 0114 QMimeData* mimeData(const QList<QTreeWidgetItem*>& items) const override; 0115 0116 #else 0117 0118 // cppcheck-suppress passedByValue 0119 QMimeData* mimeData(const QList<QTreeWidgetItem*> items) const override; // clazy:exclude=function-args-by-ref 0120 0121 #endif 0122 0123 void mouseDoubleClickEvent(QMouseEvent*) override; 0124 QMultiMap<int, QString> itemsToMap(const QList<QTreeWidgetItem*>& items) const; 0125 }; 0126 0127 } // namespace Digikam 0128 0129 #endif // DIGIKAM_BQM_TOOLS_LIST_VIEW_H