mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-24 22:27:55 -05:00
Make sure property editor(s) and tree view selections are in sync after loading a project
This commit is contained in:
1 parent
8c80b87d30
commit
7b6934a1ff
2 files changed
+26
-30
No files matched your search
@@ -263,22 +263,22 @@ void RiuMainWindow::initializeGuiNewProjectLoaded()
|
||||
}
|
||||
}
|
||||
|
||||
// Find the project tree and reselect items to trigger the selectionChanged signal. This will make sure that the property view is
|
||||
// updated based on the selection in the main project tree.
|
||||
if ( auto dockWidget = RiuDockWidgetTools::findDockWidget( dockManager(), RiuDockWidgetTools::mainWindowProjectTreeName() ) )
|
||||
// Sync selections with property editor.
|
||||
// Go backwards as the most "important" tree view is first in the list
|
||||
// and we want that to use the property editor in case multiple tree views are visible
|
||||
for ( auto it = m_projectTreeViews.rbegin(); it != m_projectTreeViews.rend(); it++ )
|
||||
{
|
||||
if ( auto tree = dynamic_cast<caf::PdmUiTreeView*>( dockWidget->widget() ) )
|
||||
auto projectTree = *it;
|
||||
if ( !projectTree->isVisible() ) continue;
|
||||
std::vector<caf::PdmUiItem*> uiItems;
|
||||
projectTree->selectedUiItems( uiItems );
|
||||
|
||||
if ( !uiItems.empty() )
|
||||
{
|
||||
std::vector<caf::PdmUiItem*> uiItems;
|
||||
tree->selectedUiItems( uiItems );
|
||||
|
||||
std::vector<const caf::PdmUiItem*> constSelectedItems;
|
||||
for ( auto item : uiItems )
|
||||
{
|
||||
constSelectedItems.push_back( item );
|
||||
}
|
||||
|
||||
tree->selectItems( constSelectedItems );
|
||||
auto firstSelectedObject = dynamic_cast<caf::PdmObjectHandle*>( uiItems.front() );
|
||||
updateUiFieldsFromActiveResult( firstSelectedObject );
|
||||
m_pdmUiPropertyView->showProperties( firstSelectedObject );
|
||||
m_seismicHistogramPanel->showHistogram( firstSelectedObject );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1517,9 +1517,7 @@ void RiuMainWindow::selectedObjectsChanged()
|
||||
}
|
||||
|
||||
updateUiFieldsFromActiveResult( firstSelectedObject );
|
||||
|
||||
m_pdmUiPropertyView->showProperties( firstSelectedObject );
|
||||
|
||||
m_seismicHistogramPanel->showHistogram( firstSelectedObject );
|
||||
|
||||
if ( uiItems.size() == 1 && m_allowActiveViewChangeFromSelection )
|
||||
|
||||
@@ -236,22 +236,20 @@ void RiuPlotMainWindow::initializeGuiNewProjectLoaded()
|
||||
|
||||
refreshToolbars();
|
||||
|
||||
// Find the project tree and reselect items to trigger the selectionChanged signal. This will make sure that the property view is
|
||||
// updated based on the selection in the main project tree.
|
||||
if ( auto dockWidget = RiuDockWidgetTools::findDockWidget( dockManager(), RiuDockWidgetTools::plotMainWindowPlotsTreeName() ) )
|
||||
// Sync selections with property views.
|
||||
// Go backwards as the most "important" tree view is first in the list
|
||||
// and we want that to use the property editor in case multiple tree views are visible
|
||||
for ( int i = (int)m_projectTreeViews.size() - 1; i >= 0; i-- )
|
||||
{
|
||||
if ( auto tree = dynamic_cast<caf::PdmUiTreeView*>( dockWidget->widget() ) )
|
||||
auto projectTree = projectTreeView( i );
|
||||
if ( !projectTree->isVisible() ) continue;
|
||||
|
||||
std::vector<caf::PdmUiItem*> uiItems;
|
||||
projectTree->selectedUiItems( uiItems );
|
||||
if ( !uiItems.empty() )
|
||||
{
|
||||
std::vector<caf::PdmUiItem*> uiItems;
|
||||
tree->selectedUiItems( uiItems );
|
||||
|
||||
std::vector<const caf::PdmUiItem*> constSelectedItems;
|
||||
for ( auto item : uiItems )
|
||||
{
|
||||
constSelectedItems.push_back( item );
|
||||
}
|
||||
|
||||
tree->selectItems( constSelectedItems );
|
||||
auto firstSelectedObject = dynamic_cast<caf::PdmObjectHandle*>( uiItems.front() );
|
||||
if ( i < (int)m_propertyViews.size() ) m_propertyViews[i]->showProperties( firstSelectedObject );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user