forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/9.0'
Change-Id: I5e6cfc111941f9609285e1b802121644fa8cdaac
This commit is contained in:
@@ -12,6 +12,12 @@ CategorySortFilterModel::CategorySortFilterModel(QObject *parent)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CategorySortFilterModel::setNewItemRole(int role)
|
||||||
|
{
|
||||||
|
m_newItemRole = role;
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
bool CategorySortFilterModel::filterAcceptsRow(int source_row,
|
bool CategorySortFilterModel::filterAcceptsRow(int source_row,
|
||||||
const QModelIndex &source_parent) const
|
const QModelIndex &source_parent) const
|
||||||
{
|
{
|
||||||
@@ -21,6 +27,12 @@ bool CategorySortFilterModel::filterAcceptsRow(int source_row,
|
|||||||
const QModelIndex &categoryIndex = sourceModel()->index(source_row, 0, source_parent);
|
const QModelIndex &categoryIndex = sourceModel()->index(source_row, 0, source_parent);
|
||||||
if (regexp.match(sourceModel()->data(categoryIndex, filterRole()).toString()).hasMatch())
|
if (regexp.match(sourceModel()->data(categoryIndex, filterRole()).toString()).hasMatch())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (m_newItemRole != -1 && categoryIndex.isValid()) {
|
||||||
|
if (categoryIndex.data(m_newItemRole).toBool())
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
const int rowCount = sourceModel()->rowCount(categoryIndex);
|
const int rowCount = sourceModel()->rowCount(categoryIndex);
|
||||||
for (int row = 0; row < rowCount; ++row) {
|
for (int row = 0; row < rowCount; ++row) {
|
||||||
if (filterAcceptsRow(row, categoryIndex))
|
if (filterAcceptsRow(row, categoryIndex))
|
||||||
@@ -28,6 +40,14 @@ bool CategorySortFilterModel::filterAcceptsRow(int source_row,
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_newItemRole != -1) {
|
||||||
|
const QModelIndex &idx = sourceModel()->index(source_row, 0, source_parent);
|
||||||
|
if (idx.data(m_newItemRole).toBool())
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,8 +14,14 @@ class QTCREATOR_UTILS_EXPORT CategorySortFilterModel : public QSortFilterProxyMo
|
|||||||
public:
|
public:
|
||||||
CategorySortFilterModel(QObject *parent = nullptr);
|
CategorySortFilterModel(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
// "New" items will always be accepted, regardless of the filter.
|
||||||
|
void setNewItemRole(int role);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
|
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_newItemRole = -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Utils
|
} // Utils
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
#include <utils/icon.h>
|
#include <utils/icon.h>
|
||||||
|
#include <utils/stylehelper.h>
|
||||||
|
|
||||||
#include <QGraphicsOpacityEffect>
|
#include <QGraphicsOpacityEffect>
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
@@ -81,6 +82,14 @@ QSize DetailsButton::sizeHint() const
|
|||||||
spacing + fontMetrics().height() + spacing);
|
spacing + fontMetrics().height() + spacing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QColor DetailsButton::outlineColor()
|
||||||
|
{
|
||||||
|
return HostOsInfo::isMacHost()
|
||||||
|
? QGuiApplication::palette().color(QPalette::Mid)
|
||||||
|
: StyleHelper::mergedColors(creatorTheme()->color(Theme::TextColorNormal),
|
||||||
|
creatorTheme()->color(Theme::BackgroundColorNormal), 15);
|
||||||
|
}
|
||||||
|
|
||||||
void DetailsButton::paintEvent(QPaintEvent *e)
|
void DetailsButton::paintEvent(QPaintEvent *e)
|
||||||
{
|
{
|
||||||
Q_UNUSED(e)
|
Q_UNUSED(e)
|
||||||
@@ -93,11 +102,8 @@ void DetailsButton::paintEvent(QPaintEvent *e)
|
|||||||
p.restore();
|
p.restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!creatorTheme()->flag(Theme::FlatProjectsMode)) {
|
if (!creatorTheme()->flag(Theme::FlatProjectsMode))
|
||||||
const QColor outlineColor = palette().color(HostOsInfo::isMacHost() ? QPalette::Mid
|
qDrawPlainRect(&p, rect(), outlineColor());
|
||||||
: QPalette::Midlight);
|
|
||||||
qDrawPlainRect(&p, rect(), outlineColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
const QRect textRect(spacing + 3, 0, width(), height());
|
const QRect textRect(spacing + 3, 0, width(), height());
|
||||||
p.drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, text());
|
p.drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, text());
|
||||||
|
@@ -49,6 +49,7 @@ class QTCREATOR_UTILS_EXPORT DetailsButton : public ExpandButton
|
|||||||
public:
|
public:
|
||||||
DetailsButton(QWidget *parent = nullptr);
|
DetailsButton(QWidget *parent = nullptr);
|
||||||
QSize sizeHint() const override;
|
QSize sizeHint() const override;
|
||||||
|
static QColor outlineColor();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void paintEvent(QPaintEvent *e) override;
|
void paintEvent(QPaintEvent *e) override;
|
||||||
|
@@ -227,11 +227,8 @@ void DetailsWidget::paintEvent(QPaintEvent *paintEvent)
|
|||||||
: palette().color(QPalette::Window);
|
: palette().color(QPalette::Window);
|
||||||
p.fillRect(rect(), bgColor);
|
p.fillRect(rect(), bgColor);
|
||||||
}
|
}
|
||||||
if (!creatorTheme()->flag(Theme::FlatProjectsMode)) {
|
if (!creatorTheme()->flag(Theme::FlatProjectsMode))
|
||||||
const QColor outlineColor = palette().color(HostOsInfo::isMacHost() ? QPalette::Mid
|
qDrawPlainRect(&p, rect(), DetailsButton::outlineColor());
|
||||||
: QPalette::Midlight);
|
|
||||||
qDrawPlainRect(&p, rect(), outlineColor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DetailsWidget::enterEvent(QEnterEvent *event)
|
void DetailsWidget::enterEvent(QEnterEvent *event)
|
||||||
|
@@ -966,7 +966,7 @@ FilePath FilePath::relativeChildPath(const FilePath &parent) const
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \returns the relativePath of FilePath to given \a anchor.
|
/// \returns the relativePath of FilePath from a given \a anchor.
|
||||||
/// Both, FilePath and anchor may be files or directories.
|
/// Both, FilePath and anchor may be files or directories.
|
||||||
/// Example usage:
|
/// Example usage:
|
||||||
///
|
///
|
||||||
@@ -978,7 +978,7 @@ FilePath FilePath::relativeChildPath(const FilePath &parent) const
|
|||||||
///
|
///
|
||||||
/// The debug output will be "../b/ar/file.txt".
|
/// The debug output will be "../b/ar/file.txt".
|
||||||
///
|
///
|
||||||
FilePath FilePath::relativePath(const FilePath &anchor) const
|
FilePath FilePath::relativePathFrom(const FilePath &anchor) const
|
||||||
{
|
{
|
||||||
QTC_ASSERT(isSameDevice(anchor), return *this);
|
QTC_ASSERT(isSameDevice(anchor), return *this);
|
||||||
|
|
||||||
|
@@ -153,7 +153,7 @@ public:
|
|||||||
[[nodiscard]] FilePath resolveSymlinks() const;
|
[[nodiscard]] FilePath resolveSymlinks() const;
|
||||||
[[nodiscard]] FilePath withExecutableSuffix() const;
|
[[nodiscard]] FilePath withExecutableSuffix() const;
|
||||||
[[nodiscard]] FilePath relativeChildPath(const FilePath &parent) const;
|
[[nodiscard]] FilePath relativeChildPath(const FilePath &parent) const;
|
||||||
[[nodiscard]] FilePath relativePath(const FilePath &anchor) const;
|
[[nodiscard]] FilePath relativePathFrom(const FilePath &anchor) const;
|
||||||
[[nodiscard]] FilePath searchInDirectories(const FilePaths &dirs) const;
|
[[nodiscard]] FilePath searchInDirectories(const FilePaths &dirs) const;
|
||||||
[[nodiscard]] Environment deviceEnvironment() const;
|
[[nodiscard]] Environment deviceEnvironment() const;
|
||||||
[[nodiscard]] FilePath onDevice(const FilePath &deviceTemplate) const;
|
[[nodiscard]] FilePath onDevice(const FilePath &deviceTemplate) const;
|
||||||
|
@@ -634,6 +634,8 @@ public:
|
|||||||
|
|
||||||
void setProcessInterface(ProcessInterface *process)
|
void setProcessInterface(ProcessInterface *process)
|
||||||
{
|
{
|
||||||
|
if (m_process)
|
||||||
|
m_process->disconnect();
|
||||||
m_process.reset(process);
|
m_process.reset(process);
|
||||||
m_process->setParent(this);
|
m_process->setParent(this);
|
||||||
connect(m_process.get(), &ProcessInterface::started,
|
connect(m_process.get(), &ProcessInterface::started,
|
||||||
@@ -805,6 +807,14 @@ GeneralProcessBlockingImpl::GeneralProcessBlockingImpl(QtcProcessPrivate *parent
|
|||||||
// In order to move the process interface into another thread together with handle
|
// In order to move the process interface into another thread together with handle
|
||||||
parent->m_process.get()->setParent(m_processHandler.get());
|
parent->m_process.get()->setParent(m_processHandler.get());
|
||||||
m_processHandler->setParent(this);
|
m_processHandler->setParent(this);
|
||||||
|
// So the hierarchy looks like:
|
||||||
|
// QtcProcessPrivate
|
||||||
|
// |
|
||||||
|
// +- GeneralProcessBlockingImpl
|
||||||
|
// |
|
||||||
|
// +- ProcessInterfaceHandler
|
||||||
|
// |
|
||||||
|
// +- ProcessInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GeneralProcessBlockingImpl::waitForSignal(ProcessSignalType newSignal, int msecs)
|
bool GeneralProcessBlockingImpl::waitForSignal(ProcessSignalType newSignal, int msecs)
|
||||||
@@ -998,6 +1008,8 @@ QtcProcess::~QtcProcess()
|
|||||||
{
|
{
|
||||||
QTC_ASSERT(!d->m_guard.isLocked(), qWarning("Deleting QtcProcess instance directly from "
|
QTC_ASSERT(!d->m_guard.isLocked(), qWarning("Deleting QtcProcess instance directly from "
|
||||||
"one of its signal handlers will lead to crash!"));
|
"one of its signal handlers will lead to crash!"));
|
||||||
|
if (d->m_process)
|
||||||
|
d->m_process->disconnect();
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -236,6 +236,7 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildSystem *bs) :
|
|||||||
m_configTextFilterModel->setSourceModel(m_configFilterModel);
|
m_configTextFilterModel->setSourceModel(m_configFilterModel);
|
||||||
m_configTextFilterModel->setSortRole(Qt::DisplayRole);
|
m_configTextFilterModel->setSortRole(Qt::DisplayRole);
|
||||||
m_configTextFilterModel->setFilterKeyColumn(-1);
|
m_configTextFilterModel->setFilterKeyColumn(-1);
|
||||||
|
m_configTextFilterModel->setNewItemRole(ConfigModel::ItemIsUserNew);
|
||||||
|
|
||||||
connect(m_configTextFilterModel, &QAbstractItemModel::layoutChanged, this, [this]() {
|
connect(m_configTextFilterModel, &QAbstractItemModel::layoutChanged, this, [this]() {
|
||||||
QModelIndex selectedIdx = m_configView->currentIndex();
|
QModelIndex selectedIdx = m_configView->currentIndex();
|
||||||
|
@@ -67,7 +67,7 @@ static void copySourcePathsToClipboard(const FilePaths &srcPaths, const ProjectN
|
|||||||
QClipboard *clip = QGuiApplication::clipboard();
|
QClipboard *clip = QGuiApplication::clipboard();
|
||||||
|
|
||||||
QString data = Utils::transform(srcPaths, [projDir = node->filePath()](const FilePath &path) {
|
QString data = Utils::transform(srcPaths, [projDir = node->filePath()](const FilePath &path) {
|
||||||
return path.relativePath(projDir).cleanPath().toString();
|
return path.relativePathFrom(projDir).cleanPath().toString();
|
||||||
}).join(" ");
|
}).join(" ");
|
||||||
clip->setText(data);
|
clip->setText(data);
|
||||||
}
|
}
|
||||||
@@ -301,7 +301,7 @@ FilePaths CMakeBuildSystem::filesGeneratedFrom(const FilePath &sourceFile) const
|
|||||||
baseDirectory = baseDirectory.parentDir();
|
baseDirectory = baseDirectory.parentDir();
|
||||||
}
|
}
|
||||||
|
|
||||||
const FilePath relativePath = baseDirectory.relativePath(project);
|
const FilePath relativePath = baseDirectory.relativePathFrom(project);
|
||||||
FilePath generatedFilePath = buildConfiguration()->buildDirectory().resolvePath(relativePath);
|
FilePath generatedFilePath = buildConfiguration()->buildDirectory().resolvePath(relativePath);
|
||||||
|
|
||||||
if (sourceFile.suffix() == "ui") {
|
if (sourceFile.suffix() == "ui") {
|
||||||
|
@@ -546,6 +546,9 @@ QVariant ConfigModelTreeItem::data(int column, int role) const
|
|||||||
if (role == ConfigModel::ItemIsInitialRole) {
|
if (role == ConfigModel::ItemIsInitialRole) {
|
||||||
return dataItem->isInitial ? "1" : "0";
|
return dataItem->isInitial ? "1" : "0";
|
||||||
}
|
}
|
||||||
|
if (role == ConfigModel::ItemIsUserNew) {
|
||||||
|
return dataItem->isUserNew ? "1" : "0";
|
||||||
|
}
|
||||||
|
|
||||||
auto fontRole = [this]() -> QFont {
|
auto fontRole = [this]() -> QFont {
|
||||||
QFont font;
|
QFont font;
|
||||||
|
@@ -18,7 +18,8 @@ class ConfigModel : public Utils::TreeModel<>
|
|||||||
public:
|
public:
|
||||||
enum Roles {
|
enum Roles {
|
||||||
ItemIsAdvancedRole = Qt::UserRole,
|
ItemIsAdvancedRole = Qt::UserRole,
|
||||||
ItemIsInitialRole
|
ItemIsInitialRole,
|
||||||
|
ItemIsUserNew,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DataItem {
|
struct DataItem {
|
||||||
|
@@ -10,10 +10,8 @@
|
|||||||
|
|
||||||
namespace CMakeProjectManager::Internal::CMakePresets::Macros {
|
namespace CMakeProjectManager::Internal::CMakePresets::Macros {
|
||||||
|
|
||||||
QString getHostSystemName()
|
static QString getHostSystemName(Utils::OsType osType)
|
||||||
{
|
{
|
||||||
Utils::OsType osType = Utils::HostOsInfo::hostOs();
|
|
||||||
|
|
||||||
switch (osType) {
|
switch (osType) {
|
||||||
case Utils::OsTypeWindows:
|
case Utils::OsTypeWindows:
|
||||||
return "Windows";
|
return "Windows";
|
||||||
@@ -29,9 +27,9 @@ QString getHostSystemName()
|
|||||||
return "Other";
|
return "Other";
|
||||||
}
|
}
|
||||||
|
|
||||||
void expandAllButEnv(const PresetsDetails::ConfigurePreset &preset,
|
static void expandAllButEnv(const PresetsDetails::ConfigurePreset &preset,
|
||||||
const Utils::FilePath &sourceDirectory,
|
const Utils::FilePath &sourceDirectory,
|
||||||
QString &value)
|
QString &value)
|
||||||
{
|
{
|
||||||
value.replace("${dollar}", "$");
|
value.replace("${dollar}", "$");
|
||||||
|
|
||||||
@@ -43,12 +41,12 @@ void expandAllButEnv(const PresetsDetails::ConfigurePreset &preset,
|
|||||||
if (preset.generator)
|
if (preset.generator)
|
||||||
value.replace("${generator}", preset.generator.value());
|
value.replace("${generator}", preset.generator.value());
|
||||||
|
|
||||||
value.replace("${hostSystemName}", getHostSystemName());
|
value.replace("${hostSystemName}", getHostSystemName(sourceDirectory.osType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void expandAllButEnv(const PresetsDetails::BuildPreset &preset,
|
static void expandAllButEnv(const PresetsDetails::BuildPreset &preset,
|
||||||
const Utils::FilePath &sourceDirectory,
|
const Utils::FilePath &sourceDirectory,
|
||||||
QString &value)
|
QString &value)
|
||||||
{
|
{
|
||||||
value.replace("${dollar}", "$");
|
value.replace("${dollar}", "$");
|
||||||
|
|
||||||
@@ -59,9 +57,9 @@ void expandAllButEnv(const PresetsDetails::BuildPreset &preset,
|
|||||||
value.replace("${presetName}", preset.name);
|
value.replace("${presetName}", preset.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString expandMacroEnv(const QString ¯oPrefix,
|
static QString expandMacroEnv(const QString ¯oPrefix,
|
||||||
const QString &value,
|
const QString &value,
|
||||||
const std::function<QString(const QString &)> &op)
|
const std::function<QString(const QString &)> &op)
|
||||||
{
|
{
|
||||||
const QString startToken = QString("$%1{").arg(macroPrefix);
|
const QString startToken = QString("$%1{").arg(macroPrefix);
|
||||||
const QString endToken = QString("}");
|
const QString endToken = QString("}");
|
||||||
|
@@ -221,7 +221,7 @@ void GitLabCloneDialog::cloneFinished(bool success)
|
|||||||
accept();
|
accept();
|
||||||
} else {
|
} else {
|
||||||
const QStringList pFiles = Utils::transform(filesWeMayOpen, [base](const FilePath &f) {
|
const QStringList pFiles = Utils::transform(filesWeMayOpen, [base](const FilePath &f) {
|
||||||
return f.relativePath(base).toUserOutput();
|
return f.relativePathFrom(base).toUserOutput();
|
||||||
});
|
});
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
const QString fileToOpen
|
const QString fileToOpen
|
||||||
|
@@ -445,7 +445,7 @@ static QStringList filteredFlags(const QStringList &allFlags, bool considerSysro
|
|||||||
ToolChain::MacroInspectionRunner GccToolChain::createMacroInspectionRunner() const
|
ToolChain::MacroInspectionRunner GccToolChain::createMacroInspectionRunner() const
|
||||||
{
|
{
|
||||||
// Using a clean environment breaks ccache/distcc/etc.
|
// Using a clean environment breaks ccache/distcc/etc.
|
||||||
Environment env = Environment::systemEnvironment();
|
Environment env = compilerCommand().deviceEnvironment();
|
||||||
addToEnvironment(env);
|
addToEnvironment(env);
|
||||||
const QStringList platformCodeGenFlags = m_platformCodeGenFlags;
|
const QStringList platformCodeGenFlags = m_platformCodeGenFlags;
|
||||||
OptionsReinterpreter reinterpretOptions = m_optionsReinterpreter;
|
OptionsReinterpreter reinterpretOptions = m_optionsReinterpreter;
|
||||||
@@ -852,7 +852,7 @@ void GccToolChain::setOptionsReinterpreter(const OptionsReinterpreter &optionsRe
|
|||||||
|
|
||||||
GccToolChain::DetectedAbisResult GccToolChain::detectSupportedAbis() const
|
GccToolChain::DetectedAbisResult GccToolChain::detectSupportedAbis() const
|
||||||
{
|
{
|
||||||
Environment env = Environment::systemEnvironment();
|
Environment env = compilerCommand().deviceEnvironment();
|
||||||
addToEnvironment(env);
|
addToEnvironment(env);
|
||||||
ProjectExplorer::Macros macros = createMacroInspectionRunner()({}).macros;
|
ProjectExplorer::Macros macros = createMacroInspectionRunner()({}).macros;
|
||||||
return guessGccAbi(findLocalCompiler(compilerCommand(), env),
|
return guessGccAbi(findLocalCompiler(compilerCommand(), env),
|
||||||
@@ -863,7 +863,7 @@ GccToolChain::DetectedAbisResult GccToolChain::detectSupportedAbis() const
|
|||||||
|
|
||||||
QString GccToolChain::detectVersion() const
|
QString GccToolChain::detectVersion() const
|
||||||
{
|
{
|
||||||
Environment env = Environment::systemEnvironment();
|
Environment env = compilerCommand().deviceEnvironment();
|
||||||
addToEnvironment(env);
|
addToEnvironment(env);
|
||||||
return gccVersion(findLocalCompiler(compilerCommand(), env), env,
|
return gccVersion(findLocalCompiler(compilerCommand(), env), env,
|
||||||
filteredFlags(platformCodeGenFlags(), true));
|
filteredFlags(platformCodeGenFlags(), true));
|
||||||
@@ -871,7 +871,7 @@ QString GccToolChain::detectVersion() const
|
|||||||
|
|
||||||
Utils::FilePath GccToolChain::detectInstallDir() const
|
Utils::FilePath GccToolChain::detectInstallDir() const
|
||||||
{
|
{
|
||||||
Environment env = Environment::systemEnvironment();
|
Environment env = compilerCommand().deviceEnvironment();
|
||||||
addToEnvironment(env);
|
addToEnvironment(env);
|
||||||
return gccInstallDir(findLocalCompiler(compilerCommand(), env), env,
|
return gccInstallDir(findLocalCompiler(compilerCommand(), env), env,
|
||||||
filteredFlags(platformCodeGenFlags(), true));
|
filteredFlags(platformCodeGenFlags(), true));
|
||||||
|
@@ -77,7 +77,7 @@ Core::GeneratedFiles JsonWizardScannerGenerator::fileList(Utils::MacroExpander *
|
|||||||
[](const Utils::FilePath &filePath) { return int(filePath.path().count('/')); };
|
[](const Utils::FilePath &filePath) { return int(filePath.path().count('/')); };
|
||||||
int minDepth = std::numeric_limits<int>::max();
|
int minDepth = std::numeric_limits<int>::max();
|
||||||
for (auto it = result.begin(); it != result.end(); ++it) {
|
for (auto it = result.begin(); it != result.end(); ++it) {
|
||||||
const Utils::FilePath relPath = it->filePath().relativePath(projectDir);
|
const Utils::FilePath relPath = it->filePath().relativePathFrom(projectDir);
|
||||||
it->setBinary(binaryPattern.match(relPath.toString()).hasMatch());
|
it->setBinary(binaryPattern.match(relPath.toString()).hasMatch());
|
||||||
bool found = ProjectManager::canOpenProjectForMimeType(Utils::mimeTypeForFile(relPath));
|
bool found = ProjectManager::canOpenProjectForMimeType(Utils::mimeTypeForFile(relPath));
|
||||||
if (found) {
|
if (found) {
|
||||||
@@ -119,7 +119,7 @@ Core::GeneratedFiles JsonWizardScannerGenerator::scan(const Utils::FilePath &dir
|
|||||||
const Utils::FilePaths entries = dir.dirEntries({{}, QDir::AllEntries | QDir::NoDotAndDotDot},
|
const Utils::FilePaths entries = dir.dirEntries({{}, QDir::AllEntries | QDir::NoDotAndDotDot},
|
||||||
QDir::DirsLast | QDir::Name);
|
QDir::DirsLast | QDir::Name);
|
||||||
for (const Utils::FilePath &fi : entries) {
|
for (const Utils::FilePath &fi : entries) {
|
||||||
const Utils::FilePath relativePath = fi.relativePath(base);
|
const Utils::FilePath relativePath = fi.relativePathFrom(base);
|
||||||
if (fi.isDir() && matchesSubdirectoryPattern(relativePath)) {
|
if (fi.isDir() && matchesSubdirectoryPattern(relativePath)) {
|
||||||
result += scan(fi, base);
|
result += scan(fi, base);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -39,24 +39,37 @@ static FolderNode *recursiveFindOrCreateFolderNode(FolderNode *folder,
|
|||||||
const FilePath &overrideBaseDir,
|
const FilePath &overrideBaseDir,
|
||||||
const FolderNode::FolderNodeFactory &factory)
|
const FolderNode::FolderNodeFactory &factory)
|
||||||
{
|
{
|
||||||
QList<FilePath> paths;
|
Utils::FilePath path = overrideBaseDir.isEmpty() ? folder->filePath() : overrideBaseDir;
|
||||||
const Utils::FilePath basePath = overrideBaseDir.isEmpty() ? folder->filePath()
|
|
||||||
: overrideBaseDir;
|
|
||||||
Utils::FilePath path = basePath.isEmpty() ? directory : basePath.relativeChildPath(directory);
|
|
||||||
|
|
||||||
while (!path.isEmpty()) {
|
Utils::FilePath directoryWithoutPrefix;
|
||||||
paths.append(path);
|
bool isRelative = false;
|
||||||
path = path.parentDir();
|
|
||||||
|
if (path.isEmpty() || path.isRootPath()) {
|
||||||
|
directoryWithoutPrefix = directory;
|
||||||
|
isRelative = false;
|
||||||
|
} else {
|
||||||
|
if (directory.isChildOf(path) || directory == path) {
|
||||||
|
isRelative = true;
|
||||||
|
directoryWithoutPrefix = directory.relativeChildPath(path);
|
||||||
|
} else {
|
||||||
|
isRelative = false;
|
||||||
|
path.clear();
|
||||||
|
directoryWithoutPrefix = directory;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
std::reverse(std::begin(paths), std::end(paths));
|
QStringList parts = directoryWithoutPrefix.path().split('/', Qt::SkipEmptyParts);
|
||||||
|
if (directory.osType() != OsTypeWindows && !isRelative && !parts.isEmpty())
|
||||||
|
parts[0].prepend('/');
|
||||||
|
|
||||||
FolderNode *parent = folder;
|
ProjectExplorer::FolderNode *parent = folder;
|
||||||
for (const auto ¤tPath : paths) {
|
for (const QString &part : std::as_const(parts)) {
|
||||||
FolderNode *next = parent->folderNode(currentPath);
|
path = path.pathAppended(part);
|
||||||
|
// Find folder in subFolders
|
||||||
|
FolderNode *next = parent->folderNode(path);
|
||||||
if (!next) {
|
if (!next) {
|
||||||
// No FolderNode yet, so create it
|
// No FolderNode yet, so create it
|
||||||
auto tmp = factory(currentPath);
|
auto tmp = factory(path);
|
||||||
tmp->setDisplayName(currentPath.fileName());
|
tmp->setDisplayName(part);
|
||||||
next = tmp.get();
|
next = tmp.get();
|
||||||
parent->addNode(std::move(tmp));
|
parent->addNode(std::move(tmp));
|
||||||
}
|
}
|
||||||
|
@@ -515,7 +515,7 @@ void PropertyEditorValue::commitDrop(const QString &path)
|
|||||||
Utils::FilePath imagePath = Utils::FilePath::fromString(path);
|
Utils::FilePath imagePath = Utils::FilePath::fromString(path);
|
||||||
Utils::FilePath currFilePath = QmlDesigner::DocumentManager::currentFilePath();
|
Utils::FilePath currFilePath = QmlDesigner::DocumentManager::currentFilePath();
|
||||||
QmlDesigner::VariantProperty srcProp = texture.variantProperty("source");
|
QmlDesigner::VariantProperty srcProp = texture.variantProperty("source");
|
||||||
srcProp.setValue(imagePath.relativePath(currFilePath).toUrl());
|
srcProp.setValue(imagePath.relativePathFrom(currFilePath).toUrl());
|
||||||
|
|
||||||
// assign the texture to the property
|
// assign the texture to the property
|
||||||
setExpressionWithEmit(texture.id());
|
setExpressionWithEmit(texture.id());
|
||||||
|
@@ -113,7 +113,7 @@ ModelManagerInterface::ProjectInfo ModelManager::defaultProjectInfoForProject(
|
|||||||
auto addAppDir = [&baseDir, &projectInfo](const FilePath &mdir) {
|
auto addAppDir = [&baseDir, &projectInfo](const FilePath &mdir) {
|
||||||
auto dir = mdir.cleanPath();
|
auto dir = mdir.cleanPath();
|
||||||
if (!baseDir.path().isEmpty()) {
|
if (!baseDir.path().isEmpty()) {
|
||||||
auto rDir = dir.relativePath(baseDir);
|
auto rDir = dir.relativePathFrom(baseDir);
|
||||||
// do not add directories outside the build directory
|
// do not add directories outside the build directory
|
||||||
// this might happen for example when we think an executable path belongs to
|
// this might happen for example when we think an executable path belongs to
|
||||||
// a bundle, and we need to remove extra directories, but that was not the case
|
// a bundle, and we need to remove extra directories, but that was not the case
|
||||||
|
@@ -142,7 +142,7 @@ void CmakeGeneratorDialog::refreshNotificationText()
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (node->toFilePath().exists() && node->isChecked()) {
|
if (node->toFilePath().exists() && node->isChecked()) {
|
||||||
QString relativePath = node->toFilePath().relativePath(m_rootDir).toString();
|
QString relativePath = node->toFilePath().relativePathFrom(m_rootDir).toString();
|
||||||
cursor.insertImage(iformat);
|
cursor.insertImage(iformat);
|
||||||
cursor.insertText(QString(FILE_OVERWRITE_NOTIFICATION).arg(relativePath));
|
cursor.insertText(QString(FILE_OVERWRITE_NOTIFICATION).arg(relativePath));
|
||||||
}
|
}
|
||||||
|
@@ -1046,8 +1046,7 @@ DeviceEnvironmentFetcher::Ptr LinuxDevice::environmentFetcher() const
|
|||||||
|
|
||||||
bool LinuxDevice::usableAsBuildDevice() const
|
bool LinuxDevice::usableAsBuildDevice() const
|
||||||
{
|
{
|
||||||
const bool isUsable = qtcEnvironmentVariableIntValue("QTC_ALLOW_REMOTE_LINUX_BUILD_DEVICES");
|
return true;
|
||||||
return isUsable;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString LinuxDevice::userAtHost() const
|
QString LinuxDevice::userAtHost() const
|
||||||
|
@@ -294,7 +294,7 @@ void tst_fileutils::calcRelativePath()
|
|||||||
|
|
||||||
void tst_fileutils::relativePath_specials()
|
void tst_fileutils::relativePath_specials()
|
||||||
{
|
{
|
||||||
QString path = FilePath("").relativePath("").toString();
|
QString path = FilePath("").relativePathFrom("").toString();
|
||||||
QCOMPARE(path, "");
|
QCOMPARE(path, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,7 +320,7 @@ void tst_fileutils::relativePath()
|
|||||||
QFETCH(QString, anchor);
|
QFETCH(QString, anchor);
|
||||||
QFETCH(QString, result);
|
QFETCH(QString, result);
|
||||||
FilePath actualPath = FilePath::fromString(rootPath + "/" + relative)
|
FilePath actualPath = FilePath::fromString(rootPath + "/" + relative)
|
||||||
.relativePath(FilePath::fromString(rootPath + "/" + anchor));
|
.relativePathFrom(FilePath::fromString(rootPath + "/" + anchor));
|
||||||
QCOMPARE(actualPath.toString(), result);
|
QCOMPARE(actualPath.toString(), result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user