]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/CollectionPlugin/CollectionPlugin_WidgetField.cpp
Salome HOME
Meet the coding style (line length <= 100)
[modules/shaper.git] / src / CollectionPlugin / CollectionPlugin_WidgetField.cpp
index c3495b7ee447c90a8edad42d8830d06d1042ba9d..a34c6e6218f35213e62611ce481a8875e94bfe8d 100644 (file)
@@ -84,23 +84,26 @@ QWidget* DataTableItemDelegate::createEditor(QWidget* theParent,
         aBox->addItem(MYTrue);
         aEditor = aBox;
       }
+      break;
+    default:
+      aEditor = QStyledItemDelegate::createEditor(theParent, theOption, theIndex);
     }
   }
-  aEditor = QStyledItemDelegate::createEditor(theParent, theOption, theIndex);
-  //QObject* aThat = (QObject*) this;
-  //aEditor->installEventFilter(aThat);
+  if (myType == ModelAPI_AttributeTables::BOOLEAN)
+    connect(aEditor, SIGNAL(currentTextChanged(const QString&)),
+      SLOT(onEditItem(const QString&)));
+  else
+    connect(aEditor, SIGNAL(textEdited(const QString&)),
+      SLOT(onEditItem(const QString&)));
   return aEditor;
 }
 
-//bool DataTableItemDelegate::eventFilter(QObject* theObj, QEvent* theEvent)
-//{
-//  qDebug("### Type = %i", theEvent->type());
-//  if (theEvent->type() == QEvent::Close) {
-//    QWidget* aWgt = dynamic_cast<QWidget*>(theObj);
-//    commitData(aWgt);
-//  }
-//  return QStyledItemDelegate::eventFilter(theObj, theEvent);
-//}
+void DataTableItemDelegate::onEditItem(const QString& theText)
+{
+  QWidget* aWgt = dynamic_cast<QWidget*>(sender());
+  commitData(aWgt);
+}
+
 
 
 //**********************************************************************************
@@ -496,7 +499,9 @@ bool CollectionPlugin_WidgetField::restoreValueCustom()
   std::string aTypeStr = aSelList->selectionType();
   if (aTypeStr == "")
     return false; // The attribute is not initialized
+  isBlocked = myShapeTypeCombo->blockSignals(true);
   myShapeTypeCombo->setCurrentIndex(getSelectionType(aTypeStr));
+  myShapeTypeCombo->blockSignals(isBlocked);
 
   // Get number of components
   AttributeStringArrayPtr aStringsAttr =
@@ -823,8 +828,12 @@ bool CollectionPlugin_WidgetField::
   for (anIt = theValues.begin(); anIt != theValues.end(); anIt++) {
     ModuleBase_ViewerPrsPtr aValue = *anIt;
     ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aValue->object());
-    if (theToValidate && aRes.get() && acceptSubShape(aValue->shape(), aRes))
-      aSelected.append(aValue);
+    if (theToValidate && aRes.get()) {
+      if (myShapeTypeCombo->currentIndex() > 3)
+        aSelected.append(aValue);
+      else if (acceptSubShape(aValue->shape(), aRes))
+        aSelected.append(aValue);
+    }
   }
   AttributeSelectionListPtr aSelList =
     myFeature->data()->selectionList(CollectionPlugin_Field::SELECTED_ID());