mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 06:20:53 +01:00
Merge branch 'terminal_strip'
* terminal_strip: Terminal strip item can saved / loaded to .qet file See previous commit... Move terminal strip drawer class in is own file Fix wrong use of QStringLiteral and QLatin1String Double click a TerminalStripItem open the editor Minor change about checkable QAction of QetDiagramEditor Minor : corrects a minor aesthetic defect when unbridge terminals Revamp code Add and move terminal strip item are now managed by undo command TerminalStripItem : Draw terminal bridge Terminal strip item can be added to diagram Minor : add QGIUtility namespace
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
|
||||
#include <QDir>
|
||||
#include <QFont>
|
||||
#include <QGraphicsItem>
|
||||
#include <QPen>
|
||||
|
||||
/**
|
||||
@@ -917,7 +918,39 @@ bool validXmlProperty(const QDomElement& e) {
|
||||
if (!e.hasAttribute("value"))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief qGraphicsItemPosToXml
|
||||
* Save the pos of a QGraphicsItem into an xml element.
|
||||
* The tag name of the xml element is pos and there is 3 attributes:
|
||||
* x, y, z.
|
||||
* @param item
|
||||
* @param document
|
||||
* @return
|
||||
*/
|
||||
QDomElement qGraphicsItemPosToXml(QGraphicsItem *item, QDomDocument &document)
|
||||
{
|
||||
auto dom_pos = document.createElement(QStringLiteral("pos"));
|
||||
dom_pos.setAttribute(QStringLiteral("x"), QString::number(item->pos().x()));
|
||||
dom_pos.setAttribute(QStringLiteral("y"), QString::number(item->pos().y()));
|
||||
dom_pos.setAttribute(QStringLiteral("z"), QString::number(item->zValue()));
|
||||
|
||||
return dom_pos;
|
||||
}
|
||||
|
||||
bool qGraphicsItemPosFromXml(QGraphicsItem *item, const QDomElement &xml_elmt)
|
||||
{
|
||||
if (xml_elmt.tagName() == QLatin1String("pos"))
|
||||
{
|
||||
item->setX(xml_elmt.attribute(QStringLiteral("x"), QStringLiteral("0")).toDouble());
|
||||
item->setY(xml_elmt.attribute(QStringLiteral("y"), QStringLiteral("0")).toDouble());
|
||||
item->setZValue(xml_elmt.attribute(QStringLiteral("z"), QStringLiteral("0")).toInt());
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user