[Misc] several static methods from QskControl changed into qskXYZ

functions to avoid any conflicts with APIs that might be added to
QQuickItem in future versions
This commit is contained in:
Uwe Rathmann 2018-01-19 10:07:05 +01:00
parent b083479b21
commit 3837205847
10 changed files with 86 additions and 82 deletions

View File

@ -42,6 +42,73 @@ static inline void qskSendEventTo( QObject* object, QEvent::Type type )
QCoreApplication::sendEvent( object, &event );
}
bool qskIsAncestorOf( const QQuickItem* item, const QQuickItem* child )
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
return item->isAncestorOf( child );
#else
while ( child )
{
if ( child == item )
return true;
child = child->parentItem();
}
return false;
#endif
}
bool qskIsTabFence( const QQuickItem* item )
{
if ( item == nullptr )
return false;
return QQuickItemPrivate::get( item )->isTabFence;
}
bool qskIsShortcutScope( const QQuickItem* item )
{
if ( item == nullptr )
return false;
/*
We might have something like CTRL+W to close a "window".
But in Qt/Quick a window is not necessarily a QQuickWindow
like we have f.e QskSubWindow.
Maybe it's worth to introduce a shortcutScope flag but for
the moment we simply use the isFocusScope/isTabFence combination,
that should usually be set for those "windows".
*/
return item->isFocusScope() && QQuickItemPrivate::get( item )->isTabFence;
}
bool qskIsTransparentForPositioner( const QQuickItem* item )
{
if ( item == nullptr )
return true;
return QQuickItemPrivate::get( item )->isTransparentForPositioner();
}
const QSGNode* qskItemNode( const QQuickItem* item )
{
if ( item == nullptr )
return nullptr;
return QQuickItemPrivate::get( item )->itemNodeInstance;
}
const QSGNode* qskPaintNode( const QQuickItem* item )
{
if ( item == nullptr )
return nullptr;
return QQuickItemPrivate::get( item )->paintNode;
}
static inline controlFlags_t qskControlFlags()
{
// we are only interested in the first 8 bits
@ -479,14 +546,6 @@ bool QskControl::isTransparentForPositioner() const
return d_func()->isTransparentForPositioner();
}
bool QskControl::isTransparentForPositioner( const QQuickItem* item )
{
if ( item == nullptr )
return true;
return QQuickItemPrivate::get( item )->isTransparentForPositioner();
}
void QskControl::setPolishOnResize( bool on )
{
Q_D( QskControl );
@ -555,32 +614,6 @@ bool QskControl::isTabFence() const
return d_func()->isTabFence;
}
bool QskControl::isTabFence( const QQuickItem* item )
{
if ( item == nullptr )
return false;
return QQuickItemPrivate::get( item )->isTabFence;
}
bool QskControl::isShortcutScope( const QQuickItem* item )
{
if ( item == nullptr )
return false;
/*
We might have something like CTRL+W to close a "window".
But in Qt/Quick a window is not necessarily a QQuickWindow
like we have f.e QskSubWindow.
Maybe it's worth to introduce a shortcutScope flag but for
the moment we simply use the isFocusScope/isTabFence combination,
that should usually be set for those "windows".
*/
return item->isFocusScope() && QQuickItemPrivate::get( item )->isTabFence;
}
QskControl::Flags QskControl::controlFlags() const
{
return QskControl::Flags( d_func()->controlFlags );
@ -1170,22 +1203,6 @@ void QskControl::releaseResources()
qskReleasedWindowCounter->setWindow( window() );
}
const QSGNode* QskControl::itemNode( const QQuickItem* item )
{
if ( item == nullptr )
return nullptr;
return QQuickItemPrivate::get( item )->itemNodeInstance;
}
const QSGNode* QskControl::paintNode( const QQuickItem* item )
{
if ( item == nullptr )
return nullptr;
return QQuickItemPrivate::get( item )->paintNode;
}
void QskControl::itemChange( QQuickItem::ItemChange change,
const QQuickItem::ItemChangeData& value )
{
@ -1210,7 +1227,7 @@ void QskControl::itemChange( QQuickItem::ItemChange change,
}
case QQuickItem::ItemChildAddedChange:
{
if ( d->autoLayoutChildren && !isTransparentForPositioner( value.item ) )
if ( d->autoLayoutChildren && !qskIsTransparentForPositioner( value.item ) )
polish();
break;

View File

@ -120,11 +120,6 @@ public:
void setTransparentForPositioner( bool );
bool isTransparentForPositioner() const;
static bool isTransparentForPositioner( const QQuickItem* );
static const QSGNode* itemNode( const QQuickItem* );
static const QSGNode* paintNode( const QQuickItem* );
void setWheelEnabled( bool );
bool isWheelEnabled() const;
@ -134,9 +129,6 @@ public:
void setTabFence( bool );
bool isTabFence() const;
static bool isTabFence( const QQuickItem* );
static bool isShortcutScope( const QQuickItem* );
void setControlFlags( Flags );
void resetControlFlags();
Flags controlFlags() const;
@ -247,6 +239,14 @@ inline QSizeF QskControl::sizeHint() const
return effectiveConstraint( Qt::PreferredSize );
}
QSK_EXPORT bool qskIsAncestorOf( const QQuickItem* item, const QQuickItem *child );
QSK_EXPORT bool qskIsTransparentForPositioner( const QQuickItem* );
QSK_EXPORT bool qskIsTabFence( const QQuickItem* );
QSK_EXPORT bool qskIsShortcutScope( const QQuickItem* );
QSK_EXPORT const QSGNode* qskItemNode( const QQuickItem* );
QSK_EXPORT const QSGNode* qskPaintNode( const QQuickItem* );
Q_DECLARE_OPERATORS_FOR_FLAGS( QskControl::Flags )
Q_DECLARE_METATYPE( QskControl::Flags )

View File

@ -15,19 +15,6 @@ QSK_QT_PRIVATE_BEGIN
#include <private/qquickitemchangelistener_p.h>
QSK_QT_PRIVATE_END
static inline bool qskIsAncestorOf( const QQuickItem* item, const QQuickItem* child )
{
while ( child )
{
if ( child == item )
return true;
child = child->parentItem();
}
return false;
}
static QSizeF qskAdjustedSize( const QQuickItem* item, const QSizeF& targetSize )
{
using namespace QskLayoutConstraint;
@ -312,7 +299,7 @@ void QskScrollAreaClipItem::updateNode( QSGNode* )
const QSGClipNode* QskScrollAreaClipItem::viewPortClipNode() const
{
auto node = const_cast< QSGNode* >( QskControl::paintNode( scrollArea() ) );
auto node = const_cast< QSGNode* >( qskPaintNode( scrollArea() ) );
if ( node )
node = QskSkinlet::findNodeByRole( node, QskScrollViewSkinlet::ContentsRootRole );

View File

@ -166,7 +166,7 @@ QSGNode* QskScrollViewSkinlet::updateContentsNode(
QSGNode* QskScrollViewSkinlet::contentsNode( const QskScrollView* scrollView )
{
QSGNode* node = const_cast< QSGNode* >( QskControl::paintNode( scrollView ) );
QSGNode* node = const_cast< QSGNode* >( qskPaintNode( scrollView ) );
if ( node )
{
node = findNodeByRole( node, ContentsRootRole );

View File

@ -306,7 +306,7 @@ bool QskSetup::eventFilter( QObject* object, QEvent* event )
But we also don't want to have how it is done in QC2 by adding
the focus management in the event handler of the base class.
This implementatio reverts the expected default behaviour of when
This implementation reverts the expected default behaviour of when
events are accepted/ignored + is an error prone nightmare, when it
comes to overloading event handlers missing to call the base class.

View File

@ -360,7 +360,7 @@ bool QskShortcutMap::contextMatcher(
We have to find out if the active focus is inside
the surronding shortcut scope.
*/
if ( QskControl::isShortcutScope( item ) )
if ( qskIsShortcutScope( item ) )
{
if ( !item->hasFocus() )
return false;

View File

@ -144,7 +144,7 @@ QSizeF QskSubWindow::contentsSizeHint() const
const auto children = childItems();
for ( auto child : children )
{
if ( isTransparentForPositioner( child ) )
if ( qskIsTransparentForPositioner( child ) )
continue;
const QskControl* control = qobject_cast< QskControl* >( child );
@ -182,7 +182,7 @@ void QskSubWindow::itemChange( QQuickItem::ItemChange change,
case QQuickItem::ItemChildAddedChange:
case QQuickItem::ItemChildRemovedChange:
{
if ( !isTransparentForPositioner( value.item ) )
if ( !qskIsTransparentForPositioner( value.item ) )
{
resetImplicitSize();
polish();

View File

@ -383,7 +383,7 @@ void QskWindow::layoutItems()
const auto children = contentItem()->childItems();
for ( auto child : children )
{
if ( !QskControl::isTransparentForPositioner( child ) )
if ( !qskIsTransparentForPositioner( child ) )
{
child->setPosition( contentItem()->position() );
child->setSize( sz );

View File

@ -205,7 +205,7 @@ void QskIndexedLayoutBox::itemChange(
{
if ( m_data->autoAddChildren && !m_data->blockChildAdded )
{
if ( !isTransparentForPositioner( value.item ) )
if ( !qskIsTransparentForPositioner( value.item ) )
addItem( value.item );
}

View File

@ -192,11 +192,11 @@ static inline void countNodes( const QSGNode* node, int& counter )
static void countNodes( const QQuickItem* item, int& counter )
{
const auto itemNode = QskControl::itemNode( item );
const auto itemNode = qskItemNode( item );
if ( itemNode )
{
auto node = QskControl::paintNode( item );
auto node = qskPaintNode( item );
if ( node )
{
countNodes( node, counter );