diff --git a/src/libs/libiveditor/properties/ivpropertiesdialog.cpp b/src/libs/libiveditor/properties/ivpropertiesdialog.cpp index 08081b2aa6f951c47822170622c68e8f46f92c3a..03437f2a22417fb61b2bac56e7fbbb26f497b1e6 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 644bd7c081bed6e4dd4aae12c488c3aa1df6b100..1e132bdfd0f95a3d003283a46b0c0cd4a7d90733 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" @@ -67,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) @@ -135,7 +152,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; } @@ -147,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 d6d3742327f54da004047fe684290286c5922dfd..09427b317854c9695f50b0413f8e7483af6e3839 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 diff --git a/src/libs/shared/propertytemplate.cpp b/src/libs/shared/propertytemplate.cpp index 78d99bad35cfa86ff8e45fdd56e9e7c5d403b670..01b7daf8034dd0a509eb3612d2756cc33fc12831 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();