Remove usage of deprecated QStandardPaths::DataLocation

* Rearrange the documention to match the enumeration order.

Fixes: QTBUG-87037
Change-Id: Iad001351e0f309e694b8bbd503813017e6586a21
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
This commit is contained in:
Karsten Heimrich 2020-10-16 15:11:17 +02:00
parent 25edeaa3d6
commit 216c2ed5ce
5 changed files with 15 additions and 28 deletions

View File

@ -90,7 +90,7 @@
or writing to the current user's configuration. or writing to the current user's configuration.
It affects the locations into which test programs might write It affects the locations into which test programs might write
files: \c GenericDataLocation, \c DataLocation, \c ConfigLocation, files: \c GenericDataLocation, \c AppDataLocation, \c ConfigLocation,
\c GenericConfigLocation, \c AppConfigLocation, \c GenericConfigLocation, \c AppConfigLocation,
\c GenericCacheLocation, and \c CacheLocation. Other locations \c GenericCacheLocation, and \c CacheLocation. Other locations
are not affected. are not affected.

View File

@ -119,9 +119,9 @@ QT_BEGIN_NAMESPACE
\value HomeLocation Returns the user's home directory (the same as QDir::homePath()). On Unix \value HomeLocation Returns the user's home directory (the same as QDir::homePath()). On Unix
systems, this is equal to the HOME environment variable. This value might be systems, this is equal to the HOME environment variable. This value might be
generic or application-specific, but the returned path is never empty. generic or application-specific, but the returned path is never empty.
\value DataLocation Returns the same value as AppLocalDataLocation. This enumeration value \value AppLocalDataLocation Returns the local settings path on the Windows operating
is deprecated. Using AppDataLocation is preferable since on Windows, the roaming path is system. On all other platforms, it returns the same value as AppDataLocation.
recommended. This enum value was added in Qt 5.4.
\value CacheLocation Returns a directory location where user-specific \value CacheLocation Returns a directory location where user-specific
non-essential (cached) data should be written. This is an application-specific directory. non-essential (cached) data should be written. This is an application-specific directory.
The returned path is never empty. The returned path is never empty.
@ -149,9 +149,6 @@ QT_BEGIN_NAMESPACE
QStandardPaths::GenericDataLocation. The returned path is never empty. QStandardPaths::GenericDataLocation. The returned path is never empty.
On the Windows operating system, this returns the roaming path. On the Windows operating system, this returns the roaming path.
This enum value was added in Qt 5.4. This enum value was added in Qt 5.4.
\value AppLocalDataLocation Returns the local settings path on the Windows operating
system. On all other platforms, it returns the same value as AppDataLocation.
This enum value was added in Qt 5.4.
\value AppConfigLocation Returns a directory location where user-specific \value AppConfigLocation Returns a directory location where user-specific
configuration files should be written. This is an application-specific directory, configuration files should be written. This is an application-specific directory,
and the returned path is never empty. and the returned path is never empty.
@ -190,7 +187,7 @@ QT_BEGIN_NAMESPACE
\row \li HomeLocation \row \li HomeLocation
\li "~" \li "~"
\li "C:/Users/<USER>" \li "C:/Users/<USER>"
\row \li DataLocation \row \li AppLocalDataLocation
\li "~/Library/Application Support/<APPNAME>", "/Library/Application Support/<APPNAME>". "<APPDIR>/../Resources" \li "~/Library/Application Support/<APPNAME>", "/Library/Application Support/<APPNAME>". "<APPDIR>/../Resources"
\li "C:/Users/<USER>/AppData/Local/<APPNAME>", "C:/ProgramData/<APPNAME>", "<APPDIR>", "<APPDIR>/data", "<APPDIR>/data/<APPNAME>" \li "C:/Users/<USER>/AppData/Local/<APPNAME>", "C:/ProgramData/<APPNAME>", "<APPDIR>", "<APPDIR>/data", "<APPDIR>/data/<APPNAME>"
\row \li CacheLocation \row \li CacheLocation
@ -217,9 +214,6 @@ QT_BEGIN_NAMESPACE
\row \li AppDataLocation \row \li AppDataLocation
\li "~/Library/Application Support/<APPNAME>", "/Library/Application Support/<APPNAME>". "<APPDIR>/../Resources" \li "~/Library/Application Support/<APPNAME>", "/Library/Application Support/<APPNAME>". "<APPDIR>/../Resources"
\li "C:/Users/<USER>/AppData/Roaming/<APPNAME>", "C:/ProgramData/<APPNAME>", "<APPDIR>", "<APPDIR>/data", "<APPDIR>/data/<APPNAME>" \li "C:/Users/<USER>/AppData/Roaming/<APPNAME>", "C:/ProgramData/<APPNAME>", "<APPDIR>", "<APPDIR>/data", "<APPDIR>/data/<APPNAME>"
\row \li AppLocalDataLocation
\li "~/Library/Application Support/<APPNAME>", "/Library/Application Support/<APPNAME>". "<APPDIR>/../Resources"
\li "C:/Users/<USER>/AppData/Local/<APPNAME>", "C:/ProgramData/<APPNAME>", "<APPDIR>", "<APPDIR>/data", "<APPDIR>/data/<APPNAME>"
\row \li AppConfigLocation \row \li AppConfigLocation
\li "~/Library/Preferences/<APPNAME>" \li "~/Library/Preferences/<APPNAME>"
\li "C:/Users/<USER>/AppData/Local/<APPNAME>", "C:/ProgramData/<APPNAME>" \li "C:/Users/<USER>/AppData/Local/<APPNAME>", "C:/ProgramData/<APPNAME>"
@ -245,7 +239,7 @@ QT_BEGIN_NAMESPACE
\li "/tmp" \li "/tmp"
\row \li HomeLocation \row \li HomeLocation
\li "~" \li "~"
\row \li DataLocation \row \li AppLocalDataLocation
\li "~/.local/share/<APPNAME>", "/usr/local/share/<APPNAME>", "/usr/share/<APPNAME>" \li "~/.local/share/<APPNAME>", "/usr/local/share/<APPNAME>", "/usr/share/<APPNAME>"
\row \li CacheLocation \row \li CacheLocation
\li "~/.cache/<APPNAME>" \li "~/.cache/<APPNAME>"
@ -263,8 +257,6 @@ QT_BEGIN_NAMESPACE
\li "~/.cache" \li "~/.cache"
\row \li AppDataLocation \row \li AppDataLocation
\li "~/.local/share/<APPNAME>", "/usr/local/share/<APPNAME>", "/usr/share/<APPNAME>" \li "~/.local/share/<APPNAME>", "/usr/local/share/<APPNAME>", "/usr/share/<APPNAME>"
\row \li AppLocalDataLocation
\li "~/.local/share/<APPNAME>", "/usr/local/share/<APPNAME>", "/usr/share/<APPNAME>"
\row \li AppConfigLocation \row \li AppConfigLocation
\li "~/.config/<APPNAME>", "/etc/xdg/<APPNAME>" \li "~/.config/<APPNAME>", "/etc/xdg/<APPNAME>"
\endtable \endtable
@ -298,7 +290,7 @@ QT_BEGIN_NAMESPACE
\row \li HomeLocation \row \li HomeLocation
\li "<APPROOT>/files" \li "<APPROOT>/files"
\li system defined \li system defined
\row \li DataLocation \row \li AppLocalDataLocation
\li "<APPROOT>/files", "<USER>/<APPNAME>/files" \li "<APPROOT>/files", "<USER>/<APPNAME>/files"
\li "<APPROOT>/Library/Application Support" \li "<APPROOT>/Library/Application Support"
\row \li CacheLocation \row \li CacheLocation
@ -328,9 +320,6 @@ QT_BEGIN_NAMESPACE
\row \li AppConfigLocation \row \li AppConfigLocation
\li "<APPROOT>/files/settings" \li "<APPROOT>/files/settings"
\li "<APPROOT>/Library/Preferences/<APPNAME>" \li "<APPROOT>/Library/Preferences/<APPNAME>"
\row \li AppLocalDataLocation
\li "<APPROOT>/files", "<USER>/<APPNAME>/files"
\li "<APPROOT>/Library/Application Support"
\endtable \endtable
In the table above, \c <APPNAME> is usually the organization name, the In the table above, \c <APPNAME> is usually the organization name, the
@ -564,6 +553,8 @@ QString QStandardPaths::displayName(StandardLocation type)
return QCoreApplication::translate("QStandardPaths", "Temporary Directory"); return QCoreApplication::translate("QStandardPaths", "Temporary Directory");
case HomeLocation: case HomeLocation:
return QCoreApplication::translate("QStandardPaths", "Home"); return QCoreApplication::translate("QStandardPaths", "Home");
case AppLocalDataLocation:
return QCoreApplication::translate("QStandardPaths", "Application Data");
case CacheLocation: case CacheLocation:
return QCoreApplication::translate("QStandardPaths", "Cache"); return QCoreApplication::translate("QStandardPaths", "Cache");
case GenericDataLocation: case GenericDataLocation:
@ -579,8 +570,6 @@ QString QStandardPaths::displayName(StandardLocation type)
case DownloadLocation: case DownloadLocation:
return QCoreApplication::translate("QStandardPaths", "Download"); return QCoreApplication::translate("QStandardPaths", "Download");
case AppDataLocation: case AppDataLocation:
case AppLocalDataLocation:
return QCoreApplication::translate("QStandardPaths", "Application Data");
case AppConfigLocation: case AppConfigLocation:
return QCoreApplication::translate("QStandardPaths", "Application Configuration"); return QCoreApplication::translate("QStandardPaths", "Application Configuration");
} }

