Salome HOME
updated copyright message
[modules/gui.git] / src / Qtx / QtxPathListEdit.cxx
index 37c33aa0ce1572b302760e580b93a0e4a29c8acf..352461fc67ff5bd1d5fb6c01f023de01860e799a 100644 (file)
@@ -1,24 +1,22 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
 //
-//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// 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, or (at your option) any later version.
 //
-//  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.
 //
-//  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
 //
-//  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/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 // File:      QtxPathListEdit.cxx
 // Author:    Sergey TELKOV
 //
@@ -145,7 +143,7 @@ public:
     \brief Constructor
     \internal
   */
-  Editor( QWidget* parent = 0 ) : QtxPathEdit( parent )
+  Editor( QWidget* parent = 0 ) : QtxPathEdit( parent, true )
   {
     layout()->setSpacing( 0 );
     lineEdit()->setFrame( false );
@@ -209,8 +207,8 @@ QtxPathListEdit::Delegate::~Delegate()
   \param option style option
   \param index data model index
 */
-QWidget* QtxPathListEdit::Delegate::createEditor( QWidget* parent, const QStyleOptionViewItem& option,
-                                                  const QModelIndex& index ) const
+QWidget* QtxPathListEdit::Delegate::createEditor( QWidget* parent, const QStyleOptionViewItem& /*option*/,
+                                                  const QModelIndex& /*index*/ ) const
 {
   return myPathEdit->createEditor( parent );
 }
@@ -222,7 +220,7 @@ QWidget* QtxPathListEdit::Delegate::createEditor( QWidget* parent, const QStyleO
   \param model data model
   \param index data model index
 */
-void QtxPathListEdit::Delegate::setModelData( QWidget* editor, QAbstractItemModel* model,
+void QtxPathListEdit::Delegate::setModelData( QWidget* editor, QAbstractItemModel* /*model*/,
                                               const QModelIndex& index ) const
 {
   myPathEdit->setModelData( editor, index );
@@ -272,7 +270,7 @@ void QtxPathListEdit::Delegate::paint( QPainter* painter, const QStyleOptionView
   \param rect selection rectangle
 */
 void QtxPathListEdit::Delegate::drawFocus( QPainter* painter, const QStyleOptionViewItem& option,
-                                           const QRect& rect ) const
+                                           const QRect& /*rect*/ ) const
 {
   QItemDelegate::drawFocus( painter, option, option.rect );
 }
@@ -309,8 +307,8 @@ void QtxPathListEdit::Delegate::drawFocus( QPainter* painter, const QStyleOption
 */
 QtxPathListEdit::QtxPathListEdit( const Qtx::PathType type, QWidget* parent )
 : QFrame( parent ),
-  myCompleter( 0 ),
   myType( type ),
+  myCompleter( 0 ),
   myDuplicate( false )
 {
   initialize();
@@ -326,8 +324,8 @@ QtxPathListEdit::QtxPathListEdit( const Qtx::PathType type, QWidget* parent )
 */
 QtxPathListEdit::QtxPathListEdit( QWidget* parent )
 : QFrame( parent ),
-  myCompleter( 0 ),
   myType( Qtx::PT_OpenFile ),
+  myCompleter( 0 ),
   myDuplicate( false )
 {
   initialize();
@@ -505,24 +503,24 @@ bool QtxPathListEdit::validate( const bool quietMode )
       if (found) {
         if (found != myLastSelected) {
           // it is forbidden to add directory more then once
-         if ( !quietMode )
-           QMessageBox::critical(this, 
-                                 tr("Error"),
-                                 tr("Directory already specified."), 
-                                 tr("Ok"));
-         myEdit->setFocus();
+          if ( !quietMode )
+            QMessageBox::critical(this, 
+                                  tr("Error"),
+                                  tr("Directory already specified."), 
+                                  tr("Ok"));
+          myEdit->setFocus();
           return false;
         }
       }
       else {
         if (!dir.exists()) {
-         if ( !quietMode && QMessageBox::information(this, 
-                                                     tr("Warning"),
-                                                     tr("%1\n\nThe directory doesn't exist.\nAdd directory anyway?").arg(dir.absPath()),
-                                                     tr("Yes"), tr("No"), QString(), 1, 1) == 1) {
-           myEdit->setFocus();
+          if ( !quietMode && QMessageBox::information(this, 
+                                                      tr("Warning"),
+                                                      tr("%1\n\nThe directory doesn't exist.\nAdd directory anyway?").arg(dir.absPath()),
+                                                      tr("Yes"), tr("No"), QString(), 1, 1) == 1) {
+            myEdit->setFocus();
             return false;
-         }
+          }
         }
         // append
         appendDir(myLastSelected, dir.absPath());
@@ -764,25 +762,28 @@ bool QtxPathListEdit::checkExistance( const QString& str, const bool msg )
   if ( pathType() == Qtx::PT_SaveFile )
     return true;
 
-  bool ok = QFileInfo( str ).exists();
+  QFileInfo aFI = QFileInfo( Qtx::makeEnvVarSubst( str ) );
+  bool ok = aFI.exists();
   if ( !ok && msg )
     ok = QMessageBox::question( this, tr( "Warning" ), tr( "Path \"%1\" doesn't exist. Add it to list anyway?" ).arg( str ),
                                 QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes;
 
-  if ( ok && QFileInfo( str ).exists() )
+  if ( ok && aFI.exists() )
   {
     switch ( pathType() )
     {
     case Qtx::PT_OpenFile:
-      ok = QFileInfo( str ).isFile();
+      ok = aFI.isFile();
       if ( !ok && msg )
         QMessageBox::warning( this, tr( "Error" ), tr( "Location \"%1\" doesn't point to file" ).arg( str ) );
       break;
     case Qtx::PT_Directory:
-      ok = QFileInfo( str ).isDir();
+      ok = aFI.isDir();
       if ( !ok && msg )
         QMessageBox::warning( this, tr( "Error" ), tr( "Location \"%1\" doesn't point to directory" ).arg( str ) );
       break;
+    default:
+      break;
     }
   }