Commit 6c3ece45 authored by Guenter Schwann's avatar Guenter Schwann
Browse files

639 Check DV files when interface kind changes

parent 76c42e1e
Pipeline #6500 passed with stage
in 8 minutes and 28 seconds
......@@ -58,6 +58,11 @@ bool CommandsStack::push(QUndoCommand *command)
connect(implCommand, &CmdFunctionLanguageUpdate::implementationChanged, this,
&CommandsStack::implementationChanged, Qt::UniqueConnection);
}
if (auto attrCommand = dynamic_cast<shared::cmd::CmdEntityAttributesChange *>(command)) {
connect(attrCommand, &shared::cmd::CmdEntityAttributesChange::attributeChanged, this,
&CommandsStack::attributeChanged, Qt::UniqueConnection);
}
m_undoStack->push(command);
return true;
}
......
......@@ -31,6 +31,7 @@ class IVObject;
namespace shared {
class UndoCommand;
class VEObject;
}
namespace ive {
......@@ -50,6 +51,7 @@ Q_SIGNALS:
void implementationChanged(
ivm::IVFunction *entity, const QString &newName, const QString &oldName, shared::UndoCommand *command);
void defaultImplementationChanged(ivm::IVFunction *entity);
void attributeChanged(shared::VEObject *entity, const QString &attrName, const QVariant &oldValue);
};
}
......
......@@ -31,8 +31,8 @@ CmdEntityAttributesChange::CmdEntityAttributesChange(
: UndoCommand()
, m_config(config)
, m_entity(entity)
, m_oldAttrs(entity ? entity->entityAttributes().values() : QList<EntityAttribute>())
, m_newAttrs(attrs)
, m_oldAttrs(entity ? entity->entityAttributes().values() : QList<EntityAttribute>())
{
Q_ASSERT(entity != nullptr);
setText(QObject::tr("Change Attribute(s)"));
......@@ -45,7 +45,9 @@ void CmdEntityAttributesChange::redo()
}
for (const EntityAttribute &attr : qAsConst(m_newAttrs)) {
QVariant oldValue = m_entity->entityAttributeValue(attr.name());
m_entity->setEntityAttribute(attr);
Q_EMIT attributeChanged(m_entity, attr.name(), oldValue);
}
QList<EntityAttribute> aboutToRemoveAttrs;
for (PropertyTemplate *attrTemplate : m_config->propertyTemplatesForObject(m_entity)) {
......@@ -64,11 +66,20 @@ void CmdEntityAttributesChange::undo()
return;
}
QHash<QString, EntityAttribute> oldAttrs;
QHash<QString, EntityAttribute> attrs;
for (const EntityAttribute &attr : qAsConst(m_oldAttrs)) {
attrs[attr.name()] = attr;
const QString name = attr.name();
oldAttrs[name] = m_entity->entityAttribute(name);
attrs[name] = attr;
}
m_entity->setEntityAttributes(attrs);
for (const EntityAttribute &attr : oldAttrs) {
const QString name = attr.name();
Q_EMIT attributeChanged(m_entity, name, oldAttrs[name].value());
}
}
int CmdEntityAttributesChange::id() const
......
......@@ -39,6 +39,9 @@ public:
void undo() override;
int id() const override;
Q_SIGNALS:
void attributeChanged(VEObject *entity, const QString &attrName, const QVariant &oldValue);
private:
shared::PropertyTemplateConfig *m_config;
QPointer<VEObject> m_entity;
......
......@@ -26,6 +26,7 @@
#include "dvfunction.h"
#include "dvmessage.h"
#include "dvmodel.h"
#include "dvsystemchecks.h"
#include "interfacedocument.h"
#include "ivconnection.h"
#include "ivconnectionchain.h"
......@@ -72,6 +73,8 @@ void MscSystemChecks::setStorage(SpaceCreatorProject *storage)
&scs::MscSystemChecks::onImplementationChanged);
connect(ivCore->commandsStack(), &ive::cmd::CommandsStack::defaultImplementationChanged, this,
&scs::MscSystemChecks::onDefaultImplementationChanged);
connect(ivCore->commandsStack(), &ive::cmd::CommandsStack::attributeChanged, this,
&scs::MscSystemChecks::onAttributeChanged);
});
}
......@@ -612,4 +615,21 @@ void MscSystemChecks::onDefaultImplementationChanged()
}
}
void MscSystemChecks::onAttributeChanged(shared::VEObject *entity, const QString &attrName, const QVariant &oldValue)
{
Q_UNUSED(oldValue)
if (!entity) {
return;
}
static QString kindTocken = ivm::meta::Props::token(ivm::meta::Props::Token::kind);
if (attrName == kindTocken) {
DvSystemChecks dvChecks;
dvChecks.setStorage(m_storage);
for (const DVEditorCorePtr &dvCore : m_storage->allDVCores()) {
dvChecks.checkDVFile(dvCore);
}
}
}
}
......@@ -39,6 +39,7 @@ class MSCEditorCore;
namespace shared {
class UndoCommand;
class VEObject;
}
namespace scs {
......@@ -88,6 +89,7 @@ public Q_SLOTS:
void onImplementationChanged(
ivm::IVFunction *entity, const QString &newName, const QString &oldName, shared::UndoCommand *command);
void onDefaultImplementationChanged();
void onAttributeChanged(shared::VEObject *entity, const QString &attrName, const QVariant &oldValue);
private:
QPointer<SpaceCreatorProject> m_storage;
......
Supports Markdown
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