Merge remote-tracking branch 'origin/9.0'

Change-Id: I5e6cfc111941f9609285e1b802121644fa8cdaac
This commit is contained in:
Orgad Shaneh
2022-10-18 21:59:53 +03:00
22 changed files with 113 additions and 56 deletions

View File

@@ -12,6 +12,12 @@ CategorySortFilterModel::CategorySortFilterModel(QObject *parent)
{
}
void CategorySortFilterModel::setNewItemRole(int role)
{
m_newItemRole = role;
invalidate();
}
bool CategorySortFilterModel::filterAcceptsRow(int source_row,
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);
if (regexp.match(sourceModel()->data(categoryIndex, filterRole()).toString()).hasMatch())
return true;
if (m_newItemRole != -1 && categoryIndex.isValid()) {
if (categoryIndex.data(m_newItemRole).toBool())
return true;
}
const int rowCount = sourceModel()->rowCount(categoryIndex);
for (int row = 0; row < rowCount; ++row) {
if (filterAcceptsRow(row, categoryIndex))
@@ -28,6 +40,14 @@ bool CategorySortFilterModel::filterAcceptsRow(int source_row,
}
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);
}

View File

@@ -14,8 +14,14 @@ class QTCREATOR_UTILS_EXPORT CategorySortFilterModel : public QSortFilterProxyMo
public:
CategorySortFilterModel(QObject *parent = nullptr);
// "New" items will always be accepted, regardless of the filter.
void setNewItemRole(int role);
protected:
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
private:
int m_newItemRole = -1;
};
} // Utils

View File

@@ -5,6 +5,7 @@
#include <utils/hostosinfo.h>
#include <utils/icon.h>
#include <utils/stylehelper.h>
#include <QGraphicsOpacityEffect>
#include <QGuiApplication>
@@ -81,6 +82,14 @@ QSize DetailsButton::sizeHint() const
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)
{
Q_UNUSED(e)
@@ -93,11 +102,8 @@ void DetailsButton::paintEvent(QPaintEvent *e)
p.restore();
}
if (!creatorTheme()->flag(Theme::FlatProjectsMode)) {
const QColor outlineColor = palette().color(HostOsInfo::isMacHost() ? QPalette::Mid
: QPalette::Midlight);
qDrawPlainRect(&p, rect(), outlineColor);
}
if (!creatorTheme()->flag(Theme::FlatProjectsMode))
qDrawPlainRect(&p, rect(), outlineColor());
const QRect textRect(spacing + 3, 0, width(), height());
p.drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, text());

View File

@@ -49,6 +49,7 @@ class QTCREATOR_UTILS_EXPORT DetailsButton : public ExpandButton
public:
DetailsButton(QWidget *parent = nullptr);
QSize sizeHint() const override;
static QColor outlineColor();
private:
void paintEvent(QPaintEvent *e) override;

View File

@@ -227,11 +227,8 @@ void DetailsWidget::paintEvent(QPaintEvent *paintEvent)
: palette().color(QPalette::Window);
p.fillRect(rect(), bgColor);
}
if (!creatorTheme()->flag(Theme::FlatProjectsMode)) {
const QColor outlineColor = palette().color(HostOsInfo::isMacHost() ? QPalette::Mid
: QPalette::Midlight);
qDrawPlainRect(&p, rect(), outlineColor);
}
if (!creatorTheme()->flag(Theme::FlatProjectsMode))
qDrawPlainRect(&p, rect(), DetailsButton::outlineColor());
}
void DetailsWidget::enterEvent(QEnterEvent *event)

View File

@@ -966,7 +966,7 @@ FilePath FilePath::relativeChildPath(const FilePath &parent) const
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.
/// Example usage:
///
@@ -978,7 +978,7 @@ FilePath FilePath::relativeChildPath(const FilePath &parent) const
///
/// 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);

View File

@@ -153,7 +153,7 @@ public:
[[nodiscard]] FilePath resolveSymlinks() const;
[[nodiscard]] FilePath withExecutableSuffix() 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]] Environment deviceEnvironment() const;
[[nodiscard]] FilePath onDevice(const FilePath &deviceTemplate) const;

View File

@@ -634,6 +634,8 @@ public:
void setProcessInterface(ProcessInterface *process)
{
if (m_process)
m_process->disconnect();
m_process.reset(process);
m_process->setParent(this);
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
parent->m_process.get()->setParent(m_processHandler.get());
m_processHandler->setParent(this);
// So the hierarchy looks like:
// QtcProcessPrivate
// |
// +- GeneralProcessBlockingImpl
// |
// +- ProcessInterfaceHandler
// |
// +- ProcessInterface
}
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 "
"one of its signal handlers will lead to crash!"));
if (d->m_process)
d->m_process->disconnect();
delete d;
}

View File

