]> SALOME platform Git repositories - modules/gui.git/blobdiff - src/SUIT/SUIT_FileDlg.cxx
Salome HOME
Merge branch 'V7_dev'
[modules/gui.git] / src / SUIT / SUIT_FileDlg.cxx
index 6a2c2d943bdc91683028f72124771b1bbf31a124..09c5ad6963ea9d255a5a734d7e8e9962c1509966 100755 (executable)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -124,15 +124,20 @@ SUIT_FileDlg::SUIT_FileDlg( QWidget* parent, bool open, bool showQuickDir, bool
   myCheckPermissions( true )
 {
   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
-  
+  setOption(QFileDialog::DontUseNativeDialog, true);
   setModal( modal );
   setSizeGripEnabled( true );
   if ( parent )
     setWindowIcon( parent->windowIcon() );
 
   // GDD
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
   myUrls.insert(0,QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::ApplicationsLocation)));
   myUrls.insert(0,QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)));
+#else
+  myUrls.insert(0,QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation)));
+  myUrls.insert(0,QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)));
+#endif
   setSidebarUrls(myUrls);
 
   // add quick directories widgets
@@ -518,7 +523,7 @@ QString SUIT_FileDlg::addExtension( const QString& fileName ) const
     return fileName;
 
   QRegExp r( QString::fromLatin1("\\(?[a-zA-Z0-9.*? +;#|]*\\)?$") );
-  int index = r.indexIn( selectedFilter().trimmed() );
+  int index = r.indexIn( selectedNameFilter().trimmed() );
 
   if ( QFileInfo( fileName ).exists() )
     return fileName; // if file exists return as is
@@ -529,7 +534,7 @@ QString SUIT_FileDlg::addExtension( const QString& fileName ) const
     // Due to transformations from the filter list (*.txt *.*xx *.c++ SUIT*.* ) we 
     // will have the pattern (\.txt|\..*xx|\.c\+\+|\..*) (as we validate extension only, 
     // we remove everything except extension mask from the pattern
-    QString wildcard = selectedFilter().mid( index, r.matchedLength() ).trimmed();
+    QString wildcard = selectedNameFilter().mid( index, r.matchedLength() ).trimmed();
     // replace '|' and ';' separators by space symbol and also brackets if there are some
     wildcard.replace( QRegExp( "[\\|;|(|)]" )," " ); 
 
@@ -599,12 +604,12 @@ bool SUIT_FileDlg::processPath( const QString& path )
 */
 void SUIT_FileDlg::addFilter( const QString& filter )
 {
-  QStringList flist = filters();
+  QStringList flist = nameFilters();
   if ( !flist.contains( filter ) ) {
     flist << filter;
-    setFilters( flist );
+    setNameFilters( flist );
   }
-  selectFilter( filter );
+  selectNameFilter( filter );
 }
 
 /*!
@@ -768,9 +773,9 @@ QString SUIT_FileDlg::getFileName( QWidget* parent, const QString& initial,
   tmpfilename = tmpfilename.replace(QRegExp("\\*"), "" ).replace(QRegExp("\\?"), "" );
 
   if ( filters.isEmpty() )
-    fd.setFilter( tr( "ALL_FILES_FILTER" ) ); // All files (*)
+    fd.setNameFilter( tr( "ALL_FILES_FILTER" ) ); // All files (*)
   else
-    fd.setFilters( filters );
+    fd.setNameFilters( filters );
 
   if ( !caption.isEmpty() )
     fd.setWindowTitle( caption );
@@ -875,9 +880,9 @@ QStringList SUIT_FileDlg::getOpenFileNames( QWidget* parent, const QString& init
   fd.setFileMode( ExistingFiles );
 
   if ( filters.isEmpty() )
-    fd.setFilter( tr( "ALL_FILES_FILTER" ) ); // All files (*)
+    fd.setNameFilter( tr( "ALL_FILES_FILTER" ) ); // All files (*)
   else
-    fd.setFilters( filters );
+    fd.setNameFilters( filters );
 
   if ( !caption.isEmpty() )
     fd.setWindowTitle( caption );