add comments

This commit is contained in:
Martin Marmsoler
2020-10-01 16:28:48 +02:00
parent 27a63bbf2b
commit 10e767c3e0
2 changed files with 9 additions and 8 deletions

View File

@@ -1009,10 +1009,10 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
}
}
}
//Load all elements from the XML
//Load all elements from the collection in the XML
QList<Element *> added_elements;
QHash<int, Terminal *> table_adr_id;
foreach (QDomElement element_xml, QET::findInDomElement(root, "elements", "element"))
foreach (QDomElement element_xml, QET::findInDomElement(root, "elements", "element")) // read all elements from the diagram
{
if (!Element::valideXml(element_xml)) continue;
@@ -1027,7 +1027,8 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
}
int state = 0;
Element *nvel_elmt = ElementFactory::Instance() -> createElement(element_location, nullptr, &state); // read element definition!
// Create element from the collection
Element *nvel_elmt = ElementFactory::Instance() -> createElement(element_location, nullptr, &state); // read element definition from the collection!
if (state)
{
QString debug_message = QString("Diagram::fromXml() : Le chargement de la description de l'element %1 a echoue avec le code d'erreur %2").arg(element_location.path()).arg(state);
@@ -1038,7 +1039,7 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
addItem(nvel_elmt);
//Loading fail, remove item from the diagram
if (!nvel_elmt->fromXml(element_xml, table_adr_id, handle_inputs_rotation))
if (!nvel_elmt->fromXml(element_xml, table_adr_id, handle_inputs_rotation)) // load element definition from the diagram
{
removeItem(nvel_elmt);
delete nvel_elmt;

View File

@@ -85,7 +85,7 @@ Element::Element(const ElementsLocation &location, QGraphicsItem *parent, int *s
}
int elmt_state;
qDebug() << "\tCollection Path: " << location.collectionPath();
buildFromXml(location.xml(), &elmt_state);
buildFromXml(location.xml(), &elmt_state); // build from the collection definition
if (state) {
*state = elmt_state;
}
@@ -338,7 +338,7 @@ void Element::drawHighlight(QPainter *painter, const QStyleOptionGraphicsItem *o
/**
* @brief Element::buildFromXml
* Build this element from an xml description
* Build this element from an xml description (from the collection)
* @param xml_def_elmt
* @param state
* Optional pointer which define the status of build
@@ -638,7 +638,7 @@ bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr, bool
les bornes vont maintenant etre recensees pour associer leurs id a leur adresse reelle
ce recensement servira lors de la mise en place des fils
*/
QList<QDomElement> liste_terminals;
QList<QDomElement> liste_terminals; // terminals in the element in the diagram
foreach(QDomElement qde, QET::findInDomElement(e, "terminals", "terminal")) {
if (Terminal::valideXml(qde)) liste_terminals << qde;
}
@@ -647,7 +647,7 @@ bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr, bool
int terminals_non_trouvees = 0;
// The added childs from the collection now must match with the terminals from the diagram. Iterate through
// all Terminals in the collection and in the diagram to link them together
foreach(QGraphicsItem *qgi, childItems()) { // Where the Terminals are added as childs?
for(QGraphicsItem *qgi: childItems()) { // TODO: Where the Terminals are added as childs?
if (Terminal *p = qgraphicsitem_cast<Terminal *>(qgi)) {
bool terminal_trouvee = false;
foreach(QDomElement qde, liste_terminals) {