From 63b4ded7451913e944e2b7e016746650cfc13fe6 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Fri, 26 Feb 2010 17:08:30 +1000 Subject: Rename files to follow class name. Task-number: QT-2822 --- src/declarative/util/qdeclarativeconnection.cpp | 245 --------------------- src/declarative/util/qdeclarativeconnection_p.h | 98 --------- src/declarative/util/qdeclarativeconnections.cpp | 245 +++++++++++++++++++++ src/declarative/util/qdeclarativeconnections_p.h | 98 +++++++++ src/declarative/util/qdeclarativeutilmodule.cpp | 2 +- src/declarative/util/util.pri | 4 +- tests/auto/declarative/declarative.pro | 2 +- .../data/test-connection.qml | 10 - .../data/test-connection2.qml | 3 - .../data/test-connection3.qml | 3 - .../qdeclarativeconnection/data/trimming.qml | 10 - .../qdeclarativeconnection.pro | 8 - .../tst_qdeclarativeconnection.cpp | 135 ------------ .../data/test-connection.qml | 10 + .../data/test-connection2.qml | 3 + .../data/test-connection3.qml | 3 + .../qdeclarativeconnections/data/trimming.qml | 10 + .../qdeclarativeconnection.pro | 8 + .../tst_qdeclarativeconnection.cpp | 135 ++++++++++++ 19 files changed, 516 insertions(+), 516 deletions(-) delete mode 100644 src/declarative/util/qdeclarativeconnection.cpp delete mode 100644 src/declarative/util/qdeclarativeconnection_p.h create mode 100644 src/declarative/util/qdeclarativeconnections.cpp create mode 100644 src/declarative/util/qdeclarativeconnections_p.h delete mode 100644 tests/auto/declarative/qdeclarativeconnection/data/test-connection.qml delete mode 100644 tests/auto/declarative/qdeclarativeconnection/data/test-connection2.qml delete mode 100644 tests/auto/declarative/qdeclarativeconnection/data/test-connection3.qml delete mode 100644 tests/auto/declarative/qdeclarativeconnection/data/trimming.qml delete mode 100644 tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro delete mode 100644 tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp create mode 100644 tests/auto/declarative/qdeclarativeconnections/data/test-connection.qml create mode 100644 tests/auto/declarative/qdeclarativeconnections/data/test-connection2.qml create mode 100644 tests/auto/declarative/qdeclarativeconnections/data/test-connection3.qml create mode 100644 tests/auto/declarative/qdeclarativeconnections/data/trimming.qml create mode 100644 tests/auto/declarative/qdeclarativeconnections/qdeclarativeconnection.pro create mode 100644 tests/auto/declarative/qdeclarativeconnections/tst_qdeclarativeconnection.cpp diff --git a/src/declarative/util/qdeclarativeconnection.cpp b/src/declarative/util/qdeclarativeconnection.cpp deleted file mode 100644 index a180509..0000000 --- a/src/declarative/util/qdeclarativeconnection.cpp +++ /dev/null @@ -1,245 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (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 Technology Preview License Agreement accompanying -** this package. -** -** 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.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativeconnection_p.h" - -#include -#include -#include -#include -#include - -#include -#include - -#include - -QT_BEGIN_NAMESPACE - -class QDeclarativeConnectionsPrivate : public QObjectPrivate -{ -public: - QDeclarativeConnectionsPrivate() : target(0), componentcomplete(false) {} - - QList boundsignals; - QObject *target; - - bool componentcomplete; - - QByteArray data; -}; - -/*! - \qmlclass Connections QDeclarativeConnections - \since 4.7 - \brief A Connections object describes generalized connections to signals. - - When connecting to signals in QML, the usual way is to create an - "on" handler that reacts when a signal is received, like this: - - \qml - MouseArea { - onClicked: { foo(...) } - } - \endqml - - However, in some cases, it is not possible to connect to a signal in this - way, such as: - - \list - \i multiple connections to the same signal - \i connections outside the scope of the signal sender - \i connections to targets not defined in QML - \endlist - - When any of these are needed, the Connections object can be used instead. - - For example, the above code can be changed to use a Connections object, - like this: - - \qml - MouseArea { - Connections { - onClicked: foo(...) - } - } - \endqml - - More generally, the Connections object can be a child of some other object than - the sender of the signal: - - \qml - MouseArea { - id: area - } - ... - Connections { - target: area - onClicked: foo(...) - } - \endqml -*/ - -/*! - \internal - \class QDeclarativeConnections - \brief The QDeclarativeConnections class describes generalized connections to signals. - -*/ -QDeclarativeConnections::QDeclarativeConnections(QObject *parent) : - QObject(*(new QDeclarativeConnectionsPrivate), parent) -{ -} - -QDeclarativeConnections::~QDeclarativeConnections() -{ -} - -/*! - \qmlproperty Object Connections::target - This property holds the object that sends the signal. - - By default, the target is assumed to be the parent of the Connections. -*/ -QObject *QDeclarativeConnections::target() const -{ - Q_D(const QDeclarativeConnections); - return d->target ? d->target : parent(); -} - -void QDeclarativeConnections::setTarget(QObject *obj) -{ - Q_D(QDeclarativeConnections); - if (d->target == obj) - return; - foreach (QDeclarativeBoundSignal *s, d->boundsignals) - delete s; - d->boundsignals.clear(); - d->target = obj; - connectSignals(); - emit targetChanged(); -} - - -QByteArray -QDeclarativeConnectionsParser::compile(const QList &props) -{ - QByteArray rv; - QDataStream ds(&rv, QIODevice::WriteOnly); - - for(int ii = 0; ii < props.count(); ++ii) - { - QString propName = QString::fromUtf8(props.at(ii).name()); - if (!propName.startsWith(QLatin1String("on")) || !propName.at(2).isUpper()) { - error(props.at(ii), QDeclarativeConnections::tr("Cannot assign to non-existent property \"%1\"").arg(propName)); - return QByteArray(); - } - - QList values = props.at(ii).assignedValues(); - - for (int i = 0; i < values.count(); ++i) { - const QVariant &value = values.at(i); - - if (value.userType() == qMetaTypeId()) { - error(props.at(ii), QDeclarativeConnections::tr("Connections: nested objects not allowed")); - return QByteArray(); - } else if (value.userType() == qMetaTypeId()) { - error(props.at(ii), QDeclarativeConnections::tr("Connections: syntax error")); - return QByteArray(); - } else { - QDeclarativeParser::Variant v = qvariant_cast(value); - if (v.isScript()) { - ds << propName; - ds << v.asScript(); - } else { - error(props.at(ii), QDeclarativeConnections::tr("Connections: script expected")); - return QByteArray(); - } - } - } - } - - return rv; -} - -void QDeclarativeConnectionsParser::setCustomData(QObject *object, - const QByteArray &data) -{ - QDeclarativeConnectionsPrivate *p = - static_cast(QObjectPrivate::get(object)); - p->data = data; -} - - -void QDeclarativeConnections::connectSignals() -{ - Q_D(QDeclarativeConnections); - if (!d->componentcomplete) - return; - - QDataStream ds(d->data); - while (!ds.atEnd()) { - QString propName; - ds >> propName; - QString script; - ds >> script; - QDeclarativeProperty prop(target(), propName); - if (!prop.isValid()) { - qmlInfo(this) << tr("Cannot assign to non-existent property \"%1\"").arg(propName); - } else if (prop.type() & QDeclarativeProperty::SignalProperty) { - QDeclarativeBoundSignal *signal = - new QDeclarativeBoundSignal(target(), prop.method(), this); - signal->setExpression(new QDeclarativeExpression(qmlContext(this), script, 0)); - d->boundsignals += signal; - } else { - qmlInfo(this) << tr("Cannot assign to non-existent property \"%1\"").arg(propName); - } - } -} - -void QDeclarativeConnections::componentComplete() -{ - Q_D(QDeclarativeConnections); - d->componentcomplete=true; - connectSignals(); -} - -QT_END_NAMESPACE diff --git a/src/declarative/util/qdeclarativeconnection_p.h b/src/declarative/util/qdeclarativeconnection_p.h deleted file mode 100644 index 3eacf12..0000000 --- a/src/declarative/util/qdeclarativeconnection_p.h +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (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 Technology Preview License Agreement accompanying -** this package. -** -** 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.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVECONNECTIONS_H -#define QDECLARATIVECONNECTIONS_H - -#include -#include -#include - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QDeclarativeBoundSignal; -class QDeclarativeContext; -class QDeclarativeConnectionsPrivate; -class Q_DECLARATIVE_EXPORT QDeclarativeConnections : public QObject, public QDeclarativeParserStatus -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarativeConnections) - - Q_INTERFACES(QDeclarativeParserStatus) - Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged) - -public: - QDeclarativeConnections(QObject *parent=0); - ~QDeclarativeConnections(); - - QObject *target() const; - void setTarget(QObject *); - -Q_SIGNALS: - void targetChanged(); - -private: - void connectSignals(); - void componentComplete(); -}; - -class QDeclarativeConnectionsParser : public QDeclarativeCustomParser -{ -public: - virtual QByteArray compile(const QList &); - virtual void setCustomData(QObject *, const QByteArray &); -}; - - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarativeConnections) - -QT_END_HEADER - -#endif diff --git a/src/declarative/util/qdeclarativeconnections.cpp b/src/declarative/util/qdeclarativeconnections.cpp new file mode 100644 index 0000000..0b9e3ab --- /dev/null +++ b/src/declarative/util/qdeclarativeconnections.cpp @@ -0,0 +1,245 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qdeclarativeconnections_p.h" + +#include +#include +#include +#include +#include + +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +class QDeclarativeConnectionsPrivate : public QObjectPrivate +{ +public: + QDeclarativeConnectionsPrivate() : target(0), componentcomplete(false) {} + + QList boundsignals; + QObject *target; + + bool componentcomplete; + + QByteArray data; +}; + +/*! + \qmlclass Connections QDeclarativeConnections + \since 4.7 + \brief A Connections object describes generalized connections to signals. + + When connecting to signals in QML, the usual way is to create an + "on" handler that reacts when a signal is received, like this: + + \qml + MouseArea { + onClicked: { foo(...) } + } + \endqml + + However, in some cases, it is not possible to connect to a signal in this + way, such as: + + \list + \i multiple connections to the same signal + \i connections outside the scope of the signal sender + \i connections to targets not defined in QML + \endlist + + When any of these are needed, the Connections object can be used instead. + + For example, the above code can be changed to use a Connections object, + like this: + + \qml + MouseArea { + Connections { + onClicked: foo(...) + } + } + \endqml + + More generally, the Connections object can be a child of some other object than + the sender of the signal: + + \qml + MouseArea { + id: area + } + ... + Connections { + target: area + onClicked: foo(...) + } + \endqml +*/ + +/*! + \internal + \class QDeclarativeConnections + \brief The QDeclarativeConnections class describes generalized connections to signals. + +*/ +QDeclarativeConnections::QDeclarativeConnections(QObject *parent) : + QObject(*(new QDeclarativeConnectionsPrivate), parent) +{ +} + +QDeclarativeConnections::~QDeclarativeConnections() +{ +} + +/*! + \qmlproperty Object Connections::target + This property holds the object that sends the signal. + + By default, the target is assumed to be the parent of the Connections. +*/ +QObject *QDeclarativeConnections::target() const +{ + Q_D(const QDeclarativeConnections); + return d->target ? d->target : parent(); +} + +void QDeclarativeConnections::setTarget(QObject *obj) +{ + Q_D(QDeclarativeConnections); + if (d->target == obj) + return; + foreach (QDeclarativeBoundSignal *s, d->boundsignals) + delete s; + d->boundsignals.clear(); + d->target = obj; + connectSignals(); + emit targetChanged(); +} + + +QByteArray +QDeclarativeConnectionsParser::compile(const QList &props) +{ + QByteArray rv; + QDataStream ds(&rv, QIODevice::WriteOnly); + + for(int ii = 0; ii < props.count(); ++ii) + { + QString propName = QString::fromUtf8(props.at(ii).name()); + if (!propName.startsWith(QLatin1String("on")) || !propName.at(2).isUpper()) { + error(props.at(ii), QDeclarativeConnections::tr("Cannot assign to non-existent property \"%1\"").arg(propName)); + return QByteArray(); + } + + QList values = props.at(ii).assignedValues(); + + for (int i = 0; i < values.count(); ++i) { + const QVariant &value = values.at(i); + + if (value.userType() == qMetaTypeId()) { + error(props.at(ii), QDeclarativeConnections::tr("Connections: nested objects not allowed")); + return QByteArray(); + } else if (value.userType() == qMetaTypeId()) { + error(props.at(ii), QDeclarativeConnections::tr("Connections: syntax error")); + return QByteArray(); + } else { + QDeclarativeParser::Variant v = qvariant_cast(value); + if (v.isScript()) { + ds << propName; + ds << v.asScript(); + } else { + error(props.at(ii), QDeclarativeConnections::tr("Connections: script expected")); + return QByteArray(); + } + } + } + } + + return rv; +} + +void QDeclarativeConnectionsParser::setCustomData(QObject *object, + const QByteArray &data) +{ + QDeclarativeConnectionsPrivate *p = + static_cast(QObjectPrivate::get(object)); + p->data = data; +} + + +void QDeclarativeConnections::connectSignals() +{ + Q_D(QDeclarativeConnections); + if (!d->componentcomplete) + return; + + QDataStream ds(d->data); + while (!ds.atEnd()) { + QString propName; + ds >> propName; + QString script; + ds >> script; + QDeclarativeProperty prop(target(), propName); + if (!prop.isValid()) { + qmlInfo(this) << tr("Cannot assign to non-existent property \"%1\"").arg(propName); + } else if (prop.type() & QDeclarativeProperty::SignalProperty) { + QDeclarativeBoundSignal *signal = + new QDeclarativeBoundSignal(target(), prop.method(), this); + signal->setExpression(new QDeclarativeExpression(qmlContext(this), script, 0)); + d->boundsignals += signal; + } else { + qmlInfo(this) << tr("Cannot assign to non-existent property \"%1\"").arg(propName); + } + } +} + +void QDeclarativeConnections::componentComplete() +{ + Q_D(QDeclarativeConnections); + d->componentcomplete=true; + connectSignals(); +} + +QT_END_NAMESPACE diff --git a/src/declarative/util/qdeclarativeconnections_p.h b/src/declarative/util/qdeclarativeconnections_p.h new file mode 100644 index 0000000..3eacf12 --- /dev/null +++ b/src/declarative/util/qdeclarativeconnections_p.h @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVECONNECTIONS_H +#define QDECLARATIVECONNECTIONS_H + +#include +#include +#include + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QDeclarativeBoundSignal; +class QDeclarativeContext; +class QDeclarativeConnectionsPrivate; +class Q_DECLARATIVE_EXPORT QDeclarativeConnections : public QObject, public QDeclarativeParserStatus +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QDeclarativeConnections) + + Q_INTERFACES(QDeclarativeParserStatus) + Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged) + +public: + QDeclarativeConnections(QObject *parent=0); + ~QDeclarativeConnections(); + + QObject *target() const; + void setTarget(QObject *); + +Q_SIGNALS: + void targetChanged(); + +private: + void connectSignals(); + void componentComplete(); +}; + +class QDeclarativeConnectionsParser : public QDeclarativeCustomParser +{ +public: + virtual QByteArray compile(const QList &); + virtual void setCustomData(QObject *, const QByteArray &); +}; + + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QDeclarativeConnections) + +QT_END_HEADER + +#endif diff --git a/src/declarative/util/qdeclarativeutilmodule.cpp b/src/declarative/util/qdeclarativeutilmodule.cpp index 3d34e33..2b8c7de 100644 --- a/src/declarative/util/qdeclarativeutilmodule.cpp +++ b/src/declarative/util/qdeclarativeutilmodule.cpp @@ -45,7 +45,7 @@ #include "qdeclarativeanimation_p_p.h" #include "qdeclarativebehavior_p.h" #include "qdeclarativebind_p.h" -#include "qdeclarativeconnection_p.h" +#include "qdeclarativeconnections_p.h" #include "qdeclarativedatetimeformatter_p.h" #include "qdeclarativeeasefollow_p.h" #include "qdeclarativefontloader_p.h" diff --git a/src/declarative/util/util.pri b/src/declarative/util/util.pri index 610eb3f..198e9e5 100644 --- a/src/declarative/util/util.pri +++ b/src/declarative/util/util.pri @@ -5,7 +5,7 @@ SOURCES += \ $$PWD/qdeclarativeview.cpp \ $$PWD/qfxperf.cpp \ $$PWD/qperformancelog.cpp \ - $$PWD/qdeclarativeconnection.cpp \ + $$PWD/qdeclarativeconnections.cpp \ $$PWD/qdeclarativepackage.cpp \ $$PWD/qdeclarativeanimation.cpp \ $$PWD/qdeclarativesystempalette.cpp \ @@ -37,7 +37,7 @@ HEADERS += \ $$PWD/qdeclarativeview.h \ $$PWD/qfxperf_p_p.h \ $$PWD/qperformancelog_p_p.h \ - $$PWD/qdeclarativeconnection_p.h \ + $$PWD/qdeclarativeconnections_p.h \ $$PWD/qdeclarativepackage_p.h \ $$PWD/qdeclarativeanimation_p.h \ $$PWD/qdeclarativeanimation_p_p.h \ diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro index 42ff523..4387875 100644 --- a/tests/auto/declarative/declarative.pro +++ b/tests/auto/declarative/declarative.pro @@ -7,7 +7,7 @@ SUBDIRS += \ qdeclarativeanimations \ # Cover qdeclarativebehaviors \ # Cover qdeclarativebinding \ # Cover - qdeclarativeconnection \ # Cover + qdeclarativeconnections \ # Cover qdeclarativecontext \ # Cover qdeclarativedatetimeformatter \ # Cover qdeclarativedebug \ # Cover diff --git a/tests/auto/declarative/qdeclarativeconnection/data/test-connection.qml b/tests/auto/declarative/qdeclarativeconnection/data/test-connection.qml deleted file mode 100644 index 81ab599..0000000 --- a/tests/auto/declarative/qdeclarativeconnection/data/test-connection.qml +++ /dev/null @@ -1,10 +0,0 @@ -import Qt 4.6 - -Item { - id: screen; width: 50 - - property bool tested: false - signal testMe - - Connections { target: screen; onWidthChanged: screen.tested = true } -} diff --git a/tests/auto/declarative/qdeclarativeconnection/data/test-connection2.qml b/tests/auto/declarative/qdeclarativeconnection/data/test-connection2.qml deleted file mode 100644 index 22e9422..0000000 --- a/tests/auto/declarative/qdeclarativeconnection/data/test-connection2.qml +++ /dev/null @@ -1,3 +0,0 @@ -import Qt 4.6 - -Connections { id: connection; target: connection; onTargetChanged: 1 == 1 } diff --git a/tests/auto/declarative/qdeclarativeconnection/data/test-connection3.qml b/tests/auto/declarative/qdeclarativeconnection/data/test-connection3.qml deleted file mode 100644 index 6e396c0..0000000 --- a/tests/auto/declarative/qdeclarativeconnection/data/test-connection3.qml +++ /dev/null @@ -1,3 +0,0 @@ -import Qt 4.6 - -Connections {} diff --git a/tests/auto/declarative/qdeclarativeconnection/data/trimming.qml b/tests/auto/declarative/qdeclarativeconnection/data/trimming.qml deleted file mode 100644 index 736d5e8..0000000 --- a/tests/auto/declarative/qdeclarativeconnection/data/trimming.qml +++ /dev/null @@ -1,10 +0,0 @@ -import Qt 4.6 - -Item { - id: screen; width: 50 - - property string tested - signal testMe(int param1, string param2) - - Connections { target: screen; onTestMe: screen.tested = param2 + param1 } -} diff --git a/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro b/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro deleted file mode 100644 index a6adfa4..0000000 --- a/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro +++ /dev/null @@ -1,8 +0,0 @@ -load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative gui -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativeconnection.cpp - -# Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp b/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp deleted file mode 100644 index f10217c..0000000 --- a/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite 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 Technology Preview License Agreement accompanying -** this package. -** -** 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.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include "../../../shared/util.h" -#include - -class tst_qdeclarativeconnection : public QObject - -{ - Q_OBJECT -public: - tst_qdeclarativeconnection(); - -private slots: - void defaultValues(); - void properties(); - void connection(); - void trimming(); - -private: - QDeclarativeEngine engine; -}; - -tst_qdeclarativeconnection::tst_qdeclarativeconnection() -{ -} - -void tst_qdeclarativeconnection::defaultValues() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-connection3.qml")); - QDeclarativeConnections *item = qobject_cast(c.create()); - - QVERIFY(item != 0); - QVERIFY(item->target() == 0); - - delete item; -} - -void tst_qdeclarativeconnection::properties() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-connection2.qml")); - QDeclarativeConnections *item = qobject_cast(c.create()); - - QVERIFY(item != 0); - - QVERIFY(item != 0); - QVERIFY(item->target() == item); - - delete item; -} - -void tst_qdeclarativeconnection::connection() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-connection.qml")); - QDeclarativeItem *item = qobject_cast(c.create()); - - QVERIFY(item != 0); - - QCOMPARE(item->property("tested").toBool(), false); - QCOMPARE(item->width(), 50.); - emit item->setWidth(100.); - QCOMPARE(item->width(), 100.); - QCOMPARE(item->property("tested").toBool(), true); - - delete item; -} - -void tst_qdeclarativeconnection::trimming() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/trimming.qml")); - QDeclarativeItem *item = qobject_cast(c.create()); - - QVERIFY(item != 0); - - QCOMPARE(item->property("tested").toString(), QString("")); - int index = item->metaObject()->indexOfSignal("testMe(int,QString)"); - QMetaMethod method = item->metaObject()->method(index); - method.invoke(item, - Qt::DirectConnection, - Q_ARG(int, 5), - Q_ARG(QString, "worked")); - QCOMPARE(item->property("tested").toString(), QString("worked5")); - - delete item; -} - -QTEST_MAIN(tst_qdeclarativeconnection) - -#include "tst_qdeclarativeconnection.moc" diff --git a/tests/auto/declarative/qdeclarativeconnections/data/test-connection.qml b/tests/auto/declarative/qdeclarativeconnections/data/test-connection.qml new file mode 100644 index 0000000..81ab599 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeconnections/data/test-connection.qml @@ -0,0 +1,10 @@ +import Qt 4.6 + +Item { + id: screen; width: 50 + + property bool tested: false + signal testMe + + Connections { target: screen; onWidthChanged: screen.tested = true } +} diff --git a/tests/auto/declarative/qdeclarativeconnections/data/test-connection2.qml b/tests/auto/declarative/qdeclarativeconnections/data/test-connection2.qml new file mode 100644 index 0000000..22e9422 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeconnections/data/test-connection2.qml @@ -0,0 +1,3 @@ +import Qt 4.6 + +Connections { id: connection; target: connection; onTargetChanged: 1 == 1 } diff --git a/tests/auto/declarative/qdeclarativeconnections/data/test-connection3.qml b/tests/auto/declarative/qdeclarativeconnections/data/test-connection3.qml new file mode 100644 index 0000000..6e396c0 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeconnections/data/test-connection3.qml @@ -0,0 +1,3 @@ +import Qt 4.6 + +Connections {} diff --git a/tests/auto/declarative/qdeclarativeconnections/data/trimming.qml b/tests/auto/declarative/qdeclarativeconnections/data/trimming.qml new file mode 100644 index 0000000..736d5e8 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeconnections/data/trimming.qml @@ -0,0 +1,10 @@ +import Qt 4.6 + +Item { + id: screen; width: 50 + + property string tested + signal testMe(int param1, string param2) + + Connections { target: screen; onTestMe: screen.tested = param2 + param1 } +} diff --git a/tests/auto/declarative/qdeclarativeconnections/qdeclarativeconnection.pro b/tests/auto/declarative/qdeclarativeconnections/qdeclarativeconnection.pro new file mode 100644 index 0000000..a6adfa4 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeconnections/qdeclarativeconnection.pro @@ -0,0 +1,8 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative gui +macx:CONFIG -= app_bundle + +SOURCES += tst_qdeclarativeconnection.cpp + +# Define SRCDIR equal to test's source directory +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativeconnections/tst_qdeclarativeconnection.cpp b/tests/auto/declarative/qdeclarativeconnections/tst_qdeclarativeconnection.cpp new file mode 100644 index 0000000..f10217c --- /dev/null +++ b/tests/auto/declarative/qdeclarativeconnections/tst_qdeclarativeconnection.cpp @@ -0,0 +1,135 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite 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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include "../../../shared/util.h" +#include + +class tst_qdeclarativeconnection : public QObject + +{ + Q_OBJECT +public: + tst_qdeclarativeconnection(); + +private slots: + void defaultValues(); + void properties(); + void connection(); + void trimming(); + +private: + QDeclarativeEngine engine; +}; + +tst_qdeclarativeconnection::tst_qdeclarativeconnection() +{ +} + +void tst_qdeclarativeconnection::defaultValues() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-connection3.qml")); + QDeclarativeConnections *item = qobject_cast(c.create()); + + QVERIFY(item != 0); + QVERIFY(item->target() == 0); + + delete item; +} + +void tst_qdeclarativeconnection::properties() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-connection2.qml")); + QDeclarativeConnections *item = qobject_cast(c.create()); + + QVERIFY(item != 0); + + QVERIFY(item != 0); + QVERIFY(item->target() == item); + + delete item; +} + +void tst_qdeclarativeconnection::connection() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-connection.qml")); + QDeclarativeItem *item = qobject_cast(c.create()); + + QVERIFY(item != 0); + + QCOMPARE(item->property("tested").toBool(), false); + QCOMPARE(item->width(), 50.); + emit item->setWidth(100.); + QCOMPARE(item->width(), 100.); + QCOMPARE(item->property("tested").toBool(), true); + + delete item; +} + +void tst_qdeclarativeconnection::trimming() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/trimming.qml")); + QDeclarativeItem *item = qobject_cast(c.create()); + + QVERIFY(item != 0); + + QCOMPARE(item->property("tested").toString(), QString("")); + int index = item->metaObject()->indexOfSignal("testMe(int,QString)"); + QMetaMethod method = item->metaObject()->method(index); + method.invoke(item, + Qt::DirectConnection, + Q_ARG(int, 5), + Q_ARG(QString, "worked")); + QCOMPARE(item->property("tested").toString(), QString("worked5")); + + delete item; +} + +QTEST_MAIN(tst_qdeclarativeconnection) + +#include "tst_qdeclarativeconnection.moc" -- cgit v0.12