Salome HOME
legere difference ds VARIABLES_TO_BE...
[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 __future__ import absolute_import
24 try :
25    from builtins import str
26 except : pass
27
28 from desRechercheCatalogue import Ui_desRechercheCatalogue
29 from PyQt5.QtWidgets import QDialog, QCompleter
30 from PyQt5.QtCore import Qt
31
32 from Extensions.i18n import tr
33
34 # Import des panels
35
36 class DRechercheCatalogue (Ui_desRechercheCatalogue ,QDialog):
37   """
38   """
39   def __init__(self,parent,editor ):
40       QDialog.__init__(self,parent)
41       #self.setModal(True)
42       self.setupUi(self)
43       self.editor=editor
44       self.CBRecherche.setEditable(True)
45       self.CBRecherche.lineEdit().returnPressed.connect(self.rechercheCB)
46       self.CBRecherche.currentIndexChanged.connect(self.rechercheCB)
47       self.CBRecherche.currentTextChanged.connect(self.rechercheCB)
48
49       self.initRecherche()
50
51   def initRecherche(self):
52       listeChoix=list(self.editor.readercata.dicoInverse.keys())
53       self.CBRecherche.addItem("")
54       for choix in listeChoix:
55           self.CBRecherche.addItem(choix)
56       monCompleteur=QCompleter(listeChoix,self)
57       monCompleteur.setCompletionMode(QCompleter.PopupCompletion)
58       self.CBRecherche.setCompleter(monCompleteur)
59
60
61   def rechercheCB(self):
62       motAChercher=self.CBRecherche.lineEdit().text()
63       self.recherche(motAChercher)
64
65
66   def recherche(self,motAChercher):
67       if str(motAChercher)=="" or str(motAChercher) == None : return
68       if str(motAChercher) not in self.editor.readercata.dicoInverse:return
69       try :
70       #if 1  :
71         genea= self.editor.readercata.dicoInverse[str(motAChercher)]
72         listeGenea=[]
73         for t in genea : listeGenea.append(t[0])
74         listeGenea.reverse()
75         texte=''
76         i=0
77         for mc in listeGenea :
78          ligne = i*'   '+str(mc) + ' / '+tr(str(mc))+'\n' 
79          i=i+1
80          texte += ligne
81         self.teGenea.setText(texte)
82         self.teDoc.setText(getattr(genea[0][1],self.editor.appliEficas.langue))
83         
84         
85       except :
86         pass
87