1 // Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // SMESH SMESHGUI : GUI for SMESH component
21 // File : SMESHGUI_FileValidator.cxx
22 // Author : Oleg UVAROV
25 #include "SMESHGUI_FileValidator.h"
27 // SALOME GUI includes
28 #include <SUIT_MessageBox.h>
29 #include <SUIT_Tools.h>
34 //=======================================================================
35 //function : SMESHGUI_FileValidator
37 //=======================================================================
38 SMESHGUI_FileValidator::SMESHGUI_FileValidator( QWidget* parent )
39 : SUIT_FileValidator( parent ),
44 //=======================================================================
47 //=======================================================================
48 bool SMESHGUI_FileValidator::canSave( const QString& fileName, bool checkPermission )
50 if ( QFile::exists( fileName ) ) {
52 int anAnswer = SUIT_MessageBox::question( parent(), QObject::tr( "SMESH_WRN_WARNING" ),
53 QObject::tr( "SMESH_FILE_EXISTS" ).arg( fileName ),
54 QObject::tr( "SMESH_BUT_OVERWRITE" ),
55 QObject::tr( "SMESH_BUT_ADD" ),
56 QObject::tr( "SMESH_BUT_CANCEL" ), 0, 2 );
59 myIsOverwrite = anAnswer == 0;
62 // copied from SUIT_FileValidator
63 if ( checkPermission && !QFileInfo( fileName ).isWritable() ) {
65 SUIT_MessageBox::critical( parent(), QObject::tr( "SMESH_ERROR" ),
66 QObject::tr( "NO_PERMISSION" ).arg( fileName ) );
71 return SUIT_FileValidator::canSave( fileName, checkPermission );