forked from qt-creator/qt-creator
CMakePM: Replace QDir with Utils::FilePath in editor
This way we could handle remote files. Change-Id: I7062445cb743a2838f3c9f1bcff89611127011ca Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -19,7 +19,6 @@
|
|||||||
#include <texteditor/texteditoractionhandler.h>
|
#include <texteditor/texteditoractionhandler.h>
|
||||||
#include <utils/textutils.h>
|
#include <utils/textutils.h>
|
||||||
|
|
||||||
#include <QDir>
|
|
||||||
#include <QTextDocument>
|
#include <QTextDocument>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
@@ -186,7 +185,7 @@ void CMakeEditorWidget::findLinkAt(const QTextCursor &cursor,
|
|||||||
if (buffer.isEmpty())
|
if (buffer.isEmpty())
|
||||||
return processLinkCallback(link);
|
return processLinkCallback(link);
|
||||||
|
|
||||||
QDir dir(textDocument()->filePath().toFileInfo().absolutePath());
|
const Utils::FilePath dir = textDocument()->filePath().absolutePath();
|
||||||
buffer.replace("${CMAKE_CURRENT_SOURCE_DIR}", dir.path());
|
buffer.replace("${CMAKE_CURRENT_SOURCE_DIR}", dir.path());
|
||||||
buffer.replace("${CMAKE_CURRENT_LIST_DIR}", dir.path());
|
buffer.replace("${CMAKE_CURRENT_LIST_DIR}", dir.path());
|
||||||
|
|
||||||
@@ -211,18 +210,18 @@ void CMakeEditorWidget::findLinkAt(const QTextCursor &cursor,
|
|||||||
}
|
}
|
||||||
// TODO: Resolve more variables
|
// TODO: Resolve more variables
|
||||||
|
|
||||||
QString fileName = dir.filePath(unescape(buffer));
|
Utils::FilePath fileName = dir.withNewPath(unescape(buffer));
|
||||||
QFileInfo fi(fileName);
|
if (fileName.isRelativePath())
|
||||||
if (fi.exists()) {
|
fileName = dir.pathAppended(fileName.path());
|
||||||
if (fi.isDir()) {
|
if (fileName.exists()) {
|
||||||
QDir subDir(fi.absoluteFilePath());
|
if (fileName.isDir()) {
|
||||||
QString subProject = subDir.filePath(QLatin1String("CMakeLists.txt"));
|
Utils::FilePath subProject = fileName.pathAppended("CMakeLists.txt");
|
||||||
if (QFileInfo::exists(subProject))
|
if (subProject.exists())
|
||||||
fileName = subProject;
|
fileName = subProject;
|
||||||
else
|
else
|
||||||
return processLinkCallback(link);
|
return processLinkCallback(link);
|
||||||
}
|
}
|
||||||
link.targetFilePath = Utils::FilePath::fromString(fileName);
|
link.targetFilePath = fileName;
|
||||||
link.linkTextStart = cursor.position() - column + beginPos + 1;
|
link.linkTextStart = cursor.position() - column + beginPos + 1;
|
||||||
link.linkTextEnd = cursor.position() - column + endPos;
|
link.linkTextEnd = cursor.position() - column + endPos;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user