Salome HOME
Issue #1005: To improve user-friendship of error-messages for features and attributes
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetMultiSelector.cpp
index d2e8355f30c8069f77d981de0bca61477cade666..fe5e99ecc75774a09de5d31c28f4b29f7b17edd5 100755 (executable)
@@ -117,9 +117,8 @@ ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParen
     myTypeCombo->setVisible(false);
   }
 
-  std::string aLabelText = theData->getProperty("label");
-  QLabel* aListLabel = new QLabel(!aLabelText.empty() ? aLabelText.c_str()
-                                                      : tr("Selected objects:"), this);
+  QString aLabelText = translate(theData->getProperty("label"));
+  QLabel* aListLabel = new QLabel(aLabelText, this);
   aMainLay->addWidget(aListLabel, 1, 0);
   // if the xml definition contains one type, an information label
   // should be shown near to the latest
@@ -395,7 +394,40 @@ void ModuleBase_WidgetMultiSelector::onSelectionTypeChanged()
 {
   activateSelectionAndFilters(true);
 
-  clearSelection();
+  if (!myFeature)
+    return;
+  /// store the selected type
+  AttributePtr anAttribute = myFeature->data()->attribute(attributeID());
+  std::string aType = anAttribute->attributeType();
+  if (aType == ModelAPI_AttributeSelectionList::typeId()) {
+    AttributeSelectionListPtr aSelectionListAttr = myFeature->data()->selectionList(attributeID());
+    aSelectionListAttr->setSelectionType(myTypeCombo->currentText().toStdString());
+  }
+
+  // clear attribute values
+  DataPtr aData = myFeature->data();
+  if (aType == ModelAPI_AttributeSelectionList::typeId()) {
+    AttributeSelectionListPtr aSelectionListAttr = aData->selectionList(attributeID());
+    aSelectionListAttr->clear();
+  }
+  else if (aType == ModelAPI_AttributeRefList::typeId()) {
+    AttributeRefListPtr aRefListAttr = aData->reflist(attributeID());
+    aRefListAttr->clear();
+  }
+  else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
+    AttributeRefAttrListPtr aRefAttrListAttr = aData->refattrlist(attributeID());
+    aRefAttrListAttr->clear();
+  }
+
+  // update object is necessary to flush update signal. It leads to objects references map update
+  // and the operation presentation will not contain deleted items visualized as parameters of
+  // the feature.
+  updateObject(myFeature);
+  restoreValue();
+  myWorkshop->setSelected(getAttributeSelection());
+  // may be the feature's result is not displayed, but attributes should be
+  myWorkshop->module()->customizeObject(myFeature, ModuleBase_IModule::CustomizeArguments,
+                            true); /// hope that something is redisplayed by object updated
 }
 
 //********************************************************************