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 )
|
if ( object == nullptr )
|
||||||
{
|
{
|
||||||
const auto windows = QGuiApplication::topLevelWindows();
|
const auto windows = QGuiApplication::topLevelWindows();
|
||||||
for ( QWindow* window : windows )
|
for ( auto window : windows )
|
||||||
children += window;
|
children += window;
|
||||||
}
|
}
|
||||||
else if ( object->isWindowType() )
|
else if ( object->isWindowType() )
|
||||||
{
|
{
|
||||||
const auto childObjects = object->children();
|
const auto childObjects = object->children();
|
||||||
|
|
||||||
for ( QObject* child : childObjects )
|
for ( auto child : childObjects )
|
||||||
{
|
{
|
||||||
if ( child->isWindowType() )
|
if ( child->isWindowType() )
|
||||||
{
|
|
||||||
children += child;
|
children += child;
|
||||||
}
|
}
|
||||||
else if ( qobject_cast< QQuickItem* >( child ) )
|
|
||||||
{
|
if ( auto w = qobject_cast< const QQuickWindow* >( object ) )
|
||||||
children += child;
|
{
|
||||||
}
|
// 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();
|
const auto childItems = item->childItems();
|
||||||
for ( QQuickItem* child : childItems )
|
|
||||||
|
for ( auto child : childItems )
|
||||||
children += child;
|
children += child;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,12 +58,11 @@ QObject* QskObjectTree::parentNode( const QObject* object )
|
|||||||
|
|
||||||
if ( object->isWindowType() )
|
if ( object->isWindowType() )
|
||||||
{
|
{
|
||||||
QObject* parentObject = object->parent();
|
if ( object->parent() == nullptr )
|
||||||
if ( parentObject == nullptr )
|
|
||||||
return QGuiApplication::instance();
|
return QGuiApplication::instance();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( const QQuickItem* item = qobject_cast< const QQuickItem* >( object ) )
|
if ( auto item = qobject_cast< const QQuickItem* >( object ) )
|
||||||
{
|
{
|
||||||
if ( item->parentItem() )
|
if ( item->parentItem() )
|
||||||
return item->parentItem();
|
return item->parentItem();
|
||||||
|
@ -50,10 +50,10 @@ namespace QskObjectTree
|
|||||||
|
|
||||||
bool visitDown( QObject* object ) override final
|
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 );
|
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 setImplicitValue( window, m_value );
|
||||||
|
|
||||||
return !setProperty( object, m_propertyName.constData(), m_value );
|
return !setProperty( object, m_propertyName.constData(), m_value );
|
||||||
@ -64,13 +64,13 @@ namespace QskObjectTree
|
|||||||
if ( isRoot( object ) )
|
if ( isRoot( object ) )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if ( const QskControl* control = qobject_cast< const QskControl* >( object ) )
|
if ( auto control = qobject_cast< const QskControl* >( object ) )
|
||||||
{
|
{
|
||||||
m_value = value( control );
|
m_value = value( control );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( const QskWindow* window = qobject_cast< const QskWindow* >( object ) )
|
if ( auto window = qobject_cast< const QskWindow* >( object ) )
|
||||||
{
|
{
|
||||||
m_value = value( window );
|
m_value = value( window );
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user