author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Wed, 21 Apr 2010 11:15:19 +0300 | |
branch | RCL_3 |
changeset 11 | 25a739ee40f4 |
parent 7 | 3f74d0d4af4c |
child 13 | c0432d11811c |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the QtGui module of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#ifndef QGRAPHICSITEM_P_H |
|
43 |
#define QGRAPHICSITEM_P_H |
|
44 |
||
45 |
// |
|
46 |
// W A R N I N G |
|
47 |
// ------------- |
|
48 |
// |
|
49 |
// This file is not part of the Qt API. It exists for the convenience |
|
50 |
// of other Qt classes. This header file may change from version to |
|
51 |
// version without notice, or even be removed. |
|
52 |
// |
|
53 |
// We mean it. |
|
54 |
// |
|
55 |
||
56 |
#include "qgraphicsitem.h" |
|
57 |
#include "qset.h" |
|
58 |
#include "qpixmapcache.h" |
|
59 |
#include <private/qgraphicsview_p.h> |
|
60 |
#include "qgraphicstransform.h" |
|
61 |
#include <private/qgraphicstransform_p.h> |
|
62 |
||
63 |
#include <private/qgraphicseffect_p.h> |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
64 |
#include <qgraphicseffect.h> |
0 | 65 |
|
66 |
#include <QtCore/qpoint.h> |
|
67 |
||
68 |
#if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW |
|
69 |
||
70 |
QT_BEGIN_NAMESPACE |
|
71 |
||
72 |
class QGraphicsItemPrivate; |
|
73 |
||
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
74 |
#ifndef QDECLARATIVELISTPROPERTY |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
75 |
#define QDECLARATIVELISTPROPERTY |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
76 |
template<typename T> |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
77 |
struct QDeclarativeListProperty { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
78 |
typedef void (*AppendFunction)(QDeclarativeListProperty<T> *, T*); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
79 |
typedef int (*CountFunction)(QDeclarativeListProperty<T> *); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
80 |
typedef T *(*AtFunction)(QDeclarativeListProperty<T> *, int); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
81 |
typedef void (*ClearFunction)(QDeclarativeListProperty<T> *); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
82 |
|
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
83 |
QDeclarativeListProperty() |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
84 |
: object(0), data(0), append(0), count(0), at(0), clear(0), dummy1(0), dummy2(0) {} |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
85 |
QDeclarativeListProperty(QObject *o, QList<T *> &list) |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
86 |
: object(o), data(&list), append(qlist_append), count(qlist_count), at(qlist_at), |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
87 |
clear(qlist_clear), dummy1(0), dummy2(0) {} |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
88 |
QDeclarativeListProperty(QObject *o, void *d, AppendFunction a, CountFunction c = 0, AtFunction t = 0, |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
89 |
ClearFunction r = 0) |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
90 |
: object(o), data(d), append(a), count(c), at(t), clear(r), dummy1(0), dummy2(0) {} |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
91 |
|
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
92 |
bool operator==(const QDeclarativeListProperty &o) const { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
93 |
return object == o.object && |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
94 |
data == o.data && |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
95 |
append == o.append && |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
96 |
count == o.count && |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
97 |
at == o.at && |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
98 |
clear == o.clear; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
99 |
} |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
100 |
|
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
101 |
QObject *object; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
102 |
void *data; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
103 |
|
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
104 |
AppendFunction append; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
105 |
|
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
106 |
CountFunction count; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
107 |
AtFunction at; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
108 |
|
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
109 |
ClearFunction clear; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
110 |
|
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
111 |
void *dummy1; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
112 |
void *dummy2; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
113 |
|
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
114 |
private: |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
115 |
static void qlist_append(QDeclarativeListProperty *p, T *v) { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
116 |
((QList<T *> *)p->data)->append(v); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
117 |
} |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
118 |
static int qlist_count(QDeclarativeListProperty *p) { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
119 |
return ((QList<T *> *)p->data)->count(); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
120 |
} |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
121 |
static T *qlist_at(QDeclarativeListProperty *p, int idx) { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
122 |
return ((QList<T *> *)p->data)->at(idx); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
123 |
} |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
124 |
static void qlist_clear(QDeclarativeListProperty *p) { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
125 |
return ((QList<T *> *)p->data)->clear(); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
126 |
} |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
127 |
}; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
128 |
#endif |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
129 |
|
0 | 130 |
class QGraphicsItemCache |
131 |
{ |
|
132 |
public: |
|
133 |
QGraphicsItemCache() : allExposed(false) { } |
|
134 |
||
135 |
// ItemCoordinateCache only |
|
136 |
QRect boundingRect; |
|
137 |
QSize fixedSize; |
|
138 |
QPixmapCache::Key key; |
|
139 |
||
140 |
// DeviceCoordinateCache only |
|
141 |
struct DeviceData { |
|
142 |
DeviceData() {} |
|
143 |
QTransform lastTransform; |
|
144 |
QPoint cacheIndent; |
|
145 |
QPixmapCache::Key key; |
|
146 |
}; |
|
147 |
QMap<QPaintDevice *, DeviceData> deviceData; |
|
148 |
||
149 |
// List of logical exposed rects |
|
150 |
QVector<QRectF> exposed; |
|
151 |
bool allExposed; |
|
152 |
||
153 |
// Empty cache |
|
154 |
void purge(); |
|
155 |
}; |
|
156 |
||
157 |
class Q_GUI_EXPORT QGraphicsItemPrivate |
|
158 |
{ |
|
159 |
Q_DECLARE_PUBLIC(QGraphicsItem) |
|
160 |
public: |
|
161 |
enum Extra { |
|
162 |
ExtraToolTip, |
|
163 |
ExtraCursor, |
|
164 |
ExtraCacheData, |
|
165 |
ExtraMaxDeviceCoordCacheSize, |
|
166 |
ExtraBoundingRegionGranularity |
|
167 |
}; |
|
168 |
||
169 |
enum AncestorFlag { |
|
170 |
NoFlag = 0, |
|
171 |
AncestorHandlesChildEvents = 0x1, |
|
172 |
AncestorClipsChildren = 0x2, |
|
173 |
AncestorIgnoresTransformations = 0x4, |
|
174 |
AncestorFiltersChildEvents = 0x8 |
|
175 |
}; |
|
176 |
||
177 |
inline QGraphicsItemPrivate() |
|
178 |
: z(0), |
|
179 |
opacity(1.), |
|
180 |
scene(0), |
|
181 |
parent(0), |
|
182 |
transformData(0), |
|
183 |
graphicsEffect(0), |
|
184 |
index(-1), |
|
185 |
siblingIndex(-1), |
|
186 |
itemDepth(-1), |
|
187 |
focusProxy(0), |
|
188 |
subFocusItem(0), |
|
189 |
focusScopeItem(0), |
|
190 |
imHints(Qt::ImhNone), |
|
191 |
panelModality(QGraphicsItem::NonModal), |
|
192 |
acceptedMouseButtons(0x1f), |
|
193 |
visible(1), |
|
194 |
explicitlyHidden(0), |
|
195 |
enabled(1), |
|
196 |
explicitlyDisabled(0), |
|
197 |
selected(0), |
|
198 |
acceptsHover(0), |
|
199 |
acceptDrops(0), |
|
200 |
isMemberOfGroup(0), |
|
201 |
handlesChildEvents(0), |
|
202 |
itemDiscovered(0), |
|
203 |
hasCursor(0), |
|
204 |
ancestorFlags(0), |
|
205 |
cacheMode(0), |
|
206 |
hasBoundingRegionGranularity(0), |
|
207 |
isWidget(0), |
|
208 |
dirty(0), |
|
209 |
dirtyChildren(0), |
|
210 |
localCollisionHack(0), |
|
211 |
inSetPosHelper(0), |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
212 |
needSortChildren(0), |
0 | 213 |
allChildrenDirty(0), |
214 |
fullUpdatePending(0), |
|
215 |
flags(0), |
|
216 |
dirtyChildrenBoundingRect(1), |
|
217 |
paintedViewBoundingRectsNeedRepaint(0), |
|
218 |
dirtySceneTransform(1), |
|
219 |
geometryChanged(1), |
|
220 |
inDestructor(0), |
|
221 |
isObject(0), |
|
222 |
ignoreVisible(0), |
|
223 |
ignoreOpacity(0), |
|
224 |
acceptTouchEvents(0), |
|
225 |
acceptedTouchBeginEvent(0), |
|
226 |
filtersDescendantEvents(0), |
|
227 |
sceneTransformTranslateOnly(0), |
|
228 |
notifyBoundingRectChanged(0), |
|
229 |
notifyInvalidated(0), |
|
230 |
mouseSetsFocus(1), |
|
231 |
explicitActivate(0), |
|
232 |
wantsActive(0), |
|
233 |
holesInSiblingIndex(0), |
|
234 |
sequentialOrdering(1), |
|
235 |
updateDueToGraphicsEffect(0), |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
236 |
scenePosDescendants(0), |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
237 |
pendingPolish(0), |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
238 |
mayHaveChildWithGraphicsEffect(0), |
0 | 239 |
globalStackingOrder(-1), |
240 |
q_ptr(0) |
|
241 |
{ |
|
242 |
} |
|
243 |
||
244 |
inline virtual ~QGraphicsItemPrivate() |
|
245 |
{ } |
|
246 |
||
247 |
static const QGraphicsItemPrivate *get(const QGraphicsItem *item) |
|
248 |
{ |
|
249 |
return item->d_ptr.data(); |
|
250 |
} |
|
251 |
static QGraphicsItemPrivate *get(QGraphicsItem *item) |
|
252 |
{ |
|
253 |
return item->d_ptr.data(); |
|
254 |
} |
|
255 |
||
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
256 |
void updateChildWithGraphicsEffectFlagRecursively(); |
0 | 257 |
void updateAncestorFlag(QGraphicsItem::GraphicsItemFlag childFlag, |
258 |
AncestorFlag flag = NoFlag, bool enabled = false, bool root = true); |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
259 |
void updateAncestorFlags(); |
0 | 260 |
void setIsMemberOfGroup(bool enabled); |
261 |
void remapItemPos(QEvent *event, QGraphicsItem *item); |
|
262 |
QPointF genericMapFromScene(const QPointF &pos, const QWidget *viewport) const; |
|
263 |
inline bool itemIsUntransformable() const |
|
264 |
{ |
|
265 |
return (flags & QGraphicsItem::ItemIgnoresTransformations) |
|
266 |
|| (ancestorFlags & AncestorIgnoresTransformations); |
|
267 |
} |
|
268 |
||
269 |
void combineTransformToParent(QTransform *x, const QTransform *viewTransform = 0) const; |
|
270 |
void combineTransformFromParent(QTransform *x, const QTransform *viewTransform = 0) const; |
|
271 |
virtual void updateSceneTransformFromParent(); |
|
272 |
||
273 |
// ### Qt 5: Remove. Workaround for reimplementation added after Qt 4.4. |
|
274 |
virtual QVariant inputMethodQueryHelper(Qt::InputMethodQuery query) const; |
|
275 |
static bool movableAncestorIsSelected(const QGraphicsItem *item); |
|
276 |
||
277 |
virtual void setPosHelper(const QPointF &pos); |
|
278 |
void setTransformHelper(const QTransform &transform); |
|
279 |
void appendGraphicsTransform(QGraphicsTransform *t); |
|
280 |
void setVisibleHelper(bool newVisible, bool explicitly, bool update = true); |
|
281 |
void setEnabledHelper(bool newEnabled, bool explicitly, bool update = true); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
282 |
bool discardUpdateRequest(bool ignoreVisibleBit = false, |
0 | 283 |
bool ignoreDirtyBit = false, bool ignoreOpacity = false) const; |
284 |
int depth() const; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
285 |
#ifndef QT_NO_GRAPHICSEFFECT |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
286 |
enum InvalidateReason { |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
287 |
OpacityChanged |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
288 |
}; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
289 |
void invalidateParentGraphicsEffectsRecursively(); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
290 |
void invalidateChildGraphicsEffectsRecursively(InvalidateReason reason); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
291 |
#endif //QT_NO_GRAPHICSEFFECT |
0 | 292 |
void invalidateDepthRecursively(); |
293 |
void resolveDepth(); |
|
294 |
void addChild(QGraphicsItem *child); |
|
295 |
void removeChild(QGraphicsItem *child); |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
296 |
QDeclarativeListProperty<QGraphicsObject> childrenList(); |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
297 |
void setParentItemHelper(QGraphicsItem *parent, const QVariant *newParentVariant, |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
298 |
const QVariant *thisPointerVariant); |
0 | 299 |
void childrenBoundingRectHelper(QTransform *x, QRectF *rect); |
300 |
void initStyleOption(QStyleOptionGraphicsItem *option, const QTransform &worldTransform, |
|
301 |
const QRegion &exposedRegion, bool allItems = false) const; |
|
302 |
QRectF effectiveBoundingRect() const; |
|
303 |
QRectF sceneEffectiveBoundingRect() const; |
|
304 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
305 |
QRectF effectiveBoundingRect(const QRectF &rect) const; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
306 |
|
0 | 307 |
virtual void resolveFont(uint inheritedMask) |
308 |
{ |
|
309 |
for (int i = 0; i < children.size(); ++i) |
|
310 |
children.at(i)->d_ptr->resolveFont(inheritedMask); |
|
311 |
} |
|
312 |
||
313 |
virtual void resolvePalette(uint inheritedMask) |
|
314 |
{ |
|
315 |
for (int i = 0; i < children.size(); ++i) |
|
316 |
children.at(i)->d_ptr->resolveFont(inheritedMask); |
|
317 |
} |
|
318 |
||
319 |
virtual bool isProxyWidget() const; |
|
320 |
||
321 |
inline QVariant extra(Extra type) const |
|
322 |
{ |
|
323 |
for (int i = 0; i < extras.size(); ++i) { |
|
324 |
const ExtraStruct &extra = extras.at(i); |
|
325 |
if (extra.type == type) |
|
326 |
return extra.value; |
|
327 |
} |
|
328 |
return QVariant(); |
|
329 |
} |
|
330 |
||
331 |
inline void setExtra(Extra type, const QVariant &value) |
|
332 |
{ |
|
333 |
int index = -1; |
|
334 |
for (int i = 0; i < extras.size(); ++i) { |
|
335 |
if (extras.at(i).type == type) { |
|
336 |
index = i; |
|
337 |
break; |
|
338 |
} |
|
339 |
} |
|
340 |
||
341 |
if (index == -1) { |
|
342 |
extras << ExtraStruct(type, value); |
|
343 |
} else { |
|
344 |
extras[index].value = value; |
|
345 |
} |
|
346 |
} |
|
347 |
||
348 |
inline void unsetExtra(Extra type) |
|
349 |
{ |
|
350 |
for (int i = 0; i < extras.size(); ++i) { |
|
351 |
if (extras.at(i).type == type) { |
|
352 |
extras.removeAt(i); |
|
353 |
return; |
|
354 |
} |
|
355 |
} |
|
356 |
} |
|
357 |
||
358 |
struct ExtraStruct { |
|
359 |
ExtraStruct(Extra type, QVariant value) |
|
360 |
: type(type), value(value) |
|
361 |
{ } |
|
362 |
||
363 |
Extra type; |
|
364 |
QVariant value; |
|
365 |
||
366 |
bool operator<(Extra extra) const |
|
367 |
{ return type < extra; } |
|
368 |
}; |
|
369 |
||
370 |
QList<ExtraStruct> extras; |
|
371 |
||
372 |
QGraphicsItemCache *maybeExtraItemCache() const; |
|
373 |
QGraphicsItemCache *extraItemCache() const; |
|
374 |
void removeExtraItemCache(); |
|
375 |
||
376 |
void ensureSceneTransformRecursive(QGraphicsItem **topMostDirtyItem); |
|
377 |
inline void ensureSceneTransform() |
|
378 |
{ |
|
379 |
QGraphicsItem *that = q_func(); |
|
380 |
ensureSceneTransformRecursive(&that); |
|
381 |
} |
|
382 |
||
383 |
inline bool hasTranslateOnlySceneTransform() |
|
384 |
{ |
|
385 |
ensureSceneTransform(); |
|
386 |
return sceneTransformTranslateOnly; |
|
387 |
} |
|
388 |
||
389 |
inline void invalidateChildrenSceneTransform() |
|
390 |
{ |
|
391 |
for (int i = 0; i < children.size(); ++i) |
|
392 |
children.at(i)->d_ptr->dirtySceneTransform = 1; |
|
393 |
} |
|
394 |
||
395 |
inline qreal calcEffectiveOpacity() const |
|
396 |
{ |
|
397 |
qreal o = opacity; |
|
398 |
QGraphicsItem *p = parent; |
|
399 |
int myFlags = flags; |
|
400 |
while (p) { |
|
401 |
int parentFlags = p->d_ptr->flags; |
|
402 |
||
403 |
// If I have a parent, and I don't ignore my parent's opacity, and my |
|
404 |
// parent propagates to me, then combine my local opacity with my parent's |
|
405 |
// effective opacity into my effective opacity. |
|
406 |
if ((myFlags & QGraphicsItem::ItemIgnoresParentOpacity) |
|
407 |
|| (parentFlags & QGraphicsItem::ItemDoesntPropagateOpacityToChildren)) { |
|
408 |
break; |
|
409 |
} |
|
410 |
||
411 |
o *= p->d_ptr->opacity; |
|
412 |
p = p->d_ptr->parent; |
|
413 |
myFlags = parentFlags; |
|
414 |
} |
|
415 |
return o; |
|
416 |
} |
|
417 |
||
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
418 |
inline bool isOpacityNull() const |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
419 |
{ return (opacity < qreal(0.001)); } |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
420 |
|
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
421 |
static inline bool isOpacityNull(qreal opacity) |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
422 |
{ return (opacity < qreal(0.001)); } |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
423 |
|
0 | 424 |
inline bool isFullyTransparent() const |
425 |
{ |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
426 |
if (isOpacityNull()) |
0 | 427 |
return true; |
428 |
if (!parent) |
|
429 |
return false; |
|
430 |
||
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
431 |
return isOpacityNull(calcEffectiveOpacity()); |
0 | 432 |
} |
433 |
||
434 |
inline qreal effectiveOpacity() const { |
|
435 |
if (!parent || !opacity) |
|
436 |
return opacity; |
|
437 |
||
438 |
return calcEffectiveOpacity(); |
|
439 |
} |
|
440 |
||
441 |
inline qreal combineOpacityFromParent(qreal parentOpacity) const |
|
442 |
{ |
|
443 |
if (parent && !(flags & QGraphicsItem::ItemIgnoresParentOpacity) |
|
444 |
&& !(parent->d_ptr->flags & QGraphicsItem::ItemDoesntPropagateOpacityToChildren)) { |
|
445 |
return parentOpacity * opacity; |
|
446 |
} |
|
447 |
return opacity; |
|
448 |
} |
|
449 |
||
450 |
inline bool childrenCombineOpacity() const |
|
451 |
{ |
|
452 |
if (!children.size()) |
|
453 |
return true; |
|
454 |
if (flags & QGraphicsItem::ItemDoesntPropagateOpacityToChildren) |
|
455 |
return false; |
|
456 |
||
457 |
for (int i = 0; i < children.size(); ++i) { |
|
458 |
if (children.at(i)->d_ptr->flags & QGraphicsItem::ItemIgnoresParentOpacity) |
|
459 |
return false; |
|
460 |
} |
|
461 |
return true; |
|
462 |
} |
|
463 |
||
464 |
inline bool childrenClippedToShape() const |
|
465 |
{ return (flags & QGraphicsItem::ItemClipsChildrenToShape) || children.isEmpty(); } |
|
466 |
||
467 |
inline bool isInvisible() const |
|
468 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
469 |
return !visible || (childrenCombineOpacity() && isFullyTransparent()); |
0 | 470 |
} |
471 |
||
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
472 |
inline void markParentDirty(bool updateBoundingRect = false); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
473 |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
474 |
void setFocusHelper(Qt::FocusReason focusReason, bool climb, bool focusFromShow); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
475 |
void clearFocusHelper(bool giveFocusToParent); |
0 | 476 |
void setSubFocus(QGraphicsItem *rootItem = 0); |
477 |
void clearSubFocus(QGraphicsItem *rootItem = 0); |
|
478 |
void resetFocusProxy(); |
|
479 |
virtual void subFocusItemChange(); |
|
480 |
||
481 |
inline QTransform transformToParent() const; |
|
482 |
inline void ensureSortedChildren(); |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
483 |
static void append(QDeclarativeListProperty<QGraphicsObject> *list, QGraphicsObject *item); |
0 | 484 |
static inline bool insertionOrder(QGraphicsItem *a, QGraphicsItem *b); |
485 |
void ensureSequentialSiblingIndex(); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
486 |
inline void sendScenePosChange(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
487 |
virtual void siblingOrderChange(); |
0 | 488 |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
489 |
// Private Properties |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
490 |
virtual qreal width() const; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
491 |
virtual void setWidth(qreal); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
492 |
virtual void resetWidth(); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
493 |
|
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
494 |
virtual qreal height() const; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
495 |
virtual void setHeight(qreal); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
496 |
virtual void resetHeight(); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
497 |
|
0 | 498 |
QRectF childrenBoundingRect; |
499 |
QRectF needsRepaint; |
|
500 |
QMap<QWidget *, QRect> paintedViewBoundingRects; |
|
501 |
QPointF pos; |
|
502 |
qreal z; |
|
503 |
qreal opacity; |
|
504 |
QGraphicsScene *scene; |
|
505 |
QGraphicsItem *parent; |
|
506 |
QList<QGraphicsItem *> children; |
|
507 |
struct TransformData; |
|
508 |
TransformData *transformData; |
|
509 |
QGraphicsEffect *graphicsEffect; |
|
510 |
QTransform sceneTransform; |
|
511 |
int index; |
|
512 |
int siblingIndex; |
|
513 |
int itemDepth; // Lazily calculated when calling depth(). |
|
514 |
QGraphicsItem *focusProxy; |
|
515 |
QList<QGraphicsItem **> focusProxyRefs; |
|
516 |
QGraphicsItem *subFocusItem; |
|
517 |
QGraphicsItem *focusScopeItem; |
|
518 |
Qt::InputMethodHints imHints; |
|
519 |
QGraphicsItem::PanelModality panelModality; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
520 |
QMap<Qt::GestureType, Qt::GestureFlags> gestureContext; |
0 | 521 |
|
522 |
// Packed 32 bits |
|
523 |
quint32 acceptedMouseButtons : 5; |
|
524 |
quint32 visible : 1; |
|
525 |
quint32 explicitlyHidden : 1; |
|
526 |
quint32 enabled : 1; |
|
527 |
quint32 explicitlyDisabled : 1; |
|
528 |
quint32 selected : 1; |
|
529 |
quint32 acceptsHover : 1; |
|
530 |
quint32 acceptDrops : 1; |
|
531 |
quint32 isMemberOfGroup : 1; |
|
532 |
quint32 handlesChildEvents : 1; |
|
533 |
quint32 itemDiscovered : 1; |
|
534 |
quint32 hasCursor : 1; |
|
535 |
quint32 ancestorFlags : 4; |
|
536 |
quint32 cacheMode : 2; |
|
537 |
quint32 hasBoundingRegionGranularity : 1; |
|
538 |
quint32 isWidget : 1; |
|
539 |
quint32 dirty : 1; |
|
540 |
quint32 dirtyChildren : 1; |
|
541 |
quint32 localCollisionHack : 1; |
|
542 |
quint32 inSetPosHelper : 1; |
|
543 |
quint32 needSortChildren : 1; |
|
544 |
quint32 allChildrenDirty : 1; |
|
545 |
||
546 |
// Packed 32 bits |
|
547 |
quint32 fullUpdatePending : 1; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
548 |
quint32 flags : 17; |
0 | 549 |
quint32 dirtyChildrenBoundingRect : 1; |
550 |
quint32 paintedViewBoundingRectsNeedRepaint : 1; |
|
551 |
quint32 dirtySceneTransform : 1; |
|
552 |
quint32 geometryChanged : 1; |
|
553 |
quint32 inDestructor : 1; |
|
554 |
quint32 isObject : 1; |
|
555 |
quint32 ignoreVisible : 1; |
|
556 |
quint32 ignoreOpacity : 1; |
|
557 |
quint32 acceptTouchEvents : 1; |
|
558 |
quint32 acceptedTouchBeginEvent : 1; |
|
559 |
quint32 filtersDescendantEvents : 1; |
|
560 |
quint32 sceneTransformTranslateOnly : 1; |
|
561 |
quint32 notifyBoundingRectChanged : 1; |
|
562 |
quint32 notifyInvalidated : 1; |
|
563 |
||
564 |
// New 32 bits |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
565 |
quint32 mouseSetsFocus : 1; |
0 | 566 |
quint32 explicitActivate : 1; |
567 |
quint32 wantsActive : 1; |
|
568 |
quint32 holesInSiblingIndex : 1; |
|
569 |
quint32 sequentialOrdering : 1; |
|
570 |
quint32 updateDueToGraphicsEffect : 1; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
571 |
quint32 scenePosDescendants : 1; |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
572 |
quint32 pendingPolish : 1; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
573 |
quint32 mayHaveChildWithGraphicsEffect : 1; |
0 | 574 |
|
575 |
// Optional stacking order |
|
576 |
int globalStackingOrder; |
|
577 |
QGraphicsItem *q_ptr; |
|
578 |
}; |
|
579 |
||
580 |
struct QGraphicsItemPrivate::TransformData |
|
581 |
{ |
|
582 |
QTransform transform; |
|
583 |
qreal scale; |
|
584 |
qreal rotation; |
|
585 |
qreal xOrigin; |
|
586 |
qreal yOrigin; |
|
587 |
QList<QGraphicsTransform *> graphicsTransforms; |
|
588 |
bool onlyTransform; |
|
589 |
||
590 |
TransformData() : |
|
591 |
scale(1.0), rotation(0.0), |
|
592 |
xOrigin(0.0), yOrigin(0.0), |
|
593 |
onlyTransform(true) |
|
594 |
{ } |
|
595 |
||
596 |
QTransform computedFullTransform(QTransform *postmultiplyTransform = 0) const |
|
597 |
{ |
|
598 |
if (onlyTransform) { |
|
599 |
if (!postmultiplyTransform || postmultiplyTransform->isIdentity()) |
|
600 |
return transform; |
|
601 |
if (transform.isIdentity()) |
|
602 |
return *postmultiplyTransform; |
|
603 |
return transform * *postmultiplyTransform; |
|
604 |
} |
|
605 |
||
606 |
QTransform x(transform); |
|
607 |
if (!graphicsTransforms.isEmpty()) { |
|
608 |
QMatrix4x4 m; |
|
609 |
for (int i = 0; i < graphicsTransforms.size(); ++i) |
|
610 |
graphicsTransforms.at(i)->applyTo(&m); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
611 |
x *= m.toTransform(); |
0 | 612 |
} |
613 |
x.translate(xOrigin, yOrigin); |
|
614 |
x.rotate(rotation); |
|
615 |
x.scale(scale, scale); |
|
616 |
x.translate(-xOrigin, -yOrigin); |
|
617 |
if (postmultiplyTransform) |
|
618 |
x *= *postmultiplyTransform; |
|
619 |
return x; |
|
620 |
} |
|
621 |
}; |
|
622 |
||
623 |
struct QGraphicsItemPaintInfo |
|
624 |
{ |
|
625 |
inline QGraphicsItemPaintInfo(const QTransform *const xform1, const QTransform *const xform2, |
|
626 |
const QTransform *const xform3, |
|
627 |
QRegion *r, QWidget *w, QStyleOptionGraphicsItem *opt, |
|
628 |
QPainter *p, qreal o, bool b1, bool b2) |
|
629 |
: viewTransform(xform1), transformPtr(xform2), effectTransform(xform3), exposedRegion(r), widget(w), |
|
630 |
option(opt), painter(p), opacity(o), wasDirtySceneTransform(b1), drawItem(b2) |
|
631 |
{} |
|
632 |
||
633 |
const QTransform *viewTransform; |
|
634 |
const QTransform *transformPtr; |
|
635 |
const QTransform *effectTransform; |
|
636 |
QRegion *exposedRegion; |
|
637 |
QWidget *widget; |
|
638 |
QStyleOptionGraphicsItem *option; |
|
639 |
QPainter *painter; |
|
640 |
qreal opacity; |
|
641 |
quint32 wasDirtySceneTransform : 1; |
|
642 |
quint32 drawItem : 1; |
|
643 |
}; |
|
644 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
645 |
#ifndef QT_NO_GRAPHICSEFFECT |
0 | 646 |
class QGraphicsItemEffectSourcePrivate : public QGraphicsEffectSourcePrivate |
647 |
{ |
|
648 |
public: |
|
649 |
QGraphicsItemEffectSourcePrivate(QGraphicsItem *i) |
|
650 |
: QGraphicsEffectSourcePrivate(), item(i), info(0) |
|
651 |
{} |
|
652 |
||
653 |
inline void detach() |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
654 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
655 |
item->d_ptr->graphicsEffect = 0; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
656 |
item->prepareGeometryChange(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
657 |
} |
0 | 658 |
|
659 |
inline const QGraphicsItem *graphicsItem() const |
|
660 |
{ return item; } |
|
661 |
||
662 |
inline const QWidget *widget() const |
|
663 |
{ return 0; } |
|
664 |
||
665 |
inline void update() { |
|
666 |
item->d_ptr->updateDueToGraphicsEffect = true; |
|
667 |
item->update(); |
|
668 |
item->d_ptr->updateDueToGraphicsEffect = false; |
|
669 |
} |
|
670 |
||
671 |
inline void effectBoundingRectChanged() |
|
672 |
{ item->prepareGeometryChange(); } |
|
673 |
||
674 |
inline bool isPixmap() const |
|
675 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
676 |
return item->type() == QGraphicsPixmapItem::Type |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
677 |
&& !(item->flags() & QGraphicsItem::ItemIsSelectable) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
678 |
&& item->d_ptr->children.size() == 0; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
679 |
//|| (item->d_ptr->isObject && qobject_cast<QmlGraphicsImage *>(q_func())); |
0 | 680 |
} |
681 |
||
682 |
inline const QStyleOption *styleOption() const |
|
683 |
{ return info ? info->option : 0; } |
|
684 |
||
685 |
inline QRect deviceRect() const |
|
686 |
{ |
|
687 |
if (!info || !info->widget) { |
|
688 |
qWarning("QGraphicsEffectSource::deviceRect: Not yet implemented, lacking device context"); |
|
689 |
return QRect(); |
|
690 |
} |
|
691 |
return info->widget->rect(); |
|
692 |
} |
|
693 |
||
694 |
QRectF boundingRect(Qt::CoordinateSystem system) const; |
|
695 |
void draw(QPainter *); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
696 |
QPixmap pixmap(Qt::CoordinateSystem system, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
697 |
QPoint *offset, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
698 |
QGraphicsEffect::PixmapPadMode mode) const; |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
699 |
QRect paddedEffectRect(Qt::CoordinateSystem system, QGraphicsEffect::PixmapPadMode mode, const QRectF &sourceRect, bool *unpadded = 0) const; |
0 | 700 |
|
701 |
QGraphicsItem *item; |
|
702 |
QGraphicsItemPaintInfo *info; |
|
703 |
QTransform lastEffectTransform; |
|
704 |
}; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
705 |
#endif //QT_NO_GRAPHICSEFFECT |
0 | 706 |
|
707 |
/*! |
|
708 |
Returns true if \a item1 is on top of \a item2. |
|
709 |
The items dont need to be siblings. |
|
710 |
||
711 |
\internal |
|
712 |
*/ |
|
713 |
inline bool qt_closestItemFirst(const QGraphicsItem *item1, const QGraphicsItem *item2) |
|
714 |
{ |
|
715 |
// Siblings? Just check their z-values. |
|
716 |
const QGraphicsItemPrivate *d1 = item1->d_ptr.data(); |
|
717 |
const QGraphicsItemPrivate *d2 = item2->d_ptr.data(); |
|
718 |
if (d1->parent == d2->parent) |
|
719 |
return qt_closestLeaf(item1, item2); |
|
720 |
||
721 |
// Find common ancestor, and each item's ancestor closest to the common |
|
722 |
// ancestor. |
|
723 |
int item1Depth = d1->depth(); |
|
724 |
int item2Depth = d2->depth(); |
|
725 |
const QGraphicsItem *p = item1; |
|
726 |
const QGraphicsItem *t1 = item1; |
|
727 |
while (item1Depth > item2Depth && (p = p->d_ptr->parent)) { |
|
728 |
if (p == item2) { |
|
729 |
// item2 is one of item1's ancestors; item1 is on top |
|
730 |
return !(t1->d_ptr->flags & QGraphicsItem::ItemStacksBehindParent); |
|
731 |
} |
|
732 |
t1 = p; |
|
733 |
--item1Depth; |
|
734 |
} |
|
735 |
p = item2; |
|
736 |
const QGraphicsItem *t2 = item2; |
|
737 |
while (item2Depth > item1Depth && (p = p->d_ptr->parent)) { |
|
738 |
if (p == item1) { |
|
739 |
// item1 is one of item2's ancestors; item1 is not on top |
|
740 |
return (t2->d_ptr->flags & QGraphicsItem::ItemStacksBehindParent); |
|
741 |
} |
|
742 |
t2 = p; |
|
743 |
--item2Depth; |
|
744 |
} |
|
745 |
||
746 |
// item1Ancestor is now at the same level as item2Ancestor, but not the same. |
|
747 |
const QGraphicsItem *p1 = t1; |
|
748 |
const QGraphicsItem *p2 = t2; |
|
749 |
while (t1 && t1 != t2) { |
|
750 |
p1 = t1; |
|
751 |
p2 = t2; |
|
752 |
t1 = t1->d_ptr->parent; |
|
753 |
t2 = t2->d_ptr->parent; |
|
754 |
} |
|
755 |
||
756 |
// in case we have a common ancestor, we compare the immediate children in the ancestor's path. |
|
757 |
// otherwise we compare the respective items' topLevelItems directly. |
|
758 |
return qt_closestLeaf(p1, p2); |
|
759 |
} |
|
760 |
||
761 |
/*! |
|
762 |
Returns true if \a item2 is on top of \a item1. |
|
763 |
The items dont need to be siblings. |
|
764 |
||
765 |
\internal |
|
766 |
*/ |
|
767 |
inline bool qt_closestItemLast(const QGraphicsItem *item1, const QGraphicsItem *item2) |
|
768 |
{ |
|
769 |
return qt_closestItemFirst(item2, item1); |
|
770 |
} |
|
771 |
||
772 |
/*! |
|
773 |
\internal |
|
774 |
*/ |
|
775 |
inline bool qt_closestLeaf(const QGraphicsItem *item1, const QGraphicsItem *item2) |
|
776 |
{ |
|
777 |
// Return true if sibling item1 is on top of item2. |
|
778 |
const QGraphicsItemPrivate *d1 = item1->d_ptr.data(); |
|
779 |
const QGraphicsItemPrivate *d2 = item2->d_ptr.data(); |
|
780 |
bool f1 = d1->flags & QGraphicsItem::ItemStacksBehindParent; |
|
781 |
bool f2 = d2->flags & QGraphicsItem::ItemStacksBehindParent; |
|
782 |
if (f1 != f2) |
|
783 |
return f2; |
|
784 |
if (d1->z != d2->z) |
|
785 |
return d1->z > d2->z; |
|
786 |
return d1->siblingIndex > d2->siblingIndex; |
|
787 |
} |
|
788 |
||
789 |
/*! |
|
790 |
\internal |
|
791 |
*/ |
|
792 |
inline bool qt_notclosestLeaf(const QGraphicsItem *item1, const QGraphicsItem *item2) |
|
793 |
{ return qt_closestLeaf(item2, item1); } |
|
794 |
||
795 |
/* |
|
796 |
return the full transform of the item to the parent. This include the position and all the transform data |
|
797 |
*/ |
|
798 |
inline QTransform QGraphicsItemPrivate::transformToParent() const |
|
799 |
{ |
|
800 |
QTransform matrix; |
|
801 |
combineTransformToParent(&matrix); |
|
802 |
return matrix; |
|
803 |
} |
|
804 |
||
805 |
/*! |
|
806 |
\internal |
|
807 |
*/ |
|
808 |
inline void QGraphicsItemPrivate::ensureSortedChildren() |
|
809 |
{ |
|
810 |
if (needSortChildren) { |
|
811 |
needSortChildren = 0; |
|
812 |
sequentialOrdering = 1; |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
813 |
if (children.isEmpty()) |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
814 |
return; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
815 |
qSort(children.begin(), children.end(), qt_notclosestLeaf); |
0 | 816 |
for (int i = 0; i < children.size(); ++i) { |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
817 |
if (children.at(i)->d_ptr->siblingIndex != i) { |
0 | 818 |
sequentialOrdering = 0; |
819 |
break; |
|
820 |
} |
|
821 |
} |
|
822 |
} |
|
823 |
} |
|
824 |
||
825 |
/*! |
|
826 |
\internal |
|
827 |
*/ |
|
828 |
inline bool QGraphicsItemPrivate::insertionOrder(QGraphicsItem *a, QGraphicsItem *b) |
|
829 |
{ |
|
830 |
return a->d_ptr->siblingIndex < b->d_ptr->siblingIndex; |
|
831 |
} |
|
832 |
||
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
833 |
/*! |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
834 |
\internal |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
835 |
*/ |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
836 |
inline void QGraphicsItemPrivate::markParentDirty(bool updateBoundingRect) |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
837 |
{ |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
838 |
QGraphicsItemPrivate *parentp = this; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
839 |
while (parentp->parent) { |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
840 |
parentp = parentp->parent->d_ptr.data(); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
841 |
parentp->dirtyChildren = 1; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
842 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
843 |
if (updateBoundingRect) { |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
844 |
parentp->dirtyChildrenBoundingRect = 1; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
845 |
// ### Only do this if the parent's effect applies to the entire subtree. |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
846 |
parentp->notifyBoundingRectChanged = 1; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
847 |
} |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
848 |
#ifndef QT_NO_GRAPHICSEFFECT |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
849 |
if (parentp->graphicsEffect) { |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
850 |
if (updateBoundingRect) { |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
851 |
parentp->notifyInvalidated = 1; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
852 |
static_cast<QGraphicsItemEffectSourcePrivate *>(parentp->graphicsEffect->d_func() |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
853 |
->source->d_func())->invalidateCache(); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
854 |
} |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
855 |
if (parentp->graphicsEffect->isEnabled()) { |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
856 |
parentp->dirty = 1; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
857 |
parentp->fullUpdatePending = 1; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
858 |
} |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
859 |
} |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
860 |
#endif |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
861 |
} |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
862 |
} |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
863 |
|
0 | 864 |
QT_END_NAMESPACE |
865 |
||
866 |
#endif // QT_NO_GRAPHICSVIEW |
|
867 |
||
868 |
#endif |