File indexing completed on 2024-04-28 11:31:03
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2006-2007 Torsten Rahn <tackat@kde.org> 0004 // SPDX-FileCopyrightText: 2007 Inge Wallin <ingwa@kde.org> 0005 // 0006 0007 #ifndef MARBLE_MARBLEDIRS_H 0008 #define MARBLE_MARBLEDIRS_H 0009 0010 #include "marble_export.h" 0011 0012 #include <QDir> 0013 0014 class QString; 0015 class QStringList; 0016 0017 namespace Marble 0018 { 0019 0020 /** 0021 * @short A class that manages data look-up for Marble. 0022 * 0023 * The class basically does for Marble what KStandardDirs did for KDE4. 0024 * Given that the MarbleWidget is a Qt5-only library and given that it 0025 * comes with its own model and data we need this class. 0026 * 0027 * The class needs to respect the requirements of the different plattforms, 0028 * so to avoid very different implementations for each plattform we 0029 * specify how data should get looked up: 0030 * 0031 * Generally there are two places of which Marble will draw it's data from: 0032 * 0033 * "localPath" and "systemPath". 0034 * 0035 * look-up of the data should happen in the localPath first. 0036 * Only if the look-up in the localPath failed then MarbleDirs should 0037 * look up the data in the systemPath. 0038 * 0039 * localPath: 0040 * The place for localPath should match space that is fully accessible to 0041 * the user. On Unix-like plattforms this matches 0042 * QDir::homePath() + "/.marble/data" 0043 * 0044 * systemPath: 0045 * Ideally the systemPath should match the place where cmake installed the 0046 * data for marble. However this doesn't work for all plattforms: 0047 * 0048 * - For Linux and Mac non-bundle deployment the location can be 0049 * chosen using the cmake MARBLE_DATA_PATH option at compile time. 0050 * - For Mac bundle deployment the location inside the bundle gets 0051 * chosen as the default location. 0052 * - For Windows a path relative to the application binary can be chosen 0053 * as this should usually work without problems. 0054 * 0055 * To allow kiosk-like setups and for custom setups in general 0056 * it should be possible to change the place of the systemPath at runtime. 0057 * Therefore we introduce a global variable "MarbleDataPath" in the 0058 * MarbleDirs.h source code. 0059 * Initially MarbleDataPath is empty. The systemPath will point to 0060 * MarbleDataPath as soon as it gets changed to a valid non-empty path. So 0061 * as soon as MarbleDataPath contains a valid path the path specified by 0062 * cmake will get ignored. 0063 * 0064 * ( Possible future extension: if the MarbleDataPath contains several 0065 * valid paths separated by a colon then each of these paths should be 0066 * used for look up in the same order as for the KDE kiosk framework. ) 0067 * 0068 * It's the duty of each application that uses the MarbleWidget to retrieve 0069 * the value of the MarbleDataPath from the MarbleWidget and to save it 0070 * in its settings and restore it on start-up of the application. 0071 * 0072 */ 0073 0074 class MARBLE_EXPORT MarbleDirs 0075 { 0076 public: 0077 MarbleDirs(); 0078 0079 static QString path( const QString& relativePath ); 0080 0081 static QString pluginPath( const QString& relativePath ); 0082 0083 0084 static QStringList entryList( const QString& relativePath, QDir::Filters filters = QDir::NoFilter ); 0085 0086 static QStringList pluginEntryList( const QString& relativePath, QDir::Filters filters = QDir::NoFilter ); 0087 0088 0089 static QString systemPath(); 0090 0091 static QString pluginSystemPath(); 0092 0093 0094 static QString localPath(); 0095 0096 static QStringList oldLocalPaths(); 0097 0098 static QString pluginLocalPath(); 0099 0100 0101 static QString marbleDataPath(); 0102 0103 static QString marblePluginPath(); 0104 0105 0106 static void setMarbleDataPath( const QString& adaptedPath); 0107 0108 static void setMarblePluginPath( const QString& adaptedPath); 0109 0110 0111 static void debug(); 0112 0113 private: 0114 Q_DISABLE_COPY( MarbleDirs ) 0115 class Private; 0116 Private * const d; 0117 }; 0118 0119 } 0120 0121 #endif