Rename QLibraryInfo::location() to path()

As per ### Qt6 comment. Also rename the LibraryLocation enum
to LibraryPath.

Change-Id: I556025a19c5bcdf2ff52598eaba32269522d4128
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Lars Knoll 2020-09-04 09:45:26 +02:00
parent d24174918f
commit 557623cc4f
26 changed files with 55 additions and 42 deletions

View File

@ -65,7 +65,7 @@ int main(int argc, char *argv[])
QString translatorFileName = QLatin1String("qtbase_");
translatorFileName += QLocale::system().name();
QTranslator *translator = new QTranslator(&app);
if (translator->load(translatorFileName, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
if (translator->load(translatorFileName, QLibraryInfo::path(QLibraryInfo::TranslationsPath)))
app.installTranslator(translator);
#endif

View File

@ -65,7 +65,7 @@ int main(int argc, char *argv[])
QString translatorFileName = QLatin1String("qtbase_");
translatorFileName += QLocale::system().name();
QTranslator *translator = new QTranslator(&app);
if (translator->load(translatorFileName, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
if (translator->load(translatorFileName, QLibraryInfo::path(QLibraryInfo::TranslationsPath)))
app.installTranslator(translator);
#endif

View File

@ -66,7 +66,7 @@ int main(int argc, char *argv[])
QString translatorFileName = QLatin1String("qtbase_");
translatorFileName += QLocale::system().name();
QTranslator *translator = new QTranslator(&app);
if (translator->load(translatorFileName, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
if (translator->load(translatorFileName, QLibraryInfo::path(QLibraryInfo::TranslationsPath)))
app.installTranslator(translator);
#endif

View File

@ -129,7 +129,7 @@ int main(int argc, char *argv[])
QString translatorFileName = QLatin1String("qtbase_");
translatorFileName += QLocale::system().name();
QTranslator *translator = new QTranslator(&app);
if (translator->load(translatorFileName, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
if (translator->load(translatorFileName, QLibraryInfo::path(QLibraryInfo::TranslationsPath)))
app.installTranslator(translator);
#endif

View File

@ -57,7 +57,7 @@ Window::Window(QWidget *parent)
: QWidget(parent)
{
FileListModel *model = new FileListModel(this);
model->setDirPath(QLibraryInfo::location(QLibraryInfo::PrefixPath));
model->setDirPath(QLibraryInfo::path(QLibraryInfo::PrefixPath));
QLabel *label = new QLabel(tr("&Directory:"));
QLineEdit *lineEdit = new QLineEdit;

View File

@ -218,7 +218,7 @@ Option::parseCommandLine(QStringList &args, QMakeCmdLineParserState &state)
"QMake version %s\n"
"Using Qt version %s in %s\n",
QMAKE_VERSION_STR, QT_VERSION_STR,
QLibraryInfo::location(QLibraryInfo::LibrariesPath).toLatin1().constData());
QLibraryInfo::path(QLibraryInfo::LibrariesPath).toLatin1().constData());
#ifdef QMAKE_OPENSOURCE_VERSION
fprintf(stdout, "QMake is Open Source software from The Qt Company Ltd and/or its subsidiary(-ies).\n");
#endif

View File

@ -39,7 +39,7 @@ QT_BEGIN_NAMESPACE
static const struct {
const char *name;
QLibraryInfo::LibraryLocation loc;
QLibraryInfo::LibraryPath loc;
bool raw;
bool singular;
} propList[] = {
@ -84,7 +84,7 @@ void QMakeProperty::reload()
QString val = QLibraryInfo::rawLocation(propList[i].loc, QLibraryInfo::FinalPaths);
if (!propList[i].raw) {
m_values[ProKey(name + "/dev")] = QLibraryInfo::rawLocation(propList[i].loc, QLibraryInfo::DevicePaths);
m_values[ProKey(name)] = QLibraryInfo::location(propList[i].loc);
m_values[ProKey(name)] = QLibraryInfo::path(propList[i].loc);
name += "/raw";
}
m_values[ProKey(name)] = val;

View File

@ -356,7 +356,7 @@ QVersionNumber QLibraryInfo::version() noexcept
#endif // QT_BUILD_QMAKE
/*
* To add a new entry in QLibrary::LibraryLocation, add it to the enum above the bootstrapped values and:
* To add a new entry in QLibrary::LibraryPath, add it to the enum above the bootstrapped values and:
* - add its relative path in the qtConfEntries[] array below
* (the key is what appears in a qt.conf file)
* - add a property name in qmake/property.cpp propList[] array
@ -636,12 +636,19 @@ static QString getPrefix(
}
#endif // QT_BUILD_QMAKE_BOOTSTRAP
/*!
Returns the location specified by \a loc.
/*! \fn QString QLibraryInfo::path(LibraryPath loc)
\obsolete Use path() instead.
Returns the path specified by \a loc.
\sa path()
*/
QString
QLibraryInfo::location(LibraryLocation loc)
/*!
Returns the path specified by \a p.
*/
QString QLibraryInfo::path(LibraryPath p)
{
const LibraryPath loc = p;
#ifdef QT_BUILD_QMAKE // ends inside rawLocation !
QString ret = rawLocation(loc, FinalPaths);
@ -653,7 +660,7 @@ QLibraryInfo::location(LibraryLocation loc)
}
QString
QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group)
QLibraryInfo::rawLocation(LibraryPath loc, PathGroup group)
{
#endif // QT_BUILD_QMAKE, started inside location !
QString ret;
@ -803,7 +810,7 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group)
baseDir = prefixFromAppDirHelper();
} else {
// we make any other path absolute to the prefix directory
baseDir = location(PrefixPath);
baseDir = path(PrefixPath);
}
#endif // QT_BUILD_QMAKE
ret = QDir::cleanPath(baseDir + QLatin1Char('/') + ret);
@ -842,7 +849,7 @@ QStringList QLibraryInfo::platformPluginArguments(const QString &platformName)
}
/*!
\enum QLibraryInfo::LibraryLocation
\enum QLibraryInfo::LibraryPath
\keyword library location

View File

@ -59,7 +59,7 @@ public:
static QVersionNumber version() noexcept Q_DECL_CONST_FUNCTION;
#endif
enum LibraryLocation
enum LibraryPath
{
PrefixPath = 0,
DocumentationPath,
@ -90,10 +90,16 @@ public:
#endif
SettingsPath = 100
};
static QString location(LibraryLocation); // ### Qt 6: consider renaming it to path()
static QString path(LibraryPath p);
#if QT_DEPRECATED_SINCE(6, 0)
using LibraryLocation = LibraryPath;
QT_DEPRECATED_VERSION_X_6_0("Use path()")
static QString location(LibraryLocation location)
{ return path(location); }
#endif
#ifdef QT_BUILD_QMAKE
enum PathGroup { FinalPaths, EffectivePaths, EffectiveSourcePaths, DevicePaths };
static QString rawLocation(LibraryLocation, PathGroup);
static QString rawLocation(LibraryPath, PathGroup);
static void reload();
static void sysrootify(QString *path);
#endif

View File

@ -324,7 +324,7 @@ void QLoggingRegistry::initializeRules()
#if !defined(QT_BOOTSTRAPPED)
// get rules from Qt data configuration path
const QString qtConfigPath
= QDir(QLibraryInfo::location(QLibraryInfo::DataPath)).absoluteFilePath(configFileName);
= QDir(QLibraryInfo::path(QLibraryInfo::DataPath)).absoluteFilePath(configFileName);
qr = loadRulesFromFile(qtConfigPath);
#endif

View File

@ -992,11 +992,11 @@ static std::unique_lock<QBasicMutex> initDefaultPaths(std::unique_lock<QBasicMut
locker.unlock();
/*
QLibraryInfo::location() uses QSettings, so in order to
QLibraryInfo::path() uses QSettings, so in order to
avoid a dead-lock, we can't hold the global mutex while
calling it.
*/
QString systemPath = QLibraryInfo::location(QLibraryInfo::SettingsPath) + QLatin1Char('/');
QString systemPath = QLibraryInfo::path(QLibraryInfo::SettingsPath) + QLatin1Char('/');
locker.lock();
if (pathHash->isEmpty()) {

View File

@ -2706,7 +2706,7 @@ QStringList QCoreApplication::libraryPathsLocked()
}
#endif // Q_OS_DARWIN
QString installPathPlugins = QLibraryInfo::location(QLibraryInfo::PluginsPath);
QString installPathPlugins = QLibraryInfo::path(QLibraryInfo::PluginsPath);
if (QFile::exists(installPathPlugins)) {
// Make sure we convert from backslashes to slashes.
installPathPlugins = QDir(installPathPlugins).canonicalPath();

View File

@ -357,7 +357,7 @@ QString QPlatformFontDatabase::fontDir() const
{
QString fontpath = QString::fromLocal8Bit(qgetenv("QT_QPA_FONTDIR"));
if (fontpath.isEmpty())
fontpath = QLibraryInfo::location(QLibraryInfo::LibrariesPath) + QLatin1String("/fonts");
fontpath = QLibraryInfo::path(QLibraryInfo::LibrariesPath) + QLatin1String("/fonts");
return fontpath;
}

View File

@ -263,7 +263,7 @@ static inline QString resolveBugListFile(const QString &fileName)
return fileName;
// Try QLibraryInfo::SettingsPath which is typically empty unless specified in qt.conf,
// then resolve via QStandardPaths::ConfigLocation.
const QString settingsPath = QLibraryInfo::location(QLibraryInfo::SettingsPath);
const QString settingsPath = QLibraryInfo::path(QLibraryInfo::SettingsPath);
if (!settingsPath.isEmpty()) { // SettingsPath is empty unless specified in qt.conf.
const QFileInfo fi(settingsPath + u'/' + fileName);
if (fi.isFile())

View File

@ -2193,7 +2193,7 @@ QString QTest::qFindTestData(const QString& base, const char *file, int line, co
if (found.isEmpty()) {
const char *testObjectName = QTestResult::currentTestObjectName();
if (testObjectName) {
const QString testsPath = QLibraryInfo::location(QLibraryInfo::TestsPath);
const QString testsPath = QLibraryInfo::path(QLibraryInfo::TestsPath);
const QString candidate = QString::fromLatin1("%1/%2/%3")
.arg(testsPath, QFile::decodeName(testObjectName).toLower(), base);
if (QFileInfo::exists(candidate)) {

View File

@ -590,7 +590,7 @@ namespace QTest {
<< QLatin1String("project.pro");
qmake.setWorkingDirectory(temporaryDirPath);
QString cmd = QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmake";
QString cmd = QLibraryInfo::path(QLibraryInfo::BinariesPath) + "/qmake";
#ifdef Q_OS_WIN
cmd.append(".exe");
#endif

View File

@ -592,7 +592,7 @@ void tst_QUndoGroup::commandTextFormat()
#if !QT_CONFIG(process)
QSKIP("No QProcess available");
#else
QString binDir = QLibraryInfo::location(QLibraryInfo::BinariesPath);
QString binDir = QLibraryInfo::path(QLibraryInfo::BinariesPath);
if (QProcess::execute(binDir + "/lrelease -version") != 0)
QSKIP("lrelease is missing or broken");

View File

@ -3856,7 +3856,7 @@ void tst_QUndoStack::commandTextFormat()
#if !QT_CONFIG(process)
QSKIP("No QProcess available");
#else
QString binDir = QLibraryInfo::location(QLibraryInfo::BinariesPath);
QString binDir = QLibraryInfo::path(QLibraryInfo::BinariesPath);
if (QProcess::execute(binDir + "/lrelease -version") != 0)
QSKIP("lrelease is missing or broken");

View File

@ -56,7 +56,7 @@ void FindTestData::initTestCase()
+ "/tests";
QVERIFY(QDir("/").mkpath(install_path));
QVERIFY(QDir("/").mkpath(install_path + "/findtestdata"));
QCOMPARE(QLibraryInfo::location(QLibraryInfo::TestsPath), install_path);
QCOMPARE(QLibraryInfo::path(QLibraryInfo::TestsPath), install_path);
// make fake source and build directories
QVERIFY(QDir("/").mkpath(app_path + "/fakesrc"));

View File

@ -772,7 +772,7 @@ private:
void tst_Moc::initTestCase()
{
QString binpath = QLibraryInfo::location(QLibraryInfo::BinariesPath);
QString binpath = QLibraryInfo::path(QLibraryInfo::BinariesPath);
QString qmake = QString("%1/qmake").arg(binpath);
m_moc = QString("%1/moc").arg(binpath);

View File

@ -129,7 +129,7 @@ void tst_qdbuscpp2xml::qdbuscpp2xml()
}
// Launch
const QString binpath = QLibraryInfo::location(QLibraryInfo::BinariesPath);
const QString binpath = QLibraryInfo::path(QLibraryInfo::BinariesPath);
const QString command = binpath + QLatin1String("/qdbuscpp2xml");
QProcess process;
process.start(command, QStringList() << options << (QFINDTESTDATA(inputfile + QStringLiteral(".h"))));

View File

@ -218,7 +218,7 @@ void tst_qdbusxml2cpp::process()
QFETCH_GLOBAL(QString, commandLineArg);
// Run the tool
const QString binpath = QLibraryInfo::location(QLibraryInfo::BinariesPath);
const QString binpath = QLibraryInfo::path(QLibraryInfo::BinariesPath);
const QString command = binpath + QLatin1String("/qdbusxml2cpp");
QProcess process;
process.start(command, QStringList() << commandLineArg << "-" << "-N");

View File

@ -117,7 +117,7 @@ static void copyDir(const QString &sourceDirPath, const QString &targetDirPath)
void tst_qmake::initTestCase()
{
QVERIFY2(tempWorkDir.isValid(), qPrintable(tempWorkDir.errorString()));
QString binpath = QLibraryInfo::location(QLibraryInfo::BinariesPath);
QString binpath = QLibraryInfo::path(QLibraryInfo::BinariesPath);
QString cmd = QString("%1/qmake").arg(binpath);
#ifdef Q_CC_MSVC
const QString jom = QStandardPaths::findExecutable(QLatin1String("jom.exe"));
@ -656,7 +656,7 @@ void tst_qmake::qinstall()
// install an executable file
{
const QString mocFilePath = QLibraryInfo::location(QLibraryInfo::BinariesPath)
const QString mocFilePath = QLibraryInfo::path(QLibraryInfo::BinariesPath)
+ "/moc"
#ifdef Q_OS_WIN
+ ".exe"

View File

@ -103,7 +103,7 @@ private:
void tst_rcc::initTestCase()
{
m_rcc = QLibraryInfo::location(QLibraryInfo::BinariesPath) + QLatin1String("/rcc");
m_rcc = QLibraryInfo::path(QLibraryInfo::BinariesPath) + QLatin1String("/rcc");
m_dataPath = QFINDTESTDATA("data");
QVERIFY(!m_dataPath.isEmpty());

View File

@ -105,7 +105,7 @@ static const char versionRegexp[] =
R"([*#][*#] Created by: Qt User Interface Compiler version \d{1,2}\.\d{1,2}\.\d{1,2})";
tst_uic::tst_uic()
: m_command(QLibraryInfo::location(QLibraryInfo::BinariesPath) + QLatin1String("/uic"))
: m_command(QLibraryInfo::path(QLibraryInfo::BinariesPath) + QLatin1String("/uic"))
, m_versionRegexp(QLatin1String(versionRegexp))
{
}

View File

@ -911,7 +911,7 @@ void tst_QApplication::libraryPaths()
int argc = 1;
QApplication app(argc, &argv0);
QString appDirPath = QCoreApplication::applicationDirPath();
QString installPathPlugins = QLibraryInfo::location(QLibraryInfo::PluginsPath);
QString installPathPlugins = QLibraryInfo::path(QLibraryInfo::PluginsPath);
QStringList actual = QApplication::libraryPaths();
actual.sort();
@ -939,7 +939,7 @@ void tst_QApplication::libraryPaths()
// this test doesn't work if KDE 4 is installed
QCOMPARE(count, 1); // before creating QApplication, only the PluginsPath is in the libraryPaths()
#endif
QString installPathPlugins = QLibraryInfo::location(QLibraryInfo::PluginsPath);
QString installPathPlugins = QLibraryInfo::path(QLibraryInfo::PluginsPath);
QApplication::addLibraryPath(installPathPlugins);
qCDebug(lcTests) << "installPathPlugins" << installPathPlugins;
qCDebug(lcTests) << "After adding plugins path:" << QApplication::libraryPaths();
@ -963,7 +963,7 @@ void tst_QApplication::libraryPaths()
qCDebug(lcTests) << "Initial library path:" << QCoreApplication::libraryPaths();
int count = QCoreApplication::libraryPaths().count();
QString installPathPlugins = QLibraryInfo::location(QLibraryInfo::PluginsPath);
QString installPathPlugins = QLibraryInfo::path(QLibraryInfo::PluginsPath);
QCoreApplication::addLibraryPath(installPathPlugins);
qCDebug(lcTests) << "installPathPlugins" << installPathPlugins;
qCDebug(lcTests) << "After adding plugins path:" << QCoreApplication::libraryPaths();
@ -1024,7 +1024,7 @@ void tst_QApplication::libraryPaths_qt_plugin_path_2()
// library path list should contain the default plus the one valid path
QStringList expected =
QStringList()
<< QLibraryInfo::location(QLibraryInfo::PluginsPath)
<< QLibraryInfo::path(QLibraryInfo::PluginsPath)
<< QDir(QCoreApplication::applicationDirPath()).canonicalPath()
<< QDir(QDir::fromNativeSeparators(QString::fromLatin1(validPath))).canonicalPath();
@ -1045,7 +1045,7 @@ void tst_QApplication::libraryPaths_qt_plugin_path_2()
// library path list should contain the default
QStringList expected =
QStringList()
<< QLibraryInfo::location(QLibraryInfo::PluginsPath)
<< QLibraryInfo::path(QLibraryInfo::PluginsPath)
<< QCoreApplication::applicationDirPath();
QVERIFY(isPathListIncluded(QCoreApplication::libraryPaths(), expected));