digiKam
toolslistview.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2008-11-24
7  * Description : Available batch tools list.
8  *
9  * Copyright (C) 2008-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  *
11  * This program is free software; you can redistribute it
12  * and/or modify it under the terms of the GNU General
13  * Public License as published by the Free Software Foundation;
14  * either version 2, or (at your option)
15  * any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * ============================================================ */
23 
24 #ifndef DIGIKAM_BQM_TOOLS_LIST_VIEW_H
25 #define DIGIKAM_BQM_TOOLS_LIST_VIEW_H
26 
27 // Qt includes
28 
29 #include <QTreeWidget>
30 #include <QWidget>
31 #include <QPixmap>
32 #include <QMap>
33 #include <QString>
34 #include <QList>
35 
36 // Local includes
37 
38 #include "batchtool.h"
39 #include "batchtoolsfactory.h"
40 
41 namespace Digikam
42 {
43 
44 class ToolListViewGroup : public QTreeWidgetItem
45 {
46 
47 public:
48 
49  ToolListViewGroup(QTreeWidget* const parent,
51  ~ToolListViewGroup() override;
52 
54 
55 private:
56 
58 
59  private:
60 
61  Q_DISABLE_COPY(ToolListViewGroup)
62 };
63 
64 // -------------------------------------------------------------------------
65 
66 class ToolListViewItem : public QTreeWidgetItem
67 {
68 
69 public:
70 
71  ToolListViewItem(ToolListViewGroup* const parent,
72  BatchTool* const tool);
73  ~ToolListViewItem() override;
74 
75  BatchTool* tool() const;
76 
77 private:
78 
79  BatchTool* m_tool;
80 
81 private:
82 
83  Q_DISABLE_COPY(ToolListViewItem)
84 };
85 
86 // -------------------------------------------------------------------------
87 
88 class ToolsListView : public QTreeWidget
89 {
90  Q_OBJECT
91 
92 public:
93 
94  explicit ToolsListView(QWidget* const parent);
95  ~ToolsListView() override;
96 
98 
99  void addTool(BatchTool* const tool);
100  bool removeTool(BatchTool* const tool);
101 
102 Q_SIGNALS:
103 
104  void signalAssignTools(const QMultiMap<int, QString>&);
105 
106 private Q_SLOTS:
107 
108  void slotContextMenu();
109  void slotAssignTools();
110  void slotToolVisible(bool);
111 
112 private:
113 
114  bool hasTool(BatchTool* const tool);
115  ToolListViewItem* findTool(BatchTool* const tool);
116  ToolListViewGroup* findToolGroup(BatchTool::BatchToolGroup group);
117 
118  void startDrag(Qt::DropActions supportedActions) override;
119  QStringList mimeTypes() const override;
120 
121 #if (QT_VERSION > QT_VERSION_CHECK(5, 99, 0))
122  QMimeData* mimeData(const QList<QTreeWidgetItem*>& items) const override;
123 #else
124  // cppcheck-suppress passedByValue
125  QMimeData* mimeData(const QList<QTreeWidgetItem*> items) const override; // clazy:exclude=function-args-by-ref
126 #endif
127 
128  void mouseDoubleClickEvent(QMouseEvent*) override;
129  QMultiMap<int, QString> itemsToMap(const QList<QTreeWidgetItem*>& items) const;
130 };
131 
132 } // namespace Digikam
133 
134 #endif // DIGIKAM_BQM_TOOLS_LIST_VIEW_H
Definition: batchtool.h:56
BatchToolGroup
Definition: batchtool.h:62
Definition: toolslistview.h:45
~ToolListViewGroup() override
Definition: toolslistview.cpp:119
BatchTool::BatchToolGroup toolGroup() const
Definition: toolslistview.cpp:123
ToolListViewGroup(QTreeWidget *const parent, BatchTool::BatchToolGroup group)
Definition: toolslistview.cpp:49
Definition: toolslistview.h:67
ToolListViewItem(ToolListViewGroup *const parent, BatchTool *const tool)
Definition: toolslistview.cpp:130
~ToolListViewItem() override
Definition: toolslistview.cpp:146
BatchTool * tool() const
Definition: toolslistview.cpp:150
Definition: toolslistview.h:89
BatchToolsList toolsList()
Definition: toolslistview.cpp:179
void signalAssignTools(const QMultiMap< int, QString > &)
~ToolsListView() override
Definition: toolslistview.cpp:175
void addTool(BatchTool *const tool)
Definition: toolslistview.cpp:200
bool removeTool(BatchTool *const tool)
Definition: toolslistview.cpp:235
ToolsListView(QWidget *const parent)
Definition: toolslistview.cpp:157
Definition: datefolderview.cpp:43