File indexing completed on 2025-04-27 03:58:23
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2011-03-04 0007 * Description : A simple item to click, drag and release 0008 * 0009 * SPDX-FileCopyrightText: 2010-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 #ifndef DIGIKAM_CLICK_DRAG_RELEASE_ITEM_H 0016 #define DIGIKAM_CLICK_DRAG_RELEASE_ITEM_H 0017 0018 // Qt includes 0019 0020 #include <QGraphicsObject> 0021 0022 // Local includes 0023 0024 #include "digikam_export.h" 0025 0026 namespace Digikam 0027 { 0028 0029 class DIGIKAM_EXPORT ClickDragReleaseItem : public QGraphicsObject // clazy:exclude=ctor-missing-parent-argument 0030 { 0031 Q_OBJECT 0032 0033 public: 0034 0035 explicit ClickDragReleaseItem(QGraphicsItem* const parent); 0036 ~ClickDragReleaseItem() override; 0037 0038 QRectF boundingRect() const override; 0039 void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override; 0040 0041 Q_SIGNALS: 0042 0043 /** 0044 * Signals are emitted at click, drag and release event. 0045 * Reported positions are in scene coordinates. 0046 * A drag is reported only if the mouse was moved a certain threshold. 0047 * A release is reported after every press. 0048 */ 0049 0050 void started(const QPointF& pos); 0051 void moving(const QRectF& rect); 0052 void finished(const QRectF& rect); 0053 void cancelled(); 0054 0055 protected: 0056 0057 void mousePressEvent(QGraphicsSceneMouseEvent*) override; 0058 void mouseMoveEvent(QGraphicsSceneMouseEvent*) override; 0059 void mouseReleaseEvent(QGraphicsSceneMouseEvent*) override; 0060 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*) override; 0061 void hoverMoveEvent(QGraphicsSceneHoverEvent*) override; 0062 void keyPressEvent(QKeyEvent*) override; 0063 0064 private: 0065 0066 class Private; 0067 Private* const d; 0068 }; 0069 0070 } // namespace Digikam 0071 0072 #endif // DIGIKAM_CLICK_DRAG_RELEASE_ITEM_H