X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_PageBase.cpp;h=ed9fb7694031d374eb4120e8ee216a60a9afe5bd;hb=8cd56d486b6e96b8814002f9f0f4acadd6cea11b;hp=5adaebf34b668d7f365c883dae5cdeaef8d90488;hpb=2734393c7c19899fca7e7c36577b31317887a9c9;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_PageBase.cpp b/src/ModuleBase/ModuleBase_PageBase.cpp index 5adaebf34..ed9fb7694 100644 --- a/src/ModuleBase/ModuleBase_PageBase.cpp +++ b/src/ModuleBase/ModuleBase_PageBase.cpp @@ -22,6 +22,11 @@ ModuleBase_PageBase::~ModuleBase_PageBase() } +QWidget* ModuleBase_PageBase::pageWidget() +{ + return dynamic_cast(this); +} + void ModuleBase_PageBase::addModelWidget(ModuleBase_ModelWidget* theWidget) { placeModelWidget(theWidget); @@ -35,20 +40,62 @@ void ModuleBase_PageBase::addPageWidget(ModuleBase_PageBase* thePage) void ModuleBase_PageBase::clearPage() { - qDeleteAll(pageLayout()->children()); myWidgetList.clear(); + + QLayoutItem *aChild; + while ((aChild = pageLayout()->takeAt(0)) != 0) { + if(aChild->widget()) { + delete aChild->widget(); + } else { + delete aChild; + } + } + + // Issue #460: this patch is necessary since the row stretch information + // is stored independently on the items: when the items are removed + // from the layout the stretch information is kept, so in the next + // filling of the layout some "additional" (old) rows may be stretched + // without necessity. + // In this patch we clear the stretch information specifying the default value: 0. + QGridLayout* aLayout = dynamic_cast( pageLayout() ); + if( aLayout ) + { + int r = aLayout->rowCount(); + for( int i=0; isetRowStretch( i, 0 ); + } } -void ModuleBase_PageBase::takeFocus() +bool ModuleBase_PageBase::takeFocus() { if(myWidgetList.isEmpty()) - return; + return false; - myWidgetList.first()->focusTo(); + return myWidgetList.first()->focusTo(); } QList ModuleBase_PageBase::modelWidgets() { return myWidgetList; } + +void ModuleBase_PageBase::alignToTop() +{ + bool hasExpanding = false; + QList aListToCheck; + ModuleBase_ModelWidget* aModelWidget; + foreach(aModelWidget, myWidgetList) { + aListToCheck << aModelWidget->getControls(); + } + foreach(QWidget* eachWidget, aListToCheck) { + QSizePolicy::Policy aVPolicy = eachWidget->sizePolicy().verticalPolicy(); + if(aVPolicy & QSizePolicy::ExpandFlag) { + hasExpanding = true; + break; + } + } + if(!hasExpanding) { + addPageStretch(); + } +}