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