SessionPtr aMgr = ModelAPI_Session::get();
aMgr->startOperation("Rename");
- if (!canRename(aObj, aName)) {
+ if (!XGUI_Tools::canRename(this, aObj, aName)) {
aMgr->abortOperation();
return;
}
}
}
-bool XGUI_DataTree::canRename(const ObjectPtr& theObject, const QString& theName)
-{
- double aValue;
- ResultParameterPtr aParam;
-
- bool isVariableFound = ModelAPI_Tools::findVariable(theObject->document(), qPrintable(theName), aValue, aParam);
-
- if (isVariableFound)
- QMessageBox::information(this, tr("Rename parameter"),
- QString(tr("Selected parameter can not be renamed to: %1. \
-There is a parameter with the same name. Its value is: %2.")).arg(qPrintable(theName)).arg(aValue));
-
- return !isVariableFound;
-}
-
void XGUI_DataTree::clear()
{
ModuleBase_IDocumentDataModel* aModel = dataModel();
/// Commit modified data (used for renaming of objects)
virtual void commitData(QWidget* theEditor);
- /// Returns true if theObject can be renamed in theName
- bool canRename(const ObjectPtr& theObject, const QString& theName);
-
protected:
/// Redefinition of virtual method
virtual void contextMenuEvent(QContextMenuEvent* theEvent);
#include <ModelAPI_Document.h>
#include <ModelAPI_ResultPart.h>
#include <ModelAPI_CompositeFeature.h>
+#include <ModelAPI_Tools.h>
#include <GeomAPI_Shape.h>
return aResult;
}
+//******************************************************************
+bool canRename(QWidget* theParent, const ObjectPtr& theObject, const QString& theName)
+{
+ if (std::dynamic_pointer_cast<ModelAPI_ResultParameter>(theObject).get()) {
+ double aValue;
+ ResultParameterPtr aParam;
+ if (ModelAPI_Tools::findVariable(theObject->document(), qPrintable(theName), aValue, aParam)) {
+ QMessageBox::information(theParent, QObject::tr("Rename parameter"),
+ QString(QObject::tr("Selected parameter can not be renamed to: %1. \
+There is a parameter with the same name. Its value is: %2.")).arg(qPrintable(theName)).arg(aValue));
+ return false;
+ }
+ }
+
+ return true;
+}
+
//******************************************************************
bool allDocumentsActivated(QString& theNotActivatedNames)
{
*/
bool XGUI_EXPORT canRemoveOrRename(QWidget* theParent, const QObjectPtrList& aList);
+/*!
+ Returns true if theObject can be renamed in theName
+ */
+bool canRename(QWidget* theParent, const ObjectPtr& theObject, const QString& theName);
+
/*!
Returns true if there are no parts in the document, which are not activated
\return a boolean value