summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qstandardpaths_mac.cpp
diff options
context:
space:
mode:
authorDavid Faure <faure@kde.org>2011-10-21 20:54:35 +0200
committerQt by Nokia <qt-info@nokia.com>2011-10-23 00:56:39 +0200
commit8f3032dfe080c47c6fab7244a356064ce313f050 (patch)
tree714fc893d0286cba3b1b4e714d818d2ce8c3a428 /src/corelib/io/qstandardpaths_mac.cpp
parent86558de34134f67cf3815a29612edc2d730f2ea2 (diff)
QStandardPaths: add Config and GenericData, add methods
New methods: standardLocations, locate, locateAll. Change-Id: I60bc90f8df53727a72c4b1839ea4d1d88a204e29 Reviewed-by: Thiago Macieira (Intel) <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io/qstandardpaths_mac.cpp')
-rw-r--r--src/corelib/io/qstandardpaths_mac.cpp64
1 files changed, 43 insertions, 21 deletions
diff --git a/src/corelib/io/qstandardpaths_mac.cpp b/src/corelib/io/qstandardpaths_mac.cpp
index b90cc7c6f2..a13162cc7b 100644
--- a/src/corelib/io/qstandardpaths_mac.cpp
+++ b/src/corelib/io/qstandardpaths_mac.cpp
@@ -56,6 +56,8 @@ QT_BEGIN_NAMESPACE
OSType translateLocation(QStandardPaths::StandardLocation type)
{
switch (type) {
+ case QStandardPaths::ConfigLocation:
+ return kPreferencesFolderType;
case QStandardPaths::DesktopLocation:
return kDesktopFolderType;
case QStandardPaths::DocumentsLocation:
@@ -74,6 +76,7 @@ OSType translateLocation(QStandardPaths::StandardLocation type)
return kPictureDocumentsFolderType;
case QStandardPaths::TempLocation:
return kTemporaryFolderType;
+ case QStandardPaths::GenericDataLocation:
case QStandardPaths::DataLocation:
return kApplicationSupportFolderType;
case QStandardPaths::CacheLocation:
@@ -94,35 +97,54 @@ static QString getFullPath(const FSRef &ref)
return QString();
}
-QString QStandardPaths::storageLocation(StandardLocation type)
+static QString macLocation(QStandardPaths::StandardLocation type, short domain)
{
- if (type == HomeLocation)
- return QDir::homePath();
-
- if (type == TempLocation)
- return QDir::tempPath();
+ // http://developer.apple.com/documentation/Carbon/Reference/Folder_Manager/Reference/reference.html
+ FSRef ref;
+ OSErr err = FSFindFolder(domain, translateLocation(type), false, &ref);
+ if (err)
+ return QString();
- short domain = kOnAppropriateDisk;
+ QString path = getFullPath(ref);
- if (type == DataLocation || type == CacheLocation)
- domain = kUserDomain;
+ if (type == QStandardPaths::DataLocation || type == QStandardPaths::CacheLocation) {
+ if (!QCoreApplication::organizationName().isEmpty())
+ path += QLatin1Char('/') + QCoreApplication::organizationName();
+ if (!QCoreApplication::applicationName().isEmpty())
+ path += QLatin1Char('/') + QCoreApplication::applicationName();
+ }
+ return path;
+}
- // http://developer.apple.com/documentation/Carbon/Reference/Folder_Manager/Reference/reference.html
- FSRef ref;
- OSErr err = FSFindFolder(domain, translateLocation(type), false, &ref);
- if (err)
- return QString();
+QString QStandardPaths::storageLocation(StandardLocation type)
+{
+ switch (type) {
+ case HomeLocation:
+ return QDir::homePath();
+ case TempLocation:
+ return QDir::tempPath();
+ case GenericDataLocation:
+ case DataLocation:
+ case CacheLocation:
+ return macLocation(type, kUserDomain);
+ default:
+ return macLocation(type, kOnAppropriateDisk);
+ }
+}
- QString path = getFullPath(ref);
+QStringList QStandardPaths::standardLocations(StandardLocation type)
+{
+ QStringList dirs;
- if (type == DataLocation || type == CacheLocation) {
- if (QCoreApplication::organizationName().isEmpty() == false)
- path += QLatin1Char('/') + QCoreApplication::organizationName();
- if (QCoreApplication::applicationName().isEmpty() == false)
- path += QLatin1Char('/') + QCoreApplication::applicationName();
+ if (type == GenericDataLocation || type == DataLocation || type == CacheLocation) {
+ const QString path = macLocation(type, kOnAppropriateDisk);
+ if (!path.isEmpty())
+ dirs.append(path);
}
- return path;
+ const QString localDir = storageLocation(type);
+ dirs.prepend(localDir);
+ return dirs;
}
QString QStandardPaths::displayName(StandardLocation type)