From 2ae178f42442d633ac4563315f212a6cdcc5b174 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Sun, 14 Jun 2015 20:39:43 +0200 Subject: Let QQuickGroupBox inherit QQuickFrame Change-Id: If1d8f3c5ca35b47031adb308a313deb5c1f38bca Reviewed-by: J-P Nurmi --- src/controls/controls.pri | 1 + src/controls/qquickframe.cpp | 35 +++++++++++++++++++++- src/controls/qquickframe_p.h | 16 ++++++++++ src/controls/qquickframe_p_p.h | 65 +++++++++++++++++++++++++++++++++++++++++ src/controls/qquickgroupbox.cpp | 34 ++++----------------- src/controls/qquickgroupbox_p.h | 9 ++---- 6 files changed, 123 insertions(+), 37 deletions(-) create mode 100644 src/controls/qquickframe_p_p.h (limited to 'src/controls') diff --git a/src/controls/controls.pri b/src/controls/controls.pri index 9a7efe97..bf636066 100644 --- a/src/controls/controls.pri +++ b/src/controls/controls.pri @@ -14,6 +14,7 @@ HEADERS += \ $$PWD/qquickcontrol_p_p.h \ $$PWD/qquickexclusivegroup_p.h \ $$PWD/qquickframe_p.h \ + $$PWD/qquickframe_p_p.h \ $$PWD/qquickgroupbox_p.h \ $$PWD/qquicklabel_p.h \ $$PWD/qquickpageindicator_p.h \ diff --git a/src/controls/qquickframe.cpp b/src/controls/qquickframe.cpp index 1a0f5f68..e64ff13e 100644 --- a/src/controls/qquickframe.cpp +++ b/src/controls/qquickframe.cpp @@ -35,6 +35,7 @@ ****************************************************************************/ #include "qquickframe_p.h" +#include "qquickframe_p_p.h" QT_BEGIN_NAMESPACE @@ -49,9 +50,41 @@ QT_BEGIN_NAMESPACE TODO */ +QQuickFramePrivate::QQuickFramePrivate() : frame(Q_NULLPTR) +{ +} + QQuickFrame::QQuickFrame(QQuickItem *parent) : - QQuickContainer(parent) + QQuickContainer(*(new QQuickFramePrivate), parent) +{ +} + +QQuickFrame::QQuickFrame(QQuickFramePrivate &dd, QQuickItem *parent) : + QQuickContainer(dd, parent) +{ +} + +/*! + \qmlproperty Item QtQuickControls2::Frame::frame + + TODO +*/ +QQuickItem *QQuickFrame::frame() const +{ + Q_D(const QQuickFrame); + return d->frame; +} + +void QQuickFrame::setFrame(QQuickItem *frame) { + Q_D(QQuickFrame); + if (d->frame != frame) { + delete d->frame; + d->frame = frame; + if (frame && !frame->parentItem()) + frame->setParentItem(this); + emit frameChanged(); + } } QT_END_NAMESPACE diff --git a/src/controls/qquickframe_p.h b/src/controls/qquickframe_p.h index 85bd72fc..c62cf0fb 100644 --- a/src/controls/qquickframe_p.h +++ b/src/controls/qquickframe_p.h @@ -52,12 +52,28 @@ QT_BEGIN_NAMESPACE +class QQuickFramePrivate; + class Q_QUICKCONTROLS_EXPORT QQuickFrame : public QQuickContainer { Q_OBJECT + Q_PROPERTY(QQuickItem *frame READ frame WRITE setFrame NOTIFY frameChanged FINAL) public: explicit QQuickFrame(QQuickItem *parent = Q_NULLPTR); + + QQuickItem *frame() const; + void setFrame(QQuickItem *frame); + +Q_SIGNALS: + void frameChanged(); + +protected: + QQuickFrame(QQuickFramePrivate &dd, QQuickItem *parent); + +private: + Q_DISABLE_COPY(QQuickFrame) + Q_DECLARE_PRIVATE(QQuickFrame) }; QT_END_NAMESPACE diff --git a/src/controls/qquickframe_p_p.h b/src/controls/qquickframe_p_p.h new file mode 100644 index 00000000..f7985593 --- /dev/null +++ b/src/controls/qquickframe_p_p.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later 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 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQUICKFRAME_P_P_H +#define QQUICKFRAME_P_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class Q_QUICKCONTROLS_EXPORT QQuickFramePrivate : public QQuickContainerPrivate +{ +public: + QQuickFramePrivate(); + + QQuickItem *frame; +}; + +QT_END_NAMESPACE + +#endif // QQUICKFRAME_P_P_H diff --git a/src/controls/qquickgroupbox.cpp b/src/controls/qquickgroupbox.cpp index 3937f6c1..a3266aa6 100644 --- a/src/controls/qquickgroupbox.cpp +++ b/src/controls/qquickgroupbox.cpp @@ -35,13 +35,13 @@ ****************************************************************************/ #include "qquickgroupbox_p.h" -#include "qquickcontainer_p_p.h" +#include "qquickframe_p_p.h" QT_BEGIN_NAMESPACE /*! \qmltype GroupBox - \inherits Container + \inherits Frame \instantiates QQuickGroupBox \inqmlmodule QtQuick.Controls \ingroup containers @@ -50,18 +50,17 @@ QT_BEGIN_NAMESPACE TODO */ -class QQuickGroupBoxPrivate : public QQuickContainerPrivate +class QQuickGroupBoxPrivate : public QQuickFramePrivate { public: - QQuickGroupBoxPrivate() : label(Q_NULLPTR), frame(Q_NULLPTR) { } + QQuickGroupBoxPrivate() : label(Q_NULLPTR) { } QString title; QQuickItem *label; - QQuickItem *frame; }; QQuickGroupBox::QQuickGroupBox(QQuickItem *parent) : - QQuickContainer(*(new QQuickGroupBoxPrivate), parent) + QQuickFrame(*(new QQuickGroupBoxPrivate), parent) { } @@ -108,27 +107,4 @@ void QQuickGroupBox::setLabel(QQuickItem *label) } } -/*! - \qmlproperty Item QtQuickControls2::GroupBox::frame - - TODO -*/ -QQuickItem *QQuickGroupBox::frame() const -{ - Q_D(const QQuickGroupBox); - return d->frame; -} - -void QQuickGroupBox::setFrame(QQuickItem *frame) -{ - Q_D(QQuickGroupBox); - if (d->frame != frame) { - delete d->frame; - d->frame = frame; - if (frame && !frame->parentItem()) - frame->setParentItem(this); - emit frameChanged(); - } -} - QT_END_NAMESPACE diff --git a/src/controls/qquickgroupbox_p.h b/src/controls/qquickgroupbox_p.h index d2e65f63..bae21a36 100644 --- a/src/controls/qquickgroupbox_p.h +++ b/src/controls/qquickgroupbox_p.h @@ -48,18 +48,17 @@ // We mean it. // -#include +#include QT_BEGIN_NAMESPACE class QQuickGroupBoxPrivate; -class Q_QUICKCONTROLS_EXPORT QQuickGroupBox : public QQuickContainer +class Q_QUICKCONTROLS_EXPORT QQuickGroupBox : public QQuickFrame { Q_OBJECT Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged FINAL) Q_PROPERTY(QQuickItem *label READ label WRITE setLabel NOTIFY labelChanged FINAL) - Q_PROPERTY(QQuickItem *frame READ frame WRITE setFrame NOTIFY frameChanged FINAL) public: explicit QQuickGroupBox(QQuickItem *parent = Q_NULLPTR); @@ -70,13 +69,9 @@ public: QQuickItem *label() const; void setLabel(QQuickItem *label); - QQuickItem *frame() const; - void setFrame(QQuickItem *frame); - Q_SIGNALS: void titleChanged(); void labelChanged(); - void frameChanged(); private: Q_DISABLE_COPY(QQuickGroupBox) -- cgit v1.2.3