diff --git a/sources/diagram.cpp b/sources/diagram.cpp index e4935170e..f0d51b097 100644 --- a/sources/diagram.cpp +++ b/sources/diagram.cpp @@ -555,7 +555,7 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf if (type_id.startsWith("embed://")) element_location.setProject(project_); int state = 0; - Element *nvel_elmt = ElementFactory::Instance()->createElement(element_location, 0, this, &state); + Element *nvel_elmt = ElementFactory::Instance() -> createElement(element_location, 0, &state); 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); qDebug() << qPrintable(debug_message); @@ -579,7 +579,7 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf // Load text QList added_texts; foreach (QDomElement text_xml, QET::findInDomElement(root, "inputs", "input")) { - IndependentTextItem *iti = new IndependentTextItem(this); + IndependentTextItem *iti = new IndependentTextItem(); iti -> fromXml(text_xml); addItem(iti); added_texts << iti; @@ -623,8 +623,9 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf } } if (can_add_conductor) { - Conductor *c = new Conductor(table_adr_id.value(id_p1), table_adr_id.value(id_p2), this); + Conductor *c = new Conductor(table_adr_id.value(id_p1), table_adr_id.value(id_p2)); c -> fromXml(f); + addItem(c); added_conductors << c; } } diff --git a/sources/diagramview.cpp b/sources/diagramview.cpp index 040253da7..b2e406c23 100644 --- a/sources/diagramview.cpp +++ b/sources/diagramview.cpp @@ -314,7 +314,7 @@ void DiagramView::handleTitleBlockDrop(QDropEvent *e) { void DiagramView::handleTextDrop(QDropEvent *e) { if (scene -> isReadOnly() || (e -> mimeData() -> hasText() == false) ) return; - IndependentTextItem *iti = new IndependentTextItem (e -> mimeData() -> text(), scene); + IndependentTextItem *iti = new IndependentTextItem (e -> mimeData() -> text()); if (e -> mimeData() -> hasHtml()) { iti -> setHtml (e -> mimeData() -> text()); @@ -863,7 +863,7 @@ bool DiagramView::mustIntegrateTitleBlockTemplate(const TitleBlockTemplateLocati bool DiagramView::addElementAtPos(const ElementsLocation &location, const QPoint &pos) { // construit une instance de l'element correspondant a l'emplacement int state; - Element *el = ElementFactory::Instance()->createElement(location, 0, diagram(), &state); + Element *el = ElementFactory::Instance()->createElement(location, 0, &state); if (state) { delete el; return(false); diff --git a/sources/elementscollectioncache.cpp b/sources/elementscollectioncache.cpp index cef172a90..d591b11da 100644 --- a/sources/elementscollectioncache.cpp +++ b/sources/elementscollectioncache.cpp @@ -196,7 +196,7 @@ QPixmap ElementsCollectionCache::pixmap() const { */ bool ElementsCollectionCache::fetchData(const ElementsLocation &location) { int state; - Element *custom_elmt = ElementFactory::Instance()->createElement(location, 0, 0, &state); + Element *custom_elmt = ElementFactory::Instance() -> createElement(location, 0, &state); if (state) { qDebug() << "ElementsCollectionCache::fetchData() : Le chargement du composant" << qPrintable(location.toString()) << "a echoue avec le code d'erreur" << state; } else { diff --git a/sources/elementspanel.cpp b/sources/elementspanel.cpp index 5308f3410..e5d65d66c 100644 --- a/sources/elementspanel.cpp +++ b/sources/elementspanel.cpp @@ -294,7 +294,7 @@ void ElementsPanel::startElementDrag(const ElementsLocation &location) { // element temporaire pour fournir un apercu int elmt_creation_state; - Element *temp_elmt = ElementFactory::Instance()->createElement(location, 0, 0, &elmt_creation_state); + Element *temp_elmt = ElementFactory::Instance() -> createElement(location, 0, &elmt_creation_state); if (elmt_creation_state) { delete temp_elmt; return; diff --git a/sources/factory/elementfactory.cpp b/sources/factory/elementfactory.cpp index 221900235..78344dabc 100644 --- a/sources/factory/elementfactory.cpp +++ b/sources/factory/elementfactory.cpp @@ -31,29 +31,31 @@ ElementFactory* ElementFactory::factory_ = 0; * @brief ElementFactory::createElement * @param location create element at this location * @param qgi parent item for this elemnt - * @param s diagram of the element * @param state state of the creation * @return the element or 0 */ -Element * ElementFactory::createElement(const ElementsLocation &location, QGraphicsItem *qgi, Diagram *s, int *state) { - // recupere la definition de l'element +Element * ElementFactory::createElement(const ElementsLocation &location, QGraphicsItem *qgi, int *state) +{ + // recupere la definition de l'element ElementsCollectionItem *element_item = QETApp::collectionItem(location); ElementDefinition *element_definition; if (!element_item ||\ !element_item -> isElement() ||\ - !(element_definition = qobject_cast(element_item))) { + !(element_definition = qobject_cast(element_item))) + { if (state) *state = 1; return 0; } - if (element_definition->xml().hasAttribute("link_type")) { + if (element_definition->xml().hasAttribute("link_type")) + { QString link_type = element_definition->xml().attribute("link_type"); - if (link_type == "next_report" || link_type == "previous_report") return (new ReportElement(location, link_type, qgi, s, state)); - if (link_type == "master") return (new MasterElement (location, qgi, s, state)); - if (link_type == "slave") return (new SlaveElement (location, qgi, s, state)); - if (link_type == "terminal") return (new TerminalElement (location, qgi, s, state)); + if (link_type == "next_report" || link_type == "previous_report") return (new ReportElement(location, link_type, qgi, state)); + if (link_type == "master") return (new MasterElement (location, qgi, state)); + if (link_type == "slave") return (new SlaveElement (location, qgi, state)); + if (link_type == "terminal") return (new TerminalElement (location, qgi, state)); } - //default if nothing match for link_type - return (new SimpleElement(location, qgi, s, state)); + //default if nothing match for link_type + return (new SimpleElement(location, qgi, state)); } diff --git a/sources/factory/elementfactory.h b/sources/factory/elementfactory.h index 098e8098d..067034feb 100644 --- a/sources/factory/elementfactory.h +++ b/sources/factory/elementfactory.h @@ -33,41 +33,43 @@ class Diagram; */ class ElementFactory { - //methods for singleton pattern + //methods for singleton pattern public: - // return instance of factory - static ElementFactory* Instance() { - static QMutex mutex; - if (!factory_) { - mutex.lock(); - if (!factory_) factory_ = new ElementFactory(); - mutex.unlock(); + // return instance of factory + static ElementFactory* Instance() { + static QMutex mutex; + if (!factory_) { + mutex.lock(); + if (!factory_) factory_ = new ElementFactory(); + mutex.unlock(); + } + return factory_; } - return factory_; - } - // delete the instance of factory - static void dropInstance () { - static QMutex mutex; - if (factory_) { - mutex.lock(); - delete factory_; - factory_ = 0; - mutex.unlock(); - } - } - //attributes - private: - static ElementFactory* factory_; - //methods for the class factory himself + // delete the instance of factory + static void dropInstance () { + static QMutex mutex; + if (factory_) { + mutex.lock(); + delete factory_; + factory_ = 0; + mutex.unlock(); + } + } + + //attributes private: - ElementFactory() {} - ElementFactory (const ElementFactory &); - ElementFactory operator= (const ElementFactory &); - ~ElementFactory() {} + static ElementFactory* factory_; + + //methods for the class factory himself + private: + ElementFactory() {} + ElementFactory (const ElementFactory &); + ElementFactory operator= (const ElementFactory &); + ~ElementFactory() {} public: - Element * createElement (const ElementsLocation &, QGraphicsItem * = 0, Diagram * = 0, int * = 0); + Element * createElement (const ElementsLocation &, QGraphicsItem * = 0, int * = 0); }; //ElementFactory ElementFactory::factory_ = 0; #endif // ELEMENTFACTORY_H diff --git a/sources/qetgraphicsitem/conductor.cpp b/sources/qetgraphicsitem/conductor.cpp index fe7dfe7ec..f232bb825 100644 --- a/sources/qetgraphicsitem/conductor.cpp +++ b/sources/qetgraphicsitem/conductor.cpp @@ -39,9 +39,9 @@ QBrush Conductor::square_brush = QBrush(Qt::darkGreen); @param p2 Seconde Borne a laquelle le conducteur est lie @param parent_diagram QGraphicsScene a laquelle appartient le conducteur */ -Conductor::Conductor(Terminal *p1, Terminal* p2, Diagram *parent_diagram) : +Conductor::Conductor(Terminal *p1, Terminal* p2) : QObject(), - QGraphicsPathItem(0, parent_diagram), + QGraphicsPathItem(0), terminal1(p1), terminal2(p2), bMouseOver(false), diff --git a/sources/qetgraphicsitem/conductor.h b/sources/qetgraphicsitem/conductor.h index 3f0651f06..9b12d9d80 100644 --- a/sources/qetgraphicsitem/conductor.h +++ b/sources/qetgraphicsitem/conductor.h @@ -41,14 +41,14 @@ class Conductor : public QObject, public QGraphicsPathItem { Q_PROPERTY(QPointF pos READ pos WRITE setPos) Q_PROPERTY(int animPath READ fakePath WRITE updatePathAnimate) - // constructors, destructor + // constructors, destructor public: - Conductor(Terminal *, Terminal *, Diagram * = 0); - virtual ~Conductor(); + Conductor(Terminal *, Terminal *); + virtual ~Conductor(); private: - Conductor(const Conductor &); - + Conductor(const Conductor &); + // attributes public: enum { Type = UserType + 1001 }; diff --git a/sources/qetgraphicsitem/conductortextitem.cpp b/sources/qetgraphicsitem/conductortextitem.cpp index b4f3ac299..f9910ede3 100644 --- a/sources/qetgraphicsitem/conductortextitem.cpp +++ b/sources/qetgraphicsitem/conductortextitem.cpp @@ -25,8 +25,8 @@ @param parent_conductor Conducteur auquel ce texte est rattache @param parent_diagram Schema auquel ce texte et son conducteur parent sont rattaches */ -ConductorTextItem::ConductorTextItem(Conductor *parent_conductor, Diagram *parent_diagram) : - DiagramTextItem(parent_conductor, parent_diagram), +ConductorTextItem::ConductorTextItem(Conductor *parent_conductor) : + DiagramTextItem(parent_conductor), parent_conductor_(parent_conductor), moved_by_user_(false), rotate_by_user_(false) @@ -40,8 +40,8 @@ ConductorTextItem::ConductorTextItem(Conductor *parent_conductor, Diagram *paren @param parent_conductor Conducteur auquel ce texte est rattache @param parent_diagram Schema auquel ce texte et son conducteur parent sont rattaches */ -ConductorTextItem::ConductorTextItem(const QString &text, Conductor *parent_conductor, Diagram *parent_diagram) : - DiagramTextItem(text, parent_conductor, parent_diagram), +ConductorTextItem::ConductorTextItem(const QString &text, Conductor *parent_conductor) : + DiagramTextItem(text, parent_conductor), parent_conductor_(parent_conductor), moved_by_user_(false), rotate_by_user_(false) diff --git a/sources/qetgraphicsitem/conductortextitem.h b/sources/qetgraphicsitem/conductortextitem.h index a8335ee1a..55427d428 100644 --- a/sources/qetgraphicsitem/conductortextitem.h +++ b/sources/qetgraphicsitem/conductortextitem.h @@ -31,8 +31,8 @@ class ConductorTextItem : public DiagramTextItem { // constructors, destructor public: - ConductorTextItem(Conductor * = 0, Diagram * = 0); - ConductorTextItem(const QString &, Conductor * = 0, Diagram * = 0); + ConductorTextItem(Conductor * = 0); + ConductorTextItem(const QString &, Conductor * = 0); virtual ~ConductorTextItem(); private: ConductorTextItem(const ConductorTextItem &); diff --git a/sources/qetgraphicsitem/customelement.cpp b/sources/qetgraphicsitem/customelement.cpp index dd7fa5213..ff9bb0b72 100644 --- a/sources/qetgraphicsitem/customelement.cpp +++ b/sources/qetgraphicsitem/customelement.cpp @@ -44,8 +44,8 @@ - 7 : L'analyse d'un element XML decrivant une partie du dessin de l'element a echoue - 8 : Aucune partie du dessin n'a pu etre chargee */ -CustomElement::CustomElement(const ElementsLocation &location, QGraphicsItem *qgi, Diagram *s, int *state) : - FixedElement(qgi, s), +CustomElement::CustomElement(const ElementsLocation &location, QGraphicsItem *qgi, int *state) : + FixedElement(qgi), elmt_state(-1), location_(location), forbid_antialiasing(false) @@ -759,7 +759,7 @@ Terminal *CustomElement::parseTerminal(QDomElement &e) { else if (e.attribute("orientation") == "e") terminalo = Qet::East; else if (e.attribute("orientation") == "w") terminalo = Qet::West; else return(0); - Terminal *new_terminal = new Terminal(terminalx, terminaly, terminalo, this, qobject_cast(scene())); + 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 list_terminals << new_terminal; return(new_terminal); diff --git a/sources/qetgraphicsitem/customelement.h b/sources/qetgraphicsitem/customelement.h index c55cdf107..9ad567f88 100644 --- a/sources/qetgraphicsitem/customelement.h +++ b/sources/qetgraphicsitem/customelement.h @@ -36,7 +36,7 @@ class CustomElement : public FixedElement { // constructors, destructor public: - CustomElement(const ElementsLocation &, QGraphicsItem * = 0, Diagram * = 0, int * = 0); + CustomElement(const ElementsLocation &, QGraphicsItem * = 0, int * = 0); virtual ~CustomElement(); private: diff --git a/sources/qetgraphicsitem/diagramtextitem.cpp b/sources/qetgraphicsitem/diagramtextitem.cpp index ba94f601b..80176a4a7 100644 --- a/sources/qetgraphicsitem/diagramtextitem.cpp +++ b/sources/qetgraphicsitem/diagramtextitem.cpp @@ -26,8 +26,8 @@ @param parent Le QGraphicsItem parent du champ de texte @param parent_diagram Le schema auquel appartient le champ de texte */ -DiagramTextItem::DiagramTextItem(QGraphicsItem *parent, Diagram *parent_diagram) : - QGraphicsTextItem(parent, parent_diagram), +DiagramTextItem::DiagramTextItem(QGraphicsItem *parent) : + QGraphicsTextItem(parent), bMouseOver(false), previous_text_(), rotation_angle_(0.0), @@ -43,8 +43,8 @@ DiagramTextItem::DiagramTextItem(QGraphicsItem *parent, Diagram *parent_diagram) @param parent Le QGraphicsItem parent du champ de texte @param parent_diagram Le schema auquel appartient le champ de texte */ -DiagramTextItem::DiagramTextItem(const QString &text, QGraphicsItem *parent, Diagram *parent_diagram) : - QGraphicsTextItem(text, parent, parent_diagram), +DiagramTextItem::DiagramTextItem(const QString &text, QGraphicsItem *parent) : + QGraphicsTextItem(text, parent), bMouseOver(false), previous_text_(text), rotation_angle_(0.0) diff --git a/sources/qetgraphicsitem/diagramtextitem.h b/sources/qetgraphicsitem/diagramtextitem.h index 708d20f83..7e2a9fdbe 100644 --- a/sources/qetgraphicsitem/diagramtextitem.h +++ b/sources/qetgraphicsitem/diagramtextitem.h @@ -33,8 +33,8 @@ class DiagramTextItem : public QGraphicsTextItem { Q_OBJECT // constructors, destructor public: - DiagramTextItem(QGraphicsItem * = 0, Diagram * = 0); - DiagramTextItem(const QString &, QGraphicsItem * = 0, Diagram * = 0); + DiagramTextItem(QGraphicsItem * = 0); + DiagramTextItem(const QString &, QGraphicsItem * = 0); virtual ~DiagramTextItem(); private: diff --git a/sources/qetgraphicsitem/element.cpp b/sources/qetgraphicsitem/element.cpp index f790c1609..1413925cc 100644 --- a/sources/qetgraphicsitem/element.cpp +++ b/sources/qetgraphicsitem/element.cpp @@ -30,14 +30,12 @@ /** Constructeur pour un element sans scene ni parent */ -Element::Element(QGraphicsItem *parent, Diagram *scene) : +Element::Element(QGraphicsItem *parent) : QetGraphicsItem(parent), internal_connections_(false), must_highlight_(false), bMouseOver(false) { - Q_UNUSED(scene); - link_type_ = Simple; uuid_ = QUuid::createUuid(); setZValue(10); diff --git a/sources/qetgraphicsitem/element.h b/sources/qetgraphicsitem/element.h index 0e0070a8a..6bde6c15b 100644 --- a/sources/qetgraphicsitem/element.h +++ b/sources/qetgraphicsitem/element.h @@ -22,7 +22,6 @@ #include "qetgraphicsitem.h" #include "diagramcontext.h" -class Diagram; class ElementTextItem; class QETProject; class Terminal; @@ -31,29 +30,28 @@ class Conductor; /** This is the base class for electrical elements. */ -class Element : public QetGraphicsItem { - +class Element : public QetGraphicsItem { Q_OBJECT - // constructors, destructor + // constructors, destructor public: - Element(QGraphicsItem * = 0, Diagram * = 0); - virtual ~Element(); + Element(QGraphicsItem * = 0); + virtual ~Element(); private: - Element(const Element &); + Element(const Element &); - // attributes + // attributes public: - enum { Type = UserType + 1000 }; - // this enum is use to know the kind of element and - // to use flag for element provider class - enum kind {Simple = 1, - NextReport = 2, - PreviousReport = 4, - AllReport = 6, - Master = 8, - Slave = 16, - Terminale = 32}; + enum { Type = UserType + 1000 }; + // this enum is use to know the kind of element and + // to use flag for element provider class + enum kind {Simple = 1, + NextReport = 2, + PreviousReport = 4, + AllReport = 6, + Master = 8, + Slave = 16, + Terminale = 32}; private: QSize dimensions; diff --git a/sources/qetgraphicsitem/elementtextitem.cpp b/sources/qetgraphicsitem/elementtextitem.cpp index 549e28bef..716f5ebb4 100644 --- a/sources/qetgraphicsitem/elementtextitem.cpp +++ b/sources/qetgraphicsitem/elementtextitem.cpp @@ -26,8 +26,8 @@ @param parent_element Le QGraphicsItem parent du champ de texte @param parent_diagram Le schema auquel appartient le champ de texte */ -ElementTextItem::ElementTextItem(Element *parent_element, Diagram *parent_diagram) : - DiagramTextItem(parent_element, parent_diagram), +ElementTextItem::ElementTextItem(Element *parent_element) : + DiagramTextItem(parent_element), parent_element_(parent_element), follow_parent_rotations(false), original_rotation_angle_(0.0) @@ -39,8 +39,8 @@ ElementTextItem::ElementTextItem(Element *parent_element, Diagram *parent_diagra @param parent_diagram Le schema auquel appartient le champ de texte @param text Le texte affiche par le champ de texte */ -ElementTextItem::ElementTextItem(const QString &text, Element *parent_element, Diagram *parent_diagram) : - DiagramTextItem(text, parent_element, parent_diagram), +ElementTextItem::ElementTextItem(const QString &text, Element *parent_element) : + DiagramTextItem(text, parent_element), parent_element_(parent_element), follow_parent_rotations(false), original_rotation_angle_(0.0) diff --git a/sources/qetgraphicsitem/elementtextitem.h b/sources/qetgraphicsitem/elementtextitem.h index 6d8c20705..9eead8db0 100644 --- a/sources/qetgraphicsitem/elementtextitem.h +++ b/sources/qetgraphicsitem/elementtextitem.h @@ -20,7 +20,6 @@ #include "diagramtextitem.h" -class Diagram; class Element; /** @@ -32,8 +31,8 @@ class ElementTextItem : public DiagramTextItem { Q_OBJECT // constructors, destructor public: - ElementTextItem(Element * = 0, Diagram * = 0); - ElementTextItem(const QString &, Element * = 0, Diagram * = 0); + ElementTextItem(Element * = 0); + ElementTextItem(const QString &, Element * = 0); virtual ~ElementTextItem(); // attributes diff --git a/sources/qetgraphicsitem/fixedelement.cpp b/sources/qetgraphicsitem/fixedelement.cpp index 8184f9038..ec2d13504 100644 --- a/sources/qetgraphicsitem/fixedelement.cpp +++ b/sources/qetgraphicsitem/fixedelement.cpp @@ -19,7 +19,7 @@ /** Constructeur */ -FixedElement::FixedElement(QGraphicsItem *parent, Diagram *scene) : Element(parent, scene) { +FixedElement::FixedElement(QGraphicsItem *parent) : Element(parent) { } /** diff --git a/sources/qetgraphicsitem/fixedelement.h b/sources/qetgraphicsitem/fixedelement.h index 025a043a5..4df755c58 100644 --- a/sources/qetgraphicsitem/fixedelement.h +++ b/sources/qetgraphicsitem/fixedelement.h @@ -17,7 +17,9 @@ */ #ifndef ELEMENTFIXE_H #define ELEMENTFIXE_H + #include "element.h" + /** This class represents an element having a fixed number of terminals. */ @@ -27,7 +29,7 @@ class FixedElement : public Element { // constructors, destructor public: - FixedElement(QGraphicsItem * = 0, Diagram * = 0); + FixedElement(QGraphicsItem * = 0); virtual ~FixedElement(); // methods diff --git a/sources/qetgraphicsitem/ghostelement.cpp b/sources/qetgraphicsitem/ghostelement.cpp index 735c74f08..54c6e0453 100644 --- a/sources/qetgraphicsitem/ghostelement.cpp +++ b/sources/qetgraphicsitem/ghostelement.cpp @@ -29,10 +29,9 @@ */ GhostElement::GhostElement( const ElementsLocation &location, - QGraphicsItem *qgi, - Diagram *d + QGraphicsItem *qgi ) : - CustomElement(location, qgi, d) + CustomElement(location, qgi) { QString tooltip_string = QString( tr("\311l\351ment manquant\240: %1") diff --git a/sources/qetgraphicsitem/ghostelement.h b/sources/qetgraphicsitem/ghostelement.h index fe7c97aac..3c7b501ef 100644 --- a/sources/qetgraphicsitem/ghostelement.h +++ b/sources/qetgraphicsitem/ghostelement.h @@ -18,7 +18,6 @@ #ifndef GHOST_ELEMENT_H #define GHOST_ELEMENT_H #include "customelement.h" -class Diagram; class QGraphicsItem; class ElementsLocation; class Terminal; @@ -37,7 +36,7 @@ class GhostElement : public CustomElement { // constructor, destructor public: - GhostElement(const ElementsLocation &, QGraphicsItem * = 0, Diagram * = 0); + GhostElement(const ElementsLocation &, QGraphicsItem * = 0); virtual ~GhostElement(); // methods diff --git a/sources/qetgraphicsitem/independenttextitem.cpp b/sources/qetgraphicsitem/independenttextitem.cpp index b84f9b192..5b3354e35 100644 --- a/sources/qetgraphicsitem/independenttextitem.cpp +++ b/sources/qetgraphicsitem/independenttextitem.cpp @@ -22,8 +22,8 @@ Constructeur @param parent_diagram Le schema auquel est rattache le champ de texte */ -IndependentTextItem::IndependentTextItem(Diagram *parent_diagram) : - DiagramTextItem(0, parent_diagram) +IndependentTextItem::IndependentTextItem() : + DiagramTextItem(0) {} /** @@ -31,8 +31,8 @@ IndependentTextItem::IndependentTextItem(Diagram *parent_diagram) : @param text Le texte affiche par le champ de texte @param parent_diagram Le schema auquel est rattache le champ de texte */ -IndependentTextItem::IndependentTextItem(const QString &text, Diagram *parent_diagram) : - DiagramTextItem(text, 0, parent_diagram) +IndependentTextItem::IndependentTextItem(const QString &text) : + DiagramTextItem(text, 0) {} /// Destructeur diff --git a/sources/qetgraphicsitem/independenttextitem.h b/sources/qetgraphicsitem/independenttextitem.h index 7e10ad053..0809a74c5 100644 --- a/sources/qetgraphicsitem/independenttextitem.h +++ b/sources/qetgraphicsitem/independenttextitem.h @@ -28,8 +28,8 @@ class IndependentTextItem : public DiagramTextItem { Q_OBJECT // constructors, destructor public: - IndependentTextItem(Diagram * = 0); - IndependentTextItem(const QString &, Diagram* = 0); + IndependentTextItem(); + IndependentTextItem(const QString &); virtual ~IndependentTextItem(); // attributes diff --git a/sources/qetgraphicsitem/masterelement.cpp b/sources/qetgraphicsitem/masterelement.cpp index b3d47046b..5d488bd86 100644 --- a/sources/qetgraphicsitem/masterelement.cpp +++ b/sources/qetgraphicsitem/masterelement.cpp @@ -27,8 +27,8 @@ * @param s parent diagram * @param state int used to know if the creation of element have error */ -MasterElement::MasterElement(const ElementsLocation &location, QGraphicsItem *qgi, Diagram *s, int *state) : - CustomElement(location, qgi, s, state), +MasterElement::MasterElement(const ElementsLocation &location, QGraphicsItem *qgi, int *state) : + CustomElement(location, qgi, state), cri_ (nullptr) { link_type_ = Master; diff --git a/sources/qetgraphicsitem/masterelement.h b/sources/qetgraphicsitem/masterelement.h index 32d83916a..58b73cd39 100644 --- a/sources/qetgraphicsitem/masterelement.h +++ b/sources/qetgraphicsitem/masterelement.h @@ -33,7 +33,7 @@ class MasterElement : public CustomElement Q_OBJECT public: - explicit MasterElement(const ElementsLocation &, QGraphicsItem * = 0, Diagram * = 0, int * = 0); + explicit MasterElement(const ElementsLocation &, QGraphicsItem * = 0, int * = 0); ~MasterElement(); virtual void linkToElement (Element *elmt); diff --git a/sources/qetgraphicsitem/reportelement.cpp b/sources/qetgraphicsitem/reportelement.cpp index 6e9d1c073..d1b612434 100644 --- a/sources/qetgraphicsitem/reportelement.cpp +++ b/sources/qetgraphicsitem/reportelement.cpp @@ -21,17 +21,13 @@ #include "qetproject.h" #include "diagram.h" -ReportElement::ReportElement(const ElementsLocation &location, QString link_type,QGraphicsItem *qgi, Diagram *s, int *state) : - CustomElement(location, qgi, s, state) +ReportElement::ReportElement(const ElementsLocation &location, QString link_type,QGraphicsItem *qgi, int *state) : + CustomElement(location, qgi, state) { if (!texts().isEmpty()) texts().first()->setNoEditable(); link_type == "next_report"? link_type_=NextReport : link_type_=PreviousReport; link_type == "next_report"? inverse_report=PreviousReport : inverse_report=NextReport; - if (s) { - label_ = s->defaultReportProperties(); - connect(s, SIGNAL(reportPropertiesChanged(QString)), this, SLOT(setLabel(QString))); - } } ReportElement::~ReportElement() { @@ -44,22 +40,36 @@ ReportElement::~ReportElement() { * @param elmt * element to be linked with this */ -void ReportElement::linkToElement(Element * elmt) { - //ensure elmt isn't already linked - bool i=true; - if (!this->isFree()){ +void ReportElement::linkToElement(Element * elmt) +{ + if (!diagram() && !elmt -> diagram()) + { + qDebug() << "ReportElement : linkToElement : Unable to link this or element to link isn't in a diagram"; + return; + } + + //ensure elmt isn't already linked + bool i = true; + if (!this -> isFree()) + { if (connected_elements.first() == elmt) i = false; } - //ensure elmt is an inverse report of this element - if ((elmt->linkType() == inverse_report) && i) { + //ensure elmt is an inverse report of this element + if ((elmt->linkType() == inverse_report) && i) + { unlinkAllElements(); connected_elements << elmt; - connect(elmt, SIGNAL(xChanged()), this, SLOT(updateLabel())); - connect(elmt, SIGNAL(yChanged()), this, SLOT(updateLabel())); - connect(diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel())); + + connect(elmt, SIGNAL( xChanged() ), this, SLOT( updateLabel() )); + connect(elmt, SIGNAL( yChanged() ), this, SLOT( updateLabel() )); + connect(diagram(), SIGNAL( reportPropertiesChanged(QString) ), this, SLOT( setLabel(QString) )); + connect(diagram() -> project(), SIGNAL( projectDiagramsOrderChanged(QETProject*,int,int) ), this, SLOT( updateLabel() )); + + label_ = diagram() -> defaultReportProperties(); updateLabel(); - elmt->linkToElement(this); + + elmt -> linkToElement(this); } } diff --git a/sources/qetgraphicsitem/reportelement.h b/sources/qetgraphicsitem/reportelement.h index a3fd78348..b9505acf6 100644 --- a/sources/qetgraphicsitem/reportelement.h +++ b/sources/qetgraphicsitem/reportelement.h @@ -30,7 +30,7 @@ class ReportElement : public CustomElement { Q_OBJECT public : - explicit ReportElement(const ElementsLocation &,QString link_type, QGraphicsItem * = 0, Diagram * = 0, int * = 0); + explicit ReportElement(const ElementsLocation &,QString link_type, QGraphicsItem * = 0, int * = 0); ~ReportElement(); virtual void linkToElement(Element *); virtual void unlinkAllElements(); diff --git a/sources/qetgraphicsitem/simpleelement.cpp b/sources/qetgraphicsitem/simpleelement.cpp index a187efdb5..504015cfd 100644 --- a/sources/qetgraphicsitem/simpleelement.cpp +++ b/sources/qetgraphicsitem/simpleelement.cpp @@ -25,8 +25,8 @@ * @param s * @param state */ -SimpleElement::SimpleElement(const ElementsLocation &location, QGraphicsItem *qgi, Diagram *s, int *state) : - CustomElement(location, qgi, s, state), +SimpleElement::SimpleElement(const ElementsLocation &location, QGraphicsItem *qgi, int *state) : + CustomElement(location, qgi, state), m_comment_item (nullptr) { link_type_ = Simple; diff --git a/sources/qetgraphicsitem/simpleelement.h b/sources/qetgraphicsitem/simpleelement.h index 8b7c09c48..81ae18739 100644 --- a/sources/qetgraphicsitem/simpleelement.h +++ b/sources/qetgraphicsitem/simpleelement.h @@ -32,7 +32,7 @@ class SimpleElement : public CustomElement { Q_OBJECT public : - explicit SimpleElement(const ElementsLocation &, QGraphicsItem * = 0, Diagram * = 0, int * = 0); + explicit SimpleElement(const ElementsLocation &, QGraphicsItem * = 0, int * = 0); ~SimpleElement(); virtual void initLink(QETProject *project); diff --git a/sources/qetgraphicsitem/slaveelement.cpp b/sources/qetgraphicsitem/slaveelement.cpp index df159842a..746685b1b 100644 --- a/sources/qetgraphicsitem/slaveelement.cpp +++ b/sources/qetgraphicsitem/slaveelement.cpp @@ -29,8 +29,8 @@ * @param s parent diagram * @param state int used to know if the creation of element have error */ -SlaveElement::SlaveElement(const ElementsLocation &location, QGraphicsItem *qgi, Diagram *s, int *state) : - CustomElement(location, qgi, s, state) +SlaveElement::SlaveElement(const ElementsLocation &location, QGraphicsItem *qgi, int *state) : + CustomElement(location, qgi, state) { Xref_item = NULL; link_type_ = Slave; diff --git a/sources/qetgraphicsitem/slaveelement.h b/sources/qetgraphicsitem/slaveelement.h index 5b82f09d0..2d7d34b55 100644 --- a/sources/qetgraphicsitem/slaveelement.h +++ b/sources/qetgraphicsitem/slaveelement.h @@ -24,7 +24,7 @@ class SlaveElement : public CustomElement { Q_OBJECT public: - explicit SlaveElement (const ElementsLocation &, QGraphicsItem * = 0, Diagram * = 0, int * = 0); + explicit SlaveElement (const ElementsLocation &, QGraphicsItem * = 0, int * = 0); ~SlaveElement(); virtual void linkToElement(Element *elmt); virtual void unlinkAllElements(); diff --git a/sources/qetgraphicsitem/terminal.cpp b/sources/qetgraphicsitem/terminal.cpp index b033b2fdd..bf24b7019 100644 --- a/sources/qetgraphicsitem/terminal.cpp +++ b/sources/qetgraphicsitem/terminal.cpp @@ -76,8 +76,8 @@ void Terminal::init(QPointF pf, Qet::Orientation o, QString number, QString name @param e Element auquel cette borne appartient @param s Scene sur laquelle figure cette borne */ -Terminal::Terminal(QPointF pf, Qet::Orientation o, Element *e, Diagram *s) : - QGraphicsItem(e, s), +Terminal::Terminal(QPointF pf, Qet::Orientation o, Element *e) : + QGraphicsItem(e), parent_element_(e), hovered_color_(Terminal::neutralColor) { @@ -92,8 +92,8 @@ Terminal::Terminal(QPointF pf, Qet::Orientation o, Element *e, Diagram *s) : @param e Element auquel cette borne appartient @param s Scene sur laquelle figure cette borne */ -Terminal::Terminal(qreal pf_x, qreal pf_y, Qet::Orientation o, Element *e, Diagram *s) : - QGraphicsItem(e, s), +Terminal::Terminal(qreal pf_x, qreal pf_y, Qet::Orientation o, Element *e) : + QGraphicsItem(e), parent_element_(e), hovered_color_(Terminal::neutralColor) { @@ -110,8 +110,8 @@ Terminal::Terminal(qreal pf_x, qreal pf_y, Qet::Orientation o, Element *e, Diagr @param e Element auquel cette borne appartient @param s Scene sur laquelle figure cette borne */ -Terminal::Terminal(QPointF pf, Qet::Orientation o, QString num, QString name, bool hiddenName, Element *e, Diagram *s) : - QGraphicsItem(e, s), +Terminal::Terminal(QPointF pf, Qet::Orientation o, QString num, QString name, bool hiddenName, Element *e) : + QGraphicsItem(e), parent_element_(e), hovered_color_(Terminal::neutralColor) { diff --git a/sources/qetgraphicsitem/terminal.h b/sources/qetgraphicsitem/terminal.h index c690b2426..63200afc9 100644 --- a/sources/qetgraphicsitem/terminal.h +++ b/sources/qetgraphicsitem/terminal.h @@ -31,13 +31,13 @@ class Terminal : public QGraphicsItem { // constructors, destructor public: - Terminal(QPointF, Qet::Orientation, Element * = 0, Diagram * = 0); - Terminal(qreal, qreal, Qet::Orientation, Element * = 0, Diagram * = 0); - Terminal(QPointF, Qet::Orientation, QString number, QString name, bool hiddenName, Element * = 0, Diagram * = 0); - virtual ~Terminal(); + Terminal(QPointF, Qet::Orientation, Element * = 0); + Terminal(qreal, qreal, Qet::Orientation, Element * = 0); + Terminal(QPointF, Qet::Orientation, QString number, QString name, bool hiddenName, Element * = 0); + virtual ~Terminal(); private: - Terminal(const Terminal &); + Terminal(const Terminal &); // methods public: