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 // SMESH SMESHGUI : GUI for SMESH component
23 // File : SMESHGUI_FileValidator.cxx
24 // Author : Oleg UVAROV
27 #include "SMESHGUI_FileValidator.h"
29 // SALOME GUI includes
30 #include <SUIT_MessageBox.h>
31 #include <SUIT_Tools.h>
36 //=======================================================================
37 //function : SMESHGUI_FileValidator
39 //=======================================================================
40 SMESHGUI_FileValidator::SMESHGUI_FileValidator( QWidget* parent )
41 : SUIT_FileValidator( parent ),
46 //=======================================================================
49 //=======================================================================
50 bool SMESHGUI_FileValidator::canSave( const QString& fileName, bool checkPermission )
52 if ( QFile::exists( fileName ) ) {
54 int anAnswer = SUIT_MessageBox::question( parent(), QObject::tr( "SMESH_WRN_WARNING" ),
55 QObject::tr( "SMESH_FILE_EXISTS" ).arg( fileName ),
56 QObject::tr( "SMESH_BUT_OVERWRITE" ),
57 QObject::tr( "SMESH_BUT_ADD" ),
58 QObject::tr( "SMESH_BUT_CANCEL" ), 0, 2 );
61 myIsOverwrite = anAnswer == 0;
64 // copied from SUIT_FileValidator
65 if ( checkPermission && !QFileInfo( fileName ).isWritable() ) {
67 SUIT_MessageBox::critical( parent(), QObject::tr( "SMESH_ERROR" ),
68 QObject::tr( "NO_PERMISSION" ).arg( fileName ) );
73 return SUIT_FileValidator::canSave( fileName, checkPermission );