mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Minor change according to the evolution of Qt class (remove QGraphicsScene from constructor of QGraphicsItem).
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3547 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -555,7 +555,7 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
|
|||||||
if (type_id.startsWith("embed://")) element_location.setProject(project_);
|
if (type_id.startsWith("embed://")) element_location.setProject(project_);
|
||||||
|
|
||||||
int state = 0;
|
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) {
|
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);
|
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);
|
qDebug() << qPrintable(debug_message);
|
||||||
@@ -579,7 +579,7 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
|
|||||||
// Load text
|
// Load text
|
||||||
QList<IndependentTextItem *> added_texts;
|
QList<IndependentTextItem *> added_texts;
|
||||||
foreach (QDomElement text_xml, QET::findInDomElement(root, "inputs", "input")) {
|
foreach (QDomElement text_xml, QET::findInDomElement(root, "inputs", "input")) {
|
||||||
IndependentTextItem *iti = new IndependentTextItem(this);
|
IndependentTextItem *iti = new IndependentTextItem();
|
||||||
iti -> fromXml(text_xml);
|
iti -> fromXml(text_xml);
|
||||||
addItem(iti);
|
addItem(iti);
|
||||||
added_texts << iti;
|
added_texts << iti;
|
||||||
@@ -623,8 +623,9 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (can_add_conductor) {
|
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);
|
c -> fromXml(f);
|
||||||
|
addItem(c);
|
||||||
added_conductors << c;
|
added_conductors << c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ void DiagramView::handleTitleBlockDrop(QDropEvent *e) {
|
|||||||
void DiagramView::handleTextDrop(QDropEvent *e) {
|
void DiagramView::handleTextDrop(QDropEvent *e) {
|
||||||
if (scene -> isReadOnly() || (e -> mimeData() -> hasText() == false) ) return;
|
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()) {
|
if (e -> mimeData() -> hasHtml()) {
|
||||||
iti -> setHtml (e -> mimeData() -> text());
|
iti -> setHtml (e -> mimeData() -> text());
|
||||||
@@ -863,7 +863,7 @@ bool DiagramView::mustIntegrateTitleBlockTemplate(const TitleBlockTemplateLocati
|
|||||||
bool DiagramView::addElementAtPos(const ElementsLocation &location, const QPoint &pos) {
|
bool DiagramView::addElementAtPos(const ElementsLocation &location, const QPoint &pos) {
|
||||||
// construit une instance de l'element correspondant a l'emplacement
|
// construit une instance de l'element correspondant a l'emplacement
|
||||||
int state;
|
int state;
|
||||||
Element *el = ElementFactory::Instance()->createElement(location, 0, diagram(), &state);
|
Element *el = ElementFactory::Instance()->createElement(location, 0, &state);
|
||||||
if (state) {
|
if (state) {
|
||||||
delete el;
|
delete el;
|
||||||
return(false);
|
return(false);
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ QPixmap ElementsCollectionCache::pixmap() const {
|
|||||||
*/
|
*/
|
||||||
bool ElementsCollectionCache::fetchData(const ElementsLocation &location) {
|
bool ElementsCollectionCache::fetchData(const ElementsLocation &location) {
|
||||||
int state;
|
int state;
|
||||||
Element *custom_elmt = ElementFactory::Instance()->createElement(location, 0, 0, &state);
|
Element *custom_elmt = ElementFactory::Instance() -> createElement(location, 0, &state);
|
||||||
if (state) {
|
if (state) {
|
||||||
qDebug() << "ElementsCollectionCache::fetchData() : Le chargement du composant" << qPrintable(location.toString()) << "a echoue avec le code d'erreur" << state;
|
qDebug() << "ElementsCollectionCache::fetchData() : Le chargement du composant" << qPrintable(location.toString()) << "a echoue avec le code d'erreur" << state;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -294,7 +294,7 @@ void ElementsPanel::startElementDrag(const ElementsLocation &location) {
|
|||||||
|
|
||||||
// element temporaire pour fournir un apercu
|
// element temporaire pour fournir un apercu
|
||||||
int elmt_creation_state;
|
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) {
|
if (elmt_creation_state) {
|
||||||
delete temp_elmt;
|
delete temp_elmt;
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -31,29 +31,31 @@ ElementFactory* ElementFactory::factory_ = 0;
|
|||||||
* @brief ElementFactory::createElement
|
* @brief ElementFactory::createElement
|
||||||
* @param location create element at this location
|
* @param location create element at this location
|
||||||
* @param qgi parent item for this elemnt
|
* @param qgi parent item for this elemnt
|
||||||
* @param s diagram of the element
|
|
||||||
* @param state state of the creation
|
* @param state state of the creation
|
||||||
* @return the element or 0
|
* @return the element or 0
|
||||||
*/
|
*/
|
||||||
Element * ElementFactory::createElement(const ElementsLocation &location, QGraphicsItem *qgi, Diagram *s, int *state) {
|
Element * ElementFactory::createElement(const ElementsLocation &location, QGraphicsItem *qgi, int *state)
|
||||||
// recupere la definition de l'element
|
{
|
||||||
|
// recupere la definition de l'element
|
||||||
ElementsCollectionItem *element_item = QETApp::collectionItem(location);
|
ElementsCollectionItem *element_item = QETApp::collectionItem(location);
|
||||||
ElementDefinition *element_definition;
|
ElementDefinition *element_definition;
|
||||||
if (!element_item ||\
|
if (!element_item ||\
|
||||||
!element_item -> isElement() ||\
|
!element_item -> isElement() ||\
|
||||||
!(element_definition = qobject_cast<ElementDefinition *>(element_item))) {
|
!(element_definition = qobject_cast<ElementDefinition *>(element_item)))
|
||||||
|
{
|
||||||
if (state) *state = 1;
|
if (state) *state = 1;
|
||||||
return 0;
|
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");
|
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 == "next_report" || link_type == "previous_report") return (new ReportElement(location, link_type, qgi, state));
|
||||||
if (link_type == "master") return (new MasterElement (location, qgi, s, state));
|
if (link_type == "master") return (new MasterElement (location, qgi, state));
|
||||||
if (link_type == "slave") return (new SlaveElement (location, qgi, s, state));
|
if (link_type == "slave") return (new SlaveElement (location, qgi, state));
|
||||||
if (link_type == "terminal") return (new TerminalElement (location, qgi, s, state));
|
if (link_type == "terminal") return (new TerminalElement (location, qgi, state));
|
||||||
}
|
}
|
||||||
|
|
||||||
//default if nothing match for link_type
|
//default if nothing match for link_type
|
||||||
return (new SimpleElement(location, qgi, s, state));
|
return (new SimpleElement(location, qgi, state));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,41 +33,43 @@ class Diagram;
|
|||||||
*/
|
*/
|
||||||
class ElementFactory
|
class ElementFactory
|
||||||
{
|
{
|
||||||
//methods for singleton pattern
|
//methods for singleton pattern
|
||||||
public:
|
public:
|
||||||
// return instance of factory
|
// return instance of factory
|
||||||
static ElementFactory* Instance() {
|
static ElementFactory* Instance() {
|
||||||
static QMutex mutex;
|
static QMutex mutex;
|
||||||
if (!factory_) {
|
if (!factory_) {
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
if (!factory_) factory_ = new ElementFactory();
|
if (!factory_) factory_ = new ElementFactory();
|
||||||
mutex.unlock();
|
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:
|
private:
|
||||||
ElementFactory() {}
|
static ElementFactory* factory_;
|
||||||
ElementFactory (const ElementFactory &);
|
|
||||||
ElementFactory operator= (const ElementFactory &);
|
//methods for the class factory himself
|
||||||
~ElementFactory() {}
|
private:
|
||||||
|
ElementFactory() {}
|
||||||
|
ElementFactory (const ElementFactory &);
|
||||||
|
ElementFactory operator= (const ElementFactory &);
|
||||||
|
~ElementFactory() {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Element * createElement (const ElementsLocation &, QGraphicsItem * = 0, Diagram * = 0, int * = 0);
|
Element * createElement (const ElementsLocation &, QGraphicsItem * = 0, int * = 0);
|
||||||
};
|
};
|
||||||
//ElementFactory ElementFactory::factory_ = 0;
|
//ElementFactory ElementFactory::factory_ = 0;
|
||||||
#endif // ELEMENTFACTORY_H
|
#endif // ELEMENTFACTORY_H
|
||||||
|
|||||||
@@ -39,9 +39,9 @@ QBrush Conductor::square_brush = QBrush(Qt::darkGreen);
|
|||||||
@param p2 Seconde Borne a laquelle le conducteur est lie
|
@param p2 Seconde Borne a laquelle le conducteur est lie
|
||||||
@param parent_diagram QGraphicsScene a laquelle appartient le conducteur
|
@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(),
|
QObject(),
|
||||||
QGraphicsPathItem(0, parent_diagram),
|
QGraphicsPathItem(0),
|
||||||
terminal1(p1),
|
terminal1(p1),
|
||||||
terminal2(p2),
|
terminal2(p2),
|
||||||
bMouseOver(false),
|
bMouseOver(false),
|
||||||
|
|||||||
@@ -41,14 +41,14 @@ class Conductor : public QObject, public QGraphicsPathItem {
|
|||||||
Q_PROPERTY(QPointF pos READ pos WRITE setPos)
|
Q_PROPERTY(QPointF pos READ pos WRITE setPos)
|
||||||
Q_PROPERTY(int animPath READ fakePath WRITE updatePathAnimate)
|
Q_PROPERTY(int animPath READ fakePath WRITE updatePathAnimate)
|
||||||
|
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
Conductor(Terminal *, Terminal *, Diagram * = 0);
|
Conductor(Terminal *, Terminal *);
|
||||||
virtual ~Conductor();
|
virtual ~Conductor();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Conductor(const Conductor &);
|
Conductor(const Conductor &);
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
public:
|
public:
|
||||||
enum { Type = UserType + 1001 };
|
enum { Type = UserType + 1001 };
|
||||||
|
|||||||
@@ -25,8 +25,8 @@
|
|||||||
@param parent_conductor Conducteur auquel ce texte est rattache
|
@param parent_conductor Conducteur auquel ce texte est rattache
|
||||||
@param parent_diagram Schema auquel ce texte et son conducteur parent sont rattaches
|
@param parent_diagram Schema auquel ce texte et son conducteur parent sont rattaches
|
||||||
*/
|
*/
|
||||||
ConductorTextItem::ConductorTextItem(Conductor *parent_conductor, Diagram *parent_diagram) :
|
ConductorTextItem::ConductorTextItem(Conductor *parent_conductor) :
|
||||||
DiagramTextItem(parent_conductor, parent_diagram),
|
DiagramTextItem(parent_conductor),
|
||||||
parent_conductor_(parent_conductor),
|
parent_conductor_(parent_conductor),
|
||||||
moved_by_user_(false),
|
moved_by_user_(false),
|
||||||
rotate_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_conductor Conducteur auquel ce texte est rattache
|
||||||
@param parent_diagram Schema auquel ce texte et son conducteur parent sont rattaches
|
@param parent_diagram Schema auquel ce texte et son conducteur parent sont rattaches
|
||||||
*/
|
*/
|
||||||
ConductorTextItem::ConductorTextItem(const QString &text, Conductor *parent_conductor, Diagram *parent_diagram) :
|
ConductorTextItem::ConductorTextItem(const QString &text, Conductor *parent_conductor) :
|
||||||
DiagramTextItem(text, parent_conductor, parent_diagram),
|
DiagramTextItem(text, parent_conductor),
|
||||||
parent_conductor_(parent_conductor),
|
parent_conductor_(parent_conductor),
|
||||||
moved_by_user_(false),
|
moved_by_user_(false),
|
||||||
rotate_by_user_(false)
|
rotate_by_user_(false)
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ class ConductorTextItem : public DiagramTextItem {
|
|||||||
|
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
ConductorTextItem(Conductor * = 0, Diagram * = 0);
|
ConductorTextItem(Conductor * = 0);
|
||||||
ConductorTextItem(const QString &, Conductor * = 0, Diagram * = 0);
|
ConductorTextItem(const QString &, Conductor * = 0);
|
||||||
virtual ~ConductorTextItem();
|
virtual ~ConductorTextItem();
|
||||||
private:
|
private:
|
||||||
ConductorTextItem(const ConductorTextItem &);
|
ConductorTextItem(const ConductorTextItem &);
|
||||||
|
|||||||
@@ -44,8 +44,8 @@
|
|||||||
- 7 : L'analyse d'un element XML decrivant une partie du dessin de l'element a echoue
|
- 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
|
- 8 : Aucune partie du dessin n'a pu etre chargee
|
||||||
*/
|
*/
|
||||||
CustomElement::CustomElement(const ElementsLocation &location, QGraphicsItem *qgi, Diagram *s, int *state) :
|
CustomElement::CustomElement(const ElementsLocation &location, QGraphicsItem *qgi, int *state) :
|
||||||
FixedElement(qgi, s),
|
FixedElement(qgi),
|
||||||
elmt_state(-1),
|
elmt_state(-1),
|
||||||
location_(location),
|
location_(location),
|
||||||
forbid_antialiasing(false)
|
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") == "e") terminalo = Qet::East;
|
||||||
else if (e.attribute("orientation") == "w") terminalo = Qet::West;
|
else if (e.attribute("orientation") == "w") terminalo = Qet::West;
|
||||||
else return(0);
|
else return(0);
|
||||||
Terminal *new_terminal = new Terminal(terminalx, terminaly, terminalo, this, qobject_cast<Diagram *>(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
|
new_terminal -> setZValue(420); // valeur arbitraire pour maintenir les bornes au-dessus des champs de texte
|
||||||
list_terminals << new_terminal;
|
list_terminals << new_terminal;
|
||||||
return(new_terminal);
|
return(new_terminal);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class CustomElement : public FixedElement {
|
|||||||
|
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
CustomElement(const ElementsLocation &, QGraphicsItem * = 0, Diagram * = 0, int * = 0);
|
CustomElement(const ElementsLocation &, QGraphicsItem * = 0, int * = 0);
|
||||||
virtual ~CustomElement();
|
virtual ~CustomElement();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -26,8 +26,8 @@
|
|||||||
@param parent Le QGraphicsItem parent du champ de texte
|
@param parent Le QGraphicsItem parent du champ de texte
|
||||||
@param parent_diagram Le schema auquel appartient le champ de texte
|
@param parent_diagram Le schema auquel appartient le champ de texte
|
||||||
*/
|
*/
|
||||||
DiagramTextItem::DiagramTextItem(QGraphicsItem *parent, Diagram *parent_diagram) :
|
DiagramTextItem::DiagramTextItem(QGraphicsItem *parent) :
|
||||||
QGraphicsTextItem(parent, parent_diagram),
|
QGraphicsTextItem(parent),
|
||||||
bMouseOver(false),
|
bMouseOver(false),
|
||||||
previous_text_(),
|
previous_text_(),
|
||||||
rotation_angle_(0.0),
|
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 Le QGraphicsItem parent du champ de texte
|
||||||
@param parent_diagram Le schema auquel appartient le champ de texte
|
@param parent_diagram Le schema auquel appartient le champ de texte
|
||||||
*/
|
*/
|
||||||
DiagramTextItem::DiagramTextItem(const QString &text, QGraphicsItem *parent, Diagram *parent_diagram) :
|
DiagramTextItem::DiagramTextItem(const QString &text, QGraphicsItem *parent) :
|
||||||
QGraphicsTextItem(text, parent, parent_diagram),
|
QGraphicsTextItem(text, parent),
|
||||||
bMouseOver(false),
|
bMouseOver(false),
|
||||||
previous_text_(text),
|
previous_text_(text),
|
||||||
rotation_angle_(0.0)
|
rotation_angle_(0.0)
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ class DiagramTextItem : public QGraphicsTextItem {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
DiagramTextItem(QGraphicsItem * = 0, Diagram * = 0);
|
DiagramTextItem(QGraphicsItem * = 0);
|
||||||
DiagramTextItem(const QString &, QGraphicsItem * = 0, Diagram * = 0);
|
DiagramTextItem(const QString &, QGraphicsItem * = 0);
|
||||||
virtual ~DiagramTextItem();
|
virtual ~DiagramTextItem();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -30,14 +30,12 @@
|
|||||||
/**
|
/**
|
||||||
Constructeur pour un element sans scene ni parent
|
Constructeur pour un element sans scene ni parent
|
||||||
*/
|
*/
|
||||||
Element::Element(QGraphicsItem *parent, Diagram *scene) :
|
Element::Element(QGraphicsItem *parent) :
|
||||||
QetGraphicsItem(parent),
|
QetGraphicsItem(parent),
|
||||||
internal_connections_(false),
|
internal_connections_(false),
|
||||||
must_highlight_(false),
|
must_highlight_(false),
|
||||||
bMouseOver(false)
|
bMouseOver(false)
|
||||||
{
|
{
|
||||||
Q_UNUSED(scene);
|
|
||||||
|
|
||||||
link_type_ = Simple;
|
link_type_ = Simple;
|
||||||
uuid_ = QUuid::createUuid();
|
uuid_ = QUuid::createUuid();
|
||||||
setZValue(10);
|
setZValue(10);
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
#include "qetgraphicsitem.h"
|
#include "qetgraphicsitem.h"
|
||||||
#include "diagramcontext.h"
|
#include "diagramcontext.h"
|
||||||
|
|
||||||
class Diagram;
|
|
||||||
class ElementTextItem;
|
class ElementTextItem;
|
||||||
class QETProject;
|
class QETProject;
|
||||||
class Terminal;
|
class Terminal;
|
||||||
@@ -31,29 +30,28 @@ class Conductor;
|
|||||||
/**
|
/**
|
||||||
This is the base class for electrical elements.
|
This is the base class for electrical elements.
|
||||||
*/
|
*/
|
||||||
class Element : public QetGraphicsItem {
|
class Element : public QetGraphicsItem {
|
||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
Element(QGraphicsItem * = 0, Diagram * = 0);
|
Element(QGraphicsItem * = 0);
|
||||||
virtual ~Element();
|
virtual ~Element();
|
||||||
private:
|
private:
|
||||||
Element(const Element &);
|
Element(const Element &);
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
public:
|
public:
|
||||||
enum { Type = UserType + 1000 };
|
enum { Type = UserType + 1000 };
|
||||||
// this enum is use to know the kind of element and
|
// this enum is use to know the kind of element and
|
||||||
// to use flag for element provider class
|
// to use flag for element provider class
|
||||||
enum kind {Simple = 1,
|
enum kind {Simple = 1,
|
||||||
NextReport = 2,
|
NextReport = 2,
|
||||||
PreviousReport = 4,
|
PreviousReport = 4,
|
||||||
AllReport = 6,
|
AllReport = 6,
|
||||||
Master = 8,
|
Master = 8,
|
||||||
Slave = 16,
|
Slave = 16,
|
||||||
Terminale = 32};
|
Terminale = 32};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSize dimensions;
|
QSize dimensions;
|
||||||
|
|||||||
@@ -26,8 +26,8 @@
|
|||||||
@param parent_element Le QGraphicsItem parent du champ de texte
|
@param parent_element Le QGraphicsItem parent du champ de texte
|
||||||
@param parent_diagram Le schema auquel appartient le champ de texte
|
@param parent_diagram Le schema auquel appartient le champ de texte
|
||||||
*/
|
*/
|
||||||
ElementTextItem::ElementTextItem(Element *parent_element, Diagram *parent_diagram) :
|
ElementTextItem::ElementTextItem(Element *parent_element) :
|
||||||
DiagramTextItem(parent_element, parent_diagram),
|
DiagramTextItem(parent_element),
|
||||||
parent_element_(parent_element),
|
parent_element_(parent_element),
|
||||||
follow_parent_rotations(false),
|
follow_parent_rotations(false),
|
||||||
original_rotation_angle_(0.0)
|
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 parent_diagram Le schema auquel appartient le champ de texte
|
||||||
@param text Le texte affiche par 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) :
|
ElementTextItem::ElementTextItem(const QString &text, Element *parent_element) :
|
||||||
DiagramTextItem(text, parent_element, parent_diagram),
|
DiagramTextItem(text, parent_element),
|
||||||
parent_element_(parent_element),
|
parent_element_(parent_element),
|
||||||
follow_parent_rotations(false),
|
follow_parent_rotations(false),
|
||||||
original_rotation_angle_(0.0)
|
original_rotation_angle_(0.0)
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#include "diagramtextitem.h"
|
#include "diagramtextitem.h"
|
||||||
|
|
||||||
class Diagram;
|
|
||||||
class Element;
|
class Element;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,8 +31,8 @@ class ElementTextItem : public DiagramTextItem {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
ElementTextItem(Element * = 0, Diagram * = 0);
|
ElementTextItem(Element * = 0);
|
||||||
ElementTextItem(const QString &, Element * = 0, Diagram * = 0);
|
ElementTextItem(const QString &, Element * = 0);
|
||||||
virtual ~ElementTextItem();
|
virtual ~ElementTextItem();
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
/**
|
/**
|
||||||
Constructeur
|
Constructeur
|
||||||
*/
|
*/
|
||||||
FixedElement::FixedElement(QGraphicsItem *parent, Diagram *scene) : Element(parent, scene) {
|
FixedElement::FixedElement(QGraphicsItem *parent) : Element(parent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -17,7 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
#ifndef ELEMENTFIXE_H
|
#ifndef ELEMENTFIXE_H
|
||||||
#define ELEMENTFIXE_H
|
#define ELEMENTFIXE_H
|
||||||
|
|
||||||
#include "element.h"
|
#include "element.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This class represents an element having a fixed number of terminals.
|
This class represents an element having a fixed number of terminals.
|
||||||
*/
|
*/
|
||||||
@@ -27,7 +29,7 @@ class FixedElement : public Element {
|
|||||||
|
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
FixedElement(QGraphicsItem * = 0, Diagram * = 0);
|
FixedElement(QGraphicsItem * = 0);
|
||||||
virtual ~FixedElement();
|
virtual ~FixedElement();
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
|
|||||||
@@ -29,10 +29,9 @@
|
|||||||
*/
|
*/
|
||||||
GhostElement::GhostElement(
|
GhostElement::GhostElement(
|
||||||
const ElementsLocation &location,
|
const ElementsLocation &location,
|
||||||
QGraphicsItem *qgi,
|
QGraphicsItem *qgi
|
||||||
Diagram *d
|
|
||||||
) :
|
) :
|
||||||
CustomElement(location, qgi, d)
|
CustomElement(location, qgi)
|
||||||
{
|
{
|
||||||
QString tooltip_string = QString(
|
QString tooltip_string = QString(
|
||||||
tr("<u>\311l\351ment manquant\240:</u> %1")
|
tr("<u>\311l\351ment manquant\240:</u> %1")
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
#ifndef GHOST_ELEMENT_H
|
#ifndef GHOST_ELEMENT_H
|
||||||
#define GHOST_ELEMENT_H
|
#define GHOST_ELEMENT_H
|
||||||
#include "customelement.h"
|
#include "customelement.h"
|
||||||
class Diagram;
|
|
||||||
class QGraphicsItem;
|
class QGraphicsItem;
|
||||||
class ElementsLocation;
|
class ElementsLocation;
|
||||||
class Terminal;
|
class Terminal;
|
||||||
@@ -37,7 +36,7 @@ class GhostElement : public CustomElement {
|
|||||||
|
|
||||||
// constructor, destructor
|
// constructor, destructor
|
||||||
public:
|
public:
|
||||||
GhostElement(const ElementsLocation &, QGraphicsItem * = 0, Diagram * = 0);
|
GhostElement(const ElementsLocation &, QGraphicsItem * = 0);
|
||||||
virtual ~GhostElement();
|
virtual ~GhostElement();
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
|
|||||||
@@ -22,8 +22,8 @@
|
|||||||
Constructeur
|
Constructeur
|
||||||
@param parent_diagram Le schema auquel est rattache le champ de texte
|
@param parent_diagram Le schema auquel est rattache le champ de texte
|
||||||
*/
|
*/
|
||||||
IndependentTextItem::IndependentTextItem(Diagram *parent_diagram) :
|
IndependentTextItem::IndependentTextItem() :
|
||||||
DiagramTextItem(0, parent_diagram)
|
DiagramTextItem(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,8 +31,8 @@ IndependentTextItem::IndependentTextItem(Diagram *parent_diagram) :
|
|||||||
@param text Le texte affiche par le champ de texte
|
@param text Le texte affiche par le champ de texte
|
||||||
@param parent_diagram Le schema auquel est rattache le champ de texte
|
@param parent_diagram Le schema auquel est rattache le champ de texte
|
||||||
*/
|
*/
|
||||||
IndependentTextItem::IndependentTextItem(const QString &text, Diagram *parent_diagram) :
|
IndependentTextItem::IndependentTextItem(const QString &text) :
|
||||||
DiagramTextItem(text, 0, parent_diagram)
|
DiagramTextItem(text, 0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/// Destructeur
|
/// Destructeur
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ class IndependentTextItem : public DiagramTextItem {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
IndependentTextItem(Diagram * = 0);
|
IndependentTextItem();
|
||||||
IndependentTextItem(const QString &, Diagram* = 0);
|
IndependentTextItem(const QString &);
|
||||||
virtual ~IndependentTextItem();
|
virtual ~IndependentTextItem();
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
|
|||||||
@@ -27,8 +27,8 @@
|
|||||||
* @param s parent diagram
|
* @param s parent diagram
|
||||||
* @param state int used to know if the creation of element have error
|
* @param state int used to know if the creation of element have error
|
||||||
*/
|
*/
|
||||||
MasterElement::MasterElement(const ElementsLocation &location, QGraphicsItem *qgi, Diagram *s, int *state) :
|
MasterElement::MasterElement(const ElementsLocation &location, QGraphicsItem *qgi, int *state) :
|
||||||
CustomElement(location, qgi, s, state),
|
CustomElement(location, qgi, state),
|
||||||
cri_ (nullptr)
|
cri_ (nullptr)
|
||||||
{
|
{
|
||||||
link_type_ = Master;
|
link_type_ = Master;
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class MasterElement : public CustomElement
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MasterElement(const ElementsLocation &, QGraphicsItem * = 0, Diagram * = 0, int * = 0);
|
explicit MasterElement(const ElementsLocation &, QGraphicsItem * = 0, int * = 0);
|
||||||
~MasterElement();
|
~MasterElement();
|
||||||
|
|
||||||
virtual void linkToElement (Element *elmt);
|
virtual void linkToElement (Element *elmt);
|
||||||
|
|||||||
@@ -21,17 +21,13 @@
|
|||||||
#include "qetproject.h"
|
#include "qetproject.h"
|
||||||
#include "diagram.h"
|
#include "diagram.h"
|
||||||
|
|
||||||
ReportElement::ReportElement(const ElementsLocation &location, QString link_type,QGraphicsItem *qgi, Diagram *s, int *state) :
|
ReportElement::ReportElement(const ElementsLocation &location, QString link_type,QGraphicsItem *qgi, int *state) :
|
||||||
CustomElement(location, qgi, s, state)
|
CustomElement(location, qgi, state)
|
||||||
{
|
{
|
||||||
if (!texts().isEmpty())
|
if (!texts().isEmpty())
|
||||||
texts().first()->setNoEditable();
|
texts().first()->setNoEditable();
|
||||||
link_type == "next_report"? link_type_=NextReport : link_type_=PreviousReport;
|
link_type == "next_report"? link_type_=NextReport : link_type_=PreviousReport;
|
||||||
link_type == "next_report"? inverse_report=PreviousReport : inverse_report=NextReport;
|
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() {
|
ReportElement::~ReportElement() {
|
||||||
@@ -44,22 +40,36 @@ ReportElement::~ReportElement() {
|
|||||||
* @param elmt
|
* @param elmt
|
||||||
* element to be linked with this
|
* element to be linked with this
|
||||||
*/
|
*/
|
||||||
void ReportElement::linkToElement(Element * elmt) {
|
void ReportElement::linkToElement(Element * elmt)
|
||||||
//ensure elmt isn't already linked
|
{
|
||||||
bool i=true;
|
if (!diagram() && !elmt -> diagram())
|
||||||
if (!this->isFree()){
|
{
|
||||||
|
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;
|
if (connected_elements.first() == elmt) i = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//ensure elmt is an inverse report of this element
|
//ensure elmt is an inverse report of this element
|
||||||
if ((elmt->linkType() == inverse_report) && i) {
|
if ((elmt->linkType() == inverse_report) && i)
|
||||||
|
{
|
||||||
unlinkAllElements();
|
unlinkAllElements();
|
||||||
connected_elements << elmt;
|
connected_elements << elmt;
|
||||||
connect(elmt, SIGNAL(xChanged()), this, SLOT(updateLabel()));
|
|
||||||
connect(elmt, SIGNAL(yChanged()), this, SLOT(updateLabel()));
|
connect(elmt, SIGNAL( xChanged() ), this, SLOT( updateLabel() ));
|
||||||
connect(diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), 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();
|
updateLabel();
|
||||||
elmt->linkToElement(this);
|
|
||||||
|
elmt -> linkToElement(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class ReportElement : public CustomElement {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public :
|
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();
|
~ReportElement();
|
||||||
virtual void linkToElement(Element *);
|
virtual void linkToElement(Element *);
|
||||||
virtual void unlinkAllElements();
|
virtual void unlinkAllElements();
|
||||||
|
|||||||
@@ -25,8 +25,8 @@
|
|||||||
* @param s
|
* @param s
|
||||||
* @param state
|
* @param state
|
||||||
*/
|
*/
|
||||||
SimpleElement::SimpleElement(const ElementsLocation &location, QGraphicsItem *qgi, Diagram *s, int *state) :
|
SimpleElement::SimpleElement(const ElementsLocation &location, QGraphicsItem *qgi, int *state) :
|
||||||
CustomElement(location, qgi, s, state),
|
CustomElement(location, qgi, state),
|
||||||
m_comment_item (nullptr)
|
m_comment_item (nullptr)
|
||||||
{
|
{
|
||||||
link_type_ = Simple;
|
link_type_ = Simple;
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class SimpleElement : public CustomElement {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public :
|
public :
|
||||||
explicit SimpleElement(const ElementsLocation &, QGraphicsItem * = 0, Diagram * = 0, int * = 0);
|
explicit SimpleElement(const ElementsLocation &, QGraphicsItem * = 0, int * = 0);
|
||||||
~SimpleElement();
|
~SimpleElement();
|
||||||
|
|
||||||
virtual void initLink(QETProject *project);
|
virtual void initLink(QETProject *project);
|
||||||
|
|||||||
@@ -29,8 +29,8 @@
|
|||||||
* @param s parent diagram
|
* @param s parent diagram
|
||||||
* @param state int used to know if the creation of element have error
|
* @param state int used to know if the creation of element have error
|
||||||
*/
|
*/
|
||||||
SlaveElement::SlaveElement(const ElementsLocation &location, QGraphicsItem *qgi, Diagram *s, int *state) :
|
SlaveElement::SlaveElement(const ElementsLocation &location, QGraphicsItem *qgi, int *state) :
|
||||||
CustomElement(location, qgi, s, state)
|
CustomElement(location, qgi, state)
|
||||||
{
|
{
|
||||||
Xref_item = NULL;
|
Xref_item = NULL;
|
||||||
link_type_ = Slave;
|
link_type_ = Slave;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class SlaveElement : public CustomElement
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit SlaveElement (const ElementsLocation &, QGraphicsItem * = 0, Diagram * = 0, int * = 0);
|
explicit SlaveElement (const ElementsLocation &, QGraphicsItem * = 0, int * = 0);
|
||||||
~SlaveElement();
|
~SlaveElement();
|
||||||
virtual void linkToElement(Element *elmt);
|
virtual void linkToElement(Element *elmt);
|
||||||
virtual void unlinkAllElements();
|
virtual void unlinkAllElements();
|
||||||
|
|||||||
@@ -76,8 +76,8 @@ void Terminal::init(QPointF pf, Qet::Orientation o, QString number, QString name
|
|||||||
@param e Element auquel cette borne appartient
|
@param e Element auquel cette borne appartient
|
||||||
@param s Scene sur laquelle figure cette borne
|
@param s Scene sur laquelle figure cette borne
|
||||||
*/
|
*/
|
||||||
Terminal::Terminal(QPointF pf, Qet::Orientation o, Element *e, Diagram *s) :
|
Terminal::Terminal(QPointF pf, Qet::Orientation o, Element *e) :
|
||||||
QGraphicsItem(e, s),
|
QGraphicsItem(e),
|
||||||
parent_element_(e),
|
parent_element_(e),
|
||||||
hovered_color_(Terminal::neutralColor)
|
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 e Element auquel cette borne appartient
|
||||||
@param s Scene sur laquelle figure cette borne
|
@param s Scene sur laquelle figure cette borne
|
||||||
*/
|
*/
|
||||||
Terminal::Terminal(qreal pf_x, qreal pf_y, Qet::Orientation o, Element *e, Diagram *s) :
|
Terminal::Terminal(qreal pf_x, qreal pf_y, Qet::Orientation o, Element *e) :
|
||||||
QGraphicsItem(e, s),
|
QGraphicsItem(e),
|
||||||
parent_element_(e),
|
parent_element_(e),
|
||||||
hovered_color_(Terminal::neutralColor)
|
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 e Element auquel cette borne appartient
|
||||||
@param s Scene sur laquelle figure cette borne
|
@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) :
|
Terminal::Terminal(QPointF pf, Qet::Orientation o, QString num, QString name, bool hiddenName, Element *e) :
|
||||||
QGraphicsItem(e, s),
|
QGraphicsItem(e),
|
||||||
parent_element_(e),
|
parent_element_(e),
|
||||||
hovered_color_(Terminal::neutralColor)
|
hovered_color_(Terminal::neutralColor)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,13 +31,13 @@ class Terminal : public QGraphicsItem {
|
|||||||
|
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
Terminal(QPointF, Qet::Orientation, Element * = 0, Diagram * = 0);
|
Terminal(QPointF, Qet::Orientation, Element * = 0);
|
||||||
Terminal(qreal, qreal, Qet::Orientation, Element * = 0, Diagram * = 0);
|
Terminal(qreal, qreal, Qet::Orientation, Element * = 0);
|
||||||
Terminal(QPointF, Qet::Orientation, QString number, QString name, bool hiddenName, Element * = 0, Diagram * = 0);
|
Terminal(QPointF, Qet::Orientation, QString number, QString name, bool hiddenName, Element * = 0);
|
||||||
virtual ~Terminal();
|
virtual ~Terminal();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Terminal(const Terminal &);
|
Terminal(const Terminal &);
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user