}
}
+void Model_AttributeString::setValue(const std::wstring& theValue)
+{
+ TCollection_ExtendedString aValue(theValue.c_str());
+ if (!myIsInitialized || myString->Get() != aValue) {
+ if (myString.IsNull())
+ myString = TDataStd_Name::Set(myLab, TCollection_ExtendedString());
+ myString->Set(aValue);
+ owner()->data()->sendAttributeUpdated(this);
+ }
+}
+
std::string Model_AttributeString::value()
{
if (myString.IsNull())
return ""; // not initialized
return TCollection_AsciiString(myString->Get()).ToCString();
}
+std::wstring Model_AttributeString::valueW()
+{
+ if (myString.IsNull())
+ return std::wstring(L""); // not initialized
+ return std::wstring((wchar_t*)(myString->Get().ToExtString()));
+}
Model_AttributeString::Model_AttributeString(TDF_Label& theLabel)
{
public:
/// Defines the std::string value
MODEL_EXPORT virtual void setValue(const std::string& theValue);
+ /// Defines the std::wstring value
+ MODEL_EXPORT virtual void setValue(const std::wstring& theValue);
/// Returns the std::string value
MODEL_EXPORT virtual std::string value();
+ /// Returns the std::wstring value
+ MODEL_EXPORT virtual std::wstring valueW();
protected:
/// Initializes attibutes
public:
/// Defines the string value
MODELAPI_EXPORT virtual void setValue(const std::string& theValue) = 0;
+ /// Defines the wstring value
+ MODELAPI_EXPORT virtual void setValue(const std::wstring& theValue) = 0;
/// Returns the string value
MODELAPI_EXPORT virtual std::string value() = 0;
+ /// Returns the wstring value
+ MODELAPI_EXPORT virtual std::wstring valueW() = 0;
/// Returns the type of this class of attributes
MODELAPI_EXPORT static std::string typeId()
aMainLay->addWidget(aTitleLabel, 0, 0);
myPathField = new QLineEdit(this);
aMainLay->addWidget(myPathField, 1, 0);
+
QPushButton* aSelectPathBtn = new QPushButton("...", this);
aSelectPathBtn->setToolTip(tr("Select file..."));
aSelectPathBtn->setMaximumWidth(20);
DataPtr aData = myFeature->data();
AttributeStringPtr aStringAttr = aData->string(attributeID());
QString aWidgetValue = myPathField->text();
- aStringAttr->setValue(aWidgetValue.toStdString());
+ aStringAttr->setValue(aWidgetValue.toStdWString());
updateObject(myFeature);
return true;
}
DataPtr aData = myFeature->data();
AttributeStringPtr aStringAttr = aData->string(attributeID());
- bool isBlocked = myPathField->blockSignals(true);
- QString aNewText = QString::fromStdString(aStringAttr->value());
- if( myPathField->text() != aNewText )
- myPathField->setText( aNewText );
- myPathField->blockSignals(isBlocked);
+ std::wstring aUtfStr = aStringAttr->valueW();
+ QString aNewText = QString::fromStdWString(aUtfStr);
+ if (myPathField->text() != aNewText) {
+ bool isBlocked = myPathField->blockSignals(true);
+ myPathField->setText(aNewText);
+ myPathField->blockSignals(isBlocked);
+ }
return true;
}
if (!aFileName.isEmpty()) {
if (myType == WFS_SAVE)
aFileName = applyExtension(aFileName, mySelectedFilter);
- myPathField->setText(aFileName);
+ myPathField->setText(aFileName.toUtf8());
myDefaultPath = QFileInfo(aFileName).absolutePath();
emit focusOutWidget(this);
}