1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 * ModuleBase_PageBase.cpp
5 * Created on: Mar 4, 2015
9 #include <ModuleBase_PageBase.h>
10 #include <ModuleBase_ModelWidget.h>
16 ModuleBase_PageBase::ModuleBase_PageBase()
21 ModuleBase_PageBase::~ModuleBase_PageBase()
26 QWidget* ModuleBase_PageBase::pageWidget()
28 return dynamic_cast<QWidget*>(this);
31 void ModuleBase_PageBase::addModelWidget(ModuleBase_ModelWidget* theWidget)
33 placeModelWidget(theWidget);
34 myWidgetList.append(theWidget);
37 void ModuleBase_PageBase::addPageWidget(ModuleBase_PageBase* thePage)
39 placePageWidget(thePage);
42 void ModuleBase_PageBase::addWidget(QWidget* theWidget)
44 placeWidget(theWidget);
47 void ModuleBase_PageBase::clearPage()
52 while ((aChild = pageLayout()->takeAt(0)) != 0) {
53 if(aChild->widget()) {
54 delete aChild->widget();
60 // Issue #460: this patch is necessary since the row stretch information
61 // is stored independently on the items: when the items are removed
62 // from the layout the stretch information is kept, so in the next
63 // filling of the layout some "additional" (old) rows may be stretched
65 // In this patch we clear the stretch information specifying the default value: 0.
66 QGridLayout* aLayout = dynamic_cast<QGridLayout*>( pageLayout() );
69 int r = aLayout->rowCount();
70 for( int i=0; i<r; i++ )
71 aLayout->setRowStretch( i, 0 );
76 bool ModuleBase_PageBase::takeFocus()
78 if(myWidgetList.isEmpty())
81 return myWidgetList.first()->focusTo();
84 QList<ModuleBase_ModelWidget*> ModuleBase_PageBase::modelWidgets() const
89 void ModuleBase_PageBase::alignToTop()
91 bool hasExpanding = false;
92 QList<QWidget *> aListToCheck;
93 ModuleBase_ModelWidget* aModelWidget;
94 foreach(aModelWidget, myWidgetList) {
95 aListToCheck << aModelWidget->getControls();
97 foreach(QWidget* eachWidget, aListToCheck) {
98 QSizePolicy::Policy aVPolicy = eachWidget->sizePolicy().verticalPolicy();
99 if(aVPolicy & QSizePolicy::ExpandFlag) {
109 void ModuleBase_PageBase::placePageWidget(ModuleBase_PageBase* theWidget)
111 QWidget* aWidget = dynamic_cast<QWidget*>(theWidget);
112 placeWidget(aWidget);