mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-04-30 01:39:59 +02:00
Add ability to store informations for element like label, manufacturer, ref etc....
Add widget to edit it, save/load works Informations are stored in a diagramcontext, this class was modified (new feature) to store information but keep compatibilty with older version. git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2850 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#include <QtDebug>
|
||||
#include <ui/elementpropertieswidget.h>
|
||||
#include "elementprovider.h"
|
||||
#include "elementsproperties.h"
|
||||
|
||||
/**
|
||||
Constructeur pour un element sans scene ni parent
|
||||
@@ -395,6 +396,9 @@ bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr, bool
|
||||
//uuid of this element
|
||||
uuid_= QUuid(e.attribute("uuid", QUuid::createUuid().toString()));
|
||||
|
||||
//load informations
|
||||
informations_.fromXml(e.firstChildElement("informations"), "information");
|
||||
|
||||
// position, selection
|
||||
setPos(e.attribute("x").toDouble(), e.attribute("y").toDouble());
|
||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||
@@ -473,6 +477,11 @@ QDomElement Element::toXml(QDomDocument &document, QHash<Terminal *, int> &table
|
||||
}
|
||||
element.appendChild(links_uuids);
|
||||
}
|
||||
|
||||
//save information of this element
|
||||
QDomElement infos = document.createElement("informations");
|
||||
informations_.toXml(infos, "information");
|
||||
element.appendChild(infos);
|
||||
|
||||
return(element);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "terminal.h"
|
||||
#include "qetgraphicsitem.h"
|
||||
#include <QUuid>
|
||||
#include "elementsproperties.h"
|
||||
class Diagram;
|
||||
class ElementTextItem;
|
||||
|
||||
@@ -35,8 +36,7 @@ class Element : public QetGraphicsItem {
|
||||
// constructors, destructor
|
||||
public:
|
||||
Element(QGraphicsItem * = 0, Diagram * = 0);
|
||||
virtual ~Element();
|
||||
|
||||
virtual ~Element();
|
||||
private:
|
||||
Element(const Element &);
|
||||
|
||||
@@ -55,15 +55,11 @@ class Element : public QetGraphicsItem {
|
||||
AllSlave = 48,
|
||||
Bornier = 64};
|
||||
|
||||
protected:
|
||||
QList <Element *> connected_elements;
|
||||
QList <QUuid> tmp_uuids_link;
|
||||
|
||||
private:
|
||||
QSize dimensions;
|
||||
QPoint hotspot_coord;
|
||||
QPixmap preview;
|
||||
QUuid uuid_;
|
||||
|
||||
|
||||
// methods
|
||||
public:
|
||||
@@ -98,19 +94,41 @@ class Element : public QetGraphicsItem {
|
||||
/// @return the maximum number of terminals for this element
|
||||
virtual int maxTerminalsCount() const = 0;
|
||||
|
||||
// related method for link between element
|
||||
|
||||
/**
|
||||
*related method and attributes,
|
||||
*about none graphic thing
|
||||
*like the linked element or information about this element
|
||||
*/
|
||||
//METHODS related to linked element
|
||||
public:
|
||||
bool isFree () const;
|
||||
virtual void linkToElement(Element *) {}
|
||||
virtual void unlinkAllElements() {}
|
||||
virtual void unlinkElement(Element *elmt) {}
|
||||
virtual void unlinkElement(Element *) {}
|
||||
void initLink(QETProject *);
|
||||
QList<Element *> linkedElements () const;
|
||||
//create new uuid for this element
|
||||
void newUuid() {uuid_ = QUuid::createUuid();}
|
||||
void newUuid() {uuid_ = QUuid::createUuid();} //create new uuid for this element
|
||||
|
||||
//ATTRIBUTES related to linked element
|
||||
protected:
|
||||
QList <Element *> connected_elements;
|
||||
QList <QUuid> tmp_uuids_link;
|
||||
QUuid uuid_;
|
||||
|
||||
//METHODS related to information
|
||||
public:
|
||||
DiagramContext informations()const {return informations_;}
|
||||
void setInformations(DiagramContext dc) {informations_ = dc;}
|
||||
|
||||
//ATTRIBUTES
|
||||
protected:
|
||||
DiagramContext informations_;
|
||||
|
||||
/**
|
||||
Draw this element
|
||||
*/
|
||||
public:
|
||||
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *) = 0;
|
||||
/// @return This element type ID
|
||||
virtual QString typeId() const = 0;
|
||||
|
||||
Reference in New Issue
Block a user