digiKam
importoverlays.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 : 2012-08-21
7  * Description : Overlays for the import interface
8  *
9  * Copyright (C) 2012 by Islam Wazery <wazery at ubuntu dot com>
10  * Copyright (C) 2012-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option)
16  * any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * ============================================================ */
24 
25 #ifndef DIGIKAM_IMPORT_OVERLAYS_H
26 #define DIGIKAM_IMPORT_OVERLAYS_H
27 
28 // Qt includes
29 
30 #include <QAbstractButton>
31 #include <QAbstractItemView>
32 
33 // Local includes
34 
35 #include "itemviewhoverbutton.h"
36 #include "itemdelegateoverlay.h"
37 #include "itemviewimportdelegate.h"
38 #include "ratingwidget.h"
39 
40 namespace Digikam
41 {
42 
43 class ImportOverlayWidget : public QAbstractButton
44 {
45  Q_OBJECT
46 
47 public:
48 
49  explicit ImportOverlayWidget(QWidget* const parent = nullptr);
50 
51 protected:
52 
53  void paintEvent(QPaintEvent*) override;
54 };
55 
56 // --------------------------------------------------------------------
57 
59 {
60  Q_OBJECT
62 
63 public:
64 
65  explicit ImportCoordinatesOverlay(QObject* const parent);
67 
68 protected:
69 
70  void updatePosition();
71 
72  QWidget* createWidget() override;
73  void setActive(bool active) override;
74  void visualChange() override;
75  bool checkIndex(const QModelIndex& index) const override;
76  void slotEntered(const QModelIndex& index) override;
77 
78 protected:
79 
80  QPersistentModelIndex m_index;
81 };
82 
83 // --------------------------------------------------------------------
84 
86 {
87  Q_OBJECT
89 
90 public:
91 
92  explicit ImportLockOverlay(QObject* const parent);
94 
95 protected:
96 
97  void updatePosition();
98 
99  QWidget* createWidget() override;
100  void setActive(bool active) override;
101  void visualChange() override;
102  bool checkIndex(const QModelIndex& index) const override;
103  void slotEntered(const QModelIndex& index) override;
104 
105 protected:
106 
107  QPersistentModelIndex m_index;
108 };
109 
110 // --------------------------------------------------------------------
111 
113 {
114  Q_OBJECT
116 
117 public:
118 
119  explicit ImportDownloadOverlay(QObject* const parent);
121 
122 protected:
123 
124  void updatePosition();
125 
126  QWidget* createWidget() override;
127  void setActive(bool active) override;
128  void visualChange() override;
129  bool checkIndex(const QModelIndex& index) const override;
130  void slotEntered(const QModelIndex& index) override;
131 
132 protected:
133 
134  QPersistentModelIndex m_index;
135 };
136 
137 // ------------------------------------------------------------------------------------------------
138 
140 {
141  Q_OBJECT
143 
144 public:
145 
146  explicit ImportRatingOverlay(QObject* const parent);
147  RatingWidget* ratingWidget() const;
148 
149 Q_SIGNALS:
150 
151  void ratingEdited(const QList<QModelIndex>& indexes, int rating);
152 
153 protected Q_SLOTS:
154 
155  void slotRatingChanged(int);
156  void slotDataChanged(const QModelIndex&, const QModelIndex&);
157 
158 protected:
159 
160  QWidget* createWidget() override;
161  void setActive(bool) override;
162  void visualChange() override;
163  void hide() override;
164  void slotEntered(const QModelIndex& index) override;
165  void widgetEnterEvent() override;
166  void widgetLeaveEvent() override;
167 
168  void updatePosition();
169  void updateRating();
170 
171 protected:
172 
173  QPersistentModelIndex m_index;
174 };
175 
176 // ------------------------------------------------------------------------------------------------
177 
179 {
182 };
183 
185 {
186  Q_OBJECT
187 
188 public:
189 
190  explicit ImportRotateOverlayButton(ImportRotateOverlayDirection dir, QAbstractItemView* const parentView);
191  QSize sizeHint() const override;
192 
193 protected:
194 
195  QIcon icon() override;
196  void updateToolTip() override;
197 
198 protected:
199 
201 };
202 
203 // --------------------------------------------------------------------
204 
206 {
207  Q_OBJECT
208 
209 public:
210 
211  explicit ImportRotateOverlay(ImportRotateOverlayDirection dir, QObject* const parent);
212  void setActive(bool active) override;
213 
214  ImportRotateOverlayDirection direction() const { return m_direction; }
215  bool isLeft() const { return m_direction == ImportRotateOverlayLeft; }
216  bool isRight() const { return m_direction == ImportRotateOverlayRight; }
217 
218  static ImportRotateOverlay* left (QObject* const parent) { return new ImportRotateOverlay(ImportRotateOverlayLeft, parent); }
219  static ImportRotateOverlay* right(QObject* const parent) { return new ImportRotateOverlay(ImportRotateOverlayRight, parent); }
220 
221 Q_SIGNALS:
222 
223  void signalRotate(const QList<QModelIndex>& indexes);
224 
225 protected:
226 
227  ItemViewHoverButton* createButton() override;
228  void updateButton(const QModelIndex& index) override;
229  bool checkIndex(const QModelIndex& index) const override;
230  void widgetEnterEvent() override;
231  void widgetLeaveEvent() override;
232 
233 private Q_SLOTS:
234 
235  void slotClicked();
236 
237 private:
238 
239  ImportRotateOverlayDirection const m_direction;
240 };
241 
242 } // namespace Digikam
243 
244 #endif // DIGIKAM_IMPORT_OVERLAYS_H
Definition: itemdelegateoverlay.h:125
Definition: itemdelegateoverlay.h:225
Definition: importoverlays.h:59
QWidget * createWidget() override
Definition: importoverlays.cpp:62
void updatePosition()
Definition: importoverlays.cpp:84
void setActive(bool active) override
Definition: importoverlays.cpp:71
bool checkIndex(const QModelIndex &index) const override
Definition: importoverlays.cpp:99
ImportOverlayWidget * buttonWidget() const
Definition: importoverlays.cpp:57
void slotEntered(const QModelIndex &index) override
Definition: importoverlays.cpp:115
void visualChange() override
Definition: importoverlays.cpp:76
QPersistentModelIndex m_index
Definition: importoverlays.h:80
ImportCoordinatesOverlay(QObject *const parent)
Definition: importoverlays.cpp:52
Definition: importoverlays.h:113
void updatePosition()
Definition: importoverlays.cpp:227
void setActive(bool active) override
Definition: importoverlays.cpp:214
void visualChange() override
Definition: importoverlays.cpp:219
void slotEntered(const QModelIndex &index) override
Definition: importoverlays.cpp:267
QWidget * createWidget() override
Definition: importoverlays.cpp:205
bool checkIndex(const QModelIndex &index) const override
Definition: importoverlays.cpp:242
ImportOverlayWidget * buttonWidget() const
Definition: importoverlays.cpp:200
QPersistentModelIndex m_index
Definition: importoverlays.h:134
ImportDownloadOverlay(QObject *const parent)
Definition: importoverlays.cpp:195
Definition: importoverlays.h:86
void visualChange() override
Definition: importoverlays.cpp:148
void setActive(bool active) override
Definition: importoverlays.cpp:143
void updatePosition()
Definition: importoverlays.cpp:156
bool checkIndex(const QModelIndex &index) const override
Definition: importoverlays.cpp:171
QWidget * createWidget() override
Definition: importoverlays.cpp:134
QPersistentModelIndex m_index
Definition: importoverlays.h:107
ImportLockOverlay(QObject *const parent)
Definition: importoverlays.cpp:124
ImportOverlayWidget * buttonWidget() const
Definition: importoverlays.cpp:129
void slotEntered(const QModelIndex &index) override
Definition: importoverlays.cpp:186
Definition: importoverlays.h:44
ImportOverlayWidget(QWidget *const parent=nullptr)
Definition: importoverlays.cpp:41
void paintEvent(QPaintEvent *) override
Definition: importoverlays.cpp:46
Definition: importoverlays.h:140
void updateRating()
Definition: importoverlays.cpp:367
QPersistentModelIndex m_index
Definition: importoverlays.h:173
void slotEntered(const QModelIndex &index) override
Definition: importoverlays.cpp:386
void setActive(bool) override
Definition: importoverlays.cpp:295
void slotRatingChanged(int)
Definition: importoverlays.cpp:378
void hide() override
Definition: importoverlays.cpp:339
RatingWidget * ratingWidget() const
Definition: importoverlays.cpp:281
void slotDataChanged(const QModelIndex &, const QModelIndex &)
Definition: importoverlays.cpp:406
void ratingEdited(const QList< QModelIndex > &indexes, int rating)
void updatePosition()
Definition: importoverlays.cpp:345
void widgetLeaveEvent() override
Definition: importoverlays.cpp:334
void visualChange() override
Definition: importoverlays.cpp:321
ImportRatingOverlay(QObject *const parent)
Definition: importoverlays.cpp:276
QWidget * createWidget() override
Definition: importoverlays.cpp:286
void widgetEnterEvent() override
Definition: importoverlays.cpp:329
Definition: importoverlays.h:185
QIcon icon() override
Definition: importoverlays.cpp:428
QSize sizeHint() const override
Definition: importoverlays.cpp:423
ImportRotateOverlayButton(ImportRotateOverlayDirection dir, QAbstractItemView *const parentView)
Definition: importoverlays.cpp:416
void updateToolTip() override
Definition: importoverlays.cpp:440
ImportRotateOverlayDirection const m_direction
Definition: importoverlays.h:200
Definition: importoverlays.h:206
static ImportRotateOverlay * left(QObject *const parent)
Definition: importoverlays.h:218
void updateButton(const QModelIndex &index) override
Definition: importoverlays.cpp:476
bool checkIndex(const QModelIndex &index) const override
Definition: importoverlays.cpp:497
static ImportRotateOverlay * right(QObject *const parent)
Definition: importoverlays.h:219
bool isRight() const
Definition: importoverlays.h:216
void widgetLeaveEvent() override
Definition: importoverlays.cpp:508
ImportRotateOverlay(ImportRotateOverlayDirection dir, QObject *const parent)
Definition: importoverlays.cpp:454
void widgetEnterEvent() override
Definition: importoverlays.cpp:503
bool isLeft() const
Definition: importoverlays.h:215
ItemViewHoverButton * createButton() override
Definition: importoverlays.cpp:471
void signalRotate(const QList< QModelIndex > &indexes)
void setActive(bool active) override
Definition: importoverlays.cpp:460
ImportRotateOverlayDirection direction() const
Definition: importoverlays.h:214
Definition: itemviewhoverbutton.h:42
NOTE: Some reuse of the existing model-view classes.
Definition: itemviewimportdelegate.h:46
Definition: ratingwidget.h:46
#define REQUIRE_DELEGATE(Delegate)
Definition: itemdelegateoverlay.h:112
Definition: datefolderview.cpp:43
ImportRotateOverlayDirection
Definition: importoverlays.h:179
@ ImportRotateOverlayLeft
Definition: importoverlays.h:180
@ ImportRotateOverlayRight
Definition: importoverlays.h:181