Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0
[modules/shaper.git] / src / ModuleBase / ModuleBase_PageBase.cpp
index 5adaebf34b668d7f365c883dae5cdeaef8d90488..027150f22426c45f4538ea262119d8399c3abe91 100644 (file)
@@ -22,6 +22,11 @@ ModuleBase_PageBase::~ModuleBase_PageBase()
 
 }
 
+QWidget* ModuleBase_PageBase::pageWidget()
+{
+  return dynamic_cast<QWidget*>(this);
+}
+
 void ModuleBase_PageBase::addModelWidget(ModuleBase_ModelWidget* theWidget)
 {
   placeModelWidget(theWidget);
@@ -35,20 +40,47 @@ void ModuleBase_PageBase::addPageWidget(ModuleBase_PageBase* thePage)
 
 void ModuleBase_PageBase::clearPage()
 {
-  qDeleteAll(pageLayout()->children());
+  QLayoutItem *aChild;
+  while ((aChild = pageLayout()->takeAt(0)) != 0) {
+    if(aChild->widget()) {
+      aChild->widget()->deleteLater();
+    } else {
+      delete aChild;
+    }
+  }
   myWidgetList.clear();
 }
 
 
-void ModuleBase_PageBase::takeFocus()
+bool ModuleBase_PageBase::takeFocus()
 {
   if(myWidgetList.isEmpty())
-    return;
+    return false;
 
-  myWidgetList.first()->focusTo();
+  return myWidgetList.first()->focusTo();
 }
 
 QList<ModuleBase_ModelWidget*> ModuleBase_PageBase::modelWidgets()
 {
   return myWidgetList;
 }
+
+void ModuleBase_PageBase::alignToTop()
+{
+  bool hasExpanding = false;
+  QList<QWidget *> 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();
+  }
+}