Multipaste : improve the conductor autonum, conductors are numerated from top to bottom, and left to right

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5340 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2018-04-24 17:23:27 +00:00
parent 9d2124f593
commit c96593e373
2 changed files with 99 additions and 61 deletions

View File

@@ -249,10 +249,19 @@ QList<Terminal *> CustomElement::terminals() const {
return(m_terminals);
}
/// @return la liste des conducteurs rattaches a cet element
QList<Conductor *> CustomElement::conductors() const {
/**
* @brief CustomElement::conductors
* @return The list of conductor docked to this element
* the list is sorted according to the position of the terminal where the conductor is docked
* from top to bottom, and left to right.
*/
QList<Conductor *> CustomElement::conductors() const
{
QList<Conductor *> conductors;
foreach(Terminal *t, m_terminals) conductors << t -> conductors();
for(Terminal *t : m_terminals)
conductors << t -> conductors();
return(conductors);
}
@@ -803,6 +812,16 @@ Terminal *CustomElement::parseTerminal(QDomElement &e) {
Terminal *new_terminal = new Terminal(terminalx, terminaly, terminalo, this);
new_terminal -> setZValue(420); // valeur arbitraire pour maintenir les bornes au-dessus des champs de texte
m_terminals << new_terminal;
//Sort from top to bottom and left to rigth
std::sort(m_terminals.begin(), m_terminals.end(), [](Terminal *a, Terminal *b)
{
if(a->dockConductor().y() == b->dockConductor().y())
return (a->dockConductor().x() < b->dockConductor().x());
else
return (a->dockConductor().y() < b->dockConductor().y());
});
return(new_terminal);
}