diff --git a/sources/qetgraphicsitem/element.cpp b/sources/qetgraphicsitem/element.cpp index 85bc24d2c..db888585f 100644 --- a/sources/qetgraphicsitem/element.cpp +++ b/sources/qetgraphicsitem/element.cpp @@ -1,5 +1,5 @@ /* - Copyright 2006-2017 The QElectroTech Team + Copyright 2006-2018 The QElectroTech Team This file is part of QElectroTech. QElectroTech is free software: you can redistribute it and/or modify @@ -69,8 +69,9 @@ class ElementXmlRetroCompatibility * @param parent, parent graphics item * @param state, state of the instanciation */ -Element::Element(const ElementsLocation &location, QGraphicsItem *parent, int *state) : +Element::Element(const ElementsLocation &location, QGraphicsItem *parent, int *state, kind link_type) : QetGraphicsItem(parent), + m_link_type (link_type), m_location (location) { if(! (location.isElement() && location.exist())) @@ -94,7 +95,6 @@ Element::Element(const ElementsLocation &location, QGraphicsItem *parent, int *s } setPrefix(autonum::elementPrefixForLocation(location)); - m_link_type = Simple; m_uuid = QUuid::createUuid(); setZValue(10); setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable); diff --git a/sources/qetgraphicsitem/element.h b/sources/qetgraphicsitem/element.h index 9cd51a69e..716e383e9 100644 --- a/sources/qetgraphicsitem/element.h +++ b/sources/qetgraphicsitem/element.h @@ -1,5 +1,5 @@ /* - Copyright 2006-2017 The QElectroTech Team + Copyright 2006-2018 The QElectroTech Team This file is part of QElectroTech. QElectroTech is free software: you can redistribute it and/or modify @@ -42,10 +42,20 @@ class Element : public QetGraphicsItem friend class DiagramEventAddElement; Q_OBJECT - - // constructors, destructor public: - Element(const ElementsLocation &location, QGraphicsItem * = nullptr, int *state = nullptr); + /** + * @brief The kind enum + * Used to know the kind of this element (master, slave, report ect...) + */ + enum kind {Simple = 1, + NextReport = 2, + PreviousReport = 4, + AllReport = 6, + Master = 8, + Slave = 16, + Terminale = 32}; + + Element(const ElementsLocation &location, QGraphicsItem * = nullptr, int *state = nullptr, Element::kind link_type = Element::Simple); ~Element() override; private: Element(const Element &); @@ -58,18 +68,6 @@ class Element : public QetGraphicsItem */ enum { Type = UserType + 1000 }; int type() const override { return Type; } - - /** - * @brief The kind enum - * Used to know the kind of this element (master, slave, report ect...) - */ - enum kind {Simple = 1, - NextReport = 2, - PreviousReport = 4, - AllReport = 6, - Master = 8, - Slave = 16, - Terminale = 32}; signals: void linkedElementChanged(); //This signal is emited when the linked elements with this element change @@ -173,7 +171,7 @@ class Element : public QetGraphicsItem QList connected_elements; QList tmp_uuids_link; QUuid m_uuid; - kind m_link_type; + kind m_link_type = Element::Simple; //ATTRIBUTES related to informations DiagramContext m_element_informations, m_kind_informations; diff --git a/sources/qetgraphicsitem/masterelement.cpp b/sources/qetgraphicsitem/masterelement.cpp index c0d8c8a25..8fbec4e83 100644 --- a/sources/qetgraphicsitem/masterelement.cpp +++ b/sources/qetgraphicsitem/masterelement.cpp @@ -1,5 +1,5 @@ /* - Copyright 2006-2017 The QElectroTech Team + Copyright 2006-2018 The QElectroTech Team This file is part of QElectroTech. QElectroTech is free software: you can redistribute it and/or modify @@ -30,10 +30,8 @@ * @param state int used to know if the creation of element have error */ MasterElement::MasterElement(const ElementsLocation &location, QGraphicsItem *qgi, int *state) : - Element(location, qgi, state) -{ - m_link_type = Element::Master; -} + Element(location, qgi, state, Element::Master) +{} /** * @brief MasterElement::~MasterElement diff --git a/sources/qetgraphicsitem/reportelement.cpp b/sources/qetgraphicsitem/reportelement.cpp index dd1f11c9e..0826797fe 100644 --- a/sources/qetgraphicsitem/reportelement.cpp +++ b/sources/qetgraphicsitem/reportelement.cpp @@ -1,5 +1,5 @@ /* - Copyright 2006-2017 The QElectroTech Team + Copyright 2006-2018 The QElectroTech Team This file is part of QElectroTech. QElectroTech is free software: you can redistribute it and/or modify @@ -24,11 +24,10 @@ #include "dynamicelementtextitem.h" ReportElement::ReportElement(const ElementsLocation &location, const QString& link_type,QGraphicsItem *qgi, int *state) : - Element(location, qgi, state) -{ - link_type == "next_report"? m_link_type=NextReport : m_link_type=PreviousReport; - link_type == "next_report"? m_inverse_report=PreviousReport : m_inverse_report=NextReport; -} + Element(location, qgi, state, + link_type == "next_report"? Element::NextReport : Element::PreviousReport), + m_inverse_report(link_type == "next_report"? Element::PreviousReport : Element::NextReport) +{} /** * @brief ReportElement::~ReportElement diff --git a/sources/qetgraphicsitem/simpleelement.cpp b/sources/qetgraphicsitem/simpleelement.cpp index 2c78e4bdb..bae278f65 100644 --- a/sources/qetgraphicsitem/simpleelement.cpp +++ b/sources/qetgraphicsitem/simpleelement.cpp @@ -1,5 +1,5 @@ /* - Copyright 2006-2017 The QElectroTech Team + Copyright 2006-2018 The QElectroTech Team This file is part of QElectroTech. QElectroTech is free software: you can redistribute it and/or modify @@ -26,10 +26,8 @@ * @param state */ SimpleElement::SimpleElement(const ElementsLocation &location, QGraphicsItem *qgi, int *state) : - Element(location, qgi, state) -{ - m_link_type = Simple; -} + Element(location, qgi, state, Element::Simple) +{} /** * @brief SimpleElement::~SimpleElement diff --git a/sources/qetgraphicsitem/slaveelement.cpp b/sources/qetgraphicsitem/slaveelement.cpp index d41c2cde9..16b3088a5 100644 --- a/sources/qetgraphicsitem/slaveelement.cpp +++ b/sources/qetgraphicsitem/slaveelement.cpp @@ -1,5 +1,5 @@ /* - Copyright 2006-2017 The QElectroTech Team + Copyright 2006-2018 The QElectroTech Team This file is part of QElectroTech. QElectroTech is free software: you can redistribute it and/or modify @@ -30,10 +30,9 @@ * @param state int used to know if the creation of element have error */ SlaveElement::SlaveElement(const ElementsLocation &location, QGraphicsItem *qgi, int *state) : - Element(location, qgi, state) + Element(location, qgi, state, Element::Slave) { m_xref_item = nullptr; - m_link_type = Slave; } /** diff --git a/sources/qetgraphicsitem/terminalelement.cpp b/sources/qetgraphicsitem/terminalelement.cpp index c17eacb4c..3e1e2c02b 100644 --- a/sources/qetgraphicsitem/terminalelement.cpp +++ b/sources/qetgraphicsitem/terminalelement.cpp @@ -1,5 +1,5 @@ /* - Copyright 2006-2017 The QElectroTech Team + Copyright 2006-2018 The QElectroTech Team This file is part of QElectroTech. QElectroTech is free software: you can redistribute it and/or modify @@ -26,8 +26,8 @@ * @param state int used to know if the creation of element have error */ TerminalElement::TerminalElement(const ElementsLocation &location, QGraphicsItem *qgi, int *state) : - Element(location, qgi, state) -{m_link_type = Terminale;} + Element(location, qgi, state, Element::Terminale) +{} TerminalElement::~TerminalElement() {}