diff options
31 files changed, 243 insertions, 373 deletions
diff --git a/configure.exe b/configure.exe Binary files differindex e91c1de..d52b0c1 100644 --- a/configure.exe +++ b/configure.exe diff --git a/demos/declarative/calculator/CalcButton.qml b/demos/declarative/calculator/CalcButton.qml index 0fb5412..966c8e4 100644 --- a/demos/declarative/calculator/CalcButton.qml +++ b/demos/declarative/calculator/CalcButton.qml @@ -16,7 +16,7 @@ Rectangle { Text { anchors.centerIn: parent; text: operation; color: Palette.buttonText } MouseRegion { - id: MouseRegion + id: ClickRegion anchors.fill: parent onClicked: { doOp(operation); @@ -28,7 +28,7 @@ Rectangle { states: [ State { - name: "Pressed"; when: MouseRegion.pressed == true + name: "Pressed"; when: ClickRegion.pressed == true PropertyChanges { target: G1; color: Palette.dark } PropertyChanges { target: G2; color: Palette.button } }, diff --git a/demos/declarative/contacts/contacts.qml b/demos/declarative/contacts/contacts.qml index f009631..278eeb3 100644 --- a/demos/declarative/contacts/contacts.qml +++ b/demos/declarative/contacts/contacts.qml @@ -290,10 +290,8 @@ Rectangle { } ] } - KeyProxy { - focus: contacts.mode != 'new' - targets: { contacts.mode == "list" ? [searchBarWrapper, contactListView] : [contactListView]} - } + focus: contacts.mode != 'new' + forwardTo: { contacts.mode == "list" ? [searchBarWrapper, contactListView] : [contactListView]} states: [ State { name: "editNewState" diff --git a/demos/declarative/flickr/common/MediaLineEdit.qml b/demos/declarative/flickr/common/MediaLineEdit.qml index eab0b95..094571f 100644 --- a/demos/declarative/flickr/common/MediaLineEdit.qml +++ b/demos/declarative/flickr/common/MediaLineEdit.qml @@ -26,7 +26,7 @@ Item { width: 100 } PropertyChanges { - target: Proxy + target: Container focus: true } StateChangeScript { @@ -96,12 +96,7 @@ Item { anchors.left: Label.right anchors.verticalCenter: Container.verticalCenter } - KeyProxy { - id: Proxy - anchors.left: Container.left - anchors.fill: Container - targets: [(ReturnKey), (Editor)] - } + Keys.forwardTo: [(ReturnKey), (Editor)] Item { id: ReturnKey Keys.onReturnPressed: "Container.state = ''" diff --git a/demos/declarative/flickr/common/ScrollBar.qml b/demos/declarative/flickr/common/ScrollBar.qml index 89d51e2..d31c57c 100644 --- a/demos/declarative/flickr/common/ScrollBar.qml +++ b/demos/declarative/flickr/common/ScrollBar.qml @@ -12,9 +12,9 @@ Item { border.color: "white" border.width: 2 x: 0 - y: flickableArea.pageYPosition * Container.height + y: flickableArea.visibleArea.yPosition * Container.height width: parent.width - height: flickableArea.pageHeight * Container.height + height: flickableArea.visibleArea.heightRatio * Container.height } states: [ State { diff --git a/demos/declarative/flickr/mobile/TitleBar.qml b/demos/declarative/flickr/mobile/TitleBar.qml index 79c1326..b95452a 100644 --- a/demos/declarative/flickr/mobile/TitleBar.qml +++ b/demos/declarative/flickr/mobile/TitleBar.qml @@ -53,11 +53,7 @@ Item { color: "#151515"; highlightColor: "Green" } - KeyProxy { - id: Proxy - anchors.fill: parent - targets: [(ReturnKey), (Editor)] - } + Keys.forwardTo: [ (ReturnKey), (Editor)] Item { id: ReturnKey @@ -71,7 +67,7 @@ Item { name: "Tags" PropertyChanges { target: Container; x: -TagButton.x + 5 } PropertyChanges { target: TagButton; text: "OK" } - PropertyChanges { target: Proxy; focus: true } + PropertyChanges { target: LineEdit; focus: true } } transitions: Transition { diff --git a/demos/declarative/twitter/content/AuthView.qml b/demos/declarative/twitter/content/AuthView.qml index 9ca4d88..7d0d865 100644 --- a/demos/declarative/twitter/content/AuthView.qml +++ b/demos/declarative/twitter/content/AuthView.qml @@ -29,11 +29,7 @@ Item { maximumLength:21 font.bold: true color: "#151515"; highlightColor: "green" - KeyProxy { - id: Proxy - targets: [(tabber), (nameIn)] - focus: true - } + Keys.forwardTo: [(tabber), (nameIn)] Item { id: tabber //Note: it's not working yet diff --git a/demos/declarative/twitter/content/HomeTitleBar.qml b/demos/declarative/twitter/content/HomeTitleBar.qml index 5cb8bea..9bca2c8 100644 --- a/demos/declarative/twitter/content/HomeTitleBar.qml +++ b/demos/declarative/twitter/content/HomeTitleBar.qml @@ -94,11 +94,7 @@ Item { wrap:true color: "#151515"; highlightColor: "green" } - KeyProxy { - id: Proxy - anchors.fill: parent - targets: [(ReturnKey), (Editor)] - } + Keys.forwardTo: [(ReturnKey), (Editor)] Item { id: ReturnKey Keys.onReturnPressed: accept() @@ -114,7 +110,7 @@ Item { PropertyChanges { target: TagButton; text: "OK" } PropertyChanges { target: TagButton; width: 28 } PropertyChanges { target: TagButton; height: 24 } - PropertyChanges { target: Proxy; focus: true } + PropertyChanges { target: txtEdit; focus: true } } ] transitions: [ diff --git a/demos/declarative/twitter/twitter.qml b/demos/declarative/twitter/twitter.qml index 14075bf..eb9f5d6 100644 --- a/demos/declarative/twitter/twitter.qml +++ b/demos/declarative/twitter/twitter.qml @@ -43,7 +43,7 @@ Item { id: Views x: 2; width: parent.width - 4 y:60 //Below the title bars - height: 320 + height: 380 Twitter.AuthView{ id: authView diff --git a/examples/declarative/listview/content/MediaButton.qml b/examples/declarative/listview/content/MediaButton.qml index 599452d..3b0ef1e 100644 --- a/examples/declarative/listview/content/MediaButton.qml +++ b/examples/declarative/listview/content/MediaButton.qml @@ -6,7 +6,7 @@ Item { id: Container Image { - id: Image + id: Normal source: "pics/button.png" } Image { @@ -15,21 +15,21 @@ Item { opacity: 0 } MouseRegion { - id: MouseRegion - anchors.fill: Image + id: ClickRegion + anchors.fill: Normal onClicked: { Container.clicked(); } } Text { font.bold: true color: "white" - anchors.centerIn: Image + anchors.centerIn: Normal text: Container.text } - width: Image.width + width: Normal.width states: [ State { name: "Pressed" - when: MouseRegion.pressed == true + when: ClickRegion.pressed == true PropertyChanges { target: Pressed opacity: 1 diff --git a/examples/declarative/listview/listview.qml b/examples/declarative/listview/listview.qml index 0f197b4..1cca5ad 100644 --- a/examples/declarative/listview/listview.qml +++ b/examples/declarative/listview/listview.qml @@ -66,17 +66,14 @@ Rectangle { model: MyPetsModel; delegate: PetDelegate currentItemPositioning: "SnapAuto"; snapPosition: 125 currentIndex: List1.currentIndex - children: [ - // Position a static highlight rather than a normal highlight so that - // when the view is flicked, the highlight does not move. - // By positioning the highlight at the same position as the snapPosition - // the item under the highlight will always be the current item. - // Note that we specify the 'children' property. This is because - // the default property of a ListView is 'delegate'. - Rectangle { - y: 125; width: 200; height: 50 - color: "#FFFF88"; z: -1 - } - ] + + // Position a static highlight rather than a normal highlight so that + // when the view is flicked, the highlight does not move. + // By positioning the highlight at the same position as the snapPosition + // the item under the highlight will always be the current item. + Rectangle { + y: 125; width: 200; height: 50 + color: "#FFFF88"; z: -1 + } } } diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri index ddb4017..003693b 100644 --- a/src/corelib/kernel/kernel.pri +++ b/src/corelib/kernel/kernel.pri @@ -33,7 +33,6 @@ HEADERS += \ kernel/qsystemsemaphore.h \ kernel/qsystemsemaphore_p.h \ kernel/qfunctions_p.h \ - kernel/qmetaobjectbuilder_p.h \ kernel/qguard_p.h SOURCES += \ @@ -56,7 +55,6 @@ SOURCES += \ kernel/qcoreglobaldata.cpp \ kernel/qsharedmemory.cpp \ kernel/qsystemsemaphore.cpp \ - kernel/qmetaobjectbuilder.cpp \ kernel/qpointer.cpp win32 { diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt index 7dda5cc..95c81c7 100644 --- a/src/declarative/QmlChanges.txt +++ b/src/declarative/QmlChanges.txt @@ -78,6 +78,7 @@ Other Changes: Drag: axis becomes an enum with values "XAxis", "YAxis", "XandYAxis" Image: scaleGrid property removed. New item called BorderImage instead. KeyActions: changed to a Keys attached property on any item. +KeyProxy: changed to a Keys.forwardTo property on any item. Pending Changes =============== diff --git a/src/declarative/fx/fx.pri b/src/declarative/fx/fx.pri index 63ac818..80a6fdd 100644 --- a/src/declarative/fx/fx.pri +++ b/src/declarative/fx/fx.pri @@ -20,7 +20,6 @@ HEADERS += \ fx/qfxitem_p.h \ fx/qfxfocuspanel.h \ fx/qfxfocusscope.h \ - fx/qfxkeyproxy.h \ fx/qfxpositioners.h \ fx/qfxpositioners_p.h \ fx/qfxloader.h \ @@ -62,7 +61,6 @@ SOURCES += \ fx/qfxitem.cpp \ fx/qfxfocuspanel.cpp \ fx/qfxfocusscope.cpp \ - fx/qfxkeyproxy.cpp \ fx/qfxpositioners.cpp \ fx/qfxloader.cpp \ fx/qfxmouseregion.cpp \ diff --git a/src/declarative/fx/qfxgridview.cpp b/src/declarative/fx/qfxgridview.cpp index 6fd080b..cccd7a6 100644 --- a/src/declarative/fx/qfxgridview.cpp +++ b/src/declarative/fx/qfxgridview.cpp @@ -59,7 +59,7 @@ public: attachedProperties.remove(parent()); } - Q_PROPERTY(QFxGridView *view READ view) + Q_PROPERTY(QFxGridView *view READ view CONSTANT) QFxGridView *view() { return m_view; } Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY currentItemChanged) @@ -699,6 +699,7 @@ QFxGridView::QFxGridView(QFxItem *parent) QFxGridView::~QFxGridView() { Q_D(QFxGridView); + d->clear(); if (d->ownModel) delete d->model; } diff --git a/src/declarative/fx/qfxgridview.h b/src/declarative/fx/qfxgridview.h index 4f2146d..4ebd311 100644 --- a/src/declarative/fx/qfxgridview.h +++ b/src/declarative/fx/qfxgridview.h @@ -58,7 +58,6 @@ class Q_DECLARATIVE_EXPORT QFxGridView : public QFxFlickable Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QFxGridView) Q_PROPERTY(QVariant model READ model WRITE setModel) - Q_CLASSINFO("DefaultProperty", "delegate") Q_PROPERTY(QmlComponent *delegate READ delegate WRITE setDelegate) Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged) Q_PROPERTY(QFxItem *current READ currentItem NOTIFY currentIndexChanged) @@ -70,6 +69,7 @@ class Q_DECLARATIVE_EXPORT QFxGridView : public QFxFlickable Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer) Q_PROPERTY(int cellWidth READ cellWidth WRITE setCellWidth NOTIFY cellSizeChanged) Q_PROPERTY(int cellHeight READ cellHeight WRITE setCellHeight NOTIFY cellSizeChanged) + Q_CLASSINFO("DefaultProperty", "data") public: QFxGridView(QFxItem *parent=0); diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 073d5d9..88a0854 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -334,6 +334,8 @@ public: virtual void keyPressed(QKeyEvent *event); virtual void keyReleased(QKeyEvent *event); + virtual void inputMethodEvent(QInputMethodEvent *event); + virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const; private: QFxItemKeyFilter *m_next; @@ -364,6 +366,17 @@ void QFxItemKeyFilter::keyReleased(QKeyEvent *event) if (m_next) m_next->keyReleased(event); } +void QFxItemKeyFilter::inputMethodEvent(QInputMethodEvent *event) +{ + if (m_next) m_next->inputMethodEvent(event); +} + +QVariant QFxItemKeyFilter::inputMethodQuery(Qt::InputMethodQuery query) const +{ + if (m_next) return m_next->inputMethodQuery(query); + return QVariant(); +} + class QFxKeyNavigationAttachedPrivate : public QObjectPrivate { public: @@ -592,6 +605,25 @@ void QFxKeyNavigationAttached::keyReleased(QKeyEvent *event) */ /*! + \qmlproperty List<Object> Keys::forwardTo + + This property provides a way to forward key presses, key releases, and keyboard input + coming from input methods to other items. This can be useful when you want + one item to handle some keys (e.g. the up and down arrow keys), and another item to + handle other keys (e.g. the left and right arrow keys). Once an item that has been + forwarded keys accepts the event it is no longer forwarded to items later in the + list. + + This example forwards key events to two lists: + \qml + ListView { id: List1 ... } + ListView { id: List2 ... } + Keys.forwardTo: [List1, List2] + focus: true + \endqml +*/ + +/*! \qmlsignal Keys::onPressed(event) This handler is called when a key has been pressed. The \a event @@ -853,19 +885,42 @@ void QFxKeyNavigationAttached::keyReleased(QKeyEvent *event) class QFxKeysAttachedPrivate : public QObjectPrivate { public: - QFxKeysAttachedPrivate() : QObjectPrivate(), enabled(true) {} + QFxKeysAttachedPrivate() + : QObjectPrivate(), inPress(false), inRelease(false) + , inIM(false), enabled(true), imeItem(0), item(0) + {} bool isConnected(const char *signalName); - bool enabled; + QGraphicsItem *finalFocusProxy(QGraphicsItem *item) const + { + QGraphicsItem *fp; + while ((fp = item->focusProxy())) + item = fp; + return item; + } + + //loop detection + bool inPress:1; + bool inRelease:1; + bool inIM:1; + + bool enabled : 1; + + QGraphicsItem *imeItem; + QList<QFxItem *> targets; + QFxItem *item; }; -class QFxKeysAttached : public QObject, public QFxItemKeyFilter +class QFxKeysAttached : public QObject, public QFxItemKeyFilter, public QmlParserStatus { Q_OBJECT - Q_DECLARE_PRIVATE(QFxKeysAttached); + Q_DECLARE_PRIVATE(QFxKeysAttached) + Q_INTERFACES(QmlParserStatus) Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) + Q_PROPERTY(QList<QFxItem *> *forwardTo READ forwardTo) + public: QFxKeysAttached(QObject *parent=0); ~QFxKeysAttached(); @@ -879,6 +934,13 @@ public: } } + QList<QFxItem *> *forwardTo() { + Q_D(QFxKeysAttached); + return &d->targets; + } + + virtual void componentComplete(); + static QFxKeysAttached *qmlAttachedProperties(QObject *); Q_SIGNALS: @@ -927,6 +989,8 @@ Q_SIGNALS: private: virtual void keyPressed(QKeyEvent *event); virtual void keyReleased(QKeyEvent *event); + virtual void inputMethodEvent(QInputMethodEvent *); + virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const; const QByteArray keyToSignal(int key) { QByteArray keySignal; @@ -989,20 +1053,52 @@ QFxKeysAttached::QFxKeysAttached(QObject *parent) : QObject(*(new QFxKeysAttachedPrivate), parent), QFxItemKeyFilter(qobject_cast<QFxItem*>(parent)) { + Q_D(QFxKeysAttached); + d->item = qobject_cast<QFxItem*>(parent); } QFxKeysAttached::~QFxKeysAttached() { } +void QFxKeysAttached::componentComplete() +{ + Q_D(QFxKeysAttached); + if (d->item) { + for (int ii = 0; ii < d->targets.count(); ++ii) { + QGraphicsItem *targetItem = d->finalFocusProxy(d->targets.at(ii)); + if (targetItem && (targetItem->flags() & QGraphicsItem::ItemAcceptsInputMethod)) { + d->item->setFlag(QGraphicsItem::ItemAcceptsInputMethod); + break; + } + } + } +} + void QFxKeysAttached::keyPressed(QKeyEvent *event) { Q_D(QFxKeysAttached); - if (!d->enabled) { + if (!d->enabled || d->inPress) { event->ignore(); return; } + // first process forwards + if (d->item && d->item->scene()) { + d->inPress = true; + for (int ii = 0; ii < d->targets.count(); ++ii) { + QGraphicsItem *i = d->finalFocusProxy(d->targets.at(ii)); + if (i) { + d->item->scene()->sendEvent(i, event); + if (event->isAccepted()) { + d->inPress = false; + return; + } + } + } + d->inPress = false; + } + QFxKeyEvent ke(*event); QByteArray keySignal = keyToSignal(event->key()); if (!keySignal.isEmpty()) { @@ -1024,10 +1120,26 @@ void QFxKeysAttached::keyPressed(QKeyEvent *event) void QFxKeysAttached::keyReleased(QKeyEvent *event) { Q_D(QFxKeysAttached); - if (!d->enabled) { + if (!d->enabled || d->inRelease) { event->ignore(); return; } + + if (d->item && d->item->scene()) { + d->inRelease = true; + for (int ii = 0; ii < d->targets.count(); ++ii) { + QGraphicsItem *i = d->finalFocusProxy(d->targets.at(ii)); + if (i) { + d->item->scene()->sendEvent(i, event); + if (event->isAccepted()) { + d->inRelease = false; + return; + } + } + } + d->inRelease = false; + } + QFxKeyEvent ke(*event); emit released(&ke); event->setAccepted(ke.isAccepted()); @@ -1035,6 +1147,52 @@ void QFxKeysAttached::keyReleased(QKeyEvent *event) if (!event->isAccepted()) QFxItemKeyFilter::keyReleased(event); } +void QFxKeysAttached::inputMethodEvent(QInputMethodEvent *event) +{ + Q_D(QFxKeysAttached); + if (d->item && !d->inIM && d->item->scene()) { + d->inIM = true; + for (int ii = 0; ii < d->targets.count(); ++ii) { + QGraphicsItem *i = d->finalFocusProxy(d->targets.at(ii)); + if (i && (i->flags() & QGraphicsItem::ItemAcceptsInputMethod)) { + d->item->scene()->sendEvent(i, event); + if (event->isAccepted()) { + d->imeItem = i; + d->inIM = false; + return; + } + } + } + d->inIM = false; + } + if (!event->isAccepted()) QFxItemKeyFilter::inputMethodEvent(event); +} + +class QFxItemAccessor : public QGraphicsItem +{ +public: + QVariant doInputMethodQuery(Qt::InputMethodQuery query) const { + return QGraphicsItem::inputMethodQuery(query); + } +}; + +QVariant QFxKeysAttached::inputMethodQuery(Qt::InputMethodQuery query) const +{ + Q_D(const QFxKeysAttached); + if (d->item) { + for (int ii = 0; ii < d->targets.count(); ++ii) { + QGraphicsItem *i = d->finalFocusProxy(d->targets.at(ii)); + if (i && (i->flags() & QGraphicsItem::ItemAcceptsInputMethod) && i == d->imeItem) { //### how robust is i == d->imeItem check? + QVariant v = static_cast<QFxItemAccessor *>(i)->doInputMethodQuery(query); + if (v.type() == QVariant::RectF) + v = d->item->mapRectFromItem(i, v.toRectF()); //### cost? + return v; + } + } + } + return QFxItemKeyFilter::inputMethodQuery(query); +} + QFxKeysAttached *QFxKeysAttached::qmlAttachedProperties(QObject *obj) { return new QFxKeysAttached(obj); @@ -1672,6 +1830,28 @@ void QFxItem::keyReleaseEvent(QKeyEvent *event) event->ignore(); } +void QFxItem::inputMethodEvent(QInputMethodEvent *event) +{ + Q_D(QFxItem); + if (d->keyHandler) + d->keyHandler->inputMethodEvent(event); + else + event->ignore(); +} + +QVariant QFxItem::inputMethodQuery(Qt::InputMethodQuery query) const +{ + Q_D(const QFxItem); + QVariant v; + if (d->keyHandler) + v = d->keyHandler->inputMethodQuery(query); + + if (!v.isValid()) + v = QGraphicsObject::inputMethodQuery(query); + + return v; +} + /*! \qmlproperty string Item::id This property holds the identifier for the item. diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index 5b95478..643987d 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -181,6 +181,8 @@ protected: virtual void activeFocusChanged(bool); virtual void keyPressEvent(QKeyEvent *event); virtual void keyReleaseEvent(QKeyEvent *event); + virtual void inputMethodEvent(QInputMethodEvent *); + virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const; virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); diff --git a/src/declarative/fx/qfxkeyproxy.cpp b/src/declarative/fx/qfxkeyproxy.cpp deleted file mode 100644 index b22d686..0000000 --- a/src/declarative/fx/qfxkeyproxy.cpp +++ /dev/null @@ -1,212 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qfxkeyproxy.h" -#include <QGraphicsScene> -#include <QKeyEvent> - -QT_BEGIN_NAMESPACE - -QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,KeyProxy,QFxKeyProxy) - -/*! - \qmlclass KeyProxy - \brief The KeyProxy item proxies key events to a number of other items. - \inherits Item - - KeyProxy provides a way to forward key presses, key releases, and keyboard input - coming from input methods to other items. This can be useful when you want - one item to handle some keys (e.g. the up and down arrow keys), and another item to - handle other keys (e.g. the left and right arrow keys). - - To receive key events, the KeyProxy item must be in the current focus chain, - just like any other item. - - KeyProxy is an invisible item: it is never painted. - - A simple KeyProxy that forward key events to two lists: - \qml - ListView { id: List1 ... } - ListView { id: List2 ... } - KeyProxy { - focus: true - targets: [List1, List2] - } - \endqml -*/ - -/*! - \internal - \class QFxKeyProxy - \brief The QFxKeyProxy class proxies key events to a number of other items. -*/ - -class QFxKeyProxyPrivate -{ -public: - QFxKeyProxyPrivate() : inPress(false), inRelease(false), inIM(false), imeItem(0) {} - QList<QFxItem *> targets; - - QGraphicsItem *finalFocusProxy(QGraphicsItem *item) - { - QGraphicsItem *fp; - while ((fp = item->focusProxy())) - item = fp; - return item; - } - - //loop detection - bool inPress:1; - bool inRelease:1; - bool inIM:1; - - QGraphicsItem *imeItem; -}; - -QFxKeyProxy::QFxKeyProxy(QFxItem *parent) -: QFxItem(parent), d(new QFxKeyProxyPrivate) -{ - setFlag(QGraphicsItem::ItemAcceptsInputMethod); -} - -QFxKeyProxy::~QFxKeyProxy() -{ - delete d; d = 0; -} - -/*! - \qmlproperty list<Item> KeyProxy::targets - - An ordered list of the items that will be forwarded key events. - - The events will be forwarded to the targets in turn until one of them - accepts the event. -*/ - -QList<QFxItem *> *QFxKeyProxy::targets() const -{ - return &d->targets; -} - -void QFxKeyProxy::keyPressEvent(QKeyEvent *e) -{ - if (!scene()) - return; - if (!d->inPress) { - d->inPress = true; - for (int ii = 0; ii < d->targets.count(); ++ii) { - QGraphicsItem *i = d->finalFocusProxy(d->targets.at(ii)); - if (i) { - scene()->sendEvent(i, e); - if (e->isAccepted()) { - d->inPress = false; - return; - } - } - } - d->inPress = false; - } -} - -void QFxKeyProxy::keyReleaseEvent(QKeyEvent *e) -{ - if (!scene()) - return; - if (!d->inRelease) { - d->inRelease = true; - for (int ii = 0; ii < d->targets.count(); ++ii) { - QGraphicsItem *i = d->finalFocusProxy(d->targets.at(ii)); - if (i) { - scene()->sendEvent(i, e); - if (e->isAccepted()) { - d->inRelease = false; - return; - } - } - } - d->inRelease = false; - } -} - -void QFxKeyProxy::inputMethodEvent(QInputMethodEvent *e) -{ - if (!scene()) - return; - if (!d->inIM) { - d->inIM = true; - for (int ii = 0; ii < d->targets.count(); ++ii) { - QGraphicsItem *i = d->finalFocusProxy(d->targets.at(ii)); - if (i && (i->flags() & ItemAcceptsInputMethod)) { - scene()->sendEvent(i, e); - if (e->isAccepted()) { - d->imeItem = i; - d->inIM = false; - return; - } - } - } - d->inIM = false; - } -} - -class QFxItemAccessor : public QGraphicsItem -{ -public: - QVariant doInputMethodQuery(Qt::InputMethodQuery query) const { - return QGraphicsItem::inputMethodQuery(query); - } -}; - -QVariant QFxKeyProxy::inputMethodQuery(Qt::InputMethodQuery query) const -{ - for (int ii = 0; ii < d->targets.count(); ++ii) { - QGraphicsItem *i = d->finalFocusProxy(d->targets.at(ii)); - if (i && (i->flags() & ItemAcceptsInputMethod) && i == d->imeItem) { //### how robust is i == d->imeItem check? - QVariant v = static_cast<QFxItemAccessor *>(i)->doInputMethodQuery(query); - if (v.type() == QVariant::RectF) - v = mapRectFromItem(i, v.toRectF()); //### cost? - return v; - } - } - return QFxItem::inputMethodQuery(query); -} - -QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxkeyproxy.h b/src/declarative/fx/qfxkeyproxy.h deleted file mode 100644 index d5f8c7c..0000000 --- a/src/declarative/fx/qfxkeyproxy.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QFXKEYPROXY_H -#define QFXKEYPROXY_H - -#include <QtDeclarative/qfxitem.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -//### move to Keys attached property as Keys.forwardTo - -class QFxKeyProxyPrivate; -class Q_DECLARATIVE_EXPORT QFxKeyProxy : public QFxItem -{ - Q_OBJECT - Q_PROPERTY(QList<QFxItem *> *targets READ targets) -public: - QFxKeyProxy(QFxItem *parent=0); - virtual ~QFxKeyProxy(); - - QList<QFxItem *> *targets() const; - -protected: - virtual void keyPressEvent(QKeyEvent *); - virtual void keyReleaseEvent(QKeyEvent *); - virtual void inputMethodEvent(QInputMethodEvent *); - virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const; - -private: - Q_DISABLE_COPY(QFxKeyProxy) - QFxKeyProxyPrivate *d; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QFxKeyProxy) - -QT_END_HEADER - -#endif // QFXKEYPROXY_H diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp index 523786f..c24610f 100644 --- a/src/declarative/fx/qfxlistview.cpp +++ b/src/declarative/fx/qfxlistview.cpp @@ -881,6 +881,7 @@ QFxListView::QFxListView(QFxItem *parent) QFxListView::~QFxListView() { Q_D(QFxListView); + d->clear(); if (d->ownModel) delete d->model; } diff --git a/src/declarative/fx/qfxlistview.h b/src/declarative/fx/qfxlistview.h index dbab57b..42ce1a2 100644 --- a/src/declarative/fx/qfxlistview.h +++ b/src/declarative/fx/qfxlistview.h @@ -60,7 +60,6 @@ class Q_DECLARATIVE_EXPORT QFxListView : public QFxFlickable Q_ENUMS(CurrentItemPositioning) Q_PROPERTY(QVariant model READ model WRITE setModel) - Q_CLASSINFO("DefaultProperty", "delegate") Q_PROPERTY(QmlComponent *delegate READ delegate WRITE setDelegate) Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged) Q_PROPERTY(QFxItem *current READ currentItem NOTIFY currentIndexChanged) @@ -75,6 +74,7 @@ class Q_DECLARATIVE_EXPORT QFxListView : public QFxFlickable Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer) Q_PROPERTY(QString sectionExpression READ sectionExpression WRITE setSectionExpression NOTIFY sectionExpressionChanged) Q_PROPERTY(QString currentSection READ currentSection NOTIFY currentSectionChanged) + Q_CLASSINFO("DefaultProperty", "data") public: QFxListView(QFxItem *parent=0); diff --git a/src/declarative/fx/qfxpainteditem.cpp b/src/declarative/fx/qfxpainteditem.cpp index cbd00cf..5471e1b 100644 --- a/src/declarative/fx/qfxpainteditem.cpp +++ b/src/declarative/fx/qfxpainteditem.cpp @@ -175,6 +175,7 @@ QFxPaintedItem::QFxPaintedItem(QFxPaintedItemPrivate &dd, QFxItem *parent) */ QFxPaintedItem::~QFxPaintedItem() { + clearCache(); } /*! diff --git a/src/declarative/fx/qfxpathview.h b/src/declarative/fx/qfxpathview.h index a0ef262..3ee352a 100644 --- a/src/declarative/fx/qfxpathview.h +++ b/src/declarative/fx/qfxpathview.h @@ -66,7 +66,7 @@ class Q_DECLARATIVE_EXPORT QFxPathView : public QFxItem Q_PROPERTY(int count READ count) Q_PROPERTY(QmlComponent *delegate READ delegate WRITE setDelegate) Q_PROPERTY(int pathItemCount READ pathItemCount WRITE setPathItemCount) - Q_CLASSINFO("DefaultProperty", "delegate") + public: QFxPathView(QFxItem *parent=0); virtual ~QFxPathView(); diff --git a/src/declarative/fx/qfxtextinput_p.h b/src/declarative/fx/qfxtextinput_p.h index 22a5306..b533854 100644 --- a/src/declarative/fx/qfxtextinput_p.h +++ b/src/declarative/fx/qfxtextinput_p.h @@ -72,6 +72,7 @@ public: ~QFxTextInputPrivate() { + delete control; } void init(); diff --git a/src/corelib/kernel/qmetaobjectbuilder.cpp b/src/declarative/qml/qmetaobjectbuilder.cpp index 58ee454..58ee454 100644 --- a/src/corelib/kernel/qmetaobjectbuilder.cpp +++ b/src/declarative/qml/qmetaobjectbuilder.cpp diff --git a/src/corelib/kernel/qmetaobjectbuilder_p.h b/src/declarative/qml/qmetaobjectbuilder_p.h index d503163..d503163 100644 --- a/src/corelib/kernel/qmetaobjectbuilder_p.h +++ b/src/declarative/qml/qmetaobjectbuilder_p.h diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri index 9a8d3f2..29d97ba 100644 --- a/src/declarative/qml/qml.pri +++ b/src/declarative/qml/qml.pri @@ -31,7 +31,8 @@ SOURCES += qml/qmlparser.cpp \ qml/qmlbasicscript.cpp \ qml/qmlvaluetype.cpp \ qml/qmlbindingoptimizations.cpp \ - qml/qmlxmlhttprequest.cpp + qml/qmlxmlhttprequest.cpp \ + qml/qmetaobjectbuilder.cpp HEADERS += qml/qmlparser_p.h \ qml/qmlinstruction_p.h \ @@ -79,7 +80,8 @@ HEADERS += qml/qmlparser_p.h \ qml/qpodvector_p.h \ qml/qmlvaluetype_p.h \ qml/qmlbindingoptimizations_p.h \ - qml/qmlxmlhttprequest_p.h + qml/qmlxmlhttprequest_p.h \ + qml/qmetaobjectbuilder_p.h # for qtscript debugger contains(QT_CONFIG, scripttools):QT += scripttools diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index 3d8b2c4..6d3506c 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -144,6 +144,10 @@ QmlEnginePrivate::~QmlEnginePrivate() contextClass = 0; delete objectClass; objectClass = 0; + delete valueTypeClass; + valueTypeClass = 0; + delete typeNameClass; + typeNameClass = 0; delete networkAccessManager; networkAccessManager = 0; delete nodeListClass; @@ -270,14 +274,10 @@ QmlEnginePrivate::queryContext(const QString &propName, uint *id, return rv; } -QScriptValue -QmlEnginePrivate::propertyContext(const QScriptString &name, - QmlContext *bindContext, - uint id) +QScriptValue QmlEnginePrivate::propertyContext(const QScriptString &name, uint id) { Q_ASSERT(id == resolveData.safetyCheckId); - if (resolveData.type || resolveData.ns) { QmlTypeNameBridge tnb = { resolveData.object, @@ -1092,11 +1092,10 @@ QScriptValue QmlContextScriptClass::property(const QScriptValue &object, const QScriptString &name, uint id) { - QmlContext *bindContext = - static_cast<QmlContext*>(object.data().toQObject()); + Q_UNUSED(object); QmlEnginePrivate *ep = QmlEnginePrivate::get(engine); - return ep->propertyContext(name, bindContext, id); + return ep->propertyContext(name, id); } void QmlContextScriptClass::setProperty(QScriptValue &object, @@ -1104,6 +1103,7 @@ void QmlContextScriptClass::setProperty(QScriptValue &object, uint id, const QScriptValue &value) { + Q_UNUSED(object); Q_UNUSED(name); QmlEnginePrivate::get(engine)->setPropertyContext(value, id); @@ -1124,6 +1124,8 @@ QmlTypeNameScriptClass::queryProperty(const QScriptValue &scriptObject, const QScriptString &name, QueryFlags flags, uint *id) { + Q_UNUSED(flags); + QmlTypeNameBridge bridge = qvariant_cast<QmlTypeNameBridge>(scriptObject.data().toVariant()); @@ -1279,7 +1281,7 @@ QScriptValue QmlObjectToString(QScriptContext *context, QScriptEngine *engine) ret += QLatin1String("\""); ret += obj->objectName(); ret += QLatin1String("\" "); - ret += obj->metaObject()->className(); + ret += QLatin1String(obj->metaObject()->className()); ret += QLatin1String("(0x"); ret += QString::number((quintptr)obj,16); ret += QLatin1String(")"); diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h index f492ccb..15ab40d 100644 --- a/src/declarative/qml/qmlengine_p.h +++ b/src/declarative/qml/qmlengine_p.h @@ -100,8 +100,7 @@ public: QScriptClass::QueryFlags queryContext(const QString &name, uint *id, QmlContext *); - QScriptValue propertyContext(const QScriptString &propName, QmlContext *, - uint id); + QScriptValue propertyContext(const QScriptString &propName, uint id); void setPropertyContext(const QScriptValue &, uint id); QScriptClass::QueryFlags queryObject(const QString &name, uint *id, QObject *); diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp index 98c552f..0d9ea94 100644 --- a/src/declarative/util/qmllistmodel.cpp +++ b/src/declarative/util/qmllistmodel.cpp @@ -230,6 +230,7 @@ QmlListModel::QmlListModel(QObject *parent) QmlListModel::~QmlListModel() { + delete _root; } void QmlListModel::checkRoles() const |