From 23b92af3e95c098cd24ab17dd2e597427b2f1962 Mon Sep 17 00:00:00 2001 From: vsv Date: Fri, 25 Nov 2016 14:21:52 +0300 Subject: [PATCH] Provide activation of the widget in edit mode --- src/CollectionPlugin/CMakeLists.txt | 2 ++ .../CollectionPlugin_WidgetField.cpp | 27 ++++++++++++++++--- .../CollectionPlugin_WidgetField.h | 2 ++ 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/CollectionPlugin/CMakeLists.txt b/src/CollectionPlugin/CMakeLists.txt index c1b22136e..31bd93d10 100644 --- a/src/CollectionPlugin/CMakeLists.txt +++ b/src/CollectionPlugin/CMakeLists.txt @@ -41,6 +41,7 @@ INCLUDE_DIRECTORIES( ../Events ../ModuleBase ../Config + ../XGUI ${CAS_INCLUDE_DIRS} ) @@ -51,6 +52,7 @@ SET(PROJECT_LIBRARIES GeomAlgoAPI GeomValidators ModuleBase + XGUI ) ADD_DEFINITIONS(-DCOLLECTIONPLUGIN_EXPORTS ${CAS_DEFINITIONS}) diff --git a/src/CollectionPlugin/CollectionPlugin_WidgetField.cpp b/src/CollectionPlugin/CollectionPlugin_WidgetField.cpp index b410a3c65..273683e26 100644 --- a/src/CollectionPlugin/CollectionPlugin_WidgetField.cpp +++ b/src/CollectionPlugin/CollectionPlugin_WidgetField.cpp @@ -11,6 +11,10 @@ #include #include +#include +#include +#include + #include #include #include @@ -112,7 +116,7 @@ CollectionPlugin_WidgetField:: ModuleBase_IWorkshop* theWorkshop, const Config_WidgetAPI* theData): ModuleBase_WidgetSelector(theParent, theWorkshop, theData), myHeaderEditor(0), - myIsEditing(false) + myIsEditing(false), myActivation(false) { QVBoxLayout* aMainLayout = new QVBoxLayout(this); @@ -223,6 +227,7 @@ void CollectionPlugin_WidgetField::appendStepControls() // Data table QTableWidget* aDataTbl = new QTableWidget(1, myCompNamesList.count() + 1, aWidget); + aDataTbl->installEventFilter(this); DataTableItemDelegate* aDelegate = 0; if (myDataTblList.isEmpty()) aDelegate = new DataTableItemDelegate( @@ -330,6 +335,16 @@ bool CollectionPlugin_WidgetField::eventFilter(QObject* theObject, QEvent* theEv foreach(QTableWidget* aTable, myDataTblList) { updateHeaders(aTable); } + } else if (theEvent->type() == QEvent::FocusIn) { + QTableWidget* aTable = dynamic_cast(theObject); + if (aTable) { + XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop); + XGUI_PropertyPanel* aPanel = aWorkshop->propertyPanel(); + if (aPanel->activeWidget() != this) { + myActivation = true; + aPanel->activateWidget(this, false); + } + } } return ModuleBase_WidgetSelector::eventFilter(theObject, theEvent); } @@ -397,9 +412,9 @@ QList CollectionPlugin_WidgetField::getControls() const { QList aControls; // this control will accept focus and will be highlighted in the Property Panel - aControls.push_back(myStepWgt); - //aControls.push_back(myFieldTypeCombo); - //aControls.push_back(myNbComponentsSpn); + aControls.push_back(myShapeTypeCombo); + aControls.push_back(myFieldTypeCombo); + aControls.push_back(myNbComponentsSpn); return aControls; } @@ -730,6 +745,10 @@ bool CollectionPlugin_WidgetField:: //********************************************************************************** void CollectionPlugin_WidgetField::onSelectionChanged() { + if (myActivation) { + myActivation = false; + return; + } // Ignore selection for Parts mode if (myShapeTypeCombo->currentIndex() == 5) return; diff --git a/src/CollectionPlugin/CollectionPlugin_WidgetField.h b/src/CollectionPlugin/CollectionPlugin_WidgetField.h index 27085c393..8466877d8 100644 --- a/src/CollectionPlugin/CollectionPlugin_WidgetField.h +++ b/src/CollectionPlugin/CollectionPlugin_WidgetField.h @@ -193,6 +193,8 @@ private: /// Stae of a table editing bool myIsEditing; + + bool myActivation; }; #endif \ No newline at end of file -- 2.39.2