Expose QFileSelectorPrivate::selectionHelper()
Let QQuickStyleSelector in Qt Quick Controls 2 re-use the same selection helper implementation. Change-Id: I34cbba0aa178e342bb4004313e7ff56811e6be19 Reviewed-by: Liang Qi <liang.qi@qt.io>
This commit is contained in:
parent
5c08fed264
commit
bbf596890f
@ -55,8 +55,6 @@ QT_BEGIN_NAMESPACE
|
|||||||
//Environment variable to allow tooling full control of file selectors
|
//Environment variable to allow tooling full control of file selectors
|
||||||
static const char env_override[] = "QT_NO_BUILTIN_SELECTORS";
|
static const char env_override[] = "QT_NO_BUILTIN_SELECTORS";
|
||||||
|
|
||||||
static const ushort selectorIndicator = '+';
|
|
||||||
|
|
||||||
Q_GLOBAL_STATIC(QFileSelectorSharedData, sharedData);
|
Q_GLOBAL_STATIC(QFileSelectorSharedData, sharedData);
|
||||||
static QBasicMutex sharedDataMutex;
|
static QBasicMutex sharedDataMutex;
|
||||||
|
|
||||||
@ -267,7 +265,7 @@ QUrl QFileSelector::select(const QUrl &filePath) const
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString selectionHelper(const QString &path, const QString &fileName, const QStringList &selectors)
|
QString QFileSelectorPrivate::selectionHelper(const QString &path, const QString &fileName, const QStringList &selectors, const QChar &indicator)
|
||||||
{
|
{
|
||||||
/* selectionHelper does a depth-first search of possible selected files. Because there is strict
|
/* selectionHelper does a depth-first search of possible selected files. Because there is strict
|
||||||
selector ordering in the API, we can stop checking as soon as we find the file in a directory
|
selector ordering in the API, we can stop checking as soon as we find the file in a directory
|
||||||
@ -276,12 +274,15 @@ static QString selectionHelper(const QString &path, const QString &fileName, con
|
|||||||
Q_ASSERT(path.isEmpty() || path.endsWith(QLatin1Char('/')));
|
Q_ASSERT(path.isEmpty() || path.endsWith(QLatin1Char('/')));
|
||||||
|
|
||||||
for (const QString &s : selectors) {
|
for (const QString &s : selectors) {
|
||||||
QString prospectiveBase = path + QLatin1Char(selectorIndicator) + s + QLatin1Char('/');
|
QString prospectiveBase = path;
|
||||||
|
if (!indicator.isNull())
|
||||||
|
prospectiveBase += indicator;
|
||||||
|
prospectiveBase += s + QLatin1Char('/');
|
||||||
QStringList remainingSelectors = selectors;
|
QStringList remainingSelectors = selectors;
|
||||||
remainingSelectors.removeAll(s);
|
remainingSelectors.removeAll(s);
|
||||||
if (!QDir(prospectiveBase).exists())
|
if (!QDir(prospectiveBase).exists())
|
||||||
continue;
|
continue;
|
||||||
QString prospectiveFile = selectionHelper(prospectiveBase, fileName, remainingSelectors);
|
QString prospectiveFile = selectionHelper(prospectiveBase, fileName, remainingSelectors, indicator);
|
||||||
if (!prospectiveFile.isEmpty())
|
if (!prospectiveFile.isEmpty())
|
||||||
return prospectiveFile;
|
return prospectiveFile;
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,8 @@ public:
|
|||||||
static void updateSelectors();
|
static void updateSelectors();
|
||||||
static QStringList platformSelectors();
|
static QStringList platformSelectors();
|
||||||
static void addStatics(const QStringList &); //For loading GUI statics from other Qt modules
|
static void addStatics(const QStringList &); //For loading GUI statics from other Qt modules
|
||||||
|
static QString selectionHelper(const QString &path, const QString &fileName,
|
||||||
|
const QStringList &selectors, const QChar &indicator = QLatin1Char('+'));
|
||||||
QFileSelectorPrivate();
|
QFileSelectorPrivate();
|
||||||
QString select(const QString &filePath) const;
|
QString select(const QString &filePath) const;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user