From: vsv Date: Fri, 30 Dec 2016 08:53:07 +0000 (+0300) Subject: Issue #1949: Process first enter as entering a data X-Git-Tag: V_2.7.0~351^2~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c9bdacd8d72a1dbfdba7ad176984dfe8e29121d5;p=modules%2Fshaper.git Issue #1949: Process first enter as entering a data --- diff --git a/src/CollectionPlugin/CollectionPlugin_WidgetField.cpp b/src/CollectionPlugin/CollectionPlugin_WidgetField.cpp index 509789ad9..c3495b7ee 100644 --- a/src/CollectionPlugin/CollectionPlugin_WidgetField.cpp +++ b/src/CollectionPlugin/CollectionPlugin_WidgetField.cpp @@ -40,15 +40,22 @@ const char* MYFirstCol = "Shape"; const char* MYTrue = "True"; const char* MYFalse = "False"; +DataTableItemDelegate::DataTableItemDelegate(ModelAPI_AttributeTables::ValueType theType) + : QStyledItemDelegate(), myType(theType) +{ +} + + QWidget* DataTableItemDelegate::createEditor(QWidget* theParent, const QStyleOptionViewItem & theOption, const QModelIndex& theIndex ) const { + QWidget* aEditor = 0; if ((theIndex.column() == 0) && (theIndex.row() > 0)) { QWidget* aWgt = QStyledItemDelegate::createEditor(theParent, theOption, theIndex); QLineEdit* aEdt = static_cast(aWgt); aEdt->setReadOnly(true); - return aEdt; + aEditor = aEdt; } else { QLineEdit* aLineEdt = 0; switch (myType) { @@ -58,7 +65,7 @@ QWidget* DataTableItemDelegate::createEditor(QWidget* theParent, theIndex)); if (aLineEdt) { aLineEdt->setValidator(new QDoubleValidator(aLineEdt)); - return aLineEdt; + aEditor = aLineEdt; } break; case ModelAPI_AttributeTables::INTEGER: @@ -67,7 +74,7 @@ QWidget* DataTableItemDelegate::createEditor(QWidget* theParent, theIndex)); if (aLineEdt) { aLineEdt->setValidator(new QIntValidator(aLineEdt)); - return aLineEdt; + aEditor = aLineEdt; } break; case ModelAPI_AttributeTables::BOOLEAN: @@ -75,13 +82,25 @@ QWidget* DataTableItemDelegate::createEditor(QWidget* theParent, QComboBox* aBox = new QComboBox(theParent); aBox->addItem(MYFalse); aBox->addItem(MYTrue); - return aBox; + aEditor = aBox; } } } - return QStyledItemDelegate::createEditor(theParent, theOption, theIndex); + aEditor = QStyledItemDelegate::createEditor(theParent, theOption, theIndex); + //QObject* aThat = (QObject*) this; + //aEditor->installEventFilter(aThat); + 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); +//} //********************************************************************************** @@ -413,9 +432,14 @@ QList CollectionPlugin_WidgetField::getControls() const { QList aControls; // this control will accept focus and will be highlighted in the Property Panel - aControls.push_back(myShapeTypeCombo); - aControls.push_back(myFieldTypeCombo); - aControls.push_back(myNbComponentsSpn); + aControls.append(myShapeTypeCombo); + aControls.append(myFieldTypeCombo); + aControls.append(myNbComponentsSpn); + if (myStampSpnList.size() > 0) + aControls.append(myStampSpnList.first()); + if (myDataTblList.size() > 0) + aControls.append(myDataTblList.first()); + return aControls; } @@ -946,6 +970,16 @@ bool CollectionPlugin_WidgetField::processEnter() myIsTabEdit = false; return true; } + QWidget* aCurrWgt = qApp->focusWidget(); + int aCurWgtId = myStepWgt->currentIndex(); + if ((aCurrWgt == myShapeTypeCombo) || + (aCurrWgt == myFieldTypeCombo) || + (aCurrWgt == myNbComponentsSpn) || + (aCurrWgt == myStampSpnList[aCurWgtId]) || + (aCurrWgt == myDataTblList[aCurWgtId])) { + setFocus(); + return true; + } return false; } diff --git a/src/CollectionPlugin/CollectionPlugin_WidgetField.h b/src/CollectionPlugin/CollectionPlugin_WidgetField.h index e0084fcb3..515a442aa 100644 --- a/src/CollectionPlugin/CollectionPlugin_WidgetField.h +++ b/src/CollectionPlugin/CollectionPlugin_WidgetField.h @@ -36,8 +36,7 @@ class DataTableItemDelegate : public QStyledItemDelegate { Q_OBJECT public: - DataTableItemDelegate(ModelAPI_AttributeTables::ValueType theType) : - QStyledItemDelegate() { myType = theType; } + DataTableItemDelegate(ModelAPI_AttributeTables::ValueType theType); virtual QWidget* createEditor(QWidget* theParent, const QStyleOptionViewItem & theOption, @@ -47,6 +46,9 @@ public: void setDataType(ModelAPI_AttributeTables::ValueType theType) { myType = theType; } +//protected: +// bool eventFilter(QObject* theObj, QEvent* theEvent); + private: ModelAPI_AttributeTables::ValueType myType; };