summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/QmlChanges.txt5
-rw-r--r--src/declarative/fx/fx.pri3
-rw-r--r--src/declarative/fx/qfxcomponentinstance.cpp149
-rw-r--r--src/declarative/fx/qfxcomponentinstance.h93
-rw-r--r--src/declarative/fx/qfxcomponentinstance_p.h76
-rw-r--r--src/declarative/fx/qfxgridview.h4
-rw-r--r--src/declarative/fx/qfxlistview.h22
-rw-r--r--src/declarative/fx/qfxloader.cpp260
-rw-r--r--src/declarative/fx/qfxloader.h13
-rw-r--r--src/declarative/fx/qfxloader_p.h6
-rw-r--r--src/declarative/fx/qfxpositioners.cpp12
-rw-r--r--src/declarative/fx/qfxtextinput.cpp11
-rw-r--r--src/declarative/qml/parser/qmljs.g1
-rw-r--r--src/declarative/qml/parser/qmljsastfwd_p.h4
-rw-r--r--src/declarative/qml/parser/qmljsengine_p.cpp6
-rw-r--r--src/declarative/qml/parser/qmljsengine_p.h4
-rw-r--r--src/declarative/qml/parser/qmljslexer.cpp11
-rw-r--r--src/declarative/qml/parser/qmljslexer_p.h3
-rw-r--r--src/declarative/qml/qmetaobjectbuilder_p.h8
-rw-r--r--src/declarative/qml/qmlcomponent.cpp5
-rw-r--r--src/declarative/qml/qmlrewrite.cpp4
-rw-r--r--src/declarative/util/qfxperf.cpp1
-rw-r--r--src/declarative/util/qfxperf_p.h1
-rw-r--r--src/declarative/util/qmlanimation.cpp3
24 files changed, 298 insertions, 407 deletions
diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt
index 9bf4b10..87873f2 100644
--- a/src/declarative/QmlChanges.txt
+++ b/src/declarative/QmlChanges.txt
@@ -59,6 +59,8 @@ WebView: status -> statusText
WebView: mouseX -> clickX (parameter to onDoubleClick)
WebView: mouseY -> clickY (parameter to onDoubleClick)
WebView: cacheSize -> pixelCacheSize
+Repeater: component -> delegate
+Repeater: dataSource -> model
Additions:
MouseRegion: add "acceptedButtons" property
@@ -67,6 +69,8 @@ MouseRegion: add "pressedButtons" property
Timer: add start() and stop() slots
WebView: add newWindowComponent and newWindowParent properties
Loader: add status() and progress() properties
+Loader: add sourceComponent property
+Loader: add resizeMode property
Deletions:
Column/VerticalPositioner: lost "margins" property
@@ -74,6 +78,7 @@ Row/HorizontalPositioner: lost "margins" property
Grid/Positioner/Layout: lost "margins" property
WebView: lost "interactive" property (always true now)
Flickable: removed "dragMode" property
+ComponentInstance: removed. Replaced by Loader.sourceComponent
Other Changes:
Drag: axis becomes an enum with values "XAxis", "YAxis", "XandYAxis"
diff --git a/src/declarative/fx/fx.pri b/src/declarative/fx/fx.pri
index 80a6fdd..cfe78e1 100644
--- a/src/declarative/fx/fx.pri
+++ b/src/declarative/fx/fx.pri
@@ -1,8 +1,6 @@
HEADERS += \
fx/qfxanchors.h \
fx/qfxanchors_p.h \
- fx/qfxcomponentinstance.h \
- fx/qfxcomponentinstance_p.h \
fx/qfxevents_p.h \
fx/qfxflickable.h \
fx/qfxflickable_p.h \
@@ -49,7 +47,6 @@ HEADERS += \
SOURCES += \
fx/qfxanchors.cpp \
- fx/qfxcomponentinstance.cpp \
fx/qfxevents.cpp \
fx/qfxflickable.cpp \
fx/qfxflipable.cpp \
diff --git a/src/declarative/fx/qfxcomponentinstance.cpp b/src/declarative/fx/qfxcomponentinstance.cpp
deleted file mode 100644
index 7a712aa..0000000
--- a/src/declarative/fx/qfxcomponentinstance.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-/****************************************************************************
-**
-** 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 "qfxcomponentinstance.h"
-#include "qfxcomponentinstance_p.h"
-#include <private/qfxperf_p.h>
-#include <QtDeclarative/qmlinfo.h>
-
-
-QT_BEGIN_NAMESPACE
-QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,ComponentInstance,QFxComponentInstance)
-
-/*!
- \internal
- \class QFxComponentInstance ComponentInstance
-
- \brief The QFxComponentInstance class provides a way to instantiate an item from a component.
- */
-
-/*!
- \qmlclass ComponentInstance QFxComponentInstance
- \brief The ComponentInstance item allows you to instantiate a \l{Component}.
-
- \qml
- Item {
- Component {
- id: RedSquare
- Rectangle { color: "red"; width: 10; height: 10 }
- }
-
- ComponentInstance { component: RedSquare }
- }
- \endqml
-*/
-QFxComponentInstance::QFxComponentInstance(QFxItem *parent)
- : QFxItem(*(new QFxComponentInstancePrivate), parent)
-{
-}
-
-QFxComponentInstance::QFxComponentInstance(QFxComponentInstancePrivate &dd, QFxItem *parent)
- : QFxItem(dd, parent)
-{
-}
-
-/*!
- \qmlproperty Component QFxComponentInstance::component
-
- This property holds the component to instantiate.
-*/
-QmlComponent *QFxComponentInstance::component() const
-{
- Q_D(const QFxComponentInstance);
- return d->component;
-}
-
-void QFxComponentInstance::setComponent(QmlComponent *c)
-{
- Q_D(QFxComponentInstance);
- if (d->component) {
- qmlInfo(this) << "component is a write-once property.";
- return;
- }
- d->component = c;
- create();
-}
-
-void QFxComponentInstance::create()
-{
- Q_D(QFxComponentInstance);
- if (d->component) {
- QObject *obj= d->component->create(qmlContext(this));
- if (obj) {
- QFxItem *objitem = qobject_cast<QFxItem *>(obj);
- if (objitem) {
- d->instance = objitem;
- objitem->setParentItem(this);
- objitem->setFocus(true);
- connect(objitem, SIGNAL(widthChanged()), this, SLOT(updateSize()));
- connect(objitem, SIGNAL(heightChanged()), this, SLOT(updateSize()));
- updateSize();
- emit instanceChanged();
- } else {
- delete obj;
- }
- }
- }
-}
-
-void QFxComponentInstance::updateSize()
-{
- QFxItem *i = instance();
- if (i) {
- if (!widthValid())
- setImplicitWidth(i->width());
- if (!heightValid())
- setImplicitHeight(i->height());
- }
-}
-
-/*!
- \qmlproperty Item QFxComponentInstance::instance
-
- This property holds the instantiated component.
-*/
-QFxItem *QFxComponentInstance::instance() const
-{
- Q_D(const QFxComponentInstance);
- return d->instance;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxcomponentinstance.h b/src/declarative/fx/qfxcomponentinstance.h
deleted file mode 100644
index b223ca2..0000000
--- a/src/declarative/fx/qfxcomponentinstance.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/****************************************************************************
-**
-** 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 QFXCOMPONENTINSTANCE_H
-#define QFXCOMPONENTINSTANCE_H
-
-#include <QtDeclarative/qfxitem.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-//### remove
-//### add component property to Loader
-
-class QFxComponentInstancePrivate;
-class Q_DECLARATIVE_EXPORT QFxComponentInstance : public QFxItem
-{
- Q_OBJECT
- Q_PROPERTY(QmlComponent *component READ component WRITE setComponent)
- Q_PROPERTY(QFxItem *instance READ instance)
- Q_CLASSINFO("DefaultProperty", "component")
-public:
- QFxComponentInstance(QFxItem *parent=0);
-
- QmlComponent *component() const;
- void setComponent(QmlComponent *);
-
- QFxItem *instance() const;
-
-Q_SIGNALS:
- void instanceChanged();
-
-private Q_SLOTS:
- void updateSize();
-
-private:
- void create();
-
-protected:
- QFxComponentInstance(QFxComponentInstancePrivate &dd, QFxItem *parent);
-
-private:
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QFxComponentInstance)
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QFxComponentInstance)
-
-QT_END_HEADER
-
-#endif // QFXCOMPONENTINSTANCE_H
diff --git a/src/declarative/fx/qfxcomponentinstance_p.h b/src/declarative/fx/qfxcomponentinstance_p.h
deleted file mode 100644
index defeb74..0000000
--- a/src/declarative/fx/qfxcomponentinstance_p.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** 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 QFXCOMPONENTINSTANCE_P_H
-#define QFXCOMPONENTINSTANCE_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 "qfxitem_p.h"
-
-
-QT_BEGIN_NAMESPACE
-class QFxComponentInstancePrivate : public QFxItemPrivate
-{
- Q_DECLARE_PUBLIC(QFxComponentInstance)
-
-public:
- QFxComponentInstancePrivate()
- : component(0), instance(0)
- {
- }
-
- QmlComponent *component;
- QFxItem *instance;
-};
-
-QT_END_NAMESPACE
-
-#endif // QFXCOMPONENTINSTANCE_P_H
diff --git a/src/declarative/fx/qfxgridview.h b/src/declarative/fx/qfxgridview.h
index 4ebd311..954f9fe 100644
--- a/src/declarative/fx/qfxgridview.h
+++ b/src/declarative/fx/qfxgridview.h
@@ -60,14 +60,14 @@ class Q_DECLARATIVE_EXPORT QFxGridView : public QFxFlickable
Q_PROPERTY(QVariant model READ model WRITE setModel)
Q_PROPERTY(QmlComponent *delegate READ delegate WRITE setDelegate)
Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
- Q_PROPERTY(QFxItem *current READ currentItem NOTIFY currentIndexChanged)
+ Q_PROPERTY(QFxItem *current READ currentItem NOTIFY currentIndexChanged) //### currentItem
Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_PROPERTY(QmlComponent *highlight READ highlight WRITE setHighlight)
Q_PROPERTY(bool autoHighlight READ autoHighlight WRITE setAutoHighlight)
Q_PROPERTY(Flow flow READ flow WRITE setFlow)
Q_PROPERTY(bool wrap READ isWrapEnabled WRITE setWrapEnabled)
Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer)
- Q_PROPERTY(int cellWidth READ cellWidth WRITE setCellWidth NOTIFY cellSizeChanged)
+ Q_PROPERTY(int cellWidth READ cellWidth WRITE setCellWidth NOTIFY cellSizeChanged) //### columnCount, rowCount
Q_PROPERTY(int cellHeight READ cellHeight WRITE setCellHeight NOTIFY cellSizeChanged)
Q_CLASSINFO("DefaultProperty", "data")
diff --git a/src/declarative/fx/qfxlistview.h b/src/declarative/fx/qfxlistview.h
index 42ce1a2..dc0b039 100644
--- a/src/declarative/fx/qfxlistview.h
+++ b/src/declarative/fx/qfxlistview.h
@@ -50,6 +50,11 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
+//### get rid of z = index and set known z-value (1 for items, 0 for highlight)
+//### incrementCurrentIndex(), decrementCurrentIndex() slots
+//### default Keys.OnUp/DownPressed handler
+
+
class QFxVisualModel;
class QFxListViewAttached;
class QFxListViewPrivate;
@@ -60,17 +65,17 @@ class Q_DECLARATIVE_EXPORT QFxListView : public QFxFlickable
Q_ENUMS(CurrentItemPositioning)
Q_PROPERTY(QVariant model READ model WRITE setModel)
- Q_PROPERTY(QmlComponent *delegate READ delegate WRITE setDelegate)
+ Q_PROPERTY(QmlComponent *delegate READ delegate WRITE setDelegate) //### what happens if delegate is not a QFxItem?
Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
- Q_PROPERTY(QFxItem *current READ currentItem NOTIFY currentIndexChanged)
+ Q_PROPERTY(QFxItem *current READ currentItem NOTIFY currentIndexChanged) //### currentItem
Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_PROPERTY(QmlComponent *highlight READ highlight WRITE setHighlight)
- Q_PROPERTY(bool autoHighlight READ autoHighlight WRITE setAutoHighlight)
- Q_PROPERTY(CurrentItemPositioning currentItemPositioning READ currentItemPositioning WRITE setCurrentItemPositioning)
+ Q_PROPERTY(bool autoHighlight READ autoHighlight WRITE setAutoHighlight) //### highlightFollowsCurrentItem
+ Q_PROPERTY(CurrentItemPositioning currentItemPositioning READ currentItemPositioning WRITE setCurrentItemPositioning) //### mode
Q_PROPERTY(int snapPosition READ snapPosition WRITE setSnapPosition)
- Q_PROPERTY(int spacing READ spacing WRITE setSpacing NOTIFY spacingChanged)
+ Q_PROPERTY(int spacing READ spacing WRITE setSpacing NOTIFY spacingChanged) //### qreal
Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
- Q_PROPERTY(bool wrap READ isWrapEnabled WRITE setWrapEnabled)
+ Q_PROPERTY(bool wrap READ isWrapEnabled WRITE setWrapEnabled) //### keyNavigationWraps, stops at end when held
Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer)
Q_PROPERTY(QString sectionExpression READ sectionExpression WRITE setSectionExpression NOTIFY sectionExpressionChanged)
Q_PROPERTY(QString currentSection READ currentSection NOTIFY currentSectionChanged)
@@ -98,6 +103,11 @@ public:
bool autoHighlight() const;
void setAutoHighlight(bool);
+ //### QSpan preferredHighlightRange
+ //### bool strictlyEnforceHighlightRange
+
+ //### don't jump around unnecessarily
+ //### fix highlight for snapAuto
enum CurrentItemPositioning { Free, Snap, SnapAuto };
CurrentItemPositioning currentItemPositioning() const;
void setCurrentItemPositioning(CurrentItemPositioning mode);
diff --git a/src/declarative/fx/qfxloader.cpp b/src/declarative/fx/qfxloader.cpp
index 869a5b0..e75ce6d 100644
--- a/src/declarative/fx/qfxloader.cpp
+++ b/src/declarative/fx/qfxloader.cpp
@@ -45,7 +45,7 @@
QT_BEGIN_NAMESPACE
QFxLoaderPrivate::QFxLoaderPrivate()
-: item(0), qmlcomp(0)
+: item(0), component(0), ownComponent(false), resizeMode(QFxLoader::SizeLoaderToItem)
{
}
@@ -59,9 +59,22 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Loader,QFxLoader)
\qmlclass Loader
\inherits Item
- \brief The Loader item allows you to dynamically load an Item-based
- subtree from a QML URL.
- */
+ \brief The Loader item allows dynamically loading an Item-based
+ subtree from a QML URL or Component.
+
+ Loader instantiates an item from a component. The component to
+ instantiate may be specified directly by the \c sourceComponent
+ property, or loaded from a URL via the \c source property.
+
+ It is also an effective means of delaying the creation of a component
+ until it is required:
+ \code
+ Loader { id: PageLoader }
+ Rectangle {
+ MouseRegion { anchors.fill: parent; onClicked: PageLoader.source = "Page1.qml" }
+ }
+ \endcode
+*/
/*!
\internal
@@ -86,10 +99,10 @@ QFxLoader::~QFxLoader()
/*!
\qmlproperty url Loader::source
- This property holds the dynamic URL of the QML for the item.
+ This property holds the URL of the QML component to
+ instantiate.
- This property is used for dynamically loading QML into the
- item.
+ \sa status, progress
*/
QUrl QFxLoader::source() const
{
@@ -103,44 +116,98 @@ void QFxLoader::setSource(const QUrl &url)
if (d->source == url)
return;
- if (!d->source.isEmpty()) {
- QHash<QString, QFxItem *>::Iterator iter = d->cachedChildren.find(d->source.toString());
- if (iter != d->cachedChildren.end())
- (*iter)->setOpacity(0.);
+ if (d->ownComponent) {
+ delete d->component;
+ d->component = 0;
}
-
- d->source = url;
d->item = 0;
- emit itemChanged();
+ delete d->item;
+ d->source = url;
if (d->source.isEmpty()) {
emit sourceChanged();
emit statusChanged();
emit progressChanged();
+ emit itemChanged();
+ return;
+ }
+
+ d->component = new QmlComponent(qmlEngine(this), d->source, this);
+ d->ownComponent = true;
+ if (!d->component->isLoading()) {
+ d->_q_sourceLoaded();
+ } else {
+ connect(d->component, SIGNAL(statusChanged(QmlComponent::Status)),
+ this, SLOT(_q_sourceLoaded()));
+ connect(d->component, SIGNAL(progressChanged(qreal)),
+ this, SIGNAL(progressChanged()));
+ emit statusChanged();
+ emit progressChanged();
+ emit sourceChanged();
+ emit itemChanged();
+ }
+}
+
+/*!
+ \qmlproperty Component Loader::sourceComponent
+ The sourceComponent property holds the \l{Component} to instantiate.
+
+ \qml
+ Item {
+ Component {
+ id: RedSquare
+ Rectangle { color: "red"; width: 10; height: 10 }
+ }
+
+ Loader { sourceComponent: RedSquare }
+ Loader { sourceComponent: RedSquare; x: 10 }
+ }
+ \endqml
+
+ \sa source
+*/
+
+QmlComponent *QFxLoader::sourceComponent() const
+{
+ Q_D(const QFxLoader);
+ return d->component;
+}
+
+void QFxLoader::setSourceComponent(QmlComponent *comp)
+{
+ Q_D(QFxLoader);
+ if (comp == d->component)
return;
+
+ d->source = QUrl();
+ if (d->ownComponent) {
+ delete d->component;
+ d->component = 0;
}
+ delete d->item;
+ d->item = 0;
- QHash<QString, QFxItem *>::Iterator iter = d->cachedChildren.find(d->source.toString());
- if (iter != d->cachedChildren.end()) {
- (*iter)->setOpacity(1.);
- d->item = (*iter);
+ d->component = comp;
+ d->ownComponent = false;
+ if (!d->component) {
emit sourceChanged();
emit statusChanged();
emit progressChanged();
emit itemChanged();
+ return;
+ }
+
+ if (!d->component->isLoading()) {
+ d->_q_sourceLoaded();
} else {
- d->qmlcomp =
- new QmlComponent(qmlEngine(this), d->source, this);
- if (!d->qmlcomp->isLoading()) {
- d->_q_sourceLoaded();
- } else {
- connect(d->qmlcomp, SIGNAL(statusChanged(QmlComponent::Status)),
- this, SLOT(_q_sourceLoaded()));
- connect(d->qmlcomp, SIGNAL(progressChanged(qreal)),
- this, SIGNAL(progressChanged()));
- emit statusChanged();
- emit progressChanged();
- }
+ connect(d->component, SIGNAL(statusChanged(QmlComponent::Status)),
+ this, SLOT(_q_sourceLoaded()));
+ connect(d->component, SIGNAL(progressChanged(qreal)),
+ this, SIGNAL(progressChanged()));
+ emit progressChanged();
+ emit sourceChanged();
+ emit statusChanged();
+ emit itemChanged();
}
}
@@ -148,33 +215,39 @@ void QFxLoaderPrivate::_q_sourceLoaded()
{
Q_Q(QFxLoader);
- if (qmlcomp) {
+ if (component) {
QmlContext *ctxt = new QmlContext(qmlContext(q));
ctxt->addDefaultObject(q);
- if (!qmlcomp->errors().isEmpty()) {
- qWarning() << qmlcomp->errors();
- delete qmlcomp;
- qmlcomp = 0;
+ if (!component->errors().isEmpty()) {
+ qWarning() << component->errors();
emit q->sourceChanged();
emit q->statusChanged();
emit q->progressChanged();
return;
}
- QObject *obj = qmlcomp->create(ctxt);
- if (!qmlcomp->errors().isEmpty())
- qWarning() << qmlcomp->errors();
- QFxItem *qmlChild = qobject_cast<QFxItem *>(obj);
- if (qmlChild) {
- qmlChild->setParentItem(q);
- cachedChildren.insert(source.toString(), qmlChild);
- item = qmlChild;
+
+ QObject *obj = component->create(ctxt);
+ if (obj) {
+ item = qobject_cast<QFxItem *>(obj);
+ if (item) {
+ item->setParentItem(q);
+// item->setFocus(true);
+ QFxItem *resizeItem = 0;
+ if (resizeMode == QFxLoader::SizeLoaderToItem)
+ resizeItem = item;
+ else if (resizeMode == QFxLoader::SizeItemToLoader)
+ resizeItem = q;
+ if (resizeItem) {
+ QObject::connect(resizeItem, SIGNAL(widthChanged()), q, SLOT(_q_updateSize()));
+ QObject::connect(resizeItem, SIGNAL(heightChanged()), q, SLOT(_q_updateSize()));
+ }
+ _q_updateSize();
+ }
} else {
- delete qmlChild;
+ delete obj;
source = QUrl();
}
- delete qmlcomp;
- qmlcomp = 0;
emit q->sourceChanged();
emit q->statusChanged();
emit q->progressChanged();
@@ -196,6 +269,19 @@ void QFxLoaderPrivate::_q_sourceLoaded()
\sa progress
*/
+QFxLoader::Status QFxLoader::status() const
+{
+ Q_D(const QFxLoader);
+
+ if (d->component)
+ return static_cast<QFxLoader::Status>(d->component->status());
+
+ if (d->item)
+ return Ready;
+
+ return d->source.isEmpty() ? Null : Error;
+}
+
/*!
\qmlproperty real Loader::progress
@@ -204,27 +290,89 @@ void QFxLoaderPrivate::_q_sourceLoaded()
\sa status
*/
-QFxLoader::Status QFxLoader::status() const
+qreal QFxLoader::progress() const
{
Q_D(const QFxLoader);
- if (d->qmlcomp)
- return static_cast<QFxLoader::Status>(d->qmlcomp->status());
-
if (d->item)
- return Ready;
+ return 1.0;
- return d->source.isEmpty() ? Null : Error;
+ if (d->component)
+ return d->component->progress();
+
+ return 0.0;
}
-qreal QFxLoader::progress() const
+/*!
+ \qmlproperty enum Loader::resizeMode
+
+ This property determines how the Loader or item are resized:
+ \list
+ \o NoResize - no item will be resized
+ \o SizeLoaderToItem - the Loader will be sized to the size of the item, unless the size of the Loader has been otherwise specified.
+ \o SizeItemToLoader - the item will be sized to the size of the Loader.
+ \endlist
+
+ The default resizeMode is SizeLoaderToItem.
+*/
+QFxLoader::ResizeMode QFxLoader::resizeMode() const
{
Q_D(const QFxLoader);
+ return d->resizeMode;
+}
- if (d->qmlcomp)
- return d->qmlcomp->progress();
+void QFxLoader::setResizeMode(ResizeMode mode)
+{
+ Q_D(QFxLoader);
+ if (mode == d->resizeMode)
+ return;
- return d->item ? 1.0 : 0.0;
+ if (d->item) {
+ QFxItem *resizeItem = 0;
+ if (d->resizeMode == SizeLoaderToItem)
+ resizeItem = d->item;
+ else if (d->resizeMode == SizeItemToLoader)
+ resizeItem = this;
+ if (resizeItem) {
+ disconnect(resizeItem, SIGNAL(widthChanged()), this, SLOT(_q_updateSize()));
+ disconnect(resizeItem, SIGNAL(heightChanged()), this, SLOT(_q_updateSize()));
+ }
+ }
+
+ d->resizeMode = mode;
+
+ if (d->item) {
+ QFxItem *resizeItem = 0;
+ if (d->resizeMode == SizeLoaderToItem)
+ resizeItem = d->item;
+ else if (d->resizeMode == SizeItemToLoader)
+ resizeItem = this;
+ if (resizeItem) {
+ connect(resizeItem, SIGNAL(widthChanged()), this, SLOT(_q_updateSize()));
+ connect(resizeItem, SIGNAL(heightChanged()), this, SLOT(_q_updateSize()));
+ }
+ }
+}
+
+void QFxLoaderPrivate::_q_updateSize()
+{
+ Q_Q(QFxLoader);
+ if (!item)
+ return;
+ switch (resizeMode) {
+ case QFxLoader::SizeLoaderToItem:
+ if (!q->widthValid())
+ q->setImplicitWidth(item->width());
+ if (!q->heightValid())
+ q->setImplicitHeight(item->height());
+ break;
+ case QFxLoader::SizeItemToLoader:
+ item->setWidth(q->width());
+ item->setHeight(q->height());
+ break;
+ default:
+ break;
+ }
}
/*!
diff --git a/src/declarative/fx/qfxloader.h b/src/declarative/fx/qfxloader.h
index 132c8f4..b967465 100644
--- a/src/declarative/fx/qfxloader.h
+++ b/src/declarative/fx/qfxloader.h
@@ -55,14 +55,15 @@ class Q_DECLARATIVE_EXPORT QFxLoader : public QFxItem
{
Q_OBJECT
Q_ENUMS(Status)
+ Q_ENUMS(ResizeMode)
Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
+ Q_PROPERTY(QmlComponent *sourceComponent READ sourceComponent WRITE setSourceComponent NOTIFY sourceChanged)
+ Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode)
Q_PROPERTY(QFxItem *item READ item NOTIFY itemChanged)
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
//### sourceItem
- //### sourceComponent
- //### resizeMode { NoResize, SizeLoaderToItem (default), SizeItemToLoader }
public:
QFxLoader(QFxItem *parent=0);
@@ -71,10 +72,17 @@ public:
QUrl source() const;
void setSource(const QUrl &);
+ QmlComponent *sourceComponent() const;
+ void setSourceComponent(QmlComponent *);
+
enum Status { Null, Ready, Loading, Error };
Status status() const;
qreal progress() const;
+ enum ResizeMode { NoResize, SizeLoaderToItem, SizeItemToLoader };
+ ResizeMode resizeMode() const;
+ void setResizeMode(ResizeMode mode);
+
QFxItem *item() const;
Q_SIGNALS:
@@ -87,6 +95,7 @@ private:
Q_DISABLE_COPY(QFxLoader)
Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QFxLoader)
Q_PRIVATE_SLOT(d_func(), void _q_sourceLoaded())
+ Q_PRIVATE_SLOT(d_func(), void _q_updateSize())
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxloader_p.h b/src/declarative/fx/qfxloader_p.h
index 13f3b53..0700fcd 100644
--- a/src/declarative/fx/qfxloader_p.h
+++ b/src/declarative/fx/qfxloader_p.h
@@ -69,10 +69,12 @@ public:
QUrl source;
QFxItem *item;
- QmlComponent *qmlcomp;
- QHash<QString, QFxItem *> cachedChildren;
+ QmlComponent *component;
+ bool ownComponent;
+ QFxLoader::ResizeMode resizeMode;
void _q_sourceLoaded();
+ void _q_updateSize();
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxpositioners.cpp b/src/declarative/fx/qfxpositioners.cpp
index bad4944..e4500aa 100644
--- a/src/declarative/fx/qfxpositioners.cpp
+++ b/src/declarative/fx/qfxpositioners.cpp
@@ -251,6 +251,18 @@ void QFxBasePositioner::prePositioning()
d->_animated.clear();
doPositioning();
finishApplyTransitions();
+ //Set implicit size to the size of its children
+ //###To keep this valid, do we need to update on pos change as well?
+ qreal h = 0.0f;
+ qreal w = 0.0f;
+ foreach(QFxItem *child, d->_items){
+ if(!child->isVisible() || child->opacity() <= 0)
+ continue;
+ h = qMax(h, child->y() + child->height());
+ w = qMax(w, child->x() + child->width());
+ }
+ setImplicitHeight(h);
+ setImplicitWidth(w);
}
void QFxBasePositioner::applyTransition(const QList<QPair<QString, QVariant> >& changes, QFxItem* target, QmlStateOperation::ActionList &actions)
diff --git a/src/declarative/fx/qfxtextinput.cpp b/src/declarative/fx/qfxtextinput.cpp
index 4dd29cd..39a0187 100644
--- a/src/declarative/fx/qfxtextinput.cpp
+++ b/src/declarative/fx/qfxtextinput.cpp
@@ -480,6 +480,13 @@ void QFxTextInput::focusChanged(bool hasFocus)
void QFxTextInput::keyPressEvent(QKeyEvent* ev)
{
Q_D(QFxTextInput);
+ if((d->control->cursor() == 0 && ev->key() == Qt::Key_Left)
+ || (d->control->cursor() == d->control->text().length()
+ && ev->key() == Qt::Key_Right)){
+ //ignore moving off the end
+ ev->ignore();
+ return;
+ }
d->control->processKeyEvent(ev);
if (!ev->isAccepted())
QFxPaintedItem::keyPressEvent(ev);
@@ -500,6 +507,7 @@ bool QFxTextInput::event(QEvent* ev)
Q_D(QFxTextInput);
//Anything we don't deal with ourselves, pass to the control
switch(ev->type()){
+ case QEvent::KeyPress:
case QEvent::GraphicsSceneMousePress:
break;
default:
@@ -645,7 +653,8 @@ void QFxTextInput::updateSize()
setImplicitHeight(d->control->height());
//d->control->width() is max width, not current width
QFontMetrics fm = QFontMetrics(d->font);
- setImplicitWidth(fm.boundingRect(d->control->text()).width()+1);
+ setImplicitWidth(fm.width(d->control->text())+1);
+ //setImplicitWidth(d->control->naturalWidth());//### This fn should be coming into 4.6 shortly, and might be faster
setContentsSize(QSize(width(), height()));
}
diff --git a/src/declarative/qml/parser/qmljs.g b/src/declarative/qml/parser/qmljs.g
index b0ef866..4ed75e8 100644
--- a/src/declarative/qml/parser/qmljs.g
+++ b/src/declarative/qml/parser/qmljs.g
@@ -80,6 +80,7 @@
%token T_DEBUGGER "debugger"
%token T_RESERVED_WORD "reserved word"
%token T_MULTILINE_STRING_LITERAL "multiline string literal"
+%token T_COMMENT "comment"
--- context keywords.
%token T_PUBLIC "public"
diff --git a/src/declarative/qml/parser/qmljsastfwd_p.h b/src/declarative/qml/parser/qmljsastfwd_p.h
index f79cfc2..a6fee1d 100644
--- a/src/declarative/qml/parser/qmljsastfwd_p.h
+++ b/src/declarative/qml/parser/qmljsastfwd_p.h
@@ -62,9 +62,9 @@ namespace QmlJS { namespace AST {
class SourceLocation
{
public:
- SourceLocation(quint32 offset = 0, quint32 length = 0)
+ SourceLocation(quint32 offset = 0, quint32 length = 0, quint32 line = 0, quint32 column = 0)
: offset(offset), length(length),
- startLine(0), startColumn(0)
+ startLine(line), startColumn(column)
{ }
bool isValid() const { return length != 0; }
diff --git a/src/declarative/qml/parser/qmljsengine_p.cpp b/src/declarative/qml/parser/qmljsengine_p.cpp
index 02d9b9c..eab8944 100644
--- a/src/declarative/qml/parser/qmljsengine_p.cpp
+++ b/src/declarative/qml/parser/qmljsengine_p.cpp
@@ -178,6 +178,12 @@ Engine::~Engine()
QSet<NameId> Engine::literals() const
{ return _literals; }
+void Engine::addComment(int pos, int len, int line, int col)
+{ if (len > 0) _comments.append(QmlJS::AST::SourceLocation(pos, len, line, col)); }
+
+QList<QmlJS::AST::SourceLocation> Engine::comments() const
+{ return _comments; }
+
NameId *Engine::intern(const QChar *u, int s)
{ return const_cast<NameId *>(&*_literals.insert(NameId(u, s))); }
diff --git a/src/declarative/qml/parser/qmljsengine_p.h b/src/declarative/qml/parser/qmljsengine_p.h
index 5aea983..877fff2 100644
--- a/src/declarative/qml/parser/qmljsengine_p.h
+++ b/src/declarative/qml/parser/qmljsengine_p.h
@@ -143,6 +143,7 @@ class Engine
Lexer *_lexer;
NodePool *_nodePool;
QSet<NameId> _literals;
+ QList<QmlJS::AST::SourceLocation> _comments;
public:
Engine();
@@ -150,6 +151,9 @@ public:
QSet<NameId> literals() const;
+ void addComment(int pos, int len, int line, int col);
+ QList<QmlJS::AST::SourceLocation> comments() const;
+
NameId *intern(const QChar *u, int s);
static QString toString(NameId *id);
diff --git a/src/declarative/qml/parser/qmljslexer.cpp b/src/declarative/qml/parser/qmljslexer.cpp
index 9da6ec0..f302733 100644
--- a/src/declarative/qml/parser/qmljslexer.cpp
+++ b/src/declarative/qml/parser/qmljslexer.cpp
@@ -71,7 +71,7 @@ extern double integerFromString(const char *buf, int size, int radix);
using namespace QmlJS;
-Lexer::Lexer(Engine *eng)
+Lexer::Lexer(Engine *eng, bool tokenizeComments)
: driver(eng),
yylineno(0),
done(false),
@@ -94,7 +94,8 @@ Lexer::Lexer(Engine *eng)
check_reserved(true),
parenthesesState(IgnoreParentheses),
parenthesesCount(0),
- prohibitAutomaticSemicolon(false)
+ prohibitAutomaticSemicolon(false),
+ tokenizeComments(tokenizeComments)
{
driver->setLexer(this);
// allocate space for read buffers
@@ -647,22 +648,28 @@ int Lexer::lex()
setDone(Other);
} else
state = Start;
+ driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
} else if (current == 0) {
+ driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
setDone(Eof);
}
+
break;
case InMultiLineComment:
if (current == 0) {
setDone(Bad);
err = UnclosedComment;
errmsg = QLatin1String("Unclosed comment at end of file");
+ driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
} else if (isLineTerminator()) {
shiftWindowsLineBreak();
yylineno++;
} else if (current == '*' && next1 == '/') {
state = Start;
shift(1);
+ driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
}
+
break;
case InIdentifier:
if (isIdentLetter(current) || isDecimalDigit(current)) {
diff --git a/src/declarative/qml/parser/qmljslexer_p.h b/src/declarative/qml/parser/qmljslexer_p.h
index 5817868..6cca45d 100644
--- a/src/declarative/qml/parser/qmljslexer_p.h
+++ b/src/declarative/qml/parser/qmljslexer_p.h
@@ -67,7 +67,7 @@ class NameId;
class Lexer
{
public:
- Lexer(Engine *eng);
+ Lexer(Engine *eng, bool tokenizeComments = false);
~Lexer();
void setCode(const QString &c, int lineno);
@@ -239,6 +239,7 @@ private:
ParenthesesState parenthesesState;
int parenthesesCount;
bool prohibitAutomaticSemicolon;
+ bool tokenizeComments;
};
} // namespace QmlJS
diff --git a/src/declarative/qml/qmetaobjectbuilder_p.h b/src/declarative/qml/qmetaobjectbuilder_p.h
index d503163..c0b7426 100644
--- a/src/declarative/qml/qmetaobjectbuilder_p.h
+++ b/src/declarative/qml/qmetaobjectbuilder_p.h
@@ -68,7 +68,7 @@ class QMetaPropertyBuilderPrivate;
class QMetaEnumBuilder;
class QMetaEnumBuilderPrivate;
-class Q_CORE_EXPORT QMetaObjectBuilder
+class Q_DECLARATIVE_EXPORT QMetaObjectBuilder
{
public:
enum AddMember
@@ -189,7 +189,7 @@ private:
friend class QMetaEnumBuilder;
};
-class Q_CORE_EXPORT QMetaMethodBuilder
+class Q_DECLARATIVE_EXPORT QMetaMethodBuilder
{
public:
QMetaMethodBuilder() : _mobj(0), _index(0) {}
@@ -227,7 +227,7 @@ private:
QMetaMethodBuilderPrivate *d_func() const;
};
-class Q_CORE_EXPORT QMetaPropertyBuilder
+class Q_DECLARATIVE_EXPORT QMetaPropertyBuilder
{
public:
QMetaPropertyBuilder() : _mobj(0), _index(0) {}
@@ -278,7 +278,7 @@ private:
QMetaPropertyBuilderPrivate *d_func() const;
};
-class Q_CORE_EXPORT QMetaEnumBuilder
+class Q_DECLARATIVE_EXPORT QMetaEnumBuilder
{
public:
QMetaEnumBuilder() : _mobj(0), _index(0) {}
diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp
index f291ac0..1c35606 100644
--- a/src/declarative/qml/qmlcomponent.cpp
+++ b/src/declarative/qml/qmlcomponent.cpp
@@ -91,8 +91,8 @@ Item {
height: 10
}
}
- ComponentInstance { component: RedSquare }
- ComponentInstance { component: RedSquare; x: 20 }
+ Loader { sourceComponent: RedSquare }
+ Loader { sourceComponent: RedSquare; x: 20 }
}
\endqml
*/
@@ -328,6 +328,7 @@ QmlComponent::QmlComponent(QmlEngine *engine, QmlCompiledData *cc, int start, in
d->start = start;
d->count = count;
d->url = cc->url;
+ d->progress = 1.0;
}
/*!
diff --git a/src/declarative/qml/qmlrewrite.cpp b/src/declarative/qml/qmlrewrite.cpp
index 3f35160..5166c96 100644
--- a/src/declarative/qml/qmlrewrite.cpp
+++ b/src/declarative/qml/qmlrewrite.cpp
@@ -73,8 +73,8 @@ QString RewriteBinding::rewrite(QString code, unsigned position,
unsigned startOfStatement = node->firstSourceLocation().begin() - _position;
unsigned endOfStatement = node->lastSourceLocation().end() - _position;
- _writer->replace(startOfStatement, 0, QLatin1String("(function() {\n"));
- _writer->replace(endOfStatement, 0, QLatin1String("\n})"));
+ _writer->replace(startOfStatement, 0, QLatin1String("(function() { "));
+ _writer->replace(endOfStatement, 0, QLatin1String(" })"));
w.write(&code);
diff --git a/src/declarative/util/qfxperf.cpp b/src/declarative/util/qfxperf.cpp
index 90f639e..739e480 100644
--- a/src/declarative/util/qfxperf.cpp
+++ b/src/declarative/util/qfxperf.cpp
@@ -58,7 +58,6 @@ Q_DEFINE_PERFORMANCE_LOG(QFxPerf, "QFx") {
Q_DEFINE_PERFORMANCE_METRIC(CreateParticle, " QFxParticles: Particle creation")
Q_DEFINE_PERFORMANCE_METRIC(ItemComponentComplete, " QFxItem::componentComplete")
Q_DEFINE_PERFORMANCE_METRIC(ImageComponentComplete, " QFxImage::componentComplete")
- Q_DEFINE_PERFORMANCE_METRIC(ComponentInstanceComponentComplete, " QFxComponentInstance::componentComplete")
Q_DEFINE_PERFORMANCE_METRIC(BaseLayoutComponentComplete, " QFxBasePositioner::componentComplete")
Q_DEFINE_PERFORMANCE_METRIC(TextComponentComplete, " QFxText::componentComplete")
Q_DEFINE_PERFORMANCE_METRIC(QFxText_setText, " QFxText::setText")
diff --git a/src/declarative/util/qfxperf_p.h b/src/declarative/util/qfxperf_p.h
index a1e38b7..cea7e80 100644
--- a/src/declarative/util/qfxperf_p.h
+++ b/src/declarative/util/qfxperf_p.h
@@ -77,7 +77,6 @@ Q_DECLARE_PERFORMANCE_LOG(QFxPerf) {
Q_DECLARE_PERFORMANCE_METRIC(CreateParticle)
Q_DECLARE_PERFORMANCE_METRIC(ItemComponentComplete)
Q_DECLARE_PERFORMANCE_METRIC(ImageComponentComplete)
- Q_DECLARE_PERFORMANCE_METRIC(ComponentInstanceComponentComplete)
Q_DECLARE_PERFORMANCE_METRIC(BaseLayoutComponentComplete)
Q_DECLARE_PERFORMANCE_METRIC(TextComponentComplete)
Q_DECLARE_PERFORMANCE_METRIC(QFxText_setText)
diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp
index 6047d4a..3edbc5f 100644
--- a/src/declarative/util/qmlanimation.cpp
+++ b/src/declarative/util/qmlanimation.cpp
@@ -1442,8 +1442,7 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,ParallelAnimation,QmlParallelAni
void QmlPropertyAnimationPrivate::convertVariant(QVariant &variant, int type)
{
if (variant.type() != QVariant::String) {
- if ((uint)type < QVariant::UserType)
- variant.convert((QVariant::Type)type);
+ variant.convert((QVariant::Type)type);
return;
}