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 email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 * ModuleBase_PageBase.cpp
23 * Created on: Mar 4, 2015
27 #include <ModuleBase_PageBase.h>
28 #include <ModuleBase_ModelWidget.h>
34 ModuleBase_PageBase::ModuleBase_PageBase()
39 ModuleBase_PageBase::~ModuleBase_PageBase()
44 QWidget* ModuleBase_PageBase::pageWidget()
46 return dynamic_cast<QWidget*>(this);
49 void ModuleBase_PageBase::addModelWidget(ModuleBase_ModelWidget* theWidget)
51 placeModelWidget(theWidget);
52 myWidgetList.append(theWidget);
55 void ModuleBase_PageBase::addPageWidget(ModuleBase_PageBase* thePage)
57 placePageWidget(thePage);
60 void ModuleBase_PageBase::addWidget(QWidget* theWidget)
62 placeWidget(theWidget);
65 void ModuleBase_PageBase::clearPage()
70 while ((aChild = pageLayout()->takeAt(0)) != 0) {
71 if(aChild->widget()) {
72 delete aChild->widget();
78 // Issue #460: this patch is necessary since the row stretch information
79 // is stored independently on the items: when the items are removed
80 // from the layout the stretch information is kept, so in the next
81 // filling of the layout some "additional" (old) rows may be stretched
83 // In this patch we clear the stretch information specifying the default value: 0.
84 QGridLayout* aLayout = dynamic_cast<QGridLayout*>( pageLayout() );
87 int r = aLayout->rowCount();
88 for( int i=0; i<r; i++ )
89 aLayout->setRowStretch( i, 0 );
94 bool ModuleBase_PageBase::takeFocus()
96 if(myWidgetList.isEmpty())
99 return myWidgetList.first()->focusTo();
102 QList<ModuleBase_ModelWidget*> ModuleBase_PageBase::modelWidgets() const
107 void ModuleBase_PageBase::alignToTop()
109 bool hasExpanding = false;
110 QList<QWidget *> aListToCheck;
111 ModuleBase_ModelWidget* aModelWidget;
112 foreach(aModelWidget, myWidgetList) {
113 aListToCheck << aModelWidget->getControls();
115 foreach(QWidget* eachWidget, aListToCheck) {
116 QSizePolicy::Policy aVPolicy = eachWidget->sizePolicy().verticalPolicy();
117 if(aVPolicy & QSizePolicy::ExpandFlag) {
127 void ModuleBase_PageBase::placePageWidget(ModuleBase_PageBase* theWidget)
129 QWidget* aWidget = dynamic_cast<QWidget*>(theWidget);
130 placeWidget(aWidget);