digiKam
queuelist.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-21
7  * Description : Batch Queue Manager items 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_QUEUE_LIST_H
25 #define DIGIKAM_BQM_QUEUE_LIST_H
26 
27 // Qt includes
28 
29 #include <QTreeWidget>
30 #include <QWidget>
31 #include <QPixmap>
32 #include <QIcon>
33 
34 // Local includes
35 
36 #include "batchtool.h"
37 #include "batchtoolutils.h"
38 #include "iteminfo.h"
39 #include "iteminfolist.h"
40 #include "loadingdescription.h"
41 #include "queuesettingsview.h"
42 
43 namespace Digikam
44 {
45 
46 class QueueListView;
47 
48 class QueueListViewItem : public QTreeWidgetItem
49 {
50 
51 public:
52 
53  QueueListViewItem(QueueListView* const view, const ItemInfo& info);
54  ~QueueListViewItem() override;
55 
56  bool hasValidThumbnail() const;
57 
58  void setInfo(const ItemInfo& info);
59  ItemInfo info() const;
60 
61  void assignTool(int index, const BatchToolSet& set);
62  void unassignTool(int index);
63 
64  void setThumb(const QPixmap& pix, bool hasThumb = true);
65 
66  void animProgress();
67 
68  void setCanceled();
69  void setFailed();
70 
71  void setDone();
72  bool isDone() const;
73 
74  void setBusy();
75  bool isBusy() const;
76 
77  void reset();
78 
79  void setDestFileName(const QString& str);
80  QString destFileName() const;
81  QString destBaseName() const;
82  QString destSuffix() const;
83 
84 private:
85 
86  void setPixmap(const QPixmap& pix);
87 
88 private:
89 
90  class Private;
91  Private* const d;
92 
93 private:
94 
95  Q_DISABLE_COPY(QueueListViewItem)
96 };
97 
98 // -------------------------------------------------------------------------
99 
101 
102 class QueueListView : public QTreeWidget
103 {
104  Q_OBJECT
105 
106 public:
107 
108  explicit QueueListView(QWidget* const parent);
109  ~QueueListView() override;
110 
111  void cancelItems();
112  int itemsCount();
113  void removeItemByInfo(const ItemInfo& info);
114  void removeItemById(qlonglong id);
115 
117  int pendingItemsCount();
118  int pendingTasksCount();
119 
120  QueueListViewItem* findItemByUrl(const QUrl& url);
121  QueueListViewItem* findItemById(qlonglong id);
122 
123  void setSettings(const QueueSettings& settings);
124  QueueSettings settings() const;
125 
126  void setAssignedTools(const AssignedBatchTools& tools);
128 
129  void setEnableToolTips(bool val);
130 
131  void reloadThumbs(const QUrl& url);
132 
133  void setItemBusy(qlonglong id);
134  QPixmap progressPixmapForIndex(int index) const;
135 
136 Q_SIGNALS:
137 
139 
140 public Q_SLOTS:
141 
142  void slotClearList();
144  void slotRemoveItemsDone();
145  void slotAddItems(const ItemInfoList&);
147 
148 private Q_SLOTS:
149 
150  void slotCollectionImageChange(const CollectionImageChangeset&);
151  void slotThumbnailLoaded(const LoadingDescription&, const QPixmap&);
152  void slotContextMenu();
153  void slotToolTip();
154  void slotProgressTimerDone();
155 
156 private:
157 
158  bool findItemByInfo(const ItemInfo& info);
159 
160  void removeItems(int removeType);
161  void updateDestFileNames();
162  void hideToolTip();
163  bool acceptToolTip(const QPoint& pos) const;
164 
165 #if (QT_VERSION > QT_VERSION_CHECK(5, 99, 0))
166  QMimeData* mimeData(const QList<QTreeWidgetItem*>& items) const override;
167 #else
168  // cppcheck-suppress passedByValue
169  QMimeData* mimeData(const QList<QTreeWidgetItem*> items) const override; // clazy:exclude=function-args-by-ref
170 #endif
171 
172  Qt::DropActions supportedDropActions() const override;
173  void startDrag(Qt::DropActions supportedActions) override;
174 
175  void dragMoveEvent(QDragMoveEvent*) override;
176  void dragEnterEvent(QDragEnterEvent*) override;
177  void dropEvent(QDropEvent*) override;
178  void mouseMoveEvent(QMouseEvent*) override;
179  void wheelEvent(QWheelEvent*) override;
180  void keyPressEvent(QKeyEvent*) override;
181  void focusOutEvent(QFocusEvent*) override;
182  void leaveEvent(QEvent*) override;
183  void resetQueue();
184 
185  void drawRow(QPainter* p,
186  const QStyleOptionViewItem& opt,
187  const QModelIndex& index) const override;
188 
189 private:
190 
191  class Private;
192  Private* const d;
193 };
194 
195 } // namespace Digikam
196 
197 #endif // DIGIKAM_BQM_QUEUE_LIST_H
Definition: batchtoolutils.h:91
Definition: batchtoolutils.h:53
Definition: coredbchangesets.h:152
Definition: iteminfolist.h:47
Definition: iteminfo.h:78
Definition: loadingdescription.h:45
Definition: queuelist.h:49
void unassignTool(int index)
void setFailed()
Definition: queuelist.cpp:198
bool isBusy() const
Definition: queuelist.cpp:235
void reset()
Definition: queuelist.cpp:221
ItemInfo info() const
Definition: queuelist.cpp:138
void setThumb(const QPixmap &pix, bool hasThumb=true)
Definition: queuelist.cpp:158
QString destFileName() const
Definition: queuelist.cpp:246
QueueListViewItem(QueueListView *const view, const ItemInfo &info)
Definition: queuelist.cpp:113
bool hasValidThumbnail() const
Definition: queuelist.cpp:127
QString destBaseName() const
Definition: queuelist.cpp:251
bool isDone() const
Definition: queuelist.cpp:216
void animProgress()
Definition: queuelist.cpp:170
void setDone()
Definition: queuelist.cpp:207
void setCanceled()
Definition: queuelist.cpp:189
void setInfo(const ItemInfo &info)
Definition: queuelist.cpp:132
void assignTool(int index, const BatchToolSet &set)
QString destSuffix() const
Definition: queuelist.cpp:258
void setDestFileName(const QString &str)
Definition: queuelist.cpp:240
void setBusy()
Definition: queuelist.cpp:230
~QueueListViewItem() override
Definition: queuelist.cpp:122
Definition: queuelist.h:103
AssignedBatchTools assignedTools() const
Definition: queuelist.cpp:1049
QueueListView(QWidget *const parent)
Definition: queuelist.cpp:313
ItemInfoList pendingItemsList()
Definition: queuelist.cpp:985
void cancelItems()
Definition: queuelist.cpp:968
void removeItemById(qlonglong id)
Definition: queuelist.cpp:875
QueueSettings settings() const
Definition: queuelist.cpp:1037
void slotRemoveSelectedItems()
Definition: queuelist.cpp:798
void slotRemoveItemsDone()
Definition: queuelist.cpp:805
QueueListViewItem * findItemByUrl(const QUrl &url)
Definition: queuelist.cpp:929
~QueueListView() override
Definition: queuelist.cpp:368
int pendingTasksCount()
Definition: queuelist.cpp:1010
int itemsCount()
Definition: queuelist.cpp:948
void setAssignedTools(const AssignedBatchTools &tools)
Definition: queuelist.cpp:1042
int pendingItemsCount()
Definition: queuelist.cpp:1005
void slotAddItems(const ItemInfoList &)
Definition: queuelist.cpp:711
void removeItemByInfo(const ItemInfo &info)
Definition: queuelist.cpp:870
void slotAssignedToolsChanged(const AssignedBatchTools &)
Definition: queuelist.cpp:1054
void reloadThumbs(const QUrl &url)
Definition: queuelist.cpp:1203
QueueListViewItem * findItemById(qlonglong id)
Definition: queuelist.cpp:910
void setItemBusy(qlonglong id)
Definition: queuelist.cpp:1208
void setSettings(const QueueSettings &settings)
Definition: queuelist.cpp:1030
QPixmap progressPixmapForIndex(int index) const
Definition: queuelist.cpp:374
void setEnableToolTips(bool val)
Definition: queuelist.cpp:616
void slotClearList()
Definition: queuelist.cpp:791
Definition: queuesettings.h:44
Definition: piwigotalker.h:48
Definition: datefolderview.cpp:43