From edcc572c32e34f3e90d7de1da03dbf911412af42 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20Ribes?= Date: Wed, 23 Feb 2011 14:49:20 +0100 Subject: [PATCH] =?utf8?q?Gestion=20de=20la=20s=C3=A9lection=20dans=20l'ar?= =?utf8?q?bre=20d'=C3=A9tude?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../daEficasWrapper/adaoEficasWrapper.py | 22 +++++++++---------- .../daGUI/daGuiImpl/adaoGuiManager.py | 18 ++++++++++++--- 2 files changed, 25 insertions(+), 15 deletions(-) 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): """ -- 2.39.2