Salome HOME
gestion des liste et bugs
[tools/eficas.git] / InterfaceQT4 / gereListe.py
index 640dc9075eece8c941d39871ffbabb74ad3731bf..f08adac3b21b98ee0d86001a12781016aed31d9a 100644 (file)
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 # Modules Python
-import string,types,os
+
+from __future__ import absolute_import
+try :
+   from builtins import str
+   from builtins import range
+   from builtins import object
+except : pass
+
+import types,os
 import traceback
 
-from determine import monEnvQT5
-if monEnvQT5:
-   from PyQt5.QtWidgets import QLineEdit, QLabel
-   from PyQt5.QtCore    import QEvent, Qt
-   from PyQt5.QtGui     import QIcon, QPalette
-else :
-   from PyQt4.QtGui import *
-   from PyQt4.QtCore import *
+
+import six
+from six.moves import range
+from PyQt5.QtWidgets import QLineEdit, QLabel, QFileDialog
+from PyQt5.QtCore    import QEvent, Qt
+from PyQt5.QtGui     import QIcon, QPalette
 
 from Extensions.i18n import tr
-from monViewTexte   import ViewText
+from InterfaceQT4.monViewTexte   import ViewText
 
 
 # ---------------------- #
@@ -42,23 +48,31 @@ class LECustom(QLineEdit):
         Constructor
         """
         QLineEdit.__init__(self,parent)
+        
         self.parentQt=parentQt
         self.num=i
         self.dansUnTuple=False
+        self.numDsLaListe=-1
 
  def focusInEvent(self,event):
      #print "dans focusInEvent de LECustom"
      self.parentQt.LineEditEnCours=self
      self.parentQt.NumLineEditEnCours=self.num
+     self.parentQt.textSelected=self.text()
      self.setStyleSheet("border: 2px solid gray")
      QLineEdit.focusInEvent(self,event)
 
  def focusOutEvent(self,event):
-     #print "dans focusOutEvent de LECustom"
      self.setStyleSheet("border: 0px")
      if self.dansUnTuple    : self.setStyleSheet("background:rgb(235,235,235); border: 0px;")
      elif self.num % 2 == 1 : self.setStyleSheet("background:rgb(210,210,210)")
      else                   : self.setStyleSheet("background:rgb(235,235,235)")
+       
+    
+     if isinstance(self,LECustomTuple)  and  not self.tupleCustomParent.inFocusOutEvent:
+         self.tupleCustomParent.inFocusOutEvent=True
+         self.tupleCustomParent.valueChange()
+         self.tupleCustomParent.inFocusOutEvent=False
      QLineEdit.focusOutEvent(self,event)
 
  def clean(self):
@@ -70,6 +84,8 @@ class LECustom(QLineEdit):
  def setValeur(self,valeur):
      self.setText(valeur)
 
+
+
 # --------------------------- #
 class LECustomTuple(LECustom):
 # --------------------------- #
@@ -77,6 +93,7 @@ class LECustomTuple(LECustom):
    #  index sera mis a jour par TupleCustom
    parentQt=parent.parent().parent().parent()
    LECustom. __init__(self,parent,parentQt,0)
+   #print (dir(self))
 
 # ---------------------------- #
 class MonLabelListeClic(QLabel):
@@ -95,12 +112,11 @@ class MonLabelListeClic(QLabel):
 
 
 # ------------- #
-class GereListe:
+class GereListe(object):
 # ------------- #
 
    def __init__(self):
-       if monEnvQT5 :self.connecterSignaux()
-       else : self.connecterSignauxQT4()
+       self.connecterSignaux()
 
    def connecterSignauxQT4(self):
        if hasattr(self,'RBHaut'):
@@ -129,7 +145,6 @@ class GereListe:
           self.LEFiltre.returnPressed.connect(self.LEFiltreReturnPressed)
 
    def filtreListe(self):
-       print self.alpha
        l=[]
        if self.filtre != "" :
           for i in self.listeAAfficher :
@@ -146,7 +161,7 @@ class GereListe:
        self.prepareListeResultatFiltre()
 
    def alphaPushed(self):
-       print "alphaPushed" ,self.alpha
+       #print "alphaPushed" ,self.alpha
        if self.alpha == 1 : return
        self.alpha=1
        self.prepareListeResultat()
@@ -190,6 +205,7 @@ class GereListe:
 
    def moinsPushed(self):
        # on supprime le dernier
+       if self.NumLineEditEnCours == 0 : return
        if self.NumLineEditEnCours==self.indexDernierLabel : 
           nomLineEdit=self.nomLine+str(self.indexDernierLabel)
           courant=getattr(self,nomLineEdit)
@@ -252,17 +268,18 @@ class GereListe:
 
 
    def selectInFile(self):
-       init=QString( self.editor.CONFIGURATION.savedir)
+       init=str( self.editor.CONFIGURATION.savedir)
        fn = QFileDialog.getOpenFileName(self.node.appliEficas,
                                          tr("Fichier de donnees"),
                                          init,
                                          tr('Tous les  Fichiers (*)',))
+       fn=fn[0]
        if fn == None : return
        if fn == "" : return
-       ulfile = os.path.abspath(unicode(fn))
+       ulfile = os.path.abspath(six.text_type(fn))
        self.editor.CONFIGURATION.savedir=os.path.split(ulfile)[0]
 
-       from monSelectVal import MonSelectVal
+       from .monSelectVal import MonSelectVal
        MonSelectVal(file=fn,parent=self).show()
 
    def noircirResultatFiltre(self):
@@ -278,11 +295,12 @@ class GereListe:
 
   
 # ----------- #
-class GerePlie:
+class GerePlie(object):
 # ----------- #
 
    def gereIconePlier(self):
       if not(hasattr(self,'BFermeListe')) : return
+      self.editor.listeDesListesOuvertes.add(self.node.item)
       repIcon=self.node.editor.appliEficas.repIcon
       if not (self.editor.afficheListesPliees):
          fichier=os.path.join(repIcon, 'empty.png')
@@ -292,8 +310,7 @@ class GerePlie:
       fichier=os.path.join(repIcon, 'minusnode.png')
       icon = QIcon(fichier)
       self.BFermeListe.setIcon(icon)
-      if monEnvQT5 : self.BFermeListe.clicked.connect( self.selectWidgetPlie)
-      else : self.connect(self.BFermeListe,SIGNAL("clicked()"), self.selectWidgetPlie)
+      self.BFermeListe.clicked.connect( self.selectWidgetPlie)
 
    def selectWidgetPlie(self):
       self.editor.listeDesListesOuvertes.remove(self.node.item)