1 // Copyright (C) 2007-2008 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
22 // File : VisuGUI_FileDlg.cxx
25 // $Header: /dn05/salome/CVS/SALOME_ROOT/SALOME/src/VISUGUI/Visu_FileDlg.cxx
27 #include <QApplication>
28 #include <QPushButton>
33 #include "VISUConfig.hh"
34 #include "VisuGUI_FileDlg.h"
35 #include "SUIT_ResourceMgr.h"
39 bool VisuGUI_FileDlg::IsBuild = false;
44 VisuGUI_FileDlg::VisuGUI_FileDlg (QWidget* parent,
48 SUIT_FileDlg(parent, open, showQuickDir, modal)
50 myCBuildAll = new QCheckBox (tr("FULL_LOAD"), this);
52 QLabel* label = new QLabel("", this);
53 label->setMaximumWidth(0);
54 QPushButton* pb = new QPushButton(this);
55 pb->setMaximumWidth(0);
56 addWidgets( label, myCBuildAll, pb );
58 bool toBuildAll = VISU::GetResourceMgr()->booleanValue("VISU", "full_med_loading", false);
59 if (toBuildAll) myCBuildAll->setChecked(true);
65 VisuGUI_FileDlg::~VisuGUI_FileDlg()
70 Processes selection : tries to set given path or filename as selection
72 bool VisuGUI_FileDlg::processPath( const QString& path )
74 if ( !path.isNull() ) {
79 setDirectory( fi.absoluteDir().absolutePath() );
80 selectFile( fi.fileName() );
82 else if ( fi.isDir() )
87 if ( QFileInfo( fi.absoluteDir().absolutePath() ).exists() ) {
88 setDirectory( fi.absoluteDir().absolutePath() );
97 Returns the file name for Open/Save [ static ]
99 QString VisuGUI_FileDlg::getFileName( QWidget* parent,
100 const QString& initial,
101 const QStringList& filters,
102 const QString& caption,
105 SUIT_FileValidator* validator )
107 VisuGUI_FileDlg* fd = new VisuGUI_FileDlg( parent, open, showQuickDir, true );
108 if ( !caption.isEmpty() )
109 fd->setWindowTitle( caption );
110 if ( !initial.isEmpty() ) {
111 fd->processPath( initial ); // VSR 24/03/03 check for existing of directory has been added to avoid QFileDialog's bug
113 fd->setFilters( filters );
115 fd->setValidator( validator );
117 QString filename = fd->selectedFile();
119 VisuGUI_FileDlg::IsBuild = fd->IsChecked();
122 qApp->processEvents();
127 bool VisuGUI_FileDlg::IsChecked()
129 return myCBuildAll->isChecked();