diff options
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativerepeater.cpp | 10 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativetextedit.cpp | 2 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativetextinput.cpp | 2 | ||||
-rw-r--r-- | src/declarative/qml/parser/qdeclarativejs.g | 5 | ||||
-rw-r--r-- | src/declarative/qml/parser/qdeclarativejsparser.cpp | 5 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativeengine.cpp | 88 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativeengine.h | 4 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativeengine_p.h | 1 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativepixmapcache.cpp | 14 | ||||
-rw-r--r-- | tools/qml/main.cpp | 11 |
10 files changed, 65 insertions, 77 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 <private/qdeclarativeglobal_p.h> #include <qdeclarativelistaccessor_p.h> #include <qlistmodelinterface_p.h> @@ -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); } } 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 <private/qdeclarativeglobal_p.h> #include <QTextLayout> #include <QTextLine> @@ -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 <private/qdeclarativeglobal_p.h> #include <qdeclarativeinfo.h> #include <QValidator> @@ -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()); 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<AST::UiImport>(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<AST::UiImport>(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<AST::UiImport>(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<AST::UiImport>(driver->nodePool(), qualifiedId); node->fileNameToken = loc(2); } 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<QString> initializedPlugins; QString resolvePlugin(const QDir &dir, const QString &baseName, 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'; 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 <QWidget> #include <QDir> #include <QApplication> @@ -100,7 +101,8 @@ void usage() qWarning(" -dragthreshold <size> .................... set mouse drag threshold size"); qWarning(" -netcache <size> ......................... set disk cache to size bytes"); qWarning(" -translation <translationfile> ........... set the language to run in"); - qWarning(" -L <directory> ........................... prepend to the library search path"); + qWarning(" -L <directory> ........................... prepend to the library search path,"); + qWarning(" display path if <directory> is empty"); qWarning(" -opengl .................................. use a QGLWidget for the viewport"); qWarning(" -script <path> ........................... set the script to use"); qWarning(" -scriptopts <options>|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(); |