1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtQml module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #ifndef QQUICKITEM_P_H
43 #define QQUICKITEM_P_H
49 // This file is not part of the Qt API. It exists purely as an
50 // implementation detail. This header file may change from version to
51 // version without notice, or even be removed.
56 #include "qquickitem.h"
58 #include "qquickanchors_p.h"
59 #include "qquickanchors_p_p.h"
60 #include "qquickitemchangelistener_p.h"
62 #include "qquickcanvas_p.h"
64 #include <QtQuick/qsgnode.h>
65 #include "qquickclipnode_p.h"
67 #include <private/qpodvector_p.h>
68 #include <QtQuick/private/qquickstate_p.h>
69 #include <private/qqmlnullablevalue_p_p.h>
70 #include <private/qqmlnotifier_p.h>
71 #include <private/qqmlglobal_p.h>
72 #include <private/qlazilyallocated_p.h>
75 #include <qqmlcontext.h>
77 #include <QtCore/qlist.h>
78 #include <QtCore/qdebug.h>
79 #include <QtCore/qelapsedtimer.h>
81 #include <QtQuick/private/qquickshadereffectsource_p.h>
82 #include <QtQuick/private/qquickshadereffect_p.h>
87 class QQuickItemKeyFilter;
88 class QQuickLayoutMirroringAttached;
89 class QQuickScreenAttached;
91 class QQuickContents : public QQuickItemChangeListener
94 QQuickContents(QQuickItem *item);
97 QRectF rectF() const { return QRectF(m_x, m_y, m_width, m_height); }
99 inline void calcGeometry(QQuickItem *changed = 0);
103 void itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry);
104 void itemDestroyed(QQuickItem *item);
105 void itemChildAdded(QQuickItem *, QQuickItem *);
106 void itemChildRemoved(QQuickItem *, QQuickItem *);
107 //void itemVisibilityChanged(QQuickItem *item)
110 bool calcHeight(QQuickItem *changed = 0);
111 bool calcWidth(QQuickItem *changed = 0);
121 void QQuickContents::calcGeometry(QQuickItem *changed)
123 bool wChanged = calcWidth(changed);
124 bool hChanged = calcHeight(changed);
125 if (wChanged || hChanged)
129 class QQuickTransformPrivate : public QObjectPrivate
131 Q_DECLARE_PUBLIC(QQuickTransform);
133 static QQuickTransformPrivate* get(QQuickTransform *transform) { return transform->d_func(); }
135 QQuickTransformPrivate();
137 QList<QQuickItem *> items;
141 class QQuickItemLayer : public QObject, public QQuickItemChangeListener
144 Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
145 Q_PROPERTY(QSize textureSize READ size WRITE setSize NOTIFY sizeChanged)
146 Q_PROPERTY(QRectF sourceRect READ sourceRect WRITE setSourceRect NOTIFY sourceRectChanged)
147 Q_PROPERTY(bool mipmap READ mipmap WRITE setMipmap NOTIFY mipmapChanged)
148 Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged)
149 Q_PROPERTY(QQuickShaderEffectSource::WrapMode wrapMode READ wrapMode WRITE setWrapMode NOTIFY wrapModeChanged)
150 Q_PROPERTY(QQuickShaderEffectSource::Format format READ format WRITE setFormat NOTIFY formatChanged)
151 Q_PROPERTY(QByteArray samplerName READ name WRITE setName NOTIFY nameChanged)
152 Q_PROPERTY(QQmlComponent *effect READ effect WRITE setEffect NOTIFY effectChanged)
154 QQuickItemLayer(QQuickItem *item);
158 void componentComplete();
160 bool enabled() const { return m_enabled; }
161 void setEnabled(bool enabled);
163 bool mipmap() const { return m_mipmap; }
164 void setMipmap(bool mipmap);
166 bool smooth() const { return m_smooth; }
167 void setSmooth(bool s);
169 QSize size() const { return m_size; }
170 void setSize(const QSize &size);
172 QQuickShaderEffectSource::Format format() const { return m_format; }
173 void setFormat(QQuickShaderEffectSource::Format f);
175 QRectF sourceRect() const { return m_sourceRect; }
176 void setSourceRect(const QRectF &sourceRect);
178 QQuickShaderEffectSource::WrapMode wrapMode() const { return m_wrapMode; }
179 void setWrapMode(QQuickShaderEffectSource::WrapMode mode);
181 QByteArray name() const { return m_name; }
182 void setName(const QByteArray &name);
184 QQmlComponent *effect() const { return m_effectComponent; }
185 void setEffect(QQmlComponent *effect);
187 QQuickShaderEffectSource *effectSource() const { return m_effectSource; }
189 void itemGeometryChanged(QQuickItem *, const QRectF &, const QRectF &);
190 void itemOpacityChanged(QQuickItem *);
191 void itemParentChanged(QQuickItem *, QQuickItem *);
192 void itemSiblingOrderChanged(QQuickItem *);
193 void itemVisibilityChanged(QQuickItem *);
196 void updateGeometry();
197 void updateOpacity();
201 void enabledChanged(bool enabled);
202 void sizeChanged(const QSize &size);
203 void mipmapChanged(bool mipmap);
204 void wrapModeChanged(QQuickShaderEffectSource::WrapMode mode);
205 void nameChanged(const QByteArray &name);
206 void effectChanged(QQmlComponent *component);
207 void smoothChanged(bool smooth);
208 void formatChanged(QQuickShaderEffectSource::Format format);
209 void sourceRectChanged(const QRectF &sourceRect);
214 void activateEffect();
215 void deactivateEffect();
221 bool m_componentComplete;
222 QQuickShaderEffectSource::WrapMode m_wrapMode;
223 QQuickShaderEffectSource::Format m_format;
227 QQmlComponent *m_effectComponent;
228 QQuickItem *m_effect;
229 QQuickShaderEffectSource *m_effectSource;
232 class Q_QUICK_EXPORT QQuickItemPrivate : public QObjectPrivate
234 Q_DECLARE_PUBLIC(QQuickItem)
237 static QQuickItemPrivate* get(QQuickItem *item) { return item->d_func(); }
238 static const QQuickItemPrivate* get(const QQuickItem *item) { return item->d_func(); }
240 static void registerAccessorProperties();
243 ~QQuickItemPrivate();
244 void init(QQuickItem *parent);
246 QQmlListProperty<QObject> data();
247 QQmlListProperty<QObject> resources();
248 QQmlListProperty<QQuickItem> children();
249 QQmlListProperty<QQuickItem> visibleChildren();
251 QQmlListProperty<QQuickState> states();
252 QQmlListProperty<QQuickTransition> transitions();
254 QString state() const;
255 void setState(const QString &);
257 QQuickAnchorLine left() const;
258 QQuickAnchorLine right() const;
259 QQuickAnchorLine horizontalCenter() const;
260 QQuickAnchorLine top() const;
261 QQuickAnchorLine bottom() const;
262 QQuickAnchorLine verticalCenter() const;
263 QQuickAnchorLine baseline() const;
265 QQuickItemLayer *layer() const;
268 static void data_append(QQmlListProperty<QObject> *, QObject *);
269 static int data_count(QQmlListProperty<QObject> *);
270 static QObject *data_at(QQmlListProperty<QObject> *, int);
271 static void data_clear(QQmlListProperty<QObject> *);
273 // resources property
274 static QObject *resources_at(QQmlListProperty<QObject> *, int);
275 static void resources_append(QQmlListProperty<QObject> *, QObject *);
276 static int resources_count(QQmlListProperty<QObject> *);
277 static void resources_clear(QQmlListProperty<QObject> *);
280 static void children_append(QQmlListProperty<QQuickItem> *, QQuickItem *);
281 static int children_count(QQmlListProperty<QQuickItem> *);
282 static QQuickItem *children_at(QQmlListProperty<QQuickItem> *, int);
283 static void children_clear(QQmlListProperty<QQuickItem> *);
285 // visibleChildren property
286 static void visibleChildren_append(QQmlListProperty<QQuickItem> *prop, QQuickItem *o);
287 static int visibleChildren_count(QQmlListProperty<QQuickItem> *prop);
288 static QQuickItem *visibleChildren_at(QQmlListProperty<QQuickItem> *prop, int index);
290 // transform property
291 static int transform_count(QQmlListProperty<QQuickTransform> *list);
292 static void transform_append(QQmlListProperty<QQuickTransform> *list, QQuickTransform *);
293 static QQuickTransform *transform_at(QQmlListProperty<QQuickTransform> *list, int);
294 static void transform_clear(QQmlListProperty<QQuickTransform> *list);
307 Q_DECLARE_FLAGS(ChangeTypes, ChangeType)
309 enum GeometryChangeType {
315 SizeChange = WidthChange | HeightChange,
316 GeometryChange = XChange | YChange | SizeChange
319 Q_DECLARE_FLAGS(GeometryChangeTypes, GeometryChangeType)
321 struct ChangeListener {
322 ChangeListener(QQuickItemChangeListener *l, QQuickItemPrivate::ChangeTypes t) : listener(l), types(t), gTypes(GeometryChange) {}
323 ChangeListener(QQuickItemChangeListener *l, QQuickItemPrivate::GeometryChangeTypes gt) : listener(l), types(Geometry), gTypes(gt) {}
324 QQuickItemChangeListener *listener;
325 QQuickItemPrivate::ChangeTypes types;
326 QQuickItemPrivate::GeometryChangeTypes gTypes; //NOTE: not used for ==
327 bool operator==(const ChangeListener &other) const { return listener == other.listener && types == other.types; }
338 QQuickContents *contents;
339 QQuickScreenAttached *screenAttached;
340 QQuickLayoutMirroringAttached* layoutDirectionAttached;
341 QQuickItemKeyFilter *keyHandler;
342 mutable QQuickItemLayer *layer;
343 QPointF userTransformOriginPoint;
348 QSGOpacityNode *opacityNode;
349 QQuickDefaultClipNode *clipNode;
350 QSGRootNode *rootNode;
351 QSGNode *beforePaintNode;
353 // Although acceptedMouseButtons is inside ExtraData, we actually store
354 // the LeftButton flag in the extra.flag() bit. This is because it is
355 // extremely common to set acceptedMouseButtons to LeftButton, but very
356 // rare to use any of the other buttons.
357 Qt::MouseButtons acceptedMouseButtons;
359 QQuickItem::TransformOrigin origin:5;
361 QLazilyAllocated<ExtraData> extra;
363 QQuickAnchors *anchors() const;
364 mutable QQuickAnchors *_anchors;
366 inline Qt::MouseButtons acceptedMouseButtons() const;
368 QPODVector<QQuickItemPrivate::ChangeListener,4> changeListeners;
370 void addItemChangeListener(QQuickItemChangeListener *listener, ChangeTypes types);
371 void removeItemChangeListener(QQuickItemChangeListener *, ChangeTypes types);
372 void updateOrAddGeometryChangeListener(QQuickItemChangeListener *listener, GeometryChangeTypes types);
373 void updateOrRemoveGeometryChangeListener(QQuickItemChangeListener *listener, GeometryChangeTypes types);
375 QQuickStateGroup *_states();
376 QQuickStateGroup *_stateGroup;
378 inline QQuickItem::TransformOrigin origin() const;
384 bool baselineOffsetValid:1;
385 bool componentComplete:1;
392 bool notifiedFocus:1;
394 bool notifiedActiveFocus:1;
395 bool filtersChildMouseEvents:1;
396 bool explicitVisible:1;
397 bool effectiveVisible:1;
398 bool explicitEnable:1;
399 bool effectiveEnable:1;
400 bool polishScheduled:1;
401 bool inheritedLayoutMirror:1;
402 bool effectiveLayoutMirror:1;
403 bool isMirrorImplicit:1;
404 bool inheritMirrorFromParent:1;
405 bool inheritMirrorFromItem:1;
406 bool childrenDoNotOverlap:1;
407 bool staticSubtreeGeometry:1;
413 TransformOrigin = 0x00000001,
414 Transform = 0x00000002,
415 BasicTransform = 0x00000004,
416 Position = 0x00000008,
420 Content = 0x00000040,
422 OpacityValue = 0x00000100,
423 ChildrenChanged = 0x00000200,
424 ChildrenStackingChanged = 0x00000400,
425 ParentChanged = 0x00000800,
430 EffectReference = 0x00008000,
431 Visible = 0x00010000,
432 HideReference = 0x00020000,
433 PerformanceHints = 0x00040000,
434 // When you add an attribute here, don't forget to update
437 TransformUpdateMask = TransformOrigin | Transform | BasicTransform | Position |
439 ComplexTransformUpdateMask = Transform | Canvas,
440 ContentUpdateMask = Size | Content | Smooth | Canvas,
441 ChildrenUpdateMask = ChildrenChanged | ChildrenStackingChanged | EffectReference | Canvas
444 quint32 dirtyAttributes;
445 QString dirtyToString() const;
446 void dirty(DirtyType);
447 void addToDirtyList();
448 void removeFromDirtyList();
449 QQuickItem *nextDirtyItem;
450 QQuickItem**prevDirtyItem;
452 QQuickCanvas *canvas;
454 inline QSGContext *sceneGraphContext() const;
456 QQuickItem *parentItem;
457 QQmlNotifier parentNotifier;
459 QList<QQuickItem *> childItems;
460 mutable QList<QQuickItem *> *sortedChildItems;
461 QList<QQuickItem *> paintOrderChildItems() const;
462 void addChild(QQuickItem *);
463 void removeChild(QQuickItem *);
464 void siblingOrderChanged();
466 inline void markSortedChildrenDirty(QQuickItem *child);
468 class InitializationState {
470 QQuickItem *getFocusScope(QQuickItem *item);
472 void clear(QQuickItem *focusScope);
474 QQuickItem *focusScope;
477 void refCanvas(QQuickCanvas *);
478 void refCanvas(InitializationState *, QQuickCanvas *);
481 QQuickItem *subFocusItem;
482 void updateSubFocusItem(QQuickItem *scope, bool focus);
484 QTransform canvasToItemTransform() const;
485 QTransform itemToCanvasTransform() const;
486 void itemToParentTransform(QTransform &) const;
493 qreal implicitHeight;
495 qreal baselineOffset;
497 QList<QQuickTransform *> transforms;
499 inline qreal z() const { return extra.isAllocated()?extra->z:0; }
500 inline qreal scale() const { return extra.isAllocated()?extra->scale:1; }
501 inline qreal rotation() const { return extra.isAllocated()?extra->rotation:0; }
502 inline qreal opacity() const { return extra.isAllocated()?extra->opacity:1; }
504 void setAccessibleFlagAndListener();
506 virtual qreal getImplicitWidth() const;
507 virtual qreal getImplicitHeight() const;
508 virtual void implicitWidthChanged();
509 virtual void implicitHeightChanged();
511 void resolveLayoutMirror();
512 void setImplicitLayoutMirror(bool mirror, bool inherit);
513 void setLayoutMirror(bool mirror);
514 bool isMirrored() const {
515 return effectiveLayoutMirror;
518 void emitChildrenRectChanged(const QRectF &rect) {
520 emit q->childrenRectChanged(rect);
523 QPointF computeTransformOrigin() const;
524 virtual void transformChanged();
526 void deliverKeyEvent(QKeyEvent *);
527 void deliverInputMethodEvent(QInputMethodEvent *);
528 void deliverFocusEvent(QFocusEvent *);
529 void deliverMouseEvent(QMouseEvent *);
530 void deliverWheelEvent(QWheelEvent *);
531 void deliverTouchEvent(QTouchEvent *);
532 void deliverHoverEvent(QHoverEvent *);
533 void deliverDragEvent(QEvent *);
535 bool calcEffectiveVisible() const;
536 bool setEffectiveVisibleRecur(bool);
537 bool calcEffectiveEnable() const;
538 void setEffectiveEnableRecur(QQuickItem *scope, bool);
541 inline QSGTransformNode *itemNode();
542 inline QSGNode *childContainerNode();
553 QSGOpacityNode *opacityNode() const { return extra.isAllocated()?extra->opacityNode:0; }
554 QQuickDefaultClipNode *clipNode() const { return extra.isAllocated()?extra->clipNode:0; }
555 QSGRootNode *rootNode() const { return extra.isAllocated()?extra->rootNode:0; }
557 QSGTransformNode *itemNodeInstance;
561 virtual QSGTransformNode *createTransformNode();
563 // A reference from an effect item means that this item is used by the effect, so
564 // it should insert a root node.
565 void refFromEffectItem(bool hide);
566 void derefFromEffectItem(bool unhide);
568 void itemChange(QQuickItem::ItemChange, const QQuickItem::ItemChangeData &);
570 virtual void mirrorChange() {}
572 static qint64 consistentTime;
573 static void setConsistentTime(qint64 t);
574 static void start(QElapsedTimer &);
575 static qint64 elapsed(QElapsedTimer &);
576 static qint64 restart(QElapsedTimer &);
580 Key filters can be installed on a QQuickItem, but not removed. Currently they
581 are only used by attached objects (which are only destroyed on Item
582 destruction), so this isn't a problem. If in future this becomes any form
583 of public API, they will have to support removal too.
585 class QQuickItemKeyFilter
588 QQuickItemKeyFilter(QQuickItem * = 0);
589 virtual ~QQuickItemKeyFilter();
591 virtual void keyPressed(QKeyEvent *event, bool post);
592 virtual void keyReleased(QKeyEvent *event, bool post);
593 virtual void inputMethodEvent(QInputMethodEvent *event, bool post);
594 virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
595 virtual void componentComplete();
600 QQuickItemKeyFilter *m_next;
603 class QQuickKeyNavigationAttachedPrivate : public QObjectPrivate
606 QQuickKeyNavigationAttachedPrivate()
608 left(0), right(0), up(0), down(0), tab(0), backtab(0),
609 leftSet(false), rightSet(false), upSet(false), downSet(false),
610 tabSet(false), backtabSet(false) {}
626 class QQuickKeyNavigationAttached : public QObject, public QQuickItemKeyFilter
629 Q_DECLARE_PRIVATE(QQuickKeyNavigationAttached)
631 Q_PROPERTY(QQuickItem *left READ left WRITE setLeft NOTIFY leftChanged)
632 Q_PROPERTY(QQuickItem *right READ right WRITE setRight NOTIFY rightChanged)
633 Q_PROPERTY(QQuickItem *up READ up WRITE setUp NOTIFY upChanged)
634 Q_PROPERTY(QQuickItem *down READ down WRITE setDown NOTIFY downChanged)
635 Q_PROPERTY(QQuickItem *tab READ tab WRITE setTab NOTIFY tabChanged)
636 Q_PROPERTY(QQuickItem *backtab READ backtab WRITE setBacktab NOTIFY backtabChanged)
637 Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY priorityChanged)
642 QQuickKeyNavigationAttached(QObject * = 0);
644 QQuickItem *left() const;
645 void setLeft(QQuickItem *);
646 QQuickItem *right() const;
647 void setRight(QQuickItem *);
648 QQuickItem *up() const;
649 void setUp(QQuickItem *);
650 QQuickItem *down() const;
651 void setDown(QQuickItem *);
652 QQuickItem *tab() const;
653 void setTab(QQuickItem *);
654 QQuickItem *backtab() const;
655 void setBacktab(QQuickItem *);
657 enum Priority { BeforeItem, AfterItem };
658 Priority priority() const;
659 void setPriority(Priority);
661 static QQuickKeyNavigationAttached *qmlAttachedProperties(QObject *);
669 void backtabChanged();
670 void priorityChanged();
673 virtual void keyPressed(QKeyEvent *event, bool post);
674 virtual void keyReleased(QKeyEvent *event, bool post);
675 void setFocusNavigation(QQuickItem *currentItem, const char *dir);
678 class QQuickLayoutMirroringAttached : public QObject
681 Q_PROPERTY(bool enabled READ enabled WRITE setEnabled RESET resetEnabled NOTIFY enabledChanged)
682 Q_PROPERTY(bool childrenInherit READ childrenInherit WRITE setChildrenInherit NOTIFY childrenInheritChanged)
685 explicit QQuickLayoutMirroringAttached(QObject *parent = 0);
687 bool enabled() const;
688 void setEnabled(bool);
691 bool childrenInherit() const;
692 void setChildrenInherit(bool);
694 static QQuickLayoutMirroringAttached *qmlAttachedProperties(QObject *);
696 void enabledChanged();
697 void childrenInheritChanged();
699 friend class QQuickItemPrivate;
700 QQuickItemPrivate *itemPrivate;
703 class QQuickKeysAttachedPrivate : public QObjectPrivate
706 QQuickKeysAttachedPrivate()
707 : QObjectPrivate(), inPress(false), inRelease(false)
708 , inIM(false), enabled(true), imeItem(0), item(0)
711 bool isConnected(const char *signalName);
721 QList<QQuickItem *> targets;
725 class QQuickKeysAttached : public QObject, public QQuickItemKeyFilter
728 Q_DECLARE_PRIVATE(QQuickKeysAttached)
730 Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
731 Q_PROPERTY(QQmlListProperty<QQuickItem> forwardTo READ forwardTo)
732 Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY priorityChanged)
737 QQuickKeysAttached(QObject *parent=0);
738 ~QQuickKeysAttached();
740 bool enabled() const { Q_D(const QQuickKeysAttached); return d->enabled; }
741 void setEnabled(bool enabled) {
742 Q_D(QQuickKeysAttached);
743 if (enabled != d->enabled) {
744 d->enabled = enabled;
745 emit enabledChanged();
749 enum Priority { BeforeItem, AfterItem};
750 Priority priority() const;
751 void setPriority(Priority);
753 QQmlListProperty<QQuickItem> forwardTo() {
754 Q_D(QQuickKeysAttached);
755 return QQmlListProperty<QQuickItem>(this, d->targets);
758 virtual void componentComplete();
760 static QQuickKeysAttached *qmlAttachedProperties(QObject *);
763 void enabledChanged();
764 void priorityChanged();
765 void pressed(QQuickKeyEvent *event);
766 void released(QQuickKeyEvent *event);
767 void digit0Pressed(QQuickKeyEvent *event);
768 void digit1Pressed(QQuickKeyEvent *event);
769 void digit2Pressed(QQuickKeyEvent *event);
770 void digit3Pressed(QQuickKeyEvent *event);
771 void digit4Pressed(QQuickKeyEvent *event);
772 void digit5Pressed(QQuickKeyEvent *event);
773 void digit6Pressed(QQuickKeyEvent *event);
774 void digit7Pressed(QQuickKeyEvent *event);
775 void digit8Pressed(QQuickKeyEvent *event);
776 void digit9Pressed(QQuickKeyEvent *event);
778 void leftPressed(QQuickKeyEvent *event);
779 void rightPressed(QQuickKeyEvent *event);
780 void upPressed(QQuickKeyEvent *event);
781 void downPressed(QQuickKeyEvent *event);
782 void tabPressed(QQuickKeyEvent *event);
783 void backtabPressed(QQuickKeyEvent *event);
785 void asteriskPressed(QQuickKeyEvent *event);
786 void numberSignPressed(QQuickKeyEvent *event);
787 void escapePressed(QQuickKeyEvent *event);
788 void returnPressed(QQuickKeyEvent *event);
789 void enterPressed(QQuickKeyEvent *event);
790 void deletePressed(QQuickKeyEvent *event);
791 void spacePressed(QQuickKeyEvent *event);
792 void backPressed(QQuickKeyEvent *event);
793 void cancelPressed(QQuickKeyEvent *event);
794 void selectPressed(QQuickKeyEvent *event);
795 void yesPressed(QQuickKeyEvent *event);
796 void noPressed(QQuickKeyEvent *event);
797 void context1Pressed(QQuickKeyEvent *event);
798 void context2Pressed(QQuickKeyEvent *event);
799 void context3Pressed(QQuickKeyEvent *event);
800 void context4Pressed(QQuickKeyEvent *event);
801 void callPressed(QQuickKeyEvent *event);
802 void hangupPressed(QQuickKeyEvent *event);
803 void flipPressed(QQuickKeyEvent *event);
804 void menuPressed(QQuickKeyEvent *event);
805 void volumeUpPressed(QQuickKeyEvent *event);
806 void volumeDownPressed(QQuickKeyEvent *event);
809 virtual void keyPressed(QKeyEvent *event, bool post);
810 virtual void keyReleased(QKeyEvent *event, bool post);
811 virtual void inputMethodEvent(QInputMethodEvent *, bool post);
812 virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
814 const QByteArray keyToSignal(int key) {
815 QByteArray keySignal;
816 if (key >= Qt::Key_0 && key <= Qt::Key_9) {
817 keySignal = "digit0Pressed";
818 keySignal[5] = '0' + (key - Qt::Key_0);
821 while (sigMap[i].key && sigMap[i].key != key)
823 keySignal = sigMap[i].sig;
833 static const SigMap sigMap[];
836 Qt::MouseButtons QQuickItemPrivate::acceptedMouseButtons() const
838 return ((extra.flag() ? Qt::LeftButton : Qt::MouseButton(0)) |
839 (extra.isAllocated() ? extra->acceptedMouseButtons : Qt::MouseButtons(0)));
842 QSGContext *QQuickItemPrivate::sceneGraphContext() const
845 return static_cast<QQuickCanvasPrivate *>(QObjectPrivate::get(canvas))->context;
848 void QQuickItemPrivate::markSortedChildrenDirty(QQuickItem *child)
850 // If sortedChildItems == &childItems then all in childItems have z == 0
851 // and we don't need to invalidate if the changed item also has z == 0.
852 if (child->z() != 0. || sortedChildItems != &childItems) {
853 if (sortedChildItems != &childItems)
854 delete sortedChildItems;
855 sortedChildItems = 0;
859 QQuickItem::TransformOrigin QQuickItemPrivate::origin() const
861 return extra.isAllocated()?extra->origin:QQuickItem::Center;
864 inline void QQuickItemPrivate::refCanvas(QQuickCanvas *c)
866 QQuickItemPrivate::InitializationState initState;
868 refCanvas(&initState, c);
871 QSGTransformNode *QQuickItemPrivate::itemNode()
873 if (!itemNodeInstance) {
874 itemNodeInstance = createTransformNode();
875 itemNodeInstance->setFlag(QSGNode::OwnedByParent, false);
876 #ifdef QML_RUNTIME_TESTING
878 itemNodeInstance->description = QString::fromLatin1("QQuickItem(%1)").arg(QString::fromLatin1(q->metaObject()->className()));
881 return itemNodeInstance;
884 QSGNode *QQuickItemPrivate::childContainerNode()
887 groupNode = new QSGNode();
889 rootNode()->appendChildNode(groupNode);
891 clipNode()->appendChildNode(groupNode);
892 else if (opacityNode())
893 opacityNode()->appendChildNode(groupNode);
895 itemNode()->appendChildNode(groupNode);
896 groupNode->setFlag(QSGNode::ChildrenDoNotOverlap, childrenDoNotOverlap);
897 groupNode->setFlag(QSGNode::StaticSubtreeGeometry, staticSubtreeGeometry);
898 #ifdef QML_RUNTIME_TESTING
899 groupNode->description = QLatin1String("group");
905 Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickItemPrivate::ChangeTypes);
909 QML_DECLARE_TYPE(QQuickItemLayer)
910 QML_DECLARE_TYPE(QQuickKeysAttached)
911 QML_DECLARE_TYPEINFO(QQuickKeysAttached, QML_HAS_ATTACHED_PROPERTIES)
912 QML_DECLARE_TYPE(QQuickKeyNavigationAttached)
913 QML_DECLARE_TYPEINFO(QQuickKeyNavigationAttached, QML_HAS_ATTACHED_PROPERTIES)
914 QML_DECLARE_TYPE(QQuickLayoutMirroringAttached)
915 QML_DECLARE_TYPEINFO(QQuickLayoutMirroringAttached, QML_HAS_ATTACHED_PROPERTIES)
917 #endif // QQUICKITEM_P_H