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