digiKam
itemrotationoverlay.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 : 2009-05-31
7  * Description : rotate icon view item at mouse hover
8  *
9  * Copyright (C) 2009-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_ITEM_ROTATION_OVERLAY_H
25 #define DIGIKAM_ITEM_ROTATION_OVERLAY_H
26 
27 // Qt includes
28 
29 #include <QAbstractItemView>
30 
31 // Local includes
32 
33 #include "itemviewhoverbutton.h"
34 #include "itemdelegateoverlay.h"
35 
36 namespace Digikam
37 {
38 
40 {
43 };
44 
46 {
47  Q_OBJECT
48 
49 public:
50 
51  ItemRotateOverlayButton(ItemRotateOverlayDirection dir, QAbstractItemView* const parentView);
52  QSize sizeHint() const override;
53 
54 protected:
55 
56  QIcon icon() override;
57  void updateToolTip() override;
58 
59 protected:
60 
62 };
63 
64 // --------------------------------------------------------------------
65 
67 {
68  Q_OBJECT
69 
70 public:
71 
72  ItemRotateOverlay(ItemRotateOverlayDirection dir, QObject* const parent);
73  void setActive(bool active) override;
74 
75  ItemRotateOverlayDirection direction() const { return m_direction; }
76  bool isLeft() const { return m_direction == ItemRotateOverlayLeft; }
77  bool isRight() const { return m_direction == ItemRotateOverlayRight; }
78 
79  static ItemRotateOverlay* left(QObject* const parent) { return new ItemRotateOverlay(ItemRotateOverlayLeft, parent); }
80  static ItemRotateOverlay* right(QObject* const parent) { return new ItemRotateOverlay(ItemRotateOverlayRight, parent); }
81 
82 Q_SIGNALS:
83 
84  void signalRotate(const QList<QModelIndex>& indexes);
85 
86 protected:
87 
89  void updateButton(const QModelIndex& index) override;
90  bool checkIndex(const QModelIndex& index) const override;
91  void widgetEnterEvent() override;
92  void widgetLeaveEvent() override;
93 
94 private Q_SLOTS:
95 
96  void slotClicked();
97 
98 private:
99 
100  ItemRotateOverlayDirection const m_direction;
101 };
102 
103 } // namespace Digikam
104 
105 #endif // DIGIKAM_ITEM_ROTATION_OVERLAY_H
Definition: itemdelegateoverlay.h:225
Definition: itemrotationoverlay.h:46
void updateToolTip() override
Definition: itemrotationoverlay.cpp:64
ItemRotateOverlayButton(ItemRotateOverlayDirection dir, QAbstractItemView *const parentView)
Definition: itemrotationoverlay.cpp:40
QSize sizeHint() const override
Definition: itemrotationoverlay.cpp:47
QIcon icon() override
Definition: itemrotationoverlay.cpp:52
ItemRotateOverlayDirection const m_direction
Definition: itemrotationoverlay.h:61
Definition: itemrotationoverlay.h:67
ItemRotateOverlayDirection direction() const
Definition: itemrotationoverlay.h:75
bool isRight() const
Definition: itemrotationoverlay.h:77
ItemViewHoverButton * createButton() override
Definition: itemrotationoverlay.cpp:97
void updateButton(const QModelIndex &index) override
Definition: itemrotationoverlay.cpp:102
void setActive(bool active) override
Definition: itemrotationoverlay.cpp:84
void widgetLeaveEvent() override
Definition: itemrotationoverlay.cpp:142
ItemRotateOverlay(ItemRotateOverlayDirection dir, QObject *const parent)
Definition: itemrotationoverlay.cpp:78
bool checkIndex(const QModelIndex &index) const override
Definition: itemrotationoverlay.cpp:129
void signalRotate(const QList< QModelIndex > &indexes)
bool isLeft() const
Definition: itemrotationoverlay.h:76
void widgetEnterEvent() override
Definition: itemrotationoverlay.cpp:137
static ItemRotateOverlay * right(QObject *const parent)
Definition: itemrotationoverlay.h:80
static ItemRotateOverlay * left(QObject *const parent)
Definition: itemrotationoverlay.h:79
Definition: itemviewhoverbutton.h:42
Definition: datefolderview.cpp:43
ItemRotateOverlayDirection
Definition: itemrotationoverlay.h:40
@ ItemRotateOverlayRight
Definition: itemrotationoverlay.h:42
@ ItemRotateOverlayLeft
Definition: itemrotationoverlay.h:41