From: sbh Date: Wed, 26 Nov 2014 18:05:11 +0000 (+0300) Subject: Issue #218 Disable stratch is expandable object is in the panel X-Git-Tag: V_0.6.0^2~60^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=81e0a6c31838fd3f276d6b44ae24a2acc831a8f4;p=modules%2Fshaper.git Issue #218 Disable stratch is expandable object is in the panel --- diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index ea21968a1..d799931f5 100644 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -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 diff --git a/src/XGUI/XGUI_PropertyPanel.cpp b/src/XGUI/XGUI_PropertyPanel.cpp index d36354589..2830d85c1 100644 --- a/src/XGUI/XGUI_PropertyPanel.cpp +++ b/src/XGUI/XGUI_PropertyPanel.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -17,6 +18,7 @@ #include #include #include +#include #ifdef _DEBUG #include @@ -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& t myWidgets = theWidgets; int aS = myWidgets.size(); if (theWidgets.empty()) return; - + bool isEnableStretch = true; QList::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(*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 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); diff --git a/src/XGUI/XGUI_PropertyPanel.h b/src/XGUI/XGUI_PropertyPanel.h index 04c4d1ed3..4fdc626a9 100644 --- a/src/XGUI/XGUI_PropertyPanel.h +++ b/src/XGUI/XGUI_PropertyPanel.h @@ -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