Simplify RiuPlotMainWindowTools (#9211)

* Janitor: Add and use onObjectAppended()
* Janitor: Simplify API
This commit is contained in:
Magne Sjaastad authored and GitHub committed 2022-08-18 12:37:51 +02:00
1 parent febbdcf7a0
commit a1e7b64d92
34 files changed
+66 -93

No files matched your search

@@ -47,25 +47,27 @@ void RiuPlotMainWindowTools::setActiveViewer( QWidget* subWindow )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindowTools::setExpanded( const caf::PdmUiItem* uiItem, bool expanded /*= true*/ )
void RiuPlotMainWindowTools::setExpanded( const caf::PdmUiItem* uiItem )
{
if ( RiaGuiApplication::isRunning() )
{
RiuPlotMainWindow* mpw = RiaGuiApplication::instance()->mainPlotWindow();
if ( mpw ) mpw->setExpanded( uiItem, expanded );
bool expand = true;
if ( mpw ) mpw->setExpanded( uiItem, expand );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindowTools::selectAsCurrentItem( const caf::PdmObject* object, bool allowActiveViewChange /*= true*/ )
void RiuPlotMainWindowTools::selectAsCurrentItem( const caf::PdmObject* object )
{
if ( RiaGuiApplication::isRunning() )
{
RiuPlotMainWindow* mpw = RiaGuiApplication::instance()->mainPlotWindow();
bool allowActiveViewChange = true;
if ( mpw ) mpw->selectAsCurrentItem( object, allowActiveViewChange );
}
}
@@ -73,12 +75,13 @@ void RiuPlotMainWindowTools::selectAsCurrentItem( const caf::PdmObject* object,
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindowTools::toggleItemInSelection( const caf::PdmObject* object, bool allowActiveViewChange /*= true*/ )
void RiuPlotMainWindowTools::toggleItemInSelection( const caf::PdmObject* object )
{
if ( RiaGuiApplication::isRunning() )
{
RiuPlotMainWindow* mpw = RiaGuiApplication::instance()->mainPlotWindow();
bool allowActiveViewChange = true;
if ( mpw ) mpw->toggleItemInSelection( object, allowActiveViewChange );
}
}
@@ -114,3 +117,16 @@ void RiuPlotMainWindowTools::refreshToolbars()
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindowTools::onObjectAppended( const caf::PdmObject* objectToSelect, const caf::PdmObject* objectToExpand )
{
if ( objectToExpand == nullptr ) objectToExpand = objectToSelect;
if ( objectToExpand ) RiuPlotMainWindowTools::setExpanded( objectToExpand );
if ( objectToSelect ) RiuPlotMainWindowTools::selectAsCurrentItem( objectToSelect );
RiuPlotMainWindowTools::refreshToolbars();
}