Salome HOME
Add file dialog options in QtxPathEdit
[modules/gui.git] / src / Qtx / QtxPathEdit.cxx
index c349ff8a20602e9280ad34f5f5db13cddbf14edd..8dcac94eec04bae436f0b3eed6001d07ef98bcd7 100644 (file)
@@ -29,7 +29,6 @@
 #include <QCompleter>
 #include <QKeyEvent>
 #include <QToolButton>
-#include <QFileDialog>
 #include <QRegExpValidator>
 
 static const char* browse_icon[] = {
@@ -185,6 +184,30 @@ void QtxPathEdit::setPathFilter( const QString& f )
   updateState();
 }
 
+/*!
+  \brief Set path file dialog options.
+  \param f new file or directory path options
+  \sa pathOptions()
+*/
+void QtxPathEdit::setPathOptions(const QFileDialog::Options options)
+{
+  if ( myOptions == options )
+    return;
+
+  myOptions = options;
+}
+
+/*!
+  \brief Get currently used path options.
+  \return file or directory path options
+  \sa setPathOptions()
+*/
+QFileDialog::Options QtxPathEdit::pathOptions() const
+{
+  return myOptions;
+}
+
+
 /*!
   \brief Called when user clicks "Browse" button. 
 
@@ -200,13 +223,13 @@ void QtxPathEdit::onBrowse( bool /*on*/ )
   switch ( pathType() )
   {
   case Qtx::PT_OpenFile:
-    path = QFileDialog::getOpenFileName( myPath, QString(), initial, pathFilter() );
+    path = QFileDialog::getOpenFileName( myPath, QString(), initial, pathFilter(), nullptr, pathOptions() );
     break;
   case Qtx::PT_SaveFile:
-    path = QFileDialog::getSaveFileName( myPath, QString(), initial, pathFilter() );
+    path = QFileDialog::getSaveFileName( myPath, QString(), initial, pathFilter(), nullptr, pathOptions() );
     break;
   case Qtx::PT_Directory:
-    path = QFileDialog::getExistingDirectory( myPath, QString(), initial );
+    path = QFileDialog::getExistingDirectory( myPath, QString(), initial, pathOptions() );
     break;
   }