From: André Ribes Date: Wed, 23 Feb 2011 13:49:20 +0000 (+0100) Subject: Gestion de la sélection dans l'arbre d'étude X-Git-Tag: V6_4_0rc3~82 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=edcc572c32e34f3e90d7de1da03dbf911412af42;p=modules%2Fadao.git Gestion de la sélection dans l'arbre d'étude --- diff --git a/src/daSalome/daGUI/daEficasWrapper/adaoEficasWrapper.py b/src/daSalome/daGUI/daEficasWrapper/adaoEficasWrapper.py index 98ac5a9..b64544c 100644 --- a/src/daSalome/daGUI/daEficasWrapper/adaoEficasWrapper.py +++ b/src/daSalome/daGUI/daEficasWrapper/adaoEficasWrapper.py @@ -65,7 +65,10 @@ class AdaoEficasWrapper(eficasSalome.MyEficas): def tabChanged(self, index): debug("tabChanged " + str(index)) - self.notifyObserver(EficasEvent.EVENT_TYPES.TABCHANGED, callbackId=self.viewmanager.dict_editors[index]) + # This signal is also emit when a new case is created/added + # On regarde que le dictionnaire contient l'index + if index in self.viewmanager.dict_editors.keys(): + self.notifyObserver(EficasEvent.EVENT_TYPES.TABCHANGED, callbackId=self.viewmanager.dict_editors[index]) def addJdcInSalome( self, jdcPath ): # On gere nous meme l'etude @@ -147,18 +150,13 @@ class AdaoEficasWrapper(eficasSalome.MyEficas): def getOpenFileName(self): return str(self.__file_open_name) - def selectCase(self, callbackId): + def selectCase(self, editor): rtn = False - for editor, myCallbackId in self.__myCallbackId.iteritems(): - if myCallbackId[0] == callbackId[0]: - if myCallbackId[1].GetID() == callbackId[1].GetID(): - try: - for indexEditor in self.viewmanager.dict_editors.keys(): - if editor is self.viewmanager.dict_editors[indexEditor]: - self.viewmanager.myQtab.setCurrentIndex(indexEditor) - rtn = True - except: - pass + for indexEditor in self.viewmanager.dict_editors.keys(): + if editor is self.viewmanager.dict_editors[indexEditor]: + self.viewmanager.myQtab.setCurrentIndex(indexEditor) + rtn = True + break return rtn def fileClose(self): diff --git a/src/daSalome/daGUI/daGuiImpl/adaoGuiManager.py b/src/daSalome/daGUI/daGuiImpl/adaoGuiManager.py index eafa644..4fffb9c 100644 --- a/src/daSalome/daGUI/daGuiImpl/adaoGuiManager.py +++ b/src/daSalome/daGUI/daGuiImpl/adaoGuiManager.py @@ -27,6 +27,7 @@ __author__ = "aribes/gboulant" import traceback from PyQt4.QtCore import QObject +from PyQt4.QtCore import * # Import from PyQT from PyQt4 import QtGui,QtCore import SalomePyQt sgPyQt = SalomePyQt.SalomePyQt() @@ -83,7 +84,6 @@ class AdaoCaseManager(EficasObserver): # Value == objet AdaoCase() self.cases = {} - # Création des deux managers self.salome_manager = AdaoGuiUiComponentBuilder() self.eficas_manager = AdaoEficasWrapper(parent=SalomePyQt.SalomePyQt().getDesktop()) @@ -108,11 +108,23 @@ class AdaoCaseManager(EficasObserver): # Cela simplifier grandement le code sgPyQt.setViewClosable(self.eficas_viewId, False) + # On s'abonne au gestionnaire de selection + self.selection_manager = sgPyQt.getSelection() + QtCore.QObject.connect(self.selection_manager, QtCore.SIGNAL('currentSelectionChanged()'), self.currentSelectionChanged) + def activate(self): - self.__dlgEficasWrapper.setEnabled(True) + self.eficas_manager.setEnabled(True) def deactivate(self): - self.__dlgEficasWrapper.setEnabled(False) + self.eficas_manager.setEnabled(False) + + def currentSelectionChanged(self): + adaoLogger.debug("currentSelectionChanged") + salomeStudyItem = adaoGuiHelper.getSelectedItem() + for case_name, adao_case in self.cases.iteritems(): + if adao_case.salome_study_item.GetID() == salomeStudyItem.GetID(): + self.eficas_manager.selectCase(adao_case.eficas_editor) + break def _processEficasTabChanged(self, eficasWrapper, eficasEvent): """