Rename SubWindowActivated blocking methods

to clarify their differences
This commit is contained in:
Jacob Støren 2019-10-30 10:34:39 +01:00
parent 32b5d7696d
commit 99fb39bd68
7 changed files with 37 additions and 34 deletions

View File

@ -671,9 +671,9 @@ void RicSummaryPlotFeatureImpl::createSummaryPlotsFromArgumentLine( const QStrin
// Needed to avoid unneccessary activation of sub windows (plots)
// which results in population of property editor, and missing deleteLater because we are outside any event
// loop when switching object. Results in stray widgets.
mpw->setBlockSubWindowProjectTreeSelection( true );
mpw->setBlockViewSelectionOnSubWindowActivated( true );
RiuPlotMainWindowTools::showPlotMainWindow();
mpw->setBlockSubWindowProjectTreeSelection( false );
mpw->setBlockViewSelectionOnSubWindowActivated( false );
RiuPlotMainWindowTools::setExpanded( lastPlotCreated );
RiuPlotMainWindowTools::selectAsCurrentItem( lastPlotCreated );

View File

@ -1230,7 +1230,7 @@ void RiuMainWindow::slotViewFromBelow()
//--------------------------------------------------------------------------------------------------
void RiuMainWindow::slotSubWindowActivated( QMdiSubWindow* subWindow )
{
if ( blockSubWindowActivation() ) return;
if ( isBlockingSubWindowActivatedSignal() ) return;
Rim3dView* previousActiveReservoirView = RiaApplication::instance()->activeReservoirView();
Rim3dView* activatedView = dynamic_cast<Rim3dView*>( findViewWindowFromSubWindow( subWindow ) );
@ -1238,9 +1238,9 @@ void RiuMainWindow::slotSubWindowActivated( QMdiSubWindow* subWindow )
if ( !activatedView ) return;
RiaApplication::instance()->setActiveReservoirView( activatedView );
if ( !blockSubWindowProjectTreeSelection() )
if ( !isBlockingViewSelectionOnSubWindowActivated() )
{
selectViewInProjectTree( previousActiveReservoirView, activatedView );
selectViewInProjectTreePreservingSubItemSelection( previousActiveReservoirView, activatedView );
}
slotRefreshViewActions();
@ -1251,7 +1251,8 @@ void RiuMainWindow::slotSubWindowActivated( QMdiSubWindow* subWindow )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainWindow::selectViewInProjectTree( const Rim3dView* previousActiveReservoirView, Rim3dView* activatedView )
void RiuMainWindow::selectViewInProjectTreePreservingSubItemSelection( const Rim3dView* previousActiveReservoirView,
Rim3dView* activatedView )
{
bool is3dViewCurrentlySelected = false;
if ( caf::SelectionManager::instance()->selectedItem() )
@ -1442,9 +1443,9 @@ void RiuMainWindow::selectedObjectsChanged()
// Set focus in MDI area to this window if it exists
if ( selectedReservoirView->viewer() )
{
setBlockSubWindowProjectTreeSelection( true );
setBlockViewSelectionOnSubWindowActivated( true );
setActiveViewer( selectedReservoirView->viewer()->layoutWidget() );
setBlockSubWindowProjectTreeSelection( false );
setBlockViewSelectionOnSubWindowActivated( false );
isActiveViewChanged = true;
}
@ -2001,14 +2002,14 @@ void RiuMainWindow::tileSubWindows()
// Based on workaround described here
// https://forum.qt.io/topic/50053/qmdiarea-tilesubwindows-always-places-widgets-in-activationhistoryorder-in-subwindowview-mode
bool prevActivationBlock = blockSubWindowActivation();
bool prevActivationBlock = isBlockingSubWindowActivatedSignal();
QMdiSubWindow* a = m_mdiArea->activeSubWindow();
// Force activation order so they end up in the order of the loop.
m_mdiArea->setActivationOrder( QMdiArea::ActivationHistoryOrder );
setBlockSubWindowActivation( true );
setBlockSubWindowActivatedSignal( true );
// Activate in reverse order
for ( auto it = windowList.rbegin(); it != windowList.rend(); ++it )
@ -2020,7 +2021,7 @@ void RiuMainWindow::tileSubWindows()
// Set back the original activation order to avoid messing with the standard ordering
m_mdiArea->setActivationOrder( currentActivationOrder );
m_mdiArea->setActiveSubWindow( a );
setBlockSubWindowActivation( prevActivationBlock );
setBlockSubWindowActivatedSignal( prevActivationBlock );
storeSubWindowTiling( true );
}
@ -2039,7 +2040,7 @@ void RiuMainWindow::storeSubWindowTiling( bool tiled )
//--------------------------------------------------------------------------------------------------
void RiuMainWindow::clearWindowTiling()
{
setBlockSubWindowActivation( true );
setBlockSubWindowActivatedSignal( true );
QMdiArea::WindowOrder currentActivationOrder = m_mdiArea->activationOrder();
for ( QMdiSubWindow* subWindow : m_mdiArea->subWindowList( currentActivationOrder ) )
@ -2048,7 +2049,7 @@ void RiuMainWindow::clearWindowTiling()
subWindow->showNormal();
}
storeSubWindowTiling( false );
setBlockSubWindowActivation( false );
setBlockSubWindowActivatedSignal( false );
}
//--------------------------------------------------------------------------------------------------

View File

@ -233,11 +233,13 @@ private slots:
void slotBuildWindowActions();
void slotSubWindowActivated( QMdiSubWindow* subWindow );
void selectViewInProjectTree( const Rim3dView* previousActiveReservoirView, Rim3dView* activatedView );
void selectedObjectsChanged();
void customMenuRequested( const QPoint& pos );
private:
void selectViewInProjectTreePreservingSubItemSelection( const Rim3dView* previousActiveReservoirView,
Rim3dView* activatedView );
// Pdm System :
public:
void setPdmRoot( caf::PdmObject* pdmRoot );

View File

@ -246,7 +246,7 @@ void RiuMainWindowBase::enableShowFirstVisibleMdiWindowMaximized( bool enable )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainWindowBase::setBlockSubWindowActivation( bool block )
void RiuMainWindowBase::setBlockSubWindowActivatedSignal( bool block )
{
m_blockSubWindowActivation = block;
}
@ -254,7 +254,7 @@ void RiuMainWindowBase::setBlockSubWindowActivation( bool block )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuMainWindowBase::blockSubWindowActivation() const
bool RiuMainWindowBase::isBlockingSubWindowActivatedSignal() const
{
return m_blockSubWindowActivation;
}
@ -262,7 +262,7 @@ bool RiuMainWindowBase::blockSubWindowActivation() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainWindowBase::setBlockSubWindowProjectTreeSelection( bool block )
void RiuMainWindowBase::setBlockViewSelectionOnSubWindowActivated( bool block )
{
m_blockSubWindowProjectTreeSelection = block;
}
@ -270,7 +270,7 @@ void RiuMainWindowBase::setBlockSubWindowProjectTreeSelection( bool block )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuMainWindowBase::blockSubWindowProjectTreeSelection() const
bool RiuMainWindowBase::isBlockingViewSelectionOnSubWindowActivated() const
{
return m_blockSubWindowProjectTreeSelection;
}

View File

@ -76,11 +76,11 @@ public:
virtual void clearWindowTiling() = 0;
virtual bool subWindowsAreTiled() const = 0;
void setBlockSubWindowActivation( bool block );
bool blockSubWindowActivation() const;
void setBlockSubWindowActivatedSignal( bool block );
bool isBlockingSubWindowActivatedSignal() const;
void setBlockSubWindowProjectTreeSelection( bool block );
bool blockSubWindowProjectTreeSelection() const;
void setBlockViewSelectionOnSubWindowActivated( bool block );
bool isBlockingViewSelectionOnSubWindowActivated() const;
protected:
void removeViewerFromMdiArea( QMdiArea* mdiArea, QWidget* viewer );

View File

@ -58,7 +58,7 @@ void RiuMdiArea::resizeEvent( QResizeEvent* resizeEvent )
}
RiuMainWindowBase* mainWindow = dynamic_cast<RiuMainWindowBase*>( window() );
mainWindow->setBlockSubWindowActivation( true );
mainWindow->setBlockSubWindowActivatedSignal( true );
// Workaround for Qt bug #51761: https://bugreports.qt.io/browse/QTBUG-51761
// Set the first window to be the active window then perform resize event and set back.
@ -70,7 +70,7 @@ void RiuMdiArea::resizeEvent( QResizeEvent* resizeEvent )
setActiveSubWindow( a );
mainWindow->setBlockSubWindowActivation( false );
mainWindow->setBlockSubWindowActivatedSignal( false );
for ( auto subWindow : subWindowList() )
{

View File

@ -684,14 +684,14 @@ void RiuPlotMainWindow::setPdmRoot( caf::PdmObject* pdmRoot )
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindow::slotSubWindowActivated( QMdiSubWindow* subWindow )
{
if ( blockSubWindowActivation() ) return;
if ( isBlockingSubWindowActivatedSignal() ) return;
RimViewWindow* activatedView = findViewWindowFromSubWindow( subWindow );
if ( !activatedView ) return;
m_activePlotViewWindow = activatedView;
if ( !blockSubWindowProjectTreeSelection() )
if ( !isBlockingViewSelectionOnSubWindowActivated() )
{
std::vector<caf::PdmUiItem*> currentSelection;
m_projectTreeView->selectedUiItems( currentSelection );
@ -809,9 +809,9 @@ void RiuPlotMainWindow::selectedObjectsChanged()
{
if ( selectedWindow->viewWidget() )
{
setBlockSubWindowProjectTreeSelection( true );
setBlockViewSelectionOnSubWindowActivated( true );
setActiveViewer( selectedWindow->viewWidget() );
setBlockSubWindowProjectTreeSelection( false );
setBlockViewSelectionOnSubWindowActivated( false );
}
m_activePlotViewWindow = selectedWindow;
@ -913,12 +913,12 @@ void RiuPlotMainWindow::tileSubWindows()
// Based on workaround described here
// https://forum.qt.io/topic/50053/qmdiarea-tilesubwindows-always-places-widgets-in-activationhistoryorder-in-subwindowview-mode
bool prevActivationBlock = blockSubWindowActivation();
bool prevActivationBlock = isBlockingSubWindowActivatedSignal();
// Force activation order so they end up in the order of the loop.
m_mdiArea->setActivationOrder( QMdiArea::ActivationHistoryOrder );
QMdiSubWindow* a = m_mdiArea->activeSubWindow();
setBlockSubWindowActivation( true );
setBlockSubWindowActivatedSignal( true );
// Activate in reverse order
for ( auto it = windowList.rbegin(); it != windowList.rend(); ++it )
{
@ -929,7 +929,7 @@ void RiuPlotMainWindow::tileSubWindows()
// Set back the original activation order to avoid messing with the standard ordering
m_mdiArea->setActivationOrder( currentActivationOrder );
m_mdiArea->setActiveSubWindow( a );
setBlockSubWindowActivation( prevActivationBlock );
setBlockSubWindowActivatedSignal( prevActivationBlock );
storeSubWindowTiling( true );
}
@ -948,7 +948,7 @@ void RiuPlotMainWindow::storeSubWindowTiling( bool tiled )
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindow::clearWindowTiling()
{
setBlockSubWindowActivation( true );
setBlockSubWindowActivatedSignal( true );
QMdiArea::WindowOrder currentActivationOrder = m_mdiArea->activationOrder();
for ( QMdiSubWindow* subWindow : m_mdiArea->subWindowList( currentActivationOrder ) )
@ -957,7 +957,7 @@ void RiuPlotMainWindow::clearWindowTiling()
subWindow->showNormal();
}
storeSubWindowTiling( false );
setBlockSubWindowActivation( false );
setBlockSubWindowActivatedSignal( false );
}
//--------------------------------------------------------------------------------------------------