Commit bb01be2f authored by Guenter Schwann's avatar Guenter Schwann
Browse files

662 Copy all system entities from boards to nodes

parent 91252bea
Pipeline #5802 passed with stage
in 15 minutes and 39 seconds
......@@ -18,6 +18,7 @@
#include "dvboard.h"
#include "dvdevice.h"
#include "dvsystemfunction.h"
namespace dvm {
......@@ -49,4 +50,9 @@ QList<DVPort *> DVBoard::ports() const
return d->ports;
}
QList<DVSystemFunction *> DVBoard::systemFunctions() const
{
return typedChildren<DVSystemFunction>();
}
} // namespace dvm
......@@ -25,6 +25,7 @@
namespace dvm {
struct DVBoardPrivate;
class DVPort;
class DVSystemFunction;
class DVBoard : public DVObject
{
......@@ -39,6 +40,8 @@ public:
QList<DVPort *> ports() const;
QList<DVSystemFunction *> systemFunctions() const;
private:
std::unique_ptr<DVBoardPrivate> d;
};
......
......@@ -21,6 +21,15 @@
namespace dvm {
/**
Constructore that copies all attributes and parameters from \p copy
*/
DVSystemFunction::DVSystemFunction(const DVSystemFunction &copy, DVObject *parent)
: DVSystemFunction(parent)
{
setEntityAttributes(copy.entityAttributes());
}
DVSystemFunction::DVSystemFunction(DVObject *parent)
: DVObject(DVObject::Type::SystemFunction, {}, parent)
{
......
......@@ -30,6 +30,7 @@ class DVSystemFunction : public DVObject
Q_PROPERTY(QList<dvm::DVSystemInterface *> interfaces READ interfaces)
public:
explicit DVSystemFunction(const DVSystemFunction &copy, DVObject *parent = nullptr);
explicit DVSystemFunction(DVObject *parent = nullptr);
QList<DVSystemInterface *> interfaces() const;
......
......@@ -19,6 +19,16 @@
namespace dvm {
/**
Constructore that copies all attributes and parameters from \p copy
*/
DVSystemInterface::DVSystemInterface(const DVSystemInterface &copy, DVObject *parent)
: DVSystemInterface(parent)
{
setEntityAttributes(copy.entityAttributes());
setParams(copy.params());
}
DVSystemInterface::DVSystemInterface(DVObject *parent)
: DVObject(DVObject::Type::SystemInterface, {}, parent)
{
......
......@@ -39,6 +39,7 @@ public:
};
Q_ENUM(InterfaceType)
explicit DVSystemInterface(const DVSystemInterface &copy, DVObject *parent = nullptr);
explicit DVSystemInterface(DVObject *parent = nullptr);
void setInterfaceType(InterfaceType type);
......
......@@ -25,6 +25,8 @@
#include "dvnamevalidator.h"
#include "dvnode.h"
#include "dvpartition.h"
#include "dvsystemfunction.h"
#include "dvsysteminterface.h"
#include "graphicsviewutils.h"
#include <QRectF>
......@@ -43,13 +45,21 @@ CmdNodeEntityCreate::CmdNodeEntityCreate(dvm::DVModel *model, const dvm::DVBoard
m_node->setTitle(dvm::DVNameValidator::nameForObject(m_node, m_model, m_board->title()));
const QRectF geometry { QRectF(pos, shared::graphicsviewutils::kDefaultNodeGraphicsItemSize) };
prepareData({ qMakePair(m_node, QVector<QPointF> { geometry.topLeft(), geometry.bottomRight() }) });
m_partition->setTitle(dvm::DVNameValidator::nameForObject(m_partition, m_model));
m_node->addPartition(m_partition);
for (const dvm::DVPort *port : m_board->ports()) {
auto nodeDevice = new dvm::DVDevice(*port, m_node);
m_node->addDevice(nodeDevice);
m_devices.append(nodeDevice);
}
for (const dvm::DVSystemFunction *sfunc : m_board->systemFunctions()) {
auto newFunc = new dvm::DVSystemFunction(*sfunc, m_node);
for (const dvm::DVSystemInterface *sface : sfunc->interfaces()) {
new dvm::DVSystemInterface(*sface, newFunc);
}
}
}
CmdNodeEntityCreate::~CmdNodeEntityCreate()
......@@ -71,12 +81,24 @@ void CmdNodeEntityCreate::redo()
for (dvm::DVDevice *dev : qAsConst(m_devices)) {
m_model->addObject(dev);
}
for (dvm::DVSystemFunction *sfunc : m_node->systemFunctions()) {
m_model->addObject(sfunc);
for (dvm::DVSystemInterface *sface : sfunc->interfaces()) {
m_model->addObject(sface);
}
}
}
}
void CmdNodeEntityCreate::undo()
{
if (m_model) {
for (dvm::DVSystemFunction *sfunc : m_node->systemFunctions()) {
for (dvm::DVSystemInterface *sface : sfunc->interfaces()) {
m_model->removeObject(sface);
}
m_model->removeObject(sfunc);
}
for (dvm::DVDevice *dev : qAsConst(m_devices)) {
m_model->removeObject(dev);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment