Skip to content
Permalink
Browse files

Fix build on older qt versions

  • Loading branch information
nyalldawson committed Nov 4, 2020
1 parent 8dc1f0c commit d34d61e36f9313a300790dbea4f01d17907dfefc
Showing with 8 additions and 1 deletion.
  1. +8 −0 src/core/qgsfileutils.cpp
  2. +0 −1 tests/src/python/test_qgsfileutils.py
@@ -70,10 +70,18 @@ bool QgsFileUtils::fileMatchesFilter( const QString &fileName, const QString &fi
const QStringList globPatterns = matches.captured( 1 ).split( ' ' );
for ( const QString &glob : globPatterns )
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
const QString re = QRegularExpression::wildcardToRegularExpression( glob );

const QRegularExpression globRx( re );
if ( globRx.match( name ).hasMatch() )
return true;
#else
QRegExp rx( glob );
rx.setPatternSyntax( QRegExp::Wildcard );
if ( rx.indexIn( name ) != -1 )
return true;
#endif
}
}
}
@@ -37,7 +37,6 @@ def testFileMatchesFilter(self):
self.assertFalse(QgsFileUtils.fileMatchesFilter('/home/me/test.tif', '*'))
self.assertFalse(QgsFileUtils.fileMatchesFilter('/home/me/test.tif', '*.'))
self.assertFalse(QgsFileUtils.fileMatchesFilter('/home/me/test.tif', 'Tiff files'))
self.assertFalse(QgsFileUtils.fileMatchesFilter('/home/me/test.tif', '(*.)'))
self.assertTrue(QgsFileUtils.fileMatchesFilter('/home/me/test.tif', '(*.*)'))
self.assertFalse(QgsFileUtils.fileMatchesFilter('/home/me/test.tif', 'PNG Files (*.png)'))
self.assertTrue(QgsFileUtils.fileMatchesFilter('/home/me/test.tif', 'Tif Files (*.tif)'))

0 comments on commit d34d61e

Please sign in to comment.
You can’t perform that action at this time.