]> SALOME platform Git repositories - tools/eficas.git/blob - InterfaceQT4/monRechercheCatalogue.py
Salome HOME
ac115eb3d9a4d183fb9af2c0a79a9dc6abd8f1f8
[tools/eficas.git] / InterfaceQT4 / monRechercheCatalogue.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2013   EDF R&D
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
8 #
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20 # Modules Python
21 # Modules Eficas
22
23 from desRechercheCatalogue import Ui_desRechercheCatalogue
24 from determine import monEnvQT5
25 if monEnvQT5:
26     from PyQt5.QtWidgets import QDialog, QCompleter
27     from PyQt5.QtCore import Qt
28 else :
29     from PyQt4.QtGui  import *
30     from PyQt4.QtCore import *
31
32 from Extensions.i18n import tr
33
34 # Import des panels
35
36 class DRechercheCatalogue (Ui_desRechercheCatalogue ,QDialog):
37   """
38   Classe définissant le panel associé aux mots-clés qui demandent
39   à l'utilisateur de choisir une seule valeur parmi une liste de valeurs
40   discrètes
41   """
42   def __init__(self,parent,editor ):
43       QDialog.__init__(self,parent)
44       #self.setModal(True)
45       self.setupUi(self)
46       self.editor=editor
47       self.CBRecherche.setEditable(True)
48       if monEnvQT5 :
49          self.LERecherche.returnPressed.connect(self.rechercheLE)
50          self.CBRecherche.lineEdit().returnPressed.connect(self.rechercheCB)
51          self.CBRecherche.currentIndexChanged.connect(self.rechercheCB)
52       else :
53          self.connect(self.LERecherche,SIGNAL("returnPressed()"),self.rechercheLE)
54          self.connect(self.CBRecherche.lineEdit(),SIGNAL("returnPressed()"),self.rechercheCB)
55          self.connect(self.CBRecherche,SIGNAL("currentIndexChanged(int)"),self.rechercheCB)
56
57       self.initRecherche()
58
59   def initRecherche(self):
60       listeChoix=self.editor.readercata.dicoInverse.keys()
61       self.CBRecherche.addItem("")
62       for choix in listeChoix:
63           self.CBRecherche.addItem(choix)
64       monCompleteur=QCompleter(listeChoix,self)
65       monCompleteur.setCompletionMode(QCompleter.PopupCompletion)
66       self.CBRecherche.setCompleter(monCompleteur)
67
68
69   def rechercheCB(self):
70       motAChercher=self.CBRecherche.lineEdit().text()
71       self.recherche(motAChercher)
72
73   def rechercheLE(self):
74       motAChercher=self.LERecherche.text()
75       self.recherche(motAChercher)
76
77   def recherche(self,motAChercher):
78       if str(motAChercher)=="" or str(motAChercher) == None : return
79       if str(motAChercher) not in self.editor.readercata.dicoInverse.keys():return
80       try :
81       #if 1  :
82         genea= self.editor.readercata.dicoInverse[str(motAChercher)]
83         print genea
84         listeGenea=[]
85         for t in genea : listeGenea.append(t[0])
86         listeGenea.reverse()
87         texte=''
88         i=0
89         for mc in listeGenea :
90          ligne = i*'   '+str(mc) + ' / '+tr(str(mc))+'\n' 
91          i=i+1
92          texte += ligne
93         self.teGenea.setText(texte)
94         self.teDoc.setText(getattr(genea[0][1],self.editor.appliEficas.langue))
95         
96         
97       except :
98         pass
99