1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date        : 2009-02-13
7  * Description : tabbed queue items list.
8  *
9  * Copyright (C) 2009-2021 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_POOL_H
25 #define DIGIKAM_BQM_QUEUE_POOL_H
26 
27 // Qt includes
28 
29 #include <QMap>
30 #include <QTabBar>
31 #include <QWidget>
32 #include <QDragMoveEvent>
33 #include <QDropEvent>
34 #include <QTabWidget>
35 
36 // Local includes
37 
38 #include "iteminfoset.h"
39 
40 namespace Digikam
41 {
42 
43 class DRawDecoding;
44 class AssignedBatchTools;
45 class QueueSettings;
46 class QueueListView;
47 
48 
49 class QueuePoolBar : public QTabBar
50 {
51     Q_OBJECT
52 
53 public:
54 
55     explicit QueuePoolBar(QWidget* const parent);
56     ~QueuePoolBar() override;
57 
58 Q_SIGNALS:
59 
60     void signalTestCanDecode(const QDragMoveEvent*, bool&);
61 
62 private:
63 
64     void dragEnterEvent(QDragEnterEvent* e) override;
65     void dragMoveEvent(QDragMoveEvent* e)   override;
66 };
67 
68 // --------------------------------------------------------------------------------------
69 
70 class QueuePool : public QTabWidget
71 {
72     Q_OBJECT
73 
74 public:
75 
76     explicit QueuePool(QWidget* const parent);
77     ~QueuePool() override;
78 
79     QueueListView*     currentQueue()                    const;
80     QString            currentTitle()                    const;
81     QueueListView*     findQueueByIndex(int index)       const;
82     QueuePoolItemsList queueItemsList(int index)         const;
83     int                totalPendingItems()               const;
84     int                totalPendingTasks()               const;
85     QMap<int, QString> queuesMap()                       const;
86     QString            queueTitle(int index)             const;
87     bool               customRenamingRulesAreValid()     const;
88     bool               assignedBatchToolsListsAreValid() const;
89     bool               saveWorkflow()                    const;
90 
91     void setBusy(bool b);
92     void setItemBusy(qlonglong id);
93 
94     /** Apply settings changes to all queues settings container when something have been changed in
95      *  digiKam setup dialog.
96      */
97     void applySettings();
98 
99 Q_SIGNALS:
100 
101     void signalItemSelectionChanged();
102     void signalQueuePoolChanged();
103     void signalQueueSelected(int id, const QueueSettings&, const AssignedBatchTools&);
104     void signalQueueContentsChanged();
105 
106 public Q_SLOTS:
107 
108     void removeTab(int index);
109 
110     void slotAddQueue();
111     void slotRemoveCurrentQueue();
112     void slotClearList();
113     void slotRemoveSelectedItems();
114     void slotRemoveItemsDone();
115     void slotAddItems(const ItemInfoList&, int queueId);
116     void slotAssignedToolsChanged(const AssignedBatchTools&);
117     void slotSettingsChanged(const QueueSettings&);
118     void slotQueueSelected(int);
119 
120 protected:
121 
122     void keyPressEvent(QKeyEvent* event) override;
123 
124 private :
125 
126     QueueListView* findQueueByItemId(qlonglong id) const;
127 
128 private Q_SLOTS:
129 
130     void slotFileChanged(const QString&);
131     void slotCloseQueueRequest(int);
132     void slotTestCanDecode(const QDragMoveEvent*, bool&);
133 };
134 
135 } // namespace Digikam
136 
137 #endif // DIGIKAM_BQM_QUEUE_POOL_H
138