[qet] [2121] add method for get each potentials in a diagram and revamp method for reset all conductors text in a diagram |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 2121
Author: blacksun
Date: 2013-04-19 16:59:20 +0200 (Fri, 19 Apr 2013)
Log Message:
-----------
add method for get each potentials in a diagram and revamp method for reset all conductors text in a diagram
Modified Paths:
--------------
trunk/sources/conductorautonumerotation.cpp
trunk/sources/conductorautonumerotation.h
trunk/sources/diagram.cpp
trunk/sources/diagram.h
trunk/sources/ui/dialogconductorautonum.cpp
Modified: trunk/sources/conductorautonumerotation.cpp
===================================================================
--- trunk/sources/conductorautonumerotation.cpp 2013-04-19 13:22:30 UTC (rev 2120)
+++ trunk/sources/conductorautonumerotation.cpp 2013-04-19 14:59:20 UTC (rev 2121)
@@ -27,6 +27,16 @@
{}
/**
+ * Constructor
+ * @param d a diagram to apply automatic numerotation
+ */
+ConductorAutoNumerotation::ConductorAutoNumerotation(Diagram *d) :
+ conductor_ (0),
+ diagram_ (d),
+ strategy_ (0)
+{}
+
+/**
*destructor
*/
ConductorAutoNumerotation::~ConductorAutoNumerotation() {
@@ -120,15 +130,17 @@
/**
- * @brief Set the default text to all conductors of the diagram
+ * @brief Set the default text to all potentials of the diagram
* @param dg the diagram
*/
-void ConductorAutoNumerotation::removeNum_ofDiagram(Diagram *dg) {
- // Get all conductors presents in diagram
- QList<Conductor *> Conductors = dg -> content().conductors();
- // Browse all conductors and set the default value
- for (int i=0; i<Conductors.count(); i++) {
- Conductors.at(i) -> setText( dg ->defaultConductorProperties.text );
+void ConductorAutoNumerotation::removeNum_ofDiagram() {
+ if (!diagram_) return;
+ //Get all potentials presents in diagram
+ QList <QSet <Conductor *> > potential_list = diagram_ -> potentials();
+ //Browse all potentials and set the default text
+ for (int i=0; i < potential_list.size(); i++) {
+ ConductorAutoNumerotation can (potential_list.at(i).toList().first());
+ can.applyText(diagram_ -> defaultConductorProperties.text);
}
}
Modified: trunk/sources/conductorautonumerotation.h
===================================================================
--- trunk/sources/conductorautonumerotation.h 2013-04-19 13:22:30 UTC (rev 2120)
+++ trunk/sources/conductorautonumerotation.h 2013-04-19 14:59:20 UTC (rev 2121)
@@ -14,13 +14,14 @@
public:
//constructors & destructor
ConductorAutoNumerotation ();
- ConductorAutoNumerotation(Conductor *);
+ ConductorAutoNumerotation (Conductor *);
+ ConductorAutoNumerotation (Diagram *);
~ConductorAutoNumerotation();
//methods
void setConductor(Conductor *);
void numerate();
- void removeNum_ofDiagram(Diagram *);
+ void removeNum_ofDiagram();
public slots:
void applyText(QString);
Modified: trunk/sources/diagram.cpp
===================================================================
--- trunk/sources/diagram.cpp 2013-04-19 13:22:30 UTC (rev 2120)
+++ trunk/sources/diagram.cpp 2013-04-19 14:59:20 UTC (rev 2121)
@@ -273,6 +273,26 @@
}
/**
+ * @brief Diagram::potential
+ * @return all potential in the diagram
+ *each potential are in the QList and each conductors of one potential are in the QSet
+ */
+QList < QSet <Conductor *> > Diagram::potentials() {
+ QList < QSet <Conductor *> > potential_List;
+ if (content().conductors().size() == 0) return (potential_List); //return an empty potential
+ QList <Conductor *> conductors_list = content().conductors();
+
+ do {
+ QSet <Conductor *> one_potential = conductors_list.first() -> relatedPotentialConductors();
+ one_potential << conductors_list.takeFirst();
+ foreach (Conductor *c, one_potential) conductors_list.removeOne(c);
+ potential_List << one_potential;
+ } while (!conductors_list.empty());
+
+ return (potential_List);
+}
+
+/**
Exporte tout ou partie du schema
@param whole_content Booleen (a vrai par defaut) indiquant si le XML genere doit
representer l'integralite du schema ou seulement le contenu selectionne
Modified: trunk/sources/diagram.h
===================================================================
--- trunk/sources/diagram.h 2013-04-19 13:22:30 UTC (rev 2120)
+++ trunk/sources/diagram.h 2013-04-19 14:59:20 UTC (rev 2121)
@@ -109,6 +109,7 @@
void setConductor(bool);
void setConductorStart (QPointF);
void setConductorStop(QPointF);
+ QList < QSet <Conductor *> > potentials();
// methods related to XML import/export
QDomDocument toXml(bool = true);
Modified: trunk/sources/ui/dialogconductorautonum.cpp
===================================================================
--- trunk/sources/ui/dialogconductorautonum.cpp 2013-04-19 13:22:30 UTC (rev 2120)
+++ trunk/sources/ui/dialogconductorautonum.cpp 2013-04-19 14:59:20 UTC (rev 2121)
@@ -36,8 +36,8 @@
// if yes remove all
if( answer == QMessageBox::Yes) {
- ConductorAutoNumerotation ConductorNum;
- ConductorNum.removeNum_ofDiagram( dg_ );
+ ConductorAutoNumerotation can(dg_);
+ can.removeNum_ofDiagram();
}
}