From a4d208f1831ecba1d51d3afe9a9e9e21faf8b3cf Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 29 Mar 2010 12:18:20 +0200 Subject: Update autotest a little variant property was removed, and data property was altered, without updating this autotest. However the remaining failure for date appears to be genuine --- tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp b/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp index 16efba9..c41855d 100644 --- a/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp +++ b/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp @@ -451,7 +451,6 @@ void tst_qdeclarativedom::loadDynamicProperty() " property color g\n" " property date h\n" " property var i\n" - " property variant j\n" " property QtObject k\n" "}"; @@ -461,7 +460,7 @@ void tst_qdeclarativedom::loadDynamicProperty() QDeclarativeDomObject rootObject = document.rootObject(); QVERIFY(rootObject.isValid()); - QCOMPARE(rootObject.dynamicProperties().count(), 11); + QCOMPARE(rootObject.dynamicProperties().count(), 10); #define DP_TEST(index, name, type, test_position, test_length, propTypeName) \ { \ @@ -483,9 +482,8 @@ void tst_qdeclarativedom::loadDynamicProperty() DP_TEST(4, e, QVariant::String, 106, 17, "string"); DP_TEST(5, f, QVariant::Url, 128, 14, "url"); DP_TEST(6, g, QVariant::Color, 147, 16, "color"); - DP_TEST(7, h, QVariant::Date, 168, 15, "date"); + DP_TEST(7, h, QVariant::DateTime, 168, 15, "date"); DP_TEST(8, i, qMetaTypeId(), 188, 14, "var"); - DP_TEST(9, j, qMetaTypeId(), 207, 18, "variant"); DP_TEST(10, k, -1, 230, 19, "QtObject"); } -- cgit v0.12 From 5a6747ad0418862cafde45837c02a87bfb6b3db3 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Mon, 29 Mar 2010 17:14:37 +0200 Subject: Removed unneeded code. --- src/declarative/qml/parser/qdeclarativejs.g | 5 ----- src/declarative/qml/parser/qdeclarativejsparser.cpp | 5 ----- 2 files changed, 10 deletions(-) diff --git a/src/declarative/qml/parser/qdeclarativejs.g b/src/declarative/qml/parser/qdeclarativejs.g index c7524a4..6434d10 100644 --- a/src/declarative/qml/parser/qdeclarativejs.g +++ b/src/declarative/qml/parser/qdeclarativejs.g @@ -654,11 +654,6 @@ case $rule_number: { node = makeAstNode(driver->nodePool(), importIdLiteral->value); node->fileNameToken = loc(2); } else if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(2).Expression)) { - QString text; - for (AST::UiQualifiedId *q = qualifiedId; q; q = q->next) { - text += q->name->asString(); - if (q->next) text += QLatin1String("."); - } node = makeAstNode(driver->nodePool(), qualifiedId); node->fileNameToken = loc(2); } diff --git a/src/declarative/qml/parser/qdeclarativejsparser.cpp b/src/declarative/qml/parser/qdeclarativejsparser.cpp index 2949e88..3cf73b1 100644 --- a/src/declarative/qml/parser/qdeclarativejsparser.cpp +++ b/src/declarative/qml/parser/qdeclarativejsparser.cpp @@ -273,11 +273,6 @@ case 20: { node = makeAstNode(driver->nodePool(), importIdLiteral->value); node->fileNameToken = loc(2); } else if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(2).Expression)) { - QString text; - for (AST::UiQualifiedId *q = qualifiedId; q; q = q->next) { - text += q->name->asString(); - if (q->next) text += QLatin1String("."); - } node = makeAstNode(driver->nodePool(), qualifiedId); node->fileNameToken = loc(2); } -- cgit v0.12 From 176390773658ce396b1776e2872ecb389a2351a3 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 30 Mar 2010 08:43:05 +1000 Subject: Simplify import path. Reviewed-by: mae --- src/declarative/qml/qdeclarativeengine.cpp | 88 +++++++++++------------------- src/declarative/qml/qdeclarativeengine.h | 4 +- src/declarative/qml/qdeclarativeengine_p.h | 1 - tools/qml/main.cpp | 11 +++- 4 files changed, 45 insertions(+), 59 deletions(-) diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 5335b8c..abac086 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -178,10 +178,16 @@ QDeclarativeEnginePrivate::QDeclarativeEnginePrivate(QDeclarativeEngine *e) #endif foreach (const QString &path, QString::fromLatin1(envImportPath).split(pathSep, QString::SkipEmptyParts)) { QString canonicalPath = QDir(path).canonicalPath(); - if (!canonicalPath.isEmpty() && !environmentImportPath.contains(canonicalPath)) - environmentImportPath.append(canonicalPath); + if (!canonicalPath.isEmpty() && !fileImportPath.contains(canonicalPath)) + fileImportPath.append(canonicalPath); } } +#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0)) + QString builtinPath = QLibraryInfo::location(QLibraryInfo::ImportsPath); + if (!builtinPath.isEmpty()) + fileImportPath += builtinPath; +#endif + } QUrl QDeclarativeScriptEngine::resolvedUrl(QScriptContext *context, const QUrl& url) @@ -1495,29 +1501,7 @@ public: if (dir.endsWith(QLatin1Char('/')) || dir.endsWith(QLatin1Char('\\'))) dir.chop(1); - QStringList paths; - -// if (!base.isEmpty()) { -// QString baseDir = QFileInfo(toLocalFileOrQrc(base)).path(); -// paths += baseDir; -// } - - QString applicationDirPath = QCoreApplication::applicationDirPath(); - if (!applicationDirPath.isEmpty()) - paths += applicationDirPath; - - paths += QDeclarativeEnginePrivate::get(engine)->environmentImportPath; -#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0)) - QString builtinPath = QLibraryInfo::location(QLibraryInfo::ImportsPath); -#else - QString builtinPath; -#endif - if (!builtinPath.isEmpty()) - paths += builtinPath; - - // add fileImportPath last, this is *not* search order. - paths += QDeclarativeEnginePrivate::get(engine)->fileImportPath; - + QStringList paths = QDeclarativeEnginePrivate::get(engine)->fileImportPath; qSort(paths.begin(), paths.end(), greaterThan); // Ensure subdirs preceed their parents. QString stableRelativePath = dir; @@ -1557,28 +1541,8 @@ public: QString dir; - // user import paths - QStringList paths; - // base.. -// QString localFileOrQrc = toLocalFileOrQrc(base); -// QString localFileOrQrcPath = QFileInfo(localFileOrQrc).path(); -// paths += localFileOrQrcPath; - paths += QDeclarativeEnginePrivate::get(engine)->fileImportPath; - - QString applicationDirPath = QCoreApplication::applicationDirPath(); - if (!applicationDirPath.isEmpty()) - paths += applicationDirPath; - - paths += QDeclarativeEnginePrivate::get(engine)->environmentImportPath; -#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0)) - QString builtinPath = QLibraryInfo::location(QLibraryInfo::ImportsPath); -#else - QString builtinPath; -#endif - if (!builtinPath.isEmpty()) - paths += builtinPath; - - foreach (const QString &p, paths) { + foreach (const QString &p, + QDeclarativeEnginePrivate::get(engine)->fileImportPath) { dir = p+QLatin1Char('/')+url; QFileInfo fi(dir+QLatin1String("/qmldir")); @@ -1810,7 +1774,9 @@ QUrl QDeclarativeEnginePrivate::Imports::baseUrl() const Adds \a path as a directory where installed QML components are defined in a URL-based directory structure. - \sa importPathList() + The newly added \a path will be first in the importPathList(). + + \sa setImportPathList() */ void QDeclarativeEngine::addImportPath(const QString& path) { @@ -1822,7 +1788,7 @@ void QDeclarativeEngine::addImportPath(const QString& path) /*! - Returns the list of directories with the engine searches for + Returns the list of directories where the engine searches for installed modules. For example, if \c /opt/MyApp/lib/imports is in the path, then QML that @@ -1831,13 +1797,10 @@ void QDeclarativeEngine::addImportPath(const QString& path) provided by that module. A \c qmldir file is required for defining the type version mapping and possibly declarative extensions plugins. - In addition to this list, - the engine searches in the directory containing the - application executable (QCoreApplication::applicationDirPath()), - then the paths specified in the \c QML_IMPORT_PATH environment variable, then the - builtin \c ImportsPath from QLibraryInfo. + By default, the list contains the paths specified in the \c QML_IMPORT_PATH environment + variable, then the builtin \c ImportsPath from QLibraryInfo. - \sa addImportPath() + \sa addImportPath() setImportPathList() */ QStringList QDeclarativeEngine::importPathList() const { @@ -1846,6 +1809,21 @@ QStringList QDeclarativeEngine::importPathList() const } /*! + Sets the list of directories where the engine searches for + installed modules. + + By default, the list contains the paths specified in the \c QML_IMPORT_PATH environment + variable, then the builtin \c ImportsPath from QLibraryInfo. + + \sa importPathList() addImportPath() + */ +void QDeclarativeEngine::setImportPathList(const QStringList &paths) +{ + Q_D(QDeclarativeEngine); + d->fileImportPath = paths; +} + +/*! Imports the extension named \a fileName from the \a uri provided. Returns true if the extension was successfully imported. */ diff --git a/src/declarative/qml/qdeclarativeengine.h b/src/declarative/qml/qdeclarativeengine.h index a24962e..b861c1b 100644 --- a/src/declarative/qml/qdeclarativeengine.h +++ b/src/declarative/qml/qdeclarativeengine.h @@ -77,8 +77,10 @@ public: void clearComponentCache(); - void addImportPath(const QString& dir); QStringList importPathList() const; + void setImportPathList(const QStringList &paths); + void addImportPath(const QString& dir); + bool importExtension(const QString &fileName, const QString &uri); void setNetworkAccessManagerFactory(QDeclarativeNetworkAccessManagerFactory *); diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h index 84bf061..5aff30d 100644 --- a/src/declarative/qml/qdeclarativeengine_p.h +++ b/src/declarative/qml/qdeclarativeengine_p.h @@ -272,7 +272,6 @@ public: }; - QStringList environmentImportPath; QSet initializedPlugins; QString resolvePlugin(const QDir &dir, const QString &baseName, diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp index a4de339..8062e8e 100644 --- a/tools/qml/main.cpp +++ b/tools/qml/main.cpp @@ -41,6 +41,7 @@ #include "qdeclarative.h" #include "qmlruntime.h" +#include "qdeclarativeengine.h" #include #include #include @@ -100,7 +101,8 @@ void usage() qWarning(" -dragthreshold .................... set mouse drag threshold size"); qWarning(" -netcache ......................... set disk cache to size bytes"); qWarning(" -translation ........... set the language to run in"); - qWarning(" -L ........................... prepend to the library search path"); + qWarning(" -L ........................... prepend to the library search path,"); + qWarning(" display path if is empty"); qWarning(" -opengl .................................. use a QGLWidget for the viewport"); qWarning(" -script ........................... set the script to use"); qWarning(" -scriptopts |help ............... set the script options to use"); @@ -238,7 +240,12 @@ int main(int argc, char ** argv) } else if (arg == "-qmlbrowser") { useNativeFileBrowser = false; } else if (arg == "-L") { - if (lastArg) usage(); + if (lastArg) { + QDeclarativeEngine tmpEngine; + QString paths = tmpEngine.importPathList().join(QLatin1String(":")); + fprintf(stderr, "Current search path: %s\n", paths.toLocal8Bit().constData()); + return 0; + } libraries << QString(argv[++i]); } else if (arg == "-script") { if (lastArg) usage(); -- cgit v0.12 From 9f38b5824b0300c615231729f1e7cdb17890083a Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 30 Mar 2010 09:03:46 +1000 Subject: Allow just one dimension to be set, the other scaled accordingly Task-number: QTBUG-8984 --- src/declarative/util/qdeclarativepixmapcache.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/declarative/util/qdeclarativepixmapcache.cpp b/src/declarative/util/qdeclarativepixmapcache.cpp index fe5863f..a9c30f8 100644 --- a/src/declarative/util/qdeclarativepixmapcache.cpp +++ b/src/declarative/util/qdeclarativepixmapcache.cpp @@ -179,8 +179,16 @@ static bool readImage(const QUrl& url, QIODevice *dev, QImage *image, QString *e bool scaled = false; if (req_width > 0 || req_height > 0) { QSize s = imgio.size(); - if (req_width && (force_scale || req_width < s.width())) { s.setWidth(req_width); scaled = true; } - if (req_height && (force_scale || req_height < s.height())) { s.setHeight(req_height); scaled = true; } + if (req_width && (force_scale || req_width < s.width())) { + if (req_height <= 0) + s.setHeight(s.height()*req_width/s.width()); + s.setWidth(req_width); scaled = true; + } + if (req_height && (force_scale || req_height < s.height())) { + if (req_width <= 0) + s.setWidth(s.width()*req_height/s.height()); + s.setHeight(req_height); scaled = true; + } if (scaled) { imgio.setScaledSize(s); } } @@ -596,7 +604,7 @@ QDeclarativePixmapReply::Status QDeclarativePixmapCache::get(const QUrl& url, QP QDeclarativePixmapReply::Status status = QDeclarativePixmapReply::Unrequested; QByteArray key = url.toEncoded(QUrl::FormattingOption(0x100)); - if (req_width > 0 && req_height > 0) { + if (req_width > 0 || req_height > 0) { key += ':'; key += QByteArray::number(req_width); key += 'x'; -- cgit v0.12 From cee97322cab0c14e1e3cce7773ba82c6aca86bb3 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 30 Mar 2010 09:32:48 +1000 Subject: Make sure cursor delegate is parented. setParentItem no longer sets QObject parent. --- src/declarative/graphicsitems/qdeclarativetextedit.cpp | 2 ++ src/declarative/graphicsitems/qdeclarativetextinput.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index 7dacfbb..03b2425 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -43,6 +43,7 @@ #include "qdeclarativetextedit_p_p.h" #include "qdeclarativeevents_p_p.h" +#include #include #include @@ -485,6 +486,7 @@ void QDeclarativeTextEdit::loadCursorDelegate() this, SLOT(moveCursorDelegate())); d->control->setCursorWidth(0); dirtyCache(cursorRect()); + QDeclarative_setParent_noEvent(d->cursor, this); d->cursor->setParentItem(this); d->cursor->setHeight(QFontMetrics(d->font).height()); moveCursorDelegate(); diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index f57ffc1..88801a4 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -42,6 +42,7 @@ #include "qdeclarativetextinput_p.h" #include "qdeclarativetextinput_p_p.h" +#include #include #include @@ -619,6 +620,7 @@ void QDeclarativeTextInput::createCursor() return; } + QDeclarative_setParent_noEvent(d->cursorItem, this); d->cursorItem->setParentItem(this); d->cursorItem->setX(d->control->cursorToX()); d->cursorItem->setHeight(d->control->height()); -- cgit v0.12 From f5504a76518c65644b665f9c16299fbe423015db Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 30 Mar 2010 10:08:57 +1000 Subject: Correctly parent repeater items. --- src/declarative/graphicsitems/qdeclarativerepeater.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativerepeater.cpp b/src/declarative/graphicsitems/qdeclarativerepeater.cpp index e8f9b24..bbee4e5 100644 --- a/src/declarative/graphicsitems/qdeclarativerepeater.cpp +++ b/src/declarative/graphicsitems/qdeclarativerepeater.cpp @@ -43,7 +43,7 @@ #include "qdeclarativerepeater_p_p.h" #include "qdeclarativevisualitemmodel_p.h" - +#include #include #include @@ -283,7 +283,6 @@ void QDeclarativeRepeater::clear() Q_D(QDeclarativeRepeater); if (d->model) { foreach (QDeclarativeItem *item, d->deletables) { - item->setParentItem(this); d->model->release(item); } } @@ -307,7 +306,8 @@ void QDeclarativeRepeater::regenerate() for (int ii = 0; ii < count(); ++ii) { QDeclarativeItem *item = d->model->item(ii); if (item) { - item->setParent(parentItem()); + QDeclarative_setParent_noEvent(item, parentItem()); + item->setParentItem(parentItem()); item->stackBefore(this); d->deletables << item; } @@ -323,7 +323,8 @@ void QDeclarativeRepeater::itemsInserted(int index, int count) int modelIndex = index + i; QDeclarativeItem *item = d->model->item(modelIndex); if (item) { - item->setParent(parentItem()); + QDeclarative_setParent_noEvent(item, parentItem()); + item->setParentItem(parentItem()); if (modelIndex < d->deletables.count()) item->stackBefore(d->deletables.at(modelIndex)); else @@ -341,7 +342,6 @@ void QDeclarativeRepeater::itemsRemoved(int index, int count) while (count--) { QDeclarativeItem *item = d->deletables.takeAt(index); if (item) { - item->setParentItem(this); d->model->release(item); } } -- cgit v0.12