diff --git a/elementperso.cpp b/elementperso.cpp index ad8759fac..ac14436e0 100644 --- a/elementperso.cpp +++ b/elementperso.cpp @@ -7,7 +7,8 @@ ElementPerso::ElementPerso(QString &nom_fichier, QGraphicsItem *qgi, Schema *s, elmt_etat = -1; // le fichier doit exister - if (!QFileInfo(nomfichier).exists()) { + QFileInfo infos_file(nomfichier); + if (!infos_file.exists() || !infos_file.isFile()) { if (etat != NULL) *etat = 1; elmt_etat = 1; return; @@ -40,7 +41,6 @@ ElementPerso::ElementPerso(QString &nom_fichier, QGraphicsItem *qgi, Schema *s, // ces attributs doivent etre presents et valides int w, h, hot_x, hot_y; if ( - racine.attribute("nom") == QString("") ||\ !attributeIsAnInteger(racine, QString("width"), &w) ||\ !attributeIsAnInteger(racine, QString("height"), &h) ||\ !attributeIsAnInteger(racine, QString("hotspot_x"), &hot_x) ||\ @@ -52,8 +52,7 @@ ElementPerso::ElementPerso(QString &nom_fichier, QGraphicsItem *qgi, Schema *s, return; } - // on peut d'ores et deja specifier le nom, la taille et le hotspot - priv_nom = racine.attribute("nom"); + // on peut d'ores et deja specifier la taille et le hotspot setSize(w, h); setHotspot(QPoint(hot_x, hot_y)); setConnexionsInternesAcceptees(racine.attribute("ci") == "true"); @@ -64,8 +63,7 @@ ElementPerso::ElementPerso(QString &nom_fichier, QGraphicsItem *qgi, Schema *s, return; } - // parcours des enfants de la definition - int nb_elements_parses = 0; + // initialisation du QPainter (pour dessiner l'element) QPainter qp; qp.begin(&dessin); QPen t; @@ -73,16 +71,53 @@ ElementPerso::ElementPerso(QString &nom_fichier, QGraphicsItem *qgi, Schema *s, t.setWidthF(1.0); t.setJoinStyle(Qt::MiterJoin); qp.setPen(t); + + // recupere les deux premiers caracteres de la locale en cours du systeme + QString system_language = QLocale::system().name().left(2); + + // au depart, le nom de l'element est celui du fichier le decrivant + bool name_found = false; + QString name_elmt = infos_file.baseName(); + + // parcours des enfants de la definition : noms et parties du dessin + int nb_elements_parses = 0; for (QDomNode node = racine.firstChild() ; !node.isNull() ; node = node.nextSibling()) { QDomElement elmts = node.toElement(); - if(elmts.isNull()) continue; - if (parseElement(elmts, qp, s)) ++ nb_elements_parses; - else { - if (etat != NULL) *etat = 7; - elmt_etat = 7; - return; + if (elmts.isNull()) continue; + if (elmts.tagName() == "names") { + // gestion des noms de l'element + if (name_found) continue; + for (QDomNode n = node.firstChild() ; !n.isNull() ; n = n.nextSibling()) { + QDomElement qde = n.toElement(); + if (qde.isNull() || qde.tagName() != "name" || !qde.hasAttribute("lang")) continue; + if (qde.attribute("lang") == system_language) { + name_elmt = qde.text(); + name_found = true; + break; + } else if (qde.attribute("lang") == "en") { + name_elmt = qde.text(); + } + } + } else if (elmts.tagName() == "description") { + // gestion de la description graphique de l'element + // = parcours des differentes parties du dessin + for (QDomNode n = node.firstChild() ; !n.isNull() ; n = n.nextSibling()) { + QDomElement qde = n.toElement(); + if (qde.isNull()) continue; + if (parseElement(qde, qp, s)) ++ nb_elements_parses; + else { + if (etat != NULL) *etat = 7; + elmt_etat = 7; + return; + } + } } } + + // on garde le nom trouve + priv_nom = name_elmt; + + // fin du dessin qp.end(); // il doit y avoir au moins un element charge diff --git a/elements/bobine.elmt b/elements/bobine.elmt index b378bd9ce..a1c21e766 100644 --- a/elements/bobine.elmt +++ b/elements/bobine.elmt @@ -1,14 +1,21 @@ - - - - - - - - - - - - - + + + + Bobine + Coil + + + + + + + + + + + + + + + diff --git a/elements/contacts/bp.elmt b/elements/contacts/bp.elmt index 9867c4750..742fdfde2 100644 --- a/elements/contacts/bp.elmt +++ b/elements/contacts/bp.elmt @@ -1,14 +1,21 @@ - - - - - - - - - - - - - + + + + Bouton poussoir + Push-button + + + + + + + + + + + + + + + diff --git a/elements/contacts/bp_nf.elmt b/elements/contacts/bp_nf.elmt index 41b8195e2..b68109a4f 100644 --- a/elements/contacts/bp_nf.elmt +++ b/elements/contacts/bp_nf.elmt @@ -1,15 +1,22 @@ - - - - - - - - - - - - - - + + + + Bouton Poussoir NF + Push-button NF + + + + + + + + + + + + + + + + diff --git a/elements/contacts/capteur.elmt b/elements/contacts/capteur.elmt index 6fe2625f9..ab5263c7e 100644 --- a/elements/contacts/capteur.elmt +++ b/elements/contacts/capteur.elmt @@ -1,12 +1,19 @@ - - - - - - - - - - - + + + + Contact Capteur TOR + AoN Transducer Contact + + + + + + + + + + + + + diff --git a/elements/contacts/capteur_nf.elmt b/elements/contacts/capteur_nf.elmt index 34410a6e6..a272f4159 100644 --- a/elements/contacts/capteur_nf.elmt +++ b/elements/contacts/capteur_nf.elmt @@ -1,14 +1,20 @@ - - - - - - - - - - - - + + + + Capteur NF + Transducer NF + + + + + + + + + + + + + + diff --git a/elements/contacts/contact.elmt b/elements/contacts/contact.elmt index 45bfba1de..148aa0624 100644 --- a/elements/contacts/contact.elmt +++ b/elements/contacts/contact.elmt @@ -1,9 +1,16 @@ - - - - - - - - + + + + Contact + Contact + + + + + + + + + + diff --git a/elements/contacts/contact_nf.elmt b/elements/contacts/contact_nf.elmt index 0e8e69f84..03139ba83 100644 --- a/elements/contacts/contact_nf.elmt +++ b/elements/contacts/contact_nf.elmt @@ -1,10 +1,17 @@ - - - - - - - - - + + + + Contact NF + Contact NF + + + + + + + + + + + diff --git a/elements/contacts/disjoncteur.elmt b/elements/contacts/disjoncteur.elmt index afb16ce2c..48aa26b0f 100644 --- a/elements/contacts/disjoncteur.elmt +++ b/elements/contacts/disjoncteur.elmt @@ -1,12 +1,19 @@ - - - - - - - - - - - + + + + Disjoncteur + Circuit-breaker + + + + + + + + + + + + + diff --git a/elements/contacts/disjoncteur_sectionneur.elmt b/elements/contacts/disjoncteur_sectionneur.elmt index 7432fbb30..b30b90d73 100644 --- a/elements/contacts/disjoncteur_sectionneur.elmt +++ b/elements/contacts/disjoncteur_sectionneur.elmt @@ -1,14 +1,21 @@ - - - - - - - - - - - - - + + + + Disjoncteur-sectionneur + Disconnecting circuit-breaker + + + + + + + + + + + + + + + diff --git a/elements/contacts/sectionneur.elmt b/elements/contacts/sectionneur.elmt index 5bde99e1b..6c8182518 100644 --- a/elements/contacts/sectionneur.elmt +++ b/elements/contacts/sectionneur.elmt @@ -1,11 +1,18 @@ - - - - - - - - - - + + + + Sectioneur + Disconnecting switch + + + + + + + + + + + + diff --git a/elements/definition_element.dtd b/elements/definition_element.dtd index 34e2b5e4e..e8889afd3 100644 --- a/elements/definition_element.dtd +++ b/elements/definition_element.dtd @@ -1,7 +1,6 @@ - + + + + + + + + - - - - - - - - - - - + + + DEL + LED + + + + + + + + + + + + + diff --git a/elements/entree.elmt b/elements/entree.elmt index 48d5a2ae7..60e0c9d50 100644 --- a/elements/entree.elmt +++ b/elements/entree.elmt @@ -1,6 +1,12 @@ - - - - + + + Entree + Input + + + + + + diff --git a/elements/moteurs/mcc.elmt b/elements/moteurs/mcc.elmt index 88f224cbd..d1a347c87 100644 --- a/elements/moteurs/mcc.elmt +++ b/elements/moteurs/mcc.elmt @@ -1,24 +1,31 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + Moteur a courant continu + Direct-current motor + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/elements/moteurs/moteur_alt3.elmt b/elements/moteurs/moteur_alt3.elmt index 33e41e84e..c85c64cec 100644 --- a/elements/moteurs/moteur_alt3.elmt +++ b/elements/moteurs/moteur_alt3.elmt @@ -1,20 +1,27 @@ - - - - - - - - - - - - - - - - - - - + + + + Moteur asynchrone triphasé + Three-phase induction motor + + + + + + + + + + + + + + + + + + + + + diff --git a/elements/moteurs/moteur_alt6.elmt b/elements/moteurs/moteur_alt6.elmt index b66c1dbd2..f19c37dbf 100644 --- a/elements/moteurs/moteur_alt6.elmt +++ b/elements/moteurs/moteur_alt6.elmt @@ -1,32 +1,39 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + Moteur Asyncrone triphasé (non couplé) + Three-phase induction motor (not coupled) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/elements/semi_conducteurs/diode.elmt b/elements/semi_conducteurs/diode.elmt index 3e404f0b8..973dfbfbf 100644 --- a/elements/semi_conducteurs/diode.elmt +++ b/elements/semi_conducteurs/diode.elmt @@ -1,9 +1,16 @@ - - - - - - - - + + + + Diode + Diode + + + + + + + + + + diff --git a/elements/semi_conducteurs/thyristor.elmt b/elements/semi_conducteurs/thyristor.elmt index d96b3f79b..f168a1f43 100644 --- a/elements/semi_conducteurs/thyristor.elmt +++ b/elements/semi_conducteurs/thyristor.elmt @@ -1,14 +1,21 @@ - - - - - - - - - - - - - + + + + Thyristor + Thyristor + + + + + + + + + + + + + + + diff --git a/elements/semi_conducteurs/zener.elmt b/elements/semi_conducteurs/zener.elmt index 3538ccec7..855077cbb 100644 --- a/elements/semi_conducteurs/zener.elmt +++ b/elements/semi_conducteurs/zener.elmt @@ -1,12 +1,19 @@ - - - - - - - - - - - + + + + Zener + Zener + + + + + + + + + + + + + diff --git a/elements/terre.elmt b/elements/terre.elmt index 7b0389025..19f8e9d33 100644 --- a/elements/terre.elmt +++ b/elements/terre.elmt @@ -1,9 +1,16 @@ - - - - - - - - + + + + Terre + Ground + + + + + + + + + + diff --git a/elements/transformateurs/transfo_mono.elmt b/elements/transformateurs/transfo_mono.elmt index c132aec3b..fd0dc8def 100644 --- a/elements/transformateurs/transfo_mono.elmt +++ b/elements/transformateurs/transfo_mono.elmt @@ -1,23 +1,30 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + Transformateur monophasé + One-phase transformer + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/elements/transformateurs/transfo_tri.elmt b/elements/transformateurs/transfo_tri.elmt index 74d2befe7..f02ac808a 100644 --- a/elements/transformateurs/transfo_tri.elmt +++ b/elements/transformateurs/transfo_tri.elmt @@ -1,29 +1,36 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + Transformateur triphasé + Three-phase transformer + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +