From 253f7e35afc4e5419c01822f1c61da5ed125ba6d Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 14 Sep 2018 15:02:16 +0200 Subject: [PATCH 01/25] RemoteLinux: Use aspects in RemoteLinuxCustomCommandDeploymentStep Change-Id: Idb25506c172f7300d3485fd8dcfda231e5351532 Reviewed-by: Ulf Hermann --- ...remotelinuxcustomcommanddeploymentstep.cpp | 81 +++---------------- .../remotelinuxcustomcommanddeploymentstep.h | 6 -- 2 files changed, 9 insertions(+), 78 deletions(-) diff --git a/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.cpp b/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.cpp index c1c25c76fad..471ed7579d4 100644 --- a/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.cpp +++ b/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.cpp @@ -25,58 +25,17 @@ #include "remotelinuxcustomcommanddeploymentstep.h" -#include -#include -#include -#include -#include +#include using namespace ProjectExplorer; namespace RemoteLinux { namespace Internal { -namespace { - -const char CommandLineKey[] = "RemoteLinuxCustomCommandDeploymentStep.CommandLine"; - -class ConfigWidget : public SimpleBuildStepConfigWidget -{ - Q_OBJECT -public: - ConfigWidget(AbstractRemoteLinuxCustomCommandDeploymentStep *step) - : SimpleBuildStepConfigWidget(step) - { - QVBoxLayout * const mainLayout = new QVBoxLayout(this); - mainLayout->setMargin(0); - QHBoxLayout * const commandLineLayout = new QHBoxLayout; - mainLayout->addLayout(commandLineLayout); - QLabel * const commandLineLabel = new QLabel(tr("Command line:")); - commandLineLayout->addWidget(commandLineLabel); - m_commandLineEdit.setText(step->commandLine()); - commandLineLayout->addWidget(&m_commandLineEdit); - - connect(&m_commandLineEdit, &QLineEdit::textEdited, - this, &ConfigWidget::handleCommandLineEdited); - } - - bool showWidget() const { return true; } - -private: - void handleCommandLineEdited() { - AbstractRemoteLinuxCustomCommandDeploymentStep *step = - qobject_cast(this->step()); - step->setCommandLine(m_commandLineEdit.text().trimmed()); - } - - QLineEdit m_commandLineEdit; -}; - -} // anonymous namespace class AbstractRemoteLinuxCustomCommandDeploymentStepPrivate { public: - QString commandLine; + BaseStringAspect *commandLineAspect; }; class GenericRemoteLinuxCustomCommandDeploymentStepPrivate @@ -95,6 +54,11 @@ AbstractRemoteLinuxCustomCommandDeploymentStep::AbstractRemoteLinuxCustomCommand : AbstractRemoteLinuxDeployStep(bsl, id) { d = new AbstractRemoteLinuxCustomCommandDeploymentStepPrivate; + + d->commandLineAspect = addAspect(); + d->commandLineAspect->setSettingsKey("RemoteLinuxCustomCommandDeploymentStep.CommandLine"); + d->commandLineAspect->setLabelText(tr("Command line:")); + d->commandLineAspect->setDisplayStyle(BaseStringAspect::LineEditDisplay); } AbstractRemoteLinuxCustomCommandDeploymentStep::~AbstractRemoteLinuxCustomCommandDeploymentStep() @@ -102,40 +66,15 @@ AbstractRemoteLinuxCustomCommandDeploymentStep::~AbstractRemoteLinuxCustomComman delete d; } -bool AbstractRemoteLinuxCustomCommandDeploymentStep::fromMap(const QVariantMap &map) -{ - if (!AbstractRemoteLinuxDeployStep::fromMap(map)) - return false; - d->commandLine = map.value(QLatin1String(CommandLineKey)).toString(); - return true; -} - -QVariantMap AbstractRemoteLinuxCustomCommandDeploymentStep::toMap() const -{ - QVariantMap map = AbstractRemoteLinuxDeployStep::toMap(); - map.insert(QLatin1String(CommandLineKey), d->commandLine); - return map; -} - -void AbstractRemoteLinuxCustomCommandDeploymentStep::setCommandLine(const QString &commandLine) -{ - d->commandLine = commandLine; -} - -QString AbstractRemoteLinuxCustomCommandDeploymentStep::commandLine() const -{ - return d->commandLine; -} - bool AbstractRemoteLinuxCustomCommandDeploymentStep::initInternal(QString *error) { - deployService()->setCommandLine(d->commandLine); + deployService()->setCommandLine(d->commandLineAspect->value().trimmed()); return deployService()->isDeploymentPossible(error); } BuildStepConfigWidget *AbstractRemoteLinuxCustomCommandDeploymentStep::createConfigWidget() { - return new ConfigWidget(this); + return BuildStep::createConfigWidget(); } @@ -167,5 +106,3 @@ QString GenericRemoteLinuxCustomCommandDeploymentStep::displayName() } } // namespace RemoteLinux - -#include "remotelinuxcustomcommanddeploymentstep.moc" diff --git a/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.h b/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.h index 47ff761962d..d8a740355d5 100644 --- a/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.h +++ b/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.h @@ -42,12 +42,6 @@ class REMOTELINUX_EXPORT AbstractRemoteLinuxCustomCommandDeploymentStep public: ~AbstractRemoteLinuxCustomCommandDeploymentStep() override; - bool fromMap(const QVariantMap &map) override; - QVariantMap toMap() const override; - - void setCommandLine(const QString &commandLine); - QString commandLine() const; - protected: AbstractRemoteLinuxCustomCommandDeploymentStep(ProjectExplorer::BuildStepList *bsl, Core::Id id); From d05e906bac963fe48ce3dbceaf65c953ce12e6c0 Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 14 Sep 2018 14:35:14 +0200 Subject: [PATCH 02/25] ProjectExplorer: Replace virtual BuildStepConfigWidget::showWidget ... by a bool member. One reason less for the need of custom derived classes, i.e. one step forward to a setup where the then-generic config widget can be created in BuildStepListWidget::init() and filled with aspect- created subwidget, reducing the need of per-BuildStep boilerplate similar to what was done in RunConfiguration recently. Task-number: QTCREATORBUG-19985 Change-Id: I85d26bdb6b35d0d6715782214328a40eef87286e Reviewed-by: Ulf Hermann --- src/plugins/android/androidpackageinstallationstep.cpp | 6 +----- src/plugins/android/androidpackageinstallationstep.h | 1 - src/plugins/projectexplorer/buildstep.cpp | 2 +- src/plugins/projectexplorer/buildstep.h | 9 +++++++-- src/plugins/remotelinux/tarpackagecreationstep.cpp | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/plugins/android/androidpackageinstallationstep.cpp b/src/plugins/android/androidpackageinstallationstep.cpp index 3148fbc42da..cc6b8fc9466 100644 --- a/src/plugins/android/androidpackageinstallationstep.cpp +++ b/src/plugins/android/androidpackageinstallationstep.cpp @@ -128,6 +128,7 @@ namespace Internal { AndroidPackageInstallationStepWidget::AndroidPackageInstallationStepWidget(AndroidPackageInstallationStep *step) : m_step(step) { + setShowWidget(false); } QString AndroidPackageInstallationStepWidget::summaryText() const @@ -140,11 +141,6 @@ QString AndroidPackageInstallationStepWidget::displayName() const return tr("Make install"); } -bool AndroidPackageInstallationStepWidget::showWidget() const -{ - return false; -} - // // AndroidPackageInstallationStepFactory // diff --git a/src/plugins/android/androidpackageinstallationstep.h b/src/plugins/android/androidpackageinstallationstep.h index 40174ef1c6b..9e314a6f8f8 100644 --- a/src/plugins/android/androidpackageinstallationstep.h +++ b/src/plugins/android/androidpackageinstallationstep.h @@ -61,7 +61,6 @@ public: QString summaryText() const override; QString displayName() const override; - bool showWidget() const override; private: AndroidPackageInstallationStep *m_step; }; diff --git a/src/plugins/projectexplorer/buildstep.cpp b/src/plugins/projectexplorer/buildstep.cpp index 361b5e2b8e1..242ffea2a29 100644 --- a/src/plugins/projectexplorer/buildstep.cpp +++ b/src/plugins/projectexplorer/buildstep.cpp @@ -132,13 +132,13 @@ class ConfigWidget : public BuildStepConfigWidget public: ConfigWidget(BuildStep *step) : m_step(step) { + setShowWidget(true); connect(m_step, &ProjectConfiguration::displayNameChanged, this, &BuildStepConfigWidget::updateSummary); } QString summaryText() const override { return "" + displayName() + ""; } QString displayName() const override { return m_step->displayName(); } - bool showWidget() const override { return true; } BuildStep *step() const { return m_step; } private: diff --git a/src/plugins/projectexplorer/buildstep.h b/src/plugins/projectexplorer/buildstep.h index d6e685735b7..ddbb91d5d46 100644 --- a/src/plugins/projectexplorer/buildstep.h +++ b/src/plugins/projectexplorer/buildstep.h @@ -174,11 +174,16 @@ public: virtual QString summaryText() const = 0; virtual QString additionalSummaryText() const { return QString(); } virtual QString displayName() const = 0; - virtual bool showWidget() const { return true; } + + bool showWidget() const { return m_showWidget; } + void setShowWidget(bool showWidget) { m_showWidget = showWidget; } signals: void updateSummary(); void updateAdditionalSummary(); + +private: + bool m_showWidget = true; }; class PROJECTEXPLORER_EXPORT SimpleBuildStepConfigWidget : public BuildStepConfigWidget @@ -189,11 +194,11 @@ public: { connect(m_step, &ProjectConfiguration::displayNameChanged, this, &BuildStepConfigWidget::updateSummary); + setShowWidget(false); } QString summaryText() const override { return QLatin1String("") + displayName() + QLatin1String(""); } QString displayName() const override { return m_step->displayName(); } - bool showWidget() const override { return false; } BuildStep *step() const { return m_step; } private: diff --git a/src/plugins/remotelinux/tarpackagecreationstep.cpp b/src/plugins/remotelinux/tarpackagecreationstep.cpp index 2c95b13b4bb..bcf631d8f23 100644 --- a/src/plugins/remotelinux/tarpackagecreationstep.cpp +++ b/src/plugins/remotelinux/tarpackagecreationstep.cpp @@ -56,6 +56,8 @@ class CreateTarStepWidget : public SimpleBuildStepConfigWidget public: CreateTarStepWidget(TarPackageCreationStep *step) : SimpleBuildStepConfigWidget(step) { + setShowWidget(true); + m_ignoreMissingFilesCheckBox.setText(tr("Ignore missing files")); m_incrementalDeploymentCheckBox.setText(tr("Package modified files only")); @@ -88,8 +90,6 @@ public: + step->packageFilePath(); } - bool showWidget() const { return true; } - private: void handleIgnoreMissingFilesChanged(bool ignoreMissingFiles) { TarPackageCreationStep *step = qobject_cast(this->step()); From 8dfa977f2fc83ed24358c654ed90936bb066b58a Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 17 Sep 2018 15:56:14 +0200 Subject: [PATCH 03/25] ProjectExplorer: Move Base{Bool,String}Aspect to new files Create projectconfigurationaspect.{h,cpp} for re-usable aspects. Also pimpl the two exported classes. Task-number: QTCREATORBUG-19985 Change-Id: Id1d44b551c5dc2cf6eb4fbc3a2a505d4a83ae53f Reviewed-by: Ulf Hermann --- .../projectconfigurationaspects.cpp | 340 ++++++++++++++++++ .../projectconfigurationaspects.h | 109 ++++++ .../projectexplorer/projectexplorer.pro | 6 +- .../projectexplorer/projectexplorer.qbs | 1 + .../runconfigurationaspects.cpp | 256 ------------- .../projectexplorer/runconfigurationaspects.h | 92 +---- 6 files changed, 455 insertions(+), 349 deletions(-) create mode 100644 src/plugins/projectexplorer/projectconfigurationaspects.cpp create mode 100644 src/plugins/projectexplorer/projectconfigurationaspects.h diff --git a/src/plugins/projectexplorer/projectconfigurationaspects.cpp b/src/plugins/projectexplorer/projectconfigurationaspects.cpp new file mode 100644 index 00000000000..92dd68f60a1 --- /dev/null +++ b/src/plugins/projectexplorer/projectconfigurationaspects.cpp @@ -0,0 +1,340 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "projectconfigurationaspects.h" + +#include "environmentaspect.h" +#include "project.h" +#include "projectexplorer.h" +#include "projectexplorersettings.h" +#include "runconfiguration.h" +#include "target.h" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +using namespace Utils; + +namespace ProjectExplorer { +namespace Internal { + +class BaseBoolAspectPrivate +{ +public: + bool m_value = false; + bool m_defaultValue = false; + QString m_label; + QPointer m_checkBox; // Owned by configuration widget +}; + +class BaseStringAspectPrivate +{ +public: + BaseStringAspect::DisplayStyle m_displayStyle = BaseStringAspect::LabelDisplay; + QString m_labelText; + std::function m_displayFilter; + std::unique_ptr m_checker; + + QString m_value; + QString m_placeHolderText; + QString m_historyCompleterKey; + PathChooser::Kind m_expectedKind = PathChooser::File; + Environment m_environment; + QPointer m_label; + QPointer m_labelDisplay; + QPointer m_lineEditDisplay; + QPointer m_pathChooserDisplay; + QPixmap m_labelPixmap; +}; + +} // Internal + +/*! + \class ProjectExplorer::BaseStringAspect +*/ + +BaseStringAspect::BaseStringAspect() + : d(new Internal::BaseStringAspectPrivate) +{} + +BaseStringAspect::~BaseStringAspect() = default; + +QString BaseStringAspect::value() const +{ + return d->m_value; +} + +void BaseStringAspect::setValue(const QString &value) +{ + const bool isSame = value == d->m_value; + d->m_value = value; + update(); + if (!isSame) + emit changed(); +} + +void BaseStringAspect::fromMap(const QVariantMap &map) +{ + if (!settingsKey().isEmpty()) + d->m_value = map.value(settingsKey()).toString(); + if (d->m_checker) + d->m_checker->fromMap(map); +} + +void BaseStringAspect::toMap(QVariantMap &map) const +{ + if (!settingsKey().isEmpty()) + map.insert(settingsKey(), d->m_value); + if (d->m_checker) + d->m_checker->toMap(map); +} + +FileName BaseStringAspect::fileName() const +{ + return FileName::fromString(d->m_value); +} + +void BaseStringAspect::setLabelText(const QString &labelText) +{ + d->m_labelText = labelText; + if (d->m_label) + d->m_label->setText(labelText); +} + +void BaseStringAspect::setLabelPixmap(const QPixmap &labelPixmap) +{ + d->m_labelPixmap = labelPixmap; + if (d->m_label) + d->m_label->setPixmap(labelPixmap); +} + +QString BaseStringAspect::labelText() const +{ + return d->m_labelText; +} + +void BaseStringAspect::setDisplayFilter(const std::function &displayFilter) +{ + d->m_displayFilter = displayFilter; +} + +bool BaseStringAspect::isChecked() const +{ + return !d->m_checker || d->m_checker->value(); +} + +void BaseStringAspect::setDisplayStyle(DisplayStyle displayStyle) +{ + d->m_displayStyle = displayStyle; +} + +void BaseStringAspect::setPlaceHolderText(const QString &placeHolderText) +{ + d->m_placeHolderText = placeHolderText; + if (d->m_lineEditDisplay) + d->m_lineEditDisplay->setPlaceholderText(placeHolderText); +} + +void BaseStringAspect::setHistoryCompleter(const QString &historyCompleterKey) +{ + d->m_historyCompleterKey = historyCompleterKey; + if (d->m_lineEditDisplay) + d->m_lineEditDisplay->setHistoryCompleter(historyCompleterKey); + if (d->m_pathChooserDisplay) + d->m_pathChooserDisplay->setHistoryCompleter(historyCompleterKey); +} + +void BaseStringAspect::setExpectedKind(const PathChooser::Kind expectedKind) +{ + d->m_expectedKind = expectedKind; + if (d->m_pathChooserDisplay) + d->m_pathChooserDisplay->setExpectedKind(expectedKind); +} + +void BaseStringAspect::setEnvironment(const Environment &env) +{ + d->m_environment = env; + if (d->m_pathChooserDisplay) + d->m_pathChooserDisplay->setEnvironment(env); +} + +void BaseStringAspect::addToConfigurationLayout(QFormLayout *layout) +{ + QTC_CHECK(!d->m_label); + QWidget *parent = layout->parentWidget(); + d->m_label = new QLabel(parent); + d->m_label->setTextInteractionFlags(Qt::TextSelectableByMouse); + d->m_label->setText(d->m_labelText); + if (!d->m_labelPixmap.isNull()) + d->m_label->setPixmap(d->m_labelPixmap); + + auto hbox = new QHBoxLayout; + switch (d->m_displayStyle) { + case PathChooserDisplay: + d->m_pathChooserDisplay = new PathChooser(parent); + d->m_pathChooserDisplay->setExpectedKind(d->m_expectedKind); + d->m_pathChooserDisplay->setHistoryCompleter(d->m_historyCompleterKey); + d->m_pathChooserDisplay->setEnvironment(d->m_environment); + connect(d->m_pathChooserDisplay, &PathChooser::pathChanged, + this, &BaseStringAspect::setValue); + hbox->addWidget(d->m_pathChooserDisplay); + break; + case LineEditDisplay: + d->m_lineEditDisplay = new FancyLineEdit(parent); + d->m_lineEditDisplay->setPlaceholderText(d->m_placeHolderText); + d->m_lineEditDisplay->setHistoryCompleter(d->m_historyCompleterKey); + connect(d->m_lineEditDisplay, &FancyLineEdit::textEdited, + this, &BaseStringAspect::setValue); + hbox->addWidget(d->m_lineEditDisplay); + break; + case LabelDisplay: + d->m_labelDisplay = new QLabel(parent); + d->m_labelDisplay->setTextInteractionFlags(Qt::TextSelectableByMouse); + hbox->addWidget(d->m_labelDisplay); + break; + } + + if (d->m_checker) { + auto form = new QFormLayout; + form->setContentsMargins(0, 0, 0, 0); + form->setFormAlignment(Qt::AlignLeft | Qt::AlignVCenter); + d->m_checker->addToConfigurationLayout(form); + hbox->addLayout(form); + } + layout->addRow(d->m_label, hbox); + + update(); +} + +void BaseStringAspect::update() +{ + const QString displayedString = d->m_displayFilter ? d->m_displayFilter(d->m_value) + : d->m_value; + + const bool enabled = !d->m_checker || d->m_checker->value(); + + if (d->m_pathChooserDisplay) { + d->m_pathChooserDisplay->setFileName(FileName::fromString(displayedString)); + d->m_pathChooserDisplay->setEnabled(enabled); + } + + if (d->m_lineEditDisplay) { + d->m_lineEditDisplay->setText(displayedString); + d->m_lineEditDisplay->setEnabled(enabled); + } + + if (d->m_labelDisplay) + d->m_labelDisplay->setText(displayedString); + + if (d->m_label) { + d->m_label->setText(d->m_labelText); + if (!d->m_labelPixmap.isNull()) + d->m_label->setPixmap(d->m_labelPixmap); + } +} + +void BaseStringAspect::makeCheckable(const QString &checkerLabel, const QString &checkerKey) +{ + QTC_ASSERT(!d->m_checker, return); + d->m_checker.reset(new BaseBoolAspect); + d->m_checker->setLabel(checkerLabel); + d->m_checker->setSettingsKey(checkerKey); + + connect(d->m_checker.get(), &BaseBoolAspect::changed, this, &BaseStringAspect::update); + connect(d->m_checker.get(), &BaseBoolAspect::changed, this, &BaseStringAspect::changed); + + update(); +} + +/*! + \class ProjectExplorer::BaseBoolAspect +*/ + +BaseBoolAspect::BaseBoolAspect(const QString &settingsKey) + : d(new Internal::BaseBoolAspectPrivate) +{ + setSettingsKey(settingsKey); +} + +BaseBoolAspect::~BaseBoolAspect() = default; + +void BaseBoolAspect::addToConfigurationLayout(QFormLayout *layout) +{ + QTC_CHECK(!d->m_checkBox); + d->m_checkBox = new QCheckBox(d->m_label, layout->parentWidget()); + d->m_checkBox->setChecked(d->m_value); + layout->addRow(QString(), d->m_checkBox); + connect(d->m_checkBox.data(), &QAbstractButton::clicked, this, [this] { + d->m_value = d->m_checkBox->isChecked(); + emit changed(); + }); +} + +void BaseBoolAspect::fromMap(const QVariantMap &map) +{ + d->m_value = map.value(settingsKey(), d->m_defaultValue).toBool(); +} + +void BaseBoolAspect::toMap(QVariantMap &data) const +{ + data.insert(settingsKey(), d->m_value); +} + +bool BaseBoolAspect::defaultValue() const +{ + return d->m_defaultValue; +} + +void BaseBoolAspect::setDefaultValue(bool defaultValue) +{ + d->m_defaultValue = defaultValue; +} + +bool BaseBoolAspect::value() const +{ + return d->m_value; +} + +void BaseBoolAspect::setValue(bool value) +{ + d->m_value = value; + if (d->m_checkBox) + d->m_checkBox->setChecked(d->m_value); +} + +void BaseBoolAspect::setLabel(const QString &label) +{ + d->m_label = label; +} + +} // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/projectconfigurationaspects.h b/src/plugins/projectexplorer/projectconfigurationaspects.h new file mode 100644 index 00000000000..a058c20ec0f --- /dev/null +++ b/src/plugins/projectexplorer/projectconfigurationaspects.h @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include "projectconfiguration.h" +#include "environmentaspect.h" + +#include +#include + +#include + +namespace ProjectExplorer { + +namespace Internal { +class BaseBoolAspectPrivate; +class BaseStringAspectPrivate; +} // Internal + +class PROJECTEXPLORER_EXPORT BaseBoolAspect : public ProjectConfigurationAspect +{ + Q_OBJECT + +public: + explicit BaseBoolAspect(const QString &settingsKey = QString()); + ~BaseBoolAspect() override; + + void addToConfigurationLayout(QFormLayout *layout) override; + + bool value() const; + void setValue(bool val); + + bool defaultValue() const; + void setDefaultValue(bool defaultValue); + + void setLabel(const QString &label); + + void fromMap(const QVariantMap &map) override; + void toMap(QVariantMap &map) const override; + +private: + std::unique_ptr d; +}; + +class PROJECTEXPLORER_EXPORT BaseStringAspect : public ProjectConfigurationAspect +{ + Q_OBJECT + +public: + BaseStringAspect(); + ~BaseStringAspect() override; + + void addToConfigurationLayout(QFormLayout *layout) override; + + QString value() const; + void setValue(const QString &val); + + QString labelText() const; + void setLabelText(const QString &labelText); + void setLabelPixmap(const QPixmap &labelPixmap); + + void setDisplayFilter(const std::function &displayFilter); + void setPlaceHolderText(const QString &placeHolderText); + void setHistoryCompleter(const QString &historyCompleterKey); + void setExpectedKind(const Utils::PathChooser::Kind expectedKind); + void setEnvironment(const Utils::Environment &env); + + bool isChecked() const; + void makeCheckable(const QString &optionalLabel, const QString &optionalBaseKey); + + enum DisplayStyle { LabelDisplay, LineEditDisplay, PathChooserDisplay }; + void setDisplayStyle(DisplayStyle style); + + void fromMap(const QVariantMap &map) override; + void toMap(QVariantMap &map) const override; + + Utils::FileName fileName() const; + void setFileName(const Utils::FileName &val); + +private: + void update(); + + std::unique_ptr d; +}; + +} // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/projectexplorer.pro b/src/plugins/projectexplorer/projectexplorer.pro index 598e8ceddb1..8e21d9a0dd2 100644 --- a/src/plugins/projectexplorer/projectexplorer.pro +++ b/src/plugins/projectexplorer/projectexplorer.pro @@ -155,7 +155,8 @@ HEADERS += projectexplorer.h \ extracompiler.h \ customexecutablerunconfiguration.h \ projectmacro.h \ - makestep.h + makestep.h \ + projectconfigurationaspects.h SOURCES += projectexplorer.cpp \ abi.cpp \ @@ -292,7 +293,8 @@ SOURCES += projectexplorer.cpp \ extracompiler.cpp \ customexecutablerunconfiguration.cpp \ projectmacro.cpp \ - makestep.cpp + makestep.cpp \ + projectconfigurationaspects.cpp FORMS += processstep.ui \ editorsettingspropertiespage.ui \ diff --git a/src/plugins/projectexplorer/projectexplorer.qbs b/src/plugins/projectexplorer/projectexplorer.qbs index 67f07840acc..58646326fab 100644 --- a/src/plugins/projectexplorer/projectexplorer.qbs +++ b/src/plugins/projectexplorer/projectexplorer.qbs @@ -101,6 +101,7 @@ Project { "processstep.cpp", "processstep.h", "processstep.ui", "project.cpp", "project.h", "projectconfiguration.cpp", "projectconfiguration.h", + "projectconfigurationaspects.cpp", "projectconfigurationaspects.h", "projectconfigurationmodel.cpp", "projectconfigurationmodel.h", "projectexplorer.cpp", "projectexplorer.h", "projectexplorer.qrc", diff --git a/src/plugins/projectexplorer/runconfigurationaspects.cpp b/src/plugins/projectexplorer/runconfigurationaspects.cpp index a87ee68d0b8..06aa1e583ed 100644 --- a/src/plugins/projectexplorer/runconfigurationaspects.cpp +++ b/src/plugins/projectexplorer/runconfigurationaspects.cpp @@ -292,203 +292,6 @@ void ArgumentsAspect::addToConfigurationLayout(QFormLayout *layout) layout->addRow(tr("Command line arguments:"), m_chooser); } -/*! - \class ProjectExplorer::BaseStringAspect -*/ - -BaseStringAspect::BaseStringAspect() = default; - -BaseStringAspect::~BaseStringAspect() -{ - delete m_checker; - m_checker = nullptr; -} - -QString BaseStringAspect::value() const -{ - return m_value; -} - -void BaseStringAspect::setValue(const QString &value) -{ - const bool isSame = value == m_value; - m_value = value; - update(); - if (!isSame) - emit changed(); -} - -void BaseStringAspect::fromMap(const QVariantMap &map) -{ - if (!settingsKey().isEmpty()) - m_value = map.value(settingsKey()).toString(); - if (m_checker) - m_checker->fromMap(map); -} - -void BaseStringAspect::toMap(QVariantMap &map) const -{ - if (!settingsKey().isEmpty()) - map.insert(settingsKey(), m_value); - if (m_checker) - m_checker->toMap(map); -} - -FileName BaseStringAspect::fileName() const -{ - return FileName::fromString(m_value); -} - -void BaseStringAspect::setLabelText(const QString &labelText) -{ - m_labelText = labelText; - if (m_label) - m_label->setText(labelText); -} - -void BaseStringAspect::setLabelPixmap(const QPixmap &labelPixmap) -{ - m_labelPixmap = labelPixmap; - if (m_label) - m_label->setPixmap(labelPixmap); -} - -QString BaseStringAspect::labelText() const -{ - return m_labelText; -} - -void BaseStringAspect::setDisplayFilter(const std::function &displayFilter) -{ - m_displayFilter = displayFilter; -} - -bool BaseStringAspect::isChecked() const -{ - return !m_checker || m_checker->value(); -} - -void BaseStringAspect::setDisplayStyle(DisplayStyle displayStyle) -{ - m_displayStyle = displayStyle; -} - -void BaseStringAspect::setPlaceHolderText(const QString &placeHolderText) -{ - m_placeHolderText = placeHolderText; - if (m_lineEditDisplay) - m_lineEditDisplay->setPlaceholderText(placeHolderText); -} - -void BaseStringAspect::setHistoryCompleter(const QString &historyCompleterKey) -{ - m_historyCompleterKey = historyCompleterKey; - if (m_lineEditDisplay) - m_lineEditDisplay->setHistoryCompleter(historyCompleterKey); - if (m_pathChooserDisplay) - m_pathChooserDisplay->setHistoryCompleter(historyCompleterKey); -} - -void BaseStringAspect::setExpectedKind(const PathChooser::Kind expectedKind) -{ - m_expectedKind = expectedKind; - if (m_pathChooserDisplay) - m_pathChooserDisplay->setExpectedKind(expectedKind); -} - -void BaseStringAspect::setEnvironment(const Environment &env) -{ - m_environment = env; - if (m_pathChooserDisplay) - m_pathChooserDisplay->setEnvironment(env); -} - -void BaseStringAspect::addToConfigurationLayout(QFormLayout *layout) -{ - QTC_CHECK(!m_label); - QWidget *parent = layout->parentWidget(); - m_label = new QLabel(parent); - m_label->setTextInteractionFlags(Qt::TextSelectableByMouse); - m_label->setText(m_labelText); - if (!m_labelPixmap.isNull()) - m_label->setPixmap(m_labelPixmap); - - auto hbox = new QHBoxLayout; - switch (m_displayStyle) { - case PathChooserDisplay: - m_pathChooserDisplay = new PathChooser(parent); - m_pathChooserDisplay->setExpectedKind(m_expectedKind); - m_pathChooserDisplay->setHistoryCompleter(m_historyCompleterKey); - m_pathChooserDisplay->setEnvironment(m_environment); - connect(m_pathChooserDisplay, &PathChooser::pathChanged, - this, &BaseStringAspect::setValue); - hbox->addWidget(m_pathChooserDisplay); - break; - case LineEditDisplay: - m_lineEditDisplay = new FancyLineEdit(parent); - m_lineEditDisplay->setPlaceholderText(m_placeHolderText); - m_lineEditDisplay->setHistoryCompleter(m_historyCompleterKey); - connect(m_lineEditDisplay, &FancyLineEdit::textEdited, - this, &BaseStringAspect::setValue); - hbox->addWidget(m_lineEditDisplay); - break; - case LabelDisplay: - m_labelDisplay = new QLabel(parent); - m_labelDisplay->setTextInteractionFlags(Qt::TextSelectableByMouse); - hbox->addWidget(m_labelDisplay); - break; - } - - if (m_checker) { - auto form = new QFormLayout; - form->setContentsMargins(0, 0, 0, 0); - form->setFormAlignment(Qt::AlignLeft | Qt::AlignVCenter); - m_checker->addToConfigurationLayout(form); - hbox->addLayout(form); - } - layout->addRow(m_label, hbox); - - update(); -} - -void BaseStringAspect::update() -{ - const QString displayedString = m_displayFilter ? m_displayFilter(m_value) : m_value; - const bool enabled = !m_checker || m_checker->value(); - - if (m_pathChooserDisplay) { - m_pathChooserDisplay->setFileName(FileName::fromString(displayedString)); - m_pathChooserDisplay->setEnabled(enabled); - } - - if (m_lineEditDisplay) { - m_lineEditDisplay->setText(displayedString); - m_lineEditDisplay->setEnabled(enabled); - } - - if (m_labelDisplay) - m_labelDisplay->setText(displayedString); - - if (m_label) { - m_label->setText(m_labelText); - if (!m_labelPixmap.isNull()) - m_label->setPixmap(m_labelPixmap); - } -} - -void BaseStringAspect::makeCheckable(const QString &checkerLabel, const QString &checkerKey) -{ - QTC_ASSERT(!m_checker, return); - m_checker = new BaseBoolAspect; - m_checker->setLabel(checkerLabel); - m_checker->setSettingsKey(checkerKey); - - connect(m_checker, &BaseBoolAspect::changed, this, &BaseStringAspect::update); - connect(m_checker, &BaseBoolAspect::changed, this, &BaseStringAspect::changed); - - update(); -} - /*! \class ProjectExplorer::ExecutableAspect */ @@ -607,65 +410,6 @@ void ExecutableAspect::toMap(QVariantMap &map) const m_alternativeExecutable->toMap(map); } -/*! - \class ProjectExplorer::BaseBoolAspect -*/ - -BaseBoolAspect::BaseBoolAspect(const QString &settingsKey) -{ - setSettingsKey(settingsKey); -} - -BaseBoolAspect::~BaseBoolAspect() = default; - -void BaseBoolAspect::addToConfigurationLayout(QFormLayout *layout) -{ - QTC_CHECK(!m_checkBox); - m_checkBox = new QCheckBox(m_label, layout->parentWidget()); - m_checkBox->setChecked(m_value); - layout->addRow(QString(), m_checkBox); - connect(m_checkBox.data(), &QAbstractButton::clicked, this, [this] { - m_value = m_checkBox->isChecked(); - emit changed(); - }); -} - -void BaseBoolAspect::fromMap(const QVariantMap &map) -{ - m_value = map.value(settingsKey(), m_defaultValue).toBool(); -} - -void BaseBoolAspect::toMap(QVariantMap &data) const -{ - data.insert(settingsKey(), m_value); -} - -bool BaseBoolAspect::defaultValue() const -{ - return m_defaultValue; -} - -void BaseBoolAspect::setDefaultValue(bool defaultValue) -{ - m_defaultValue = defaultValue; -} - -bool BaseBoolAspect::value() const -{ - return m_value; -} - -void BaseBoolAspect::setValue(bool value) -{ - m_value = value; - if (m_checkBox) - m_checkBox->setChecked(m_value); -} - -void BaseBoolAspect::setLabel(const QString &label) -{ - m_label = label; -} /*! \class ProjectExplorer::UseLibraryPathsAspect diff --git a/src/plugins/projectexplorer/runconfigurationaspects.h b/src/plugins/projectexplorer/runconfigurationaspects.h index c17efc3197a..be40af6d292 100644 --- a/src/plugins/projectexplorer/runconfigurationaspects.h +++ b/src/plugins/projectexplorer/runconfigurationaspects.h @@ -25,19 +25,12 @@ #pragma once -#include "runconfiguration.h" +#include "projectconfigurationaspects.h" #include "applicationlauncher.h" #include "environmentaspect.h" -#include -#include -#include - QT_BEGIN_NAMESPACE class QCheckBox; -class QLabel; -class QLineEdit; -class QFormLayout; class QToolButton; QT_END_NAMESPACE @@ -120,34 +113,6 @@ private: QPointer m_chooser; }; -class PROJECTEXPLORER_EXPORT BaseBoolAspect : public ProjectConfigurationAspect -{ - Q_OBJECT - -public: - explicit BaseBoolAspect(const QString &settingsKey = QString()); - ~BaseBoolAspect() override; - - void addToConfigurationLayout(QFormLayout *layout) override; - - bool value() const; - void setValue(bool val); - - bool defaultValue() const; - void setDefaultValue(bool defaultValue); - - void setLabel(const QString &label); - - void fromMap(const QVariantMap &map) override; - void toMap(QVariantMap &map) const override; - -private: - bool m_value = false; - bool m_defaultValue = false; - QString m_label; - QPointer m_checkBox; // Owned by configuration widget -}; - class PROJECTEXPLORER_EXPORT UseLibraryPathsAspect : public BaseBoolAspect { Q_OBJECT @@ -164,61 +129,6 @@ public: UseDyldSuffixAspect(); }; -class PROJECTEXPLORER_EXPORT BaseStringAspect : public ProjectConfigurationAspect -{ - Q_OBJECT - -public: - BaseStringAspect(); - ~BaseStringAspect() override; - - void addToConfigurationLayout(QFormLayout *layout) override; - - QString value() const; - void setValue(const QString &val); - - QString labelText() const; - void setLabelText(const QString &labelText); - void setLabelPixmap(const QPixmap &labelPixmap); - - void setDisplayFilter(const std::function &displayFilter); - void setPlaceHolderText(const QString &placeHolderText); - void setHistoryCompleter(const QString &historyCompleterKey); - void setExpectedKind(const Utils::PathChooser::Kind expectedKind); - void setEnvironment(const Utils::Environment &env); - - bool isChecked() const; - void makeCheckable(const QString &optionalLabel, const QString &optionalBaseKey); - - enum DisplayStyle { LabelDisplay, LineEditDisplay, PathChooserDisplay }; - void setDisplayStyle(DisplayStyle style); - - void fromMap(const QVariantMap &map) override; - void toMap(QVariantMap &map) const override; - - Utils::FileName fileName() const; - void setFileName(const Utils::FileName &val); - -private: - void update(); - - DisplayStyle m_displayStyle = LabelDisplay; - QString m_labelText; - std::function m_displayFilter; - BaseBoolAspect *m_checker = nullptr; - - QString m_value; - QString m_placeHolderText; - QString m_historyCompleterKey; - Utils::PathChooser::Kind m_expectedKind = Utils::PathChooser::File; - Utils::Environment m_environment; - QPointer m_label; - QPointer m_labelDisplay; - QPointer m_lineEditDisplay; - QPointer m_pathChooserDisplay; - QPixmap m_labelPixmap; -}; - class PROJECTEXPLORER_EXPORT ExecutableAspect : public ProjectConfigurationAspect { Q_OBJECT From 82688cabd16d8ac054d92e80ed606d5945bf3e3e Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 18 Sep 2018 12:52:23 +0200 Subject: [PATCH 04/25] RemoteLinux: Merge {Abstract,Generic}RLCustomCommandDeploymentStep ... into a RemoteLinuxCustomCommandDeploymentStep class. There's only one one incarnation of the abstract base, and neither the base nor the implementation is really big enough anymore to justify the hierarchy. Change-Id: I85759051589482ad48efc0e3cad4679416ceb387 Reviewed-by: Ulf Hermann --- ...remotelinuxcustomcommanddeploymentstep.cpp | 49 ++++++------------- .../remotelinuxcustomcommanddeploymentstep.h | 39 +++------------ src/plugins/remotelinux/remotelinuxplugin.cpp | 2 +- 3 files changed, 23 insertions(+), 67 deletions(-) diff --git a/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.cpp b/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.cpp index 471ed7579d4..67a623a43c0 100644 --- a/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.cpp +++ b/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.cpp @@ -24,6 +24,7 @@ ****************************************************************************/ #include "remotelinuxcustomcommanddeploymentstep.h" +#include "remotelinuxcustomcommanddeployservice.h" #include @@ -32,75 +33,53 @@ using namespace ProjectExplorer; namespace RemoteLinux { namespace Internal { -class AbstractRemoteLinuxCustomCommandDeploymentStepPrivate +class RemoteLinuxCustomCommandDeploymentStepPrivate { public: BaseStringAspect *commandLineAspect; -}; - -class GenericRemoteLinuxCustomCommandDeploymentStepPrivate -{ -public: RemoteLinuxCustomCommandDeployService service; }; } // namespace Internal -using namespace Internal; - - -AbstractRemoteLinuxCustomCommandDeploymentStep::AbstractRemoteLinuxCustomCommandDeploymentStep - (BuildStepList *bsl, Core::Id id) - : AbstractRemoteLinuxDeployStep(bsl, id) +RemoteLinuxCustomCommandDeploymentStep::RemoteLinuxCustomCommandDeploymentStep(BuildStepList *bsl) + : AbstractRemoteLinuxDeployStep(bsl, stepId()) { - d = new AbstractRemoteLinuxCustomCommandDeploymentStepPrivate; - + d = new Internal::RemoteLinuxCustomCommandDeploymentStepPrivate; d->commandLineAspect = addAspect(); d->commandLineAspect->setSettingsKey("RemoteLinuxCustomCommandDeploymentStep.CommandLine"); d->commandLineAspect->setLabelText(tr("Command line:")); d->commandLineAspect->setDisplayStyle(BaseStringAspect::LineEditDisplay); + setDefaultDisplayName(displayName()); } -AbstractRemoteLinuxCustomCommandDeploymentStep::~AbstractRemoteLinuxCustomCommandDeploymentStep() +RemoteLinuxCustomCommandDeploymentStep::~RemoteLinuxCustomCommandDeploymentStep() { delete d; } -bool AbstractRemoteLinuxCustomCommandDeploymentStep::initInternal(QString *error) +bool RemoteLinuxCustomCommandDeploymentStep::initInternal(QString *error) { - deployService()->setCommandLine(d->commandLineAspect->value().trimmed()); - return deployService()->isDeploymentPossible(error); + d->service.setCommandLine(d->commandLineAspect->value().trimmed()); + return d->service.isDeploymentPossible(error); } -BuildStepConfigWidget *AbstractRemoteLinuxCustomCommandDeploymentStep::createConfigWidget() +BuildStepConfigWidget *RemoteLinuxCustomCommandDeploymentStep::createConfigWidget() { return BuildStep::createConfigWidget(); } - -GenericRemoteLinuxCustomCommandDeploymentStep::GenericRemoteLinuxCustomCommandDeploymentStep(BuildStepList *bsl) - : AbstractRemoteLinuxCustomCommandDeploymentStep(bsl, stepId()) -{ - d = new GenericRemoteLinuxCustomCommandDeploymentStepPrivate; - setDefaultDisplayName(displayName()); -} - -GenericRemoteLinuxCustomCommandDeploymentStep::~GenericRemoteLinuxCustomCommandDeploymentStep() -{ - delete d; -} - -RemoteLinuxCustomCommandDeployService *GenericRemoteLinuxCustomCommandDeploymentStep::deployService() const +AbstractRemoteLinuxDeployService *RemoteLinuxCustomCommandDeploymentStep::deployService() const { return &d->service; } -Core::Id GenericRemoteLinuxCustomCommandDeploymentStep::stepId() +Core::Id RemoteLinuxCustomCommandDeploymentStep::stepId() { return "RemoteLinux.GenericRemoteLinuxCustomCommandDeploymentStep"; } -QString GenericRemoteLinuxCustomCommandDeploymentStep::displayName() +QString RemoteLinuxCustomCommandDeploymentStep::displayName() { return tr("Run custom remote command"); } diff --git a/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.h b/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.h index d8a740355d5..4ba666f8e9c 100644 --- a/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.h +++ b/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.h @@ -26,50 +26,27 @@ #pragma once #include "abstractremotelinuxdeploystep.h" -#include "remotelinuxcustomcommanddeployservice.h" namespace RemoteLinux { -namespace Internal { -class AbstractRemoteLinuxCustomCommandDeploymentStepPrivate; -class GenericRemoteLinuxCustomCommandDeploymentStepPrivate; -} // namespace Internal +namespace Internal { class RemoteLinuxCustomCommandDeploymentStepPrivate; } - -class REMOTELINUX_EXPORT AbstractRemoteLinuxCustomCommandDeploymentStep +class REMOTELINUX_EXPORT RemoteLinuxCustomCommandDeploymentStep : public AbstractRemoteLinuxDeployStep { Q_OBJECT public: - ~AbstractRemoteLinuxCustomCommandDeploymentStep() override; - -protected: - AbstractRemoteLinuxCustomCommandDeploymentStep(ProjectExplorer::BuildStepList *bsl, Core::Id id); - - bool initInternal(QString *error = 0) override; - -private: - RemoteLinuxCustomCommandDeployService *deployService() const override = 0; - ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override; - - Internal::AbstractRemoteLinuxCustomCommandDeploymentStepPrivate *d; -}; - - -class REMOTELINUX_EXPORT GenericRemoteLinuxCustomCommandDeploymentStep - : public AbstractRemoteLinuxCustomCommandDeploymentStep -{ - Q_OBJECT -public: - explicit GenericRemoteLinuxCustomCommandDeploymentStep(ProjectExplorer::BuildStepList *bsl); - ~GenericRemoteLinuxCustomCommandDeploymentStep() override; + explicit RemoteLinuxCustomCommandDeploymentStep(ProjectExplorer::BuildStepList *bsl); + ~RemoteLinuxCustomCommandDeploymentStep() override; static Core::Id stepId(); static QString displayName(); private: - RemoteLinuxCustomCommandDeployService *deployService() const override; + bool initInternal(QString *error) override; + AbstractRemoteLinuxDeployService *deployService() const override; + ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override; - Internal::GenericRemoteLinuxCustomCommandDeploymentStepPrivate *d; + Internal::RemoteLinuxCustomCommandDeploymentStepPrivate *d; }; } // namespace RemoteLinux diff --git a/src/plugins/remotelinux/remotelinuxplugin.cpp b/src/plugins/remotelinux/remotelinuxplugin.cpp index 2f67ae25e98..6a5dffa7474 100644 --- a/src/plugins/remotelinux/remotelinuxplugin.cpp +++ b/src/plugins/remotelinux/remotelinuxplugin.cpp @@ -73,7 +73,7 @@ public: GenericDeployStepFactory tarPackageCreationStepFactory; GenericDeployStepFactory uploadAndInstallTarPackageStepFactory; GenericDeployStepFactory genericDirectUploadStepFactory; - GenericDeployStepFactory + GenericDeployStepFactory customCommandDeploymentStepFactory; GenericDeployStepFactory checkForFreeDiskSpaceStepFactory; From b9db5ea86e30b57f48b757de30f71f5c0a9bd525 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Wed, 19 Sep 2018 14:39:46 +0200 Subject: [PATCH 05/25] Move documentationPath() from Core::ICore to Core::HelpManager It is documentation related API, so it belongs there. Change-Id: I5d1676f251e6deb92050ddedac19bf3c332aab54 Reviewed-by: Jarek Kobus Reviewed-by: Tim Jenssen --- src/plugins/coreplugin/helpmanager.cpp | 7 +++++++ src/plugins/coreplugin/helpmanager.h | 2 ++ src/plugins/coreplugin/icore.cpp | 5 ----- src/plugins/coreplugin/icore.h | 1 - src/plugins/help/helpplugin.cpp | 2 +- src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp | 2 +- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/plugins/coreplugin/helpmanager.cpp b/src/plugins/coreplugin/helpmanager.cpp index a27b1499b3e..e5db350e99a 100644 --- a/src/plugins/coreplugin/helpmanager.cpp +++ b/src/plugins/coreplugin/helpmanager.cpp @@ -30,6 +30,8 @@ #include #include +#include +#include #include namespace Core { @@ -67,6 +69,11 @@ Implementation::~Implementation() m_instance = nullptr; } +QString documentationPath() +{ + return QDir::cleanPath(QCoreApplication::applicationDirPath() + '/' + RELATIVE_DOC_PATH); +} + void registerDocumentation(const QStringList &files) { if (checkInstance()) diff --git a/src/plugins/coreplugin/helpmanager.h b/src/plugins/coreplugin/helpmanager.h index 60bb412752f..a97f65b362f 100644 --- a/src/plugins/coreplugin/helpmanager.h +++ b/src/plugins/coreplugin/helpmanager.h @@ -58,6 +58,8 @@ enum HelpViewerLocation { ExternalHelpAlways = 3 }; +CORE_EXPORT QString documentationPath(); + CORE_EXPORT void registerDocumentation(const QStringList &fileNames); CORE_EXPORT void unregisterDocumentation(const QStringList &nameSpaces); diff --git a/src/plugins/coreplugin/icore.cpp b/src/plugins/coreplugin/icore.cpp index f88f0f8df44..f16f4369bb2 100644 --- a/src/plugins/coreplugin/icore.cpp +++ b/src/plugins/coreplugin/icore.cpp @@ -445,11 +445,6 @@ QString ICore::installerResourcePath() + Constants::IDE_ID; } -QString ICore::documentationPath() -{ - return QDir::cleanPath(QCoreApplication::applicationDirPath() + '/' + RELATIVE_DOC_PATH); -} - /*! Returns the path to the command line tools that are shipped with \QC (corresponding to the IDE_LIBEXEC_PATH qmake variable). diff --git a/src/plugins/coreplugin/icore.h b/src/plugins/coreplugin/icore.h index 37ce9b05dd8..80e387658f4 100644 --- a/src/plugins/coreplugin/icore.h +++ b/src/plugins/coreplugin/icore.h @@ -95,7 +95,6 @@ public: static QString resourcePath(); static QString userResourcePath(); static QString installerResourcePath(); - static QString documentationPath(); static QString libexecPath(); static QString clangExecutable(const QString &clangBinDirectory); static QString clangIncludeDirectory(const QString &clangVersion, diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp index 2ce03e0789f..ea1b229236e 100644 --- a/src/plugins/help/helpplugin.cpp +++ b/src/plugins/help/helpplugin.cpp @@ -329,7 +329,7 @@ void HelpPlugin::extensionsInitialized() { QStringList filesToRegister; // we might need to register creators inbuild help - filesToRegister.append(ICore::documentationPath() + "/qtcreator.qch"); + filesToRegister.append(Core::HelpManager::documentationPath() + "/qtcreator.qch"); Core::HelpManager::registerDocumentation(filesToRegister); } diff --git a/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp b/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp index b235d7e3598..4aac91bad63 100644 --- a/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp +++ b/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp @@ -111,7 +111,7 @@ bool QbsProjectManagerPlugin::initialize(const QStringList &arguments, QString * const Core::Context projectContext(::QbsProjectManager::Constants::PROJECT_ID); Core::FileIconProvider::registerIconOverlayForSuffix(ProjectExplorer::Constants::FILEOVERLAY_QT, "qbs"); - Core::HelpManager::registerDocumentation({Core::ICore::documentationPath() + "/qbs.qch"}); + Core::HelpManager::registerDocumentation({Core::HelpManager::documentationPath() + "/qbs.qch"}); ProjectManager::registerProjectType(QmlJSTools::Constants::QBS_MIMETYPE); KitManager::registerKitInformation(); From 807b0f78fc89409559ecc22229650a883def436d Mon Sep 17 00:00:00 2001 From: Jonathan Liu Date: Thu, 20 Sep 2018 13:46:05 +1000 Subject: [PATCH 06/25] ProjectExplorer: Do not add too many newlines for remote processes Do not add newlines when remote process output gets flushed. Task-number: QTCREATORBUG-19367 Change-Id: I9e878695279404d436264abd580884fb6a9e91ad Reviewed-by: hjk --- src/plugins/projectexplorer/runconfiguration.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index 438d631c781..f2f5871a5a3 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -1659,12 +1659,12 @@ void SimpleTargetRunner::start() connect(&m_launcher, &ApplicationLauncher::remoteStderr, this, [this](const QString &output) { - appendMessage(output, Utils::StdErrFormatSameLine); + appendMessage(output, Utils::StdErrFormatSameLine, false); }); connect(&m_launcher, &ApplicationLauncher::remoteStdout, this, [this](const QString &output) { - appendMessage(output, Utils::StdOutFormatSameLine); + appendMessage(output, Utils::StdOutFormatSameLine, false); }); connect(&m_launcher, &ApplicationLauncher::finished, From 7bd3f0682842b9324b926091166ee94be75d7bfc Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 20 Sep 2018 09:45:24 +0200 Subject: [PATCH 07/25] Make BuildStep::createConfigWidget default implementation non-pure Amends 760723f7. The intention was actually that the default implementation is not only good enough, but also that there doesn't need to be a re-implementation to call it. Change-Id: I47bd4dba6f8df2826d17696f727252954a5bbabf Reviewed-by: Ulf Hermann --- src/plugins/projectexplorer/buildstep.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/projectexplorer/buildstep.h b/src/plugins/projectexplorer/buildstep.h index ddbb91d5d46..72f83c1bb37 100644 --- a/src/plugins/projectexplorer/buildstep.h +++ b/src/plugins/projectexplorer/buildstep.h @@ -55,7 +55,7 @@ protected: public: virtual bool init(QList &earlierSteps) = 0; virtual void run(QFutureInterface &fi) = 0; - virtual BuildStepConfigWidget *createConfigWidget() = 0; + virtual BuildStepConfigWidget *createConfigWidget(); virtual bool immutable() const; virtual bool runInGuiThread() const; From ed2fbeeecfb94648b5c1ba25bc7b8eca3be1ec9e Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 20 Sep 2018 10:03:57 +0200 Subject: [PATCH 08/25] RemoteLinux: Remove RemoteLinuxKillAppStep::createConfigWidget Identical to base AbstractRemoteLinuxDeployStep::createConfigWidget. Change-Id: I10a94514e50839950eb4e07a4ce1b4c004b51881 Reviewed-by: Ulf Hermann --- src/plugins/remotelinux/remotelinuxkillappstep.cpp | 5 ----- src/plugins/remotelinux/remotelinuxkillappstep.h | 2 -- 2 files changed, 7 deletions(-) diff --git a/src/plugins/remotelinux/remotelinuxkillappstep.cpp b/src/plugins/remotelinux/remotelinuxkillappstep.cpp index bdf3972a7ba..25730602550 100644 --- a/src/plugins/remotelinux/remotelinuxkillappstep.cpp +++ b/src/plugins/remotelinux/remotelinuxkillappstep.cpp @@ -43,11 +43,6 @@ RemoteLinuxKillAppStep::RemoteLinuxKillAppStep(BuildStepList *bsl, Core::Id id) setDefaultDisplayName(displayName()); } -BuildStepConfigWidget *RemoteLinuxKillAppStep::createConfigWidget() -{ - return new SimpleBuildStepConfigWidget(this); -} - bool RemoteLinuxKillAppStep::initInternal(QString *error) { Q_UNUSED(error); diff --git a/src/plugins/remotelinux/remotelinuxkillappstep.h b/src/plugins/remotelinux/remotelinuxkillappstep.h index dc94808ff12..e1f9b3f47e9 100644 --- a/src/plugins/remotelinux/remotelinuxkillappstep.h +++ b/src/plugins/remotelinux/remotelinuxkillappstep.h @@ -41,8 +41,6 @@ public: static QString displayName(); private: - ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override; - bool initInternal(QString *error) override; AbstractRemoteLinuxDeployService *deployService() const override; From b9a8e77a829eafe2171d9ab0bc34efe422cddf17 Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 4 Jun 2018 10:28:16 +0200 Subject: [PATCH 09/25] ProjectExplorer: Decommission RunWorkerFactory::priority The only ever user (AppManager) doesn't need it for disambiguation anymore. Change-Id: Iea2f4d545bf9afb0610bf73c4ec7b2f29357edc0 Reviewed-by: Ulf Hermann --- src/plugins/projectexplorer/runconfiguration.cpp | 16 +++++----------- src/plugins/projectexplorer/runconfiguration.h | 6 +----- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index cbf24c37e21..21ddbf03360 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -642,11 +642,6 @@ bool RunWorkerFactory::canRun(RunConfiguration *runConfiguration, Core::Id runMo return true; } -void RunWorkerFactory::setPriority(int priority) -{ - m_priority = priority; -} - void RunWorkerFactory::setProducer(const WorkerCreator &producer) { m_producer = producer; @@ -971,15 +966,14 @@ RunWorkerFactory::WorkerCreator RunControl::producer(RunConfiguration *runConfig const auto canRun = std::bind(&RunWorkerFactory::canRun, std::placeholders::_1, runConfig, runMode); const QList candidates = Utils::filtered(g_runWorkerFactories, canRun); + // This is legit, there might be combinations that cannot run. if (candidates.empty()) return {}; - const auto higherPriority = std::bind(std::greater<>(), - std::bind(&RunWorkerFactory::priority, std::placeholders::_1), - std::bind(&RunWorkerFactory::priority, std::placeholders::_2)); - const auto bestFactory = std::max_element(candidates.begin(), candidates.end(), higherPriority); - - return (*bestFactory)->producer(); + // There should be at most one top-level producer feeling responsible per combination. + // Breaking a tie should be done by tightening the restrictions on one of them. + QTC_CHECK(candidates.size() == 1); + return candidates.front()->producer(); } void RunControlPrivate::initiateStart() diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index aaac5f7595c..33c72a9654c 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.h @@ -382,12 +382,10 @@ public: bool canRun(RunConfiguration *runConfiguration, Core::Id runMode) const; - void setPriority(int priority); void setProducer(const WorkerCreator &producer); void addConstraint(const Constraint &constraint); void addSupportedRunMode(Core::Id runMode); - int priority() const { return m_priority; } WorkerCreator producer() const { return m_producer; } private: @@ -399,7 +397,6 @@ private: QList m_supportedRunModes; QList m_constraints; WorkerCreator m_producer; - int m_priority = 0; }; /** @@ -478,13 +475,12 @@ public: factory->addConstraint(constraint); } template - static void registerWorker(Core::Id runMode, const Constraint &constraint, int priority = 0) + static void registerWorker(Core::Id runMode, const Constraint &constraint) { auto factory = new RunWorkerFactory; factory->setProducer([](RunControl *rc) { return new Worker(rc); }); factory->addSupportedRunMode(runMode); factory->addConstraint(constraint); - factory->setPriority(priority); } static WorkerCreator producer(RunConfiguration *runConfiguration, Core::Id runMode); From bcb2df7b30208ad87545001e9d685ee6594cf6dc Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 20 Sep 2018 09:38:38 +0200 Subject: [PATCH 10/25] Debugger: Add Perspective::name() accessor Will be needed again by GammaRay. Change-Id: I9afe61dd1db4a1ba4ec95a6abd089e12c6cbcd9a Reviewed-by: Christian Stenger --- src/plugins/debugger/debuggermainwindow.cpp | 5 +++++ src/plugins/debugger/debuggermainwindow.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/plugins/debugger/debuggermainwindow.cpp b/src/plugins/debugger/debuggermainwindow.cpp index d8a45e55b30..5834c359334 100644 --- a/src/plugins/debugger/debuggermainwindow.cpp +++ b/src/plugins/debugger/debuggermainwindow.cpp @@ -593,6 +593,11 @@ QString Perspective::id() const return d->m_id; } +QString Perspective::name() const +{ + return d->m_name; +} + void Perspective::setAboutToActivateCallback(const Perspective::Callback &cb) { d->m_aboutToActivateCallback = cb; diff --git a/src/plugins/debugger/debuggermainwindow.h b/src/plugins/debugger/debuggermainwindow.h index bb057b7b482..6cdb2c90eac 100644 --- a/src/plugins/debugger/debuggermainwindow.h +++ b/src/plugins/debugger/debuggermainwindow.h @@ -87,6 +87,7 @@ public: void setShouldPersistChecker(const ShouldPersistChecker &checker); QString id() const; // Currently used by GammaRay plugin. + QString name() const; QWidget *centralWidget() const; using Callback = std::function; From 08ec1f93267eb66f52ee5ad61ed3aecc7cf68a16 Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Thu, 20 Sep 2018 12:04:21 +0200 Subject: [PATCH 11/25] CppTools: Fix crash on smart selection change with lambda ...in case there is no lambda declarator provided, e.g.: []{} Fixes: QTCREATORBUG-20994 Change-Id: I6a77cffe4e585422f1ed0639cabc687d3d123f5d Reviewed-by: Christian Stenger Reviewed-by: Alexandru Croitor --- src/plugins/cpptools/cppselectionchanger.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/plugins/cpptools/cppselectionchanger.cpp b/src/plugins/cpptools/cppselectionchanger.cpp index 5ac29f97cac..59ac0a1634c 100644 --- a/src/plugins/cpptools/cppselectionchanger.cpp +++ b/src/plugins/cpptools/cppselectionchanger.cpp @@ -924,6 +924,9 @@ void CppSelectionChanger::fineTuneASTNodePositions(ASTNodePositions &positions) // TODO: Fix more lambda cases. LambdaIntroducerAST *lambdaIntroducerAST = lambdaExpressionAST->lambda_introducer; LambdaDeclaratorAST *lambdaDeclaratorAST = lambdaExpressionAST->lambda_declarator; + if (!lambdaDeclaratorAST) + return; + TrailingReturnTypeAST *trailingReturnTypeAST = lambdaDeclaratorAST->trailing_return_type; unsigned firstSquareBracketTokenIndex = lambdaIntroducerAST->lbracket_token; unsigned lastParenTokenIndex = lambdaDeclaratorAST->rparen_token; From 6cf573534f49e2bd5ec2aeef97dca4a66002c671 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Thu, 20 Sep 2018 14:24:02 +0200 Subject: [PATCH 12/25] Bump version to 4.7.2 Change-Id: I10b0692b069aa587ab39156ddd6c4601646ff493 Reviewed-by: Eike Ziller --- qbs/modules/qtc/qtc.qbs | 4 ++-- qtcreator.pri | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/qbs/modules/qtc/qtc.qbs b/qbs/modules/qtc/qtc.qbs index 9d739f926b6..c289851119a 100644 --- a/qbs/modules/qtc/qtc.qbs +++ b/qbs/modules/qtc/qtc.qbs @@ -4,10 +4,10 @@ import qbs.FileInfo import "qtc.js" as HelperFunctions Module { - property string qtcreator_display_version: '4.7.1' + property string qtcreator_display_version: '4.7.2' property string ide_version_major: '4' property string ide_version_minor: '7' - property string ide_version_release: '1' + property string ide_version_release: '2' property string qtcreator_version: ide_version_major + '.' + ide_version_minor + '.' + ide_version_release diff --git a/qtcreator.pri b/qtcreator.pri index 6a65bf602c6..f108158c6e2 100644 --- a/qtcreator.pri +++ b/qtcreator.pri @@ -1,10 +1,10 @@ !isEmpty(QTCREATOR_PRI_INCLUDED):error("qtcreator.pri already included") QTCREATOR_PRI_INCLUDED = 1 -QTCREATOR_VERSION = 4.7.1 +QTCREATOR_VERSION = 4.7.2 QTCREATOR_COMPAT_VERSION = 4.7.0 VERSION = $$QTCREATOR_VERSION -QTCREATOR_DISPLAY_VERSION = 4.7.1 +QTCREATOR_DISPLAY_VERSION = 4.7.2 QTCREATOR_COPYRIGHT_YEAR = 2018 BINARY_ARTIFACTS_BRANCH = 4.7 From 12e253df9d5afee8d1cf56b4932917d0eb5d1f15 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Fri, 21 Sep 2018 02:08:41 +0300 Subject: [PATCH 13/25] AutoTest: Remove usages of deprecated QModelIndex::child Change-Id: I8b310a54d6c1a044c94edac8fd67dfa8b2fcfb91 Reviewed-by: Christian Stenger --- src/plugins/autotest/testresultmodel.cpp | 2 +- src/plugins/autotest/testresultspane.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/autotest/testresultmodel.cpp b/src/plugins/autotest/testresultmodel.cpp index 7eb23e41c95..d4dd274c478 100644 --- a/src/plugins/autotest/testresultmodel.cpp +++ b/src/plugins/autotest/testresultmodel.cpp @@ -430,7 +430,7 @@ bool TestResultFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &s bool TestResultFilterModel::acceptTestCaseResult(const QModelIndex &srcIndex) const { for (int row = 0, count = m_sourceModel->rowCount(srcIndex); row < count; ++row) { - const QModelIndex &child = srcIndex.child(row, 0); + const QModelIndex &child = m_sourceModel->index(row, 0, srcIndex); Result::Type type = m_sourceModel->testResult(child)->result(); if (type == Result::MessageTestCaseSuccess) type = Result::Pass; diff --git a/src/plugins/autotest/testresultspane.cpp b/src/plugins/autotest/testresultspane.cpp index 89fce104de9..277109b600a 100644 --- a/src/plugins/autotest/testresultspane.cpp +++ b/src/plugins/autotest/testresultspane.cpp @@ -324,7 +324,7 @@ void TestResultsPane::goToNext() if (currentIndex.isValid()) { // try to set next to first child or next sibling if (m_filterModel->rowCount(currentIndex)) { - nextCurrentIndex = currentIndex.child(0, 0); + nextCurrentIndex = m_filterModel->index(0, 0, currentIndex); } else { nextCurrentIndex = currentIndex.sibling(currentIndex.row() + 1, 0); // if it had no sibling check siblings of parent (and grandparents if necessary) @@ -369,7 +369,7 @@ void TestResultsPane::goToPrev() nextCurrentIndex = currentIndex.sibling(currentIndex.row() - 1, 0); // if the sibling has children, use the last one while (int rowCount = m_filterModel->rowCount(nextCurrentIndex)) - nextCurrentIndex = nextCurrentIndex.child(rowCount - 1, 0); + nextCurrentIndex = m_filterModel->index(rowCount - 1, 0, nextCurrentIndex); } else { nextCurrentIndex = currentIndex.parent(); } @@ -386,7 +386,7 @@ void TestResultsPane::goToPrev() nextCurrentIndex = m_filterModel->index(m_filterModel->rowCount(QModelIndex()) - 1, 0); // step through until end while (int rowCount = m_filterModel->rowCount(nextCurrentIndex)) - nextCurrentIndex = nextCurrentIndex.child(rowCount - 1, 0); + nextCurrentIndex = m_filterModel->index(rowCount - 1, 0, nextCurrentIndex); } m_treeView->setCurrentIndex(nextCurrentIndex); From 9364e4b8ecbed6a555ba29d68678490d088c4c8d Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Fri, 21 Sep 2018 01:30:02 +0300 Subject: [PATCH 14/25] Core: Modernize (minor) Replace 2 loops with range loops, and use nullptr. Change-Id: I9f8920bb978ed218c5ec9ca01105652ebb51d842 Reviewed-by: Alessandro Portale --- src/plugins/coreplugin/actionmanager/command.cpp | 3 +-- src/plugins/coreplugin/mainwindow.cpp | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/plugins/coreplugin/actionmanager/command.cpp b/src/plugins/coreplugin/actionmanager/command.cpp index 4d9715f8b82..c74dbedb103 100644 --- a/src/plugins/coreplugin/actionmanager/command.cpp +++ b/src/plugins/coreplugin/actionmanager/command.cpp @@ -313,8 +313,7 @@ void Action::addOverrideAction(QAction *action, const Context &context, bool scr if (context.isEmpty()) { m_contextActionMap.insert(Constants::C_GLOBAL, action); } else { - for (int i = 0; i < context.size(); ++i) { - Id id = context.at(i); + for (const Id &id : context) { if (m_contextActionMap.contains(id)) qWarning("%s", qPrintable(msgActionWarning(action, id, m_contextActionMap.value(id, nullptr)))); m_contextActionMap.insert(id, action); diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp index 6b86a9ca223..94bc49a7e92 100644 --- a/src/plugins/coreplugin/mainwindow.cpp +++ b/src/plugins/coreplugin/mainwindow.cpp @@ -355,7 +355,7 @@ void MainWindow::openDroppedFiles(const QList &files) IContext *MainWindow::currentContextObject() const { - return m_activeContext.isEmpty() ? 0 : m_activeContext.first(); + return m_activeContext.isEmpty() ? nullptr : m_activeContext.first(); } QStatusBar *MainWindow::statusBar() const @@ -1086,8 +1086,7 @@ void MainWindow::updateContext() contexts.add(m_lowPrioAdditionalContexts); Context uniquecontexts; - for (int i = 0; i < contexts.size(); ++i) { - const Id id = contexts.at(i); + for (const Id &id : qAsConst(contexts)) { if (!uniquecontexts.contains(id)) uniquecontexts.add(id); } From d88a0d8e681ec18a98540fa0a77d589511083f1f Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Fri, 21 Sep 2018 01:15:38 +0300 Subject: [PATCH 15/25] Utils: Modernize range-based for, nullptr, member initializers, override. Change-Id: I21ac5b23883c08dbd75819bb3298bc956cdb972c Reviewed-by: Alessandro Portale --- src/libs/modelinglib/qmt/stereotype/toolbar.h | 2 +- src/libs/utils/fancylineedit.cpp | 8 ++-- src/libs/utils/mimetypes/mimedatabase_p.h | 2 +- src/libs/utils/mimetypes/mimeglobpattern_p.h | 8 +--- src/libs/utils/mimetypes/mimeprovider_p.h | 22 +++++----- src/libs/utils/mimetypes/mimetypeparser_p.h | 12 +++--- src/libs/utils/outputformatter.cpp | 8 +--- src/libs/utils/pathchooser.cpp | 3 +- src/libs/utils/projectintropage.cpp | 9 ++-- src/libs/utils/tooltip/tips.h | 42 +++++++++---------- 10 files changed, 52 insertions(+), 64 deletions(-) diff --git a/src/libs/modelinglib/qmt/stereotype/toolbar.h b/src/libs/modelinglib/qmt/stereotype/toolbar.h index ab3974ec2ec..2f9be9188c5 100644 --- a/src/libs/modelinglib/qmt/stereotype/toolbar.h +++ b/src/libs/modelinglib/qmt/stereotype/toolbar.h @@ -54,7 +54,7 @@ public: } Tool(const QString &name, const QString &elementType, - const QString &stereotype = QString::null) + const QString &stereotype = QString()) : m_name(name), m_elementType(elementType), m_stereotype(stereotype) diff --git a/src/libs/utils/fancylineedit.cpp b/src/libs/utils/fancylineedit.cpp index 9efe74687e1..55b4b12f7f1 100644 --- a/src/libs/utils/fancylineedit.cpp +++ b/src/libs/utils/fancylineedit.cpp @@ -236,7 +236,7 @@ void FancyLineEdit::updateButtonPositions() { QRect contentRect = rect(); for (int i = 0; i < 2; ++i) { - Side iconpos = (Side)i; + Side iconpos = Side(i); if (layoutDirection() == Qt::RightToLeft) iconpos = (iconpos == Left ? Right : Left); @@ -473,9 +473,9 @@ void FancyLineEdit::validate() // Check buttons. if (d->m_oldText.isEmpty() || t.isEmpty()) { - for (int i = 0; i < 2; ++i) { - if (d->m_iconbutton[i]->hasAutoHide()) - d->m_iconbutton[i]->animateShow(!t.isEmpty()); + for (auto &button : qAsConst(d->m_iconbutton)) { + if (button->hasAutoHide()) + button->animateShow(!t.isEmpty()); } d->m_oldText = t; } diff --git a/src/libs/utils/mimetypes/mimedatabase_p.h b/src/libs/utils/mimetypes/mimedatabase_p.h index 1a464fb0076..6f87b213f34 100644 --- a/src/libs/utils/mimetypes/mimedatabase_p.h +++ b/src/libs/utils/mimetypes/mimedatabase_p.h @@ -99,7 +99,7 @@ public: MimeType mimeTypeForName(const QString &nameOrAlias); MimeType mimeTypeForFileNameAndData(const QString &fileName, QIODevice *device, int *priorityPtr); MimeType findByData(const QByteArray &data, int *priorityPtr); - QStringList mimeTypeForFileName(const QString &fileName, QString *foundSuffix = 0); + QStringList mimeTypeForFileName(const QString &fileName, QString *foundSuffix = nullptr); mutable MimeProviderBase *m_provider; const QString m_defaultMimeType; diff --git a/src/libs/utils/mimetypes/mimeglobpattern_p.h b/src/libs/utils/mimetypes/mimeglobpattern_p.h index 863c432653b..accbab06469 100644 --- a/src/libs/utils/mimetypes/mimeglobpattern_p.h +++ b/src/libs/utils/mimetypes/mimeglobpattern_p.h @@ -58,15 +58,11 @@ namespace Internal { struct MimeGlobMatchResult { - MimeGlobMatchResult() - : m_weight(0), m_matchingPatternLength(0) - {} - void addMatch(const QString &mimeType, int weight, const QString &pattern); QStringList m_matchingMimeTypes; - int m_weight; - int m_matchingPatternLength; + int m_weight = 0; + int m_matchingPatternLength = 0; QString m_foundSuffix; }; diff --git a/src/libs/utils/mimetypes/mimeprovider_p.h b/src/libs/utils/mimetypes/mimeprovider_p.h index deda7b9645c..b616d198798 100644 --- a/src/libs/utils/mimetypes/mimeprovider_p.h +++ b/src/libs/utils/mimetypes/mimeprovider_p.h @@ -141,14 +141,14 @@ class MimeXMLProvider : public MimeProviderBase public: MimeXMLProvider(MimeDatabasePrivate *db); - virtual bool isValid(); - virtual MimeType mimeTypeForName(const QString &name); - virtual QStringList findByFileName(const QString &fileName, QString *foundSuffix); - virtual QStringList parents(const QString &mime); - virtual QString resolveAlias(const QString &name); - virtual QStringList listAliases(const QString &name); - virtual MimeType findByMagic(const QByteArray &data, int *accuracyPtr); - virtual QList allMimeTypes(); + bool isValid() override; + MimeType mimeTypeForName(const QString &name) override; + QStringList findByFileName(const QString &fileName, QString *foundSuffix) override; + QStringList parents(const QString &mime) override; + QString resolveAlias(const QString &name) override; + QStringList listAliases(const QString &name) override; + MimeType findByMagic(const QByteArray &data, int *accuracyPtr) override; + QList allMimeTypes() override; bool load(const QString &fileName, QString *errorMessage); @@ -161,9 +161,9 @@ public: // Qt Creator additions void addData(const QString &id, const QByteArray &data); - QMap > magicRulesForMimeType(const MimeType &mimeType); - void setGlobPatternsForMimeType(const MimeType &mimeType, const QStringList &patterns); - void setMagicRulesForMimeType(const MimeType &mimeType, const QMap > &rules); + QMap > magicRulesForMimeType(const MimeType &mimeType) override; + void setGlobPatternsForMimeType(const MimeType &mimeType, const QStringList &patterns) override; + void setMagicRulesForMimeType(const MimeType &mimeType, const QMap > &rules) override; private: void ensureLoaded(); diff --git a/src/libs/utils/mimetypes/mimetypeparser_p.h b/src/libs/utils/mimetypes/mimetypeparser_p.h index b37cec464df..8d70004bff0 100644 --- a/src/libs/utils/mimetypes/mimetypeparser_p.h +++ b/src/libs/utils/mimetypes/mimetypeparser_p.h @@ -101,22 +101,22 @@ public: explicit MimeTypeParser(MimeXMLProvider &provider) : m_provider(provider) {} protected: - inline bool mimeTypeExists(const QString &mimeTypeName) + inline bool mimeTypeExists(const QString &mimeTypeName) override { return m_provider.mimeTypeForName(mimeTypeName).isValid(); } - inline bool process(const MimeType &t, QString *) + inline bool process(const MimeType &t, QString *) override { m_provider.addMimeType(t); return true; } - inline bool process(const MimeGlobPattern &glob, QString *) + inline bool process(const MimeGlobPattern &glob, QString *) override { m_provider.addGlobPattern(glob); return true; } - inline void processParent(const QString &child, const QString &parent) + inline void processParent(const QString &child, const QString &parent) override { m_provider.addParent(child, parent); } - inline void processAlias(const QString &alias, const QString &name) + inline void processAlias(const QString &alias, const QString &name) override { m_provider.addAlias(alias, name); } - inline void processMagicMatcher(const MimeMagicRuleMatcher &matcher) + inline void processMagicMatcher(const MimeMagicRuleMatcher &matcher) override { m_provider.addMagicMatcher(matcher); } private: diff --git a/src/libs/utils/outputformatter.cpp b/src/libs/utils/outputformatter.cpp index de1e20d33f8..ab47485e6e3 100644 --- a/src/libs/utils/outputformatter.cpp +++ b/src/libs/utils/outputformatter.cpp @@ -37,16 +37,12 @@ namespace Internal { class OutputFormatterPrivate { public: - OutputFormatterPrivate() - : plainTextEdit(nullptr), overwriteOutput(false) - {} - - QPlainTextEdit *plainTextEdit; + QPlainTextEdit *plainTextEdit = nullptr; QTextCharFormat formats[NumberOfFormats]; QFont font; QTextCursor cursor; AnsiEscapeCodeHandler escapeCodeHandler; - bool overwriteOutput; + bool overwriteOutput = false; }; } // namespace Internal diff --git a/src/libs/utils/pathchooser.cpp b/src/libs/utils/pathchooser.cpp index 0d0dab0e60c..7efe61db630 100644 --- a/src/libs/utils/pathchooser.cpp +++ b/src/libs/utils/pathchooser.cpp @@ -167,7 +167,7 @@ public: QHBoxLayout *m_hLayout = nullptr; FancyLineEdit *m_lineEdit = nullptr; - PathChooser::Kind m_acceptingKind; + PathChooser::Kind m_acceptingKind = PathChooser::ExistingDirectory; QString m_dialogTitleOverride; QString m_dialogFilter; QString m_initialBrowsePathOverride; @@ -181,7 +181,6 @@ public: PathChooserPrivate::PathChooserPrivate() : m_hLayout(new QHBoxLayout), m_lineEdit(new FancyLineEdit), - m_acceptingKind(PathChooser::ExistingDirectory), m_macroExpander(globalMacroExpander()) { } diff --git a/src/libs/utils/projectintropage.cpp b/src/libs/utils/projectintropage.cpp index 4aeabdaceb2..a449fe1285f 100644 --- a/src/libs/utils/projectintropage.cpp +++ b/src/libs/utils/projectintropage.cpp @@ -60,22 +60,19 @@ class ProjectIntroPagePrivate public: ProjectIntroPagePrivate(); Ui::ProjectIntroPage m_ui; - bool m_complete; + bool m_complete = false; QRegularExpressionValidator m_projectNameValidator; // Status label style sheets const QString m_errorStyleSheet; const QString m_warningStyleSheet; const QString m_hintStyleSheet; - bool m_forceSubProject; + bool m_forceSubProject = false; QStringList m_projectDirectories; }; ProjectIntroPagePrivate:: ProjectIntroPagePrivate() : - m_complete(false), m_errorStyleSheet(QLatin1String("background : red;")), - m_warningStyleSheet(QLatin1String("background : yellow;")), - m_hintStyleSheet(), - m_forceSubProject(false) + m_warningStyleSheet(QLatin1String("background : yellow;")) { } diff --git a/src/libs/utils/tooltip/tips.h b/src/libs/utils/tooltip/tips.h index fe1a8633d01..844848e7965 100644 --- a/src/libs/utils/tooltip/tips.h +++ b/src/libs/utils/tooltip/tips.h @@ -63,14 +63,14 @@ class TextTip : public QTipLabel public: TextTip(QWidget *parent); - virtual void setContent(const QVariant &content); - virtual bool isInteractive() const; - virtual void configure(const QPoint &pos, QWidget *w); - virtual bool canHandleContentReplacement(int typeId) const; - virtual int showTime() const; - virtual bool equals(int typeId, const QVariant &other, const QString &otherHelpId) const; - virtual void paintEvent(QPaintEvent *event); - virtual void resizeEvent(QResizeEvent *event); + void setContent(const QVariant &content) override; + bool isInteractive() const override; + void configure(const QPoint &pos, QWidget *w) override; + bool canHandleContentReplacement(int typeId) const override; + int showTime() const override; + bool equals(int typeId, const QVariant &other, const QString &otherHelpId) const override; + void paintEvent(QPaintEvent *event) override; + void resizeEvent(QResizeEvent *event) override; private: QString m_text; @@ -81,12 +81,12 @@ class ColorTip : public QTipLabel public: ColorTip(QWidget *parent); - virtual void setContent(const QVariant &content); - virtual void configure(const QPoint &pos, QWidget *w); - virtual bool canHandleContentReplacement(int typeId) const; - virtual int showTime() const { return 4000; } - virtual bool equals(int typeId, const QVariant &other, const QString &otherHelpId) const; - virtual void paintEvent(QPaintEvent *event); + void setContent(const QVariant &content) override; + void configure(const QPoint &pos, QWidget *w) override; + bool canHandleContentReplacement(int typeId) const override; + int showTime() const override { return 4000; } + bool equals(int typeId, const QVariant &other, const QString &otherHelpId) const override; + void paintEvent(QPaintEvent *event) override; private: QColor m_color; @@ -98,15 +98,15 @@ class WidgetTip : public QTipLabel Q_OBJECT public: - explicit WidgetTip(QWidget *parent = 0); + explicit WidgetTip(QWidget *parent = nullptr); void pinToolTipWidget(QWidget *parent); - virtual void setContent(const QVariant &content); - virtual void configure(const QPoint &pos, QWidget *w); - virtual bool canHandleContentReplacement(int typeId) const; - virtual int showTime() const { return 30000; } - virtual bool equals(int typeId, const QVariant &other, const QString &otherHelpId) const; - virtual bool isInteractive() const { return true; } + void setContent(const QVariant &content) override; + void configure(const QPoint &pos, QWidget *w) override; + bool canHandleContentReplacement(int typeId) const override; + int showTime() const override { return 30000; } + bool equals(int typeId, const QVariant &other, const QString &otherHelpId) const override; + bool isInteractive() const override { return true; } private: QWidget *m_widget; From 3c8f8f1ffcc0669b0a31aca0f6fa138606bfa061 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 20 Sep 2018 08:39:59 +0200 Subject: [PATCH 16/25] qtcdebugger: Extend help text Factor out a helper function to read out the current debugger. Display the currently registered debugger and the Qt version used in the help. Enable copying the message box text. This offers a convenient way of checking since the debugger settings often get overwritten by OS or MSVC updates. Change-Id: If61e30ae22802b71960cb6f3da96100f5fd9e47c Reviewed-by: Eike Ziller Reviewed-by: hjk Reviewed-by: David Schulz --- src/tools/qtcdebugger/main.cpp | 48 +++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/src/tools/qtcdebugger/main.cpp b/src/tools/qtcdebugger/main.cpp index 7453c08afca..38507c85394 100644 --- a/src/tools/qtcdebugger/main.cpp +++ b/src/tools/qtcdebugger/main.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -138,6 +139,26 @@ static bool parseArguments(const QStringList &args, QString *errorMessage) return true; } +static bool readDebugger(const wchar_t *key, QString *debugger, + QString *errorMessage) +{ + bool success = false; + HKEY handle; + const RegistryAccess::AccessMode accessMode = optIsWow +#ifdef Q_OS_WIN64 + ? RegistryAccess::Registry32Mode +#else + ? RegistryAccess::Registry64Mode +#endif + : RegistryAccess::DefaultAccessMode; + + if (openRegistryKey(HKEY_LOCAL_MACHINE, debuggerRegistryKeyC, false, &handle, accessMode, errorMessage)) { + success = registryReadStringKey(handle, key, debugger, errorMessage); + RegCloseKey(handle); + } + return success; +} + static void usage(const QString &binary, const QString &message = QString()) { QString msg; @@ -170,10 +191,16 @@ static void usage(const QString &binary, const QString &message = QString()) << "

