QStandardPaths: add DownloadLocation.

Only properly implemented on unix (XDG), falls back to Document location
on Mac and Windows, because not easily available with the current API
being used by either one.

Change-Id: Id269f0e3c4e3a68e19205de96c0b39980fde80ff
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
David Faure 2011-11-03 19:13:32 +01:00 committed by Qt by Nokia
parent ae6e7e3d59
commit 272d20ce27
6 changed files with 14 additions and 3 deletions

View File

@ -72,7 +72,7 @@ QT_BEGIN_NAMESPACE
\value DocumentsLocation Returns the user's document.
\value FontsLocation Returns the user's fonts.
\value ApplicationsLocation Returns the user's applications.
\value MusicLocation Returns the users music.
\value MusicLocation Returns the user's music.
\value MoviesLocation Returns the user's movies.
\value PicturesLocation Returns the user's pictures.
\value TempLocation Returns the system's temporary directory.
@ -89,6 +89,7 @@ QT_BEGIN_NAMESPACE
files should be written. For instance unix local sockets.
\value ConfigLocation Returns a directory location where user-specific
configuration files should be written.
\value DownloadLocation Returns a directory for user's downloaded files.
\sa writableLocation() standardLocations() displayName() locate() locateAll()

View File

@ -72,7 +72,8 @@ public:
CacheLocation,
GenericDataLocation,
RuntimeLocation,
ConfigLocation
ConfigLocation,
DownloadLocation
};
static QString writableLocation(StandardLocation type);

View File

@ -60,6 +60,8 @@ OSType translateLocation(QStandardPaths::StandardLocation type)
return kPreferencesFolderType;
case QStandardPaths::DesktopLocation:
return kDesktopFolderType;
case QStandardPaths::DownloadLocation: // needs NSSearchPathForDirectoriesInDomains with NSDownloadsDirectory
// which needs an objective-C *.mm file...
case QStandardPaths::DocumentsLocation:
return kDocumentsFolderType;
case QStandardPaths::FontsLocation:

View File

@ -173,6 +173,9 @@ QString QStandardPaths::writableLocation(StandardLocation type)
case MoviesLocation:
key = QLatin1String("VIDEOS");
break;
case DownloadLocation:
key = QLatin1String("DOWNLOAD");
break;
default:
break;
}
@ -210,7 +213,9 @@ QString QStandardPaths::writableLocation(StandardLocation type)
case MoviesLocation:
path = QDir::homePath() + QLatin1String("/Videos");
break;
case DownloadLocation:
path = QDir::homePath() + QLatin1String("/Downloads");
break;
case ApplicationsLocation:
path = writableLocation(GenericDataLocation) + QLatin1String("/applications");
break;

View File

@ -123,6 +123,7 @@ QString QStandardPaths::writableLocation(StandardLocation type)
result = convertCharArray(path);
break;
case DownloadLocation: // TODO implement with SHGetKnownFolderPath(FOLDERID_Downloads) (starting from Vista)
case DocumentsLocation:
if (SHGetSpecialFolderPath(0, path, CSIDL_PERSONAL, FALSE))
result = convertCharArray(path);

View File

@ -266,6 +266,7 @@ void tst_qstandardpaths::testAllWritableLocations_data()
QTest::newRow("TempLocation") << QStandardPaths::TempLocation;
QTest::newRow("HomeLocation") << QStandardPaths::HomeLocation;
QTest::newRow("DataLocation") << QStandardPaths::DataLocation;
QTest::newRow("DownloadLocation") << QStandardPaths::DownloadLocation;
}
void tst_qstandardpaths::testAllWritableLocations()