forked from qt-creator/qt-creator
Core: Make UtilsJsExtension::relativeFilePath() work on remote
Task-number: QTCREATORBUG-28355 Change-Id: I67fad186ed31e42688835b38177f3fb7cd59c1d0 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -234,9 +234,10 @@ public:
|
|||||||
[[nodiscard]] static int rootLength(const QStringView path); // Assumes no scheme and host
|
[[nodiscard]] static int rootLength(const QStringView path); // Assumes no scheme and host
|
||||||
[[nodiscard]] static int schemeAndHostLength(const QStringView path);
|
[[nodiscard]] static int schemeAndHostLength(const QStringView path);
|
||||||
|
|
||||||
|
static QString calcRelativePath(const QString &absolutePath, const QString &absoluteAnchorPath);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class ::tst_fileutils;
|
friend class ::tst_fileutils;
|
||||||
static QString calcRelativePath(const QString &absolutePath, const QString &absoluteAnchorPath);
|
|
||||||
void setPath(QStringView path);
|
void setPath(QStringView path);
|
||||||
void setFromString(const QString &filepath);
|
void setFromString(const QString &filepath);
|
||||||
DeviceFileAccess *fileAccess() const;
|
DeviceFileAccess *fileAccess() const;
|
||||||
|
@@ -16,8 +16,9 @@
|
|||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QVersionNumber>
|
#include <QVersionNumber>
|
||||||
|
|
||||||
namespace Core {
|
using namespace Utils;
|
||||||
namespace Internal {
|
|
||||||
|
namespace Core::Internal {
|
||||||
|
|
||||||
QString UtilsJsExtension::qtVersion() const
|
QString UtilsJsExtension::qtVersion() const
|
||||||
{
|
{
|
||||||
@@ -83,7 +84,9 @@ QString UtilsJsExtension::absoluteFilePath(const QString &in) const
|
|||||||
|
|
||||||
QString UtilsJsExtension::relativeFilePath(const QString &path, const QString &base) const
|
QString UtilsJsExtension::relativeFilePath(const QString &path, const QString &base) const
|
||||||
{
|
{
|
||||||
return QDir(base).relativeFilePath(path);
|
const FilePath basePath = FilePath::fromString(base).cleanPath();
|
||||||
|
const FilePath filePath = FilePath::fromString(path).cleanPath();
|
||||||
|
return FilePath::calcRelativePath(filePath.toFSPathString(), basePath.toFSPathString());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UtilsJsExtension::exists(const QString &in) const
|
bool UtilsJsExtension::exists(const QString &in) const
|
||||||
@@ -175,5 +178,4 @@ QString UtilsJsExtension::qtQuickVersion(const QString &filePath) const
|
|||||||
return QLatin1String("2.15");
|
return QLatin1String("2.15");
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // Core::Internal
|
||||||
} // namespace Core
|
|
||||||
|
@@ -8,9 +8,7 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
|
|
||||||
namespace Core {
|
namespace Core::Internal {
|
||||||
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class UtilsJsExtension : public QObject
|
class UtilsJsExtension : public QObject
|
||||||
{
|
{
|
||||||
@@ -59,5 +57,4 @@ public:
|
|||||||
Q_INVOKABLE QString qtQuickVersion(const QString &filePath) const;
|
Q_INVOKABLE QString qtQuickVersion(const QString &filePath) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // Core::Internal
|
||||||
} // namespace Core
|
|
||||||
|
Reference in New Issue
Block a user