]> SALOME platform Git repositories - modules/gui.git/blobdiff - src/SUIT/SUIT_FileDlg.cxx
Salome HOME
Copyrights update
[modules/gui.git] / src / SUIT / SUIT_FileDlg.cxx
index 992b6be7395bc14f38ff3f0831a65bdf39c81540..80a6ad5890b411b4191c320ca3720390c1c52262 100755 (executable)
@@ -1,3 +1,21 @@
+// Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either 
+// version 2.1 of the License.
+// 
+// This library is distributed in the hope that it will be useful 
+// but WITHOUT ANY WARRANTY; without even the implied warranty of 
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public  
+// License along with this library; if not, write to the Free Software 
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/
+//
 //*********************************************************************************
 // SUIT_FileDlg class is the extension of the Qt's Open/Save file dialog box.
 // To get the file/directory name(s) call static methods:
@@ -76,9 +94,19 @@ SUIT_FileDlg::SUIT_FileDlg( QWidget* parent, bool open, bool showQuickDir, bool
 QFileDialog( parent, 0, modal ),
 myValidator( 0 ),
 myQuickCombo( 0 ), myQuickButton( 0 ), myQuickLab( 0 ),
-myOpen( open ),
-myAccepted( false )
+myOpen( open )//,
+//myAccepted( false )
 {    
+  const QObjectList* child = children();
+  QObjectList::const_iterator anIt = child->begin(), aLast = child->end();
+  for( ; anIt!=aLast; anIt++ )
+    if( (*anIt)->inherits( "QPushButton" ) )
+    {
+      QPushButton* bt = ( QPushButton* )( *anIt );
+      bt->setDefault( false );
+      bt->setAutoDefault( false );
+    }
+
   if ( parent->icon() )
     setIcon( *parent->icon() );       
   setSizeGripEnabled( true );
@@ -207,7 +235,7 @@ void SUIT_FileDlg::accept()
    * in file name editor while file name is not acceptable by acceptData()
    * (e.g. permission denied)
    */
-  if ( !myAccepted ) {
+//  if ( !myAccepted ) {
     if ( mode() != ExistingFiles ) {
       mySelectedFile = QFileDialog::selectedFile();
       addExtension();
@@ -216,10 +244,10 @@ void SUIT_FileDlg::accept()
     if ( acceptData() ) {
       myLastVisitedPath = dirPath();
       QFileDialog::accept();        
-      myAccepted = true;
+//      myAccepted = true;
     }
-  }
-  myAccepted = !myAccepted;
+//  }
+//  myAccepted = !myAccepted;
 }
 
 /*! Closes this dialog and sets the return code to 'Rejected' */
@@ -239,18 +267,23 @@ bool SUIT_FileDlg::acceptData()
   if ( myValidator )
   {
     if ( isOpenDlg() )
-      if ( mode() == ExistingFiles ) {
-       QStringList fileNames = selectedFiles();
-       for ( int i = 0; i < fileNames.count(); i++ ) {
-         if ( !myValidator->canOpen( fileNames[i] ) )
-           return false;
-       }
-       return true;
+    {
+      if ( mode() == ExistingFiles )
+      {
+             QStringList fileNames = selectedFiles();
+             for ( int i = 0; i < (int)fileNames.count(); i++ )
+        {
+               if ( !myValidator->canOpen( fileNames[i] ) )
+                 return false;
+             }
+             return true;
       }
-      else {
-       return myValidator->canOpen( selectedFile() );
+      else
+      {
+             return myValidator->canOpen( selectedFile() );
       }
-    else 
+    }
+    else
       return myValidator->canSave( selectedFile() );
   }
   return true;
@@ -315,15 +348,18 @@ void SUIT_FileDlg::addExtension()
     QRegExp anExtRExp( "^("+ aPattern + ")$" );
 
     // Check if the current file extension matches the pattern
-    if ( anExtRExp.match( anExt ) < 0 ) { 
+    if ( anExtRExp.match( anExt ) < 0 )
+    {
       // find first appropriate extension in the selected filter 
       // (it should be without wildcard symbols)
-      for ( int i = 0; i < extList.count(); i++ ) {
+      for ( int i = 0; i < (int)extList.count(); i++ )
+      {
         QString newExt = extList[i].replace( QRegExp( "[\\\\][+]" ),"+" );
         int res = newExt.findRev( '.' );
-        if ( res >= 0 ) 
+        if ( res >= 0 )
           newExt = newExt.mid( res + 1 );
-        if ( newExt.find( QRegExp("[*|?]" ) ) < 0 ) {
+        if ( newExt.find( QRegExp("[*|?]" ) ) < 0 )
+        {
           mySelectedFile.stripWhiteSpace();
           mySelectedFile += mySelectedFile.endsWith(".") ? newExt : QString(".") + newExt;
           break;
@@ -361,15 +397,13 @@ void SUIT_FileDlg::quickDir(const QString& dirPath)
   QString aPath = dirPath;
   if ( !QDir(aPath).exists() ) {
     aPath = QDir::homeDirPath();
-    /*    SUIT_MessageBox::error1(this, 
-                          tr("ERR_ERROR"),
-                          tr("ERR_DIR_NOT_EXIST").arg(dirPath), 
-                          tr("BUT_OK"));*/
-    
+    SUIT_MessageBox::error1(this, 
+                  tr("ERR_ERROR"),
+                  tr("ERR_DIR_NOT_EXIST").arg(dirPath), 
+                  tr("BUT_OK"));    
   }
-  //  else {
+  else
   processPath(aPath);
-    //  }
 }
 /*!
   Called when user presses "Add" button - adds current directory to quick directory