void DisplayGroupRenderer::setDisplayGroup( DisplayGroupPtr displayGroup )
{
    QDeclarativeEngine& engine = renderContext_->getQmlEngine();

    // Update the scene with the new information
    engine.rootContext()->setContextProperty( "displaygroup",
                                              displayGroup.get( ));

    if( !displayGroupItem_ )
        createDisplayGroupQmlItem();

    if( hasBackgroundChanged( *displayGroup ))
    {
        setBackground( displayGroup->getBackgroundContent( ));
        adjustBackgroundTo( *displayGroup );
    }

    ContentWindowPtrs contentWindows = displayGroup->getContentWindows();

    // Update windows, creating new ones if needed
    QSet<QUuid> updatedWindows;
    int stackingOrder = BACKGROUND_STACKING_ORDER + 1;
    BOOST_FOREACH( ContentWindowPtr window, contentWindows )
    {
        const QUuid& id = window->getID();

        updatedWindows.insert( id );

        if( windowItems_.contains( id ))
            windowItems_[id]->update( window );
        else
            createWindowQmlItem( window );

        windowItems_[id]->setStackingOrder( stackingOrder++ );
    }

    // Remove old windows
    QmlWindows::iterator it = windowItems_.begin();
    while( it != windowItems_.end( ))
    {
        if( updatedWindows.contains( it.key( )))
            ++it;
        else
        {
            emit windowRemoved( *it );
            it = windowItems_.erase( it );
        }
    }

    // Retain the new DisplayGroup
    displayGroup_ = displayGroup;
}
Example #2
0
void DisplayGroupRenderer::setDisplayGroup(DisplayGroupPtr displayGroup)
{
    _qmlContext->setContextProperty("displaygroup", displayGroup.get());
    _updateWindowItems(*displayGroup);
    _displayGroup = std::move(displayGroup);
}