Salome HOME
Merge branch 'BR_internationalization'
[modules/shaper.git] / src / XGUI / XGUI_Tools.cpp
index b3e1dca321ec14877c55949df0323add655eb3bd..a60b1f2190ac49b646281c1a5fd8f4a8ac93d136 100644 (file)
@@ -6,6 +6,7 @@
 #include "XGUI_Workshop.h"
 
 #include "ModuleBase_IWorkshop.h"
+#include "ModuleBase_Tools.h"
 
 #include <TopoDS_Shape.hxx>
 #include <ModelAPI_Object.h>
@@ -26,6 +27,7 @@
 
 #include <iostream>
 #include <sstream>
+#include <string>
 
 namespace XGUI_Tools {
 //******************************************************************
@@ -102,23 +104,18 @@ std::string featureInfo(FeaturePtr theFeature)
  }
  }*/
 
+
 //******************************************************************
-bool canRemoveOrRename(QWidget* theParent, const QObjectPtrList& theObjects)
+bool canRemoveOrRename(QWidget* theParent, const std::set<FeaturePtr>& theFeatures)
 {
   bool aResult = true;
-  QString aNotActivatedNames;
-  if (!XGUI_Tools::allDocumentsActivated(aNotActivatedNames)) {
-    DocumentPtr aModuleDoc = ModelAPI_Session::get()->moduleDocument();
-    bool aFoundPartSetObject = false;
-    foreach (ObjectPtr aObj, theObjects) {
-      if (aObj->groupName() == ModelAPI_ResultPart::group())
-        continue;
-      aFoundPartSetObject = aObj->document() == aModuleDoc;
-    }
+  std::string aNotActivatedNames;
+  if (!ModelAPI_Tools::allDocumentsActivated(aNotActivatedNames)) {
+    bool aFoundPartSetObject = ModuleBase_Tools::hasModuleDocumentFeature(theFeatures);
     if (aFoundPartSetObject) {
       QMessageBox::StandardButton aRes = QMessageBox::warning(theParent, QObject::tr("Warning"),
                QObject::tr("Selected objects can be used in Part documents which are not loaded: \
-%1. Whould you like to continue?").arg(aNotActivatedNames),
+%1. Whould you like to continue?").arg(aNotActivatedNames.c_str()),
                QMessageBox::No | QMessageBox::Yes, QMessageBox::No);
       aResult = aRes == QMessageBox::Yes;
     }
@@ -145,26 +142,6 @@ bool canRename(const ObjectPtr& theObject, const QString& theName)
   return true;
 }
 
-//******************************************************************
-bool allDocumentsActivated(QString& theNotActivatedNames)
-{
-  bool anAllPartActivated = true;
-  QStringList aRefNames;
-
-  DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
-  int aSize = aRootDoc->size(ModelAPI_ResultPart::group());
-  for (int i = 0; i < aSize; i++) {
-    ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), i);
-    ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aObject);
-    if (!aPart->isActivated()) {
-      anAllPartActivated = false;
-      aRefNames.append(aObject->data()->name().c_str());
-    }
-  }
-  theNotActivatedNames = aRefNames.join(", ");
-  return anAllPartActivated;
-}
-
 //**************************************************************
 
 XGUI_Workshop* workshop(ModuleBase_IWorkshop* theWorkshop)