File indexing completed on 2019-10-03 10:48:19

0001 /* This file is part of the KDE libraries
0002 Copyright (C) 2015 Harald Sitter <sitter@kde.org>
0003 
0004 This library is free software; you can redistribute it and/or
0005 modify it under the terms of the GNU Library General Public
0006 License version 2 as published by the Free Software Foundation.
0007 
0008 This library is distributed in the hope that it will be useful,
0009 but WITHOUT ANY WARRANTY; without even the implied warranty of
0010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0011 Library General Public License for more details.
0012 
0013 You should have received a copy of the GNU Library General Public License
0014 along with this library; see the file COPYING.LIB.  If not, write to
0015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0016 Boston, MA 02110-1301, USA.
0017 */
0018 
0019 #include "kioglobal_p.h"
0020 
0021 #include <QStandardPaths>
0022 
0023 static QMap<QString, QString> standardLocationsMap()
0024 {
0025     static const
0026             struct { QStandardPaths::StandardLocation location;
0027                      QString name; }
0028                    mapping[] = {
0029             { QStandardPaths::MusicLocation, QStringLiteral("folder-music") },
0030             { QStandardPaths::MoviesLocation, QStringLiteral("folder-videos") },
0031             { QStandardPaths::PicturesLocation, QStringLiteral("folder-pictures") },
0032             { QStandardPaths::TempLocation, QStringLiteral("folder-temp") },
0033             { QStandardPaths::DownloadLocation, QStringLiteral("folder-download") },
0034             // Order matters here as paths can be reused for multiple purposes
0035             // We essentially want more generic choices to trump more specific
0036             // ones.
0037             // home > desktop > documents > *.
0038             { QStandardPaths::DocumentsLocation, QStringLiteral("folder-documents") },
0039             { QStandardPaths::DesktopLocation, QStringLiteral("user-desktop") },
0040             { QStandardPaths::HomeLocation, QStringLiteral("user-home") } };
0041 
0042     QMap<QString, QString> map;
0043     for (const auto &row : mapping) {
0044         const QStringList locations = QStandardPaths::standardLocations(row.location);
0045         for (const QString &location : locations) {
0046             map.insert(location, row.name);
0047         }
0048     }
0049     return map;
0050 }
0051 
0052 QString KIOPrivate::iconForStandardPath(const QString &localDirectory)
0053 {
0054     static auto map = standardLocationsMap();
0055     return map.value(localDirectory, QString());
0056 }