8#include "MarbleDebug.h" 
   10#include <QCoreApplication> 
   15#include <QStandardPaths> 
   20#define _WIN32_IE 0x0501 
   26#include <ApplicationServices/ApplicationServices.h> 
   29#include <config-marble.h> 
   40MarbleDirs::MarbleDirs()
 
   47    QString localpath = localPath() + QLatin1Char(
'/') + relativePath; 
 
   48    QString systempath = systemPath() + QLatin1Char(
'/') + relativePath; 
 
   50    QString fullpath = systempath;
 
   54    return QDir(fullpath).canonicalPath();
 
   57QString MarbleDirs::pluginPath(
const QString &relativePath)
 
   59    const QString localpath = pluginLocalPath() + 
QDir::separator() + relativePath; 
 
   60    const QString systempath = pluginSystemPath() + 
QDir::separator() + relativePath; 
 
   62    QString fullpath = systempath;
 
   67    return QDir(fullpath).canonicalPath();
 
   70QStringList MarbleDirs::entryList(
const QString &relativePath, 
QDir::Filters filters)
 
   72    QStringList filesLocal = QDir(MarbleDirs::localPath() + QLatin1Char(
'/') + relativePath).entryList(filters);
 
   73    QStringList filesSystem = QDir(MarbleDirs::systemPath() + QLatin1Char(
'/') + relativePath).entryList(filters);
 
   74    QStringList allFiles(filesLocal);
 
   75    allFiles << filesSystem;
 
   79    for (
int i = 1; i < allFiles.size(); ++i) {
 
   80        if (allFiles.at(i) == allFiles.at(i - 1)) {
 
   89QStringList MarbleDirs::pluginEntryList(
const QString &relativePath, 
QDir::Filters filters)
 
   91    QStringList allFiles = QDir(MarbleDirs::pluginLocalPath() + QLatin1Char(
'/') + relativePath).entryList(filters);
 
   92    auto const pluginSystemPath = MarbleDirs::pluginSystemPath();
 
   93    if (!pluginSystemPath.isEmpty()) {
 
   94        allFiles << QDir(pluginSystemPath + QLatin1Char(
'/') + relativePath).entryList(filters);
 
   99    for (
int i = 1; i < allFiles.
size(); ++i) {
 
  100        if (allFiles.
at(i) == allFiles.
at(i - 1)) {
 
  109QString MarbleDirs::systemPath()
 
  111    if (!runTimeMarbleDataPath.isEmpty()) {
 
  112        return runTimeMarbleDataPath;
 
  117#ifdef MARBLE_DATA_PATH 
  121    if (QDir(compileTimeMarbleDataPath).exists())
 
  122        return compileTimeMarbleDataPath;
 
  134    CFURLRef myBundleRef = CFBundleCopyBundleURL(CFBundleGetMainBundle());
 
  135    CFStringRef myMacPath = CFURLCopyFileSystemPath(myBundleRef, kCFURLPOSIXPathStyle);
 
  136    const char *mypPathPtr = CFStringGetCStringPtr(myMacPath, CFStringGetSystemEncoding());
 
  137    CFRelease(myBundleRef);
 
  138    QString myPath(mypPathPtr);
 
  139    CFRelease(myMacPath);
 
  142    if (myPath.contains(QLatin1StringView(
".app"))) { 
 
  143        systempath = myPath + QLatin1StringView(
"/Contents/Resources/data");
 
  152    systempath = 
"assets:/data";
 
  167QString MarbleDirs::pluginSystemPath()
 
  169    if (!runTimeMarblePluginPath.isEmpty()) {
 
  170        return runTimeMarblePluginPath;
 
  175#ifdef MARBLE_PLUGIN_PATH 
  179    if (QDir(compileTimeMarblePluginPath).exists())
 
  180        return compileTimeMarblePluginPath;
 
  188    CFURLRef myBundleRef = CFBundleCopyBundleURL(CFBundleGetMainBundle());
 
  189    CFStringRef myMacPath = CFURLCopyFileSystemPath(myBundleRef, kCFURLPOSIXPathStyle);
 
  190    const char *mypPathPtr = CFStringGetCStringPtr(myMacPath, CFStringGetSystemEncoding());
 
  191    CFRelease(myBundleRef);
 
  192    CFRelease(myMacPath);
 
  193    QString myPath(mypPathPtr);
 
  196    if (myPath.contains(QLatin1StringView(
".app"))) { 
 
  197        systempath = myPath + QLatin1StringView(
"/Contents/Resources/plugins");
 
  210    return "assets:/plugins";
 
  224QString MarbleDirs::localPath()
 
  231    return dataHome + QLatin1StringView(
"/marble"); 
 
  237QStringList MarbleDirs::oldLocalPaths()
 
  239    QStringList possibleOldPaths;
 
  242    const QString oldDefault = 
QDir::homePath() + QLatin1StringView(
"/.marble/data");
 
  243    possibleOldPaths.
append(oldDefault);
 
  245    const QString xdgDefault = 
QDir::homePath() + QLatin1StringView(
"/.local/share/marble");
 
  246    possibleOldPaths.
append(xdgDefault);
 
  249    xdg += QLatin1StringView(
"/marble/");
 
  250    possibleOldPaths.
append(xdg);
 
  255    WCHAR *appdata_path = 
new WCHAR[MAX_PATH + 1];
 
  257    SHGetSpecialFolderPathW(hwnd, appdata_path, CSIDL_APPDATA, 0);
 
  259    delete[] appdata_path;
 
  263    QString currentLocalPath = QDir(MarbleDirs::localPath()).canonicalPath();
 
  264    QStringList oldPaths;
 
  265    for (
const QString &possibleOldPath : possibleOldPaths) {
 
  266        if (!QDir().exists(possibleOldPath)) {
 
  270        QString canonicalPossibleOldPath = QDir(possibleOldPath).canonicalPath();
 
  271        if (canonicalPossibleOldPath == currentLocalPath) {
 
  275        oldPaths.
append(canonicalPossibleOldPath);
 
  281QString MarbleDirs::pluginLocalPath()
 
  290QString MarbleDirs::marbleDataPath()
 
  292    return runTimeMarbleDataPath;
 
  295QString MarbleDirs::marblePluginPath()
 
  297    return runTimeMarblePluginPath;
 
  300void MarbleDirs::setMarbleDataPath(
const QString &adaptedPath)
 
  303        qWarning() << QStringLiteral(
"Invalid MarbleDataPath \"%1\". Using \"%2\" instead.").arg(adaptedPath, systemPath());
 
  307    runTimeMarbleDataPath = adaptedPath;
 
  310void MarbleDirs::setMarblePluginPath(
const QString &adaptedPath)
 
  313        qWarning() << QStringLiteral(
"Invalid MarblePluginPath \"%1\". Using \"%2\" instead.").arg(adaptedPath, pluginSystemPath());
 
  317    runTimeMarblePluginPath = adaptedPath;
 
  320void MarbleDirs::debug()
 
  322    mDebug() << 
"=== MarbleDirs: ===";
 
  323    mDebug() << 
"Local Path:" << localPath();
 
  324    mDebug() << 
"Plugin Local Path:" << pluginLocalPath();
 
  326    mDebug() << 
"Marble Data Path (Run Time) :" << runTimeMarbleDataPath;
 
  329    mDebug() << 
"Marble Plugin Path (Run Time) :" << runTimeMarblePluginPath;
 
  330    mDebug() << 
"Marble Plugin Path (Compile Time):" << 
QString::fromLatin1(MARBLE_PLUGIN_PATH);
 
  332    mDebug() << 
"System Path:" << systemPath();
 
  333    mDebug() << 
"Plugin System Path:" << pluginSystemPath();
 
  334    mDebug() << 
"===================";
 
Binds a QML item to a specific geodetic location in screen coordinates.
 
QString applicationDirPath()
 
QString fromNativeSeparators(const QString &pathName)
 
bool exists() const const
 
void append(QList< T > &&value)
 
const_reference at(qsizetype i) const const
 
void removeAt(qsizetype i)
 
qsizetype size() const const
 
QString writableLocation(StandardLocation type)
 
QString fromLatin1(QByteArrayView str)
 
QString fromUtf16(const char16_t *unicode, qsizetype size)
 
QString fromUtf8(QByteArrayView str)
 
bool isEmpty() const const
 
void sort(Qt::CaseSensitivity cs)