Merge branch 'master' into refactor
[profile/ivi/qtdeclarative.git] / src / qtquick1 / graphicsitems / qdeclarativeitem_p.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
6 **
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 **
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 **
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
29 **
30 ** Other Usage
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QDECLARATIVEITEM_P_H
43 #define QDECLARATIVEITEM_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 purely as an
50 // implementation detail.  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 "QtQuick1/qdeclarativeitem.h"
57
58 #include "QtQuick1/private/qdeclarativeanchors_p.h"
59 #include "QtQuick1/private/qdeclarativeanchors_p_p.h"
60 #include "QtQuick1/private/qdeclarativeitemchangelistener_p.h"
61 #include <QtDeclarative/private/qpodvector_p.h>
62
63 #include <QtQuick1/private/qdeclarativestate_p.h>
64 #include <QtDeclarative/private/qdeclarativenullablevalue_p_p.h>
65 #include <QtDeclarative/private/qdeclarativenotifier_p.h>
66 #include <QtDeclarative/private/qdeclarativeglobal_p.h>
67
68 #include <QtDeclarative/qdeclarative.h>
69 #include <QtDeclarative/qdeclarativecontext.h>
70
71 #include <QtCore/qlist.h>
72 #include <QtCore/qrect.h>
73 #include <QtCore/qdebug.h>
74
75 #include <QtWidgets/private/qgraphicsitem_p.h>
76
77 QT_BEGIN_NAMESPACE
78
79 class QNetworkReply;
80
81 class QDeclarativeItemKeyFilter;
82 class QDeclarative1LayoutMirroringAttached;
83
84 //### merge into private?
85 class QDeclarative1Contents : public QObject, public QDeclarativeItemChangeListener
86 {
87     Q_OBJECT
88 public:
89     QDeclarative1Contents(QDeclarativeItem *item);
90     ~QDeclarative1Contents();
91
92     QRectF rectF() const;
93
94     void childRemoved(QDeclarativeItem *item);
95     void childAdded(QDeclarativeItem *item);
96
97     void calcGeometry() { calcWidth(); calcHeight(); }
98     void complete();
99
100 Q_SIGNALS:
101     void rectChanged(QRectF);
102
103 protected:
104     void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry);
105     void itemDestroyed(QDeclarativeItem *item);
106     //void itemVisibilityChanged(QDeclarativeItem *item)
107
108 private:
109     void calcHeight(QDeclarativeItem *changed = 0);
110     void calcWidth(QDeclarativeItem *changed = 0);
111
112     QDeclarativeItem *m_item;
113     qreal m_x;
114     qreal m_y;
115     qreal m_width;
116     qreal m_height;
117 };
118
119 class Q_DECLARATIVE_EXPORT QDeclarativeItemPrivate : public QGraphicsItemPrivate
120 {
121     Q_DECLARE_PUBLIC(QDeclarativeItem)
122
123 public:
124     QDeclarativeItemPrivate()
125     : _anchors(0), _contents(0),
126       baselineOffset(0),
127       _anchorLines(0),
128       _stateGroup(0), origin(QDeclarativeItem::Center),
129       widthValid(false), heightValid(false),
130       componentComplete(true), keepMouse(false),
131       smooth(false), transformOriginDirty(true), doneEventPreHandler(false),
132       inheritedLayoutMirror(false), effectiveLayoutMirror(false), isMirrorImplicit(true),
133       inheritMirrorFromParent(false), inheritMirrorFromItem(false), keyHandler(0),
134       mWidth(0), mHeight(0), mImplicitWidth(0), mImplicitHeight(0), attachedLayoutDirection(0), hadSubFocusItem(false)
135     {
136         QGraphicsItemPrivate::acceptedMouseButtons = 0;
137         isDeclarativeItem = 1;
138         QGraphicsItemPrivate::flags = QGraphicsItem::GraphicsItemFlags(
139                                       QGraphicsItem::ItemHasNoContents
140                                       | QGraphicsItem::ItemIsFocusable
141                                       | QGraphicsItem::ItemNegativeZStacksBehindParent);
142     }
143
144     void init(QDeclarativeItem *parent)
145     {
146         Q_Q(QDeclarativeItem);
147         if (parent) {
148             QDeclarative_setParent_noEvent(q, parent);
149             q->setParentItem(parent);
150             QDeclarativeItemPrivate *parentPrivate = QDeclarativeItemPrivate::get(parent);
151             setImplicitLayoutMirror(parentPrivate->inheritedLayoutMirror, parentPrivate->inheritMirrorFromParent);
152         }
153         baselineOffset.invalidate();
154         mouseSetsFocus = false;
155     }
156
157     bool isMirrored() const {
158         return effectiveLayoutMirror;
159     }
160
161     // Private Properties
162     qreal width() const;
163     void setWidth(qreal);
164     void resetWidth();
165
166     qreal height() const;
167     void setHeight(qreal);
168     void resetHeight();
169
170     virtual qreal implicitWidth() const;
171     virtual qreal implicitHeight() const;
172     virtual void implicitWidthChanged();
173     virtual void implicitHeightChanged();
174
175     void resolveLayoutMirror();
176     void setImplicitLayoutMirror(bool mirror, bool inherit);
177     void setLayoutMirror(bool mirror);
178
179     QDeclarativeListProperty<QObject> data();
180     QDeclarativeListProperty<QObject> resources();
181
182     QDeclarativeListProperty<QDeclarative1State> states();
183     QDeclarativeListProperty<QDeclarative1Transition> transitions();
184
185     QString state() const;
186     void setState(const QString &);
187
188     QDeclarative1AnchorLine left() const;
189     QDeclarative1AnchorLine right() const;
190     QDeclarative1AnchorLine horizontalCenter() const;
191     QDeclarative1AnchorLine top() const;
192     QDeclarative1AnchorLine bottom() const;
193     QDeclarative1AnchorLine verticalCenter() const;
194     QDeclarative1AnchorLine baseline() const;
195
196     // data property
197     static void data_append(QDeclarativeListProperty<QObject> *, QObject *);
198     static int data_count(QDeclarativeListProperty<QObject> *);
199     static QObject *data_at(QDeclarativeListProperty<QObject> *, int);
200     static void data_clear(QDeclarativeListProperty<QObject> *);
201
202     // resources property
203     static QObject *resources_at(QDeclarativeListProperty<QObject> *, int);
204     static void resources_append(QDeclarativeListProperty<QObject> *, QObject *);
205     static int resources_count(QDeclarativeListProperty<QObject> *);
206     static void resources_clear(QDeclarativeListProperty<QObject> *);
207
208     // transform property
209     static int transform_count(QDeclarativeListProperty<QGraphicsTransform> *list);
210     static void transform_append(QDeclarativeListProperty<QGraphicsTransform> *list, QGraphicsTransform *);
211     static QGraphicsTransform *transform_at(QDeclarativeListProperty<QGraphicsTransform> *list, int);
212     static void transform_clear(QDeclarativeListProperty<QGraphicsTransform> *list);
213
214     static QDeclarativeItemPrivate* get(QDeclarativeItem *item)
215     {
216         return item->d_func();
217     }
218
219     // Accelerated property accessors
220     QDeclarativeNotifier parentNotifier;
221     static void parentProperty(QObject *o, void *rv, QDeclarativeNotifierEndpoint *e);
222
223     QDeclarative1Anchors *anchors() {
224         if (!_anchors) {
225             Q_Q(QDeclarativeItem);
226             _anchors = new QDeclarative1Anchors(q);
227             if (!componentComplete)
228                 _anchors->classBegin();
229         }
230         return _anchors;
231     }
232     QDeclarative1Anchors *_anchors;
233     QDeclarative1Contents *_contents;
234
235     QDeclarativeNullableValue<qreal> baselineOffset;
236
237     struct AnchorLines {
238         AnchorLines(QGraphicsObject *);
239         QDeclarative1AnchorLine left;
240         QDeclarative1AnchorLine right;
241         QDeclarative1AnchorLine hCenter;
242         QDeclarative1AnchorLine top;
243         QDeclarative1AnchorLine bottom;
244         QDeclarative1AnchorLine vCenter;
245         QDeclarative1AnchorLine baseline;
246     };
247     mutable AnchorLines *_anchorLines;
248     AnchorLines *anchorLines() const {
249         Q_Q(const QDeclarativeItem);
250         if (!_anchorLines) _anchorLines =
251             new AnchorLines(const_cast<QDeclarativeItem *>(q));
252         return _anchorLines;
253     }
254
255     enum ChangeType {
256         Geometry = 0x01,
257         SiblingOrder = 0x02,
258         Visibility = 0x04,
259         Opacity = 0x08,
260         Destroyed = 0x10
261     };
262
263     Q_DECLARE_FLAGS(ChangeTypes, ChangeType)
264
265     struct ChangeListener {
266         ChangeListener(QDeclarativeItemChangeListener *l, QDeclarativeItemPrivate::ChangeTypes t) : listener(l), types(t) {}
267         QDeclarativeItemChangeListener *listener;
268         QDeclarativeItemPrivate::ChangeTypes types;
269         bool operator==(const ChangeListener &other) const { return listener == other.listener && types == other.types; }
270     };
271
272     void addItemChangeListener(QDeclarativeItemChangeListener *listener, ChangeTypes types) {
273         changeListeners.append(ChangeListener(listener, types));
274     }
275     void removeItemChangeListener(QDeclarativeItemChangeListener *, ChangeTypes types);
276     QPODVector<ChangeListener,4> changeListeners;
277
278     QDeclarative1StateGroup *_states();
279     QDeclarative1StateGroup *_stateGroup;
280
281     QDeclarativeItem::TransformOrigin origin:5;
282     bool widthValid:1;
283     bool heightValid:1;
284     bool componentComplete:1;
285     bool keepMouse:1;
286     bool smooth:1;
287     bool transformOriginDirty : 1;
288     bool doneEventPreHandler : 1;
289     bool inheritedLayoutMirror:1;
290     bool effectiveLayoutMirror:1;
291     bool isMirrorImplicit:1;
292     bool inheritMirrorFromParent:1;
293     bool inheritMirrorFromItem:1;
294
295     QDeclarativeItemKeyFilter *keyHandler;
296
297     qreal mWidth;
298     qreal mHeight;
299     qreal mImplicitWidth;
300     qreal mImplicitHeight;
301
302     QDeclarative1LayoutMirroringAttached* attachedLayoutDirection;
303
304     bool hadSubFocusItem;
305
306     QPointF computeTransformOrigin() const;
307
308     virtual void setPosHelper(const QPointF &pos)
309     {
310         Q_Q(QDeclarativeItem);
311         QRectF oldGeometry(this->pos.x(), this->pos.y(), mWidth, mHeight);
312         QGraphicsItemPrivate::setPosHelper(pos);
313         q->geometryChanged(QRectF(this->pos.x(), this->pos.y(), mWidth, mHeight), oldGeometry);
314     }
315
316     // Reimplemented from QGraphicsItemPrivate
317     virtual void subFocusItemChange()
318     {
319         bool hasSubFocusItem = subFocusItem != 0;
320         if (((flags & QGraphicsItem::ItemIsFocusScope) || !parent) && hasSubFocusItem != hadSubFocusItem)
321             emit q_func()->activeFocusChanged(hasSubFocusItem);
322         //see also QDeclarativeItemPrivate::focusChanged
323         hadSubFocusItem = hasSubFocusItem;
324     }
325
326     // Reimplemented from QGraphicsItemPrivate
327     virtual void focusScopeItemChange(bool isSubFocusItem)
328     {
329         emit q_func()->focusChanged(isSubFocusItem);
330     }
331
332
333     // Reimplemented from QGraphicsItemPrivate
334     virtual void siblingOrderChange()
335     {
336         Q_Q(QDeclarativeItem);
337         for(int ii = 0; ii < changeListeners.count(); ++ii) {
338             const QDeclarativeItemPrivate::ChangeListener &change = changeListeners.at(ii);
339             if (change.types & QDeclarativeItemPrivate::SiblingOrder) {
340                 change.listener->itemSiblingOrderChanged(q);
341             }
342         }
343     }
344
345     // Reimplemented from QGraphicsItemPrivate
346     virtual void transformChanged();
347
348     virtual void focusChanged(bool);
349
350     virtual void mirrorChange() {};
351
352     static qint64 consistentTime;
353     static void setConsistentTime(qint64 t);
354     static void start(QElapsedTimer &);
355     static qint64 elapsed(QElapsedTimer &);
356     static qint64 restart(QElapsedTimer &);
357 };
358
359 /*
360     Key filters can be installed on a QDeclarativeItem, but not removed.  Currently they
361     are only used by attached objects (which are only destroyed on Item
362     destruction), so this isn't a problem.  If in future this becomes any form
363     of public API, they will have to support removal too.
364 */
365 class QDeclarativeItemKeyFilter
366 {
367 public:
368     QDeclarativeItemKeyFilter(QDeclarativeItem * = 0);
369     virtual ~QDeclarativeItemKeyFilter();
370
371     virtual void keyPressed(QKeyEvent *event, bool post);
372     virtual void keyReleased(QKeyEvent *event, bool post);
373     virtual void inputMethodEvent(QInputMethodEvent *event, bool post);
374     virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
375     virtual void componentComplete();
376
377     bool m_processPost;
378
379 private:
380     QDeclarativeItemKeyFilter *m_next;
381 };
382
383 class QDeclarative1KeyNavigationAttachedPrivate : public QObjectPrivate
384 {
385 public:
386     QDeclarative1KeyNavigationAttachedPrivate()
387         : QObjectPrivate(),
388           left(0), right(0), up(0), down(0), tab(0), backtab(0),
389           leftSet(false), rightSet(false), upSet(false), downSet(false),
390           tabSet(false), backtabSet(false) {}
391
392     QDeclarativeItem *left;
393     QDeclarativeItem *right;
394     QDeclarativeItem *up;
395     QDeclarativeItem *down;
396     QDeclarativeItem *tab;
397     QDeclarativeItem *backtab;
398     bool leftSet : 1;
399     bool rightSet : 1;
400     bool upSet : 1;
401     bool downSet : 1;
402     bool tabSet : 1;
403     bool backtabSet : 1;
404 };
405
406 class QDeclarative1KeyNavigationAttached : public QObject, public QDeclarativeItemKeyFilter
407 {
408     Q_OBJECT
409     Q_DECLARE_PRIVATE(QDeclarative1KeyNavigationAttached)
410
411     Q_PROPERTY(QDeclarativeItem *left READ left WRITE setLeft NOTIFY leftChanged)
412     Q_PROPERTY(QDeclarativeItem *right READ right WRITE setRight NOTIFY rightChanged)
413     Q_PROPERTY(QDeclarativeItem *up READ up WRITE setUp NOTIFY upChanged)
414     Q_PROPERTY(QDeclarativeItem *down READ down WRITE setDown NOTIFY downChanged)
415     Q_PROPERTY(QDeclarativeItem *tab READ tab WRITE setTab NOTIFY tabChanged)
416     Q_PROPERTY(QDeclarativeItem *backtab READ backtab WRITE setBacktab NOTIFY backtabChanged)
417     Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY priorityChanged)
418
419     Q_ENUMS(Priority)
420
421 public:
422     QDeclarative1KeyNavigationAttached(QObject * = 0);
423
424     QDeclarativeItem *left() const;
425     void setLeft(QDeclarativeItem *);
426     QDeclarativeItem *right() const;
427     void setRight(QDeclarativeItem *);
428     QDeclarativeItem *up() const;
429     void setUp(QDeclarativeItem *);
430     QDeclarativeItem *down() const;
431     void setDown(QDeclarativeItem *);
432     QDeclarativeItem *tab() const;
433     void setTab(QDeclarativeItem *);
434     QDeclarativeItem *backtab() const;
435     void setBacktab(QDeclarativeItem *);
436
437     enum Priority { BeforeItem, AfterItem };
438     Priority priority() const;
439     void setPriority(Priority);
440
441     static QDeclarative1KeyNavigationAttached *qmlAttachedProperties(QObject *);
442
443 Q_SIGNALS:
444     void leftChanged();
445     void rightChanged();
446     void upChanged();
447     void downChanged();
448     void tabChanged();
449     void backtabChanged();
450     void priorityChanged();
451
452 private:
453     virtual void keyPressed(QKeyEvent *event, bool post);
454     virtual void keyReleased(QKeyEvent *event, bool post);
455     void setFocusNavigation(QDeclarativeItem *currentItem, const char *dir);
456 };
457
458 class QDeclarative1LayoutMirroringAttached : public QObject
459 {
460     Q_OBJECT
461     Q_PROPERTY(bool enabled READ enabled WRITE setEnabled RESET resetEnabled NOTIFY enabledChanged)
462     Q_PROPERTY(bool childrenInherit READ childrenInherit WRITE setChildrenInherit NOTIFY childrenInheritChanged)
463
464 public:
465     explicit QDeclarative1LayoutMirroringAttached(QObject *parent = 0);
466
467     bool enabled() const;
468     void setEnabled(bool);
469     void resetEnabled();
470
471     bool childrenInherit() const;
472     void setChildrenInherit(bool);
473
474     static QDeclarative1LayoutMirroringAttached *qmlAttachedProperties(QObject *);
475 Q_SIGNALS:
476     void enabledChanged();
477     void childrenInheritChanged();
478 private:
479     friend class QDeclarativeItemPrivate;
480     QDeclarativeItemPrivate *itemPrivate;
481 };
482
483 class QDeclarative1KeysAttachedPrivate : public QObjectPrivate
484 {
485 public:
486     QDeclarative1KeysAttachedPrivate()
487         : QObjectPrivate(), inPress(false), inRelease(false)
488         , inIM(false), enabled(true), imeItem(0), item(0)
489     {}
490
491     bool isConnected(const char *signalName);
492
493     QGraphicsItem *finalFocusProxy(QGraphicsItem *item) const
494     {
495         QGraphicsItem *fp;
496         while ((fp = item->focusProxy()))
497             item = fp;
498         return item;
499     }
500
501     //loop detection
502     bool inPress:1;
503     bool inRelease:1;
504     bool inIM:1;
505
506     bool enabled : 1;
507
508     QGraphicsItem *imeItem;
509     QList<QDeclarativeItem *> targets;
510     QDeclarativeItem *item;
511 };
512
513 class QDeclarative1KeysAttached : public QObject, public QDeclarativeItemKeyFilter
514 {
515     Q_OBJECT
516     Q_DECLARE_PRIVATE(QDeclarative1KeysAttached)
517
518     Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
519     Q_PROPERTY(QDeclarativeListProperty<QDeclarativeItem> forwardTo READ forwardTo)
520     Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY priorityChanged)
521
522     Q_ENUMS(Priority)
523
524 public:
525     QDeclarative1KeysAttached(QObject *parent=0);
526     ~QDeclarative1KeysAttached();
527
528     bool enabled() const { Q_D(const QDeclarative1KeysAttached); return d->enabled; }
529     void setEnabled(bool enabled) {
530         Q_D(QDeclarative1KeysAttached);
531         if (enabled != d->enabled) {
532             d->enabled = enabled;
533             emit enabledChanged();
534         }
535     }
536
537     enum Priority { BeforeItem, AfterItem};
538     Priority priority() const;
539     void setPriority(Priority);
540
541     QDeclarativeListProperty<QDeclarativeItem> forwardTo() {
542         Q_D(QDeclarative1KeysAttached);
543         return QDeclarativeListProperty<QDeclarativeItem>(this, d->targets);
544     }
545
546     virtual void componentComplete();
547
548     static QDeclarative1KeysAttached *qmlAttachedProperties(QObject *);
549
550 Q_SIGNALS:
551     void enabledChanged();
552     void priorityChanged();
553     void pressed(QDeclarative1KeyEvent *event);
554     void released(QDeclarative1KeyEvent *event);
555     void digit0Pressed(QDeclarative1KeyEvent *event);
556     void digit1Pressed(QDeclarative1KeyEvent *event);
557     void digit2Pressed(QDeclarative1KeyEvent *event);
558     void digit3Pressed(QDeclarative1KeyEvent *event);
559     void digit4Pressed(QDeclarative1KeyEvent *event);
560     void digit5Pressed(QDeclarative1KeyEvent *event);
561     void digit6Pressed(QDeclarative1KeyEvent *event);
562     void digit7Pressed(QDeclarative1KeyEvent *event);
563     void digit8Pressed(QDeclarative1KeyEvent *event);
564     void digit9Pressed(QDeclarative1KeyEvent *event);
565
566     void leftPressed(QDeclarative1KeyEvent *event);
567     void rightPressed(QDeclarative1KeyEvent *event);
568     void upPressed(QDeclarative1KeyEvent *event);
569     void downPressed(QDeclarative1KeyEvent *event);
570     void tabPressed(QDeclarative1KeyEvent *event);
571     void backtabPressed(QDeclarative1KeyEvent *event);
572
573     void asteriskPressed(QDeclarative1KeyEvent *event);
574     void numberSignPressed(QDeclarative1KeyEvent *event);
575     void escapePressed(QDeclarative1KeyEvent *event);
576     void returnPressed(QDeclarative1KeyEvent *event);
577     void enterPressed(QDeclarative1KeyEvent *event);
578     void deletePressed(QDeclarative1KeyEvent *event);
579     void spacePressed(QDeclarative1KeyEvent *event);
580     void backPressed(QDeclarative1KeyEvent *event);
581     void cancelPressed(QDeclarative1KeyEvent *event);
582     void selectPressed(QDeclarative1KeyEvent *event);
583     void yesPressed(QDeclarative1KeyEvent *event);
584     void noPressed(QDeclarative1KeyEvent *event);
585     void context1Pressed(QDeclarative1KeyEvent *event);
586     void context2Pressed(QDeclarative1KeyEvent *event);
587     void context3Pressed(QDeclarative1KeyEvent *event);
588     void context4Pressed(QDeclarative1KeyEvent *event);
589     void callPressed(QDeclarative1KeyEvent *event);
590     void hangupPressed(QDeclarative1KeyEvent *event);
591     void flipPressed(QDeclarative1KeyEvent *event);
592     void menuPressed(QDeclarative1KeyEvent *event);
593     void volumeUpPressed(QDeclarative1KeyEvent *event);
594     void volumeDownPressed(QDeclarative1KeyEvent *event);
595
596 private:
597     virtual void keyPressed(QKeyEvent *event, bool post);
598     virtual void keyReleased(QKeyEvent *event, bool post);
599     virtual void inputMethodEvent(QInputMethodEvent *, bool post);
600     virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
601
602     const QByteArray keyToSignal(int key) {
603         QByteArray keySignal;
604         if (key >= Qt::Key_0 && key <= Qt::Key_9) {
605             keySignal = "digit0Pressed";
606             keySignal[5] = '0' + (key - Qt::Key_0);
607         } else {
608             int i = 0;
609             while (sigMap[i].key && sigMap[i].key != key)
610                 ++i;
611             keySignal = sigMap[i].sig;
612         }
613         return keySignal;
614     }
615
616     struct SigMap {
617         int key;
618         const char *sig;
619     };
620
621     static const SigMap sigMap[];
622 };
623
624 Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeItemPrivate::ChangeTypes);
625
626 QT_END_NAMESPACE
627
628 QML_DECLARE_TYPE(QDeclarative1KeysAttached)
629 QML_DECLARE_TYPEINFO(QDeclarative1KeysAttached, QML_HAS_ATTACHED_PROPERTIES)
630 QML_DECLARE_TYPE(QDeclarative1KeyNavigationAttached)
631 QML_DECLARE_TYPEINFO(QDeclarative1KeyNavigationAttached, QML_HAS_ATTACHED_PROPERTIES)
632 QML_DECLARE_TYPE(QDeclarative1LayoutMirroringAttached)
633 QML_DECLARE_TYPEINFO(QDeclarative1LayoutMirroringAttached, QML_HAS_ATTACHED_PROPERTIES)
634
635 #endif // QDECLARATIVEITEM_P_H