mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-03-26 09:49:59 +01:00
Folio report are save/load in .qet file
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2688 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include "diagramcommands.h"
|
||||
#include <QtDebug>
|
||||
#include <ui/elementpropertieswidget.h>
|
||||
#include "elementprovider.h"
|
||||
|
||||
/**
|
||||
Constructeur pour un element sans scene ni parent
|
||||
@@ -32,6 +33,7 @@ Element::Element(QGraphicsItem *parent, Diagram *scene) :
|
||||
internal_connections_(false),
|
||||
must_highlight_(false)
|
||||
{
|
||||
uuid_ = QUuid::createUuid();
|
||||
setZValue(10);
|
||||
}
|
||||
|
||||
@@ -385,7 +387,14 @@ bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr, bool
|
||||
foreach(QDomElement input, inputs) eti -> fromXml(input);
|
||||
}
|
||||
}
|
||||
|
||||
//load uuid of connected elements
|
||||
QList <QDomElement> uuid_list = QET::findInDomElement(e, "links_uuids", "link_uuid");
|
||||
foreach (QDomElement qdo, uuid_list) tmp_uuids_link << qdo.attribute("uuid");
|
||||
|
||||
//uuid of this element
|
||||
uuid_= QUuid(e.attribute("uuid", QUuid::createUuid().toString()));
|
||||
|
||||
// position, selection
|
||||
setPos(e.attribute("x").toDouble(), e.attribute("y").toDouble());
|
||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||
@@ -415,6 +424,8 @@ QDomElement Element::toXml(QDomDocument &document, QHash<Terminal *, int> &table
|
||||
|
||||
// type
|
||||
element.setAttribute("type", typeId());
|
||||
// uuid
|
||||
element.setAttribute("uuid", uuid().toString());
|
||||
|
||||
// position, selection et orientation
|
||||
element.setAttribute("x", QString("%1").arg(pos().x()));
|
||||
@@ -450,6 +461,30 @@ QDomElement Element::toXml(QDomDocument &document, QHash<Terminal *, int> &table
|
||||
inputs.appendChild(eti -> toXml(document));
|
||||
}
|
||||
element.appendChild(inputs);
|
||||
|
||||
//if this element is linked to other elements,
|
||||
//save the uuid of each other elements
|
||||
if (! isFree()) {
|
||||
QDomElement links_uuids = document.createElement("links_uuids");
|
||||
foreach (Element *elmt, connected_elements) {
|
||||
QDomElement link_uuid = document.createElement("link_uuid");
|
||||
link_uuid.setAttribute("uuid", elmt->uuid().toString());
|
||||
links_uuids.appendChild(link_uuid);
|
||||
}
|
||||
element.appendChild(links_uuids);
|
||||
}
|
||||
|
||||
return(element);
|
||||
}
|
||||
|
||||
// Initialise link for this element
|
||||
void Element::initLink(QETProject *prj) {
|
||||
// if nothing to link return now
|
||||
if (tmp_uuids_link.isEmpty()) return;
|
||||
|
||||
ElementProvider ep(prj);
|
||||
foreach (Element *elmt, ep.fromUuids(tmp_uuids_link)) {
|
||||
elmt->linkToElement(this);
|
||||
}
|
||||
tmp_uuids_link.clear();
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <QtGui>
|
||||
#include "terminal.h"
|
||||
#include "qetgraphicsitem.h"
|
||||
#include <QUuid>
|
||||
class Diagram;
|
||||
class ElementTextItem;
|
||||
|
||||
@@ -54,11 +55,13 @@ class Element : public QetGraphicsItem {
|
||||
|
||||
protected:
|
||||
QList <Element *> connected_elements;
|
||||
QList <QUuid> tmp_uuids_link;
|
||||
|
||||
private:
|
||||
QSize dimensions;
|
||||
QPoint hotspot_coord;
|
||||
QPixmap preview;
|
||||
QUuid uuid_;
|
||||
|
||||
// methods
|
||||
public:
|
||||
@@ -82,9 +85,13 @@ class Element : public QetGraphicsItem {
|
||||
virtual int minTerminalsCount() const = 0;
|
||||
/// @return the maximum number of terminals for this element
|
||||
virtual int maxTerminalsCount() const = 0;
|
||||
|
||||
// related method for link between element
|
||||
bool isFree () const;
|
||||
virtual void linkToElement(Element *) {}
|
||||
virtual void unLinkAllElements() {}
|
||||
void initLink(QETProject *);
|
||||
|
||||
/**
|
||||
Draw this element
|
||||
*/
|
||||
@@ -122,6 +129,7 @@ class Element : public QetGraphicsItem {
|
||||
static bool valideXml(QDomElement &);
|
||||
virtual bool fromXml(QDomElement &, QHash<int, Terminal *> &, bool = false);
|
||||
virtual QDomElement toXml(QDomDocument &, QHash<Terminal *, int> &) const;
|
||||
QUuid uuid() const;
|
||||
|
||||
// orientation-related methods
|
||||
int orientation() const;
|
||||
@@ -171,4 +179,12 @@ inline int Element::orientation() const {
|
||||
return(QET::correctAngle(rotation())/90);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Element::uuid
|
||||
* @return the uuid of this element
|
||||
*/
|
||||
inline QUuid Element::uuid() const {
|
||||
return uuid_;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -44,6 +44,7 @@ void ReportElement::linkToElement(Element * elmt) {
|
||||
connected_elements << elmt;
|
||||
connect(elmt, SIGNAL(positionChange(QPointF)), this, SLOT(updateLabel()));
|
||||
updateLabel();
|
||||
tmp_uuids_link.removeAll(elmt->uuid());
|
||||
elmt->linkToElement(this);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user