mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-20 16:20:52 +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:
@@ -686,6 +686,11 @@ QDomElement Diagram::writeXml(QDomDocument &xml_doc) const {
|
|||||||
return(new_node.toElement());
|
return(new_node.toElement());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Diagram::initElementsLinks() {
|
||||||
|
foreach (Element *elmt, elements())
|
||||||
|
elmt->initLink(project());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Ajoute un element sur le schema
|
Ajoute un element sur le schema
|
||||||
@param element Element a ajouter
|
@param element Element a ajouter
|
||||||
|
|||||||
@@ -133,6 +133,7 @@ class Diagram : public QGraphicsScene {
|
|||||||
QDomElement writeXml(QDomDocument &) const;
|
QDomElement writeXml(QDomDocument &) const;
|
||||||
|
|
||||||
// methods related to graphics items addition/removal on the diagram
|
// methods related to graphics items addition/removal on the diagram
|
||||||
|
void initElementsLinks();
|
||||||
void addElement(Element *);
|
void addElement(Element *);
|
||||||
void addConductor(Conductor *);
|
void addConductor(Conductor *);
|
||||||
void addIndependentTextItem(IndependentTextItem *);
|
void addIndependentTextItem(IndependentTextItem *);
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "elementprovider.h"
|
#include "elementprovider.h"
|
||||||
|
#include "QUuid"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementProvider::ElementProvider Constructor
|
* @brief ElementProvider::ElementProvider Constructor
|
||||||
@@ -52,3 +53,22 @@ QList <Element *> ElementProvider::FreeElement(const int filter) const{
|
|||||||
}
|
}
|
||||||
return (free_elmt);
|
return (free_elmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ElementProvider::fromUuids
|
||||||
|
* @param uuid_list list of uuid must be found
|
||||||
|
* @return all elements with uuid corresponding to uuid in @uuid_list
|
||||||
|
*/
|
||||||
|
QList <Element *> ElementProvider::fromUuids(QList<QUuid> uuid_list) const {
|
||||||
|
QList <Element *> found_element;
|
||||||
|
|
||||||
|
foreach (Diagram *d, diag_list) {
|
||||||
|
foreach(Element *elmt, d->elements()) {
|
||||||
|
if (uuid_list.contains(elmt->uuid())) {
|
||||||
|
found_element << elmt;
|
||||||
|
uuid_list.removeAll(elmt->uuid());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return found_element;
|
||||||
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ class ElementProvider
|
|||||||
public:
|
public:
|
||||||
ElementProvider(QETProject *prj, Diagram *diagram=0);
|
ElementProvider(QETProject *prj, Diagram *diagram=0);
|
||||||
QList <Element *> FreeElement(const int filter) const;
|
QList <Element *> FreeElement(const int filter) const;
|
||||||
|
QList <Element *> fromUuids(QList <QUuid>) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList <Diagram *> diag_list;
|
QList <Diagram *> diag_list;
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include "diagramcommands.h"
|
#include "diagramcommands.h"
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
#include <ui/elementpropertieswidget.h>
|
#include <ui/elementpropertieswidget.h>
|
||||||
|
#include "elementprovider.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructeur pour un element sans scene ni parent
|
Constructeur pour un element sans scene ni parent
|
||||||
@@ -32,6 +33,7 @@ Element::Element(QGraphicsItem *parent, Diagram *scene) :
|
|||||||
internal_connections_(false),
|
internal_connections_(false),
|
||||||
must_highlight_(false)
|
must_highlight_(false)
|
||||||
{
|
{
|
||||||
|
uuid_ = QUuid::createUuid();
|
||||||
setZValue(10);
|
setZValue(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -386,6 +388,13 @@ bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr, bool
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//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
|
// position, selection
|
||||||
setPos(e.attribute("x").toDouble(), e.attribute("y").toDouble());
|
setPos(e.attribute("x").toDouble(), e.attribute("y").toDouble());
|
||||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||||
@@ -415,6 +424,8 @@ QDomElement Element::toXml(QDomDocument &document, QHash<Terminal *, int> &table
|
|||||||
|
|
||||||
// type
|
// type
|
||||||
element.setAttribute("type", typeId());
|
element.setAttribute("type", typeId());
|
||||||
|
// uuid
|
||||||
|
element.setAttribute("uuid", uuid().toString());
|
||||||
|
|
||||||
// position, selection et orientation
|
// position, selection et orientation
|
||||||
element.setAttribute("x", QString("%1").arg(pos().x()));
|
element.setAttribute("x", QString("%1").arg(pos().x()));
|
||||||
@@ -451,5 +462,29 @@ QDomElement Element::toXml(QDomDocument &document, QHash<Terminal *, int> &table
|
|||||||
}
|
}
|
||||||
element.appendChild(inputs);
|
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);
|
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 <QtGui>
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
#include "qetgraphicsitem.h"
|
#include "qetgraphicsitem.h"
|
||||||
|
#include <QUuid>
|
||||||
class Diagram;
|
class Diagram;
|
||||||
class ElementTextItem;
|
class ElementTextItem;
|
||||||
|
|
||||||
@@ -54,11 +55,13 @@ class Element : public QetGraphicsItem {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
QList <Element *> connected_elements;
|
QList <Element *> connected_elements;
|
||||||
|
QList <QUuid> tmp_uuids_link;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSize dimensions;
|
QSize dimensions;
|
||||||
QPoint hotspot_coord;
|
QPoint hotspot_coord;
|
||||||
QPixmap preview;
|
QPixmap preview;
|
||||||
|
QUuid uuid_;
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
@@ -82,9 +85,13 @@ class Element : public QetGraphicsItem {
|
|||||||
virtual int minTerminalsCount() const = 0;
|
virtual int minTerminalsCount() const = 0;
|
||||||
/// @return the maximum number of terminals for this element
|
/// @return the maximum number of terminals for this element
|
||||||
virtual int maxTerminalsCount() const = 0;
|
virtual int maxTerminalsCount() const = 0;
|
||||||
|
|
||||||
|
// related method for link between element
|
||||||
bool isFree () const;
|
bool isFree () const;
|
||||||
virtual void linkToElement(Element *) {}
|
virtual void linkToElement(Element *) {}
|
||||||
virtual void unLinkAllElements() {}
|
virtual void unLinkAllElements() {}
|
||||||
|
void initLink(QETProject *);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Draw this element
|
Draw this element
|
||||||
*/
|
*/
|
||||||
@@ -122,6 +129,7 @@ class Element : public QetGraphicsItem {
|
|||||||
static bool valideXml(QDomElement &);
|
static bool valideXml(QDomElement &);
|
||||||
virtual bool fromXml(QDomElement &, QHash<int, Terminal *> &, bool = false);
|
virtual bool fromXml(QDomElement &, QHash<int, Terminal *> &, bool = false);
|
||||||
virtual QDomElement toXml(QDomDocument &, QHash<Terminal *, int> &) const;
|
virtual QDomElement toXml(QDomDocument &, QHash<Terminal *, int> &) const;
|
||||||
|
QUuid uuid() const;
|
||||||
|
|
||||||
// orientation-related methods
|
// orientation-related methods
|
||||||
int orientation() const;
|
int orientation() const;
|
||||||
@@ -171,4 +179,12 @@ inline int Element::orientation() const {
|
|||||||
return(QET::correctAngle(rotation())/90);
|
return(QET::correctAngle(rotation())/90);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Element::uuid
|
||||||
|
* @return the uuid of this element
|
||||||
|
*/
|
||||||
|
inline QUuid Element::uuid() const {
|
||||||
|
return uuid_;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ void ReportElement::linkToElement(Element * elmt) {
|
|||||||
connected_elements << elmt;
|
connected_elements << elmt;
|
||||||
connect(elmt, SIGNAL(positionChange(QPointF)), this, SLOT(updateLabel()));
|
connect(elmt, SIGNAL(positionChange(QPointF)), this, SLOT(updateLabel()));
|
||||||
updateLabel();
|
updateLabel();
|
||||||
|
tmp_uuids_link.removeAll(elmt->uuid());
|
||||||
elmt->linkToElement(this);
|
elmt->linkToElement(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -990,6 +990,11 @@ void QETProject::readDiagramsXml() {
|
|||||||
foreach(Diagram *diagram, loaded_diagrams.values()) {
|
foreach(Diagram *diagram, loaded_diagrams.values()) {
|
||||||
addDiagram(diagram);
|
addDiagram(diagram);
|
||||||
}
|
}
|
||||||
|
// Initialise links between elements in this project
|
||||||
|
foreach (Diagram *d, diagrams()) {
|
||||||
|
d->initElementsLinks();
|
||||||
|
}
|
||||||
|
|
||||||
//delete dialog object
|
//delete dialog object
|
||||||
delete dlgWaiting;
|
delete dlgWaiting;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user