From bb8ba98542e1ed363d4218b9a9a4e68a6c4b5337 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 6 Oct 2010 11:26:23 +1000 Subject: Create Loader components in correct context Task-number: QTBUG-13481 --- src/declarative/graphicsitems/qdeclarativeloader.cpp | 4 +++- .../qdeclarativeloader/data/CreationContextLoader.qml | 15 +++++++++++++++ .../qdeclarativeloader/data/creationContext.qml | 8 ++++++++ .../qdeclarativeloader/tst_qdeclarativeloader.cpp | 14 ++++++++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 tests/auto/declarative/qdeclarativeloader/data/CreationContextLoader.qml create mode 100644 tests/auto/declarative/qdeclarativeloader/data/creationContext.qml diff --git a/src/declarative/graphicsitems/qdeclarativeloader.cpp b/src/declarative/graphicsitems/qdeclarativeloader.cpp index 1066c2b..5647b14 100644 --- a/src/declarative/graphicsitems/qdeclarativeloader.cpp +++ b/src/declarative/graphicsitems/qdeclarativeloader.cpp @@ -337,7 +337,9 @@ void QDeclarativeLoaderPrivate::_q_sourceLoaded() return; } - QDeclarativeContext *ctxt = new QDeclarativeContext(qmlContext(q)); + QDeclarativeContext *creationContext = component->creationContext(); + if (!creationContext) creationContext = qmlContext(q); + QDeclarativeContext *ctxt = new QDeclarativeContext(creationContext); ctxt->setContextObject(q); QDeclarativeComponent *c = component; diff --git a/tests/auto/declarative/qdeclarativeloader/data/CreationContextLoader.qml b/tests/auto/declarative/qdeclarativeloader/data/CreationContextLoader.qml new file mode 100644 index 0000000..bfc9a8d --- /dev/null +++ b/tests/auto/declarative/qdeclarativeloader/data/CreationContextLoader.qml @@ -0,0 +1,15 @@ +import QtQuick 1.0 + +Loader { + id: myLoader + property int testProperty: 1912 + sourceComponent: loaderComponent + Component { + id: loaderComponent + Item { + Component.onCompleted: { + test = (myLoader.testProperty == 1912); + } + } + } +} diff --git a/tests/auto/declarative/qdeclarativeloader/data/creationContext.qml b/tests/auto/declarative/qdeclarativeloader/data/creationContext.qml new file mode 100644 index 0000000..5297978 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeloader/data/creationContext.qml @@ -0,0 +1,8 @@ +import QtQuick 1.0 + +Item { + property bool test: false + + CreationContextLoader { + } +} diff --git a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp index 8d04616..1bde55b 100644 --- a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp +++ b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp @@ -89,6 +89,7 @@ private slots: void deleteComponentCrash(); void nonItem(); void vmeErrors(); + void creationContext(); private: QDeclarativeEngine engine; @@ -562,6 +563,19 @@ void tst_QDeclarativeLoader::vmeErrors() delete loader; } +// QTBUG-13481 +void tst_QDeclarativeLoader::creationContext() +{ + QDeclarativeComponent component(&engine, TEST_FILE("creationContext.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test").toBool(), true); + + delete o; +} + QTEST_MAIN(tst_QDeclarativeLoader) #include "tst_qdeclarativeloader.moc" -- cgit v0.12 From 0030599cbe39c9fc7d6f2632b4e66a54b1b46417 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 6 Oct 2010 13:59:19 +1000 Subject: Ensure PathView updates positions when path changes. Fixes regression caused by optimization added in commit 35a51442ed21f58c06b21293eeb56e843251ee82. Task-number: QTBUG-14239 Reviewed-by: Martin Jones --- src/declarative/graphicsitems/qdeclarativepathview.cpp | 17 +++++++++++++++-- src/declarative/graphicsitems/qdeclarativepathview_p.h | 1 + .../qdeclarativepathview/data/pathUpdate.qml | 18 ++++++++++++++++++ .../qdeclarativepathview/tst_qdeclarativepathview.cpp | 18 ++++++++++++++++++ 4 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativepathview/data/pathUpdate.qml diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp index d134929..3ae8788 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview.cpp +++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp @@ -300,6 +300,19 @@ void QDeclarativePathViewPrivate::setHighlightPosition(qreal pos) } } +void QDeclarativePathView::pathUpdated() +{ + Q_D(QDeclarativePathView); + QList::iterator it = d->items.begin(); + while (it != d->items.end()) { + QDeclarativeItem *item = *it; + if (QDeclarativePathViewAttached *att = d->attached(item)) + att->m_percent = -1; + ++it; + } + refill(); +} + void QDeclarativePathViewPrivate::updateItem(QDeclarativeItem *item, qreal percent) { if (QDeclarativePathViewAttached *att = attached(item)) { @@ -526,9 +539,9 @@ void QDeclarativePathView::setPath(QDeclarativePath *path) if (d->path == path) return; if (d->path) - disconnect(d->path, SIGNAL(changed()), this, SLOT(refill())); + disconnect(d->path, SIGNAL(changed()), this, SLOT(pathUpdated())); d->path = path; - connect(d->path, SIGNAL(changed()), this, SLOT(refill())); + connect(d->path, SIGNAL(changed()), this, SLOT(pathUpdated())); if (d->isValid() && isComponentComplete()) { d->clear(); if (d->attType) { diff --git a/src/declarative/graphicsitems/qdeclarativepathview_p.h b/src/declarative/graphicsitems/qdeclarativepathview_p.h index 62a8c44..7775b1c 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview_p.h +++ b/src/declarative/graphicsitems/qdeclarativepathview_p.h @@ -186,6 +186,7 @@ private Q_SLOTS: void modelReset(); void createdItem(int index, QDeclarativeItem *item); void destroyingItem(QDeclarativeItem *item); + void pathUpdated(); private: friend class QDeclarativePathViewAttached; diff --git a/tests/auto/declarative/qdeclarativepathview/data/pathUpdate.qml b/tests/auto/declarative/qdeclarativepathview/data/pathUpdate.qml new file mode 100644 index 0000000..0c99e7f --- /dev/null +++ b/tests/auto/declarative/qdeclarativepathview/data/pathUpdate.qml @@ -0,0 +1,18 @@ +import Qt 4.7 + +Rectangle { + width: 400 + height: 400 + + PathView { + id: view + objectName: "pathView" + anchors.fill: parent + model: 10 + delegate: Rectangle { objectName: "wrapper"; color: "green"; width: 100; height: 100 } + path: Path { + startX: view.width/2; startY: 0 + PathLine { x: view.width/2; y: view.height } + } + } +} diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp index 65007a6..3a2a577 100644 --- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp +++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp @@ -86,6 +86,7 @@ private slots: void package(); void emptyModel(); void closed(); + void pathUpdate(); private: QDeclarativeView *createView(); @@ -808,6 +809,23 @@ void tst_QDeclarativePathView::closed() } } +// QTBUG-14239 +void tst_QDeclarativePathView::pathUpdate() +{ + QDeclarativeView *canvas = createView(); + QVERIFY(canvas); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathUpdate.qml")); + + QDeclarativePathView *pathView = canvas->rootObject()->findChild("pathView"); + QVERIFY(pathView); + + QDeclarativeItem *item = findItem(pathView, "wrapper", 0); + QVERIFY(item); + QCOMPARE(item->x(), 150.0); + + delete canvas; +} + QDeclarativeView *tst_QDeclarativePathView::createView() { QDeclarativeView *canvas = new QDeclarativeView(0); -- cgit v0.12 From 4647f24469ec93b3b66628472af5462fbe957439 Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Wed, 6 Oct 2010 12:41:16 +1000 Subject: Update QtGui def files --- src/s60installs/bwins/QtGuiu.def | 5 ++++- src/s60installs/eabi/QtGuiu.def | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/s60installs/bwins/QtGuiu.def b/src/s60installs/bwins/QtGuiu.def index 9a61523..7cc2752 100644 --- a/src/s60installs/bwins/QtGuiu.def +++ b/src/s60installs/bwins/QtGuiu.def @@ -12892,5 +12892,8 @@ EXPORTS ?setTimeout@QTapAndHoldGesture@@SAXH@Z @ 12891 NONAME ; void QTapAndHoldGesture::setTimeout(int) ?qmljsDebugArguments@QApplicationPrivate@@2VQString@@A @ 12892 NONAME ; class QString QApplicationPrivate::qmljsDebugArguments ?effectiveBoundingRect@QGraphicsItemPrivate@@QBE?AVQRectF@@PAVQGraphicsItem@@@Z @ 12893 NONAME ; class QRectF QGraphicsItemPrivate::effectiveBoundingRect(class QGraphicsItem *) const - ?lastResortFont@QFont@@QBE?AVQString@@XZ @ 12894 NONAME ; class QString QFont::lastResortFont(void) const + ?maxTextureHeight@QTextureGlyphCache@@UBEHXZ @ 12894 NONAME ; int QTextureGlyphCache::maxTextureHeight(void) const + ?maxTextureWidth@QTextureGlyphCache@@UBEHXZ @ 12895 NONAME ; int QTextureGlyphCache::maxTextureWidth(void) const + ?convertToPostscriptFontFamilyName@QFontEngine@@SA?AVQByteArray@@ABV2@@Z @ 12896 NONAME ; class QByteArray QFontEngine::convertToPostscriptFontFamilyName(class QByteArray const &) + ?lastResortFont@QFont@@QBE?AVQString@@XZ @ 12897 NONAME ; class QString QFont::lastResortFont(void) const diff --git a/src/s60installs/eabi/QtGuiu.def b/src/s60installs/eabi/QtGuiu.def index 634b7af..4e867a3 100644 --- a/src/s60installs/eabi/QtGuiu.def +++ b/src/s60installs/eabi/QtGuiu.def @@ -12098,4 +12098,5 @@ EXPORTS _ZN20QGraphicsItemPrivate26childrenBoundingRectHelperEP10QTransformP6QRectFP13QGraphicsItem @ 12097 NONAME _ZNK20QGraphicsItemPrivate21effectiveBoundingRectEP13QGraphicsItem @ 12098 NONAME _ZNK5QFont14lastResortFontEv @ 12099 NONAME + _ZN11QFontEngine33convertToPostscriptFontFamilyNameERK10QByteArray @ 12100 NONAME -- cgit v0.12 From 695b54e671b55bd8103dee8b30ee76309dbd26c1 Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Wed, 6 Oct 2010 14:01:56 +1000 Subject: Fix minehunt execution from QtDemo Task-number: QTBUG-14250 Reviewed-by: Martin Jones --- demos/declarative/minehunt/main.cpp | 2 +- demos/declarative/minehunt/minehunt.pro | 1 + demos/declarative/minehunt/minehunt.qrc | 20 ++++++++++++++++++++ demos/qtdemo/menumanager.cpp | 1 + demos/qtdemo/xml/examples.xml | 2 +- 5 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 demos/declarative/minehunt/minehunt.qrc diff --git a/demos/declarative/minehunt/main.cpp b/demos/declarative/minehunt/main.cpp index 8bbaee9..2b286ef 100644 --- a/demos/declarative/minehunt/main.cpp +++ b/demos/declarative/minehunt/main.cpp @@ -58,7 +58,7 @@ int main(int argc, char *argv[]) canvas.setResizeMode(QDeclarativeView::SizeRootObjectToView); #endif canvas.engine()->rootContext()->setContextObject(game); - canvas.setSource(QString("minehunt.qml")); + canvas.setSource(QString("qrc:minehunt.qml")); QObject::connect(canvas.engine(), SIGNAL(quit()), &app, SLOT(quit())); #ifdef Q_OS_SYMBIAN diff --git a/demos/declarative/minehunt/minehunt.pro b/demos/declarative/minehunt/minehunt.pro index 7a491ab..753ca4e 100644 --- a/demos/declarative/minehunt/minehunt.pro +++ b/demos/declarative/minehunt/minehunt.pro @@ -6,6 +6,7 @@ CONFIG += qt plugin # Input HEADERS += minehunt.h SOURCES += main.cpp minehunt.cpp +RESOURCES = minehunt.qrc sources.files = minehunt.qml minehunt.pro MinehuntCore sources.path = $$[QT_INSTALL_DEMOS]/declarative/minehunt diff --git a/demos/declarative/minehunt/minehunt.qrc b/demos/declarative/minehunt/minehunt.qrc new file mode 100644 index 0000000..fa8e27d --- /dev/null +++ b/demos/declarative/minehunt/minehunt.qrc @@ -0,0 +1,20 @@ + + + minehunt.qml + MinehuntCore/Explosion.qml + MinehuntCore/Tile.qml + MinehuntCore/qmldir + MinehuntCore/pics/background.png + MinehuntCore/pics/back.png + MinehuntCore/pics/bomb-color.png + MinehuntCore/pics/bomb.png + MinehuntCore/pics/face-sad.png + MinehuntCore/pics/face-smile-big.png + MinehuntCore/pics/face-smile.png + MinehuntCore/pics/flag-color.png + MinehuntCore/pics/flag.png + MinehuntCore/pics/front.png + MinehuntCore/pics/quit.png + MinehuntCore/pics/star.png + + diff --git a/demos/qtdemo/menumanager.cpp b/demos/qtdemo/menumanager.cpp index fe3c5aa..ea9146e 100644 --- a/demos/qtdemo/menumanager.cpp +++ b/demos/qtdemo/menumanager.cpp @@ -518,6 +518,7 @@ QString MenuManager::resolveExeFile(const QString &name) dir.cd(dirName); dir.cd(fileName); + fileName = fileName.split("/").last(); QFile unixFile(dir.path() + "/" + fileName); if (unixFile.exists()) return unixFile.fileName(); QFile winR(dir.path() + "\\release\\" + fileName + ".exe"); diff --git a/demos/qtdemo/xml/examples.xml b/demos/qtdemo/xml/examples.xml index 0ab048e..27f72bb 100644 --- a/demos/qtdemo/xml/examples.xml +++ b/demos/qtdemo/xml/examples.xml @@ -18,7 +18,7 @@ - + -- cgit v0.12 From cd4389efee184d2ad65b52c5ef64793868f1a004 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 6 Oct 2010 15:12:46 +1000 Subject: Ensure the TextInput cursor blinks immediately when enabled. Previously we relied on cursorPosChanged being called to do the update, but that isn't called in all circumstances. Now we explicitly update when the cursor is enabled or disabled. Task-number: QTBUG-13993 --- src/declarative/graphicsitems/qdeclarativetextinput.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index 4817999..637dd77 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -417,7 +417,11 @@ void QDeclarativeTextInput::setCursorVisible(bool on) return; d->cursorVisible = on; d->control->setCursorBlinkPeriod(on?QApplication::cursorFlashTime():0); - //d->control should emit the cursor update regions + QRect r = d->control->cursorRect(); + if (d->control->inputMask().isEmpty()) + updateRect(r); + else + updateRect(); emit cursorVisibleChanged(d->cursorVisible); } -- cgit v0.12 From 8209815ee6eea3cbc1ca7b71ce8b68ae8930c0bd Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 6 Oct 2010 15:38:39 +1000 Subject: Autotest Task-number: QTBUG-14089 --- .../data/aliasPropertyChangeSignals.qml | 16 ++++++++++++++++ .../qdeclarativelanguage/tst_qdeclarativelanguage.cpp | 15 +++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 tests/auto/declarative/qdeclarativelanguage/data/aliasPropertyChangeSignals.qml diff --git a/tests/auto/declarative/qdeclarativelanguage/data/aliasPropertyChangeSignals.qml b/tests/auto/declarative/qdeclarativelanguage/data/aliasPropertyChangeSignals.qml new file mode 100644 index 0000000..7944deb --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/aliasPropertyChangeSignals.qml @@ -0,0 +1,16 @@ +import QtQuick 1.0 + +QtObject { + id: root + + property alias aliasProperty: root.realProperty + onAliasPropertyChanged: root.test = true + + property int realProperty: 0 + + property bool test: false + + Component.onCompleted: { + root.realProperty = 10; + } +} diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index 8609a7e..3c82fc5 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -119,6 +119,7 @@ private slots: void cppnamespace(); void aliasProperties(); void aliasPropertiesAndSignals(); + void aliasPropertyChangeSignals(); void componentCompositeType(); void i18n(); void i18n_data(); @@ -1816,6 +1817,20 @@ void tst_qdeclarativelanguage::initTestCase() out.write(in.readAll()); } +void tst_qdeclarativelanguage::aliasPropertyChangeSignals() +{ + QDeclarativeComponent component(&engine, TEST_FILE("aliasPropertyChangeSignals.qml")); + + VERIFY_ERRORS(0); + QObject *o = component.create(); + QVERIFY(o != 0); + + QEXPECT_FAIL("", "QTBUG-14089", Abort); + QCOMPARE(o->property("test").toBool(), true); + + delete o; +} + QTEST_MAIN(tst_qdeclarativelanguage) #include "tst_qdeclarativelanguage.moc" -- cgit v0.12 From 9d2078629b54a44defda7fa491824df437ffea11 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 6 Oct 2010 17:43:22 +1000 Subject: Allow default QApplication::startDragDistance() to be defined in platformdefs.h Task-number: QT-3930 Reviewed-by: Joona Petrell --- src/gui/kernel/qapplication.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index fdacefc..3323fbc 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -477,11 +477,14 @@ bool Q_GUI_EXPORT qt_tab_all_widgets = true; bool qt_in_tab_key_event = false; int qt_antialiasing_threshold = -1; static int drag_time = 500; +#ifndef QT_GUI_DRAG_DISTANCE +#define QT_GUI_DRAG_DISTANCE 4 +#endif #ifdef Q_OS_SYMBIAN // The screens are a bit too small to for your thumb when using only 4 pixels drag distance. -static int drag_distance = 12; +static int drag_distance = 12; //XXX move to qplatformdefs.h #else -static int drag_distance = 4; +static int drag_distance = QT_GUI_DRAG_DISTANCE; #endif static Qt::LayoutDirection layout_direction = Qt::LeftToRight; QSize QApplicationPrivate::app_strut = QSize(0,0); // no default application strut -- cgit v0.12 From 7d79beeb4c88d4e5fb8d7aecd8dd07419b465f55 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 6 Oct 2010 17:55:15 +1000 Subject: Set reasonable QT_GUI_DRAG_DISTANCE in mkspecs/linux-g++-maemo/qplatformdefs.h Task-number: QT-3930 --- mkspecs/linux-g++-maemo/qplatformdefs.h | 1 + 1 file changed, 1 insertion(+) diff --git a/mkspecs/linux-g++-maemo/qplatformdefs.h b/mkspecs/linux-g++-maemo/qplatformdefs.h index d7feb9e..df6152a 100644 --- a/mkspecs/linux-g++-maemo/qplatformdefs.h +++ b/mkspecs/linux-g++-maemo/qplatformdefs.h @@ -42,3 +42,4 @@ #include "../linux-g++/qplatformdefs.h" #define QT_GUI_DOUBLE_CLICK_RADIUS 20 +#define QT_GUI_DRAG_DISTANCE 16 -- cgit v0.12 From 651135cf53aacc4f580cc382b8192bd313366ed8 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Wed, 6 Oct 2010 18:52:44 +1000 Subject: Do not show 'More' button when in fullscreen view. Task-number: QTBUG-11813 --- demos/declarative/flickr/mobile/ImageDetails.qml | 2 ++ demos/declarative/flickr/mobile/ToolBar.qml | 22 +++++++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/demos/declarative/flickr/mobile/ImageDetails.qml b/demos/declarative/flickr/mobile/ImageDetails.qml index 5dd3b4e..9d1464e 100644 --- a/demos/declarative/flickr/mobile/ImageDetails.qml +++ b/demos/declarative/flickr/mobile/ImageDetails.qml @@ -172,6 +172,8 @@ Flipable { states: State { name: "Back" PropertyChanges { target: itemRotation; angle: 180 } + PropertyChanges { target: toolBar; button2Visible: false } + PropertyChanges { target: toolBar; button1Label: "Back" } } transitions: Transition { diff --git a/demos/declarative/flickr/mobile/ToolBar.qml b/demos/declarative/flickr/mobile/ToolBar.qml index 55f19d2..d8abb14 100644 --- a/demos/declarative/flickr/mobile/ToolBar.qml +++ b/demos/declarative/flickr/mobile/ToolBar.qml @@ -46,20 +46,24 @@ Item { property alias button1Label: button1.text property alias button2Label: button2.text + property alias button2Visible: button2.visible + signal button1Clicked signal button2Clicked BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 } - Button { - id: button1 - anchors.left: parent.left; anchors.leftMargin: 5; y: 3; width: 140; height: 32 - onClicked: toolbar.button1Clicked() - } + Row { + anchors.right: parent.right; anchors.rightMargin: 5; y: 3; height: 32; spacing: 30 + Button { + id: button1 + width: 140; height: 32 + onClicked: toolbar.button1Clicked() + } - Button { - id: button2 - anchors.right: parent.right; anchors.rightMargin: 5; y: 3; width: 140; height: 32 - onClicked: toolbar.button2Clicked() + Button { + id: button2; width: 140; height: 32 + onClicked: toolbar.button2Clicked() + } } } -- cgit v0.12 From f532679ca11914b453e22342f2ae5e9f790ce47a Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Wed, 6 Oct 2010 11:48:24 +0200 Subject: Fixes assert in QDeclarativeWebView If QDeclarativeWebView was instantiated twice an assert was triggered by QWebSettings::enablePersistentStorage(); This patch is crtical for tooling (Bauhaus) Task-number: QTBUG-14278 Reviewed-by: Aaron Kennedy --- src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp b/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp index 94f08bd..e4f70de 100644 --- a/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp +++ b/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp @@ -249,7 +249,11 @@ void QDeclarativeWebView::init() { d = new QDeclarativeWebViewPrivate(this); - QWebSettings::enablePersistentStorage(); + if (QWebSettings::iconDatabasePath().isNull() && + QWebSettings::globalSettings()->localStoragePath().isNull() && + QWebSettings::offlineStoragePath().isNull() && + QWebSettings::offlineWebApplicationCachePath().isNull()) + QWebSettings::enablePersistentStorage(); setAcceptedMouseButtons(Qt::LeftButton); setFlag(QGraphicsItem::ItemHasNoContents, true); -- cgit v0.12 From 9d574d9c6bed5b4528415402a9f2f68ab5de8009 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 7 Oct 2010 08:30:18 +1000 Subject: Update import statement. --- tests/auto/declarative/qdeclarativepathview/data/pathUpdate.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/declarative/qdeclarativepathview/data/pathUpdate.qml b/tests/auto/declarative/qdeclarativepathview/data/pathUpdate.qml index 0c99e7f..0c2ac0c 100644 --- a/tests/auto/declarative/qdeclarativepathview/data/pathUpdate.qml +++ b/tests/auto/declarative/qdeclarativepathview/data/pathUpdate.qml @@ -1,4 +1,4 @@ -import Qt 4.7 +import QtQuick 1.0 Rectangle { width: 400 -- cgit v0.12 From d97692f1eb18cb85830493be2e8d22fc00a85edf Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Thu, 7 Oct 2010 09:39:28 +1000 Subject: Rename toolbar button. Task-number: QT-3637 --- demos/declarative/flickr/flickr.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/declarative/flickr/flickr.qml b/demos/declarative/flickr/flickr.qml index 1533c04..740ee35 100644 --- a/demos/declarative/flickr/flickr.qml +++ b/demos/declarative/flickr/flickr.qml @@ -109,7 +109,7 @@ Item { states: State { name: "DetailedView" PropertyChanges { target: views; x: -parent.width } - PropertyChanges { target: toolBar; button1Label: "More..." } + PropertyChanges { target: toolBar; button1Label: "View..." } PropertyChanges { target: toolBar onButton1Clicked: if (imageDetails.state=='') imageDetails.state='Back'; else imageDetails.state='' -- cgit v0.12 From 0ed462973acc683882ac30ae6959340564f305a3 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 7 Oct 2010 10:37:50 +1000 Subject: Fix setting PathView offset when all visible items are removed. If we remove all items then we don't have a valid firstIndex with which to anchor item positions, so just use offset. Task-number: QTBUG-14199 Reviewed-by: Michael Brasser --- src/declarative/graphicsitems/qdeclarativepathview.cpp | 2 ++ .../qdeclarativepathview/tst_qdeclarativepathview.cpp | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp index 3ae8788..31943b2 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview.cpp +++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp @@ -1331,6 +1331,8 @@ void QDeclarativePathView::refill() if (idx >= d->modelCount) idx = 0; } + if (!d->items.count()) + d->firstIndex = -1; if (d->modelCount) { // add items to beginning and end diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp index 3a2a577..a2a5363 100644 --- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp +++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp @@ -351,6 +351,10 @@ void tst_QDeclarativePathView::dataModel() model.addItem("yellow", "7"); model.addItem("thistle", "8"); model.addItem("cyan", "9"); + model.addItem("peachpuff", "10"); + model.addItem("powderblue", "11"); + model.addItem("gold", "12"); + model.addItem("sandybrown", "13"); ctxt->setContextProperty("testData", &model); @@ -371,7 +375,7 @@ void tst_QDeclarativePathView::dataModel() model.insertItem(4, "orange", "10"); QTest::qWait(100); - QTRY_COMPARE(findItems(pathview, "wrapper").count(), 10); + QTRY_COMPARE(findItems(pathview, "wrapper").count(), 14); QVERIFY(pathview->currentIndex() == 0); @@ -420,6 +424,11 @@ void tst_QDeclarativePathView::dataModel() QVERIFY(item->property("onPath").toBool()); } + // QTBUG-14199 + pathview->setOffset(7); + pathview->setOffset(0); + QCOMPARE(findItems(pathview, "wrapper").count(), 5); + delete canvas; } -- cgit v0.12 From 591695490b9ed7f1cd31e03e067a5962d6aadcee Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 7 Oct 2010 10:50:54 +1000 Subject: Doc fix. --- src/declarative/graphicsitems/qdeclarativerepeater.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativerepeater.cpp b/src/declarative/graphicsitems/qdeclarativerepeater.cpp index 00f2848..cb64212 100644 --- a/src/declarative/graphicsitems/qdeclarativerepeater.cpp +++ b/src/declarative/graphicsitems/qdeclarativerepeater.cpp @@ -134,13 +134,13 @@ QDeclarativeRepeaterPrivate::~QDeclarativeRepeaterPrivate() create items as they are required. Also, note that Repeater is \l {Item}-based, and can only repeat \l {Item}-derived objects. - For example, it cannot be used to repeat QObjects: + For example, it cannot be used to repeat QtObjects: \badcode Item { - //XXX does not work! Can't repeat QObject as it doesn't derive from Item. + //XXX does not work! Can't repeat QtObject as it doesn't derive from Item. Repeater { model: 10 - QObject {} + QtObject {} } } \endcode -- cgit v0.12 From 803bdd187ec1673541b7ef8dc69652c10d0e6f88 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 7 Oct 2010 17:42:08 +1000 Subject: Connect property alias change signals on use Task-number: QTBUG-14089 --- src/declarative/qml/qdeclarativeboundsignal.cpp | 4 +- src/declarative/qml/qdeclarativecompiler.cpp | 6 ++- src/declarative/qml/qdeclarativenotifier.cpp | 16 +++++++ src/declarative/qml/qdeclarativenotifier_p.h | 17 +------ src/declarative/qml/qdeclarativeproperty.cpp | 56 +++++++++++++++++++++- src/declarative/qml/qdeclarativeproperty_p.h | 3 ++ src/declarative/qml/qdeclarativepropertycache.cpp | 19 +++++++- src/declarative/qml/qdeclarativepropertycache_p.h | 9 ++-- .../qml/qdeclarativeproxymetaobject.cpp | 4 +- src/declarative/qml/qdeclarativevme.cpp | 2 +- src/declarative/qml/qdeclarativevmemetaobject.cpp | 48 ++++++++++++++----- src/declarative/qml/qdeclarativevmemetaobject_p.h | 2 + src/declarative/qml/qdeclarativewatcher.cpp | 3 +- .../tst_qdeclarativelanguage.cpp | 1 - 14 files changed, 147 insertions(+), 43 deletions(-) diff --git a/src/declarative/qml/qdeclarativeboundsignal.cpp b/src/declarative/qml/qdeclarativeboundsignal.cpp index 8769122..6af3e05 100644 --- a/src/declarative/qml/qdeclarativeboundsignal.cpp +++ b/src/declarative/qml/qdeclarativeboundsignal.cpp @@ -103,7 +103,7 @@ QDeclarativeBoundSignal::QDeclarativeBoundSignal(QObject *scope, const QMetaMeth if (evaluateIdx == -1) evaluateIdx = metaObject()->methodCount(); QDeclarative_setParent_noEvent(this, parent); - QMetaObject::connect(scope, m_signal.methodIndex(), this, evaluateIdx); + QDeclarativePropertyPrivate::connect(scope, m_signal.methodIndex(), this, evaluateIdx); } QDeclarativeBoundSignal::QDeclarativeBoundSignal(QDeclarativeContext *ctxt, const QString &val, @@ -117,7 +117,7 @@ QDeclarativeBoundSignal::QDeclarativeBoundSignal(QDeclarativeContext *ctxt, cons if (evaluateIdx == -1) evaluateIdx = metaObject()->methodCount(); QDeclarative_setParent_noEvent(this, parent); - QMetaObject::connect(scope, m_signal.methodIndex(), this, evaluateIdx); + QDeclarativePropertyPrivate::connect(scope, m_signal.methodIndex(), this, evaluateIdx); m_expression = new QDeclarativeExpression(ctxt, scope, val); } diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp index 90d38b3..dc28e22 100644 --- a/src/declarative/qml/qdeclarativecompiler.cpp +++ b/src/declarative/qml/qdeclarativecompiler.cpp @@ -945,7 +945,8 @@ void QDeclarativeCompiler::genObject(QDeclarativeParser::Object *obj) propertyCache = enginePrivate->cache(obj->metaObject()->superClass())->copy(); propertyCache->append(engine, obj->metaObject(), QDeclarativePropertyCache::Data::NoFlags, - QDeclarativePropertyCache::Data::IsVMEFunction); + QDeclarativePropertyCache::Data::IsVMEFunction, + QDeclarativePropertyCache::Data::IsVMESignal); if (obj == unitRoot) { propertyCache->addref(); @@ -1098,7 +1099,8 @@ void QDeclarativeCompiler::genObjectBody(QDeclarativeParser::Object *obj) QDeclarativePropertyCache *propertyCache = enginePrivate->cache(prop->value->metaObject()->superClass())->copy(); propertyCache->append(engine, prop->value->metaObject(), QDeclarativePropertyCache::Data::NoFlags, - QDeclarativePropertyCache::Data::IsVMEFunction); + QDeclarativePropertyCache::Data::IsVMEFunction, + QDeclarativePropertyCache::Data::IsVMESignal); output->propertyCaches << propertyCache; output->bytecode << meta; diff --git a/src/declarative/qml/qdeclarativenotifier.cpp b/src/declarative/qml/qdeclarativenotifier.cpp index 8c946f8..2e3f756 100644 --- a/src/declarative/qml/qdeclarativenotifier.cpp +++ b/src/declarative/qml/qdeclarativenotifier.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "private/qdeclarativenotifier_p.h" +#include "private/qdeclarativeproperty_p.h" QT_BEGIN_NAMESPACE @@ -66,6 +67,21 @@ void QDeclarativeNotifier::emitNotify(QDeclarativeNotifierEndpoint *endpoint) if (oldDisconnected) *oldDisconnected = endpoint; } +void QDeclarativeNotifierEndpoint::connect(QObject *source, int sourceSignal) +{ + Signal *s = toSignal(); + + if (s->source == source && s->sourceSignal == sourceSignal) + return; + + disconnect(); + + QDeclarativePropertyPrivate::connect(source, sourceSignal, target, targetMethod); + + s->source = source; + s->sourceSignal = sourceSignal; +} + void QDeclarativeNotifierEndpoint::copyAndClear(QDeclarativeNotifierEndpoint &other) { other.disconnect(); diff --git a/src/declarative/qml/qdeclarativenotifier_p.h b/src/declarative/qml/qdeclarativenotifier_p.h index 0781caf..ad04ba8 100644 --- a/src/declarative/qml/qdeclarativenotifier_p.h +++ b/src/declarative/qml/qdeclarativenotifier_p.h @@ -75,7 +75,7 @@ public: inline bool isConnected(QObject *source, int sourceSignal); inline bool isConnected(QDeclarativeNotifier *); - inline void connect(QObject *source, int sourceSignal); + void connect(QObject *source, int sourceSignal); inline void connect(QDeclarativeNotifier *); inline void disconnect(); @@ -175,21 +175,6 @@ bool QDeclarativeNotifierEndpoint::isConnected(QDeclarativeNotifier *notifier) return NotifierType == type && asNotifier()->notifier == notifier; } -void QDeclarativeNotifierEndpoint::connect(QObject *source, int sourceSignal) -{ - Signal *s = toSignal(); - - if (s->source == source && s->sourceSignal == sourceSignal) - return; - - disconnect(); - - QMetaObject::connect(source, sourceSignal, target, targetMethod); - - s->source = source; - s->sourceSignal = sourceSignal; -} - void QDeclarativeNotifierEndpoint::connect(QDeclarativeNotifier *notifier) { Notifier *n = toNotifier(); diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp index bc20bff..b5fb619 100644 --- a/src/declarative/qml/qdeclarativeproperty.cpp +++ b/src/declarative/qml/qdeclarativeproperty.cpp @@ -53,6 +53,7 @@ #include "private/qdeclarativestringconverters_p.h" #include "private/qdeclarativelist_p.h" #include "private/qdeclarativecompiler_p.h" +#include "private/qdeclarativevmemetaobject_p.h" #include #include @@ -1212,7 +1213,7 @@ bool QDeclarativeProperty::connectNotifySignal(QObject *dest, int method) const QMetaProperty prop = d->object->metaObject()->property(d->core.coreIndex); if (prop.hasNotifySignal()) { - return QMetaObject::connect(d->object, prop.notifySignalIndex(), dest, method, Qt::DirectConnection); + return QDeclarativePropertyPrivate::connect(d->object, prop.notifySignalIndex(), dest, method, Qt::DirectConnection); } else { return false; } @@ -1383,4 +1384,57 @@ QMetaMethod QDeclarativePropertyPrivate::findSignalByName(const QMetaObject *mo, return QMetaMethod(); } +static inline int QMetaObject_methods(const QMetaObject *metaObject) +{ + struct Private + { + int revision; + int className; + int classInfoCount, classInfoData; + int methodCount, methodData; + }; + + return reinterpret_cast(metaObject->d.data)->methodCount; +} + +static inline void flush_vme_signal(const QObject *object, int index) +{ + QDeclarativeData *data = static_cast(QObjectPrivate::get(const_cast(object))->declarativeData); + if (data && data->propertyCache) { + QDeclarativePropertyCache::Data *property = data->propertyCache->method(index); + + if (property && property->flags & QDeclarativePropertyCache::Data::IsVMESignal) { + const QMetaObject *metaObject = object->metaObject(); + int methodOffset = metaObject->methodOffset(); + + while (methodOffset > index) { + methodOffset -= QMetaObject_methods(metaObject); + metaObject = metaObject->d.superdata; + } + + QDeclarativeVMEMetaObject *vme = + static_cast(const_cast(metaObject)); + + vme->connectAliasSignal(index); + } + } +} + +/*! +Connect \a sender \a signal_index to \a receiver \a method_index with the specified +\a type and \a types. This behaves identically to QMetaObject::connect() except that +it connects any lazy "proxy" signal connections set up by QML. + +It is possible that this logic should be moved to QMetaObject::connect(). +*/ +bool QDeclarativePropertyPrivate::connect(const QObject *sender, int signal_index, + const QObject *receiver, int method_index, + int type, int *types) +{ + flush_vme_signal(sender, signal_index); + flush_vme_signal(receiver, method_index); + + return QMetaObject::connect(sender, signal_index, receiver, method_index, type, types); +} + QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativeproperty_p.h b/src/declarative/qml/qdeclarativeproperty_p.h index 8522561..a8438c8 100644 --- a/src/declarative/qml/qdeclarativeproperty_p.h +++ b/src/declarative/qml/qdeclarativeproperty_p.h @@ -133,6 +133,9 @@ public: static int valueTypeCoreIndex(const QDeclarativeProperty &that); static int bindingIndex(const QDeclarativeProperty &that); static QMetaMethod findSignalByName(const QMetaObject *mo, const QByteArray &); + static bool connect(const QObject *sender, int signal_index, + const QObject *receiver, int method_index, + int type = 0, int *types = 0); }; Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativePropertyPrivate::WriteFlags) diff --git a/src/declarative/qml/qdeclarativepropertycache.cpp b/src/declarative/qml/qdeclarativepropertycache.cpp index 08503c2..9e1ceb8 100644 --- a/src/declarative/qml/qdeclarativepropertycache.cpp +++ b/src/declarative/qml/qdeclarativepropertycache.cpp @@ -94,6 +94,8 @@ void QDeclarativePropertyCache::Data::load(const QMetaMethod &m) { coreIndex = m.methodIndex(); flags |= Data::IsFunction; + if (m.methodType() == QMetaMethod::Signal) + flags |= Data::IsSignal; propType = QVariant::Invalid; const char *returnType = m.typeName(); @@ -215,7 +217,7 @@ QDeclarativePropertyCache *QDeclarativePropertyCache::copy() const } void QDeclarativePropertyCache::append(QDeclarativeEngine *engine, const QMetaObject *metaObject, - Data::Flag propertyFlags, Data::Flag methodFlags) + Data::Flag propertyFlags, Data::Flag methodFlags, Data::Flag signalFlags) { QDeclarativeEnginePrivate *enginePriv = QDeclarativeEnginePrivate::get(engine); @@ -251,6 +253,8 @@ void QDeclarativePropertyCache::append(QDeclarativeEngine *engine, const QMetaOb int methodCount = metaObject->methodCount(); int methodOffset = qMax(2, metaObject->methodOffset()); // 2 to block the destroyed signal + + methodIndexCache.resize(methodCount); for (int ii = methodOffset; ii < methodCount; ++ii) { QMetaMethod m = metaObject->method(ii); if (m.access() == QMetaMethod::Private) @@ -272,6 +276,10 @@ void QDeclarativePropertyCache::append(QDeclarativeEngine *engine, const QMetaOb data->load(m); if (m.methodType() == QMetaMethod::Slot || m.methodType() == QMetaMethod::Method) data->flags |= methodFlags; + else if (m.methodType() == QMetaMethod::Signal) + data->flags |= signalFlags; + + methodIndexCache[ii] = data; stringCache.insert(methodName, data); identifierCache.insert(data->identifier.identifier, data); @@ -350,6 +358,15 @@ QDeclarativePropertyCache::property(int index) const } QDeclarativePropertyCache::Data * +QDeclarativePropertyCache::method(int index) const +{ + if (index < 0 || index >= methodIndexCache.count()) + return 0; + + return methodIndexCache.at(index); +} + +QDeclarativePropertyCache::Data * QDeclarativePropertyCache::property(const QString &str) const { return stringCache.value(str); diff --git a/src/declarative/qml/qdeclarativepropertycache_p.h b/src/declarative/qml/qdeclarativepropertycache_p.h index 72cfeba..79b126d 100644 --- a/src/declarative/qml/qdeclarativepropertycache_p.h +++ b/src/declarative/qml/qdeclarativepropertycache_p.h @@ -94,8 +94,9 @@ public: // Apply only to IsFunctions IsVMEFunction = 0x00000400, - HasArguments = 0x00000800 - + HasArguments = 0x00000800, + IsSignal = 0x00001000, + IsVMESignal = 0x00002000, }; Q_DECLARE_FLAGS(Flags, Flag) @@ -125,7 +126,7 @@ public: QDeclarativePropertyCache *copy() const; void append(QDeclarativeEngine *, const QMetaObject *, Data::Flag propertyFlags = Data::NoFlags, - Data::Flag methodFlags = Data::NoFlags); + Data::Flag methodFlags = Data::NoFlags, Data::Flag signalFlags = Data::NoFlags); static QDeclarativePropertyCache *create(QDeclarativeEngine *, const QMetaObject *); static Data create(const QMetaObject *, const QString &); @@ -133,6 +134,7 @@ public: inline Data *property(const QScriptDeclarativeClass::Identifier &id) const; Data *property(const QString &) const; Data *property(int) const; + Data *method(int) const; QStringList propertyNames() const; inline QDeclarativeEngine *qmlEngine() const; @@ -152,6 +154,7 @@ private: QDeclarativeEngine *engine; IndexCache indexCache; + IndexCache methodIndexCache; StringCache stringCache; IdentifierCache identifierCache; }; diff --git a/src/declarative/qml/qdeclarativeproxymetaobject.cpp b/src/declarative/qml/qdeclarativeproxymetaobject.cpp index c2dce0a..ceb6977 100644 --- a/src/declarative/qml/qdeclarativeproxymetaobject.cpp +++ b/src/declarative/qml/qdeclarativeproxymetaobject.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "private/qdeclarativeproxymetaobject_p.h" +#include "private/qdeclarativeproperty_p.h" QT_BEGIN_NAMESPACE @@ -95,8 +96,7 @@ int QDeclarativeProxyMetaObject::metaCall(QMetaObject::Call c, int id, void **a) QMetaMethod method = metaObject->method(jj + methodOffset); if (method.methodType() == QMetaMethod::Signal) - QMetaObject::connect(proxy, methodOffset + jj, - object, localOffset + jj); + QDeclarativePropertyPrivate::connect(proxy, methodOffset + jj, object, localOffset + jj); } } diff --git a/src/declarative/qml/qdeclarativevme.cpp b/src/declarative/qml/qdeclarativevme.cpp index 4e41c22..360186c 100644 --- a/src/declarative/qml/qdeclarativevme.cpp +++ b/src/declarative/qml/qdeclarativevme.cpp @@ -608,7 +608,7 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack &stack, if (!QMetaObject::checkConnectArgs(prop.method().signature(), method.signature())) VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Cannot connect mismatched signal/slot %1 %vs. %2").arg(QString::fromLatin1(method.signature())).arg(QString::fromLatin1(prop.method().signature()))); - QMetaObject::connect(target, prop.index(), assign, method.methodIndex()); + QDeclarativePropertyPrivate::connect(target, prop.index(), assign, method.methodIndex()); } else { VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Cannot assign an object to signal property %1").arg(QString::fromUtf8(pr))); diff --git a/src/declarative/qml/qdeclarativevmemetaobject.cpp b/src/declarative/qml/qdeclarativevmemetaobject.cpp index 3e32006..37f08fc 100644 --- a/src/declarative/qml/qdeclarativevmemetaobject.cpp +++ b/src/declarative/qml/qdeclarativevmemetaobject.cpp @@ -584,19 +584,7 @@ int QDeclarativeVMEMetaObject::metaCall(QMetaObject::Call c, int _id, void **a) if (!target) return -1; - if (c == QMetaObject::ReadProperty && !aConnected.testBit(id)) { - int sigIdx = methodOffset + id + metaData->propertyCount; - QMetaObject::connect(context, d->contextIdx + ctxtPriv->notifyIndex, object, sigIdx); - - if (d->propertyIdx != -1) { - QMetaProperty prop = - target->metaObject()->property(d->propertyIdx); - if (prop.hasNotifySignal()) - QMetaObject::connect(target, prop.notifySignalIndex(), - object, sigIdx); - } - aConnected.setBit(id); - } + connectAlias(id); if (d->propertyIdx == -1) { *reinterpret_cast(a[0]) = target; @@ -818,4 +806,38 @@ void QDeclarativeVMEMetaObject::setVMEProperty(int index, const QScriptValue &v) return writeVarProperty(index - propOffset, v); } +void QDeclarativeVMEMetaObject::connectAlias(int aliasId) +{ + if (!aConnected.testBit(aliasId)) { + aConnected.setBit(aliasId); + + QDeclarativeContext *context = ctxt->asQDeclarativeContext(); + QDeclarativeContextPrivate *ctxtPriv = QDeclarativeContextPrivate::get(context); + + QDeclarativeVMEMetaData::AliasData *d = metaData->aliasData() + aliasId; + + QObject *target = ctxtPriv->data->idValues[d->contextIdx].data(); + if (!target) + return; + + int sigIdx = methodOffset + aliasId + metaData->propertyCount; + QMetaObject::connect(context, d->contextIdx + ctxtPriv->notifyIndex, object, sigIdx); + + if (d->propertyIdx != -1) { + QMetaProperty prop = target->metaObject()->property(d->propertyIdx); + if (prop.hasNotifySignal()) + QDeclarativePropertyPrivate::connect(target, prop.notifySignalIndex(), object, sigIdx); + } + } +} + +void QDeclarativeVMEMetaObject::connectAliasSignal(int index) +{ + int aliasId = (index - methodOffset) - metaData->propertyCount; + if (aliasId < 0 || aliasId >= metaData->aliasCount) + return; + + connectAlias(aliasId); +} + QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativevmemetaobject_p.h b/src/declarative/qml/qdeclarativevmemetaobject_p.h index 20ca80b..4ccaa73 100644 --- a/src/declarative/qml/qdeclarativevmemetaobject_p.h +++ b/src/declarative/qml/qdeclarativevmemetaobject_p.h @@ -126,6 +126,7 @@ public: QScriptValue vmeProperty(int index); void setVMEProperty(int index, const QScriptValue &); + void connectAliasSignal(int index); protected: virtual int metaCall(QMetaObject::Call _c, int _id, void **_a); @@ -140,6 +141,7 @@ private: QDeclarativeVMEVariant *data; + void connectAlias(int aliasId); QBitArray aConnected; QBitArray aInterceptors; QHash > interceptors; diff --git a/src/declarative/qml/qdeclarativewatcher.cpp b/src/declarative/qml/qdeclarativewatcher.cpp index da1419f..b9d5ec8 100644 --- a/src/declarative/qml/qdeclarativewatcher.cpp +++ b/src/declarative/qml/qdeclarativewatcher.cpp @@ -46,6 +46,7 @@ #include "qdeclarative.h" #include +#include "private/qdeclarativeproperty_p.h" #include #include @@ -103,7 +104,7 @@ QDeclarativeWatchProxy::QDeclarativeWatchProxy(int id, refreshIdx = QDeclarativeWatchProxy::staticMetaObject.indexOfMethod("notifyValueChanged()"); if (prop.hasNotifySignal()) - QMetaObject::connect(m_object, prop.notifySignalIndex(), this, refreshIdx); + QDeclarativePropertyPrivate::connect(m_object, prop.notifySignalIndex(), this, refreshIdx); } void QDeclarativeWatchProxy::notifyValueChanged() diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index 3c82fc5..9a8c944 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -1825,7 +1825,6 @@ void tst_qdeclarativelanguage::aliasPropertyChangeSignals() QObject *o = component.create(); QVERIFY(o != 0); - QEXPECT_FAIL("", "QTBUG-14089", Abort); QCOMPARE(o->property("test").toBool(), true); delete o; -- cgit v0.12 From f9a8c4ec598a0070b9d2d861efe5ee69d5045a1f Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 7 Oct 2010 19:05:27 +1000 Subject: Support device orientation in harmattan Task-number: QTBUG-14137 Reviewed-by: Aaron Kennedy --- tools/qml/deviceorientation_harmattan.cpp | 161 ++++++++++++++++++++++++++++++ tools/qml/qml.pri | 5 + 2 files changed, 166 insertions(+) create mode 100644 tools/qml/deviceorientation_harmattan.cpp diff --git a/tools/qml/deviceorientation_harmattan.cpp b/tools/qml/deviceorientation_harmattan.cpp new file mode 100644 index 0000000..22f9f4c --- /dev/null +++ b/tools/qml/deviceorientation_harmattan.cpp @@ -0,0 +1,161 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the tools applications 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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "deviceorientation.h" +#include +#include + +#define ORIENTATION_SERVICE "com.nokia.SensorService" +#define ORIENTATION_PATH "/org/maemo/contextkit/Screen/TopEdge" +#define CONTEXT_INTERFACE "org.maemo.contextkit.Property" +#define CONTEXT_CHANGED "ValueChanged" +#define CONTEXT_SUBSCRIBE "Subscribe" +#define CONTEXT_UNSUBSCRIBE "Unsubscribe" +#define CONTEXT_GET "Get" + + +class HarmattanOrientation : public DeviceOrientation +{ + Q_OBJECT +public: + HarmattanOrientation() + : o(UnknownOrientation), sensorEnabled(false) + { + resumeListening(); + // connect to the orientation change signal + bool ok = QDBusConnection::systemBus().connect(ORIENTATION_SERVICE, ORIENTATION_PATH, + CONTEXT_INTERFACE, + CONTEXT_CHANGED, + this, + SLOT(deviceOrientationChanged(QList,quint64))); +// qDebug() << "connection OK" << ok; + QDBusMessage reply = QDBusConnection::systemBus().call( + QDBusMessage::createMethodCall(ORIENTATION_SERVICE, ORIENTATION_PATH, + CONTEXT_INTERFACE, CONTEXT_GET)); + if (reply.type() != QDBusMessage::ErrorMessage) { + QList args; + qvariant_cast(reply.arguments().at(0)) >> args; + deviceOrientationChanged(args, 0); + } + } + + ~HarmattanOrientation() + { + // unsubscribe from the orientation sensor + if (sensorEnabled) + QDBusConnection::systemBus().call( + QDBusMessage::createMethodCall(ORIENTATION_SERVICE, ORIENTATION_PATH, + CONTEXT_INTERFACE, CONTEXT_UNSUBSCRIBE)); + } + + inline Orientation orientation() const + { + return o; + } + + void setOrientation(Orientation) + { + } + + void pauseListening() { + if (sensorEnabled) { + // unsubscribe from the orientation sensor + QDBusConnection::systemBus().call( + QDBusMessage::createMethodCall(ORIENTATION_SERVICE, ORIENTATION_PATH, + CONTEXT_INTERFACE, CONTEXT_UNSUBSCRIBE)); + sensorEnabled = false; + } + } + + void resumeListening() { + if (!sensorEnabled) { + // subscribe to the orientation sensor + QDBusMessage reply = QDBusConnection::systemBus().call( + QDBusMessage::createMethodCall(ORIENTATION_SERVICE, ORIENTATION_PATH, + CONTEXT_INTERFACE, CONTEXT_SUBSCRIBE)); + + if (reply.type() == QDBusMessage::ErrorMessage) { + qWarning("Unable to retrieve device orientation: %s", qPrintable(reply.errorMessage())); + } else { + sensorEnabled = true; + } + } + } + +private Q_SLOTS: + void deviceOrientationChanged(QList args,quint64) + { + if (args.count() == 0) + return; + Orientation newOrientation = toOrientation(args.at(0).toString()); + if (newOrientation != o) { + o = newOrientation; + emit orientationChanged(); + } +// qDebug() << "orientation" << args.at(0).toString(); + } + +private: + static Orientation toOrientation(const QString &nativeOrientation) + { + if (nativeOrientation == "top") + return Landscape; + else if (nativeOrientation == "left") + return Portrait; + else if (nativeOrientation == "bottom") + return LandscapeInverted; + else if (nativeOrientation == "right") + return PortraitInverted; + return UnknownOrientation; + } + +private: + Orientation o; + bool sensorEnabled; +}; + +DeviceOrientation* DeviceOrientation::instance() +{ + static HarmattanOrientation *o = new HarmattanOrientation; + return o; +} + +#include "deviceorientation_harmattan.moc" diff --git a/tools/qml/qml.pri b/tools/qml/qml.pri index e5b2c7f..5db7678 100644 --- a/tools/qml/qml.pri +++ b/tools/qml/qml.pri @@ -29,6 +29,11 @@ symbian:!contains(S60_VERSION, 3.1):!contains(S60_VERSION, 3.2) { SOURCES += $$PWD/deviceorientation_maemo5.cpp FORMS = $$PWD/recopts_maemo5.ui \ $$PWD/proxysettings_maemo5.ui +} else:linux-g++-maemo { + QT += dbus + SOURCES += $$PWD/deviceorientation_harmattan.cpp + FORMS = $$PWD/recopts.ui \ + $$PWD/proxysettings.ui } else { SOURCES += $$PWD/deviceorientation.cpp FORMS = $$PWD/recopts.ui \ -- cgit v0.12