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="labelVal"+str(num1)
83 courant=getattr(self,nomLineEdit)
84 valeurAGarder=courant.text()
85 nomLineEdit2="labelVal"+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 # on supprime le dernier
96 if self.NumLineEditEnCours==self.indexDernierLabel :
99 for i in range (self.NumLineEditEnCours, self.indexDernierLabel):
101 nomLineEdit="labelVal"+str(aRemonter)
102 courant=getattr(self,nomLineEdit)
103 valeurARemonter=courant.text()
104 nomLineEdit="labelVal"+str(i)
105 courant=getattr(self,nomLineEdit)
106 courant.setText(valeurARemonter)
107 nomLineEdit="labelVal"+str(self.indexDernierLabel)
108 courant=getattr(self,nomLineEdit)
110 self.changeValeur(changeDePlace=False)
112 def plusPushed(self):
114 if self.NumLineEditEnCours==self.indexDernierLabel : return
115 nomLineEdit="labelVal"+str(self.NumLineEditEnCours+1)
116 courant=getattr(self,nomLineEdit)
117 valeurADescendre=courant.text()
119 for i in range (self.NumLineEditEnCours+1, self.indexDernierLabel):
121 nomLineEdit="labelVal"+str(aDescendre)
122 courant=getattr(self,nomLineEdit)
123 valeurAGarder=courant.text()
124 courant.setText(valeurADescendre)
125 valeurADescendre=valeurAGarder
126 self.changeValeur(changeDePlace=False)
127 self.scrollArea.ensureWidgetVisible(self.LineEditEnCours)
129 def voisListePushed(self):
130 print "voisListePushed"
132 for v in self.node.item.GetListeValeurs():
133 texteValeurs+=str(v)+", "
134 entete="Valeurs pour "+self.nom
135 f=ViewText(self,self.editor,entete,texteValeurs[0:-2])
138 def salomePushed(self):
141 def salomeVuePushed(self):
142 print "salomeVuePushed"