@@ -236,6 +236,7 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildSystem *bs) :
m_configTextFilterModel->setSourceModel(m_configFilterModel);
m_configTextFilterModel->setSortRole(Qt::DisplayRole);
m_configTextFilterModel->setFilterKeyColumn(-1);
m_configTextFilterModel->setNewItemRole(ConfigModel::ItemIsUserNew);
connect(m_configTextFilterModel, &QAbstractItemModel::layoutChanged, this, [this]() {
QModelIndex selectedIdx = m_configView->currentIndex();

View File

@@ -67,7 +67,7 @@ static void copySourcePathsToClipboard(const FilePaths &srcPaths, const ProjectN
QClipboard *clip = QGuiApplication::clipboard();
QString data = Utils::transform(srcPaths, [projDir = node->filePath()](const FilePath &path) {
return path.relativePath(projDir).cleanPath().toString();
return path.relativePathFrom(projDir).cleanPath().toString();
}).join(" ");
clip->setText(data);
}
@@ -301,7 +301,7 @@ FilePaths CMakeBuildSystem::filesGeneratedFrom(const FilePath &sourceFile) const
baseDirectory = baseDirectory.parentDir();
}
const FilePath relativePath = baseDirectory.relativePath(project);
const FilePath relativePath = baseDirectory.relativePathFrom(project);
FilePath generatedFilePath = buildConfiguration()->buildDirectory().resolvePath(relativePath);
if (sourceFile.suffix() == "ui") {

View File

@@ -546,6 +546,9 @@ QVariant ConfigModelTreeItem::data(int column, int role) const
if (role == ConfigModel::ItemIsInitialRole) {
return dataItem->isInitial ? "1" : "0";
}
if (role == ConfigModel::ItemIsUserNew) {
return dataItem->isUserNew ? "1" : "0";
}
auto fontRole = [this]() -> QFont {
QFont font;

View File

@@ -18,7 +18,8 @@ class ConfigModel : public Utils::TreeModel<>
public:
enum Roles {
ItemIsAdvancedRole = Qt::UserRole,
ItemIsInitialRole
ItemIsInitialRole,
ItemIsUserNew,
};
struct DataItem {

View File

@@ -10,10 +10,8 @@
namespace CMakeProjectManager::Internal::CMakePresets::Macros {
QString getHostSystemName()
static QString getHostSystemName(Utils::OsType osType)
{
Utils::OsType osType = Utils::HostOsInfo::hostOs();
switch (osType) {
case Utils::OsTypeWindows:
return "Windows";
@@ -29,7 +27,7 @@ QString getHostSystemName()
return "Other";
}
void expandAllButEnv(const PresetsDetails::ConfigurePreset &preset,
static void expandAllButEnv(const PresetsDetails::ConfigurePreset &preset,
const Utils::FilePath &sourceDirectory,
QString &value)
{
@@ -43,10 +41,10 @@ void expandAllButEnv(const PresetsDetails::ConfigurePreset &preset,
if (preset.generator)
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,
QString &value)
{
@@ -59,7 +57,7 @@ void expandAllButEnv(const PresetsDetails::BuildPreset &preset,
value.replace("${presetName}", preset.name);
}
QString expandMacroEnv(const QString &macroPrefix,
static QString expandMacroEnv(const QString &macroPrefix,
const QString &value,
const std::function<QString(const QString &)> &op)
{

View File

@@ -221,7 +221,7 @@ void GitLabCloneDialog::cloneFinished(bool success)
accept();
} else {
const QStringList pFiles = Utils::transform(filesWeMayOpen, [base](const FilePath &f) {
return f.relativePath(base).toUserOutput();
return f.relativePathFrom(base).toUserOutput();
});
bool ok = false;
const QString fileToOpen

View File

@@ -445,7 +445,7 @@ static QStringList filteredFlags(const QStringList &allFlags, bool considerSysro
ToolChain::MacroInspectionRunner GccToolChain::createMacroInspectionRunner() const
{
// Using a clean environment breaks ccache/distcc/etc.
Environment env = Environment::systemEnvironment();
Environment env = compilerCommand().deviceEnvironment();
addToEnvironment(env);
const QStringList platformCodeGenFlags = m_platformCodeGenFlags;
OptionsReinterpreter reinterpretOptions = m_optionsReinterpreter;
@@ -852,7 +852,7 @@ void GccToolChain::setOptionsReinterpreter(const OptionsReinterpreter &optionsRe
GccToolChain::DetectedAbisResult GccToolChain::detectSupportedAbis() const
{
Environment env = Environment::systemEnvironment();
Environment env = compilerCommand().deviceEnvironment();
addToEnvironment(env);
ProjectExplorer::Macros macros = createMacroInspectionRunner()({}).macros;
return guessGccAbi(findLocalCompiler(compilerCommand(), env),
@@ -863,7 +863,7 @@ GccToolChain::DetectedAbisResult GccToolChain::detectSupportedAbis() const
QString GccToolChain::detectVersion() const
{
Environment env = Environment::systemEnvironment();
Environment env = compilerCommand().deviceEnvironment();
addToEnvironment(env);
return gccVersion(findLocalCompiler(compilerCommand(), env), env,
filteredFlags(platformCodeGenFlags(), true));
@@ -871,7 +871,7 @@ QString GccToolChain::detectVersion() const
Utils::FilePath GccToolChain::detectInstallDir() const
{
Environment env = Environment::systemEnvironment();
Environment env = compilerCommand().deviceEnvironment();
addToEnvironment(env);
return gccInstallDir(findLocalCompiler(compilerCommand(), env), env,
filteredFlags(platformCodeGenFlags(), true));

View File

@@ -77,7 +77,7 @@ Core::GeneratedFiles JsonWizardScannerGenerator::fileList(Utils::MacroExpander *
[](const Utils::FilePath &filePath) { return int(filePath.path().count('/')); };
int minDepth = std::numeric_limits<int>::max();
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());
bool found = ProjectManager::canOpenProjectForMimeType(Utils::mimeTypeForFile(relPath));
if (found) {
@@ -119,7 +119,7 @@ Core::GeneratedFiles JsonWizardScannerGenerator::scan(const Utils::FilePath &dir
const Utils::FilePaths entries = dir.dirEntries({{}, QDir::AllEntries | QDir::NoDotAndDotDot},
QDir::DirsLast | QDir::Name);
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)) {
result += scan(fi, base);
} else {

View File

@@ -39,24 +39,37 @@ static FolderNode *recursiveFindOrCreateFolderNode(FolderNode *folder,
const FilePath &overrideBaseDir,
const FolderNode::FolderNodeFactory &factory)
{
QList<FilePath> paths;
const Utils::FilePath basePath = overrideBaseDir.isEmpty() ? folder->filePath()
: overrideBaseDir;
Utils::FilePath path = basePath.isEmpty() ? directory : basePath.relativeChildPath(directory);
Utils::FilePath path = overrideBaseDir.isEmpty() ? folder->filePath() : overrideBaseDir;
while (!path.isEmpty()) {
paths.append(path);
path = path.parentDir();
Utils::FilePath directoryWithoutPrefix;
bool isRelative = false;
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;
for (const auto &currentPath : paths) {
FolderNode *next = parent->folderNode(currentPath);
ProjectExplorer::FolderNode *parent = folder;
for (const QString &part : std::as_const(parts)) {
path = path.pathAppended(part);
// Find folder in subFolders
FolderNode *next = parent->folderNode(path);
if (!next) {
// No FolderNode yet, so create it
auto tmp = factory(currentPath);
tmp->setDisplayName(currentPath.fileName());
auto tmp = factory(path);
tmp->setDisplayName(part);
next = tmp.get();
parent->addNode(std::move(tmp));
}

View File

@@ -515,7 +515,7 @@ void PropertyEditorValue::commitDrop(const QString &path)
Utils::FilePath imagePath = Utils::FilePath::fromString(path);
Utils::FilePath currFilePath = QmlDesigner::DocumentManager::currentFilePath();
QmlDesigner::VariantProperty srcProp = texture.variantProperty("source");
srcProp.setValue(imagePath.relativePath(currFilePath).toUrl());
srcProp.setValue(imagePath.relativePathFrom(currFilePath).toUrl());
// assign the texture to the property
setExpressionWithEmit(texture.id());

View File

@@ -113,7 +113,7 @@ ModelManagerInterface::ProjectInfo ModelManager::defaultProjectInfoForProject(
auto addAppDir = [&baseDir, &projectInfo](const FilePath &mdir) {
auto dir = mdir.cleanPath();
if (!baseDir.path().isEmpty()) {
auto rDir = dir.relativePath(baseDir);
auto rDir = dir.relativePathFrom(baseDir);
// do not add directories outside the build directory
// 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

View File

@@ -142,7 +142,7 @@ void CmakeGeneratorDialog::refreshNotificationText()
continue;
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.insertText(QString(FILE_OVERWRITE_NOTIFICATION).arg(relativePath));
}

View File

@@ -1046,8 +1046,7 @@ DeviceEnvironmentFetcher::Ptr LinuxDevice::environmentFetcher() const
bool LinuxDevice::usableAsBuildDevice() const
{
const bool isUsable = qtcEnvironmentVariableIntValue("QTC_ALLOW_REMOTE_LINUX_BUILD_DEVICES");
return isUsable;
return true;
}
QString LinuxDevice::userAtHost() const

View File

@@ -294,7 +294,7 @@ void tst_fileutils::calcRelativePath()
void tst_fileutils::relativePath_specials()
{
QString path = FilePath("").relativePath("").toString();
QString path = FilePath("").relativePathFrom("").toString();
QCOMPARE(path, "");
}
@@ -320,7 +320,7 @@ void tst_fileutils::relativePath()
QFETCH(QString, anchor);
QFETCH(QString, result);
FilePath actualPath = FilePath::fromString(rootPath + "/" + relative)
.relativePath(FilePath::fromString(rootPath + "/" + anchor));
.relativePathFrom(FilePath::fromString(rootPath + "/" + anchor));
QCOMPARE(actualPath.toString(), result);
}