digiKam
regionframeitem.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 : 2010-09-09
7 * Description : tag region frame
8 *
9 * Copyright (C) 2007 by Aurelien Gateau <agateau at kde dot org>
10 * Copyright (C) 2010-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
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_REGION_FRAME_ITEM_H
26 #define DIGIKAM_REGION_FRAME_ITEM_H
27 
28 // Qt includes
29 
30 #include <QFlags>
31 
32 // Local includes
33 
34 #include "dimgchilditem.h"
35 #include "digikam_export.h"
36 
37 class QWidget;
38 
39 namespace Digikam
40 {
41 
42 class DIGIKAM_EXPORT RegionFrameItem : public DImgChildItem // clazy:exclude=ctor-missing-parent-argument
43 {
44  Q_OBJECT
45 
46 public:
47 
48  enum Flag
49  {
50  NoFlags = 0,
51  ShowResizeHandles = 1 << 0,
52  MoveByDrag = 1 << 1,
53 
54  GeometryEditable = ShowResizeHandles | MoveByDrag
55  };
56  Q_DECLARE_FLAGS(Flags, Flag)
57 
58 public:
59 
60  explicit RegionFrameItem(QGraphicsItem* const parent);
61  ~RegionFrameItem() override;
62 
63  void setFlags(Flags flags);
64  void changeFlags(Flags flags, bool addOrRemove);
65  Flags flags() const;
66 
73  void setHudWidget(QGraphicsWidget* const hudWidget);
74  void setHudWidget(QWidget* const widget, Qt::WindowFlags wFlags = Qt::WindowFlags());
75  QGraphicsWidget* hudWidget() const;
76  void setHudWidgetVisible(bool visible);
77 
78  void setFixedRatio(double ratio);
79 
80  void setRectInSceneCoordinatesAdjusted(const QRectF& rect);
81 
82  QRectF boundingRect() const override;
83 
84 public Q_SLOTS:
85 
93  void setViewportRect(const QRectF& rect);
94 
95 Q_SIGNALS:
96 
98 
99 protected:
100 
101  void paint(QPainter* painter,
102  const QStyleOptionGraphicsItem* option,
103  QWidget* widget = nullptr) override;
104  void mousePressEvent(QGraphicsSceneMouseEvent*) override;
105  void mouseMoveEvent(QGraphicsSceneMouseEvent*) override;
106  void mouseReleaseEvent(QGraphicsSceneMouseEvent*) override;
107  void hoverEnterEvent(QGraphicsSceneHoverEvent* event) override;
108  void hoverMoveEvent(QGraphicsSceneHoverEvent* event) override;
109  void hoverLeaveEvent(QGraphicsSceneHoverEvent* event) override;
110 
111  bool eventFilter(QObject* watched, QEvent* event) override;
112 
113 private Q_SLOTS:
114 
115  void slotUpdate();
116  void slotSizeChanged();
117  void slotPosChanged();
118  void hudSizeChanged();
119  void moveHudWidget();
120 
121 private:
122 
123  // Disable
124  RegionFrameItem();
125 
126 private:
127 
128  class Private;
129  Private* const d;
130 };
131 
132 } // namespace Digikam
133 
134 Q_DECLARE_OPERATORS_FOR_FLAGS(Digikam::RegionFrameItem::Flags)
135 
136 #endif // DIGIKAM_REGION_FRAME_ITEM_H
Definition: dimgchilditem.h:41
Definition: regionframeitem.h:43
Flag
Definition: regionframeitem.h:49
Definition: datefolderview.cpp:43