if (XGUI_Tools::canRename(aObj, aName)) {
SessionPtr aMgr = ModelAPI_Session::get();
aMgr->startOperation("Rename");
- std::wstring aaa = aName.toStdWString();
aObj->data()->setName(aName.toStdWString());
aMgr->finishOperation();
}
return true;
}
+//******************************************************************
+bool isValidName(const QString& theName)
+{
+ QChar aChar;
+ for (int i = 0; i < theName.size(); i++) {
+ aChar = theName[i];
+ if (!aChar.isLetterOrNumber()) {
+ if ((aChar != "_") && (!aChar.isSpace()))
+ return false;
+ }
+ }
+ return true;
+}
+
//******************************************************************
bool canRename(const ObjectPtr& theObject, const QString& theName)
{
}
}
else {
+ if (!isValidName(theName))
+ return false;
+
DocumentPtr aDoc = theObject->document();
ObjectPtr aObj =
aDoc->objectByName(aType, theName.toStdWString());