From 05eb22e3879a63e37574aad5061d8cfa31ab308b Mon Sep 17 00:00:00 2001 From: Alex Diev Date: Wed, 4 Aug 2021 15:13:52 +0300 Subject: [PATCH 1/2] IVE: Unable to create new template property --- src/libs/libiveditor/properties/ivpropertieslistmodel.cpp | 5 ++++- src/libs/shared/propertytemplate.cpp | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/libs/libiveditor/properties/ivpropertieslistmodel.cpp b/src/libs/libiveditor/properties/ivpropertieslistmodel.cpp index 644bd7c08..40f0940d7 100644 --- a/src/libs/libiveditor/properties/ivpropertieslistmodel.cpp +++ b/src/libs/libiveditor/properties/ivpropertieslistmodel.cpp @@ -17,6 +17,7 @@ #include "ivpropertieslistmodel.h" +#include "commands/cmdentitypropertychange.h" #include "commands/cmdfunctionattrchange.h" #include "commands/cmdifaceattrchange.h" #include "ivcommonprops.h" @@ -135,7 +136,9 @@ bool FunctionPropertiesListModel::setData(const QModelIndex &index, const QVaria { const QPair data = prepareDataForUpdate(index, value, role); if (!data.first.isEmpty()) { - return m_cmdMacro->push(new cmd::CmdFunctionAttrChange(entity(), { { data.first, data.second } })); + if (isAttr(index)) + return m_cmdMacro->push(new cmd::CmdFunctionAttrChange(entity(), { { data.first, data.second } })); + return m_cmdMacro->push(new shared::cmd::CmdEntityPropertyChange(entity(), { { data.first, data.second } })); } return false; } diff --git a/src/libs/shared/propertytemplate.cpp b/src/libs/shared/propertytemplate.cpp index 78d99bad3..01b7daf80 100644 --- a/src/libs/shared/propertytemplate.cpp +++ b/src/libs/shared/propertytemplate.cpp @@ -181,7 +181,8 @@ QDomElement PropertyTemplate::toXml(QDomDocument *doc) const static const QMetaEnum &infoMeta = QMetaEnum::fromType(); if (d->m_info == PropertyTemplate::Info::Property) { - attrElement.setAttribute(QLatin1String("type"), infoMeta.valueToKey(static_cast(d->m_info))); + const QString infoStr = QString::fromLatin1(infoMeta.valueToKey(static_cast(d->m_info))); + attrElement.setAttribute(QLatin1String("type"), infoStr.toLower()); } static const QMetaEnum &typeMeta = QMetaEnum::fromType(); -- GitLab From a8abeade3fa77c0c8fc341f3bc4c2ddbd64559e7 Mon Sep 17 00:00:00 2001 From: Alex Diev Date: Wed, 4 Aug 2021 16:00:01 +0300 Subject: [PATCH 2/2] IVE: FunctionType properties configuring fixed --- .../properties/ivpropertiesdialog.cpp | 12 +++++++++--- .../properties/ivpropertieslistmodel.cpp | 18 +++++++++++++++++- .../properties/ivpropertieslistmodel.h | 1 + 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/libs/libiveditor/properties/ivpropertiesdialog.cpp b/src/libs/libiveditor/properties/ivpropertiesdialog.cpp index 08081b2aa..03437f2a2 100644 --- a/src/libs/libiveditor/properties/ivpropertiesdialog.cpp +++ b/src/libs/libiveditor/properties/ivpropertiesdialog.cpp @@ -138,13 +138,19 @@ void IVPropertiesDialog::initAttributesView() switch (dataObject()->type()) { case ivm::IVObject::Type::FunctionType: - case ivm::IVObject::Type::Function: { + modelAttrs = new IVPropertiesListModel(commandMacro(), propertiesConfig(), this); + break; + case ivm::IVObject::Type::Function: modelAttrs = new FunctionPropertiesListModel(commandMacro(), propertiesConfig(), this); break; - } - default: + case ivm::IVObject::Type::InterfaceGroup: + case ivm::IVObject::Type::ProvidedInterface: + case ivm::IVObject::Type::RequiredInterface: modelAttrs = new InterfacePropertiesListModel(commandMacro(), propertiesConfig(), this); break; + default: + modelAttrs = new shared::PropertiesListModel(commandMacro(), propertiesConfig(), this); + break; } modelAttrs->setDataObject(dataObject()); diff --git a/src/libs/libiveditor/properties/ivpropertieslistmodel.cpp b/src/libs/libiveditor/properties/ivpropertieslistmodel.cpp index 40f0940d7..1e132bdfd 100644 --- a/src/libs/libiveditor/properties/ivpropertieslistmodel.cpp +++ b/src/libs/libiveditor/properties/ivpropertieslistmodel.cpp @@ -68,6 +68,22 @@ QPair IVPropertiesListModel::prepareDataForUpdate( return {}; } +bool IVPropertiesListModel::isEditable(const QModelIndex &index) const +{ + if (!entity() || !index.isValid() || !PropertiesListModel::isEditable(index)) + return false; + + bool editable = true; + switch (tokenFromIndex(index)) { + case ivm::meta::Props::Token::is_type: + editable = false; + break; + default: + break; + } + return editable; +} + IVPropertiesListModel::IVPropertiesListModel( cmd::CommandsStack::Macro *macro, shared::PropertyTemplateConfig *dynPropConfig, QObject *parent) : shared::PropertiesListModel(macro, dynPropConfig, parent) @@ -150,7 +166,7 @@ ivm::IVFunction *FunctionPropertiesListModel::entity() const bool FunctionPropertiesListModel::isEditable(const QModelIndex &index) const { - if (!entity() || !index.isValid() || !PropertiesListModel::isEditable(index)) + if (!entity() || !index.isValid() || !IVPropertiesListModel::isEditable(index)) return false; bool editable = true; diff --git a/src/libs/libiveditor/properties/ivpropertieslistmodel.h b/src/libs/libiveditor/properties/ivpropertieslistmodel.h index d6d374232..09427b317 100644 --- a/src/libs/libiveditor/properties/ivpropertieslistmodel.h +++ b/src/libs/libiveditor/properties/ivpropertieslistmodel.h @@ -46,6 +46,7 @@ public: protected: QPair prepareDataForUpdate(const QModelIndex &index, const QVariant &value, int role) const; + bool isEditable(const QModelIndex &index) const override; }; class FunctionPropertiesListModel : public IVPropertiesListModel -- GitLab