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
54 self.connecterSignaux()
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)
66 if self.NumLineEditEnCours == 1 : return
67 else : numEchange=self.NumLineEditEnCours-1
68 self.echange(self.NumLineEditEnCours,numEchange)
69 self.scrollArea.ensureWidgetVisible(self.LineEditEnCours)
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)
78 def echange(self,num1,num2):
79 # on donne le focus au a celui ou on a bouge
81 nomLineEdit="lineEditVal"+str(num1)
83 courant=getattr(self,nomLineEdit)
84 valeurAGarder=courant.text()
85 nomLineEdit2="lineEditVal"+str(num2)
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
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')
98 # on supprime le dernier
99 if self.NumLineEditEnCours==self.indexDernierLabel :
102 for i in range (self.NumLineEditEnCours, self.indexDernierLabel):
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)
113 self.changeValeur(changeDePlace=False)
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')
120 if self.NumLineEditEnCours==self.indexDernierLabel : return
121 nomLineEdit="lineEditVal"+str(self.NumLineEditEnCours+1)
122 courant=getattr(self,nomLineEdit)
123 valeurADescendre=courant.text()
125 for i in range (self.NumLineEditEnCours+1, self.indexDernierLabel):
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)
135 def voisListePushed(self):
136 print "voisListePushed"
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])
144 def salomePushed(self):
147 def salomeVuePushed(self):
148 print "salomeVuePushed"