From 00ce52c432d3e43eb0a5f72a35e5bf7fa7f08e17 Mon Sep 17 00:00:00 2001 From: Ladislav Michl Date: Sat, 2 Nov 2024 19:44:00 +0100 Subject: [PATCH] Gui: propertyeditor: add setPropertyValue with std::string argument --- src/Gui/propertyeditor/PropertyItem.cpp | 10 +++++++--- src/Gui/propertyeditor/PropertyItem.h | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Gui/propertyeditor/PropertyItem.cpp b/src/Gui/propertyeditor/PropertyItem.cpp index 83ec217cca..c6b8bd3044 100644 --- a/src/Gui/propertyeditor/PropertyItem.cpp +++ b/src/Gui/propertyeditor/PropertyItem.cpp @@ -598,7 +598,7 @@ void PropertyItem::setPropertyName(const QString& name, const QString& realName) displayText = str; } -void PropertyItem::setPropertyValue(const QString& value) +void PropertyItem::setPropertyValue(const std::string& value) { // Construct command for property assignment in one go, in case of any // intermediate changes caused by property change that may potentially @@ -631,8 +631,7 @@ void PropertyItem::setPropertyValue(const QString& value) continue; } - ss << parent->getPropertyPrefix() << prop->getName() << " = " << value.toUtf8().constData() - << '\n'; + ss << parent->getPropertyPrefix() << prop->getName() << " = " << value << '\n'; } std::string cmd = ss.str(); @@ -655,6 +654,11 @@ void PropertyItem::setPropertyValue(const QString& value) } } +void PropertyItem::setPropertyValue(const QString& value) +{ + setPropertyValue(value.toStdString()); +} + QVariant PropertyItem::dataProperty(int role) const { if (role == Qt::ForegroundRole && linked) { diff --git a/src/Gui/propertyeditor/PropertyItem.h b/src/Gui/propertyeditor/PropertyItem.h index 682826232b..04481b3000 100644 --- a/src/Gui/propertyeditor/PropertyItem.h +++ b/src/Gui/propertyeditor/PropertyItem.h @@ -203,6 +203,7 @@ public: protected: PropertyItem(); + void setPropertyValue(const std::string& value); virtual QVariant displayName() const; virtual QVariant decoration(const QVariant&) const; virtual QVariant toolTip(const App::Property*) const;