mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Simplify RiuPlotMainWindowTools (#9211)
* Janitor: Add and use onObjectAppended() * Janitor: Simplify API
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -31,9 +31,15 @@ class RiuPlotMainWindowTools
|
||||
public:
|
||||
static void showPlotMainWindow();
|
||||
static void setActiveViewer( QWidget* subWindow );
|
||||
static void setExpanded( const caf::PdmUiItem* uiItem, bool expanded = true );
|
||||
static void selectAsCurrentItem( const caf::PdmObject* object, bool allowActiveViewChange = true );
|
||||
static void toggleItemInSelection( const caf::PdmObject* object, bool allowActiveViewChange = true );
|
||||
static void setExpanded( const caf::PdmUiItem* uiItem );
|
||||
static void selectAsCurrentItem( const caf::PdmObject* object );
|
||||
static void selectOrToggleObject( const caf::PdmObject* object, bool toggle );
|
||||
static void refreshToolbars();
|
||||
|
||||
// Use this function to select (and expand) an object in the project tree and update tool bars. Use the second
|
||||
// parameter to expand a different object than the object to be selected.
|
||||
static void onObjectAppended( const caf::PdmObject* objectToSelect, const caf::PdmObject* objectToExpand = nullptr );
|
||||
|
||||
private:
|
||||
static void toggleItemInSelection( const caf::PdmObject* object );
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user