From fe3c4ac63bf4879534caf32419b5d481a7c6113a Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Thu, 23 Jul 2009 14:09:32 +1000 Subject: make scrollbars look nice again. --- examples/declarative/scrollbar/ScrollBar.qml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/declarative/scrollbar/ScrollBar.qml b/examples/declarative/scrollbar/ScrollBar.qml index 8020d62..f329fbe 100644 --- a/examples/declarative/scrollbar/ScrollBar.qml +++ b/examples/declarative/scrollbar/ScrollBar.qml @@ -12,18 +12,18 @@ Item { // A light, semi-transparent background Rect { id: Background - radius: orientation == 'Vertical' ? (width/2) : (height/2) + radius: orientation == 'Vertical' ? (width/2 - 1) : (height/2 - 1) color: "white"; opacity: 0.3 anchors.fill: parent } // Size the bar to the required size, depending upon the orientation. Rect { - opacity: 0.6 + opacity: 0.7 color: "black" - radius: orientation == 'Vertical' ? (width/2) : (height/2) - x: orientation == 'Vertical' ? 2 : (ScrollBar.position * (ScrollBar.width-4) + 2) - y: orientation == 'Vertical' ? (ScrollBar.position * (ScrollBar.height-4) + 2) : 2 - width: orientation == 'Vertical' ? (parent.width-4) : (ScrollBar.pageSize * (ScrollBar.width-4)) - height: orientation == 'Vertical' ? (ScrollBar.pageSize * (ScrollBar.height-4)) : (parent.height-4) + radius: orientation == 'Vertical' ? (width/2 - 1) : (height/2 - 1) + x: orientation == 'Vertical' ? 1 : (ScrollBar.position * (ScrollBar.width-2) + 1) + y: orientation == 'Vertical' ? (ScrollBar.position * (ScrollBar.height-2) + 1) : 1 + width: orientation == 'Vertical' ? (parent.width-2) : (ScrollBar.pageSize * (ScrollBar.width-2)) + height: orientation == 'Vertical' ? (ScrollBar.pageSize * (ScrollBar.height-2)) : (parent.height-2) } } -- cgit v0.12 From fa9a292388e93f128eac2ba4438f8b1e772a4782 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Thu, 23 Jul 2009 16:58:26 +1000 Subject: Add QmlFontFamily. --- src/declarative/util/qmlfontfamily.cpp | 152 +++++++++++++++++++++++++++++++++ src/declarative/util/qmlfontfamily.h | 86 +++++++++++++++++++ src/declarative/util/util.pri | 2 + 3 files changed, 240 insertions(+) create mode 100644 src/declarative/util/qmlfontfamily.cpp create mode 100644 src/declarative/util/qmlfontfamily.h diff --git a/src/declarative/util/qmlfontfamily.cpp b/src/declarative/util/qmlfontfamily.cpp new file mode 100644 index 0000000..91d1cde --- /dev/null +++ b/src/declarative/util/qmlfontfamily.cpp @@ -0,0 +1,152 @@ +/**************************************************************************** +** +** 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 "private/qobject_p.h" +#include "qmlfontfamily.h" +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QmlFontFamilyPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QmlFontFamily); + +public: + QmlFontFamilyPrivate() : reply(0) {} + + void addFontToDatabase(const QByteArray &); + + QUrl url; + QString name; + QNetworkReply *reply; +}; + +QML_DEFINE_TYPE(QmlFontFamily,FontFamily) + +/*! + \qmlclass FontFamily QmlFontFamily + \ingroup group_utility +*/ +QmlFontFamily::QmlFontFamily(QObject *parent) + : QObject(*(new QmlFontFamilyPrivate), parent) +{ +} + +QmlFontFamily::~QmlFontFamily() +{ +} + +QUrl QmlFontFamily::source() const +{ + Q_D(const QmlFontFamily); + return d->url; +} + +void QmlFontFamily::setSource(const QUrl &url) +{ + Q_D(QmlFontFamily); + if (url == d->url) + return; + d->url = qmlContext(this)->resolvedUrl(url); + +#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML + if (d->url.scheme() == QLatin1String("file")) { + QFile file(d->url.toLocalFile()); + file.open(QIODevice::ReadOnly); + QByteArray ba = file.readAll(); + d->addFontToDatabase(ba); + } else +#endif + { + QNetworkRequest req(d->url); + req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache); + d->reply = qmlEngine(this)->networkAccessManager()->get(req); + QObject::connect(d->reply, SIGNAL(finished()), this, SLOT(replyFinished())); + } +} + +QString QmlFontFamily::name() const +{ + Q_D(const QmlFontFamily); + return d->name; +} + +void QmlFontFamily::setName(const QString &name) +{ + Q_D(QmlFontFamily); + if (d->name == name ) + return; + d->name = name; + emit nameChanged(); +} + +void QmlFontFamily::replyFinished() +{ + Q_D(QmlFontFamily); + if (!d->reply->error()) { + QByteArray ba = d->reply->readAll(); + d->addFontToDatabase(ba); + } + d->reply->deleteLater(); + d->reply = 0; +} + +void QmlFontFamilyPrivate::addFontToDatabase(const QByteArray &ba) +{ + Q_Q(QmlFontFamily); + + int id = QFontDatabase::addApplicationFontFromData(ba); + if (id != -1) { + name = QFontDatabase::applicationFontFamilies(id).at(0); + emit q->nameChanged(); + } else { + qWarning() << "Cannot load font: " << name << url; + } +} + +QT_END_NAMESPACE diff --git a/src/declarative/util/qmlfontfamily.h b/src/declarative/util/qmlfontfamily.h new file mode 100644 index 0000000..739a553 --- /dev/null +++ b/src/declarative/util/qmlfontfamily.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** 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 QMLFONTFAMILY_H +#define QMLFONTFAMILY_H + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QmlFontFamilyPrivate; +class Q_DECLARATIVE_EXPORT QmlFontFamily : public QObject +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QmlFontFamily) + + Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) + +public: + QmlFontFamily(QObject *parent = 0); + ~QmlFontFamily(); + + QUrl source() const; + void setSource(const QUrl &url); + + QString name() const; + void setName(const QString &name); + +private Q_SLOTS: + void replyFinished(); + +Q_SIGNALS: + void nameChanged(); +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QmlFontFamily) + +QT_END_HEADER + +#endif // QMLFONTFAMILY_H diff --git a/src/declarative/util/util.pri b/src/declarative/util/util.pri index 59e3695..dfb79ac 100644 --- a/src/declarative/util/util.pri +++ b/src/declarative/util/util.pri @@ -7,6 +7,7 @@ SOURCES += \ util/qmlscript.cpp \ util/qmlanimation.cpp \ util/qmlfont.cpp \ + util/qmlfontfamily.cpp \ util/qmlpalette.cpp \ util/qmlfollow.cpp \ util/qmlstate.cpp\ @@ -33,6 +34,7 @@ HEADERS += \ util/qmlanimation.h \ util/qmlanimation_p.h \ util/qmlfont.h \ + util/qmlfontfamily.h \ util/qmlpalette.h \ util/qmlfollow.h \ util/qmlstate.h\ -- cgit v0.12 From ee91cc1041681654f7a250dc197d0902c53a951f Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Thu, 23 Jul 2009 09:08:59 +0200 Subject: Fixed the semantic action of UiArrayMemberList --- src/declarative/qml/parser/qmljs.g | 2 +- src/declarative/qml/parser/qmljsparser.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/declarative/qml/parser/qmljs.g b/src/declarative/qml/parser/qmljs.g index d7fb17c..7d8faee 100644 --- a/src/declarative/qml/parser/qmljs.g +++ b/src/declarative/qml/parser/qmljs.g @@ -782,7 +782,7 @@ UiArrayMemberList: UiArrayMemberList T_COMMA UiAnnotation UiObjectDefinition ; case $rule_number: { sym(4).UiObjectMember->attributes = sym(3).UiAttributeList; AST::UiArrayMemberList *node = makeAstNode (driver->nodePool(), - sym(1).UiArrayMemberList, sym(3).UiObjectMember); + sym(1).UiArrayMemberList, sym(4).UiObjectMember); node->commaToken = loc(2); sym(1).Node = node; } break; diff --git a/src/declarative/qml/parser/qmljsparser.cpp b/src/declarative/qml/parser/qmljsparser.cpp index 93f9fda..296559b 100644 --- a/src/declarative/qml/parser/qmljsparser.cpp +++ b/src/declarative/qml/parser/qmljsparser.cpp @@ -360,7 +360,7 @@ case 35: { case 36: { sym(4).UiObjectMember->attributes = sym(3).UiAttributeList; AST::UiArrayMemberList *node = makeAstNode (driver->nodePool(), - sym(1).UiArrayMemberList, sym(3).UiObjectMember); + sym(1).UiArrayMemberList, sym(4).UiObjectMember); node->commaToken = loc(2); sym(1).Node = node; } break; -- cgit v0.12 From fb0f1485ed37b8055b4ffbfd0805ceff1e9401f5 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 23 Jul 2009 17:13:00 +1000 Subject: Move import access functions to QmlEnginePrivate. --- src/declarative/fx/qfxwebview.h | 10 +- src/declarative/qml/qml.pri | 1 + src/declarative/qml/qmlcompiler.cpp | 1 + src/declarative/qml/qmlcomponent.cpp | 1 + src/declarative/qml/qmlcompositetypedata_p.h | 123 ++++++++++++++++++++++++ src/declarative/qml/qmlcompositetypemanager.cpp | 5 +- src/declarative/qml/qmlcompositetypemanager_p.h | 60 +----------- src/declarative/qml/qmldom.cpp | 1 + src/declarative/qml/qmlengine.cpp | 49 +++++----- src/declarative/qml/qmlengine.h | 15 --- src/declarative/qml/qmlengine_p.h | 16 +++ 11 files changed, 179 insertions(+), 103 deletions(-) create mode 100644 src/declarative/qml/qmlcompositetypedata_p.h diff --git a/src/declarative/fx/qfxwebview.h b/src/declarative/fx/qfxwebview.h index 1200162..7f22439 100644 --- a/src/declarative/fx/qfxwebview.h +++ b/src/declarative/fx/qfxwebview.h @@ -96,12 +96,12 @@ class Q_DECLARATIVE_EXPORT QFxWebView : public QFxPaintedItem Q_PROPERTY(bool interactive READ interactive WRITE setInteractive NOTIFY interactiveChanged) - Q_PROPERTY(QObject* reload READ reloadAction CONSTANT) - Q_PROPERTY(QObject* back READ backAction CONSTANT) - Q_PROPERTY(QObject* forward READ forwardAction CONSTANT) - Q_PROPERTY(QObject* stop READ stopAction CONSTANT) + Q_PROPERTY(QObject* reload READ reloadAction) + Q_PROPERTY(QObject* back READ backAction) + Q_PROPERTY(QObject* forward READ forwardAction) + Q_PROPERTY(QObject* stop READ stopAction) - Q_PROPERTY(QObject* settings READ settingsObject CONSTANT) + Q_PROPERTY(QObject* settings READ settingsObject) public: QFxWebView(QFxItem *parent=0); diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri index 1021dec..d8b69df 100644 --- a/src/declarative/qml/qml.pri +++ b/src/declarative/qml/qml.pri @@ -65,6 +65,7 @@ HEADERS += qml/qmlparser_p.h \ qml/qmlinfo.h \ qml/qmlmetaproperty_p.h \ qml/qmlcontext_p.h \ + qml/qmlcompositetypedata_p.h \ qml/qmlcompositetypemanager_p.h \ qml/qmllist.h \ qml/qmldeclarativedata_p.h \ diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index 94710c6..20f0d93f 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "private/qmlcompiler_p.h" +#include "private/qmlcompositetypedata_p.h" #include #include "qmlparser_p.h" #include "private/qmlscriptparser_p.h" diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp index 214d2fa..7dcc373 100644 --- a/src/declarative/qml/qmlcomponent.cpp +++ b/src/declarative/qml/qmlcomponent.cpp @@ -43,6 +43,7 @@ #include "qmlcomponent_p.h" #include "qmlcompiler_p.h" #include "private/qmlcontext_p.h" +#include "private/qmlcompositetypedata_p.h" #include "private/qmlengine_p.h" #include "qmlvme_p.h" #include "qml.h" diff --git a/src/declarative/qml/qmlcompositetypedata_p.h b/src/declarative/qml/qmlcompositetypedata_p.h new file mode 100644 index 0000000..3469fea --- /dev/null +++ b/src/declarative/qml/qmlcompositetypedata_p.h @@ -0,0 +1,123 @@ +/**************************************************************************** +** +** 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 QMLCOMPOSITETYPEDATA_P_H +#define QMLCOMPOSITETYPEDATA_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +struct QmlCompositeTypeData : public QmlRefCount +{ + QmlCompositeTypeData(); + virtual ~QmlCompositeTypeData(); + + enum Status { + Invalid, + Complete, + Error, + Waiting + }; + Status status; + enum ErrorType { + NoError, + AccessError, + GeneralError + }; + ErrorType errorType; + + QList errors; + + QmlEnginePrivate::Imports imports; + + QList dependants; + + // Return a QmlComponent if the QmlCompositeTypeData is not in the Waiting + // state. The QmlComponent is owned by the QmlCompositeTypeData, so a + // reference should be kept to keep the QmlComponent alive. + QmlComponent *toComponent(QmlEngine *); + // Return a QmlCompiledData if possible, or 0 if an error + // occurs + QmlCompiledData *toCompiledComponent(QmlEngine *); + + struct TypeReference + { + TypeReference(); + + QmlType *type; + QmlCompositeTypeData *unit; + }; + + QList types; + + // Add or remove p as a waiter. When the QmlCompositeTypeData becomes + // ready, the QmlComponentPrivate::typeDataReady() method will be invoked on + // p. The waiter is automatically removed when the typeDataReady() method + // is invoked, so there is no need to call remWaiter() in this case. + void addWaiter(QmlComponentPrivate *p); + void remWaiter(QmlComponentPrivate *p); + +private: + friend class QmlCompositeTypeManager; + friend class QmlCompiler; + friend class QmlDomDocument; + + QmlScriptParser data; + QList waiters; + QmlComponent *component; + QmlCompiledData *compiledComponent; +}; + +#endif // QMLCOMPOSITETYPEDATA_P_H + diff --git a/src/declarative/qml/qmlcompositetypemanager.cpp b/src/declarative/qml/qmlcompositetypemanager.cpp index 3037051..6f17b70 100644 --- a/src/declarative/qml/qmlcompositetypemanager.cpp +++ b/src/declarative/qml/qmlcompositetypemanager.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ +#include #include #include #include @@ -246,7 +247,7 @@ void QmlCompositeTypeManager::setData(QmlCompositeTypeData *unit, unit->errors << unit->data.errors(); } else { foreach (QmlScriptParser::Import imp, unit->data.imports()) { - if (!engine->addToImport(&unit->imports, imp.uri, imp.qualifier, imp.version, imp.type==QmlScriptParser::Import::Library ? QmlEngine::LibraryImport : QmlEngine::FileImport)) { + if (!engine->d_func()->addToImport(&unit->imports, imp.uri, imp.qualifier, imp.version, imp.type)) { QmlError error; error.setUrl(url); error.setDescription(tr("Import %1 unavailable").arg(imp.uri)); @@ -322,7 +323,7 @@ void QmlCompositeTypeManager::compile(QmlCompositeTypeData *unit) } QUrl url; - if (!engine->resolveType(unit->imports, type, &ref.type, &url)) { + if (!engine->d_func()->resolveType(unit->imports, type, &ref.type, &url)) { // XXX could produce error message here. } diff --git a/src/declarative/qml/qmlcompositetypemanager_p.h b/src/declarative/qml/qmlcompositetypemanager_p.h index 0685b03..cb0fc43 100644 --- a/src/declarative/qml/qmlcompositetypemanager_p.h +++ b/src/declarative/qml/qmlcompositetypemanager_p.h @@ -65,66 +65,8 @@ class QmlCompiledData; class QmlComponentPrivate; class QmlComponent; class QmlDomDocument; -struct QmlCompositeTypeData : public QmlRefCount -{ - QmlCompositeTypeData(); - virtual ~QmlCompositeTypeData(); - - enum Status { - Invalid, - Complete, - Error, - Waiting - }; - Status status; - enum ErrorType { - NoError, - AccessError, - GeneralError - }; - ErrorType errorType; - - QList errors; - - QmlEngine::Imports imports; - - QList dependants; - - // Return a QmlComponent if the QmlCompositeTypeData is not in the Waiting - // state. The QmlComponent is owned by the QmlCompositeTypeData, so a - // reference should be kept to keep the QmlComponent alive. - QmlComponent *toComponent(QmlEngine *); - // Return a QmlCompiledData if possible, or 0 if an error - // occurs - QmlCompiledData *toCompiledComponent(QmlEngine *); - - struct TypeReference - { - TypeReference(); - - QmlType *type; - QmlCompositeTypeData *unit; - }; - - QList types; - - // Add or remove p as a waiter. When the QmlCompositeTypeData becomes - // ready, the QmlComponentPrivate::typeDataReady() method will be invoked on - // p. The waiter is automatically removed when the typeDataReady() method - // is invoked, so there is no need to call remWaiter() in this case. - void addWaiter(QmlComponentPrivate *p); - void remWaiter(QmlComponentPrivate *p); -private: - friend class QmlCompositeTypeManager; - friend class QmlCompiler; - friend class QmlDomDocument; - - QmlScriptParser data; - QList waiters; - QmlComponent *component; - QmlCompiledData *compiledComponent; -}; +struct QmlCompositeTypeData; class QmlCompositeTypeManager : public QObject { diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp index 293ea6a..5082fda 100644 --- a/src/declarative/qml/qmldom.cpp +++ b/src/declarative/qml/qmldom.cpp @@ -41,6 +41,7 @@ #include "qmldom.h" #include "qmldom_p.h" +#include "private/qmlcompositetypedata_p.h" #include "private/qmlcompiler_p.h" #include "private/qmlengine_p.h" #include diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index 2229916..33c6710 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -1036,7 +1036,7 @@ void QmlObjectScriptClass::setProperty(QScriptValue &object, } -struct QmlEngine::ImportedNamespace { +struct QmlEnginePrivate::ImportedNamespace { QStringList urls; QStringList versions; QList isLibrary; @@ -1100,27 +1100,27 @@ struct QmlEngine::ImportedNamespace { class QmlImportsPrivate { public: - bool add(const QUrl& base, const QString& uri, const QString& prefix, const QString& version, QmlEngine::ImportType importType, const QStringList& importPath) + bool add(const QUrl& base, const QString& uri, const QString& prefix, const QString& version, QmlScriptParser::Import::Type importType, const QStringList& importPath) { - QmlEngine::ImportedNamespace *s; + QmlEnginePrivate::ImportedNamespace *s; if (prefix.isEmpty()) { - if (importType == QmlEngine::LibraryImport && version.isEmpty()) { + if (importType == QmlScriptParser::Import::Library && version.isEmpty()) { // unversioned library imports are always qualified - if only by final URI component int lastdot = uri.lastIndexOf(QLatin1Char('.')); QString defaultprefix = uri.mid(lastdot+1); s = set.value(defaultprefix); if (!s) - set.insert(defaultprefix,(s=new QmlEngine::ImportedNamespace)); + set.insert(defaultprefix,(s=new QmlEnginePrivate::ImportedNamespace)); } else { s = &unqualifiedset; } } else { s = set.value(prefix); if (!s) - set.insert(prefix,(s=new QmlEngine::ImportedNamespace)); + set.insert(prefix,(s=new QmlEnginePrivate::ImportedNamespace)); } QString url = uri; - if (importType == QmlEngine::LibraryImport) { + if (importType == QmlScriptParser::Import::Library) { url.replace(QLatin1Char('.'),QLatin1Char('/')); bool found = false; foreach (QString p, importPath) { @@ -1139,13 +1139,13 @@ public: } s->urls.append(url); s->versions.append(version); - s->isLibrary.append(importType == QmlEngine::LibraryImport); + s->isLibrary.append(importType == QmlScriptParser::Import::Library); return true; } QUrl find(const QString& type) const { - const QmlEngine::ImportedNamespace *s = 0; + const QmlEnginePrivate::ImportedNamespace *s = 0; int slash = type.indexOf(QLatin1Char('/')); if (slash >= 0) { while (!s) { @@ -1169,7 +1169,7 @@ public: QmlType *findBuiltin(const QByteArray& type, QByteArray* found=0) { - QmlEngine::ImportedNamespace *s = 0; + QmlEnginePrivate::ImportedNamespace *s = 0; int slash = type.indexOf('/'); if (slash >= 0) { while (!s) { @@ -1190,29 +1190,29 @@ public: return 0; } - QmlEngine::ImportedNamespace *findNamespace(const QString& type) + QmlEnginePrivate::ImportedNamespace *findNamespace(const QString& type) { return set.value(type); } private: - QmlEngine::ImportedNamespace unqualifiedset; - QHash set; + QmlEnginePrivate::ImportedNamespace unqualifiedset; + QHash set; }; -QmlEngine::Imports::Imports() : +QmlEnginePrivate::Imports::Imports() : d(new QmlImportsPrivate) { } -QmlEngine::Imports::~Imports() +QmlEnginePrivate::Imports::~Imports() { } /*! Sets the base URL to be used for all relative file imports added. */ -void QmlEngine::Imports::setBaseUrl(const QUrl& url) +void QmlEnginePrivate::Imports::setBaseUrl(const QUrl& url) { base = url; } @@ -1236,6 +1236,8 @@ void QmlEngine::addImportPath(const QString& path) } /*! + \internal + Adds information to \a imports such that subsequent calls to resolveType() will resolve types qualified by \a prefix by considering types found at the given \a uri. @@ -1247,16 +1249,17 @@ void QmlEngine::addImportPath(const QString& path) The base URL must already have been set with Import::setBaseUrl(). */ -bool QmlEngine::addToImport(Imports* imports, const QString& uri, const QString& prefix, const QString& version, ImportType importType) const +bool QmlEnginePrivate::addToImport(Imports* imports, const QString& uri, const QString& prefix, const QString& version, QmlScriptParser::Import::Type importType) const { - Q_D(const QmlEngine); - bool ok = imports->d->add(imports->base,uri,prefix,version,importType,d->fileImportPath); + bool ok = imports->d->add(imports->base,uri,prefix,version,importType,fileImportPath); if (qmlImportTrace()) - qDebug() << "QmlEngine::addToImport(" << imports << uri << prefix << version << (importType==LibraryImport ? "Library" : "File") << ": " << ok; + qDebug() << "QmlEngine::addToImport(" << imports << uri << prefix << version << (importType==QmlScriptParser::Import::Library? "Library" : "File") << ": " << ok; return ok; } /*! + \internal + Using the given \a imports, the given (namespace qualified) \a type is resolved to either an ImportedNamespace stored at \a ns_return, a QmlType stored at \a type_return, or @@ -1266,7 +1269,7 @@ bool QmlEngine::addToImport(Imports* imports, const QString& uri, const QString& \sa addToImport() */ -bool QmlEngine::resolveType(const Imports& imports, const QByteArray& type, QmlType** type_return, QUrl* url_return, ImportedNamespace** ns_return) const +bool QmlEnginePrivate::resolveType(const Imports& imports, const QByteArray& type, QmlType** type_return, QUrl* url_return, ImportedNamespace** ns_return) const { if (ns_return) { *ns_return = imports.d->findNamespace(QLatin1String(type)); @@ -1301,6 +1304,8 @@ bool QmlEngine::resolveType(const Imports& imports, const QByteArray& type, QmlT } /*! + \internal + Searching \e only in the namespace \a ns (previously returned in a call to resolveType(), \a type is found and returned to either a QmlType stored at \a type_return, or @@ -1308,7 +1313,7 @@ bool QmlEngine::resolveType(const Imports& imports, const QByteArray& type, QmlT If either return pointer is 0, the corresponding search is not done. */ -void QmlEngine::resolveTypeInNamespace(ImportedNamespace* ns, const QByteArray& type, QmlType** type_return, QUrl* url_return ) const +void QmlEnginePrivate::resolveTypeInNamespace(ImportedNamespace* ns, const QByteArray& type, QmlType** type_return, QUrl* url_return ) const { if (type_return) { *type_return = ns->findBuiltin(type); diff --git a/src/declarative/qml/qmlengine.h b/src/declarative/qml/qmlengine.h index 98deba7..2faad66 100644 --- a/src/declarative/qml/qmlengine.h +++ b/src/declarative/qml/qmlengine.h @@ -74,23 +74,8 @@ public: void clearComponentCache(); - struct Imports { - Imports(); - ~Imports(); - void setBaseUrl(const QUrl& url); - QUrl baseUrl() const { return base; } - private: - friend class QmlEngine; - QUrl base; - QmlImportsPrivate *d; - }; - struct ImportedNamespace; void addImportPath(const QString& dir); - enum ImportType { LibraryImport, FileImport }; - bool addToImport(Imports*, const QString& uri, const QString& prefix, const QString& version, ImportType type) const; - bool resolveType(const Imports&, const QByteArray& type, QmlType** type_return, QUrl* url_return, ImportedNamespace** ns_return=0) const; - void resolveTypeInNamespace(ImportedNamespace*, const QByteArray& type, QmlType** type_return, QUrl* url_return ) const; void setNetworkAccessManager(QNetworkAccessManager *); QNetworkAccessManager *networkAccessManager() const; diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h index af561e7..b8d49aa 100644 --- a/src/declarative/qml/qmlengine_p.h +++ b/src/declarative/qml/qmlengine_p.h @@ -172,6 +172,22 @@ public: } QmlValueTypeFactory valueTypes; + + struct Imports { + Imports(); + ~Imports(); + void setBaseUrl(const QUrl& url); + QUrl baseUrl() const { return base; } + private: + friend class QmlEnginePrivate; + QUrl base; + QmlImportsPrivate *d; + }; + struct ImportedNamespace; + bool addToImport(Imports*, const QString& uri, const QString& prefix, const QString& version, QmlScriptParser::Import::Type type) const; + bool resolveType(const Imports&, const QByteArray& type, QmlType** type_return, QUrl* url_return, ImportedNamespace** ns_return=0) const; + void resolveTypeInNamespace(ImportedNamespace*, const QByteArray& type, QmlType** type_return, QUrl* url_return ) const; + }; class QmlScriptClass : public QScriptClass -- cgit v0.12 From 73567f6bb4c730f6d3ba1a84302ae8269c13b158 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 23 Jul 2009 17:18:26 +1000 Subject: Unreverts 6fc708801b5f0a616af2cbf44859ad9f6757579e --- src/declarative/fx/qfxwebview.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/declarative/fx/qfxwebview.h b/src/declarative/fx/qfxwebview.h index 7f22439..1200162 100644 --- a/src/declarative/fx/qfxwebview.h +++ b/src/declarative/fx/qfxwebview.h @@ -96,12 +96,12 @@ class Q_DECLARATIVE_EXPORT QFxWebView : public QFxPaintedItem Q_PROPERTY(bool interactive READ interactive WRITE setInteractive NOTIFY interactiveChanged) - Q_PROPERTY(QObject* reload READ reloadAction) - Q_PROPERTY(QObject* back READ backAction) - Q_PROPERTY(QObject* forward READ forwardAction) - Q_PROPERTY(QObject* stop READ stopAction) + Q_PROPERTY(QObject* reload READ reloadAction CONSTANT) + Q_PROPERTY(QObject* back READ backAction CONSTANT) + Q_PROPERTY(QObject* forward READ forwardAction CONSTANT) + Q_PROPERTY(QObject* stop READ stopAction CONSTANT) - Q_PROPERTY(QObject* settings READ settingsObject) + Q_PROPERTY(QObject* settings READ settingsObject CONSTANT) public: QFxWebView(QFxItem *parent=0); -- cgit v0.12 From 5fe175b1b6e8434c66237dfd079b6db85ff06ae0 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Thu, 23 Jul 2009 17:20:24 +1000 Subject: Fix after Warwick's changes. --- src/declarative/util/qmlfontfamily.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/util/qmlfontfamily.cpp b/src/declarative/util/qmlfontfamily.cpp index 91d1cde..407d2ab 100644 --- a/src/declarative/util/qmlfontfamily.cpp +++ b/src/declarative/util/qmlfontfamily.cpp @@ -66,7 +66,7 @@ public: QNetworkReply *reply; }; -QML_DEFINE_TYPE(QmlFontFamily,FontFamily) +QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,FontFamily,QmlFontFamily) /*! \qmlclass FontFamily QmlFontFamily -- cgit v0.12 From 54afe4e470c365fec0bbe9f349c143dd2c84a343 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Fri, 24 Jul 2009 08:58:49 +1000 Subject: Some SameGame cleanup Mostly commenting the JS code. --- demos/declarative/samegame/SameGame.qml | 4 +- demos/declarative/samegame/content/samegame.js | 66 ++++++++++++++++++-------- 2 files changed, 48 insertions(+), 22 deletions(-) mode change 100644 => 100755 demos/declarative/samegame/content/samegame.js diff --git a/demos/declarative/samegame/SameGame.qml b/demos/declarative/samegame/SameGame.qml index 231de03..e2c2089 100644 --- a/demos/declarative/samegame/SameGame.qml +++ b/demos/declarative/samegame/SameGame.qml @@ -28,9 +28,9 @@ Rect { anchors.topMargin: 10 anchors.horizontalCenter: parent.horizontalCenter MediaButton { id: btnA; text: "New Game"; onClicked: {initBoard();} } - MediaButton { id: btnB; text: "Swap Theme"; onClicked: {swapTileSrc(); dialog.opacity = 1; + MediaButton { id: btnB; text: "Swap Tiles"; onClicked: {swapTileSrc(); dialog.opacity = 1; dialog.text="Takes effect next game.";} } - Text{ text: "Score: " + gameCanvas.score; width:100 } + Text{ text: "Score: " + gameCanvas.score; width:120; font.size:14 } } SameDialog { id: dialog diff --git a/demos/declarative/samegame/content/samegame.js b/demos/declarative/samegame/content/samegame.js old mode 100644 new mode 100755 index 6bcfd17..ef32230 --- a/demos/declarative/samegame/content/samegame.js +++ b/demos/declarative/samegame/content/samegame.js @@ -1,5 +1,6 @@ /* This script file handles the game logic */ +//Note that X/Y referred to here are in game coordinates var maxX = 10;//Nums are for tileSize 40 var maxY = 15; var tileSize = 40; @@ -19,6 +20,7 @@ function swapTileSrc(){ } } +//Index function used instead of a 2D array function index(xIdx,yIdx){ return xIdx + (yIdx * maxX); } @@ -31,12 +33,14 @@ function initBoard() board[i].destroy(); } + //Game size is as many rows/cols fit in the GameCanvas maxX = Math.floor(gameCanvas.width/tileSize); maxY = Math.floor(gameCanvas.height/tileSize); maxIndex = maxX*maxY; + + //Initialize Board board = new Array(maxIndex); gameCanvas.score = 0; - for(xIdx=0; xIdx= maxX || xIdx < 0 || yIdx >= maxY || yIdx < 0) return; if(board[index(xIdx, yIdx)] == null) return; + //If it's a valid tile, remove it and all connected + //floodFill does nothing if it's not connected to any other tiles. floodFill(xIdx,yIdx, -1, "kill"); if(fillFound <= 0) return; @@ -80,7 +91,17 @@ function handleClick(xIdx,yIdx) victoryCheck(); } -//cmd = "kill" is the removal case, cmd = "hover" is the mouse overed case +/* + the floodFill function does something on all tiles connected to the + given Game position. Connected requires the adjacency of one or more + tiles of the same type. Note that if there is no tile, or the tile + is not adjacent to a similar typed tile, then it will not do anything. + + Since many things need this flood functionality, a string command is + given telling it what to do with these tiles. + + cmd = "kill" is the removal case, cmd = "hover" sets selection +*/ function floodFill(xIdx,yIdx,type, cmd) { if(board[index(xIdx, yIdx)] == null) @@ -111,9 +132,11 @@ function floodFill(xIdx,yIdx,type, cmd) } if(cmd == "kill"){ board[index(xIdx,yIdx)].dying = true; - board[index(xIdx,yIdx)] = null;//They'll have to destroy themselves(can we do that?) + board[index(xIdx,yIdx)] = null; }else if(cmd == "hover"){ board[index(xIdx,yIdx)].selected = true; + }else if(cmd == "unhover"){ + board[index(xIdx,yIdx)].selected = false; }else{ print ("Flood Error"); } @@ -160,10 +183,11 @@ function shuffleDown() function victoryCheck() { - //awards bonuses + //awards bonuses for no tiles left deservesBonus = true; - if(board[index(0, maxY - 1)] != null) - deservesBonus = false; + for(xIdx=maxX-1; xIdx>=0; xIdx--) + if(board[index(xIdx, maxY - 1)] != null) + deservesBonus = false; if(deservesBonus) gameCanvas.score += 500; //Checks for game over @@ -175,10 +199,10 @@ function victoryCheck() function noMoreMoves() { - moreMoves = floodMoveCheck(0, maxY-1, -1); - return !moreMoves; + return !floodMoveCheck(0, maxY-1, -1); } +//only floods up and right, to see if it can find adjacent same-typed tiles function floodMoveCheck(xIdx, yIdx, type) { if(xIdx >= maxX || xIdx < 0 || yIdx >= maxY || yIdx < 0) @@ -188,17 +212,19 @@ function floodMoveCheck(xIdx, yIdx, type) myType = board[index(xIdx, yIdx)].type; if(type == myType) return true; - var at = myType; - var bt = myType; - return floodMoveCheck(xIdx + 1, yIdx, at) || floodMoveCheck(xIdx, yIdx - 1, bt); + aT = myType; + bT = myType; + return floodMoveCheck(xIdx + 1, yIdx, aT) || floodMoveCheck(xIdx, yIdx - 1, bT); } +//If the component isn't ready, then the signal doesn't include the game x,y +//So we store any x,y sent that we couldn't create at the time, and use those +//if we are triggered by the signal. //Need a simpler method of doing this? var waitStack = new Array(maxIndex); var waitTop = -1; function finishCreatingBlock(xIdx,yIdx){ - //TODO: Doc that the 'x', 'y' that were here are hidden properties from the calling QFxItem if(component.isReady){ if(xIdx == undefined){ //Called without arguments, create a previously stored (xIdx,yIdx) -- cgit v0.12