as the root item is no child of the window we have to handle it
explicitly, so that traversing does not stop
This commit is contained in:
parent
3e40bfb257
commit
3efb1f93e7
@ -21,31 +21,30 @@ QObjectList QskObjectTree::childNodes( const QObject* object )
|
||||
if ( object == nullptr )
|
||||
{
|
||||
const auto windows = QGuiApplication::topLevelWindows();
|
||||
for ( QWindow* window : windows )
|
||||
for ( auto window : windows )
|
||||
children += window;
|
||||
}
|
||||
else if ( object->isWindowType() )
|
||||
{
|
||||
const auto childObjects = object->children();
|
||||
|
||||
for ( QObject* child : childObjects )
|
||||
for ( auto child : childObjects )
|
||||
{
|
||||
if ( child->isWindowType() )
|
||||
{
|
||||
children += child;
|
||||
}
|
||||
else if ( qobject_cast< QQuickItem* >( child ) )
|
||||
{
|
||||
children += child;
|
||||
}
|
||||
}
|
||||
|
||||
if ( auto w = qobject_cast< const QQuickWindow* >( object ) )
|
||||
{
|
||||
// For some reason the window is not the parent of its contentItem()
|
||||
children += w->contentItem();
|
||||
}
|
||||
}
|
||||
else
|
||||
else if ( auto item = qobject_cast< const QQuickItem* >( object ) )
|
||||
{
|
||||
const QQuickItem* item = static_cast< const QQuickItem* >( object );
|
||||
|
||||
const auto childItems = item->childItems();
|
||||
for ( QQuickItem* child : childItems )
|
||||
|
||||
for ( auto child : childItems )
|
||||
children += child;
|
||||
}
|
||||
|
||||
@ -59,12 +58,11 @@ QObject* QskObjectTree::parentNode( const QObject* object )
|
||||
|
||||
if ( object->isWindowType() )
|
||||
{
|
||||
QObject* parentObject = object->parent();
|
||||
if ( parentObject == nullptr )
|
||||
if ( object->parent() == nullptr )
|
||||
return QGuiApplication::instance();
|
||||
}
|
||||
|
||||
if ( const QQuickItem* item = qobject_cast< const QQuickItem* >( object ) )
|
||||
if ( auto item = qobject_cast< const QQuickItem* >( object ) )
|
||||
{
|
||||
if ( item->parentItem() )
|
||||
return item->parentItem();
|
||||
|
@ -50,10 +50,10 @@ namespace QskObjectTree
|
||||
|
||||
bool visitDown( QObject* object ) override final
|
||||
{
|
||||
if ( QskControl* control = qobject_cast< QskControl* >( object ) )
|
||||
if ( auto control = qobject_cast< QskControl* >( object ) )
|
||||
return setImplicitValue( control, m_value );
|
||||
|
||||
if ( QskWindow* window = qobject_cast< QskWindow* >( object ) )
|
||||
if ( auto window = qobject_cast< QskWindow* >( object ) )
|
||||
return setImplicitValue( window, m_value );
|
||||
|
||||
return !setProperty( object, m_propertyName.constData(), m_value );
|
||||
@ -64,13 +64,13 @@ namespace QskObjectTree
|
||||
if ( isRoot( object ) )
|
||||
return true;
|
||||
|
||||
if ( const QskControl* control = qobject_cast< const QskControl* >( object ) )
|
||||
if ( auto control = qobject_cast< const QskControl* >( object ) )
|
||||
{
|
||||
m_value = value( control );
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( const QskWindow* window = qobject_cast< const QskWindow* >( object ) )
|
||||
if ( auto window = qobject_cast< const QskWindow* >( object ) )
|
||||
{
|
||||
m_value = value( window );
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user