digiKam
dimgchilditem.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-05-15
7  * Description : Graphics View item for a child item on a DImg item
8  *
9  * Copyright (C) 2010-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
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_DIMG_CHILD_ITEM_H
25 #define DIGIKAM_DIMG_CHILD_ITEM_H
26 
27 // Qt includes
28 
29 #include <QGraphicsObject>
30 
31 // Local includes
32 
33 #include "digikam_export.h"
34 
35 namespace Digikam
36 {
37 
38 class GraphicsDImgItem;
39 
40 class DIGIKAM_EXPORT DImgChildItem : public QGraphicsObject // clazy:exclude=ctor-missing-parent-argument
41 {
42  Q_OBJECT
43 
44 public:
45 
53  explicit DImgChildItem(QGraphicsItem* const parent = nullptr);
54  ~DImgChildItem() override;
55 
60  void setRelativePos(const QPointF& relativePosition);
61  void setRelativePos(qreal x, qreal y)
62  {
63  setRelativePos(QPointF(x, y));
64  }
65 
66  void setRelativeSize(const QSizeF& relativeSize);
67  void setRelativeSize(qreal width, qreal height)
68  {
69  setRelativeSize(QSizeF(width, height));
70  }
71 
72  void setRelativeRect(const QRectF& rect);
73  void setRelativeRect(qreal x, qreal y, qreal width, qreal height)
74  {
75  setRelativeRect(QRectF(x, y, width, height));
76  }
77 
82  QRectF relativeRect() const;
83  QPointF relativePos() const;
84  QSizeF relativeSize() const;
85 
91  void setOriginalPos(const QPointF& posInOriginal);
92  void setOriginalPos(qreal x, qreal y)
93  {
94  setOriginalPos(QPointF(x, y));
95  }
96 
97  void setOriginalSize(const QSizeF& sizeInOriginal);
98  void setOriginalSize(qreal width, qreal height)
99  {
100  setOriginalSize(QSizeF(width, height));
101  }
102 
103  void setOriginalRect(const QRectF& rect);
104  void setOriginalRect(qreal x, qreal y, qreal width, qreal height)
105  {
106  setOriginalRect(QRectF(x, y,width, height));
107  }
108 
115  QRect originalRect() const;
116  QPoint originalPos() const;
117  QSize originalSize() const;
118 
124  void setPos(const QPointF& zoomedPos);
125  void setPos(qreal x, qreal y)
126  {
127  setPos(QPointF(x, y));
128  }
129 
130  void setSize(const QSizeF& zoomedSize);
131  void setSize(qreal width, qreal height)
132  {
133  setSize(QSizeF(width, height));
134  }
135 
136  void setRect(const QRectF& rect);
137  void setRect(qreal x, qreal y, qreal width, qreal height)
138  {
139  setPos(QPointF(x,y));
140  setSize(QSizeF(width, height));
141  }
142 
146  void setRectInSceneCoordinates(const QRectF& rect);
147 
153  QRectF rect() const;
154  QSizeF size() const;
155 
156  // Override
157  void moveBy(qreal dx, qreal dy)
158  {
159  setPos(pos().x() + dx, pos().y() + dy);
160  }
161 
166  GraphicsDImgItem* parentDImgItem() const;
167 
172  QRectF boundingRect() const override;
173 
174 protected Q_SLOTS:
175 
176  void imageSizeChanged(const QSizeF&);
177 
178 Q_SIGNALS:
179 
187 
195  void sizeChanged();
197 
198 protected:
199 
200  QVariant itemChange(GraphicsItemChange change,
201  const QVariant& value) override;
202 
203 private:
204 
205  void updatePos();
206  void updateSize();
207 
208 private:
209 
210  class Private;
211  Private* const d;
212 };
213 
214 } // namespace Digikam
215 
216 #endif // DIGIKAM_DIMG_CHILD_ITEM_H
Definition: dimgchilditem.h:41
void setRelativeRect(qreal x, qreal y, qreal width, qreal height)
Definition: dimgchilditem.h:73
void setPos(qreal x, qreal y)
Definition: dimgchilditem.h:125
void setSize(qreal width, qreal height)
Definition: dimgchilditem.h:131
void setOriginalSize(qreal width, qreal height)
Definition: dimgchilditem.h:98
void setRelativeSize(qreal width, qreal height)
Definition: dimgchilditem.h:67
void setOriginalPos(qreal x, qreal y)
Definition: dimgchilditem.h:92
void setOriginalRect(qreal x, qreal y, qreal width, qreal height)
Definition: dimgchilditem.h:104
void moveBy(qreal dx, qreal dy)
Definition: dimgchilditem.h:157
void setRect(qreal x, qreal y, qreal width, qreal height)
Definition: dimgchilditem.h:137
void setRelativePos(qreal x, qreal y)
Definition: dimgchilditem.h:61
Definition: dimgitems_p.h:75
qulonglong value
Definition: itemviewutilities.cpp:592
Definition: datefolderview.cpp:43