summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2009-07-23 22:59:56 (GMT)
committerAlan Alpert <alan.alpert@nokia.com>2009-07-23 22:59:56 (GMT)
commite730ab886a3e995e63125701e344d535d43b2d58 (patch)
treee862b3a8c7a032e667233ebfe65750b9553bf9e8
parent54afe4e470c365fec0bbe9f349c143dd2c84a343 (diff)
parentd40282bdf1c0524058f8871ca37dd11de95b6a4d (diff)
downloadQt-e730ab886a3e995e63125701e344d535d43b2d58.zip
Qt-e730ab886a3e995e63125701e344d535d43b2d58.tar.gz
Qt-e730ab886a3e995e63125701e344d535d43b2d58.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r--examples/declarative/scrollbar/ScrollBar.qml14
-rw-r--r--src/declarative/qml/parser/qmljs.g2
-rw-r--r--src/declarative/qml/parser/qmljsparser.cpp2
-rw-r--r--src/declarative/qml/qml.pri1
-rw-r--r--src/declarative/qml/qmlcompiler.cpp1
-rw-r--r--src/declarative/qml/qmlcomponent.cpp1
-rw-r--r--src/declarative/qml/qmlcompositetypedata_p.h123
-rw-r--r--src/declarative/qml/qmlcompositetypemanager.cpp5
-rw-r--r--src/declarative/qml/qmlcompositetypemanager_p.h60
-rw-r--r--src/declarative/qml/qmldom.cpp1
-rw-r--r--src/declarative/qml/qmlengine.cpp49
-rw-r--r--src/declarative/qml/qmlengine.h15
-rw-r--r--src/declarative/qml/qmlengine_p.h16
-rw-r--r--src/declarative/util/qmlfontfamily.cpp152
-rw-r--r--src/declarative/util/qmlfontfamily.h86
-rw-r--r--src/declarative/util/util.pri2
16 files changed, 423 insertions, 107 deletions
diff --git a/examples/declarative/scrollbar/ScrollBar.qml b/examples/declarative/scrollbar/ScrollBar.qml
index 93e4de6..84dbfd9 100644
--- a/examples/declarative/scrollbar/ScrollBar.qml
+++ b/examples/declarative/scrollbar/ScrollBar.qml
@@ -14,18 +14,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)
}
}
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<AST::UiArrayMemberList> (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<AST::UiArrayMemberList> (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/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 <private/qfxperf_p.h>
#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 <QtCore/qglobal.h>
+#include <private/qmlengine_p.h>
+
+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<QmlError> errors;
+
+ QmlEnginePrivate::Imports imports;
+
+ QList<QmlCompositeTypeData *> 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<TypeReference> 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<QmlComponentPrivate *> 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 <private/qmlcompositetypedata_p.h>
#include <private/qmlcompositetypemanager_p.h>
#include <private/qmlscriptparser_p.h>
#include <QtDeclarative/qmlengine.h>
@@ -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<QmlError> errors;
-
- QmlEngine::Imports imports;
-
- QList<QmlCompositeTypeData *> 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<TypeReference> 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<QmlComponentPrivate *> 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 <QtCore/QByteArray>
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<bool> 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<QString,QmlEngine::ImportedNamespace* > set;
+ QmlEnginePrivate::ImportedNamespace unqualifiedset;
+ QHash<QString,QmlEnginePrivate::ImportedNamespace* > 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
diff --git a/src/declarative/util/qmlfontfamily.cpp b/src/declarative/util/qmlfontfamily.cpp
new file mode 100644
index 0000000..407d2ab
--- /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 <QUrl>
+#include <QDebug>
+#include <QNetworkRequest>
+#include <QNetworkReply>
+#include <QFile>
+#include <QmlContext>
+#include <QtDeclarative/qmlengine.h>
+#include <QFontDatabase>
+
+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(Qt,4,6,(QT_VERSION&0x00ff00)>>8,FontFamily,QmlFontFamily)
+
+/*!
+ \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 <QtCore/qobject.h>
+#include <QtDeclarative/qml.h>
+
+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\