File indexing completed on 2025-01-05 03:51:11
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2009-05-31 0007 * Description : rotate icon view item at mouse hover 0008 * 0009 * SPDX-FileCopyrightText: 2009-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 #ifndef DIGIKAM_ITEM_ROTATION_OVERLAY_H 0016 #define DIGIKAM_ITEM_ROTATION_OVERLAY_H 0017 0018 // Qt includes 0019 0020 #include <QAbstractItemView> 0021 0022 // Local includes 0023 0024 #include "itemviewhoverbutton.h" 0025 #include "itemdelegateoverlay.h" 0026 0027 namespace Digikam 0028 { 0029 0030 enum ItemRotateOverlayDirection 0031 { 0032 ItemRotateOverlayLeft, 0033 ItemRotateOverlayRight 0034 }; 0035 0036 class ItemRotateOverlayButton : public ItemViewHoverButton 0037 { 0038 Q_OBJECT 0039 0040 public: 0041 0042 ItemRotateOverlayButton(ItemRotateOverlayDirection dir, QAbstractItemView* const parentView); 0043 QSize sizeHint() const override; 0044 0045 protected: 0046 0047 QIcon icon() override; 0048 void updateToolTip() override; 0049 0050 protected: 0051 0052 ItemRotateOverlayDirection const m_direction; 0053 }; 0054 0055 // -------------------------------------------------------------------- 0056 0057 class ItemRotateOverlay : public HoverButtonDelegateOverlay 0058 { 0059 Q_OBJECT 0060 0061 public: 0062 0063 ItemRotateOverlay(ItemRotateOverlayDirection dir, QObject* const parent); 0064 void setActive(bool active) override; 0065 0066 ItemRotateOverlayDirection direction() const { return m_direction; } 0067 bool isLeft() const { return m_direction == ItemRotateOverlayLeft; } 0068 bool isRight() const { return m_direction == ItemRotateOverlayRight; } 0069 0070 static ItemRotateOverlay* left(QObject* const parent) { return new ItemRotateOverlay(ItemRotateOverlayLeft, parent); } 0071 static ItemRotateOverlay* right(QObject* const parent) { return new ItemRotateOverlay(ItemRotateOverlayRight, parent); } 0072 0073 Q_SIGNALS: 0074 0075 void signalRotate(const QList<QModelIndex>& indexes); 0076 0077 protected: 0078 0079 ItemViewHoverButton* createButton() override; 0080 void updateButton(const QModelIndex& index) override; 0081 bool checkIndex(const QModelIndex& index) const override; 0082 void widgetEnterEvent() override; 0083 void widgetLeaveEvent() override; 0084 0085 private Q_SLOTS: 0086 0087 void slotClicked(); 0088 0089 private: 0090 0091 ItemRotateOverlayDirection const m_direction; 0092 }; 0093 0094 } // namespace Digikam 0095 0096 #endif // DIGIKAM_ITEM_ROTATION_OVERLAY_H