2 * ModuleBase_PageBase.cpp
4 * Created on: Mar 4, 2015
8 #include <ModuleBase_PageBase.h>
9 #include <ModuleBase_ModelWidget.h>
15 ModuleBase_PageBase::ModuleBase_PageBase()
20 ModuleBase_PageBase::~ModuleBase_PageBase()
25 QWidget* ModuleBase_PageBase::pageWidget()
27 return dynamic_cast<QWidget*>(this);
30 void ModuleBase_PageBase::addModelWidget(ModuleBase_ModelWidget* theWidget)
32 placeModelWidget(theWidget);
33 myWidgetList.append(theWidget);
36 void ModuleBase_PageBase::addPageWidget(ModuleBase_PageBase* thePage)
38 placePageWidget(thePage);
41 void ModuleBase_PageBase::clearPage()
44 while ((aChild = pageLayout()->takeAt(0)) != 0) {
45 if(aChild->widget()) {
46 aChild->widget()->deleteLater();
52 // Issue #460: this patch is necessary since the row stretch information
53 // is stored independently on the items: when the items are removed
54 // from the layout the stretch information is kept, so in the next
55 // filling of the layout some "additional" (old) rows may be stretched
57 // In this patch we clear the stretch information specifying the default value: 0.
58 QGridLayout* aLayout = dynamic_cast<QGridLayout*>( pageLayout() );
61 int r = aLayout->rowCount();
62 for( int i=0; i<r; i++ )
63 aLayout->setRowStretch( i, 0 );
69 bool ModuleBase_PageBase::takeFocus()
71 if(myWidgetList.isEmpty())
74 return myWidgetList.first()->focusTo();
77 QList<ModuleBase_ModelWidget*> ModuleBase_PageBase::modelWidgets()
82 void ModuleBase_PageBase::alignToTop()
84 bool hasExpanding = false;
85 QList<QWidget *> aListToCheck;
86 ModuleBase_ModelWidget* aModelWidget;
87 foreach(aModelWidget, myWidgetList) {
88 aListToCheck << aModelWidget->getControls();
90 foreach(QWidget* eachWidget, aListToCheck) {
91 QSizePolicy::Policy aVPolicy = eachWidget->sizePolicy().verticalPolicy();
92 if(aVPolicy & QSizePolicy::ExpandFlag) {