#5435 Ensemble Import : File dialog report no matching files

Unity build causes file global static members to not work as expected.
This commit is contained in:
Magne Sjaastad 2020-01-30 12:42:22 +01:00
parent ce630c3067
commit 96fd4a1c9f
3 changed files with 22 additions and 23 deletions

View File

@ -25,7 +25,10 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const QChar RiaFilePathTools::SEPARATOR = '/';
const QChar RiaFilePathTools::separator()
{
return '/';
}
//--------------------------------------------------------------------------------------------------
///
@ -42,7 +45,7 @@ QString RiaFilePathTools::toInternalSeparator( const QString& path )
// On other systems (i.e. Windows) -> Convert to internal separator (/)
QString output = path;
return output.replace( QString( "\\" ), SEPARATOR );
return output.replace( QString( "\\" ), separator() );
}
//--------------------------------------------------------------------------------------------------
@ -50,9 +53,9 @@ QString RiaFilePathTools::toInternalSeparator( const QString& path )
//--------------------------------------------------------------------------------------------------
QString& RiaFilePathTools::appendSeparatorIfNo( QString& path )
{
if ( !path.endsWith( SEPARATOR ) )
if ( !path.endsWith( separator() ) )
{
path.append( SEPARATOR );
path.append( separator() );
}
return path;
}
@ -67,7 +70,7 @@ QString RiaFilePathTools::relativePath( const QString& rootDir, const QString& d
QString relPath = dir;
relPath.remove( 0, rootDir.size() );
if ( relPath.startsWith( SEPARATOR ) ) relPath.remove( 0, 1 );
if ( relPath.startsWith( separator() ) ) relPath.remove( 0, 1 );
return appendSeparatorIfNo( relPath );
}
else
@ -102,7 +105,7 @@ QString RiaFilePathTools::canonicalPath( const QString& path )
std::pair<QString, QString> RiaFilePathTools::toFolderAndFileName( const QString& absFileName )
{
auto absFN = toInternalSeparator( absFileName );
int lastSep = absFN.lastIndexOf( SEPARATOR );
int lastSep = absFN.lastIndexOf( separator() );
if ( lastSep > 0 )
{
return std::make_pair( absFN.left( lastSep ), absFN.mid( lastSep + 1 ) );
@ -123,7 +126,7 @@ QString RiaFilePathTools::removeDuplicatePathSeparators( const QString& path )
do
{
len = correctedPath.size();
correctedPath.replace( QString( "%1%1" ).arg( SEPARATOR ), SEPARATOR );
correctedPath.replace( QString( "%1%1" ).arg( separator() ), separator() );
} while ( correctedPath.size() != len );
return correctedPath;
@ -134,7 +137,7 @@ QString RiaFilePathTools::removeDuplicatePathSeparators( const QString& path )
//--------------------------------------------------------------------------------------------------
QString RiaFilePathTools::rootSearchPathFromSearchFilter( const QString& searchFilter )
{
QStringList pathPartList = searchFilter.split( SEPARATOR );
QStringList pathPartList = searchFilter.split( separator() );
QStringList::iterator pathPartIt = pathPartList.begin();
@ -156,5 +159,5 @@ QString RiaFilePathTools::rootSearchPathFromSearchFilter( const QString& searchF
pathPartList.erase( pathPartIt, pathPartList.end() );
return pathPartList.join( SEPARATOR );
return pathPartList.join( separator() );
}

View File

@ -32,8 +32,7 @@
class RiaFilePathTools
{
public:
static const QChar SEPARATOR;
static const QChar separator();
static QString toInternalSeparator( const QString& path );
static QString& appendSeparatorIfNo( QString& path );
static QString relativePath( const QString& rootDir, const QString& dir );

View File

@ -46,11 +46,6 @@
#define FIND_BUTTON_FIND_TEXT "Find"
#define FILES_FOUND_TEXT "Files Found"
//--------------------------------------------------------------------------------------------------
/// Internal variables
//--------------------------------------------------------------------------------------------------
static const QChar SEPARATOR = RiaFilePathTools::SEPARATOR;
//--------------------------------------------------------------------------------------------------
/// Internal functions
//--------------------------------------------------------------------------------------------------
@ -250,7 +245,7 @@ QString RicRecursiveFileSearchDialog::pathFilterWithoutStartSeparator() const
QString rootDir = RiaFilePathTools::rootSearchPathFromSearchFilter( pathFilter );
pathFilter.remove( 0, rootDir.size() );
if ( pathFilter.startsWith( SEPARATOR ) ) pathFilter.remove( 0, 1 );
if ( pathFilter.startsWith( RiaFilePathTools::separator() ) ) pathFilter.remove( 0, 1 );
return pathFilter;
}
@ -379,7 +374,7 @@ QStringList RicRecursiveFileSearchDialog::findMatchingFiles()
QString pathFilter = this->pathFilterWithoutStartSeparator();
QString rootDir = this->rootDirWithEndSeparator();
if ( rootDir.size() > 1 && rootDir.endsWith( SEPARATOR ) ) rootDir.chop( 1 );
if ( rootDir.size() > 1 && rootDir.endsWith( RiaFilePathTools::separator() ) ) rootDir.chop( 1 );
buildDirectoryListRecursiveSimple( rootDir, pathFilter, &dirs );
@ -411,7 +406,7 @@ void RicRecursiveFileSearchDialog::buildDirectoryListRecursiveSimple( const QStr
return;
}
QStringList pathFilterPartList = pathFilter.split( SEPARATOR );
QStringList pathFilterPartList = pathFilter.split( RiaFilePathTools::separator() );
QDir qdir( currDir, pathFilterPartList[0], QDir::NoSort, QDir::Dirs | QDir::NoDotAndDotDot );
QStringList subDirs = qdir.entryList();
@ -433,7 +428,7 @@ void RicRecursiveFileSearchDialog::buildDirectoryListRecursiveSimple( const QStr
{
auto pf = pathFilterPartList;
pf.removeFirst();
nextPathFilter = pf.join( SEPARATOR );
nextPathFilter = pf.join( RiaFilePathTools::separator() );
}
buildDirectoryListRecursiveSimple( fullPath, nextPathFilter, accumulatedDirs );
@ -498,7 +493,7 @@ QStringList RicRecursiveFileSearchDialog::createFileNameFilterList()
void RicRecursiveFileSearchDialog::updateEffectiveFilter()
{
QString pathFilterText = pathFilterWithoutStartSeparator();
if ( pathFilterText == "*" || pathFilterText.endsWith( QString( SEPARATOR ) + "*" ) )
if ( pathFilterText == "*" || pathFilterText.endsWith( QString( RiaFilePathTools::separator() ) + "*" ) )
{
pathFilterText.chop( 1 );
pathFilterText = pathFilterText + "...";
@ -789,7 +784,7 @@ QStringList RicRecursiveFileSearchDialog::buildDirectoryListRecursive( const QSt
QString pathFilter = this->pathFilterWithoutStartSeparator();
if ( !pathFilter.startsWith( "*" ) )
{
int wildcardIndex = pathFilter.indexOf( QRegExp( QString( "[*%1]" ).arg( SEPARATOR ) ) );
int wildcardIndex = pathFilter.indexOf( QRegExp( QString( "[*%1]" ).arg( RiaFilePathTools::separator() ) ) );
if ( wildcardIndex >= 0 )
{
currPathFilter = pathFilter.left( wildcardIndex + 1 );
@ -826,7 +821,9 @@ QStringList RicRecursiveFileSearchDialog::buildDirectoryListRecursive( const QSt
bool RicRecursiveFileSearchDialog::pathFilterMatch( const QString& pathFilter, const QString& relPath )
{
QString pattern = pathFilter;
if ( relPath.endsWith( SEPARATOR ) && !pathFilter.endsWith( SEPARATOR ) ) pattern += SEPARATOR;
if ( relPath.endsWith( RiaFilePathTools::separator() ) && !pathFilter.endsWith( RiaFilePathTools::separator() ) )
pattern += RiaFilePathTools::separator();
QRegExp regexp( pattern, Qt::CaseInsensitive, QRegExp::Wildcard );
return regexp.exactMatch( relPath );
}