From 85c8f528226fae71785c3bb65ffa53982c2c1c87 Mon Sep 17 00:00:00 2001 From: Znurre Date: Wed, 28 Mar 2018 18:13:21 +0200 Subject: [PATCH] Dropped the Splitter attached properties --- src/declarativesplitter.cpp | 55 ------------------------------- src/declarativesplitter_p.h | 28 ---------------- src/declarativewidgets_plugin.cpp | 4 +-- src/splitterwidgetcontainer.cpp | 12 +------ 4 files changed, 3 insertions(+), 96 deletions(-) diff --git a/src/declarativesplitter.cpp b/src/declarativesplitter.cpp index abf0a7b..25fccd4 100644 --- a/src/declarativesplitter.cpp +++ b/src/declarativesplitter.cpp @@ -27,62 +27,7 @@ #include "declarativesplitter_p.h" -#include -#include -#include - -class DeclarativeSplitterAttached::Private -{ - public: - Private(QWidget *w) - : stretch(0) - , widget(w) - { - } - - int stretch; - - QPointer widget; -}; - -DeclarativeSplitterAttached::DeclarativeSplitterAttached(QWidget *widget, QObject *parent) - : QObject(parent) - , d(new Private(widget)) -{ -} - -DeclarativeSplitterAttached::~DeclarativeSplitterAttached() -{ - delete d; -} - -void DeclarativeSplitterAttached::setStretch(int stretch) -{ - if (stretch == d->stretch) - return; - - d->stretch = stretch; - - emit stretchChanged(stretch); -} - -int DeclarativeSplitterAttached::stretch() const -{ - return d->stretch; -} - DeclarativeSplitter::DeclarativeSplitter(QWidget *parent) : QSplitter(parent) { } - -DeclarativeSplitterAttached *DeclarativeSplitter::qmlAttachedProperties(QObject *parent) -{ - QWidget *widget = qobject_cast(parent); - if (widget) - return new DeclarativeSplitterAttached(widget, parent); - - qmlInfo(parent) << "Can only attach Splitter to widgets"; - - return Q_NULLPTR; -} diff --git a/src/declarativesplitter_p.h b/src/declarativesplitter_p.h index f0e7730..c5cc58b 100644 --- a/src/declarativesplitter_p.h +++ b/src/declarativesplitter_p.h @@ -28,40 +28,12 @@ #ifndef DECLARATIVESPLITTER_P_H #define DECLARATIVESPLITTER_P_H -#include -#include #include -#include - -class DeclarativeSplitterAttached : public QObject -{ - Q_OBJECT - - Q_PROPERTY(int stretch READ stretch WRITE setStretch NOTIFY stretchChanged) - - public: - DeclarativeSplitterAttached(QWidget *widget, QObject *parent); - ~DeclarativeSplitterAttached(); - - void setStretch(int stretch); - int stretch() const; - - Q_SIGNALS: - void stretchChanged(int stretch); - - private: - class Private; - Private *const d; -}; class DeclarativeSplitter : public QSplitter { public: DeclarativeSplitter(QWidget *parent = Q_NULLPTR); - - static DeclarativeSplitterAttached *qmlAttachedProperties(QObject *parent); }; -QML_DECLARE_TYPEINFO(DeclarativeSplitter, QML_HAS_ATTACHED_PROPERTIES) - #endif // DECLARATIVESPLITTER_P_H diff --git a/src/declarativewidgets_plugin.cpp b/src/declarativewidgets_plugin.cpp index a57a806..4e474e8 100644 --- a/src/declarativewidgets_plugin.cpp +++ b/src/declarativewidgets_plugin.cpp @@ -54,6 +54,7 @@ #include "declarativeseparator_p.h" #include "declarativesizepolicy_p.h" #include "declarativespaceritem_p.h" +#include "declarativesplitter_p.h" #include "declarativestackedlayout_p.h" #include "declarativestatusbar_p.h" #include "declarativestringlistmodelextension_p.h" @@ -68,10 +69,9 @@ #include "menubarwidgetcontainer_p.h" #include "menuwidgetcontainer_p.h" #include "scrollareawidgetcontainer_p.h" +#include "splitterwidgetcontainer_p.h" #include "stackedwidgetwidgetcontainer_p.h" #include "toolbarwidgetcontainer_p.h" -#include "splitterwidgetcontainer_p.h" -#include "declarativesplitter_p.h" #include #include diff --git a/src/splitterwidgetcontainer.cpp b/src/splitterwidgetcontainer.cpp index b6e6af4..8bc1f24 100644 --- a/src/splitterwidgetcontainer.cpp +++ b/src/splitterwidgetcontainer.cpp @@ -29,9 +29,8 @@ #include "declarativesplitter_p.h" -#include #include -#include +#include SplitterWidgetContainer::SplitterWidgetContainer(QObject *parent) : DefaultWidgetContainer(qobject_cast(parent)) @@ -47,15 +46,6 @@ void SplitterWidgetContainer::setLayout(QLayout *layout) void SplitterWidgetContainer::addWidget(QWidget *widget) { - QObject *attachedProperties = qmlAttachedPropertiesObject(widget, false); - DeclarativeSplitterAttached *properties = qobject_cast(attachedProperties); - if (properties) { - QSizePolicy policy = widget->sizePolicy(); - policy.setHorizontalStretch(properties->stretch()); - policy.setVerticalStretch(properties->stretch()); - widget->setSizePolicy(policy); - } - extendedSplitter()->addWidget(widget); }