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_StricklerTableDlg.h"
20 #include "HYDROGUI_Module.h"
22 #include <LightApp_Application.h>
24 #include <SUIT_Session.h>
25 #include <SUIT_ResourceMgr.h>
26 #include <SUIT_FileDlg.h>
27 #include <SUIT_Desktop.h>
28 #include <SUIT_MessageBox.h>
32 #include <QToolButton>
36 HYDROGUI_StricklerTableDlg::HYDROGUI_StricklerTableDlg( HYDROGUI_Module* theModule, const QString& theTitle )
37 : HYDROGUI_InputPanel( theModule, theTitle ), myName(NULL)
39 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
41 // Import Strickler table from file
42 myFileNameGroup = new QGroupBox( tr( "IMPORT_STRICKLER_TABLE_FROM_FILE" ), this );
44 QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), myFileNameGroup );
46 myFileName = new QLineEdit( myFileNameGroup );
47 myFileName->setReadOnly( true );
49 myBrowseBtn = new QToolButton( myFileNameGroup );
50 myBrowseBtn->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "BROWSE_ICO" ) ) );
52 QBoxLayout* aFileNameLayout = new QHBoxLayout( myFileNameGroup );
53 aFileNameLayout->setMargin( 5 );
54 aFileNameLayout->setSpacing( 5 );
55 aFileNameLayout->addWidget( aFileNameLabel );
56 aFileNameLayout->addWidget( myFileName );
57 aFileNameLayout->addWidget( myBrowseBtn );
59 // Strickler table name
60 myNameGroup = new QGroupBox( tr( "STRICKLER_TABLE_NAME" ), this );
62 QLabel* anImageNameLabel = new QLabel( tr( "NAME" ), myNameGroup );
63 myName = new QLineEdit( myNameGroup );
65 QBoxLayout* anImageNameLayout = new QHBoxLayout( myNameGroup );
66 anImageNameLayout->setMargin( 5 );
67 anImageNameLayout->setSpacing( 5 );
68 anImageNameLayout->addWidget( anImageNameLabel );
69 anImageNameLayout->addWidget( myName );
75 addWidget( myFileNameGroup );
76 addWidget( myNameGroup );
77 //addWidget( myTableGroup );
80 connect( myBrowseBtn, SIGNAL( clicked() ), this, SLOT( onBrowse() ) );
82 setMinimumWidth( 350 );
85 HYDROGUI_StricklerTableDlg::~HYDROGUI_StricklerTableDlg()
89 void HYDROGUI_StricklerTableDlg::setIsEdit( const bool theIsEdit )
91 myFileNameGroup->setVisible( !theIsEdit );
92 myNameGroup->setEnabled( theIsEdit );
93 //myTableGroup->setEnabled( theIsEdit );
96 void HYDROGUI_StricklerTableDlg::reset()
101 myNameGroup->setEnabled( false );
103 //myTableGroup->setEnabled( false );
105 //myIsInitialized = false;
108 QString HYDROGUI_StricklerTableDlg::getFileName() const
110 return myFileName->text();
113 void HYDROGUI_StricklerTableDlg::setFileName( const QString& theName )
115 myFileName->setText( theName );
118 void HYDROGUI_StricklerTableDlg::setStricklerTableName( const QString& theName )
120 myName->setText(theName);
123 QString HYDROGUI_StricklerTableDlg::getStricklerTableName() const
125 return myName->text();
128 void HYDROGUI_StricklerTableDlg::onBrowse()
130 QString aFilter( tr( "STRICKLER_TABLE_FILTER" ) );
131 QString aFileName = SUIT_FileDlg::getFileName( this, "", aFilter, tr( "IMPORT_STRICKLER_TABLE_FROM_FILE" ), true );
132 if( !aFileName.isEmpty() )
134 setFileName( aFileName );
135 emit fileSelected( aFileName );