1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "HYDROGUI_StricklerTypeComboBox.h"
21 #include "HYDROGUI_Module.h"
27 #include <HYDROData_Iterator.h>
28 #include <HYDROData_Document.h>
29 #include <HYDROData_StricklerTable.h>
31 HYDROGUI_StricklerTypeComboBox::HYDROGUI_StricklerTypeComboBox( HYDROGUI_Module* theModule,
32 const QString& theTitle,
34 : QWidget( theParent ),
37 QBoxLayout* base = new QHBoxLayout( this );
40 if ( !theTitle.isEmpty() )
41 base->addWidget( new QLabel( theTitle, this ) );
42 myStricklerTypes = new QComboBox( this );
43 myStricklerTypes->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
44 base->addWidget( myStricklerTypes );
48 // Construct a list of unique names of all Strickler types defined within the data model
49 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document();
52 QStringList aStricklerTypes;
53 HYDROData_Iterator anIterator( aDoc, KIND_STRICKLER_TABLE );
54 for( ; anIterator.More(); anIterator.Next() )
56 Handle(HYDROData_StricklerTable) aStricklerTableObj =
57 Handle(HYDROData_StricklerTable)::DownCast( anIterator.Current() );
58 if ( !aStricklerTableObj.IsNull() )
60 // Get Strickler table data from the data model
61 QStringList aTypes = aStricklerTableObj->GetTypes();
62 for ( QStringList::iterator it = aTypes.begin(); it != aTypes.end(); ++it )
65 if ( !aType.isEmpty() && !aStricklerTypes.contains( aType ) )
66 aStricklerTypes.append( aType );
71 aStricklerTypes.sort();
72 setStricklerTypes( aStricklerTypes );
77 HYDROGUI_StricklerTypeComboBox::~HYDROGUI_StricklerTypeComboBox()
81 HYDROGUI_Module* HYDROGUI_StricklerTypeComboBox::module() const
86 void HYDROGUI_StricklerTypeComboBox::setStricklerTypes( const QStringList& theTypes )
88 bool isBlocked = blockSignals( true );
90 myStricklerTypes->clear();
91 myStricklerTypes->addItems( theTypes );
93 blockSignals( isBlocked );
96 void HYDROGUI_StricklerTypeComboBox::setSelectedStricklerTypeName( const QString& theName )
98 myStricklerTypes->setCurrentIndex( myStricklerTypes->findText( theName ) );
101 QString HYDROGUI_StricklerTypeComboBox::getSelectedStricklerTypeName() const
103 return myStricklerTypes->currentText();