From: vsv Date: Fri, 30 Dec 2016 11:18:04 +0000 (+0300) Subject: Store content of table item when user presses Ok button X-Git-Tag: V_2.7.0~351^2~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d3e739dbd0889d27e230d33ff54ce82b2c6b9a13;p=modules%2Fshaper.git Store content of table item when user presses Ok button --- diff --git a/src/CollectionPlugin/CollectionPlugin_WidgetField.cpp b/src/CollectionPlugin/CollectionPlugin_WidgetField.cpp index bdb55bdf3..7d091f00c 100644 --- a/src/CollectionPlugin/CollectionPlugin_WidgetField.cpp +++ b/src/CollectionPlugin/CollectionPlugin_WidgetField.cpp @@ -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(theObj); -// commitData(aWgt); -// } -// return QStyledItemDelegate::eventFilter(theObj, theEvent); -//} +void DataTableItemDelegate::onEditItem(const QString& theText) +{ + QWidget* aWgt = dynamic_cast(sender()); + commitData(aWgt); +} + //********************************************************************************** diff --git a/src/CollectionPlugin/CollectionPlugin_WidgetField.h b/src/CollectionPlugin/CollectionPlugin_WidgetField.h index 515a442aa..f56f6431b 100644 --- a/src/CollectionPlugin/CollectionPlugin_WidgetField.h +++ b/src/CollectionPlugin/CollectionPlugin_WidgetField.h @@ -49,6 +49,9 @@ public: //protected: // bool eventFilter(QObject* theObj, QEvent* theEvent); +private slots: + void onEditItem(const QString& theText); + private: ModelAPI_AttributeTables::ValueType myType; };