1 // Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : VisuGUI_FileDlg.cxx
26 // $Header: /dn05/salome/CVS/SALOME_ROOT/SALOME/src/VISUGUI/Visu_FileDlg.cxx
28 #include <QApplication>
29 #include <QPushButton>
34 #include "VISUConfig.hh"
35 #include "VisuGUI_FileDlg.h"
36 #include "SUIT_ResourceMgr.h"
40 bool VisuGUI_FileDlg::IsBuild = false;
45 VisuGUI_FileDlg::VisuGUI_FileDlg (QWidget* parent,
49 SUIT_FileDlg(parent, open, showQuickDir, modal)
51 myCBuildAll = new QCheckBox (tr("FULL_LOAD"), this);
53 QLabel* label = new QLabel("", this);
54 label->setMaximumWidth(0);
55 QPushButton* pb = new QPushButton(this);
56 pb->setMaximumWidth(0);
57 addWidgets( label, myCBuildAll, pb );
59 bool toBuildAll = VISU::GetResourceMgr()->booleanValue("VISU", "full_med_loading", false);
60 if (toBuildAll) myCBuildAll->setChecked(true);
66 VisuGUI_FileDlg::~VisuGUI_FileDlg()
71 Processes selection : tries to set given path or filename as selection
73 bool VisuGUI_FileDlg::processPath( const QString& path )
75 if ( !path.isNull() ) {
80 setDirectory( fi.absoluteDir().absolutePath() );
81 selectFile( fi.fileName() );
83 else if ( fi.isDir() )
88 if ( QFileInfo( fi.absoluteDir().absolutePath() ).exists() ) {
89 setDirectory( fi.absoluteDir().absolutePath() );
98 Returns the file name for Open/Save [ static ]
100 QString VisuGUI_FileDlg::getFileName( QWidget* parent,
101 const QString& initial,
102 const QStringList& filters,
103 const QString& caption,
106 SUIT_FileValidator* validator )
108 VisuGUI_FileDlg* fd = new VisuGUI_FileDlg( parent, open, showQuickDir, true );
109 if ( !caption.isEmpty() )
110 fd->setWindowTitle( caption );
111 if ( !initial.isEmpty() ) {
112 fd->processPath( initial ); // VSR 24/03/03 check for existing of directory has been added to avoid QFileDialog's bug
114 fd->setFilters( filters );
116 fd->setValidator( validator );
118 QString filename = fd->selectedFile();
120 VisuGUI_FileDlg::IsBuild = fd->IsChecked();
123 qApp->processEvents();
128 bool VisuGUI_FileDlg::IsChecked()
130 return myCBuildAll->isChecked();