add method for get each potentials in a diagram and revamp method for reset all conductors text in a diagram

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2121 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2013-04-19 14:59:20 +00:00
parent acb7e21a6d
commit 73d78ea623
5 changed files with 45 additions and 11 deletions

View File

@@ -26,6 +26,16 @@ ConductorAutoNumerotation::ConductorAutoNumerotation(Conductor *c) :
strategy_ (0)
{}
/**
* Constructor
* @param d a diagram to apply automatic numerotation
*/
ConductorAutoNumerotation::ConductorAutoNumerotation(Diagram *d) :
conductor_ (0),
diagram_ (d),
strategy_ (0)
{}
/**
*destructor
*/
@@ -120,15 +130,17 @@ void ConductorAutoNumerotation::setNumStrategy() {}
/**
* @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);
}
}

View File

@@ -14,13 +14,14 @@ class ConductorAutoNumerotation: public QObject
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);

View File

@@ -272,6 +272,26 @@ bool Diagram::isEmpty() const {
return(!items().count());
}
/**
* @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

View File

@@ -109,6 +109,7 @@ class Diagram : public QGraphicsScene {
void setConductor(bool);
void setConductorStart (QPointF);
void setConductorStop(QPointF);
QList < QSet <Conductor *> > potentials();
// methods related to XML import/export
QDomDocument toXml(bool = true);

View File

@@ -36,8 +36,8 @@ void DialogConductorAutoNum::on_pushButton_delete_clicked() {
// if yes remove all
if( answer == QMessageBox::Yes) {
ConductorAutoNumerotation ConductorNum;
ConductorNum.removeNum_ofDiagram( dg_ );
ConductorAutoNumerotation can(dg_);
can.removeNum_ofDiagram();
}
}