Salome HOME
Provide activation of the widget in edit mode
authorvsv <vitaly.smetannikov@opencascade.com>
Fri, 25 Nov 2016 11:21:52 +0000 (14:21 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Fri, 25 Nov 2016 11:21:52 +0000 (14:21 +0300)
src/CollectionPlugin/CMakeLists.txt
src/CollectionPlugin/CollectionPlugin_WidgetField.cpp
src/CollectionPlugin/CollectionPlugin_WidgetField.h

index c1b22136e81a2ee841c4aa599481ed01095a0f5c..31bd93d10052182dedcc20077f9e4c7bbfcd692a 100644 (file)
@@ -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})
index b410a3c65f92dd8377d1f6e0668947703c702342..273683e26a911775bb18f9e8ac5a50d419c0a9ac 100644 (file)
 #include <ModuleBase_IWorkshop.h>
 #include <ModuleBase_ISelection.h>
 
+#include <XGUI_Tools.h>
+#include <XGUI_Workshop.h>
+#include <XGUI_PropertyPanel.h>
+
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_AttributeStringArray.h>
 #include <ModelAPI_AttributeInteger.h>
@@ -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<QTableWidget*>(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<QWidget*> CollectionPlugin_WidgetField::getControls() const
 {
   QList<QWidget*> 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;
index 27085c393028970ef1877eab36934f27014c27e9..8466877d84c09a6d20f9d3e070242f20fee2ba3d 100644 (file)
@@ -193,6 +193,8 @@ private:
 
   /// Stae of a table editing
   bool myIsEditing;
+
+  bool myActivation;
 };
 
 #endif
\ No newline at end of file