1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2013 EDF R&D
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.
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.
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
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 import string,types,os
25 from PyQt4.QtGui import *
26 from PyQt4.QtCore import *
27 from Extensions.i18n import tr
28 from monViewTexte import ViewText
30 # ---------------------- #
31 class LECustom(QLineEdit):
32 # ---------------------- #
33 def __init__(self,parent,parentQt,i):
37 QMainWindow.__init__(self,parent)
38 self.parentQt=parentQt
41 def focusInEvent(self,event):
42 self.parentQt.LineEditEnCours=self
43 self.parentQt.NumLineEditEnCours=self.num
53 self.connecterSignaux()
55 def connecterSignaux(self):
56 self.connect(self.RBHaut,SIGNAL("clicked()"),self.hautPushed)
57 self.connect(self.RBBas,SIGNAL("clicked()"),self.basPushed)
58 self.connect(self.RBMoins,SIGNAL("clicked()"),self.moinsPushed)
59 self.connect(self.RBPlus,SIGNAL("clicked()"),self.plusPushed)
60 self.connect(self.RBVoisListe,SIGNAL("clicked()"),self.voisListePushed)
61 self.connect(self.RBSalome,SIGNAL("clicked()"),self.salomePushed)
62 self.connect(self.RBSalomeVue,SIGNAL("clicked()"),self.salomeVuePushed)
65 if self.NumLineEditEnCours == 1 : return
66 else : numEchange=self.NumLineEditEnCours-1
67 self.echange(self.NumLineEditEnCours,numEchange)
68 self.scrollArea.ensureWidgetVisible(self.LineEditEnCours)
72 if self.NumLineEditEnCours == self.indexDernierLabel : return
73 else : numEchange=self.NumLineEditEnCours+1
74 self.echange(self.NumLineEditEnCours,numEchange)
75 self.scrollArea.ensureWidgetVisible(self.LineEditEnCours)
77 def echange(self,num1,num2):
78 # on donne le focus au a celui ou on a bouge
80 nomLineEdit="lineEditVal"+str(num1)
82 courant=getattr(self,nomLineEdit)
83 valeurAGarder=courant.text()
84 nomLineEdit2="lineEditVal"+str(num2)
86 courant2=getattr(self,nomLineEdit2)
87 courant.setText(courant2.text())
88 courant2.setText(valeurAGarder)
89 self.changeValeur(changeDePlace=False)
90 self.NumLineEditEnCours=num2
91 self.LineEditEnCours=courant2
93 def moinsPushed(self):
94 if self.indexDernierLabel < self.monSimpDef.min:
95 self.editor.affiche_infos('nb min de valeurs : '+str(self.monSimpDef.min)+' atteint')
97 # on supprime le dernier
98 if self.NumLineEditEnCours==self.indexDernierLabel :
101 for i in range (self.NumLineEditEnCours, self.indexDernierLabel):
103 nomLineEdit="lineEditVal"+str(aRemonter)
104 courant=getattr(self,nomLineEdit)
105 valeurARemonter=courant.text()
106 nomLineEdit="lineEditVal"+str(i)
107 courant=getattr(self,nomLineEdit)
108 courant.setText(valeurARemonter)
109 nomLineEdit="lineEditVal"+str(self.indexDernierLabel)
110 courant=getattr(self,nomLineEdit)
112 self.changeValeur(changeDePlace=False)
114 def plusPushed(self):
115 if self.indexDernierLabel == self.monSimpDef.max:
116 self.editor.affiche_infos('nb max de valeurs : '+str(self.monSimpDef.max)+' atteint')
119 if self.NumLineEditEnCours==self.indexDernierLabel : return
120 nomLineEdit="lineEditVal"+str(self.NumLineEditEnCours+1)
121 courant=getattr(self,nomLineEdit)
122 valeurADescendre=courant.text()
124 for i in range (self.NumLineEditEnCours+1, self.indexDernierLabel):
126 nomLineEdit="lineEditVal"+str(aDescendre)
127 courant=getattr(self,nomLineEdit)
128 valeurAGarder=courant.text()
129 courant.setText(valeurADescendre)
130 valeurADescendre=valeurAGarder
131 self.changeValeur(changeDePlace=False)
132 self.scrollArea.ensureWidgetVisible(self.LineEditEnCours)
134 def voisListePushed(self):
135 print "voisListePushed"
137 for v in self.node.item.GetListeValeurs():
138 texteValeurs+=str(v)+", "
139 entete="Valeurs pour "+self.nom
140 f=ViewText(self,self.editor,entete,texteValeurs[0:-2])
143 def salomePushed(self):
146 def salomeVuePushed(self):
147 print "salomeVuePushed"