From f42235705a62c522f6870ed90cb3b7d50a5b2e3e Mon Sep 17 00:00:00 2001 From: vsr Date: Thu, 3 Dec 2015 17:24:09 +0300 Subject: [PATCH] Properly update visibility state of data objects after Object browser destroyed and re-created --- src/LightApp/LightApp_Application.cxx | 3 +++ src/LightApp/LightApp_Module.cxx | 18 +++++++++++++----- src/LightApp/LightApp_Module.h | 1 + 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index f50576ea8..5970789d5 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -520,6 +520,9 @@ bool LightApp_Application::activateModule( const QString& modName ) objectBrowser()->setRoot( activeStudy()->root() ); updateObjectBrowser( true ); } + + if ( activeModule() ) activeModule()->updateModuleVisibilityState(); + return true; } diff --git a/src/LightApp/LightApp_Module.cxx b/src/LightApp/LightApp_Module.cxx index 6a8d0e45d..02845df16 100644 --- a/src/LightApp/LightApp_Module.cxx +++ b/src/LightApp/LightApp_Module.cxx @@ -249,11 +249,6 @@ bool LightApp_Module::activateModule( SUIT_Study* study ) treeModel->setAppropriate( EntryCol, Qtx::Toggled ); }*/ - if ( myIsFirstActivate ) { - updateModuleVisibilityState(); - myIsFirstActivate = false; - } - return res; } @@ -800,9 +795,17 @@ void LightApp_Module::updateModuleVisibilityState() SUIT_DataBrowser* ob = app->objectBrowser(); if ( !ob || !ob->model() ) return; + if ( !myIsFirstActivate ) + return; + + myIsFirstActivate = false; + // connect to click on item connect( ob->model(), SIGNAL( clicked( SUIT_DataObject*, int ) ), this, SLOT( onObjectClicked( SUIT_DataObject*, int ) ), Qt::UniqueConnection ); + // connect to click on item + connect( ob, SIGNAL( destroyed( QObject* ) ), + this, SLOT( onOBDestroyed() ), Qt::UniqueConnection ); SUIT_DataObject* rootObj = ob->root(); if ( !rootObj ) return; @@ -845,3 +848,8 @@ void LightApp_Module::onObjectClicked( SUIT_DataObject* theObject, int theColumn if ( id != -1 ) startOperation( id ); } + +void LightApp_Module::onOBDestroyed() +{ + myIsFirstActivate = true; +} diff --git a/src/LightApp/LightApp_Module.h b/src/LightApp/LightApp_Module.h index ed716f195..babb9c698 100644 --- a/src/LightApp/LightApp_Module.h +++ b/src/LightApp/LightApp_Module.h @@ -113,6 +113,7 @@ public slots: virtual bool deactivateModule( SUIT_Study* ); virtual void studyClosed( SUIT_Study* ); virtual void onObjectClicked( SUIT_DataObject*, int ); + void onOBDestroyed(); void MenuItem(); -- 2.39.2