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_PRIVATE_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);
305 ImplicitWidth = 0x100,
306 ImplicitHeight = 0x200
309 Q_DECLARE_FLAGS(ChangeTypes, ChangeType)
311 enum GeometryChangeType {
317 SizeChange = WidthChange | HeightChange,
318 GeometryChange = XChange | YChange | SizeChange
321 Q_DECLARE_FLAGS(GeometryChangeTypes, GeometryChangeType)
323 struct ChangeListener {
324 ChangeListener(QQuickItemChangeListener *l, QQuickItemPrivate::ChangeTypes t) : listener(l), types(t), gTypes(GeometryChange) {}
325 ChangeListener(QQuickItemChangeListener *l, QQuickItemPrivate::GeometryChangeTypes gt) : listener(l), types(Geometry), gTypes(gt) {}
326 QQuickItemChangeListener *listener;
327 QQuickItemPrivate::ChangeTypes types;
328 QQuickItemPrivate::GeometryChangeTypes gTypes; //NOTE: not used for ==
329 bool operator==(const ChangeListener &other) const { return listener == other.listener && types == other.types; }
340 QQuickContents *contents;
341 QQuickScreenAttached *screenAttached;
342 QQuickLayoutMirroringAttached* layoutDirectionAttached;
343 QQuickItemKeyFilter *keyHandler;
344 mutable QQuickItemLayer *layer;
345 QPointF userTransformOriginPoint;
350 QSGOpacityNode *opacityNode;
351 QQuickDefaultClipNode *clipNode;
352 QSGRootNode *rootNode;
353 QSGNode *beforePaintNode;
355 // Although acceptedMouseButtons is inside ExtraData, we actually store
356 // the LeftButton flag in the extra.flag() bit. This is because it is
357 // extremely common to set acceptedMouseButtons to LeftButton, but very
358 // rare to use any of the other buttons.
359 Qt::MouseButtons acceptedMouseButtons;
361 QQuickItem::TransformOrigin origin:5;
363 QLazilyAllocated<ExtraData> extra;
365 QQuickAnchors *anchors() const;
366 mutable QQuickAnchors *_anchors;
368 inline Qt::MouseButtons acceptedMouseButtons() const;
370 QPODVector<QQuickItemPrivate::ChangeListener,4> changeListeners;
372 void addItemChangeListener(QQuickItemChangeListener *listener, ChangeTypes types);
373 void removeItemChangeListener(QQuickItemChangeListener *, ChangeTypes types);
374 void updateOrAddGeometryChangeListener(QQuickItemChangeListener *listener, GeometryChangeTypes types);
375 void updateOrRemoveGeometryChangeListener(QQuickItemChangeListener *listener, GeometryChangeTypes types);
377 QQuickStateGroup *_states();
378 QQuickStateGroup *_stateGroup;
380 inline QQuickItem::TransformOrigin origin() const;
386 bool baselineOffsetValid:1;
387 bool componentComplete:1;
395 bool notifiedFocus:1;
397 bool notifiedActiveFocus:1;
398 bool filtersChildMouseEvents:1;
399 bool explicitVisible:1;
400 bool effectiveVisible:1;
401 bool explicitEnable:1;
402 bool effectiveEnable:1;
403 bool polishScheduled:1;
404 bool inheritedLayoutMirror:1;
405 bool effectiveLayoutMirror:1;
406 bool isMirrorImplicit:1;
407 bool inheritMirrorFromParent:1;
408 bool inheritMirrorFromItem:1;
415 TransformOrigin = 0x00000001,
416 Transform = 0x00000002,
417 BasicTransform = 0x00000004,
418 Position = 0x00000008,
422 Content = 0x00000040,
424 OpacityValue = 0x00000100,
425 ChildrenChanged = 0x00000200,
426 ChildrenStackingChanged = 0x00000400,
427 ParentChanged = 0x00000800,
432 EffectReference = 0x00008000,
433 Visible = 0x00010000,
434 HideReference = 0x00020000,
435 Antialiasing = 0x00040000,
436 // When you add an attribute here, don't forget to update
439 TransformUpdateMask = TransformOrigin | Transform | BasicTransform | Position |
441 ComplexTransformUpdateMask = Transform | Canvas,
442 ContentUpdateMask = Size | Content | Smooth | Canvas | Antialiasing,
443 ChildrenUpdateMask = ChildrenChanged | ChildrenStackingChanged | EffectReference | Canvas
446 quint32 dirtyAttributes;
447 QString dirtyToString() const;
448 void dirty(DirtyType);
449 void addToDirtyList();
450 void removeFromDirtyList();
451 QQuickItem *nextDirtyItem;
452 QQuickItem**prevDirtyItem;
454 void setCulled(bool);
456 QQuickCanvas *canvas;
458 inline QSGContext *sceneGraphContext() const;
460 QQuickItem *parentItem;
461 QQmlNotifier parentNotifier;
463 QList<QQuickItem *> childItems;
464 mutable QList<QQuickItem *> *sortedChildItems;
465 QList<QQuickItem *> paintOrderChildItems() const;
466 void addChild(QQuickItem *);
467 void removeChild(QQuickItem *);
468 void siblingOrderChanged();
470 inline void markSortedChildrenDirty(QQuickItem *child);
472 void refCanvas(QQuickCanvas *);
475 QQuickItem *subFocusItem;
476 void updateSubFocusItem(QQuickItem *scope, bool focus);
478 QTransform canvasToItemTransform() const;
479 QTransform itemToCanvasTransform() const;
480 void itemToParentTransform(QTransform &) const;
487 qreal implicitHeight;
489 qreal baselineOffset;
491 QList<QQuickTransform *> transforms;
493 inline qreal z() const { return extra.isAllocated()?extra->z:0; }
494 inline qreal scale() const { return extra.isAllocated()?extra->scale:1; }
495 inline qreal rotation() const { return extra.isAllocated()?extra->rotation:0; }
496 inline qreal opacity() const { return extra.isAllocated()?extra->opacity:1; }
498 void setAccessibleFlagAndListener();
500 virtual qreal getImplicitWidth() const;
501 virtual qreal getImplicitHeight() const;
502 virtual void implicitWidthChanged();
503 virtual void implicitHeightChanged();
505 void resolveLayoutMirror();
506 void setImplicitLayoutMirror(bool mirror, bool inherit);
507 void setLayoutMirror(bool mirror);
508 bool isMirrored() const {
509 return effectiveLayoutMirror;
512 void emitChildrenRectChanged(const QRectF &rect) {
514 emit q->childrenRectChanged(rect);
517 QPointF computeTransformOrigin() const;
518 virtual void transformChanged();
520 void deliverKeyEvent(QKeyEvent *);
521 void deliverInputMethodEvent(QInputMethodEvent *);
522 void deliverFocusEvent(QFocusEvent *);
523 void deliverMouseEvent(QMouseEvent *);
524 void deliverWheelEvent(QWheelEvent *);
525 void deliverTouchEvent(QTouchEvent *);
526 void deliverHoverEvent(QHoverEvent *);
527 #ifndef QT_NO_DRAGANDDROP
528 void deliverDragEvent(QEvent *);
531 bool calcEffectiveVisible() const;
532 bool setEffectiveVisibleRecur(bool);
533 bool calcEffectiveEnable() const;
534 void setEffectiveEnableRecur(QQuickItem *scope, bool);
537 inline QSGTransformNode *itemNode();
538 inline QSGNode *childContainerNode();
549 QSGOpacityNode *opacityNode() const { return extra.isAllocated()?extra->opacityNode:0; }
550 QQuickDefaultClipNode *clipNode() const { return extra.isAllocated()?extra->clipNode:0; }
551 QSGRootNode *rootNode() const { return extra.isAllocated()?extra->rootNode:0; }
553 QSGTransformNode *itemNodeInstance;
557 virtual QSGTransformNode *createTransformNode();
559 // A reference from an effect item means that this item is used by the effect, so
560 // it should insert a root node.
561 void refFromEffectItem(bool hide);
562 void derefFromEffectItem(bool unhide);
564 void itemChange(QQuickItem::ItemChange, const QQuickItem::ItemChangeData &);
566 virtual void mirrorChange() {}
568 static qint64 consistentTime;
569 static void setConsistentTime(qint64 t);
570 static void start(QElapsedTimer &);
571 static qint64 elapsed(QElapsedTimer &);
572 static qint64 restart(QElapsedTimer &);
576 Key filters can be installed on a QQuickItem, but not removed. Currently they
577 are only used by attached objects (which are only destroyed on Item
578 destruction), so this isn't a problem. If in future this becomes any form
579 of public API, they will have to support removal too.
581 class QQuickItemKeyFilter
584 QQuickItemKeyFilter(QQuickItem * = 0);
585 virtual ~QQuickItemKeyFilter();
587 virtual void keyPressed(QKeyEvent *event, bool post);
588 virtual void keyReleased(QKeyEvent *event, bool post);
589 virtual void inputMethodEvent(QInputMethodEvent *event, bool post);
590 virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
591 virtual void componentComplete();
596 QQuickItemKeyFilter *m_next;
599 class QQuickKeyNavigationAttachedPrivate : public QObjectPrivate
602 QQuickKeyNavigationAttachedPrivate()
604 left(0), right(0), up(0), down(0), tab(0), backtab(0),
605 leftSet(false), rightSet(false), upSet(false), downSet(false),
606 tabSet(false), backtabSet(false) {}
622 class QQuickKeyNavigationAttached : public QObject, public QQuickItemKeyFilter
625 Q_DECLARE_PRIVATE(QQuickKeyNavigationAttached)
627 Q_PROPERTY(QQuickItem *left READ left WRITE setLeft NOTIFY leftChanged)
628 Q_PROPERTY(QQuickItem *right READ right WRITE setRight NOTIFY rightChanged)
629 Q_PROPERTY(QQuickItem *up READ up WRITE setUp NOTIFY upChanged)
630 Q_PROPERTY(QQuickItem *down READ down WRITE setDown NOTIFY downChanged)
631 Q_PROPERTY(QQuickItem *tab READ tab WRITE setTab NOTIFY tabChanged)
632 Q_PROPERTY(QQuickItem *backtab READ backtab WRITE setBacktab NOTIFY backtabChanged)
633 Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY priorityChanged)
638 QQuickKeyNavigationAttached(QObject * = 0);
640 QQuickItem *left() const;
641 void setLeft(QQuickItem *);
642 QQuickItem *right() const;
643 void setRight(QQuickItem *);
644 QQuickItem *up() const;
645 void setUp(QQuickItem *);
646 QQuickItem *down() const;
647 void setDown(QQuickItem *);
648 QQuickItem *tab() const;
649 void setTab(QQuickItem *);
650 QQuickItem *backtab() const;
651 void setBacktab(QQuickItem *);
653 enum Priority { BeforeItem, AfterItem };
654 Priority priority() const;
655 void setPriority(Priority);
657 static QQuickKeyNavigationAttached *qmlAttachedProperties(QObject *);
665 void backtabChanged();
666 void priorityChanged();
669 virtual void keyPressed(QKeyEvent *event, bool post);
670 virtual void keyReleased(QKeyEvent *event, bool post);
671 void setFocusNavigation(QQuickItem *currentItem, const char *dir);
674 class QQuickLayoutMirroringAttached : public QObject
677 Q_PROPERTY(bool enabled READ enabled WRITE setEnabled RESET resetEnabled NOTIFY enabledChanged)
678 Q_PROPERTY(bool childrenInherit READ childrenInherit WRITE setChildrenInherit NOTIFY childrenInheritChanged)
681 explicit QQuickLayoutMirroringAttached(QObject *parent = 0);
683 bool enabled() const;
684 void setEnabled(bool);
687 bool childrenInherit() const;
688 void setChildrenInherit(bool);
690 static QQuickLayoutMirroringAttached *qmlAttachedProperties(QObject *);
692 void enabledChanged();
693 void childrenInheritChanged();
695 friend class QQuickItemPrivate;
696 QQuickItemPrivate *itemPrivate;
699 class QQuickKeysAttachedPrivate : public QObjectPrivate
702 QQuickKeysAttachedPrivate()
703 : QObjectPrivate(), inPress(false), inRelease(false)
704 , inIM(false), enabled(true), imeItem(0), item(0)
715 QList<QQuickItem *> targets;
719 class QQuickKeysAttached : public QObject, public QQuickItemKeyFilter
722 Q_DECLARE_PRIVATE(QQuickKeysAttached)
724 Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
725 Q_PROPERTY(QQmlListProperty<QQuickItem> forwardTo READ forwardTo)
726 Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY priorityChanged)
731 QQuickKeysAttached(QObject *parent=0);
732 ~QQuickKeysAttached();
734 bool enabled() const { Q_D(const QQuickKeysAttached); return d->enabled; }
735 void setEnabled(bool enabled) {
736 Q_D(QQuickKeysAttached);
737 if (enabled != d->enabled) {
738 d->enabled = enabled;
739 emit enabledChanged();
743 enum Priority { BeforeItem, AfterItem};
744 Priority priority() const;
745 void setPriority(Priority);
747 QQmlListProperty<QQuickItem> forwardTo() {
748 Q_D(QQuickKeysAttached);
749 return QQmlListProperty<QQuickItem>(this, d->targets);
752 virtual void componentComplete();
754 static QQuickKeysAttached *qmlAttachedProperties(QObject *);
757 void enabledChanged();
758 void priorityChanged();
759 void pressed(QQuickKeyEvent *event);
760 void released(QQuickKeyEvent *event);
761 void digit0Pressed(QQuickKeyEvent *event);
762 void digit1Pressed(QQuickKeyEvent *event);
763 void digit2Pressed(QQuickKeyEvent *event);
764 void digit3Pressed(QQuickKeyEvent *event);
765 void digit4Pressed(QQuickKeyEvent *event);
766 void digit5Pressed(QQuickKeyEvent *event);
767 void digit6Pressed(QQuickKeyEvent *event);
768 void digit7Pressed(QQuickKeyEvent *event);
769 void digit8Pressed(QQuickKeyEvent *event);
770 void digit9Pressed(QQuickKeyEvent *event);
772 void leftPressed(QQuickKeyEvent *event);
773 void rightPressed(QQuickKeyEvent *event);
774 void upPressed(QQuickKeyEvent *event);
775 void downPressed(QQuickKeyEvent *event);
776 void tabPressed(QQuickKeyEvent *event);
777 void backtabPressed(QQuickKeyEvent *event);
779 void asteriskPressed(QQuickKeyEvent *event);
780 void numberSignPressed(QQuickKeyEvent *event);
781 void escapePressed(QQuickKeyEvent *event);
782 void returnPressed(QQuickKeyEvent *event);
783 void enterPressed(QQuickKeyEvent *event);
784 void deletePressed(QQuickKeyEvent *event);
785 void spacePressed(QQuickKeyEvent *event);
786 void backPressed(QQuickKeyEvent *event);
787 void cancelPressed(QQuickKeyEvent *event);
788 void selectPressed(QQuickKeyEvent *event);
789 void yesPressed(QQuickKeyEvent *event);
790 void noPressed(QQuickKeyEvent *event);
791 void context1Pressed(QQuickKeyEvent *event);
792 void context2Pressed(QQuickKeyEvent *event);
793 void context3Pressed(QQuickKeyEvent *event);
794 void context4Pressed(QQuickKeyEvent *event);
795 void callPressed(QQuickKeyEvent *event);
796 void hangupPressed(QQuickKeyEvent *event);
797 void flipPressed(QQuickKeyEvent *event);
798 void menuPressed(QQuickKeyEvent *event);
799 void volumeUpPressed(QQuickKeyEvent *event);
800 void volumeDownPressed(QQuickKeyEvent *event);
803 virtual void keyPressed(QKeyEvent *event, bool post);
804 virtual void keyReleased(QKeyEvent *event, bool post);
805 virtual void inputMethodEvent(QInputMethodEvent *, bool post);
806 virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
808 const QByteArray keyToSignal(int key) {
809 QByteArray keySignal;
810 if (key >= Qt::Key_0 && key <= Qt::Key_9) {
811 keySignal = "digit0Pressed";
812 keySignal[5] = '0' + (key - Qt::Key_0);
815 while (sigMap[i].key && sigMap[i].key != key)
817 keySignal = sigMap[i].sig;
822 bool isConnected(const char *signalName);
829 static const SigMap sigMap[];
832 Qt::MouseButtons QQuickItemPrivate::acceptedMouseButtons() const
834 return ((extra.flag() ? Qt::LeftButton : Qt::MouseButton(0)) |
835 (extra.isAllocated() ? extra->acceptedMouseButtons : Qt::MouseButtons(0)));
838 QSGContext *QQuickItemPrivate::sceneGraphContext() const
841 return static_cast<QQuickCanvasPrivate *>(QObjectPrivate::get(canvas))->context;
844 void QQuickItemPrivate::markSortedChildrenDirty(QQuickItem *child)
846 // If sortedChildItems == &childItems then all in childItems have z == 0
847 // and we don't need to invalidate if the changed item also has z == 0.
848 if (child->z() != 0. || sortedChildItems != &childItems) {
849 if (sortedChildItems != &childItems)
850 delete sortedChildItems;
851 sortedChildItems = 0;
855 QQuickItem::TransformOrigin QQuickItemPrivate::origin() const
857 return extra.isAllocated()?extra->origin:QQuickItem::Center;
860 QSGTransformNode *QQuickItemPrivate::itemNode()
862 if (!itemNodeInstance) {
863 itemNodeInstance = createTransformNode();
864 itemNodeInstance->setFlag(QSGNode::OwnedByParent, false);
865 #ifdef QML_RUNTIME_TESTING
867 itemNodeInstance->description = QString::fromLatin1("QQuickItem(%1)").arg(QString::fromLatin1(q->metaObject()->className()));
870 return itemNodeInstance;
873 QSGNode *QQuickItemPrivate::childContainerNode()
876 groupNode = new QSGNode();
878 rootNode()->appendChildNode(groupNode);
880 clipNode()->appendChildNode(groupNode);
881 else if (opacityNode())
882 opacityNode()->appendChildNode(groupNode);
884 itemNode()->appendChildNode(groupNode);
885 #ifdef QML_RUNTIME_TESTING
886 groupNode->description = QLatin1String("group");
892 Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickItemPrivate::ChangeTypes);
896 QML_DECLARE_TYPE(QQuickItemLayer)
897 QML_DECLARE_TYPE(QQuickKeysAttached)
898 QML_DECLARE_TYPEINFO(QQuickKeysAttached, QML_HAS_ATTACHED_PROPERTIES)
899 QML_DECLARE_TYPE(QQuickKeyNavigationAttached)
900 QML_DECLARE_TYPEINFO(QQuickKeyNavigationAttached, QML_HAS_ATTACHED_PROPERTIES)
901 QML_DECLARE_TYPE(QQuickLayoutMirroringAttached)
902 QML_DECLARE_TYPEINFO(QQuickLayoutMirroringAttached, QML_HAS_ATTACHED_PROPERTIES)
904 #endif // QQUICKITEM_P_H