On 64-bit systems, do the same for the key HKEY_LOCAL_MACHINE\\" << wCharToQString(debuggerWow32RegistryKeyC) << ", " << "setting the new value to

\"" << QDir::toNativeSeparators(binary) << "\" -wow %ld %ld

" << "

How to run a command with administrative privileges:

" - << "
runas /env /noprofile /user:Administrator \"command arguments\"
" - << ""; + << "
runas /env /noprofile /user:Administrator \"command arguments\"
"; + QString currentDebugger; + QString errorMessage; + if (readDebugger(debuggerRegistryValueNameC, ¤tDebugger, &errorMessage)) + str << "

Currently registered debugger:

" << currentDebugger << "
"; + str << "

Qt " << QT_VERSION_STR << ", " << QSysInfo::WordSize + << "bit

"; QMessageBox msgBox(QMessageBox::Information, QLatin1String(titleC), msg, QMessageBox::Ok); + msgBox.setTextInteractionFlags(Qt::TextBrowserInteraction); msgBox.exec(); } @@ -321,22 +348,7 @@ bool startCreatorAsDebugger(bool asClient, QString *errorMessage) bool readDefaultDebugger(QString *defaultDebugger, QString *errorMessage) { - bool success = false; - HKEY handle; - const RegistryAccess::AccessMode accessMode = optIsWow -#ifdef Q_OS_WIN64 - ? RegistryAccess::Registry32Mode -#else - ? RegistryAccess::Registry64Mode -#endif - : RegistryAccess::DefaultAccessMode; - - if (openRegistryKey(HKEY_LOCAL_MACHINE, debuggerRegistryKeyC, false, &handle, accessMode, errorMessage)) { - success = registryReadStringKey(handle, debuggerRegistryDefaultValueNameC, - defaultDebugger, errorMessage); - RegCloseKey(handle); - } - return success; + return readDebugger(debuggerRegistryDefaultValueNameC, defaultDebugger, errorMessage); } bool startDefaultDebugger(QString *errorMessage) From 6059d560bcce7b23e60dc194de6a2eaa76962ed9 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Fri, 21 Sep 2018 01:28:48 +0300 Subject: [PATCH 17/25] TextEditor: Add punctuation to nameForStyle This amends commit 50e5aacb026e79995c9967b12eabb9d37336a841. Change-Id: I9ff8dc5757f527f499f6268b7c92b938af4cd0d3 Reviewed-by: Ivan Donchevskii --- src/plugins/texteditor/texteditorconstants.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/texteditor/texteditorconstants.cpp b/src/plugins/texteditor/texteditorconstants.cpp index 4e2f0e9d9d8..6c3c95c8789 100644 --- a/src/plugins/texteditor/texteditorconstants.cpp +++ b/src/plugins/texteditor/texteditorconstants.cpp @@ -64,6 +64,7 @@ const char *nameForStyle(TextStyle style) case C_PRIMITIVE_TYPE: return "PrimitiveType"; case C_OPERATOR: return "Operator"; case C_OVERLOADED_OPERATOR: return "Overloaded Operator"; + case C_PUNCTUATION: return "Punctuation"; case C_PREPROCESSOR: return "Preprocessor"; case C_LABEL: return "Label"; case C_COMMENT: return "Comment"; From 46886d01e62a38d491fbea0daebf7be47f8eba64 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Fri, 21 Sep 2018 01:34:13 +0300 Subject: [PATCH 18/25] CppEditor: Use some member initializers Change-Id: Ia30723b5a208fee2b7cf18aa95f6b1aadf70422f Reviewed-by: Ivan Donchevskii --- .../cppeditor/cppinsertvirtualmethods.cpp | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/plugins/cppeditor/cppinsertvirtualmethods.cpp b/src/plugins/cppeditor/cppinsertvirtualmethods.cpp index 655803cb03c..260fa5235ba 100644 --- a/src/plugins/cppeditor/cppinsertvirtualmethods.cpp +++ b/src/plugins/cppeditor/cppinsertvirtualmethods.cpp @@ -514,12 +514,6 @@ public: InsertVirtualMethodsDialog *factory) : CppQuickFixOperation(interface, 0) , m_factory(factory) - , m_classAST(0) - , m_valid(false) - , m_cppFileName(QString::null) - , m_insertPosDecl(0) - , m_insertPosOutside(0) - , m_functionCount(0) { setDescription(QCoreApplication::translate( "CppEditor::QuickFix", "Insert Virtual Functions of Base Classes")); @@ -890,13 +884,13 @@ public: } private: - InsertVirtualMethodsDialog *m_factory; - const ClassSpecifierAST *m_classAST; - bool m_valid; + InsertVirtualMethodsDialog *m_factory = nullptr; + const ClassSpecifierAST *m_classAST = nullptr; + bool m_valid = false; QString m_cppFileName; - int m_insertPosDecl; - int m_insertPosOutside; - unsigned m_functionCount; + int m_insertPosDecl = 0; + int m_insertPosOutside = 0; + unsigned m_functionCount = 0; }; class InsertVirtualMethodsFilterModel : public QSortFilterProxyModel From 6635f85d47289e63a01d85e3fe50541a90fe7bad Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 19 Sep 2018 18:14:28 +0200 Subject: [PATCH 19/25] Debugger: Move some debugger specific bits out of debuggermainwindow.* A step towards making the perspective handling independent of the debugger plugin. Change-Id: Ic07f4b34d44c48f16a494ba7f470e0a34d3d56a3 Reviewed-by: David Schulz --- src/plugins/debugger/debuggermainwindow.cpp | 54 ------------------ src/plugins/debugger/debuggermainwindow.h | 2 - src/plugins/debugger/debuggerplugin.cpp | 62 ++++++++++++++++++--- 3 files changed, 55 insertions(+), 63 deletions(-) diff --git a/src/plugins/debugger/debuggermainwindow.cpp b/src/plugins/debugger/debuggermainwindow.cpp index 5834c359334..12ea2685570 100644 --- a/src/plugins/debugger/debuggermainwindow.cpp +++ b/src/plugins/debugger/debuggermainwindow.cpp @@ -32,10 +32,8 @@ #include #include #include -#include #include #include -#include #include #include @@ -400,58 +398,6 @@ void DebuggerMainWindowPrivate::selectPerspective(Perspective *perspective) } } -QWidget *createModeWindow(const Core::Id &mode, QWidget *switcher) -{ - theMainWindow->setSubPerspectiveSwitcher(switcher); - - auto editorHolderLayout = new QVBoxLayout; - editorHolderLayout->setMargin(0); - editorHolderLayout->setSpacing(0); - - auto editorAndFindWidget = new QWidget; - editorAndFindWidget->setLayout(editorHolderLayout); - editorHolderLayout->addWidget(theMainWindow->centralWidgetStack()); - editorHolderLayout->addWidget(new FindToolBarPlaceHolder(editorAndFindWidget)); - - auto documentAndRightPane = new MiniSplitter; - documentAndRightPane->addWidget(editorAndFindWidget); - documentAndRightPane->addWidget(new RightPanePlaceHolder(mode)); - documentAndRightPane->setStretchFactor(0, 1); - documentAndRightPane->setStretchFactor(1, 0); - - auto centralEditorWidget = new QWidget; - auto centralLayout = new QVBoxLayout(centralEditorWidget); - centralEditorWidget->setLayout(centralLayout); - centralLayout->setMargin(0); - centralLayout->setSpacing(0); - centralLayout->addWidget(documentAndRightPane); - centralLayout->setStretch(0, 1); - centralLayout->setStretch(1, 0); - - // Right-side window with editor, output etc. - auto mainWindowSplitter = new MiniSplitter; - mainWindowSplitter->addWidget(theMainWindow); - mainWindowSplitter->addWidget(new OutputPanePlaceHolder(mode, mainWindowSplitter)); - auto outputPane = new OutputPanePlaceHolder(mode, mainWindowSplitter); - outputPane->setObjectName(QLatin1String("DebuggerOutputPanePlaceHolder")); - mainWindowSplitter->addWidget(outputPane); - mainWindowSplitter->setStretchFactor(0, 10); - mainWindowSplitter->setStretchFactor(1, 0); - mainWindowSplitter->setOrientation(Qt::Vertical); - - // Navigation and right-side window. - auto splitter = new MiniSplitter; - splitter->setFocusProxy(theMainWindow->centralWidgetStack()); - splitter->addWidget(new NavigationWidgetPlaceHolder(mode, Side::Left)); - splitter->addWidget(mainWindowSplitter); - splitter->setStretchFactor(0, 0); - splitter->setStretchFactor(1, 1); - splitter->setObjectName(QLatin1String("DebugModeWidget")); - theMainWindow->setCentralWidget(centralEditorWidget); - - return splitter; -} - void DebuggerMainWindowPrivate::depopulateCurrentPerspective() { // Clean up old perspective. diff --git a/src/plugins/debugger/debuggermainwindow.h b/src/plugins/debugger/debuggermainwindow.h index 6cdb2c90eac..460163f9efe 100644 --- a/src/plugins/debugger/debuggermainwindow.h +++ b/src/plugins/debugger/debuggermainwindow.h @@ -140,6 +140,4 @@ private: class DebuggerMainWindowPrivate *d = nullptr; }; -DEBUGGER_EXPORT QWidget *createModeWindow(const Core::Id &mode, QWidget *); - } // Utils diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 06461bd4aba..d4ca02f5f19 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -72,6 +72,7 @@ #include #include #include +#include #include #include #include @@ -472,7 +473,60 @@ public: Icons::MODE_DEBUGGER_FLAT, Icons::MODE_DEBUGGER_FLAT_ACTIVE)); setPriority(85); setId(MODE_DEBUG); + + DebuggerMainWindow *mainWindow = DebuggerMainWindow::instance(); + + auto editorHolderLayout = new QVBoxLayout; + editorHolderLayout->setMargin(0); + editorHolderLayout->setSpacing(0); + + auto editorAndFindWidget = new QWidget; + editorAndFindWidget->setLayout(editorHolderLayout); + editorHolderLayout->addWidget(mainWindow->centralWidgetStack()); + editorHolderLayout->addWidget(new FindToolBarPlaceHolder(editorAndFindWidget)); + + auto documentAndRightPane = new MiniSplitter; + documentAndRightPane->addWidget(editorAndFindWidget); + documentAndRightPane->addWidget(new RightPanePlaceHolder(MODE_DEBUG)); + documentAndRightPane->setStretchFactor(0, 1); + documentAndRightPane->setStretchFactor(1, 0); + + auto centralEditorWidget = new QWidget; + auto centralLayout = new QVBoxLayout(centralEditorWidget); + centralEditorWidget->setLayout(centralLayout); + centralLayout->setMargin(0); + centralLayout->setSpacing(0); + centralLayout->addWidget(documentAndRightPane); + centralLayout->setStretch(0, 1); + centralLayout->setStretch(1, 0); + + // Right-side window with editor, output etc. + auto mainWindowSplitter = new MiniSplitter; + mainWindowSplitter->addWidget(mainWindow); + mainWindowSplitter->addWidget(new OutputPanePlaceHolder(MODE_DEBUG, mainWindowSplitter)); + auto outputPane = new OutputPanePlaceHolder(MODE_DEBUG, mainWindowSplitter); + outputPane->setObjectName(QLatin1String("DebuggerOutputPanePlaceHolder")); + mainWindowSplitter->addWidget(outputPane); + mainWindowSplitter->setStretchFactor(0, 10); + mainWindowSplitter->setStretchFactor(1, 0); + mainWindowSplitter->setOrientation(Qt::Vertical); + + // Navigation and right-side window. + auto splitter = new MiniSplitter; + splitter->setFocusProxy(mainWindow->centralWidgetStack()); + splitter->addWidget(new NavigationWidgetPlaceHolder(MODE_DEBUG, Side::Left)); + splitter->addWidget(mainWindowSplitter); + splitter->setStretchFactor(0, 0); + splitter->setStretchFactor(1, 1); + splitter->setObjectName(QLatin1String("DebugModeWidget")); + + mainWindow->setCentralWidget(centralEditorWidget); + mainWindow->setSubPerspectiveSwitcher(EngineManager::engineChooser()); + + setWidget(splitter); } + + ~DebugMode() { delete widget(); } }; /////////////////////////////////////////////////////////////////////// @@ -686,7 +740,6 @@ public: void updatePresetState(); public: - QPointer m_modeWindow; QPointer m_mode; ActionContainer *m_menu = nullptr; @@ -1296,11 +1349,9 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, // Debug mode setup m_mode = new DebugMode; - m_modeWindow = createModeWindow(Constants::MODE_DEBUG, EngineManager::engineChooser()); - m_mode->setWidget(m_modeWindow); m_debugModeContext.setContext(Context(CC::C_EDITORMANAGER)); - m_debugModeContext.setWidget(m_modeWindow); + m_debugModeContext.setWidget(m_mode->widget()); ICore::addContextObject(&m_debugModeContext); // @@ -2243,9 +2294,6 @@ void DebuggerPluginPrivate::doShutdown() m_shutdownTimer.stop(); - delete m_modeWindow; - m_modeWindow = nullptr; - delete m_mode; m_mode = nullptr; emit m_plugin->asynchronousShutdownFinished(); From 8d814facf7e8bb03b26424f4899c2a6c5db19fe8 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Fri, 21 Sep 2018 01:26:18 +0300 Subject: [PATCH 20/25] Replace QString::null with default constructed QString QString::null is deprecated since Qt 5.9. Change-Id: Ib84f338ed8cecaee0c164191fb580c851bd84ab4 Reviewed-by: Eike Ziller --- src/libs/modelinglib/qmt/infrastructure/ioexceptions.h | 2 +- src/libs/qmljs/qmljsrewriter.cpp | 6 +++--- .../qmldesigner/designercore/filemanager/qmlrewriter.cpp | 2 +- src/plugins/qmljseditor/quicktoolbar.cpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libs/modelinglib/qmt/infrastructure/ioexceptions.h b/src/libs/modelinglib/qmt/infrastructure/ioexceptions.h index cba138b0563..fc5eb73917d 100644 --- a/src/libs/modelinglib/qmt/infrastructure/ioexceptions.h +++ b/src/libs/modelinglib/qmt/infrastructure/ioexceptions.h @@ -38,7 +38,7 @@ public: class FileIOException : public IOException { public: - explicit FileIOException(const QString &errorMsg, const QString &fileName = QString::null, + explicit FileIOException(const QString &errorMsg, const QString &fileName = QString(), int lineNumber = -1); QString fileName() const { return m_fileName; } diff --git a/src/libs/qmljs/qmljsrewriter.cpp b/src/libs/qmljs/qmljsrewriter.cpp index 4e70a26b4a0..b672f8df868 100644 --- a/src/libs/qmljs/qmljsrewriter.cpp +++ b/src/libs/qmljs/qmljsrewriter.cpp @@ -220,7 +220,7 @@ UiObjectMemberList *Rewriter::searchMemberToInsertAfter(UiObjectMemberList *memb else if (UiObjectBinding *objectBinding = cast(member)) orderedMembers[toString(objectBinding->qualifiedId)] = iter; else if (cast(member)) - orderedMembers[QString::null] = iter; + orderedMembers[QString()] = iter; else if (UiScriptBinding *scriptBinding = cast(member)) orderedMembers[toString(scriptBinding->qualifiedId)] = iter; else if (cast(member)) @@ -517,7 +517,7 @@ void Rewriter::includeEmptyGroupedProperty(UiObjectDefinition *groupedProperty, #if 0 UiObjectMemberList *QMLRewriter::searchMemberToInsertAfter(UiObjectMemberList *members, const QStringList &propertyOrder) { - const int objectDefinitionInsertionPoint = propertyOrder.indexOf(QString::null); + const int objectDefinitionInsertionPoint = propertyOrder.indexOf(QString()); UiObjectMemberList *lastObjectDef = 0; UiObjectMemberList *lastNonObjectDef = 0; @@ -562,7 +562,7 @@ UiObjectMemberList *QMLRewriter::searchMemberToInsertAfter(UiObjectMemberList *m else if (UiObjectBinding *objectBinding = cast(member)) orderedMembers[toString(objectBinding->qualifiedId)] = iter; else if (cast(member)) - orderedMembers[QString::null] = iter; + orderedMembers[QString()] = iter; else if (UiScriptBinding *scriptBinding = cast(member)) orderedMembers[toString(scriptBinding->qualifiedId)] = iter; else if (cast(member)) diff --git a/src/plugins/qmldesigner/designercore/filemanager/qmlrewriter.cpp b/src/plugins/qmldesigner/designercore/filemanager/qmlrewriter.cpp index b5388afc59f..7777f3202c2 100644 --- a/src/plugins/qmldesigner/designercore/filemanager/qmlrewriter.cpp +++ b/src/plugins/qmldesigner/designercore/filemanager/qmlrewriter.cpp @@ -309,7 +309,7 @@ QmlJS::AST::UiObjectMemberList *QMLRewriter::searchMemberToInsertAfter(QmlJS::AS else if (auto objectBinding = QmlJS::AST::cast(member)) orderedMembers[toString(objectBinding->qualifiedId)] = iter; else if (QmlJS::AST::cast(member)) - orderedMembers[QString::null] = iter; + orderedMembers[QString()] = iter; else if (auto scriptBinding = QmlJS::AST::cast(member)) orderedMembers[toString(scriptBinding->qualifiedId)] = iter; else if (QmlJS::AST::cast(member)) diff --git a/src/plugins/qmljseditor/quicktoolbar.cpp b/src/plugins/qmljseditor/quicktoolbar.cpp index 3122c43ceda..41c1bea1146 100644 --- a/src/plugins/qmljseditor/quicktoolbar.cpp +++ b/src/plugins/qmljseditor/quicktoolbar.cpp @@ -96,7 +96,7 @@ QuickToolBar::QuickToolBar() << QLatin1String("font.italic") << QLatin1String("font.underline") << QLatin1String("font.strikeout") - << QString::null + << QString() << QLatin1String("states") << QLatin1String("transitions") ; From bab836c00963bce5c5b995c7f8d746ed606e9ef6 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Wed, 8 Aug 2018 12:40:03 +0200 Subject: [PATCH 21/25] AutoTest: Provide way to remember last chosen run configurations In some special setups it is almost impossible to get the right executable or run configuration. For bigger projects this can become a pain point when trying to execute tests and always getting asked which one to run. So, allow remembering the choice and use it if appropriate. The cached information is not stored permanently. Resetting of the cached information can also be triggered by switching or closing the current project and inside the settings. Task-number: QTCREATORBUG-20859 Change-Id: If416ea0ae9ad3548daca2ffcf5888fd568fd2622 Reviewed-by: Leena Miettinen Reviewed-by: David Schulz --- src/plugins/autotest/autotestplugin.cpp | 28 ++++++++++++++++++++++ src/plugins/autotest/autotestplugin.h | 18 ++++++++++++++ src/plugins/autotest/testrunner.cpp | 22 +++++++++++++++++ src/plugins/autotest/testrunner.h | 3 +++ src/plugins/autotest/testsettingspage.cpp | 3 +++ src/plugins/autotest/testsettingspage.ui | 29 ++++++++++++++++++++++- 6 files changed, 102 insertions(+), 1 deletion(-) diff --git a/src/plugins/autotest/autotestplugin.cpp b/src/plugins/autotest/autotestplugin.cpp index a4ae1ffa452..7fdedda74ef 100644 --- a/src/plugins/autotest/autotestplugin.cpp +++ b/src/plugins/autotest/autotestplugin.cpp @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -183,6 +184,10 @@ bool AutotestPlugin::initialize(const QStringList &arguments, QString *errorStri m_frameworkManager->activateFrameworksFromSettings(m_settings); TestTreeModel::instance()->syncTestFrameworks(); + connect(ProjectExplorer::SessionManager::instance(), + &ProjectExplorer::SessionManager::startupProjectChanged, this, [this] { + m_runconfigCache.clear(); + }); return true; } @@ -311,6 +316,23 @@ void AutotestPlugin::updateMenuItemsEnabledState() ActionManager::command(Constants::ACTION_RUN_DBG_UCURSOR)->action()->setEnabled(canRun); } +void AutotestPlugin::cacheRunConfigChoice(const QString &buildTargetKey, const ChoicePair &choice) +{ + if (s_instance) + s_instance->m_runconfigCache.insert(buildTargetKey, choice); +} + +ChoicePair AutotestPlugin::cachedChoiceFor(const QString &buildTargetKey) +{ + return s_instance ? s_instance->m_runconfigCache.value(buildTargetKey) : ChoicePair(); +} + +void AutotestPlugin::clearChoiceCache() +{ + if (s_instance) + s_instance->m_runconfigCache.clear(); +} + QList AutotestPlugin::createTestObjects() const { QList tests; @@ -319,3 +341,9 @@ QList AutotestPlugin::createTestObjects() const #endif return tests; } + +bool ChoicePair::matches(const ProjectExplorer::RunConfiguration *rc) const +{ + return rc ? (rc->displayName() == displayName && rc->runnable().executable == executable) + : false; +} diff --git a/src/plugins/autotest/autotestplugin.h b/src/plugins/autotest/autotestplugin.h index 5d48d2b4600..97dbcc38d5f 100644 --- a/src/plugins/autotest/autotestplugin.h +++ b/src/plugins/autotest/autotestplugin.h @@ -29,6 +29,10 @@ #include +#include + +namespace ProjectExplorer { class RunConfiguration; } + namespace Autotest { namespace Internal { @@ -39,6 +43,16 @@ struct TestSettings; class TestSettingsPage; enum class TestRunMode; +struct ChoicePair +{ + explicit ChoicePair(const QString &name = QString(), const QString &exe = QString()) + : displayName(name), executable(exe) {} + bool matches(const ProjectExplorer::RunConfiguration *rc) const; + + QString displayName; + QString executable; +}; + class AutotestPlugin : public ExtensionSystem::IPlugin { Q_OBJECT @@ -54,6 +68,9 @@ public: static QSharedPointer settings(); static void updateMenuItemsEnabledState(); + static void cacheRunConfigChoice(const QString &buildTargetKey, const ChoicePair &choice); + static ChoicePair cachedChoiceFor(const QString &buildTargetKey); + static void clearChoiceCache(); private: bool checkLicense(); @@ -68,6 +85,7 @@ private: TestSettingsPage *m_testSettingPage = nullptr; TestNavigationWidgetFactory *m_navigationWidgetFactory = nullptr; TestResultsPane *m_resultsPane = nullptr; + QMap m_runconfigCache; }; } // namespace Internal diff --git a/src/plugins/autotest/testrunner.cpp b/src/plugins/autotest/testrunner.cpp index 8000b11c769..1e5cd5ac748 100644 --- a/src/plugins/autotest/testrunner.cpp +++ b/src/plugins/autotest/testrunner.cpp @@ -49,6 +49,7 @@ #include #include +#include #include #include #include @@ -365,6 +366,17 @@ static ProjectExplorer::RunConfiguration *getRunConfiguration(const QString &bui = Utils::filtered(target->runConfigurations(), [] (const RunConfiguration *rc) { return !rc->runnable().executable.isEmpty(); }); + + const ChoicePair oldChoice = AutotestPlugin::cachedChoiceFor(buildTargetKey); + if (!oldChoice.executable.isEmpty()) { + runConfig = Utils::findOrDefault(runConfigurations, + [&oldChoice] (const RunConfiguration *rc) { + return oldChoice.matches(rc); + }); + if (runConfig) + return runConfig; + } + if (runConfigurations.size() == 1) return runConfigurations.first(); @@ -380,6 +392,8 @@ static ProjectExplorer::RunConfiguration *getRunConfiguration(const QString &bui return false; return rc->runnable().executable == exe; }); + if (runConfig && dialog.rememberChoice()) + AutotestPlugin::cacheRunConfigChoice(buildTargetKey, ChoicePair(dName, exe)); } return runConfig; } @@ -669,6 +683,8 @@ RunConfigurationSelectionDialog::RunConfigurationSelectionDialog(const QString & details.append(QString(" (%1)").arg(buildTargetKey)); m_details = new QLabel(details, this); m_rcCombo = new QComboBox(this); + m_rememberCB = new QCheckBox(tr("Remember choice. Cached choices can be reset by switching " + "projects or using the option to clear the cache."), this); m_executable = new QLabel(this); m_arguments = new QLabel(this); m_workingDir = new QLabel(this); @@ -680,6 +696,7 @@ RunConfigurationSelectionDialog::RunConfigurationSelectionDialog(const QString & formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow); formLayout->addRow(m_details); formLayout->addRow(tr("Run Configuration:"), m_rcCombo); + formLayout->addRow(m_rememberCB); formLayout->addRow(createLine(this)); formLayout->addRow(tr("Executable:"), m_executable); formLayout->addRow(tr("Arguments:"), m_arguments); @@ -709,6 +726,11 @@ QString RunConfigurationSelectionDialog::executable() const return m_executable ? m_executable->text() : QString(); } +bool RunConfigurationSelectionDialog::rememberChoice() const +{ + return m_rememberCB ? m_rememberCB->isChecked() : false; +} + void RunConfigurationSelectionDialog::populate() { m_rcCombo->addItem(QString(), QStringList({QString(), QString(), QString()})); // empty default diff --git a/src/plugins/autotest/testrunner.h b/src/plugins/autotest/testrunner.h index c5bc3dfe4de..b56d7974016 100644 --- a/src/plugins/autotest/testrunner.h +++ b/src/plugins/autotest/testrunner.h @@ -36,6 +36,7 @@ #include QT_BEGIN_NAMESPACE +class QCheckBox; class QComboBox; class QDialogButtonBox; class QLabel; @@ -111,6 +112,7 @@ public: explicit RunConfigurationSelectionDialog(const QString &buildTargetKey, QWidget *parent = nullptr); QString displayName() const; QString executable() const; + bool rememberChoice() const; private: void populate(); void updateLabels(); @@ -119,6 +121,7 @@ private: QLabel *m_arguments; QLabel *m_workingDir; QComboBox *m_rcCombo; + QCheckBox *m_rememberCB; QDialogButtonBox *m_buttonBox; }; diff --git a/src/plugins/autotest/testsettingspage.cpp b/src/plugins/autotest/testsettingspage.cpp index 97946d8226c..7c69be15106 100644 --- a/src/plugins/autotest/testsettingspage.cpp +++ b/src/plugins/autotest/testsettingspage.cpp @@ -29,6 +29,7 @@ #include "testsettingspage.h" #include "testsettings.h" #include "testtreemodel.h" +#include "autotestplugin.h" #include #include @@ -139,6 +140,8 @@ TestSettingsWidget::TestSettingsWidget(QWidget *parent) m_ui.editFilter->setEnabled(enable); m_ui.removeFilter->setEnabled(enable); }); + connect(m_ui.resetChoicesButton, &QPushButton::clicked, + this, [] { AutotestPlugin::clearChoiceCache(); }); } void TestSettingsWidget::setSettings(const TestSettings &settings) diff --git a/src/plugins/autotest/testsettingspage.ui b/src/plugins/autotest/testsettingspage.ui index 1ad42a63506..ec79213140c 100644 --- a/src/plugins/autotest/testsettingspage.ui +++ b/src/plugins/autotest/testsettingspage.ui @@ -7,7 +7,7 @@ 0 0 585 - 373 + 431 @@ -148,6 +148,33 @@ Warning: this is an experimental feature and might lead to failing to execute th + + + + + + Clear all cached choices of run configurations for tests where the executable could not be deduced. + + + Reset Cached Choices + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + From f9da340c6b2701cc5f9319dc9a6209eb3e7b9dff Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Fri, 21 Sep 2018 02:00:43 +0300 Subject: [PATCH 22/25] Debugger: Remove obsolete condition We don't support Windows earlier than 7. Change-Id: I5782e65ad4e6fb1c8acd9d083ccc410133178cd5 Reviewed-by: hjk --- src/plugins/debugger/terminal.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/plugins/debugger/terminal.cpp b/src/plugins/debugger/terminal.cpp index 5b2262e8fad..654adde42f1 100644 --- a/src/plugins/debugger/terminal.cpp +++ b/src/plugins/debugger/terminal.cpp @@ -189,11 +189,7 @@ void TerminalRunner::start() m_stubProc.setWorkingDirectory(m_stubRunnable.workingDirectory); if (HostOsInfo::isWindowsHost()) { - // Windows up to xp needs a workaround for attaching to freshly started processes. see proc_stub_win - if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA) - m_stubProc.setMode(ConsoleProcess::Suspend); - else - m_stubProc.setMode(ConsoleProcess::Debug); + m_stubProc.setMode(ConsoleProcess::Suspend); } else { m_stubProc.setMode(ConsoleProcess::Debug); m_stubProc.setSettings(Core::ICore::settings()); From 8f4d67da8fe6822907bc0b3b74d931e00c16fc18 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Fri, 21 Sep 2018 01:32:48 +0300 Subject: [PATCH 23/25] Core/ProjectExplorer: Avoid deprecated QModelIndex::child Change-Id: I74b16a90a534ea16642f8444a9915cfd19ce33de Reviewed-by: Eike Ziller --- src/plugins/coreplugin/dialogs/newdialog.cpp | 5 ++- src/plugins/coreplugin/find/itemviewfind.cpp | 2 +- .../coreplugin/find/searchresulttreemodel.cpp | 17 ++++----- .../projectexplorer/selectablefilesmodel.cpp | 37 ++++++++++--------- .../projectexplorer/selectablefilesmodel.h | 6 +-- 5 files changed, 34 insertions(+), 33 deletions(-) diff --git a/src/plugins/coreplugin/dialogs/newdialog.cpp b/src/plugins/coreplugin/dialogs/newdialog.cpp index 7e1cca297e7..e89ea9846c4 100644 --- a/src/plugins/coreplugin/dialogs/newdialog.cpp +++ b/src/plugins/coreplugin/dialogs/newdialog.cpp @@ -334,7 +334,7 @@ void NewDialog::showDialog() m_ui->templateCategoryView->setExpanded(m_filterProxyModel->index(row, 0), true); // Ensure that item description is visible on first show - currentItemChanged(m_ui->templatesView->rootIndex().child(0,0)); + currentItemChanged(m_filterProxyModel->index(0, 0, m_ui->templatesView->rootIndex())); updateOkButton(); show(); @@ -438,7 +438,8 @@ void NewDialog::currentCategoryChanged(const QModelIndex &index) sourceIndex = m_filterProxyModel->mapFromSource(sourceIndex); m_ui->templatesView->setRootIndex(sourceIndex); // Focus the first item by default - m_ui->templatesView->setCurrentIndex(m_ui->templatesView->rootIndex().child(0,0)); + m_ui->templatesView->setCurrentIndex( + m_filterProxyModel->index(0, 0, m_ui->templatesView->rootIndex())); } } diff --git a/src/plugins/coreplugin/find/itemviewfind.cpp b/src/plugins/coreplugin/find/itemviewfind.cpp index 13174c8cd97..87f1160e979 100644 --- a/src/plugins/coreplugin/find/itemviewfind.cpp +++ b/src/plugins/coreplugin/find/itemviewfind.cpp @@ -261,7 +261,7 @@ QModelIndex ItemViewFind::nextIndex(const QModelIndex &idx, bool *wrapped) const if (d->m_option == FetchMoreWhileSearching && model->canFetchMore(current)) model->fetchMore(current); if (model->rowCount(current) > 0) - return current.child(0, 0); + return model->index(0, 0, current); // no more children, go up and look for parent with more children QModelIndex nextIndex; diff --git a/src/plugins/coreplugin/find/searchresulttreemodel.cpp b/src/plugins/coreplugin/find/searchresulttreemodel.cpp index ea2c5ae9dfd..bd9f482d20d 100644 --- a/src/plugins/coreplugin/find/searchresulttreemodel.cpp +++ b/src/plugins/coreplugin/find/searchresulttreemodel.cpp @@ -104,14 +104,14 @@ QModelIndex SearchResultTreeModel::index(int row, int column, const SearchResultTreeItem *childItem = parentItem->childAt(row); if (childItem) - return createIndex(row, column, (void *)childItem); + return createIndex(row, column, const_cast(childItem)); else return QModelIndex(); } QModelIndex SearchResultTreeModel::index(SearchResultTreeItem *item) const { - return createIndex(item->rowOfItem(), 0, (void *)item); + return createIndex(item->rowOfItem(), 0, item); } QModelIndex SearchResultTreeModel::parent(const QModelIndex &idx) const @@ -125,7 +125,7 @@ QModelIndex SearchResultTreeModel::parent(const QModelIndex &idx) const if (parentItem == m_rootItem) return QModelIndex(); - return createIndex(parentItem->rowOfItem(), 0, (void *)parentItem); + return createIndex(parentItem->rowOfItem(), 0, const_cast(parentItem)); } int SearchResultTreeModel::rowCount(const QModelIndex &parent) const @@ -220,10 +220,9 @@ bool SearchResultTreeModel::setCheckState(const QModelIndex &idx, Qt::CheckState } // check children if (int children = item->childrenCount()) { - for (int i = 0; i < children; ++i) { - setCheckState(idx.child(i, 0), checkState, false); - } - emit dataChanged(idx.child(0, 0), idx.child(children-1, 0)); + for (int i = 0; i < children; ++i) + setCheckState(index(i, 0, idx), checkState, false); + emit dataChanged(index(0, 0, idx), index(children-1, 0, idx)); } return true; } @@ -355,7 +354,7 @@ void SearchResultTreeModel::addResultsToCurrentParent(const QListsetGenerated(false); existingItem->item = item; - QModelIndex itemIndex = m_currentIndex.child(insertionIndex, 0); + QModelIndex itemIndex = index(insertionIndex, 0, m_currentIndex); dataChanged(itemIndex, itemIndex); } else { beginInsertRows(m_currentIndex, insertionIndex, insertionIndex); @@ -434,7 +433,7 @@ QModelIndex SearchResultTreeModel::nextIndex(const QModelIndex &idx, bool *wrapp if (rowCount(idx) > 0) { // node with children - return idx.child(0, 0); + return index(0, 0, idx); } // leaf node QModelIndex nextIndex; diff --git a/src/plugins/projectexplorer/selectablefilesmodel.cpp b/src/plugins/projectexplorer/selectablefilesmodel.cpp index 6895a6457e9..f31049b0ea1 100644 --- a/src/plugins/projectexplorer/selectablefilesmodel.cpp +++ b/src/plugins/projectexplorer/selectablefilesmodel.cpp @@ -281,19 +281,19 @@ void SelectableFilesModel::propagateUp(const QModelIndex &index) } } -void SelectableFilesModel::propagateDown(const QModelIndex &index) +void SelectableFilesModel::propagateDown(const QModelIndex &idx) { - auto t = static_cast(index.internalPointer()); + auto t = static_cast(idx.internalPointer()); for (int i = 0; ichildDirectories.size(); ++i) { t->childDirectories[i]->checked = t->checked; - propagateDown(index.child(i, 0)); + propagateDown(index(i, 0, idx)); } for (int i = 0; ifiles.size(); ++i) t->files[i]->checked = t->checked; - int rows = rowCount(index); + int rows = rowCount(idx); if (rows) - emit dataChanged(index.child(0, 0), index.child(rows-1, 0)); + emit dataChanged(index(0, 0, idx), index(rows-1, 0, idx)); } Qt::ItemFlags SelectableFilesModel::flags(const QModelIndex &index) const @@ -401,14 +401,14 @@ void SelectableFilesModel::selectAllFiles(Tree *root) emit checkedFilesChanged(); } -Qt::CheckState SelectableFilesModel::applyFilter(const QModelIndex &index) +Qt::CheckState SelectableFilesModel::applyFilter(const QModelIndex &idx) { bool allChecked = true; bool allUnchecked = true; - auto t = static_cast(index.internalPointer()); + auto t = static_cast(idx.internalPointer()); for (int i=0; i < t->childDirectories.size(); ++i) { - Qt::CheckState childCheckState = applyFilter(index.child(i, 0)); + Qt::CheckState childCheckState = applyFilter(index(i, 0, idx)); if (childCheckState == Qt::Checked) allUnchecked = false; else if (childCheckState == Qt::Unchecked) @@ -428,7 +428,7 @@ Qt::CheckState SelectableFilesModel::applyFilter(const QModelIndex &index) removeBlock = (filter(t->visibleFiles.at(visibleIndex)) == FilterState::HIDDEN); } else if (removeBlock != (filter(t->visibleFiles.at(visibleIndex)) == FilterState::HIDDEN)) { if (removeBlock) { - beginRemoveRows(index, startOfBlock, visibleIndex - 1); + beginRemoveRows(idx, startOfBlock, visibleIndex - 1); for (int i=startOfBlock; i < visibleIndex; ++i) t->visibleFiles[i]->checked = Qt::Unchecked; t->visibleFiles.erase(t->visibleFiles.begin() + startOfBlock, @@ -442,7 +442,7 @@ Qt::CheckState SelectableFilesModel::applyFilter(const QModelIndex &index) } } if (removeBlock) { - beginRemoveRows(index, startOfBlock, visibleEnd - 1); + beginRemoveRows(idx, startOfBlock, visibleEnd - 1); for (int i=startOfBlock; i < visibleEnd; ++i) t->visibleFiles[i]->checked = Qt::Unchecked; t->visibleFiles.erase(t->visibleFiles.begin() + startOfBlock, @@ -476,7 +476,7 @@ Qt::CheckState SelectableFilesModel::applyFilter(const QModelIndex &index) ++newIndex; } // end of block = newIndex - beginInsertRows(index, visibleIndex, visibleIndex + newIndex - startOfBlock - 1); + beginInsertRows(idx, visibleIndex, visibleIndex + newIndex - startOfBlock - 1); for (int i= newIndex - 1; i >= startOfBlock; --i) t->visibleFiles.insert(visibleIndex, newRows.at(i)); endInsertRows(); @@ -486,7 +486,7 @@ Qt::CheckState SelectableFilesModel::applyFilter(const QModelIndex &index) break; } if (newIndex != newEnd) { - beginInsertRows(index, visibleIndex, visibleIndex + newEnd - newIndex - 1); + beginInsertRows(idx, visibleIndex, visibleIndex + newEnd - newIndex - 1); for (int i = newEnd - 1; i >= newIndex; --i) t->visibleFiles.insert(visibleIndex, newRows.at(i)); endInsertRows(); @@ -508,7 +508,7 @@ Qt::CheckState SelectableFilesModel::applyFilter(const QModelIndex &index) newState = Qt::Unchecked; if (t->checked != newState) { t->checked = newState; - emit dataChanged(index, index); + emit dataChanged(idx, idx); } return newState; @@ -705,13 +705,14 @@ void SelectableFilesWidget::parsingFinished() enableWidgets(true); } -void SelectableFilesWidget::smartExpand(const QModelIndex &index) +void SelectableFilesWidget::smartExpand(const QModelIndex &idx) { - if (m_view->model()->data(index, Qt::CheckStateRole) == Qt::PartiallyChecked) { - m_view->expand(index); - int rows = m_view->model()->rowCount(index); + QAbstractItemModel *model = m_view->model(); + if (model->data(idx, Qt::CheckStateRole) == Qt::PartiallyChecked) { + m_view->expand(idx); + int rows = model->rowCount(idx); for (int i = 0; i < rows; ++i) - smartExpand(index.child(i, 0)); + smartExpand(model->index(i, 0, idx)); } } diff --git a/src/plugins/projectexplorer/selectablefilesmodel.h b/src/plugins/projectexplorer/selectablefilesmodel.h index 3112a1e0cab..e094d1b48e1 100644 --- a/src/plugins/projectexplorer/selectablefilesmodel.h +++ b/src/plugins/projectexplorer/selectablefilesmodel.h @@ -132,11 +132,11 @@ signals: protected: void propagateUp(const QModelIndex &index); - void propagateDown(const QModelIndex &index); + void propagateDown(const QModelIndex &idx); private: QList parseFilter(const QString &filter); - Qt::CheckState applyFilter(const QModelIndex &index); + Qt::CheckState applyFilter(const QModelIndex &idx); void collectFiles(Tree *root, Utils::FileNameList *result) const; void collectPaths(Tree *root, Utils::FileNameList *result) const; void selectAllFiles(Tree *root); @@ -214,7 +214,7 @@ private: void parsingProgress(const Utils::FileName &fileName); void parsingFinished(); - void smartExpand(const QModelIndex &index); + void smartExpand(const QModelIndex &idx); SelectableFilesFromDirModel *m_model = nullptr; From b49175c86ac086798105765bcfc5d6b18ff32466 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Fri, 21 Sep 2018 01:31:23 +0300 Subject: [PATCH 24/25] Core: Avoid deprecated QDateTime::toTime_t Change-Id: I96364e5c0bfa478483614910025169ffb7369b51 Reviewed-by: Eike Ziller --- src/plugins/coreplugin/coreplugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/coreplugin/coreplugin.cpp b/src/plugins/coreplugin/coreplugin.cpp index e2fa72999b9..b2f3ac9d8c8 100644 --- a/src/plugins/coreplugin/coreplugin.cpp +++ b/src/plugins/coreplugin/coreplugin.cpp @@ -150,7 +150,7 @@ bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage) if (args.overrideColor.isValid()) m_mainWindow->setOverrideColor(args.overrideColor); m_locator = new Locator; - qsrand(QDateTime::currentDateTime().toTime_t()); + std::srand(unsigned(QDateTime::currentDateTime().toSecsSinceEpoch())); m_mainWindow->init(); m_editMode = new EditMode; ModeManager::activateMode(m_editMode->id()); From f350c4d1d4696074f7f947ca89509dfa5700f364 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Fri, 21 Sep 2018 09:10:54 +0200 Subject: [PATCH 25/25] AutoTest: Replace some scary wording Change-Id: If8c45824c80ed6dd2da5874af56e61ab7abb3305 Reviewed-by: Leena Miettinen Reviewed-by: David Schulz --- doc/src/howto/creator-only/creator-autotest.qdoc | 2 +- src/plugins/autotest/testconfiguration.cpp | 12 ++++++------ src/plugins/autotest/testconfiguration.h | 8 ++++---- src/plugins/autotest/testrunner.cpp | 10 +++++----- src/plugins/autotest/testsettingspage.ui | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/doc/src/howto/creator-only/creator-autotest.qdoc b/doc/src/howto/creator-only/creator-autotest.qdoc index 76e352d7d15..1848e0f8a56 100644 --- a/doc/src/howto/creator-only/creator-autotest.qdoc +++ b/doc/src/howto/creator-only/creator-autotest.qdoc @@ -391,7 +391,7 @@ \uicontrol {Limit result output} check box. To disable automatic scrolling, deselect the \uicontrol {Automatically scroll results} check box. - Internal messages and run configuration warnings for guessed configurations + Internal messages and run configuration warnings for deduced configurations are omitted by default. To view them, deselect the \uicontrol {Omit internal messages} and \uicontrol {Omit run configuration warnings} check boxes. */ diff --git a/src/plugins/autotest/testconfiguration.cpp b/src/plugins/autotest/testconfiguration.cpp index 1cd550c807c..ece34ead496 100644 --- a/src/plugins/autotest/testconfiguration.cpp +++ b/src/plugins/autotest/testconfiguration.cpp @@ -151,11 +151,11 @@ void TestConfiguration::completeTestInformation(TestRunMode runMode) if (targetInfo.targetFilePath.isEmpty()) { qCDebug(LOG) << "BuildTargetInfos"; const QList buildTargets = target->applicationTargets().list; - // if there is only one build target just use it (but be honest that we're guessing) + // if there is only one build target just use it (but be honest that we're deducing) if (buildTargets.size() == 1) { targetInfo = buildTargets.first(); - m_guessedConfiguration = true; - m_guessedFrom = targetInfo.buildKey; + m_deducedConfiguration = true; + m_deducedFrom = targetInfo.buildKey; } } @@ -223,8 +223,8 @@ void TestConfiguration::completeTestInformation(TestRunMode runMode) if (isLocal(rc)) { // FIXME for now only Desktop support const Runnable runnable = rc->runnable(); m_runnable.environment = runnable.environment; - m_guessedConfiguration = true; - m_guessedFrom = rc->displayName(); + m_deducedConfiguration = true; + m_deducedFrom = rc->displayName(); if (runMode == TestRunMode::Debug) m_runConfig = new TestRunConfiguration(rc->target(), this); } else { @@ -234,7 +234,7 @@ void TestConfiguration::completeTestInformation(TestRunMode runMode) } } - if (m_displayName.isEmpty()) // happens e.g. when guessing the TestConfiguration or error + if (m_displayName.isEmpty()) // happens e.g. when deducing the TestConfiguration or error m_displayName = (*buildSystemTargets.begin()); } diff --git a/src/plugins/autotest/testconfiguration.h b/src/plugins/autotest/testconfiguration.h index 52241f5f10d..929731bce3a 100644 --- a/src/plugins/autotest/testconfiguration.h +++ b/src/plugins/autotest/testconfiguration.h @@ -84,8 +84,8 @@ public: ProjectExplorer::RunConfiguration *originalRunConfiguration() const { return m_origRunConfig; } TestRunConfiguration *runConfiguration() const { return m_runConfig; } bool hasExecutable() const; - bool isGuessed() const { return m_guessedConfiguration; } - QString runConfigDisplayName() const { return m_guessedConfiguration ? m_guessedFrom + bool isDeduced() const { return m_deducedConfiguration; } + QString runConfigDisplayName() const { return m_deducedConfiguration ? m_deducedFrom : m_displayName; } ProjectExplorer::Runnable runnable() const { return m_runnable; } @@ -99,9 +99,9 @@ private: QString m_projectFile; QString m_buildDir; QString m_displayName; - QString m_guessedFrom; + QString m_deducedFrom; QPointer m_project; - bool m_guessedConfiguration = false; + bool m_deducedConfiguration = false; TestRunConfiguration *m_runConfig = nullptr; QSet m_buildTargets; ProjectExplorer::RunConfiguration *m_origRunConfig = nullptr; diff --git a/src/plugins/autotest/testrunner.cpp b/src/plugins/autotest/testrunner.cpp index 1e5cd5ac748..da720005033 100644 --- a/src/plugins/autotest/testrunner.cpp +++ b/src/plugins/autotest/testrunner.cpp @@ -138,8 +138,8 @@ static QString processInformation(const QProcess *proc) static QString rcInfo(const TestConfiguration * const config) { QString info = '\n' + TestRunner::tr("Run configuration:") + ' '; - if (config->isGuessed()) - info += TestRunner::tr("guessed from"); + if (config->isDeduced()) + info += TestRunner::tr("deduced from"); return info + " \"" + config->runConfigDisplayName() + '"'; } @@ -406,11 +406,11 @@ int TestRunner::precheckTestConfigurations() config->completeTestInformation(TestRunMode::Run); if (config->project()) { testCaseCount += config->testCaseCount(); - if (!omitWarnings && config->isGuessed()) { + if (!omitWarnings && config->isDeduced()) { QString message = tr( - "Project's run configuration was guessed for \"%1\".\n" + "Project's run configuration was deduced for \"%1\".\n" "This might cause trouble during execution.\n" - "(guessed from \"%2\")"); + "(deduced from \"%2\")"); message = message.arg(config->displayName()).arg(config->runConfigDisplayName()); emit testResultReady( TestResultPtr(new FaultyTestResult(Result::MessageWarn, message))); diff --git a/src/plugins/autotest/testsettingspage.ui b/src/plugins/autotest/testsettingspage.ui index ec79213140c..bef08a5a285 100644 --- a/src/plugins/autotest/testsettingspage.ui +++ b/src/plugins/autotest/testsettingspage.ui @@ -40,7 +40,7 @@ - Hides warnings related to a guessed run configuration. + Hides warnings related to a deduced run configuration. Omit run configuration warnings