1 // Copyright (C) 2014-2019 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 email : webmaster.salome@opencascade.com
20 #include <ModuleBase_PageBase.h>
21 #include <ModuleBase_ModelWidget.h>
27 ModuleBase_PageBase::ModuleBase_PageBase()
32 ModuleBase_PageBase::~ModuleBase_PageBase()
37 QWidget* ModuleBase_PageBase::pageWidget()
39 return dynamic_cast<QWidget*>(this);
42 void ModuleBase_PageBase::addModelWidget(ModuleBase_ModelWidget* theWidget)
44 placeModelWidget(theWidget);
45 myWidgetList.append(theWidget);
48 void ModuleBase_PageBase::addPageWidget(ModuleBase_PageBase* thePage)
50 placePageWidget(thePage);
53 void ModuleBase_PageBase::addWidget(QWidget* theWidget)
55 placeWidget(theWidget);
58 void ModuleBase_PageBase::clearPage()
63 while ((aChild = pageLayout()->takeAt(0)) != 0) {
64 if(aChild->widget()) {
65 delete aChild->widget();
71 // Issue #460: this patch is necessary since the row stretch information
72 // is stored independently on the items: when the items are removed
73 // from the layout the stretch information is kept, so in the next
74 // filling of the layout some "additional" (old) rows may be stretched
76 // In this patch we clear the stretch information specifying the default value: 0.
77 QGridLayout* aLayout = dynamic_cast<QGridLayout*>( pageLayout() );
80 int r = aLayout->rowCount();
81 for( int i=0; i<r; i++ )
82 aLayout->setRowStretch( i, 0 );
87 bool ModuleBase_PageBase::takeFocus()
89 if(myWidgetList.isEmpty())
92 return myWidgetList.first()->focusTo();
95 QList<ModuleBase_ModelWidget*> ModuleBase_PageBase::modelWidgets() const
100 void ModuleBase_PageBase::alignToTop()
102 bool hasExpanding = false;
103 QList<QWidget *> aListToCheck;
104 ModuleBase_ModelWidget* aModelWidget;
105 foreach(aModelWidget, myWidgetList) {
106 aListToCheck << aModelWidget->getControls();
108 foreach(QWidget* eachWidget, aListToCheck) {
109 QSizePolicy::Policy aVPolicy = eachWidget->sizePolicy().verticalPolicy();
110 if(aVPolicy & QSizePolicy::ExpandFlag) {
120 void ModuleBase_PageBase::placePageWidget(ModuleBase_PageBase* theWidget)
122 QWidget* aWidget = dynamic_cast<QWidget*>(theWidget);
123 placeWidget(aWidget);