]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #218 Disable stratch is expandable object is in the panel
authorsbh <sergey.belash@opencascade.com>
Wed, 26 Nov 2014 18:05:11 +0000 (21:05 +0300)
committersbh <sergey.belash@opencascade.com>
Wed, 26 Nov 2014 18:05:11 +0000 (21:05 +0300)
src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp
src/XGUI/XGUI_PropertyPanel.cpp
src/XGUI/XGUI_PropertyPanel.h

index ea21968a10618d8e6ee9a29161d873644473f118..d799931f56cbfebd593bd9656c04c61edacd8828 100644 (file)
@@ -54,9 +54,10 @@ ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParen
 
   myListControl = new QListWidget(myMainWidget);
   aMainLay->addWidget(myListControl, 2, 0, 2, -1);
-  aMainLay->setColumnStretch(1, 1);
+  aMainLay->setRowStretch(2, 1);
+  aMainLay->addWidget(new QLabel(myMainWidget));
+  aMainLay->setRowMinimumHeight(3, 20);
   myMainWidget->setLayout(aMainLay);
-
   //TODO: Move into the base class
   myUseSubShapes = theData->getBooleanAttribute("use_subshapes", false);
   //TODO_END
index d36354589a1c9d57ce2881acae09cac05dda27d5..2830d85c149621163459792ed82cd09fce3d27c2 100644 (file)
@@ -8,6 +8,7 @@
 #include <XGUI_PropertyPanel.h>
 #include <XGUI_Constants.h>
 #include <ModuleBase_WidgetPoint2D.h>
+#include <ModuleBase_WidgetMultiSelector.h>
 
 #include <QWidget>
 #include <QVBoxLayout>
@@ -17,6 +18,7 @@
 #include <QVBoxLayout>
 #include <QEvent>
 #include <QKeyEvent>
+#include <QLayoutItem>
 
 #ifdef _DEBUG
 #include <iostream>
@@ -62,7 +64,7 @@ XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent)
 
   myCustomWidget = new QWidget(aContent);
   myMainLayout->addWidget(myCustomWidget);
-  myMainLayout->addStretch(1);
+  setStretchEnabled(true);
 }
 
 XGUI_PropertyPanel::~XGUI_PropertyPanel()
@@ -81,22 +83,32 @@ void XGUI_PropertyPanel::setModelWidgets(const QList<ModuleBase_ModelWidget*>& t
   myWidgets = theWidgets;
   int aS = myWidgets.size();
   if (theWidgets.empty()) return;
-
+  bool isEnableStretch = true;
   QList<ModuleBase_ModelWidget*>::const_iterator anIt = theWidgets.begin(), aLast =
       theWidgets.end();
   for (; anIt != aLast; anIt++) {
     connect(*anIt, SIGNAL(keyReleased(QKeyEvent*)), this, SIGNAL(keyReleased(QKeyEvent*)));
-
-    connect(*anIt, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)), this,
-            SLOT(activateNextWidget(ModuleBase_ModelWidget*)));
+    connect(*anIt, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)),
+            this,  SLOT(activateNextWidget(ModuleBase_ModelWidget*)));
     connect(*anIt, SIGNAL(focusInWidget(ModuleBase_ModelWidget*)),
-            this, SLOT(activateWidget(ModuleBase_ModelWidget*)));
+            this,  SLOT(activateWidget(ModuleBase_ModelWidget*)));
 
     ModuleBase_WidgetPoint2D* aPointWidget = dynamic_cast<ModuleBase_WidgetPoint2D*>(*anIt);
-    if (aPointWidget)
-      connect(aPointWidget, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)), this,
-              SIGNAL(storedPoint2D(ObjectPtr, const std::string&)));
+    if (aPointWidget) {
+      connect(aPointWidget, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)),
+              this,         SIGNAL(storedPoint2D(ObjectPtr, const std::string&)));
+    }
+
+    if (!isEnableStretch) continue;
+    foreach(QWidget* eachWidget, (*anIt)->getControls()) {
+      QSizePolicy::Policy aVPolicy = eachWidget->sizePolicy().verticalPolicy();
+      if(aVPolicy == QSizePolicy::Expanding ||
+         aVPolicy == QSizePolicy::MinimumExpanding) {
+        isEnableStretch = false;
+      }
+    }
   }
+  setStretchEnabled(isEnableStretch);
   ModuleBase_ModelWidget* aLastWidget = theWidgets.last();
   if (aLastWidget) {
     QList<QWidget*> aControls = aLastWidget->getControls();
@@ -156,6 +168,21 @@ void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget)
   //}
 }
 
+void XGUI_PropertyPanel::setStretchEnabled(bool isEnabled)
+{
+  if (myMainLayout->count() == 0)
+    return;
+  int aStretchIdx = myMainLayout->count() - 1;
+  bool hasStretch = myMainLayout->itemAt(aStretchIdx)->spacerItem() != NULL;
+  QLayoutItem* aChild;
+  if (isEnabled) {
+    if (!hasStretch) myMainLayout->addStretch(1);
+  } else if (hasStretch) {
+    aChild = myMainLayout->takeAt(aStretchIdx);
+    delete aChild;
+  }
+}
+
 void XGUI_PropertyPanel::activateNextWidget()
 {
   activateNextWidget(myActiveWidget);
index 04c4d1ed3c5521bfe40ab28368bc5de21968f906..4fdc626a95e832d36a817bbfebba6a50ecc6585d 100644 (file)
@@ -49,6 +49,8 @@ Q_OBJECT
   /// Activate the next from current widget in the property panel
   virtual void activateNextWidget();
 
+  void setStretchEnabled(bool isEnabled);
+
  public slots:
   void updateContentWidget(FeaturePtr theFeature);
   // Enables / disables "ok" ("accept") button