diff options
Diffstat (limited to 'src/wrappedobjects/qwrappedobject.cpp')
-rw-r--r-- | src/wrappedobjects/qwrappedobject.cpp | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/src/wrappedobjects/qwrappedobject.cpp b/src/wrappedobjects/qwrappedobject.cpp new file mode 100644 index 00000000..d0563809 --- /dev/null +++ b/src/wrappedobjects/qwrappedobject.cpp @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Sandro S. Andrade <sandroandrade@kde.org> +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtWrappedObjects module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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. +** +** 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwrappedobject.h" +#include "qwrappedobject_p.h" + +QT_BEGIN_NAMESPACE_QTWRAPPEDOBJECTS + +QWrappedObjectPrivate::QWrappedObjectPrivate(int version) + : QObjectPrivate(version), wrapper(0) +{ +} + +QWrappedObjectPrivate::~QWrappedObjectPrivate() +{ +} + +QWrappedObject::QWrappedObject(QWrappedObject *parent, QWrappedObject *wrapper) : + QObject(*new QWrappedObjectPrivate, parent) +{ + setWrapper(wrapper); +} + +QWrappedObject::QWrappedObject(QWrappedObjectPrivate &dd, QWrappedObject *parent, QWrappedObject *wrapper) : + QObject(dd, parent) +{ + setWrapper(wrapper); +} + +QWrappedObject::~QWrappedObject() +{ +} + +const QList<QWrappedObject *> &QWrappedObject::wrappedObjects() const +{ + Q_D(const QWrappedObject); + return d->wrappedObjects; +} + +void QWrappedObject::setWrapper(QWrappedObject *wrapper) +{ + Q_D(QWrappedObject); + if (wrapper == d->wrapper) + return; + + if (d->wrapper) + d->wrapper->d_func()->wrappedObjects.removeAll(this); + + d->wrapper = wrapper; + + if (wrapper) + wrapper->d_func()->wrappedObjects.append(this); +} + +QWrappedObject *QWrappedObject::wrapper() const +{ + Q_D(const QWrappedObject); + return d->wrapper; +} + +#include "moc_qwrappedobject.cpp" + +QT_END_NAMESPACE_QTWRAPPEDOBJECTS + |