Fix test fails related to QTBUG-22237
[profile/ivi/qtdeclarative.git] / src / declarative / items / qquickitem_p.h
1 // Commit: 5c783d0a9a912816813945387903857a314040b5
2 /****************************************************************************
3 **
4 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
5 ** All rights reserved.
6 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 **
8 ** This file is part of the QtDeclarative module of the Qt Toolkit.
9 **
10 ** $QT_BEGIN_LICENSE:LGPL$
11 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this
15 ** file. Please review the following information to ensure the GNU Lesser
16 ** General Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 **
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 **
23 ** GNU General Public License Usage
24 ** Alternatively, this file may be used under the terms of the GNU General
25 ** Public License version 3.0 as published by the Free Software Foundation
26 ** and appearing in the file LICENSE.GPL included in the packaging of this
27 ** file. Please review the following information to ensure the GNU General
28 ** Public License version 3.0 requirements will be met:
29 ** http://www.gnu.org/copyleft/gpl.html.
30 **
31 ** Other Usage
32 ** Alternatively, this file may be used in accordance with the terms and
33 ** conditions contained in a signed written agreement between you and Nokia.
34 **
35 **
36 **
37 **
38 **
39 ** $QT_END_LICENSE$
40 **
41 ****************************************************************************/
42
43 #ifndef QQUICKITEM_P_H
44 #define QQUICKITEM_P_H
45
46 //
47 //  W A R N I N G
48 //  -------------
49 //
50 // This file is not part of the Qt API.  It exists purely as an
51 // implementation detail.  This header file may change from version to
52 // version without notice, or even be removed.
53 //
54 // We mean it.
55 //
56
57 #include "qquickitem.h"
58
59 #include "qquickanchors_p.h"
60 #include "qquickanchors_p_p.h"
61 #include "qquickitemchangelistener_p.h"
62
63 #include "qquickcanvas_p.h"
64
65 #include <qsgnode.h>
66 #include "qquickclipnode_p.h"
67
68 #include <private/qpodvector_p.h>
69 #include <private/qdeclarativestate_p.h>
70 #include <private/qdeclarativenullablevalue_p_p.h>
71 #include <private/qdeclarativenotifier_p.h>
72 #include <private/qdeclarativeglobal_p.h>
73
74 #include <qdeclarative.h>
75 #include <qdeclarativecontext.h>
76
77 #include <QtCore/qlist.h>
78 #include <QtCore/qdebug.h>
79 #include <QtCore/qelapsedtimer.h>
80
81 QT_BEGIN_NAMESPACE
82
83 class QNetworkReply;
84 class QQuickItemKeyFilter;
85 class QQuickLayoutMirroringAttached;
86
87 //### merge into private?
88 class QQuickContents : public QObject, public QQuickItemChangeListener
89 {
90     Q_OBJECT
91 public:
92     QQuickContents(QQuickItem *item);
93     ~QQuickContents();
94
95     QRectF rectF() const;
96
97     void childRemoved(QQuickItem *item);
98     void childAdded(QQuickItem *item);
99
100     void calcGeometry() { calcWidth(); calcHeight(); }
101     void complete();
102
103 Q_SIGNALS:
104     void rectChanged(QRectF);
105
106 protected:
107     void itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry);
108     void itemDestroyed(QQuickItem *item);
109     //void itemVisibilityChanged(QQuickItem *item)
110
111 private:
112     void calcHeight(QQuickItem *changed = 0);
113     void calcWidth(QQuickItem *changed = 0);
114
115     QQuickItem *m_item;
116     qreal m_x;
117     qreal m_y;
118     qreal m_width;
119     qreal m_height;
120 };
121
122 class QQuickTransformPrivate : public QObjectPrivate
123 {
124     Q_DECLARE_PUBLIC(QQuickTransform);
125 public:
126     static QQuickTransformPrivate* get(QQuickTransform *transform) { return transform->d_func(); }
127
128     QQuickTransformPrivate();
129
130     QList<QQuickItem *> items;
131 };
132
133 class Q_DECLARATIVE_EXPORT QQuickItemPrivate : public QObjectPrivate
134 {
135     Q_DECLARE_PUBLIC(QQuickItem)
136
137 public:
138     static QQuickItemPrivate* get(QQuickItem *item) { return item->d_func(); }
139     static const QQuickItemPrivate* get(const QQuickItem *item) { return item->d_func(); }
140
141     QQuickItemPrivate();
142     void init(QQuickItem *parent);
143
144     QDeclarativeListProperty<QObject> data();
145     QDeclarativeListProperty<QObject> resources();
146     QDeclarativeListProperty<QQuickItem> children();
147
148     QDeclarativeListProperty<QDeclarativeState> states();
149     QDeclarativeListProperty<QDeclarativeTransition> transitions();
150
151     QString state() const;
152     void setState(const QString &);
153
154     QQuickAnchorLine left() const;
155     QQuickAnchorLine right() const;
156     QQuickAnchorLine horizontalCenter() const;
157     QQuickAnchorLine top() const;
158     QQuickAnchorLine bottom() const;
159     QQuickAnchorLine verticalCenter() const;
160     QQuickAnchorLine baseline() const;
161
162     // data property
163     static void data_append(QDeclarativeListProperty<QObject> *, QObject *);
164     static int data_count(QDeclarativeListProperty<QObject> *);
165     static QObject *data_at(QDeclarativeListProperty<QObject> *, int);
166     static void data_clear(QDeclarativeListProperty<QObject> *);
167
168     // resources property
169     static QObject *resources_at(QDeclarativeListProperty<QObject> *, int);
170     static void resources_append(QDeclarativeListProperty<QObject> *, QObject *);
171     static int resources_count(QDeclarativeListProperty<QObject> *);
172     static void resources_clear(QDeclarativeListProperty<QObject> *);
173
174     // children property
175     static void children_append(QDeclarativeListProperty<QQuickItem> *, QQuickItem *);
176     static int children_count(QDeclarativeListProperty<QQuickItem> *);
177     static QQuickItem *children_at(QDeclarativeListProperty<QQuickItem> *, int);
178     static void children_clear(QDeclarativeListProperty<QQuickItem> *);
179
180     // transform property
181     static int transform_count(QDeclarativeListProperty<QQuickTransform> *list);
182     static void transform_append(QDeclarativeListProperty<QQuickTransform> *list, QQuickTransform *);
183     static QQuickTransform *transform_at(QDeclarativeListProperty<QQuickTransform> *list, int);
184     static void transform_clear(QDeclarativeListProperty<QQuickTransform> *list);
185
186     QQuickAnchors *anchors() const;
187     mutable QQuickAnchors *_anchors;
188     QQuickContents *_contents;
189
190     QDeclarativeNullableValue<qreal> baselineOffset;
191
192     struct AnchorLines {
193         AnchorLines(QQuickItem *);
194         QQuickAnchorLine left;
195         QQuickAnchorLine right;
196         QQuickAnchorLine hCenter;
197         QQuickAnchorLine top;
198         QQuickAnchorLine bottom;
199         QQuickAnchorLine vCenter;
200         QQuickAnchorLine baseline;
201     };
202     mutable AnchorLines *_anchorLines;
203     AnchorLines *anchorLines() const;
204
205     enum ChangeType {
206         Geometry = 0x01,
207         SiblingOrder = 0x02,
208         Visibility = 0x04,
209         Opacity = 0x08,
210         Destroyed = 0x10,
211         Parent = 0x20,
212         Children = 0x40,
213         Rotation = 0x80,
214     };
215
216     Q_DECLARE_FLAGS(ChangeTypes, ChangeType)
217
218     struct ChangeListener {
219         ChangeListener(QQuickItemChangeListener *l, QQuickItemPrivate::ChangeTypes t) : listener(l), types(t) {}
220         QQuickItemChangeListener *listener;
221         QQuickItemPrivate::ChangeTypes types;
222         bool operator==(const ChangeListener &other) const { return listener == other.listener && types == other.types; }
223     };
224
225     void addItemChangeListener(QQuickItemChangeListener *listener, ChangeTypes types) {
226         changeListeners.append(ChangeListener(listener, types));
227     }
228     void removeItemChangeListener(QQuickItemChangeListener *, ChangeTypes types);
229     QPODVector<ChangeListener,4> changeListeners;
230
231     QDeclarativeStateGroup *_states();
232     QDeclarativeStateGroup *_stateGroup;
233
234     QQuickItem::TransformOrigin origin:5;
235     quint32 flags:5;
236     bool widthValid:1;
237     bool heightValid:1;
238     bool componentComplete:1;
239     bool keepMouse:1;
240     bool hoverEnabled:1;
241     bool smooth:1;
242     bool focus:1;
243     bool activeFocus:1;
244     bool notifiedFocus:1;
245     bool notifiedActiveFocus:1;
246     bool filtersChildMouseEvents:1;
247     bool explicitVisible:1;
248     bool effectiveVisible:1;
249     bool explicitEnable:1;
250     bool effectiveEnable:1;
251     bool polishScheduled:1;
252     bool inheritedLayoutMirror:1;
253     bool effectiveLayoutMirror:1;
254     bool isMirrorImplicit:1;
255     bool inheritMirrorFromParent:1;
256     bool inheritMirrorFromItem:1;
257     bool childrenDoNotOverlap:1;
258     quint32 dummy:1;
259
260     QQuickCanvas *canvas;
261     QSGContext *sceneGraphContext() const { Q_ASSERT(canvas); return static_cast<QQuickCanvasPrivate *>(QObjectPrivate::get(canvas))->context; }
262
263     QQuickItem *parentItem;
264     QList<QQuickItem *> childItems;
265     QList<QQuickItem *> paintOrderChildItems() const;
266     void addChild(QQuickItem *);
267     void removeChild(QQuickItem *);
268     void siblingOrderChanged();
269
270     class InitializationState {
271     public:
272         QQuickItem *getFocusScope(QQuickItem *item);
273         void clear();
274         void clear(QQuickItem *focusScope);
275     private:
276         QQuickItem *focusScope;
277     };
278     void initCanvas(InitializationState *, QQuickCanvas *);
279
280     QQuickItem *subFocusItem;
281
282     QTransform canvasToItemTransform() const;
283     QTransform itemToCanvasTransform() const;
284     void itemToParentTransform(QTransform &) const;
285
286     qreal x;
287     qreal y;
288     qreal width;
289     qreal height;
290     qreal implicitWidth;
291     qreal implicitHeight;
292
293     qreal z;
294     qreal scale;
295     qreal rotation;
296     qreal opacity;
297
298     QQuickLayoutMirroringAttached* attachedLayoutDirection;
299
300     Qt::MouseButtons acceptedMouseButtons;
301     Qt::InputMethodHints imHints;
302
303     QPointF transformOriginPoint;
304
305     virtual qreal getImplicitWidth() const;
306     virtual qreal getImplicitHeight() const;
307     virtual void implicitWidthChanged();
308     virtual void implicitHeightChanged();
309
310     void resolveLayoutMirror();
311     void setImplicitLayoutMirror(bool mirror, bool inherit);
312     void setLayoutMirror(bool mirror);
313     bool isMirrored() const {
314         return effectiveLayoutMirror;
315     }
316
317     QPointF computeTransformOrigin() const;
318     QList<QQuickTransform *> transforms;
319     virtual void transformChanged();
320
321     QQuickItemKeyFilter *keyHandler;
322     void deliverKeyEvent(QKeyEvent *);
323     void deliverInputMethodEvent(QInputMethodEvent *);
324     void deliverFocusEvent(QFocusEvent *);
325     void deliverMouseEvent(QMouseEvent *);
326     void deliverWheelEvent(QWheelEvent *);
327     void deliverTouchEvent(QTouchEvent *);
328     void deliverHoverEvent(QHoverEvent *);
329     void deliverDragEvent(QEvent *);
330
331     bool calcEffectiveVisible() const;
332     void setEffectiveVisibleRecur(bool);
333     bool calcEffectiveEnable() const;
334     void setEffectiveEnableRecur(bool);
335
336     // XXX todo
337     enum DirtyType {
338         TransformOrigin         = 0x00000001,
339         Transform               = 0x00000002,
340         BasicTransform          = 0x00000004,
341         Position                = 0x00000008,
342         Size                    = 0x00000010,
343
344         ZValue                  = 0x00000020,
345         Content                 = 0x00000040,
346         Smooth                  = 0x00000080,
347         OpacityValue            = 0x00000100,
348         ChildrenChanged         = 0x00000200,
349         ChildrenStackingChanged = 0x00000400,
350         ParentChanged           = 0x00000800,
351
352         Clip                    = 0x00001000,
353         Canvas                  = 0x00002000,
354
355         EffectReference         = 0x00008000,
356         Visible                 = 0x00010000,
357         HideReference           = 0x00020000,
358         // When you add an attribute here, don't forget to update
359         // dirtyToString()
360
361         TransformUpdateMask     = TransformOrigin | Transform | BasicTransform | Position | Size | Canvas,
362         ComplexTransformUpdateMask     = Transform | Canvas,
363         ContentUpdateMask       = Size | Content | Smooth | Canvas,
364         ChildrenUpdateMask      = ChildrenChanged | ChildrenStackingChanged | EffectReference | Canvas,
365
366     };
367     quint32 dirtyAttributes;
368     QString dirtyToString() const;
369     void dirty(DirtyType);
370     void addToDirtyList();
371     void removeFromDirtyList();
372     QQuickItem *nextDirtyItem;
373     QQuickItem**prevDirtyItem;
374
375     inline QSGTransformNode *itemNode();
376     inline QSGNode *childContainerNode();
377
378     /*
379       QSGNode order is:
380          - itemNode
381          - (opacityNode)
382          - (clipNode)
383          - (effectNode)
384          - groupNode
385      */
386
387     QSGTransformNode *itemNodeInstance;
388     QSGOpacityNode *opacityNode;
389     QQuickDefaultClipNode *clipNode;
390     QSGRootNode *rootNode;
391     QSGNode *groupNode;
392     QSGNode *paintNode;
393     QSGNode *beforePaintNode;
394
395     virtual QSGTransformNode *createTransformNode();
396
397     // A reference from an effect item means that this item is used by the effect, so
398     // it should insert a root node.
399     void refFromEffectItem(bool hide);
400     void derefFromEffectItem(bool unhide);
401     int effectRefCount;
402     int hideRefCount;
403
404     void itemChange(QQuickItem::ItemChange, const QQuickItem::ItemChangeData &);
405
406     virtual void mirrorChange() {}
407
408     static qint64 consistentTime;
409     static void setConsistentTime(qint64 t);
410     static void start(QElapsedTimer &);
411     static qint64 elapsed(QElapsedTimer &);
412     static qint64 restart(QElapsedTimer &);
413 };
414
415 /*
416     Key filters can be installed on a QQuickItem, but not removed.  Currently they
417     are only used by attached objects (which are only destroyed on Item
418     destruction), so this isn't a problem.  If in future this becomes any form
419     of public API, they will have to support removal too.
420 */
421 class QQuickItemKeyFilter
422 {
423 public:
424     QQuickItemKeyFilter(QQuickItem * = 0);
425     virtual ~QQuickItemKeyFilter();
426
427     virtual void keyPressed(QKeyEvent *event, bool post);
428     virtual void keyReleased(QKeyEvent *event, bool post);
429     virtual void inputMethodEvent(QInputMethodEvent *event, bool post);
430     virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
431     virtual void componentComplete();
432
433     bool m_processPost;
434
435 private:
436     QQuickItemKeyFilter *m_next;
437 };
438
439 class QQuickKeyNavigationAttachedPrivate : public QObjectPrivate
440 {
441 public:
442     QQuickKeyNavigationAttachedPrivate()
443         : QObjectPrivate(),
444           left(0), right(0), up(0), down(0), tab(0), backtab(0),
445           leftSet(false), rightSet(false), upSet(false), downSet(false),
446           tabSet(false), backtabSet(false) {}
447
448     QQuickItem *left;
449     QQuickItem *right;
450     QQuickItem *up;
451     QQuickItem *down;
452     QQuickItem *tab;
453     QQuickItem *backtab;
454     bool leftSet : 1;
455     bool rightSet : 1;
456     bool upSet : 1;
457     bool downSet : 1;
458     bool tabSet : 1;
459     bool backtabSet : 1;
460 };
461
462 class QQuickKeyNavigationAttached : public QObject, public QQuickItemKeyFilter
463 {
464     Q_OBJECT
465     Q_DECLARE_PRIVATE(QQuickKeyNavigationAttached)
466
467     Q_PROPERTY(QQuickItem *left READ left WRITE setLeft NOTIFY leftChanged)
468     Q_PROPERTY(QQuickItem *right READ right WRITE setRight NOTIFY rightChanged)
469     Q_PROPERTY(QQuickItem *up READ up WRITE setUp NOTIFY upChanged)
470     Q_PROPERTY(QQuickItem *down READ down WRITE setDown NOTIFY downChanged)
471     Q_PROPERTY(QQuickItem *tab READ tab WRITE setTab NOTIFY tabChanged)
472     Q_PROPERTY(QQuickItem *backtab READ backtab WRITE setBacktab NOTIFY backtabChanged)
473     Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY priorityChanged)
474
475     Q_ENUMS(Priority)
476
477 public:
478     QQuickKeyNavigationAttached(QObject * = 0);
479
480     QQuickItem *left() const;
481     void setLeft(QQuickItem *);
482     QQuickItem *right() const;
483     void setRight(QQuickItem *);
484     QQuickItem *up() const;
485     void setUp(QQuickItem *);
486     QQuickItem *down() const;
487     void setDown(QQuickItem *);
488     QQuickItem *tab() const;
489     void setTab(QQuickItem *);
490     QQuickItem *backtab() const;
491     void setBacktab(QQuickItem *);
492
493     enum Priority { BeforeItem, AfterItem };
494     Priority priority() const;
495     void setPriority(Priority);
496
497     static QQuickKeyNavigationAttached *qmlAttachedProperties(QObject *);
498
499 Q_SIGNALS:
500     void leftChanged();
501     void rightChanged();
502     void upChanged();
503     void downChanged();
504     void tabChanged();
505     void backtabChanged();
506     void priorityChanged();
507
508 private:
509     virtual void keyPressed(QKeyEvent *event, bool post);
510     virtual void keyReleased(QKeyEvent *event, bool post);
511     void setFocusNavigation(QQuickItem *currentItem, const char *dir);
512 };
513
514 class QQuickLayoutMirroringAttached : public QObject
515 {
516     Q_OBJECT
517     Q_PROPERTY(bool enabled READ enabled WRITE setEnabled RESET resetEnabled NOTIFY enabledChanged)
518     Q_PROPERTY(bool childrenInherit READ childrenInherit WRITE setChildrenInherit NOTIFY childrenInheritChanged)
519
520 public:
521     explicit QQuickLayoutMirroringAttached(QObject *parent = 0);
522
523     bool enabled() const;
524     void setEnabled(bool);
525     void resetEnabled();
526
527     bool childrenInherit() const;
528     void setChildrenInherit(bool);
529
530     static QQuickLayoutMirroringAttached *qmlAttachedProperties(QObject *);
531 Q_SIGNALS:
532     void enabledChanged();
533     void childrenInheritChanged();
534 private:
535     friend class QQuickItemPrivate;
536     QQuickItemPrivate *itemPrivate;
537 };
538
539 class QQuickKeysAttachedPrivate : public QObjectPrivate
540 {
541 public:
542     QQuickKeysAttachedPrivate()
543         : QObjectPrivate(), inPress(false), inRelease(false)
544         , inIM(false), enabled(true), imeItem(0), item(0)
545     {}
546
547     bool isConnected(const char *signalName);
548
549     //loop detection
550     bool inPress:1;
551     bool inRelease:1;
552     bool inIM:1;
553
554     bool enabled : 1;
555
556     QQuickItem *imeItem;
557     QList<QQuickItem *> targets;
558     QQuickItem *item;
559 };
560
561 class QQuickKeysAttached : public QObject, public QQuickItemKeyFilter
562 {
563     Q_OBJECT
564     Q_DECLARE_PRIVATE(QQuickKeysAttached)
565
566     Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
567     Q_PROPERTY(QDeclarativeListProperty<QQuickItem> forwardTo READ forwardTo)
568     Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY priorityChanged)
569
570     Q_ENUMS(Priority)
571
572 public:
573     QQuickKeysAttached(QObject *parent=0);
574     ~QQuickKeysAttached();
575
576     bool enabled() const { Q_D(const QQuickKeysAttached); return d->enabled; }
577     void setEnabled(bool enabled) {
578         Q_D(QQuickKeysAttached);
579         if (enabled != d->enabled) {
580             d->enabled = enabled;
581             emit enabledChanged();
582         }
583     }
584
585     enum Priority { BeforeItem, AfterItem};
586     Priority priority() const;
587     void setPriority(Priority);
588
589     QDeclarativeListProperty<QQuickItem> forwardTo() {
590         Q_D(QQuickKeysAttached);
591         return QDeclarativeListProperty<QQuickItem>(this, d->targets);
592     }
593
594     virtual void componentComplete();
595
596     static QQuickKeysAttached *qmlAttachedProperties(QObject *);
597
598 Q_SIGNALS:
599     void enabledChanged();
600     void priorityChanged();
601     void pressed(QQuickKeyEvent *event);
602     void released(QQuickKeyEvent *event);
603     void digit0Pressed(QQuickKeyEvent *event);
604     void digit1Pressed(QQuickKeyEvent *event);
605     void digit2Pressed(QQuickKeyEvent *event);
606     void digit3Pressed(QQuickKeyEvent *event);
607     void digit4Pressed(QQuickKeyEvent *event);
608     void digit5Pressed(QQuickKeyEvent *event);
609     void digit6Pressed(QQuickKeyEvent *event);
610     void digit7Pressed(QQuickKeyEvent *event);
611     void digit8Pressed(QQuickKeyEvent *event);
612     void digit9Pressed(QQuickKeyEvent *event);
613
614     void leftPressed(QQuickKeyEvent *event);
615     void rightPressed(QQuickKeyEvent *event);
616     void upPressed(QQuickKeyEvent *event);
617     void downPressed(QQuickKeyEvent *event);
618     void tabPressed(QQuickKeyEvent *event);
619     void backtabPressed(QQuickKeyEvent *event);
620
621     void asteriskPressed(QQuickKeyEvent *event);
622     void numberSignPressed(QQuickKeyEvent *event);
623     void escapePressed(QQuickKeyEvent *event);
624     void returnPressed(QQuickKeyEvent *event);
625     void enterPressed(QQuickKeyEvent *event);
626     void deletePressed(QQuickKeyEvent *event);
627     void spacePressed(QQuickKeyEvent *event);
628     void backPressed(QQuickKeyEvent *event);
629     void cancelPressed(QQuickKeyEvent *event);
630     void selectPressed(QQuickKeyEvent *event);
631     void yesPressed(QQuickKeyEvent *event);
632     void noPressed(QQuickKeyEvent *event);
633     void context1Pressed(QQuickKeyEvent *event);
634     void context2Pressed(QQuickKeyEvent *event);
635     void context3Pressed(QQuickKeyEvent *event);
636     void context4Pressed(QQuickKeyEvent *event);
637     void callPressed(QQuickKeyEvent *event);
638     void hangupPressed(QQuickKeyEvent *event);
639     void flipPressed(QQuickKeyEvent *event);
640     void menuPressed(QQuickKeyEvent *event);
641     void volumeUpPressed(QQuickKeyEvent *event);
642     void volumeDownPressed(QQuickKeyEvent *event);
643
644 private:
645     virtual void keyPressed(QKeyEvent *event, bool post);
646     virtual void keyReleased(QKeyEvent *event, bool post);
647     virtual void inputMethodEvent(QInputMethodEvent *, bool post);
648     virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
649
650     const QByteArray keyToSignal(int key) {
651         QByteArray keySignal;
652         if (key >= Qt::Key_0 && key <= Qt::Key_9) {
653             keySignal = "digit0Pressed";
654             keySignal[5] = '0' + (key - Qt::Key_0);
655         } else {
656             int i = 0;
657             while (sigMap[i].key && sigMap[i].key != key)
658                 ++i;
659             keySignal = sigMap[i].sig;
660         }
661         return keySignal;
662     }
663
664     struct SigMap {
665         int key;
666         const char *sig;
667     };
668
669     static const SigMap sigMap[];
670 };
671
672 QSGTransformNode *QQuickItemPrivate::itemNode()
673 {
674     if (!itemNodeInstance) {
675         itemNodeInstance = createTransformNode();
676         itemNodeInstance->setFlag(QSGNode::OwnedByParent, false);
677 #ifdef QML_RUNTIME_TESTING
678         Q_Q(QQuickItem);
679         itemNodeInstance->description = QString::fromLatin1("QQuickItem(%1)").arg(QString::fromLatin1(q->metaObject()->className()));
680 #endif
681     }
682     return itemNodeInstance;
683 }
684
685 QSGNode *QQuickItemPrivate::childContainerNode()
686 {
687     if (!groupNode) {
688         groupNode = new QSGNode();
689         if (rootNode)
690             rootNode->appendChildNode(groupNode);
691         else if (clipNode)
692             clipNode->appendChildNode(groupNode);
693         else if (opacityNode)
694             opacityNode->appendChildNode(groupNode);
695         else
696             itemNode()->appendChildNode(groupNode);
697         groupNode->setFlag(QSGNode::ChildrenDoNotOverlap, childrenDoNotOverlap);
698 #ifdef QML_RUNTIME_TESTING
699         groupNode->description = QLatin1String("group");
700 #endif
701     }
702     return groupNode;
703 }
704
705 Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickItemPrivate::ChangeTypes);
706
707 QT_END_NAMESPACE
708
709 QML_DECLARE_TYPE(QQuickKeysAttached)
710 QML_DECLARE_TYPEINFO(QQuickKeysAttached, QML_HAS_ATTACHED_PROPERTIES)
711 QML_DECLARE_TYPE(QQuickKeyNavigationAttached)
712 QML_DECLARE_TYPEINFO(QQuickKeyNavigationAttached, QML_HAS_ATTACHED_PROPERTIES)
713 QML_DECLARE_TYPE(QQuickLayoutMirroringAttached)
714 QML_DECLARE_TYPEINFO(QQuickLayoutMirroringAttached, QML_HAS_ATTACHED_PROPERTIES)
715
716 #endif // QQUICKITEM_P_H