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
24 from PyQt4.QtGui import *
25 from PyQt4.QtCore import *
26 from Extensions.i18n import tr
28 from feuille import Feuille
29 from desWidgetSDCOInto import Ui_WidgetSDCOInto
30 from qtSaisie import SaisieSDCO
31 from politiquesValidation import PolitiqueUnique
35 class MonWidgetSDCOInto (Ui_WidgetSDCOInto,Feuille,SaisieSDCO):
37 def __init__(self,node,monSimpDef,nom,objSimp,parentQt,commande):
38 #print "MonWidgetSDCOInto init"
39 Feuille.__init__(self,node,monSimpDef,nom,objSimp,parentQt,commande)
40 self.politique=PolitiqueUnique(self.node,self.editor)
41 self.parentQt.commandesLayout.insertWidget(-1,self)
42 self.maCommande.listeAffichageWidget.append(self.LESDCO)
43 self.AAficher=self.LESDCO
45 self.connect(self.LESDCO, SIGNAL("returnPressed()"),self.LESDCOReturnPressed)
46 self.connect(self.LBSDCO, SIGNAL("itemDoubleClicked(QListWidgetItem*)" ), self.LBSDCODoubleClicked )
48 def LESDCOReturnPressed(self) :
49 self.LBSDCO.clearSelection()
50 SaisieSDCO.LESDCOReturnPressed(self)
54 listeNomsSDCO = self.node.item.get_sd_avant_du_bon_type()
55 for aSDCO in listeNomsSDCO:
56 self.LBSDCO.insertItem( 1,aSDCO)
57 valeur = self.node.item.get_valeur()
58 if valeur != "" and valeur != None :
59 self.LESDCO.setText(QString(valeur.nom))
62 def LBSDCODoubleClicked(self):
64 Teste si la valeur fournie par l'utilisateur est une valeur permise :
65 - si oui, l'enregistre
66 - si non, restaure l'ancienne valeur
68 nomConcept=str(self.LBSDCO.currentItem().text())
70 self.editor.init_modif()
71 anc_val = self.node.item.get_valeur()
72 test_CO=self.node.item.is_CO(anc_val)
74 valeur,validite=self.node.item.eval_valeur(nomConcept)
75 test = self.node.item.set_valeur(valeur)
77 commentaire = tr("impossible d'evaluer : ") + valeur
79 commentaire = tr("Valeur du mot-clef enregistree")
81 # il faut egalement propager la destruction de l'ancien concept
82 self.node.item.delete_valeur_co(valeur=anc_val)
83 self.node.item.object.etape.get_type_produit(force=1)
84 self.node.item.object.etape.parent.reset_context()
85 self.LESDCO.setText(QString(nomConcept))
87 commentaire = self.node.item.get_cr()
88 self.reset_old_valeur(anc_val,mess=mess)
89 self.editor.affiche_infos(commentaire,Qt.red)
90 self.Commentaire.setText(tr(commentaire))