[qet] [3229] Autonumerotation: Auto numbering isn' t increased through the terminal Elements |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 3229
Author: blacksun
Date: 2014-07-23 21:54:25 +0200 (Wed, 23 Jul 2014)
Log Message:
-----------
Autonumerotation: Auto numbering isn't increased through the terminal Elements
Modified Paths:
--------------
trunk/sources/factory/elementfactory.cpp
trunk/sources/qetgraphicsitem/conductor.cpp
trunk/sources/qetgraphicsitem/element.h
trunk/sources/ui/elementpropertieswidget.cpp
Added Paths:
-----------
trunk/sources/qetgraphicsitem/terminalelement.cpp
trunk/sources/qetgraphicsitem/terminalelement.h
Modified: trunk/sources/factory/elementfactory.cpp
===================================================================
--- trunk/sources/factory/elementfactory.cpp 2014-07-23 18:02:29 UTC (rev 3228)
+++ trunk/sources/factory/elementfactory.cpp 2014-07-23 19:54:25 UTC (rev 3229)
@@ -20,10 +20,11 @@
#include "elementscollectionitem.h"
#include "qetapp.h"
#include "QDomElement"
-#include "qetgraphicsitem/simpleelement.h"
-#include "qetgraphicsitem/reportelement.h"
-#include "qetgraphicsitem/masterelement.h"
-#include "qetgraphicsitem/slaveelement.h"
+#include "simpleelement.h"
+#include "reportelement.h"
+#include "masterelement.h"
+#include "slaveelement.h"
+#include "terminalelement.h"
ElementFactory* ElementFactory::factory_ = 0;
/**
@@ -48,8 +49,9 @@
if (element_definition->xml().hasAttribute("link_type")) {
QString link_type = element_definition->xml().attribute("link_type");
if (link_type == "next_report" || link_type == "previous_report") return (new ReportElement(location, link_type, qgi, s, state));
- if (link_type == "master") return (new MasterElement(location, qgi, s, state));
- if (link_type == "slave") return (new SlaveElement (location, qgi, s, state));
+ if (link_type == "master") return (new MasterElement (location, qgi, s, state));
+ if (link_type == "slave") return (new SlaveElement (location, qgi, s, state));
+ if (link_type == "terminal") return (new TerminalElement (location, qgi, s, state));
}
//default if nothing match for link_type
Modified: trunk/sources/qetgraphicsitem/conductor.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/conductor.cpp 2014-07-23 18:02:29 UTC (rev 3228)
+++ trunk/sources/qetgraphicsitem/conductor.cpp 2014-07-23 19:54:25 UTC (rev 3229)
@@ -1325,6 +1325,13 @@
* @return les conducteurs avec lesquels ce conducteur partage
* le meme potentiel electrique a l'exception de lui même
*/
+/**
+ * @brief Conductor::relatedPotentialConductors
+ * Return all conductors at the same potential of this conductor, this conductor isn't
+ * part of the returned QSet.
+ * @param t_list, a list of terminal already cheched for the serach of potential.
+ * @return a QSet of conductor at the same potential.
+ */
QSet<Conductor *> Conductor::relatedPotentialConductors(QList <Terminal *> *t_list) {
bool declar_t_list = false;
if (t_list == 0) {
@@ -1333,64 +1340,62 @@
}
QSet <Conductor *> other_conductors;
- //renvoie tous les conducteurs du terminal 1
- if (!t_list -> contains(terminal1)) {
- t_list -> append(terminal1);
- QList <Conductor *> other_conductors_list_t1 = terminal1 -> conductors();
+ QList <Terminal *> this_terminal{terminal1, terminal2};
- //get terminal share the same potential of terminal1
- Terminal *t1_bis = relatedPotentialTerminal(terminal1);
- if (t1_bis && !t_list->contains(t1_bis)) {
- t_list -> append(t1_bis);
- other_conductors_list_t1 += t1_bis->conductors();
- }
+ // Return all conductor of terminal 1 and 2
+ foreach (Terminal *terminal, this_terminal) {
+ if (!t_list -> contains(terminal)) {
+ t_list -> append(terminal);
+ QList <Conductor *> other_conductors_list_t = terminal -> conductors();
- other_conductors_list_t1.removeAll(this);
- //recherche les conducteurs connecté au conducteur déjà trouvé
- foreach (Conductor *c, other_conductors_list_t1) {
- other_conductors += c -> relatedPotentialConductors(t_list);
+ //get terminal share the same potential of @terminal, of parent element
+ Terminal *t1_bis = relatedPotentialTerminal(terminal);
+ if (t1_bis && !t_list->contains(t1_bis)) {
+ t_list -> append(t1_bis);
+ other_conductors_list_t += t1_bis->conductors();
+ }
+
+ other_conductors_list_t.removeAll(this);
+ // Research the conductors connected to conductors already found
+ foreach (Conductor *c, other_conductors_list_t) {
+ other_conductors += c -> relatedPotentialConductors(t_list);
+ }
+ other_conductors += other_conductors_list_t.toSet();
}
- other_conductors += other_conductors_list_t1.toSet();
}
- //renvoie tous les conducteurs du terminal 2
- if (!t_list -> contains(terminal2)) {
- t_list -> append(terminal2);
- QList <Conductor *> other_conductors_list_t2 = terminal2 -> conductors();
+ other_conductors.remove(this);
- //get terminal share the same potential of terminal1
- Terminal *t2_bis = relatedPotentialTerminal(terminal2);
- if (t2_bis && !t_list->contains(t2_bis)) {
- t_list -> append(t2_bis);
- other_conductors_list_t2 += t2_bis->conductors();
- }
-
- other_conductors_list_t2.removeAll(this);
- //recherche les conducteurs connecté au conducteur déjà trouvé
- foreach (Conductor *c, other_conductors_list_t2) {
- other_conductors += c -> relatedPotentialConductors(t_list);
- }
- other_conductors += other_conductors_list_t2.toSet();
- }
- other_conductors.remove(const_cast<Conductor *>(this));
-
if (declar_t_list) delete t_list;
return(other_conductors);
}
/**
* @brief Conductor::relatedPotentialTerminal
- * find another terminal in the same electric potential of terminal @t
+ * Return terminal at the same potential from the same
+ * parent element of @t.
+ * For folio report, return the terminal of linked other report.
+ * For Terminal element, return the other terminal of terminal element.
+ * @param t terminal to start search
+ * @return
*/
Terminal * Conductor::relatedPotentialTerminal (Terminal *t) {
- //terminal must have a folio report parent.
+ // If terminal parent element is a folio report.
if (t->parentElement()->linkType() & Element::AllReport) {
QList <Element *> elmt_list = t->parentElement()->linkedElements();
if (!elmt_list.isEmpty()) {
return (elmt_list.first()->terminals().first());
}
}
- return 0;
+ // If terminal parent element is a Terminal element.
+ if (t->parentElement() -> linkType() & Element::Terminale) {
+ QList <Terminal *> terminals = t->parentElement()->terminals();
+ terminals.removeAll(t);
+ if (!terminals.isEmpty()) return terminals.first();
+ else return nullptr;
+ }
+
+ return nullptr;
}
/**
Modified: trunk/sources/qetgraphicsitem/element.h
===================================================================
--- trunk/sources/qetgraphicsitem/element.h 2014-07-23 18:02:29 UTC (rev 3228)
+++ trunk/sources/qetgraphicsitem/element.h 2014-07-23 19:54:25 UTC (rev 3229)
@@ -53,7 +53,7 @@
AllReport = 6,
Master = 8,
Slave = 16,
- Bornier = 32};
+ Terminale = 32};
private:
QSize dimensions;
Added: trunk/sources/qetgraphicsitem/terminalelement.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/terminalelement.cpp (rev 0)
+++ trunk/sources/qetgraphicsitem/terminalelement.cpp 2014-07-23 19:54:25 UTC (rev 3229)
@@ -0,0 +1,34 @@
+/*
+ Copyright 2006-2014 The QElectroTech Team
+ This file is part of QElectroTech.
+
+ QElectroTech is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ QElectroTech is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
+*/
+#include "terminalelement.h"
+
+/**
+ * @brief TerminalElement::TerminalElement
+ * Default constructor
+ * @param location location of xml definition
+ * @param qgi parent QGraphicItem
+ * @param s parent diagram
+ * @param state int used to know if the creation of element have error
+ */
+TerminalElement::TerminalElement(const ElementsLocation &location, QGraphicsItem *qgi, Diagram *s, int *state) :
+ CustomElement(location, qgi, s, state)
+{
+ link_type_ = Terminale;
+}
+
+TerminalElement::~TerminalElement() {}
Added: trunk/sources/qetgraphicsitem/terminalelement.h
===================================================================
--- trunk/sources/qetgraphicsitem/terminalelement.h (rev 0)
+++ trunk/sources/qetgraphicsitem/terminalelement.h 2014-07-23 19:54:25 UTC (rev 3229)
@@ -0,0 +1,31 @@
+/*
+ Copyright 2006-2014 The QElectroTech Team
+ This file is part of QElectroTech.
+
+ QElectroTech is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ QElectroTech is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef TERMINALELEMENT_H
+#define TERMINALELEMENT_H
+
+#include "customelement.h"
+
+class TerminalElement : public CustomElement
+{
+ Q_OBJECT
+ public:
+ TerminalElement(const ElementsLocation &, QGraphicsItem * = 0, Diagram * = 0, int * = 0);
+ ~TerminalElement();
+};
+
+#endif // TERMINALELEMENT_H
Modified: trunk/sources/ui/elementpropertieswidget.cpp
===================================================================
--- trunk/sources/ui/elementpropertieswidget.cpp 2014-07-23 18:02:29 UTC (rev 3228)
+++ trunk/sources/ui/elementpropertieswidget.cpp 2014-07-23 19:54:25 UTC (rev 3229)
@@ -131,7 +131,7 @@
lsew_ = new LinkSingleElementWidget(element_, this);
tab_ -> addTab(lsew_, tr("R\351f\351rence crois\351e (esclave)"));
break;
- case Element::Bornier:
+ case Element::Terminale:
break;
default:
break;