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:
joshua
2023-01-02 19:40:08 +01:00
45 changed files with 1628 additions and 276 deletions

View File

@@ -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;
}
}