]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Store content of table item when user presses Ok button
authorvsv <vitaly.smetannikov@opencascade.com>
Fri, 30 Dec 2016 11:18:04 +0000 (14:18 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Fri, 30 Dec 2016 11:18:04 +0000 (14:18 +0300)
src/CollectionPlugin/CollectionPlugin_WidgetField.cpp
src/CollectionPlugin/CollectionPlugin_WidgetField.h

index bdb55bdf3b549f63af391edc6403a8ef12e5d624..7d091f00c31505f41d8a589473daeebcd7433ca1 100644 (file)
@@ -89,20 +89,21 @@ QWidget* DataTableItemDelegate::createEditor(QWidget* theParent,
       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);
+}
+
 
 
 //**********************************************************************************
index 515a442aaf3dfd878b15dcf48546dce9eb46e853..f56f6431b3d08760d17432ead6f5ccfdd4b3a0e8 100644 (file)
@@ -49,6 +49,9 @@ public:
 //protected:
 //  bool eventFilter(QObject* theObj, QEvent* theEvent);
 
+private slots:
+  void onEditItem(const QString& theText);
+
 private:
   ModelAPI_AttributeTables::ValueType myType;
 };