Salome HOME
travail sur monPlusieurs
[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="labelVal"+str(num1)
82        print nomLineEdit
83        courant=getattr(self,nomLineEdit)
84        valeurAGarder=courant.text()
85        nomLineEdit2="labelVal"+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        # on supprime le dernier
96        if self.NumLineEditEnCours==self.indexDernierLabel : 
97           self.setText("")
98        else :
99          for i in range (self.NumLineEditEnCours, self.indexDernierLabel):
100              aRemonter=i+1
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)
109          courant.setText("")
110        self.changeValeur(changeDePlace=False)
111
112    def plusPushed(self):
113        self.ajoutLineEdit()
114        if self.NumLineEditEnCours==self.indexDernierLabel : return
115        nomLineEdit="labelVal"+str(self.NumLineEditEnCours+1)
116        courant=getattr(self,nomLineEdit)
117        valeurADescendre=courant.text()
118        courant.setText("")
119        for i in range (self.NumLineEditEnCours+1, self.indexDernierLabel):
120              aDescendre=i+1
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)
128
129    def voisListePushed(self):
130        print "voisListePushed"
131        texteValeurs=""
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])
136        f.show()
137
138    def salomePushed(self):
139        print "salomePushed"
140
141    def salomeVuePushed(self):
142        print "salomeVuePushed"
143