From 603cfb5665f10e0cbef3d67df04e33d3e1e2b5f2 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 17 Jul 2009 14:25:03 +1000 Subject: WidgetContainer renamed to GraphicsObjectContainer. Also corrected handling of scene change. --- src/declarative/fx/fx.pri | 4 +- src/declarative/fx/qfxgraphicsobjectcontainer.cpp | 98 +++++++++++++++++++++++ src/declarative/fx/qfxgraphicsobjectcontainer.h | 82 +++++++++++++++++++ src/declarative/fx/qfxwidgetcontainer.cpp | 97 ---------------------- src/declarative/fx/qfxwidgetcontainer.h | 82 ------------------- 5 files changed, 182 insertions(+), 181 deletions(-) create mode 100644 src/declarative/fx/qfxgraphicsobjectcontainer.cpp create mode 100644 src/declarative/fx/qfxgraphicsobjectcontainer.h delete mode 100644 src/declarative/fx/qfxwidgetcontainer.cpp delete mode 100644 src/declarative/fx/qfxwidgetcontainer.h diff --git a/src/declarative/fx/fx.pri b/src/declarative/fx/fx.pri index 413b8db..24c5536 100644 --- a/src/declarative/fx/fx.pri +++ b/src/declarative/fx/fx.pri @@ -40,7 +40,7 @@ HEADERS += \ fx/qfxpixmap.cpp \ fx/qfxvisualitemmodel.h \ fx/qfxlistview.h \ - fx/qfxwidgetcontainer.h \ + fx/qfxgraphicsobjectcontainer.h \ SOURCES += \ fx/qfxanchors.cpp \ @@ -69,7 +69,7 @@ SOURCES += \ fx/qfxpixmap.cpp \ fx/qfxvisualitemmodel.cpp \ fx/qfxlistview.cpp \ - fx/qfxwidgetcontainer.cpp \ + fx/qfxgraphicsobjectcontainer.cpp \ contains(QT_CONFIG, webkit) { QT+=webkit diff --git a/src/declarative/fx/qfxgraphicsobjectcontainer.cpp b/src/declarative/fx/qfxgraphicsobjectcontainer.cpp new file mode 100644 index 0000000..479a21d --- /dev/null +++ b/src/declarative/fx/qfxgraphicsobjectcontainer.cpp @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** 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 "qfxgraphicsobjectcontainer.h" +#include + +QT_BEGIN_NAMESPACE + +/*! + \qmlclass GraphicsObjectContainer QFxGraphicsObjectContainer + \brief The GraphicsObjectContainer element allows you to add QGraphicsObjects into Fluid UI elements. +*/ + +/*! + \internal + \class QFxGraphicsObjectContainer + \brief The QFxGraphicsObjectContainer class allows you to add QGraphicsObjects into Fluid UI applications. +*/ + +QML_DEFINE_TYPE(QFxGraphicsObjectContainer, GraphicsObjectContainer) + +QFxGraphicsObjectContainer::QFxGraphicsObjectContainer(QFxItem *parent) +: QFxItem(parent), _graphicsObject(0) +{ +} + +QFxGraphicsObjectContainer::~QFxGraphicsObjectContainer() +{ +} + +QGraphicsObject *QFxGraphicsObjectContainer::graphicsObject() const +{ + return _graphicsObject; +} + +/*! + \qmlproperty QGraphicsObject GraphicsObjectContainer::graphicsObject + The QGraphicsObject associated with this element. +*/ +void QFxGraphicsObjectContainer::setGraphicsObject(QGraphicsObject *object) +{ + if (object == _graphicsObject) + return; + + _graphicsObject = object; + + _graphicsObject->setParentItem(this); +} + +QVariant QFxGraphicsObjectContainer::itemChange(GraphicsItemChange change, const QVariant &value) +{ + if (change == ItemSceneHasChanged) { + QGraphicsObject *o = _graphicsObject; + _graphicsObject = 0; + setGraphicsObject(o); + } + return QFxItem::itemChange(change, value); +} + +QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxgraphicsobjectcontainer.h b/src/declarative/fx/qfxgraphicsobjectcontainer.h new file mode 100644 index 0000000..e118555 --- /dev/null +++ b/src/declarative/fx/qfxgraphicsobjectcontainer.h @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** 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 QFXGRAPHICSOBJECTCONTAINER_H +#define QFXGRAPHICSOBJECTCONTAINER_H + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QGraphicsObject; + +class Q_DECLARATIVE_EXPORT QFxGraphicsObjectContainer : public QFxItem +{ + Q_OBJECT + + Q_CLASSINFO("DefaultProperty", "graphicsObject") + Q_PROPERTY(QGraphicsObject *graphicsObject READ graphicsObject WRITE setGraphicsObject) + +public: + QFxGraphicsObjectContainer(QFxItem *parent = 0); + ~QFxGraphicsObjectContainer(); + + QGraphicsObject *graphicsObject() const; + void setGraphicsObject(QGraphicsObject *); + +protected: + QVariant itemChange(GraphicsItemChange change, const QVariant &value); + +private: + QGraphicsObject *_graphicsObject; +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QFxGraphicsObjectContainer) + +QT_END_HEADER + +#endif // QFXGRAPHICSOBJECTCONTAINER_H diff --git a/src/declarative/fx/qfxwidgetcontainer.cpp b/src/declarative/fx/qfxwidgetcontainer.cpp deleted file mode 100644 index ea702db..0000000 --- a/src/declarative/fx/qfxwidgetcontainer.cpp +++ /dev/null @@ -1,97 +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 "qfxwidgetcontainer.h" -#include - -QT_BEGIN_NAMESPACE - -/*! - \qmlclass WidgetContainer QFxWidgetContainer - \brief The WidgetContainer element allows you to add QGraphicsWidgets into Fluid UI elements. -*/ - -/*! - \internal - \class QFxWidgetContainer - \brief The QFxWidgetContainer class allows you to add QGraphicsWidgets into Fluid UI applications. -*/ - -QML_DEFINE_TYPE(QFxWidgetContainer, WidgetContainer) - -QFxWidgetContainer::QFxWidgetContainer(QFxItem *parent) -: QFxItem(parent), _graphicsWidget(0) -{ -} - -QFxWidgetContainer::~QFxWidgetContainer() -{ -} - -QGraphicsWidget *QFxWidgetContainer::graphicsWidget() const -{ - return _graphicsWidget; -} - -/*! - \qmlproperty QGraphicsWidget QFxWidgetContainer::graphicsWidget - The QGraphicsWidget associated with this element. -*/ -void QFxWidgetContainer::setGraphicsWidget(QGraphicsWidget *widget) -{ - if (widget == _graphicsWidget) - return; - - _graphicsWidget = widget; - - _graphicsWidget->setParentItem(this); -} - -void QFxWidgetContainer::canvasChanged() -{ - if (_graphicsWidget) { - QGraphicsWidget *w = _graphicsWidget; - _graphicsWidget = 0; - setGraphicsWidget(w); - } -} - -QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxwidgetcontainer.h b/src/declarative/fx/qfxwidgetcontainer.h deleted file mode 100644 index 862a280..0000000 --- a/src/declarative/fx/qfxwidgetcontainer.h +++ /dev/null @@ -1,82 +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 QFXWIDGETCONTAINER_H -#define QFXWIDGETCONTAINER_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QGraphicsWidget; - -class Q_DECLARATIVE_EXPORT QFxWidgetContainer : public QFxItem -{ - Q_OBJECT - - Q_CLASSINFO("DefaultProperty", "graphicsWidget") - Q_PROPERTY(QGraphicsWidget *graphicsWidget READ graphicsWidget WRITE setGraphicsWidget) - -public: - QFxWidgetContainer(QFxItem *parent = 0); - ~QFxWidgetContainer(); - - QGraphicsWidget *graphicsWidget() const; - void setGraphicsWidget(QGraphicsWidget *); - -protected: - virtual void canvasChanged(); - -private: - QGraphicsWidget *_graphicsWidget; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QFxWidgetContainer) - -QT_END_HEADER - -#endif // QFXGRAPHICSWIDGET_H -- cgit v0.12 From 43a497cac00a93f015ec62339529f36ba3f19ece Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 17 Jul 2009 14:28:12 +1000 Subject: Update list of elements in doc. --- doc/src/declarative/elements.qdoc | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc index eda9079..e6e31f4 100644 --- a/doc/src/declarative/elements.qdoc +++ b/doc/src/declarative/elements.qdoc @@ -74,14 +74,12 @@ The following table lists the Qml elements provided by the Qt Declarative module \o \l TextEdit \o \l Rect \o \l AnimatedImage -\o \l BlendedImage \endlist \o \list \o \l MouseRegion \o \l KeyActions -\o \l FocusPanel \o \l FocusRealm \o \l KeyProxy \endlist @@ -96,12 +94,8 @@ The following table lists the Qml elements provided by the Qt Declarative module \o \list \o \l Repeater -\o \l ContentWrapper - \list - \o \l Content - \endlist \o \l ComponentInstance -\o \l WidgetContainer +\o \l GraphicsObjectContainer \endlist \header @@ -147,10 +141,6 @@ The following table lists the Qml elements provided by the Qt Declarative module \o \list -\o \l Shadow -\o \l Reflection -\o \l Blur -\o \l Highlight \o \l Particles \list \o \l ParticleMotionLinear -- cgit v0.12 From dff083ccb6971fa28d838493353857783297b4a9 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Fri, 17 Jul 2009 16:48:36 +1000 Subject: Remove debuggery --- src/declarative/qml/qmlcompositetypemanager.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/declarative/qml/qmlcompositetypemanager.cpp b/src/declarative/qml/qmlcompositetypemanager.cpp index 9af5c3c..3037051 100644 --- a/src/declarative/qml/qmlcompositetypemanager.cpp +++ b/src/declarative/qml/qmlcompositetypemanager.cpp @@ -251,7 +251,6 @@ void QmlCompositeTypeManager::setData(QmlCompositeTypeData *unit, error.setUrl(url); error.setDescription(tr("Import %1 unavailable").arg(imp.uri)); unit->errors << error; -qDebug() << "ERR"; ok = false; } } -- cgit v0.12 From 4937b60008fcb0923f30f976556f427495695a91 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 17 Jul 2009 16:55:13 +1000 Subject: "snow" demo --- examples/declarative/snow/ImageBatch.qml | 79 ++++++++++++++++++++++++++++++++ examples/declarative/snow/Loading.qml | 6 +++ examples/declarative/snow/create.js | 13 ++++++ examples/declarative/snow/snow.qml | 72 +++++++++++++++++++++++++++++ 4 files changed, 170 insertions(+) create mode 100644 examples/declarative/snow/ImageBatch.qml create mode 100644 examples/declarative/snow/Loading.qml create mode 100644 examples/declarative/snow/create.js create mode 100644 examples/declarative/snow/snow.qml diff --git a/examples/declarative/snow/ImageBatch.qml b/examples/declarative/snow/ImageBatch.qml new file mode 100644 index 0000000..f7ae8b1 --- /dev/null +++ b/examples/declarative/snow/ImageBatch.qml @@ -0,0 +1,79 @@ +GridView { + id: MyGrid + property int offset: 0 + property var ref + property bool isSelected: ref.selectedItemColumn >= offset && ref.selectedItemColumn < offset + 5 + + currentIndex: (ref.selectedItemColumn - offset) + ref.selectedItemRow * 5 + + property int imageWidth: ref.imageWidth + property int imageHeight: ref.imageHeight + + width: 5 * imageWidth + height: 4 * imageHeight + cellWidth: imageWidth + cellHeight: imageHeight + + states: State { + name: "selected"; when: MyGrid.isSelected + SetProperties { target: MyGrid; z: 150 } + } + transitions: Transition { + SequentialAnimation { + PauseAnimation { duration: 150 } + SetPropertyAction { properties: "z" } + } + } + model: XmlListModel { + property string tags : "" + source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+tags+"&" : "")+"format=rss2" + query: "/rss/channel/item" + namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";" + + XmlRole { name: "title"; query: "title/string()" } + XmlRole { name: "imagePath"; query: "media:thumbnail/@url/string()" } + XmlRole { name: "url"; query: "media:content/@url/string()" } + XmlRole { name: "description"; query: "description/string()" } + XmlRole { name: "tags"; query: "media:category/string()" } + XmlRole { name: "photoWidth"; query: "media:content/@width/string()" } + XmlRole { name: "photoHeight"; query: "media:content/@height/string()" } + XmlRole { name: "photoType"; query: "media:content/@type/string()" } + XmlRole { name: "photoAuthor"; query: "author/string()" } + XmlRole { name: "photoDate"; query: "pubDate/string()" } + } + + Item { + id: Root + property bool isSelected: GridView.isCurrentItem && MyGrid.isSelected + transformOrigin: "Center" + width: MyGrid.imageWidth; height: MyGrid.imageHeight; + + Image { id: Image; source: url; preserveAspect: true; smooth: true; anchors.fill: parent; + opacity: (status == 0)?1:0; opacity: Behavior { NumberAnimation { properties: "opacity" } } } + Loading { anchors.centeredIn: parent; visible: Image.status } + + states: State { + name: "selected" + when: Root.isSelected + SetProperties { target: Root; scale: 3; z: 100 } + } + transitions: [ + Transition { + toState: "selected" + SequentialAnimation { + PauseAnimation { duration: 150 } + SetPropertyAction { properties: "z" } + NumberAnimation { properties: "scale"; duration: 150; } + } + }, + Transition { + fromState: "selected" + SequentialAnimation { + NumberAnimation { properties: "scale"; duration: 150 } + SetPropertyAction { properties: "z" } + } + } + ] + } +} + diff --git a/examples/declarative/snow/Loading.qml b/examples/declarative/snow/Loading.qml new file mode 100644 index 0000000..0a8a51a --- /dev/null +++ b/examples/declarative/snow/Loading.qml @@ -0,0 +1,6 @@ +Image { + id: Loading; source: "pics/loading.png"; transformOrigin: "Center" + rotation: NumberAnimation { + id: "RotationAnimation"; from: 0; to: 360; running: Loading.visible == true; repeat: true; duration: 900 + } +} diff --git a/examples/declarative/snow/create.js b/examples/declarative/snow/create.js new file mode 100644 index 0000000..51f870d --- /dev/null +++ b/examples/declarative/snow/create.js @@ -0,0 +1,13 @@ +var myComponent = null; + +function createNewBlock() { + if (myComponent == null) + myComponent = createComponent("ImageBatch.qml"); + + var obj = myComponent.createObject(); + obj.parent = MyLayout; + obj.offset = maximumColumn + 1; + obj.ref = ImagePanel; + maximumColumn += 5; +} + diff --git a/examples/declarative/snow/snow.qml b/examples/declarative/snow/snow.qml new file mode 100644 index 0000000..b73c2d2 --- /dev/null +++ b/examples/declarative/snow/snow.qml @@ -0,0 +1,72 @@ +Rect { + id: ImagePanel + width: 1024 + height: 768 + color: "black" + + property int maximumColumn: 4 + property int selectedItemRow: 0 + property int selectedItemColumn: 0 + + Script { source: "create.js" } + + onSelectedItemColumnChanged: if (selectedItemColumn == maximumColumn) createNewBlock(); + + property int imageWidth: 200 + property int imageHeight: 200 + + property int selectedX: selectedItemColumn * imageWidth + property int selectedY: selectedItemRow * imageHeight + + Item { + anchors.centeredIn: parent + HorizontalLayout { + id: MyLayout + property real targetX: -(selectedX + imageWidth / 2) + + property real targetDeform: 0 + property bool slowDeform: true + + property real deform + deform: Follow { source: MyLayout.targetDeform; velocity: MyLayout.slowDeform?0.1:2 } + + onDeformChanged: if(deform == targetDeform) { slowDeform = true; targetDeform = 0; } + + ImageBatch { offset: 0; ref: ImagePanel } + + x: Follow { source: MyLayout.targetX; velocity: 1000 } + y: Follow { source: -(selectedY + imageHeight / 2); velocity: 500 } + } + + transform: Rotation3D { + axis { startX: 0; startY: 0; endX: 0; endY: 1 } + angle: MyLayout.deform * 100 + } + + } + + Script { + function leftPressed() { + if (selectedItemColumn <= 0) return; + selectedItemColumn -= 1; + MyLayout.slowDeform = false; + MyLayout.targetDeform = Math.max(Math.min(MyLayout.deform - 0.1, -0.1), -0.4); + } + function rightPressed() { + selectedItemColumn += 1; + MyLayout.slowDeform = false; + MyLayout.targetDeform = Math.min(Math.max(MyLayout.deform + 0.1, 0.1), 0.4); + } + } + KeyActions { + focus: true + leftArrow: "leftPressed()" + rightArrow: "rightPressed()" + upArrow: "if (selectedItemRow > 0) selectedItemRow = selectedItemRow - 1" + downArrow: "if (selectedItemRow < 3) selectedItemRow = selectedItemRow + 1" + } + + Text { + text: MyLayout.deform + } +} -- cgit v0.12 From 76002f882a260082ca17b6f82130eb38db89adff Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 17 Jul 2009 16:55:44 +1000 Subject: Add a preserveAspect property to Image --- src/declarative/fx/qfximage.cpp | 33 +++++++++++++++++++++++++++++++-- src/declarative/fx/qfximage.h | 4 ++++ src/declarative/fx/qfximage_p.h | 4 +++- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp index 148c269..34ff157 100644 --- a/src/declarative/fx/qfximage.cpp +++ b/src/declarative/fx/qfximage.cpp @@ -339,9 +339,22 @@ void QFxImage::paintContents(QPainter &p) p.restore(); } else if (!d->scaleGrid || d->scaleGrid->isNull()) { if (width() != pix.width() || height() != pix.height()) { + qreal widthScale = width() / qreal(pix.width()); + qreal heightScale = height() / qreal(pix.height()); + QTransform scale; - scale.scale(width() / qreal(pix.width()), - height() / qreal(pix.height())); + + if (d->preserveAspect) { + if (widthScale < heightScale) { + heightScale = widthScale; + scale.translate(0, (height() - heightScale * pix.height()) / 2); + } else if(heightScale < widthScale) { + widthScale = heightScale; + scale.translate((width() - widthScale * pix.width()) / 2, 0); + } + } + + scale.scale(widthScale, heightScale); QTransform old = p.transform(); p.setWorldTransform(scale * old); p.drawPixmap(0, 0, pix); @@ -486,6 +499,22 @@ QUrl QFxImage::source() const return d->url; } +bool QFxImage::preserveAspect() const +{ + Q_D(const QFxImage); + return d->preserveAspect; +} + +void QFxImage::setPreserveAspect(bool p) +{ + Q_D(QFxImage); + + if (p == d->preserveAspect) + return; + d->preserveAspect = p; + update(); +} + void QFxImage::setSource(const QUrl &url) { #ifdef Q_ENABLE_PERFORMANCE_LOG diff --git a/src/declarative/fx/qfximage.h b/src/declarative/fx/qfximage.h index 925a520..bc63d7a 100644 --- a/src/declarative/fx/qfximage.h +++ b/src/declarative/fx/qfximage.h @@ -66,6 +66,7 @@ class Q_DECLARATIVE_EXPORT QFxImage : public QFxItem Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap DESIGNABLE false) Q_PROPERTY(bool opaque READ isOpaque WRITE setOpaque) Q_PROPERTY(bool smooth READ smoothTransform WRITE setSmoothTransform) + Q_PROPERTY(bool preserveAspect READ preserveAspect WRITE setPreserveAspect); public: QFxImage(QFxItem *parent=0); ~QFxImage(); @@ -88,6 +89,9 @@ public: Status status() const; qreal progress() const; + bool preserveAspect() const; + void setPreserveAspect(bool); + QUrl source() const; virtual void setSource(const QUrl &url); diff --git a/src/declarative/fx/qfximage_p.h b/src/declarative/fx/qfximage_p.h index e4a3a90..de7ebe6 100644 --- a/src/declarative/fx/qfximage_p.h +++ b/src/declarative/fx/qfximage_p.h @@ -69,7 +69,8 @@ class QFxImagePrivate : public QFxItemPrivate public: QFxImagePrivate() : scaleGrid(0), tiled(false), smooth(false), opaque(false), - status(QFxImage::Idle), sciReply(0), progress(0.0) + preserveAspect(false), status(QFxImage::Idle), sciReply(0), + progress(0.0) { } @@ -92,6 +93,7 @@ public: bool tiled : 1; bool smooth : 1; bool opaque : 1; + bool preserveAspect : 1; QFxImage::Status status; QUrl url; -- cgit v0.12 From ef353b5754e81923358d030760cabd193a2cb248 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 17 Jul 2009 16:56:03 +1000 Subject: Add NOTIFY for count signal --- src/declarative/extra/qmlxmllistmodel.cpp | 1 + src/declarative/extra/qmlxmllistmodel.h | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/declarative/extra/qmlxmllistmodel.cpp b/src/declarative/extra/qmlxmllistmodel.cpp index e154268..7f0029d 100644 --- a/src/declarative/extra/qmlxmllistmodel.cpp +++ b/src/declarative/extra/qmlxmllistmodel.cpp @@ -645,6 +645,7 @@ void QmlXmlListModel::queryCompleted(int id, int size) if (size > 0) { d->data = d->qmlXmlQuery.modelData(); emit itemsInserted(0, d->size); + emit countChanged(); } } diff --git a/src/declarative/extra/qmlxmllistmodel.h b/src/declarative/extra/qmlxmllistmodel.h index d9871ab..3b6ffb4 100644 --- a/src/declarative/extra/qmlxmllistmodel.h +++ b/src/declarative/extra/qmlxmllistmodel.h @@ -98,6 +98,7 @@ class Q_DECLARATIVE_EXPORT QmlXmlListModel : public QListModelInterface, public Q_PROPERTY(QString query READ query WRITE setQuery) Q_PROPERTY(QString namespaceDeclarations READ namespaceDeclarations WRITE setNamespaceDeclarations) Q_PROPERTY(QmlList *roles READ roleObjects) + Q_PROPERTY(int count READ count NOTIFY countChanged) Q_CLASSINFO("DefaultProperty", "roles") public: @@ -130,6 +131,7 @@ public: signals: void statusChanged(Status); void progressChanged(qreal progress); + void countChanged(); public Q_SLOTS: void reload(); -- cgit v0.12 From fe66eaeed64402a7b22a43a85cd92c938a534b71 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 17 Jul 2009 16:56:15 +1000 Subject: Missing SetDefault instruction --- src/declarative/qml/qmlcompiler.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index 220c464..138be29 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -903,6 +903,11 @@ void QmlCompiler::genComponent(QmlParser::Object *obj) genObject(root); + QmlInstruction def; + init.line = 0; + def.type = QmlInstruction::SetDefault; + output->bytecode << def; + output->bytecode[count - 1].createComponent.count = output->bytecode.count() - count; -- cgit v0.12 From 4031c0f0613090d70cd1fcacfc5b8316b12eb14e Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 17 Jul 2009 17:04:08 +1000 Subject: Add non-threadsafe QGuard class --- examples/declarative/snow/pics/loading.png | Bin 0 -> 761 bytes src/corelib/kernel/kernel.pri | 6 +- src/corelib/kernel/qguard.cpp | 26 +++++ src/corelib/kernel/qguard_p.h | 151 +++++++++++++++++++++++++++++ src/corelib/kernel/qobject.cpp | 18 +++- src/corelib/kernel/qobject_p.h | 2 + 6 files changed, 200 insertions(+), 3 deletions(-) create mode 100644 examples/declarative/snow/pics/loading.png create mode 100644 src/corelib/kernel/qguard.cpp create mode 100644 src/corelib/kernel/qguard_p.h diff --git a/examples/declarative/snow/pics/loading.png b/examples/declarative/snow/pics/loading.png new file mode 100644 index 0000000..0296cfe Binary files /dev/null and b/examples/declarative/snow/pics/loading.png differ diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri index f31794d..d71a22a 100644 --- a/src/corelib/kernel/kernel.pri +++ b/src/corelib/kernel/kernel.pri @@ -33,7 +33,8 @@ HEADERS += \ kernel/qsystemsemaphore.h \ kernel/qsystemsemaphore_p.h \ kernel/qfunctions_p.h \ - kernel/qmetaobjectbuilder_p.h + kernel/qmetaobjectbuilder_p.h \ + kernel/qguard_p.h SOURCES += \ kernel/qabstracteventdispatcher.cpp \ @@ -56,7 +57,8 @@ SOURCES += \ kernel/qsharedmemory.cpp \ kernel/qsystemsemaphore.cpp \ kernel/qmetaobjectbuilder.cpp \ - kernel/qpointer.cpp + kernel/qpointer.cpp \ + kernel/qguard.cpp win32 { SOURCES += \ diff --git a/src/corelib/kernel/qguard.cpp b/src/corelib/kernel/qguard.cpp new file mode 100644 index 0000000..c61be00 --- /dev/null +++ b/src/corelib/kernel/qguard.cpp @@ -0,0 +1,26 @@ +#include "qguard_p.h" +#include + +void q_guard_addGuard(QGuard *g) +{ + QObjectPrivate *p = QObjectPrivate::get(g->o); + if (p->wasDeleted) { + qWarning("QGuard: cannot add guard to deleted object"); + g->o = 0; + return; + } + + g->next = p->objectGuards; + p->objectGuards = g; + g->prev = &p->objectGuards; + if (g->next) + g->next->prev = &g->next; +} + +void q_guard_removeGuard(QGuard *g) +{ + *g->prev = g->next; + g->next = 0; + g->prev = 0; +} + diff --git a/src/corelib/kernel/qguard_p.h b/src/corelib/kernel/qguard_p.h new file mode 100644 index 0000000..7236ed6 --- /dev/null +++ b/src/corelib/kernel/qguard_p.h @@ -0,0 +1,151 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore 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 http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGUARD_P_H +#define QGUARD_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header +// file may change from version to version without notice, or even be removed. +// +// We mean it. +// + +#include "QtCore/qglobal.h" + +QT_BEGIN_NAMESPACE + +class QObject; +template +class QGuard +{ + QObject *o; + QGuard *next; + QGuard **prev; + friend void q_guard_addGuard(QGuard *); + friend void q_guard_removeGuard(QGuard *); + friend class QObjectPrivate; +public: + inline QGuard(); + inline QGuard(T *); + inline QGuard(const QGuard &); + inline virtual ~QGuard(); + + inline QGuard &operator=(const QGuard &o); + inline QGuard &operator=(T *); + + inline bool isNull() const + { return !o; } + + inline T* operator->() const + { return static_cast(const_cast(o)); } + inline T& operator*() const + { return *static_cast(const_cast(o)); } + inline operator T*() const + { return static_cast(const_cast(o)); } + inline T* data() const + { return static_cast(const_cast(o)); } + +protected: + virtual void objectDestroyed(T *) {} +}; + +void Q_CORE_EXPORT q_guard_addGuard(QGuard *); +void Q_CORE_EXPORT q_guard_removeGuard(QGuard *); + +template +QGuard::QGuard() +: o(0), next(0), prev(0) +{ +} + +template +QGuard::QGuard(T *g) +: o(g), next(0), prev(0) +{ + if (o) q_guard_addGuard(reinterpret_cast *>(this)); +} + +template +QGuard::QGuard(const QGuard &g) +: o(g.o), next(0), prev(0) +{ + if (o) q_guard_addGuard(reinterpret_cast *>(this)); +} + +template +QGuard::~QGuard() +{ + if (prev) q_guard_removeGuard(reinterpret_cast *>(this)); + o = 0; +} + +template +QGuard &QGuard::operator=(const QGuard &g) +{ + if (g.o != o) { + if (prev) + q_guard_removeGuard(reinterpret_cast *>(this)); + o = g.o; + if (o) q_guard_addGuard(reinterpret_cast *>(this)); + } + return *this; +} + +template +inline QGuard &QGuard::operator=(T *g) +{ + if (g != o) { + if (prev) + q_guard_removeGuard(reinterpret_cast *>(this)); + o = g; + if (o) q_guard_addGuard(reinterpret_cast *>(this)); + } + return *this; +} + +QT_END_NAMESPACE + +#endif // QGUARD_P_H diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 1742cd0..8517897 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -144,6 +144,7 @@ QObjectPrivate::QObjectPrivate(int version) inEventHandler = false; inThreadChangeEvent = false; deleteWatch = 0; + objectGuards = 0; metaObject = 0; hasGuards = false; } @@ -428,7 +429,22 @@ void QMetaObject::changeGuard(QObject **ptr, QObject *o) */ void QObjectPrivate::clearGuards(QObject *object) { - if (!QObjectPrivate::get(object)->hasGuards) + QObjectPrivate *priv = QObjectPrivate::get(object); + QGuard *guard = priv->objectGuards; + while (guard) { + guard->o = 0; + guard = guard->next; + } + while (priv->objectGuards) { + guard = priv->objectGuards; + guard->prev = 0; + if (guard->next) guard->next->prev = &priv->objectGuards; + priv->objectGuards = guard->next; + guard->next = 0; + guard->objectDestroyed(object); + } + + if (!priv->hasGuards) return; GuardHash *hash = guardHash(); if (hash) { diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 83239fe..4ac0d2d 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -60,6 +60,7 @@ #include "QtCore/qvector.h" #include "QtCore/qreadwritelock.h" #include "QtCore/qvariant.h" +#include "qguard_p.h" QT_BEGIN_NAMESPACE @@ -184,6 +185,7 @@ public: static void resetDeleteWatch(QObjectPrivate *d, int *oldWatch, int deleteWatch); int *deleteWatch; + QGuard *objectGuards; static QObjectPrivate *get(QObject *o) { return o->d_func(); -- cgit v0.12 From b27bc8ef235e4e72cbe2ca0ee9d8f4587e564976 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 17 Jul 2009 17:30:21 +1000 Subject: Remove unnecessary stuff from the example --- examples/declarative/snow/ImageBatch.qml | 9 --------- examples/declarative/snow/create.js | 1 - examples/declarative/snow/snow.qml | 5 ----- 3 files changed, 15 deletions(-) diff --git a/examples/declarative/snow/ImageBatch.qml b/examples/declarative/snow/ImageBatch.qml index f7ae8b1..4c65605 100644 --- a/examples/declarative/snow/ImageBatch.qml +++ b/examples/declarative/snow/ImageBatch.qml @@ -30,16 +30,7 @@ GridView { query: "/rss/channel/item" namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";" - XmlRole { name: "title"; query: "title/string()" } - XmlRole { name: "imagePath"; query: "media:thumbnail/@url/string()" } XmlRole { name: "url"; query: "media:content/@url/string()" } - XmlRole { name: "description"; query: "description/string()" } - XmlRole { name: "tags"; query: "media:category/string()" } - XmlRole { name: "photoWidth"; query: "media:content/@width/string()" } - XmlRole { name: "photoHeight"; query: "media:content/@height/string()" } - XmlRole { name: "photoType"; query: "media:content/@type/string()" } - XmlRole { name: "photoAuthor"; query: "author/string()" } - XmlRole { name: "photoDate"; query: "pubDate/string()" } } Item { diff --git a/examples/declarative/snow/create.js b/examples/declarative/snow/create.js index 51f870d..9def7a7 100644 --- a/examples/declarative/snow/create.js +++ b/examples/declarative/snow/create.js @@ -10,4 +10,3 @@ function createNewBlock() { obj.ref = ImagePanel; maximumColumn += 5; } - diff --git a/examples/declarative/snow/snow.qml b/examples/declarative/snow/snow.qml index b73c2d2..2b413bb 100644 --- a/examples/declarative/snow/snow.qml +++ b/examples/declarative/snow/snow.qml @@ -42,7 +42,6 @@ Rect { axis { startX: 0; startY: 0; endX: 0; endY: 1 } angle: MyLayout.deform * 100 } - } Script { @@ -65,8 +64,4 @@ Rect { upArrow: "if (selectedItemRow > 0) selectedItemRow = selectedItemRow - 1" downArrow: "if (selectedItemRow < 3) selectedItemRow = selectedItemRow + 1" } - - Text { - text: MyLayout.deform - } } -- cgit v0.12 From 6626a96b8fa00c5ebb1ed308b77c9cf046e78849 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 17 Jul 2009 11:32:22 +0200 Subject: Compile Moved some code so that the QtSvg module will compile on MSVC2003. --- src/gui/graphicsview/qgraphicsitem.h | 1 + src/gui/graphicsview/qgraphicsitem_p.h | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h index ba03987..7240eaa 100644 --- a/src/gui/graphicsview/qgraphicsitem.h +++ b/src/gui/graphicsview/qgraphicsitem.h @@ -48,6 +48,7 @@ #include #include #include +#include class tst_QGraphicsItem; diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index 7204d7f..d14ae7f 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -56,7 +56,6 @@ #include "qgraphicsitem.h" #include "qset.h" #include "qpixmapcache.h" -#include "qgraphicsview_p.h" #include -- cgit v0.12 From c112906daac96178d9d016a170fa863545a0b972 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 17 Jul 2009 13:08:46 +0200 Subject: Compile Change 6626a9 broke compilation because several files indirectly depended on a #include that was removed. --- src/declarative/extra/qfxparticles.cpp | 2 +- src/declarative/fx/qfxgridview.cpp | 4 +++- src/declarative/fx/qfximage.cpp | 19 +++++++++++-------- src/declarative/fx/qfximage_p.h | 10 ++++++---- src/declarative/fx/qfxlineedit.cpp | 1 + src/declarative/fx/qfxlistview.cpp | 3 ++- src/declarative/fx/qfxpainteditem.cpp | 1 + src/declarative/fx/qfxrect.cpp | 5 +++-- src/declarative/fx/qfxtext.cpp | 32 ++++++++++++++++---------------- src/declarative/fx/qfxtextedit.cpp | 16 ++++++++-------- 10 files changed, 52 insertions(+), 41 deletions(-) diff --git a/src/declarative/extra/qfxparticles.cpp b/src/declarative/extra/qfxparticles.cpp index c31163c..08d38ba 100644 --- a/src/declarative/extra/qfxparticles.cpp +++ b/src/declarative/extra/qfxparticles.cpp @@ -55,7 +55,7 @@ #include #include "qfxparticles.h" - +#include QT_BEGIN_NAMESPACE #define PI_SQR 9.8696044 diff --git a/src/declarative/fx/qfxgridview.cpp b/src/declarative/fx/qfxgridview.cpp index 11b630a..905af3b 100644 --- a/src/declarative/fx/qfxgridview.cpp +++ b/src/declarative/fx/qfxgridview.cpp @@ -45,6 +45,8 @@ #include "private/qfxflickable_p.h" #include "qfxgridview.h" +#include + QT_BEGIN_NAMESPACE class QFxGridViewAttached : public QObject @@ -811,7 +813,7 @@ QFxItem *QFxGridView::currentItem() Q_D(QFxGridView); if (!d->currentItem) { // Always return something valid - if (!d->tmpCurrent) + if (!d->tmpCurrent) d->tmpCurrent = new QFxItem(viewport()); return d->tmpCurrent; } diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp index d19d620..027b22a 100644 --- a/src/declarative/fx/qfximage.cpp +++ b/src/declarative/fx/qfximage.cpp @@ -47,6 +47,9 @@ #include #include +#include +#include + QT_BEGIN_NAMESPACE @@ -233,12 +236,12 @@ void QFxImage::componentComplete() \qmlproperty bool Image::smooth Set this property if you want the image to be smoothly filtered when scaled or - transformed. Smooth filtering gives better visual quality, but is slower. If - the Image is displayed at its natural size, this property has no visual or + transformed. Smooth filtering gives better visual quality, but is slower. If + the Image is displayed at its natural size, this property has no visual or performance effect. - \note Generally scaling artifacts are only visible if the image is stationary on - the screen. A common pattern when animating an image is to disable smooth + \note Generally scaling artifacts are only visible if the image is stationary on + the screen. A common pattern when animating an image is to disable smooth filtering at the beginning of the animation and reenable it at the conclusion. */ @@ -247,7 +250,7 @@ void QFxImage::componentComplete() \brief whether the image is smoothly transformed. This property is provided purely for the purpose of optimization. Turning - smooth transforms off is faster, but looks worse; turning smooth + smooth transforms off is faster, but looks worse; turning smooth transformations on is slower, but looks better. By default smooth transformations are off. @@ -348,7 +351,7 @@ void QFxImage::paintContents(QPainter &p) p.drawPixmap(QRect(sgl, 0, w - xSide, sgt), pix, QRect(sgl, 0, pix.width() - xSide, sgt)); // Upper right - if (sgt && pix.width() - sgr) + if (sgt && pix.width() - sgr) p.drawPixmap(QPoint(w-sgr, 0), pix, QRect(pix.width()-sgr, 0, sgr, sgt)); // Middle left @@ -359,13 +362,13 @@ void QFxImage::paintContents(QPainter &p) // Middle if (pix.width() - xSide && pix.height() - ySide) p.drawPixmap(QRect(sgl, sgt, w - xSide, h - ySide), - pix, + pix, QRect(sgl, sgt, pix.width() - xSide, pix.height() - ySide)); // Middle right if (sgr && pix.height() - ySide) p.drawPixmap(QRect(w-sgr, sgt, sgr, h - ySide), pix, QRect(pix.width()-sgr, sgt, sgr, pix.height() - ySide)); - // Lower left + // Lower left if (sgl && sgr) p.drawPixmap(QPoint(0, h - sgb), pix, QRect(0, pix.height() - sgb, sgl, sgb)); diff --git a/src/declarative/fx/qfximage_p.h b/src/declarative/fx/qfximage_p.h index de7ebe6..7792dbf 100644 --- a/src/declarative/fx/qfximage_p.h +++ b/src/declarative/fx/qfximage_p.h @@ -55,6 +55,8 @@ #include "qfxitem_p.h" +#include + QT_BEGIN_NAMESPACE class QSvgRenderer; @@ -69,12 +71,12 @@ class QFxImagePrivate : public QFxItemPrivate public: QFxImagePrivate() : scaleGrid(0), tiled(false), smooth(false), opaque(false), - preserveAspect(false), status(QFxImage::Idle), sciReply(0), + preserveAspect(false), status(QFxImage::Idle), sciReply(0), progress(0.0) { } - ~QFxImagePrivate() + ~QFxImagePrivate() { delete scaleGrid; } @@ -83,11 +85,11 @@ public: QFxScaleGrid *getScaleGrid() { - if (!scaleGrid) + if (!scaleGrid) scaleGrid = new QFxScaleGrid; return scaleGrid; } - + QFxScaleGrid *scaleGrid; QPixmap pix; bool tiled : 1; diff --git a/src/declarative/fx/qfxlineedit.cpp b/src/declarative/fx/qfxlineedit.cpp index 24cf3fc..da79979 100644 --- a/src/declarative/fx/qfxlineedit.cpp +++ b/src/declarative/fx/qfxlineedit.cpp @@ -44,6 +44,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE QML_DEFINE_TYPE(QFxLineEdit,LineEdit); diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp index 889cfdd..351365d 100644 --- a/src/declarative/fx/qfxlistview.cpp +++ b/src/declarative/fx/qfxlistview.cpp @@ -46,6 +46,7 @@ #include "qfxlistview.h" #include +#include QT_BEGIN_NAMESPACE class QFxListViewAttached : public QObject @@ -292,7 +293,7 @@ public: } return -1; // Not in visibleList } - + bool mapRangeFromModel(int &index, int &count) const { if (index + count < visibleIndex) return false; diff --git a/src/declarative/fx/qfxpainteditem.cpp b/src/declarative/fx/qfxpainteditem.cpp index c79abbd..7ff3361 100644 --- a/src/declarative/fx/qfxpainteditem.cpp +++ b/src/declarative/fx/qfxpainteditem.cpp @@ -48,6 +48,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE diff --git a/src/declarative/fx/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp index 2ad8536..32d3eb4 100644 --- a/src/declarative/fx/qfxrect.cpp +++ b/src/declarative/fx/qfxrect.cpp @@ -42,6 +42,7 @@ #include "qfxrect.h" #include "qfxrect_p.h" +#include QT_BEGIN_NAMESPACE QML_DEFINE_TYPE(QFxPen,Pen) @@ -331,7 +332,7 @@ void QFxRect::setGradient(QFxGradient *gradient) This property holds the corner radius used to draw a rounded rect. If radius is non-zero, the rect will be painted as a rounded rectangle, otherwise it will be - painted as a normal rectangle. The same radius is used by all 4 corners; there is currently + painted as a normal rectangle. The same radius is used by all 4 corners; there is currently no way to specify different radii for different corners. */ @@ -591,7 +592,7 @@ void QFxRect::drawRect(QPainter &p) if (yMiddles) p.drawPixmap(QRect(width()-xOffset+pw/2, yOffset-pw/2, xOffset, height() - ySide + pw), d->rectImage, QRect(d->rectImage.width()-xOffset, d->rectImage.height()/2, xOffset, 1)); - // Lower left + // Lower left p.drawPixmap(QPoint(-pw/2, height() - yOffset + pw/2), d->rectImage, QRect(0, d->rectImage.height() - yOffset, xOffset, yOffset)); // Lower Middle diff --git a/src/declarative/fx/qfxtext.cpp b/src/declarative/fx/qfxtext.cpp index 8618b87..2bae53f 100644 --- a/src/declarative/fx/qfxtext.cpp +++ b/src/declarative/fx/qfxtext.cpp @@ -49,7 +49,7 @@ #include #include #include - +#include QT_BEGIN_NAMESPACE QML_DEFINE_TYPE(QFxText,Text) @@ -68,7 +68,7 @@ QML_DEFINE_TYPE(QFxText,Text) \image declarative-text.png - If height and width are not explicitly set, Text will attempt to determine how + If height and width are not explicitly set, Text will attempt to determine how much room is needed and set it accordingly. Unless \c wrap is set, it will always prefer width to height (all text will be placed on a single line). @@ -86,7 +86,7 @@ QML_DEFINE_TYPE(QFxText,Text) \brief The QFxText class provides a formatted text item that you can add to a QFxView. - Text was designed for read-only text; it does not allow for any text editing. + Text was designed for read-only text; it does not allow for any text editing. It can display both plain and rich text. For example: \qml @@ -96,7 +96,7 @@ QML_DEFINE_TYPE(QFxText,Text) \image text.png - If height and width are not explicitly set, Text will attempt to determine how + If height and width are not explicitly set, Text will attempt to determine how much room is needed and set it accordingly. Unless \c wrap is set, it will always prefer width to height (all text will be placed on a single line). @@ -161,9 +161,9 @@ void QFxText::setText(const QString &n) if (d->richText) { if (!d->doc) { - d->control = new QTextControl(this); + d->control = new QTextControl(this); d->control->setTextInteractionFlags(Qt::TextBrowserInteraction); - d->doc = d->control->document(); + d->doc = d->control->document(); d->doc->setDocumentMargin(0); } d->doc->setHtml(n); @@ -299,8 +299,8 @@ QColor QFxText::styleColor() const Sets the horizontal and vertical alignment of the text within the Text items width and height. By default, the text is top-left aligned. - The valid values for \c hAlign are \c AlignLeft, \c AlignRight and - \c AlignHCenter. The valid values for \c vAlign are \c AlignTop, \c AlignBottom + The valid values for \c hAlign are \c AlignLeft, \c AlignRight and + \c AlignHCenter. The valid values for \c vAlign are \c AlignTop, \c AlignBottom and \c AlignVCenter. */ @@ -479,7 +479,7 @@ QString QFxText::activeLink() const return d->activeLink; } -void QFxText::geometryChanged(const QRectF &newGeometry, +void QFxText::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { Q_D(QFxText); @@ -516,7 +516,7 @@ void QFxTextPrivate::updateSize() QSize size(0, 0); //setup instance of QTextLayout for all cases other than richtext - if (!richText) + if (!richText) { tmp = text; tmp.replace(QLatin1Char('\n'), QChar::LineSeparator); @@ -545,7 +545,7 @@ void QFxTextPrivate::updateSize() dy -= (int)doc->size().height(); } else { dy -= size.height(); - } + } int yoff = 0; if (q->heightValid()) { @@ -555,7 +555,7 @@ void QFxTextPrivate::updateSize() yoff = dy/2; } q->setBaselineOffset(fm.ascent() + yoff); - + if (!q->widthValid()) { int newWidth = (richText ? (int)doc->idealWidth() : size.width()); q->setImplicitWidth(newWidth); @@ -645,7 +645,7 @@ QSize QFxTextPrivate::setupTextLayout(QTextLayout *layout) QTextLine line = layout->createLine(); if (!line.isValid()) break; - + if ((wrap || elideMode != Qt::ElideNone) && q->widthValid()) line.setLineWidth(lineWidth); } @@ -686,7 +686,7 @@ QPixmap QFxTextPrivate::wrappedTextImage(bool drawStyle) if (drawStyle) { p.setPen(styleColor); } - else + else p.setPen(color); p.setFont(f); layout.draw(&p, QPointF(0, 0)); @@ -813,7 +813,7 @@ void QFxText::paintContents(QPainter &p) break; } - bool needClip = !clip() && (d->imgCache.width() > width() || + bool needClip = !clip() && (d->imgCache.width() > width() || d->imgCache.height() > height()); if (needClip) { @@ -862,7 +862,7 @@ void QFxText::mousePressEvent(QGraphicsSceneMouseEvent *event) if (!event->isAccepted()) QFxItem::mousePressEvent(event); - + } /*! diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp index 5a62727..f9cde7c 100644 --- a/src/declarative/fx/qfxtextedit.cpp +++ b/src/declarative/fx/qfxtextedit.cpp @@ -50,7 +50,7 @@ #include #include - +#include QT_BEGIN_NAMESPACE QML_DEFINE_TYPE(QFxTextEdit, TextEdit) @@ -353,8 +353,8 @@ void QFxTextEdit::setHighlightedTextColor(const QColor &color) Sets the horizontal and vertical alignment of the text within the TextEdit items width and height. By default, the text is top-left aligned. - The valid values for \c hAlign are \c AlignLeft, \c AlignRight and - \c AlignHCenter. The valid values for \c vAlign are \c AlignTop, \c AlignBottom + The valid values for \c hAlign are \c AlignLeft, \c AlignRight and + \c AlignHCenter. The valid values for \c vAlign are \c AlignTop, \c AlignBottom and \c AlignVCenter. */ @@ -670,7 +670,7 @@ void QFxTextEdit::setTextMargin(qreal margin) d->document->setDocumentMargin(d->textMargin); } -void QFxTextEdit::geometryChanged(const QRectF &newGeometry, +void QFxTextEdit::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { if (newGeometry.width() != oldGeometry.width()) @@ -762,7 +762,7 @@ Qt::TextInteractionFlags QFxTextEdit::textInteractionFlags() const } /*! - Returns the cursor for the point at the given \a pos on the + Returns the cursor for the point at the given \a pos on the text edit. */ QTextCursor QFxTextEdit::cursorForPosition(const QPoint &pos) const @@ -1130,9 +1130,9 @@ void QFxTextEdit::updateSize() if (!heightValid()) { if (d->text.isEmpty()) { setImplicitHeight(fm.height()); - } else { + } else { setImplicitHeight((int)d->document->size().height()); - } + } } setContentsSize(QSize(width(), height())); } else { @@ -1146,7 +1146,7 @@ void QFxTextEditPrivate::updateDefaultTextOption() QTextOption opt = document->defaultTextOption(); int oldAlignment = opt.alignment(); opt.setAlignment((Qt::Alignment)(int)(hAlign | vAlign)); - + QTextOption::WrapMode oldWrapMode = opt.wrapMode(); if (wrap) -- cgit v0.12 From 1dc2e92b4630a0c19d1d2bdf5a05cd18003c566a Mon Sep 17 00:00:00 2001 From: Leonardo Sobral Cunha Date: Fri, 17 Jul 2009 15:55:53 +0200 Subject: Fix compilation after change 6626a9 --- src/declarative/fx/qfxwebview.cpp | 2 ++ src/gui/graphicsview/qgraphicsscene_p.h | 1 + 2 files changed, 3 insertions(+) diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp index 7149455..a3dca79e 100644 --- a/src/declarative/fx/qfxwebview.cpp +++ b/src/declarative/fx/qfxwebview.cpp @@ -43,6 +43,8 @@ #include #include #include +#include +#include #include #include #include diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h index ff7e8c6..fc8fa2b 100644 --- a/src/gui/graphicsview/qgraphicsscene_p.h +++ b/src/gui/graphicsview/qgraphicsscene_p.h @@ -59,6 +59,7 @@ #include "qgraphicssceneevent.h" #include "qgraphicsview.h" +#include "qgraphicsview_p.h" #include "qgraphicsitem_p.h" #include -- cgit v0.12 From 3b4ef95d18631845d34e63186fdf76124443ac79 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 20 Jul 2009 11:00:52 +1000 Subject: Add missing docs. --- src/declarative/extra/qmlxmllistmodel.cpp | 4 ++++ src/declarative/fx/qfximage.cpp | 6 ++++++ src/declarative/util/qmllistmodel.cpp | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/src/declarative/extra/qmlxmllistmodel.cpp b/src/declarative/extra/qmlxmllistmodel.cpp index 7f0029d..91ad538 100644 --- a/src/declarative/extra/qmlxmllistmodel.cpp +++ b/src/declarative/extra/qmlxmllistmodel.cpp @@ -432,6 +432,10 @@ QHash QmlXmlListModel::data(int index, const QList &roles) co return rv; } +/*! + \qmlproperty int XmlListModel::count + The number of data entries in the model. +*/ int QmlXmlListModel::count() const { Q_D(const QmlXmlListModel); diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp index 027b22a..69030d2 100644 --- a/src/declarative/fx/qfximage.cpp +++ b/src/declarative/fx/qfximage.cpp @@ -464,6 +464,12 @@ QUrl QFxImage::source() const return d->url; } +/*! + \qmlproperty bool Image::preserveAspect + + Whether the image's aspect ratio should be preserved when resizing. By default this + is false. +*/ bool QFxImage::preserveAspect() const { Q_D(const QFxImage); diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp index 61d32f4..8edd871 100644 --- a/src/declarative/util/qmllistmodel.cpp +++ b/src/declarative/util/qmllistmodel.cpp @@ -331,6 +331,10 @@ QHash QmlListModel::data(int index, const QList &roles) const return rv; } +/*! + \qmlproperty int ListModel::count + The number of data entries in the model. +*/ int QmlListModel::count() const { if (!_root) return 0; -- cgit v0.12 From 0eaa2231ed4e3acc0c1411492c13d9057d1caa00 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 20 Jul 2009 11:54:56 +1000 Subject: Compile fix. --- src/corelib/kernel/qmetaobjectbuilder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/kernel/qmetaobjectbuilder.cpp b/src/corelib/kernel/qmetaobjectbuilder.cpp index e6817fe..d655e3f 100644 --- a/src/corelib/kernel/qmetaobjectbuilder.cpp +++ b/src/corelib/kernel/qmetaobjectbuilder.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include "qmetaobjectbuilder_p.h" -#include +#include QT_BEGIN_NAMESPACE -- cgit v0.12 From 2193f4d417d94530e7d2f1948de03372b02dcdcf Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 20 Jul 2009 12:04:21 +1000 Subject: Fix warning. --- src/declarative/qml/qmlcompiler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index 138be29..477e6a5 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -940,7 +940,7 @@ bool QmlCompiler::buildComponent(QmlParser::Object *obj, COMPILE_EXCEPTION(obj, "Invalid component id specification"); if (idProp) { - QString idVal = idProp->values.first()->primitive().toUtf8(); + QString idVal = idProp->values.first()->primitive(); if (compileState.ids.contains(idVal)) COMPILE_EXCEPTION(obj, "id is not unique"); -- cgit v0.12 From 341f47a31d6d98e402547c77ccbe358465f8b1a9 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 20 Jul 2009 12:08:39 +1000 Subject: Update in light of new Image.preserveAspect property --- examples/declarative/aspectratio/face_fit.qml | 4 ---- examples/declarative/aspectratio/face_fit_animated.qml | 4 ---- examples/declarative/aspectratio/scale_and_crop.qml | 4 ---- examples/declarative/aspectratio/scale_and_sidecrop.qml | 4 ---- examples/declarative/aspectratio/scale_to_fit.qml | 7 ++----- examples/declarative/aspectratio/scale_to_fit_simple.qml | 8 ++++++++ 6 files changed, 10 insertions(+), 21 deletions(-) create mode 100644 examples/declarative/aspectratio/scale_to_fit_simple.qml diff --git a/examples/declarative/aspectratio/face_fit.qml b/examples/declarative/aspectratio/face_fit.qml index 35c63ce..3005d1b 100644 --- a/examples/declarative/aspectratio/face_fit.qml +++ b/examples/declarative/aspectratio/face_fit.qml @@ -1,7 +1,3 @@ -// The Image primitive does not have any special handling for maintaining -// aspect ratio. This example shows that you can provide whatever specific -// behaviour you like. -// // Here, we implement a hybrid of the "scale to fit" and "scale and crop" // behaviours which will crop up to 25% from *one* dimension if necessary // to fully scale the other. This is a realistic algorithm, for example diff --git a/examples/declarative/aspectratio/face_fit_animated.qml b/examples/declarative/aspectratio/face_fit_animated.qml index 366d27b..9036eeb 100644 --- a/examples/declarative/aspectratio/face_fit_animated.qml +++ b/examples/declarative/aspectratio/face_fit_animated.qml @@ -1,7 +1,3 @@ -// The Image primitive does not have any special handling for maintaining -// aspect ratio. This example shows that you can provide whatever specific -// behaviour you like. -// // Here, we extend the "face_fit" example with animation to show how truly // diverse and usage-specific behaviours are made possible by NOT putting a // hard-coded aspect ratio feature into the Image primitive. diff --git a/examples/declarative/aspectratio/scale_and_crop.qml b/examples/declarative/aspectratio/scale_and_crop.qml index a5409f9..2f35fb5 100644 --- a/examples/declarative/aspectratio/scale_and_crop.qml +++ b/examples/declarative/aspectratio/scale_and_crop.qml @@ -1,7 +1,3 @@ -// The Image primitive does not have any special handling for maintaining -// aspect ratio. This example shows that you can provide whatever specific -// behaviour you like. -// // Here, we implement "Scale and Crop" behaviour. // Rect { diff --git a/examples/declarative/aspectratio/scale_and_sidecrop.qml b/examples/declarative/aspectratio/scale_and_sidecrop.qml index e076735..4b1eb63 100644 --- a/examples/declarative/aspectratio/scale_and_sidecrop.qml +++ b/examples/declarative/aspectratio/scale_and_sidecrop.qml @@ -1,7 +1,3 @@ -// The Image primitive does not have any special handling for maintaining -// aspect ratio. This example shows that you can provide whatever specific -// behaviour you like. -// // Here, we implement a variant of "Scale and Crop" behaviour, where we // crop the sides if necessary to fully fit vertically, but not the reverse. // diff --git a/examples/declarative/aspectratio/scale_to_fit.qml b/examples/declarative/aspectratio/scale_to_fit.qml index 61a4082..867eb37 100644 --- a/examples/declarative/aspectratio/scale_to_fit.qml +++ b/examples/declarative/aspectratio/scale_to_fit.qml @@ -1,8 +1,5 @@ -// The Image primitive does not have any special handling for maintaining -// aspect ratio. This example shows that you can provide whatever specific -// behaviour you like. -// -// Here, we implement "Scale to Fit" behaviour. +// Here, we implement "Scale to Fit" behaviour "manually", rather +// than using the preserveAspect property. // Rect { // default size: whole image, unscaled diff --git a/examples/declarative/aspectratio/scale_to_fit_simple.qml b/examples/declarative/aspectratio/scale_to_fit_simple.qml new file mode 100644 index 0000000..ae2be83 --- /dev/null +++ b/examples/declarative/aspectratio/scale_to_fit_simple.qml @@ -0,0 +1,8 @@ +// Here, we implement "Scale to Fit" behaviour, using the +// preserveAspect property. +// +Image { + id: Image + source: "pics/face.png" + preserveAspect: true +} -- cgit v0.12 From aff973dfb0d43c32c0686017498ea2ab03d585ae Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 20 Jul 2009 12:11:42 +1000 Subject: Make identical to non-simple example. --- .../declarative/aspectratio/scale_to_fit_simple.qml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/examples/declarative/aspectratio/scale_to_fit_simple.qml b/examples/declarative/aspectratio/scale_to_fit_simple.qml index ae2be83..4f89586 100644 --- a/examples/declarative/aspectratio/scale_to_fit_simple.qml +++ b/examples/declarative/aspectratio/scale_to_fit_simple.qml @@ -1,8 +1,17 @@ // Here, we implement "Scale to Fit" behaviour, using the // preserveAspect property. // -Image { - id: Image - source: "pics/face.png" - preserveAspect: true +Rect { + // default size: whole image, unscaled + width: Image.width + height: Image.height + color: "gray" + clip: true + + Image { + id: Image + source: "pics/face.png" + preserveAspect: true + anchors.fill: parent + } } -- cgit v0.12 From 5f03a1502bee93523033e8769b8fc235d36d58db Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 20 Jul 2009 12:47:44 +1000 Subject: Compile fix. --- src/corelib/kernel/qmetaobjectbuilder.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/corelib/kernel/qmetaobjectbuilder.cpp b/src/corelib/kernel/qmetaobjectbuilder.cpp index d655e3f..dd831a8 100644 --- a/src/corelib/kernel/qmetaobjectbuilder.cpp +++ b/src/corelib/kernel/qmetaobjectbuilder.cpp @@ -40,7 +40,9 @@ ****************************************************************************/ #include "qmetaobjectbuilder_p.h" +#ifndef Q_OS_WIN #include +#endif QT_BEGIN_NAMESPACE -- cgit v0.12 From ecc71bebda5cdc842932f29757d869c8a1288962 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 20 Jul 2009 13:16:07 +1000 Subject: Make network cache size settable. --- tools/qmlviewer/main.cpp | 10 +++++----- tools/qmlviewer/qmlviewer.cpp | 19 ++++++++++++------- tools/qmlviewer/qmlviewer.h | 2 +- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/tools/qmlviewer/main.cpp b/tools/qmlviewer/main.cpp index ae9c356..e786edb 100644 --- a/tools/qmlviewer/main.cpp +++ b/tools/qmlviewer/main.cpp @@ -36,7 +36,7 @@ void usage() qWarning(" -record arg .............................. add a recording process argument"); qWarning(" -autorecord [from-] ...... set recording to start and stop"); qWarning(" -devicekeys .............................. use numeric keys (see F1)"); - qWarning(" -cache ................................... disk cache remote content"); + qWarning(" -netcache ......................... set disk cache to size bytes"); qWarning(" -recordtest .................. record an autotest"); qWarning(" -runtest ..................... run a previously recorded test"); qWarning(" -translation ........... set the language to run in"); @@ -74,7 +74,7 @@ int main(int argc, char ** argv) QStringList libraries; QString skin; bool devkeys = false; - bool cache = false; + int cache = 0; QString translationFile; for (int i = 1; i < argc; ++i) { @@ -83,8 +83,8 @@ int main(int argc, char ** argv) frameless = true; } else if (arg == "-skin") { skin = QString(argv[++i]); - } else if (arg == "-cache") { - cache = true; + } else if (arg == "-netcache") { + cache = QString(argv[++i]).toInt(); } else if (arg == "-recordperiod") { period = QString(argv[++i]).toInt(); } else if (arg == "-recordfile") { @@ -127,7 +127,7 @@ int main(int argc, char ** argv) QmlViewer viewer(0, frameless ? Qt::FramelessWindowHint : Qt::Widget); foreach (QString lib, libraries) viewer.addLibraryPath(lib); - viewer.setCacheEnabled(cache); + viewer.setNetworkCacheSize(cache); viewer.setRecordFile(recordfile); if (period>0) viewer.setRecordPeriod(period); diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp index c9d70e8..8f99206 100644 --- a/tools/qmlviewer/qmlviewer.cpp +++ b/tools/qmlviewer/qmlviewer.cpp @@ -699,17 +699,22 @@ void QmlViewer::setupProxy() nam->setProxyFactory(new SystemProxyFactory); } -void QmlViewer::setCacheEnabled(bool on) +void QmlViewer::setNetworkCacheSize(int size) { QNetworkAccessManager * nam = canvas->engine()->networkAccessManager(); - if (on == !!nam->cache()) - return; - if (on) { - // Setup a caching network manager - QNetworkDiskCache *cache = new QNetworkDiskCache; + QNetworkDiskCache *cache = qobject_cast(nam->cache()); + if (!cache) { + if (size==0) + return; + cache = new QNetworkDiskCache; cache->setCacheDirectory(QDir::tempPath()+QLatin1String("/qml-duiviewer-network-cache")); - cache->setMaximumCacheSize(8000000); nam->setCache(cache); + } + if (size == cache->maximumCacheSize()) + return; + if (size>0) { + // Setup a caching network manager + cache->setMaximumCacheSize(size); } else { nam->setCache(0); } diff --git a/tools/qmlviewer/qmlviewer.h b/tools/qmlviewer/qmlviewer.h index 4714bdc..62ee908 100644 --- a/tools/qmlviewer/qmlviewer.h +++ b/tools/qmlviewer/qmlviewer.h @@ -42,7 +42,7 @@ public: bool isRecording() const { return recordTimer.isActive(); } void setAutoRecord(int from, int to); void setDeviceKeys(bool); - void setCacheEnabled(bool); + void setNetworkCacheSize(int size); void addLibraryPath(const QString& lib); QMenuBar *menuBar() const; -- cgit v0.12