1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #include <ModuleBase_PageBase.h>
22 #include <ModuleBase_ModelWidget.h>
28 ModuleBase_PageBase::ModuleBase_PageBase()
33 ModuleBase_PageBase::~ModuleBase_PageBase()
38 QWidget* ModuleBase_PageBase::pageWidget()
40 return dynamic_cast<QWidget*>(this);
43 void ModuleBase_PageBase::addModelWidget(ModuleBase_ModelWidget* theWidget)
45 placeModelWidget(theWidget);
46 myWidgetList.append(theWidget);
49 void ModuleBase_PageBase::addPageWidget(ModuleBase_PageBase* thePage)
51 placePageWidget(thePage);
54 void ModuleBase_PageBase::addWidget(QWidget* theWidget)
56 placeWidget(theWidget);
59 void ModuleBase_PageBase::clearPage()
64 while ((aChild = pageLayout()->takeAt(0)) != 0) {
65 if(aChild->widget()) {
66 delete aChild->widget();
72 // Issue #460: this patch is necessary since the row stretch information
73 // is stored independently on the items: when the items are removed
74 // from the layout the stretch information is kept, so in the next
75 // filling of the layout some "additional" (old) rows may be stretched
77 // In this patch we clear the stretch information specifying the default value: 0.
78 QGridLayout* aLayout = dynamic_cast<QGridLayout*>( pageLayout() );
81 int r = aLayout->rowCount();
82 for( int i=0; i<r; i++ )
83 aLayout->setRowStretch( i, 0 );
88 bool ModuleBase_PageBase::takeFocus()
90 if(myWidgetList.isEmpty())
93 return myWidgetList.first()->focusTo();
96 QList<ModuleBase_ModelWidget*> ModuleBase_PageBase::modelWidgets() const
101 void ModuleBase_PageBase::alignToTop()
103 bool hasExpanding = false;
104 QList<QWidget *> aListToCheck;
105 ModuleBase_ModelWidget* aModelWidget;
106 foreach(aModelWidget, myWidgetList) {
107 aListToCheck << aModelWidget->getControls();
109 foreach(QWidget* eachWidget, aListToCheck) {
110 QSizePolicy::Policy aVPolicy = eachWidget->sizePolicy().verticalPolicy();
111 if(aVPolicy & QSizePolicy::ExpandFlag) {
121 void ModuleBase_PageBase::placePageWidget(ModuleBase_PageBase* theWidget)
123 QWidget* aWidget = dynamic_cast<QWidget*>(theWidget);
124 placeWidget(aWidget);