View File

@ -53,7 +53,6 @@ class Q_CORE_EXPORT QStandardPaths
Q_GADGET Q_GADGET
public: public:
// Do not re-order, must match QDesktopServices
enum StandardLocation { enum StandardLocation {
DesktopLocation, DesktopLocation,
DocumentsLocation, DocumentsLocation,
@ -64,7 +63,7 @@ public:
PicturesLocation, PicturesLocation,
TempLocation, TempLocation,
HomeLocation, HomeLocation,
DataLocation, AppLocalDataLocation,
CacheLocation, CacheLocation,
GenericDataLocation, GenericDataLocation,
RuntimeLocation, RuntimeLocation,
@ -73,8 +72,7 @@ public:
GenericCacheLocation, GenericCacheLocation,
GenericConfigLocation, GenericConfigLocation,
AppDataLocation, AppDataLocation,
AppConfigLocation, AppConfigLocation
AppLocalDataLocation = DataLocation
}; };
Q_ENUM(StandardLocation) Q_ENUM(StandardLocation)

View File

@ -137,7 +137,7 @@ static GUID writableSpecialFolderId(QStandardPaths::StandardLocation type)
FOLDERID_Videos, // MoviesLocation FOLDERID_Videos, // MoviesLocation
FOLDERID_Pictures, // PicturesLocation FOLDERID_Pictures, // PicturesLocation
GUID(), GUID(), // TempLocation/HomeLocation GUID(), GUID(), // TempLocation/HomeLocation
FOLDERID_LocalAppData, // AppLocalDataLocation ("Local" path), AppLocalDataLocation = DataLocation FOLDERID_LocalAppData, // AppLocalDataLocation ("Local" path)
GUID(), // CacheLocation GUID(), // CacheLocation
FOLDERID_LocalAppData, // GenericDataLocation ("Local" path) FOLDERID_LocalAppData, // GenericDataLocation ("Local" path)
GUID(), // RuntimeLocation GUID(), // RuntimeLocation
@ -159,7 +159,7 @@ static GUID writableSpecialFolderId(QStandardPaths::StandardLocation type)
FOLDERID_Videos, // MoviesLocation FOLDERID_Videos, // MoviesLocation
FOLDERID_Pictures, // PicturesLocation FOLDERID_Pictures, // PicturesLocation
GUID(), GUID(), // TempLocation/HomeLocation GUID(), GUID(), // TempLocation/HomeLocation
FOLDERID_LocalAppDataLow,// AppLocalDataLocation ("Local" path), AppLocalDataLocation = DataLocation FOLDERID_LocalAppDataLow,// AppLocalDataLocation ("Local" path)
GUID(), // CacheLocation GUID(), // CacheLocation
FOLDERID_LocalAppDataLow,// GenericDataLocation ("Local" path) FOLDERID_LocalAppDataLow,// GenericDataLocation ("Local" path)
GUID(), // RuntimeLocation GUID(), // RuntimeLocation

View File

@ -118,7 +118,7 @@ static const char * const enumNames[MaxStandardLocation + 1 - int(QStandardPaths
"PicturesLocation", "PicturesLocation",
"TempLocation", "TempLocation",
"HomeLocation", "HomeLocation",
"DataLocation", "AppLocalDataLocation",
"CacheLocation", "CacheLocation",
"GenericDataLocation", "GenericDataLocation",
"RuntimeLocation", "RuntimeLocation",
@ -307,7 +307,7 @@ void tst_qstandardpaths::testLocateAll()
void tst_qstandardpaths::testDataLocation() void tst_qstandardpaths::testDataLocation()
{ {
// On all platforms, DataLocation should be GenericDataLocation / organization name / app name // On all platforms, AppLocalDataLocation should be GenericDataLocation / organization name / app name
// This allows one app to access the data of another app. // This allows one app to access the data of another app.
// Android is an exception to this case, owing to the fact that // Android is an exception to this case, owing to the fact that
// applications are sandboxed. // applications are sandboxed.