Salome HOME
1645b1d09a9800293b6165860c1e909cd3f2b8c3
[tools/eficas.git] / InterfaceQT4 / gereListe.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 import string,types,os
22 import traceback
23
24 from PyQt4 import *
25 from PyQt4.QtGui import *
26 from PyQt4.QtCore import *
27 from Extensions.i18n import tr
28 from monViewTexte   import ViewText
29
30 # ---------------------- #
31 class LECustom(QLineEdit):
32 # ---------------------- #
33  def __init__(self,parent,parentQt,i):
34         """
35         Constructor
36         """
37         QMainWindow.__init__(self,parent)
38         self.parentQt=parentQt
39         self.num=i
40
41  def focusInEvent(self,event):
42      self.parentQt.LineEditEnCours=self
43      self.parentQt.NumLineEditEnCours=self.num
44
45
46
47
48 # ------------- #
49 class GereListe:
50 # ------------- #
51
52    def __init__(self):
53        print "GereListe"
54        self.connecterSignaux()
55
56    def connecterSignaux(self):
57        self.connect(self.RBHaut,SIGNAL("clicked()"),self.hautPushed)
58        self.connect(self.RBBas,SIGNAL("clicked()"),self.basPushed)
59        self.connect(self.RBMoins,SIGNAL("clicked()"),self.moinsPushed)
60        self.connect(self.RBPlus,SIGNAL("clicked()"),self.plusPushed)
61        self.connect(self.RBVoisListe,SIGNAL("clicked()"),self.voisListePushed)
62        self.connect(self.RBSalome,SIGNAL("clicked()"),self.salomePushed)
63        self.connect(self.RBSalomeVue,SIGNAL("clicked()"),self.salomeVuePushed)
64
65    def hautPushed(self):
66        if self.NumLineEditEnCours == 1 : return
67        else : numEchange=self.NumLineEditEnCours-1
68        self.echange(self.NumLineEditEnCours,numEchange)
69        self.scrollArea.ensureWidgetVisible(self.LineEditEnCours)
70
71
72    def basPushed(self):
73        if self.NumLineEditEnCours == self.indexDernierLabel : return
74        else : numEchange=self.NumLineEditEnCours+1
75        self.echange(self.NumLineEditEnCours,numEchange)
76        self.scrollArea.ensureWidgetVisible(self.LineEditEnCours)
77
78    def echange(self,num1,num2):
79        # on donne le focus au a celui ou on a bouge
80        # par convention le 2
81        nomLineEdit="lineEditVal"+str(num1)
82        #print nomLineEdit
83        courant=getattr(self,nomLineEdit)
84        valeurAGarder=courant.text()
85        nomLineEdit2="lineEditVal"+str(num2)
86        #print nomLineEdit2
87        courant2=getattr(self,nomLineEdit2)
88        courant.setText(courant2.text())
89        courant2.setText(valeurAGarder)
90        self.changeValeur(changeDePlace=False)
91        self.NumLineEditEnCours=num2
92        self.LineEditEnCours=courant2
93
94    def moinsPushed(self):
95        if self.indexDernierLabel < self.monSimpDef.min:
96           self.editor.affiche_infos('nb min de valeurs : '+str(self.monSimpDef.min)+' atteint')
97           return
98        # on supprime le dernier
99        if self.NumLineEditEnCours==self.indexDernierLabel : 
100           self.setText("")
101        else :
102          for i in range (self.NumLineEditEnCours, self.indexDernierLabel):
103              aRemonter=i+1
104              nomLineEdit="lineEditVal"+str(aRemonter)
105              courant=getattr(self,nomLineEdit)
106              valeurARemonter=courant.text()
107              nomLineEdit="lineEditVal"+str(i)
108              courant=getattr(self,nomLineEdit)
109              courant.setText(valeurARemonter)
110          nomLineEdit="lineEditVal"+str(self.indexDernierLabel)
111          courant=getattr(self,nomLineEdit)
112          courant.setText("")
113        self.changeValeur(changeDePlace=False)
114
115    def plusPushed(self):
116        if self.indexDernierLabel == self.monSimpDef.max:
117           self.editor.affiche_infos('nb max de valeurs : '+str(self.monSimpDef.max)+' atteint')
118           return
119        self.ajoutLineEdit()
120        if self.NumLineEditEnCours==self.indexDernierLabel : return
121        nomLineEdit="lineEditVal"+str(self.NumLineEditEnCours+1)
122        courant=getattr(self,nomLineEdit)
123        valeurADescendre=courant.text()
124        courant.setText("")
125        for i in range (self.NumLineEditEnCours+1, self.indexDernierLabel):
126              aDescendre=i+1
127              nomLineEdit="lineEditVal"+str(aDescendre)
128              courant=getattr(self,nomLineEdit)
129              valeurAGarder=courant.text()
130              courant.setText(valeurADescendre)
131              valeurADescendre=valeurAGarder
132        self.changeValeur(changeDePlace=False)
133        self.scrollArea.ensureWidgetVisible(self.LineEditEnCours)
134
135    def voisListePushed(self):
136        print "voisListePushed"
137        texteValeurs=""
138        for v in self.node.item.GetListeValeurs():
139           texteValeurs+=str(v)+", "
140        entete="Valeurs pour "+self.nom
141        f=ViewText(self,self.editor,entete,texteValeurs[0:-2])
142        f.show()
143
144    def salomePushed(self):
145        print "salomePushed"
146
147    def salomeVuePushed(self):
148        print "salomeVuePushed"
149