forked from qt-creator/qt-creator
Variable manager: Provide file path variables with native separators
Since we cannot know if the path should be represented with native separators or not, we have to leave the decision to the user, by providing separate variables for it. Change-Id: I4d06d0a29627f4e82f8b2c7acac06f442c5c5eb4 Task-number: QTCREATORBUG-11896 Reviewed-by: Daniel Teske <daniel.teske@theqtcompany.com>
This commit is contained in:
@@ -37,6 +37,7 @@
|
|||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QDir>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
|
||||||
@@ -45,6 +46,8 @@ namespace Internal {
|
|||||||
|
|
||||||
const char kFilePathPostfix[] = ":FilePath";
|
const char kFilePathPostfix[] = ":FilePath";
|
||||||
const char kPathPostfix[] = ":Path";
|
const char kPathPostfix[] = ":Path";
|
||||||
|
const char kNativeFilePathPostfix[] = ":NativeFilePath";
|
||||||
|
const char kNativePathPostfix[] = ":NativePath";
|
||||||
const char kFileNamePostfix[] = ":FileName";
|
const char kFileNamePostfix[] = ":FileName";
|
||||||
const char kFileBaseNamePostfix[] = ":FileBaseName";
|
const char kFileBaseNamePostfix[] = ":FileBaseName";
|
||||||
|
|
||||||
@@ -370,6 +373,22 @@ void MacroExpander::registerFileVariables(const QByteArray &prefix,
|
|||||||
[base]() -> QString { QString tmp = base(); return tmp.isEmpty() ? QString() : QFileInfo(tmp).path(); },
|
[base]() -> QString { QString tmp = base(); return tmp.isEmpty() ? QString() : QFileInfo(tmp).path(); },
|
||||||
visibleInChooser);
|
visibleInChooser);
|
||||||
|
|
||||||
|
registerVariable(prefix + kNativeFilePathPostfix,
|
||||||
|
tr("%1: Full path including file name, with native path separator (backslash on Windows).").arg(heading),
|
||||||
|
[base]() -> QString {
|
||||||
|
QString tmp = base();
|
||||||
|
return tmp.isEmpty() ? QString() : QDir::toNativeSeparators(QFileInfo(tmp).filePath());
|
||||||
|
},
|
||||||
|
visibleInChooser);
|
||||||
|
|
||||||
|
registerVariable(prefix + kNativePathPostfix,
|
||||||
|
tr("%1: Full path excluding file name, with native path separator (backslash on Windows).").arg(heading),
|
||||||
|
[base]() -> QString {
|
||||||
|
QString tmp = base();
|
||||||
|
return tmp.isEmpty() ? QString() : QDir::toNativeSeparators(QFileInfo(tmp).path());
|
||||||
|
},
|
||||||
|
visibleInChooser);
|
||||||
|
|
||||||
registerVariable(prefix + kFileNamePostfix,
|
registerVariable(prefix + kFileNamePostfix,
|
||||||
tr("%1: File name without path.").arg(heading),
|
tr("%1: File name without path.").arg(heading),
|
||||||
[base]() -> QString { QString tmp = base(); return tmp.isEmpty() ? QString() : Utils::FileName::fromString(tmp).fileName(); },
|
[base]() -> QString { QString tmp = base(); return tmp.isEmpty() ? QString() : Utils::FileName::fromString(tmp).fileName(); },
|
||||||
|
|||||||
Reference in New Issue
Block a user