QskControlPrivate separate declaration/implemetation
This commit is contained in:
parent
cbc5d2b11f
commit
b99dd147f2
|
@ -195,7 +195,90 @@ class QskControlPrivate final : public QQuickItemPrivate
|
||||||
{ qskDefaultSizeHints[ 0 ], qskDefaultSizeHints[ 1 ], qskDefaultSizeHints[ 2 ] };
|
{ qskDefaultSizeHints[ 0 ], qskDefaultSizeHints[ 1 ], qskDefaultSizeHints[ 2 ] };
|
||||||
};
|
};
|
||||||
|
|
||||||
QskControlPrivate()
|
QskControlPrivate();
|
||||||
|
~QskControlPrivate() override;
|
||||||
|
|
||||||
|
void mirrorChange() override;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
// can we do something useful with overloading those ???
|
||||||
|
|
||||||
|
qreal getImplicitWidth() const override;
|
||||||
|
qreal getImplicitHeight() const override;
|
||||||
|
|
||||||
|
QSGTransformNode* createTransformNode() override;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void implicitWidthChanged() override;
|
||||||
|
void implicitHeightChanged() override;
|
||||||
|
|
||||||
|
void setExplicitSizeHint( Qt::SizeHint whichHint, const QSizeF& size );
|
||||||
|
QSizeF explicitSizeHint( Qt::SizeHint whichHint ) const;
|
||||||
|
|
||||||
|
bool maybeGesture( QQuickItem* child, QEvent* event );
|
||||||
|
|
||||||
|
void updateControlFlags( QskControl::Flags flags );
|
||||||
|
|
||||||
|
/*
|
||||||
|
Qt 5.11:
|
||||||
|
sizeof( QQuickItemPrivate::ExtraData ) -> 184
|
||||||
|
sizeof( QQuickItemPrivate ) -> 320
|
||||||
|
|
||||||
|
sizeof( QskControlPrivate ) -> sizeof( QQuickItemPrivate ) + 32
|
||||||
|
sizeof( QskSkinnable::PrivateData ) -> 40
|
||||||
|
|
||||||
|
( these numbers include pointers to optional extra data, that might
|
||||||
|
increase the effective memory footprint, when being accurate ).
|
||||||
|
|
||||||
|
It might be possible to save some bytes, but in the end QskControl
|
||||||
|
is heavy simply because of deriving from QQuickItem. So without
|
||||||
|
patching Qt the only way to limit the memory footprint of an application
|
||||||
|
substantially is to limit the number of QQuickItems.
|
||||||
|
|
||||||
|
That's why QSkinny builds more complex controls from scene graph nodes
|
||||||
|
instead of doing QQuickItem composition. As this can only be done
|
||||||
|
in C++ it is kind of obvious, why it is often a bad idea to build
|
||||||
|
custom controls in QML.
|
||||||
|
*/
|
||||||
|
|
||||||
|
private:
|
||||||
|
void implicitSizeChanged();
|
||||||
|
|
||||||
|
ExplicitSizeData* explicitSizeData;
|
||||||
|
|
||||||
|
public:
|
||||||
|
QLocale locale;
|
||||||
|
|
||||||
|
QskSizePolicy sizePolicy;
|
||||||
|
|
||||||
|
quint16 controlFlags;
|
||||||
|
quint16 controlFlagsMask;
|
||||||
|
|
||||||
|
bool explicitLocale : 1;
|
||||||
|
|
||||||
|
bool autoFillBackground : 1;
|
||||||
|
bool autoLayoutChildren : 1;
|
||||||
|
bool polishOnResize : 1;
|
||||||
|
|
||||||
|
bool blockedPolish : 1;
|
||||||
|
bool blockedImplicitSize : 1;
|
||||||
|
bool clearPreviousNodes : 1;
|
||||||
|
|
||||||
|
bool blockImplicitSizeNotification : 1;
|
||||||
|
|
||||||
|
bool isInitiallyPainted : 1;
|
||||||
|
|
||||||
|
uint focusPolicy : 4;
|
||||||
|
bool isWheelEnabled : 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void qskUpdateControlFlags( QskControl::Flags flags, QskControl* control )
|
||||||
|
{
|
||||||
|
auto d = static_cast< QskControlPrivate* >( QQuickItemPrivate::get( control ) );
|
||||||
|
d->updateControlFlags( flags );
|
||||||
|
}
|
||||||
|
|
||||||
|
QskControlPrivate::QskControlPrivate()
|
||||||
: explicitSizeData( nullptr )
|
: explicitSizeData( nullptr )
|
||||||
, sizePolicy( QskSizePolicy::Preferred, QskSizePolicy::Preferred )
|
, sizePolicy( QskSizePolicy::Preferred, QskSizePolicy::Preferred )
|
||||||
, controlFlags( qskControlFlags() )
|
, controlFlags( qskControlFlags() )
|
||||||
|
@ -233,18 +316,18 @@ class QskControlPrivate final : public QQuickItemPrivate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
~QskControlPrivate() override
|
QskControlPrivate::~QskControlPrivate()
|
||||||
{
|
{
|
||||||
delete explicitSizeData;
|
delete explicitSizeData;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mirrorChange() override
|
void QskControlPrivate::mirrorChange()
|
||||||
{
|
{
|
||||||
Q_Q( QskControl );
|
Q_Q( QskControl );
|
||||||
qskSendEventTo( q, QEvent::LayoutDirectionChange );
|
qskSendEventTo( q, QEvent::LayoutDirectionChange );
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void implicitSizeChanged()
|
inline void QskControlPrivate::implicitSizeChanged()
|
||||||
{
|
{
|
||||||
Q_Q( QskControl );
|
Q_Q( QskControl );
|
||||||
if ( !q->explicitSizeHint( Qt::PreferredSize ).isValid() )
|
if ( !q->explicitSizeHint( Qt::PreferredSize ).isValid() )
|
||||||
|
@ -256,16 +339,7 @@ class QskControlPrivate final : public QQuickItemPrivate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
void QskControlPrivate::implicitWidthChanged()
|
||||||
// can we do something useful with overloading those ???
|
|
||||||
|
|
||||||
qreal getImplicitWidth() const override;
|
|
||||||
qreal getImplicitHeight() const override;
|
|
||||||
|
|
||||||
QSGTransformNode* createTransformNode() override;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void implicitWidthChanged() override
|
|
||||||
{
|
{
|
||||||
QQuickItemPrivate::implicitWidthChanged();
|
QQuickItemPrivate::implicitWidthChanged();
|
||||||
|
|
||||||
|
@ -273,7 +347,7 @@ class QskControlPrivate final : public QQuickItemPrivate
|
||||||
implicitSizeChanged();
|
implicitSizeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void implicitHeightChanged() override
|
void QskControlPrivate::implicitHeightChanged()
|
||||||
{
|
{
|
||||||
QQuickItemPrivate::implicitWidthChanged();
|
QQuickItemPrivate::implicitWidthChanged();
|
||||||
|
|
||||||
|
@ -281,7 +355,8 @@ class QskControlPrivate final : public QQuickItemPrivate
|
||||||
implicitSizeChanged();
|
implicitSizeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void setExplicitSizeHint( Qt::SizeHint whichHint, const QSizeF& size )
|
inline void QskControlPrivate::setExplicitSizeHint(
|
||||||
|
Qt::SizeHint whichHint, const QSizeF& size )
|
||||||
{
|
{
|
||||||
if ( explicitSizeData == nullptr )
|
if ( explicitSizeData == nullptr )
|
||||||
explicitSizeData = new ExplicitSizeData;
|
explicitSizeData = new ExplicitSizeData;
|
||||||
|
@ -289,7 +364,7 @@ class QskControlPrivate final : public QQuickItemPrivate
|
||||||
explicitSizeData->sizeHints[ whichHint ] = size;
|
explicitSizeData->sizeHints[ whichHint ] = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QSizeF explicitSizeHint( Qt::SizeHint whichHint ) const
|
inline QSizeF QskControlPrivate::explicitSizeHint( Qt::SizeHint whichHint ) const
|
||||||
{
|
{
|
||||||
if ( explicitSizeData )
|
if ( explicitSizeData )
|
||||||
return explicitSizeData->sizeHints[ whichHint ];
|
return explicitSizeData->sizeHints[ whichHint ];
|
||||||
|
@ -297,7 +372,7 @@ class QskControlPrivate final : public QQuickItemPrivate
|
||||||
return qskDefaultSizeHints[ whichHint ];
|
return qskDefaultSizeHints[ whichHint ];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool maybeGesture( QQuickItem* child, QEvent* event )
|
bool QskControlPrivate::maybeGesture( QQuickItem* child, QEvent* event )
|
||||||
{
|
{
|
||||||
Q_Q( QskControl );
|
Q_Q( QskControl );
|
||||||
|
|
||||||
|
@ -330,7 +405,7 @@ class QskControlPrivate final : public QQuickItemPrivate
|
||||||
return q->gestureFilter( child, event );
|
return q->gestureFilter( child, event );
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateControlFlags( QskControl::Flags flags )
|
void QskControlPrivate::updateControlFlags( QskControl::Flags flags )
|
||||||
{
|
{
|
||||||
Q_Q( QskControl );
|
Q_Q( QskControl );
|
||||||
|
|
||||||
|
@ -352,62 +427,7 @@ class QskControlPrivate final : public QQuickItemPrivate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// --------
|
||||||
Qt 5.11:
|
|
||||||
sizeof( QQuickItemPrivate::ExtraData ) -> 184
|
|
||||||
sizeof( QQuickItemPrivate ) -> 320
|
|
||||||
|
|
||||||
sizeof( QskControlPrivate ) -> sizeof( QQuickItemPrivate ) + 32
|
|
||||||
sizeof( QskSkinnable::PrivateData ) -> 40
|
|
||||||
|
|
||||||
( these numbers include pointers to optional extra data, that might
|
|
||||||
increase the effective memory footprint, when being accurate ).
|
|
||||||
|
|
||||||
It might be possible to save some bytes, but in the end QskControl
|
|
||||||
is heavy simply because of deriving from QQuickItem. So without
|
|
||||||
patching Qt the only way to limit the memory footprint of an application
|
|
||||||
substantially is to limit the number of QQuickItems.
|
|
||||||
|
|
||||||
That's why QSkinny builds more complex controls from scene graph nodes
|
|
||||||
instead of doing QQuickItem composition. As this can only be done
|
|
||||||
in C++ it is kind of obvious, why it is often a bad idea to build
|
|
||||||
custom controls in QML.
|
|
||||||
*/
|
|
||||||
|
|
||||||
private:
|
|
||||||
ExplicitSizeData* explicitSizeData;
|
|
||||||
|
|
||||||
public:
|
|
||||||
QLocale locale;
|
|
||||||
|
|
||||||
QskSizePolicy sizePolicy;
|
|
||||||
|
|
||||||
quint16 controlFlags;
|
|
||||||
quint16 controlFlagsMask;
|
|
||||||
|
|
||||||
bool explicitLocale : 1;
|
|
||||||
|
|
||||||
bool autoFillBackground : 1;
|
|
||||||
bool autoLayoutChildren : 1;
|
|
||||||
bool polishOnResize : 1;
|
|
||||||
|
|
||||||
bool blockedPolish : 1;
|
|
||||||
bool blockedImplicitSize : 1;
|
|
||||||
bool clearPreviousNodes : 1;
|
|
||||||
|
|
||||||
bool blockImplicitSizeNotification : 1;
|
|
||||||
|
|
||||||
bool isInitiallyPainted : 1;
|
|
||||||
|
|
||||||
uint focusPolicy : 4;
|
|
||||||
bool isWheelEnabled : 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
static void qskUpdateControlFlags( QskControl::Flags flags, QskControl* control )
|
|
||||||
{
|
|
||||||
auto d = static_cast< QskControlPrivate* >( QQuickItemPrivate::get( control ) );
|
|
||||||
d->updateControlFlags( flags );
|
|
||||||
}
|
|
||||||
|
|
||||||
QskControl::QskControl( QQuickItem* parent )
|
QskControl::QskControl( QQuickItem* parent )
|
||||||
: Inherited( *( new QskControlPrivate() ), parent )
|
: Inherited( *( new QskControlPrivate() ), parent )
|
||||||
|
|
Loading…
Reference in New Issue