diff options
Diffstat (limited to 'src/plugins')
339 files changed, 2716 insertions, 3554 deletions
diff --git a/src/plugins/android/androidbuildapkstep.cpp b/src/plugins/android/androidbuildapkstep.cpp index 20b8e73876a..130872bb0e2 100644 --- a/src/plugins/android/androidbuildapkstep.cpp +++ b/src/plugins/android/androidbuildapkstep.cpp @@ -129,6 +129,7 @@ AndroidBuildApkStep::AndroidBuildApkStep(BuildStepList *parent) { //: AndroidBuildApkStep default display name setDefaultDisplayName(tr("Build Android APK")); + setImmutable(true); } bool AndroidBuildApkStep::init(QList<const BuildStep *> &earlierSteps) diff --git a/src/plugins/android/androidbuildapkstep.h b/src/plugins/android/androidbuildapkstep.h index 665c28db4d3..8c7fddd924f 100644 --- a/src/plugins/android/androidbuildapkstep.h +++ b/src/plugins/android/androidbuildapkstep.h @@ -77,7 +77,6 @@ private: bool init(QList<const BuildStep *> &earlierSteps) override; ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override; - bool immutable() const override { return true; } void processStarted() override; void processFinished(int exitCode, QProcess::ExitStatus status) override; bool verifyKeystorePassword(); diff --git a/src/plugins/android/androidbuildapkwidget.cpp b/src/plugins/android/androidbuildapkwidget.cpp index 5e865347aa8..9067f5b36df 100644 --- a/src/plugins/android/androidbuildapkwidget.cpp +++ b/src/plugins/android/androidbuildapkwidget.cpp @@ -57,11 +57,13 @@ namespace Android { namespace Internal { AndroidBuildApkInnerWidget::AndroidBuildApkInnerWidget(AndroidBuildApkStep *step) - : ProjectExplorer::BuildStepConfigWidget(), + : ProjectExplorer::BuildStepConfigWidget(step), m_ui(new Ui::AndroidBuildApkWidget), m_step(step) { m_ui->setupUi(this); + setDisplayName("<b>" + tr("Build Android APK") + "</b>"); + setSummaryText(displayName()); // Target sdk combobox const int minApiSupported = AndroidManager::apiLevelRange().first; @@ -133,16 +135,6 @@ AndroidBuildApkInnerWidget::~AndroidBuildApkInnerWidget() delete m_ui; } -QString AndroidBuildApkInnerWidget::displayName() const -{ - return "<b>" + tr("Build Android APK") + "</b>"; -} - -QString AndroidBuildApkInnerWidget::summaryText() const -{ - return displayName(); -} - void AndroidBuildApkInnerWidget::setTargetSdk(const QString &sdk) { m_step->setBuildTargetSdk(sdk); @@ -230,8 +222,12 @@ void AndroidBuildApkInnerWidget::updateSigningWarning() // AndroidBuildApkWidget AndroidBuildApkWidget::AndroidBuildApkWidget(AndroidBuildApkStep *step) : + BuildStepConfigWidget(step), m_step(step) { + setDisplayName("<b>" + tr("Build Android APK") + "</b>"); + setSummaryText("<b>" + tr("Build Android APK") + "</b>"); + m_extraLibraryListModel = new AndroidExtraLibraryListModel(m_step->target(), this); auto base = new AndroidBuildApkInnerWidget(step); @@ -322,15 +318,5 @@ void AndroidBuildApkWidget::checkEnableRemoveButton() m_removeAndroidExtraLibButton->setEnabled(m_androidExtraLibsListView->selectionModel()->hasSelection()); } -QString AndroidBuildApkWidget::summaryText() const -{ - return "<b>" + tr("Build Android APK") + "</b>"; -} - -QString AndroidBuildApkWidget::displayName() const -{ - return summaryText(); -} - } // Internal } // Android diff --git a/src/plugins/android/androidbuildapkwidget.h b/src/plugins/android/androidbuildapkwidget.h index 47946298d26..db935ecc35d 100644 --- a/src/plugins/android/androidbuildapkwidget.h +++ b/src/plugins/android/androidbuildapkwidget.h @@ -63,8 +63,6 @@ private: void updateKeyStorePath(const QString &path); void signPackageCheckBoxToggled(bool checked); - QString summaryText() const override; - QString displayName() const override; void setCertificates(); Ui::AndroidBuildApkWidget *m_ui; @@ -86,9 +84,6 @@ private: void removeAndroidExtraLib(); void checkEnableRemoveButton(); - QString summaryText() const final; - QString displayName() const final; - private: QListView *m_androidExtraLibsListView = nullptr; QToolButton *m_removeAndroidExtraLibButton = nullptr; diff --git a/src/plugins/android/androiddeployqtstep.cpp b/src/plugins/android/androiddeployqtstep.cpp index d49971115ca..dea4742e71a 100644 --- a/src/plugins/android/androiddeployqtstep.cpp +++ b/src/plugins/android/androiddeployqtstep.cpp @@ -92,6 +92,7 @@ AndroidDeployQtStepFactory::AndroidDeployQtStepFactory() AndroidDeployQtStep::AndroidDeployQtStep(ProjectExplorer::BuildStepList *parent) : ProjectExplorer::BuildStep(parent, Id) { + setImmutable(true); m_uninstallPreviousPackage = QtSupport::QtKitInformation::qtVersion(target()->kit())->qtVersion() < QtSupport::QtVersionNumber(5, 4, 0); //: AndroidDeployQtStep default display name @@ -123,7 +124,7 @@ bool AndroidDeployQtStep::init(QList<const BuildStep *> &earlierSteps) return false; } - emit addOutput(tr("initializing deployment to Android device/simulator"), OutputFormat::Stdout); + emit addOutput(tr("Initializing deployment to Android device/simulator"), OutputFormat::Stdout); RunConfiguration *rc = target()->activeRunConfiguration(); QTC_ASSERT(rc, return false); @@ -251,10 +252,27 @@ AndroidDeployQtStep::DeployErrorCode AndroidDeployQtStep::runDeploy(QFutureInter QTC_ASSERT(rc, return DeployErrorCode::Failure); const bool deployQtLive = rc->id().name().startsWith(qmlProjectRunConfigIdName); QString packageName; + int packageVersion = -1; if (deployQtLive) { - AndroidManager::apkInfo(m_apkPath, &packageName); - if (AndroidManager::packageInstalled(m_serialNumber, packageName)) - return DeployErrorCode::NoError; + // Do not install Qt live if apk is already installed or the same version is + // being installed. + AndroidManager::apkInfo(m_apkPath, &packageName, &packageVersion); + if (AndroidManager::packageInstalled(m_serialNumber, packageName)) { + int installedVersion = AndroidManager::packageVersionCode(m_serialNumber, + packageName); + if (installedVersion == packageVersion) { + qCDebug(deployStepLog) << "Qt live APK already installed. APK version:" + << packageVersion << "Installed version:" + << installedVersion; + return DeployErrorCode::NoError; + } else { + qCDebug(deployStepLog) << "Re-installing Qt live APK. Version mismatch." + << "APK version:" << packageVersion + << "Installed version:" << installedVersion; + } + } else { + qCDebug(deployStepLog) << "Installing Qt live APK. APK version:" << packageVersion; + } } if (m_uninstallPreviousPackageRun) { @@ -551,11 +569,6 @@ void AndroidDeployQtStep::setUninstallPreviousPackage(bool uninstall) m_uninstallPreviousPackage = uninstall; } -bool AndroidDeployQtStep::runInGuiThread() const -{ - return false; -} - AndroidDeployQtStep::UninstallType AndroidDeployQtStep::uninstallPreviousPackage() { if (QtSupport::QtKitInformation::qtVersion(target()->kit())->qtVersion() < QtSupport::QtVersionNumber(5, 4, 0)) diff --git a/src/plugins/android/androiddeployqtstep.h b/src/plugins/android/androiddeployqtstep.h index a23f8f9ef61..4da27db55f6 100644 --- a/src/plugins/android/androiddeployqtstep.h +++ b/src/plugins/android/androiddeployqtstep.h @@ -74,8 +74,6 @@ public: bool fromMap(const QVariantMap &map) override; QVariantMap toMap() const override; - bool runInGuiThread() const override; - UninstallType uninstallPreviousPackage(); AndroidDeviceInfo deviceInfo() const; @@ -97,7 +95,6 @@ private: void slotSetSerialNumber(const QString &serialNumber); ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override; - bool immutable() const override { return true; } void processReadyReadStdOutput(DeployErrorCode &errorCode); void stdOutput(const QString &line); diff --git a/src/plugins/android/androiddeployqtwidget.cpp b/src/plugins/android/androiddeployqtwidget.cpp index 314120a6856..3b7f86f1362 100644 --- a/src/plugins/android/androiddeployqtwidget.cpp +++ b/src/plugins/android/androiddeployqtwidget.cpp @@ -36,11 +36,13 @@ using namespace Android; using namespace Internal; AndroidDeployQtWidget::AndroidDeployQtWidget(AndroidDeployQtStep *step) - : ProjectExplorer::BuildStepConfigWidget(), + : ProjectExplorer::BuildStepConfigWidget(step), m_ui(new Ui::AndroidDeployQtWidget), m_step(step) { m_ui->setupUi(this); + setDisplayName(tr("<b>Deploy configurations</b>")); + setSummaryText(displayName()); m_ui->uninstallPreviousPackage->setChecked(m_step->uninstallPreviousPackage() > AndroidDeployQtStep::Keep); m_ui->uninstallPreviousPackage->setEnabled(m_step->uninstallPreviousPackage() != AndroidDeployQtStep::ForceUnintall); @@ -60,16 +62,6 @@ AndroidDeployQtWidget::~AndroidDeployQtWidget() delete m_ui; } -QString AndroidDeployQtWidget::displayName() const -{ - return tr("<b>Deploy configurations</b>"); -} - -QString AndroidDeployQtWidget::summaryText() const -{ - return displayName(); -} - void AndroidDeployQtWidget::installMinistro() { QString packagePath = diff --git a/src/plugins/android/androiddeployqtwidget.h b/src/plugins/android/androiddeployqtwidget.h index 949aee637ed..e1f5b19abb9 100644 --- a/src/plugins/android/androiddeployqtwidget.h +++ b/src/plugins/android/androiddeployqtwidget.h @@ -51,9 +51,6 @@ private: void cleanLibsOnDevice(); void resetDefaultDevices(); - QString summaryText() const override; - QString displayName() const override; - Ui::AndroidDeployQtWidget *m_ui; AndroidDeployQtStep *m_step; }; diff --git a/src/plugins/android/androiddevicefactory.cpp b/src/plugins/android/androiddevicefactory.cpp index 2eb8726fa4d..6e6f507679c 100644 --- a/src/plugins/android/androiddevicefactory.cpp +++ b/src/plugins/android/androiddevicefactory.cpp @@ -28,62 +28,17 @@ #include "androidconstants.h" -#include <utils/icon.h> - -#include <QIcon> - namespace Android { namespace Internal { AndroidDeviceFactory::AndroidDeviceFactory() + : ProjectExplorer::IDeviceFactory(Constants::ANDROID_DEVICE_TYPE) { setObjectName(QLatin1String("AndroidDeviceFactory")); -} - -QString AndroidDeviceFactory::displayNameForId(Core::Id type) const -{ - if (type == Constants::ANDROID_DEVICE_TYPE) - return tr("Android Device"); - return QString(); -} - -QList<Core::Id> AndroidDeviceFactory::availableCreationIds() const -{ - return QList<Core::Id>() << Core::Id(Constants::ANDROID_DEVICE_TYPE); -} - -QIcon AndroidDeviceFactory::iconForId(Core::Id type) const -{ - Q_UNUSED(type) - using namespace Utils; - static const QIcon icon = - Icon::combinedIcon({Icon({{":/android/images/androiddevicesmall.png", - Theme::PanelTextColorDark}}, Icon::Tint), - Icon({{":/android/images/androiddevice.png", - Theme::IconsBaseColor}})}); - return icon; -} - -bool AndroidDeviceFactory::canCreate() const -{ - return false; -} - -ProjectExplorer::IDevice::Ptr AndroidDeviceFactory::create(Core::Id id) const -{ - Q_UNUSED(id) - return ProjectExplorer::IDevice::Ptr(); -} - -bool AndroidDeviceFactory::canRestore(const QVariantMap &map) const -{ - return ProjectExplorer::IDevice::typeFromMap(map) == Constants::ANDROID_DEVICE_TYPE; -} - -ProjectExplorer::IDevice::Ptr AndroidDeviceFactory::restore(const QVariantMap &map) const -{ - Q_UNUSED(map) - return ProjectExplorer::IDevice::Ptr(new AndroidDevice); + setDisplayName(tr("Android Device")); + setCombinedIcon(":/android/images/androiddevicesmall.png", + ":/android/images/androiddevice.png"); + setConstructionFunction([] { return ProjectExplorer::IDevice::Ptr(new AndroidDevice); }); } } // namespace Internal diff --git a/src/plugins/android/androiddevicefactory.h b/src/plugins/android/androiddevicefactory.h index 781c6ae1f55..10e97bcd0ec 100644 --- a/src/plugins/android/androiddevicefactory.h +++ b/src/plugins/android/androiddevicefactory.h @@ -35,15 +35,6 @@ class AndroidDeviceFactory : public ProjectExplorer::IDeviceFactory Q_OBJECT public: AndroidDeviceFactory(); - - QString displayNameForId(Core::Id type) const override; - QList<Core::Id> availableCreationIds() const override; - QIcon iconForId(Core::Id type) const override; - - bool canCreate() const override; - ProjectExplorer::IDevice::Ptr create(Core::Id id) const override; - bool canRestore(const QVariantMap &map) const override; - ProjectExplorer::IDevice::Ptr restore(const QVariantMap &map) const override; }; } // namespace Internal diff --git a/src/plugins/android/androidmanager.cpp b/src/plugins/android/androidmanager.cpp index 2ce812d6753..1f52d9c2146 100644 --- a/src/plugins/android/androidmanager.cpp +++ b/src/plugins/android/androidmanager.cpp @@ -70,34 +70,20 @@ namespace { const QLatin1String AndroidDefaultPropertiesName("project.properties"); const QLatin1String AndroidDeviceSn("AndroidDeviceSerialNumber"); const QLatin1String ApiLevelKey("AndroidVersion.ApiLevel"); - const QString packageNameRegEx("(package: name=)\\'(([a-z]{1}[a-z\\d_]*\\." - ")*[a-z][a-z\\d_]*)\\'"); - const QString activityRegEx("(launchable-activity: name=)\\'" - "(([a-z]{1}[a-z\\d_]*\\.)*[a-z][a-z\\d_]*)\\'"); - const QString apkVersionRegEx("package: name=([\\=a-z\\d_\\.\\'\\s]*)" - "\\sversionName='([\\d\\.]*)'"); + const QString packageNameRegEx("(?<token>package: )(.*?)(name=)'(?<target>.*?)'"); + const QString activityRegEx("(?<token>launchable-activity: )(.*?)(name=)'(?<target>.*?)'"); + const QString apkVersionRegEx("(?<token>package: )(.*?)(versionCode=)'(?<target>.*?)'"); + const QString versionCodeRegEx("(?<token>versionCode=)(?<version>\\d*)"); Q_LOGGING_CATEGORY(androidManagerLog, "qtc.android.androidManager", QtWarningMsg) - bool runCommand(const QString &executable, const QStringList &args, - QString *output = nullptr, int timeoutS = 30) - { - Utils::SynchronousProcess cmdProc; - cmdProc.setTimeoutS(timeoutS); - qCDebug(androidManagerLog) << executable << args.join(' '); - Utils::SynchronousProcessResponse response = cmdProc.runBlocking(executable, args); - if (output) - *output = response.allOutput(); - return response.result == Utils::SynchronousProcessResponse::Finished; - } - QString parseAaptOutput(const QString &output, const QString ®Ex) { const QRegularExpression regRx(regEx, QRegularExpression::CaseInsensitiveOption | QRegularExpression::MultilineOption); QRegularExpressionMatch match = regRx.match(output); if (match.hasMatch()) - return match.captured(2); + return match.captured("target"); return QString(); }; } // anonymous namespace @@ -162,10 +148,8 @@ bool AndroidManager::packageInstalled(const QString &deviceSerial, return false; QStringList args = AndroidDeviceInfo::adbSelector(deviceSerial); args << "shell" << "pm" << "list" << "packages"; - QString output; - runAdbCommand(args, &output); - QStringList lines = output.split(QRegularExpression("[\\n\\r]"), - QString::SkipEmptyParts); + QStringList lines = runAdbCommand(args).stdOut().split(QRegularExpression("[\\n\\r]"), + QString::SkipEmptyParts); for (const QString &line : lines) { // Don't want to confuse com.abc.xyz with com.abc.xyz.def so check with // endsWith @@ -175,30 +159,48 @@ bool AndroidManager::packageInstalled(const QString &deviceSerial, return false; } +int AndroidManager::packageVersionCode(const QString &deviceSerial, + const QString &packageName) +{ + if (deviceSerial.isEmpty() || packageName.isEmpty()) + return -1; + + QStringList args = AndroidDeviceInfo::adbSelector(deviceSerial); + args << "shell" << "dumpsys" << "package" << packageName; + const QRegularExpression regRx(versionCodeRegEx, + QRegularExpression::CaseInsensitiveOption | + QRegularExpression::MultilineOption); + QRegularExpressionMatch match = regRx.match(runAdbCommand(args).stdOut()); + if (match.hasMatch()) + return match.captured("version").toInt(); + + return -1; +} + void AndroidManager::apkInfo(const Utils::FileName &apkPath, QString *packageName, - QVersionNumber *version, + int *version, QString *activityPath) { - QString output; - runAaptCommand({"dump", "badging", apkPath.toString()}, &output); + SdkToolResult result; + result = runAaptCommand({"dump", "badging", apkPath.toString()}); QString packageStr; if (activityPath) { - packageStr = parseAaptOutput(output, packageNameRegEx); - QString path = parseAaptOutput(output, activityRegEx); + packageStr = parseAaptOutput(result.stdOut(), packageNameRegEx); + QString path = parseAaptOutput(result.stdOut(), activityRegEx); if (!packageStr.isEmpty() && !path.isEmpty()) *activityPath = packageStr + '/' + path; } if (packageName) { *packageName = activityPath ? packageStr : - parseAaptOutput(output, packageNameRegEx); + parseAaptOutput(result.stdOut(), packageNameRegEx); } if (version) { - QString versionStr = parseAaptOutput(output, apkVersionRegEx); - *version = QVersionNumber::fromString(versionStr); + QString versionStr = parseAaptOutput(result.stdOut(), apkVersionRegEx); + *version = versionStr.toInt(); } } @@ -477,8 +479,11 @@ void AndroidManager::cleanLibsOnDevice(ProjectExplorer::Target *target) } QStringList arguments = AndroidDeviceInfo::adbSelector(deviceSerialNumber); - arguments << QLatin1String("shell") << QLatin1String("rm") << QLatin1String("-r") << QLatin1String("/data/local/tmp/qt"); - runAdbCommandDetached(arguments); + arguments << "shell" << "rm" << "-r" << "/data/local/tmp/qt"; + + QString error; + if (!runAdbCommandDetached(arguments, &error)) + Core::MessageManager::write(tr("Cleaning Qt libraries on device failed.\n%1").arg(error)); } void AndroidManager::installQASIPackage(ProjectExplorer::Target *target, const QString &packagePath) @@ -499,8 +504,10 @@ void AndroidManager::installQASIPackage(ProjectExplorer::Target *target, const Q } QStringList arguments = AndroidDeviceInfo::adbSelector(deviceSerialNumber); - arguments << QLatin1String("install") << QLatin1String("-r ") << packagePath; - runAdbCommandDetached(arguments); + arguments << "install" << "-r " << packagePath; + QString error; + if (!runAdbCommandDetached(arguments, &error, true)) + Core::MessageManager::write(tr("Android package installation failed.\n%1").arg(error)); } bool AndroidManager::checkKeystorePassword(const QString &keystorePath, const QString &keystorePasswd) @@ -683,27 +690,57 @@ int AndroidManager::findApiLevel(const Utils::FileName &platformPath) return apiLevel; } -void AndroidManager::runAdbCommandDetached(const QStringList &args) +QProcess *AndroidManager::runAdbCommandDetached(const QStringList &args, QString *err, + bool deleteOnFinish) { - auto process = new QProcess(); - connect(process, static_cast<void (QProcess::*)(int)>(&QProcess::finished), - process, &QObject::deleteLater); + std::unique_ptr<QProcess> p(new QProcess); const QString adb = AndroidConfigurations::currentConfig().adbToolPath().toString(); - qCDebug(androidManagerLog) << adb << args.join(' '); - process->start(adb, args); - if (!process->waitForStarted(500) && process->state() != QProcess::Running) - delete process; + qCDebug(androidManagerLog) << "Running command:" << adb << args.join(' '); + p->start(adb, args); + if (p->waitForStarted(500) && p->state() == QProcess::Running) { + if (deleteOnFinish) { + connect(p.get(), static_cast<void (QProcess::*)(int)>(&QProcess::finished), + p.get(), &QObject::deleteLater); + } + return p.release(); + } + + QString errorStr = QString::fromUtf8(p->readAllStandardError()); + qCDebug(androidManagerLog) << "Running command failed" << adb << args.join(' ') << errorStr; + if (err) + *err = errorStr; + return nullptr; +} + +SdkToolResult AndroidManager::runCommand(const QString &executable, const QStringList &args, + const QByteArray &writeData, int timeoutS) +{ + Android::SdkToolResult cmdResult; + Utils::SynchronousProcess cmdProc; + cmdProc.setTimeoutS(timeoutS); + qCDebug(androidManagerLog) << "Running command: " << executable << args.join(' '); + Utils::SynchronousProcessResponse response = cmdProc.run(executable, args, writeData); + cmdResult.m_stdOut = response.stdOut().trimmed(); + cmdResult.m_stdErr = response.stdErr().trimmed(); + cmdResult.m_success = response.result == Utils::SynchronousProcessResponse::Finished; + qCDebug(androidManagerLog) << "Running command finshed:" << executable << args.join(' ') + << "Success:" << cmdResult.m_success + << "Output:" << response.allRawOutput(); + if (!cmdResult.success()) + cmdResult.m_exitMessage = response.exitMessage(executable, timeoutS); + return cmdResult; } -bool AndroidManager::runAdbCommand(const QStringList &args, QString *output) +SdkToolResult AndroidManager::runAdbCommand(const QStringList &args, + const QByteArray &writeData, int timeoutS) { - return runCommand(AndroidConfigurations::currentConfig().adbToolPath().toString(), - args, output); + return runCommand(AndroidConfigurations::currentConfig().adbToolPath().toString(), args, + writeData, timeoutS); } -bool AndroidManager::runAaptCommand(const QStringList &args, QString *output) +SdkToolResult AndroidManager::runAaptCommand(const QStringList &args, int timeoutS) { - return runCommand(AndroidConfigurations::currentConfig().aaptToolPath().toString(), - args, output); + return runCommand(AndroidConfigurations::currentConfig().aaptToolPath().toString(), args, {}, + timeoutS); } } // namespace Android diff --git a/src/plugins/android/androidmanager.h b/src/plugins/android/androidmanager.h index 444710ac918..6ddd63f7fdd 100644 --- a/src/plugins/android/androidmanager.h +++ b/src/plugins/android/androidmanager.h @@ -31,6 +31,10 @@ #include <QObject> #include <QVersionNumber> +QT_BEGIN_NAMESPACE +class QProcess; +QT_END_NAMESPACE + namespace ProjectExplorer { class Kit; class Target; @@ -42,6 +46,22 @@ namespace Android { class AndroidQtSupport; +class SdkToolResult { +public: + SdkToolResult() = default; + bool success() const { return m_success; } + const QString &stdOut() { return m_stdOut; } + const QString &stdErr() { return m_stdErr; } + const QString &exitMessage() { return m_exitMessage; } + +private: + bool m_success = false; + QString m_stdOut; + QString m_stdErr; + QString m_exitMessage; + friend class AndroidManager; +}; + class ANDROID_EXPORT AndroidManager : public QObject { Q_OBJECT @@ -49,11 +69,11 @@ class ANDROID_EXPORT AndroidManager : public QObject public: static QString packageName(ProjectExplorer::Target *target); static QString packageName(const Utils::FileName &manifestFile); - static bool packageInstalled(const QString &deviceSerial, - const QString &packageName); + static bool packageInstalled(const QString &deviceSerial, const QString &packageName); + static int packageVersionCode(const QString &deviceSerial, const QString &packageName); static void apkInfo(const Utils::FileName &apkPath, QString *packageName = nullptr, - QVersionNumber *version = nullptr, + int *version = nullptr, QString *activityPath = nullptr); static QString intentName(ProjectExplorer::Target *target); static QString activityName(ProjectExplorer::Target *target); @@ -94,9 +114,15 @@ public: static bool updateGradleProperties(ProjectExplorer::Target *target); static int findApiLevel(const Utils::FileName &platformPath); - static void runAdbCommandDetached(const QStringList &args); - static bool runAdbCommand(const QStringList &args, QString *output = nullptr); - static bool runAaptCommand(const QStringList &args, QString *output = nullptr); + static QProcess *runAdbCommandDetached(const QStringList &args, QString *err = nullptr, + bool deleteOnFinish = false); + static SdkToolResult runAdbCommand(const QStringList &args, const QByteArray &writeData = {}, + int timeoutS = 30); + static SdkToolResult runAaptCommand(const QStringList &args, int timeoutS = 30); + +private: + static SdkToolResult runCommand(const QString &executable, const QStringList &args, + const QByteArray &writeData = {}, int timeoutS = 30); }; } // namespace Android diff --git a/src/plugins/android/androidpackageinstallationstep.cpp b/src/plugins/android/androidpackageinstallationstep.cpp index cc6b8fc9466..a35379ed628 100644 --- a/src/plugins/android/androidpackageinstallationstep.cpp +++ b/src/plugins/android/androidpackageinstallationstep.cpp @@ -52,6 +52,8 @@ AndroidPackageInstallationStep::AndroidPackageInstallationStep(BuildStepList *bs const QString name = tr("Copy application data"); setDefaultDisplayName(name); setDisplayName(name); + setWidgetExpandedByDefault(false); + setImmutable(true); } bool AndroidPackageInstallationStep::init(QList<const BuildStep *> &earlierSteps) @@ -114,11 +116,6 @@ BuildStepConfigWidget *AndroidPackageInstallationStep::createConfigWidget() } -bool AndroidPackageInstallationStep::immutable() const -{ - return true; -} - // // AndroidPackageInstallationStepWidget // @@ -126,19 +123,10 @@ bool AndroidPackageInstallationStep::immutable() const namespace Internal { AndroidPackageInstallationStepWidget::AndroidPackageInstallationStepWidget(AndroidPackageInstallationStep *step) - : m_step(step) -{ - setShowWidget(false); -} - -QString AndroidPackageInstallationStepWidget::summaryText() const -{ - return "<b>" + tr("Make install") + "</b>"; -} - -QString AndroidPackageInstallationStepWidget::displayName() const + : BuildStepConfigWidget(step) { - return tr("Make install"); + setDisplayName(tr("Make install")); + setSummaryText("<b>" + tr("Make install") + "</b>"); } // diff --git a/src/plugins/android/androidpackageinstallationstep.h b/src/plugins/android/androidpackageinstallationstep.h index 9e314a6f8f8..4b27635a52e 100644 --- a/src/plugins/android/androidpackageinstallationstep.h +++ b/src/plugins/android/androidpackageinstallationstep.h @@ -43,7 +43,6 @@ public: bool init(QList<const BuildStep *> &earlierSteps) override; ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override; - bool immutable() const override; void run(QFutureInterface<bool> &fi) override; @@ -58,11 +57,6 @@ class AndroidPackageInstallationStepWidget : public ProjectExplorer::BuildStepCo Q_OBJECT public: AndroidPackageInstallationStepWidget(AndroidPackageInstallationStep *step); - - QString summaryText() const override; - QString displayName() const override; -private: - AndroidPackageInstallationStep *m_step; }; class AndroidPackageInstallationFactory: public ProjectExplorer::BuildStepFactory diff --git a/src/plugins/android/androidrunnerworker.cpp b/src/plugins/android/androidrunnerworker.cpp index 78cc6ffcff7..5ba4ac52b31 100644 --- a/src/plugins/android/androidrunnerworker.cpp +++ b/src/plugins/android/androidrunnerworker.cpp @@ -94,14 +94,14 @@ static bool isTimedOut(const chrono::high_resolution_clock::time_point &start, return timedOut; } -static qint64 extractPID(const QByteArray &output, const QString &packageName) +static qint64 extractPID(const QString &output, const QString &packageName) { qint64 pid = -1; foreach (auto tuple, output.split('\n')) { tuple = tuple.simplified(); if (!tuple.isEmpty()) { auto parts = tuple.split(':'); - QString commandName = QString::fromLocal8Bit(parts.first()); + QString commandName = parts.first(); if (parts.length() == 2 && commandName == packageName) { pid = parts.last().toLongLong(); break; @@ -111,9 +111,8 @@ static qint64 extractPID(const QByteArray &output, const QString &packageName) return pid; } -static void findProcessPID(QFutureInterface<qint64> &fi, const QString &adbPath, - QStringList selector, const QString &packageName, - bool preNougat) +static void findProcessPID(QFutureInterface<qint64> &fi, QStringList selector, + const QString &packageName, bool preNougat) { qCDebug(androidRunWorkerLog) << "Finding PID. PreNougat:" << preNougat; if (packageName.isEmpty()) @@ -127,12 +126,12 @@ static void findProcessPID(QFutureInterface<qint64> &fi, const QString &adbPath, do { QThread::msleep(200); - const QByteArray out = Utils::SynchronousProcess().runBlocking(adbPath, selector).allRawOutput(); + SdkToolResult result = AndroidManager::runAdbCommand(selector); if (preNougat) { - processPID = extractPID(out, packageName); + processPID = extractPID(result.stdOut(), packageName); } else { - if (!out.isEmpty()) - processPID = out.trimmed().toLongLong(); + if (!result.stdOut().isEmpty()) + processPID = result.stdOut().trimmed().toLongLong(); } } while (processPID == -1 && !isTimedOut(start) && !fi.isCanceled()); @@ -188,7 +187,6 @@ AndroidRunnerWorker::AndroidRunnerWorker(RunWorker *runner, const QString &packa m_qmlServer.setPort(server.serverPort()); qCDebug(androidRunWorkerLog) << "QML server:" << m_qmlServer.toDisplayString(); } - m_adb = AndroidConfigurations::currentConfig().adbToolPath().toString(); m_localJdbServerPort = Utils::Port(5038); QTC_CHECK(m_localJdbServerPort.isValid()); @@ -236,40 +234,16 @@ AndroidRunnerWorker::~AndroidRunnerWorker() m_pidFinder.cancel(); } -bool AndroidRunnerWorker::adbShellAmNeedsQuotes() -{ - // Between Android SDK Tools version 24.3.1 and 24.3.4 the quoting - // needs for the 'adb shell am start ...' parameters changed. - // Run a test to find out on what side of the fence we live. - // The command will fail with a complaint about the "--dummy" - // option on newer SDKs, and with "No intent supplied" on older ones. - // In case the test itself fails assume a new SDK. - Utils::SynchronousProcess adb; - adb.setTimeoutS(10); - Utils::SynchronousProcessResponse response - = adb.run(m_adb, selector() << "shell" << "am" << "start" - << "-e" << "dummy" << "dummy --dummy"); - if (response.result == Utils::SynchronousProcessResponse::StartFailed - || response.result != Utils::SynchronousProcessResponse::Finished) - return true; - - const QString output = response.allOutput(); - const bool oldSdk = output.contains("Error: No intent supplied"); - return !oldSdk; -} - -bool AndroidRunnerWorker::runAdb(const QStringList &args, int timeoutS, const QByteArray &writeData) +bool AndroidRunnerWorker::runAdb(const QStringList &args, QString *stdOut, + const QByteArray &writeData) { QStringList adbArgs = selector() + args; - qCDebug(androidRunWorkerLog) << "ADB command: " << m_adb << adbArgs.join(' '); - Utils::SynchronousProcess adb; - adb.setTimeoutS(timeoutS); - Utils::SynchronousProcessResponse response = adb.run(m_adb, adbArgs, writeData); - m_lastRunAdbError = response.exitMessage(m_adb, timeoutS); - m_lastRunAdbRawOutput = response.allRawOutput(); - bool success = response.result == Utils::SynchronousProcessResponse::Finished; - qCDebug(androidRunWorkerLog) << "ADB command result:" << success << response.allRawOutput(); - return success; + SdkToolResult result = AndroidManager::runAdbCommand(adbArgs, writeData); + if (!result.success()) + emit remoteErrorOutput(result.exitMessage() + "\n" + result.stdErr()); + if (stdOut) + *stdOut = result.stdOut(); + return result.success(); } bool AndroidRunnerWorker::uploadFile(const QString &from, const QString &to, const QString &flags) @@ -278,7 +252,8 @@ bool AndroidRunnerWorker::uploadFile(const QString &from, const QString &to, con if (!f.open(QIODevice::ReadOnly)) return false; runAdb({"shell", "run-as", m_packageName, "rm", to}); - auto res = runAdb({"shell", "run-as", m_packageName, "sh", "-c", QString("'cat > %1'").arg(to)}, 60, f.readAll()); + auto res = runAdb({"shell", "run-as", m_packageName, "sh", "-c", QString("'cat > %1'").arg(to)}, + nullptr, f.readAll()); if (!res) return false; return runAdb({"shell", "run-as", m_packageName, "chmod", flags, to}); @@ -297,17 +272,14 @@ QStringList AndroidRunnerWorker::selector() const void AndroidRunnerWorker::forceStop() { - runAdb({"shell", "am", "force-stop", m_packageName}, 30); + runAdb({"shell", "am", "force-stop", m_packageName}); // try killing it via kill -9 - const QByteArray out = Utils::SynchronousProcess() - .runBlocking(m_adb, selector() << QStringLiteral("shell") << pidScriptPreNougat) - .allRawOutput(); - + QString out; + runAdb({"shell", pidScriptPreNougat}, &out); qint64 pid = extractPID(out.simplified(), m_packageName); - if (pid != -1) { + if (pid != -1) adbKill(pid); - } } void AndroidRunnerWorker::logcatReadStandardError() @@ -395,17 +367,18 @@ void AndroidRunnerWorker::asyncStartHelper() { forceStop(); - // Start the logcat process before app starts. - std::unique_ptr<QProcess, Deleter> logcatProcess(new QProcess, deleter); - connect(logcatProcess.get(), &QProcess::readyReadStandardOutput, - this, &AndroidRunnerWorker::logcatReadStandardOutput); - connect(logcatProcess.get(), &QProcess::readyReadStandardError, - this, &AndroidRunnerWorker::logcatReadStandardError); // Its assumed that the device or avd returned by selector() is online. - logcatProcess->start(m_adb, selector() << "logcat"); + // Start the logcat process before app starts. QTC_ASSERT(!m_adbLogcatProcess, /**/); - m_adbLogcatProcess = std::move(logcatProcess); - m_adbLogcatProcess->setObjectName("AdbLogcatProcess"); + m_adbLogcatProcess.reset(AndroidManager::runAdbCommandDetached(selector() << "logcat")); + if (m_adbLogcatProcess) { + m_adbLogcatProcess->setObjectName("AdbLogcatProcess"); + connect(m_adbLogcatProcess.get(), &QProcess::readyReadStandardOutput, + this, &AndroidRunnerWorker::logcatReadStandardOutput); + connect(m_adbLogcatProcess.get(), &QProcess::readyReadStandardError, + this, &AndroidRunnerWorker::logcatReadStandardError); + } + for (const QString &entry : m_beforeStartAdbCommands) runAdb(entry.split(' ', QString::SkipEmptyParts)); @@ -415,42 +388,27 @@ void AndroidRunnerWorker::asyncStartHelper() if (m_useCppDebugger) { args << "-D"; // run-as <package-name> pwd fails on API 22 so route the pwd through shell. - if (!runAdb({"shell", "run-as", m_packageName, "/system/bin/sh", "-c", "pwd"})) { - emit remoteProcessFinished(tr("Failed to get process path. Reason: %1.").arg(m_lastRunAdbError)); + QString packageDir; + if (!runAdb({"shell", "run-as", m_packageName, "/system/bin/sh", "-c", "pwd"}, + &packageDir)) { + emit remoteProcessFinished(tr("Failed to find application directory.")); return; } - QString packageDir = QString::fromUtf8(m_lastRunAdbRawOutput.trimmed()); // Add executable flag to package dir. Gdb can't connect to running server on device on // e.g. on Android 8 with NDK 10e - runAdb({"shell", "run-as", m_packageName, "chmod", "a+x", packageDir}); + runAdb({"shell", "run-as", m_packageName, "chmod", "a+x", packageDir.trimmed()}); if (m_gdbserverPath.isEmpty() || !uploadFile(m_gdbserverPath, "gdbserver")) { emit remoteProcessFinished(tr("Cannot find/copy C++ debug server.")); return; } - QString gdbServerSocket = packageDir + "/debug-socket"; - runAdb({"shell", "run-as", m_packageName, "killall", "gdbserver"}); - runAdb({"shell", "run-as", m_packageName, "rm", gdbServerSocket}); - std::unique_ptr<QProcess, Deleter> gdbServerProcess(new QProcess, deleter); - gdbServerProcess->start(m_adb, selector() << "shell" << "run-as" - << m_packageName << "./gdbserver" - << "--multi" << "+" + gdbServerSocket); - if (!gdbServerProcess->waitForStarted()) { - emit remoteProcessFinished(tr("Failed to start C++ debugger.")); - return; - } - m_gdbServerProcess = std::move(gdbServerProcess); - m_gdbServerProcess->setObjectName("GdbServerProcess"); - QStringList removeForward{"forward", "--remove", "tcp:" + m_localGdbServerPort.toString()}; - runAdb(removeForward); - if (!runAdb({"forward", "tcp:" + m_localGdbServerPort.toString(), - "localfilesystem:" + gdbServerSocket})) { - emit remoteProcessFinished(tr("Failed to forward C++ debugging ports. Reason: %1.").arg(m_lastRunAdbError)); + QString debuggerServerErr; + if (!startDebuggerServer(packageDir, &debuggerServerErr)) { + emit remoteProcessFinished(debuggerServerErr); return; } - m_afterFinishAdbCommands.push_back(removeForward.join(' ')); } if (m_qmlDebugServices != QmlDebug::NoQmlDebugServices) { @@ -459,8 +417,7 @@ void AndroidRunnerWorker::asyncStartHelper() QStringList removeForward{{"forward", "--remove", port}}; runAdb(removeForward); if (!runAdb({"forward", port, port})) { - emit remoteProcessFinished(tr("Failed to forward QML debugging ports. Reason: %1.") - .arg(m_lastRunAdbError) + "\n" + m_lastRunAdbRawOutput); + emit remoteProcessFinished(tr("Failed to forward QML debugging ports.")); return; } m_afterFinishAdbCommands.push_back(removeForward.join(' ')); @@ -487,17 +444,49 @@ void AndroidRunnerWorker::asyncStartHelper() } if (!runAdb(args)) { - emit remoteProcessFinished(tr("Failed to start the activity. Reason: %1.") - .arg(m_lastRunAdbError)); + emit remoteProcessFinished(tr("Failed to start the activity")); return; } } +bool AndroidRunnerWorker::startDebuggerServer(QString packageDir, QString *errorStr) +{ + QString gdbServerSocket = packageDir + "/debug-socket"; + runAdb({"shell", "run-as", m_packageName, "killall", "gdbserver"}); + runAdb({"shell", "run-as", m_packageName, "rm", gdbServerSocket}); + + QString gdbProcessErr; + QStringList gdbServerArgs = selector(); + gdbServerArgs << "shell" << "run-as" << m_packageName << "./gdbserver" << "--multi" + << "+" + gdbServerSocket; + m_gdbServerProcess.reset(AndroidManager::runAdbCommandDetached(gdbServerArgs, &gdbProcessErr)); + + if (!m_gdbServerProcess) { + qCDebug(androidRunWorkerLog) << "Debugger process failed to start" << gdbProcessErr; + if (errorStr) + *errorStr = tr("Failed to start debugger server."); + return false; + } + qCDebug(androidRunWorkerLog) << "Debugger process started"; + m_gdbServerProcess->setObjectName("AndroidDebugServerProcess"); + + QStringList removeForward{"forward", "--remove", "tcp:" + m_localGdbServerPort.toString()}; + runAdb(removeForward); + if (!runAdb({"forward", "tcp:" + m_localGdbServerPort.toString(), + "localfilesystem:" + gdbServerSocket})) { + if (errorStr) + *errorStr = tr("Failed to forward C++ debugging ports."); + return false; + } + m_afterFinishAdbCommands.push_back(removeForward.join(' ')); + return true; +} + void AndroidRunnerWorker::asyncStart() { asyncStartHelper(); - m_pidFinder = Utils::onResultReady(Utils::runAsync(findProcessPID, m_adb, selector(), + m_pidFinder = Utils::onResultReady(Utils::runAsync(findProcessPID, selector(), m_packageName, m_isPreNougat), bind(&AndroidRunnerWorker::onProcessIdChanged, this, _1)); } @@ -520,7 +509,7 @@ void AndroidRunnerWorker::handleJdbWaiting() runAdb(removeForward); if (!runAdb({"forward", "tcp:" + m_localJdbServerPort.toString(), "jdwp:" + QString::number(m_processPID)})) { - emit remoteProcessFinished(tr("Failed to forward jdb debugging ports. Reason: %1.").arg(m_lastRunAdbError)); + emit remoteProcessFinished(tr("Failed to forward jdb debugging ports.")); return; } m_afterFinishAdbCommands.push_back(removeForward.join(' ')); @@ -579,8 +568,7 @@ void AndroidRunnerWorker::handleJdbSettled() } } } - emit remoteProcessFinished(tr("Cannot attach jdb to the running application. Reason: %1.") - .arg(m_lastRunAdbError)); + emit remoteProcessFinished(tr("Cannot attach jdb to the running application")); } void AndroidRunnerWorker::onProcessIdChanged(qint64 pid) @@ -608,13 +596,13 @@ void AndroidRunnerWorker::onProcessIdChanged(qint64 pid) emit remoteProcessStarted(m_localGdbServerPort, m_qmlServer, m_processPID); logcatReadStandardOutput(); QTC_ASSERT(!m_psIsAlive, /**/); - m_psIsAlive.reset(new QProcess); + QStringList isAliveArgs = selector() << "shell" << pidPollingScript.arg(m_processPID); + m_psIsAlive.reset(AndroidManager::runAdbCommandDetached(isAliveArgs)); + QTC_ASSERT(m_psIsAlive, return); m_psIsAlive->setObjectName("IsAliveProcess"); m_psIsAlive->setProcessChannelMode(QProcess::MergedChannels); connect(m_psIsAlive.get(), static_cast<void(QProcess::*)(int)>(&QProcess::finished), this, bind(&AndroidRunnerWorker::onProcessIdChanged, this, -1)); - m_psIsAlive->start(m_adb, selector() << QStringLiteral("shell") - << pidPollingScript.arg(m_processPID)); } } diff --git a/src/plugins/android/androidrunnerworker.h b/src/plugins/android/androidrunnerworker.h index ee5ec87287a..6f166ea7c27 100644 --- a/src/plugins/android/androidrunnerworker.h +++ b/src/plugins/android/androidrunnerworker.h @@ -46,9 +46,9 @@ class AndroidRunnerWorker : public QObject public: AndroidRunnerWorker(ProjectExplorer::RunWorker *runner, const QString &packageName); ~AndroidRunnerWorker() override; - bool adbShellAmNeedsQuotes(); - bool runAdb(const QStringList &args, int timeoutS = 10, const QByteArray &writeData = {}); + bool uploadFile(const QString &from, const QString &to, const QString &flags = QString("+x")); + bool runAdb(const QStringList &args, QString *stdOut = nullptr, const QByteArray &writeData = {}); void adbKill(qint64 pid); QStringList selector() const; void forceStop(); @@ -73,6 +73,7 @@ signals: protected: void asyncStartHelper(); + bool startDebuggerServer(QString packageDir, QString *errorStr = nullptr); enum class JDBState { Idle, @@ -88,7 +89,6 @@ protected: QString m_intentName; QStringList m_beforeStartAdbCommands; QStringList m_afterFinishAdbCommands; - QString m_adb; QStringList m_amStartExtraArgs; qint64 m_processPID = -1; std::unique_ptr<QProcess, Deleter> m_adbLogcatProcess; @@ -101,8 +101,6 @@ protected: QmlDebug::QmlDebugServicesPreset m_qmlDebugServices; Utils::Port m_localGdbServerPort; // Local end of forwarded debug socket. QUrl m_qmlServer; - QByteArray m_lastRunAdbRawOutput; - QString m_lastRunAdbError; JDBState m_jdbState = JDBState::Idle; Utils::Port m_localJdbServerPort; std::unique_ptr<QProcess, Deleter> m_gdbServerProcess; diff --git a/src/plugins/autotoolsprojectmanager/autogenstep.cpp b/src/plugins/autotoolsprojectmanager/autogenstep.cpp index 3bcb90d052c..eb8affc2adc 100644 --- a/src/plugins/autotoolsprojectmanager/autogenstep.cpp +++ b/src/plugins/autotoolsprojectmanager/autogenstep.cpp @@ -26,22 +26,16 @@ ****************************************************************************/ #include "autogenstep.h" -#include "autotoolsproject.h" -#include "autotoolsbuildconfiguration.h" #include "autotoolsprojectconstants.h" +#include <projectexplorer/buildconfiguration.h> #include <projectexplorer/buildsteplist.h> -#include <projectexplorer/target.h> -#include <projectexplorer/toolchain.h> -#include <projectexplorer/gnumakeparser.h> +#include <projectexplorer/project.h> #include <projectexplorer/projectexplorer.h> #include <projectexplorer/projectexplorerconstants.h> -#include <utils/qtcprocess.h> +#include <projectexplorer/target.h> -#include <QVariantMap> #include <QDateTime> -#include <QLineEdit> -#include <QFormLayout> using namespace AutotoolsProjectManager; using namespace AutotoolsProjectManager::Internal; @@ -67,6 +61,12 @@ AutogenStepFactory::AutogenStepFactory() AutogenStep::AutogenStep(BuildStepList *bsl) : AbstractProcessStep(bsl, AUTOGEN_STEP_ID) { setDefaultDisplayName(tr("Autogen")); + + m_additionalArgumentsAspect = addAspect<BaseStringAspect>(); + m_additionalArgumentsAspect->setSettingsKey(AUTOGEN_ADDITIONAL_ARGUMENTS_KEY); + m_additionalArgumentsAspect->setLabelText(tr("Arguments:")); + m_additionalArgumentsAspect->setDisplayStyle(BaseStringAspect::LineEditDisplay); + m_additionalArgumentsAspect->setHistoryCompleter("AutotoolsPM.History.AutogenStepArgs"); } bool AutogenStep::init(QList<const BuildStep *> &earlierSteps) @@ -79,7 +79,7 @@ bool AutogenStep::init(QList<const BuildStep *> &earlierSteps) const QString projectDir(bc->target()->project()->projectDirectory().toString()); pp->setWorkingDirectory(projectDir); pp->setCommand("./autogen.sh"); - pp->setArguments(additionalArguments()); + pp->setArguments(m_additionalArgumentsAspect->value()); pp->resolveAll(); return AbstractProcessStep::init(earlierSteps); @@ -113,89 +113,28 @@ void AutogenStep::run(QFutureInterface<bool> &fi) BuildStepConfigWidget *AutogenStep::createConfigWidget() { - return new AutogenStepConfigWidget(this); -} - -bool AutogenStep::immutable() const -{ - return false; -} - -void AutogenStep::setAdditionalArguments(const QString &list) -{ - if (list == m_additionalArguments) - return; + auto widget = AbstractProcessStep::createConfigWidget(); - m_additionalArguments = list; - m_runAutogen = true; + auto updateDetails = [this, widget] { + BuildConfiguration *bc = buildConfiguration(); - emit additionalArgumentsChanged(list); -} + ProcessParameters param; + param.setMacroExpander(bc->macroExpander()); + param.setEnvironment(bc->environment()); + const QString projectDir(bc->target()->project()->projectDirectory().toString()); + param.setWorkingDirectory(projectDir); + param.setCommand("./autogen.sh"); + param.setArguments(m_additionalArgumentsAspect->value()); -QString AutogenStep::additionalArguments() const -{ - return m_additionalArguments; -} - -QVariantMap AutogenStep::toMap() const -{ - QVariantMap map(AbstractProcessStep::toMap()); - - map.insert(AUTOGEN_ADDITIONAL_ARGUMENTS_KEY, m_additionalArguments); - return map; -} - -bool AutogenStep::fromMap(const QVariantMap &map) -{ - m_additionalArguments = map.value(AUTOGEN_ADDITIONAL_ARGUMENTS_KEY).toString(); - - return BuildStep::fromMap(map); -} - -////////////////////////////////// -// AutogenStepConfigWidget class -////////////////////////////////// -AutogenStepConfigWidget::AutogenStepConfigWidget(AutogenStep *autogenStep) : - m_autogenStep(autogenStep), - m_additionalArguments(new QLineEdit) -{ - QFormLayout *fl = new QFormLayout(this); - fl->setMargin(0); - fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); - setLayout(fl); - - fl->addRow(tr("Arguments:"), m_additionalArguments); - m_additionalArguments->setText(m_autogenStep->additionalArguments()); + widget->setSummaryText(param.summary(displayName())); + }; updateDetails(); - connect(m_additionalArguments, &QLineEdit::textChanged, - autogenStep, &AutogenStep::setAdditionalArguments); - connect(autogenStep, &AutogenStep::additionalArgumentsChanged, - this, &AutogenStepConfigWidget::updateDetails); -} - -QString AutogenStepConfigWidget::displayName() const -{ - return tr("Autogen", "AutotoolsProjectManager::AutogenStepConfigWidget display name."); -} - -QString AutogenStepConfigWidget::summaryText() const -{ - return m_summaryText; -} - -void AutogenStepConfigWidget::updateDetails() -{ - BuildConfiguration *bc = m_autogenStep->buildConfiguration(); + connect(m_additionalArgumentsAspect, &ProjectConfigurationAspect::changed, this, [=] { + updateDetails(); + m_runAutogen = true; + }); - ProcessParameters param; - param.setMacroExpander(bc->macroExpander()); - param.setEnvironment(bc->environment()); - const QString projectDir(bc->target()->project()->projectDirectory().toString()); - param.setWorkingDirectory(projectDir); - param.setCommand("./autogen.sh"); - param.setArguments(m_autogenStep->additionalArguments()); - m_summaryText = param.summary(displayName()); - emit updateSummary(); + return widget; } diff --git a/src/plugins/autotoolsprojectmanager/autogenstep.h b/src/plugins/autotoolsprojectmanager/autogenstep.h index a4659ebcbcc..7e2a872e122 100644 --- a/src/plugins/autotoolsprojectmanager/autogenstep.h +++ b/src/plugins/autotoolsprojectmanager/autogenstep.h @@ -28,18 +28,11 @@ #pragma once #include <projectexplorer/abstractprocessstep.h> - -QT_BEGIN_NAMESPACE -class QLineEdit; -QT_END_NAMESPACE +#include <projectexplorer/projectconfigurationaspects.h> namespace AutotoolsProjectManager { namespace Internal { -class AutotoolsProject; -class AutogenStep; -class AutogenStepConfigWidget; - ///////////////////////////// // AutogenStepFactory class ///////////////////////////// @@ -63,16 +56,12 @@ public: * A autogen step can be configured by selecting the "Projects" button of Qt Creator * (in the left hand side menu) and under "Build Settings". * - * It is possible for the user to specify custom arguments. The corresponding - * configuration widget is created by AutogenStep::createConfigWidget and is - * represented by an instance of the class AutogenStepConfigWidget. + * It is possible for the user to specify custom arguments. */ class AutogenStep : public ProjectExplorer::AbstractProcessStep { Q_OBJECT - friend class AutogenStepFactory; - friend class AutogenStepConfigWidget; public: explicit AutogenStep(ProjectExplorer::BuildStepList *bsl); @@ -80,47 +69,11 @@ public: bool init(QList<const BuildStep *> &earlierSteps) override; void run(QFutureInterface<bool> &fi) override; ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override; - bool immutable() const override; - QString additionalArguments() const; - QVariantMap toMap() const override; - - void setAdditionalArguments(const QString &list); - -signals: - void additionalArgumentsChanged(const QString &); private: - bool fromMap(const QVariantMap &map) override; - - QString m_additionalArguments; + ProjectExplorer::BaseStringAspect *m_additionalArgumentsAspect = nullptr; bool m_runAutogen = false; }; -////////////////////////////////// -// AutogenStepConfigWidget class -////////////////////////////////// -/** - * @brief Implementation of the ProjectExplorer::BuildStepConfigWidget interface. - * - * Allows to configure a autogen step in the GUI. - */ -class AutogenStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget -{ - Q_OBJECT - -public: - AutogenStepConfigWidget(AutogenStep *autogenStep); - - QString displayName() const override; - QString summaryText() const override; - -private: - void updateDetails(); - - AutogenStep *m_autogenStep; - QString m_summaryText; - QLineEdit *m_additionalArguments; -}; - } // namespace Internal } // namespace AutotoolsProjectManager diff --git a/src/plugins/autotoolsprojectmanager/autoreconfstep.cpp b/src/plugins/autotoolsprojectmanager/autoreconfstep.cpp index 51e2e34751f..1eae2935128 100644 --- a/src/plugins/autotoolsprojectmanager/autoreconfstep.cpp +++ b/src/plugins/autotoolsprojectmanager/autoreconfstep.cpp @@ -26,28 +26,20 @@ ****************************************************************************/ #include "autoreconfstep.h" -#include "autotoolsproject.h" -#include "autotoolsbuildconfiguration.h" #include "autotoolsprojectconstants.h" +#include <projectexplorer/buildconfiguration.h> #include <projectexplorer/buildsteplist.h> -#include <projectexplorer/target.h> -#include <projectexplorer/toolchain.h> -#include <projectexplorer/gnumakeparser.h> +#include <projectexplorer/project.h> #include <projectexplorer/projectexplorer.h> #include <projectexplorer/projectexplorerconstants.h> -#include <utils/qtcprocess.h> - -#include <QVariantMap> -#include <QLineEdit> -#include <QFormLayout> +#include <projectexplorer/target.h> using namespace AutotoolsProjectManager; using namespace AutotoolsProjectManager::Internal; using namespace ProjectExplorer; const char AUTORECONF_STEP_ID[] = "AutotoolsProjectManager.AutoreconfStep"; -const char AUTORECONF_ADDITIONAL_ARGUMENTS_KEY[] = "AutotoolsProjectManager.AutoreconfStep.AdditionalArguments"; // AutoreconfStepFactory class @@ -66,6 +58,13 @@ AutoreconfStepFactory::AutoreconfStepFactory() AutoreconfStep::AutoreconfStep(BuildStepList *bsl) : AbstractProcessStep(bsl, AUTORECONF_STEP_ID) { setDefaultDisplayName(tr("Autoreconf")); + + m_additionalArgumentsAspect = addAspect<BaseStringAspect>(); + m_additionalArgumentsAspect->setSettingsKey("AutotoolsProjectManager.AutoreconfStep.AdditionalArguments"); + m_additionalArgumentsAspect->setLabelText(tr("Arguments:")); + m_additionalArgumentsAspect->setValue("--force --install"); + m_additionalArgumentsAspect->setDisplayStyle(BaseStringAspect::LineEditDisplay); + m_additionalArgumentsAspect->setHistoryCompleter("AutotoolsPM.History.AutoreconfStepArgs"); } bool AutoreconfStep::init(QList<const BuildStep *> &earlierSteps) @@ -78,7 +77,7 @@ bool AutoreconfStep::init(QList<const BuildStep *> &earlierSteps) const QString projectDir(bc->target()->project()->projectDirectory().toString()); pp->setWorkingDirectory(projectDir); pp->setCommand("autoreconf"); - pp->setArguments(additionalArguments()); + pp->setArguments(m_additionalArgumentsAspect->value()); pp->resolveAll(); return AbstractProcessStep::init(earlierSteps); @@ -106,89 +105,28 @@ void AutoreconfStep::run(QFutureInterface<bool> &fi) BuildStepConfigWidget *AutoreconfStep::createConfigWidget() { - return new AutoreconfStepConfigWidget(this); -} - -bool AutoreconfStep::immutable() const -{ - return false; -} - -void AutoreconfStep::setAdditionalArguments(const QString &list) -{ - if (list == m_additionalArguments) - return; - - m_additionalArguments = list; - m_runAutoreconf = true; - - emit additionalArgumentsChanged(list); -} - -QString AutoreconfStep::additionalArguments() const -{ - return m_additionalArguments; -} - -QVariantMap AutoreconfStep::toMap() const -{ - QVariantMap map = AbstractProcessStep::toMap(); + auto widget = AbstractProcessStep::createConfigWidget(); - map.insert(AUTORECONF_ADDITIONAL_ARGUMENTS_KEY, m_additionalArguments); - return map; -} + auto updateDetails = [this, widget] { + BuildConfiguration *bc = buildConfiguration(); -bool AutoreconfStep::fromMap(const QVariantMap &map) -{ - m_additionalArguments = map.value(AUTORECONF_ADDITIONAL_ARGUMENTS_KEY).toString(); + ProcessParameters param; + param.setMacroExpander(bc->macroExpander()); + param.setEnvironment(bc->environment()); + const QString projectDir(bc->target()->project()->projectDirectory().toString()); + param.setWorkingDirectory(projectDir); + param.setCommand("autoreconf"); + param.setArguments(m_additionalArgumentsAspect->value()); - return BuildStep::fromMap(map); -} - -////////////////////////////////////// -// AutoreconfStepConfigWidget class -////////////////////////////////////// -AutoreconfStepConfigWidget::AutoreconfStepConfigWidget(AutoreconfStep *autoreconfStep) : - m_autoreconfStep(autoreconfStep), - m_additionalArguments(new QLineEdit(this)) -{ - QFormLayout *fl = new QFormLayout(this); - fl->setMargin(0); - fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); - setLayout(fl); - - fl->addRow(tr("Arguments:"), m_additionalArguments); - m_additionalArguments->setText(m_autoreconfStep->additionalArguments()); + widget->setSummaryText(param.summary(displayName())); + }; updateDetails(); - connect(m_additionalArguments, &QLineEdit::textChanged, - autoreconfStep, &AutoreconfStep::setAdditionalArguments); - connect(autoreconfStep, &AutoreconfStep::additionalArgumentsChanged, - this, &AutoreconfStepConfigWidget::updateDetails); -} - -QString AutoreconfStepConfigWidget::displayName() const -{ - return tr("Autoreconf", "AutotoolsProjectManager::AutoreconfStepConfigWidget display name."); -} - -QString AutoreconfStepConfigWidget::summaryText() const -{ - return m_summaryText; -} - -void AutoreconfStepConfigWidget::updateDetails() -{ - BuildConfiguration *bc = m_autoreconfStep->buildConfiguration(); + connect(m_additionalArgumentsAspect, &ProjectConfigurationAspect::changed, this, [=] { + updateDetails(); + m_runAutoreconf = true; + }); - ProcessParameters param; - param.setMacroExpander(bc->macroExpander()); - param.setEnvironment(bc->environment()); - const QString projectDir(bc->target()->project()->projectDirectory().toString()); - param.setWorkingDirectory(projectDir); - param.setCommand("autoreconf"); - param.setArguments(m_autoreconfStep->additionalArguments()); - m_summaryText = param.summary(displayName()); - emit updateSummary(); + return widget; } diff --git a/src/plugins/autotoolsprojectmanager/autoreconfstep.h b/src/plugins/autotoolsprojectmanager/autoreconfstep.h index 7aa345c1480..9d4ec349555 100644 --- a/src/plugins/autotoolsprojectmanager/autoreconfstep.h +++ b/src/plugins/autotoolsprojectmanager/autoreconfstep.h @@ -28,17 +28,11 @@ #pragma once #include <projectexplorer/abstractprocessstep.h> - -QT_BEGIN_NAMESPACE -class QLineEdit; -QT_END_NAMESPACE +#include <projectexplorer/projectconfigurationaspects.h> namespace AutotoolsProjectManager { namespace Internal { -class AutotoolsProject; -class AutoreconfStep; - //////////////////////////////// // AutoreconfStepFactory class //////////////////////////////// @@ -62,16 +56,12 @@ public: * A autoreconf step can be configured by selecting the "Projects" button * of Qt Creator (in the left hand side menu) and under "Build Settings". * - * It is possible for the user to specify custom arguments. The corresponding - * configuration widget is created by AutoreconfStep::createConfigWidget and is - * represented by an instance of the class AutoreconfStepConfigWidget. + * It is possible for the user to specify custom arguments. */ class AutoreconfStep : public ProjectExplorer::AbstractProcessStep { Q_OBJECT - friend class AutoreconfStepFactory; - friend class AutoreconfStepConfigWidget; public: explicit AutoreconfStep(ProjectExplorer::BuildStepList *bsl); @@ -79,47 +69,11 @@ public: bool init(QList<const BuildStep *> &earlierSteps) override; void run(QFutureInterface<bool> &fi) override; ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override; - bool immutable() const override; - QString additionalArguments() const; - QVariantMap toMap() const override; - - void setAdditionalArguments(const QString &list); - -signals: - void additionalArgumentsChanged(const QString &); private: - bool fromMap(const QVariantMap &map) override; - - QString m_additionalArguments; + ProjectExplorer::BaseStringAspect *m_additionalArgumentsAspect = nullptr; bool m_runAutoreconf = false; }; -////////////////////////////////////// -// AutoreconfStepConfigWidget class -////////////////////////////////////// -/** - * @brief Implementation of the ProjectExplorer::BuildStepConfigWidget interface. - * - * Allows to configure a autoreconf step in the GUI.. - */ -class AutoreconfStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget -{ - Q_OBJECT - -public: - AutoreconfStepConfigWidget(AutoreconfStep *autoreconfStep); - - QString displayName() const override; - QString summaryText() const override; - -private: - void updateDetails(); - - AutoreconfStep *m_autoreconfStep; - QString m_summaryText; - QLineEdit *m_additionalArguments; -}; - } // namespace Internal } // namespace AutotoolsProjectManager diff --git a/src/plugins/autotoolsprojectmanager/autotoolsbuildconfiguration.cpp b/src/plugins/autotoolsprojectmanager/autotoolsbuildconfiguration.cpp index c4f90b83c1a..93f62323a13 100644 --- a/src/plugins/autotoolsprojectmanager/autotoolsbuildconfiguration.cpp +++ b/src/plugins/autotoolsprojectmanager/autotoolsbuildconfiguration.cpp @@ -74,29 +74,27 @@ void AutotoolsBuildConfiguration::initialize(const BuildInfo *info) // autogen.sh or autoreconf QFile autogenFile(target()->project()->projectDirectory().toString() + "/autogen.sh"); if (autogenFile.exists()) { - AutogenStep *autogenStep = new AutogenStep(buildSteps); - buildSteps->insertStep(0, autogenStep); + auto autogenStep = new AutogenStep(buildSteps); + buildSteps->appendStep(autogenStep); } else { - AutoreconfStep *autoreconfStep = new AutoreconfStep(buildSteps); - autoreconfStep->setAdditionalArguments("--force --install"); - buildSteps->insertStep(0, autoreconfStep); + auto autoreconfStep = new AutoreconfStep(buildSteps); + buildSteps->appendStep(autoreconfStep); } // ./configure. - ConfigureStep *configureStep = new ConfigureStep(buildSteps); - buildSteps->insertStep(1, configureStep); + auto configureStep = new ConfigureStep(buildSteps); + buildSteps->appendStep(configureStep); connect(this, &BuildConfiguration::buildDirectoryChanged, configureStep, &ConfigureStep::notifyBuildDirectoryChanged); // make - MakeStep *makeStep = new MakeStep(buildSteps, "all"); - buildSteps->insertStep(2, makeStep); + auto makeStep = new MakeStep(buildSteps); + buildSteps->appendStep(makeStep); // ### Build Steps Clean ### BuildStepList *cleanSteps = stepList(BUILDSTEPS_CLEAN); - MakeStep *cleanMakeStep = new MakeStep(cleanSteps, "clean"); - cleanMakeStep->setClean(true); - cleanSteps->insertStep(0, cleanMakeStep); + auto cleanMakeStep = new MakeStep(cleanSteps); + cleanSteps->appendStep(cleanMakeStep); } NamedWidget *AutotoolsBuildConfiguration::createConfigWidget() @@ -135,7 +133,7 @@ QList<BuildInfo *> AutotoolsBuildConfigurationFactory::availableSetups(const Kit BuildInfo *AutotoolsBuildConfigurationFactory::createBuildInfo(const Kit *k, const Utils::FileName &buildDir) const { - BuildInfo *info = new BuildInfo(this); + auto info = new BuildInfo(this); info->typeName = tr("Build"); info->buildDirectory = buildDir; info->kitId = k->id(); diff --git a/src/plugins/autotoolsprojectmanager/autotoolsbuildsettingswidget.cpp b/src/plugins/autotoolsprojectmanager/autotoolsbuildsettingswidget.cpp index cf136546c33..08eb39d7ee2 100644 --- a/src/plugins/autotoolsprojectmanager/autotoolsbuildsettingswidget.cpp +++ b/src/plugins/autotoolsprojectmanager/autotoolsbuildsettingswidget.cpp @@ -49,7 +49,7 @@ AutotoolsBuildSettingsWidget::AutotoolsBuildSettingsWidget(AutotoolsBuildConfigu m_pathChooser(new Utils::PathChooser), m_buildConfiguration(bc) { - QFormLayout *fl = new QFormLayout(this); + auto fl = new QFormLayout(this); fl->setContentsMargins(0, 0, 0, 0); fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); diff --git a/src/plugins/autotoolsprojectmanager/autotoolsopenprojectwizard.cpp b/src/plugins/autotoolsprojectmanager/autotoolsopenprojectwizard.cpp index 37a8d6fd927..cbfbe47173b 100644 --- a/src/plugins/autotoolsprojectmanager/autotoolsopenprojectwizard.cpp +++ b/src/plugins/autotoolsprojectmanager/autotoolsopenprojectwizard.cpp @@ -75,7 +75,7 @@ void AutotoolsOpenProjectWizard::setBuildDirectory(const QString &directory) BuildPathPage::BuildPathPage(AutotoolsOpenProjectWizard *w) : QWizardPage(w), m_pc(new Utils::PathChooser) { - QFormLayout *fl = new QFormLayout; + auto fl = new QFormLayout; this->setLayout(fl); QLabel *label = new QLabel(this); @@ -86,7 +86,7 @@ BuildPathPage::BuildPathPage(AutotoolsOpenProjectWizard *w) : QWizardPage(w), "with different settings.")); fl->addWidget(label); m_pc->setHistoryCompleter(QLatin1String("AutoTools.BuildDir.History")); - AutotoolsOpenProjectWizard *wiz = static_cast<AutotoolsOpenProjectWizard *>(wizard()); + auto wiz = static_cast<AutotoolsOpenProjectWizard *>(wizard()); m_pc->setBaseDirectory(wiz->sourceDirectory()); m_pc->setPath(wiz->buildDirectory()); connect(m_pc, &Utils::PathChooser::rawPathChanged, this, &BuildPathPage::buildDirectoryChanged); diff --git a/src/plugins/autotoolsprojectmanager/autotoolsopenprojectwizard.h b/src/plugins/autotoolsprojectmanager/autotoolsopenprojectwizard.h index ebd0a619e81..62eeab16d7b 100644 --- a/src/plugins/autotoolsprojectmanager/autotoolsopenprojectwizard.h +++ b/src/plugins/autotoolsprojectmanager/autotoolsopenprojectwizard.h @@ -41,7 +41,7 @@ class AutotoolsOpenProjectWizard : public Utils::Wizard public: enum PageId { BuildPathPageId }; - AutotoolsOpenProjectWizard(const QString &sourceDirectory, QWidget *parent = 0); + AutotoolsOpenProjectWizard(const QString &sourceDirectory, QWidget *parent = nullptr); QString buildDirectory() const; QString sourceDirectory() const; diff --git a/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp b/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp index fc4850b84fc..4ea59f07a86 100644 --- a/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp +++ b/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp @@ -127,7 +127,7 @@ void AutotoolsProject::loadProjectTree() this, &AutotoolsProject::makefileParsingFinished); m_makefileParserThread->wait(); delete m_makefileParserThread; - m_makefileParserThread = 0; + m_makefileParserThread = nullptr; } // Parse the makefile asynchronously in a thread diff --git a/src/plugins/autotoolsprojectmanager/configurestep.cpp b/src/plugins/autotoolsprojectmanager/configurestep.cpp index 5ae119553d7..50b7ca82e07 100644 --- a/src/plugins/autotoolsprojectmanager/configurestep.cpp +++ b/src/plugins/autotoolsprojectmanager/configurestep.cpp @@ -81,6 +81,12 @@ ConfigureStepFactory::ConfigureStepFactory() ConfigureStep::ConfigureStep(BuildStepList *bsl) : AbstractProcessStep(bsl, CONFIGURE_STEP_ID) { setDefaultDisplayName(tr("Configure")); + + m_additionalArgumentsAspect = addAspect<BaseStringAspect>(); + m_additionalArgumentsAspect->setDisplayStyle(BaseStringAspect::LineEditDisplay); + m_additionalArgumentsAspect->setSettingsKey(CONFIGURE_ADDITIONAL_ARGUMENTS_KEY); + m_additionalArgumentsAspect->setLabelText(tr("Arguments:")); + m_additionalArgumentsAspect->setHistoryCompleter("AutotoolsPM.History.ConfigureArgs"); } bool ConfigureStep::init(QList<const BuildStep *> &earlierSteps) @@ -92,7 +98,7 @@ bool ConfigureStep::init(QList<const BuildStep *> &earlierSteps) pp->setEnvironment(bc->environment()); pp->setWorkingDirectory(bc->buildDirectory().toString()); pp->setCommand(projectDirRelativeToBuildDir(bc) + "configure"); - pp->setArguments(additionalArguments()); + pp->setArguments(m_additionalArgumentsAspect->value()); pp->resolveAll(); return AbstractProcessStep::init(earlierSteps); @@ -124,95 +130,36 @@ void ConfigureStep::run(QFutureInterface<bool>& fi) BuildStepConfigWidget *ConfigureStep::createConfigWidget() { - return new ConfigureStepConfigWidget(this); -} - -bool ConfigureStep::immutable() const -{ - return false; -} + m_widget = AbstractProcessStep::createConfigWidget(); -void ConfigureStep::setAdditionalArguments(const QString &list) -{ - if (list == m_additionalArguments) - return; + updateDetails(); - m_additionalArguments = list; - m_runConfigure = true; + connect(m_additionalArgumentsAspect, &ProjectConfigurationAspect::changed, this, [this] { + m_runConfigure = true; + updateDetails(); + }); - emit additionalArgumentsChanged(list); + return m_widget.data(); } void ConfigureStep::notifyBuildDirectoryChanged() { - emit buildDirectoryChanged(); -} - -QString ConfigureStep::additionalArguments() const -{ - return m_additionalArguments; -} - -QVariantMap ConfigureStep::toMap() const -{ - QVariantMap map = AbstractProcessStep::toMap(); - - map.insert(CONFIGURE_ADDITIONAL_ARGUMENTS_KEY, m_additionalArguments); - return map; -} - -bool ConfigureStep::fromMap(const QVariantMap &map) -{ - m_additionalArguments = map.value(CONFIGURE_ADDITIONAL_ARGUMENTS_KEY).toString(); - - return BuildStep::fromMap(map); -} - -///////////////////////////////////// -// ConfigureStepConfigWidget class -///////////////////////////////////// -ConfigureStepConfigWidget::ConfigureStepConfigWidget(ConfigureStep *configureStep) : - m_configureStep(configureStep), - m_additionalArguments(new QLineEdit) -{ - QFormLayout *fl = new QFormLayout(this); - fl->setMargin(0); - fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); - setLayout(fl); - - fl->addRow(tr("Arguments:"), m_additionalArguments); - m_additionalArguments->setText(m_configureStep->additionalArguments()); - updateDetails(); - - connect(m_additionalArguments, &QLineEdit::textChanged, - configureStep, &ConfigureStep::setAdditionalArguments); - connect(configureStep, &ConfigureStep::additionalArgumentsChanged, - this, &ConfigureStepConfigWidget::updateDetails); - connect(configureStep, &ConfigureStep::buildDirectoryChanged, - this, &ConfigureStepConfigWidget::updateDetails); } -QString ConfigureStepConfigWidget::displayName() const +void ConfigureStep::updateDetails() { - return tr("Configure", "AutotoolsProjectManager::ConfigureStepConfigWidget display name."); -} - -QString ConfigureStepConfigWidget::summaryText() const -{ - return m_summaryText; -} + if (!m_widget) + return; -void ConfigureStepConfigWidget::updateDetails() -{ - BuildConfiguration *bc = m_configureStep->buildConfiguration(); + BuildConfiguration *bc = buildConfiguration(); ProcessParameters param; param.setMacroExpander(bc->macroExpander()); param.setEnvironment(bc->environment()); param.setWorkingDirectory(bc->buildDirectory().toString()); param.setCommand(projectDirRelativeToBuildDir(bc) + "configure"); - param.setArguments(m_configureStep->additionalArguments()); - m_summaryText = param.summaryInWorkdir(displayName()); - emit updateSummary(); + param.setArguments(m_additionalArgumentsAspect->value()); + + m_widget->setSummaryText(param.summaryInWorkdir(displayName())); } diff --git a/src/plugins/autotoolsprojectmanager/configurestep.h b/src/plugins/autotoolsprojectmanager/configurestep.h index 0ab97fbae36..59c6591b276 100644 --- a/src/plugins/autotoolsprojectmanager/configurestep.h +++ b/src/plugins/autotoolsprojectmanager/configurestep.h @@ -28,17 +28,11 @@ #pragma once #include <projectexplorer/abstractprocessstep.h> - -QT_BEGIN_NAMESPACE -class QLineEdit; -QT_END_NAMESPACE +#include <projectexplorer/projectconfigurationaspects.h> namespace AutotoolsProjectManager { namespace Internal { -class AutotoolsProject; -class ConfigureStepConfigWidget; - ////////////////////////////////// // ConfigureStepFactory Class ////////////////////////////////// @@ -69,8 +63,6 @@ public: class ConfigureStep : public ProjectExplorer::AbstractProcessStep { Q_OBJECT - friend class ConfigureStepFactory; - friend class ConfigureStepConfigWidget; public: explicit ConfigureStep(ProjectExplorer::BuildStepList *bsl); @@ -78,48 +70,16 @@ public: bool init(QList<const BuildStep *> &earlierSteps) override; void run(QFutureInterface<bool> &fi) override; ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override; - bool immutable() const override; - QString additionalArguments() const; - QVariantMap toMap() const override; void setAdditionalArguments(const QString &list); void notifyBuildDirectoryChanged(); -signals: - void additionalArgumentsChanged(const QString &); - void buildDirectoryChanged(); - -private: - bool fromMap(const QVariantMap &map) override; - - QString m_additionalArguments; - bool m_runConfigure = false; -}; - -///////////////////////////////////// -// ConfigureStepConfigWidget class -///////////////////////////////////// -/** - * @brief Implementation of the ProjectExplorer::BuildStepConfigWidget interface. - * - * Allows to configure a configure step in the GUI. - */ -class ConfigureStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget -{ - Q_OBJECT - -public: - ConfigureStepConfigWidget(ConfigureStep *configureStep); - - QString displayName() const override; - QString summaryText() const override; - private: void updateDetails(); - ConfigureStep *m_configureStep; - QString m_summaryText; - QLineEdit *m_additionalArguments; + ProjectExplorer::BaseStringAspect *m_additionalArgumentsAspect = nullptr; + bool m_runConfigure = false; + QPointer<ProjectExplorer::BuildStepConfigWidget> m_widget; }; } // namespace Internal diff --git a/src/plugins/autotoolsprojectmanager/makefileparser.cpp b/src/plugins/autotoolsprojectmanager/makefileparser.cpp index 9c3e32216b6..4587f7bacf3 100644 --- a/src/plugins/autotoolsprojectmanager/makefileparser.cpp +++ b/src/plugins/autotoolsprojectmanager/makefileparser.cpp @@ -56,7 +56,7 @@ bool MakefileParser::parse() m_sources.clear(); m_makefiles.clear(); - QFile *file = new QFile(m_makefile); + auto file = new QFile(m_makefile); if (!file->open(QIODevice::ReadOnly | QIODevice::Text)) { qWarning("%s: %s", qPrintable(m_makefile), qPrintable(file->errorString())); delete file; @@ -343,7 +343,7 @@ QStringList MakefileParser::directorySources(const QString &directory, QStringList MakefileParser::targetValues(bool *hasVariables) { QStringList values; - if (hasVariables != 0) + if (hasVariables) *hasVariables = false; const int index = m_line.indexOf(QLatin1Char('=')); @@ -366,7 +366,7 @@ QStringList MakefileParser::targetValues(bool *hasVariables) while (it != lineValues.end()) { if ((*it).startsWith(QLatin1String("$("))) { it = lineValues.erase(it); - if (hasVariables != 0) + if (hasVariables) *hasVariables = true; } else { ++it; @@ -400,9 +400,9 @@ QStringList MakefileParser::targetValues(bool *hasVariables) void MakefileParser::appendHeader(QStringList &list, const QDir &dir, const QString &fileName) { - const char *const headerExtensions[] = {".h", ".hh", ".hg", ".hxx", ".hpp", 0}; + const char *const headerExtensions[] = {".h", ".hh", ".hg", ".hxx", ".hpp", nullptr}; int i = 0; - while (headerExtensions[i] != 0) { + while (headerExtensions[i]) { const QString headerFile = fileName + QLatin1String(headerExtensions[i]); QFileInfo fileInfo(dir, headerFile); if (fileInfo.exists()) diff --git a/src/plugins/autotoolsprojectmanager/makefileparser.h b/src/plugins/autotoolsprojectmanager/makefileparser.h index d6387bc29c7..c9caec86aee 100644 --- a/src/plugins/autotoolsprojectmanager/makefileparser.h +++ b/src/plugins/autotoolsprojectmanager/makefileparser.h @@ -200,7 +200,7 @@ private: * contained a variable like $(test). Note that all variables are not * part of the return value, as they cannot get interpreted currently. */ - QStringList targetValues(bool *hasVariables = 0); + QStringList targetValues(bool *hasVariables = nullptr); /** * Adds recursively all sources of the current folder to m_sources and removes diff --git a/src/plugins/autotoolsprojectmanager/makefileparserthread.h b/src/plugins/autotoolsprojectmanager/makefileparserthread.h index 3e16bdccc44..fa300e8d352 100644 --- a/src/plugins/autotoolsprojectmanager/makefileparserthread.h +++ b/src/plugins/autotoolsprojectmanager/makefileparserthread.h @@ -56,7 +56,7 @@ public: MakefileParserThread(const QString &makefile); /** @see QThread::run() */ - void run(); + void run() override; /** * @return List of sources that are set for the _SOURCES target. diff --git a/src/plugins/autotoolsprojectmanager/makestep.cpp b/src/plugins/autotoolsprojectmanager/makestep.cpp index 315d235c9bb..f8f3fb2596f 100644 --- a/src/plugins/autotoolsprojectmanager/makestep.cpp +++ b/src/plugins/autotoolsprojectmanager/makestep.cpp @@ -43,27 +43,20 @@ const char MAKE_STEP_ID[] = "AutotoolsProjectManager.MakeStep"; MakeStepFactory::MakeStepFactory() { - struct Step : public MakeStep - { - Step(ProjectExplorer::BuildStepList *bsl) : MakeStep(bsl) - { - if (bsl->id() == ProjectExplorer::Constants::BUILDSTEPS_CLEAN) { - setBuildTarget("clean", true); - setClean(true); - } else { - setBuildTarget("all", true); - } - } - }; - - registerStep<Step>(MAKE_STEP_ID); + registerStep<MakeStep>(MAKE_STEP_ID); setDisplayName(ProjectExplorer::MakeStep::defaultDisplayName()); setSupportedProjectType(AUTOTOOLS_PROJECT_ID); } // MakeStep -MakeStep::MakeStep(ProjectExplorer::BuildStepList *bsl, const QString &buildTarget) - : ProjectExplorer::MakeStep(bsl, MAKE_STEP_ID, buildTarget, {"all", "clean"}) +MakeStep::MakeStep(ProjectExplorer::BuildStepList *bsl) + : ProjectExplorer::MakeStep(bsl, MAKE_STEP_ID, QString(), {"all", "clean"}) { + if (bsl->id() == ProjectExplorer::Constants::BUILDSTEPS_CLEAN) { + setBuildTarget("clean", true); + setClean(true); + } else { + setBuildTarget("all", true); + } } diff --git a/src/plugins/autotoolsprojectmanager/makestep.h b/src/plugins/autotoolsprojectmanager/makestep.h index f738fd10576..77bc2c0be23 100644 --- a/src/plugins/autotoolsprojectmanager/makestep.h +++ b/src/plugins/autotoolsprojectmanager/makestep.h @@ -49,7 +49,7 @@ class MakeStep : public ProjectExplorer::MakeStep Q_OBJECT public: - explicit MakeStep(ProjectExplorer::BuildStepList *bsl, const QString &buildTarget = QString()); + explicit MakeStep(ProjectExplorer::BuildStepList *bsl); }; } // namespace Internal diff --git a/src/plugins/baremetal/baremetaldevice.cpp b/src/plugins/baremetal/baremetaldevice.cpp index e482073021c..2f50336c79e 100644 --- a/src/plugins/baremetal/baremetaldevice.cpp +++ b/src/plugins/baremetal/baremetaldevice.cpp @@ -119,7 +119,7 @@ void BareMetalDevice::fromMap(const QVariantMap &map) gdbServerProvider = provider->id(); } else { const QSsh::SshConnectionParameters sshParams = sshParameters(); - DefaultGdbServerProvider *newProvider = new DefaultGdbServerProvider; + auto newProvider = new DefaultGdbServerProvider; newProvider->setDisplayName(name); newProvider->m_host = sshParams.host(); newProvider->m_port = sshParams.port(); diff --git a/src/plugins/baremetal/baremetaldevice.h b/src/plugins/baremetal/baremetaldevice.h index 1a2fdbe8c5d..c608bc8c4e5 100644 --- a/src/plugins/baremetal/baremetaldevice.h +++ b/src/plugins/baremetal/baremetaldevice.h @@ -36,15 +36,15 @@ class GdbServerProvider; class BareMetalDevice : public ProjectExplorer::IDevice { public: - typedef QSharedPointer<BareMetalDevice> Ptr; - typedef QSharedPointer<const BareMetalDevice> ConstPtr; + using Ptr = QSharedPointer<BareMetalDevice>; + using ConstPtr = QSharedPointer<const BareMetalDevice>; static Ptr create(); static Ptr create(const QString &name, Core::Id type, MachineType machineType, Origin origin = ManuallyAdded, Core::Id id = Core::Id()); static Ptr create(const BareMetalDevice &other); - ~BareMetalDevice(); + ~BareMetalDevice() override; QString displayType() const override; ProjectExplorer::IDeviceWidget *createWidget() override; QList<Core::Id> actionIds() const override; @@ -63,11 +63,11 @@ public: void unregisterProvider(GdbServerProvider *provider); void providerUpdated(GdbServerProvider *provider); - virtual void fromMap(const QVariantMap &map) override; - virtual QVariantMap toMap() const override; + void fromMap(const QVariantMap &map) override; + QVariantMap toMap() const override; protected: - BareMetalDevice() {} + BareMetalDevice() = default; BareMetalDevice(const QString &name, Core::Id type, MachineType machineType, Origin origin, Core::Id id); BareMetalDevice(const BareMetalDevice &other); diff --git a/src/plugins/baremetal/baremetaldeviceconfigurationfactory.cpp b/src/plugins/baremetal/baremetaldeviceconfigurationfactory.cpp index 6272450fdb3..b532a081a25 100644 --- a/src/plugins/baremetal/baremetaldeviceconfigurationfactory.cpp +++ b/src/plugins/baremetal/baremetaldeviceconfigurationfactory.cpp @@ -29,63 +29,30 @@ #include "baremetalconstants.h" #include "baremetaldevice.h" -#include <utils/icon.h> #include <utils/qtcassert.h> -#include <QIcon> - using namespace ProjectExplorer; namespace BareMetal { namespace Internal { BareMetalDeviceConfigurationFactory::BareMetalDeviceConfigurationFactory() + : IDeviceFactory(Constants::BareMetalOsType) { + setDisplayName(tr("Bare Metal Device")); + setCombinedIcon(":/baremetal/images/baremetaldevicesmall.png", + ":/baremetal/images/baremetaldevice.png"); + setCanCreate(true); + setConstructionFunction([] { return BareMetalDevice::create(); }); } -QString BareMetalDeviceConfigurationFactory::displayNameForId(Core::Id type) const -{ - return type == Constants::BareMetalOsType ? tr("Bare Metal Device") : QString(); -} - -QList<Core::Id> BareMetalDeviceConfigurationFactory::availableCreationIds() const -{ - return QList<Core::Id>() << Core::Id(Constants::BareMetalOsType); -} - -QIcon BareMetalDeviceConfigurationFactory::iconForId(Core::Id type) const -{ - Q_UNUSED(type) - using namespace Utils; - static const QIcon icon = - Icon::combinedIcon({Icon({{":/baremetal/images/baremetaldevicesmall.png", - Theme::PanelTextColorDark}}, Icon::Tint), - Icon({{":/baremetal/images/baremetaldevice.png", - Theme::IconsBaseColor}})}); - return icon; -} - -IDevice::Ptr BareMetalDeviceConfigurationFactory::create(Core::Id id) const +IDevice::Ptr BareMetalDeviceConfigurationFactory::create() const { - QTC_ASSERT(id == Constants::BareMetalOsType, return IDevice::Ptr()); BareMetalDeviceConfigurationWizard wizard; if (wizard.exec() != QDialog::Accepted) return IDevice::Ptr(); return wizard.device(); } -bool BareMetalDeviceConfigurationFactory::canRestore(const QVariantMap &map) const -{ - return IDevice::typeFromMap(map) == Constants::BareMetalOsType; -} - -IDevice::Ptr BareMetalDeviceConfigurationFactory::restore(const QVariantMap &map) const -{ - QTC_ASSERT(canRestore(map), return IDevice::Ptr()); - const IDevice::Ptr device = BareMetalDevice::create(); - device->fromMap(map); - return device; -} - } // namespace Internal } // namespace BareMetal diff --git a/src/plugins/baremetal/baremetaldeviceconfigurationfactory.h b/src/plugins/baremetal/baremetaldeviceconfigurationfactory.h index d5203bd6eee..5415491d90c 100644 --- a/src/plugins/baremetal/baremetaldeviceconfigurationfactory.h +++ b/src/plugins/baremetal/baremetaldeviceconfigurationfactory.h @@ -38,13 +38,7 @@ class BareMetalDeviceConfigurationFactory public: BareMetalDeviceConfigurationFactory(); - QString displayNameForId(Core::Id type) const; - QList<Core::Id> availableCreationIds() const; - QIcon iconForId(Core::Id type) const; - - ProjectExplorer::IDevice::Ptr create(Core::Id id) const; - bool canRestore(const QVariantMap &map) const; - ProjectExplorer::IDevice::Ptr restore(const QVariantMap &map) const; + ProjectExplorer::IDevice::Ptr create() const override; }; } // namespace Internal diff --git a/src/plugins/baremetal/baremetaldeviceconfigurationwidget.h b/src/plugins/baremetal/baremetaldeviceconfigurationwidget.h index 7c55b1aa00e..e56e7e76ced 100644 --- a/src/plugins/baremetal/baremetaldeviceconfigurationwidget.h +++ b/src/plugins/baremetal/baremetaldeviceconfigurationwidget.h @@ -40,11 +40,11 @@ class BareMetalDeviceConfigurationWidget public: explicit BareMetalDeviceConfigurationWidget( - const ProjectExplorer::IDevice::Ptr &deviceConfig, QWidget *parent = 0); + const ProjectExplorer::IDevice::Ptr &deviceConfig, QWidget *parent = nullptr); private: void gdbServerProviderChanged(); - void updateDeviceFromUi(); + void updateDeviceFromUi() override; GdbServerProviderChooser *m_gdbServerProviderChooser; }; diff --git a/src/plugins/baremetal/baremetaldeviceconfigurationwizard.h b/src/plugins/baremetal/baremetaldeviceconfigurationwizard.h index dd496590213..4663516fd96 100644 --- a/src/plugins/baremetal/baremetaldeviceconfigurationwizard.h +++ b/src/plugins/baremetal/baremetaldeviceconfigurationwizard.h @@ -38,7 +38,7 @@ class BareMetalDeviceConfigurationWizard : public Utils::Wizard Q_OBJECT public: - BareMetalDeviceConfigurationWizard(QWidget *parent = 0); + BareMetalDeviceConfigurationWizard(QWidget *parent = nullptr); ProjectExplorer::IDevice::Ptr device() const; diff --git a/src/plugins/baremetal/baremetaldeviceconfigurationwizardpages.h b/src/plugins/baremetal/baremetaldeviceconfigurationwizardpages.h index af61c11d651..f47c8a79e9e 100644 --- a/src/plugins/baremetal/baremetaldeviceconfigurationwizardpages.h +++ b/src/plugins/baremetal/baremetaldeviceconfigurationwizardpages.h @@ -42,10 +42,10 @@ class BareMetalDeviceConfigurationWizardSetupPage : public QWizardPage Q_OBJECT public: - explicit BareMetalDeviceConfigurationWizardSetupPage(QWidget *parent = 0); + explicit BareMetalDeviceConfigurationWizardSetupPage(QWidget *parent = nullptr); - void initializePage(); - bool isComplete() const; + void initializePage() override; + bool isComplete() const override; QString configurationName() const; QString gdbServerProviderId() const; diff --git a/src/plugins/baremetal/baremetalgdbcommandsdeploystep.cpp b/src/plugins/baremetal/baremetalgdbcommandsdeploystep.cpp index 8affd8d6593..8e8015280bc 100644 --- a/src/plugins/baremetal/baremetalgdbcommandsdeploystep.cpp +++ b/src/plugins/baremetal/baremetalgdbcommandsdeploystep.cpp @@ -35,9 +35,9 @@ namespace Internal { const char GdbCommandsKey[] = "BareMetal.GdbCommandsStep.Commands"; BareMetalGdbCommandsDeployStepWidget::BareMetalGdbCommandsDeployStepWidget(BareMetalGdbCommandsDeployStep &step) - : m_step(step) + : BuildStepConfigWidget(&step), m_step(step) { - QFormLayout *fl = new QFormLayout(this); + auto fl = new QFormLayout(this); fl->setMargin(0); fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); setLayout(fl); @@ -66,6 +66,7 @@ BareMetalGdbCommandsDeployStep::BareMetalGdbCommandsDeployStep(BuildStepList *bs : BuildStep(bsl, stepId()) { setDefaultDisplayName(displayName()); + setRunInGuiThread(true); } void BareMetalGdbCommandsDeployStep::run(QFutureInterface<bool> &fi) diff --git a/src/plugins/baremetal/baremetalgdbcommandsdeploystep.h b/src/plugins/baremetal/baremetalgdbcommandsdeploystep.h index 83a21913692..e78a238387d 100644 --- a/src/plugins/baremetal/baremetalgdbcommandsdeploystep.h +++ b/src/plugins/baremetal/baremetalgdbcommandsdeploystep.h @@ -42,7 +42,6 @@ public: bool init(QList<const BuildStep *> &earlierSteps) override; void run(QFutureInterface<bool> &fi) override; - bool runInGuiThread() const override { return true;} bool fromMap(const QVariantMap &map) override; QVariantMap toMap() const override; diff --git a/src/plugins/baremetal/defaultgdbserverprovider.cpp b/src/plugins/baremetal/defaultgdbserverprovider.cpp index 567b9369189..10ade873960 100644 --- a/src/plugins/baremetal/defaultgdbserverprovider.cpp +++ b/src/plugins/baremetal/defaultgdbserverprovider.cpp @@ -47,12 +47,7 @@ DefaultGdbServerProvider::DefaultGdbServerProvider() { } -DefaultGdbServerProvider::DefaultGdbServerProvider(const DefaultGdbServerProvider &other) - : GdbServerProvider(other) - , m_host(other.m_host) - , m_port(other.m_port) -{ -} +DefaultGdbServerProvider::DefaultGdbServerProvider(const DefaultGdbServerProvider &other) = default; quint16 DefaultGdbServerProvider::port() const { @@ -162,7 +157,7 @@ GdbServerProvider *DefaultGdbServerProviderFactory::restore(const QVariantMap &d if (p->fromMap(updated)) return p; delete p; - return 0; + return nullptr; } DefaultGdbServerProviderConfigWidget::DefaultGdbServerProviderConfigWidget( diff --git a/src/plugins/baremetal/gdbserverprovider.cpp b/src/plugins/baremetal/gdbserverprovider.cpp index 179a207a6cb..cf633d86024 100644 --- a/src/plugins/baremetal/gdbserverprovider.cpp +++ b/src/plugins/baremetal/gdbserverprovider.cpp @@ -229,7 +229,7 @@ QString GdbServerProviderFactory::idFromMap(const QVariantMap &data) return data.value(QLatin1String(idKeyC)).toString(); } -void GdbServerProviderFactory::idToMap(QVariantMap &data, const QString id) +void GdbServerProviderFactory::idToMap(QVariantMap &data, const QString &id) { data.insert(QLatin1String(idKeyC), id); } diff --git a/src/plugins/baremetal/gdbserverprovider.h b/src/plugins/baremetal/gdbserverprovider.h index eabac0fa292..8ca0777ea74 100644 --- a/src/plugins/baremetal/gdbserverprovider.h +++ b/src/plugins/baremetal/gdbserverprovider.h @@ -126,7 +126,7 @@ public: virtual GdbServerProvider *restore(const QVariantMap &data) = 0; static QString idFromMap(const QVariantMap &data); - static void idToMap(QVariantMap &data, const QString id); + static void idToMap(QVariantMap &data, const QString &id); protected: void setId(const QString &id); @@ -174,7 +174,7 @@ private: void setFromProvider(); GdbServerProvider *m_provider; - QLabel *m_errorLabel = 0; + QLabel *m_errorLabel = nullptr; }; class HostWidget : public QWidget @@ -182,7 +182,7 @@ class HostWidget : public QWidget Q_OBJECT public: - explicit HostWidget(QWidget *parent = 0); + explicit HostWidget(QWidget *parent = nullptr); void setHost(const QString &host); QString host() const; diff --git a/src/plugins/baremetal/gdbserverproviderchooser.h b/src/plugins/baremetal/gdbserverproviderchooser.h index 424d89201e2..c2827921cac 100644 --- a/src/plugins/baremetal/gdbserverproviderchooser.h +++ b/src/plugins/baremetal/gdbserverproviderchooser.h @@ -45,7 +45,7 @@ class GdbServerProviderChooser : public QWidget public: explicit GdbServerProviderChooser( - bool useManageButton = true, QWidget *parent = 0); + bool useManageButton = true, QWidget *parent = nullptr); QString currentProviderId() const; void setCurrentProviderId(const QString &id); diff --git a/src/plugins/baremetal/gdbserverprovidermanager.cpp b/src/plugins/baremetal/gdbserverprovidermanager.cpp index 0af2d0d94a9..e08b9bb30f1 100644 --- a/src/plugins/baremetal/gdbserverprovidermanager.cpp +++ b/src/plugins/baremetal/gdbserverprovidermanager.cpp @@ -48,7 +48,7 @@ const char countKeyC[] = "GdbServerProvider.Count"; const char fileVersionKeyC[] = "Version"; const char fileNameKeyC[] = "/gdbserverproviders.xml"; -static GdbServerProviderManager *m_instance = 0; +static GdbServerProviderManager *m_instance = nullptr; GdbServerProviderManager::GdbServerProviderManager() : m_configFile(Utils::FileName::fromString(Core::ICore::userResourcePath() + fileNameKeyC)) @@ -76,7 +76,7 @@ GdbServerProviderManager::~GdbServerProviderManager() qDeleteAll(m_providers); m_providers.clear(); delete m_writer; - m_instance = 0; + m_instance = nullptr; } GdbServerProviderManager *GdbServerProviderManager::instance() @@ -154,7 +154,7 @@ QList<GdbServerProviderFactory *> GdbServerProviderManager::factories() GdbServerProvider *GdbServerProviderManager::findProvider(const QString &id) { if (id.isEmpty() || !m_instance) - return 0; + return nullptr; return Utils::findOrDefault(m_instance->m_providers, Utils::equal(&GdbServerProvider::id, id)); } @@ -162,7 +162,7 @@ GdbServerProvider *GdbServerProviderManager::findProvider(const QString &id) GdbServerProvider *GdbServerProviderManager::findByDisplayName(const QString &displayName) { if (displayName.isEmpty()) - return 0; + return nullptr; return Utils::findOrDefault(m_instance->m_providers, Utils::equal(&GdbServerProvider::displayName, displayName)); diff --git a/src/plugins/baremetal/gdbserverprovidermanager.h b/src/plugins/baremetal/gdbserverprovidermanager.h index a26c5bfe13f..8a6ed109bac 100644 --- a/src/plugins/baremetal/gdbserverprovidermanager.h +++ b/src/plugins/baremetal/gdbserverprovidermanager.h @@ -46,7 +46,7 @@ class GdbServerProviderManager : public QObject public: static GdbServerProviderManager *instance(); - ~GdbServerProviderManager(); + ~GdbServerProviderManager() override; static QList<GdbServerProvider *> providers(); static QList<GdbServerProviderFactory *> factories(); diff --git a/src/plugins/baremetal/gdbserverproviderprocess.h b/src/plugins/baremetal/gdbserverproviderprocess.h index 4065ec5d10e..8640db5aef1 100644 --- a/src/plugins/baremetal/gdbserverproviderprocess.h +++ b/src/plugins/baremetal/gdbserverproviderprocess.h @@ -38,7 +38,7 @@ class GdbServerProviderProcess : public ProjectExplorer::DeviceProcess public: explicit GdbServerProviderProcess( const QSharedPointer<const ProjectExplorer::IDevice> &device, - QObject *parent = 0); + QObject *parent = nullptr); void start(const ProjectExplorer::Runnable &runnable) override; void interrupt() override; diff --git a/src/plugins/baremetal/gdbserverproviderssettingspage.cpp b/src/plugins/baremetal/gdbserverproviderssettingspage.cpp index 3eb43c89118..60af0a9d2b9 100644 --- a/src/plugins/baremetal/gdbserverproviderssettingspage.cpp +++ b/src/plugins/baremetal/gdbserverproviderssettingspage.cpp @@ -105,13 +105,13 @@ GdbServerProvider *GdbServerProviderModel::provider(const QModelIndex &index) co if (GdbServerProviderNode *node = nodeForIndex(index)) return node->provider; - return 0; + return nullptr; } GdbServerProviderNode *GdbServerProviderModel::nodeForIndex(const QModelIndex &index) const { if (!index.isValid()) - return 0; + return nullptr; return static_cast<GdbServerProviderNode *>(itemForIndex(index)); } @@ -316,7 +316,7 @@ GdbServerProvidersSettingsWidget::GdbServerProvidersSettingsWidget addMenu->addAction(action); } - connect(m_cloneButton, &QAbstractButton::clicked, this, [this] { createProvider(0); }); + connect(m_cloneButton, &QAbstractButton::clicked, this, [this] { createProvider(nullptr); }); m_addButton->setMenu(addMenu); @@ -336,15 +336,15 @@ void GdbServerProvidersSettingsWidget::providerSelectionChanged() w->setVisible(false); GdbServerProviderNode *node = m_model.nodeForIndex(current); - w = node ? node->widget : 0; + w = node ? node->widget : nullptr; m_container->setWidget(w); - m_container->setVisible(w != 0); + m_container->setVisible(w != nullptr); updateState(); } void GdbServerProvidersSettingsWidget::createProvider(GdbServerProviderFactory *f) { - GdbServerProvider *provider = 0; + GdbServerProvider *provider = nullptr; if (!f) { GdbServerProvider *old = m_model.provider(currentIndex()); if (!old) @@ -427,7 +427,7 @@ void GdbServerProvidersSettingsPage::finish() m_configWidget, &GdbServerProvidersSettingsWidget::providerSelectionChanged); delete m_configWidget; - m_configWidget = 0; + m_configWidget = nullptr; } } // namespace Internal diff --git a/src/plugins/baremetal/gdbserverproviderssettingspage.h b/src/plugins/baremetal/gdbserverproviderssettingspage.h index 28c5bc3b4c1..d1b6119fd9b 100644 --- a/src/plugins/baremetal/gdbserverproviderssettingspage.h +++ b/src/plugins/baremetal/gdbserverproviderssettingspage.h @@ -86,9 +86,9 @@ public: explicit GdbServerProvidersSettingsPage(QObject *parent = nullptr); private: - QWidget *widget(); - void apply(); - void finish(); + QWidget *widget() override; + void apply() override; + void finish() override; GdbServerProvidersSettingsWidget *m_configWidget = nullptr; }; diff --git a/src/plugins/baremetal/openocdgdbserverprovider.cpp b/src/plugins/baremetal/openocdgdbserverprovider.cpp index 0e21b9d0b3c..33d05c88a2a 100644 --- a/src/plugins/baremetal/openocdgdbserverprovider.cpp +++ b/src/plugins/baremetal/openocdgdbserverprovider.cpp @@ -63,16 +63,7 @@ OpenOcdGdbServerProvider::OpenOcdGdbServerProvider() } OpenOcdGdbServerProvider::OpenOcdGdbServerProvider( - const OpenOcdGdbServerProvider &other) - : GdbServerProvider(other) - , m_host(other.m_host) - , m_port(other.m_port) - , m_executableFile(other.m_executableFile) - , m_rootScriptsDir(other.m_rootScriptsDir) - , m_configurationFile(other.m_configurationFile) - , m_additionalArguments(other.m_additionalArguments) -{ -} + const OpenOcdGdbServerProvider &other) = default; QString OpenOcdGdbServerProvider::defaultInitCommands() { @@ -246,7 +237,7 @@ GdbServerProvider *OpenOcdGdbServerProviderFactory::restore(const QVariantMap &d if (p->fromMap(updated)) return p; delete p; - return 0; + return nullptr; } OpenOcdGdbServerProviderConfigWidget::OpenOcdGdbServerProviderConfigWidget( diff --git a/src/plugins/baremetal/stlinkutilgdbserverprovider.cpp b/src/plugins/baremetal/stlinkutilgdbserverprovider.cpp index ada59255fd0..146f826e26a 100644 --- a/src/plugins/baremetal/stlinkutilgdbserverprovider.cpp +++ b/src/plugins/baremetal/stlinkutilgdbserverprovider.cpp @@ -238,7 +238,7 @@ GdbServerProvider *StLinkUtilGdbServerProviderFactory::restore(const QVariantMap if (p->fromMap(updated)) return p; delete p; - return 0; + return nullptr; } StLinkUtilGdbServerProviderConfigWidget::StLinkUtilGdbServerProviderConfigWidget( diff --git a/src/plugins/bineditor/bineditorplugin.cpp b/src/plugins/bineditor/bineditorplugin.cpp index 58a317d761a..7ca01958d04 100644 --- a/src/plugins/bineditor/bineditorplugin.cpp +++ b/src/plugins/bineditor/bineditorplugin.cpp @@ -148,7 +148,7 @@ public: } else { result = NotFound; m_contPos = -1; - m_widget->highlightSearchResults(QByteArray(), 0); + m_widget->highlightSearchResults(QByteArray(), nullptr); } } return result; @@ -313,7 +313,7 @@ public: void provideNewRange(quint64 offset) { if (filePath().exists()) - openImpl(0, filePath().toString(), offset); + openImpl(nullptr, filePath().toString(), offset); } public: @@ -404,13 +404,13 @@ private: } void jumpToAddress() { - editorWidget()->jumpToAddress(m_addressEdit->text().toULongLong(0, 16)); + editorWidget()->jumpToAddress(m_addressEdit->text().toULongLong(nullptr, 16)); updateCursorPosition(editorWidget()->cursorPosition()); } BinEditorWidget *editorWidget() const { - QTC_ASSERT(qobject_cast<BinEditorWidget *>(m_widget.data()), return 0); + QTC_ASSERT(qobject_cast<BinEditorWidget *>(m_widget.data()), return nullptr); return static_cast<BinEditorWidget *>(m_widget.data()); } @@ -426,7 +426,7 @@ class BinEditorPluginPrivate : public QObject { public: BinEditorPluginPrivate(); - ~BinEditorPluginPrivate(); + ~BinEditorPluginPrivate() override; QAction *m_undoAction = nullptr; QAction *m_redoAction = nullptr; @@ -511,7 +511,7 @@ EditorService *FactoryServiceImpl::createEditorService(const QString &title0, bo IEditor *editor = EditorManager::openEditorWithContents( Core::Constants::K_DEFAULT_BINARY_EDITOR_ID, &title); if (!editor) - return 0; + return nullptr; widget = qobject_cast<BinEditorWidget *>(editor->widget()); widget->setEditor(editor); } else { diff --git a/src/plugins/bineditor/bineditorplugin.h b/src/plugins/bineditor/bineditorplugin.h index 8c893a46379..8db7761c2cb 100644 --- a/src/plugins/bineditor/bineditorplugin.h +++ b/src/plugins/bineditor/bineditorplugin.h @@ -39,8 +39,8 @@ class BinEditorPlugin : public ExtensionSystem::IPlugin Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "BinEditor.json") public: - BinEditorPlugin() {} - ~BinEditorPlugin(); + BinEditorPlugin() = default; + ~BinEditorPlugin() override; bool initialize(const QStringList &arguments, QString *errorMessage) final; void extensionsInitialized() final {} diff --git a/src/plugins/bineditor/bineditorservice.h b/src/plugins/bineditor/bineditorservice.h index 5a68907e030..19480816d29 100644 --- a/src/plugins/bineditor/bineditorservice.h +++ b/src/plugins/bineditor/bineditorservice.h @@ -40,7 +40,7 @@ namespace BinEditor { class EditorService { public: - virtual ~EditorService() {} + virtual ~EditorService() = default; virtual QWidget *widget() = 0; virtual Core::IEditor *editor() = 0; @@ -70,7 +70,7 @@ public: class FactoryService { public: - virtual ~FactoryService() {} + virtual ~FactoryService() = default; // Create a BinEditor widget. Embed into a Core::IEditor iff wantsEditor == true. virtual EditorService *createEditorService(const QString &title, bool wantsEditor) = 0; diff --git a/src/plugins/bineditor/bineditorwidget.cpp b/src/plugins/bineditor/bineditorwidget.cpp index bc942c708d9..b27fc5de78b 100644 --- a/src/plugins/bineditor/bineditorwidget.cpp +++ b/src/plugins/bineditor/bineditorwidget.cpp @@ -1591,6 +1591,8 @@ void BinEditorWidget::contextMenuEvent(QContextMenuEvent *event) auto copyAsciiAction = new QAction(tr("Copy Selection as ASCII Characters"), contextMenu); auto copyHexAction = new QAction(tr("Copy Selection as Hex Values"), contextMenu); + auto copyBeValue = new QAction(contextMenu); + auto copyLeValue = new QAction(contextMenu); auto jumpToBeAddressHereAction = new QAction(contextMenu); auto jumpToBeAddressNewWindowAction = new QAction(contextMenu); auto jumpToLeAddressHereAction = new QAction(contextMenu); @@ -1606,10 +1608,16 @@ void BinEditorWidget::contextMenuEvent(QContextMenuEvent *event) quint64 leAddress = 0; if (byteCount <= 8) { asIntegers(selStart, byteCount, beAddress, leAddress); + copyBeValue->setText(tr("Copy 0x%1").arg(QString::number(beAddress, 16))); + contextMenu->addAction(copyBeValue); + // If the menu entries would be identical, show only one of them. + if (beAddress != leAddress) { + copyLeValue->setText(tr("Copy 0x%1").arg(QString::number(leAddress, 16))); + contextMenu->addAction(copyLeValue); + } setupJumpToMenuAction(contextMenu, jumpToBeAddressHereAction, jumpToBeAddressNewWindowAction, beAddress); - // If the menu entries would be identical, show only one of them. if (beAddress != leAddress) { setupJumpToMenuAction(contextMenu, jumpToLeAddressHereAction, jumpToLeAddressNewWindowAction, leAddress); @@ -1617,8 +1625,11 @@ void BinEditorWidget::contextMenuEvent(QContextMenuEvent *event) } else { jumpToBeAddressHereAction->setText(tr("Jump to Address in This Window")); jumpToBeAddressNewWindowAction->setText(tr("Jump to Address in New Window")); + copyBeValue->setText(tr("Copy value")); jumpToBeAddressHereAction->setEnabled(false); jumpToBeAddressNewWindowAction->setEnabled(false); + copyBeValue->setEnabled(false); + contextMenu->addAction(copyBeValue); contextMenu->addAction(jumpToBeAddressHereAction); contextMenu->addAction(jumpToBeAddressNewWindowAction); } @@ -1631,6 +1642,10 @@ void BinEditorWidget::contextMenuEvent(QContextMenuEvent *event) copy(true); else if (action == copyHexAction) copy(false); + else if (action == copyBeValue) + QApplication::clipboard()->setText("0x" + QString::number(beAddress, 16)); + else if (action == copyLeValue) + QApplication::clipboard()->setText("0x" + QString::number(leAddress, 16)); else if (action == jumpToBeAddressHereAction) jumpToAddress(beAddress); else if (action == jumpToLeAddressHereAction) diff --git a/src/plugins/bineditor/bineditorwidget.h b/src/plugins/bineditor/bineditorwidget.h index ce02c937932..c44dbb4c8c2 100644 --- a/src/plugins/bineditor/bineditorwidget.h +++ b/src/plugins/bineditor/bineditorwidget.h @@ -62,8 +62,8 @@ class BinEditorWidget : public QAbstractScrollArea Q_PROPERTY(bool newWindowRequestAllowed READ newWindowRequestAllowed WRITE setNewWindowRequestAllowed DESIGNABLE false) public: - BinEditorWidget(QWidget *parent = 0); - ~BinEditorWidget(); + BinEditorWidget(QWidget *parent = nullptr); + ~BinEditorWidget() override; EditorService *editorService() const; @@ -98,7 +98,7 @@ public: bool isReadOnly() const; int find(const QByteArray &pattern, qint64 from = 0, - QTextDocument::FindFlags findFlags = 0); + QTextDocument::FindFlags findFlags = nullptr); void selectAll(); void clear(); @@ -112,7 +112,7 @@ public: int selectionStart() const { return qMin(m_anchorPosition, m_cursorPosition); } int selectionEnd() const { return qMax(m_anchorPosition, m_cursorPosition); } - bool event(QEvent*); + bool event(QEvent*) override; bool isUndoAvailable() const { return m_undoStack.size(); } bool isRedoAvailable() const { return m_redoStack.size(); } @@ -125,7 +125,7 @@ public: void setFontSettings(const TextEditor::FontSettings &fs); void highlightSearchResults(const QByteArray &pattern, - QTextDocument::FindFlags findFlags = 0); + QTextDocument::FindFlags findFlags = nullptr); void copy(bool raw = false); void setMarkup(const QList<Markup> &markup); void setNewWindowRequestAllowed(bool c); @@ -137,24 +137,24 @@ signals: void cursorPositionChanged(int position); private: - void scrollContentsBy(int dx, int dy); - void paintEvent(QPaintEvent *e); - void resizeEvent(QResizeEvent *); - void changeEvent(QEvent *); - void wheelEvent(QWheelEvent *e); - void mousePressEvent(QMouseEvent *e); - void mouseMoveEvent(QMouseEvent *e); - void mouseReleaseEvent(QMouseEvent *e); - void keyPressEvent(QKeyEvent *e); - void focusInEvent(QFocusEvent *); - void focusOutEvent(QFocusEvent *); - void timerEvent(QTimerEvent *); - void contextMenuEvent(QContextMenuEvent *event); + void scrollContentsBy(int dx, int dy) override; + void paintEvent(QPaintEvent *e) override; + void resizeEvent(QResizeEvent *) override; + void changeEvent(QEvent *) override; + void wheelEvent(QWheelEvent *e) override; + void mousePressEvent(QMouseEvent *e) override; + void mouseMoveEvent(QMouseEvent *e) override; + void mouseReleaseEvent(QMouseEvent *e) override; + void keyPressEvent(QKeyEvent *e) override; + void focusInEvent(QFocusEvent *) override; + void focusOutEvent(QFocusEvent *) override; + void timerEvent(QTimerEvent *) override; + void contextMenuEvent(QContextMenuEvent *event) override; friend class BinEditorWidgetPrivate; BinEditorWidgetPrivate *d; - typedef QMap<qint64, QByteArray> BlockMap; + using BlockMap = QMap<qint64, QByteArray>; BlockMap m_data; BlockMap m_oldData; int m_blockSize; diff --git a/src/plugins/bookmarks/bookmarkmanager.cpp b/src/plugins/bookmarks/bookmarkmanager.cpp index 8516ea31890..81795057717 100644 --- a/src/plugins/bookmarks/bookmarkmanager.cpp +++ b/src/plugins/bookmarks/bookmarkmanager.cpp @@ -426,7 +426,7 @@ void BookmarkManager::toggleBookmark(const FileName &fileName, int lineNumber) } // Add a new bookmark if no bookmark existed on this line - Bookmark *mark = new Bookmark(lineNumber, this); + auto mark = new Bookmark(lineNumber, this); mark->updateFileName(fileName); const QModelIndex currentIndex = selectionModel()->currentIndex(); const int insertionIndex = currentIndex.isValid() ? currentIndex.row() + 1 @@ -749,7 +749,7 @@ void BookmarkManager::addBookmark(const QString &s) const QString ¬e = s.mid(index3 + 1); const int lineNumber = s.midRef(index2 + 1, index3 - index2 - 1).toInt(); if (!filePath.isEmpty() && !findBookmark(FileName::fromString(filePath), lineNumber)) { - Bookmark *b = new Bookmark(lineNumber, this); + auto b = new Bookmark(lineNumber, this); b->updateFileName(FileName::fromString(filePath)); b->setNote(note); addBookmark(b, false); diff --git a/src/plugins/bookmarks/bookmarksplugin.h b/src/plugins/bookmarks/bookmarksplugin.h index ee4c7d0b515..348bbd2328b 100644 --- a/src/plugins/bookmarks/bookmarksplugin.h +++ b/src/plugins/bookmarks/bookmarksplugin.h @@ -38,14 +38,14 @@ class BookmarksPlugin : public ExtensionSystem::IPlugin Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Bookmarks.json") public: - BookmarksPlugin() {} + BookmarksPlugin() = default; ~BookmarksPlugin() final; private: bool initialize(const QStringList &arguments, QString *errorMessage) final; void extensionsInitialized() final {} - BookmarksPluginRunData *m_runData; + BookmarksPluginRunData *m_runData = nullptr; }; } // namespace Internal diff --git a/src/plugins/clangpchmanager/clangpchmanager-source.pri b/src/plugins/clangpchmanager/clangpchmanager-source.pri index 27e35dc7409..c0eb7ba90a4 100644 --- a/src/plugins/clangpchmanager/clangpchmanager-source.pri +++ b/src/plugins/clangpchmanager/clangpchmanager-source.pri @@ -12,7 +12,9 @@ HEADERS += \ $$PWD/pchmanagerconnectionclient.h \ $$PWD/clangpchmanager_global.h \ $$PWD/projectupdater.h \ - $$PWD/pchmanagerprojectupdater.h + $$PWD/pchmanagerprojectupdater.h \ + $$PWD/progressmanager.h \ + $$PWD/progressmanagerinterface.h SOURCES += \ $$PWD/pchmanagerclient.cpp \ diff --git a/src/plugins/clangpchmanager/clangpchmanager.pro b/src/plugins/clangpchmanager/clangpchmanager.pro index 204f740a28c..e222ffd3d46 100644 --- a/src/plugins/clangpchmanager/clangpchmanager.pro +++ b/src/plugins/clangpchmanager/clangpchmanager.pro @@ -13,6 +13,7 @@ win32 { HEADERS += \ $$PWD/clangpchmanagerplugin.h \ qtcreatorprojectupdater.h + SOURCES += \ $$PWD/clangpchmanagerplugin.cpp \ qtcreatorprojectupdater.cpp diff --git a/src/plugins/clangpchmanager/clangpchmanagerplugin.cpp b/src/plugins/clangpchmanager/clangpchmanagerplugin.cpp index 098faf50b31..90ba8f62bc0 100644 --- a/src/plugins/clangpchmanager/clangpchmanagerplugin.cpp +++ b/src/plugins/clangpchmanager/clangpchmanagerplugin.cpp @@ -27,6 +27,7 @@ #include "pchmanagerconnectionclient.h" #include "pchmanagerclient.h" +#include "progressmanager.h" #include "qtcreatorprojectupdater.h" #include <filepathcaching.h> @@ -34,10 +35,13 @@ #include <sqlitedatabase.h> #include <coreplugin/icore.h> +#include <coreplugin/progressmanager/progressmanager.h> #include <extensionsystem/pluginmanager.h> #include <utils/hostosinfo.h> +#include <QFutureInterface> + #include <chrono> using namespace std::chrono_literals; @@ -61,7 +65,12 @@ public: Sqlite::Database database{Utils::PathString{Core::ICore::userResourcePath() + "/symbol-experimental-v1.db"}, 1000ms}; ClangBackEnd::RefactoringDatabaseInitializer<Sqlite::Database> databaseInitializer{database}; ClangBackEnd::FilePathCaching filePathCache{database}; - PchManagerClient pchManagerClient; + ClangPchManager::ProgressManager progressManager{ + [] (QFutureInterface<void> &promise) { + auto title = QCoreApplication::translate("ClangPchProgressManager", "Creating PCHs", "PCH stands for precompiled header"); + Core::ProgressManager::addTask(promise.future(), title, "pch creation", nullptr); + }}; + PchManagerClient pchManagerClient{progressManager}; PchManagerConnectionClient connectionClient{&pchManagerClient}; QtCreatorProjectUpdater<PchManagerProjectUpdater> projectUpdate{connectionClient.serverProxy(), pchManagerClient, diff --git a/src/plugins/clangpchmanager/pchmanagerclient.cpp b/src/plugins/clangpchmanager/pchmanagerclient.cpp index 81af53308e5..56e64b2b56f 100644 --- a/src/plugins/clangpchmanager/pchmanagerclient.cpp +++ b/src/plugins/clangpchmanager/pchmanagerclient.cpp @@ -26,8 +26,9 @@ #include "pchmanagerclient.h" #include <precompiledheadersupdatedmessage.h> +#include <progressmanagerinterface.h> +#include <progressmessage.h> #include <pchmanagerconnectionclient.h> - #include <pchmanagernotifierinterface.h> #include <algorithm> @@ -50,6 +51,11 @@ void PchManagerClient::precompiledHeadersUpdated(ClangBackEnd::PrecompiledHeader } } +void PchManagerClient::progress(ClangBackEnd::ProgressMessage &&message) +{ + m_progressManager.setProgress(message.progress, message.total); +} + void PchManagerClient::precompiledHeaderRemoved(const QString &projectPartId) { for (auto notifier : m_notifiers) { diff --git a/src/plugins/clangpchmanager/pchmanagerclient.h b/src/plugins/clangpchmanager/pchmanagerclient.h index 92c44465f23..d7c0b68f713 100644 --- a/src/plugins/clangpchmanager/pchmanagerclient.h +++ b/src/plugins/clangpchmanager/pchmanagerclient.h @@ -34,7 +34,7 @@ namespace ClangPchManager { class PchManagerConnectionClient; - +class ProgressManagerInterface; class PchManagerNotifierInterface; class CLANGPCHMANAGER_EXPORT PchManagerClient final : public ClangBackEnd::PchManagerClientInterface, @@ -42,9 +42,13 @@ class CLANGPCHMANAGER_EXPORT PchManagerClient final : public ClangBackEnd::PchMa { friend class PchManagerNotifierInterface; public: - PchManagerClient() = default; + PchManagerClient(ProgressManagerInterface &progressManager) + : m_progressManager(progressManager) + {} + void alive() override; void precompiledHeadersUpdated(ClangBackEnd::PrecompiledHeadersUpdatedMessage &&message) override; + void progress(ClangBackEnd::ProgressMessage &&message) override; void precompiledHeaderRemoved(const QString &projectPartId); @@ -74,6 +78,7 @@ private: ClangBackEnd::ProjectPartPchs m_projectPartPchs; std::vector<PchManagerNotifierInterface*> m_notifiers; PchManagerConnectionClient *m_connectionClient=nullptr; + ProgressManagerInterface &m_progressManager; }; } // namespace ClangPchManager diff --git a/src/plugins/cpaster/pastebindotcaprotocol.h b/src/plugins/clangpchmanager/progressmanager.h index b46b8fcfbea..cc6ab1946cb 100644 --- a/src/plugins/cpaster/pastebindotcaprotocol.h +++ b/src/plugins/clangpchmanager/progressmanager.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2018 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of Qt Creator. @@ -25,41 +25,60 @@ #pragma once -#include "protocol.h" +#include "progressmanagerinterface.h" -namespace CodePaster { -class PasteBinDotCaProtocol : public NetworkProtocol +#include <QFutureInterface> +#include <QCoreApplication> +#include <QString> + +#include <functional> +#include <memory> + +namespace ClangPchManager { + +class ProgressManager : public ProgressManagerInterface { - Q_OBJECT public: - static QString protocolName(); - QString name() const override { return protocolName(); } + using Promise = QFutureInterface<void>; + using Callback = std::function<void(Promise &)>; + + ProgressManager(Callback &&callback) + : m_callback(std::move(callback)) + {} - bool hasSettings() const override { return false; } - unsigned capabilities() const override; - void fetch(const QString &id) override; - void paste(const QString &text, - ContentType ct = Text, - int expiryDays = 1, - const QString &username = QString(), - const QString &comment = QString(), - const QString &description = QString()) override; - void list() override; + void setProgress(int currentProgress, int maximumProgress) + { + if (!m_promise) + initialize(); -protected: - bool checkConfiguration(QString *errorMessage) override; + m_promise->setExpectedResultCount(maximumProgress); + m_promise->setProgressValue(currentProgress); + if (currentProgress >= maximumProgress) + finish(); + } + + Promise *promise() + { + return m_promise.get(); + } private: - void fetchFinished(); - void listFinished(); - void pasteFinished(); + void initialize() + { + m_promise = std::make_unique<Promise>(); + m_callback(*m_promise); + } + + void finish() + { + m_promise->reportFinished(); + m_promise.reset(); + } - QNetworkReply *m_fetchReply = nullptr; - QNetworkReply *m_listReply = nullptr; - QNetworkReply *m_pasteReply = nullptr; - QString m_fetchId; - bool m_hostChecked = false; +private: + Callback m_callback; + std::unique_ptr<Promise> m_promise; }; -} // namespace CodePaster +} // namespace ClangPchManager diff --git a/src/plugins/remotelinux/remotelinuxutils.h b/src/plugins/clangpchmanager/progressmanagerinterface.h index 57aec1d442d..5653e5cd7f5 100644 --- a/src/plugins/remotelinux/remotelinuxutils.h +++ b/src/plugins/clangpchmanager/progressmanagerinterface.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2018 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of Qt Creator. @@ -25,13 +25,15 @@ #pragma once -#include "remotelinux_export.h" +namespace ClangPchManager { -namespace RemoteLinux { - -class REMOTELINUX_EXPORT RemoteLinuxUtils +class ProgressManagerInterface { public: + virtual void setProgress(int currentProgress, int maximumProgress) = 0; + +protected: + ~ProgressManagerInterface() = default; }; -} // namespace RemoteLinux +} // namespace ClangPchManager diff --git a/src/plugins/clangrefactoring/clangrefactoringplugin.cpp b/src/plugins/clangrefactoring/clangrefactoringplugin.cpp index a0db4712912..917823152e3 100644 --- a/src/plugins/clangrefactoring/clangrefactoringplugin.cpp +++ b/src/plugins/clangrefactoring/clangrefactoringplugin.cpp @@ -34,11 +34,13 @@ #include "symbolquery.h" #include <clangpchmanager/clangpchmanagerplugin.h> +#include <clangpchmanager/progressmanager.h> #include <clangsupport/refactoringdatabaseinitializer.h> #include <cpptools/cppmodelmanager.h> #include <coreplugin/icore.h> +#include <coreplugin/progressmanager/progressmanager.h> #include <extensionsystem/pluginmanager.h> #include <cpptools/cpptoolsconstants.h> @@ -46,7 +48,6 @@ #include <filepathcaching.h> #include <sqlitedatabase.h> - #include <utils/hostosinfo.h> #include <QDir> @@ -79,13 +80,16 @@ public: Sqlite::Database database{Utils::PathString{Core::ICore::userResourcePath() + "/symbol-experimental-v1.db"}, 1000ms}; ClangBackEnd::RefactoringDatabaseInitializer<Sqlite::Database> databaseInitializer{database}; ClangBackEnd::FilePathCaching filePathCache{database}; - RefactoringClient refactoringClient; + ClangPchManager::ProgressManager progressManager{ + [] (QFutureInterface<void> &promise) { + auto title = QCoreApplication::translate("ClangRefactoringProgressManager", "C++ Indexing"); + Core::ProgressManager::addTask(promise.future(), title, "clang indexing", nullptr);}}; + RefactoringClient refactoringClient{progressManager}; QtCreatorEditorManager editorManager{filePathCache}; ClangBackEnd::RefactoringConnectionClient connectionClient{&refactoringClient}; QuerySqliteReadStatementFactory statementFactory{database}; SymbolQuery<QuerySqliteReadStatementFactory> symbolQuery{statementFactory}; RefactoringEngine engine{connectionClient.serverProxy(), refactoringClient, filePathCache, symbolQuery}; - QtCreatorSearch qtCreatorSearch; QtCreatorClangQueryFindFilter qtCreatorfindFilter{connectionClient.serverProxy(), qtCreatorSearch, diff --git a/src/plugins/clangrefactoring/refactoringclient.cpp b/src/plugins/clangrefactoring/refactoringclient.cpp index 04fc1bf08e1..3bdeb9dd532 100644 --- a/src/plugins/clangrefactoring/refactoringclient.cpp +++ b/src/plugins/clangrefactoring/refactoringclient.cpp @@ -70,6 +70,11 @@ void RefactoringClient::setLocalRenamingCallback( m_localRenamingCallback = std::move(localRenamingCallback); } +void RefactoringClient::progress(ClangBackEnd::ProgressMessage &&message) +{ + m_progressManager.setProgress(message.progress, message.total); +} + void RefactoringClient::setRefactoringEngine(RefactoringEngine *refactoringEngine) { m_refactoringEngine = refactoringEngine; diff --git a/src/plugins/clangrefactoring/refactoringclient.h b/src/plugins/clangrefactoring/refactoringclient.h index fbf10d72940..f3d9e218e5f 100644 --- a/src/plugins/clangrefactoring/refactoringclient.h +++ b/src/plugins/clangrefactoring/refactoringclient.h @@ -30,6 +30,7 @@ #include "searchhandle.h" #include <refactoringclientinterface.h> +#include <clangpchmanager/progressmanager.h> #include <functional> @@ -48,6 +49,10 @@ class ClangQueryHighlighter; class RefactoringClient final : public ClangBackEnd::RefactoringClientInterface { public: + RefactoringClient(ClangPchManager::ProgressManagerInterface &progressManager) + : m_progressManager(progressManager) + {} + void alive() override; void sourceLocationsForRenamingMessage( ClangBackEnd::SourceLocationsForRenamingMessage &&message) override; @@ -58,6 +63,8 @@ public: void setLocalRenamingCallback( CppTools::RefactoringEngineInterface::RenameCallback &&localRenamingCallback) override; + void progress(ClangBackEnd::ProgressMessage &&message) override; + void setRefactoringEngine(ClangRefactoring::RefactoringEngine *refactoringEngine); void setSearchHandle(ClangRefactoring::SearchHandle *searchHandleInterface); ClangRefactoring::SearchHandle *searchHandle() const; @@ -72,6 +79,7 @@ public: void setRefactoringConnectionClient(ClangBackEnd::RefactoringConnectionClient *connectionClient); + unittest_public: void addSearchResult(const ClangBackEnd::SourceRangeWithTextContainer &sourceRange); @@ -88,6 +96,7 @@ private: RefactoringEngine *m_refactoringEngine = nullptr; ClangQueryExampleHighlighter *m_clangQueryExampleHighlighter = nullptr; ClangQueryHighlighter *m_clangQueryHighlighter = nullptr; + ClangPchManager::ProgressManagerInterface &m_progressManager; uint m_expectedResultCount = 0; uint m_resultCounter = 0; }; diff --git a/src/plugins/clangtools/clangselectablefilesdialog.cpp b/src/plugins/clangtools/clangselectablefilesdialog.cpp index 08ba746553d..22c8d150c18 100644 --- a/src/plugins/clangtools/clangselectablefilesdialog.cpp +++ b/src/plugins/clangtools/clangselectablefilesdialog.cpp @@ -363,7 +363,7 @@ SelectableFilesDialog::SelectableFilesDialog(const ProjectInfo &projectInfo, }); } -SelectableFilesDialog::~SelectableFilesDialog() {} +SelectableFilesDialog::~SelectableFilesDialog() = default; FileInfos SelectableFilesDialog::filteredFileInfos() const { diff --git a/src/plugins/clangtools/clangtidyclazyruncontrol.cpp b/src/plugins/clangtools/clangtidyclazyruncontrol.cpp index 38d8d82094e..3d7d63a84a9 100644 --- a/src/plugins/clangtools/clangtidyclazyruncontrol.cpp +++ b/src/plugins/clangtools/clangtidyclazyruncontrol.cpp @@ -47,7 +47,7 @@ ClangTidyClazyRunControl::ClangTidyClazyRunControl( ClangToolRunner *ClangTidyClazyRunControl::createRunner() { - QTC_ASSERT(!m_clangExecutable.isEmpty(), return 0); + QTC_ASSERT(!m_clangExecutable.isEmpty(), return nullptr); auto runner = new ClangTidyClazyRunner(m_diagnosticConfig, m_clangExecutable, diff --git a/src/plugins/clangtools/clangtool.h b/src/plugins/clangtools/clangtool.h index 39d66b7e737..93f7a610505 100644 --- a/src/plugins/clangtools/clangtool.h +++ b/src/plugins/clangtools/clangtool.h @@ -44,7 +44,7 @@ class ClangTool : public QObject public: ClangTool(const QString &name); - virtual ~ClangTool(); + ~ClangTool() override; virtual void startTool(bool askUserForFileSelection) = 0; diff --git a/src/plugins/clangtools/clangtoolruncontrol.cpp b/src/plugins/clangtools/clangtoolruncontrol.cpp index 05f44f62132..d73ab10cc4c 100644 --- a/src/plugins/clangtools/clangtoolruncontrol.cpp +++ b/src/plugins/clangtools/clangtoolruncontrol.cpp @@ -354,7 +354,7 @@ void ClangToolRunControl::stop() QSetIterator<ClangToolRunner *> i(m_runners); while (i.hasNext()) { ClangToolRunner *runner = i.next(); - QObject::disconnect(runner, 0, this, 0); + QObject::disconnect(runner, nullptr, this, nullptr); delete runner; } m_runners.clear(); diff --git a/src/plugins/clangtools/clangtoolruncontrol.h b/src/plugins/clangtools/clangtoolruncontrol.h index dd5a95662ef..ee4f8fe8ef7 100644 --- a/src/plugins/clangtools/clangtoolruncontrol.h +++ b/src/plugins/clangtools/clangtoolruncontrol.h @@ -50,7 +50,7 @@ struct AnalyzeUnit { QString file; QStringList arguments; // without file itself and "-o somePath" }; -typedef QList<AnalyzeUnit> AnalyzeUnits; +using AnalyzeUnits = QList<AnalyzeUnit>; class ClangToolRunControl : public ProjectExplorer::RunWorker { diff --git a/src/plugins/clangtools/clangtoolrunner.h b/src/plugins/clangtools/clangtoolrunner.h index 01585a8ca77..b0d0b605cc7 100644 --- a/src/plugins/clangtools/clangtoolrunner.h +++ b/src/plugins/clangtools/clangtoolrunner.h @@ -45,7 +45,7 @@ public: const Utils::Environment &environment, const QString &name, QObject *parent = nullptr); - virtual ~ClangToolRunner(); + ~ClangToolRunner() override; // compilerOptions is expected to contain everything except: // (1) filePath, that is the file to analyze diff --git a/src/plugins/clangtools/clangtoolsbasicsettings.h b/src/plugins/clangtools/clangtoolsbasicsettings.h index 27cdb427865..fb896e830de 100644 --- a/src/plugins/clangtools/clangtoolsbasicsettings.h +++ b/src/plugins/clangtools/clangtoolsbasicsettings.h @@ -38,8 +38,8 @@ class ClangToolsBasicSettings : public QWidget Q_OBJECT public: - explicit ClangToolsBasicSettings(QWidget *parent = 0); - ~ClangToolsBasicSettings(); + explicit ClangToolsBasicSettings(QWidget *parent = nullptr); + ~ClangToolsBasicSettings() override; Ui::ClangToolsBasicSettings *ui(); private: diff --git a/src/plugins/clangtools/clangtoolsconfigwidget.h b/src/plugins/clangtools/clangtoolsconfigwidget.h index 6d7bcc87e5e..177aadd259b 100644 --- a/src/plugins/clangtools/clangtoolsconfigwidget.h +++ b/src/plugins/clangtools/clangtoolsconfigwidget.h @@ -44,7 +44,7 @@ class ClangToolsConfigWidget : public QWidget public: ClangToolsConfigWidget(ClangToolsSettings *settings, QWidget *parent = nullptr); - ~ClangToolsConfigWidget(); + ~ClangToolsConfigWidget() override; private: std::unique_ptr<Ui::ClangToolsConfigWidget> m_ui; ClangToolsSettings *m_settings; diff --git a/src/plugins/clangtools/clangtoolsdiagnosticmodel.cpp b/src/plugins/clangtools/clangtoolsdiagnosticmodel.cpp index 6a288a00d2b..977b264afcc 100644 --- a/src/plugins/clangtools/clangtoolsdiagnosticmodel.cpp +++ b/src/plugins/clangtools/clangtoolsdiagnosticmodel.cpp @@ -87,7 +87,7 @@ int ClangToolsDiagnosticModel::diagnosticsCount() const static QString createDiagnosticToolTipString(const Diagnostic &diagnostic) { - typedef QPair<QString, QString> StringPair; + using StringPair = QPair<QString, QString>; QList<StringPair> lines; if (!diagnostic.category.isEmpty()) { @@ -140,7 +140,7 @@ static QString createExplainingStepToolTipString(const ExplainingStep &step) if (step.message == step.extendedMessage) return createFullLocationString(step.location); - typedef QPair<QString, QString> StringPair; + using StringPair = QPair<QString, QString>; QList<StringPair> lines; if (!step.message.isEmpty()) { diff --git a/src/plugins/clangtools/clangtoolsdiagnosticmodel.h b/src/plugins/clangtools/clangtoolsdiagnosticmodel.h index 6ced6bfe22d..998989699eb 100644 --- a/src/plugins/clangtools/clangtoolsdiagnosticmodel.h +++ b/src/plugins/clangtools/clangtoolsdiagnosticmodel.h @@ -115,7 +115,7 @@ public: ProjectExplorer::Project *project() const { return m_project; } private: - bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; + bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; void handleSuppressedDiagnosticsChanged(); QPointer<ProjectExplorer::Project> m_project; diff --git a/src/plugins/clangtools/clangtoolsdiagnosticview.cpp b/src/plugins/clangtools/clangtoolsdiagnosticview.cpp index 6314697593f..e181471f66d 100644 --- a/src/plugins/clangtools/clangtoolsdiagnosticview.cpp +++ b/src/plugins/clangtools/clangtoolsdiagnosticview.cpp @@ -47,7 +47,7 @@ class ClickableFixItHeader : public QHeaderView Q_OBJECT public: - ClickableFixItHeader(Qt::Orientation orientation, QWidget *parent = 0) + ClickableFixItHeader(Qt::Orientation orientation, QWidget *parent = nullptr) : QHeaderView(orientation, parent) { } @@ -58,7 +58,7 @@ public: } protected: - void paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const + void paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const override { painter->save(); QHeaderView::paintSection(painter, rect, logicalIndex); @@ -72,7 +72,7 @@ protected: } } - void mousePressEvent(QMouseEvent *event) + void mousePressEvent(QMouseEvent *event) override { if (event->localPos().x() > sectionPosition(DiagnosticView::FixItColumn)) { state = (state != QStyle::State_On) ? QStyle::State_On : QStyle::State_Off; diff --git a/src/plugins/clangtools/clangtoolsdiagnosticview.h b/src/plugins/clangtools/clangtoolsdiagnosticview.h index 581775c0aee..b0752a3046d 100644 --- a/src/plugins/clangtools/clangtoolsdiagnosticview.h +++ b/src/plugins/clangtools/clangtoolsdiagnosticview.h @@ -35,7 +35,7 @@ class DiagnosticView : public Debugger::DetailedErrorView Q_OBJECT public: - DiagnosticView(QWidget *parent = 0); + DiagnosticView(QWidget *parent = nullptr); enum ExtraColumn { FixItColumn = LocationColumn + 1, @@ -46,7 +46,7 @@ public: private: void suppressCurrentDiagnostic(); - QList<QAction *> customActions() const; + QList<QAction *> customActions() const override; bool eventFilter(QObject *watched, QEvent *event) override; void setModel(QAbstractItemModel *model) override; diff --git a/src/plugins/clangtools/clangtoolsplugin.cpp b/src/plugins/clangtools/clangtoolsplugin.cpp index c78db789625..e3f5653da3c 100644 --- a/src/plugins/clangtools/clangtoolsplugin.cpp +++ b/src/plugins/clangtools/clangtoolsplugin.cpp @@ -82,19 +82,19 @@ public: setCategoryIcon(Analyzer::Icons::SETTINGSCATEGORY_ANALYZER); } - QWidget *widget() + QWidget *widget() override { if (!m_widget) m_widget = new ClangToolsConfigWidget(ClangToolsSettings::instance()); return m_widget; } - void apply() + void apply() override { ClangToolsSettings::instance()->writeSettings(); } - void finish() + void finish() override { delete m_widget; } diff --git a/src/plugins/clangtools/clangtoolsprojectsettings.h b/src/plugins/clangtools/clangtoolsprojectsettings.h index e6a3351ca74..fb52862966b 100644 --- a/src/plugins/clangtools/clangtoolsprojectsettings.h +++ b/src/plugins/clangtools/clangtoolsprojectsettings.h @@ -65,7 +65,7 @@ inline bool operator==(const SuppressedDiagnostic &d1, const SuppressedDiagnosti && d1.uniquifier == d2.uniquifier; } -typedef QList<SuppressedDiagnostic> SuppressedDiagnosticsList; +using SuppressedDiagnosticsList = QList<SuppressedDiagnostic>; class ClangToolsProjectSettings : public QObject { diff --git a/src/plugins/clangtools/clangtoolsprojectsettingswidget.cpp b/src/plugins/clangtools/clangtoolsprojectsettingswidget.cpp index 19b648fac01..419e2e917f0 100644 --- a/src/plugins/clangtools/clangtoolsprojectsettingswidget.cpp +++ b/src/plugins/clangtools/clangtoolsprojectsettingswidget.cpp @@ -39,7 +39,7 @@ class SuppressedDiagnosticsModel : public QAbstractTableModel { Q_OBJECT public: - SuppressedDiagnosticsModel(QObject *parent = 0) : QAbstractTableModel(parent) { } + SuppressedDiagnosticsModel(QObject *parent = nullptr) : QAbstractTableModel(parent) { } void setDiagnostics(const SuppressedDiagnosticsList &diagnostics); SuppressedDiagnostic diagnosticAt(int i) const; @@ -47,10 +47,11 @@ public: private: enum Columns { ColumnFile, ColumnContext, ColumnDescription, ColumnLast = ColumnDescription }; - int rowCount(const QModelIndex &parent = QModelIndex()) const; - int columnCount(const QModelIndex & = QModelIndex()) const { return ColumnLast + 1; } - QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + int columnCount(const QModelIndex & = QModelIndex()) const override { return ColumnLast + 1; } + QVariant headerData(int section, Qt::Orientation orientation, + int role = Qt::DisplayRole) const override; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; SuppressedDiagnosticsList m_diagnostics; }; diff --git a/src/plugins/clangtools/clangtoolsprojectsettingswidget.h b/src/plugins/clangtools/clangtoolsprojectsettingswidget.h index 2e29a613187..f9153f75a63 100644 --- a/src/plugins/clangtools/clangtoolsprojectsettingswidget.h +++ b/src/plugins/clangtools/clangtoolsprojectsettingswidget.h @@ -40,8 +40,8 @@ class ProjectSettingsWidget : public QWidget Q_OBJECT public: - explicit ProjectSettingsWidget(ProjectExplorer::Project *project, QWidget *parent = 0); - ~ProjectSettingsWidget(); + explicit ProjectSettingsWidget(ProjectExplorer::Project *project, QWidget *parent = nullptr); + ~ProjectSettingsWidget() override; private: void updateButtonStates(); diff --git a/src/plugins/clangtools/clangtoolsunittests.h b/src/plugins/clangtools/clangtoolsunittests.h index 36a2fe7e042..4ea2ebd9085 100644 --- a/src/plugins/clangtools/clangtoolsunittests.h +++ b/src/plugins/clangtools/clangtoolsunittests.h @@ -37,7 +37,7 @@ class ClangToolsUnitTests : public QObject Q_OBJECT public: - ClangToolsUnitTests() {} + ClangToolsUnitTests() = default; private slots: void initTestCase(); diff --git a/src/plugins/classview/classviewmanager.cpp b/src/plugins/classview/classviewmanager.cpp index de4b1450c59..d00343ccb3b 100644 --- a/src/plugins/classview/classviewmanager.cpp +++ b/src/plugins/classview/classviewmanager.cpp @@ -52,7 +52,7 @@ namespace Internal { ///////////////////////////////// ManagerPrivate ////////////////////////////////// // static variable initialization -static Manager *managerInstance = 0; +static Manager *managerInstance = nullptr; /*! \class ClassView::Internal::Manager @@ -141,8 +141,6 @@ static Manager *managerInstance = 0; class ManagerPrivate { public: - ManagerPrivate() : state(false), disableCodeParser(false) {} - //! State mutex QMutex mutexState; @@ -153,10 +151,10 @@ public: QThread parserThread; //! Internal manager state. \sa Manager::state - bool state; + bool state = false; //! there is some massive operation ongoing so temporary we should wait - bool disableCodeParser; + bool disableCodeParser = false; }; ///////////////////////////////// Manager ////////////////////////////////// @@ -185,7 +183,7 @@ Manager::~Manager() d->parserThread.quit(); d->parserThread.wait(); delete d; - managerInstance = 0; + managerInstance = nullptr; } Manager *Manager::instance() diff --git a/src/plugins/classview/classviewmanager.h b/src/plugins/classview/classviewmanager.h index eec5d1812f2..63158d459df 100644 --- a/src/plugins/classview/classviewmanager.h +++ b/src/plugins/classview/classviewmanager.h @@ -42,9 +42,9 @@ class Manager : public QObject Q_OBJECT public: - explicit Manager(QObject *parent = 0); + explicit Manager(QObject *parent = nullptr); - virtual ~Manager(); + ~Manager() override; //! Get an instance of Manager static Manager *instance(); diff --git a/src/plugins/classview/classviewnavigationwidget.cpp b/src/plugins/classview/classviewnavigationwidget.cpp index a2f793fcabd..3b7bcc68814 100644 --- a/src/plugins/classview/classviewnavigationwidget.cpp +++ b/src/plugins/classview/classviewnavigationwidget.cpp @@ -93,7 +93,7 @@ namespace Internal { NavigationWidget::NavigationWidget(QWidget *parent) : QWidget(parent) { - QVBoxLayout *verticalLayout = new QVBoxLayout(this); + auto verticalLayout = new QVBoxLayout(this); verticalLayout->setSpacing(0); verticalLayout->setContentsMargins(0, 0, 0, 0); treeView = new ::Utils::NavigationTreeView(this); @@ -136,9 +136,7 @@ NavigationWidget::NavigationWidget(QWidget *parent) : manager, &Manager::onRequestTreeDataUpdate); } -NavigationWidget::~NavigationWidget() -{ -} +NavigationWidget::~NavigationWidget() = default; void NavigationWidget::hideEvent(QHideEvent *event) { diff --git a/src/plugins/classview/classviewnavigationwidget.h b/src/plugins/classview/classviewnavigationwidget.h index 64128f3510b..a216714a9e5 100644 --- a/src/plugins/classview/classviewnavigationwidget.h +++ b/src/plugins/classview/classviewnavigationwidget.h @@ -46,8 +46,8 @@ class NavigationWidget : public QWidget Q_OBJECT public: - explicit NavigationWidget(QWidget *parent = 0); - ~NavigationWidget(); + explicit NavigationWidget(QWidget *parent = nullptr); + ~NavigationWidget() override; QList<QToolButton *> createToolButtons(); @@ -76,10 +76,10 @@ protected: void fetchExpandedItems(QStandardItem *item, const QStandardItem *target) const; //! implements QWidget::hideEvent - void hideEvent(QHideEvent *event); + void hideEvent(QHideEvent *event) override; //! implements QWidget::showEvent - void showEvent(QShowEvent *event); + void showEvent(QShowEvent *event) override; private: Utils::NavigationTreeView *treeView; diff --git a/src/plugins/classview/classviewnavigationwidgetfactory.cpp b/src/plugins/classview/classviewnavigationwidgetfactory.cpp index 2d35c67c70b..aaaa4295d32 100644 --- a/src/plugins/classview/classviewnavigationwidgetfactory.cpp +++ b/src/plugins/classview/classviewnavigationwidgetfactory.cpp @@ -58,7 +58,7 @@ NavigationWidgetFactory::NavigationWidgetFactory() Core::NavigationView NavigationWidgetFactory::createWidget() { Core::NavigationView navigationView; - NavigationWidget *widget = new NavigationWidget(); + auto widget = new NavigationWidget(); navigationView.widget = widget; navigationView.dockToolBarWidgets = widget->createToolButtons(); return navigationView; @@ -77,7 +77,7 @@ static QString settingsPrefix(int position) void NavigationWidgetFactory::saveSettings(QSettings *settings, int position, QWidget *widget) { - NavigationWidget *pw = qobject_cast<NavigationWidget *>(widget); + auto pw = qobject_cast<NavigationWidget *>(widget); QTC_ASSERT(pw, return); // .beginGroup is not used - to prevent simultaneous access @@ -87,7 +87,7 @@ void NavigationWidgetFactory::saveSettings(QSettings *settings, int position, QW void NavigationWidgetFactory::restoreSettings(QSettings *settings, int position, QWidget *widget) { - NavigationWidget *pw = qobject_cast<NavigationWidget *>(widget); + auto pw = qobject_cast<NavigationWidget *>(widget); QTC_ASSERT(pw, return); // .beginGroup is not used - to prevent simultaneous access diff --git a/src/plugins/classview/classviewparser.cpp b/src/plugins/classview/classviewparser.cpp index edf7a038ced..14034b46a38 100644 --- a/src/plugins/classview/classviewparser.cpp +++ b/src/plugins/classview/classviewparser.cpp @@ -92,10 +92,7 @@ namespace Internal { class ParserPrivate { public: - typedef QHash<QString, CPlusPlus::Document::Ptr>::const_iterator CitDocumentList; - - //! Constructor - ParserPrivate() : flatMode(false) {} + using CitDocumentList = QHash<QString, CPlusPlus::Document::Ptr>::const_iterator; //! Get document from documentList CPlusPlus::Document::Ptr document(const QString &fileName) const; @@ -142,7 +139,7 @@ public: ParserTreeItem::ConstPtr rootItem; //! Flat mode - bool flatMode; + bool flatMode = false; }; CPlusPlus::Document::Ptr ParserPrivate::document(const QString &fileName) const diff --git a/src/plugins/classview/classviewparser.h b/src/plugins/classview/classviewparser.h index 918397b3c45..330b717152b 100644 --- a/src/plugins/classview/classviewparser.h +++ b/src/plugins/classview/classviewparser.h @@ -50,8 +50,8 @@ class Parser : public QObject Q_OBJECT public: - explicit Parser(QObject *parent = 0); - ~Parser(); + explicit Parser(QObject *parent = nullptr); + ~Parser() override; bool canFetchMore(QStandardItem *item, bool skipRoot = false) const; @@ -86,8 +86,8 @@ public: void setFlatMode(bool flat); protected: - typedef QHash<QString, unsigned>::const_iterator CitCachedDocTreeRevision; - typedef QHash<QString, QStringList>::const_iterator CitCachedPrjFileLists; + using CitCachedDocTreeRevision = QHash<QString, unsigned>::const_iterator; + using CitCachedPrjFileLists = QHash<QString, QStringList>::const_iterator; void onResetDataDone(); diff --git a/src/plugins/classview/classviewparsertreeitem.cpp b/src/plugins/classview/classviewparsertreeitem.cpp index bd3d1901d0e..eb2009c5ed0 100644 --- a/src/plugins/classview/classviewparsertreeitem.cpp +++ b/src/plugins/classview/classviewparsertreeitem.cpp @@ -295,7 +295,7 @@ void ParserTreeItem::convertTo(QStandardItem *item) const ++curHash; } - typedef QMap<SymbolInformation, ParserTreeItem::Ptr>::const_iterator MapCitSymbolInformations; + using MapCitSymbolInformations = QMap<SymbolInformation, ParserTreeItem::Ptr>::const_iterator; // add to item MapCitSymbolInformations cur = map.constBegin(); MapCitSymbolInformations end = map.constEnd(); @@ -303,7 +303,7 @@ void ParserTreeItem::convertTo(QStandardItem *item) const const SymbolInformation &inf = cur.key(); ParserTreeItem::Ptr ptr = cur.value(); - QStandardItem *add = new QStandardItem(); + auto add = new QStandardItem; Utils::setSymbolInformationToItem(inf, add); if (!ptr.isNull()) { // icon diff --git a/src/plugins/classview/classviewparsertreeitem.h b/src/plugins/classview/classviewparsertreeitem.h index 60ca284cee4..d3ca68007ef 100644 --- a/src/plugins/classview/classviewparsertreeitem.h +++ b/src/plugins/classview/classviewparsertreeitem.h @@ -41,8 +41,8 @@ class ParserTreeItemPrivate; class ParserTreeItem { public: - typedef QSharedPointer<ParserTreeItem> Ptr; - typedef QSharedPointer<const ParserTreeItem> ConstPtr; + using Ptr = QSharedPointer<ParserTreeItem>; + using ConstPtr = QSharedPointer<const ParserTreeItem>; public: ParserTreeItem(); @@ -91,7 +91,7 @@ protected: ParserTreeItem &operator=(const ParserTreeItem &other); private: - typedef QHash<SymbolInformation, ParserTreeItem::Ptr>::const_iterator CitSymbolInformations; + using CitSymbolInformations = QHash<SymbolInformation, ParserTreeItem::Ptr>::const_iterator; //! Private class data pointer ParserTreeItemPrivate *d; }; diff --git a/src/plugins/classview/classviewtreeitemmodel.cpp b/src/plugins/classview/classviewtreeitemmodel.cpp index 0e295324c9e..4f8d361ced2 100644 --- a/src/plugins/classview/classviewtreeitemmodel.cpp +++ b/src/plugins/classview/classviewtreeitemmodel.cpp @@ -46,9 +46,7 @@ TreeItemModel::TreeItemModel(QObject *parent) { } -TreeItemModel::~TreeItemModel() -{ -} +TreeItemModel::~TreeItemModel() = default; QVariant TreeItemModel::data(const QModelIndex &index, int role) const { @@ -136,7 +134,7 @@ QMimeData *TreeItemModel::mimeData(const QModelIndexList &indexes) const } if (mimeData->files().isEmpty()) { delete mimeData; - return 0; + return nullptr; } return mimeData; } diff --git a/src/plugins/classview/classviewtreeitemmodel.h b/src/plugins/classview/classviewtreeitemmodel.h index 9864d179dbc..a060a708582 100644 --- a/src/plugins/classview/classviewtreeitemmodel.h +++ b/src/plugins/classview/classviewtreeitemmodel.h @@ -37,19 +37,19 @@ class TreeItemModel : public QStandardItemModel Q_OBJECT public: - explicit TreeItemModel(QObject *parent = 0); - virtual ~TreeItemModel(); + explicit TreeItemModel(QObject *parent = nullptr); + ~TreeItemModel() override; void moveRootToTarget(const QStandardItem *target); - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - bool canFetchMore(const QModelIndex &parent) const; - void fetchMore(const QModelIndex &parent); - bool hasChildren(const QModelIndex &parent = QModelIndex()) const; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + bool canFetchMore(const QModelIndex &parent) const override; + void fetchMore(const QModelIndex &parent) override; + bool hasChildren(const QModelIndex &parent = QModelIndex()) const override; - Qt::DropActions supportedDragActions() const; - QStringList mimeTypes() const; - QMimeData *mimeData(const QModelIndexList &indexes) const; + Qt::DropActions supportedDragActions() const override; + QStringList mimeTypes() const override; + QMimeData *mimeData(const QModelIndexList &indexes) const override; private: //! private class data pointer diff --git a/src/plugins/classview/classviewutils.cpp b/src/plugins/classview/classviewutils.cpp index 53a673bb767..7b4e0d5fbc7 100644 --- a/src/plugins/classview/classviewutils.cpp +++ b/src/plugins/classview/classviewutils.cpp @@ -72,9 +72,7 @@ const int IconSortOrder[] = { namespace Internal { -Utils::Utils() -{ -} +Utils::Utils() = default; /*! Converts internal location container to QVariant compatible. @@ -120,9 +118,8 @@ int Utils::iconTypeSortOrder(int icon) // initialization if (sortOrder.isEmpty()) { - for (unsigned i = 0 ; - i < sizeof(Constants::IconSortOrder) / sizeof(Constants::IconSortOrder[0]) ; ++i) - sortOrder.insert(Constants::IconSortOrder[i], sortOrder.count()); + for (int i : Constants::IconSortOrder) + sortOrder.insert(i, sortOrder.count()); } // if it is missing - return the same value diff --git a/src/plugins/clearcase/clearcaseplugin.cpp b/src/plugins/clearcase/clearcaseplugin.cpp index a628593b45d..96d17c23749 100644 --- a/src/plugins/clearcase/clearcaseplugin.cpp +++ b/src/plugins/clearcase/clearcaseplugin.cpp @@ -1058,7 +1058,7 @@ void ClearCasePlugin::rmdir(const QString &path) void ClearCasePlugin::diffActivity() { - typedef QMap<QString, QStringPair>::Iterator FileVerIt; + using FileVerIt = QMap<QString, QStringPair>::Iterator; const VcsBasePluginState state = currentState(); QTC_ASSERT(state.hasTopLevel(), return); @@ -1649,7 +1649,7 @@ bool ClearCasePlugin::vcsCheckIn(const QString &messageFile, const QStringList & if (files.isEmpty()) return true; const QString title = QString::fromLatin1("Checkin %1").arg(files.join(QLatin1String("; "))); - typedef QSharedPointer<FileChangeBlocker> FCBPointer; + using FCBPointer = QSharedPointer<FileChangeBlocker>; replaceActivity &= (activity != QLatin1String(Constants::KEEP_ACTIVITY)); if (replaceActivity && !vcsSetActivity(m_checkInView, title, activity)) return false; diff --git a/src/plugins/clearcase/clearcaseplugin.h b/src/plugins/clearcase/clearcaseplugin.h index 2aae2748be7..5c9fdaaf0fa 100644 --- a/src/plugins/clearcase/clearcaseplugin.h +++ b/src/plugins/clearcase/clearcaseplugin.h @@ -43,7 +43,7 @@ class QAction; template <typename T> class QFutureInterface; class QMutex; -typedef QPair<QString, QString> QStringPair; +using QStringPair = QPair<QString, QString>; class QTextCodec; QT_END_NAMESPACE @@ -93,7 +93,7 @@ public: { } }; -typedef QHash<QString, FileStatus> StatusMap; +using StatusMap = QHash<QString, FileStatus>; class ViewData { diff --git a/src/plugins/clearcase/clearcasesettings.cpp b/src/plugins/clearcase/clearcasesettings.cpp index 4f44acbd5ef..be57ebcd4a7 100644 --- a/src/plugins/clearcase/clearcasesettings.cpp +++ b/src/plugins/clearcase/clearcasesettings.cpp @@ -96,7 +96,7 @@ void ClearCaseSettings::fromSettings(QSettings *settings) void ClearCaseSettings::toSettings(QSettings *settings) const { - typedef QHash<QString, int>::ConstIterator FilesConstIt; + using FilesConstIt = QHash<QString, int>::ConstIterator; settings->beginGroup(QLatin1String(groupC)); settings->setValue(QLatin1String(commandKeyC), ccCommand); diff --git a/src/plugins/clearcase/clearcasesubmiteditor.cpp b/src/plugins/clearcase/clearcasesubmiteditor.cpp index f96c35f958e..eed9cf193ce 100644 --- a/src/plugins/clearcase/clearcasesubmiteditor.cpp +++ b/src/plugins/clearcase/clearcasesubmiteditor.cpp @@ -51,7 +51,7 @@ void ClearCaseSubmitEditor::setIsUcm(bool isUcm) void ClearCaseSubmitEditor::setStatusList(const QStringList &statusOutput) { - typedef QStringList::const_iterator ConstIterator; + using ConstIterator = QStringList::const_iterator; auto model = new VcsBase::SubmitFileModel(this); model->setRepositoryRoot(checkScriptWorkingDirectory()); diff --git a/src/plugins/clearcase/clearcasesync.cpp b/src/plugins/clearcase/clearcasesync.cpp index 2a9c16dfd77..2b871a01339 100644 --- a/src/plugins/clearcase/clearcasesync.cpp +++ b/src/plugins/clearcase/clearcasesync.cpp @@ -111,7 +111,7 @@ void ClearCaseSync::processCleartoolLsLine(const QDir &viewRootDir, const QStrin m_plugin->setStatus(absFile, FileStatus::CheckedIn, true); } -void ClearCaseSync::updateTotalFilesCount(const QString view, ClearCaseSettings settings, +void ClearCaseSync::updateTotalFilesCount(const QString &view, ClearCaseSettings settings, const int processed) { settings = m_plugin->settings(); // Might have changed while task was running diff --git a/src/plugins/clearcase/clearcasesync.h b/src/plugins/clearcase/clearcasesync.h index 179c3c6a232..e5aeda92587 100644 --- a/src/plugins/clearcase/clearcasesync.h +++ b/src/plugins/clearcase/clearcasesync.h @@ -41,7 +41,8 @@ public: void invalidateStatus(const QDir &viewRootDir, const QStringList &files); void invalidateStatusAllFiles(); void processCleartoolLsLine(const QDir &viewRootDir, const QString &buffer); - void updateTotalFilesCount(const QString view, ClearCaseSettings settings, const int processed); + void updateTotalFilesCount(const QString &view, ClearCaseSettings settings, + const int processed); void updateStatusForNotManagedFiles(const QStringList &files); void syncDynamicView(QFutureInterface<void> &future, diff --git a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp index 1aeed274a19..bcd66e71062 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp @@ -35,7 +35,6 @@ #include "cmakeprojectmanager.h" #include "cmakeprojectnodes.h" -#include <coreplugin/documentmanager.h> #include <coreplugin/icore.h> #include <projectexplorer/buildmanager.h> @@ -160,7 +159,8 @@ FileName CMakeBuildConfiguration::shadowBuildDirectory(const FileName &projectFi const QString projectName = projectFilePath.parentDir().fileName(); ProjectMacroExpander expander(projectFilePath.toString(), projectName, k, bcName, buildType); QDir projectDir = QDir(Project::projectDirectory(projectFilePath).toString()); - QString buildPath = expander.expand(Core::DocumentManager::buildDirectory()); + QString buildPath = expander.expand(ProjectExplorerPlugin::buildDirectoryTemplate()); + buildPath.replace(" ", "-"); return FileName::fromUserInput(projectDir.absoluteFilePath(buildPath)); } diff --git a/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp b/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp index 306ec7b4e19..3b808403135 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp @@ -278,11 +278,6 @@ BuildStepConfigWidget *CMakeBuildStep::createConfigWidget() return new CMakeBuildStepConfigWidget(this); } -bool CMakeBuildStep::immutable() const -{ - return false; -} - void CMakeBuildStep::stdOutput(const QString &line) { if (m_percentProgress.indexIn(line) != -1) { @@ -410,10 +405,13 @@ QStringList CMakeBuildStep::specialTargets() // CMakeBuildStepConfigWidget::CMakeBuildStepConfigWidget(CMakeBuildStep *buildStep) : + BuildStepConfigWidget(buildStep), m_buildStep(buildStep), m_toolArguments(new QLineEdit), m_buildTargetsList(new QListWidget) { + setDisplayName(tr("Build", "CMakeProjectManager::CMakeBuildStepConfigWidget display name.")); + auto fl = new QFormLayout(this); fl->setMargin(0); fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); @@ -469,11 +467,6 @@ void CMakeBuildStepConfigWidget::itemChanged(QListWidgetItem *item) updateDetails(); } -QString CMakeBuildStepConfigWidget::displayName() const -{ - return tr("Build", "CMakeProjectManager::CMakeBuildStepConfigWidget display name."); -} - void CMakeBuildStepConfigWidget::buildTargetsChanged() { { @@ -527,8 +520,7 @@ void CMakeBuildStepConfigWidget::updateDetails() { BuildConfiguration *bc = m_buildStep->buildConfiguration(); if (!bc) { - m_summaryText = tr("<b>No build configuration found on this kit.</b>"); - emit updateSummary(); + setSummaryText(tr("<b>No build configuration found on this kit.</b>")); return; } @@ -538,14 +530,8 @@ void CMakeBuildStepConfigWidget::updateDetails() param.setWorkingDirectory(bc->buildDirectory().toString()); param.setCommand(m_buildStep->cmakeCommand()); param.setArguments(m_buildStep->allArguments(0)); - m_summaryText = param.summary(displayName()); - emit updateSummary(); -} - -QString CMakeBuildStepConfigWidget::summaryText() const -{ - return m_summaryText; + setSummaryText(param.summary(displayName())); } // diff --git a/src/plugins/cmakeprojectmanager/cmakebuildstep.h b/src/plugins/cmakeprojectmanager/cmakebuildstep.h index 098310f1ebf..88e2c55f2d9 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildstep.h +++ b/src/plugins/cmakeprojectmanager/cmakebuildstep.h @@ -60,7 +60,6 @@ public: void run(QFutureInterface<bool> &fi) override; ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override; - bool immutable() const override; QString buildTarget() const; bool buildsBuildTarget(const QString &target) const; @@ -120,8 +119,6 @@ class CMakeBuildStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget Q_OBJECT public: CMakeBuildStepConfigWidget(CMakeBuildStep *buildStep); - QString displayName() const override; - QString summaryText() const override; private: void itemChanged(QListWidgetItem*); @@ -133,7 +130,6 @@ private: CMakeBuildStep *m_buildStep; QLineEdit *m_toolArguments; QListWidget *m_buildTargetsList; - QString m_summaryText; }; class CMakeBuildStepFactory : public ProjectExplorer::BuildStepFactory diff --git a/src/plugins/coreplugin/actionmanager/actioncontainer.cpp b/src/plugins/coreplugin/actionmanager/actioncontainer.cpp index b602dc54cd9..637e76ab03b 100644 --- a/src/plugins/coreplugin/actionmanager/actioncontainer.cpp +++ b/src/plugins/coreplugin/actionmanager/actioncontainer.cpp @@ -263,20 +263,25 @@ void ActionContainerPrivate::addMenu(ActionContainer *menu, Id groupId) scheduleUpdate(); } -void ActionContainerPrivate::addMenu(ActionContainer *before, ActionContainer *menu, Id groupId) +void ActionContainerPrivate::addMenu(ActionContainer *before, ActionContainer *menu) { auto containerPrivate = static_cast<ActionContainerPrivate *>(menu); if (!containerPrivate->canBeAddedToMenu()) return; - auto container = static_cast<MenuActionContainer *>(containerPrivate); - const Id actualGroupId = groupId.isValid() ? groupId : Id(Constants::G_DEFAULT_TWO); - QList<Group>::const_iterator groupIt = findGroup(actualGroupId); - QTC_ASSERT(groupIt != m_groups.constEnd(), return); - QAction *beforeAction = before->menu()->menuAction(); - m_groups[groupIt-m_groups.constBegin()].items.append(menu); + QMutableListIterator<Group> it(m_groups); + while (it.hasNext()) { + Group &group = it.next(); + const int insertionPoint = group.items.indexOf(before); + if (insertionPoint >= 0) { + group.items.insert(insertionPoint, menu); + break; + } + } connect(menu, &QObject::destroyed, this, &ActionContainerPrivate::itemDestroyed); + auto container = static_cast<MenuActionContainer *>(containerPrivate); + QAction *beforeAction = before->menu()->menuAction(); insertMenu(beforeAction, container->menu()); scheduleUpdate(); } diff --git a/src/plugins/coreplugin/actionmanager/actioncontainer.h b/src/plugins/coreplugin/actionmanager/actioncontainer.h index a20962430bd..531d01ccdbb 100644 --- a/src/plugins/coreplugin/actionmanager/actioncontainer.h +++ b/src/plugins/coreplugin/actionmanager/actioncontainer.h @@ -64,7 +64,7 @@ public: virtual void insertGroup(Id before, Id group) = 0; virtual void addAction(Command *action, Id group = Id()) = 0; virtual void addMenu(ActionContainer *menu, Id group = Id()) = 0; - virtual void addMenu(ActionContainer *before, ActionContainer *menu, Id group = Id()) = 0; + virtual void addMenu(ActionContainer *before, ActionContainer *menu) = 0; Command *addSeparator(Id group = Id()); virtual Command *addSeparator(const Context &context, Id group = Id(), QAction **outSeparator = nullptr) = 0; diff --git a/src/plugins/coreplugin/actionmanager/actioncontainer_p.h b/src/plugins/coreplugin/actionmanager/actioncontainer_p.h index ffa24eecddc..c78310b7b2a 100644 --- a/src/plugins/coreplugin/actionmanager/actioncontainer_p.h +++ b/src/plugins/coreplugin/actionmanager/actioncontainer_p.h @@ -56,7 +56,7 @@ public: void insertGroup(Id before, Id groupId) override; void addAction(Command *action, Id group = Id()) override; void addMenu(ActionContainer *menu, Id group = Id()) override; - void addMenu(ActionContainer *before, ActionContainer *menu, Id group = Id()) override; + void addMenu(ActionContainer *before, ActionContainer *menu) override; Command *addSeparator(const Context &context, Id group = Id(), QAction **outSeparator = nullptr) override; void clear() override; diff --git a/src/plugins/coreplugin/coreconstants.h b/src/plugins/coreplugin/coreconstants.h index 1c09436818a..35b8372b388 100644 --- a/src/plugins/coreplugin/coreconstants.h +++ b/src/plugins/coreplugin/coreconstants.h @@ -209,8 +209,6 @@ const char DEFAULT_THEME[] = "flat"; const char TR_CLEAR_MENU[] = QT_TRANSLATE_NOOP("Core", "Clear Menu"); -const char DEFAULT_BUILD_DIRECTORY[] = "../%{JS: Util.asciify(\"build-%{CurrentProject:Name}-%{CurrentKit:FileSystemName}-%{CurrentBuild:Name}\")}"; - const int MODEBAR_ICON_SIZE = 34; const int MODEBAR_ICONSONLY_BUTTON_SIZE = MODEBAR_ICON_SIZE + 4; const int DEFAULT_MAX_CHAR_COUNT = 10000000; diff --git a/src/plugins/coreplugin/dialogs/externaltoolconfig.cpp b/src/plugins/coreplugin/dialogs/externaltoolconfig.cpp index 3e5255ea598..f24060b9077 100644 --- a/src/plugins/coreplugin/dialogs/externaltoolconfig.cpp +++ b/src/plugins/coreplugin/dialogs/externaltoolconfig.cpp @@ -32,6 +32,7 @@ #include <utils/qtcassert.h> #include <utils/qtcprocess.h> #include <utils/fancylineedit.h> +#include <utils/environment.h> #include <utils/environmentdialog.h> #include <coreplugin/coreconstants.h> @@ -396,6 +397,14 @@ void ExternalToolModel::removeTool(const QModelIndex &modelIndex) // #pragma mark -- ExternalToolConfig +static void fillBaseEnvironmentComboBox(QComboBox *box) +{ + box->clear(); + box->addItem(ExternalTool::tr("System Environment"), QByteArray()); + for (const Utils::EnvironmentProvider &provider : Utils::EnvironmentProvider::providers()) + box->addItem(provider.displayName, Id::fromName(provider.id).toSetting()); +} + ExternalToolConfig::ExternalToolConfig(QWidget *parent) : QWidget(parent), ui(new Ui::ExternalToolConfig), @@ -414,6 +423,8 @@ ExternalToolConfig::ExternalToolConfig(QWidget *parent) : chooser->addSupportedWidget(ui->workingDirectory->lineEdit()); chooser->addSupportedWidget(ui->inputText); + fillBaseEnvironmentComboBox(ui->baseEnvironment); + connect(ui->description, &QLineEdit::editingFinished, this, &ExternalToolConfig::updateCurrentItem); connect(ui->executable, &Utils::PathChooser::editingFinished, @@ -519,9 +530,10 @@ void ExternalToolConfig::updateItem(const QModelIndex &index) tool->setExecutables(executables); tool->setArguments(ui->arguments->text()); tool->setWorkingDirectory(ui->workingDirectory->rawPath()); - tool->setEnvironment(m_environment); - tool->setOutputHandling((ExternalTool::OutputHandling)ui->outputBehavior->currentIndex()); - tool->setErrorHandling((ExternalTool::OutputHandling)ui->errorOutputBehavior->currentIndex()); + tool->setBaseEnvironmentProviderId(Id::fromSetting(ui->baseEnvironment->currentData())); + tool->setEnvironmentUserChanges(m_environment); + tool->setOutputHandling(ExternalTool::OutputHandling(ui->outputBehavior->currentIndex())); + tool->setErrorHandling(ExternalTool::OutputHandling(ui->errorOutputBehavior->currentIndex())); tool->setModifiesCurrentDocument(ui->modifiesDocumentCheckbox->checkState()); tool->setInput(ui->inputText->toPlainText()); } @@ -542,13 +554,17 @@ void ExternalToolConfig::showInfoForItem(const QModelIndex &index) } ui->infoWidget->setEnabled(true); ui->description->setText(tool->description()); - ui->executable->setPath(tool->executables().isEmpty() ? QString() : tool->executables().first()); + ui->executable->setPath(tool->executables().isEmpty() ? QString() + : tool->executables().constFirst()); ui->arguments->setText(tool->arguments()); ui->workingDirectory->setPath(tool->workingDirectory()); - ui->outputBehavior->setCurrentIndex((int)tool->outputHandling()); - ui->errorOutputBehavior->setCurrentIndex((int)tool->errorHandling()); + ui->outputBehavior->setCurrentIndex(int(tool->outputHandling())); + ui->errorOutputBehavior->setCurrentIndex(int(tool->errorHandling())); ui->modifiesDocumentCheckbox->setChecked(tool->modifiesCurrentDocument()); - m_environment = tool->environment(); + const int baseEnvironmentIndex = ui->baseEnvironment->findData( + tool->baseEnvironmentProviderId().toSetting()); + ui->baseEnvironment->setCurrentIndex(std::max(0, baseEnvironmentIndex)); + m_environment = tool->environmentUserChanges(); { QSignalBlocker blocker(ui->inputText); diff --git a/src/plugins/coreplugin/dialogs/externaltoolconfig.ui b/src/plugins/coreplugin/dialogs/externaltoolconfig.ui index 24a75872ba1..635ee47f326 100644 --- a/src/plugins/coreplugin/dialogs/externaltoolconfig.ui +++ b/src/plugins/coreplugin/dialogs/externaltoolconfig.ui @@ -93,7 +93,16 @@ <property name="fieldGrowthPolicy"> <enum>QFormLayout::ExpandingFieldsGrow</enum> </property> - <property name="margin"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> <number>0</number> </property> <item row="0" column="0"> @@ -210,14 +219,14 @@ </item> </widget> </item> - <item row="6" column="0"> + <item row="7" column="0"> <widget class="QLabel" name="label_2"> <property name="text"> <string>Environment:</string> </property> </widget> </item> - <item row="6" column="1"> + <item row="7" column="1"> <layout class="QHBoxLayout" name="horizontalLayout_3"> <property name="spacing"> <number>0</number> @@ -244,7 +253,7 @@ </item> </layout> </item> - <item row="7" column="1"> + <item row="8" column="1"> <widget class="QCheckBox" name="modifiesDocumentCheckbox"> <property name="toolTip"> <string>If the tool modifies the current document, set this flag to ensure that the document is saved before running the tool and is reloaded after the tool finished.</string> @@ -254,7 +263,7 @@ </property> </widget> </item> - <item row="8" column="0"> + <item row="9" column="0"> <widget class="QLabel" name="inputLabel"> <property name="toolTip"> <string>Text to pass to the executable via standard input. Leave empty if the executable should not receive any input.</string> @@ -264,13 +273,30 @@ </property> </widget> </item> - <item row="8" column="1"> + <item row="9" column="1"> <widget class="QPlainTextEdit" name="inputText"> <property name="lineWrapMode"> <enum>QPlainTextEdit::NoWrap</enum> </property> </widget> </item> + <item row="6" column="0"> + <widget class="QLabel" name="baseEnvironmentLabel"> + <property name="text"> + <string>Base environment:</string> + </property> + </widget> + </item> + <item row="6" column="1"> + <widget class="QComboBox" name="baseEnvironment"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> </layout> </widget> </item> diff --git a/src/plugins/coreplugin/documentmanager.cpp b/src/plugins/coreplugin/documentmanager.cpp index 95da306aca0..5eb162d6a77 100644 --- a/src/plugins/coreplugin/documentmanager.cpp +++ b/src/plugins/coreplugin/documentmanager.cpp @@ -105,7 +105,6 @@ static const char editorsKeyC[] = "EditorIds"; static const char directoryGroupC[] = "Directories"; static const char projectDirectoryKeyC[] = "Projects"; static const char useProjectDirectoryKeyC[] = "UseProjectsDirectory"; -static const char buildDirectoryKeyC[] = "BuildDirectory.Template"; using namespace Utils; @@ -155,16 +154,16 @@ public: QList<DocumentManager::RecentFile> m_recentFiles; static const int m_maxRecentFiles = 7; - QFileSystemWatcher *m_fileWatcher = nullptr; // Delayed creation. - QFileSystemWatcher *m_linkWatcher = nullptr; // Delayed creation (only UNIX/if a link is seen). bool m_postponeAutoReload = false; bool m_blockActivated = false; bool m_checkOnFocusChange = false; + bool m_useProjectsDirectory = true; + + QFileSystemWatcher *m_fileWatcher = nullptr; // Delayed creation. + QFileSystemWatcher *m_linkWatcher = nullptr; // Delayed creation (only UNIX/if a link is seen). QString m_lastVisitedDirectory = QDir::currentPath(); QString m_defaultLocationForNewFiles; FileName m_projectsDirectory; - bool m_useProjectsDirectory = true; - QString m_buildDirectory; // When we are calling into an IDocument // we don't want to receive a changed() // signal @@ -1313,7 +1312,6 @@ void DocumentManager::saveSettings() s->beginGroup(QLatin1String(directoryGroupC)); s->setValue(QLatin1String(projectDirectoryKeyC), d->m_projectsDirectory.toString()); s->setValue(QLatin1String(useProjectDirectoryKeyC), d->m_useProjectsDirectory); - s->setValue(QLatin1String(buildDirectoryKeyC), d->m_buildDirectory); s->endGroup(); } @@ -1346,13 +1344,6 @@ void readSettings() d->m_useProjectsDirectory = s->value(QLatin1String(useProjectDirectoryKeyC), d->m_useProjectsDirectory).toBool(); - const QString settingsShadowDir = s->value(QLatin1String(buildDirectoryKeyC), - QString()).toString(); - if (!settingsShadowDir.isEmpty()) - d->m_buildDirectory = settingsShadowDir; - else - d->m_buildDirectory = QLatin1String(Constants::DEFAULT_BUILD_DIRECTORY); - s->endGroup(); } @@ -1423,26 +1414,6 @@ void DocumentManager::setProjectsDirectory(const FileName &directory) } /*! - Returns the default build directory. - - \sa setBuildDirectory -*/ -QString DocumentManager::buildDirectory() -{ - return d->m_buildDirectory; -} - -/*! - Sets the shadow build directory to \a directory. - - \sa buildDirectory -*/ -void DocumentManager::setBuildDirectory(const QString &directory) -{ - d->m_buildDirectory = directory; -} - -/*! Returns whether the directory for projects is to be used or whether the user chose to use the current directory. diff --git a/src/plugins/coreplugin/documentmanager.h b/src/plugins/coreplugin/documentmanager.h index 038cad8b18f..7ddafef3f1a 100644 --- a/src/plugins/coreplugin/documentmanager.h +++ b/src/plugins/coreplugin/documentmanager.h @@ -141,9 +141,6 @@ public: static Utils::FileName projectsDirectory(); static void setProjectsDirectory(const Utils::FileName &directory); - static QString buildDirectory(); - static void setBuildDirectory(const QString &directory); - /* Used to notify e.g. the code model to update the given files. Does *not* lead to any editors to reload or any other editor manager actions. */ static void notifyFilesChangedInternally(const QStringList &files); diff --git a/src/plugins/coreplugin/externaltool.cpp b/src/plugins/coreplugin/externaltool.cpp index 1b61747dd23..15f7a97660e 100644 --- a/src/plugins/coreplugin/externaltool.cpp +++ b/src/plugins/coreplugin/externaltool.cpp @@ -64,6 +64,7 @@ const char kPath[] = "path"; const char kArguments[] = "arguments"; const char kInput[] = "input"; const char kWorkingDirectory[] = "workingdirectory"; +const char kBaseEnvironmentId[] = "baseEnvironmentId"; const char kEnvironment[] = "environment"; const char kXmlLang[] = "xml:lang"; @@ -81,7 +82,7 @@ const char kFalse[] = "false"; // #pragma mark -- ExternalTool ExternalTool::ExternalTool() : - m_displayCategory(QLatin1String("")) // difference between isNull and isEmpty + m_displayCategory("") // difference between isNull and isEmpty { } @@ -95,6 +96,7 @@ ExternalTool::ExternalTool(const ExternalTool *other) m_arguments(other->m_arguments), m_input(other->m_input), m_workingDirectory(other->m_workingDirectory), + m_baseEnvironmentProviderId(other->m_baseEnvironmentProviderId), m_environment(other->m_environment), m_outputHandling(other->m_outputHandling), m_errorHandling(other->m_errorHandling), @@ -172,7 +174,23 @@ QString ExternalTool::workingDirectory() const return m_workingDirectory; } -QList<EnvironmentItem> ExternalTool::environment() const +Id ExternalTool::baseEnvironmentProviderId() const +{ + return m_baseEnvironmentProviderId; +} + +Environment ExternalTool::baseEnvironment() const +{ + if (m_baseEnvironmentProviderId.isValid()) { + const optional<EnvironmentProvider> provider = EnvironmentProvider::provider( + m_baseEnvironmentProviderId.name()); + if (provider && provider->environment) + return provider->environment(); + } + return Environment::systemEnvironment(); +} + +QList<EnvironmentItem> ExternalTool::environmentUserChanges() const { return m_environment; } @@ -274,7 +292,12 @@ void ExternalTool::setWorkingDirectory(const QString &workingDirectory) m_workingDirectory = workingDirectory; } -void ExternalTool::setEnvironment(const QList<EnvironmentItem> &items) +void ExternalTool::setBaseEnvironmentProviderId(Id id) +{ + m_baseEnvironmentProviderId = id; +} + +void ExternalTool::setEnvironmentUserChanges(const QList<EnvironmentItem> &items) { m_environment = items; } @@ -305,8 +328,8 @@ static void localizedText(const QStringList &locales, QXmlStreamReader *reader, Q_ASSERT(reader); Q_ASSERT(currentLocale); Q_ASSERT(currentText); - if (reader->attributes().hasAttribute(QLatin1String(kXmlLang))) { - int index = locales.indexOf(reader->attributes().value(QLatin1String(kXmlLang)).toString()); + if (reader->attributes().hasAttribute(kXmlLang)) { + int index = locales.indexOf(reader->attributes().value(kXmlLang).toString()); if (index >= 0 && (index < *currentLocale || *currentLocale < 0)) { *currentText = reader->readElementText(); *currentLocale = index; @@ -323,20 +346,20 @@ static void localizedText(const QStringList &locales, QXmlStreamReader *reader, } } if (currentText->isNull()) // prefer isEmpty over isNull - *currentText = QLatin1String(""); + *currentText = ""; } static bool parseOutputAttribute(const QString &attribute, QXmlStreamReader *reader, ExternalTool::OutputHandling *value) { const QStringRef output = reader->attributes().value(attribute); - if (output == QLatin1String(kOutputShowInPane)) { + if (output == kOutputShowInPane) { *value = ExternalTool::ShowInPane; - } else if (output == QLatin1String(kOutputReplaceSelection)) { + } else if (output == kOutputReplaceSelection) { *value = ExternalTool::ReplaceSelection; - } else if (output == QLatin1String(kOutputIgnore)) { + } else if (output == kOutputIgnore) { *value = ExternalTool::Ignore; } else { - reader->raiseError(QLatin1String("Allowed values for output attribute are 'showinpane','replaceselection','ignore'")); + reader->raiseError("Allowed values for output attribute are 'showinpane','replaceselection','ignore'"); return false; } return true; @@ -351,71 +374,77 @@ ExternalTool * ExternalTool::createFromXml(const QByteArray &xml, QString *error auto tool = new ExternalTool; QXmlStreamReader reader(xml); - if (!reader.readNextStartElement() || reader.name() != QLatin1String(kExternalTool)) - reader.raiseError(QLatin1String("Missing start element <externaltool>")); - tool->m_id = reader.attributes().value(QLatin1String(kId)).toString(); + if (!reader.readNextStartElement() || reader.name() != kExternalTool) + reader.raiseError("Missing start element <externaltool>"); + tool->m_id = reader.attributes().value(kId).toString(); if (tool->m_id.isEmpty()) - reader.raiseError(QLatin1String("Missing or empty id attribute for <externaltool>")); + reader.raiseError("Missing or empty id attribute for <externaltool>"); while (reader.readNextStartElement()) { - if (reader.name() == QLatin1String(kDescription)) { + if (reader.name() == kDescription) { localizedText(locales, &reader, &descriptionLocale, &tool->m_description); - } else if (reader.name() == QLatin1String(kDisplayName)) { + } else if (reader.name() == kDisplayName) { localizedText(locales, &reader, &nameLocale, &tool->m_displayName); - } else if (reader.name() == QLatin1String(kCategory)) { + } else if (reader.name() == kCategory) { localizedText(locales, &reader, &categoryLocale, &tool->m_displayCategory); - } else if (reader.name() == QLatin1String(kOrder)) { + } else if (reader.name() == kOrder) { if (tool->m_order >= 0) { - reader.raiseError(QLatin1String("only one <order> element allowed")); + reader.raiseError("only one <order> element allowed"); break; } bool ok; tool->m_order = reader.readElementText().toInt(&ok); if (!ok || tool->m_order < 0) - reader.raiseError(QLatin1String("<order> element requires non-negative integer value")); - } else if (reader.name() == QLatin1String(kExecutable)) { - if (reader.attributes().hasAttribute(QLatin1String(kOutput))) { - if (!parseOutputAttribute(QLatin1String(kOutput), &reader, &tool->m_outputHandling)) + reader.raiseError("<order> element requires non-negative integer value"); + } else if (reader.name() == kExecutable) { + if (reader.attributes().hasAttribute(kOutput)) { + if (!parseOutputAttribute(kOutput, &reader, &tool->m_outputHandling)) break; } - if (reader.attributes().hasAttribute(QLatin1String(kError))) { - if (!parseOutputAttribute(QLatin1String(kError), &reader, &tool->m_errorHandling)) + if (reader.attributes().hasAttribute(kError)) { + if (!parseOutputAttribute(kError, &reader, &tool->m_errorHandling)) break; } - if (reader.attributes().hasAttribute(QLatin1String(kModifiesDocument))) { - const QStringRef value = reader.attributes().value(QLatin1String(kModifiesDocument)); - if (value == QLatin1String(kYes) || value == QLatin1String(kTrue)) { + if (reader.attributes().hasAttribute(kModifiesDocument)) { + const QStringRef value = reader.attributes().value(kModifiesDocument); + if (value == kYes || value == kTrue) { tool->m_modifiesCurrentDocument = true; - } else if (value == QLatin1String(kNo) || value == QLatin1String(kFalse)) { + } else if (value == kNo || value == kFalse) { tool->m_modifiesCurrentDocument = false; } else { - reader.raiseError(QLatin1String("Allowed values for modifiesdocument attribute are 'yes','true','no','false'")); + reader.raiseError("Allowed values for modifiesdocument attribute are 'yes','true','no','false'"); break; } } while (reader.readNextStartElement()) { - if (reader.name() == QLatin1String(kPath)) { + if (reader.name() == kPath) { tool->m_executables.append(reader.readElementText()); - } else if (reader.name() == QLatin1String(kArguments)) { + } else if (reader.name() == kArguments) { if (!tool->m_arguments.isEmpty()) { - reader.raiseError(QLatin1String("only one <arguments> element allowed")); + reader.raiseError("only one <arguments> element allowed"); break; } tool->m_arguments = reader.readElementText(); - } else if (reader.name() == QLatin1String(kInput)) { + } else if (reader.name() == kInput) { if (!tool->m_input.isEmpty()) { - reader.raiseError(QLatin1String("only one <input> element allowed")); + reader.raiseError("only one <input> element allowed"); break; } tool->m_input = reader.readElementText(); - } else if (reader.name() == QLatin1String(kWorkingDirectory)) { + } else if (reader.name() == kWorkingDirectory) { if (!tool->m_workingDirectory.isEmpty()) { - reader.raiseError(QLatin1String("only one <workingdirectory> element allowed")); + reader.raiseError("only one <workingdirectory> element allowed"); break; } tool->m_workingDirectory = reader.readElementText(); - } else if (reader.name() == QLatin1String(kEnvironment)) { + } else if (reader.name() == kBaseEnvironmentId) { + if (tool->m_baseEnvironmentProviderId.isValid()) { + reader.raiseError("only one <baseEnvironmentId> element allowed"); + break; + } + tool->m_baseEnvironmentProviderId = Id::fromString(reader.readElementText()); + } else if (reader.name() == kEnvironment) { if (!tool->m_environment.isEmpty()) { - reader.raiseError(QLatin1String("only one <environment> element allowed")); + reader.raiseError("only one <environment> element allowed"); break; } QStringList lines = reader.readElementText().split(QLatin1Char(';')); @@ -424,7 +453,7 @@ ExternalTool * ExternalTool::createFromXml(const QByteArray &xml, QString *error tool->m_environment = EnvironmentItem::fromStringList(lines); } else { reader.raiseError(QString::fromLatin1("Unknown element <%1> as subelement of <%2>").arg( - reader.qualifiedName().toString(), QLatin1String(kExecutable))); + reader.qualifiedName().toString(), kExecutable)); break; } } @@ -454,7 +483,7 @@ ExternalTool * ExternalTool::createFromFile(const QString &fileName, QString *er return tool; } -static QLatin1String stringForOutputHandling(ExternalTool::OutputHandling handling) +static QString stringForOutputHandling(ExternalTool::OutputHandling handling) { switch (handling) { case ExternalTool::Ignore: @@ -464,7 +493,7 @@ static QLatin1String stringForOutputHandling(ExternalTool::OutputHandling handli case ExternalTool::ReplaceSelection: return QLatin1String(kOutputReplaceSelection); } - return QLatin1String(""); + return QString(); } bool ExternalTool::save(QString *errorMessage) const @@ -475,34 +504,36 @@ bool ExternalTool::save(QString *errorMessage) const if (!saver.hasError()) { QXmlStreamWriter out(saver.file()); out.setAutoFormatting(true); - out.writeStartDocument(QLatin1String("1.0")); + out.writeStartDocument("1.0"); out.writeComment(QString::fromLatin1("Written on %1 by %2") .arg(QDateTime::currentDateTime().toString(), ICore::versionString())); - out.writeStartElement(QLatin1String(kExternalTool)); - out.writeAttribute(QLatin1String(kId), m_id); - out.writeTextElement(QLatin1String(kDescription), m_description); - out.writeTextElement(QLatin1String(kDisplayName), m_displayName); - out.writeTextElement(QLatin1String(kCategory), m_displayCategory); + out.writeStartElement(kExternalTool); + out.writeAttribute(kId, m_id); + out.writeTextElement(kDescription, m_description); + out.writeTextElement(kDisplayName, m_displayName); + out.writeTextElement(kCategory, m_displayCategory); if (m_order != -1) - out.writeTextElement(QLatin1String(kOrder), QString::number(m_order)); + out.writeTextElement(kOrder, QString::number(m_order)); - out.writeStartElement(QLatin1String(kExecutable)); - out.writeAttribute(QLatin1String(kOutput), stringForOutputHandling(m_outputHandling)); - out.writeAttribute(QLatin1String(kError), stringForOutputHandling(m_errorHandling)); - out.writeAttribute(QLatin1String(kModifiesDocument), m_modifiesCurrentDocument ? QLatin1String(kYes) : QLatin1String(kNo)); + out.writeStartElement(kExecutable); + out.writeAttribute(kOutput, stringForOutputHandling(m_outputHandling)); + out.writeAttribute(kError, stringForOutputHandling(m_errorHandling)); + out.writeAttribute(kModifiesDocument, QLatin1String(m_modifiesCurrentDocument ? kYes : kNo)); foreach (const QString &executable, m_executables) - out.writeTextElement(QLatin1String(kPath), executable); + out.writeTextElement(kPath, executable); if (!m_arguments.isEmpty()) - out.writeTextElement(QLatin1String(kArguments), m_arguments); + out.writeTextElement(kArguments, m_arguments); if (!m_input.isEmpty()) - out.writeTextElement(QLatin1String(kInput), m_input); + out.writeTextElement(kInput, m_input); if (!m_workingDirectory.isEmpty()) - out.writeTextElement(QLatin1String(kWorkingDirectory), m_workingDirectory); + out.writeTextElement(kWorkingDirectory, m_workingDirectory); + if (m_baseEnvironmentProviderId.isValid()) + out.writeTextElement(kBaseEnvironmentId, m_baseEnvironmentProviderId.toString()); if (!m_environment.isEmpty()) { QStringList envLines = EnvironmentItem::toStringList(m_environment); for (auto iter = envLines.begin(); iter != envLines.end(); ++iter) *iter = QString::fromUtf8(iter->toUtf8().toPercentEncoding()); - out.writeTextElement(QLatin1String(kEnvironment), envLines.join(QLatin1Char(';'))); + out.writeTextElement(kEnvironment, envLines.join(QLatin1Char(';'))); } out.writeEndElement(); @@ -524,6 +555,7 @@ bool ExternalTool::operator==(const ExternalTool &other) const && m_arguments == other.m_arguments && m_input == other.m_input && m_workingDirectory == other.m_workingDirectory + && m_baseEnvironmentProviderId == other.m_baseEnvironmentProviderId && m_environment == other.m_environment && m_outputHandling == other.m_outputHandling && m_modifiesCurrentDocument == other.m_modifiesCurrentDocument @@ -565,12 +597,11 @@ bool ExternalToolRunner::resolve() m_resolvedExecutable.clear(); m_resolvedArguments.clear(); m_resolvedWorkingDirectory.clear(); - m_resolvedEnvironment = Environment::systemEnvironment(); - + m_resolvedEnvironment = m_tool->baseEnvironment(); MacroExpander *expander = globalMacroExpander(); QList<EnvironmentItem> expandedEnvironment - = Utils::transform(m_tool->environment(), [expander](const EnvironmentItem &item) { + = Utils::transform(m_tool->environmentUserChanges(), [expander](const EnvironmentItem &item) { return EnvironmentItem(item.name, expander->expand(item.value), item.operation); }); m_resolvedEnvironment.modify(expandedEnvironment); @@ -589,8 +620,7 @@ bool ExternalToolRunner::resolve() m_hasError = true; for (int i = 0; i < expandedExecutables.size(); ++i) { m_errorString += tr("Could not find executable for \"%1\" (expanded \"%2\")") - .arg(m_tool->executables().at(i)) - .arg(expandedExecutables.at(i)); + .arg(m_tool->executables().at(i), expandedExecutables.at(i)); m_errorString += QLatin1Char('\n'); } if (!m_errorString.isEmpty()) diff --git a/src/plugins/coreplugin/externaltool.h b/src/plugins/coreplugin/externaltool.h index b511b9e0e24..b41ae450f2b 100644 --- a/src/plugins/coreplugin/externaltool.h +++ b/src/plugins/coreplugin/externaltool.h @@ -25,6 +25,8 @@ #pragma once +#include "id.h" + #include <utils/fileutils.h> #include <utils/environment.h> @@ -67,7 +69,9 @@ public: QString arguments() const; QString input() const; QString workingDirectory() const; - QList<Utils::EnvironmentItem> environment() const; + Id baseEnvironmentProviderId() const; + Utils::Environment baseEnvironment() const; + QList<Utils::EnvironmentItem> environmentUserChanges() const; void setFileName(const QString &fileName); void setPreset(QSharedPointer<ExternalTool> preset); @@ -96,7 +100,8 @@ public: void setArguments(const QString &arguments); void setInput(const QString &input); void setWorkingDirectory(const QString &workingDirectory); - void setEnvironment(const QList<Utils::EnvironmentItem> &items); + void setBaseEnvironmentProviderId(Id id); + void setEnvironmentUserChanges(const QList<Utils::EnvironmentItem> &items); private: QString m_id; @@ -108,6 +113,7 @@ private: QString m_arguments; QString m_input; QString m_workingDirectory; + Id m_baseEnvironmentProviderId; QList<Utils::EnvironmentItem> m_environment; OutputHandling m_outputHandling = ShowInPane; OutputHandling m_errorHandling = ShowInPane; diff --git a/src/plugins/coreplugin/externaltoolmanager.cpp b/src/plugins/coreplugin/externaltoolmanager.cpp index 1ba8a04acba..d2b37bf4ef6 100644 --- a/src/plugins/coreplugin/externaltoolmanager.cpp +++ b/src/plugins/coreplugin/externaltoolmanager.cpp @@ -235,7 +235,7 @@ void ExternalToolManager::setToolsByCategory(const QMap<QString, QList<ExternalT } else { action = new QAction(tool->displayName(), m_instance); d->m_actions.insert(toolId, action); - connect(action, &QAction::triggered, [tool] { + connect(action, &QAction::triggered, tool, [tool] { auto runner = new ExternalToolRunner(tool); if (runner->hasError()) MessageManager::write(runner->errorString()); diff --git a/src/plugins/coreplugin/locator/externaltoolsfilter.cpp b/src/plugins/coreplugin/locator/externaltoolsfilter.cpp index 0a96cf1c040..8fa71367502 100644 --- a/src/plugins/coreplugin/locator/externaltoolsfilter.cpp +++ b/src/plugins/coreplugin/locator/externaltoolsfilter.cpp @@ -67,13 +67,12 @@ void ExternalToolsFilter::refresh(QFutureInterface<void> &) void ExternalToolsFilter::prepareSearch(const QString &entry) { - m_results.clear(); + QList<LocatorFilterEntry> bestEntries; + QList<LocatorFilterEntry> betterEntries; + QList<LocatorFilterEntry> goodEntries; const Qt::CaseSensitivity entryCaseSensitivity = caseSensitivity(entry); const QMap<QString, ExternalTool *> externalToolsById = ExternalToolManager::toolsById(); - auto end = externalToolsById.cend(); - for (auto it = externalToolsById.cbegin(); it != end; ++it) { - ExternalTool *tool = *it; - + for (ExternalTool *tool : externalToolsById) { int index = tool->displayName().indexOf(entry, 0, entryCaseSensitivity); LocatorFilterEntry::HighlightInfo::DataType hDataType = LocatorFilterEntry::HighlightInfo::DisplayName; if (index < 0) { @@ -85,7 +84,14 @@ void ExternalToolsFilter::prepareSearch(const QString &entry) LocatorFilterEntry filterEntry(this, tool->displayName(), QVariant::fromValue(tool)); filterEntry.extraInfo = tool->description(); filterEntry.highlightInfo = LocatorFilterEntry::HighlightInfo(index, entry.length(), hDataType); - m_results.append(filterEntry); + + if (filterEntry.displayName.startsWith(entry, entryCaseSensitivity)) + bestEntries.append(filterEntry); + else if (filterEntry.displayName.contains(entry, entryCaseSensitivity)) + betterEntries.append(filterEntry); + else + goodEntries.append(filterEntry); } } + m_results = bestEntries + betterEntries + goodEntries; } diff --git a/src/plugins/coreplugin/outputwindow.cpp b/src/plugins/coreplugin/outputwindow.cpp index 6b2039c521e..90b06ba39f7 100644 --- a/src/plugins/coreplugin/outputwindow.cpp +++ b/src/plugins/coreplugin/outputwindow.cpp @@ -374,7 +374,9 @@ void OutputWindow::appendText(const QString &textIn, const QTextCharFormat &form if (d->maxCharCount > 0 && document()->characterCount() >= d->maxCharCount) { QTextCharFormat tmp; tmp.setFontWeight(QFont::Bold); - d->cursor.insertText(doNewlineEnforcement(tr("Additional output omitted") + QLatin1Char('\n')), tmp); + d->cursor.insertText(doNewlineEnforcement(tr("Additional output omitted. You can increase " + "the limit in the \"Build & Run\" settings.") + + QLatin1Char('\n')), tmp); } d->cursor.endEditBlock(); diff --git a/src/plugins/cpaster/codepasterservice.h b/src/plugins/cpaster/codepasterservice.h index 68f02f3bc88..dd2b1ba77ce 100644 --- a/src/plugins/cpaster/codepasterservice.h +++ b/src/plugins/cpaster/codepasterservice.h @@ -33,7 +33,7 @@ namespace CodePaster { class Service { public: - virtual ~Service() {} + virtual ~Service() = default; virtual void postText(const QString &text, const QString &mimeType) = 0; virtual void postCurrentEditor() = 0; diff --git a/src/plugins/cpaster/cpaster.pro b/src/plugins/cpaster/cpaster.pro index 6a060565307..fa3a983d3c4 100644 --- a/src/plugins/cpaster/cpaster.pro +++ b/src/plugins/cpaster/cpaster.pro @@ -6,7 +6,6 @@ HEADERS += cpasterplugin.h \ pasteview.h \ cpasterconstants.h \ pastebindotcomprotocol.h \ - pastebindotcaprotocol.h \ pastecodedotxyzprotocol.h \ settings.h \ pasteselectdialog.h \ @@ -23,7 +22,6 @@ SOURCES += cpasterplugin.cpp \ protocol.cpp \ pasteview.cpp \ pastebindotcomprotocol.cpp \ - pastebindotcaprotocol.cpp \ pastecodedotxyzprotocol.cpp \ settings.cpp \ pasteselectdialog.cpp \ diff --git a/src/plugins/cpaster/cpaster.qbs b/src/plugins/cpaster/cpaster.qbs index 35bb876034f..d8d7726e7a7 100644 --- a/src/plugins/cpaster/cpaster.qbs +++ b/src/plugins/cpaster/cpaster.qbs @@ -26,8 +26,6 @@ QtcPlugin { "fileshareprotocolsettingswidget.ui", "kdepasteprotocol.cpp", "kdepasteprotocol.h", - "pastebindotcaprotocol.cpp", - "pastebindotcaprotocol.h", "pastebindotcomprotocol.cpp", "pastebindotcomprotocol.h", "pastebindotcomsettings.ui", diff --git a/src/plugins/cpaster/cpasterplugin.cpp b/src/plugins/cpaster/cpasterplugin.cpp index 4a512c2edf0..a101598e8bf 100644 --- a/src/plugins/cpaster/cpasterplugin.cpp +++ b/src/plugins/cpaster/cpasterplugin.cpp @@ -28,7 +28,6 @@ #include "pasteview.h" #include "kdepasteprotocol.h" #include "pastebindotcomprotocol.h" -#include "pastebindotcaprotocol.h" #include "pastecodedotxyzprotocol.h" #include "fileshareprotocol.h" #include "pasteselectdialog.h" @@ -117,11 +116,10 @@ bool CodepasterPlugin::initialize(const QStringList &arguments, QString *errorMe // Create the settings Page m_settings->fromSettings(ICore::settings()); - SettingsPage *settingsPage = new SettingsPage(m_settings, this); + auto settingsPage = new SettingsPage(m_settings, this); // Create the protocols and append them to the Settings Protocol *protos[] = {new PasteBinDotComProtocol, - new PasteBinDotCaProtocol, new KdePasteProtocol, new FileShareProtocol, new PasteCodeDotXyzProtocol, @@ -193,7 +191,7 @@ static inline void textFromCurrentEditor(QString *text, QString *mimeType) return; const IDocument *document = editor->document(); QString data; - if (const BaseTextEditor *textEditor = qobject_cast<const BaseTextEditor *>(editor)) + if (auto textEditor = qobject_cast<const BaseTextEditor *>(editor)) data = textEditor->selectedText(); if (data.isEmpty()) { if (auto textDocument = qobject_cast<const TextDocument *>(document)) { diff --git a/src/plugins/cpaster/cpasterplugin.h b/src/plugins/cpaster/cpasterplugin.h index 671fdbb71f6..46207ca2867 100644 --- a/src/plugins/cpaster/cpasterplugin.h +++ b/src/plugins/cpaster/cpasterplugin.h @@ -45,7 +45,7 @@ class CodePasterServiceImpl : public QObject, public CodePaster::Service Q_OBJECT Q_INTERFACES(CodePaster::Service) public: - explicit CodePasterServiceImpl(QObject *parent = 0); + explicit CodePasterServiceImpl(QObject *parent = nullptr); void postText(const QString &text, const QString &mimeType) override; void postCurrentEditor() override; diff --git a/src/plugins/cpaster/fileshareprotocol.cpp b/src/plugins/cpaster/fileshareprotocol.cpp index 21a9796b746..3b821db4e3e 100644 --- a/src/plugins/cpaster/fileshareprotocol.cpp +++ b/src/plugins/cpaster/fileshareprotocol.cpp @@ -143,7 +143,7 @@ void FileShareProtocol::fetch(const QString &id) fi = QFileInfo(m_settings->path + QLatin1Char('/') + id); QString errorMessage; QString text; - if (parse(fi.absoluteFilePath(), &errorMessage, 0, 0, &text)) + if (parse(fi.absoluteFilePath(), &errorMessage, nullptr, nullptr, &text)) emit fetchDone(id, text, false); else emit fetchDone(id, errorMessage, true); diff --git a/src/plugins/cpaster/fileshareprotocol.h b/src/plugins/cpaster/fileshareprotocol.h index fb38901c0f9..ea89e41f2a5 100644 --- a/src/plugins/cpaster/fileshareprotocol.h +++ b/src/plugins/cpaster/fileshareprotocol.h @@ -50,7 +50,7 @@ public: bool hasSettings() const override; Core::IOptionsPage *settingsPage() const override; - bool checkConfiguration(QString *errorMessage = 0) override; + bool checkConfiguration(QString *errorMessage = nullptr) override; void fetch(const QString &id) override; void list() override; void paste(const QString &text, diff --git a/src/plugins/cpaster/fileshareprotocolsettingspage.h b/src/plugins/cpaster/fileshareprotocolsettingspage.h index 30e08716e6c..491c4fe6218 100644 --- a/src/plugins/cpaster/fileshareprotocolsettingspage.h +++ b/src/plugins/cpaster/fileshareprotocolsettingspage.h @@ -57,7 +57,7 @@ inline bool operator!=(const FileShareProtocolSettings &s1, const FileShareProto class FileShareProtocolSettingsWidget : public QWidget { Q_OBJECT public: - explicit FileShareProtocolSettingsWidget(QWidget *parent = 0); + explicit FileShareProtocolSettingsWidget(QWidget *parent = nullptr); void setSettings(const FileShareProtocolSettings &); FileShareProtocolSettings settings() const; @@ -72,7 +72,7 @@ class FileShareProtocolSettingsPage : public Core::IOptionsPage public: explicit FileShareProtocolSettingsPage(const QSharedPointer<FileShareProtocolSettings> &s, - QObject *parent = 0); + QObject *parent = nullptr); QWidget *widget() override; void apply() override; diff --git a/src/plugins/cpaster/frontend/frontend.pro b/src/plugins/cpaster/frontend/frontend.pro index 70d2e4339de..fc5913b5e8a 100644 --- a/src/plugins/cpaster/frontend/frontend.pro +++ b/src/plugins/cpaster/frontend/frontend.pro @@ -13,7 +13,6 @@ QT += network HEADERS = ../protocol.h \ ../cpasterconstants.h \ ../pastebindotcomprotocol.h \ - ../pastebindotcaprotocol.h \ ../pastecodedotxyzprotocol.h \ ../kdepasteprotocol.h \ ../urlopenprotocol.h \ @@ -21,7 +20,6 @@ HEADERS = ../protocol.h \ SOURCES += ../protocol.cpp \ ../pastebindotcomprotocol.cpp \ - ../pastebindotcaprotocol.cpp \ ../pastecodedotxyzprotocol.cpp \ ../kdepasteprotocol.cpp \ ../urlopenprotocol.cpp \ diff --git a/src/plugins/cpaster/frontend/frontend.qbs b/src/plugins/cpaster/frontend/frontend.qbs index 385c2121a1e..b1b1c998e95 100644 --- a/src/plugins/cpaster/frontend/frontend.qbs +++ b/src/plugins/cpaster/frontend/frontend.qbs @@ -24,7 +24,6 @@ QtcTool { files: [ "cpasterconstants.h", "kdepasteprotocol.h", "kdepasteprotocol.cpp", - "pastebindotcaprotocol.h", "pastebindotcaprotocol.cpp", "pastebindotcomprotocol.h", "pastebindotcomprotocol.cpp", "pastecodedotxyzprotocol.h", "pastecodedotxyzprotocol.cpp", "protocol.h", "protocol.cpp", diff --git a/src/plugins/cpaster/frontend/main.cpp b/src/plugins/cpaster/frontend/main.cpp index 05faa188455..5845334293c 100644 --- a/src/plugins/cpaster/frontend/main.cpp +++ b/src/plugins/cpaster/frontend/main.cpp @@ -25,7 +25,6 @@ #include "argumentscollector.h" #include "../kdepasteprotocol.h" -#include "../pastebindotcaprotocol.h" #include "../pastebindotcomprotocol.h" #include "../pastecodedotxyzprotocol.h" @@ -49,8 +48,6 @@ public: { if (protocol == KdePasteProtocol::protocolName().toLower()) m_protocol.reset(new KdePasteProtocol); - else if (protocol == PasteBinDotCaProtocol::protocolName().toLower()) - m_protocol.reset(new PasteBinDotCaProtocol); else if (protocol == PasteBinDotComProtocol::protocolName().toLower()) m_protocol.reset(new PasteBinDotComProtocol); else if (protocol == PasteCodeDotXyzProtocol::protocolName().toLower()) @@ -95,7 +92,6 @@ int main(int argc, char *argv[]) QCoreApplication app(argc, argv); const QStringList protocols = {KdePasteProtocol::protocolName().toLower(), - PasteBinDotCaProtocol::protocolName().toLower(), PasteBinDotComProtocol::protocolName().toLower(), PasteCodeDotXyzProtocol::protocolName().toLower()}; ArgumentsCollector argsCollector(protocols); diff --git a/src/plugins/cpaster/kdepasteprotocol.cpp b/src/plugins/cpaster/kdepasteprotocol.cpp index 21c15897a0a..030b30e0e5f 100644 --- a/src/plugins/cpaster/kdepasteprotocol.cpp +++ b/src/plugins/cpaster/kdepasteprotocol.cpp @@ -169,7 +169,7 @@ void StickyNotesPasteProtocol::pasteFinished() } m_pasteReply->deleteLater(); - m_pasteReply = 0; + m_pasteReply = nullptr; } void StickyNotesPasteProtocol::fetch(const QString &id) @@ -207,7 +207,7 @@ void StickyNotesPasteProtocol::fetchFinished() content.remove(QLatin1Char('\r')); } m_fetchReply->deleteLater(); - m_fetchReply = 0; + m_fetchReply = nullptr; emit fetchDone(title, content, error); } diff --git a/src/plugins/cpaster/kdepasteprotocol.h b/src/plugins/cpaster/kdepasteprotocol.h index e7bbd1ba1d9..c1875b14772 100644 --- a/src/plugins/cpaster/kdepasteprotocol.h +++ b/src/plugins/cpaster/kdepasteprotocol.h @@ -50,7 +50,7 @@ public: void setHostUrl(const QString &hostUrl); protected: - bool checkConfiguration(QString *errorMessage = 0) override; + bool checkConfiguration(QString *errorMessage = nullptr) override; private: void fetchFinished(); diff --git a/src/plugins/cpaster/pastebindotcaprotocol.cpp b/src/plugins/cpaster/pastebindotcaprotocol.cpp deleted file mode 100644 index 50d545300e7..00000000000 --- a/src/plugins/cpaster/pastebindotcaprotocol.cpp +++ /dev/null @@ -1,232 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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 "pastebindotcaprotocol.h" - -#include <utils/qtcassert.h> - -#include <QNetworkReply> -#include <QStringList> -#include <QJsonArray> -#include <QJsonDocument> -#include <QJsonValue> -#include <QJsonObject> - -static const char urlC[] = "https://pastebin.ca/"; -static const char internalUrlC[] = "https://pbin.ca/"; -static const char protocolNameC[] = "Pastebin.Ca"; - -static inline QByteArray expiryValue(int expiryDays) -{ - // pastebin.ca supports 1-3 days, 1-3 weeks, 1-6 months, 1 year - const int months = expiryDays / 30; - const int weeks = expiryDays / 7; - - if (expiryDays == 1) - return "1 day"; - if (expiryDays < 4) - return QByteArray::number(expiryDays) + " days"; - if (weeks <= 1) - return "1 week"; - if (weeks <= 3) - return QByteArray::number(weeks) + " weeks"; - if (months <= 1) - return "1 month"; - if (months <= 6) - return QByteArray::number(months) + " months"; - return "1 year"; // using Never makes the post expire after 1 month -} - -namespace CodePaster { - -QString PasteBinDotCaProtocol::protocolName() -{ - return QLatin1String(protocolNameC); -} - -unsigned PasteBinDotCaProtocol::capabilities() const -{ - return ListCapability | PostDescriptionCapability | PostCommentCapability; -} - -void PasteBinDotCaProtocol::fetch(const QString &id) -{ - QTC_ASSERT(!m_fetchReply, return); - const QString url = QLatin1String(internalUrlC); - const QString rawPostFix = QLatin1String("raw/"); - // Create link as ""http://pbin.ca/raw/[id]" - // If we get a complete URL, just insert 'raw', else build URL. - QString link = id; - if (link.startsWith(url)) { - const int lastSlashPos = link.lastIndexOf(QLatin1Char('/')); - if (lastSlashPos != -1) - link.insert(lastSlashPos + 1, rawPostFix); - } else { - link.insert(0, rawPostFix); - link.insert(0, url); - } - m_fetchReply = httpGet(link); - connect(m_fetchReply, &QNetworkReply::finished, - this, &PasteBinDotCaProtocol::fetchFinished); - m_fetchId = id; -} - -static QByteArray toTypeId(Protocol::ContentType ct) -{ - if (ct == Protocol::C) - return QByteArray(1, '3'); - if (ct == Protocol::Cpp) - return QByteArray(1, '4'); - if (ct == Protocol::JavaScript) - return QByteArray("27"); - if (ct == Protocol::Diff) - return QByteArray( "34"); - if (ct == Protocol::Xml) - return QByteArray("15"); - return QByteArray(1, '1'); -} - -void PasteBinDotCaProtocol::paste(const QString &text, - ContentType ct, int expiryDays, - const QString &/* username */, - const QString & comment, - const QString &description) -{ - QTC_ASSERT(!m_pasteReply, return); - QByteArray data = "api=+xKvWG+1UFXkr2Kn3Td4AnpYtCIjA4qt&"; - data += "content="; - data += QUrl::toPercentEncoding(fixNewLines(text)); - data += "&type="; - data += toTypeId(ct); - data += "&description="; - data += QUrl::toPercentEncoding(comment); - data += "&expiry="; - data += QUrl::toPercentEncoding(QLatin1String(expiryValue(expiryDays))); - data += "&name="; // Title or name. - data += QUrl::toPercentEncoding(description); - // fire request - const QString link = QLatin1String(internalUrlC) + QLatin1String("quiet-paste.php"); - m_pasteReply = httpPost(link, data); - connect(m_pasteReply, &QNetworkReply::finished, - this, &PasteBinDotCaProtocol::pasteFinished); -} - -void PasteBinDotCaProtocol::pasteFinished() -{ - if (m_pasteReply->error()) { - qWarning("%s protocol error: %s", protocolNameC, qPrintable(m_pasteReply->errorString())); - } else { - /// returns ""SUCCESS:[id]"" - const QByteArray data = m_pasteReply->readAll(); - const QString link = QString::fromLatin1(urlC) + QString::fromLatin1(data).remove(QLatin1String("SUCCESS:")); - emit pasteDone(link); - } - m_pasteReply->deleteLater(); - m_pasteReply = 0; -} - -void PasteBinDotCaProtocol::fetchFinished() -{ - QString title; - QString content; - bool error = m_fetchReply->error(); - if (error) { - content = m_fetchReply->errorString(); - } else { - title = name() + QLatin1String(": ") + m_fetchId; - const QByteArray data = m_fetchReply->readAll(); - content = QString::fromUtf8(data); - content.remove(QLatin1Char('\r')); - } - m_fetchReply->deleteLater(); - m_fetchReply = 0; - emit fetchDone(title, content, error); -} - -void PasteBinDotCaProtocol::list() -{ - QTC_ASSERT(!m_listReply, return); - m_listReply = httpGet(QLatin1String(urlC)); - connect(m_listReply, &QNetworkReply::finished, this, &PasteBinDotCaProtocol::listFinished); -} - -bool PasteBinDotCaProtocol::checkConfiguration(QString *errorMessage) -{ - if (m_hostChecked) // Check the host once. - return true; - const bool ok = httpStatus(QLatin1String(urlC), errorMessage); - if (ok) - m_hostChecked = true; - return ok; -} - -/* Quick & dirty: Parse page does no more work due to internal javascript/websocket magic - so, - * search for _initial_ json array containing the last added pastes. -\code -<script type="text/javascript">var pHistoryInitial = [{"id":3791300,"ts":1491288268,"name":"try", -"expires":1491374668}, -\endcode */ - -static inline QStringList parseLists(QIODevice *io) -{ - QStringList rc; - - QByteArray data = io->readAll(); - const QByteArray history("<script type=\"text/javascript\">var pHistoryInitial = "); - int pos = data.indexOf(history); - if (pos == -1) - return rc; - data.remove(0, pos + history.size()); - pos = data.indexOf(";</script>"); - if (pos == -1) - return rc; - data.truncate(pos); - QJsonParseError error; - const QJsonDocument doc = QJsonDocument::fromJson(data, &error); - if (error.error != QJsonParseError::NoError) - return rc; - QJsonArray array = doc.array(); - for (const QJsonValue &val : array) { - const QJsonObject obj = val.toObject(); - const QJsonValue id = obj.value("id"); - const QJsonValue name = obj.value("name"); - if (!id.isUndefined()) - rc.append(QString::number(id.toInt()) + ' ' + name.toString()); - } - return rc; -} - -void PasteBinDotCaProtocol::listFinished() -{ - const bool error = m_listReply->error(); - if (error) - qWarning("%s list failed: %s", protocolNameC, qPrintable(m_listReply->errorString())); - else - emit listDone(name(), parseLists(m_listReply)); - m_listReply->deleteLater(); - m_listReply = nullptr; -} - -} // namespace CodePaster diff --git a/src/plugins/cpaster/pastebindotcomprotocol.cpp b/src/plugins/cpaster/pastebindotcomprotocol.cpp index 057e3cf8ea9..86ae8f3f97c 100644 --- a/src/plugins/cpaster/pastebindotcomprotocol.cpp +++ b/src/plugins/cpaster/pastebindotcomprotocol.cpp @@ -135,7 +135,7 @@ void PasteBinDotComProtocol::pasteFinished() emit pasteDone(QString::fromLatin1(m_pasteReply->readAll())); m_pasteReply->deleteLater(); - m_pasteReply = 0; + m_pasteReply = nullptr; } void PasteBinDotComProtocol::fetch(const QString &id) diff --git a/src/plugins/cpaster/pasteselectdialog.cpp b/src/plugins/cpaster/pasteselectdialog.cpp index 48df0562fe2..32337e48f02 100644 --- a/src/plugins/cpaster/pasteselectdialog.cpp +++ b/src/plugins/cpaster/pasteselectdialog.cpp @@ -60,9 +60,7 @@ PasteSelectDialog::PasteSelectDialog(const QList<Protocol*> &protocols, m_ui.listWidget->setFont(listFont); } -PasteSelectDialog::~PasteSelectDialog() -{ -} +PasteSelectDialog::~PasteSelectDialog() = default; QString PasteSelectDialog::pasteId() const { diff --git a/src/plugins/cpaster/pasteselectdialog.h b/src/plugins/cpaster/pasteselectdialog.h index 94a84b1029c..b6b57fae089 100644 --- a/src/plugins/cpaster/pasteselectdialog.h +++ b/src/plugins/cpaster/pasteselectdialog.h @@ -39,7 +39,7 @@ class PasteSelectDialog : public QDialog Q_OBJECT public: explicit PasteSelectDialog(const QList<Protocol*> &protocols, - QWidget *parent = 0); + QWidget *parent = nullptr); ~PasteSelectDialog() override; QString pasteId() const; diff --git a/src/plugins/cpaster/pasteview.cpp b/src/plugins/cpaster/pasteview.cpp index 7240359493c..0035fe10d31 100644 --- a/src/plugins/cpaster/pasteview.cpp +++ b/src/plugins/cpaster/pasteview.cpp @@ -57,9 +57,7 @@ PasteView::PasteView(const QList<Protocol *> &protocols, this, &PasteView::protocolChanged); } -PasteView::~PasteView() -{ -} +PasteView::~PasteView() = default; QString PasteView::user() const { @@ -150,7 +148,7 @@ int PasteView::show(const QString &user, const QString &description, m_mode = DiffChunkMode; QString content; foreach (const FileData &part, parts) { - QListWidgetItem *itm = new QListWidgetItem(part.filename, m_ui.uiPatchList); + auto itm = new QListWidgetItem(part.filename, m_ui.uiPatchList); itm->setCheckState(Qt::Checked); itm->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled); content += part.content; diff --git a/src/plugins/cpaster/protocol.cpp b/src/plugins/cpaster/protocol.cpp index 61e9c2d91e3..ba0b4b7ec32 100644 --- a/src/plugins/cpaster/protocol.cpp +++ b/src/plugins/cpaster/protocol.cpp @@ -59,9 +59,7 @@ Protocol::Protocol() { } -Protocol::~Protocol() -{ -} +Protocol::~Protocol() = default; bool Protocol::hasSettings() const { @@ -75,7 +73,7 @@ bool Protocol::checkConfiguration(QString *) Core::IOptionsPage *Protocol::settingsPage() const { - return 0; + return nullptr; } void Protocol::list() @@ -216,9 +214,7 @@ NetworkProtocol::NetworkProtocol() this, &NetworkProtocol::authenticationRequired); } -NetworkProtocol::~NetworkProtocol() -{ -} +NetworkProtocol::~NetworkProtocol() = default; void NetworkProtocol::requestAuthentication(const QUrl &url, QNetworkReply *reply, QAuthenticator *authenticator) { diff --git a/src/plugins/cpaster/protocol.h b/src/plugins/cpaster/protocol.h index 20cad376121..0b1392656ae 100644 --- a/src/plugins/cpaster/protocol.h +++ b/src/plugins/cpaster/protocol.h @@ -63,7 +63,7 @@ public: virtual bool hasSettings() const; virtual Core::IOptionsPage *settingsPage() const; - virtual bool checkConfiguration(QString *errorMessage = 0); + virtual bool checkConfiguration(QString *errorMessage = nullptr); virtual void fetch(const QString &id) = 0; virtual void list(); virtual void paste(const QString &text, @@ -80,11 +80,11 @@ public: // Return true when settings changed. static bool showConfigurationError(const Protocol *p, const QString &message, - QWidget *parent = 0, + QWidget *parent = nullptr, bool showConfig = true); // Ensure configuration is correct static bool ensureConfiguration(Protocol *p, - QWidget *parent = 0); + QWidget *parent = nullptr); signals: void pasteDone(const QString &link); diff --git a/src/plugins/cpaster/settingspage.cpp b/src/plugins/cpaster/settingspage.cpp index 4f50ebda0f5..1054b4500cf 100644 --- a/src/plugins/cpaster/settingspage.cpp +++ b/src/plugins/cpaster/settingspage.cpp @@ -73,9 +73,7 @@ SettingsPage::SettingsPage(const QSharedPointer<Settings> &settings, QObject *pa Utils::Theme::PanelTextColorDark}}, Utils::Icon::Tint)); } -SettingsPage::~SettingsPage() -{ -} +SettingsPage::~SettingsPage() = default; QWidget *SettingsPage::widget() { diff --git a/src/plugins/cpaster/settingspage.h b/src/plugins/cpaster/settingspage.h index 3abfd0397a8..e2b9715ead7 100644 --- a/src/plugins/cpaster/settingspage.h +++ b/src/plugins/cpaster/settingspage.h @@ -42,7 +42,7 @@ class SettingsWidget : public QWidget Q_OBJECT public: - explicit SettingsWidget(const QStringList &protocols, QWidget *parent = 0); + explicit SettingsWidget(const QStringList &protocols, QWidget *parent = nullptr); void setSettings(const Settings &); Settings settings(); diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp index afc777be1a8..7878ee1533a 100644 --- a/src/plugins/cppeditor/cppquickfixes.cpp +++ b/src/plugins/cppeditor/cppquickfixes.cpp @@ -3704,7 +3704,7 @@ void ExtractFunction::match(const CppQuickFixInterface &interface, QuickFixOpera int selStart = cursor.selectionStart(); int selEnd = cursor.selectionEnd(); if (selStart > selEnd) - qSwap(selStart, selEnd); + std::swap(selStart, selEnd); Overview printer; diff --git a/src/plugins/cpptools/cppcodemodelsettings.cpp b/src/plugins/cpptools/cppcodemodelsettings.cpp index 7a5c9877401..c5aee2089bc 100644 --- a/src/plugins/cpptools/cppcodemodelsettings.cpp +++ b/src/plugins/cpptools/cppcodemodelsettings.cpp @@ -38,7 +38,7 @@ static Core::Id initialClangDiagnosticConfigId() { return Core::Id(Constants::CPP_CLANG_BUILTIN_CONFIG_ID_EVERYTHING_WITH_EXCEPTIONS); } static CppCodeModelSettings::PCHUsage initialPchUsage() -{ return CppCodeModelSettings::PchUse_None; } +{ return CppCodeModelSettings::PchUse_BuildSystem; } static QString clangDiagnosticConfigKey() { return QStringLiteral("ClangDiagnosticConfig"); } diff --git a/src/plugins/cpptools/cppcodemodelsettings.h b/src/plugins/cpptools/cppcodemodelsettings.h index 92e52554c2e..d1783711f19 100644 --- a/src/plugins/cpptools/cppcodemodelsettings.h +++ b/src/plugins/cpptools/cppcodemodelsettings.h @@ -78,7 +78,7 @@ signals: void changed(); private: - PCHUsage m_pchUsage = PchUse_None; + PCHUsage m_pchUsage = PchUse_BuildSystem; bool m_interpretAmbigiousHeadersAsCHeaders = false; bool m_skipIndexingBigFiles = true; int m_indexerFileSizeLimitInMB = 5; diff --git a/src/plugins/debugger/analyzer/analyzerutils.cpp b/src/plugins/debugger/analyzer/analyzerutils.cpp index 2a300675625..4c6e92ddbcc 100644 --- a/src/plugins/debugger/analyzer/analyzerutils.cpp +++ b/src/plugins/debugger/analyzer/analyzerutils.cpp @@ -46,7 +46,7 @@ static void moveCursorToEndOfName(QTextCursor *tc) return; QChar ch = doc->characterAt(tc->position()); - while (ch.isLetterOrNumber() || ch == QLatin1Char('_')) { + while (ch.isLetterOrNumber() || ch == '_') { tc->movePosition(QTextCursor::NextCharacter); ch = doc->characterAt(tc->position()); } diff --git a/src/plugins/debugger/analyzer/startremotedialog.cpp b/src/plugins/debugger/analyzer/startremotedialog.cpp index efee140a953..07025362629 100644 --- a/src/plugins/debugger/analyzer/startremotedialog.cpp +++ b/src/plugins/debugger/analyzer/startremotedialog.cpp @@ -86,12 +86,12 @@ StartRemoteDialog::StartRemoteDialog(QWidget *parent) verticalLayout->addWidget(d->buttonBox); QSettings *settings = Core::ICore::settings(); - settings->beginGroup(QLatin1String("AnalyzerStartRemoteDialog")); + settings->beginGroup("AnalyzerStartRemoteDialog"); d->kitChooser->populate(); - d->kitChooser->setCurrentKitId(Core::Id::fromSetting(settings->value(QLatin1String("profile")))); - d->executable->setText(settings->value(QLatin1String("executable")).toString()); - d->workingDirectory->setText(settings->value(QLatin1String("workingDirectory")).toString()); - d->arguments->setText(settings->value(QLatin1String("arguments")).toString()); + d->kitChooser->setCurrentKitId(Core::Id::fromSetting(settings->value("profile"))); + d->executable->setText(settings->value("executable").toString()); + d->workingDirectory->setText(settings->value("workingDirectory").toString()); + d->arguments->setText(settings->value("arguments").toString()); settings->endGroup(); connect(d->kitChooser, &KitChooser::activated, this, &StartRemoteDialog::validate); @@ -112,11 +112,11 @@ StartRemoteDialog::~StartRemoteDialog() void StartRemoteDialog::accept() { QSettings *settings = Core::ICore::settings(); - settings->beginGroup(QLatin1String("AnalyzerStartRemoteDialog")); - settings->setValue(QLatin1String("profile"), d->kitChooser->currentKitId().toString()); - settings->setValue(QLatin1String("executable"), d->executable->text()); - settings->setValue(QLatin1String("workingDirectory"), d->workingDirectory->text()); - settings->setValue(QLatin1String("arguments"), d->arguments->text()); + settings->beginGroup("AnalyzerStartRemoteDialog"); + settings->setValue("profile", d->kitChooser->currentKitId().toString()); + settings->setValue("executable", d->executable->text()); + settings->setValue("workingDirectory", d->workingDirectory->text()); + settings->setValue("arguments", d->arguments->text()); settings->endGroup(); QDialog::accept(); diff --git a/src/plugins/debugger/breakhandler.cpp b/src/plugins/debugger/breakhandler.cpp index 9d1fc007ca5..bf340113275 100644 --- a/src/plugins/debugger/breakhandler.cpp +++ b/src/plugins/debugger/breakhandler.cpp @@ -403,7 +403,7 @@ BreakpointDialog::BreakpointDialog(unsigned int enabledParts, QWidget *parent) m_labelType->setBuddy(m_comboBoxType); m_pathChooserFileName = new PathChooser(groupBoxBasic); - m_pathChooserFileName->setHistoryCompleter(QLatin1String("Debugger.Breakpoint.File.History")); + m_pathChooserFileName->setHistoryCompleter("Debugger.Breakpoint.File.History"); m_pathChooserFileName->setExpectedKind(PathChooser::File); m_labelFileName = new QLabel(tr("&File name:"), groupBoxBasic); m_labelFileName->setBuddy(m_pathChooserFileName); @@ -1028,7 +1028,7 @@ int BreakHandler::threadSpecFromDisplay(const QString &str) return ok ? result : -1; } -const QString empty(QLatin1Char('-')); +const QString empty("-"); QVariant BreakpointItem::data(int column, int role) const { diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index 57d81816bf0..98d9145d017 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -310,7 +310,7 @@ static QStringList mergeEnvironment(QStringList runConfigEnvironment, // We do not assume someone sets _NT_DEBUGGER_EXTENSION_PATH in the run // config, just to make sure, delete any existing entries const QString cdbExtensionPathVariableAssign = - QLatin1String(cdbExtensionPathVariableC) + QLatin1Char('='); + QLatin1String(cdbExtensionPathVariableC) + '='; for (QStringList::iterator it = runConfigEnvironment.begin(); it != runConfigEnvironment.end() ; ) { if (it->startsWith(cdbExtensionPathVariableAssign)) { it = runConfigEnvironment.erase(it); @@ -484,7 +484,7 @@ void CdbEngine::setupEngine() // Make sure that QTestLib uses OutputDebugString for logging. const QString qtLoggingToConsoleKey = QStringLiteral("QT_LOGGING_TO_CONSOLE"); if (!sp.useTerminal && !inferiorEnvironment.hasKey(qtLoggingToConsoleKey)) - inferiorEnvironment.set(qtLoggingToConsoleKey, QString(QLatin1Char('0'))); + inferiorEnvironment.set(qtLoggingToConsoleKey, "0"); m_process.setEnvironment(mergeEnvironment(inferiorEnvironment.toStringList(), extensionFi.absolutePath())); @@ -1969,7 +1969,7 @@ void CdbEngine::ensureUsing32BitStackInWow64(const DebuggerResponse &response, c { // Parsing the header of the stack output to check which bitness // the cdb is currently using. - foreach (const QStringRef &line, response.data.data().splitRef(QLatin1Char('\n'))) { + foreach (const QStringRef &line, response.data.data().splitRef('\n')) { if (!line.startsWith("Child")) continue; if (line.startsWith("ChildEBP")) { @@ -2344,9 +2344,9 @@ void CdbEngine::parseOutputLine(QString line) // for some incomprehensible reasons Microsoft cdb version 6.2 is newer than 6.12 m_autoBreakPointCorrection = major > 6 || (major == 6 && minor >= 2 && minor < 10); showMessage(line, LogMisc); - showMessage(QString::fromLatin1("Using ") + showMessage("Using " + QLatin1String(m_autoBreakPointCorrection ? "CDB " : "codemodel ") - + QString::fromLatin1("based breakpoint correction."), LogMisc); + + "based breakpoint correction.", LogMisc); } } } else if (line.startsWith("ModLoad: ")) { @@ -2736,8 +2736,8 @@ void CdbEngine::setupScripting(const DebuggerResponse &response) } const QString &verOutput = data.childAt(0).data(); - const QString firstToken = verOutput.split(QLatin1Char(' ')).constFirst(); - const QVector<QStringRef> pythonVersion = firstToken.splitRef(QLatin1Char('.')); + const QString firstToken = verOutput.split(' ').constFirst(); + const QVector<QStringRef> pythonVersion = firstToken.splitRef('.'); bool ok = false; if (pythonVersion.size() == 3) { diff --git a/src/plugins/debugger/cdb/cdboptionspage.cpp b/src/plugins/debugger/cdb/cdboptionspage.cpp index 9dacfe34ec1..b6c6a29f0a4 100644 --- a/src/plugins/debugger/cdb/cdboptionspage.cpp +++ b/src/plugins/debugger/cdb/cdboptionspage.cpp @@ -145,7 +145,7 @@ QStringList CdbBreakEventWidget::breakEvents() const const QString filter = filterText(e); QString s = QLatin1String(eventDescriptions[e].abbreviation); if (!filter.isEmpty()) { - s += QLatin1Char(':'); + s += ':'; s += filter; } rc.push_back(s); diff --git a/src/plugins/debugger/cdb/cdbparsehelpers.cpp b/src/plugins/debugger/cdb/cdbparsehelpers.cpp index 83442235d90..58047ce12fe 100644 --- a/src/plugins/debugger/cdb/cdbparsehelpers.cpp +++ b/src/plugins/debugger/cdb/cdbparsehelpers.cpp @@ -66,7 +66,7 @@ QString cdbSourcePathMapping(QString fileName, // Map parts of the path and ensure a slash follows. if (fileName.size() > sourceSize && fileName.startsWith(source, Qt::CaseInsensitive)) { const QChar next = fileName.at(sourceSize); - if (next == QLatin1Char('\\') || next == QLatin1Char('/')) { + if (next == '\\' || next == '/') { const QString &target = mode == DebuggerToSource ? m.second: m.first; fileName.replace(0, sourceSize, target); return fileName; @@ -105,23 +105,23 @@ static BreakpointParameters fixWinMSVCBreakpoint(const BreakpointParameters &p) break; case BreakpointAtExec: { // Emulate by breaking on CreateProcessW(). BreakpointParameters rc(BreakpointByFunction); - rc.module = QLatin1String("kernel32"); - rc.functionName = QLatin1String("CreateProcessW"); + rc.module = "kernel32"; + rc.functionName = "CreateProcessW"; return rc; } case BreakpointAtThrow: { BreakpointParameters rc(BreakpointByFunction); - rc.functionName = QLatin1String("CxxThrowException"); // MSVC runtime. Potentially ambiguous. + rc.functionName = "CxxThrowException"; // MSVC runtime. Potentially ambiguous. return rc; } case BreakpointAtCatch: { BreakpointParameters rc(BreakpointByFunction); - rc.functionName = QLatin1String("__CxxCallCatchBlock"); // MSVC runtime. Potentially ambiguous. + rc.functionName = "__CxxCallCatchBlock"; // MSVC runtime. Potentially ambiguous. return rc; } case BreakpointAtMain: { BreakpointParameters rc(BreakpointByFunction); - rc.functionName = QLatin1String("main"); + rc.functionName = "main"; return rc; } } // switch @@ -402,12 +402,12 @@ bool parseCdbDisassemblerFunctionLine(const QString &l, QString *currentFunction, quint64 *functionOffset, QString *sourceFile) { - if (l.isEmpty() || !l.endsWith(QLatin1Char(':')) || l.at(0).isDigit() || l.at(0).isSpace()) + if (l.isEmpty() || !l.endsWith(':') || l.at(0).isDigit() || l.at(0).isSpace()) return false; - int functionEnd = l.indexOf(QLatin1Char(' ')); + int functionEnd = l.indexOf(' '); if (functionEnd < 0) functionEnd = l.size() - 1; // Nothing at all, just ':' - const int offsetPos = l.indexOf(QLatin1String("+0x")); + const int offsetPos = l.indexOf("+0x"); if (offsetPos > 0) { *currentFunction = l.left(offsetPos); *functionOffset = l.mid(offsetPos + 3, functionEnd - offsetPos - 3).trimmed().toULongLong(nullptr, 16); @@ -417,10 +417,10 @@ bool parseCdbDisassemblerFunctionLine(const QString &l, } sourceFile->clear(); // Parse file and line. - const int filePos = l.indexOf(QLatin1Char('['), functionEnd); + const int filePos = l.indexOf('[', functionEnd); if (filePos == -1) return true; // No file - const int linePos = l.indexOf(QLatin1String(" @ "), filePos + 1); + const int linePos = l.indexOf(" @ ", filePos + 1); if (linePos == -1) return false; *sourceFile = l.mid(filePos + 1, linePos - filePos - 1).trimmed(); @@ -443,7 +443,7 @@ bool parseCdbDisassemblerLine(const QString &line, DisassemblerLine *dLine, uint *sourceLine = 0; if (line.size() < 6) return false; - const QChar blank = QLatin1Char(' '); + const QChar blank = ' '; int addressPos = 0; // Check for joined source and address in 6.11 const bool hasV611SourceLine = line.at(5).isDigit(); @@ -477,7 +477,7 @@ bool parseCdbDisassemblerLine(const QString &line, DisassemblerLine *dLine, uint const int instructionPos = rawDataEnd + 1; bool ok; QString addressS = line.mid(addressPos, addressEnd - addressPos); - if (addressS.size() > 9 && addressS.at(8) == QLatin1Char('`')) + if (addressS.size() > 9 && addressS.at(8) == '`') addressS.remove(8, 1); dLine->address = addressS.toULongLong(&ok, 16); if (!ok) diff --git a/src/plugins/debugger/commonoptionspage.cpp b/src/plugins/debugger/commonoptionspage.cpp index 2514df2c104..0aeee7f2d74 100644 --- a/src/plugins/debugger/commonoptionspage.cpp +++ b/src/plugins/debugger/commonoptionspage.cpp @@ -80,7 +80,7 @@ void CommonOptionsPage::apply() SourcePathMap allPathMap = m_sourceMappingWidget->sourcePathMap(); for (auto it = allPathMap.begin(), end = allPathMap.end(); it != end; ++it) { const QString key = it.key(); - if (key.startsWith(QLatin1Char('('))) + if (key.startsWith('(')) newOptions.sourcePathRegExpMap.append(qMakePair(QRegExp(key), it.value())); else newOptions.sourcePathMap.insert(key, it.value()); @@ -118,7 +118,7 @@ QWidget *CommonOptionsPage::widget() checkBoxUseToolTipsInMainEditor->setText(tr("Use tooltips in main editor while debugging")); QString t = tr("Stopping and stepping in the debugger " - "will automatically open views associated with the current location.") + QLatin1Char('\n'); + "will automatically open views associated with the current location.") + '\n'; auto checkBoxCloseSourceBuffersOnExit = new QCheckBox(behaviorBox); checkBoxCloseSourceBuffersOnExit->setText(tr("Close temporary source views on debugger exit")); checkBoxCloseSourceBuffersOnExit->setToolTip(t + tr("Closes automatically opened source views when the debugger exits.")); @@ -263,13 +263,13 @@ QString CommonOptionsPage::msgSetBreakpointAtFunction(const char *function) QString CommonOptionsPage::msgSetBreakpointAtFunctionToolTip(const char *function, const QString &hint) { - QString result = QLatin1String("<html><head/><body>"); + QString result = "<html><head/><body>"; result += tr("Always adds a breakpoint on the <i>%1()</i> function.").arg(QLatin1String(function)); if (!hint.isEmpty()) { - result += QLatin1String("<br>"); + result += "<br>"; result += hint; } - result += QLatin1String("</body></html>"); + result += "</body></html>"; return result; } @@ -311,11 +311,11 @@ QWidget *LocalsAndExpressionsOptionsPage::widget() auto label = new QLabel(debuggingHelperGroupBox); label->setTextFormat(Qt::AutoText); label->setWordWrap(true); - label->setText(QLatin1String("<html><head/><body>\n<p>") + label->setText("<html><head/><body>\n<p>" + tr("The debugging helpers are used to produce a nice " "display of objects of certain types like QString or " "std::map in the "Locals and Expressions" view.") - + QLatin1String("</p></body></html>")); + + "</p></body></html>"); auto groupBoxCustomDumperCommands = new QGroupBox(debuggingHelperGroupBox); groupBoxCustomDumperCommands->setTitle(tr("Debugging Helper Customization")); diff --git a/src/plugins/debugger/console/console.cpp b/src/plugins/debugger/console/console.cpp index 9391d9f05f1..1ff13a25458 100644 --- a/src/plugins/debugger/console/console.cpp +++ b/src/plugins/debugger/console/console.cpp @@ -104,7 +104,7 @@ Console::Console() m_showDebugButtonAction = new Utils::SavedAction(this); m_showDebugButtonAction->setDefaultValue(true); - m_showDebugButtonAction->setSettingsKey(QLatin1String(CONSOLE), QLatin1String(SHOW_LOG)); + m_showDebugButtonAction->setSettingsKey(CONSOLE, SHOW_LOG); m_showDebugButtonAction->setToolTip(tr("Show debug, log, and info messages.")); m_showDebugButtonAction->setCheckable(true); m_showDebugButtonAction->setChecked(true); @@ -118,7 +118,7 @@ Console::Console() m_showWarningButtonAction = new Utils::SavedAction(this); m_showWarningButtonAction->setDefaultValue(true); - m_showWarningButtonAction->setSettingsKey(QLatin1String(CONSOLE), QLatin1String(SHOW_WARNING)); + m_showWarningButtonAction->setSettingsKey(CONSOLE, SHOW_WARNING); m_showWarningButtonAction->setToolTip(tr("Show warning messages.")); m_showWarningButtonAction->setCheckable(true); m_showWarningButtonAction->setChecked(true); @@ -132,7 +132,7 @@ Console::Console() m_showErrorButtonAction = new Utils::SavedAction(this); m_showErrorButtonAction->setDefaultValue(true); - m_showErrorButtonAction->setSettingsKey(QLatin1String(CONSOLE), QLatin1String(SHOW_ERROR)); + m_showErrorButtonAction->setSettingsKey(CONSOLE, SHOW_ERROR); m_showErrorButtonAction->setToolTip(tr("Show error messages.")); m_showErrorButtonAction->setCheckable(true); m_showErrorButtonAction->setChecked(true); diff --git a/src/plugins/debugger/console/consoleitemdelegate.cpp b/src/plugins/debugger/console/consoleitemdelegate.cpp index 5a4f0becaf4..265ee6ce179 100644 --- a/src/plugins/debugger/console/consoleitemdelegate.cpp +++ b/src/plugins/debugger/console/consoleitemdelegate.cpp @@ -56,7 +56,7 @@ ConsoleItemDelegate::ConsoleItemDelegate(ConsoleItemModel *model, QObject *paren m_errorIcon(Utils::Icons::CRITICAL.icon()), m_expandIcon(Utils::Icons::EXPAND.icon()), m_collapseIcon(Utils::Icons::COLLAPSE.icon()), - m_prompt(Utils::Icon({{QLatin1String(":/utils/images/next.png"), + m_prompt(Utils::Icon({{":/utils/images/next.png", Utils::Theme::TextColorNormal}}, Utils::Icon::Tint).icon()) { } @@ -183,7 +183,7 @@ void ConsoleItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o if (!file.isEmpty()) { QFontMetrics fm(option.font); // Paint FileArea - const int pos = file.lastIndexOf(QLatin1Char('/')); + const int pos = file.lastIndexOf('/'); if (pos != -1) file = file.mid(pos +1); const int realFileWidth = fm.width(file); @@ -269,11 +269,11 @@ QWidget *ConsoleItemDelegate::createEditor(QWidget *parent, { auto editor = new ConsoleEdit(index, parent); // Make the background transparent so that the prompt shines through - editor->setStyleSheet(QLatin1String("QTextEdit {" - "margin-left: 24px;" - "margin-top: 4px;" - "background-color: transparent;" - "}")); + editor->setStyleSheet("QTextEdit {" + "margin-left: 24px;" + "margin-top: 4px;" + "background-color: transparent;" + "}"); connect(editor, &ConsoleEdit::editingFinished, this, [this, editor] { auto delegate = const_cast<ConsoleItemDelegate*>(this); emit delegate->commitData(editor); diff --git a/src/plugins/debugger/console/consoleitemmodel.cpp b/src/plugins/debugger/console/consoleitemmodel.cpp index 383a0e7b643..525aca0dc0d 100644 --- a/src/plugins/debugger/console/consoleitemmodel.cpp +++ b/src/plugins/debugger/console/consoleitemmodel.cpp @@ -87,7 +87,7 @@ int ConsoleItemModel::sizeOfFile(const QFont &font) if (lastReadOnlyRow < 0) return 0; QString filename = static_cast<ConsoleItem *>(rootItem()->childAt(lastReadOnlyRow))->file(); - const int pos = filename.lastIndexOf(QLatin1Char('/')); + const int pos = filename.lastIndexOf('/'); if (pos != -1) filename = filename.mid(pos + 1); @@ -100,7 +100,7 @@ int ConsoleItemModel::sizeOfFile(const QFont &font) int ConsoleItemModel::sizeOfLineNumber(const QFont &font) { QFontMetrics fm(font); - return fm.width(QLatin1String("88888")); + return fm.width("88888"); } } // Internal diff --git a/src/plugins/debugger/console/consoleview.cpp b/src/plugins/debugger/console/consoleview.cpp index 2891e1aa0bc..9969bfb0f5c 100644 --- a/src/plugins/debugger/console/consoleview.cpp +++ b/src/plugins/debugger/console/consoleview.cpp @@ -84,30 +84,30 @@ ConsoleView::ConsoleView(ConsoleItemModel *model, QWidget *parent) : setHeaderHidden(true); setRootIsDecorated(false); setEditTriggers(QAbstractItemView::AllEditTriggers); - setStyleSheet(QLatin1String("QTreeView::branch:has-siblings:!adjoins-item {" - "border-image: none;" - "image: none; }" - "QTreeView::branch:has-siblings:adjoins-item {" - "border-image: none;" - "image: none; }" - "QTreeView::branch:!has-children:!has-siblings:adjoins-item {" - "border-image: none;" - "image: none; }" - "QTreeView::branch:has-children:!has-siblings:closed," - "QTreeView::branch:closed:has-children:has-siblings {" - "border-image: none;" - "image: none; }" - "QTreeView::branch:open:has-children:!has-siblings," - "QTreeView::branch:open:has-children:has-siblings {" - "border-image: none;" - "image: none; }")); + setStyleSheet("QTreeView::branch:has-siblings:!adjoins-item {" + "border-image: none;" + "image: none; }" + "QTreeView::branch:has-siblings:adjoins-item {" + "border-image: none;" + "image: none; }" + "QTreeView::branch:!has-children:!has-siblings:adjoins-item {" + "border-image: none;" + "image: none; }" + "QTreeView::branch:has-children:!has-siblings:closed," + "QTreeView::branch:closed:has-children:has-siblings {" + "border-image: none;" + "image: none; }" + "QTreeView::branch:open:has-children:!has-siblings," + "QTreeView::branch:open:has-children:has-siblings {" + "border-image: none;" + "image: none; }"); QString baseName = QApplication::style()->objectName(); if (Utils::HostOsInfo::isAnyUnixHost() && !Utils::HostOsInfo::isMacHost() - && baseName == QLatin1String("windows")) { + && baseName == "windows") { // Sometimes we get the standard windows 95 style as a fallback - if (QStyleFactory::keys().contains(QLatin1String("Fusion"))) { - baseName = QLatin1String("fusion"); // Qt5 + if (QStyleFactory::keys().contains("Fusion")) { + baseName = "fusion"; // Qt5 } } auto style = new ConsoleViewStyle(baseName); diff --git a/src/plugins/debugger/debuggeractions.cpp b/src/plugins/debugger/debuggeractions.cpp index 6d44afdadcd..aeb3cf992e9 100644 --- a/src/plugins/debugger/debuggeractions.cpp +++ b/src/plugins/debugger/debuggeractions.cpp @@ -52,10 +52,10 @@ namespace Internal { void GlobalDebuggerOptions::toSettings() const { QSettings *s = Core::ICore::settings(); - s->beginWriteArray(QLatin1String(sourcePathMappingArrayNameC)); + s->beginWriteArray(sourcePathMappingArrayNameC); if (!sourcePathMap.isEmpty() || !sourcePathRegExpMap.isEmpty()) { - const QString sourcePathMappingSourceKey = QLatin1String(sourcePathMappingSourceKeyC); - const QString sourcePathMappingTargetKey = QLatin1String(sourcePathMappingTargetKeyC); + const QString sourcePathMappingSourceKey(sourcePathMappingSourceKeyC); + const QString sourcePathMappingTargetKey(sourcePathMappingTargetKeyC); int i = 0; for (auto it = sourcePathMap.constBegin(), cend = sourcePathMap.constEnd(); it != cend; @@ -79,14 +79,14 @@ void GlobalDebuggerOptions::fromSettings() { QSettings *s = Core::ICore::settings(); sourcePathMap.clear(); - if (const int count = s->beginReadArray(QLatin1String(sourcePathMappingArrayNameC))) { - const QString sourcePathMappingSourceKey = QLatin1String(sourcePathMappingSourceKeyC); - const QString sourcePathMappingTargetKey = QLatin1String(sourcePathMappingTargetKeyC); + if (const int count = s->beginReadArray(sourcePathMappingArrayNameC)) { + const QString sourcePathMappingSourceKey(sourcePathMappingSourceKeyC); + const QString sourcePathMappingTargetKey(sourcePathMappingTargetKeyC); for (int i = 0; i < count; ++i) { s->setArrayIndex(i); const QString key = s->value(sourcePathMappingSourceKey).toString(); const QString value = s->value(sourcePathMappingTargetKey).toString(); - if (key.startsWith(QLatin1Char('('))) + if (key.startsWith('(')) sourcePathRegExpMap.append(qMakePair(QRegExp(key), value)); else sourcePathMap.insert(key, value); @@ -107,8 +107,8 @@ DebuggerSettings::DebuggerSettings() { theDebuggerSettings = this; - const QString debugModeGroup = QLatin1String(debugModeSettingsGroupC); - const QString cdbSettingsGroup = QLatin1String(cdbSettingsGroupC); + const QString debugModeGroup(debugModeSettingsGroupC); + const QString cdbSettingsGroup(cdbSettingsGroupC); SavedAction *item = nullptr; @@ -124,35 +124,34 @@ DebuggerSettings::DebuggerSettings() item->setCheckable(true); item->setValue(true); item->setDefaultValue(true); - item->setSettingsKey(debugModeGroup, - QLatin1String("AlwaysAdjustColumnWidths")); + item->setSettingsKey(debugModeGroup, "AlwaysAdjustColumnWidths"); insertItem(AlwaysAdjustColumnWidths, item); // Needed by QML Inspector item = new SavedAction(this); item->setText(tr("Use Alternating Row Colors")); - item->setSettingsKey(debugModeGroup, QLatin1String("UseAlternatingRowColours")); + item->setSettingsKey(debugModeGroup, "UseAlternatingRowColours"); item->setCheckable(true); item->setDefaultValue(false); insertItem(UseAlternatingRowColors, item); item = new SavedAction(this); item->setText(tr("Keep Editor Stationary When Stepping")); - item->setSettingsKey(debugModeGroup, QLatin1String("StationaryEditorWhileStepping")); + item->setSettingsKey(debugModeGroup, "StationaryEditorWhileStepping"); item->setCheckable(true); item->setDefaultValue(false); insertItem(StationaryEditorWhileStepping, item); item = new SavedAction(this); item->setText(tr("Debugger Font Size Follows Main Editor")); - item->setSettingsKey(debugModeGroup, QLatin1String("FontSizeFollowsEditor")); + item->setSettingsKey(debugModeGroup, "FontSizeFollowsEditor"); item->setCheckable(true); item->setDefaultValue(false); insertItem(FontSizeFollowsEditor, item); item = new SavedAction(this); item->setText(tr("Show a Message Box When Receiving a Signal")); - item->setSettingsKey(debugModeGroup, QLatin1String("UseMessageBoxForSignals")); + item->setSettingsKey(debugModeGroup, "UseMessageBoxForSignals"); item->setCheckable(true); item->setDefaultValue(true); item->setValue(true); @@ -160,7 +159,7 @@ DebuggerSettings::DebuggerSettings() item = new SavedAction(this); item->setText(tr("Log Time Stamps")); - item->setSettingsKey(debugModeGroup, QLatin1String("LogTimeStamps")); + item->setSettingsKey(debugModeGroup, "LogTimeStamps"); item->setCheckable(true); item->setDefaultValue(false); insertItem(LogTimeStamps, item); @@ -169,7 +168,7 @@ DebuggerSettings::DebuggerSettings() item->setText(tr("Dereference Pointers Automatically")); item->setCheckable(true); item->setDefaultValue(true); - item->setSettingsKey(debugModeGroup, QLatin1String("AutoDerefPointers")); + item->setSettingsKey(debugModeGroup, "AutoDerefPointers"); item->setToolTip(tr("<p>This switches the Locals and Expressions view to " "automatically dereference pointers. This saves a level in the " "tree view, but also loses data for the now-missing intermediate " @@ -182,71 +181,71 @@ DebuggerSettings::DebuggerSettings() item = new SavedAction(this); item->setDefaultValue(QString()); - item->setSettingsKey(cdbSettingsGroup, QLatin1String("AdditionalArguments")); + item->setSettingsKey(cdbSettingsGroup, "AdditionalArguments"); insertItem(CdbAdditionalArguments, item); item = new SavedAction(this); item->setDefaultValue(QStringList()); - item->setSettingsKey(cdbSettingsGroup, QLatin1String("SymbolPaths")); + item->setSettingsKey(cdbSettingsGroup, "SymbolPaths"); insertItem(CdbSymbolPaths, item); item = new SavedAction(this); item->setDefaultValue(QStringList()); - item->setSettingsKey(cdbSettingsGroup, QLatin1String("SourcePaths")); + item->setSettingsKey(cdbSettingsGroup, "SourcePaths"); insertItem(CdbSourcePaths, item); item = new SavedAction(this); item->setDefaultValue(QStringList()); - item->setSettingsKey(cdbSettingsGroup, QLatin1String("BreakEvent")); + item->setSettingsKey(cdbSettingsGroup, "BreakEvent"); insertItem(CdbBreakEvents, item); item = new SavedAction(this); item->setCheckable(true); item->setDefaultValue(false); - item->setSettingsKey(cdbSettingsGroup, QLatin1String("BreakOnCrtDbgReport")); + item->setSettingsKey(cdbSettingsGroup, "BreakOnCrtDbgReport"); insertItem(CdbBreakOnCrtDbgReport, item); item = new SavedAction(this); item->setCheckable(true); item->setDefaultValue(false); - item->setSettingsKey(cdbSettingsGroup, QLatin1String("CDB_Console")); + item->setSettingsKey(cdbSettingsGroup, "CDB_Console"); insertItem(UseCdbConsole, item); item = new SavedAction(this); item->setCheckable(true); item->setDefaultValue(true); - item->setSettingsKey(cdbSettingsGroup, QLatin1String("BreakpointCorrection")); + item->setSettingsKey(cdbSettingsGroup, "BreakpointCorrection"); insertItem(CdbBreakPointCorrection, item); item = new SavedAction(this); item->setCheckable(true); item->setDefaultValue(true); - item->setSettingsKey(cdbSettingsGroup, QLatin1String("UsePythonDumper")); + item->setSettingsKey(cdbSettingsGroup, "UsePythonDumper"); insertItem(CdbUsePythonDumper, item); item = new SavedAction(this); item->setCheckable(true); item->setDefaultValue(true); - item->setSettingsKey(cdbSettingsGroup, QLatin1String("FirstChanceExceptionTaskEntry")); + item->setSettingsKey(cdbSettingsGroup, "FirstChanceExceptionTaskEntry"); insertItem(FirstChanceExceptionTaskEntry, item); item = new SavedAction(this); item->setCheckable(true); item->setDefaultValue(true); - item->setSettingsKey(cdbSettingsGroup, QLatin1String("SecondChanceExceptionTaskEntry")); + item->setSettingsKey(cdbSettingsGroup, "SecondChanceExceptionTaskEntry"); insertItem(SecondChanceExceptionTaskEntry, item); item = new SavedAction(this); item->setCheckable(true); item->setDefaultValue(false); - item->setSettingsKey(cdbSettingsGroup, QLatin1String("IgnoreFirstChanceAccessViolation")); + item->setSettingsKey(cdbSettingsGroup, "IgnoreFirstChanceAccessViolation"); insertItem(IgnoreFirstChanceAccessViolation, item); // // Locals & Watchers // item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("ShowStandardNamespace")); + item->setSettingsKey(debugModeGroup, "ShowStandardNamespace"); item->setText(tr("Show \"std::\" Namespace in Types")); item->setDialogText(tr("Show \"std::\" namespace in types")); item->setToolTip(tr("<p>Shows \"std::\" prefix for types from the standard library.")); @@ -256,7 +255,7 @@ DebuggerSettings::DebuggerSettings() insertItem(ShowStdNamespace, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("ShowQtNamespace")); + item->setSettingsKey(debugModeGroup, "ShowQtNamespace"); item->setText(tr("Show Qt's Namespace in Types")); item->setDialogText(tr("Show Qt's namespace in types")); item->setToolTip(tr("<p>Shows Qt namespace prefix for Qt types. This is only " @@ -267,7 +266,7 @@ DebuggerSettings::DebuggerSettings() insertItem(ShowQtNamespace, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("ShowQObjectNames2")); + item->setSettingsKey(debugModeGroup, "ShowQObjectNames2"); item->setText(tr("Show QObject names if available")); item->setDialogText(tr("Show QObject names if available")); item->setToolTip(tr("<p>Displays the objectName property of QObject based items. " @@ -279,7 +278,7 @@ DebuggerSettings::DebuggerSettings() insertItem(ShowQObjectNames, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("SortStructMembers")); + item->setSettingsKey(debugModeGroup, "SortStructMembers"); item->setText(tr("Sort Members of Classes and Structs Alphabetically")); item->setDialogText(tr("Sort members of classes and structs alphabetically")); item->setCheckable(true); @@ -291,7 +290,7 @@ DebuggerSettings::DebuggerSettings() // DebuggingHelper // item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("UseDebuggingHelper")); + item->setSettingsKey(debugModeGroup, "UseDebuggingHelper"); item->setText(tr("Use Debugging Helpers")); item->setCheckable(true); item->setDefaultValue(true); @@ -299,7 +298,7 @@ DebuggerSettings::DebuggerSettings() insertItem(UseDebuggingHelpers, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("UseCodeModel")); + item->setSettingsKey(debugModeGroup, "UseCodeModel"); item->setDialogText(tr("Use code model")); item->setToolTip(tr("<p>Selecting this causes the C++ Code Model being asked " "for variable scope information. This might result in slightly faster " @@ -310,7 +309,7 @@ DebuggerSettings::DebuggerSettings() insertItem(UseCodeModel, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("ShowThreadNames")); + item->setSettingsKey(debugModeGroup, "ShowThreadNames"); item->setToolTip(tr("<p>Displays names of QThread based threads.")); item->setDialogText(tr("Display thread names")); item->setCheckable(true); @@ -337,7 +336,7 @@ DebuggerSettings::DebuggerSettings() item->setCheckable(true); item->setDefaultValue(true); item->setValue(true); - item->setSettingsKey(debugModeGroup, QLatin1String("AdjustBreakpointLocations")); + item->setSettingsKey(debugModeGroup, "AdjustBreakpointLocations"); insertItem(AdjustBreakpointLocations, item); item = new SavedAction(this); @@ -345,7 +344,7 @@ DebuggerSettings::DebuggerSettings() item->setCheckable(true); item->setDefaultValue(false); item->setValue(false); - item->setSettingsKey(debugModeGroup, QLatin1String("BreakOnThrow")); + item->setSettingsKey(debugModeGroup, "BreakOnThrow"); insertItem(BreakOnThrow, item); item = new SavedAction(this); @@ -353,7 +352,7 @@ DebuggerSettings::DebuggerSettings() item->setCheckable(true); item->setDefaultValue(false); item->setValue(false); - item->setSettingsKey(debugModeGroup, QLatin1String("BreakOnCatch")); + item->setSettingsKey(debugModeGroup, "BreakOnCatch"); insertItem(BreakOnCatch, item); item = new SavedAction(this); @@ -361,7 +360,7 @@ DebuggerSettings::DebuggerSettings() item->setCheckable(true); item->setDefaultValue(false); item->setValue(false); - item->setSettingsKey(debugModeGroup, QLatin1String("BreakOnWarning")); + item->setSettingsKey(debugModeGroup, "BreakOnWarning"); insertItem(BreakOnWarning, item); item = new SavedAction(this); @@ -369,7 +368,7 @@ DebuggerSettings::DebuggerSettings() item->setCheckable(true); item->setDefaultValue(false); item->setValue(false); - item->setSettingsKey(debugModeGroup, QLatin1String("BreakOnFatal")); + item->setSettingsKey(debugModeGroup, "BreakOnFatal"); insertItem(BreakOnFatal, item); item = new SavedAction(this); @@ -377,7 +376,7 @@ DebuggerSettings::DebuggerSettings() item->setCheckable(true); item->setDefaultValue(false); item->setValue(false); - item->setSettingsKey(debugModeGroup, QLatin1String("BreakOnAbort")); + item->setSettingsKey(debugModeGroup, "BreakOnAbort"); insertItem(BreakOnAbort, item); // @@ -385,7 +384,7 @@ DebuggerSettings::DebuggerSettings() // item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("LoadGdbInit")); + item->setSettingsKey(debugModeGroup, "LoadGdbInit"); item->setDefaultValue(QString()); item->setCheckable(true); item->setDefaultValue(true); @@ -393,7 +392,7 @@ DebuggerSettings::DebuggerSettings() insertItem(LoadGdbInit, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("LoadGdbDumpers2")); + item->setSettingsKey(debugModeGroup, "LoadGdbDumpers2"); item->setDefaultValue(QString()); item->setCheckable(true); item->setDefaultValue(false); @@ -401,7 +400,7 @@ DebuggerSettings::DebuggerSettings() insertItem(LoadGdbDumpers, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("AutoEnrichParameters")); + item->setSettingsKey(debugModeGroup, "AutoEnrichParameters"); item->setDefaultValue(QString()); item->setCheckable(true); item->setDefaultValue(true); @@ -409,7 +408,7 @@ DebuggerSettings::DebuggerSettings() insertItem(AutoEnrichParameters, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("UseDynamicType")); + item->setSettingsKey(debugModeGroup, "UseDynamicType"); item->setText(tr("Use Dynamic Object Type for Display")); item->setCheckable(true); item->setDefaultValue(true); @@ -417,95 +416,95 @@ DebuggerSettings::DebuggerSettings() insertItem(UseDynamicType, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("TargetAsync")); + item->setSettingsKey(debugModeGroup, "TargetAsync"); item->setCheckable(true); item->setDefaultValue(false); item->setValue(false); insertItem(TargetAsync, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("WarnOnReleaseBuilds")); + item->setSettingsKey(debugModeGroup, "WarnOnReleaseBuilds"); item->setCheckable(true); item->setDefaultValue(true); insertItem(WarnOnReleaseBuilds, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("GdbStartupCommands")); + item->setSettingsKey(debugModeGroup, "GdbStartupCommands"); item->setDefaultValue(QString()); insertItem(GdbStartupCommands, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("GdbCustomDumperCommands")); + item->setSettingsKey(debugModeGroup, "GdbCustomDumperCommands"); item->setDefaultValue(QString()); insertItem(ExtraDumperCommands, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("ExtraDumperFile")); + item->setSettingsKey(debugModeGroup, "ExtraDumperFile"); item->setDefaultValue(QString()); insertItem(ExtraDumperFile, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("GdbPostAttachCommands")); + item->setSettingsKey(debugModeGroup, "GdbPostAttachCommands"); item->setDefaultValue(QString()); insertItem(GdbPostAttachCommands, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("CloseBuffersOnExit")); + item->setSettingsKey(debugModeGroup, "CloseBuffersOnExit"); item->setCheckable(true); item->setDefaultValue(false); insertItem(CloseSourceBuffersOnExit, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("CloseMemoryBuffersOnExit")); + item->setSettingsKey(debugModeGroup, "CloseMemoryBuffersOnExit"); item->setCheckable(true); item->setDefaultValue(true); insertItem(CloseMemoryBuffersOnExit, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("SwitchModeOnExit")); + item->setSettingsKey(debugModeGroup, "SwitchModeOnExit"); item->setCheckable(true); item->setDefaultValue(false); insertItem(SwitchModeOnExit, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("BreakpointsFullPath")); + item->setSettingsKey(debugModeGroup, "BreakpointsFullPath"); item->setCheckable(true); item->setDefaultValue(false); insertItem(BreakpointsFullPathByDefault, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("RaiseOnInterrupt")); + item->setSettingsKey(debugModeGroup, "RaiseOnInterrupt"); item->setCheckable(true); item->setDefaultValue(true); insertItem(RaiseOnInterrupt, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("AutoQuit")); + item->setSettingsKey(debugModeGroup, "AutoQuit"); item->setText(tr("Automatically Quit Debugger")); item->setCheckable(true); item->setDefaultValue(false); insertItem(AutoQuit, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("MultiInferior")); + item->setSettingsKey(debugModeGroup, "MultiInferior"); item->setCheckable(true); item->setDefaultValue(false); insertItem(MultiInferior, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("IntelFlavor")); + item->setSettingsKey(debugModeGroup, "IntelFlavor"); item->setCheckable(true); item->setDefaultValue(false); insertItem(IntelFlavor, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("IdentifyDebugInfoPackages")); + item->setSettingsKey(debugModeGroup, "IdentifyDebugInfoPackages"); item->setCheckable(true); item->setDefaultValue(false); insertItem(IdentifyDebugInfoPackages, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("UseToolTips")); + item->setSettingsKey(debugModeGroup, "UseToolTips"); item->setText(tr("Use tooltips in main editor when debugging")); item->setToolTip(tr("<p>Checking this will enable tooltips for variable " "values during debugging. Since this can slow down debugging and " @@ -516,7 +515,7 @@ DebuggerSettings::DebuggerSettings() insertItem(UseToolTipsInMainEditor, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("UseToolTipsInLocalsView")); + item->setSettingsKey(debugModeGroup, "UseToolTipsInLocalsView"); item->setText(tr("Use Tooltips in Locals View when Debugging")); item->setToolTip(tr("<p>Checking this will enable tooltips in the locals " "view during debugging.")); @@ -525,7 +524,7 @@ DebuggerSettings::DebuggerSettings() insertItem(UseToolTipsInLocalsView, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("UseToolTipsInBreakpointsView")); + item->setSettingsKey(debugModeGroup, "UseToolTipsInBreakpointsView"); item->setText(tr("Use Tooltips in Breakpoints View when Debugging")); item->setToolTip(tr("<p>Checking this will enable tooltips in the breakpoints " "view during debugging.")); @@ -534,7 +533,7 @@ DebuggerSettings::DebuggerSettings() insertItem(UseToolTipsInBreakpointsView, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("UseToolTipsInStackView")); + item->setSettingsKey(debugModeGroup, "UseToolTipsInStackView"); item->setText(tr("Use Tooltips in Stack View when Debugging")); item->setToolTip(tr("<p>Checking this will enable tooltips in the stack " "view during debugging.")); @@ -543,7 +542,7 @@ DebuggerSettings::DebuggerSettings() insertItem(UseToolTipsInStackView, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("UseAddressInBreakpointsView")); + item->setSettingsKey(debugModeGroup, "UseAddressInBreakpointsView"); item->setText(tr("Show Address Data in Breakpoints View when Debugging")); item->setToolTip(tr("<p>Checking this will show a column with address " "information in the breakpoint view during debugging.")); @@ -552,7 +551,7 @@ DebuggerSettings::DebuggerSettings() insertItem(UseAddressInBreakpointsView, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("UseAddressInStackView")); + item->setSettingsKey(debugModeGroup, "UseAddressInStackView"); item->setText(tr("Show Address Data in Stack View when Debugging")); item->setToolTip(tr("<p>Checking this will show a column with address " "information in the stack view during debugging.")); @@ -561,14 +560,14 @@ DebuggerSettings::DebuggerSettings() insertItem(UseAddressInStackView, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("SkipKnownFrames")); + item->setSettingsKey(debugModeGroup, "SkipKnownFrames"); item->setText(tr("Skip Known Frames")); item->setCheckable(true); item->setDefaultValue(false); insertItem(SkipKnownFrames, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("EnableReverseDebugging")); + item->setSettingsKey(debugModeGroup, "EnableReverseDebugging"); item->setText(tr("Enable Reverse Debugging")); item->setCheckable(true); item->setDefaultValue(false); @@ -577,7 +576,7 @@ DebuggerSettings::DebuggerSettings() #ifdef Q_OS_WIN item = new RegisterPostMortemAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("RegisterForPostMortem")); + item->setSettingsKey(debugModeGroup, "RegisterForPostMortem"); item->setText(tr("Register For Post-Mortem Debugging")); item->setCheckable(true); item->setDefaultValue(false); @@ -585,32 +584,32 @@ DebuggerSettings::DebuggerSettings() #endif item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("AllPluginBreakpoints")); + item->setSettingsKey(debugModeGroup, "AllPluginBreakpoints"); item->setDefaultValue(true); insertItem(AllPluginBreakpoints, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("SelectedPluginBreakpoints")); + item->setSettingsKey(debugModeGroup, "SelectedPluginBreakpoints"); item->setDefaultValue(false); insertItem(SelectedPluginBreakpoints, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("NoPluginBreakpoints")); + item->setSettingsKey(debugModeGroup, "NoPluginBreakpoints"); item->setDefaultValue(false); insertItem(NoPluginBreakpoints, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("SelectedPluginBreakpointsPattern")); - item->setDefaultValue(QLatin1String(".*")); + item->setSettingsKey(debugModeGroup, "SelectedPluginBreakpointsPattern"); + item->setDefaultValue(".*"); insertItem(SelectedPluginBreakpointsPattern, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("MaximalStackDepth")); + item->setSettingsKey(debugModeGroup, "MaximalStackDepth"); item->setDefaultValue(20); insertItem(MaximalStackDepth, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("DisplayStringLimit")); + item->setSettingsKey(debugModeGroup, "DisplayStringLimit"); item->setToolTip(tr("<p>The maximum length of string entries in the " "Locals and Expressions pane. Longer than that are cut off " "and displayed with an ellipsis attached.")); @@ -618,7 +617,7 @@ DebuggerSettings::DebuggerSettings() insertItem(DisplayStringLimit, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("MaximalStringLength")); + item->setSettingsKey(debugModeGroup, "MaximalStringLength"); item->setToolTip(tr("<p>The maximum length for strings in separated windows. " "Longer strings are cut off and displayed with an ellipsis attached.")); item->setDefaultValue(10000); @@ -633,7 +632,7 @@ DebuggerSettings::DebuggerSettings() insertItem(CreateFullBacktrace, item); item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("WatchdogTimeout")); + item->setSettingsKey(debugModeGroup, "WatchdogTimeout"); item->setDefaultValue(20); insertItem(GdbWatchdogTimeout, item); @@ -641,13 +640,13 @@ DebuggerSettings::DebuggerSettings() // QML Tools // item = new SavedAction(this); - item->setSettingsKey(debugModeGroup, QLatin1String("ShowQmlObjectTree")); + item->setSettingsKey(debugModeGroup, "ShowQmlObjectTree"); item->setDefaultValue(true); insertItem(ShowQmlObjectTree, item); - const QString qmlInspectorGroup = QLatin1String("QML.Inspector"); + const QString qmlInspectorGroup = "QML.Inspector"; item = new SavedAction(this); - item->setSettingsKey(qmlInspectorGroup, QLatin1String("QmlInspector.ShowAppOnTop")); + item->setSettingsKey(qmlInspectorGroup, "QmlInspector.ShowAppOnTop"); item->setDefaultValue(false); insertItem(ShowAppOnTop, item); } diff --git a/src/plugins/debugger/debuggerdialogs.cpp b/src/plugins/debugger/debuggerdialogs.cpp index f548aa0ee1e..db5731a5aa8 100644 --- a/src/plugins/debugger/debuggerdialogs.cpp +++ b/src/plugins/debugger/debuggerdialogs.cpp @@ -172,13 +172,13 @@ QString StartApplicationParameters::displayName() const const int maxLength = 60; QString name = FileName::fromString(runnable.executable).fileName() - + QLatin1Char(' ') + runnable.commandLineArguments; + + ' ' + runnable.commandLineArguments; if (name.size() > 60) { - int index = name.lastIndexOf(QLatin1Char(' '), maxLength); + int index = name.lastIndexOf(' ', maxLength); if (index == -1) index = maxLength; name.truncate(index); - name += QLatin1String("..."); + name += "..."; } if (Kit *kit = KitManager::kit(kitId)) @@ -246,15 +246,15 @@ StartApplicationDialog::StartApplicationDialog(QWidget *parent) d->localExecutablePathChooser = new PathChooser(this); d->localExecutablePathChooser->setExpectedKind(PathChooser::File); d->localExecutablePathChooser->setPromptDialogTitle(tr("Select Executable")); - d->localExecutablePathChooser->setHistoryCompleter(QLatin1String("LocalExecutable")); + d->localExecutablePathChooser->setHistoryCompleter("LocalExecutable"); d->arguments = new FancyLineEdit(this); - d->arguments->setHistoryCompleter(QLatin1String("CommandlineArguments")); + d->arguments->setHistoryCompleter("CommandlineArguments"); d->workingDirectory = new PathChooser(this); d->workingDirectory->setExpectedKind(PathChooser::ExistingDirectory); d->workingDirectory->setPromptDialogTitle(tr("Select Working Directory")); - d->workingDirectory->setHistoryCompleter(QLatin1String("WorkingDirectory")); + d->workingDirectory->setHistoryCompleter("WorkingDirectory"); d->runInTerminalCheckBox = new QCheckBox(this); @@ -277,7 +277,7 @@ StartApplicationDialog::StartApplicationDialog(QWidget *parent) d->debuginfoPathChooser->setToolTip(tr( "Base path for external debug information and debug sources. " "If empty, $SYSROOT/usr/lib/debug will be chosen.")); - d->debuginfoPathChooser->setHistoryCompleter(QLatin1String("Debugger.DebugLocation.History")); + d->debuginfoPathChooser->setHistoryCompleter("Debugger.DebugLocation.History"); auto line = new QFrame(this); line->setFrameShape(QFrame::HLine); @@ -369,8 +369,8 @@ void StartApplicationDialog::updateState() void StartApplicationDialog::run(bool attachRemote) { - const QString settingsGroup = QLatin1String("DebugMode"); - const QString arrayName = QLatin1String("StartApplication"); + const QString settingsGroup = "DebugMode"; + const QString arrayName = "StartApplication"; QList<StartApplicationParameters> history; QSettings *settings = ICore::settings(); @@ -585,8 +585,8 @@ static QString cdbRemoteHelp() "to use TCP/IP as communication protocol.</p><p>Enter the connection parameters as:</p>" "<pre>%6</pre></body></html>") .arg(Core::Constants::IDE_DISPLAY_NAME, - ext32, ext64, QLatin1String("_NT_DEBUGGER_EXTENSION_PATH"), - QLatin1String("cdb.exe -server tcp:port=1234"), + ext32, ext64, "_NT_DEBUGGER_EXTENSION_PATH", + "cdb.exe -server tcp:port=1234", QLatin1String(cdbConnectionSyntax)); } @@ -647,7 +647,7 @@ QString StartRemoteCdbDialog::connection() const { const QString rc = m_lineEdit->text(); // Transform an IP:POrt ('localhost:1234') specification into full spec - QRegExp ipRegexp(QLatin1String("([\\w\\.\\-_]+):([0-9]{1,4})")); + QRegExp ipRegexp("([\\w\\.\\-_]+):([0-9]{1,4})"); QTC_ASSERT(ipRegexp.isValid(), return QString()); if (ipRegexp.exactMatch(rc)) return QString::fromLatin1("tcp:server=%1,port=%2").arg(ipRegexp.cap(1), ipRegexp.cap(2)); @@ -669,7 +669,7 @@ AddressDialog::AddressDialog(QWidget *parent) : setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); auto hLayout = new QHBoxLayout; - hLayout->addWidget(new QLabel(tr("Enter an address:") + QLatin1Char(' '))); + hLayout->addWidget(new QLabel(tr("Enter an address:") + ' ')); hLayout->addWidget(m_lineEdit); auto vLayout = new QVBoxLayout; @@ -697,7 +697,7 @@ bool AddressDialog::isOkButtonEnabled() const void AddressDialog::setAddress(quint64 a) { - m_lineEdit->setText(QLatin1String("0x") + QString::number(a, 16)); + m_lineEdit->setText("0x" + QString::number(a, 16)); } quint64 AddressDialog::address() const @@ -748,19 +748,19 @@ StartRemoteEngineDialog::StartRemoteEngineDialog(QWidget *parent) setWindowTitle(tr("Start Remote Engine")); d->host = new FancyLineEdit(this); - d->host->setHistoryCompleter(QLatin1String("HostName")); + d->host->setHistoryCompleter("HostName"); d->username = new FancyLineEdit(this); - d->username->setHistoryCompleter(QLatin1String("UserName")); + d->username->setHistoryCompleter("UserName"); d->password = new QLineEdit(this); d->password->setEchoMode(QLineEdit::Password); d->enginePath = new FancyLineEdit(this); - d->enginePath->setHistoryCompleter(QLatin1String("EnginePath")); + d->enginePath->setHistoryCompleter("EnginePath"); d->inferiorPath = new FancyLineEdit(this); - d->inferiorPath->setHistoryCompleter(QLatin1String("InferiorPath")); + d->inferiorPath->setHistoryCompleter("InferiorPath"); d->buttonBox = new QDialogButtonBox(this); d->buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); @@ -916,11 +916,11 @@ void TypeFormatsDialog::addTypeFormats(const QString &type0, const DisplayFormats &typeFormats, int current) { QString type = type0; - type.replace(QLatin1String("__"), QLatin1String("::")); + type.replace("__", "::"); int pos = 2; - if (type.startsWith(QLatin1Char('Q'))) + if (type.startsWith('Q')) pos = 0; - else if (type.startsWith(QLatin1String("std::"))) + else if (type.startsWith("std::")) pos = 1; m_ui->pages[pos]->addTypeFormats(type, typeFormats, current); } diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index 43cd9cb20ea..e425138a2ae 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -281,7 +281,7 @@ public: m_toolTipManager(engine) { m_logWindow = new LogWindow(m_engine); // Needed before start() - m_logWindow->setObjectName(QLatin1String(DOCKWIDGET_OUTPUT)); + m_logWindow->setObjectName(DOCKWIDGET_OUTPUT); m_debuggerName = DebuggerEngine::tr("Debugger"); connect(action(EnableReverseDebugging), &SavedAction::valueChanged, @@ -503,11 +503,6 @@ public: bool m_busy = false; bool m_isDying = false; - QAction m_debugWithoutDeployAction; - QAction m_attachToQmlPortAction; - QAction m_attachToRemoteServerAction; - QAction m_startRemoteCdbAction; - QAction m_attachToCoreAction; QAction m_detachAction; OptionalAction m_continueAction{tr("Continue")}; QAction m_exitAction{tr("Stop Debugger")}; // On application output button if "Stop" is possible @@ -1317,9 +1312,6 @@ void DebuggerEnginePrivate::setInitialActionStates() m_snapshotAction.setIcon(Utils::Icons::SNAPSHOT_TOOLBAR.icon()); - m_attachToQmlPortAction.setEnabled(true); - m_attachToCoreAction.setEnabled(true); - m_attachToRemoteServerAction.setEnabled(true); m_detachAction.setEnabled(false); m_watchAction.setEnabled(true); @@ -1372,7 +1364,6 @@ void DebuggerEnginePrivate::updateState(bool alsoUpdateCompanion) m_stepIntoAction.setEnabled(true); m_stepOutAction.setEnabled(false); m_exitAction.setEnabled(false); - m_debugWithoutDeployAction.setEnabled(true); } else if (state == InferiorStopOk) { // F5 continues, Shift-F5 kills. It is "continuable". m_interruptAction.setVisible(false); @@ -1383,7 +1374,6 @@ void DebuggerEnginePrivate::updateState(bool alsoUpdateCompanion) m_stepIntoAction.setEnabled(!companionPreventsAction); m_stepOutAction.setEnabled(!companionPreventsAction); m_exitAction.setEnabled(true); - m_debugWithoutDeployAction.setEnabled(false); m_localsAndInspectorWindow->setShowLocals(true); } else if (state == InferiorRunOk) { // Shift-F5 interrupts. It is also "interruptible". @@ -1395,10 +1385,8 @@ void DebuggerEnginePrivate::updateState(bool alsoUpdateCompanion) m_stepIntoAction.setEnabled(false); m_stepOutAction.setEnabled(false); m_exitAction.setEnabled(true); - m_debugWithoutDeployAction.setEnabled(false); m_localsAndInspectorWindow->setShowLocals(false); } else if (state == DebuggerFinished) { - const bool canRun = ProjectExplorerPlugin::canRunStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE); // We don't want to do anything anymore. m_interruptAction.setVisible(true); m_interruptAction.setEnabled(false); @@ -1408,7 +1396,6 @@ void DebuggerEnginePrivate::updateState(bool alsoUpdateCompanion) m_stepIntoAction.setEnabled(false); m_stepOutAction.setEnabled(false); m_exitAction.setEnabled(false); - m_debugWithoutDeployAction.setEnabled(canRun); setBusyCursor(false); cleanupViews(); } else if (state == InferiorUnrunnable) { @@ -1421,7 +1408,6 @@ void DebuggerEnginePrivate::updateState(bool alsoUpdateCompanion) m_stepIntoAction.setEnabled(false); m_stepOutAction.setEnabled(false); m_exitAction.setEnabled(true); - m_debugWithoutDeployAction.setEnabled(false); // show locals in core dumps m_localsAndInspectorWindow->setShowLocals(true); } else { @@ -1434,13 +1420,8 @@ void DebuggerEnginePrivate::updateState(bool alsoUpdateCompanion) m_stepIntoAction.setEnabled(false); m_stepOutAction.setEnabled(false); m_exitAction.setEnabled(false); - m_debugWithoutDeployAction.setEnabled(false); } - m_attachToQmlPortAction.setEnabled(true); - m_attachToCoreAction.setEnabled(true); - m_attachToRemoteServerAction.setEnabled(true); - const bool threadsEnabled = state == InferiorStopOk || state == InferiorUnrunnable; m_threadsHandler.threadSwitcher()->setEnabled(threadsEnabled); m_threadLabel->setEnabled(threadsEnabled); @@ -1694,8 +1675,8 @@ void DebuggerEngine::showMessage(const QString &msg, int channel, int timeout) c d->m_logWindow->showOutput(LogInput, msg); break; case LogError: - d->m_logWindow->showInput(LogError, QLatin1String("ERROR: ") + msg); - d->m_logWindow->showOutput(LogError, QLatin1String("ERROR: ") + msg); + d->m_logWindow->showInput(LogError, "ERROR: " + msg); + d->m_logWindow->showOutput(LogError, "ERROR: " + msg); break; case AppOutput: case AppStuff: @@ -2404,7 +2385,7 @@ void DebuggerEngine::handleExecRunToSelectedFunction() if (functionName.isEmpty()) { const QTextBlock block = cursor.block(); const QString line = block.text(); - foreach (const QString &str, line.trimmed().split(QLatin1Char('('))) { + foreach (const QString &str, line.trimmed().split('(')) { QString a; for (int i = str.size(); --i >= 0; ) { if (!str.at(i).isLetterOrNumber()) @@ -2564,7 +2545,7 @@ QString DebuggerEngine::formatStartParameters() const if (!sp.qmlServer.host().isEmpty()) str << "QML server: " << sp.qmlServer.host() << ':' << sp.qmlServer.port() << '\n'; str << "Sysroot: " << sp.sysRoot << '\n'; - str << "Debug Source Location: " << sp.debugSourceLocation.join(QLatin1Char(':')) << '\n'; + str << "Debug Source Location: " << sp.debugSourceLocation.join(':') << '\n'; return rc; } diff --git a/src/plugins/debugger/debuggeritem.cpp b/src/plugins/debugger/debuggeritem.cpp index a160f83d297..a46908923f0 100644 --- a/src/plugins/debugger/debuggeritem.cpp +++ b/src/plugins/debugger/debuggeritem.cpp @@ -76,17 +76,17 @@ DebuggerItem::DebuggerItem(const QVariant &id) DebuggerItem::DebuggerItem(const QVariantMap &data) { - m_id = data.value(QLatin1String(DEBUGGER_INFORMATION_ID)).toString(); - m_command = FileName::fromUserInput(data.value(QLatin1String(DEBUGGER_INFORMATION_COMMAND)).toString()); + m_id = data.value(DEBUGGER_INFORMATION_ID).toString(); + m_command = FileName::fromUserInput(data.value(DEBUGGER_INFORMATION_COMMAND).toString()); m_workingDirectory = FileName::fromUserInput(data.value(DEBUGGER_INFORMATION_WORKINGDIRECTORY).toString()); - m_unexpandedDisplayName = data.value(QLatin1String(DEBUGGER_INFORMATION_DISPLAYNAME)).toString(); - m_isAutoDetected = data.value(QLatin1String(DEBUGGER_INFORMATION_AUTODETECTED), false).toBool(); - m_version = data.value(QLatin1String(DEBUGGER_INFORMATION_VERSION)).toString(); - m_engineType = DebuggerEngineType(data.value(QLatin1String(DEBUGGER_INFORMATION_ENGINETYPE), + m_unexpandedDisplayName = data.value(DEBUGGER_INFORMATION_DISPLAYNAME).toString(); + m_isAutoDetected = data.value(DEBUGGER_INFORMATION_AUTODETECTED, false).toBool(); + m_version = data.value(DEBUGGER_INFORMATION_VERSION).toString(); + m_engineType = DebuggerEngineType(data.value(DEBUGGER_INFORMATION_ENGINETYPE, static_cast<int>(NoEngineType)).toInt()); - m_lastModified = data.value(QLatin1String(DEBUGGER_INFORMATION_LASTMODIFIED)).toDateTime(); + m_lastModified = data.value(DEBUGGER_INFORMATION_LASTMODIFIED).toDateTime(); - foreach (const QString &a, data.value(QLatin1String(DEBUGGER_INFORMATION_ABIS)).toStringList()) { + foreach (const QString &a, data.value(DEBUGGER_INFORMATION_ABIS).toStringList()) { Abi abi = Abi::fromString(a); if (!abi.isNull()) m_abis.append(abi); @@ -116,12 +116,12 @@ void DebuggerItem::reinitializeFromFile() const char *version = "-version"; const QFileInfo fileInfo = m_command.toFileInfo(); m_lastModified = fileInfo.lastModified(); - if (fileInfo.baseName().toLower().contains(QLatin1String("lldb-mi"))) + if (fileInfo.baseName().toLower().contains("lldb-mi")) version = "--version"; SynchronousProcess proc; SynchronousProcessResponse response - = proc.runBlocking(m_command.toString(), QStringList({QLatin1String(version)})); + = proc.runBlocking(m_command.toString(), {QLatin1String(version)}); if (response.result != SynchronousProcessResponse::Finished) { m_engineType = NoEngineType; return; @@ -175,7 +175,7 @@ void DebuggerItem::reinitializeFromFile() // "cdb version 6.2.9200.16384" m_engineType = CdbEngineType; m_abis = Abi::abisOfBinary(m_command); - m_version = output.section(QLatin1Char(' '), 2); + m_version = output.section(' ', 2); return; } if (output.startsWith("Python")) { @@ -244,21 +244,21 @@ bool DebuggerItem::operator==(const DebuggerItem &other) const QVariantMap DebuggerItem::toMap() const { QVariantMap data; - data.insert(QLatin1String(DEBUGGER_INFORMATION_DISPLAYNAME), m_unexpandedDisplayName); - data.insert(QLatin1String(DEBUGGER_INFORMATION_ID), m_id); - data.insert(QLatin1String(DEBUGGER_INFORMATION_COMMAND), m_command.toString()); - data.insert(QLatin1String(DEBUGGER_INFORMATION_WORKINGDIRECTORY), m_workingDirectory.toString()); - data.insert(QLatin1String(DEBUGGER_INFORMATION_ENGINETYPE), int(m_engineType)); - data.insert(QLatin1String(DEBUGGER_INFORMATION_AUTODETECTED), m_isAutoDetected); - data.insert(QLatin1String(DEBUGGER_INFORMATION_VERSION), m_version); - data.insert(QLatin1String(DEBUGGER_INFORMATION_ABIS), abiNames()); - data.insert(QLatin1String(DEBUGGER_INFORMATION_LASTMODIFIED), m_lastModified); + data.insert(DEBUGGER_INFORMATION_DISPLAYNAME, m_unexpandedDisplayName); + data.insert(DEBUGGER_INFORMATION_ID, m_id); + data.insert(DEBUGGER_INFORMATION_COMMAND, m_command.toString()); + data.insert(DEBUGGER_INFORMATION_WORKINGDIRECTORY, m_workingDirectory.toString()); + data.insert(DEBUGGER_INFORMATION_ENGINETYPE, int(m_engineType)); + data.insert(DEBUGGER_INFORMATION_AUTODETECTED, m_isAutoDetected); + data.insert(DEBUGGER_INFORMATION_VERSION, m_version); + data.insert(DEBUGGER_INFORMATION_ABIS, abiNames()); + data.insert(DEBUGGER_INFORMATION_LASTMODIFIED, m_lastModified); return data; } QString DebuggerItem::displayName() const { - if (!m_unexpandedDisplayName.contains(QLatin1Char('%'))) + if (!m_unexpandedDisplayName.contains('%')) return m_unexpandedDisplayName; MacroExpander expander; @@ -268,7 +268,7 @@ QString DebuggerItem::displayName() const [this] { return !m_version.isEmpty() ? m_version : DebuggerKitInformation::tr("Unknown debugger version"); }); expander.registerVariable("Debugger:Abi", DebuggerKitInformation::tr("Debugger"), - [this] { return !m_abis.isEmpty() ? abiNames().join(QLatin1Char(' ')) : + [this] { return !m_abis.isEmpty() ? abiNames().join(' ') : DebuggerKitInformation::tr("Unknown debugger ABI"); }); return expander.expand(m_unexpandedDisplayName); } diff --git a/src/plugins/debugger/debuggeritemmanager.cpp b/src/plugins/debugger/debuggeritemmanager.cpp index 9877ce2f92b..1cd8b3ec094 100644 --- a/src/plugins/debugger/debuggeritemmanager.cpp +++ b/src/plugins/debugger/debuggeritemmanager.cpp @@ -353,7 +353,7 @@ DebuggerItem DebuggerItemConfigWidget::item() const item.setWorkingDirectory(m_workingDirectoryChooser->fileName()); item.setAutoDetected(m_autodetected); QList<ProjectExplorer::Abi> abiList; - foreach (const QString &a, m_abis->text().split(QRegExp(QLatin1String("[^A-Za-z0-9-_]+")))) { + foreach (const QString &a, m_abis->text().split(QRegExp("[^A-Za-z0-9-_]+"))) { if (a.isNull()) continue; abiList << Abi::fromString(a); @@ -372,7 +372,7 @@ void DebuggerItemConfigWidget::store() const void DebuggerItemConfigWidget::setAbis(const QStringList &abiNames) { - m_abis->setText(abiNames.join(QLatin1String(", "))); + m_abis->setText(abiNames.join(", ")); } void DebuggerItemConfigWidget::load(const DebuggerItem *item) @@ -406,9 +406,9 @@ void DebuggerItemConfigWidget::load(const DebuggerItem *item) "<a href=\"%1\">Windows Console Debugger executable</a>" " (%2) here.").arg(QLatin1String(debuggingToolsWikiLinkC), versionString) + "</p></body></html>"; - versionCommand = QLatin1String("-version"); + versionCommand = "-version"; } else { - versionCommand = QLatin1String("--version"); + versionCommand = "--version"; } m_cdbLabel->setText(text); @@ -730,7 +730,7 @@ void DebuggerItemManagerPrivate::autoDetectGdbOrLldbDebuggers() SynchronousProcess lldbInfo; lldbInfo.setTimeoutS(2); SynchronousProcessResponse response - = lldbInfo.runBlocking(QLatin1String("xcrun"), {"--find", "lldb"}); + = lldbInfo.runBlocking("xcrun", {"--find", "lldb"}); if (response.result == Utils::SynchronousProcessResponse::Finished) { QString lPath = response.allOutput().trimmed(); if (!lPath.isEmpty()) { @@ -749,8 +749,8 @@ void DebuggerItemManagerPrivate::autoDetectGdbOrLldbDebuggers() foreach (const Utils::FileName &base, path) { dir.setPath(base.toFileInfo().absoluteFilePath()); foreach (const QString &entry, dir.entryList()) { - if (entry.startsWith(QLatin1String("lldb-platform-")) - || entry.startsWith(QLatin1String("lldb-gdbserver-"))) { + if (entry.startsWith("lldb-platform-") + || entry.startsWith("lldb-gdbserver-")) { continue; } suspects.append(FileName::fromString(dir.absoluteFilePath(entry))); @@ -788,19 +788,19 @@ void DebuggerItemManagerPrivate::readLegacyDebuggers(const FileName &file) foreach (const QVariant &v, reader.restoreValues()) { QVariantMap data1 = v.toMap(); - QString kitName = data1.value(QLatin1String("PE.Profile.Name")).toString(); - QVariantMap data2 = data1.value(QLatin1String("PE.Profile.Data")).toMap(); + QString kitName = data1.value("PE.Profile.Name").toString(); + QVariantMap data2 = data1.value("PE.Profile.Data").toMap(); QVariant v3 = data2.value(DebuggerKitInformation::id().toString()); QString fn; if (v3.type() == QVariant::String) fn = v3.toString(); else - fn = v3.toMap().value(QLatin1String("Binary")).toString(); + fn = v3.toMap().value("Binary").toString(); if (fn.isEmpty()) continue; - if (fn.startsWith(QLatin1Char('{'))) + if (fn.startsWith('{')) continue; - if (fn == QLatin1String("auto")) + if (fn == "auto") continue; FileName command = FileName::fromUserInput(fn); if (!command.exists()) diff --git a/src/plugins/debugger/debuggerkitinformation.cpp b/src/plugins/debugger/debuggerkitinformation.cpp index c3b41bcd4b0..426df5dfa7b 100644 --- a/src/plugins/debugger/debuggerkitinformation.cpp +++ b/src/plugins/debugger/debuggerkitinformation.cpp @@ -51,7 +51,7 @@ namespace Debugger { DebuggerKitInformation::DebuggerKitInformation() { - setObjectName(QLatin1String("DebuggerKitInformation")); + setObjectName("DebuggerKitInformation"); setId(DebuggerKitInformation::id()); setPriority(28000); } @@ -130,11 +130,11 @@ void DebuggerKitInformation::setup(Kit *k) } else { // Old structure. const QMap<QString, QVariant> map = rawId.toMap(); - QString binary = map.value(QLatin1String("Binary")).toString(); - if (binary == QLatin1String("auto")) { + QString binary = map.value("Binary").toString(); + if (binary == "auto") { // This is close to the "new kit" case, except that we know // an engine type. - DebuggerEngineType autoEngine = DebuggerEngineType(map.value(QLatin1String("EngineType")).toInt()); + DebuggerEngineType autoEngine = DebuggerEngineType(map.value("EngineType").toInt()); if (item.engineType() == autoEngine) { // Use item if host toolchain fits, but only as fallback. level = std::min(item.matchTarget(tcAbi), DebuggerItem::MatchesSomewhat); @@ -185,8 +185,8 @@ void DebuggerKitInformation::fix(Kit *k) } QMap<QString, QVariant> map = rawId.toMap(); - QString binary = map.value(QLatin1String("Binary")).toString(); - if (binary == QLatin1String("auto")) { + QString binary = map.value("Binary").toString(); + if (binary == "auto") { // This should not happen as "auto" is handled by setup() already. QTC_CHECK(false); k->setValue(DebuggerKitInformation::id(), QVariant()); @@ -334,7 +334,7 @@ void DebuggerKitInformation::addToMacroExpander(Kit *kit, MacroExpander *expande [kit]() -> QString { const DebuggerItem *item = debugger(kit); return item && !item->abis().isEmpty() - ? item->abiNames().join(QLatin1Char(' ')) + ? item->abiNames().join(' ') : tr("Unknown debugger ABI"); }); } diff --git a/src/plugins/debugger/debuggermainwindow.cpp b/src/plugins/debugger/debuggermainwindow.cpp index 47a8f7b012a..2884f6e87e9 100644 --- a/src/plugins/debugger/debuggermainwindow.cpp +++ b/src/plugins/debugger/debuggermainwindow.cpp @@ -188,11 +188,11 @@ DebuggerMainWindowPrivate::DebuggerMainWindowPrivate(DebuggerMainWindow *parent) hbox->addWidget(closeButton); auto dock = new QDockWidget(DebuggerMainWindow::tr("Toolbar"), q); - dock->setObjectName(QLatin1String("Toolbar")); + dock->setObjectName("Toolbar"); dock->setFeatures(QDockWidget::NoDockWidgetFeatures); dock->setAllowedAreas(Qt::BottomDockWidgetArea); dock->setTitleBarWidget(new QWidget(dock)); // hide title bar - dock->setProperty("managed_dockwidget", QLatin1String("true")); + dock->setProperty("managed_dockwidget", "true"); toolbar->setParent(dock); dock->setWidget(toolbar); m_toolBarDock = dock; @@ -300,7 +300,7 @@ void DebuggerMainWindow::onModeChanged(Core::Id mode) Perspective *perspective = theMainWindow->d->m_currentPerspective; if (!perspective) { const QSettings *settings = ICore::settings(); - const QString lastPerspectiveId = settings->value(QLatin1String(LAST_PERSPECTIVE_KEY)).toString(); + const QString lastPerspectiveId = settings->value(LAST_PERSPECTIVE_KEY).toString(); perspective = Perspective::findPerspective(lastPerspectiveId); // If we don't find a perspective with the stored name, pick any. // This can happen e.g. when a plugin was disabled that provided @@ -672,7 +672,7 @@ void Perspective::select() d->m_lastActiveSubPerspectiveId.clear(); const QString &lastKey = d->m_parentPerspectiveId.isEmpty() ? d->m_id : d->m_parentPerspectiveId; - ICore::settings()->setValue(QLatin1String(LAST_PERSPECTIVE_KEY), lastKey); + ICore::settings()->setValue(LAST_PERSPECTIVE_KEY, lastKey); } void PerspectivePrivate::restoreLayout() diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index e64a2f62e05..7447d46916a 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -467,7 +467,7 @@ class DebugMode : public IMode public: DebugMode() { - setObjectName(QLatin1String("DebugMode")); + setObjectName("DebugMode"); setContext(Context(C_DEBUGMODE, CC::C_NAVIGATION_PANE)); setDisplayName(DebuggerPlugin::tr("Debug")); setIcon(Utils::Icon::modeIcon(Icons::MODE_DEBUGGER_CLASSIC, @@ -506,7 +506,7 @@ public: mainWindowSplitter->addWidget(mainWindow); mainWindowSplitter->addWidget(new OutputPanePlaceHolder(MODE_DEBUG, mainWindowSplitter)); auto outputPane = new OutputPanePlaceHolder(MODE_DEBUG, mainWindowSplitter); - outputPane->setObjectName(QLatin1String("DebuggerOutputPanePlaceHolder")); + outputPane->setObjectName("DebuggerOutputPanePlaceHolder"); mainWindowSplitter->addWidget(outputPane); mainWindowSplitter->setStretchFactor(0, 10); mainWindowSplitter->setStretchFactor(1, 0); @@ -519,7 +519,7 @@ public: splitter->addWidget(mainWindowSplitter); splitter->setStretchFactor(0, 0); splitter->setStretchFactor(1, 1); - splitter->setObjectName(QLatin1String("DebugModeWidget")); + splitter->setObjectName("DebugModeWidget"); mainWindow->setCentralWidget(centralEditorWidget); mainWindow->addSubPerspectiveSwitcher(EngineManager::engineChooser()); @@ -939,7 +939,7 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it, // -wincrashevent <event-handle>:<pid>. A handle used for // a handshake when attaching to a crashed Windows process. // This is created by $QTC/src/tools/qtcdebugger/main.cpp: - // args << QLatin1String("-wincrashevent") + // args << "-wincrashevent" // << QString::fromLatin1("%1:%2").arg(argWinCrashEvent).arg(argProcessId); if (*it == "-wincrashevent") { ++it; @@ -2133,7 +2133,7 @@ void showModuleSymbols(const QString &moduleName, const Symbols &symbols) w->setRootIsDecorated(false); w->setAlternatingRowColors(true); w->setSortingEnabled(true); - w->setObjectName(QLatin1String("Symbols.") + moduleName); + w->setObjectName("Symbols." + moduleName); QStringList header; header.append(DebuggerPlugin::tr("Symbol")); header.append(DebuggerPlugin::tr("Address")); @@ -2162,7 +2162,7 @@ void showModuleSections(const QString &moduleName, const Sections §ions) w->setRootIsDecorated(false); w->setAlternatingRowColors(true); w->setSortingEnabled(true); - w->setObjectName(QLatin1String("Sections.") + moduleName); + w->setObjectName("Sections." + moduleName); QStringList header; header.append(DebuggerPlugin::tr("Name")); header.append(DebuggerPlugin::tr("From")); @@ -2204,8 +2204,8 @@ void openTextEditor(const QString &titlePattern0, const QString &contents) EditorManager::IgnoreNavigationHistory); if (auto textEditor = qobject_cast<BaseTextEditor *>(editor)) { QString suggestion = titlePattern; - if (!suggestion.contains(QLatin1Char('.'))) - suggestion.append(QLatin1String(".txt")); + if (!suggestion.contains('.')) + suggestion.append(".txt"); textEditor->textDocument()->setFallbackSaveAsFileName(suggestion); } QTC_ASSERT(editor, return); @@ -2235,7 +2235,7 @@ static DebuggerPlugin *m_instance = nullptr; DebuggerPlugin::DebuggerPlugin() { - setObjectName(QLatin1String("DebuggerPlugin")); + setObjectName("DebuggerPlugin"); m_instance = this; } @@ -2405,7 +2405,7 @@ bool wantRunTool(ToolMode toolMode, const QString &toolName) "Do you want to continue and run the tool in %2 mode?</p></body></html>") .arg(toolName).arg(currentMode).arg(toolModeString); if (Utils::CheckableMessageBox::doNotAskAgainQuestion(ICore::mainWindow(), - title, message, ICore::settings(), QLatin1String("AnalyzerCorrectModeWarning")) + title, message, ICore::settings(), "AnalyzerCorrectModeWarning") != QDialogButtonBox::Yes) return false; } @@ -2486,7 +2486,7 @@ void DebuggerUnitTests::initTestCase() // QSKIP("No clang suitable for analyzing found"); s_testRun = true; - m_tmpDir = new CppTools::Tests::TemporaryCopiedDir(QLatin1String(":/unit-tests")); + m_tmpDir = new CppTools::Tests::TemporaryCopiedDir(":/unit-tests"); QVERIFY(m_tmpDir->isValid()); } diff --git a/src/plugins/debugger/debuggerprotocol.cpp b/src/plugins/debugger/debuggerprotocol.cpp index c414e089096..ac4fad40bbb 100644 --- a/src/plugins/debugger/debuggerprotocol.cpp +++ b/src/plugins/debugger/debuggerprotocol.cpp @@ -439,14 +439,14 @@ QString DebuggerResponse::toString() const void extractGdbVersion(const QString &msg, int *gdbVersion, int *gdbBuildVersion, bool *isMacGdb, bool *isQnxGdb) { - const QChar dot(QLatin1Char('.')); + const QChar dot('.'); - const bool ignoreParenthesisContent = msg.contains(QLatin1String("rubenvb")) - || msg.contains(QLatin1String("openSUSE")) - || msg.contains(QLatin1String("SUSE Linux Enterprise")); + const bool ignoreParenthesisContent = msg.contains("rubenvb") + || msg.contains("openSUSE") + || msg.contains("SUSE Linux Enterprise"); - const QChar parOpen(QLatin1Char('(')); - const QChar parClose(QLatin1Char(')')); + const QChar parOpen('('); + const QChar parClose(')'); QString cleaned; QString build; @@ -476,8 +476,8 @@ void extractGdbVersion(const QString &msg, } } - *isMacGdb = msg.contains(QLatin1String("Apple version")); - *isQnxGdb = msg.contains(QLatin1String("qnx")); + *isMacGdb = msg.contains("Apple version"); + *isQnxGdb = msg.contains("qnx"); *gdbVersion = 10000 * cleaned.section(dot, 0, 0).toInt() + 100 * cleaned.section(dot, 1, 1).toInt() @@ -504,7 +504,7 @@ static QString quoteUnprintableLatin1(const QString &ba) for (int i = 0, n = ba.size(); i != n; ++i) { const unsigned char c = ba.at(i).unicode(); if (isprint(c)) { - res += QLatin1Char(c); + res += c; } else { qsnprintf(buf, sizeof(buf) - 1, "\\%x", int(c)); res += QLatin1String(buf); @@ -638,18 +638,18 @@ QString decodeData(const QString &ba, const QString &encoding) } case DebuggerEncoding::JulianDate: { const QDate date = dateFromData(ba.toInt()); - return date.isValid() ? date.toString(Qt::TextDate) : QLatin1String("(invalid)"); + return date.isValid() ? date.toString(Qt::TextDate) : "(invalid)"; } case DebuggerEncoding::MillisecondsSinceMidnight: { const QTime time = timeFromData(ba.toInt()); - return time.isValid() ? time.toString(Qt::TextDate) : QLatin1String("(invalid)"); + return time.isValid() ? time.toString(Qt::TextDate) : "(invalid)"; } case DebuggerEncoding::JulianDateAndMillisecondsSinceMidnight: { const int p = ba.indexOf('/'); const QDate date = dateFromData(ba.left(p).toInt()); const QTime time = timeFromData(ba.mid(p + 1 ).toInt()); const QDateTime dateTime = QDateTime(date, time); - return dateTime.isValid() ? dateTime.toString(Qt::TextDate) : QLatin1String("(invalid)"); + return dateTime.isValid() ? dateTime.toString(Qt::TextDate) : "(invalid)"; } case DebuggerEncoding::HexEncodedUnsignedInteger: case DebuggerEncoding::HexEncodedSignedInteger: @@ -719,7 +719,7 @@ QString decodeData(const QString &ba, const QString &encoding) } if (enc.quotes) { - const QChar doubleQuote(QLatin1Char('"')); + const QChar doubleQuote('"'); result = doubleQuote + result + doubleQuote; } return result; @@ -763,7 +763,7 @@ void DebuggerCommand::arg(const char *name, const QString &value) void DebuggerCommand::arg(const char *name, const char *value) { - args = addToJsonObject(args, name, QLatin1String(value)); + args = addToJsonObject(args, name, value); } void DebuggerCommand::arg(const char *name, const QList<int> &list) @@ -786,7 +786,7 @@ void DebuggerCommand::arg(const char *value) { QTC_ASSERT(args.isArray() || args.isNull(), return); QJsonArray arr = args.toArray(); - arr.append(QLatin1String(value)); + arr.append(value); args = arr; } @@ -846,7 +846,7 @@ QString DebuggerCommand::argsToString() const DebuggerEncoding::DebuggerEncoding(const QString &data) { - const QVector<QStringRef> l = data.splitRef(QLatin1Char(':')); + const QVector<QStringRef> l = data.splitRef(':'); const QStringRef &t = l.at(0); if (t == "latin1") { diff --git a/src/plugins/debugger/debuggerrunconfigurationaspect.cpp b/src/plugins/debugger/debuggerrunconfigurationaspect.cpp index 9428954cfa2..40b1f1149bb 100644 --- a/src/plugins/debugger/debuggerrunconfigurationaspect.cpp +++ b/src/plugins/debugger/debuggerrunconfigurationaspect.cpp @@ -296,29 +296,29 @@ int DebuggerRunConfigurationAspect::portsUsedByDebugger() const void DebuggerRunConfigurationAspect::toMap(QVariantMap &map) const { - map.insert(QLatin1String(USE_CPP_DEBUGGER_KEY), d.useCppDebugger == EnabledLanguage); - map.insert(QLatin1String(USE_CPP_DEBUGGER_AUTO_KEY), d.useCppDebugger == AutoEnabledLanguage); - map.insert(QLatin1String(USE_QML_DEBUGGER_KEY), d.useQmlDebugger == EnabledLanguage); - map.insert(QLatin1String(USE_QML_DEBUGGER_AUTO_KEY), d.useQmlDebugger == AutoEnabledLanguage); - map.insert(QLatin1String(QML_DEBUG_SERVER_PORT_KEY), d.qmlDebugServerPort); - map.insert(QLatin1String(USE_MULTIPROCESS_KEY), d.useMultiProcess); + map.insert(USE_CPP_DEBUGGER_KEY, d.useCppDebugger == EnabledLanguage); + map.insert(USE_CPP_DEBUGGER_AUTO_KEY, d.useCppDebugger == AutoEnabledLanguage); + map.insert(USE_QML_DEBUGGER_KEY, d.useQmlDebugger == EnabledLanguage); + map.insert(USE_QML_DEBUGGER_AUTO_KEY, d.useQmlDebugger == AutoEnabledLanguage); + map.insert(QML_DEBUG_SERVER_PORT_KEY, d.qmlDebugServerPort); + map.insert(USE_MULTIPROCESS_KEY, d.useMultiProcess); } void DebuggerRunConfigurationAspect::fromMap(const QVariantMap &map) { - if (map.value(QLatin1String(USE_CPP_DEBUGGER_AUTO_KEY), false).toBool()) { + if (map.value(USE_CPP_DEBUGGER_AUTO_KEY, false).toBool()) { d.useCppDebugger = AutoEnabledLanguage; } else { - bool useCpp = map.value(QLatin1String(USE_CPP_DEBUGGER_KEY), false).toBool(); + bool useCpp = map.value(USE_CPP_DEBUGGER_KEY, false).toBool(); d.useCppDebugger = useCpp ? EnabledLanguage : DisabledLanguage; } - if (map.value(QLatin1String(USE_QML_DEBUGGER_AUTO_KEY), false).toBool()) { + if (map.value(USE_QML_DEBUGGER_AUTO_KEY, false).toBool()) { d.useQmlDebugger = AutoEnabledLanguage; } else { - bool useQml = map.value(QLatin1String(USE_QML_DEBUGGER_KEY), false).toBool(); + bool useQml = map.value(USE_QML_DEBUGGER_KEY, false).toBool(); d.useQmlDebugger = useQml ? EnabledLanguage : DisabledLanguage; } - d.useMultiProcess = map.value(QLatin1String(USE_MULTIPROCESS_KEY), false).toBool(); + d.useMultiProcess = map.value(USE_MULTIPROCESS_KEY, false).toBool(); } } // namespace Debugger diff --git a/src/plugins/debugger/debuggerruncontrol.cpp b/src/plugins/debugger/debuggerruncontrol.cpp index 43d9ec2af03..7c2bc7ec196 100644 --- a/src/plugins/debugger/debuggerruncontrol.cpp +++ b/src/plugins/debugger/debuggerruncontrol.cpp @@ -676,7 +676,7 @@ void DebuggerRunTool::start() DebuggerPlugin::tr("Some breakpoints cannot be handled by the debugger " "languages currently active, and will be ignored.\n" "Affected are breakpoints %1") - .arg(unhandledIds.join(QLatin1String(", "))); + .arg(unhandledIds.join(", ")); showMessage(warningMessage, LogWarning); diff --git a/src/plugins/debugger/debuggersourcepathmappingwidget.cpp b/src/plugins/debugger/debuggersourcepathmappingwidget.cpp index 4d53e55f2d2..5812763fc4c 100644 --- a/src/plugins/debugger/debuggersourcepathmappingwidget.cpp +++ b/src/plugins/debugger/debuggersourcepathmappingwidget.cpp @@ -133,8 +133,8 @@ SourcePathMap SourcePathMappingModel::sourcePathMap() const // Check a mapping whether it still contains a placeholder. bool SourcePathMappingModel::isNewPlaceHolder(const Mapping &m) const { - const QLatin1Char lessThan('<'); - const QLatin1Char greaterThan('>'); + const QChar lessThan('<'); + const QChar greaterThan('>'); return m.first.isEmpty() || m.first.startsWith(lessThan) || m.first.endsWith(greaterThan) || m.first == m_newSourcePlaceHolder @@ -253,7 +253,7 @@ DebuggerSourcePathMappingWidget::DebuggerSourcePathMappingWidget(QWidget *parent // Edit part m_targetChooser->setExpectedKind(PathChooser::ExistingDirectory); - m_targetChooser->setHistoryCompleter(QLatin1String("Debugger.MappingTarget.History")); + m_targetChooser->setHistoryCompleter("Debugger.MappingTarget.History"); connect(m_sourceLineEdit, &QLineEdit::textChanged, this, &DebuggerSourcePathMappingWidget::slotEditSourceFieldChanged); connect(m_targetChooser, &PathChooser::pathChanged, @@ -407,8 +407,8 @@ static QString findQtInstallPath(const FileName &qmakePath) return QString(); QProcess proc; QStringList args; - args.append(QLatin1String("-query")); - args.append(QLatin1String("QT_INSTALL_HEADERS")); + args.append("-query"); + args.append("QT_INSTALL_HEADERS"); proc.start(qmakePath.toString(), args); if (!proc.waitForStarted()) { qWarning("%s: Cannot start '%s': %s", Q_FUNC_INFO, qPrintable(qmakePath.toString()), diff --git a/src/plugins/debugger/debuggertooltipmanager.cpp b/src/plugins/debugger/debuggertooltipmanager.cpp index 7b733c6d623..e858bb49d2f 100644 --- a/src/plugins/debugger/debuggertooltipmanager.cpp +++ b/src/plugins/debugger/debuggertooltipmanager.cpp @@ -546,7 +546,7 @@ DebuggerToolTipWidget::DebuggerToolTipWidget() setAttribute(Qt::WA_DeleteOnClose); isPinned = false; - const QIcon pinIcon(QLatin1String(":/debugger/images/pin.xpm")); + const QIcon pinIcon(":/debugger/images/pin.xpm"); pinButton = new QToolButton; pinButton->setIcon(pinIcon); @@ -582,7 +582,7 @@ DebuggerToolTipWidget::DebuggerToolTipWidget() QString text; QTextStream str(&text); model.forAllItems([&str](ToolTipWatchItem *item) { - str << QString(item->level(), QLatin1Char('\t')) + str << QString(item->level(), '\t') << item->name << '\t' << item->value << '\t' << item->type << '\n'; }); QClipboard *clipboard = QApplication::clipboard(); @@ -832,7 +832,7 @@ void DebuggerToolTipHolder::updateTooltip(DebuggerEngine *engine) // FIXME: The engine should decide on whether it likes // the context. const bool sameFrame = context.matchesFrame(frame) - || context.fileName.endsWith(QLatin1String(".py")); + || context.fileName.endsWith(".py"); DEBUG("UPDATE TOOLTIP: STATE " << state << context.iname << "PINNED: " << widget->isPinned << "SHOW NEEDED: " << widget->isPinned @@ -940,29 +940,29 @@ static QDate dateFromString(const QString &date) void DebuggerToolTipHolder::saveSessionData(QXmlStreamWriter &w) const { - w.writeStartElement(QLatin1String(toolTipElementC)); + w.writeStartElement(toolTipElementC); QXmlStreamAttributes attributes; -// attributes.append(QLatin1String(toolTipClassAttributeC), QString::fromLatin1(metaObject()->className())); - attributes.append(QLatin1String(fileNameAttributeC), context.fileName); +// attributes.append(toolTipClassAttributeC, QString::fromLatin1(metaObject()->className())); + attributes.append(fileNameAttributeC, context.fileName); if (!context.function.isEmpty()) - attributes.append(QLatin1String(functionAttributeC), context.function); - attributes.append(QLatin1String(textPositionAttributeC), QString::number(context.position)); - attributes.append(QLatin1String(textLineAttributeC), QString::number(context.line)); - attributes.append(QLatin1String(textColumnAttributeC), QString::number(context.column)); - attributes.append(QLatin1String(dateAttributeC), creationDate.toString(QLatin1String("yyyyMMdd"))); + attributes.append(functionAttributeC, context.function); + attributes.append(textPositionAttributeC, QString::number(context.position)); + attributes.append(textLineAttributeC, QString::number(context.line)); + attributes.append(textColumnAttributeC, QString::number(context.column)); + attributes.append(dateAttributeC, creationDate.toString("yyyyMMdd")); QPoint offset = widget->titleLabel->m_offset; if (offset.x()) - attributes.append(QLatin1String(offsetXAttributeC), QString::number(offset.x())); + attributes.append(offsetXAttributeC, QString::number(offset.x())); if (offset.y()) - attributes.append(QLatin1String(offsetYAttributeC), QString::number(offset.y())); - attributes.append(QLatin1String(engineTypeAttributeC), context.engineType); - attributes.append(QLatin1String(treeExpressionAttributeC), context.expression); - attributes.append(QLatin1String(treeInameAttributeC), context.iname); + attributes.append(offsetYAttributeC, QString::number(offset.y())); + attributes.append(engineTypeAttributeC, context.engineType); + attributes.append(treeExpressionAttributeC, context.expression); + attributes.append(treeInameAttributeC, context.iname); w.writeAttributes(attributes); - w.writeStartElement(QLatin1String(treeElementC)); + w.writeStartElement(treeElementC); widget->model.forAllItems([&w](ToolTipWatchItem *item) { - const QString modelItemElement = QLatin1String(modelItemElementC); + const QString modelItemElement(modelItemElementC); for (int i = 0; i < 3; ++i) { const QString value = item->data(i, Qt::DisplayRole).toString(); if (value.isEmpty()) @@ -1078,36 +1078,36 @@ void DebuggerToolTipManagerPrivate::loadSessionData() closeAllToolTips(); const QString data = SessionManager::value(sessionSettingsKeyC).toString(); QXmlStreamReader r(data); - if (r.readNextStartElement() && r.name() == QLatin1String(sessionDocumentC)) { + if (r.readNextStartElement() && r.name() == sessionDocumentC) { while (!r.atEnd()) { if (readStartElement(r, toolTipElementC)) { const QXmlStreamAttributes attributes = r.attributes(); DebuggerToolTipContext context; - context.fileName = attributes.value(QLatin1String(fileNameAttributeC)).toString(); - context.position = attributes.value(QLatin1String(textPositionAttributeC)).toString().toInt(); - context.line = attributes.value(QLatin1String(textLineAttributeC)).toString().toInt(); - context.column = attributes.value(QLatin1String(textColumnAttributeC)).toString().toInt(); - context.function = attributes.value(QLatin1String(functionAttributeC)).toString(); + context.fileName = attributes.value(fileNameAttributeC).toString(); + context.position = attributes.value(textPositionAttributeC).toString().toInt(); + context.line = attributes.value(textLineAttributeC).toString().toInt(); + context.column = attributes.value(textColumnAttributeC).toString().toInt(); + context.function = attributes.value(functionAttributeC).toString(); QPoint offset; - const QString offsetXAttribute = QLatin1String(offsetXAttributeC); - const QString offsetYAttribute = QLatin1String(offsetYAttributeC); + const QString offsetXAttribute(offsetXAttributeC); + const QString offsetYAttribute(offsetYAttributeC); if (attributes.hasAttribute(offsetXAttribute)) offset.setX(attributes.value(offsetXAttribute).toString().toInt()); if (attributes.hasAttribute(offsetYAttribute)) offset.setY(attributes.value(offsetYAttribute).toString().toInt()); context.mousePosition = offset; - context.iname = attributes.value(QLatin1String(treeInameAttributeC)).toString(); - context.expression = attributes.value(QLatin1String(treeExpressionAttributeC)).toString(); + context.iname = attributes.value(treeInameAttributeC).toString(); + context.expression = attributes.value(treeExpressionAttributeC).toString(); - // const QStringRef className = attributes.value(QLatin1String(toolTipClassAttributeC)); - context.engineType = attributes.value(QLatin1String(engineTypeAttributeC)).toString(); - context.creationDate = dateFromString(attributes.value(QLatin1String(dateAttributeC)).toString()); + // const QStringRef className = attributes.value(toolTipClassAttributeC); + context.engineType = attributes.value(engineTypeAttributeC).toString(); + context.creationDate = dateFromString(attributes.value(dateAttributeC).toString()); bool readTree = context.isValid(); if (!context.creationDate.isValid() || context.creationDate.daysTo(QDate::currentDate()) > toolTipsExpiryDays) { // DEBUG("Expiring tooltip " << context.fileName << '@' << context.position << " from " << creationDate) //readTree = false; - } else { //if (className != QLatin1String("Debugger::Internal::DebuggerToolTipWidget")) { + } else { //if (className != "Debugger::Internal::DebuggerToolTipWidget") { //qWarning("Unable to create debugger tool tip widget of class %s", qPrintable(className.toString())); //readTree = false; } @@ -1136,8 +1136,8 @@ void DebuggerToolTipManagerPrivate::saveSessionData() QXmlStreamWriter w(&data); w.writeStartDocument(); - w.writeStartElement(QLatin1String(sessionDocumentC)); - w.writeAttribute(QLatin1String(sessionVersionAttributeC), QLatin1String("1.0")); + w.writeStartElement(sessionDocumentC); + w.writeAttribute(sessionVersionAttributeC, "1.0"); for (DebuggerToolTipHolder *tooltip : qAsConst(m_tooltips)) if (tooltip->widget->isPinned) tooltip->saveSessionData(w); diff --git a/src/plugins/debugger/disassembleragent.cpp b/src/plugins/debugger/disassembleragent.cpp index 5b45e694a68..1fad2a4b635 100644 --- a/src/plugins/debugger/disassembleragent.cpp +++ b/src/plugins/debugger/disassembleragent.cpp @@ -309,7 +309,7 @@ void DisassemblerAgent::setContentsToDocument(const DisassemblerLines &contents) { QTC_ASSERT(d, return); if (!d->document) { - QString titlePattern = QLatin1String("Disassembler"); + QString titlePattern = "Disassembler"; IEditor *editor = EditorManager::openEditorWithContents( Core::Constants::K_DEFAULT_TEXT_EDITOR_ID, &titlePattern); diff --git a/src/plugins/debugger/disassemblerlines.cpp b/src/plugins/debugger/disassemblerlines.cpp index 544f14f8b2a..a809b6fa735 100644 --- a/src/plugins/debugger/disassemblerlines.cpp +++ b/src/plugins/debugger/disassemblerlines.cpp @@ -52,12 +52,12 @@ void DisassemblerLine::fromString(const QString &unparsed) QString addr = unparsed.left(pos); // MSVC 64bit: Remove 64bit separator 00000000`00a45000'. - if (addr.size() >= 9 && addr.at(8) == QLatin1Char('`')) + if (addr.size() >= 9 && addr.at(8) == '`') addr.remove(8, 1); - if (addr.endsWith(QLatin1Char(':'))) // clang + if (addr.endsWith(':')) // clang addr.chop(1); - if (addr.startsWith(QLatin1String("0x"))) + if (addr.startsWith("0x")) addr.remove(0, 2); bool ok = false; address = addr.toULongLong(&ok, 16); @@ -121,7 +121,7 @@ void DisassemblerLines::appendSourceLine(const QString &fileName, uint lineNumbe QFile file(fileName); if (file.open(QIODevice::ReadOnly)) { QTextStream ts(&file); - cache->lines = ts.readAll().split(QLatin1Char('\n')); + cache->lines = ts.readAll().split('\n'); } } if (lineNumber >= uint(cache->lines.size())) @@ -144,42 +144,42 @@ void DisassemblerLines::appendUnparsed(const QString &unparsed) QString line = unparsed.trimmed(); if (line.isEmpty()) return; - if (line.startsWith(QLatin1String("Current language:"))) + if (line.startsWith("Current language:")) return; - if (line.startsWith(QLatin1String("Dump of assembler"))) { + if (line.startsWith("Dump of assembler")) { m_lastFunction.clear(); return; } - if (line.startsWith(QLatin1String("The current source"))) + if (line.startsWith("The current source")) return; - if (line.startsWith(QLatin1String("End of assembler"))) { + if (line.startsWith("End of assembler")) { m_lastFunction.clear(); return; } - if (line.startsWith(QLatin1String("=> "))) + if (line.startsWith("=> ")) line = line.mid(3); - if (line.startsWith(QLatin1String("0x"))) { + if (line.startsWith("0x")) { // Address line. Split at the tab. - int tab1 = line.indexOf(QLatin1Char('\t')); + int tab1 = line.indexOf('\t'); if (tab1 == -1) { appendComment(line); return; } - int tab2 = line.indexOf(QLatin1Char('\t'), tab1 + 1); + int tab2 = line.indexOf('\t', tab1 + 1); if (tab2 == -1) tab2 = tab1; QString address = line.left(tab1); - if (address.endsWith(QLatin1Char(':'))) + if (address.endsWith(':')) address.chop(1); - int pos1 = address.indexOf(QLatin1Char('<')) + 1; + int pos1 = address.indexOf('<') + 1; DisassemblerLine dl; dl.bytes = line.mid(tab1, tab2 - tab1).trimmed(); m_bytesLength = qMax(m_bytesLength, tab2 - tab1); dl.data = line.mid(tab2).trimmed(); - if (pos1 && address.indexOf(QLatin1String("<UNDEFINED> instruction:")) == -1) { - if (address.endsWith(QLatin1Char('>'))) + if (pos1 && address.indexOf("<UNDEFINED> instruction:") == -1) { + if (address.endsWith('>')) address.chop(1); - int pos2 = address.indexOf(QLatin1Char('+'), pos1); + int pos2 = address.indexOf('+', pos1); if (pos1 < pos2) { QString function = address.mid(pos1, pos2 - pos1); if (function != m_lastFunction) { @@ -222,7 +222,7 @@ QString DisassemblerLine::toString(int maxOp) const else str += " "; str += QString(" %1 ").arg(bytes); - str += QString(maxOp - bytes.size(), QLatin1Char(' ')); + str += QString(maxOp - bytes.size(), ' '); str += data; } else if (isCode()) { str += someSpace; @@ -244,7 +244,7 @@ QString DisassemblerLines::toString() const QString str; for (int i = 0, n = size(); i != n; ++i) { str += m_data.at(i).toString(m_bytesLength); - str += QLatin1Char('\n'); + str += '\n'; } return str; } diff --git a/src/plugins/debugger/enginemanager.cpp b/src/plugins/debugger/enginemanager.cpp index e583997985a..9ac2e31b11e 100644 --- a/src/plugins/debugger/enginemanager.cpp +++ b/src/plugins/debugger/enginemanager.cpp @@ -69,7 +69,7 @@ QString SnapshotData::function() const if (m_frames.isEmpty()) return QString(); const StackFrame &frame = m_frames.at(0); - return frame.function + QLatin1Char(':') + QString::number(frame.line); + return frame.function + ':' + QString::number(frame.line); } QString SnapshotData::toString() const diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 8d0c6211718..fb417f5540c 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -2716,7 +2716,7 @@ void GdbEngine::handleShowModuleSections(const DebuggerResponse &response, // ~" 0xb44a6114->0xb44a6138 at 0x00000114: .note.gnu.build-id ALLOC LOAD READONLY DATA HAS_CONTENTS\n" if (response.resultClass == ResultDone) { const QStringList lines = response.consoleStreamOutput.split('\n'); - const QString prefix = QLatin1String(" Object file: "); + const QString prefix = " Object file: "; const QString needle = prefix + moduleName; Sections sections; bool active = false; @@ -3560,7 +3560,7 @@ void GdbEngine::setupEngine() } const QString tests = QString::fromLocal8Bit(qgetenv("QTC_DEBUGGER_TESTS")); - foreach (const QStringRef &test, tests.splitRef(QLatin1Char(','))) + foreach (const QStringRef &test, tests.splitRef(',')) m_testCases.insert(test.toInt()); foreach (int test, m_testCases) showMessage("ENABLING TEST CASE: " + QString::number(test)); @@ -4673,7 +4673,7 @@ static QString findExecutableFromName(const QString &fileNameFromCore, const QSt return absPath; // remove possible trailing arguments - QLatin1Char sep(' '); + QChar sep(' '); QStringList pathFragments = absPath.split(sep); while (pathFragments.size() > 0) { QString joined_path = pathFragments.join(sep); diff --git a/src/plugins/debugger/imageviewer.cpp b/src/plugins/debugger/imageviewer.cpp index 53f7e9728d9..052e3ac4f1a 100644 --- a/src/plugins/debugger/imageviewer.cpp +++ b/src/plugins/debugger/imageviewer.cpp @@ -124,7 +124,7 @@ void ImageViewer::setInfo(const QString &info) void ImageViewer::clicked(const QString &message) { - const QString text = m_info + QLatin1Char('\n') + const QString text = m_info + '\n' + (message.isEmpty() ? tr("<Click to display color>") : message); m_infoLabel->setText(text); } diff --git a/src/plugins/debugger/lldb/lldbengine.cpp b/src/plugins/debugger/lldb/lldbengine.cpp index 124e001b7d0..f6e81e069ea 100644 --- a/src/plugins/debugger/lldb/lldbengine.cpp +++ b/src/plugins/debugger/lldb/lldbengine.cpp @@ -801,7 +801,7 @@ QString LldbEngine::errorMessage(QProcess::ProcessError error) const void LldbEngine::handleLldbFinished(int exitCode, QProcess::ExitStatus exitStatus) { - notifyDebuggerProcessFinished(exitCode, exitStatus, QLatin1String("LLDB")); + notifyDebuggerProcessFinished(exitCode, exitStatus, "LLDB"); } void LldbEngine::readLldbStandardError() @@ -964,7 +964,7 @@ void LldbEngine::fetchDisassembler(DisassemblerAgent *agent) //dl.rawData = line["rawdata"].data(); dl.data = line["rawdata"].data(); if (!dl.data.isEmpty()) - dl.data += QString(30 - dl.data.size(), QLatin1Char(' ')); + dl.data += QString(30 - dl.data.size(), ' '); dl.data += fromHex(line["hexdata"].data()); dl.data += line["data"].data(); dl.offset = line["offset"].toInt(); diff --git a/src/plugins/debugger/loadcoredialog.cpp b/src/plugins/debugger/loadcoredialog.cpp index 1a2fa0af1f7..9221b9b5b63 100644 --- a/src/plugins/debugger/loadcoredialog.cpp +++ b/src/plugins/debugger/loadcoredialog.cpp @@ -270,17 +270,17 @@ AttachCoreDialog::AttachCoreDialog(QWidget *parent) d->selectRemoteCoreButton = new QPushButton(PathChooser::browseButtonLabel(), this); d->localCoreFileName = new PathChooser(this); - d->localCoreFileName->setHistoryCompleter(QLatin1String("Debugger.CoreFile.History")); + d->localCoreFileName->setHistoryCompleter("Debugger.CoreFile.History"); d->localCoreFileName->setExpectedKind(PathChooser::File); d->localCoreFileName->setPromptDialogTitle(tr("Select Core File")); d->localExecFileName = new PathChooser(this); - d->localExecFileName->setHistoryCompleter(QLatin1String("LocalExecutable")); + d->localExecFileName->setHistoryCompleter("LocalExecutable"); d->localExecFileName->setExpectedKind(PathChooser::File); d->localExecFileName->setPromptDialogTitle(tr("Select Executable")); d->overrideStartScriptFileName = new PathChooser(this); - d->overrideStartScriptFileName->setHistoryCompleter(QLatin1String("Debugger.StartupScript.History")); + d->overrideStartScriptFileName->setHistoryCompleter("Debugger.StartupScript.History"); d->overrideStartScriptFileName->setExpectedKind(PathChooser::File); d->overrideStartScriptFileName->setPromptDialogTitle(tr("Select Startup Script")); diff --git a/src/plugins/debugger/logwindow.cpp b/src/plugins/debugger/logwindow.cpp index dca4aae5381..e6717091615 100644 --- a/src/plugins/debugger/logwindow.cpp +++ b/src/plugins/debugger/logwindow.cpp @@ -175,7 +175,7 @@ private: { using Utils::Theme; Theme *theme = Utils::creatorTheme(); - if (text.size() > 3 && text.at(2) == QLatin1Char(':')) { + if (text.size() > 3 && text.at(2) == ':') { QTextCharFormat format; format.setForeground(theme->color(Theme::Debugger_LogWindow_LogTime)); setFormat(1, text.size(), format); @@ -310,7 +310,7 @@ private: int n = 0; // cut time string - if (line.size() > 18 && line.at(0) == QLatin1Char('[')) + if (line.size() > 18 && line.at(0) == '[') line = line.mid(18); //qDebug() << line; @@ -358,8 +358,8 @@ public: void gotoResult(int i) { - QString needle = QString::number(i) + QLatin1Char('^'); - QString needle2 = QLatin1Char('>') + needle; + QString needle = QString::number(i) + '^'; + QString needle2 = '>' + needle; QString needle3 = QString::fromLatin1("dtoken(\"%1\")@").arg(i); QTextCursor cursor(document()); do { @@ -394,7 +394,7 @@ LogWindow::LogWindow(DebuggerEngine *engine) : m_engine(engine) { setWindowTitle(tr("Debugger &Log")); - setObjectName(QLatin1String("Log")); + setObjectName("Log"); m_ignoreNextInputEcho = false; @@ -412,7 +412,7 @@ LogWindow::LogWindow(DebuggerEngine *engine) m_commandEdit = new Utils::FancyLineEdit(this); m_commandEdit->setFrame(false); - m_commandEdit->setHistoryCompleter(QLatin1String("DebuggerInput")); + m_commandEdit->setHistoryCompleter("DebuggerInput"); auto repeatButton = new QToolButton(this); repeatButton->setIcon(Icons::STEP_OVER.icon()); @@ -521,12 +521,12 @@ void LogWindow::showOutput(int channel, const QString &output) return; const QChar cchar = charForChannel(channel); - const QChar nchar = QLatin1Char('\n'); + const QChar nchar = '\n'; QString out; out.reserve(output.size() + 1000); - if (output.at(0) != QLatin1Char('~') && boolSetting(LogTimeStamps)) { + if (output.at(0) != '~' && boolSetting(LogTimeStamps)) { out.append(charForChannel(LogTime)); out.append(logTimeStamp()); out.append(nchar); @@ -536,12 +536,12 @@ void LogWindow::showOutput(int channel, const QString &output) const int npos = output.indexOf(nchar, pos); const int nnpos = npos == -1 ? n : npos; const int l = nnpos - pos; - if (l != 6 || output.midRef(pos, 6) != QLatin1String("(gdb) ")) { + if (l != 6 || output.midRef(pos, 6) != "(gdb) ") { out.append(cchar); if (l > 30000) { // FIXME: QTextEdit asserts on really long lines... out.append(output.midRef(pos, 30000)); - out.append(QLatin1String(" [...] <cut off>\n")); + out.append(" [...] <cut off>\n"); } else { out.append(output.midRef(pos, l + 1)); } @@ -631,7 +631,7 @@ QString LogWindow::logTimeStamp() { // Cache the last log time entry by ms. If time progresses, // report the difference to the last time stamp in ms. - static const QString logTimeFormat(QLatin1String("hh:mm:ss.zzz")); + static const QString logTimeFormat("hh:mm:ss.zzz"); static QTime lastTime = QTime::currentTime(); static QString lastTimeStamp = lastTime.toString(logTimeFormat); @@ -642,9 +642,9 @@ QString LogWindow::logTimeStamp() lastTimeStamp = lastTime.toString(logTimeFormat); // Append time elapsed QString rc = lastTimeStamp; - rc += QLatin1String(" ["); + rc += " ["; rc += QString::number(elapsedMS); - rc += QLatin1String("ms]"); + rc += "ms]"; return rc; } return lastTimeStamp; diff --git a/src/plugins/debugger/namedemangler/demanglerexceptions.h b/src/plugins/debugger/namedemangler/demanglerexceptions.h index eb210c3f7df..aa03d80e4f9 100644 --- a/src/plugins/debugger/namedemangler/demanglerexceptions.h +++ b/src/plugins/debugger/namedemangler/demanglerexceptions.h @@ -56,7 +56,7 @@ public: #define DEMANGLER_ASSERT(cond) \ do { \ if (!(cond)) { \ - throw InternalDemanglerException(QLatin1String(Q_FUNC_INFO), QLatin1String(__FILE__), __LINE__); \ + throw InternalDemanglerException(Q_FUNC_INFO, __FILE__, __LINE__); \ } \ } while (0) @@ -69,8 +69,7 @@ template <typename T> QSharedPointer<T> demanglerCast(const QSharedPointer<Parse return out; } -#define DEMANGLER_CAST(type, input) demanglerCast<type>(input, QLatin1String(Q_FUNC_INFO), \ - QLatin1String(__FILE__), __LINE__) +#define DEMANGLER_CAST(type, input) demanglerCast<type>(input, Q_FUNC_INFO, __FILE__, __LINE__) } // namespace Internal } // namespace Debugger diff --git a/src/plugins/debugger/namedemangler/globalparsestate.cpp b/src/plugins/debugger/namedemangler/globalparsestate.cpp index 90b8e878e56..25e019816af 100644 --- a/src/plugins/debugger/namedemangler/globalparsestate.cpp +++ b/src/plugins/debugger/namedemangler/globalparsestate.cpp @@ -43,7 +43,7 @@ char GlobalParseState::advance(int steps) { Q_ASSERT(steps > 0); if (m_pos + steps > m_mangledName.size()) - throw ParseException(QLatin1String("Unexpected end of input")); + throw ParseException("Unexpected end of input"); const char c = m_mangledName[m_pos]; m_pos += steps; diff --git a/src/plugins/debugger/namedemangler/namedemangler.cpp b/src/plugins/debugger/namedemangler/namedemangler.cpp index 242d663f288..9041543fd0a 100644 --- a/src/plugins/debugger/namedemangler/namedemangler.cpp +++ b/src/plugins/debugger/namedemangler/namedemangler.cpp @@ -62,7 +62,7 @@ bool NameDemanglerPrivate::demangle(const QString &mangledName) MangledNameRule::parse(&m_parseState, ParseTreeNode::Ptr()); if (m_parseState.m_pos != m_parseState.m_mangledName.size()) - throw ParseException(QLatin1String("Unconsumed input")); + throw ParseException("Unconsumed input"); if (m_parseState.m_parseStack.count() != 1) { throw ParseException(QString::fromLatin1("There are %1 elements on the parse stack; " "expected one.").arg(m_parseState.m_parseStack.count())); diff --git a/src/plugins/debugger/namedemangler/parsetreenodes.cpp b/src/plugins/debugger/namedemangler/parsetreenodes.cpp index 556104718fb..e6e7567c457 100644 --- a/src/plugins/debugger/namedemangler/parsetreenodes.cpp +++ b/src/plugins/debugger/namedemangler/parsetreenodes.cpp @@ -54,7 +54,7 @@ #define PARSE_RULE_AND_ADD_RESULT_AS_CHILD(nodeType) \ PARSE_RULE_AND_ADD_RESULT_AS_CHILD_TO_THIS(nodeType, parseState()) -#define CHILD_AT(obj, index) obj->childAt(index, QLatin1String(Q_FUNC_INFO), QLatin1String(__FILE__), __LINE__) +#define CHILD_AT(obj, index) obj->childAt(index, Q_FUNC_INFO, __FILE__, __LINE__) #define MY_CHILD_AT(index) CHILD_AT(this, index) #define CHILD_TO_BYTEARRAY(index) MY_CHILD_AT(index)->toByteArray() @@ -514,12 +514,12 @@ void CvQualifiersNode::parse() while (true) { if (PEEK() == 'V') { if (hasQualifiers()) - throw ParseException(QLatin1String("Invalid qualifiers: unexpected 'volatile'")); + throw ParseException("Invalid qualifiers: unexpected 'volatile'"); m_hasVolatile = true; ADVANCE(); } else if (PEEK() == 'K') { if (m_hasConst) - throw ParseException(QLatin1String("Invalid qualifiers: 'const' appears twice")); + throw ParseException("Invalid qualifiers: 'const' appears twice"); m_hasConst = true; ADVANCE(); } else { @@ -684,7 +684,7 @@ void ExpressionNode::parse() while (ExpressionNode::mangledRepresentationStartsWith(PEEK())) PARSE_RULE_AND_ADD_RESULT_AS_CHILD(ExpressionNode); if (ADVANCE() != '_') - throw ParseException(QLatin1String("Invalid expression")); + throw ParseException("Invalid expression"); PARSE_RULE_AND_ADD_RESULT_AS_CHILD(TypeNode); if (PEEK() == 'E') ADVANCE(); @@ -1269,7 +1269,7 @@ void ExprPrimaryNode::parse() ? BuiltinTypeNode::Ptr() : CHILD_AT(topLevelTypeNode, 0).dynamicCast<BuiltinTypeNode>(); if (!typeNode) - throw ParseException(QLatin1String("Invalid type in expr-primary")); + throw ParseException("Invalid type in expr-primary"); switch (typeNode->type()) { case BuiltinTypeNode::UnsignedShortType: @@ -2046,7 +2046,7 @@ void NumberNode::parse() { const char next = PEEK(); if (!mangledRepresentationStartsWith(next)) - throw ParseException(QLatin1String("Invalid number")); + throw ParseException("Invalid number"); if (next == 'n') { m_isNegative = true; @@ -2756,15 +2756,15 @@ QByteArray LambdaSigNode::toByteArray() const void ClosureTypeNameNode::parse() { if (parseState()->readAhead(2) != "Ul") - throw ParseException(QLatin1String("Invalid closure-type-name")); + throw ParseException("Invalid closure-type-name"); parseState()->advance(2); PARSE_RULE_AND_ADD_RESULT_AS_CHILD(LambdaSigNode); if (ADVANCE() != 'E') - throw ParseException(QLatin1String("invalid closure-type-name")); + throw ParseException("invalid closure-type-name"); if (NonNegativeNumberNode<10>::mangledRepresentationStartsWith(PEEK())) PARSE_RULE_AND_ADD_RESULT_AS_CHILD(NonNegativeNumberNode<10>); if (ADVANCE() != '_') - throw ParseException(QLatin1String("Invalid closure-type-name")); + throw ParseException("Invalid closure-type-name"); } QByteArray ClosureTypeNameNode::toByteArray() const @@ -2798,7 +2798,7 @@ void UnnamedTypeNameNode::parse() if (NonNegativeNumberNode<10>::mangledRepresentationStartsWith(PEEK())) PARSE_RULE_AND_ADD_RESULT_AS_CHILD(NonNegativeNumberNode<10>); if (ADVANCE() != '_') - throw ParseException(QLatin1String("Invalid unnamed-type-node")); + throw ParseException("Invalid unnamed-type-node"); } else { PARSE_RULE_AND_ADD_RESULT_AS_CHILD(ClosureTypeNameNode); } @@ -2834,7 +2834,7 @@ void DeclTypeNode::parse() { const QByteArray start = parseState()->readAhead(2); if (start != "DT" && start != "Dt") - throw ParseException(QLatin1String("Invalid decltype")); + throw ParseException("Invalid decltype"); parseState()->advance(2); PARSE_RULE_AND_ADD_RESULT_AS_CHILD(ExpressionNode); if (ADVANCE() != 'E') @@ -2870,7 +2870,7 @@ void UnresolvedTypeRule::parse(GlobalParseState *parseState) else if (SubstitutionNode::mangledRepresentationStartsWith(next)) PARSE_RULE_AND_ADD_RESULT_AS_CHILD_TO_NODE(SubstitutionNode, parseState, parentNode); else - throw ParseException(QLatin1String("Invalid unresolved-type")); + throw ParseException("Invalid unresolved-type"); } @@ -2911,7 +2911,7 @@ void DestructorNameNode::parse() else if (SimpleIdNode::mangledRepresentationStartsWith(next)) PARSE_RULE_AND_ADD_RESULT_AS_CHILD(SimpleIdNode); else - throw ParseException(QLatin1String("Invalid destructor-name")); + throw ParseException("Invalid destructor-name"); } QByteArray DestructorNameNode::toByteArray() const @@ -2965,7 +2965,7 @@ void BaseUnresolvedNameNode::parse() parseState()->advance(2); PARSE_RULE_AND_ADD_RESULT_AS_CHILD(DestructorNameNode); } else { - throw ParseException(QLatin1String("Invalid <base-unresolved-name>")); + throw ParseException("Invalid <base-unresolved-name>"); } } @@ -2992,12 +2992,12 @@ bool InitializerNode::mangledRepresentationStartsWith(char c) void InitializerNode::parse() { if (parseState()->readAhead(2) != "pi") - throw ParseException(QLatin1String("Invalid initializer")); + throw ParseException("Invalid initializer"); parseState()->advance(2); while (ExpressionNode::mangledRepresentationStartsWith(PEEK())) PARSE_RULE_AND_ADD_RESULT_AS_CHILD(ExpressionNode); if (ADVANCE() != 'E') - throw ParseException(QLatin1String("Invalid initializer")); + throw ParseException("Invalid initializer"); } QByteArray InitializerNode::toByteArray() const @@ -3044,20 +3044,20 @@ void UnresolvedNameNode::parse() UnresolvedQualifierLevelRule::parse(parseState()); while (UnresolvedQualifierLevelRule::mangledRepresentationStartsWith(PEEK())); if (ADVANCE() != 'E') - throw ParseException(QLatin1String("Invalid unresolved-name")); + throw ParseException("Invalid unresolved-name"); PARSE_RULE_AND_ADD_RESULT_AS_CHILD(BaseUnresolvedNameNode); } else if (UnresolvedTypeRule::mangledRepresentationStartsWith(PEEK())) { if (m_globalNamespace) - throw ParseException(QLatin1String("Invalid unresolved-name")); + throw ParseException("Invalid unresolved-name"); UnresolvedTypeRule::parse(parseState()); PARSE_RULE_AND_ADD_RESULT_AS_CHILD(BaseUnresolvedNameNode); } else { if (!UnresolvedQualifierLevelRule::mangledRepresentationStartsWith(PEEK())) - throw ParseException(QLatin1String("Invalid unresolved-name")); + throw ParseException("Invalid unresolved-name"); while (UnresolvedQualifierLevelRule::mangledRepresentationStartsWith(PEEK())) UnresolvedQualifierLevelRule::parse(parseState()); if (ADVANCE() != 'E') - throw ParseException(QLatin1String("Invalid unresolved-name")); + throw ParseException("Invalid unresolved-name"); PARSE_RULE_AND_ADD_RESULT_AS_CHILD(BaseUnresolvedNameNode); } } else { @@ -3103,19 +3103,19 @@ void FunctionParamNode::parse() if (NonNegativeNumberNode<10>::mangledRepresentationStartsWith(PEEK())) PARSE_RULE_AND_ADD_RESULT_AS_CHILD(NonNegativeNumberNode<10>); if (ADVANCE() != '_') - throw ParseException(QLatin1String("Invalid function-param")); + throw ParseException("Invalid function-param"); } else if (parseState()->readAhead(2) == "fL") { parseState()->advance(2); PARSE_RULE_AND_ADD_RESULT_AS_CHILD(NonNegativeNumberNode<10>); if (ADVANCE() != 'p') - throw ParseException(QLatin1String("Invalid function-param")); + throw ParseException("Invalid function-param"); PARSE_RULE_AND_ADD_RESULT_AS_CHILD(CvQualifiersNode); if (NonNegativeNumberNode<10>::mangledRepresentationStartsWith(PEEK())) PARSE_RULE_AND_ADD_RESULT_AS_CHILD(NonNegativeNumberNode<10>); if (ADVANCE() != '_') - throw ParseException(QLatin1String("Invalid function-param")); + throw ParseException("Invalid function-param"); } else { - throw ParseException(QLatin1String("Invalid function-param")); + throw ParseException("Invalid function-param"); } } diff --git a/src/plugins/debugger/pdb/pdbengine.cpp b/src/plugins/debugger/pdb/pdbengine.cpp index 68682f9e752..9e6733ae94c 100644 --- a/src/plugins/debugger/pdb/pdbengine.cpp +++ b/src/plugins/debugger/pdb/pdbengine.cpp @@ -115,7 +115,7 @@ void PdbEngine::setupEngine() QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state()); m_interpreter = runParameters().interpreter; - QString bridge = ICore::resourcePath() + QLatin1String("/debugger/pdbbridge.py"); + QString bridge = ICore::resourcePath() + "/debugger/pdbbridge.py"; connect(&m_proc, &QProcess::errorOccurred, this, &PdbEngine::handlePdbError); connect(&m_proc, static_cast<void(QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished), @@ -135,7 +135,7 @@ void PdbEngine::setupEngine() QStringList args = {bridge, scriptFile.fileName()}; args.append(Utils::QtcProcess::splitArgs(runParameters().inferior.workingDirectory)); - showMessage("STARTING " + m_interpreter + QLatin1Char(' ') + args.join(QLatin1Char(' '))); + showMessage("STARTING " + m_interpreter + ' ' + args.join(' ')); m_proc.setEnvironment(runParameters().debugger.environment.toStringList()); m_proc.start(m_interpreter, args); @@ -434,7 +434,7 @@ QString PdbEngine::errorMessage(QProcess::ProcessError error) const return tr("An error occurred when attempting to read from " "the Pdb process. For example, the process may not be running."); default: - return tr("An unknown error in the Pdb process occurred.") + QLatin1Char(' '); + return tr("An unknown error in the Pdb process occurred.") + ' '; } } diff --git a/src/plugins/debugger/procinterrupt.cpp b/src/plugins/debugger/procinterrupt.cpp index bc241d9d3bb..085747ea60d 100644 --- a/src/plugins/debugger/procinterrupt.cpp +++ b/src/plugins/debugger/procinterrupt.cpp @@ -143,11 +143,11 @@ GDB 32bit | Api | Api | NA | Win32 if (breakApi == UseDebugBreakApi) { ok = DebugBreakProcess(inferior); if (!ok) - *errorMessage = QLatin1String("DebugBreakProcess failed: ") + Utils::winErrorMessage(GetLastError()); + *errorMessage = "DebugBreakProcess failed: " + Utils::winErrorMessage(GetLastError()); } else { const QString executable = breakApi == UseWin32Interrupt - ? QCoreApplication::applicationDirPath() + QLatin1String("/win32interrupt.exe") - : QCoreApplication::applicationDirPath() + QLatin1String("/win64interrupt.exe"); + ? QCoreApplication::applicationDirPath() + "/win32interrupt.exe" + : QCoreApplication::applicationDirPath() + "/win64interrupt.exe"; if (!QFile::exists(executable)) { *errorMessage = QString::fromLatin1("%1 does not exist. If you have built %2 " "on your own, checkout " @@ -165,7 +165,7 @@ GDB 32bit | Api | Api | NA | Win32 break; default: *errorMessage = QDir::toNativeSeparators(executable) - + QLatin1String(" could not break the process."); + + " could not break the process."; break; } break; diff --git a/src/plugins/debugger/qml/qmlengine.cpp b/src/plugins/debugger/qml/qmlengine.cpp index 81acdb66e06..567a3852e8e 100644 --- a/src/plugins/debugger/qml/qmlengine.cpp +++ b/src/plugins/debugger/qml/qmlengine.cpp @@ -1018,7 +1018,7 @@ void QmlEngine::updateCurrentContext() return; } - debuggerConsole()->setContext(tr("Context:") + QLatin1Char(' ') + debuggerConsole()->setContext(tr("Context:") + ' ' + (context.isEmpty() ? tr("Global QML Context") : context)); } @@ -1563,7 +1563,7 @@ QmlV8ObjectData QmlEnginePrivate::extractData(const QVariant &data) const objectData.value = dataMap.value(VALUE); } else if (type == "string") { - QLatin1Char quote('"'); + QChar quote('"'); objectData.type = "string"; objectData.value = QString(quote + dataMap.value(VALUE).toString() + quote); diff --git a/src/plugins/debugger/qml/qmlinspectoragent.cpp b/src/plugins/debugger/qml/qmlinspectoragent.cpp index 288ff845fb8..492878500ae 100644 --- a/src/plugins/debugger/qml/qmlinspectoragent.cpp +++ b/src/plugins/debugger/qml/qmlinspectoragent.cpp @@ -128,8 +128,8 @@ QmlInspectorAgent::QmlInspectorAgent(QmlEngine *engine, QmlDebugConnection *conn this, &QmlInspectorAgent::toolsClientStateChanged); // toolbar - m_selectAction->setObjectName(QLatin1String("QML Select Action")); - m_zoomAction->setObjectName(QLatin1String("QML Zoom Action")); + m_selectAction->setObjectName("QML Select Action"); + m_zoomAction->setObjectName("QML Zoom Action"); m_selectAction->setCheckable(true); m_zoomAction->setCheckable(true); m_showAppOnTopAction->setCheckable(true); @@ -223,7 +223,7 @@ bool QmlInspectorAgent::selectObjectInTree(int debugId) // we may have to fetch it m_objectToSelect = debugId; using namespace QmlDebug::Constants; - if (m_engineClient->objectName() == QLatin1String(QDECLARATIVE_ENGINE)) { + if (m_engineClient->objectName() == QDECLARATIVE_ENGINE) { // reset current Selection QString root = m_qmlEngine->watchHandler()->watchItem(QModelIndex())->iname; m_qmlEngine->watchHandler()->setCurrentItem(root); @@ -322,9 +322,9 @@ void QmlInspectorAgent::onResult(quint32 queryId, const QVariant &value, || type == "RESET_BINDING_R" || type == "SET_METHOD_BODY_R") { // FIXME: This is not supported anymore. - QString msg = QLatin1String(type) + tr("Success:"); - msg += QLatin1Char(' '); - msg += value.toBool() ? QLatin1Char('1') : QLatin1Char('0'); + QString msg = type + tr("Success:"); + msg += ' '; + msg += value.toBool() ? '1' : '0'; // if (!value.toBool()) // emit automaticUpdateFailed(); log(LogReceive, msg); @@ -366,7 +366,7 @@ void QmlInspectorAgent::newObject(int engineId, int /*objectId*/, int /*parentId { qCDebug(qmlInspectorLog) << __FUNCTION__ << "()"; - log(LogReceive, QLatin1String("OBJECT_CREATED")); + log(LogReceive, "OBJECT_CREATED"); if (m_engine.debugId() != engineId) return; @@ -456,7 +456,7 @@ void QmlInspectorAgent::queryEngineContext() if (!isConnected() || !boolSetting(ShowQmlObjectTree)) return; - log(LogSend, QLatin1String("LIST_OBJECTS")); + log(LogSend, "LIST_OBJECTS"); m_rootContextQueryId = m_engineClient->queryRootContexts(m_engine); @@ -469,7 +469,7 @@ void QmlInspectorAgent::fetchObject(int debugId) if (!isConnected() || !boolSetting(ShowQmlObjectTree)) return; - log(LogSend, QLatin1String("FETCH_OBJECT ") + QString::number(debugId)); + log(LogSend, "FETCH_OBJECT " + QString::number(debugId)); quint32 queryId = m_engineClient->queryObject(debugId); qCDebug(qmlInspectorLog) << __FUNCTION__ << '(' << debugId << ')' << " - query id" << queryId; @@ -590,7 +590,7 @@ void QmlInspectorAgent::buildDebugIdHashRecursive(const ObjectReference &ref) // handle the case where the url contains the revision number encoded. //(for object created by the debugger) - static QRegExp rx(QLatin1String("(.*)_(\\d+):(\\d+)$")); + static QRegExp rx("(.*)_(\\d+):(\\d+)$"); if (rx.exactMatch(fileUrl.path())) { fileUrl.setPath(rx.cap(1)); rev = rx.cap(2).toInt(); diff --git a/src/plugins/debugger/registerhandler.cpp b/src/plugins/debugger/registerhandler.cpp index c3be1132d86..281ae32965b 100644 --- a/src/plugins/debugger/registerhandler.cpp +++ b/src/plugins/debugger/registerhandler.cpp @@ -119,7 +119,7 @@ public: painter->setPen(lightColor); // FIXME: performance? this changes only on real font changes. QFontMetrics fm(option.font); - int charWidth = qMax(fm.width(QLatin1Char('x')), fm.width(QLatin1Char('0'))); + int charWidth = qMax(fm.width('x'), fm.width('0')); QString str = index.data(Qt::DisplayRole).toString(); int x = option.rect.x(); bool light = !paintRed; @@ -174,26 +174,26 @@ void Register::guessMissingData() static QString subTypeName(RegisterKind kind, int size, RegisterFormat format) { - QString name(QLatin1Char('[')); + QString name('['); switch (kind) { - case IntegerRegister: name += QLatin1Char('i'); break; - case FloatRegister: name += QLatin1Char('f'); break; + case IntegerRegister: name += 'i'; break; + case FloatRegister: name += 'f'; break; default: break; } name += QString::number(size); switch (format) { - case BinaryFormat: name += QLatin1Char('b'); break; - case OctalFormat: name += QLatin1Char('o'); break; - case DecimalFormat: name += QLatin1Char('u'); break; - case SignedDecimalFormat: name += QLatin1Char('s'); break; - case HexadecimalFormat: name += QLatin1Char('x'); break; - case CharacterFormat: name += QLatin1Char('c'); break; + case BinaryFormat: name += 'b'; break; + case OctalFormat: name += 'o'; break; + case DecimalFormat: name += 'u'; break; + case SignedDecimalFormat: name += 's'; break; + case HexadecimalFormat: name += 'x'; break; + case CharacterFormat: name += 'c'; break; } - name += QLatin1Char(']'); + name += ']'; return name; } @@ -492,7 +492,7 @@ Qt::ItemFlags RegisterItem::flags(int column) const { const Qt::ItemFlags notEditable = Qt::ItemIsSelectable|Qt::ItemIsEnabled; // Can edit registers if they are hex numbers and not arrays. - if (column == 1) // && IntegerWatchLineEdit::isUnsignedHexNumber(QLatin1String(m_reg.display))) + if (column == 1) // && IntegerWatchLineEdit::isUnsignedHexNumber(m_reg.display)) return notEditable | Qt::ItemIsEditable; return notEditable; } diff --git a/src/plugins/debugger/registerpostmortemaction.cpp b/src/plugins/debugger/registerpostmortemaction.cpp index a4e6bb87a0f..0b74bbabab7 100644 --- a/src/plugins/debugger/registerpostmortemaction.cpp +++ b/src/plugins/debugger/registerpostmortemaction.cpp @@ -47,8 +47,8 @@ namespace Internal { void RegisterPostMortemAction::registerNow(const QVariant &value) { const bool boolValue = value.toBool(); - const QString debuggerExe = QDir::toNativeSeparators(QCoreApplication::applicationDirPath() + QLatin1Char('/') - + QLatin1String(debuggerApplicationFileC) + QLatin1String(".exe")); + const QString debuggerExe = QDir::toNativeSeparators(QCoreApplication::applicationDirPath() + '/' + + QLatin1String(debuggerApplicationFileC) + ".exe"); const ushort *debuggerWString = debuggerExe.utf16(); CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); diff --git a/src/plugins/debugger/shared/backtrace.cpp b/src/plugins/debugger/shared/backtrace.cpp index bca1a628b3a..df2270e9bef 100644 --- a/src/plugins/debugger/shared/backtrace.cpp +++ b/src/plugins/debugger/shared/backtrace.cpp @@ -48,9 +48,9 @@ void dumpBacktrace(int maxdepth) qDebug() << "0x" + QByteArray::number(quintptr(bt[i]), 16); QProcess proc; QStringList args; - args.append(QLatin1String("-e")); + args.append("-e"); args.append(QCoreApplication::arguments().at(0)); - proc.start(QLatin1String("addr2line"), args); + proc.start("addr2line", args); proc.waitForStarted(); for (int i = 0; i < qMin(size, maxdepth); i++) proc.write("0x" + QByteArray::number(quintptr(bt[i]), 16) + '\n'); diff --git a/src/plugins/debugger/shared/cdbsymbolpathlisteditor.cpp b/src/plugins/debugger/shared/cdbsymbolpathlisteditor.cpp index 63bc34193cf..0c86728f214 100644 --- a/src/plugins/debugger/shared/cdbsymbolpathlisteditor.cpp +++ b/src/plugins/debugger/shared/cdbsymbolpathlisteditor.cpp @@ -55,7 +55,7 @@ CacheDirectoryDialog::CacheDirectoryDialog(QWidget *parent) : auto formLayout = new QFormLayout; m_chooser->setExpectedKind(Utils::PathChooser::ExistingDirectory); - m_chooser->setHistoryCompleter(QLatin1String("Debugger.CdbCacheDir.History")); + m_chooser->setHistoryCompleter("Debugger.CdbCacheDir.History"); m_chooser->setMinimumWidth(400); formLayout->addRow(tr("Path:"), m_chooser); @@ -189,10 +189,10 @@ QString CdbSymbolPathListEditor::symbolPath(const QString &cacheDir, CdbSymbolPathListEditor::SymbolPathMode mode) { if (mode == SymbolCachePath) - return QLatin1String(symbolCachePrefixC) + QDir::toNativeSeparators(cacheDir); + return symbolCachePrefixC + QDir::toNativeSeparators(cacheDir); QString s = QLatin1String(symbolServerPrefixC); if (!cacheDir.isEmpty()) - s += QDir::toNativeSeparators(cacheDir) + QLatin1Char('*'); + s += QDir::toNativeSeparators(cacheDir) + '*'; s += QLatin1String(symbolServerPostfixC); return s; } diff --git a/src/plugins/debugger/shared/peutils.cpp b/src/plugins/debugger/shared/peutils.cpp index 1973cf3afe1..ab4d2f5a428 100644 --- a/src/plugins/debugger/shared/peutils.cpp +++ b/src/plugins/debugger/shared/peutils.cpp @@ -288,7 +288,7 @@ bool getPDBFiles(const QString &peExecutableFileName, QStringList *rc, QString * { Q_UNUSED(peExecutableFileName) rc->clear(); - *errorMessage = QLatin1String("Not implemented."); + *errorMessage = "Not implemented."; return false; } diff --git a/src/plugins/debugger/simplifytype.cpp b/src/plugins/debugger/simplifytype.cpp index a23d819fa63..f8bea299f61 100644 --- a/src/plugins/debugger/simplifytype.cpp +++ b/src/plugins/debugger/simplifytype.cpp @@ -45,13 +45,13 @@ namespace Internal { static QString chopConst(QString type) { while (true) { - if (type.startsWith(QLatin1String("const"))) + if (type.startsWith("const")) type = type.mid(5); - else if (type.startsWith(QLatin1Char(' '))) + else if (type.startsWith(' ')) type = type.mid(1); - else if (type.endsWith(QLatin1String("const"))) + else if (type.endsWith("const")) type.chop(5); - else if (type.endsWith(QLatin1Char(' '))) + else if (type.endsWith(' ')) type.chop(1); else break; @@ -61,13 +61,13 @@ static QString chopConst(QString type) static inline QRegExp stdStringRegExp(const QString &charType) { - QString rc = QLatin1String("basic_string<"); + QString rc = "basic_string<"; rc += charType; - rc += QLatin1String(",[ ]?std::char_traits<"); + rc += ",[ ]?std::char_traits<"; rc += charType; - rc += QLatin1String(">,[ ]?std::allocator<"); + rc += ">,[ ]?std::allocator<"; rc += charType; - rc += QLatin1String("> >"); + rc += "> >"; const QRegExp re(rc); QTC_ASSERT(re.isValid(), /**/); return re; @@ -90,8 +90,8 @@ static inline void simplifyStdString(const QString &charType, const QString &rep pos = matchPos + replacementSize; // If we were inside an 'allocator<std::basic_string..char > >' // kill the following blank -> 'allocator<std::string>' - if (pos + 1 < type->size() && type->at(pos) == QLatin1Char(' ') - && type->at(pos + 1) == QLatin1Char('>')) + if (pos + 1 < type->size() && type->at(pos) == ' ' + && type->at(pos + 1) == '>') type->remove(pos, 1); } } @@ -102,9 +102,9 @@ static inline QString fixNestedTemplates(QString s) { const int size = s.size(); if (size > 3 - && s.at(size - 1) == QLatin1Char('>') - && s.at(size - 2) == QLatin1Char(' ') - && s.at(size - 3) != QLatin1Char('>')) + && s.at(size - 1) == '>' + && s.at(size - 2) == ' ' + && s.at(size - 3) != '>') s.remove(size - 2, 1); return s; } @@ -112,57 +112,57 @@ static inline QString fixNestedTemplates(QString s) QString simplifyType(const QString &typeIn) { QString type = typeIn; - if (type.startsWith(QLatin1String("class "))) // MSVC prepends class,struct + if (type.startsWith("class ")) // MSVC prepends class,struct type.remove(0, 6); - if (type.startsWith(QLatin1String("struct "))) + if (type.startsWith("struct ")) type.remove(0, 7); - type.replace(QLatin1String("short int"), QLatin1String("short")); + type.replace("short int", "short"); - const bool isLibCpp = type.contains(QLatin1String("std::__1")); - type.replace(QLatin1String("std::__cxx11::"), QLatin1String("std::")); - type.replace(QLatin1String("std::__1::"), QLatin1String("std::")); - type.replace(QLatin1String("std::__debug::"), QLatin1String("std::")); - QRegExp simpleStringRE(QString::fromLatin1("std::basic_string<char> ?")); - type.replace(simpleStringRE, QLatin1String("std::string")); + const bool isLibCpp = type.contains("std::__1"); + type.replace("std::__cxx11::", "std::"); + type.replace("std::__1::", "std::"); + type.replace("std::__debug::", "std::"); + QRegExp simpleStringRE("std::basic_string<char> ?"); + type.replace(simpleStringRE, "std::string"); // Normalize space + ptr. - type.replace(QLatin1String(" *"), QLatin1String("@")); - type.replace(QLatin1Char('*'), QLatin1Char('@')); + type.replace(" *", "@"); + type.replace('*', '@'); // Normalize char const * and const char *. - type.replace(QLatin1String("char const@"), QLatin1String("const char@")); + type.replace("char const@", "const char@"); for (int i = 0; i < 10; ++i) { // boost::shared_ptr<...>::element_type - if (type.startsWith(QLatin1String("boost::shared_ptr<")) - && type.endsWith(QLatin1String(">::element_type"))) + if (type.startsWith("boost::shared_ptr<") + && type.endsWith(">::element_type")) type = type.mid(18, type.size() - 33); // std::shared_ptr<...>::element_type - if (type.startsWith(QLatin1String("std::shared_ptr<")) - && type.endsWith(QLatin1String(">::element_type"))) + if (type.startsWith("std::shared_ptr<") + && type.endsWith(">::element_type")) type = type.mid(16, type.size() - 31); // std::ifstream - QRegExp ifstreamRE(QLatin1String("std::basic_ifstream<char,\\s*std::char_traits<char>\\s*>")); + QRegExp ifstreamRE("std::basic_ifstream<char,\\s*std::char_traits<char>\\s*>"); ifstreamRE.setMinimal(true); QTC_ASSERT(ifstreamRE.isValid(), return typeIn); if (ifstreamRE.indexIn(type) != -1) - type.replace(ifstreamRE.cap(0), QLatin1String("std::ifstream")); + type.replace(ifstreamRE.cap(0), "std::ifstream"); // std::__1::hash_node<int, void *>::value_type -> int if (isLibCpp) { - //QRegExp hashNodeRE(QLatin1String("std::__hash_node<([^<>]*),\\s*void\\s*@>::value_type")); - QRegExp hashNodeRE(QLatin1String("std::__hash_node<([^<>]*),\\s*void\\s*@>::value_type")); + //QRegExp hashNodeRE("std::__hash_node<([^<>]*),\\s*void\\s*@>::value_type"); + QRegExp hashNodeRE("std::__hash_node<([^<>]*),\\s*void\\s*@>::value_type"); QTC_ASSERT(hashNodeRE.isValid(), return typeIn); if (hashNodeRE.indexIn(type) != -1) type.replace(hashNodeRE.cap(0), hashNodeRE.cap(1)); } // Anything with a std::allocator - int start = type.indexOf(QLatin1String("std::allocator<")); + int start = type.indexOf("std::allocator<"); if (start != -1) { // search for matching '>' int pos; @@ -182,12 +182,12 @@ QString simplifyType(const QString &typeIn) const QString allocEsc = QRegExp::escape(alloc); const QString innerEsc = QRegExp::escape(inner); - if (inner == QLatin1String("char")) { // std::string - simplifyStdString(QLatin1String("char"), QLatin1String("string"), &type); - } else if (inner == QLatin1String("wchar_t")) { // std::wstring - simplifyStdString(QLatin1String("wchar_t"), QLatin1String("wstring"), &type); - } else if (inner == QLatin1String("unsigned short")) { // std::wstring/MSVC - simplifyStdString(QLatin1String("unsigned short"), QLatin1String("wstring"), &type); + if (inner == "char") { // std::string + simplifyStdString("char", "string", &type); + } else if (inner == "wchar_t") { // std::wstring + simplifyStdString("wchar_t", "wstring", &type); + } else if (inner == "unsigned short") { // std::wstring/MSVC + simplifyStdString("unsigned short", "wstring", &type); } // std::vector, std::deque, std::list QRegExp re1(QString::fromLatin1("(vector|list|deque)<%1, ?%2\\s*>").arg(innerEsc, allocEsc)); @@ -233,7 +233,7 @@ QString simplifyType(const QString &typeIn) type.replace(boostUnorderedSetRE.cap(0), QString::fromLatin1("unordered_set<%1>").arg(inner)); // std::map - if (inner.startsWith(QLatin1String("std::pair<"))) { + if (inner.startsWith("std::pair<")) { // search for outermost ',', split key and value int pos; int level = 0; @@ -249,7 +249,7 @@ QString simplifyType(const QString &typeIn) const QString key = chopConst(inner.mid(10, pos - 10)); const QString keyEsc = QRegExp::escape(key); // Get value: MSVC: 'pair<a const ,b>', gcc: 'pair<const a, b>' - if (inner.at(++pos) == QLatin1Char(' ')) + if (inner.at(++pos) == ' ') pos++; const QString value = inner.mid(pos, inner.size() - pos - 1).trimmed(); const QString valueEsc = QRegExp::escape(value); @@ -269,7 +269,7 @@ QString simplifyType(const QString &typeIn) } // std::unordered_map - if (inner.startsWith(QLatin1String("std::pair<"))) { + if (inner.startsWith("std::pair<")) { // search for outermost ',', split key and value int pos; int level = 0; @@ -285,7 +285,7 @@ QString simplifyType(const QString &typeIn) const QString key = chopConst(inner.mid(10, pos - 10)); const QString keyEsc = QRegExp::escape(key); // Get value: MSVC: 'pair<a const ,b>', gcc: 'pair<const a, b>' - if (inner.at(++pos) == QLatin1Char(' ')) + if (inner.at(++pos) == ' ') pos++; const QString value = inner.mid(pos, inner.size() - pos - 1).trimmed(); const QString valueEsc = QRegExp::escape(value); @@ -308,8 +308,8 @@ QString simplifyType(const QString &typeIn) } } // with std::allocator } - type.replace(QLatin1Char('@'), QLatin1String(" *")); - type.replace(QLatin1String(" >"), QLatin1String(">")); + type.replace('@', " *"); + type.replace(" >", ">"); return type; } diff --git a/src/plugins/debugger/sourceagent.cpp b/src/plugins/debugger/sourceagent.cpp index d133081b461..074806c5bb0 100644 --- a/src/plugins/debugger/sourceagent.cpp +++ b/src/plugins/debugger/sourceagent.cpp @@ -68,7 +68,7 @@ public: }; SourceAgentPrivate::SourceAgentPrivate() - : producer(QLatin1String("remote")) + : producer("remote") { } @@ -103,7 +103,7 @@ void SourceAgent::setContent(const QString &filePath, const QString &content) d->path = filePath; if (!d->editor) { - QString titlePattern = d->producer + QLatin1String(": ") + QString titlePattern = d->producer + ": " + Utils::FileName::fromString(filePath).fileName(); d->editor = qobject_cast<BaseTextEditor *>( EditorManager::openEditorWithContents( diff --git a/src/plugins/debugger/sourcefileshandler.cpp b/src/plugins/debugger/sourcefileshandler.cpp index 3de9b483607..f99372fb646 100644 --- a/src/plugins/debugger/sourcefileshandler.cpp +++ b/src/plugins/debugger/sourcefileshandler.cpp @@ -67,8 +67,8 @@ QVariant SourceFilesHandler::headerData(int section, { if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { static QString headers[] = { - tr("Internal Name") + QLatin1String(" "), - tr("Full Name") + QLatin1String(" "), + tr("Internal Name") + " ", + tr("Full Name") + " ", }; return headers[section]; } diff --git a/src/plugins/debugger/sourceutils.cpp b/src/plugins/debugger/sourceutils.cpp index dc42a69296a..b1c254038ac 100644 --- a/src/plugins/debugger/sourceutils.cpp +++ b/src/plugins/debugger/sourceutils.cpp @@ -263,7 +263,7 @@ QString cppExpressionAt(TextEditorWidget *editorWidget, int pos, if (expr.isEmpty()) { tc.setPosition(pos); const QChar ch = editorWidget->characterAt(pos); - if (ch.isLetterOrNumber() || ch == QLatin1Char('_')) + if (ch.isLetterOrNumber() || ch == '_') tc.movePosition(QTextCursor::EndOfWord); // Fetch the expression's code. @@ -324,7 +324,7 @@ ContextData getLocationContext(TextDocument *document, int lineNumber) QString fileName = document->property(Constants::DISASSEMBLER_SOURCE_FILE).toString(); if (!fileName.isEmpty()) { // Possibly one of the "27 [1] foo = x" lines - int pos = line.indexOf(QLatin1Char('[')); + int pos = line.indexOf('['); int ln = line.leftRef(pos - 1).toInt(); if (ln > 0) { data.type = LocationByFile; diff --git a/src/plugins/debugger/stackframe.cpp b/src/plugins/debugger/stackframe.cpp index 9a2707b19b8..d5a52bc4c38 100644 --- a/src/plugins/debugger/stackframe.cpp +++ b/src/plugins/debugger/stackframe.cpp @@ -98,8 +98,8 @@ StackFrame StackFrame::parseFrame(const GdbMi &frameMi, const DebuggerRunParamet frame.address = frameMi["address"].toAddress(); frame.context = frameMi["context"].data(); if (frameMi["language"].data() == "js" - || frame.file.endsWith(QLatin1String(".js")) - || frame.file.endsWith(QLatin1String(".qml"))) { + || frame.file.endsWith(".js") + || frame.file.endsWith(".qml")) { frame.language = QmlLanguage; frame.fixQrcFrame(rp); } @@ -151,9 +151,8 @@ QString StackFrame::toToolTip() const showDistributionNote = true; } if (!Utils::HostOsInfo::isWindowsHost() && showDistributionNote) { - str << QLatin1Char(' ') << - tr("Note that most distributions ship debug information " - "in separate packages."); + str << ' ' << tr("Note that most distributions ship debug information " + "in separate packages."); } str << "</body></html>"; @@ -185,11 +184,11 @@ void StackFrame::fixQrcFrame(const DebuggerRunParameters &rp) usable = aFi.isFile(); return; } - if (!file.startsWith(QLatin1String("qrc:/"))) + if (!file.startsWith("qrc:/")) return; QString relativeFile = file.right(file.size() - 5); - while (relativeFile.startsWith(QLatin1Char('/'))) + while (relativeFile.startsWith('/')) relativeFile = relativeFile.mid(1); QString absFile = findFile(rp.projectSourceDirectory.toString(), relativeFile); diff --git a/src/plugins/debugger/threadshandler.cpp b/src/plugins/debugger/threadshandler.cpp index 54b87599e3c..de58f7b6155 100644 --- a/src/plugins/debugger/threadshandler.cpp +++ b/src/plugins/debugger/threadshandler.cpp @@ -130,14 +130,14 @@ QVariant ThreadItem::threadPart(int column) const ? QString::number(threadData.lineNumber) : QString(); case ThreadData::AddressColumn: return threadData.address > 0 - ? QLatin1String("0x") + QString::number(threadData.address, 16) + ? "0x" + QString::number(threadData.address, 16) : QString(); case ThreadData::CoreColumn: return threadData.core; case ThreadData::StateColumn: return threadData.state; case ThreadData::TargetIdColumn: - if (threadData.targetId.startsWith(QLatin1String("Thread "))) + if (threadData.targetId.startsWith("Thread ")) return threadData.targetId.mid(7); return threadData.targetId; case ThreadData::NameColumn: @@ -215,9 +215,9 @@ void ThreadItem::mergeThreadData(const ThreadData &other) ThreadsHandler::ThreadsHandler(DebuggerEngine *engine) : m_engine(engine) { - setObjectName(QLatin1String("ThreadsModel")); + setObjectName("ThreadsModel"); setHeader({ - QLatin1String(" ") + tr("ID") + QLatin1String(" "), + " " + tr("ID") + " ", tr("Address"), tr("Function"), tr("File"), tr("Line"), tr("State"), tr("Name"), tr("Target ID"), tr("Details"), tr("Core"), }); diff --git a/src/plugins/debugger/unstartedappwatcherdialog.cpp b/src/plugins/debugger/unstartedappwatcherdialog.cpp index 9415c573550..8a52c57e1d6 100644 --- a/src/plugins/debugger/unstartedappwatcherdialog.cpp +++ b/src/plugins/debugger/unstartedappwatcherdialog.cpp @@ -105,7 +105,7 @@ UnstartedAppWatcherDialog::UnstartedAppWatcherDialog(QWidget *parent) auto pathLayout = new QHBoxLayout; m_pathChooser = new Utils::PathChooser(this); m_pathChooser->setExpectedKind(Utils::PathChooser::ExistingCommand); - m_pathChooser->setHistoryCompleter(QLatin1String("LocalExecutable"), true); + m_pathChooser->setHistoryCompleter("LocalExecutable", true); m_pathChooser->setMinimumWidth(400); auto resetExecutable = new QPushButton(tr("Reset")); diff --git a/src/plugins/debugger/watchdata.cpp b/src/plugins/debugger/watchdata.cpp index 1204b9a2f23..c37e9d46a2b 100644 --- a/src/plugins/debugger/watchdata.cpp +++ b/src/plugins/debugger/watchdata.cpp @@ -137,7 +137,7 @@ void WatchItem::setError(const QString &msg) void WatchItem::setValue(const QString &value0) { value = value0; - if (value == QLatin1String("{...}")) { + if (value == "{...}") { value.clear(); wantsChildren = true; // at least one... } @@ -148,7 +148,7 @@ QString WatchItem::toString() const const char *doubleQuoteComma = "\","; QString res; QTextStream str(&res); - str << QLatin1Char('{'); + str << '{'; if (!iname.isEmpty()) str << "iname=\"" << iname << doubleQuoteComma; if (!name.isEmpty() && name != iname) @@ -180,9 +180,9 @@ QString WatchItem::toString() const str << "wantsChildren=\"" << (wantsChildren ? "true" : "false") << doubleQuoteComma; str.flush(); - if (res.endsWith(QLatin1Char(','))) + if (res.endsWith(',')) res.truncate(res.size() - 1); - return res + QLatin1Char('}'); + return res + '}'; } QString WatchItem::msgNotInScope() @@ -468,7 +468,7 @@ void WatchItem::parse(const GdbMi &data, bool maySort) static void formatToolTipRow(QTextStream &str, const QString &category, const QString &value) { QString val = value.toHtmlEscaped(); - val.replace(QLatin1Char('\n'), QLatin1String("<br>")); + val.replace('\n', "<br>"); str << "<tr><td>" << category << "</td><td>"; if (!category.isEmpty()) str << ':'; @@ -494,7 +494,7 @@ QString WatchItem::toToolTip() const QString val = value; if (val.size() > 1000) { val.truncate(1000); - val += QLatin1Char(' '); + val += ' '; val += tr("... <cut off>"); } formatToolTipRow(str, tr("Value"), val); diff --git a/src/plugins/debugger/watchdelegatewidgets.cpp b/src/plugins/debugger/watchdelegatewidgets.cpp index 4a6d9bbba40..efd2dca0649 100644 --- a/src/plugins/debugger/watchdelegatewidgets.cpp +++ b/src/plugins/debugger/watchdelegatewidgets.cpp @@ -109,14 +109,14 @@ QValidator::State IntegerValidator::validateEntry(const QString &s, int base, bo return QValidator::Intermediate; int pos = 0; // Skip sign. - if (signedV && s.at(pos) == QLatin1Char('-')) { + if (signedV && s.at(pos) == '-') { pos++; if (pos == size) return QValidator::Intermediate; } // Hexadecimal: '0x'? if (base == 16 && pos + 2 <= size - && s.at(pos) == QLatin1Char('0') && s.at(pos + 1) == QLatin1Char('x')) { + && s.at(pos) == '0' && s.at(pos + 1) == 'x') { pos+= 2; if (pos == size) return QValidator::Intermediate; @@ -236,7 +236,7 @@ void IntegerWatchLineEdit::setModelData(const QVariant &v) default: qWarning("Invalid value (%s) passed to IntegerLineEdit::setModelData", v.typeName()); - setText(QString(QLatin1Char('0'))); + setText(QString('0')); break; } if (debug) @@ -303,7 +303,7 @@ WatchLineEdit *WatchLineEdit::create(QVariant::Type t, QWidget *parent) BooleanComboBox::BooleanComboBox(QWidget *parent) : QComboBox(parent) { QStringList items; - items << QLatin1String("false") << QLatin1String("true"); + items << "false" << "true"; addItems(items); } diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 81ffc9174d5..3826e33a9f2 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -652,7 +652,7 @@ static QString reformatCharacter(int code, int size, bool isSigned) if (code < 0) out += QString("/%1 ").arg((1ULL << (8*size)) + code).left(2 + 2 * size); else - out += QString(2 + 2 * size, QLatin1Char(' ')); + out += QString(2 + 2 * size, ' '); } else { out += QString::number(unsigned(code)); } @@ -2193,7 +2193,7 @@ void WatchHandler::watchExpression(const QString &exp, const QString &name, bool saveWatchers(); if (m_model->m_engine->state() == DebuggerNotReady) { - item->setValue(QString(QLatin1Char(' '))); + item->setValue(" "); item->update(); } else { m_model->m_engine->updateWatchData(item->iname); @@ -2216,7 +2216,7 @@ void WatchHandler::updateWatchExpression(WatchItem *item, const QString &newExp) saveWatchers(); if (m_model->m_engine->state() == DebuggerNotReady) { - item->setValue(QString(QLatin1Char(' '))); + item->setValue(" "); item->update(); } else { m_model->m_engine->updateWatchData(item->iname); @@ -2622,7 +2622,7 @@ QString WatchModel::editorContents(const QModelIndexList &list) QTextStream ts(&contents); forAllItems([&ts, this, list](WatchItem *item) { if (list.isEmpty() || list.contains(indexForItem(item))) { - const QChar tab = QLatin1Char('\t'); + const QChar tab = '\t'; const QChar nl = '\n'; ts << QString(item->level(), tab) << item->name << tab << displayValue(item) << tab << item->type << nl; diff --git a/src/plugins/diffeditor/descriptionwidgetwatcher.cpp b/src/plugins/diffeditor/descriptionwidgetwatcher.cpp index 5b266ebe74a..0279fdcdb9c 100644 --- a/src/plugins/diffeditor/descriptionwidgetwatcher.cpp +++ b/src/plugins/diffeditor/descriptionwidgetwatcher.cpp @@ -68,7 +68,7 @@ QList<TextEditor::TextEditorWidget *> DescriptionWidgetWatcher::descriptionWidge TextEditor::TextEditorWidget *DescriptionWidgetWatcher::descriptionWidget(Core::IEditor *editor) const { - if (Internal::DiffEditor *diffEditor = qobject_cast<Internal::DiffEditor *>(editor)) { + if (auto diffEditor = qobject_cast<const Internal::DiffEditor *>(editor)) { if (diffEditor->document() == m_document) return diffEditor->descriptionWidget(); } diff --git a/src/plugins/diffeditor/diffeditor.cpp b/src/plugins/diffeditor/diffeditor.cpp index ca860beb375..3e86febfab6 100644 --- a/src/plugins/diffeditor/diffeditor.cpp +++ b/src/plugins/diffeditor/diffeditor.cpp @@ -258,7 +258,7 @@ DiffEditor::~DiffEditor() Core::IEditor *DiffEditor::duplicate() { - DiffEditor *editor = new DiffEditor(); + auto editor = new DiffEditor(); Utils::GuardLocker guard(editor->m_ignoreChanges); editor->setDocument(m_document); diff --git a/src/plugins/diffeditor/diffeditorfactory.h b/src/plugins/diffeditor/diffeditorfactory.h index bea963632ee..2f89ac6ba31 100644 --- a/src/plugins/diffeditor/diffeditorfactory.h +++ b/src/plugins/diffeditor/diffeditorfactory.h @@ -40,7 +40,7 @@ class DiffEditorFactory : public Core::IEditorFactory public: explicit DiffEditorFactory(QObject *parent); - Core::IEditor *createEditor(); + Core::IEditor *createEditor() override; }; } // namespace Internal diff --git a/src/plugins/diffeditor/diffeditorplugin.cpp b/src/plugins/diffeditor/diffeditorplugin.cpp index 6d3ba8858d8..0c52b55a9e1 100644 --- a/src/plugins/diffeditor/diffeditorplugin.cpp +++ b/src/plugins/diffeditor/diffeditorplugin.cpp @@ -129,7 +129,7 @@ class DiffFilesController : public DiffEditorController Q_OBJECT public: DiffFilesController(IDocument *document); - ~DiffFilesController(); + ~DiffFilesController() override; protected: void reload() final; @@ -203,7 +203,7 @@ QList<ReloadInput> DiffCurrentFileController::reloadInputList() const { QList<ReloadInput> result; - TextEditor::TextDocument *textDocument = qobject_cast<TextEditor::TextDocument *>( + auto textDocument = qobject_cast<TextEditor::TextDocument *>( DocumentModel::documentForFilePath(m_fileName)); if (textDocument && textDocument->isModified()) { @@ -259,7 +259,7 @@ QList<ReloadInput> DiffOpenFilesController::reloadInputList() const const QList<IDocument *> openedDocuments = DocumentModel::openedDocuments(); for (IDocument *doc : openedDocuments) { - TextEditor::TextDocument *textDocument = qobject_cast<TextEditor::TextDocument *>(doc); + auto textDocument = qobject_cast<TextEditor::TextDocument *>(doc); if (textDocument && textDocument->isModified()) { QString errorString; @@ -317,7 +317,7 @@ QList<ReloadInput> DiffModifiedFilesController::reloadInputList() const QList<ReloadInput> result; for (const QString &fileName : m_fileNames) { - TextEditor::TextDocument *textDocument = qobject_cast<TextEditor::TextDocument *>( + auto textDocument = qobject_cast<TextEditor::TextDocument *>( DocumentModel::documentForFilePath(fileName)); if (textDocument && textDocument->isModified()) { diff --git a/src/plugins/diffeditor/diffeditorplugin.h b/src/plugins/diffeditor/diffeditorplugin.h index 28654210150..84d642b9f37 100644 --- a/src/plugins/diffeditor/diffeditorplugin.h +++ b/src/plugins/diffeditor/diffeditorplugin.h @@ -54,8 +54,8 @@ class DiffEditorPlugin : public ExtensionSystem::IPlugin Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "DiffEditor.json") public: - bool initialize(const QStringList &arguments, QString *errorMessage = nullptr); - void extensionsInitialized(); + bool initialize(const QStringList &arguments, QString *errorMessage = nullptr) override; + void extensionsInitialized() override; private: void updateDiffCurrentFileAction(); diff --git a/src/plugins/diffeditor/diffeditorwidgetcontroller.cpp b/src/plugins/diffeditor/diffeditorwidgetcontroller.cpp index 834c320a526..e1c656d5c74 100644 --- a/src/plugins/diffeditor/diffeditorwidgetcontroller.cpp +++ b/src/plugins/diffeditor/diffeditorwidgetcontroller.cpp @@ -168,7 +168,7 @@ void DiffEditorWidgetController::patch(bool revert, int fileIndex, int chunkInde workingDirectory, strip, revert)) m_document->reload(); } else { // PatchEditor - TextEditor::TextDocument *textDocument = qobject_cast<TextEditor::TextDocument *>( + auto textDocument = qobject_cast<TextEditor::TextDocument *>( DocumentModel::documentForFilePath(absFileName)); if (!textDocument) return; diff --git a/src/plugins/diffeditor/diffutils.h b/src/plugins/diffeditor/diffutils.h index 31956e62968..605266a0efe 100644 --- a/src/plugins/diffeditor/diffutils.h +++ b/src/plugins/diffeditor/diffutils.h @@ -47,7 +47,7 @@ public: PatchEditor }; - DiffFileInfo() {} + DiffFileInfo() = default; DiffFileInfo(const QString &file) : fileName(file) {} DiffFileInfo(const QString &file, const QString &type) : fileName(file), typeInfo(type) {} diff --git a/src/plugins/diffeditor/diffview.h b/src/plugins/diffeditor/diffview.h index 93405a04230..1f760d82c4a 100644 --- a/src/plugins/diffeditor/diffview.h +++ b/src/plugins/diffeditor/diffview.h @@ -93,17 +93,17 @@ class UnifiedView : public IDiffView public: UnifiedView(); - QWidget *widget(); + QWidget *widget() override; TextEditor::TextEditorWidget *textEditorWidget(); - void setDocument(DiffEditorDocument *document); + void setDocument(DiffEditorDocument *document) override; - void beginOperation(); - void setCurrentDiffFileIndex(int index); - void setDiff(const QList<FileData> &diffFileList, const QString &workingDirectory); - void endOperation(bool success); + void beginOperation() override; + void setCurrentDiffFileIndex(int index) override; + void setDiff(const QList<FileData> &diffFileList, const QString &workingDirectory) override; + void endOperation(bool success) override; - void setSync(bool sync); + void setSync(bool sync) override; private: UnifiedDiffEditorWidget *m_widget = nullptr; @@ -116,18 +116,18 @@ class SideBySideView : public IDiffView public: SideBySideView(); - QWidget *widget(); + QWidget *widget() override; TextEditor::TextEditorWidget *leftEditorWidget(); TextEditor::TextEditorWidget *rightEditorWidget(); - void setDocument(DiffEditorDocument *document); + void setDocument(DiffEditorDocument *document) override; - void beginOperation(); - void setCurrentDiffFileIndex(int index); - void setDiff(const QList<FileData> &diffFileList, const QString &workingDirectory); - void endOperation(bool success); + void beginOperation() override; + void setCurrentDiffFileIndex(int index) override; + void setDiff(const QList<FileData> &diffFileList, const QString &workingDirectory) override; + void endOperation(bool success) override; - void setSync(bool sync); + void setSync(bool sync) override; private: SideBySideDiffEditorWidget *m_widget; diff --git a/src/plugins/diffeditor/selectabletexteditorwidget.cpp b/src/plugins/diffeditor/selectabletexteditorwidget.cpp index 68158fdf449..5d35b06e567 100644 --- a/src/plugins/diffeditor/selectabletexteditorwidget.cpp +++ b/src/plugins/diffeditor/selectabletexteditorwidget.cpp @@ -40,9 +40,7 @@ SelectableTextEditorWidget::SelectableTextEditorWidget(Core::Id id, QWidget *par setupFallBackEditor(id); } -SelectableTextEditorWidget::~SelectableTextEditorWidget() -{ -} +SelectableTextEditorWidget::~SelectableTextEditorWidget() = default; static QList<DiffSelection> subtractSelection( const DiffSelection &minuendSelection, diff --git a/src/plugins/diffeditor/selectabletexteditorwidget.h b/src/plugins/diffeditor/selectabletexteditorwidget.h index e8df6fed7bf..7059177f648 100644 --- a/src/plugins/diffeditor/selectabletexteditorwidget.h +++ b/src/plugins/diffeditor/selectabletexteditorwidget.h @@ -33,7 +33,7 @@ namespace Internal { class DiffSelection { public: - DiffSelection() {} + DiffSelection() = default; DiffSelection(QTextCharFormat *f) : format(f) {} DiffSelection(int s, int e, QTextCharFormat *f) : start(s), end(e), format(f) {} diff --git a/src/plugins/diffeditor/sidebysidediffeditorwidget.cpp b/src/plugins/diffeditor/sidebysidediffeditorwidget.cpp index f1e893cd1f3..3e9a72050b3 100644 --- a/src/plugins/diffeditor/sidebysidediffeditorwidget.cpp +++ b/src/plugins/diffeditor/sidebysidediffeditorwidget.cpp @@ -174,7 +174,7 @@ SideDiffEditorWidget::SideDiffEditorWidget(QWidget *parent) ToolTip::hide(); }); - TextDocumentLayout *documentLayout = qobject_cast<TextDocumentLayout*>(document()->documentLayout()); + auto documentLayout = qobject_cast<TextDocumentLayout*>(document()->documentLayout()); if (documentLayout) connect(documentLayout, &TextDocumentLayout::foldChanged, this, &SideDiffEditorWidget::foldChanged); @@ -210,7 +210,7 @@ void SideDiffEditorWidget::setFolded(int blockNumber, bool folded) TextDocumentLayout::doFoldOrUnfold(block, !folded); - TextDocumentLayout *documentLayout = qobject_cast<TextDocumentLayout*>(document()->documentLayout()); + auto documentLayout = qobject_cast<TextDocumentLayout*>(document()->documentLayout()); documentLayout->requestUpdate(); documentLayout->emitDocumentSizeChanged(); } diff --git a/src/plugins/diffeditor/sidebysidediffeditorwidget.h b/src/plugins/diffeditor/sidebysidediffeditorwidget.h index ee6f5f0eb72..1750a13ba8e 100644 --- a/src/plugins/diffeditor/sidebysidediffeditorwidget.h +++ b/src/plugins/diffeditor/sidebysidediffeditorwidget.h @@ -57,7 +57,7 @@ class SideBySideDiffEditorWidget : public QWidget Q_OBJECT public: explicit SideBySideDiffEditorWidget(QWidget *parent = nullptr); - ~SideBySideDiffEditorWidget(); + ~SideBySideDiffEditorWidget() override; TextEditor::TextEditorWidget *leftEditorWidget() const; TextEditor::TextEditorWidget *rightEditorWidget() const; diff --git a/src/plugins/emacskeys/emacskeysplugin.cpp b/src/plugins/emacskeys/emacskeysplugin.cpp index de26f421664..369d1dea02d 100644 --- a/src/plugins/emacskeys/emacskeysplugin.cpp +++ b/src/plugins/emacskeys/emacskeysplugin.cpp @@ -58,13 +58,9 @@ namespace Internal { // EmacsKeysPlugin //--------------------------------------------------------------------------- -EmacsKeysPlugin::EmacsKeysPlugin(): m_currentEditorWidget(0) -{ -} +EmacsKeysPlugin::EmacsKeysPlugin() = default; -EmacsKeysPlugin::~EmacsKeysPlugin() -{ -} +EmacsKeysPlugin::~EmacsKeysPlugin() = default; bool EmacsKeysPlugin::initialize(const QStringList &arguments, QString *errorString) { @@ -141,7 +137,7 @@ ExtensionSystem::IPlugin::ShutdownFlag EmacsKeysPlugin::aboutToShutdown() void EmacsKeysPlugin::editorAboutToClose(IEditor *editor) { - QPlainTextEdit *w = qobject_cast<QPlainTextEdit*>(editor->widget()); + auto w = qobject_cast<QPlainTextEdit*>(editor->widget()); if (!w) return; @@ -154,7 +150,7 @@ void EmacsKeysPlugin::editorAboutToClose(IEditor *editor) void EmacsKeysPlugin::currentEditorChanged(IEditor *editor) { if (!editor) { - m_currentEditorWidget = 0; + m_currentEditorWidget = nullptr; return; } m_currentEditorWidget = qobject_cast<QPlainTextEdit*>(editor->widget()); @@ -314,7 +310,7 @@ void EmacsKeysPlugin::insertLineAndIndent() QTextCursor cursor = m_currentEditorWidget->textCursor(); cursor.beginEditBlock(); cursor.insertBlock(); - if (m_currentBaseTextEditorWidget != 0) + if (m_currentBaseTextEditorWidget) m_currentBaseTextEditorWidget->textDocument()->autoIndent(cursor); cursor.endEditBlock(); m_currentEditorWidget->setTextCursor(cursor); @@ -324,7 +320,7 @@ void EmacsKeysPlugin::insertLineAndIndent() QAction *EmacsKeysPlugin::registerAction(Id id, void (EmacsKeysPlugin::*callback)(), const QString &title) { - QAction *result = new QAction(title, this); + auto result = new QAction(title, this); ActionManager::registerAction(result, id, Context(Core::Constants::C_GLOBAL), true); connect(result, &QAction::triggered, this, callback); return result; @@ -339,7 +335,7 @@ void EmacsKeysPlugin::genericGoto(QTextCursor::MoveOperation op, bool abortAssis cursor.movePosition(op, m_currentState->mark() != -1 ? QTextCursor::KeepAnchor : QTextCursor::MoveAnchor); m_currentEditorWidget->setTextCursor(cursor); - if (abortAssist && m_currentBaseTextEditorWidget != 0) + if (abortAssist && m_currentBaseTextEditorWidget) m_currentBaseTextEditorWidget->abortAssist(); m_currentState->endOwnAction(KeysActionOther); } diff --git a/src/plugins/emacskeys/emacskeysplugin.h b/src/plugins/emacskeys/emacskeysplugin.h index 96561b75f96..5f8ba19235e 100644 --- a/src/plugins/emacskeys/emacskeysplugin.h +++ b/src/plugins/emacskeys/emacskeysplugin.h @@ -52,11 +52,11 @@ class EmacsKeysPlugin : public ExtensionSystem::IPlugin public: EmacsKeysPlugin(); - ~EmacsKeysPlugin(); + ~EmacsKeysPlugin() override; - bool initialize(const QStringList &arguments, QString *errorString); - void extensionsInitialized(); - ShutdownFlag aboutToShutdown(); + bool initialize(const QStringList &arguments, QString *errorString) override; + void extensionsInitialized() override; + ShutdownFlag aboutToShutdown() override; private: void editorAboutToClose(Core::IEditor *editor); @@ -93,9 +93,9 @@ private: void genericVScroll(int direction); QHash<QPlainTextEdit*, EmacsKeysState*> m_stateMap; - QPlainTextEdit *m_currentEditorWidget; - EmacsKeysState *m_currentState; - TextEditor::TextEditorWidget *m_currentBaseTextEditorWidget; + QPlainTextEdit *m_currentEditorWidget = nullptr; + EmacsKeysState *m_currentState = nullptr; + TextEditor::TextEditorWidget *m_currentBaseTextEditorWidget = nullptr; }; } // namespace Internal diff --git a/src/plugins/emacskeys/emacskeysstate.cpp b/src/plugins/emacskeys/emacskeysstate.cpp index ab3257e71e2..90cec01e9c1 100644 --- a/src/plugins/emacskeys/emacskeysstate.cpp +++ b/src/plugins/emacskeys/emacskeysstate.cpp @@ -48,7 +48,7 @@ EmacsKeysState::EmacsKeysState(QPlainTextEdit *edit): this, &EmacsKeysState::selectionChanged); } -EmacsKeysState::~EmacsKeysState() {} +EmacsKeysState::~EmacsKeysState() = default; void EmacsKeysState::setLastAction(EmacsKeysAction action) { diff --git a/src/plugins/emacskeys/emacskeysstate.h b/src/plugins/emacskeys/emacskeysstate.h index 28dc74e1c7d..a0de7ceffd6 100644 --- a/src/plugins/emacskeys/emacskeysstate.h +++ b/src/plugins/emacskeys/emacskeysstate.h @@ -42,7 +42,7 @@ class EmacsKeysState : public QObject { public: EmacsKeysState(QPlainTextEdit *edit); - ~EmacsKeysState(); + ~EmacsKeysState() override; void setLastAction(EmacsKeysAction action); void beginOwnAction() { m_ignore3rdParty = true; } void endOwnAction(EmacsKeysAction action) { diff --git a/src/plugins/fakevim/fakevim_test.cpp b/src/plugins/fakevim/fakevim_test.cpp index a5dca213fb1..88973a5200e 100644 --- a/src/plugins/fakevim/fakevim_test.cpp +++ b/src/plugins/fakevim/fakevim_test.cpp @@ -255,7 +255,7 @@ struct FakeVimPlugin::TestData int lines() const { QTextDocument *doc = editor()->document(); - Q_ASSERT(doc != 0); + Q_ASSERT(doc != nullptr); return doc->lineCount(); } diff --git a/src/plugins/fakevim/fakevimactions.cpp b/src/plugins/fakevim/fakevimactions.cpp index db8b82c1bfc..0c6dcc01ec4 100644 --- a/src/plugins/fakevim/fakevimactions.cpp +++ b/src/plugins/fakevim/fakevimactions.cpp @@ -146,7 +146,7 @@ void FakeVimSettings::writeSettings(QSettings *settings) FakeVimAction *FakeVimSettings::item(int code) { - QTC_ASSERT(m_items.value(code, 0), qDebug() << "CODE: " << code; return 0); + QTC_ASSERT(m_items.value(code, 0), qDebug() << "CODE: " << code; return nullptr); return m_items.value(code, 0); } @@ -176,7 +176,7 @@ void FakeVimSettings::createAction(int code, const QVariant &value, const QString &settingsKey, const QString &shortKey) { - FakeVimAction *item = new FakeVimAction(0); + auto item = new FakeVimAction(nullptr); item->setValue(value); item->setSettingsKey("FakeVim", settingsKey); item->setDefaultValue(value); diff --git a/src/plugins/fakevim/fakevimactions.h b/src/plugins/fakevim/fakevimactions.h index e1c230ba512..f0607f33d84 100644 --- a/src/plugins/fakevim/fakevimactions.h +++ b/src/plugins/fakevim/fakevimactions.h @@ -61,9 +61,9 @@ public: }; #ifdef FAKEVIM_STANDALONE -typedef DummyAction FakeVimAction; +using FakeVimAction = DummyAction; #else -typedef Utils::SavedAction FakeVimAction; +using FakeVimAction = Utils::SavedAction; #endif enum FakeVimSettingsCode diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index bf98680f5dc..e90393c9cfa 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -252,7 +252,7 @@ enum EventResult struct CursorPosition { - CursorPosition() {} + CursorPosition() = default; CursorPosition(int block, int column) : line(block), column(column) {} explicit CursorPosition(const QTextCursor &tc) : line(tc.block().blockNumber()), column(tc.positionInBlock()) {} @@ -320,12 +320,12 @@ private: CursorPosition m_position; QString m_fileName; }; -typedef QHash<QChar, Mark> Marks; -typedef QHashIterator<QChar, Mark> MarksIterator; +using Marks = QHash<QChar, Mark>; +using MarksIterator = QHashIterator<QChar, Mark>; struct State { - State() {} + State() = default; State(int revision, const CursorPosition &position, const Marks &marks, VisualMode lastVisualMode, bool lastVisualModeInverted) : revision(revision), position(position), marks(marks), lastVisualMode(lastVisualMode), @@ -354,7 +354,7 @@ QDebug operator<<(QDebug ts, const Column &col) struct Register { - Register() {} + Register() = default; Register(const QString &c) : contents(c) {} Register(const QString &c, RangeMode m) : contents(c), rangemode(m) {} QString contents; @@ -982,7 +982,7 @@ public: return m & ~Qt::KeypadModifier; } - Input() {} + Input() = default; explicit Input(QChar x) : m_key(x.unicode()), m_xkey(x.unicode()), m_text(x) { @@ -1252,7 +1252,7 @@ QDebug operator<<(QDebug ts, const Input &input) { return input.dump(ts); } class Inputs : public QVector<Input> { public: - Inputs() {} + Inputs() = default; explicit Inputs(const QString &str, bool noremap = true, bool silent = false) : m_noremap(noremap), m_silent(silent) @@ -1521,7 +1521,7 @@ private: }; // Mappings for all modes -typedef QHash<char, ModeMapping> Mappings; +using Mappings = QHash<char, ModeMapping>; // Iterator for mappings class MappingsIterator : public QVector<ModeMapping::Iterator> @@ -1641,7 +1641,7 @@ private: // state of current mapping struct MappingState { - MappingState() {} + MappingState() = default; MappingState(bool noremap, bool silent, bool editBlock) : noremap(noremap), silent(silent), editBlock(editBlock) {} bool noremap = false; @@ -2010,7 +2010,7 @@ public: bool startRecording(const Input &input); void record(const Input &input); void stopRecording(); - bool executeRegister(int register); + bool executeRegister(int reg); // Handle current command as synonym void handleAs(const QString &command); @@ -2037,7 +2037,7 @@ public: int position() const { return m_cursor.position(); } // Transform text selected by cursor in current visual mode. - typedef std::function<QString(const QString &)> Transformation; + using Transformation = std::function<QString(const QString &)>; void transformText(const Range &range, QTextCursor &tc, const std::function<void()> &transform) const; void transformText(const Range &range, const Transformation &transform); @@ -2119,7 +2119,7 @@ public: QString registerContents(int reg) const; void setRegister(int reg, const QString &contents, RangeMode mode); RangeMode registerRangeMode(int reg) const; - void getRegisterType(int *reg, bool *isClipboard, bool *isSelection, bool *append = 0) const; + void getRegisterType(int *reg, bool *isClipboard, bool *isSelection, bool *append = nullptr) const; void recordJump(int position = -1); void jump(int distance); @@ -2207,7 +2207,7 @@ public: QPointer<FakeVimHandler::Private> currentHandler; }; - typedef QSharedPointer<BufferData> BufferDataPtr; + using BufferDataPtr = QSharedPointer<BufferData>; void pullOrCreateBufferData(); BufferDataPtr m_buffer; @@ -5899,7 +5899,7 @@ bool FakeVimHandler::Private::handleExMoveCommand(const ExCommand &cmd) setMark('>', lastPosition); if (lines > 2) - showMessage(MessageInfo, Tr::tr("%n lines moved.", 0, lines)); + showMessage(MessageInfo, Tr::tr("%n lines moved.", nullptr, lines)); return true; } @@ -6044,7 +6044,7 @@ bool FakeVimHandler::Private::handleExBangCommand(const ExCommand &cmd) // :! endEditBlock(); leaveVisualMode(); //qDebug() << "FILTER: " << command; - showMessage(MessageInfo, Tr::tr("%n lines filtered.", 0, + showMessage(MessageInfo, Tr::tr("%n lines filtered.", nullptr, input.count('\n'))); } else if (!result.isEmpty()) { q->extraInformationChanged(result); @@ -6489,7 +6489,7 @@ void FakeVimHandler::Private::indentSelectedText(QChar typedChar) const int lines = endLine - beginLine + 1; if (lines > 2) - showMessage(MessageInfo, Tr::tr("%n lines indented.", 0, lines)); + showMessage(MessageInfo, Tr::tr("%n lines indented.", nullptr, lines)); } void FakeVimHandler::Private::indentText(const Range &range, QChar typedChar) @@ -6545,7 +6545,7 @@ void FakeVimHandler::Private::shiftRegionRight(int repeat) const int lines = endLine - beginLine + 1; if (lines > 2) { showMessage(MessageInfo, - Tr::tr("%n lines %1ed %2 time.", 0, lines) + Tr::tr("%n lines %1ed %2 time.", nullptr, lines) .arg(repeat > 0 ? '>' : '<').arg(qAbs(repeat))); } } @@ -7083,7 +7083,7 @@ void FakeVimHandler::Private::yankText(const Range &range, int reg) const int lines = blockAt(range.endPos).blockNumber() - blockAt(range.beginPos).blockNumber() + 1; if (lines > 2) - showMessage(MessageInfo, Tr::tr("%n lines yanked.", 0, lines)); + showMessage(MessageInfo, Tr::tr("%n lines yanked.", nullptr, lines)); } void FakeVimHandler::Private::transformText( @@ -8610,7 +8610,7 @@ void FakeVimHandler::Private::getRegisterType(int *reg, bool *isClipboard, bool // If register is uppercase, append content to lower case register on yank/delete. const QChar c(*reg); - if (append != 0) + if (append != nullptr) *append = c.isUpper(); if (c.isUpper()) *reg = c.toLower().unicode(); @@ -8631,9 +8631,9 @@ void FakeVimHandler::Private::getRegisterType(int *reg, bool *isClipboard, bool selection = false; } - if (isClipboard != 0) + if (isClipboard != nullptr) *isClipboard = clipboard; - if (isSelection != 0) + if (isSelection != nullptr) *isSelection = selection; } @@ -8655,8 +8655,8 @@ FakeVimHandler::~FakeVimHandler() // gracefully handle that the parent editor is deleted void FakeVimHandler::disconnectFromEditor() { - d->m_textedit = 0; - d->m_plaintextedit = 0; + d->m_textedit = nullptr; + d->m_plaintextedit = nullptr; } void FakeVimHandler::updateGlobalMarksFilenames(const QString &oldFileName, const QString &newFileName) @@ -8683,7 +8683,7 @@ bool FakeVimHandler::eventFilter(QObject *ob, QEvent *ev) if (ev->type() == QEvent::KeyPress && (ob == d->editor() || (Private::g.mode == ExMode || Private::g.subsubmode == SearchSubSubMode))) { - QKeyEvent *kev = static_cast<QKeyEvent *>(ev); + auto kev = static_cast<QKeyEvent *>(ev); KEY_DEBUG("KEYPRESS" << kev->key() << kev->text() << QChar(kev->key())); EventResult res = d->handleEvent(kev); //if (Private::g.mode == InsertMode) @@ -8697,7 +8697,7 @@ bool FakeVimHandler::eventFilter(QObject *ob, QEvent *ev) if (ev->type() == QEvent::ShortcutOverride && (ob == d->editor() || (Private::g.mode == ExMode || Private::g.subsubmode == SearchSubSubMode))) { - QKeyEvent *kev = static_cast<QKeyEvent *>(ev); + auto kev = static_cast<QKeyEvent *>(ev); if (d->wantsOverride(kev)) { KEY_DEBUG("OVERRIDING SHORTCUT" << kev->key()); ev->accept(); // accepting means "don't run the shortcuts" diff --git a/src/plugins/fakevim/fakevimhandler.h b/src/plugins/fakevim/fakevimhandler.h index 25ce463554b..9ba321fca95 100644 --- a/src/plugins/fakevim/fakevimhandler.h +++ b/src/plugins/fakevim/fakevimhandler.h @@ -47,7 +47,7 @@ enum RangeMode struct Range { - Range() {} + Range() = default; Range(int b, int e, RangeMode m = RangeCharMode); QString toString() const; bool isValid() const; @@ -59,7 +59,7 @@ struct Range struct ExCommand { - ExCommand() {} + ExCommand() = default; ExCommand(const QString &cmd, const QString &args = QString(), const Range &range = Range()); @@ -107,8 +107,8 @@ class FakeVimHandler : public QObject Q_OBJECT public: - explicit FakeVimHandler(QWidget *widget, QObject *parent = 0); - ~FakeVimHandler(); + explicit FakeVimHandler(QWidget *widget, QObject *parent = nullptr); + ~FakeVimHandler() override; QWidget *widget(); @@ -151,7 +151,7 @@ public: bool jumpToLocalMark(QChar mark, bool backTickMode); - bool eventFilter(QObject *ob, QEvent *ev); + bool eventFilter(QObject *ob, QEvent *ev) override; Signal<void(const QString &msg, int cursorPos, int anchorPos, int messageLevel)> commandBufferChanged; Signal<void(const QString &msg)> statusDataChanged; diff --git a/src/plugins/fakevim/fakevimplugin.cpp b/src/plugins/fakevim/fakevimplugin.cpp index 443b36f4d9f..0cf23112690 100644 --- a/src/plugins/fakevim/fakevimplugin.cpp +++ b/src/plugins/fakevim/fakevimplugin.cpp @@ -200,7 +200,7 @@ public: m_lastMessageLevel = messageLevel; } - QSize sizeHint() const + QSize sizeHint() const override { QSize size = QWidget::sizeHint(); // reserve maximal width for line edit widget @@ -259,7 +259,7 @@ public: } protected: - void paintEvent(QPaintEvent *event) + void paintEvent(QPaintEvent *event) override { QTextCursor firstVisibleCursor = m_editor->cursorForPosition(QPoint(0, 0)); QTextBlock firstVisibleBlock = firstVisibleCursor.block(); @@ -310,7 +310,7 @@ protected: } } - bool eventFilter(QObject *, QEvent *event) + bool eventFilter(QObject *, QEvent *event) override { if (event->type() == QEvent::Resize || event->type() == QEvent::Move) m_timerUpdate.start(); @@ -352,8 +352,8 @@ private: // /////////////////////////////////////////////////////////////////////// -typedef QMap<QString, QRegExp> ExCommandMap; -typedef QMap<int, QString> UserCommandMap; +using ExCommandMap = QMap<QString, QRegExp>; +using UserCommandMap = QMap<int, QString>; class FakeVimOptionPage : public IOptionsPage { @@ -368,9 +368,9 @@ public: Utils::Theme::PanelTextColorDark}}, Utils::Icon::Tint)); } - QWidget *widget(); - void apply(); - void finish(); + QWidget *widget() override; + void apply() override; + void finish() override; private: void copyTextEditorSettings(); @@ -556,7 +556,7 @@ public: void setActionChecked(Id id, bool check); - typedef int (*DistFunction)(const QRect &cursor, const QRect &other); + using DistFunction = int (*)(const QRect &, const QRect &); void moveSomewhere(FakeVimHandler *handler, DistFunction f, int count); void keepOnlyWindow(); // :only @@ -676,7 +676,7 @@ void FakeVimExCommandsPage::apply() QSettings *settings = ICore::settings(); settings->beginWriteArray(exCommandMapGroup); int count = 0; - typedef ExCommandMap::const_iterator Iterator; + using Iterator = ExCommandMap::const_iterator; const Iterator end = newMapping.constEnd(); for (Iterator it = newMapping.constBegin(); it != end; ++it) { const QString id = it.key(); @@ -807,12 +807,12 @@ public: FakeVimUserCommandsModel() { m_commandMap = dd->m_userCommandMap; } UserCommandMap commandMap() const { return m_commandMap; } - int rowCount(const QModelIndex &parent) const; - int columnCount(const QModelIndex &parent) const; - QVariant data(const QModelIndex &index, int role) const; - bool setData(const QModelIndex &index, const QVariant &data, int role); - QVariant headerData(int section, Qt::Orientation orientation, int role) const; - Qt::ItemFlags flags(const QModelIndex &index) const; + int rowCount(const QModelIndex &parent) const override; + int columnCount(const QModelIndex &parent) const override; + QVariant data(const QModelIndex &index, int role) const override; + bool setData(const QModelIndex &index, const QVariant &data, int role) override; + QVariant headerData(int section, Qt::Orientation orientation, int role) const override; + Qt::ItemFlags flags(const QModelIndex &index) const override; private: UserCommandMap m_commandMap; @@ -856,7 +856,7 @@ public: {} QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &, - const QModelIndex &) const + const QModelIndex &) const override { auto lineEdit = new QLineEdit(parent); lineEdit->setFrame(false); @@ -864,9 +864,9 @@ public: } void setModelData(QWidget *editor, QAbstractItemModel *model, - const QModelIndex &index) const + const QModelIndex &index) const override { - QLineEdit *lineEdit = qobject_cast<QLineEdit *>(editor); + auto lineEdit = qobject_cast<QLineEdit *>(editor); QTC_ASSERT(lineEdit, return); model->setData(index, lineEdit->text(), Qt::EditRole); } @@ -891,7 +891,7 @@ public: private: QPointer<QWidget> m_widget; - FakeVimUserCommandsModel *m_model; + FakeVimUserCommandsModel *m_model = nullptr; }; QWidget *FakeVimUserCommandsPage::widget() @@ -928,7 +928,7 @@ void FakeVimUserCommandsPage::apply() QSettings *settings = ICore::settings(); settings->beginWriteArray(userCommandMapGroup); int count = 0; - typedef UserCommandMap::const_iterator Iterator; + using Iterator = UserCommandMap::const_iterator; const Iterator end = current.constEnd(); for (Iterator it = current.constBegin(); it != end; ++it) { const int key = it.key(); @@ -960,7 +960,7 @@ void FakeVimUserCommandsPage::apply() class FakeVimCompletionAssistProvider : public CompletionAssistProvider { public: - IAssistProcessor *createProcessor() const; + IAssistProcessor *createProcessor() const override; void setActive(const QString &needle, bool forward, FakeVimHandler *handler) { @@ -969,7 +969,7 @@ public: if (!m_handler) return; - TextEditorWidget *editor = qobject_cast<TextEditorWidget *>(handler->widget()); + auto editor = qobject_cast<TextEditorWidget *>(handler->widget()); if (!editor) return; @@ -1258,7 +1258,7 @@ void FakeVimPluginPrivate::userActionTriggered(int key) void FakeVimPluginPrivate::createRelativeNumberWidget(IEditor *editor) { - if (TextEditorWidget *textEditor = qobject_cast<TextEditorWidget *>(editor->widget())) { + if (auto textEditor = qobject_cast<TextEditorWidget *>(editor->widget())) { auto relativeNumbers = new RelativeNumbersColumn(textEditor); connect(theFakeVimSetting(ConfigRelativeNumber), &SavedAction::valueChanged, relativeNumbers, &QObject::deleteLater); @@ -1386,13 +1386,13 @@ void FakeVimPluginPrivate::moveSomewhere(FakeVimHandler *handler, DistFunction f { QTC_ASSERT(handler, return); QWidget *w = handler->widget(); - QPlainTextEdit *pe = qobject_cast<QPlainTextEdit *>(w); + auto pe = qobject_cast<QPlainTextEdit *>(w); QTC_ASSERT(pe, return); QRect rc = pe->cursorRect(); QRect cursorRect(w->mapToGlobal(rc.topLeft()), w->mapToGlobal(rc.bottomRight())); //qDebug() << "\nCURSOR: " << cursorRect; - IEditor *bestEditor = 0; + IEditor *bestEditor = nullptr; int repeat = count; IEditor *currentEditor = EditorManager::currentEditor(); @@ -1503,12 +1503,12 @@ public: : QObject(parent), m_handler(handler) {} - ~DeferredDeleter() + ~DeferredDeleter() override { if (m_handler) { m_handler->disconnectFromEditor(); m_handler->deleteLater(); - m_handler = 0; + m_handler = nullptr; } } }; @@ -1526,12 +1526,12 @@ void FakeVimPluginPrivate::editorOpened(IEditor *editor) if (!qobject_cast<QTextEdit *>(widget) && !qobject_cast<QPlainTextEdit *>(widget)) return; - TextEditorWidget *tew = qobject_cast<TextEditorWidget *>(widget); + auto tew = qobject_cast<TextEditorWidget *>(widget); //qDebug() << "OPENING: " << editor << editor->widget() // << "MODE: " << theFakeVimSetting(ConfigUseFakeVim)->value(); - auto handler = new FakeVimHandler(widget, 0); + auto handler = new FakeVimHandler(widget, nullptr); // the handler might have triggered the deletion of the editor: // make sure that it can return before being deleted itself new DeferredDeleter(widget, handler); @@ -1560,8 +1560,7 @@ void FakeVimPluginPrivate::editorOpened(IEditor *editor) handler->highlightMatches.connect([](const QString &needle) { for (IEditor *editor : EditorManager::visibleEditors()) { QWidget *w = editor->widget(); - IFindSupport *find = Aggregation::query<IFindSupport>(w); - if (find != 0) + if (auto find = Aggregation::query<IFindSupport>(w)) find->highlightAll(needle, FindRegularExpression | FindCaseSensitively); } }); @@ -1707,7 +1706,7 @@ void FakeVimPluginPrivate::editorOpened(IEditor *editor) handler->foldAll.connect([handler](bool fold) { QTextDocument *document = handler->textCursor().document(); auto documentLayout = qobject_cast<TextDocumentLayout*>(document->documentLayout()); - QTC_ASSERT(documentLayout != 0, return); + QTC_ASSERT(documentLayout, return); QTextBlock block = document->firstBlock(); while (block.isValid()) { @@ -1871,7 +1870,7 @@ void FakeVimPluginPrivate::setUseFakeVimInternal(bool on) // Context(FAKEVIM_CONTEXT)); resetCommandBuffer(); foreach (IEditor *editor, m_editorToHandler.keys()) { - if (TextDocument *textDocument = qobject_cast<TextDocument *>(editor->document())) + if (auto textDocument = qobject_cast<const TextDocument *>(editor->document())) m_editorToHandler[editor]->restoreWidget(textDocument->tabSettings().m_tabSize); } } @@ -1928,7 +1927,7 @@ void FakeVimPluginPrivate::handleExCommand(FakeVimHandler *handler, bool *handle if (failed.isEmpty()) handler->showMessage(MessageInfo, Tr::tr("Saving succeeded")); else - handler->showMessage(MessageError, Tr::tr("%n files not saved", 0, failed.size())); + handler->showMessage(MessageError, Tr::tr("%n files not saved", nullptr, failed.size())); if (cmd.matches("wqa", "wqall")) emit delayedQuitAllRequested(cmd.hasBang); } else if (cmd.matches("q", "quit")) { diff --git a/src/plugins/fakevim/fakevimplugin.h b/src/plugins/fakevim/fakevimplugin.h index 98f526ce44a..2dbcbfcb8a4 100644 --- a/src/plugins/fakevim/fakevimplugin.h +++ b/src/plugins/fakevim/fakevimplugin.h @@ -39,13 +39,13 @@ class FakeVimPlugin : public ExtensionSystem::IPlugin public: FakeVimPlugin(); - ~FakeVimPlugin(); + ~FakeVimPlugin() override; private: // implementation of ExtensionSystem::IPlugin - bool initialize(const QStringList &arguments, QString *errorMessage); - ShutdownFlag aboutToShutdown(); - void extensionsInitialized(); + bool initialize(const QStringList &arguments, QString *errorMessage) override; + ShutdownFlag aboutToShutdown() override; + void extensionsInitialized() override; private: friend class FakeVimPluginPrivate; diff --git a/src/plugins/genericprojectmanager/filesselectionwizardpage.cpp b/src/plugins/genericprojectmanager/filesselectionwizardpage.cpp index 4e8f5f9d809..9e2c92f7d52 100644 --- a/src/plugins/genericprojectmanager/filesselectionwizardpage.cpp +++ b/src/plugins/genericprojectmanager/filesselectionwizardpage.cpp @@ -44,7 +44,7 @@ FilesSelectionWizardPage::FilesSelectionWizardPage(GenericProjectWizardDialog *g m_genericProjectWizardDialog(genericProjectWizard), m_filesWidget(new ProjectExplorer::SelectableFilesWidget(this)) { - QVBoxLayout *layout = new QVBoxLayout(this); + auto layout = new QVBoxLayout(this); layout->addWidget(m_filesWidget); m_filesWidget->setBaseDirEditable(false); diff --git a/src/plugins/genericprojectmanager/genericbuildconfiguration.cpp b/src/plugins/genericprojectmanager/genericbuildconfiguration.cpp index ef4f03b5c1f..f6b9ea99f56 100644 --- a/src/plugins/genericprojectmanager/genericbuildconfiguration.cpp +++ b/src/plugins/genericprojectmanager/genericbuildconfiguration.cpp @@ -89,9 +89,7 @@ GenericBuildConfigurationFactory::GenericBuildConfigurationFactory() setSupportedProjectMimeTypeName(Constants::GENERICMIMETYPE); } -GenericBuildConfigurationFactory::~GenericBuildConfigurationFactory() -{ -} +GenericBuildConfigurationFactory::~GenericBuildConfigurationFactory() = default; QList<BuildInfo *> GenericBuildConfigurationFactory::availableBuilds(const Target *parent) const { @@ -136,7 +134,7 @@ void GenericBuildConfiguration::addToEnvironment(Utils::Environment &env) const //////////////////////////////////////////////////////////////////////////////////// GenericBuildSettingsWidget::GenericBuildSettingsWidget(GenericBuildConfiguration *bc) - : m_buildConfiguration(0) + : m_buildConfiguration(nullptr) { auto fl = new QFormLayout(this); fl->setContentsMargins(0, -1, 0, -1); diff --git a/src/plugins/genericprojectmanager/genericbuildconfiguration.h b/src/plugins/genericprojectmanager/genericbuildconfiguration.h index bb3781e51cf..f43e02f1fa9 100644 --- a/src/plugins/genericprojectmanager/genericbuildconfiguration.h +++ b/src/plugins/genericprojectmanager/genericbuildconfiguration.h @@ -55,7 +55,7 @@ class GenericBuildConfigurationFactory : public ProjectExplorer::IBuildConfigura public: GenericBuildConfigurationFactory(); - ~GenericBuildConfigurationFactory(); + ~GenericBuildConfigurationFactory() override; private: QList<ProjectExplorer::BuildInfo *> availableBuilds(const ProjectExplorer::Target *parent) const override; diff --git a/src/plugins/genericprojectmanager/genericproject.cpp b/src/plugins/genericprojectmanager/genericproject.cpp index b99d037e65f..5ae6299a759 100644 --- a/src/plugins/genericprojectmanager/genericproject.cpp +++ b/src/plugins/genericprojectmanager/genericproject.cpp @@ -135,12 +135,12 @@ public: || action == Rename; } - bool addFiles(const QStringList &filePaths, QStringList * = 0) override + bool addFiles(const QStringList &filePaths, QStringList * = nullptr) override { return m_project->addFiles(filePaths); } - bool removeFiles(const QStringList &filePaths, QStringList * = 0) override + bool removeFiles(const QStringList &filePaths, QStringList * = nullptr) override { return m_project->removeFiles(filePaths); } diff --git a/src/plugins/genericprojectmanager/genericprojectwizard.cpp b/src/plugins/genericprojectmanager/genericprojectwizard.cpp index f38be2003b5..edd55df5b6b 100644 --- a/src/plugins/genericprojectmanager/genericprojectwizard.cpp +++ b/src/plugins/genericprojectmanager/genericprojectwizard.cpp @@ -126,7 +126,7 @@ GenericProjectWizard::GenericProjectWizard() Core::BaseFileWizard *GenericProjectWizard::create(QWidget *parent, const Core::WizardDialogParameters ¶meters) const { - GenericProjectWizardDialog *wizard = new GenericProjectWizardDialog(this, parent); + auto wizard = new GenericProjectWizardDialog(this, parent); wizard->setPath(parameters.defaultPath()); @@ -141,7 +141,7 @@ Core::GeneratedFiles GenericProjectWizard::generateFiles(const QWizard *w, { Q_UNUSED(errorMessage) - const GenericProjectWizardDialog *wizard = qobject_cast<const GenericProjectWizardDialog *>(w); + auto wizard = qobject_cast<const GenericProjectWizardDialog *>(w); const QString projectPath = wizard->path(); const QDir dir(projectPath); const QString projectName = wizard->projectName(); diff --git a/src/plugins/genericprojectmanager/genericprojectwizard.h b/src/plugins/genericprojectmanager/genericprojectwizard.h index e9b608a5a28..fbe8590faaf 100644 --- a/src/plugins/genericprojectmanager/genericprojectwizard.h +++ b/src/plugins/genericprojectmanager/genericprojectwizard.h @@ -42,7 +42,7 @@ class GenericProjectWizardDialog : public Core::BaseFileWizard Q_OBJECT public: - explicit GenericProjectWizardDialog(const Core::BaseFileWizardFactory *factory, QWidget *parent = 0); + explicit GenericProjectWizardDialog(const Core::BaseFileWizardFactory *factory, QWidget *parent = nullptr); QString path() const; void setPath(const QString &path); diff --git a/src/plugins/git/branchview.cpp b/src/plugins/git/branchview.cpp index 4e17f31686b..a9589781948 100644 --- a/src/plugins/git/branchview.cpp +++ b/src/plugins/git/branchview.cpp @@ -204,51 +204,55 @@ void BranchView::slotCustomContextMenu(const QPoint &point) const bool currentLocal = m_model->isLocal(currentBranch); QMenu contextMenu; - contextMenu.addAction(tr("Add..."), this, &BranchView::add); + contextMenu.addAction(tr("&Add..."), this, &BranchView::add); const Utils::optional<QString> remote = m_model->remoteName(index); if (remote.has_value()) { - contextMenu.addAction(tr("Fetch"), this, [this, &remote]() { + contextMenu.addAction(tr("&Fetch"), this, [this, &remote]() { GitPlugin::client()->fetch(m_repository, *remote); }); contextMenu.addSeparator(); - contextMenu.addAction(tr("Manage Remotes..."), GitPlugin::instance(), + contextMenu.addAction(tr("Manage &Remotes..."), GitPlugin::instance(), &GitPlugin::manageRemotes); } if (hasActions) { if (!currentSelected && (isLocal || isTag)) - contextMenu.addAction(tr("Remove..."), this, &BranchView::remove); + contextMenu.addAction(tr("Rem&ove..."), this, &BranchView::remove); if (isLocal || isTag) - contextMenu.addAction(tr("Rename..."), this, &BranchView::rename); + contextMenu.addAction(tr("Re&name..."), this, &BranchView::rename); if (!currentSelected) - contextMenu.addAction(tr("Checkout"), this, &BranchView::checkout); + contextMenu.addAction(tr("&Checkout"), this, &BranchView::checkout); contextMenu.addSeparator(); - contextMenu.addAction(tr("Diff"), this, [this] { + contextMenu.addAction(tr("&Diff"), this, [this] { const QString fullName = m_model->fullName(selectedIndex(), true); if (!fullName.isEmpty()) GitPlugin::client()->diffBranch(m_repository, fullName); }); - contextMenu.addAction(tr("Log"), this, [this] { log(selectedIndex()); }); + contextMenu.addAction(tr("&Log"), this, [this] { log(selectedIndex()); }); contextMenu.addSeparator(); if (!currentSelected) { if (currentLocal) - contextMenu.addAction(tr("Reset"), this, &BranchView::reset); + contextMenu.addAction(tr("Re&set"), this, &BranchView::reset); QString mergeTitle; if (isFastForwardMerge()) { - contextMenu.addAction(tr("Merge (Fast-Forward)"), this, [this] { merge(true); }); - mergeTitle = tr("Merge (No Fast-Forward)"); + contextMenu.addAction(tr("&Merge (Fast-Forward)"), this, [this] { merge(true); }); + mergeTitle = tr("Merge (No &Fast-Forward)"); } else { - mergeTitle = tr("Merge"); + mergeTitle = tr("&Merge"); } contextMenu.addAction(mergeTitle, this, [this] { merge(false); }); - contextMenu.addAction(tr("Rebase"), this, &BranchView::rebase); + contextMenu.addAction(tr("&Rebase"), this, &BranchView::rebase); contextMenu.addSeparator(); - contextMenu.addAction(tr("Cherry Pick"), this, &BranchView::cherryPick); + contextMenu.addAction(tr("Cherry &Pick"), this, &BranchView::cherryPick); } if (currentLocal && !currentSelected && !isTag) { - contextMenu.addAction(tr("Track"), this, [this] { + contextMenu.addAction(tr("&Track"), this, [this] { m_model->setRemoteTracking(selectedIndex()); }); + if (!isLocal) { + contextMenu.addSeparator(); + contextMenu.addAction(tr("&Push"), this, &BranchView::push); + } } } contextMenu.exec(m_branchView->viewport()->mapToGlobal(point)); @@ -533,6 +537,22 @@ void BranchView::log(const QModelIndex &idx) GitPlugin::client()->log(m_repository, QString(), false, {branchName}); } +void BranchView::push() +{ + const QModelIndex selected = selectedIndex(); + QTC_CHECK(selected != m_model->currentBranch()); + + const QString fullTargetName = m_model->fullName(selected); + const int pos = fullTargetName.indexOf('/'); + + const QString localBranch = m_model->fullName(m_model->currentBranch()); + const QString remoteName = fullTargetName.left(pos); + const QString remoteBranch = fullTargetName.mid(pos + 1); + const QStringList pushArgs = {remoteName, localBranch + ':' + remoteBranch}; + + GitPlugin::client()->push(m_repository, pushArgs); +} + BranchViewFactory::BranchViewFactory() { setDisplayName(tr("Git Branches")); diff --git a/src/plugins/git/branchview.h b/src/plugins/git/branchview.h index 8994cbe1dc8..7e400b704a0 100644 --- a/src/plugins/git/branchview.h +++ b/src/plugins/git/branchview.h @@ -82,6 +82,7 @@ private: void rebase(); bool cherryPick(); void log(const QModelIndex &idx); + void push(); QToolButton *m_addButton = nullptr; QToolButton *m_refreshButton = nullptr; diff --git a/src/plugins/ios/iosbuildstep.cpp b/src/plugins/ios/iosbuildstep.cpp index 3c04cc70805..64eca46235a 100644 --- a/src/plugins/ios/iosbuildstep.cpp +++ b/src/plugins/ios/iosbuildstep.cpp @@ -178,11 +178,6 @@ BuildStepConfigWidget *IosBuildStep::createConfigWidget() return new IosBuildStepConfigWidget(this); } -bool IosBuildStep::immutable() const -{ - return false; -} - void IosBuildStep::setBaseArguments(const QStringList &args) { m_baseBuildArguments = args; @@ -206,11 +201,13 @@ QStringList IosBuildStep::baseArguments() const // IosBuildStepConfigWidget::IosBuildStepConfigWidget(IosBuildStep *buildStep) - : m_buildStep(buildStep) + : BuildStepConfigWidget(buildStep), m_buildStep(buildStep) { m_ui = new Ui::IosBuildStep; m_ui->setupUi(this); + setDisplayName(tr("iOS build", "iOS BuildStep display name.")); + Project *pro = m_buildStep->target()->project(); m_ui->buildArgumentsTextEdit->setPlainText(Utils::QtcProcess::joinArgs( @@ -247,11 +244,6 @@ IosBuildStepConfigWidget::~IosBuildStepConfigWidget() delete m_ui; } -QString IosBuildStepConfigWidget::displayName() const -{ - return tr("iOS build", "iOS BuildStep display name."); -} - void IosBuildStepConfigWidget::updateDetails() { BuildConfiguration *bc = m_buildStep->buildConfiguration(); @@ -262,13 +254,8 @@ void IosBuildStepConfigWidget::updateDetails() param.setEnvironment(bc->environment()); param.setCommand(m_buildStep->buildCommand()); param.setArguments(Utils::QtcProcess::joinArgs(m_buildStep->allArguments())); - m_summaryText = param.summary(displayName()); - emit updateSummary(); -} -QString IosBuildStepConfigWidget::summaryText() const -{ - return m_summaryText; + setSummaryText(param.summary(displayName())); } void IosBuildStepConfigWidget::buildArgumentsChanged() diff --git a/src/plugins/ios/iosbuildstep.h b/src/plugins/ios/iosbuildstep.h index 47de3d66518..ad45c9fbcf2 100644 --- a/src/plugins/ios/iosbuildstep.h +++ b/src/plugins/ios/iosbuildstep.h @@ -52,7 +52,6 @@ public: void run(QFutureInterface<bool> &fi) override; ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override; - bool immutable() const override; void setBaseArguments(const QStringList &args); void setExtraArguments(const QStringList &extraArgs); QStringList baseArguments() const; @@ -77,8 +76,6 @@ class IosBuildStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget public: IosBuildStepConfigWidget(IosBuildStep *buildStep); ~IosBuildStepConfigWidget(); - QString displayName() const override; - QString summaryText() const override; private: void buildArgumentsChanged(); @@ -88,7 +85,6 @@ private: Ui::IosBuildStep *m_ui; IosBuildStep *m_buildStep; - QString m_summaryText; }; class IosBuildStepFactory : public ProjectExplorer::BuildStepFactory diff --git a/src/plugins/ios/iosdeploystep.cpp b/src/plugins/ios/iosdeploystep.cpp index b311bd54331..cba167a89d6 100644 --- a/src/plugins/ios/iosdeploystep.cpp +++ b/src/plugins/ios/iosdeploystep.cpp @@ -59,6 +59,8 @@ const Core::Id IosDeployStep::Id("Qt4ProjectManager.IosDeployStep"); IosDeployStep::IosDeployStep(BuildStepList *parent) : BuildStep(parent, Id) { + setImmutable(true); + setRunInGuiThread(true); updateDisplayNames(); connect(DeviceManager::instance(), &DeviceManager::updated, this, &IosDeployStep::updateDisplayNames); diff --git a/src/plugins/ios/iosdeploystep.h b/src/plugins/ios/iosdeploystep.h index 5e45b6ca7bb..db03c1687e9 100644 --- a/src/plugins/ios/iosdeploystep.h +++ b/src/plugins/ios/iosdeploystep.h @@ -72,8 +72,6 @@ private: bool init(QList<const BuildStep *> &earlierSteps) override; ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override; - bool immutable() const override { return true; } - bool runInGuiThread() const override { return true; } ProjectExplorer::IDevice::ConstPtr device() const; IosDevice::ConstPtr iosdevice() const; IosSimulator::ConstPtr iossimulator() const; diff --git a/src/plugins/ios/iosdeploystepwidget.cpp b/src/plugins/ios/iosdeploystepwidget.cpp index 252aa6f47ea..d24b2d38b78 100644 --- a/src/plugins/ios/iosdeploystepwidget.cpp +++ b/src/plugins/ios/iosdeploystepwidget.cpp @@ -31,16 +31,16 @@ #include <coreplugin/icore.h> -#include <QFileDialog> - namespace Ios { namespace Internal { IosDeployStepWidget::IosDeployStepWidget(IosDeployStep *step) : - ProjectExplorer::BuildStepConfigWidget(), + ProjectExplorer::BuildStepConfigWidget(step), ui(new Ui::IosDeployStepWidget), m_step(step) { + setDisplayName(QString::fromLatin1("<b>%1</b>").arg(m_step->displayName())); + setSummaryText(displayName()); ui->setupUi(this); connect(m_step, &ProjectExplorer::ProjectConfiguration::displayNameChanged, this, &ProjectExplorer::BuildStepConfigWidget::updateSummary); @@ -51,15 +51,5 @@ IosDeployStepWidget::~IosDeployStepWidget() delete ui; } -QString IosDeployStepWidget::displayName() const -{ - return QString::fromLatin1("<b>%1</b>").arg(m_step->displayName()); -} - -QString IosDeployStepWidget::summaryText() const -{ - return displayName(); -} - } // namespace Internal } // namespace Ios diff --git a/src/plugins/ios/iosdeploystepwidget.h b/src/plugins/ios/iosdeploystepwidget.h index ad88e5f20de..6ab40cc8dce 100644 --- a/src/plugins/ios/iosdeploystepwidget.h +++ b/src/plugins/ios/iosdeploystepwidget.h @@ -43,9 +43,6 @@ public: ~IosDeployStepWidget(); private: - QString summaryText() const override; - QString displayName() const override; - Ui::IosDeployStepWidget *ui; IosDeployStep *m_step; }; diff --git a/src/plugins/ios/iosdevicefactory.cpp b/src/plugins/ios/iosdevicefactory.cpp index c3eaa1f840f..6370cbce409 100644 --- a/src/plugins/ios/iosdevicefactory.cpp +++ b/src/plugins/ios/iosdevicefactory.cpp @@ -28,55 +28,21 @@ #include "iosconstants.h" -#include <utils/icon.h> - -#include <QIcon> - namespace Ios { namespace Internal { IosDeviceFactory::IosDeviceFactory() + : ProjectExplorer::IDeviceFactory(Constants::IOS_DEVICE_ID) { setObjectName(QLatin1String("IosDeviceFactory")); -} - -QString IosDeviceFactory::displayNameForId(Core::Id type) const -{ - return type == Constants::IOS_DEVICE_TYPE ? IosDevice::name() : QString(); -} - -QList<Core::Id> IosDeviceFactory::availableCreationIds() const -{ - return QList<Core::Id>() << Core::Id(Constants::IOS_DEVICE_TYPE); -} - -QIcon IosDeviceFactory::iconForId(Core::Id type) const -{ - Q_UNUSED(type) - using namespace Utils; - static const QIcon icon = - Icon::combinedIcon({Icon({{":/ios/images/iosdevicesmall.png", - Theme::PanelTextColorDark}}, Icon::Tint), - Icon({{":/ios/images/iosdevice.png", - Theme::IconsBaseColor}})}); - return icon; -} - -bool IosDeviceFactory::canCreate() const -{ - return false; -} - -ProjectExplorer::IDevice::Ptr IosDeviceFactory::create(Core::Id id) const -{ - Q_UNUSED(id) - return ProjectExplorer::IDevice::Ptr(); + setDisplayName(IosDevice::name()); + setCombinedIcon(":/ios/images/iosdevicesmall.png", + ":/ios/images/iosdevice.png"); + setConstructionFunction([] { return ProjectExplorer::IDevice::Ptr(new IosDevice); }); } bool IosDeviceFactory::canRestore(const QVariantMap &map) const { - if (ProjectExplorer::IDevice::typeFromMap(map) != Constants::IOS_DEVICE_TYPE) - return false; QVariantMap vMap = map.value(QLatin1String(Constants::EXTRA_INFO_KEY)).toMap(); if (vMap.isEmpty() || vMap.value(QLatin1String("deviceName")).toString() == QLatin1String("*unknown*")) @@ -84,14 +50,5 @@ bool IosDeviceFactory::canRestore(const QVariantMap &map) const return true; } -ProjectExplorer::IDevice::Ptr IosDeviceFactory::restore(const QVariantMap &map) const -{ - IosDevice *newDev = new IosDevice; - newDev->fromMap(map); - // updating the active ones should be enough... - //IosDeviceManager::instance()->updateInfo(newDev->uniqueDeviceID()); - return ProjectExplorer::IDevice::Ptr(newDev); -} - } // namespace Internal } // namespace Ios diff --git a/src/plugins/ios/iosdevicefactory.h b/src/plugins/ios/iosdevicefactory.h index 0b7004d6fce..cdf3d61ffd5 100644 --- a/src/plugins/ios/iosdevicefactory.h +++ b/src/plugins/ios/iosdevicefactory.h @@ -27,10 +27,6 @@ #include <projectexplorer/devicesupport/idevicefactory.h> -#include <QTimer> -#include <QMap> -#include <QString> - namespace Ios { namespace Internal { @@ -40,14 +36,7 @@ class IosDeviceFactory : public ProjectExplorer::IDeviceFactory public: IosDeviceFactory(); - QString displayNameForId(Core::Id type) const override; - QList<Core::Id> availableCreationIds() const override; - QIcon iconForId(Core::Id type) const override; - - bool canCreate() const override; - ProjectExplorer::IDevice::Ptr create(Core::Id id) const override; bool canRestore(const QVariantMap &map) const override; - ProjectExplorer::IDevice::Ptr restore(const QVariantMap &map) const override; }; } // namespace Internal diff --git a/src/plugins/ios/iosdsymbuildstep.cpp b/src/plugins/ios/iosdsymbuildstep.cpp index 3fc3c090dc9..e9889281dea 100644 --- a/src/plugins/ios/iosdsymbuildstep.cpp +++ b/src/plugins/ios/iosdsymbuildstep.cpp @@ -197,11 +197,6 @@ BuildStepConfigWidget *IosDsymBuildStep::createConfigWidget() return new IosDsymBuildStepConfigWidget(this); } -bool IosDsymBuildStep::immutable() const -{ - return false; -} - void IosDsymBuildStep::setArguments(const QStringList &args) { if (arguments() == args) @@ -227,7 +222,7 @@ QStringList IosDsymBuildStep::arguments() const // IosDsymBuildStepConfigWidget::IosDsymBuildStepConfigWidget(IosDsymBuildStep *buildStep) - : m_buildStep(buildStep) + : BuildStepConfigWidget(buildStep), m_buildStep(buildStep) { m_ui = new Ui::IosPresetBuildStep; m_ui->setupUi(this); @@ -267,11 +262,6 @@ IosDsymBuildStepConfigWidget::~IosDsymBuildStepConfigWidget() delete m_ui; } -QString IosDsymBuildStepConfigWidget::displayName() const -{ - return m_buildStep->displayName(); -} - void IosDsymBuildStepConfigWidget::updateDetails() { BuildConfiguration *bc = m_buildStep->buildConfiguration(); @@ -282,13 +272,8 @@ void IosDsymBuildStepConfigWidget::updateDetails() param.setEnvironment(bc->environment()); param.setCommand(m_buildStep->command()); param.setArguments(Utils::QtcProcess::joinArgs(m_buildStep->arguments())); - m_summaryText = param.summary(displayName()); - emit updateSummary(); -} -QString IosDsymBuildStepConfigWidget::summaryText() const -{ - return m_summaryText; + setSummaryText(param.summary(displayName())); } void IosDsymBuildStepConfigWidget::commandChanged() diff --git a/src/plugins/ios/iosdsymbuildstep.h b/src/plugins/ios/iosdsymbuildstep.h index 58200826f28..6b6004e2367 100644 --- a/src/plugins/ios/iosdsymbuildstep.h +++ b/src/plugins/ios/iosdsymbuildstep.h @@ -46,7 +46,6 @@ public: void run(QFutureInterface<bool> &fi) override; ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override; - bool immutable() const override; void setArguments(const QStringList &args); QStringList arguments() const; QStringList defaultArguments() const; @@ -74,8 +73,6 @@ class IosDsymBuildStepConfigWidget : public ProjectExplorer::BuildStepConfigWidg public: IosDsymBuildStepConfigWidget(IosDsymBuildStep *buildStep); ~IosDsymBuildStepConfigWidget(); - QString displayName() const override; - QString summaryText() const override; private: void commandChanged(); @@ -85,7 +82,6 @@ private: Ui::IosPresetBuildStep *m_ui; IosDsymBuildStep *m_buildStep; - QString m_summaryText; }; class IosDsymBuildStepFactory : public ProjectExplorer::BuildStepFactory diff --git a/src/plugins/ios/iossimulatorfactory.cpp b/src/plugins/ios/iossimulatorfactory.cpp index bede066b759..e90bd76570e 100644 --- a/src/plugins/ios/iossimulatorfactory.cpp +++ b/src/plugins/ios/iossimulatorfactory.cpp @@ -24,68 +24,23 @@ ****************************************************************************/ #include "iossimulatorfactory.h" -#include <QLatin1String> + #include "iosconstants.h" #include "iossimulator.h" -#include "utils/icon.h" -#include "utils/qtcassert.h" -#include <QIcon> +#include "utils/qtcassert.h" namespace Ios { namespace Internal { IosSimulatorFactory::IosSimulatorFactory() + : ProjectExplorer::IDeviceFactory(Constants::IOS_SIMULATOR_TYPE) { setObjectName(QLatin1String("IosSimulatorFactory")); -} - -QString IosSimulatorFactory::displayNameForId(Core::Id type) const -{ - if (type == Constants::IOS_SIMULATOR_TYPE) - return tr("iOS Simulator"); - return QString(); -} - -QList<Core::Id> IosSimulatorFactory::availableCreationIds() const -{ - return QList<Core::Id>() << Core::Id(Constants::IOS_SIMULATOR_TYPE); -} - -QIcon IosSimulatorFactory::iconForId(Core::Id type) const -{ - Q_UNUSED(type) - using namespace Utils; - static const QIcon icon = - Icon::combinedIcon({Icon({{":/ios/images/iosdevicesmall.png", - Theme::PanelTextColorDark}}, Icon::Tint), - Icon({{":/ios/images/iosdevice.png", - Theme::IconsBaseColor}})}); - return icon; -} - -bool IosSimulatorFactory::canCreate() const -{ - return false; -} - -ProjectExplorer::IDevice::Ptr IosSimulatorFactory::create(Core::Id id) const -{ - Q_UNUSED(id) - return ProjectExplorer::IDevice::Ptr(); -} - -bool IosSimulatorFactory::canRestore(const QVariantMap &map) const -{ - return ProjectExplorer::IDevice::typeFromMap(map) == Constants::IOS_SIMULATOR_TYPE; -} - -ProjectExplorer::IDevice::Ptr IosSimulatorFactory::restore(const QVariantMap &map) const -{ - QTC_ASSERT(canRestore(map), return ProjectExplorer::IDevice::Ptr()); - const ProjectExplorer::IDevice::Ptr device = ProjectExplorer::IDevice::Ptr(new IosSimulator()); - device->fromMap(map); - return device; + setDisplayName(tr("iOS Simulator")); + setCombinedIcon(":/ios/images/iosdevicesmall.png", + ":/ios/images/iosdevice.png"); + setConstructionFunction([] { return ProjectExplorer::IDevice::Ptr(new IosSimulator()); }); } } // namespace Internal diff --git a/src/plugins/ios/iossimulatorfactory.h b/src/plugins/ios/iossimulatorfactory.h index 013695e7859..5d05c7b370f 100644 --- a/src/plugins/ios/iossimulatorfactory.h +++ b/src/plugins/ios/iossimulatorfactory.h @@ -35,15 +35,6 @@ class IosSimulatorFactory : public ProjectExplorer::IDeviceFactory Q_OBJECT public: IosSimulatorFactory(); - - QString displayNameForId(Core::Id type) const override; - QList<Core::Id> availableCreationIds() const override; - QIcon iconForId(Core::Id type) const override; - - bool canCreate() const override; - ProjectExplorer::IDevice::Ptr create(Core::Id id) const override; - bool canRestore(const QVariantMap &map) const override; - ProjectExplorer::IDevice::Ptr restore(const QVariantMap &map) const override; }; } // namespace Internal diff --git a/src/plugins/modeleditor/componentviewcontroller.cpp b/src/plugins/modeleditor/componentviewcontroller.cpp index c8c0f1b1c30..9c578cc29bf 100644 --- a/src/plugins/modeleditor/componentviewcontroller.cpp +++ b/src/plugins/modeleditor/componentviewcontroller.cpp @@ -25,6 +25,8 @@ #include "componentviewcontroller.h" +#include "modelutilities.h" +#include "packageviewcontroller.h" #include "pxnodeutilities.h" #include "qmt/controller/namecontroller.h" @@ -116,31 +118,41 @@ class UpdateIncludeDependenciesVisitor : }; public: + void setPackageViewController(PackageViewController *packageViewController); void setModelController(qmt::ModelController *modelController); + void setModelUtilities(ModelUtilities *modelUtilities); void updateFilePaths(); void visitMComponent(qmt::MComponent *component); private: - bool haveMatchingStereotypes(const qmt::MObject *object1, const qmt::MObject *object2); QStringList findFilePathOfComponent(const qmt::MComponent *component); void collectElementPaths(const ProjectExplorer::FolderNode *folderNode, QMultiHash<QString, Node> *filePathsMap); qmt::MComponent *findComponentFromFilePath(const QString &filePath); - bool haveDependency(const qmt::MObject *source, const qmt::MObject *target, - bool inverted = false); - bool haveDependency(const qmt::MObject *source, const QList<qmt::MPackage *> &targets); private: + PackageViewController *m_packageViewController = nullptr; qmt::ModelController *m_modelController = nullptr; + ModelUtilities *m_modelUtilities = nullptr; QMultiHash<QString, Node> m_filePaths; QHash<QString, qmt::MComponent *> m_filePathComponentsMap; }; +void UpdateIncludeDependenciesVisitor::setPackageViewController(PackageViewController *packageViewController) +{ + m_packageViewController = packageViewController; +} + void UpdateIncludeDependenciesVisitor::setModelController(qmt::ModelController *modelController) { m_modelController = modelController; } +void UpdateIncludeDependenciesVisitor::setModelUtilities(ModelUtilities *modelUtilities) +{ + m_modelUtilities = modelUtilities; +} + void UpdateIncludeDependenciesVisitor::updateFilePaths() { m_filePaths.clear(); @@ -175,7 +187,7 @@ void UpdateIncludeDependenciesVisitor::visitMComponent(qmt::MComponent *componen qmt::MComponent *includeComponent = findComponentFromFilePath(includeFilePath); if (includeComponent && includeComponent != component) { // add dependency between components - if (!haveDependency(component, includeComponent)) { + if (!m_modelUtilities->haveDependency(component, includeComponent)) { auto dependency = new qmt::MDependency; dependency->setFlags(qmt::MElement::ReverseEngineered); dependency->setStereotypes(QStringList() << "include"); @@ -184,88 +196,7 @@ void UpdateIncludeDependenciesVisitor::visitMComponent(qmt::MComponent *componen dependency->setTarget(includeComponent->uid()); m_modelController->addRelation(component, dependency); } - - // search ancestors sharing a common owner - QList<qmt::MPackage *> componentAncestors; - auto ancestor = dynamic_cast<qmt::MPackage *>(component->owner()); - while (ancestor) { - componentAncestors.append(ancestor); - ancestor = dynamic_cast<qmt::MPackage *>(ancestor->owner()); - } - QList<qmt::MPackage *> includeComponentAncestors; - ancestor = dynamic_cast<qmt::MPackage *>(includeComponent->owner()); - while (ancestor) { - includeComponentAncestors.append(ancestor); - ancestor = dynamic_cast<qmt::MPackage *>(ancestor->owner()); - } - - int componentHighestAncestorIndex = componentAncestors.size() - 1; - int includeComponentHighestAncestorIndex = includeComponentAncestors.size() - 1; - QMT_ASSERT(componentAncestors.at(componentHighestAncestorIndex) == includeComponentAncestors.at(includeComponentHighestAncestorIndex), return); - while (componentHighestAncestorIndex > 0 && includeComponentHighestAncestorIndex > 0) { - if (componentAncestors.at(componentHighestAncestorIndex) != includeComponentAncestors.at(includeComponentHighestAncestorIndex)) - break; - --componentHighestAncestorIndex; - --includeComponentHighestAncestorIndex; - } - - // add dependency between parent packages with same stereotype - int index1 = 0; - int includeComponentLowestIndex = 0; - while (index1 <= componentHighestAncestorIndex - && includeComponentLowestIndex <= includeComponentHighestAncestorIndex) { - if (!componentAncestors.at(index1)->stereotypes().isEmpty()) { - int index2 = includeComponentLowestIndex; - while (index2 <= includeComponentHighestAncestorIndex) { - if (haveMatchingStereotypes(componentAncestors.at(index1), includeComponentAncestors.at(index2))) { - if (!haveDependency(componentAncestors.at(index1), includeComponentAncestors.at(index2))) { - auto dependency = new qmt::MDependency; - dependency->setFlags(qmt::MElement::ReverseEngineered); - // TODO set stereotype for testing purpose - dependency->setStereotypes(QStringList() << "same stereotype"); - dependency->setDirection(qmt::MDependency::AToB); - dependency->setSource(componentAncestors.at(index1)->uid()); - dependency->setTarget(includeComponentAncestors.at(index2)->uid()); - m_modelController->addRelation(componentAncestors.at(index1), dependency); - } - includeComponentLowestIndex = index2 + 1; - break; - } - ++index2; - } - } - ++index1; - } - - // add dependency between topmost packages with common owner - if (componentAncestors.at(componentHighestAncestorIndex) != includeComponentAncestors.at(includeComponentHighestAncestorIndex)) { - if (!haveDependency(componentAncestors.at(componentHighestAncestorIndex), includeComponentAncestors)) { - auto dependency = new qmt::MDependency; - dependency->setFlags(qmt::MElement::ReverseEngineered); - // TODO set stereotype for testing purpose - dependency->setStereotypes(QStringList() << "ancestor"); - dependency->setDirection(qmt::MDependency::AToB); - dependency->setSource(componentAncestors.at(componentHighestAncestorIndex)->uid()); - dependency->setTarget(includeComponentAncestors.at(includeComponentHighestAncestorIndex)->uid()); - m_modelController->addRelation(componentAncestors.at(componentHighestAncestorIndex), dependency); - } - } - - // add dependency between parent packages - if (componentHighestAncestorIndex > 0 && includeComponentHighestAncestorIndex > 0) { // check for valid parents - if (componentAncestors.at(0) != includeComponentAncestors.at(0)) { - if (!haveDependency(componentAncestors.at(0), includeComponentAncestors)) { - auto dependency = new qmt::MDependency; - dependency->setFlags(qmt::MElement::ReverseEngineered); - // TODO set stereotype for testing purpose - dependency->setStereotypes(QStringList() << "parents"); - dependency->setDirection(qmt::MDependency::AToB); - dependency->setSource(componentAncestors.at(0)->uid()); - dependency->setTarget(includeComponentAncestors.at(0)->uid()); - m_modelController->addRelation(componentAncestors.at(0), dependency); - } - } - } + m_packageViewController->createAncestorDependencies(component, includeComponent); } } } @@ -273,12 +204,6 @@ void UpdateIncludeDependenciesVisitor::visitMComponent(qmt::MComponent *componen visitMObject(component); } -bool UpdateIncludeDependenciesVisitor::haveMatchingStereotypes(const qmt::MObject *object1, - const qmt::MObject *object2) -{ - return !(object1->stereotypes().toSet() & object2->stereotypes().toSet()).isEmpty(); -} - QStringList UpdateIncludeDependenciesVisitor::findFilePathOfComponent(const qmt::MComponent *component) { QStringList elementPath; @@ -335,48 +260,10 @@ qmt::MComponent *UpdateIncludeDependenciesVisitor::findComponentFromFilePath(con return component; } -bool UpdateIncludeDependenciesVisitor::haveDependency(const qmt::MObject *source, - const qmt::MObject *target, bool inverted) -{ - qmt::MDependency::Direction aToB = qmt::MDependency::AToB; - qmt::MDependency::Direction bToA = qmt::MDependency::BToA; - if (inverted) { - aToB = qmt::MDependency::BToA; - bToA = qmt::MDependency::AToB; - } - for (const qmt::Handle<qmt::MRelation> &handle : source->relations()) { - if (auto dependency = dynamic_cast<qmt::MDependency *>(handle.target())) { - if (dependency->source() == source->uid() - && dependency->target() == target->uid() - && (dependency->direction() == aToB - || dependency->direction() == qmt::MDependency::Bidirectional)) { - return true; - } - if (dependency->source() == target->uid() - && dependency->target() == source->uid() - && (dependency->direction() == bToA - || dependency->direction() == qmt::MDependency::Bidirectional)) { - return true; - } - } - } - if (!inverted) - return haveDependency(target, source, true); - return false; -} - -bool UpdateIncludeDependenciesVisitor::haveDependency(const qmt::MObject *source, - const QList<qmt::MPackage *> &targets) -{ - foreach (const qmt::MObject *target, targets) { - if (haveDependency(source, target)) - return true; - } - return false; -} - class ComponentViewController::ComponentViewControllerPrivate { public: + ModelUtilities *modelUtilities = nullptr; + PackageViewController *packageViewController = nullptr; PxNodeUtilities *pxnodeUtilities = nullptr; qmt::DiagramSceneController *diagramSceneController = nullptr; }; @@ -392,6 +279,16 @@ ComponentViewController::~ComponentViewController() delete d; } +void ComponentViewController::setModelUtilities(ModelUtilities *modelUtilities) +{ + d->modelUtilities = modelUtilities; +} + +void ComponentViewController::setPackageViewController(PackageViewController *packageViewController) +{ + d->packageViewController = packageViewController; +} + void ComponentViewController::setPxNodeUtilties(PxNodeUtilities *pxnodeUtilities) { d->pxnodeUtilities = pxnodeUtilities; @@ -416,7 +313,9 @@ void ComponentViewController::updateIncludeDependencies(qmt::MPackage *rootPacka { d->diagramSceneController->modelController()->startResetModel(); UpdateIncludeDependenciesVisitor visitor; + visitor.setPackageViewController(d->packageViewController); visitor.setModelController(d->diagramSceneController->modelController()); + visitor.setModelUtilities(d->modelUtilities); visitor.updateFilePaths(); rootPackage->accept(&visitor); d->diagramSceneController->modelController()->finishResetModel(true); diff --git a/src/plugins/modeleditor/componentviewcontroller.h b/src/plugins/modeleditor/componentviewcontroller.h index 584bc55b50d..f7437d3c104 100644 --- a/src/plugins/modeleditor/componentviewcontroller.h +++ b/src/plugins/modeleditor/componentviewcontroller.h @@ -38,6 +38,8 @@ class DiagramSceneController; namespace ModelEditor { namespace Internal { +class ModelUtilities; +class PackageViewController; class PxNodeUtilities; class ComponentViewController : @@ -50,6 +52,8 @@ public: explicit ComponentViewController(QObject *parent = nullptr); ~ComponentViewController(); + void setModelUtilities(ModelUtilities *modelUtilities); + void setPackageViewController(PackageViewController *packageViewController); void setPxNodeUtilties(PxNodeUtilities *pxnodeUtilities); void setDiagramSceneController(qmt::DiagramSceneController *diagramSceneController); diff --git a/src/plugins/modeleditor/modeleditor.pro b/src/plugins/modeleditor/modeleditor.pro index d15513938ea..c2039ecc05b 100644 --- a/src/plugins/modeleditor/modeleditor.pro +++ b/src/plugins/modeleditor/modeleditor.pro @@ -23,7 +23,9 @@ SOURCES += \ modeleditor_plugin.cpp \ modelindexer.cpp \ modelsmanager.cpp \ + modelutilities.cpp \ openelementvisitor.cpp \ + packageviewcontroller.cpp \ pxnodecontroller.cpp \ pxnodeutilities.cpp \ settingscontroller.cpp \ @@ -48,7 +50,9 @@ HEADERS += \ modeleditor_plugin.h \ modelindexer.h \ modelsmanager.h \ + modelutilities.h \ openelementvisitor.h \ + packageviewcontroller.h \ pxnodecontroller.h \ pxnodeutilities.h \ settingscontroller.h \ diff --git a/src/plugins/modeleditor/modeleditor.qbs b/src/plugins/modeleditor/modeleditor.qbs index b2dfaf9cd87..dd72cbc1d0c 100644 --- a/src/plugins/modeleditor/modeleditor.qbs +++ b/src/plugins/modeleditor/modeleditor.qbs @@ -59,8 +59,12 @@ QtcPlugin { "modelindexer.h", "modelsmanager.cpp", "modelsmanager.h", + "modelutilities.cpp", + "modelutilities.h", "openelementvisitor.cpp", "openelementvisitor.h", + "packageviewcontroller.cpp", + "packageviewcontroller.h", "pxnodecontroller.cpp", "pxnodecontroller.h", "pxnodeutilities.cpp", diff --git a/src/plugins/modeleditor/modelutilities.cpp b/src/plugins/modeleditor/modelutilities.cpp new file mode 100644 index 00000000000..58c8d7d851d --- /dev/null +++ b/src/plugins/modeleditor/modelutilities.cpp @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2018 Jochen Becher +** 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 "modelutilities.h" + +#include "qmt/model/mobject.h" +#include "qmt/model/mdependency.h" +#include "qmt/model/mpackage.h" + +namespace ModelEditor { +namespace Internal { + +ModelUtilities::ModelUtilities(QObject *parent) + : QObject(parent) +{ +} + +ModelUtilities::~ModelUtilities() +{ +} + +bool ModelUtilities::haveDependency(const qmt::MObject *source, + const qmt::MObject *target, bool inverted) +{ + qmt::MDependency::Direction aToB = qmt::MDependency::AToB; + qmt::MDependency::Direction bToA = qmt::MDependency::BToA; + if (inverted) { + aToB = qmt::MDependency::BToA; + bToA = qmt::MDependency::AToB; + } + for (const qmt::Handle<qmt::MRelation> &handle : source->relations()) { + if (auto dependency = dynamic_cast<qmt::MDependency *>(handle.target())) { + if (dependency->source() == source->uid() + && dependency->target() == target->uid() + && (dependency->direction() == aToB + || dependency->direction() == qmt::MDependency::Bidirectional)) { + return true; + } + if (dependency->source() == target->uid() + && dependency->target() == source->uid() + && (dependency->direction() == bToA + || dependency->direction() == qmt::MDependency::Bidirectional)) { + return true; + } + } + } + if (!inverted) + return haveDependency(target, source, true); + return false; +} + +bool ModelUtilities::haveDependency(const qmt::MObject *source, + const QList<qmt::MPackage *> &targets) +{ + foreach (const qmt::MPackage *target, targets) { + if (haveDependency(source, target)) + return true; + } + return false; +} + +} // namespace Internal +} // namespace ModelEditor diff --git a/src/plugins/remotelinux/remotelinuxutils.cpp b/src/plugins/modeleditor/modelutilities.h index 0fe6934ae3b..475f49df4b0 100644 --- a/src/plugins/remotelinux/remotelinuxutils.cpp +++ b/src/plugins/modeleditor/modelutilities.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2018 Jochen Becher ** Contact: https://www.qt.io/licensing/ ** ** This file is part of Qt Creator. @@ -23,8 +23,29 @@ ** ****************************************************************************/ -#include "remotelinuxutils.h" +#pragma once -namespace RemoteLinux { +#include <QObject> -} // namespace RemoteLinux +namespace qmt { +class MObject; +class MPackage; +} + +namespace ModelEditor { +namespace Internal { + +class ModelUtilities : public QObject +{ + Q_OBJECT +public: + explicit ModelUtilities(QObject *parent = nullptr); + ~ModelUtilities(); + + bool haveDependency(const qmt::MObject *source, const qmt::MObject *target, + bool inverted = false); + bool haveDependency(const qmt::MObject *source, const QList<qmt::MPackage *> &targets); +}; + +} // namespace Internal +} // namespace ModelEditor diff --git a/src/plugins/modeleditor/packageviewcontroller.cpp b/src/plugins/modeleditor/packageviewcontroller.cpp new file mode 100644 index 00000000000..b04a3c67d03 --- /dev/null +++ b/src/plugins/modeleditor/packageviewcontroller.cpp @@ -0,0 +1,157 @@ +/**************************************************************************** +** +** Copyright (C) 2018 Jochen Becher +** 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 "packageviewcontroller.h" + +#include "modelutilities.h" + +#include "qmt/model/mpackage.h" +#include "qmt/model/mdependency.h" +#include "qmt/model_controller/modelcontroller.h" + +namespace ModelEditor { +namespace Internal { + +class PackageViewController::PackageViewControllerPrivate { +public: + qmt::ModelController *m_modelController = nullptr; + ModelUtilities *m_modelUtilities = nullptr; +}; + +PackageViewController::PackageViewController(QObject *parent) + : QObject(parent), + d(new PackageViewControllerPrivate) +{ +} + +PackageViewController::~PackageViewController() +{ + delete d; +} + +void PackageViewController::setModelController(qmt::ModelController *modelController) +{ + d->m_modelController = modelController; +} + +void PackageViewController::setModelUtilities(ModelUtilities *modelUtilities) +{ + d->m_modelUtilities = modelUtilities; +} + +void PackageViewController::createAncestorDependencies(qmt::MObject *object1, qmt::MObject *object2) +{ + // search ancestors sharing a common owner + QList<qmt::MPackage *> componentAncestors; + auto ancestor = dynamic_cast<qmt::MPackage *>(object1->owner()); + while (ancestor) { + componentAncestors.append(ancestor); + ancestor = dynamic_cast<qmt::MPackage *>(ancestor->owner()); + } + QList<qmt::MPackage *> includeComponentAncestors; + ancestor = dynamic_cast<qmt::MPackage *>(object2->owner()); + while (ancestor) { + includeComponentAncestors.append(ancestor); + ancestor = dynamic_cast<qmt::MPackage *>(ancestor->owner()); + } + + int componentHighestAncestorIndex = componentAncestors.size() - 1; + int includeComponentHighestAncestorIndex = includeComponentAncestors.size() - 1; + QMT_ASSERT(componentAncestors.at(componentHighestAncestorIndex) == includeComponentAncestors.at(includeComponentHighestAncestorIndex), return); + while (componentHighestAncestorIndex > 0 && includeComponentHighestAncestorIndex > 0) { + if (componentAncestors.at(componentHighestAncestorIndex) != includeComponentAncestors.at(includeComponentHighestAncestorIndex)) + break; + --componentHighestAncestorIndex; + --includeComponentHighestAncestorIndex; + } + + // add dependency between parent packages with same stereotype + int index1 = 0; + int includeComponentLowestIndex = 0; + while (index1 <= componentHighestAncestorIndex + && includeComponentLowestIndex <= includeComponentHighestAncestorIndex) { + if (!componentAncestors.at(index1)->stereotypes().isEmpty()) { + int index2 = includeComponentLowestIndex; + while (index2 <= includeComponentHighestAncestorIndex) { + if (haveMatchingStereotypes(componentAncestors.at(index1), includeComponentAncestors.at(index2))) { + if (!d->m_modelUtilities->haveDependency(componentAncestors.at(index1), includeComponentAncestors.at(index2))) { + auto dependency = new qmt::MDependency; + dependency->setFlags(qmt::MElement::ReverseEngineered); + // TODO set stereotype for testing purpose + dependency->setStereotypes(QStringList() << "same stereotype"); + dependency->setDirection(qmt::MDependency::AToB); + dependency->setSource(componentAncestors.at(index1)->uid()); + dependency->setTarget(includeComponentAncestors.at(index2)->uid()); + d->m_modelController->addRelation(componentAncestors.at(index1), dependency); + } + includeComponentLowestIndex = index2 + 1; + break; + } + ++index2; + } + } + ++index1; + } + + // add dependency between topmost packages with common owner + if (componentAncestors.at(componentHighestAncestorIndex) != includeComponentAncestors.at(includeComponentHighestAncestorIndex)) { + if (!d->m_modelUtilities->haveDependency(componentAncestors.at(componentHighestAncestorIndex), includeComponentAncestors)) { + auto dependency = new qmt::MDependency; + dependency->setFlags(qmt::MElement::ReverseEngineered); + // TODO set stereotype for testing purpose + dependency->setStereotypes(QStringList() << "ancestor"); + dependency->setDirection(qmt::MDependency::AToB); + dependency->setSource(componentAncestors.at(componentHighestAncestorIndex)->uid()); + dependency->setTarget(includeComponentAncestors.at(includeComponentHighestAncestorIndex)->uid()); + d->m_modelController->addRelation(componentAncestors.at(componentHighestAncestorIndex), dependency); + } + } + + // add dependency between parent packages + if (componentHighestAncestorIndex > 0 && includeComponentHighestAncestorIndex > 0) { // check for valid parents + if (componentAncestors.at(0) != includeComponentAncestors.at(0)) { + if (!d->m_modelUtilities->haveDependency(componentAncestors.at(0), includeComponentAncestors)) { + auto dependency = new qmt::MDependency; + dependency->setFlags(qmt::MElement::ReverseEngineered); + // TODO set stereotype for testing purpose + dependency->setStereotypes(QStringList() << "parents"); + dependency->setDirection(qmt::MDependency::AToB); + dependency->setSource(componentAncestors.at(0)->uid()); + dependency->setTarget(includeComponentAncestors.at(0)->uid()); + d->m_modelController->addRelation(componentAncestors.at(0), dependency); + } + } + } +} + +bool PackageViewController::haveMatchingStereotypes(const qmt::MObject *object1, + const qmt::MObject *object2) +{ + return !(object1->stereotypes().toSet() & object2->stereotypes().toSet()).isEmpty(); +} + + +} // namespace Internal +} // namespace ModelEditor diff --git a/src/plugins/winrt/winrtpackagedeploymentstepwidget.h b/src/plugins/modeleditor/packageviewcontroller.h index 2a7f92f6467..9b2b076289c 100644 --- a/src/plugins/winrt/winrtpackagedeploymentstepwidget.h +++ b/src/plugins/modeleditor/packageviewcontroller.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2018 Jochen Becher ** Contact: https://www.qt.io/licensing/ ** ** This file is part of Qt Creator. @@ -25,31 +25,37 @@ #pragma once -#include "winrtpackagedeploymentstep.h" +#include <QObject> -#include <projectexplorer/buildstep.h> +namespace qmt { +class MObject; +class ModelController; +} -namespace WinRt { +namespace ModelEditor { namespace Internal { -namespace Ui { class WinRtPackageDeploymentStepWidget; } +class ModelUtilities; -class WinRtPackageDeploymentStepWidget : public ProjectExplorer::BuildStepConfigWidget +class PackageViewController : public QObject { Q_OBJECT + class PackageViewControllerPrivate; + public: - WinRtPackageDeploymentStepWidget(WinRtPackageDeploymentStep *step); - ~WinRtPackageDeploymentStepWidget(); + explicit PackageViewController(QObject *parent = nullptr); + ~PackageViewController(); + + void setModelController(qmt::ModelController *modelController); + void setModelUtilities(ModelUtilities *modelUtilities); - virtual QString summaryText() const; - virtual QString displayName() const; + void createAncestorDependencies(qmt::MObject *object1, qmt::MObject *object2); private: - void restoreDefaultArguments(); + bool haveMatchingStereotypes(const qmt::MObject *object1, const qmt::MObject *object2); - Ui::WinRtPackageDeploymentStepWidget *m_ui; - WinRtPackageDeploymentStep *m_step; + PackageViewControllerPrivate *d; }; } // namespace Internal -} // namespace WinRt +} // namespace ModelEditor diff --git a/src/plugins/modeleditor/pxnodecontroller.cpp b/src/plugins/modeleditor/pxnodecontroller.cpp index cb04382e13c..86e3b63a5be 100644 --- a/src/plugins/modeleditor/pxnodecontroller.cpp +++ b/src/plugins/modeleditor/pxnodecontroller.cpp @@ -28,6 +28,8 @@ #include "pxnodeutilities.h" #include "componentviewcontroller.h" #include "classviewcontroller.h" +#include "modelutilities.h" +#include "packageviewcontroller.h" #include "qmt/model/mpackage.h" #include "qmt/model/mclass.h" @@ -92,6 +94,8 @@ class PxNodeController::PxNodeControllerPrivate { public: PxNodeUtilities *pxnodeUtilities = nullptr; + ModelUtilities *modelUtilities = nullptr; + PackageViewController *packageViewController = nullptr; ComponentViewController *componentViewController = nullptr; ClassViewController *classViewController = nullptr; qmt::DiagramSceneController *diagramSceneController = nullptr; @@ -103,8 +107,13 @@ PxNodeController::PxNodeController(QObject *parent) d(new PxNodeControllerPrivate) { d->pxnodeUtilities = new PxNodeUtilities(this); + d->modelUtilities = new ModelUtilities(this); + d->packageViewController = new PackageViewController(this); + d->packageViewController->setModelUtilities(d->modelUtilities); d->componentViewController = new ComponentViewController(this); d->componentViewController->setPxNodeUtilties(d->pxnodeUtilities); + d->componentViewController->setPackageViewController(d->packageViewController); + d->componentViewController->setModelUtilities(d->modelUtilities); d->classViewController = new ClassViewController(this); } @@ -123,6 +132,7 @@ void PxNodeController::setDiagramSceneController( { d->diagramSceneController = diagramSceneController; d->pxnodeUtilities->setDiagramSceneController(diagramSceneController); + d->packageViewController->setModelController(diagramSceneController->modelController()); d->componentViewController->setDiagramSceneController(diagramSceneController); } diff --git a/src/plugins/nim/project/nimbuildconfiguration.cpp b/src/plugins/nim/project/nimbuildconfiguration.cpp index 135d44f5a73..d5ba778b879 100644 --- a/src/plugins/nim/project/nimbuildconfiguration.cpp +++ b/src/plugins/nim/project/nimbuildconfiguration.cpp @@ -34,12 +34,12 @@ #include "../nimconstants.h" -#include <coreplugin/documentmanager.h> #include <projectexplorer/buildconfiguration.h> #include <projectexplorer/buildinfo.h> #include <projectexplorer/buildsteplist.h> #include <projectexplorer/buildstep.h> #include <projectexplorer/kit.h> +#include <projectexplorer/projectexplorer.h> #include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectmacroexpander.h> #include <projectexplorer/target.h> @@ -59,7 +59,7 @@ static FileName defaultBuildDirectory(const Kit *k, QFileInfo projectFileInfo(projectFilePath); ProjectMacroExpander expander(projectFilePath, projectFileInfo.baseName(), k, bc, buildType); - QString buildDirectory = expander.expand(Core::DocumentManager::buildDirectory()); + QString buildDirectory = expander.expand(ProjectExplorerPlugin::buildDirectoryTemplate()); if (FileUtils::isAbsolutePath(buildDirectory)) return FileName::fromString(buildDirectory); diff --git a/src/plugins/nim/project/nimcompilerbuildstepconfigwidget.cpp b/src/plugins/nim/project/nimcompilerbuildstepconfigwidget.cpp index ef4b9be9437..cb49e4c605d 100644 --- a/src/plugins/nim/project/nimcompilerbuildstepconfigwidget.cpp +++ b/src/plugins/nim/project/nimcompilerbuildstepconfigwidget.cpp @@ -39,12 +39,15 @@ using namespace Utils; namespace Nim { NimCompilerBuildStepConfigWidget::NimCompilerBuildStepConfigWidget(NimCompilerBuildStep *buildStep) - : BuildStepConfigWidget() + : BuildStepConfigWidget(buildStep) , m_buildStep(buildStep) , m_ui(new Ui::NimCompilerBuildStepConfigWidget()) { m_ui->setupUi(this); + setDisplayName(tr(Constants::C_NIMCOMPILERBUILDSTEPWIDGET_DISPLAY)); + setSummaryText(tr(Constants::C_NIMCOMPILERBUILDSTEPWIDGET_SUMMARY)); + // Connect the project signals auto project = static_cast<NimProject *>(m_buildStep->project()); connect(project, &NimProject::fileListChanged, @@ -67,16 +70,6 @@ NimCompilerBuildStepConfigWidget::NimCompilerBuildStepConfigWidget(NimCompilerBu NimCompilerBuildStepConfigWidget::~NimCompilerBuildStepConfigWidget() = default; -QString NimCompilerBuildStepConfigWidget::summaryText() const -{ - return tr(Constants::C_NIMCOMPILERBUILDSTEPWIDGET_SUMMARY); -} - -QString NimCompilerBuildStepConfigWidget::displayName() const -{ - return tr(Constants::C_NIMCOMPILERBUILDSTEPWIDGET_DISPLAY); -} - void NimCompilerBuildStepConfigWidget::onTargetChanged(int index) { Q_UNUSED(index); diff --git a/src/plugins/nim/project/nimcompilerbuildstepconfigwidget.h b/src/plugins/nim/project/nimcompilerbuildstepconfigwidget.h index f2a115b63ed..4c7d1e8d8b8 100644 --- a/src/plugins/nim/project/nimcompilerbuildstepconfigwidget.h +++ b/src/plugins/nim/project/nimcompilerbuildstepconfigwidget.h @@ -41,9 +41,6 @@ public: NimCompilerBuildStepConfigWidget(NimCompilerBuildStep *buildStep); ~NimCompilerBuildStepConfigWidget(); - QString summaryText() const override; - QString displayName() const override; - private: void updateUi(); void updateCommandLineText(); diff --git a/src/plugins/nim/project/nimcompilercleanstepconfigwidget.cpp b/src/plugins/nim/project/nimcompilercleanstepconfigwidget.cpp index 3dade2e330f..0b82052202c 100644 --- a/src/plugins/nim/project/nimcompilercleanstepconfigwidget.cpp +++ b/src/plugins/nim/project/nimcompilercleanstepconfigwidget.cpp @@ -36,11 +36,12 @@ using namespace ProjectExplorer; namespace Nim { NimCompilerCleanStepConfigWidget::NimCompilerCleanStepConfigWidget(NimCompilerCleanStep *cleanStep) - : BuildStepConfigWidget() - , m_cleanStep(cleanStep) + : BuildStepConfigWidget(cleanStep) , m_ui(new Ui::NimCompilerCleanStepConfigWidget()) { m_ui->setupUi(this); + setDisplayName(tr(Constants::C_NIMCOMPILERCLEANSTEPWIDGET_DISPLAY)); + setSummaryText(tr(Constants::C_NIMCOMPILERCLEANSTEPWIDGET_SUMMARY)); connect(cleanStep->buildConfiguration(), &BuildConfiguration::buildDirectoryChanged, this, &NimCompilerCleanStepConfigWidget::updateUi); updateUi(); @@ -48,19 +49,9 @@ NimCompilerCleanStepConfigWidget::NimCompilerCleanStepConfigWidget(NimCompilerCl NimCompilerCleanStepConfigWidget::~NimCompilerCleanStepConfigWidget() = default; -QString NimCompilerCleanStepConfigWidget::summaryText() const -{ - return tr(Constants::C_NIMCOMPILERCLEANSTEPWIDGET_SUMMARY); -} - -QString NimCompilerCleanStepConfigWidget::displayName() const -{ - return tr(Constants::C_NIMCOMPILERCLEANSTEPWIDGET_DISPLAY); -} - void NimCompilerCleanStepConfigWidget::updateUi() { - auto buildDiretory = m_cleanStep->buildConfiguration()->buildDirectory(); + auto buildDiretory = step()->buildConfiguration()->buildDirectory(); m_ui->workingDirectoryLineEdit->setText(buildDiretory.toString()); } diff --git a/src/plugins/nim/project/nimcompilercleanstepconfigwidget.h b/src/plugins/nim/project/nimcompilercleanstepconfigwidget.h index 409f412b842..3de99648566 100644 --- a/src/plugins/nim/project/nimcompilercleanstepconfigwidget.h +++ b/src/plugins/nim/project/nimcompilercleanstepconfigwidget.h @@ -42,14 +42,9 @@ public: ~NimCompilerCleanStepConfigWidget(); - QString summaryText() const override; - - QString displayName() const override; - private: void updateUi(); - NimCompilerCleanStep *m_cleanStep; QScopedPointer<Ui::NimCompilerCleanStepConfigWidget> m_ui; }; diff --git a/src/plugins/projectexplorer/abstractprocessstep.cpp b/src/plugins/projectexplorer/abstractprocessstep.cpp index 1e7f33bf658..bc51e9bbdc1 100644 --- a/src/plugins/projectexplorer/abstractprocessstep.cpp +++ b/src/plugins/projectexplorer/abstractprocessstep.cpp @@ -96,6 +96,7 @@ AbstractProcessStep::AbstractProcessStep(BuildStepList *bsl, Core::Id id) : { m_timer.setInterval(500); connect(&m_timer, &QTimer::timeout, this, &AbstractProcessStep::checkForCancel); + setRunInGuiThread(true); } /*! diff --git a/src/plugins/projectexplorer/abstractprocessstep.h b/src/plugins/projectexplorer/abstractprocessstep.h index 290d78341b8..c338339a018 100644 --- a/src/plugins/projectexplorer/abstractprocessstep.h +++ b/src/plugins/projectexplorer/abstractprocessstep.h @@ -53,7 +53,6 @@ class PROJECTEXPLORER_EXPORT AbstractProcessStep : public BuildStep public: bool init(QList<const BuildStep *> &earlierSteps) override; void run(QFutureInterface<bool> &) override; - bool runInGuiThread() const final { return true; } ProcessParameters *processParameters() { return &m_param; } diff --git a/src/plugins/projectexplorer/buildstep.cpp b/src/plugins/projectexplorer/buildstep.cpp index 242ffea2a29..b5dfc86bb2e 100644 --- a/src/plugins/projectexplorer/buildstep.cpp +++ b/src/plugins/projectexplorer/buildstep.cpp @@ -127,27 +127,9 @@ BuildStep::BuildStep(BuildStepList *bsl, Core::Id id) : expander->registerSubProvider([this] { return projectConfiguration()->macroExpander(); }); } -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 "<b>" + displayName() + "</b>"; } - QString displayName() const override { return m_step->displayName(); } - BuildStep *step() const { return m_step; } - -private: - BuildStep *m_step; -}; - BuildStepConfigWidget *BuildStep::createConfigWidget() { - auto widget = new ConfigWidget(this); + auto widget = new BuildStepConfigWidget(this); auto formLayout = new QFormLayout(widget); formLayout->setMargin(0); @@ -218,20 +200,32 @@ bool BuildStep::isActive() const return projectConfiguration()->isActive(); } +bool BuildStep::widgetExpandedByDefault() const +{ + return m_widgetExpandedByDefault; +} + +void BuildStep::setWidgetExpandedByDefault(bool widgetExpandedByDefault) +{ + m_widgetExpandedByDefault = widgetExpandedByDefault; +} + /*! + \fn BuildStep::isImmutable() + If this function returns \c true, the user cannot delete this build step for this target and the user is prevented from changing the order in which immutable steps are run. The default implementation returns \c false. */ -bool BuildStep::immutable() const +bool BuildStep::runInGuiThread() const { - return false; + return m_runInGuiThread; } -bool BuildStep::runInGuiThread() const +void BuildStep::setRunInGuiThread(bool runInGuiThread) { - return false; + m_runInGuiThread = runInGuiThread; } /*! @@ -381,4 +375,38 @@ BuildStep *BuildStepFactory::restore(BuildStepList *parent, const QVariantMap &m return bs; } +// BuildStepConfigWidget + +BuildStepConfigWidget::BuildStepConfigWidget(BuildStep *step) + : m_step(step) +{ + m_displayName = step->displayName(); + m_summaryText = "<b>" + m_displayName + "</b>"; + connect(m_step, &ProjectConfiguration::displayNameChanged, + this, &BuildStepConfigWidget::updateSummary); +} + +QString BuildStepConfigWidget::summaryText() const +{ + return m_summaryText; +} + +QString BuildStepConfigWidget::displayName() const +{ + return m_displayName; +} + +void BuildStepConfigWidget::setDisplayName(const QString &displayName) +{ + m_displayName = displayName; +} + +void BuildStepConfigWidget::setSummaryText(const QString &summaryText) +{ + if (summaryText != m_summaryText) { + m_summaryText = summaryText; + updateSummary(); + } +} + } // ProjectExplorer diff --git a/src/plugins/projectexplorer/buildstep.h b/src/plugins/projectexplorer/buildstep.h index 72f83c1bb37..efc53f3ea63 100644 --- a/src/plugins/projectexplorer/buildstep.h +++ b/src/plugins/projectexplorer/buildstep.h @@ -57,8 +57,6 @@ public: virtual void run(QFutureInterface<bool> &fi) = 0; virtual BuildStepConfigWidget *createConfigWidget(); - virtual bool immutable() const; - virtual bool runInGuiThread() const; virtual void cancel(); bool fromMap(const QVariantMap &map) override; @@ -84,6 +82,15 @@ public: bool isActive() const override; + bool widgetExpandedByDefault() const; + void setWidgetExpandedByDefault(bool widgetExpandedByDefault); + + bool isImmutable() const { return m_immutable; } + void setImmutable(bool immutable) { m_immutable = immutable; } + + bool runInGuiThread() const; + void setRunInGuiThread(bool runInGuiThread); + signals: /// Adds a \p task to the Issues pane. /// Do note that for linking compile output with tasks, you should first emit the task @@ -99,6 +106,9 @@ signals: private: bool m_enabled = true; + bool m_immutable = false; + bool m_widgetExpandedByDefault = true; + bool m_runInGuiThread = false; }; class PROJECTEXPLORER_EXPORT BuildStepInfo @@ -171,38 +181,22 @@ class PROJECTEXPLORER_EXPORT BuildStepConfigWidget : public QWidget { Q_OBJECT public: - virtual QString summaryText() const = 0; - virtual QString additionalSummaryText() const { return QString(); } - virtual QString displayName() const = 0; + explicit BuildStepConfigWidget(BuildStep *step); - bool showWidget() const { return m_showWidget; } - void setShowWidget(bool showWidget) { m_showWidget = showWidget; } + QString summaryText() const; + QString displayName() const; + BuildStep *step() const { return m_step; } + + void setDisplayName(const QString &displayName); + void setSummaryText(const QString &summaryText); signals: void updateSummary(); - void updateAdditionalSummary(); - -private: - bool m_showWidget = true; -}; - -class PROJECTEXPLORER_EXPORT SimpleBuildStepConfigWidget : public BuildStepConfigWidget -{ - Q_OBJECT -public: - SimpleBuildStepConfigWidget(BuildStep *step) : m_step(step) - { - connect(m_step, &ProjectConfiguration::displayNameChanged, - this, &BuildStepConfigWidget::updateSummary); - setShowWidget(false); - } - - QString summaryText() const override { return QLatin1String("<b>") + displayName() + QLatin1String("</b>"); } - QString displayName() const override { return m_step->displayName(); } - BuildStep *step() const { return m_step; } private: - BuildStep *m_step; + BuildStep *m_step = nullptr; + QString m_displayName; + QString m_summaryText; }; } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/buildstepspage.cpp b/src/plugins/projectexplorer/buildstepspage.cpp index 2465ef002db..5c8fdc7b773 100644 --- a/src/plugins/projectexplorer/buildstepspage.cpp +++ b/src/plugins/projectexplorer/buildstepspage.cpp @@ -182,7 +182,6 @@ BuildStepsWidgetData::BuildStepsWidgetData(BuildStep *s) : detailsWidget->setToolWidget(toolWidget); detailsWidget->setContentsMargins(0, 0, 0, 1); detailsWidget->setSummaryText(widget->summaryText()); - detailsWidget->setAdditionalSummaryText(widget->additionalSummaryText()); } BuildStepsWidgetData::~BuildStepsWidgetData() @@ -214,19 +213,6 @@ void BuildStepListWidget::updateSummary() } } -void BuildStepListWidget::updateAdditionalSummary() -{ - auto widget = qobject_cast<BuildStepConfigWidget *>(sender()); - if (widget) { - foreach (const BuildStepsWidgetData *s, m_buildStepsData) { - if (s->widget == widget) { - s->detailsWidget->setAdditionalSummaryText(widget->additionalSummaryText()); - break; - } - } - } -} - void BuildStepListWidget::updateEnabledState() { auto step = qobject_cast<BuildStep *>(sender()); @@ -271,7 +257,7 @@ void BuildStepListWidget::init(BuildStepList *bsl) for (int i = 0; i < bsl->count(); ++i) { addBuildStep(i); // addBuilStep expands the config widget by default, which we don't want here - if (m_buildStepsData.at(i)->widget->showWidget()) + if (m_buildStepsData.at(i)->step->widgetExpandedByDefault()) m_buildStepsData.at(i)->detailsWidget->setState(DetailsWidget::Collapsed); } @@ -319,30 +305,24 @@ void BuildStepListWidget::updateAddBuildStepMenu() } } -void BuildStepListWidget::addBuildStepWidget(int pos, BuildStep *step) +void BuildStepListWidget::addBuildStep(int pos) { + BuildStep *newStep = m_buildStepList->at(pos); + // create everything - auto s = new BuildStepsWidgetData(step); + auto s = new BuildStepsWidgetData(newStep); m_buildStepsData.insert(pos, s); m_vbox->insertWidget(pos, s->detailsWidget); connect(s->widget, &BuildStepConfigWidget::updateSummary, this, &BuildStepListWidget::updateSummary); - connect(s->widget, &BuildStepConfigWidget::updateAdditionalSummary, - this, &BuildStepListWidget::updateAdditionalSummary); connect(s->step, &BuildStep::enabledChanged, this, &BuildStepListWidget::updateEnabledState); -} -void BuildStepListWidget::addBuildStep(int pos) -{ - BuildStep *newStep = m_buildStepList->at(pos); - addBuildStepWidget(pos, newStep); - BuildStepsWidgetData *s = m_buildStepsData.at(pos); // Expand new build steps by default - if (s->widget->showWidget()) + if (newStep->widgetExpandedByDefault()) s->detailsWidget->setState(DetailsWidget::Expanded); else s->detailsWidget->setState(DetailsWidget::OnlySummary); @@ -415,7 +395,7 @@ void BuildStepListWidget::updateBuildStepButtonsState() bs->setEnabled(!bs->enabled()); s->toolWidget->setBuildStepEnabled(bs->enabled()); }); - s->toolWidget->setRemoveEnabled(!m_buildStepList->at(i)->immutable()); + s->toolWidget->setRemoveEnabled(!m_buildStepList->at(i)->isImmutable()); connect(s->toolWidget, &ToolWidget::removeClicked, this, [this, i] { if (!m_buildStepList->removeStep(i)) { @@ -427,13 +407,13 @@ void BuildStepListWidget::updateBuildStepButtonsState() }); s->toolWidget->setUpEnabled((i > 0) - && !(m_buildStepList->at(i)->immutable() - && m_buildStepList->at(i - 1)->immutable())); + && !(m_buildStepList->at(i)->isImmutable() + && m_buildStepList->at(i - 1)->isImmutable())); connect(s->toolWidget, &ToolWidget::upClicked, this, [this, i] { m_buildStepList->moveStepUp(i); }); s->toolWidget->setDownEnabled((i + 1 < m_buildStepList->count()) - && !(m_buildStepList->at(i)->immutable() - && m_buildStepList->at(i + 1)->immutable())); + && !(m_buildStepList->at(i)->isImmutable() + && m_buildStepList->at(i + 1)->isImmutable())); connect(s->toolWidget, &ToolWidget::downClicked, this, [this, i] { m_buildStepList->moveStepUp(i + 1); }); diff --git a/src/plugins/projectexplorer/buildstepspage.h b/src/plugins/projectexplorer/buildstepspage.h index 17b2879376a..fd06a715661 100644 --- a/src/plugins/projectexplorer/buildstepspage.h +++ b/src/plugins/projectexplorer/buildstepspage.h @@ -106,14 +106,12 @@ private: void updateAddBuildStepMenu(); void addBuildStep(int pos); void updateSummary(); - void updateAdditionalSummary(); void updateEnabledState(); void stepMoved(int from, int to); void removeBuildStep(int pos); void setupUi(); void updateBuildStepButtonsState(); - void addBuildStepWidget(int pos, BuildStep *step); BuildStepList *m_buildStepList = nullptr; diff --git a/src/plugins/projectexplorer/devicesupport/desktopdevicefactory.cpp b/src/plugins/projectexplorer/devicesupport/desktopdevicefactory.cpp index b6060c56cb1..0c4e488c714 100644 --- a/src/plugins/projectexplorer/devicesupport/desktopdevicefactory.cpp +++ b/src/plugins/projectexplorer/devicesupport/desktopdevicefactory.cpp @@ -32,60 +32,20 @@ #include <utils/qtcassert.h> #include <QApplication> -#include <QIcon> #include <QStyle> namespace ProjectExplorer { namespace Internal { -DesktopDeviceFactory::DesktopDeviceFactory(QObject *parent) : IDeviceFactory(parent) -{ } - -QString DesktopDeviceFactory::displayNameForId(Core::Id type) const -{ - if (type == Constants::DESKTOP_DEVICE_TYPE) - return tr("Desktop"); - return QString(); -} - -QList<Core::Id> DesktopDeviceFactory::availableCreationIds() const -{ - return QList<Core::Id>() << Core::Id(Constants::DESKTOP_DEVICE_TYPE); -} - -QIcon DesktopDeviceFactory::iconForId(Core::Id type) const +DesktopDeviceFactory::DesktopDeviceFactory() + : IDeviceFactory(Constants::DESKTOP_DEVICE_TYPE) { - Q_UNUSED(type) - static const QIcon icon = - Utils::creatorTheme()->flag(Utils::Theme::FlatSideBarIcons) + setConstructionFunction([] { return IDevice::Ptr(new DesktopDevice); }); + setDisplayName(tr("Desktop")); + setIcon(Utils::creatorTheme()->flag(Utils::Theme::FlatSideBarIcons) ? Utils::Icon::combinedIcon({Icons::DESKTOP_DEVICE.icon(), Icons::DESKTOP_DEVICE_SMALL.icon()}) - : QApplication::style()->standardIcon(QStyle::SP_ComputerIcon); - return icon; -} - -bool DesktopDeviceFactory::canCreate() const -{ - return false; -} - -IDevice::Ptr DesktopDeviceFactory::create(Core::Id id) const -{ - Q_UNUSED(id); - return IDevice::Ptr(); -} - -bool DesktopDeviceFactory::canRestore(const QVariantMap &map) const -{ - return IDevice::idFromMap(map) == Constants::DESKTOP_DEVICE_ID; -} - -IDevice::Ptr DesktopDeviceFactory::restore(const QVariantMap &map) const -{ - QTC_ASSERT(canRestore(map), return ProjectExplorer::IDevice::Ptr()); - const ProjectExplorer::IDevice::Ptr device = IDevice::Ptr(new DesktopDevice); - device->fromMap(map); - return device; + : QApplication::style()->standardIcon(QStyle::SP_ComputerIcon)); } } // namespace Internal diff --git a/src/plugins/projectexplorer/devicesupport/desktopdevicefactory.h b/src/plugins/projectexplorer/devicesupport/desktopdevicefactory.h index c712f12dedc..1ef030e67f6 100644 --- a/src/plugins/projectexplorer/devicesupport/desktopdevicefactory.h +++ b/src/plugins/projectexplorer/devicesupport/desktopdevicefactory.h @@ -32,19 +32,8 @@ namespace Internal { class DesktopDeviceFactory : public IDeviceFactory { - Q_OBJECT - public: - explicit DesktopDeviceFactory(QObject *parent = 0); - - QString displayNameForId(Core::Id type) const override; - QList<Core::Id> availableCreationIds() const override; - QIcon iconForId(Core::Id type) const override; - - bool canCreate() const override; - IDevice::Ptr create(Core::Id id) const override; - bool canRestore(const QVariantMap &map) const override; - IDevice::Ptr restore(const QVariantMap &map) const override; + DesktopDeviceFactory(); }; } // namespace Internal diff --git a/src/plugins/projectexplorer/devicesupport/devicecheckbuildstep.cpp b/src/plugins/projectexplorer/devicesupport/devicecheckbuildstep.cpp index f90f9843c2c..0c4cda9af5b 100644 --- a/src/plugins/projectexplorer/devicesupport/devicecheckbuildstep.cpp +++ b/src/plugins/projectexplorer/devicesupport/devicecheckbuildstep.cpp @@ -39,6 +39,7 @@ DeviceCheckBuildStep::DeviceCheckBuildStep(BuildStepList *bsl) : BuildStep(bsl, stepId()) { setDefaultDisplayName(displayName()); + setWidgetExpandedByDefault(false); } bool DeviceCheckBuildStep::init(QList<const BuildStep *> &earlierSteps) @@ -62,7 +63,7 @@ bool DeviceCheckBuildStep::init(QList<const BuildStep *> &earlierSteps) return false; } - IDevice::Ptr newDevice = factory->create(deviceTypeId); + IDevice::Ptr newDevice = factory->create(); if (newDevice.isNull()) { emit addOutput(tr("No device configured."), BuildStep::OutputFormat::ErrorMessage); return false; @@ -82,11 +83,6 @@ void DeviceCheckBuildStep::run(QFutureInterface<bool> &fi) reportRunResult(fi, true); } -BuildStepConfigWidget *DeviceCheckBuildStep::createConfigWidget() -{ - return new SimpleBuildStepConfigWidget(this); -} - Core::Id DeviceCheckBuildStep::stepId() { return "ProjectExplorer.DeviceCheckBuildStep"; diff --git a/src/plugins/projectexplorer/devicesupport/devicecheckbuildstep.h b/src/plugins/projectexplorer/devicesupport/devicecheckbuildstep.h index 8a114e1e6c4..2ac220ecaf2 100644 --- a/src/plugins/projectexplorer/devicesupport/devicecheckbuildstep.h +++ b/src/plugins/projectexplorer/devicesupport/devicecheckbuildstep.h @@ -42,8 +42,6 @@ public: void run(QFutureInterface<bool> &fi) override; - BuildStepConfigWidget *createConfigWidget() override; - static Core::Id stepId(); static QString displayName(); }; diff --git a/src/plugins/projectexplorer/devicesupport/devicefactoryselectiondialog.cpp b/src/plugins/projectexplorer/devicesupport/devicefactoryselectiondialog.cpp index 86afd635ded..55915d32897 100644 --- a/src/plugins/projectexplorer/devicesupport/devicefactoryselectiondialog.cpp +++ b/src/plugins/projectexplorer/devicesupport/devicefactoryselectiondialog.cpp @@ -45,11 +45,9 @@ DeviceFactorySelectionDialog::DeviceFactorySelectionDialog(QWidget *parent) : for (const IDeviceFactory * const factory : IDeviceFactory::allDeviceFactories()) { if (!factory->canCreate()) continue; - foreach (Core::Id id, factory->availableCreationIds()) { - QListWidgetItem *item = new QListWidgetItem(factory->displayNameForId(id)); - item->setData(Qt::UserRole, QVariant::fromValue(id)); - ui->listWidget->addItem(item); - } + QListWidgetItem *item = new QListWidgetItem(factory->displayName()); + item->setData(Qt::UserRole, QVariant::fromValue(factory->deviceType())); + ui->listWidget->addItem(item); } connect(ui->listWidget, &QListWidget::itemSelectionChanged, diff --git a/src/plugins/projectexplorer/devicesupport/devicemanager.cpp b/src/plugins/projectexplorer/devicesupport/devicemanager.cpp index e6d78e46517..939d4d3884b 100644 --- a/src/plugins/projectexplorer/devicesupport/devicemanager.cpp +++ b/src/plugins/projectexplorer/devicesupport/devicemanager.cpp @@ -199,8 +199,9 @@ QList<IDevice::Ptr> DeviceManager::fromMap(const QVariantMap &map, const IDeviceFactory * const factory = restoreFactory(map); if (!factory) continue; - const IDevice::Ptr device = factory->restore(map); + const IDevice::Ptr device = factory->construct(); QTC_ASSERT(device, continue); + device->fromMap(map); devices << device; } return devices; @@ -337,9 +338,10 @@ void DeviceManager::setDefaultDevice(Core::Id id) const IDeviceFactory *DeviceManager::restoreFactory(const QVariantMap &map) { + const Core::Id deviceType = IDevice::typeFromMap(map); IDeviceFactory *factory = Utils::findOrDefault(IDeviceFactory::allDeviceFactories(), - [&map](IDeviceFactory *factory) { - return factory->canRestore(map); + [&map, deviceType](IDeviceFactory *factory) { + return factory->canRestore(map) && factory->deviceType() == deviceType; }); if (!factory) diff --git a/src/plugins/projectexplorer/devicesupport/devicesettingswidget.cpp b/src/plugins/projectexplorer/devicesupport/devicesettingswidget.cpp index 117ba780430..0d5c528b665 100644 --- a/src/plugins/projectexplorer/devicesupport/devicesettingswidget.cpp +++ b/src/plugins/projectexplorer/devicesupport/devicesettingswidget.cpp @@ -147,7 +147,7 @@ void DeviceSettingsWidget::addDevice() IDeviceFactory *factory = IDeviceFactory::find(toCreate); if (!factory) return; - IDevice::Ptr device = factory->create(toCreate); + IDevice::Ptr device = factory->create(); if (device.isNull()) return; diff --git a/src/plugins/projectexplorer/devicesupport/idevice.h b/src/plugins/projectexplorer/devicesupport/idevice.h index 493b7b306e4..d917fc18636 100644 --- a/src/plugins/projectexplorer/devicesupport/idevice.h +++ b/src/plugins/projectexplorer/devicesupport/idevice.h @@ -211,7 +211,7 @@ protected: IDevice(const IDevice &other); private: - IDevice &operator=(const IDevice &); // Unimplemented. + IDevice &operator=(const IDevice &) = delete; int version() const; diff --git a/src/plugins/projectexplorer/devicesupport/idevicefactory.cpp b/src/plugins/projectexplorer/devicesupport/idevicefactory.cpp index 8b02da344e1..9f0cb7a55b9 100644 --- a/src/plugins/projectexplorer/devicesupport/idevicefactory.cpp +++ b/src/plugins/projectexplorer/devicesupport/idevicefactory.cpp @@ -26,6 +26,7 @@ #include "idevicefactory.h" #include <utils/algorithm.h> +#include <utils/icon.h> namespace ProjectExplorer { @@ -42,20 +43,15 @@ namespace ProjectExplorer { */ /*! - \fn virtual QString displayNameForId(Core::Id type) const = 0 + \fn virtual QString displayName() const = 0 - Returns a short, one-line description of the device type. + Returns a short, one-line description of the device type this factory + can create. */ /*! - \fn virtual QList<Core::Id> availableCreationIds() const = 0 - - Lists the device types this factory can create. -*/ - -/*! - \fn virtual IDevice::Ptr create(Core::Id id) const = 0 - Creates a new device with the id \a id. This may or may not open a wizard. + \fn virtual IDevice::Ptr create() const + Creates a new device. This may or may not open a wizard. */ /*! @@ -80,7 +76,12 @@ namespace ProjectExplorer { bool IDeviceFactory::canCreate() const { - return !availableCreationIds().isEmpty(); + return m_canCreate; +} + +IDevice::Ptr IDeviceFactory::construct() const +{ + return m_constructor ? m_constructor() : IDevice::Ptr(); } static QList<IDeviceFactory *> g_deviceFactories; @@ -89,15 +90,43 @@ IDeviceFactory *IDeviceFactory::find(Core::Id type) { return Utils::findOrDefault(g_deviceFactories, [&type](IDeviceFactory *factory) { - return factory->availableCreationIds().contains(type); + return factory->deviceType() == type; }); } -IDeviceFactory::IDeviceFactory(QObject *parent) : QObject(parent) +IDeviceFactory::IDeviceFactory(Core::Id deviceType) + : m_deviceType(deviceType) { g_deviceFactories.append(this); } +void IDeviceFactory::setIcon(const QIcon &icon) +{ + m_icon = icon; +} + +void IDeviceFactory::setCombinedIcon(const QString &small, const QString &large) +{ + using namespace Utils; + m_icon = Icon::combinedIcon({Icon({{small, Theme::PanelTextColorDark}}, Icon::Tint), + Icon({{large, Theme::IconsBaseColor}})}); +} + +void IDeviceFactory::setCanCreate(bool canCreate) +{ + m_canCreate = canCreate; +} + +void IDeviceFactory::setConstructionFunction(const std::function<IDevice::Ptr ()> &constructor) +{ + m_constructor = constructor; +} + +void IDeviceFactory::setDisplayName(const QString &displayName) +{ + m_displayName = displayName; +} + IDeviceFactory::~IDeviceFactory() { g_deviceFactories.removeOne(this); diff --git a/src/plugins/projectexplorer/devicesupport/idevicefactory.h b/src/plugins/projectexplorer/devicesupport/idevicefactory.h index 22f46d50db0..419e76d2dad 100644 --- a/src/plugins/projectexplorer/devicesupport/idevicefactory.h +++ b/src/plugins/projectexplorer/devicesupport/idevicefactory.h @@ -28,16 +28,10 @@ #include "idevice.h" #include <projectexplorer/projectexplorer_export.h> -#include <QObject> +#include <QIcon> #include <QVariantMap> -QT_BEGIN_NAMESPACE -class QWidget; -QT_END_NAMESPACE - namespace ProjectExplorer { -class IDeviceWidget; - class PROJECTEXPLORER_EXPORT IDeviceFactory : public QObject { @@ -47,22 +41,33 @@ public: ~IDeviceFactory() override; static const QList<IDeviceFactory *> allDeviceFactories(); - virtual QString displayNameForId(Core::Id type) const = 0; - - virtual QList<Core::Id> availableCreationIds() const = 0; - - virtual QIcon iconForId(Core::Id type) const = 0; + Core::Id deviceType() const { return m_deviceType; } + QString displayName() const { return m_displayName; } + QIcon icon() const { return m_icon; } + bool canCreate() const; + IDevice::Ptr construct() const; - virtual bool canCreate() const; - virtual IDevice::Ptr create(Core::Id id) const = 0; + virtual IDevice::Ptr create() const { return IDevice::Ptr(); } - virtual bool canRestore(const QVariantMap &map) const = 0; - virtual IDevice::Ptr restore(const QVariantMap &map) const = 0; + virtual bool canRestore(const QVariantMap &) const { return true; } static IDeviceFactory *find(Core::Id type); protected: - explicit IDeviceFactory(QObject *parent = nullptr); + explicit IDeviceFactory(Core::Id deviceType); + + void setDisplayName(const QString &displayName); + void setIcon(const QIcon &icon); + void setCombinedIcon(const QString &small, const QString &large); + void setCanCreate(bool canCreate); + void setConstructionFunction(const std::function<IDevice::Ptr ()> &constructor); + +private: + const Core::Id m_deviceType; + QString m_displayName; + QIcon m_icon; + bool m_canCreate = false; + std::function<IDevice::Ptr()> m_constructor; }; } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/devicesupport/localprocesslist.h b/src/plugins/projectexplorer/devicesupport/localprocesslist.h index 7f9a22112ff..d6e90e298cc 100644 --- a/src/plugins/projectexplorer/devicesupport/localprocesslist.h +++ b/src/plugins/projectexplorer/devicesupport/localprocesslist.h @@ -27,12 +27,6 @@ #include "deviceprocesslist.h" -#include <QString> - -QT_BEGIN_NAMESPACE -class QProcess; -QT_END_NAMESPACE - namespace ProjectExplorer { namespace Internal { diff --git a/src/plugins/projectexplorer/kit.cpp b/src/plugins/projectexplorer/kit.cpp index 37d71a2aff4..e0f3939bf35 100644 --- a/src/plugins/projectexplorer/kit.cpp +++ b/src/plugins/projectexplorer/kit.cpp @@ -356,9 +356,9 @@ static QIcon iconForDeviceType(Core::Id deviceType) { const IDeviceFactory *factory = Utils::findOrDefault(IDeviceFactory::allDeviceFactories(), [&deviceType](const IDeviceFactory *factory) { - return factory->availableCreationIds().contains(deviceType); + return factory->deviceType() == deviceType; }); - return factory ? factory->iconForId(deviceType) : QIcon(); + return factory ? factory->icon() : QIcon(); } QIcon Kit::icon() const diff --git a/src/plugins/projectexplorer/kitinformation.cpp b/src/plugins/projectexplorer/kitinformation.cpp index c5734dd2bc8..fa50794582a 100644 --- a/src/plugins/projectexplorer/kitinformation.cpp +++ b/src/plugins/projectexplorer/kitinformation.cpp @@ -586,13 +586,8 @@ KitInformation::ItemList DeviceTypeKitInformation::toUserOutput(const Kit *k) co Core::Id type = deviceTypeId(k); QString typeDisplayName = tr("Unknown device type"); if (type.isValid()) { - IDeviceFactory *factory = Utils::findOrDefault(IDeviceFactory::allDeviceFactories(), - [&type](IDeviceFactory *factory) { - return factory->availableCreationIds().contains(type); - }); - - if (factory) - typeDisplayName = factory->displayNameForId(type); + if (IDeviceFactory *factory = IDeviceFactory::find(type)) + typeDisplayName = factory->displayName(); } return ItemList() << qMakePair(tr("Device type"), typeDisplayName); } diff --git a/src/plugins/projectexplorer/kitinformationconfigwidget.cpp b/src/plugins/projectexplorer/kitinformationconfigwidget.cpp index c6fafe74699..d979367f87a 100644 --- a/src/plugins/projectexplorer/kitinformationconfigwidget.cpp +++ b/src/plugins/projectexplorer/kitinformationconfigwidget.cpp @@ -262,10 +262,8 @@ int ToolChainInformationConfigWidget::indexOf(QComboBox *cb, const ToolChain *tc DeviceTypeInformationConfigWidget::DeviceTypeInformationConfigWidget(Kit *workingCopy, const KitInformation *ki) : KitConfigWidget(workingCopy, ki), m_comboBox(new QComboBox) { - for (IDeviceFactory *factory : IDeviceFactory::allDeviceFactories()) { - foreach (Id id, factory->availableCreationIds()) - m_comboBox->addItem(factory->displayNameForId(id), id.toSetting()); - } + for (IDeviceFactory *factory : IDeviceFactory::allDeviceFactories()) + m_comboBox->addItem(factory->displayName(), factory->deviceType().toSetting()); m_comboBox->setToolTip(toolTip()); diff --git a/src/plugins/projectexplorer/kitmanager.cpp b/src/plugins/projectexplorer/kitmanager.cpp index 9ed48df0bde..090b34765f0 100644 --- a/src/plugins/projectexplorer/kitmanager.cpp +++ b/src/plugins/projectexplorer/kitmanager.cpp @@ -515,12 +515,10 @@ QSet<Id> KitFeatureProvider::availablePlatforms() const QString KitFeatureProvider::displayNameForPlatform(Id id) const { - for (IDeviceFactory *f : IDeviceFactory::allDeviceFactories()) { - if (f->availableCreationIds().contains(id)) { - const QString dn = f->displayNameForId(id); - QTC_ASSERT(!dn.isEmpty(), continue); - return dn; - } + if (IDeviceFactory *f = IDeviceFactory::find(id)) { + const QString dn = f->displayName(); + QTC_CHECK(!dn.isEmpty()); + return dn; } return QString(); } diff --git a/src/plugins/projectexplorer/makestep.cpp b/src/plugins/projectexplorer/makestep.cpp index ee051253ceb..504892c1494 100644 --- a/src/plugins/projectexplorer/makestep.cpp +++ b/src/plugins/projectexplorer/makestep.cpp @@ -312,11 +312,6 @@ BuildStepConfigWidget *MakeStep::createConfigWidget() return new MakeStepConfigWidget(this); } -bool MakeStep::immutable() const -{ - return false; -} - bool MakeStep::buildsTarget(const QString &target) const { return m_buildTargets.contains(target); @@ -342,8 +337,8 @@ QStringList MakeStep::availableTargets() const // GenericMakeStepConfigWidget // -MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep) : - m_makeStep(makeStep) +MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep) + : BuildStepConfigWidget(makeStep), m_makeStep(makeStep) { m_ui = new Internal::Ui::MakeStep; m_ui->setupUi(this); @@ -417,19 +412,6 @@ MakeStepConfigWidget::~MakeStepConfigWidget() delete m_ui; } -QString MakeStepConfigWidget::displayName() const -{ - return m_makeStep->displayName(); -} - -void MakeStepConfigWidget::setSummaryText(const QString &text) -{ - if (text == m_summaryText) - return; - m_summaryText = text; - emit updateSummary(); -} - void MakeStepConfigWidget::setUserJobCountVisible(bool visible) { m_ui->jobsLabel->setVisible(visible); @@ -485,11 +467,6 @@ void MakeStepConfigWidget::updateDetails() setSummaryText(param.summaryInWorkdir(displayName())); } -QString MakeStepConfigWidget::summaryText() const -{ - return m_summaryText; -} - void MakeStepConfigWidget::itemChanged(QListWidgetItem *item) { m_makeStep->setBuildTarget(item->text(), item->checkState() & Qt::Checked); diff --git a/src/plugins/projectexplorer/makestep.h b/src/plugins/projectexplorer/makestep.h index 1da9a541c46..0b4541b2116 100644 --- a/src/plugins/projectexplorer/makestep.h +++ b/src/plugins/projectexplorer/makestep.h @@ -48,7 +48,6 @@ public: bool init(QList<const BuildStep *> &earlierSteps) override; ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override; - bool immutable() const override; bool buildsTarget(const QString &target) const; void setBuildTarget(const QString &target, bool on); QStringList availableTargets() const; @@ -101,21 +100,16 @@ public: explicit MakeStepConfigWidget(MakeStep *makeStep); ~MakeStepConfigWidget() override; - QString displayName() const override; - QString summaryText() const override; - private: void itemChanged(QListWidgetItem *item); void makeLineEditTextEdited(); void makeArgumentsLineEditTextEdited(); void updateDetails(); - void setSummaryText(const QString &text); void setUserJobCountVisible(bool visible); void setUserJobCountEnabled(bool enabled); Internal::Ui::MakeStep *m_ui; MakeStep *m_makeStep; - QString m_summaryText; }; } // namespace GenericProjectManager diff --git a/src/plugins/projectexplorer/processstep.cpp b/src/plugins/projectexplorer/processstep.cpp index 81e463eb10c..da6f3a68dad 100644 --- a/src/plugins/projectexplorer/processstep.cpp +++ b/src/plugins/projectexplorer/processstep.cpp @@ -80,11 +80,6 @@ BuildStepConfigWidget *ProcessStep::createConfigWidget() return new ProcessStepConfigWidget(this); } -bool ProcessStep::immutable() const -{ - return false; -} - QString ProcessStep::command() const { return m_command; @@ -152,8 +147,8 @@ ProcessStepFactory::ProcessStepFactory() // ProcessStepConfigWidget //******* -ProcessStepConfigWidget::ProcessStepConfigWidget(ProcessStep *step) : - m_step(step) +ProcessStepConfigWidget::ProcessStepConfigWidget(ProcessStep *step) + : BuildStepConfigWidget(step), m_step(step) { m_ui.setupUi(this); m_ui.command->setExpectedKind(Utils::PathChooser::Command); diff --git a/src/plugins/projectexplorer/processstep.h b/src/plugins/projectexplorer/processstep.h index 4b61b2f51a7..c102c6d6f00 100644 --- a/src/plugins/projectexplorer/processstep.h +++ b/src/plugins/projectexplorer/processstep.h @@ -49,7 +49,6 @@ public: void run(QFutureInterface<bool> &) override; BuildStepConfigWidget *createConfigWidget() override; - bool immutable() const override; QString command() const; QString arguments() const; diff --git a/src/plugins/projectexplorer/projectconfigurationaspects.cpp b/src/plugins/projectexplorer/projectconfigurationaspects.cpp index fc295bbec0e..1830270bed6 100644 --- a/src/plugins/projectexplorer/projectconfigurationaspects.cpp +++ b/src/plugins/projectexplorer/projectconfigurationaspects.cpp @@ -55,6 +55,7 @@ public: bool m_value = false; bool m_defaultValue = false; QString m_label; + QString m_tooltip; QPointer<QCheckBox> m_checkBox; // Owned by configuration widget }; @@ -217,7 +218,8 @@ void BaseStringAspect::addToConfigurationLayout(QFormLayout *layout) case PathChooserDisplay: d->m_pathChooserDisplay = new PathChooser(parent); d->m_pathChooserDisplay->setExpectedKind(d->m_expectedKind); - d->m_pathChooserDisplay->setHistoryCompleter(d->m_historyCompleterKey); + if (!d->m_historyCompleterKey.isEmpty()) + d->m_pathChooserDisplay->setHistoryCompleter(d->m_historyCompleterKey); d->m_pathChooserDisplay->setEnvironment(d->m_environment); connect(d->m_pathChooserDisplay, &PathChooser::pathChanged, this, &BaseStringAspect::setValue); @@ -226,7 +228,8 @@ void BaseStringAspect::addToConfigurationLayout(QFormLayout *layout) case LineEditDisplay: d->m_lineEditDisplay = new FancyLineEdit(parent); d->m_lineEditDisplay->setPlaceholderText(d->m_placeHolderText); - d->m_lineEditDisplay->setHistoryCompleter(d->m_historyCompleterKey); + if (!d->m_historyCompleterKey.isEmpty()) + d->m_lineEditDisplay->setHistoryCompleter(d->m_historyCompleterKey); connect(d->m_lineEditDisplay, &FancyLineEdit::textEdited, this, &BaseStringAspect::setValue); hbox->addWidget(d->m_lineEditDisplay); @@ -307,6 +310,7 @@ 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); + d->m_checkBox->setToolTip(d->m_tooltip); layout->addRow(QString(), d->m_checkBox); connect(d->m_checkBox.data(), &QAbstractButton::clicked, this, [this] { d->m_value = d->m_checkBox->isChecked(); @@ -351,6 +355,11 @@ void BaseBoolAspect::setLabel(const QString &label) d->m_label = label; } +void BaseBoolAspect::setToolTip(const QString &tooltip) +{ + d->m_tooltip = tooltip; +} + /*! \class ProjectExplorer::BaseIntegerAspect */ diff --git a/src/plugins/projectexplorer/projectconfigurationaspects.h b/src/plugins/projectexplorer/projectconfigurationaspects.h index e47d232f2ee..d494f0bcb33 100644 --- a/src/plugins/projectexplorer/projectconfigurationaspects.h +++ b/src/plugins/projectexplorer/projectconfigurationaspects.h @@ -58,6 +58,7 @@ public: void setDefaultValue(bool defaultValue); void setLabel(const QString &label); + void setToolTip(const QString &tooltip); void fromMap(const QVariantMap &map) override; void toMap(QVariantMap &map) const override; diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index bf80158488b..5048c2d0ca1 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -235,6 +235,10 @@ const char RUNMENUCONTEXTMENU[] = "Project.RunMenu"; const char FOLDER_OPEN_LOCATIONS_CONTEXT_MENU[] = "Project.F.OpenLocation.CtxMenu"; const char PROJECT_OPEN_LOCATIONS_CONTEXT_MENU[] = "Project.P.OpenLocation.CtxMenu"; +// Default directories: +const char DEFAULT_BUILD_DIRECTORY_TEMPLATE[] = "../%{JS: Util.asciify(\"build-%{CurrentProject:Name}-%{CurrentKit:FileSystemName}-%{CurrentBuild:Name}\")}"; +const char DEFAULT_BUILD_DIRECTORY_TEMPLATE_KEY[] = "Directories/BuildDirectory.Template"; + } // namespace Constants @@ -269,6 +273,12 @@ static BuildConfiguration *activeBuildConfiguration() return target ? target->activeBuildConfiguration() : nullptr; } +static RunConfiguration *activeRunConfiguration() +{ + Target *target = activeTarget(); + return target ? target->activeRunConfiguration() : nullptr; +} + static Kit *currentKit() { Target *target = activeTarget(); @@ -1288,6 +1298,10 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er if (tmp < 0 || tmp > ProjectExplorerSettings::StopSameBuildDir) tmp = Utils::HostOsInfo::isWindowsHost() ? 1 : 0; dd->m_projectExplorerSettings.stopBeforeBuild = ProjectExplorerSettings::StopBeforeBuild(tmp); + dd->m_projectExplorerSettings.buildDirectoryTemplate + = s->value(Constants::DEFAULT_BUILD_DIRECTORY_TEMPLATE_KEY).toString(); + if (dd->m_projectExplorerSettings.buildDirectoryTemplate.isEmpty()) + dd->m_projectExplorerSettings.buildDirectoryTemplate = Constants::DEFAULT_BUILD_DIRECTORY_TEMPLATE; auto buildManager = new BuildManager(this, dd->m_cancelBuildAction); connect(buildManager, &BuildManager::buildStateChanged, @@ -1556,6 +1570,21 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er return QString(); }); + Utils::EnvironmentProvider::addProvider( + {Constants::VAR_CURRENTBUILD_ENV, tr("Current Build Environment"), []() { + if (BuildConfiguration *bc = activeBuildConfiguration()) + return bc->environment(); + return Utils::Environment::systemEnvironment(); + }}); + + Utils::EnvironmentProvider::addProvider( + {"CurrentRun:Env", tr("Current Run Environment"), []() { + if (RunConfiguration *rc = activeRunConfiguration()) + if (auto envAspect = rc->aspect<EnvironmentAspect>()) + return envAspect->environment(); + return Utils::Environment::systemEnvironment(); + }}); + QString fileDescription = tr("File where current session is saved."); auto fileHandler = [] { return SessionManager::sessionNameToFileName(SessionManager::activeSession()).toString(); }; expander->registerFileVariables("Session", fileDescription, fileHandler); @@ -1805,6 +1834,9 @@ void ProjectExplorerPluginPrivate::savePersistentSettings() s->setValue(QLatin1String("ProjectExplorer/Settings/MaxBuildOutputLines"), dd->m_projectExplorerSettings.maxBuildOutputChars / 100); s->setValue(QLatin1String("ProjectExplorer/Settings/EnvironmentId"), dd->m_projectExplorerSettings.environmentId.toByteArray()); s->setValue(QLatin1String("ProjectExplorer/Settings/StopBeforeBuild"), dd->m_projectExplorerSettings.stopBeforeBuild); + + // Store this in the Core directory scope for backward compatibility! + s->setValue(Constants::DEFAULT_BUILD_DIRECTORY_TEMPLATE_KEY, dd->m_projectExplorerSettings.buildDirectoryTemplate); } void ProjectExplorerPlugin::openProjectWelcomePage(const QString &fileName) @@ -3580,6 +3612,31 @@ void ProjectExplorerPlugin::openOpenProjectDialog() ICore::openFiles(files, ICore::SwitchMode); } +/*! + Returns the current build directory template. + + \sa setBuildDirectoryTemplate +*/ +QString ProjectExplorerPlugin::buildDirectoryTemplate() +{ + return dd->m_projectExplorerSettings.buildDirectoryTemplate; +} + +/*! + Sets the current build directory template to \a directory. + + \sa defaultbuildDirectory +*/ +void ProjectExplorerPlugin::setBuildDirectoryTemplate(const QString &dir) +{ + dd->m_projectExplorerSettings.buildDirectoryTemplate = dir; +} + +QString ProjectExplorerPlugin::defaultBuildDirectoryTemplate() +{ + return QString(Constants::DEFAULT_BUILD_DIRECTORY_TEMPLATE); +} + QList<QPair<QString, QString> > ProjectExplorerPlugin::recentProjects() { return dd->recentProjects(); diff --git a/src/plugins/projectexplorer/projectexplorer.h b/src/plugins/projectexplorer/projectexplorer.h index 153f8d0c105..e00fc393d0b 100644 --- a/src/plugins/projectexplorer/projectexplorer.h +++ b/src/plugins/projectexplorer/projectexplorer.h @@ -163,6 +163,10 @@ public: static void openNewProjectDialog(); static void openOpenProjectDialog(); + static QString buildDirectoryTemplate(); + static void setBuildDirectoryTemplate(const QString &dir); + static QString defaultBuildDirectoryTemplate(); + signals: void finishedInitialization(); diff --git a/src/plugins/projectexplorer/projectexplorersettings.h b/src/plugins/projectexplorer/projectexplorersettings.h index 37f35cea037..13277e9736a 100644 --- a/src/plugins/projectexplorer/projectexplorersettings.h +++ b/src/plugins/projectexplorer/projectexplorersettings.h @@ -26,6 +26,7 @@ #pragma once #include <coreplugin/coreconstants.h> +#include <projectexplorer/projectexplorerconstants.h> #include <QUuid> @@ -54,6 +55,7 @@ public: int maxAppOutputChars = Core::Constants::DEFAULT_MAX_CHAR_COUNT; int maxBuildOutputChars = Core::Constants::DEFAULT_MAX_CHAR_COUNT; StopBeforeBuild stopBeforeBuild = StopBeforeBuild::StopNone; + QString buildDirectoryTemplate; // Add a UUid which is used to identify the development environment. // This is used to warn the user when he is trying to open a .user file that was created @@ -80,7 +82,8 @@ inline bool operator==(const ProjectExplorerSettings &p1, const ProjectExplorerS && p1.maxAppOutputChars == p2.maxAppOutputChars && p1.maxBuildOutputChars == p2.maxBuildOutputChars && p1.environmentId == p2.environmentId - && p1.stopBeforeBuild == p2.stopBeforeBuild; + && p1.stopBeforeBuild == p2.stopBeforeBuild + && p1.buildDirectoryTemplate == p2.buildDirectoryTemplate; } } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/projectexplorersettingspage.cpp b/src/plugins/projectexplorer/projectexplorersettingspage.cpp index 9ee14d51831..5b4b6dbb53a 100644 --- a/src/plugins/projectexplorer/projectexplorersettingspage.cpp +++ b/src/plugins/projectexplorer/projectexplorersettingspage.cpp @@ -34,6 +34,7 @@ #include <utils/hostosinfo.h> #include <QCoreApplication> +#include <QWidget> namespace ProjectExplorer { namespace Internal { @@ -56,13 +57,13 @@ public: bool useProjectsDirectory(); void setUseProjectsDirectory(bool v); - QString buildDirectory() const; - void setBuildDirectory(const QString &bd); + QString buildDirectoryTemplate() const; + void setBuildDirectoryTemplate(const QString &bd); private: void slotDirectoryButtonGroupChanged(); - void resetDefaultBuildDirectory(); - void updateResetButton(); + void resetBuildDirectoryTemplate(); + void updateBuildDirectoryResetButton(); void setJomVisible(bool); @@ -80,10 +81,10 @@ ProjectExplorerSettingsWidget::ProjectExplorerSettingsWidget(QWidget *parent) : connect(m_ui.directoryButtonGroup, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), this, &ProjectExplorerSettingsWidget::slotDirectoryButtonGroupChanged); - connect(m_ui.resetButton, &QAbstractButton::clicked, - this, &ProjectExplorerSettingsWidget::resetDefaultBuildDirectory); + connect(m_ui.buildDirectoryResetButton, &QAbstractButton::clicked, + this, &ProjectExplorerSettingsWidget::resetBuildDirectoryTemplate); connect(m_ui.buildDirectoryEdit, &QLineEdit::textChanged, - this, &ProjectExplorerSettingsWidget::updateResetButton); + this, &ProjectExplorerSettingsWidget::updateBuildDirectoryResetButton); auto chooser = new Core::VariableChooser(this); chooser->addSupportedWidget(m_ui.buildDirectoryEdit); @@ -159,12 +160,12 @@ void ProjectExplorerSettingsWidget::setUseProjectsDirectory(bool b) } } -QString ProjectExplorerSettingsWidget::buildDirectory() const +QString ProjectExplorerSettingsWidget::buildDirectoryTemplate() const { return m_ui.buildDirectoryEdit->text(); } -void ProjectExplorerSettingsWidget::setBuildDirectory(const QString &bd) +void ProjectExplorerSettingsWidget::setBuildDirectoryTemplate(const QString &bd) { m_ui.buildDirectoryEdit->setText(bd); } @@ -175,14 +176,14 @@ void ProjectExplorerSettingsWidget::slotDirectoryButtonGroupChanged() m_ui.projectsDirectoryPathChooser->setEnabled(enable); } -void ProjectExplorerSettingsWidget::resetDefaultBuildDirectory() +void ProjectExplorerSettingsWidget::resetBuildDirectoryTemplate() { - setBuildDirectory(QLatin1String(Core::Constants::DEFAULT_BUILD_DIRECTORY)); + setBuildDirectoryTemplate(ProjectExplorerPlugin::defaultBuildDirectoryTemplate()); } -void ProjectExplorerSettingsWidget::updateResetButton() +void ProjectExplorerSettingsWidget::updateBuildDirectoryResetButton() { - m_ui.resetButton->setEnabled(buildDirectory() != QLatin1String(Core::Constants::DEFAULT_BUILD_DIRECTORY)); + m_ui.buildDirectoryResetButton->setEnabled(buildDirectoryTemplate() != ProjectExplorerPlugin::defaultBuildDirectoryTemplate()); } // ------------------ ProjectExplorerSettingsPage @@ -203,7 +204,7 @@ QWidget *ProjectExplorerSettingsPage::widget() m_widget->setSettings(ProjectExplorerPlugin::projectExplorerSettings()); m_widget->setProjectsDirectory(Core::DocumentManager::projectsDirectory().toString()); m_widget->setUseProjectsDirectory(Core::DocumentManager::useProjectsDirectory()); - m_widget->setBuildDirectory(Core::DocumentManager::buildDirectory()); + m_widget->setBuildDirectoryTemplate(ProjectExplorerPlugin::buildDirectoryTemplate()); } return m_widget; } @@ -215,7 +216,7 @@ void ProjectExplorerSettingsPage::apply() Core::DocumentManager::setProjectsDirectory( Utils::FileName::fromString(m_widget->projectsDirectory())); Core::DocumentManager::setUseProjectsDirectory(m_widget->useProjectsDirectory()); - Core::DocumentManager::setBuildDirectory(m_widget->buildDirectory()); + ProjectExplorerPlugin::setBuildDirectoryTemplate(m_widget->buildDirectoryTemplate()); } } diff --git a/src/plugins/projectexplorer/projectexplorersettingspage.ui b/src/plugins/projectexplorer/projectexplorersettingspage.ui index 7638d532fa2..7fecbfb38ef 100644 --- a/src/plugins/projectexplorer/projectexplorersettingspage.ui +++ b/src/plugins/projectexplorer/projectexplorersettingspage.ui @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>831</width> - <height>507</height> + <height>520</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_2"> @@ -328,7 +328,7 @@ <number>12</number> </property> <item> - <widget class="QLabel" name="buildDirLabel"> + <widget class="QLabel" name="buildDirectoryLabel"> <property name="text"> <string>Default build directory:</string> </property> @@ -338,7 +338,7 @@ <widget class="QLineEdit" name="buildDirectoryEdit"/> </item> <item> - <widget class="QPushButton" name="resetButton"> + <widget class="QPushButton" name="buildDirectoryResetButton"> <property name="text"> <string>Reset</string> </property> diff --git a/src/plugins/qbsprojectmanager/qbsbuildconfiguration.cpp b/src/plugins/qbsprojectmanager/qbsbuildconfiguration.cpp index af4d0bf0e13..1fcaec1f449 100644 --- a/src/plugins/qbsprojectmanager/qbsbuildconfiguration.cpp +++ b/src/plugins/qbsprojectmanager/qbsbuildconfiguration.cpp @@ -41,6 +41,7 @@ #include <projectexplorer/deployconfiguration.h> #include <projectexplorer/kit.h> #include <projectexplorer/kitinformation.h> +#include <projectexplorer/projectexplorer.h> #include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectmacroexpander.h> #include <projectexplorer/target.h> @@ -66,7 +67,7 @@ static FileName defaultBuildDirectory(const QString &projectFilePath, const Kit const QString projectName = QFileInfo(projectFilePath).completeBaseName(); ProjectMacroExpander expander(projectFilePath, projectName, k, bcName, buildType); QString projectDir = Project::projectDirectory(FileName::fromString(projectFilePath)).toString(); - QString buildPath = expander.expand(Core::DocumentManager::buildDirectory()); + QString buildPath = expander.expand(ProjectExplorerPlugin::defaultBuildDirectoryTemplate()); return FileName::fromString(FileUtils::resolvePath(projectDir, buildPath)); } diff --git a/src/plugins/qbsprojectmanager/qbsbuildstep.cpp b/src/plugins/qbsprojectmanager/qbsbuildstep.cpp index 3eb25f9da56..d7269f636af 100644 --- a/src/plugins/qbsprojectmanager/qbsbuildstep.cpp +++ b/src/plugins/qbsprojectmanager/qbsbuildstep.cpp @@ -68,8 +68,6 @@ class QbsBuildStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget public: QbsBuildStepConfigWidget(QbsBuildStep *step); ~QbsBuildStepConfigWidget() override; - QString summaryText() const override; - QString displayName() const override; private: void updateState(); @@ -87,6 +85,8 @@ private: void changeForceProbes(bool forceProbes); void applyCachedProperties(); + QbsBuildStep *qbsStep() const; + // QML debugging: void linkQmlDebuggingLibraryChecked(bool checked); @@ -114,8 +114,6 @@ private: }; QList<Property> m_propertyCache; - QbsBuildStep *m_step; - QString m_summary; bool m_ignoreChange; }; @@ -129,6 +127,8 @@ QbsBuildStep::QbsBuildStep(ProjectExplorer::BuildStepList *bsl) : { setDisplayName(tr("Qbs Build")); setQbsConfiguration(QVariantMap()); + setRunInGuiThread(true); + // setQbsConfiguration(other->qbsConfiguration(PreserveVariables)); } @@ -186,11 +186,6 @@ ProjectExplorer::BuildStepConfigWidget *QbsBuildStep::createConfigWidget() return new QbsBuildStepConfigWidget(this); } -bool QbsBuildStep::runInGuiThread() const -{ - return true; -} - void QbsBuildStep::cancel() { if (m_parsingProject) @@ -534,20 +529,20 @@ QbsProject *QbsBuildStep::qbsProject() const // -------------------------------------------------------------------- QbsBuildStepConfigWidget::QbsBuildStepConfigWidget(QbsBuildStep *step) : - m_step(step), + BuildStepConfigWidget(step), m_ignoreChange(false) { - connect(m_step, &ProjectExplorer::ProjectConfiguration::displayNameChanged, + connect(step, &ProjectExplorer::ProjectConfiguration::displayNameChanged, this, &QbsBuildStepConfigWidget::updateState); - connect(m_step, &QbsBuildStep::qbsConfigurationChanged, + connect(step, &QbsBuildStep::qbsConfigurationChanged, this, &QbsBuildStepConfigWidget::updateState); - connect(m_step, &QbsBuildStep::qbsBuildOptionsChanged, + connect(step, &QbsBuildStep::qbsBuildOptionsChanged, this, &QbsBuildStepConfigWidget::updateState); connect(&QbsProjectManagerSettings::instance(), &QbsProjectManagerSettings::settingsBaseChanged, this, &QbsBuildStepConfigWidget::updateState); step->target()->subscribeSignal(&ProjectExplorer::BuildConfiguration::buildDirectoryChanged, this, [this]() { - if (m_step->buildConfiguration() == sender()) + if (this->step()->buildConfiguration() == sender()) updateState(); }); @@ -597,62 +592,48 @@ QbsBuildStepConfigWidget::~QbsBuildStepConfigWidget() delete m_ui; } -QString QbsBuildStepConfigWidget::summaryText() const -{ - return m_summary; -} - -QString QbsBuildStepConfigWidget::displayName() const -{ - return m_step->displayName(); -} - void QbsBuildStepConfigWidget::updateState() { if (!m_ignoreChange) { - m_ui->keepGoingCheckBox->setChecked(m_step->keepGoing()); - m_ui->jobSpinBox->setValue(m_step->maxJobs()); - m_ui->showCommandLinesCheckBox->setChecked(m_step->showCommandLines()); - m_ui->installCheckBox->setChecked(m_step->install()); - m_ui->cleanInstallRootCheckBox->setChecked(m_step->cleanInstallRoot()); - m_ui->forceProbesCheckBox->setChecked(m_step->forceProbes()); - updatePropertyEdit(m_step->qbsConfiguration(QbsBuildStep::PreserveVariables)); - m_ui->qmlDebuggingLibraryCheckBox->setChecked(m_step->isQmlDebuggingEnabled()); - m_ui->installDirChooser->setFileName(m_step->installRoot(QbsBuildStep::PreserveVariables)); - m_ui->defaultInstallDirCheckBox->setChecked(!m_step->hasCustomInstallRoot()); + m_ui->keepGoingCheckBox->setChecked(qbsStep()->keepGoing()); + m_ui->jobSpinBox->setValue(qbsStep()->maxJobs()); + m_ui->showCommandLinesCheckBox->setChecked(qbsStep()->showCommandLines()); + m_ui->installCheckBox->setChecked(qbsStep()->install()); + m_ui->cleanInstallRootCheckBox->setChecked(qbsStep()->cleanInstallRoot()); + m_ui->forceProbesCheckBox->setChecked(qbsStep()->forceProbes()); + updatePropertyEdit(qbsStep()->qbsConfiguration(QbsBuildStep::PreserveVariables)); + m_ui->qmlDebuggingLibraryCheckBox->setChecked(qbsStep()->isQmlDebuggingEnabled()); + m_ui->installDirChooser->setFileName(qbsStep()->installRoot(QbsBuildStep::PreserveVariables)); + m_ui->defaultInstallDirCheckBox->setChecked(!qbsStep()->hasCustomInstallRoot()); } updateQmlDebuggingOption(); - const QString buildVariant = m_step->buildVariant(); + const QString buildVariant = qbsStep()->buildVariant(); const int idx = (buildVariant == Constants::QBS_VARIANT_DEBUG) ? 0 : 1; m_ui->buildVariantComboBox->setCurrentIndex(idx); - QString command = static_cast<QbsBuildConfiguration *>(m_step->buildConfiguration()) - ->equivalentCommandLine(m_step); + QString command = static_cast<QbsBuildConfiguration *>(step()->buildConfiguration()) + ->equivalentCommandLine(qbsStep()); for (int i = 0; i < m_propertyCache.count(); ++i) { command += ' ' + m_propertyCache.at(i).name + ':' + m_propertyCache.at(i).effectiveValue; } - if (m_step->isQmlDebuggingEnabled()) + if (qbsStep()->isQmlDebuggingEnabled()) command.append(' ').append(Constants::QBS_CONFIG_QUICK_DEBUG_KEY).append(":true"); m_ui->commandLineTextEdit->setPlainText(command); - QString summary = tr("<b>Qbs:</b> %1").arg(command); - if (m_summary != summary) { - m_summary = summary; - emit updateSummary(); - } + setSummaryText(tr("<b>Qbs:</b> %1").arg(command)); } void QbsBuildStepConfigWidget::updateQmlDebuggingOption() { QString warningText; - bool supported = QtSupport::BaseQtVersion::isQmlDebuggingSupported(m_step->target()->kit(), + bool supported = QtSupport::BaseQtVersion::isQmlDebuggingSupported(step()->target()->kit(), &warningText); m_ui->qmlDebuggingLibraryCheckBox->setEnabled(supported); - if (supported && m_step->isQmlDebuggingEnabled()) + if (supported && qbsStep()->isQmlDebuggingEnabled()) warningText = tr("Might make your application vulnerable. Only use in a safe environment."); m_ui->qmlDebuggingWarningText->setText(warningText); @@ -687,80 +668,80 @@ void QbsBuildStepConfigWidget::changeBuildVariant(int idx) else variant = Constants::QBS_VARIANT_DEBUG; m_ignoreChange = true; - m_step->setBuildVariant(variant); + qbsStep()->setBuildVariant(variant); m_ignoreChange = false; } void QbsBuildStepConfigWidget::changeShowCommandLines(bool show) { m_ignoreChange = true; - m_step->setShowCommandLines(show); + qbsStep()->setShowCommandLines(show); m_ignoreChange = false; } void QbsBuildStepConfigWidget::changeKeepGoing(bool kg) { m_ignoreChange = true; - m_step->setKeepGoing(kg); + qbsStep()->setKeepGoing(kg); m_ignoreChange = false; } void QbsBuildStepConfigWidget::changeJobCount(int count) { m_ignoreChange = true; - m_step->setMaxJobs(count); + qbsStep()->setMaxJobs(count); m_ignoreChange = false; } void QbsBuildStepConfigWidget::changeInstall(bool install) { m_ignoreChange = true; - m_step->setInstall(install); + qbsStep()->setInstall(install); m_ignoreChange = false; } void QbsBuildStepConfigWidget::changeCleanInstallRoot(bool clean) { m_ignoreChange = true; - m_step->setCleanInstallRoot(clean); + qbsStep()->setCleanInstallRoot(clean); m_ignoreChange = false; } void QbsBuildStepConfigWidget::changeUseDefaultInstallDir(bool useDefault) { m_ignoreChange = true; - QVariantMap config = m_step->qbsConfiguration(QbsBuildStep::PreserveVariables); + QVariantMap config = qbsStep()->qbsConfiguration(QbsBuildStep::PreserveVariables); m_ui->installDirChooser->setEnabled(!useDefault); if (useDefault) config.remove(Constants::QBS_INSTALL_ROOT_KEY); else config.insert(Constants::QBS_INSTALL_ROOT_KEY, m_ui->installDirChooser->rawPath()); - m_step->setQbsConfiguration(config); + qbsStep()->setQbsConfiguration(config); m_ignoreChange = false; } void QbsBuildStepConfigWidget::changeInstallDir(const QString &dir) { - if (!m_step->hasCustomInstallRoot()) + if (!qbsStep()->hasCustomInstallRoot()) return; m_ignoreChange = true; - QVariantMap config = m_step->qbsConfiguration(QbsBuildStep::PreserveVariables); + QVariantMap config = qbsStep()->qbsConfiguration(QbsBuildStep::PreserveVariables); config.insert(Constants::QBS_INSTALL_ROOT_KEY, dir); - m_step->setQbsConfiguration(config); + qbsStep()->setQbsConfiguration(config); m_ignoreChange = false; } void QbsBuildStepConfigWidget::changeForceProbes(bool forceProbes) { m_ignoreChange = true; - m_step->setForceProbes(forceProbes); + qbsStep()->setForceProbes(forceProbes); m_ignoreChange = false; } void QbsBuildStepConfigWidget::applyCachedProperties() { QVariantMap data; - const QVariantMap tmp = m_step->qbsConfiguration(QbsBuildStep::PreserveVariables); + const QVariantMap tmp = qbsStep()->qbsConfiguration(QbsBuildStep::PreserveVariables); // Insert values set up with special UIs: data.insert(Constants::QBS_CONFIG_PROFILE_KEY, @@ -782,14 +763,19 @@ void QbsBuildStepConfigWidget::applyCachedProperties() } m_ignoreChange = true; - m_step->setQbsConfiguration(data); + qbsStep()->setQbsConfiguration(data); m_ignoreChange = false; } +QbsBuildStep *QbsBuildStepConfigWidget::qbsStep() const +{ + return static_cast<QbsBuildStep *>(step()); +} + void QbsBuildStepConfigWidget::linkQmlDebuggingLibraryChecked(bool checked) { m_ignoreChange = true; - m_step->setQmlDebuggingEnabled(checked); + qbsStep()->setQmlDebuggingEnabled(checked); m_ignoreChange = false; } @@ -809,8 +795,19 @@ bool QbsBuildStepConfigWidget::validateProperties(Utils::FancyLineEdit *edit, QS foreach (const QString &rawArg, argList) { int pos = rawArg.indexOf(':'); if (pos > 0) { + const QString propertyName = rawArg.left(pos); + static const QStringList specialProperties{ + Constants::QBS_CONFIG_PROFILE_KEY, Constants::QBS_CONFIG_VARIANT_KEY, + Constants::QBS_CONFIG_QUICK_DEBUG_KEY, Constants::QBS_INSTALL_ROOT_KEY}; + if (specialProperties.contains(propertyName)) { + if (errorMessage) { + *errorMessage = tr("Property \"%1\" cannot be set here. " + "Please use the dedicated UI element.").arg(propertyName); + } + return false; + } const QString rawValue = rawArg.mid(pos + 1); - Property property(rawArg.left(pos), rawValue, expander->expand(rawValue)); + Property property(propertyName, rawValue, expander->expand(rawValue)); properties.append(property); } else { if (errorMessage) diff --git a/src/plugins/qbsprojectmanager/qbsbuildstep.h b/src/plugins/qbsprojectmanager/qbsbuildstep.h index 5081b8b96f0..ad4170ad865 100644 --- a/src/plugins/qbsprojectmanager/qbsbuildstep.h +++ b/src/plugins/qbsprojectmanager/qbsbuildstep.h @@ -64,7 +64,6 @@ public: ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override; - bool runInGuiThread() const override; void cancel() override; QVariantMap qbsConfiguration(VariableHandling variableHandling) const; diff --git a/src/plugins/qbsprojectmanager/qbscleanstep.cpp b/src/plugins/qbsprojectmanager/qbscleanstep.cpp index 9ddf533395c..a3cdce3ceeb 100644 --- a/src/plugins/qbsprojectmanager/qbscleanstep.cpp +++ b/src/plugins/qbsprojectmanager/qbscleanstep.cpp @@ -52,6 +52,7 @@ QbsCleanStep::QbsCleanStep(ProjectExplorer::BuildStepList *bsl) : ProjectExplorer::BuildStep(bsl, Constants::QBS_CLEANSTEP_ID) { setDisplayName(tr("Qbs Clean")); + setRunInGuiThread(true); } QbsCleanStep::~QbsCleanStep() @@ -107,11 +108,6 @@ ProjectExplorer::BuildStepConfigWidget *QbsCleanStep::createConfigWidget() return new QbsCleanStepConfigWidget(this); } -bool QbsCleanStep::runInGuiThread() const -{ - return true; -} - void QbsCleanStep::cancel() { if (m_job) @@ -220,7 +216,7 @@ void QbsCleanStep::setMaxJobs(int jobcount) // -------------------------------------------------------------------- QbsCleanStepConfigWidget::QbsCleanStepConfigWidget(QbsCleanStep *step) : - m_step(step) + BuildStepConfigWidget(step), m_step(step) { connect(m_step, &ProjectExplorer::ProjectConfiguration::displayNameChanged, this, &QbsCleanStepConfigWidget::updateState); @@ -245,16 +241,6 @@ QbsCleanStepConfigWidget::~QbsCleanStepConfigWidget() delete m_ui; } -QString QbsCleanStepConfigWidget::summaryText() const -{ - return m_summary; -} - -QString QbsCleanStepConfigWidget::displayName() const -{ - return m_step->displayName(); -} - void QbsCleanStepConfigWidget::updateState() { m_ui->dryRunCheckBox->setChecked(m_step->dryRun()); @@ -264,11 +250,7 @@ void QbsCleanStepConfigWidget::updateState() ->equivalentCommandLine(m_step); m_ui->commandLineTextEdit->setPlainText(command); - QString summary = tr("<b>Qbs:</b> %1").arg(command); - if (m_summary != summary) { - m_summary = summary; - emit updateSummary(); - } + setSummaryText(tr("<b>Qbs:</b> %1").arg(command)); } void QbsCleanStepConfigWidget::changeDryRun(bool dr) diff --git a/src/plugins/qbsprojectmanager/qbscleanstep.h b/src/plugins/qbsprojectmanager/qbscleanstep.h index 04d557aba4d..7c570c980ce 100644 --- a/src/plugins/qbsprojectmanager/qbscleanstep.h +++ b/src/plugins/qbsprojectmanager/qbscleanstep.h @@ -51,7 +51,6 @@ public: ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override; - bool runInGuiThread() const override; void cancel() override; bool fromMap(const QVariantMap &map) override; @@ -96,8 +95,6 @@ class QbsCleanStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget public: QbsCleanStepConfigWidget(QbsCleanStep *step); ~QbsCleanStepConfigWidget() override; - QString summaryText() const override; - QString displayName() const override; private: void updateState(); @@ -109,7 +106,6 @@ private: Ui::QbsCleanStepConfigWidget *m_ui; QbsCleanStep *m_step; - QString m_summary; }; class QbsCleanStepFactory : public ProjectExplorer::BuildStepFactory diff --git a/src/plugins/qbsprojectmanager/qbsinstallstep.cpp b/src/plugins/qbsprojectmanager/qbsinstallstep.cpp index a5a8430c0c2..7ad996c0031 100644 --- a/src/plugins/qbsprojectmanager/qbsinstallstep.cpp +++ b/src/plugins/qbsprojectmanager/qbsinstallstep.cpp @@ -61,6 +61,7 @@ QbsInstallStep::QbsInstallStep(ProjectExplorer::BuildStepList *bsl) : ProjectExplorer::BuildStep(bsl, Constants::QBS_INSTALLSTEP_ID) { setDisplayName(tr("Qbs Install")); + setRunInGuiThread(true); const QbsBuildConfiguration * const bc = buildConfig(); connect(bc, &QbsBuildConfiguration::qbsConfigurationChanged, @@ -112,11 +113,6 @@ ProjectExplorer::BuildStepConfigWidget *QbsInstallStep::createConfigWidget() return new QbsInstallStepConfigWidget(this); } -bool QbsInstallStep::runInGuiThread() const -{ - return true; -} - void QbsInstallStep::cancel() { if (m_job) @@ -251,7 +247,7 @@ void QbsInstallStep::handleBuildConfigChanged() // -------------------------------------------------------------------- QbsInstallStepConfigWidget::QbsInstallStepConfigWidget(QbsInstallStep *step) : - m_step(step), m_ignoreChange(false) + BuildStepConfigWidget(step), m_step(step), m_ignoreChange(false) { connect(m_step, &ProjectExplorer::ProjectConfiguration::displayNameChanged, this, &QbsInstallStepConfigWidget::updateState); @@ -283,16 +279,6 @@ QbsInstallStepConfigWidget::~QbsInstallStepConfigWidget() delete m_ui; } -QString QbsInstallStepConfigWidget::summaryText() const -{ - return m_summary; -} - -QString QbsInstallStepConfigWidget::displayName() const -{ - return m_step->displayName(); -} - void QbsInstallStepConfigWidget::updateState() { if (!m_ignoreChange) { @@ -306,11 +292,7 @@ void QbsInstallStepConfigWidget::updateState() m_ui->commandLineTextEdit->setPlainText(command); - QString summary = tr("<b>Qbs:</b> %1").arg(command); - if (m_summary != summary) { - m_summary = summary; - emit updateSummary(); - } + setSummaryText(tr("<b>Qbs:</b> %1").arg(command)); } void QbsInstallStepConfigWidget::changeRemoveFirst(bool rf) diff --git a/src/plugins/qbsprojectmanager/qbsinstallstep.h b/src/plugins/qbsprojectmanager/qbsinstallstep.h index e76763b2a70..65c8aa931b7 100644 --- a/src/plugins/qbsprojectmanager/qbsinstallstep.h +++ b/src/plugins/qbsprojectmanager/qbsinstallstep.h @@ -51,7 +51,6 @@ public: ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override; - bool runInGuiThread() const override; void cancel() override; bool fromMap(const QVariantMap &map) override; @@ -99,8 +98,6 @@ class QbsInstallStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget public: QbsInstallStepConfigWidget(QbsInstallStep *step); ~QbsInstallStepConfigWidget() override; - QString summaryText() const override; - QString displayName() const override; private: void updateState(); @@ -113,7 +110,6 @@ private: Ui::QbsInstallStepConfigWidget *m_ui; QbsInstallStep *m_step; - QString m_summary; bool m_ignoreChange; }; diff --git a/src/plugins/qbsprojectmanager/qbsprojectimporter.cpp b/src/plugins/qbsprojectmanager/qbsprojectimporter.cpp index 8978631d6c6..1cbee464d22 100644 --- a/src/plugins/qbsprojectmanager/qbsprojectimporter.cpp +++ b/src/plugins/qbsprojectmanager/qbsprojectimporter.cpp @@ -34,6 +34,7 @@ #include <projectexplorer/kitinformation.h> #include <projectexplorer/kitmanager.h> #include <projectexplorer/project.h> +#include <projectexplorer/projectexplorer.h> #include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectmacroexpander.h> #include <projectexplorer/toolchain.h> @@ -93,7 +94,7 @@ static QString buildDir(const QString &projectFilePath, const Kit *k) BuildConfiguration::Unknown); const QString projectDir = Project::projectDirectory(FileName::fromString(projectFilePath)).toString(); - const QString buildPath = expander.expand(Core::DocumentManager::buildDirectory()); + const QString buildPath = expander.expand(ProjectExplorerPlugin::defaultBuildDirectoryTemplate()); return FileUtils::resolvePath(projectDir, buildPath); } diff --git a/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.cpp b/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.cpp index e2b3c5cbf1d..e4eeaa4f428 100644 --- a/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.cpp +++ b/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.cpp @@ -83,7 +83,7 @@ QString QmakeBuildConfiguration::shadowBuildDirectory(const QString &proFilePath const QString projectName = QFileInfo(proFilePath).completeBaseName(); ProjectMacroExpander expander(proFilePath, projectName, k, suffix, buildType); QString projectDir = Project::projectDirectory(FileName::fromString(proFilePath)).toString(); - QString buildPath = expander.expand(Core::DocumentManager::buildDirectory()); + QString buildPath = expander.expand(ProjectExplorerPlugin::buildDirectoryTemplate()); return FileUtils::resolvePath(projectDir, buildPath); } diff --git a/src/plugins/qmakeprojectmanager/qmakestep.cpp b/src/plugins/qmakeprojectmanager/qmakestep.cpp index aa4c6ba2675..8ff396e0224 100644 --- a/src/plugins/qmakeprojectmanager/qmakestep.cpp +++ b/src/plugins/qmakeprojectmanager/qmakestep.cpp @@ -290,11 +290,6 @@ ProjectExplorer::BuildStepConfigWidget *QMakeStep::createConfigWidget() return new QMakeStepConfigWidget(this); } -bool QMakeStep::immutable() const -{ - return false; -} - void QMakeStep::processStartupFailed() { m_needToRunQMake = true; @@ -555,7 +550,7 @@ bool QMakeStep::fromMap(const QVariantMap &map) //// QMakeStepConfigWidget::QMakeStepConfigWidget(QMakeStep *step) - : BuildStepConfigWidget(), m_ui(new Internal::Ui::QMakeStep), m_step(step) + : BuildStepConfigWidget(step), m_ui(new Internal::Ui::QMakeStep), m_step(step) { m_ui->setupUi(this); @@ -616,21 +611,6 @@ QMakeStepConfigWidget::~QMakeStepConfigWidget() delete m_ui; } -QString QMakeStepConfigWidget::summaryText() const -{ - return m_summaryText; -} - -QString QMakeStepConfigWidget::additionalSummaryText() const -{ - return m_additionalSummaryText; -} - -QString QMakeStepConfigWidget::displayName() const -{ - return m_step->displayName(); -} - void QMakeStepConfigWidget::qtVersionChanged() { updateSummaryLabel(); @@ -843,14 +823,6 @@ void QMakeStepConfigWidget::recompileMessageBoxFinished(int button) } } -void QMakeStepConfigWidget::setSummaryText(const QString &text) -{ - if (text == m_summaryText) - return; - m_summaryText = text; - emit updateSummary(); -} - //// // QMakeStepFactory //// diff --git a/src/plugins/qmakeprojectmanager/qmakestep.h b/src/plugins/qmakeprojectmanager/qmakestep.h index c83f453dae9..09925bdca08 100644 --- a/src/plugins/qmakeprojectmanager/qmakestep.h +++ b/src/plugins/qmakeprojectmanager/qmakestep.h @@ -114,7 +114,6 @@ public: bool init(QList<const BuildStep *> &earlierSteps) override; void run(QFutureInterface<bool> &) override; ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override; - bool immutable() const override; void setForced(bool b); enum class ArgumentFlag { @@ -198,9 +197,7 @@ class QMakeStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget public: QMakeStepConfigWidget(QMakeStep *step); ~QMakeStepConfigWidget() override; - QString summaryText() const override; - QString additionalSummaryText() const override; - QString displayName() const override; + private: // slots for handling buildconfiguration/step signals void qtVersionChanged(); @@ -225,12 +222,8 @@ private: void updateQtQuickCompilerOption(); void updateEffectiveQMakeCall(); - void setSummaryText(const QString &); - Internal::Ui::QMakeStep *m_ui = nullptr; QMakeStep *m_step = nullptr; - QString m_summaryText; - QString m_additionalSummaryText; bool m_ignoreChange = false; }; diff --git a/src/plugins/qnx/qnxdevicefactory.cpp b/src/plugins/qnx/qnxdevicefactory.cpp index 9a44baab09d..ba025df8d16 100644 --- a/src/plugins/qnx/qnxdevicefactory.cpp +++ b/src/plugins/qnx/qnxdevicefactory.cpp @@ -30,68 +30,28 @@ #include "qnxdevice.h" #include <utils/qtcassert.h> -#include <utils/icon.h> - -#include <QIcon> namespace Qnx { namespace Internal { -QnxDeviceFactory::QnxDeviceFactory(QObject *parent) : - ProjectExplorer::IDeviceFactory(parent) -{ -} - -QString QnxDeviceFactory::displayNameForId(Core::Id type) const -{ - QTC_ASSERT(type == Constants::QNX_QNX_OS_TYPE, return QString()); - return tr("QNX Device"); -} - -QList<Core::Id> QnxDeviceFactory::availableCreationIds() const -{ - return {Constants::QNX_QNX_OS_TYPE}; -} - -QIcon QnxDeviceFactory::iconForId(Core::Id type) const +QnxDeviceFactory::QnxDeviceFactory() + : ProjectExplorer::IDeviceFactory(Constants::QNX_QNX_OS_TYPE) { - Q_UNUSED(type) - using namespace Utils; - static const QIcon icon = - Icon::combinedIcon({Icon({{":/qnx/images/qnxdevicesmall.png", - Theme::PanelTextColorDark}}, Icon::Tint), - Icon({{":/qnx/images/qnxdevice.png", - Theme::IconsBaseColor}})}); - return icon; + setDisplayName(tr("QNX Device")); + setCombinedIcon(":/qnx/images/qnxdevicesmall.png", + ":/qnx/images/qnxdevice.png"); + setCanCreate(true); + setConstructionFunction([] { return QnxDevice::create(); }); } -bool QnxDeviceFactory::canCreate() const +ProjectExplorer::IDevice::Ptr QnxDeviceFactory::create() const { - return true; -} - -ProjectExplorer::IDevice::Ptr QnxDeviceFactory::create(Core::Id id) const -{ - Q_UNUSED(id); QnxDeviceWizard wizard; if (wizard.exec() != QDialog::Accepted) return ProjectExplorer::IDevice::Ptr(); return wizard.device(); } -bool QnxDeviceFactory::canRestore(const QVariantMap &map) const -{ - return ProjectExplorer::IDevice::typeFromMap(map) == Constants::QNX_QNX_OS_TYPE; -} - -ProjectExplorer::IDevice::Ptr QnxDeviceFactory::restore(const QVariantMap &map) const -{ - QTC_ASSERT(canRestore(map), return QnxDevice::Ptr()); - const QnxDevice::Ptr device = QnxDevice::create(); - device->fromMap(map); - return device; -} - Core::Id QnxDeviceFactory::deviceType() { return Core::Id(Constants::QNX_QNX_OS_TYPE); diff --git a/src/plugins/qnx/qnxdevicefactory.h b/src/plugins/qnx/qnxdevicefactory.h index a7c06184fb8..9b08ec5efe3 100644 --- a/src/plugins/qnx/qnxdevicefactory.h +++ b/src/plugins/qnx/qnxdevicefactory.h @@ -35,17 +35,9 @@ class QnxDeviceFactory : public ProjectExplorer::IDeviceFactory Q_OBJECT public: - explicit QnxDeviceFactory(QObject *parent = 0); + QnxDeviceFactory(); - QString displayNameForId(Core::Id type) const; - QList<Core::Id> availableCreationIds() const; - QIcon iconForId(Core::Id type) const; - - bool canCreate() const; - ProjectExplorer::IDevice::Ptr create(Core::Id id) const; - - bool canRestore(const QVariantMap &map) const; - ProjectExplorer::IDevice::Ptr restore(const QVariantMap &map) const; + ProjectExplorer::IDevice::Ptr create() const override; static Core::Id deviceType(); }; diff --git a/src/plugins/remotelinux/abstractremotelinuxdeployservice.cpp b/src/plugins/remotelinux/abstractremotelinuxdeployservice.cpp index 4da0fff0fee..6e663bf8172 100644 --- a/src/plugins/remotelinux/abstractremotelinuxdeployservice.cpp +++ b/src/plugins/remotelinux/abstractremotelinuxdeployservice.cpp @@ -96,14 +96,22 @@ SshConnection *AbstractRemoteLinuxDeployService::connection() const return d->connection; } -void AbstractRemoteLinuxDeployService::saveDeploymentTimeStamp(const DeployableFile &deployableFile) +void AbstractRemoteLinuxDeployService::saveDeploymentTimeStamp(const DeployableFile &deployableFile, + const QDateTime &remoteTimestamp) { - d->deployTimes.saveDeploymentTimeStamp(deployableFile, profile()); + d->deployTimes.saveDeploymentTimeStamp(deployableFile, profile(), remoteTimestamp); } -bool AbstractRemoteLinuxDeployService::hasChangedSinceLastDeployment(const DeployableFile &deployableFile) const +bool AbstractRemoteLinuxDeployService::hasLocalFileChanged( + const DeployableFile &deployableFile) const { - return d->deployTimes.hasChangedSinceLastDeployment(deployableFile, profile()); + return d->deployTimes.hasLocalFileChanged(deployableFile, profile()); +} + +bool AbstractRemoteLinuxDeployService::hasRemoteFileChanged( + const DeployableFile &deployableFile, const QDateTime &remoteTimestamp) const +{ + return d->deployTimes.hasRemoteFileChanged(deployableFile, profile(), remoteTimestamp); } void AbstractRemoteLinuxDeployService::setTarget(Target *target) diff --git a/src/plugins/remotelinux/abstractremotelinuxdeployservice.h b/src/plugins/remotelinux/abstractremotelinuxdeployservice.h index 0553472b95c..9e55708d650 100644 --- a/src/plugins/remotelinux/abstractremotelinuxdeployservice.h +++ b/src/plugins/remotelinux/abstractremotelinuxdeployservice.h @@ -76,8 +76,12 @@ protected: ProjectExplorer::IDevice::ConstPtr deviceConfiguration() const; QSsh::SshConnection *connection() const; - void saveDeploymentTimeStamp(const ProjectExplorer::DeployableFile &deployableFile); - bool hasChangedSinceLastDeployment(const ProjectExplorer::DeployableFile &deployableFile) const; + void saveDeploymentTimeStamp(const ProjectExplorer::DeployableFile &deployableFile, + const QDateTime &remoteTimestamp); + + bool hasLocalFileChanged(const ProjectExplorer::DeployableFile &deployableFile) const; + bool hasRemoteFileChanged(const ProjectExplorer::DeployableFile &deployableFile, + const QDateTime &remoteTimestamp) const; void handleDeviceSetupDone(bool success); void handleDeploymentDone(); diff --git a/src/plugins/remotelinux/abstractremotelinuxdeploystep.cpp b/src/plugins/remotelinux/abstractremotelinuxdeploystep.cpp index 71744b57248..5b85f4bde60 100644 --- a/src/plugins/remotelinux/abstractremotelinuxdeploystep.cpp +++ b/src/plugins/remotelinux/abstractremotelinuxdeploystep.cpp @@ -48,6 +48,7 @@ public: AbstractRemoteLinuxDeployStep::AbstractRemoteLinuxDeployStep(BuildStepList *bsl, Core::Id id) : BuildStep(bsl, id), d(new Internal::AbstractRemoteLinuxDeployStepPrivate) { + setRunInGuiThread(true); } AbstractRemoteLinuxDeployStep::~AbstractRemoteLinuxDeployStep() @@ -110,11 +111,6 @@ void AbstractRemoteLinuxDeployStep::cancel() deployService()->stop(); } -BuildStepConfigWidget *AbstractRemoteLinuxDeployStep::createConfigWidget() -{ - return new SimpleBuildStepConfigWidget(this); -} - RemoteLinuxDeployConfiguration *AbstractRemoteLinuxDeployStep::deployConfiguration() const { return qobject_cast<RemoteLinuxDeployConfiguration *>(BuildStep::deployConfiguration()); diff --git a/src/plugins/remotelinux/abstractremotelinuxdeploystep.h b/src/plugins/remotelinux/abstractremotelinuxdeploystep.h index cbd56538642..e9454ef47ff 100644 --- a/src/plugins/remotelinux/abstractremotelinuxdeploystep.h +++ b/src/plugins/remotelinux/abstractremotelinuxdeploystep.h @@ -47,9 +47,7 @@ public: QVariantMap toMap() const override; bool init(QList<const BuildStep *> &earlierSteps) override; void run(QFutureInterface<bool> &fi) override; - bool runInGuiThread() const override { return true; } void cancel() override; - ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override; RemoteLinuxDeployConfiguration *deployConfiguration() const; virtual AbstractRemoteLinuxDeployService *deployService() const = 0; diff --git a/src/plugins/remotelinux/abstractuploadandinstallpackageservice.cpp b/src/plugins/remotelinux/abstractuploadandinstallpackageservice.cpp index 5974a6d5576..16c1e6fc29f 100644 --- a/src/plugins/remotelinux/abstractuploadandinstallpackageservice.cpp +++ b/src/plugins/remotelinux/abstractuploadandinstallpackageservice.cpp @@ -31,6 +31,7 @@ #include <projectexplorer/deployablefile.h> #include <utils/qtcassert.h> +#include <QDateTime> #include <QString> using namespace ProjectExplorer; @@ -87,7 +88,7 @@ QString AbstractUploadAndInstallPackageService::uploadDir() const bool AbstractUploadAndInstallPackageService::isDeploymentNecessary() const { - return hasChangedSinceLastDeployment(DeployableFile(packageFilePath(), QString())); + return hasLocalFileChanged(DeployableFile(packageFilePath(), QString())); } void AbstractUploadAndInstallPackageService::doDeviceSetup() @@ -164,7 +165,7 @@ void AbstractUploadAndInstallPackageService::handleInstallationFinished(const QS QTC_ASSERT(d->state == Installing, return); if (errorMsg.isEmpty()) { - saveDeploymentTimeStamp(DeployableFile(packageFilePath(), QString())); + saveDeploymentTimeStamp(DeployableFile(packageFilePath(), QString()), QDateTime()); emit progressMessage(tr("Package installed.")); } else { emit errorMessage(errorMsg); diff --git a/src/plugins/remotelinux/deploymenttimeinfo.cpp b/src/plugins/remotelinux/deploymenttimeinfo.cpp index fea219769be..31a4c22eefc 100644 --- a/src/plugins/remotelinux/deploymenttimeinfo.cpp +++ b/src/plugins/remotelinux/deploymenttimeinfo.cpp @@ -46,6 +46,8 @@ const char LastDeployedSysrootsKey[] = "ProjectExplorer.RunConfiguration.LastDep const char LastDeployedFilesKey[] = "ProjectExplorer.RunConfiguration.LastDeployedFiles"; const char LastDeployedRemotePathsKey[] = "ProjectExplorer.RunConfiguration.LastDeployedRemotePaths"; const char LastDeployedTimesKey[] = "ProjectExplorer.RunConfiguration.LastDeployedTimes"; +const char LastDeployedLocalTimesKey[] = "RemoteLinux.LastDeployedLocalTimes"; +const char LastDeployedRemoteTimesKey[] = "RemoteLinux.LastDeployedRemoteTimes"; class DeployParameters { @@ -72,7 +74,29 @@ uint qHash(const DeployParameters &p) { class DeploymentTimeInfoPrivate { public: - QHash<DeployParameters, QDateTime> lastDeployed; + struct Timestamps + { + QDateTime local; + QDateTime remote; + }; + QHash<DeployParameters, Timestamps> lastDeployed; + + DeployParameters parameters(const ProjectExplorer::DeployableFile &deployableFile, + const ProjectExplorer::Kit *kit) const + { + QString systemRoot; + QString host; + + if (kit) { + if (SysRootKitInformation::hasSysRoot(kit)) + systemRoot = SysRootKitInformation::sysRoot(kit).toString(); + + const IDevice::ConstPtr deviceConfiguration = DeviceKitInformation::device(kit); + host = deviceConfiguration->sshParameters().host(); + } + + return DeployParameters(deployableFile, host, systemRoot); + } }; @@ -87,42 +111,27 @@ DeploymentTimeInfo::~DeploymentTimeInfo() } void DeploymentTimeInfo::saveDeploymentTimeStamp(const DeployableFile &deployableFile, - const Kit *kit) + const Kit *kit, const QDateTime &remoteTimestamp) { - if (!kit) - return; - - QString systemRoot; - if (SysRootKitInformation::hasSysRoot(kit)) - systemRoot = SysRootKitInformation::sysRoot(kit).toString(); - - const IDevice::ConstPtr deviceConfiguration = DeviceKitInformation::device(kit); - const QString host = deviceConfiguration->sshParameters().host(); - d->lastDeployed.insert( - DeployParameters(deployableFile, host, systemRoot), - QDateTime::currentDateTime()); + d->parameters(deployableFile, kit), + { deployableFile.localFilePath().toFileInfo().lastModified(), remoteTimestamp }); } -bool DeploymentTimeInfo::hasChangedSinceLastDeployment(const DeployableFile &deployableFile, - const ProjectExplorer::Kit *kit) const +bool DeploymentTimeInfo::hasLocalFileChanged(const DeployableFile &deployableFile, + const ProjectExplorer::Kit *kit) const { - if (!kit) - return false; - - QString systemRoot; - if (SysRootKitInformation::hasSysRoot(kit)) - systemRoot = SysRootKitInformation::sysRoot(kit).toString(); - - const IDevice::ConstPtr deviceConfiguration = DeviceKitInformation::device(kit); - const QString host = deviceConfiguration->sshParameters().host(); - - const DeployParameters dp(deployableFile, host, systemRoot); - - const QDateTime &lastDeployed = d->lastDeployed.value(dp); + const auto &lastDeployed = d->lastDeployed.value(d->parameters(deployableFile, kit)); const QDateTime lastModified = deployableFile.localFilePath().toFileInfo().lastModified(); + return !lastDeployed.local.isValid() || lastModified != lastDeployed.local; +} - return !lastDeployed.isValid() || (lastModified > lastDeployed); +bool DeploymentTimeInfo::hasRemoteFileChanged(const DeployableFile &deployableFile, + const ProjectExplorer::Kit *kit, + const QDateTime &remoteTimestamp) const +{ + const auto &lastDeployed = d->lastDeployed.value(d->parameters(deployableFile, kit)); + return !lastDeployed.remote.isValid() || remoteTimestamp != lastDeployed.remote; } QVariantMap DeploymentTimeInfo::exportDeployTimes() const @@ -132,21 +141,24 @@ QVariantMap DeploymentTimeInfo::exportDeployTimes() const QVariantList fileList; QVariantList sysrootList; QVariantList remotePathList; - QVariantList timeList; - typedef QHash<DeployParameters, QDateTime>::ConstIterator DepIt; + QVariantList localTimeList; + QVariantList remoteTimeList; + using DepIt = QHash<DeployParameters, DeploymentTimeInfoPrivate::Timestamps>::ConstIterator; for (DepIt it = d->lastDeployed.constBegin(); it != d->lastDeployed.constEnd(); ++it) { fileList << it.key().file.localFilePath().toString(); remotePathList << it.key().file.remoteDirectory(); hostList << it.key().host; sysrootList << it.key().sysroot; - timeList << it.value(); + localTimeList << it.value().local; + remoteTimeList << it.value().remote; } map.insert(QLatin1String(LastDeployedHostsKey), hostList); map.insert(QLatin1String(LastDeployedSysrootsKey), sysrootList); map.insert(QLatin1String(LastDeployedFilesKey), fileList); map.insert(QLatin1String(LastDeployedRemotePathsKey), remotePathList); - map.insert(QLatin1String(LastDeployedTimesKey), timeList); + map.insert(QLatin1String(LastDeployedLocalTimesKey), localTimeList); + map.insert(QLatin1String(LastDeployedRemoteTimesKey), remoteTimeList); return map; } @@ -157,16 +169,29 @@ void DeploymentTimeInfo::importDeployTimes(const QVariantMap &map) const QVariantList &fileList = map.value(QLatin1String(LastDeployedFilesKey)).toList(); const QVariantList &remotePathList = map.value(QLatin1String(LastDeployedRemotePathsKey)).toList(); - const QVariantList &timeList = map.value(QLatin1String(LastDeployedTimesKey)).toList(); + + QVariantList localTimesList; + const auto localTimes = map.find(QLatin1String(LastDeployedLocalTimesKey)); + if (localTimes != map.end()) { + localTimesList = localTimes.value().toList(); + } else { + localTimesList = map.value(QLatin1String(LastDeployedTimesKey)).toList(); + } + + const QVariantList remoteTimesList + = map.value(QLatin1String(LastDeployedRemoteTimesKey)).toList(); const int elemCount = qMin(qMin(qMin(hostList.size(), fileList.size()), - qMin(remotePathList.size(), timeList.size())), + qMin(remotePathList.size(), localTimesList.size())), sysrootList.size()); for (int i = 0; i < elemCount; ++i) { const DeployableFile df(fileList.at(i).toString(), remotePathList.at(i).toString()); const DeployParameters dp(df, hostList.at(i).toString(), sysrootList.at(i).toString()); - d->lastDeployed.insert(dp, timeList.at(i).toDateTime()); + d->lastDeployed.insert(dp, { localTimesList.at(i).toDateTime(), + remoteTimesList.length() > i + ? remoteTimesList.at(i).toDateTime() + : QDateTime() }); } } diff --git a/src/plugins/remotelinux/deploymenttimeinfo.h b/src/plugins/remotelinux/deploymenttimeinfo.h index b0d14f829d5..3c91be74c7f 100644 --- a/src/plugins/remotelinux/deploymenttimeinfo.h +++ b/src/plugins/remotelinux/deploymenttimeinfo.h @@ -47,10 +47,15 @@ public: QVariantMap exportDeployTimes() const; void saveDeploymentTimeStamp(const ProjectExplorer::DeployableFile &deployableFile, - const ProjectExplorer::Kit *kit); + const ProjectExplorer::Kit *kit, + const QDateTime &remoteTimestamp); - bool hasChangedSinceLastDeployment(const ProjectExplorer::DeployableFile &deployableFile, - const ProjectExplorer::Kit *kit) const; + bool hasLocalFileChanged(const ProjectExplorer::DeployableFile &deployableFile, + const ProjectExplorer::Kit *kit) const; + + bool hasRemoteFileChanged(const ProjectExplorer::DeployableFile &deployableFile, + const ProjectExplorer::Kit *kit, + const QDateTime &remoteTimestamp) const; private: DeploymentTimeInfoPrivate *d; diff --git a/src/plugins/remotelinux/genericdirectuploadservice.cpp b/src/plugins/remotelinux/genericdirectuploadservice.cpp index 9839adccb7f..5f9a8353c0e 100644 --- a/src/plugins/remotelinux/genericdirectuploadservice.cpp +++ b/src/plugins/remotelinux/genericdirectuploadservice.cpp @@ -36,6 +36,8 @@ #include <QFileInfo> #include <QList> #include <QString> +#include <QDateTime> +#include <QHash> using namespace ProjectExplorer; using namespace QSsh; @@ -46,21 +48,45 @@ namespace { enum State { Inactive, InitializingSftp, Uploading }; } // anonymous namespace +enum class JobType { + PreQuery, + Upload, + Mkdir, + Ln, + Chmod, + PostQuery, + None +}; + +struct Job +{ + DeployableFile file; + JobType type; + QDateTime result; + explicit Job(const DeployableFile &file = DeployableFile(), JobType type = JobType::None, + const QDateTime &result = QDateTime()) + : file(file), type(type), result(result) {} +}; + class GenericDirectUploadServicePrivate { public: GenericDirectUploadServicePrivate() - : incremental(false), ignoreMissingFiles(false), stopRequested(false), state(Inactive) {} + : incremental(false), ignoreMissingFiles(false), state(Inactive) {} bool incremental; bool ignoreMissingFiles; - bool stopRequested; + bool uploadJobRunning = false; State state; + QList<DeployableFile> filesToUpload; + + QHash<SftpJobId, Job> runningJobs; + + SshRemoteProcess::Ptr runningProc; + DeployableFile runningProcFile; + SftpChannel::Ptr uploader; - SshRemoteProcess::Ptr mkdirProc; - SshRemoteProcess::Ptr lnProc; - SshRemoteProcess::Ptr chmodProc; QList<DeployableFile> deployableFiles; }; @@ -95,10 +121,14 @@ void GenericDirectUploadService::setIgnoreMissingFiles(bool ignoreMissingFiles) bool GenericDirectUploadService::isDeploymentNecessary() const { - d->filesToUpload.clear(); + QTC_ASSERT(d->filesToUpload.isEmpty(), d->filesToUpload.clear()); + QList<DeployableFile> collected; for (int i = 0; i < d->deployableFiles.count(); ++i) - checkDeploymentNeeded(d->deployableFiles.at(i)); - return !d->filesToUpload.isEmpty(); + collected.append(collectFilesToUpload(d->deployableFiles.at(i))); + + QTC_CHECK(collected.size() >= d->deployableFiles.size()); + d->deployableFiles = collected; + return !d->deployableFiles.isEmpty(); } void GenericDirectUploadService::doDeviceSetup() @@ -131,18 +161,13 @@ void GenericDirectUploadService::doDeploy() void GenericDirectUploadService::handleSftpInitialized() { QTC_ASSERT(d->state == InitializingSftp, setFinished(); return); - - if (d->stopRequested) { - setFinished(); - handleDeploymentDone(); - return; - } - - Q_ASSERT(!d->filesToUpload.isEmpty()); + QTC_ASSERT(!d->deployableFiles.isEmpty(), setFinished(); return); connect(d->uploader.data(), &SftpChannel::finished, - this, &GenericDirectUploadService::handleUploadFinished); + this, &GenericDirectUploadService::handleJobFinished); + connect(d->uploader.data(), &SftpChannel::fileInfoAvailable, + this, &GenericDirectUploadService::handleFileInfoAvailable); d->state = Uploading; - uploadNextFile(); + queryFiles(); } void GenericDirectUploadService::handleSftpChannelError(const QString &message) @@ -154,115 +179,154 @@ void GenericDirectUploadService::handleSftpChannelError(const QString &message) handleDeploymentDone(); } -void GenericDirectUploadService::handleUploadFinished(SftpJobId jobId, const QString &errorMsg) +void GenericDirectUploadService::handleFileInfoAvailable(SftpJobId jobId, + const QList<SftpFileInfo> &fileInfos) { - Q_UNUSED(jobId); - - QTC_ASSERT(d->state == Uploading, setFinished(); return); - - if (d->stopRequested) { - setFinished(); - handleDeploymentDone(); - } + QTC_ASSERT(d->state == Uploading, return); + QTC_ASSERT(fileInfos.length() == 1, return); + auto it = d->runningJobs.find(jobId); + QTC_ASSERT(it != d->runningJobs.end(), return); + it->result = QDateTime::fromTime_t(fileInfos.at(0).mtime); +} - const DeployableFile df = d->filesToUpload.takeFirst(); - if (!errorMsg.isEmpty()) { - QString errorString = tr("Upload of file \"%1\" failed. The server said: \"%2\".") - .arg(df.localFilePath().toUserOutput(), errorMsg); - if (errorMsg == QLatin1String("Failure") - && df.remoteDirectory().contains(QLatin1String("/bin"))) { - errorString += QLatin1Char(' ') + tr("If \"%1\" is currently running " - "on the remote host, you might need to stop it first.").arg(df.remoteFilePath()); +void GenericDirectUploadService::handleJobFinished(SftpJobId jobId, const QString &errorMsg) +{ + auto it = d->runningJobs.find(jobId); + QTC_ASSERT(it != d->runningJobs.end(), return); + + Job job = *it; + d->runningJobs.erase(it); + + switch (job.type) { + case JobType::PreQuery: + if (hasRemoteFileChanged(job.file, job.result)) { + d->filesToUpload.append(job.file); + if (!d->uploadJobRunning) + uploadNextFile(); + } else { + tryFinish(); + } + break; + case JobType::Upload: + QTC_CHECK(d->uploadJobRunning); + + if (!errorMsg.isEmpty()) { + QString errorString = tr("Upload of file \"%1\" failed. The server said: \"%2\".") + .arg(job.file.localFilePath().toUserOutput(), errorMsg); + if (errorMsg == QLatin1String("Failure") + && job.file.remoteDirectory().contains(QLatin1String("/bin"))) { + errorString += QLatin1Char(' ') + + tr("If \"%1\" is currently running on the remote host, " + "you might need to stop it first.").arg(job.file.remoteFilePath()); + } + emit errorMessage(errorString); + setFinished(); + handleDeploymentDone(); } - emit errorMessage(errorString); - setFinished(); - handleDeploymentDone(); - } else { - saveDeploymentTimeStamp(df); // This is done for Windows. - if (df.isExecutable()) { + if (job.file.isExecutable()) { const QString command = QLatin1String("chmod a+x ") - + Utils::QtcProcess::quoteArgUnix(df.remoteFilePath()); - d->chmodProc = connection()->createRemoteProcess(command.toUtf8()); - connect(d->chmodProc.data(), &SshRemoteProcess::closed, - this, &GenericDirectUploadService::handleChmodFinished); - connect(d->chmodProc.data(), &SshRemoteProcess::readyReadStandardOutput, + + Utils::QtcProcess::quoteArgUnix(job.file.remoteFilePath()); + d->runningProc = connection()->createRemoteProcess(command.toUtf8()); + d->runningProcFile = job.file; + connect(d->runningProc.data(), &SshRemoteProcess::closed, + this, &GenericDirectUploadService::handleUploadProcFinished); + connect(d->runningProc.data(), &SshRemoteProcess::readyReadStandardOutput, this, &GenericDirectUploadService::handleStdOutData); - connect(d->chmodProc.data(), &SshRemoteProcess::readyReadStandardError, + connect(d->runningProc.data(), &SshRemoteProcess::readyReadStandardError, this, &GenericDirectUploadService::handleStdErrData); - connect(d->chmodProc.data(), &SshRemoteProcess::readChannelFinished, + connect(d->runningProc.data(), &SshRemoteProcess::readChannelFinished, this, &GenericDirectUploadService::handleReadChannelFinished); - d->chmodProc->start(); + d->runningProc->start(); } else { + d->uploadJobRunning = false; + const SftpJobId jobId = d->uploader->statFile(job.file.remoteFilePath()); + if (jobId == SftpInvalidJob) { + emit errorMessage(tr("SFTP stat query for %1 failed.") + .arg(job.file.remoteFilePath())); + saveDeploymentTimeStamp(job.file, QDateTime()); + } else { + d->runningJobs.insert(jobId, Job(job.file, JobType::PostQuery)); + } uploadNextFile(); } + break; + case JobType::PostQuery: + if (!errorMsg.isEmpty()) { + emit warningMessage(tr("Could not determine remote timestamp of %1: %2") + .arg(job.file.remoteFilePath()).arg(errorMsg)); + } + saveDeploymentTimeStamp(job.file, job.result); + tryFinish(); + break; + default: + QTC_CHECK(false); + break; } } -void GenericDirectUploadService::handleLnFinished(int exitStatus) +void GenericDirectUploadService::clearRunningProc() { - QTC_ASSERT(d->state == Uploading, setFinished(); return); + d->runningProc.clear(); + d->runningProcFile = DeployableFile(); + d->uploadJobRunning = false; +} - if (d->stopRequested) { - setFinished(); - handleDeploymentDone(); - } +void GenericDirectUploadService::handleUploadProcFinished(int exitStatus) +{ + QTC_ASSERT(d->state == Uploading, setFinished(); return); + QTC_ASSERT(d->uploadJobRunning, return); - const DeployableFile df = d->filesToUpload.takeFirst(); - const QString nativePath = df.localFilePath().toUserOutput(); - if (exitStatus != SshRemoteProcess::NormalExit || d->lnProc->exitCode() != 0) { - emit errorMessage(tr("Failed to upload file \"%1\".").arg(nativePath)); - setFinished(); - handleDeploymentDone(); - return; - } else { - saveDeploymentTimeStamp(df); - uploadNextFile(); - } + if (exitStatus != SshRemoteProcess::NormalExit || d->runningProc->exitCode() != 0) + handleProcFailure(); + else + runPostQueryOnProcResult(); } -void GenericDirectUploadService::handleChmodFinished(int exitStatus) +void GenericDirectUploadService::handleProcFailure() { - QTC_ASSERT(d->state == Uploading, setFinished(); return); + emit errorMessage(tr("Failed to upload file \"%1\".") + .arg(d->runningProcFile.localFilePath().toUserOutput())); + clearRunningProc(); + setFinished(); + handleDeploymentDone(); +} - if (d->stopRequested) { - setFinished(); - handleDeploymentDone(); - return; +void GenericDirectUploadService::runPostQueryOnProcResult() +{ + const SftpJobId jobId = d->uploader->statFile(d->runningProcFile.remoteFilePath()); + if (jobId == SftpInvalidJob) { + emit errorMessage(tr("SFTP stat query for %1 failed.") + .arg(d->runningProcFile.remoteFilePath())); + saveDeploymentTimeStamp(d->runningProcFile, QDateTime()); + } else { + d->runningJobs.insert(jobId, Job(d->runningProcFile, JobType::PostQuery)); } + clearRunningProc(); + uploadNextFile(); +} - if (exitStatus != SshRemoteProcess::NormalExit || d->chmodProc->exitCode() != 0) { - emit errorMessage(tr("Failed to set executable flag.")); +void GenericDirectUploadService::tryFinish() +{ + if (d->filesToUpload.isEmpty() && d->runningJobs.isEmpty() && d->runningProc.isNull()) { + emit progressMessage(tr("All files successfully deployed.")); setFinished(); handleDeploymentDone(); - return; } - uploadNextFile(); } void GenericDirectUploadService::handleMkdirFinished(int exitStatus) { QTC_ASSERT(d->state == Uploading, setFinished(); return); - if (d->stopRequested) { - setFinished(); - handleDeploymentDone(); - } - - const DeployableFile &df = d->filesToUpload.first(); - QFileInfo fi = df.localFilePath().toFileInfo(); - const QString nativePath = df.localFilePath().toUserOutput(); - if (exitStatus != SshRemoteProcess::NormalExit || d->mkdirProc->exitCode() != 0) { - emit errorMessage(tr("Failed to upload file \"%1\".").arg(nativePath)); - setFinished(); - handleDeploymentDone(); + QFileInfo fi = d->runningProcFile.localFilePath().toFileInfo(); + if (exitStatus != SshRemoteProcess::NormalExit || d->runningProc->exitCode() != 0) { + handleProcFailure(); } else if (fi.isDir()) { - saveDeploymentTimeStamp(df); - d->filesToUpload.removeFirst(); - uploadNextFile(); + runPostQueryOnProcResult(); } else { - const QString remoteFilePath = df.remoteDirectory() + QLatin1Char('/') + fi.fileName(); + const QString remoteFilePath = d->runningProcFile.remoteFilePath(); if (fi.isSymLink()) { const QString target = fi.dir().relativeFilePath(fi.symLinkTarget()); // see QTBUG-5817. const QStringList args = QStringList() << QLatin1String("ln") << QLatin1String("-sf") @@ -270,31 +334,37 @@ void GenericDirectUploadService::handleMkdirFinished(int exitStatus) const QString command = Utils::QtcProcess::joinArgs(args, Utils::OsTypeLinux); // See comment in SftpChannel::createLink as to why we can't use it. - d->lnProc = connection()->createRemoteProcess(command.toUtf8()); - connect(d->lnProc.data(), &SshRemoteProcess::closed, - this, &GenericDirectUploadService::handleLnFinished); - connect(d->lnProc.data(), &SshRemoteProcess::readyReadStandardOutput, + d->runningProc = connection()->createRemoteProcess(command.toUtf8()); + connect(d->runningProc.data(), &SshRemoteProcess::closed, + this, &GenericDirectUploadService::handleUploadProcFinished); + connect(d->runningProc.data(), &SshRemoteProcess::readyReadStandardOutput, this, &GenericDirectUploadService::handleStdOutData); - connect(d->lnProc.data(), &SshRemoteProcess::readyReadStandardError, + connect(d->runningProc.data(), &SshRemoteProcess::readyReadStandardError, this, &GenericDirectUploadService::handleStdErrData); - connect(d->lnProc.data(), &SshRemoteProcess::readChannelFinished, + connect(d->runningProc.data(), &SshRemoteProcess::readChannelFinished, this, &GenericDirectUploadService::handleReadChannelFinished); - d->lnProc->start(); + d->runningProc->start(); } else { - const SftpJobId job = d->uploader->uploadFile(df.localFilePath().toString(), - remoteFilePath, SftpOverwriteExisting); + const SftpJobId job = d->uploader->uploadFile( + d->runningProcFile.localFilePath().toString(), remoteFilePath, + SftpOverwriteExisting); if (job == SftpInvalidJob) { const QString message = tr("Failed to upload file \"%1\": " - "Could not open for reading.").arg(nativePath); + "Could not open for reading.") + .arg(d->runningProcFile.localFilePath().toUserOutput()); + clearRunningProc(); if (d->ignoreMissingFiles) { emit warningMessage(message); - d->filesToUpload.removeFirst(); uploadNextFile(); } else { emit errorMessage(message); setFinished(); handleDeploymentDone(); } + } else { + d->runningJobs[job] = Job(d->runningProcFile, JobType::Upload); + clearRunningProc(); + d->uploadJobRunning = true; } } } @@ -329,55 +399,55 @@ void GenericDirectUploadService::stopDeployment() handleDeploymentDone(); } -void GenericDirectUploadService::checkDeploymentNeeded(const DeployableFile &deployable) const +QList<DeployableFile> GenericDirectUploadService::collectFilesToUpload( + const DeployableFile &deployable) const { + QList<DeployableFile> collected({deployable}); QFileInfo fileInfo = deployable.localFilePath().toFileInfo(); if (fileInfo.isDir()) { const QStringList files = QDir(deployable.localFilePath().toString()) .entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot); - if (files.isEmpty() && (!d->incremental || hasChangedSinceLastDeployment(deployable))) - d->filesToUpload << deployable; - foreach (const QString &fileName, files) { + for (const QString &fileName : files) { const QString localFilePath = deployable.localFilePath().toString() + QLatin1Char('/') + fileName; const QString remoteDir = deployable.remoteDirectory() + QLatin1Char('/') + fileInfo.fileName(); - checkDeploymentNeeded(DeployableFile(localFilePath, remoteDir)); + collected.append(collectFilesToUpload(DeployableFile(localFilePath, remoteDir))); } - } else if (!d->incremental || hasChangedSinceLastDeployment(deployable)) { - d->filesToUpload << deployable; } + return collected; } void GenericDirectUploadService::setFinished() { - d->stopRequested = false; d->state = Inactive; - if (d->mkdirProc) - disconnect(d->mkdirProc.data(), 0, this, 0); - if (d->lnProc) - disconnect(d->lnProc.data(), 0, this, 0); + if (d->runningProc) + disconnect(d->runningProc.data(), nullptr, this, nullptr); if (d->uploader) { - disconnect(d->uploader.data(), 0, this, 0); + disconnect(d->uploader.data(), nullptr, this, nullptr); d->uploader->closeChannel(); } + clearRunningProc(); + d->uploadJobRunning = false; + d->runningJobs.clear(); + d->filesToUpload.clear(); } void GenericDirectUploadService::uploadNextFile() { + QTC_ASSERT(!d->uploadJobRunning, return); + if (d->filesToUpload.isEmpty()) { - emit progressMessage(tr("All files successfully deployed.")); - setFinished(); - handleDeploymentDone(); + tryFinish(); return; } - const DeployableFile &df = d->filesToUpload.first(); + const DeployableFile df = d->filesToUpload.takeFirst(); + QString dirToCreate = df.remoteDirectory(); if (dirToCreate.isEmpty()) { - emit warningMessage(tr("Warning: No remote path set for local file \"%1\". Skipping upload.") - .arg(df.localFilePath().toUserOutput())); - d->filesToUpload.takeFirst(); + emit warningMessage(tr("Warning: No remote path set for local file \"%1\". " + "Skipping upload.").arg(df.localFilePath().toUserOutput())); uploadNextFile(); return; } @@ -387,18 +457,44 @@ void GenericDirectUploadService::uploadNextFile() dirToCreate += QLatin1Char('/') + fi.fileName(); const QString command = QLatin1String("mkdir -p ") + Utils::QtcProcess::quoteArgUnix(dirToCreate); - d->mkdirProc = connection()->createRemoteProcess(command.toUtf8()); - connect(d->mkdirProc.data(), &SshRemoteProcess::closed, + QTC_CHECK(d->runningProc.isNull()); + d->runningProc = connection()->createRemoteProcess(command.toUtf8()); + connect(d->runningProc.data(), &SshRemoteProcess::closed, this, &GenericDirectUploadService::handleMkdirFinished); - connect(d->mkdirProc.data(), &SshRemoteProcess::readyReadStandardOutput, + connect(d->runningProc.data(), &SshRemoteProcess::readyReadStandardOutput, this, &GenericDirectUploadService::handleStdOutData); - connect(d->mkdirProc.data(), &SshRemoteProcess::readyReadStandardError, + connect(d->runningProc.data(), &SshRemoteProcess::readyReadStandardError, this, &GenericDirectUploadService::handleStdErrData); - connect(d->mkdirProc.data(), &SshRemoteProcess::readChannelFinished, + connect(d->runningProc.data(), &SshRemoteProcess::readChannelFinished, this, &GenericDirectUploadService::handleReadChannelFinished); emit progressMessage(tr("Uploading file \"%1\"...") - .arg(df.localFilePath().toUserOutput())); - d->mkdirProc->start(); + .arg(df.localFilePath().toUserOutput())); + d->runningProcFile = df; + d->runningProc->start(); + d->uploadJobRunning = true; +} + +void GenericDirectUploadService::queryFiles() +{ + QTC_ASSERT(d->state == Uploading, return); + + for (const DeployableFile &file : d->deployableFiles) { + if (!d->incremental || hasLocalFileChanged(file)) { + d->filesToUpload.append(file); + continue; + } + + const SftpJobId jobId = d->uploader->statFile(file.remoteFilePath()); + if (jobId == SftpInvalidJob) { + emit warningMessage(tr("SFTP stat query for %1 failed.").arg(file.remoteFilePath())); + d->filesToUpload.append(file); + continue; + } + + d->runningJobs.insert(jobId, Job(file, JobType::PreQuery)); + } + + uploadNextFile(); } } //namespace RemoteLinux diff --git a/src/plugins/remotelinux/genericdirectuploadservice.h b/src/plugins/remotelinux/genericdirectuploadservice.h index 6659619140f..4f5dbb71b21 100644 --- a/src/plugins/remotelinux/genericdirectuploadservice.h +++ b/src/plugins/remotelinux/genericdirectuploadservice.h @@ -62,17 +62,25 @@ public: private: void handleSftpInitialized(); void handleSftpChannelError(const QString &errorMessage); - void handleUploadFinished(QSsh::SftpJobId jobId, const QString &errorMsg); + void handleFileInfoAvailable(QSsh::SftpJobId jobId, const QList<QSsh::SftpFileInfo> &fileInfos); + void handleJobFinished(QSsh::SftpJobId jobId, const QString &errorMsg); + void handleUploadProcFinished(int exitStatus); void handleMkdirFinished(int exitStatus); - void handleLnFinished(int exitStatus); - void handleChmodFinished(int exitStatus); void handleStdOutData(); void handleStdErrData(); void handleReadChannelFinished(); - void checkDeploymentNeeded(const ProjectExplorer::DeployableFile &file) const; + QList<ProjectExplorer::DeployableFile> collectFilesToUpload( + const ProjectExplorer::DeployableFile &file) const; void setFinished(); void uploadNextFile(); + void queryFiles(); + void clearRunningProc(); + + void handleProcFailure(); + void runPostQueryOnProcResult(); + + void tryFinish(); Internal::GenericDirectUploadServicePrivate * const d; }; diff --git a/src/plugins/remotelinux/genericdirectuploadstep.cpp b/src/plugins/remotelinux/genericdirectuploadstep.cpp index ce03867d064..a3f234685ed 100644 --- a/src/plugins/remotelinux/genericdirectuploadstep.cpp +++ b/src/plugins/remotelinux/genericdirectuploadstep.cpp @@ -79,11 +79,6 @@ bool GenericDirectUploadStep::initInternal(QString *error) return d->deployService.isDeploymentPossible(error); } -BuildStepConfigWidget *GenericDirectUploadStep::createConfigWidget() -{ - return BuildStep::createConfigWidget(); -} - GenericDirectUploadService *GenericDirectUploadStep::deployService() const { return &d->deployService; diff --git a/src/plugins/remotelinux/genericdirectuploadstep.h b/src/plugins/remotelinux/genericdirectuploadstep.h index a17c866a447..5751e833b6a 100644 --- a/src/plugins/remotelinux/genericdirectuploadstep.h +++ b/src/plugins/remotelinux/genericdirectuploadstep.h @@ -40,7 +40,6 @@ public: explicit GenericDirectUploadStep(ProjectExplorer::BuildStepList *bsl); ~GenericDirectUploadStep() override; - ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override; bool initInternal(QString *error = nullptr) override; static Core::Id stepId(); diff --git a/src/plugins/remotelinux/genericlinuxdeviceconfigurationfactory.cpp b/src/plugins/remotelinux/genericlinuxdeviceconfigurationfactory.cpp index 509f6c0ca2d..385b702bae9 100644 --- a/src/plugins/remotelinux/genericlinuxdeviceconfigurationfactory.cpp +++ b/src/plugins/remotelinux/genericlinuxdeviceconfigurationfactory.cpp @@ -33,54 +33,25 @@ #include <utils/qtcassert.h> -#include <QIcon> - using namespace ProjectExplorer; namespace RemoteLinux { -GenericLinuxDeviceConfigurationFactory::GenericLinuxDeviceConfigurationFactory(QObject *parent) - : IDeviceFactory(parent) -{ -} - -QString GenericLinuxDeviceConfigurationFactory::displayNameForId(Core::Id type) const -{ - QTC_ASSERT(type == Constants::GenericLinuxOsType, return QString()); - return tr("Generic Linux Device"); -} - -QList<Core::Id> GenericLinuxDeviceConfigurationFactory::availableCreationIds() const -{ - return QList<Core::Id>() << Core::Id(Constants::GenericLinuxOsType); -} - -QIcon GenericLinuxDeviceConfigurationFactory::iconForId(Core::Id type) const +GenericLinuxDeviceConfigurationFactory::GenericLinuxDeviceConfigurationFactory() + : IDeviceFactory(Constants::GenericLinuxOsType) { - Q_UNUSED(type) - return QIcon(); + setDisplayName(tr("Generic Linux Device")); + setIcon(QIcon()); + setCanCreate(true); + setConstructionFunction([] { return LinuxDevice::create(); }); } -IDevice::Ptr GenericLinuxDeviceConfigurationFactory::create(Core::Id id) const +IDevice::Ptr GenericLinuxDeviceConfigurationFactory::create() const { - QTC_ASSERT(id == Constants::GenericLinuxOsType, return IDevice::Ptr()); GenericLinuxDeviceConfigurationWizard wizard(Core::ICore::mainWindow()); if (wizard.exec() != QDialog::Accepted) return IDevice::Ptr(); return wizard.device(); } -bool GenericLinuxDeviceConfigurationFactory::canRestore(const QVariantMap &map) const -{ - return IDevice::typeFromMap(map) == Constants::GenericLinuxOsType; -} - -IDevice::Ptr GenericLinuxDeviceConfigurationFactory::restore(const QVariantMap &map) const -{ - QTC_ASSERT(canRestore(map), return IDevice::Ptr()); - const IDevice::Ptr device = LinuxDevice::create(); - device->fromMap(map); - return device; -} - } // namespace RemoteLinux diff --git a/src/plugins/remotelinux/genericlinuxdeviceconfigurationfactory.h b/src/plugins/remotelinux/genericlinuxdeviceconfigurationfactory.h index a8fcd486b6b..889840b3375 100644 --- a/src/plugins/remotelinux/genericlinuxdeviceconfigurationfactory.h +++ b/src/plugins/remotelinux/genericlinuxdeviceconfigurationfactory.h @@ -37,15 +37,9 @@ class REMOTELINUX_EXPORT GenericLinuxDeviceConfigurationFactory Q_OBJECT public: - GenericLinuxDeviceConfigurationFactory(QObject *parent = 0); + GenericLinuxDeviceConfigurationFactory(); - QString displayNameForId(Core::Id type) const; - QList<Core::Id> availableCreationIds() const; - QIcon iconForId(Core::Id type) const; - - ProjectExplorer::IDevice::Ptr create(Core::Id id) const; - bool canRestore(const QVariantMap &map) const; - ProjectExplorer::IDevice::Ptr restore(const QVariantMap &map) const; + ProjectExplorer::IDevice::Ptr create() const override; }; } // namespace RemoteLinux diff --git a/src/plugins/remotelinux/linuxdevicetester.cpp b/src/plugins/remotelinux/linuxdevicetester.cpp index c27bafb6a73..dfce1ab2674 100644 --- a/src/plugins/remotelinux/linuxdevicetester.cpp +++ b/src/plugins/remotelinux/linuxdevicetester.cpp @@ -28,6 +28,7 @@ #include <projectexplorer/devicesupport/deviceusedportsgatherer.h> #include <utils/port.h> #include <utils/qtcassert.h> +#include <ssh/sftpchannel.h> #include <ssh/sshremoteprocess.h> #include <ssh/sshconnection.h> @@ -38,7 +39,7 @@ namespace RemoteLinux { namespace Internal { namespace { -enum State { Inactive, Connecting, RunningUname, TestingPorts }; +enum State { Inactive, Connecting, RunningUname, TestingPorts, TestingSftp }; } // anonymous namespace @@ -49,6 +50,7 @@ public: SshConnection *connection = nullptr; SshRemoteProcess::Ptr process; DeviceUsedPortsGatherer portsGatherer; + SftpChannel::Ptr sftpChannel; State state = Inactive; }; @@ -96,6 +98,9 @@ void GenericLinuxDeviceTester::stopTest() case RunningUname: d->process->close(); break; + case TestingSftp: + d->sftpChannel->closeChannel(); + break; case Inactive: break; } @@ -170,9 +175,31 @@ void GenericLinuxDeviceTester::handlePortListReady() emit errorMessage(tr("The following specified ports are currently in use: %1") .arg(portList) + QLatin1Char('\n')); } + + emit progressMessage(tr("Checking if an SFTP channel can be set up...")); + d->sftpChannel = d->connection->createSftpChannel(); + connect(d->sftpChannel.data(), &SftpChannel::initialized, + this, &GenericLinuxDeviceTester::handleSftpInitialized); + connect(d->sftpChannel.data(), &SftpChannel::channelError, + this, &GenericLinuxDeviceTester::handleSftpError); + d->state = TestingSftp; + d->sftpChannel->initialize(); +} + +void GenericLinuxDeviceTester::handleSftpInitialized() +{ + QTC_ASSERT(d->state == TestingSftp, return); + emit progressMessage(tr("SFTP channel successfully initialized.\n")); setFinished(TestSuccess); } +void GenericLinuxDeviceTester::handleSftpError(const QString &message) +{ + QTC_ASSERT(d->state == TestingSftp, return); + emit errorMessage(tr("Error setting up SFTP channel: %1\n").arg(message)); + setFinished(TestFailure); +} + void GenericLinuxDeviceTester::setFinished(TestResult result) { d->state = Inactive; diff --git a/src/plugins/remotelinux/linuxdevicetester.h b/src/plugins/remotelinux/linuxdevicetester.h index 1f7af9ab549..d845c2e26c9 100644 --- a/src/plugins/remotelinux/linuxdevicetester.h +++ b/src/plugins/remotelinux/linuxdevicetester.h @@ -50,7 +50,8 @@ private: void handleProcessFinished(int exitStatus); void handlePortsGatheringError(const QString &message); void handlePortListReady(); - + void handleSftpInitialized(); + void handleSftpError(const QString &message); void setFinished(ProjectExplorer::DeviceTester::TestResult result); Internal::GenericLinuxDeviceTesterPrivate * const d; diff --git a/src/plugins/remotelinux/remotelinux.pro b/src/plugins/remotelinux/remotelinux.pro index 22330c7c10e..69ead7e37d2 100644 --- a/src/plugins/remotelinux/remotelinux.pro +++ b/src/plugins/remotelinux/remotelinux.pro @@ -32,7 +32,6 @@ HEADERS += \ remotelinuxenvironmentreader.h \ sshkeydeployer.h \ typespecificdeviceconfigurationlistmodel.h \ - remotelinuxutils.h \ remotelinuxcustomcommanddeployservice.h \ remotelinuxcustomcommanddeploymentstep.h \ genericlinuxdeviceconfigurationwidget.h \ @@ -74,7 +73,6 @@ SOURCES += \ remotelinuxenvironmentreader.cpp \ sshkeydeployer.cpp \ typespecificdeviceconfigurationlistmodel.cpp \ - remotelinuxutils.cpp \ remotelinuxcustomcommanddeployservice.cpp \ remotelinuxcustomcommanddeploymentstep.cpp \ genericlinuxdeviceconfigurationwidget.cpp \ diff --git a/src/plugins/remotelinux/remotelinux.qbs b/src/plugins/remotelinux/remotelinux.qbs index 375d97c6655..a08c56734e6 100644 --- a/src/plugins/remotelinux/remotelinux.qbs +++ b/src/plugins/remotelinux/remotelinux.qbs @@ -93,8 +93,6 @@ Project { "remotelinuxrunconfiguration.h", "remotelinuxsignaloperation.cpp", "remotelinuxsignaloperation.h", - "remotelinuxutils.cpp", - "remotelinuxutils.h", "sshkeydeployer.cpp", "sshkeydeployer.h", "tarpackagecreationstep.cpp", diff --git a/src/plugins/remotelinux/remotelinuxcheckforfreediskspacestep.cpp b/src/plugins/remotelinux/remotelinuxcheckforfreediskspacestep.cpp index 8361eb3240c..237a85b6c09 100644 --- a/src/plugins/remotelinux/remotelinuxcheckforfreediskspacestep.cpp +++ b/src/plugins/remotelinux/remotelinuxcheckforfreediskspacestep.cpp @@ -43,7 +43,7 @@ class RemoteLinuxCheckForFreeDiskSpaceStepWidget : public BuildStepConfigWidget public: explicit RemoteLinuxCheckForFreeDiskSpaceStepWidget(RemoteLinuxCheckForFreeDiskSpaceStep &step) - : m_step(step) + : BuildStepConfigWidget(&step), m_step(step) { m_ui.setupUi(this); m_ui.requiredSpaceSpinBox->setSuffix(tr("MB")); diff --git a/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.cpp b/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.cpp index 67a623a43c0..de2dc30da4a 100644 --- a/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.cpp +++ b/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.cpp @@ -64,11 +64,6 @@ bool RemoteLinuxCustomCommandDeploymentStep::initInternal(QString *error) return d->service.isDeploymentPossible(error); } -BuildStepConfigWidget *RemoteLinuxCustomCommandDeploymentStep::createConfigWidget() -{ - return BuildStep::createConfigWidget(); -} - AbstractRemoteLinuxDeployService *RemoteLinuxCustomCommandDeploymentStep::deployService() const { return &d->service; diff --git a/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.h b/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.h index 4ba666f8e9c..a8f036f8da5 100644 --- a/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.h +++ b/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.h @@ -44,7 +44,6 @@ public: private: bool initInternal(QString *error) override; AbstractRemoteLinuxDeployService *deployService() const override; - ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override; Internal::RemoteLinuxCustomCommandDeploymentStepPrivate *d; }; diff --git a/src/plugins/remotelinux/remotelinuxkillappstep.cpp b/src/plugins/remotelinux/remotelinuxkillappstep.cpp index 25730602550..c0c1298ad8d 100644 --- a/src/plugins/remotelinux/remotelinuxkillappstep.cpp +++ b/src/plugins/remotelinux/remotelinuxkillappstep.cpp @@ -41,6 +41,7 @@ RemoteLinuxKillAppStep::RemoteLinuxKillAppStep(BuildStepList *bsl, Core::Id id) : AbstractRemoteLinuxDeployStep(bsl, id), m_service(new RemoteLinuxKillAppService(this)) { setDefaultDisplayName(displayName()); + setWidgetExpandedByDefault(false); } bool RemoteLinuxKillAppStep::initInternal(QString *error) diff --git a/src/plugins/remotelinux/tarpackagecreationstep.cpp b/src/plugins/remotelinux/tarpackagecreationstep.cpp index 475a9dfc4e4..d772282aba4 100644 --- a/src/plugins/remotelinux/tarpackagecreationstep.cpp +++ b/src/plugins/remotelinux/tarpackagecreationstep.cpp @@ -38,9 +38,6 @@ #include <QFile> #include <QFileInfo> -#include <QCheckBox> -#include <QVBoxLayout> - #include <cstring> using namespace ProjectExplorer; @@ -50,62 +47,6 @@ namespace { const char IgnoreMissingFilesKey[] = "RemoteLinux.TarPackageCreationStep.IgnoreMissingFiles"; const char IncrementalDeploymentKey[] = "RemoteLinux.TarPackageCreationStep.IncrementalDeployment"; -class CreateTarStepWidget : public SimpleBuildStepConfigWidget -{ - Q_OBJECT -public: - CreateTarStepWidget(TarPackageCreationStep *step) : SimpleBuildStepConfigWidget(step) - { - setShowWidget(true); - - m_ignoreMissingFilesCheckBox.setText(tr("Ignore missing files")); - m_incrementalDeploymentCheckBox.setText(tr("Package modified files only")); - - QVBoxLayout *mainLayout = new QVBoxLayout(this); - mainLayout->setMargin(0); - mainLayout->addWidget(&m_incrementalDeploymentCheckBox); - mainLayout->addWidget(&m_ignoreMissingFilesCheckBox); - - m_ignoreMissingFilesCheckBox.setChecked(step->ignoreMissingFiles()); - m_incrementalDeploymentCheckBox.setChecked(step->isIncrementalDeployment()); - - connect(&m_ignoreMissingFilesCheckBox, &QAbstractButton::toggled, - this, &CreateTarStepWidget::handleIgnoreMissingFilesChanged); - - connect(&m_incrementalDeploymentCheckBox, &QAbstractButton::toggled, - this, &CreateTarStepWidget::handleIncrementalDeploymentChanged); - - connect(step, &AbstractPackagingStep::packageFilePathChanged, - this, &BuildStepConfigWidget::updateSummary); - } - - QString summaryText() const - { - TarPackageCreationStep * const step = static_cast<TarPackageCreationStep *>(this->step()); - if (step->packageFilePath().isEmpty()) { - return QLatin1String("<font color=\"red\">") - + tr("Tarball creation not possible.") + QLatin1String("</font>"); - } - return QLatin1String("<b>") + tr("Create tarball:") + QLatin1String("</b> ") - + step->packageFilePath(); - } - -private: - void handleIgnoreMissingFilesChanged(bool ignoreMissingFiles) { - TarPackageCreationStep *step = qobject_cast<TarPackageCreationStep *>(this->step()); - step->setIgnoreMissingFiles(ignoreMissingFiles); - } - - void handleIncrementalDeploymentChanged(bool incrementalDeployment) { - TarPackageCreationStep *step = qobject_cast<TarPackageCreationStep *>(this->step()); - step->setIncrementalDeployment(incrementalDeployment); - } - - QCheckBox m_ignoreMissingFilesCheckBox; - QCheckBox m_incrementalDeploymentCheckBox; -}; - - const int TarBlockSize = 512; struct TarFileHeader { char fileName[100]; @@ -133,6 +74,14 @@ TarPackageCreationStep::TarPackageCreationStep(BuildStepList *bsl) : AbstractPackagingStep(bsl, stepId()) { setDefaultDisplayName(displayName()); + + m_ignoreMissingFilesAspect = addAspect<BaseBoolAspect>(); + m_ignoreMissingFilesAspect->setLabel(tr("Ignore missing files")); + m_ignoreMissingFilesAspect->setSettingsKey(IgnoreMissingFilesKey); + + m_incrementalDeploymentAspect = addAspect<BaseBoolAspect>(); + m_incrementalDeploymentAspect->setLabel(tr("Package modified files only")); + m_incrementalDeploymentAspect->setSettingsKey(IncrementalDeploymentKey); } bool TarPackageCreationStep::init(QList<const BuildStep *> &earlierSteps) @@ -151,7 +100,7 @@ void TarPackageCreationStep::run(QFutureInterface<bool> &fi) const QList<DeployableFile> &files = target()->deploymentData().allFiles(); - if (m_incrementalDeployment) { + if (m_incrementalDeploymentAspect->value()) { m_files.clear(); for (const DeployableFile &file : files) addNeededDeploymentFiles(file, target()->kit()); @@ -173,33 +122,13 @@ void TarPackageCreationStep::run(QFutureInterface<bool> &fi) reportRunResult(fi, success); } -void TarPackageCreationStep::setIgnoreMissingFiles(bool ignoreMissingFiles) -{ - m_ignoreMissingFiles = ignoreMissingFiles; -} - -bool TarPackageCreationStep::ignoreMissingFiles() const -{ - return m_ignoreMissingFiles; -} - -void TarPackageCreationStep::setIncrementalDeployment(bool incrementalDeployment) -{ - m_incrementalDeployment = incrementalDeployment; -} - -bool TarPackageCreationStep::isIncrementalDeployment() const -{ - return m_incrementalDeployment; -} - void TarPackageCreationStep::addNeededDeploymentFiles( const ProjectExplorer::DeployableFile &deployable, const ProjectExplorer::Kit *kit) { const QFileInfo fileInfo = deployable.localFilePath().toFileInfo(); if (!fileInfo.isDir()) { - if (m_deployTimes.hasChangedSinceLastDeployment(deployable, kit)) + if (m_deployTimes.hasLocalFileChanged(deployable, kit)) m_files << deployable; return; } @@ -284,7 +213,7 @@ bool TarPackageCreationStep::appendFile(QFile &tarFile, const QFileInfo &fileInf if (!file.open(QIODevice::ReadOnly)) { const QString message = tr("Error reading file \"%1\": %2.") .arg(nativePath, file.errorString()); - if (m_ignoreMissingFiles) { + if (m_ignoreMissingFilesAspect->value()) { raiseWarning(message); return true; } else { @@ -402,7 +331,7 @@ void TarPackageCreationStep::deployFinished(bool success) // Store files that have been tar'd and successfully deployed const auto files = m_files; for (const DeployableFile &file : files) - m_deployTimes.saveDeploymentTimeStamp(file, kit); + m_deployTimes.saveDeploymentTimeStamp(file, kit, QDateTime()); } QString TarPackageCreationStep::packageFileName() const @@ -412,15 +341,31 @@ QString TarPackageCreationStep::packageFileName() const BuildStepConfigWidget *TarPackageCreationStep::createConfigWidget() { - return new CreateTarStepWidget(this); + auto widget = BuildStep::createConfigWidget(); + + auto updateSummary = [this, widget] { + QString path = packageFilePath(); + if (path.isEmpty()) { + widget->setSummaryText("<font color=\"red\">" + + tr("Tarball creation not possible.") + + "</font>"); + } else { + widget->setSummaryText("<b>" + tr("Create tarball:") + "</b> " + path); + } + }; + + connect(this, &AbstractPackagingStep::packageFilePathChanged, + this, updateSummary); + + updateSummary(); + + return widget; } bool TarPackageCreationStep::fromMap(const QVariantMap &map) { if (!AbstractPackagingStep::fromMap(map)) return false; - setIgnoreMissingFiles(map.value(QLatin1String(IgnoreMissingFilesKey), false).toBool()); - setIncrementalDeployment(map.value(QLatin1String(IncrementalDeploymentKey), false).toBool()); m_deployTimes.importDeployTimes(map); return true; } @@ -428,8 +373,6 @@ bool TarPackageCreationStep::fromMap(const QVariantMap &map) QVariantMap TarPackageCreationStep::toMap() const { QVariantMap map = AbstractPackagingStep::toMap(); - map.insert(QLatin1String(IgnoreMissingFilesKey), ignoreMissingFiles()); - map.insert(QLatin1String(IncrementalDeploymentKey), m_incrementalDeployment); map.unite(m_deployTimes.exportDeployTimes()); return map; } @@ -445,5 +388,3 @@ QString TarPackageCreationStep::displayName() } } // namespace RemoteLinux - -#include "tarpackagecreationstep.moc" diff --git a/src/plugins/remotelinux/tarpackagecreationstep.h b/src/plugins/remotelinux/tarpackagecreationstep.h index 70f21b714dd..0c9568fbae9 100644 --- a/src/plugins/remotelinux/tarpackagecreationstep.h +++ b/src/plugins/remotelinux/tarpackagecreationstep.h @@ -30,6 +30,7 @@ #include "remotelinux_export.h" #include <projectexplorer/deployablefile.h> +#include <projectexplorer/projectconfigurationaspects.h> QT_BEGIN_NAMESPACE class QFile; @@ -76,8 +77,8 @@ private: DeploymentTimeInfo m_deployTimes; - bool m_incrementalDeployment = false; - bool m_ignoreMissingFiles = false; + ProjectExplorer::BaseBoolAspect *m_incrementalDeploymentAspect = nullptr; + ProjectExplorer::BaseBoolAspect *m_ignoreMissingFilesAspect = nullptr; bool m_packagingNeeded = false; QList<ProjectExplorer::DeployableFile> m_files; }; diff --git a/src/plugins/remotelinux/uploadandinstalltarpackagestep.cpp b/src/plugins/remotelinux/uploadandinstalltarpackagestep.cpp index a2b00a3f490..8d163e3a1f4 100644 --- a/src/plugins/remotelinux/uploadandinstalltarpackagestep.cpp +++ b/src/plugins/remotelinux/uploadandinstalltarpackagestep.cpp @@ -66,6 +66,7 @@ UploadAndInstallTarPackageStep::UploadAndInstallTarPackageStep(BuildStepList *bs { m_deployService = new UploadAndInstallTarPackageService(this); setDefaultDisplayName(displayName()); + setWidgetExpandedByDefault(false); } bool UploadAndInstallTarPackageStep::initInternal(QString *error) @@ -81,11 +82,6 @@ bool UploadAndInstallTarPackageStep::initInternal(QString *error) return m_deployService->isDeploymentPossible(error); } -BuildStepConfigWidget *UploadAndInstallTarPackageStep::createConfigWidget() -{ - return new SimpleBuildStepConfigWidget(this); -} - Core::Id UploadAndInstallTarPackageStep::stepId() { return "MaemoUploadAndInstallTarPackageStep"; diff --git a/src/plugins/remotelinux/uploadandinstalltarpackagestep.h b/src/plugins/remotelinux/uploadandinstalltarpackagestep.h index edcdeff9cd6..ec891b1e5d7 100644 --- a/src/plugins/remotelinux/uploadandinstalltarpackagestep.h +++ b/src/plugins/remotelinux/uploadandinstalltarpackagestep.h @@ -57,8 +57,6 @@ public: bool initInternal(QString *error = 0) override; - ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override; - static Core::Id stepId(); static QString displayName(); diff --git a/src/plugins/valgrind/callgrind/callgrindparsedata.cpp b/src/plugins/valgrind/callgrind/callgrindparsedata.cpp index cc4af9804d7..0568ee79ac8 100644 --- a/src/plugins/valgrind/callgrind/callgrindparsedata.cpp +++ b/src/plugins/valgrind/callgrind/callgrindparsedata.cpp @@ -45,12 +45,7 @@ class ParseData::Private { Q_DECLARE_TR_FUNCTIONS(Valgrind::Callgrind::ParseData) public: Private(ParseData *q) - : m_pid(0) - , m_lineNumberPositionIndex(-1) - , m_part(0) - , m_version(0) - , m_cycleCacheValid(false) - , m_q(q) + : m_q(q) { } @@ -61,11 +56,11 @@ public: QVector<quint64> m_totalCosts; QVector<const Function *> m_functions; QString m_command; - quint64 m_pid; - int m_lineNumberPositionIndex; - uint m_part; - int m_version; - bool m_cycleCacheValid; + quint64 m_pid = 0; + int m_lineNumberPositionIndex = -1; + uint m_part = 0; + int m_version = 0; + bool m_cycleCacheValid = false; QStringList m_descriptions; QString m_creator; diff --git a/src/plugins/valgrind/callgrind/callgrindparser.cpp b/src/plugins/valgrind/callgrind/callgrindparser.cpp index 41254c3ec43..23b378ca6e8 100644 --- a/src/plugins/valgrind/callgrind/callgrindparser.cpp +++ b/src/plugins/valgrind/callgrind/callgrindparser.cpp @@ -139,16 +139,7 @@ class Parser::Private public: explicit Private(Parser *qq) - : q(qq), - addressValuesCount(0), - costValuesCount(0), - data(0), - currentFunction(0), - lastObject(-1), - lastFile(-1), - currentDifferingFile(-1), - isParsingFunctionCall(false), - callsCount(0) + : q(qq) { } @@ -174,30 +165,22 @@ public: void parseCalledSourceFile(const char *begin, const char *end); void parseCalledObjectFile(const char *begin, const char *end); - int addressValuesCount; - int costValuesCount; + int addressValuesCount = 0; + int costValuesCount = 0; - ParseData *data; - Function *currentFunction; - qint64 lastObject; - qint64 lastFile; - qint64 currentDifferingFile; + ParseData *data = nullptr; + Function *currentFunction = nullptr; + qint64 lastObject = -1; + qint64 lastFile = -1; + qint64 currentDifferingFile = -1; - bool isParsingFunctionCall; - quint64 callsCount; + bool isParsingFunctionCall = false; + quint64 callsCount = 0; struct CallData { - CallData() - : calledFunction(-1) - , calledObject(-1) - , calledFile(-1) - , call(0) - { - } - - qint64 calledFunction; - qint64 calledObject; - qint64 calledFile; - FunctionCall *call; + qint64 calledFunction = -1; + qint64 calledObject = -1; + qint64 calledFile = -1; + FunctionCall *call = nullptr; }; CallData currentCallData; QVector<quint64> callDestinations; @@ -217,7 +200,7 @@ void Parser::Private::parse(QIODevice *device) // be sure to clean up existing data before re-allocating // the callee might not have taken the parse data delete data; - data = 0; + data = nullptr; data = new ParseData; parseHeader(device); diff --git a/src/plugins/winrt/winrt.pro b/src/plugins/winrt/winrt.pro index 48a7bf69f52..15b4a3bb983 100644 --- a/src/plugins/winrt/winrt.pro +++ b/src/plugins/winrt/winrt.pro @@ -7,7 +7,6 @@ HEADERS += \ winrtdevice.h \ winrtdevicefactory.h \ winrtpackagedeploymentstep.h \ - winrtpackagedeploymentstepwidget.h \ winrtphoneqtversion.h \ winrtplugin.h \ winrtqtversion.h \ @@ -22,7 +21,6 @@ SOURCES += \ winrtdevice.cpp \ winrtdevicefactory.cpp \ winrtpackagedeploymentstep.cpp \ - winrtpackagedeploymentstepwidget.cpp \ winrtphoneqtversion.cpp \ winrtplugin.cpp \ winrtqtversion.cpp \ @@ -33,8 +31,5 @@ SOURCES += \ DEFINES += WINRT_LIBRARY -FORMS += \ - winrtpackagedeploymentstepwidget.ui - RESOURCES += \ winrt.qrc diff --git a/src/plugins/winrt/winrt.qbs b/src/plugins/winrt/winrt.qbs index 2c072e4b5f0..9053161c5c8 100644 --- a/src/plugins/winrt/winrt.qbs +++ b/src/plugins/winrt/winrt.qbs @@ -23,9 +23,6 @@ QtcPlugin { "winrtdevicefactory.h", "winrtpackagedeploymentstep.cpp", "winrtpackagedeploymentstep.h", - "winrtpackagedeploymentstepwidget.cpp", - "winrtpackagedeploymentstepwidget.h", - "winrtpackagedeploymentstepwidget.ui", "winrtphoneqtversion.cpp", "winrtphoneqtversion.h", "winrtplugin.cpp", diff --git a/src/plugins/winrt/winrtconstants.h b/src/plugins/winrt/winrtconstants.h index d185a0df26a..03a6fbd36a0 100644 --- a/src/plugins/winrt/winrtconstants.h +++ b/src/plugins/winrt/winrtconstants.h @@ -33,7 +33,6 @@ const char WINRT_DEVICE_TYPE_LOCAL[] = "WinRt.Device.Local"; const char WINRT_DEVICE_TYPE_EMULATOR[] = "WinRt.Device.Emulator"; const char WINRT_DEVICE_TYPE_PHONE[] = "WinRt.Device.Phone"; const char WINRT_BUILD_STEP_DEPLOY[] = "WinRt.BuildStep.Deploy"; -const char WINRT_BUILD_STEP_DEPLOY_ARGUMENTS[] = "WinRt.BuildStep.Deploy.Arguments"; const char WINRT_WINRTQT[] = "WinRt.QtVersion.WindowsRuntime"; const char WINRT_WINPHONEQT[] = "WinRt.QtVersion.WindowsPhone"; const char WINRT_QTMAP_SUBKEYNAME[] = "WinRt"; diff --git a/src/plugins/winrt/winrtdevicefactory.cpp b/src/plugins/winrt/winrtdevicefactory.cpp index 34681ecf483..5686d0c8ed3 100644 --- a/src/plugins/winrt/winrtdevicefactory.cpp +++ b/src/plugins/winrt/winrtdevicefactory.cpp @@ -32,10 +32,9 @@ #include <coreplugin/messagemanager.h> #include <projectexplorer/devicesupport/devicemanager.h> #include <qtsupport/qtversionmanager.h> -#include <utils/icon.h> + #include <utils/qtcassert.h> -#include <QIcon> #include <QFileInfo> using Core::MessageManager; @@ -47,7 +46,8 @@ using QtSupport::QtVersionManager; namespace WinRt { namespace Internal { -WinRtDeviceFactory::WinRtDeviceFactory() +WinRtDeviceFactory::WinRtDeviceFactory(Core::Id deviceType) + : ProjectExplorer::IDeviceFactory(deviceType) { if (allPrerequisitesLoaded()) { onPrerequisitesLoaded(); @@ -58,47 +58,10 @@ WinRtDeviceFactory::WinRtDeviceFactory() &QtVersionManager::qtVersionsLoaded, this, &WinRtDeviceFactory::onPrerequisitesLoaded, Qt::QueuedConnection); } -} - -QString WinRtDeviceFactory::displayNameForId(Core::Id type) const -{ - return WinRtDevice::displayNameForType(type); -} - -QList<Core::Id> WinRtDeviceFactory::availableCreationIds() const -{ - return QList<Core::Id>() << Constants::WINRT_DEVICE_TYPE_LOCAL - << Constants::WINRT_DEVICE_TYPE_PHONE - << Constants::WINRT_DEVICE_TYPE_EMULATOR; -} - -QIcon WinRtDeviceFactory::iconForId(Core::Id type) const -{ - Q_UNUSED(type) - using namespace Utils; - return Icon::combinedIcon({Icon({{":/winrt/images/winrtdevicesmall.png", - Theme::PanelTextColorDark}}, Icon::Tint), - Icon({{":/winrt/images/winrtdevice.png", - Theme::IconsBaseColor}})}); -} - -IDevice::Ptr WinRtDeviceFactory::create(Core::Id id) const -{ - Q_UNUSED(id); - QTC_CHECK(false); - return IDevice::Ptr(); -} - -bool WinRtDeviceFactory::canRestore(const QVariantMap &map) const -{ - return availableCreationIds().contains(IDevice::typeFromMap(map)); -} - -IDevice::Ptr WinRtDeviceFactory::restore(const QVariantMap &map) const -{ - const IDevice::Ptr device(new WinRtDevice); - device->fromMap(map); - return device; + setDisplayName(WinRtDevice::displayNameForType(deviceType)); + setConstructionFunction([] { return IDevice::Ptr(new WinRtDevice); }); + setCombinedIcon(":/winrt/images/winrtdevicesmall.png", + ":/winrt/images/winrtdevice.png"); } void WinRtDeviceFactory::autoDetect() diff --git a/src/plugins/winrt/winrtdevicefactory.h b/src/plugins/winrt/winrtdevicefactory.h index 0eac4acdff4..32a42a65c45 100644 --- a/src/plugins/winrt/winrtdevicefactory.h +++ b/src/plugins/winrt/winrtdevicefactory.h @@ -35,14 +35,7 @@ class WinRtDeviceFactory : public ProjectExplorer::IDeviceFactory { Q_OBJECT public: - WinRtDeviceFactory(); - QString displayNameForId(Core::Id type) const; - QList<Core::Id> availableCreationIds() const; - QIcon iconForId(Core::Id type) const; - bool canCreate() const { return false; } - ProjectExplorer::IDevice::Ptr create(Core::Id id) const; - bool canRestore(const QVariantMap &map) const; - ProjectExplorer::IDevice::Ptr restore(const QVariantMap &map) const; + explicit WinRtDeviceFactory(Core::Id deviceType); void autoDetect(); void onPrerequisitesLoaded(); diff --git a/src/plugins/winrt/winrtpackagedeploymentstep.cpp b/src/plugins/winrt/winrtpackagedeploymentstep.cpp index 177d114caba..d6a6f10f1f8 100644 --- a/src/plugins/winrt/winrtpackagedeploymentstep.cpp +++ b/src/plugins/winrt/winrtpackagedeploymentstep.cpp @@ -26,7 +26,6 @@ #include "winrtpackagedeploymentstep.h" #include "winrtconstants.h" -#include "winrtpackagedeploymentstepwidget.h" #include <projectexplorer/project.h> #include <projectexplorer/target.h> @@ -40,9 +39,10 @@ #include <qtsupport/qtkitinformation.h> #include <utils/qtcassert.h> -#include <utils/qtcprocess.h> +#include <QLayout> #include <QRegularExpression> +#include <QToolButton> using namespace ProjectExplorer; using Utils::QtcProcess; @@ -54,7 +54,12 @@ WinRtPackageDeploymentStep::WinRtPackageDeploymentStep(BuildStepList *bsl) : AbstractProcessStep(bsl, Constants::WINRT_BUILD_STEP_DEPLOY) { setDisplayName(tr("Run windeployqt")); - m_args = defaultWinDeployQtArguments(); + + m_argsAspect = addAspect<BaseStringAspect>(); + m_argsAspect->setDisplayStyle(BaseStringAspect::LineEditDisplay); + m_argsAspect->setSettingsKey("WinRt.BuildStep.Deploy.Arguments"); + m_argsAspect->setValue(defaultWinDeployQtArguments()); + m_argsAspect->setLabelText(tr("Arguments:")); } bool WinRtPackageDeploymentStep::init(QList<const BuildStep *> &earlierSteps) @@ -85,7 +90,7 @@ bool WinRtPackageDeploymentStep::init(QList<const BuildStep *> &earlierSteps) return false; QString args = QtcProcess::quoteArg(QDir::toNativeSeparators(m_targetFilePath)); - args += QLatin1Char(' ') + m_args; + args += ' ' + m_argsAspect->value(); if (qt->type() == QLatin1String(Constants::WINRT_WINPHONEQT)) { m_createMappingFile = true; @@ -216,17 +221,19 @@ void WinRtPackageDeploymentStep::stdOutput(const QString &line) BuildStepConfigWidget *WinRtPackageDeploymentStep::createConfigWidget() { - return new WinRtPackageDeploymentStepWidget(this); -} + auto widget = AbstractProcessStep::createConfigWidget(); -void WinRtPackageDeploymentStep::setWinDeployQtArguments(const QString &args) -{ - m_args = args; -} + auto restoreDefaultButton = new QToolButton(widget); + restoreDefaultButton->setText(tr("Restore Default Arguments")); + connect(restoreDefaultButton, &QToolButton::clicked, this, [this] { + m_argsAspect->setValue(defaultWinDeployQtArguments()); + }); -QString WinRtPackageDeploymentStep::winDeployQtArguments() const -{ - return m_args; + // Smuggle in the extra button. We know that there's exactly one aspect. + QTC_ASSERT(widget->layout()->count() == 2, return widget); + widget->layout()->itemAt(1)->layout()->addWidget(restoreDefaultButton); + + return widget; } QString WinRtPackageDeploymentStep::defaultWinDeployQtArguments() const @@ -253,23 +260,6 @@ void WinRtPackageDeploymentStep::raiseWarning(const QString &warningMessage) emit addOutput(warningMessage, BuildStep::OutputFormat::NormalMessage); } -bool WinRtPackageDeploymentStep::fromMap(const QVariantMap &map) -{ - if (!AbstractProcessStep::fromMap(map)) - return false; - QVariant v = map.value(QLatin1String(Constants::WINRT_BUILD_STEP_DEPLOY_ARGUMENTS)); - if (v.isValid()) - m_args = v.toString(); - return true; -} - -QVariantMap WinRtPackageDeploymentStep::toMap() const -{ - QVariantMap map = AbstractProcessStep::toMap(); - map.insert(QLatin1String(Constants::WINRT_BUILD_STEP_DEPLOY_ARGUMENTS), m_args); - return map; -} - bool WinRtPackageDeploymentStep::parseIconsAndExecutableFromManifest(QString manifestFileName, QStringList *icons, QString *executable) { if (!icons->isEmpty()) diff --git a/src/plugins/winrt/winrtpackagedeploymentstep.h b/src/plugins/winrt/winrtpackagedeploymentstep.h index 55d6d01203e..e7e41442513 100644 --- a/src/plugins/winrt/winrtpackagedeploymentstep.h +++ b/src/plugins/winrt/winrtpackagedeploymentstep.h @@ -26,6 +26,7 @@ #pragma once #include <projectexplorer/abstractprocessstep.h> +#include <projectexplorer/projectconfigurationaspects.h> namespace WinRt { namespace Internal { @@ -43,20 +44,15 @@ public: void stdOutput(const QString &line) override; ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override; - void setWinDeployQtArguments(const QString &args); - QString winDeployQtArguments() const; QString defaultWinDeployQtArguments() const; void raiseError(const QString &errorMessage); void raiseWarning(const QString &warningMessage); - bool fromMap(const QVariantMap &map) override; - QVariantMap toMap() const override; - private: bool parseIconsAndExecutableFromManifest(QString manifestFileName, QStringList *items, QString *executable); - QString m_args; + ProjectExplorer::BaseStringAspect *m_argsAspect = nullptr; QString m_targetFilePath; QString m_targetDirPath; QString m_executablePathInManifest; diff --git a/src/plugins/winrt/winrtpackagedeploymentstepwidget.cpp b/src/plugins/winrt/winrtpackagedeploymentstepwidget.cpp deleted file mode 100644 index c7198717b5d..00000000000 --- a/src/plugins/winrt/winrtpackagedeploymentstepwidget.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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 "winrtpackagedeploymentstepwidget.h" -#include <ui_winrtpackagedeploymentstepwidget.h> -#include <utils/utilsicons.h> -#include <QIcon> - -namespace WinRt { -namespace Internal { - -WinRtPackageDeploymentStepWidget::WinRtPackageDeploymentStepWidget(WinRtPackageDeploymentStep *step) - : m_ui(new Ui::WinRtPackageDeploymentStepWidget) - , m_step(step) -{ - m_ui->setupUi(this); - m_ui->leArguments->setText(m_step->winDeployQtArguments()); - m_ui->btnRestoreDefaultArgs->setIcon(Utils::Icons::RESET.icon()); - connect(m_ui->btnRestoreDefaultArgs, &QToolButton::pressed, - this, &WinRtPackageDeploymentStepWidget::restoreDefaultArguments); - connect(m_ui->leArguments, &QLineEdit::textChanged, - m_step, &WinRtPackageDeploymentStep::setWinDeployQtArguments); -} - -WinRtPackageDeploymentStepWidget::~WinRtPackageDeploymentStepWidget() -{ - delete m_ui; -} - -QString WinRtPackageDeploymentStepWidget::summaryText() const -{ - return displayName(); -} - -QString WinRtPackageDeploymentStepWidget::displayName() const -{ - return m_step->displayName(); -} - -void WinRtPackageDeploymentStepWidget::restoreDefaultArguments() -{ - m_ui->leArguments->setText(m_step->defaultWinDeployQtArguments()); -} - -} // namespace Internal -} // namespace WinRt diff --git a/src/plugins/winrt/winrtpackagedeploymentstepwidget.ui b/src/plugins/winrt/winrtpackagedeploymentstepwidget.ui deleted file mode 100644 index e3ce32adfc2..00000000000 --- a/src/plugins/winrt/winrtpackagedeploymentstepwidget.ui +++ /dev/null @@ -1,47 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>WinRt::Internal::WinRtPackageDeploymentStepWidget</class> - <widget class="QWidget" name="WinRt::Internal::WinRtPackageDeploymentStepWidget"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>400</width> - <height>59</height> - </rect> - </property> - <layout class="QHBoxLayout" name="horizontalLayout"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Arguments:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="leArguments"/> - </item> - <item> - <widget class="QToolButton" name="btnRestoreDefaultArgs"> - <property name="text"> - <string>Restore Default Arguments</string> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/plugins/winrt/winrtplugin.cpp b/src/plugins/winrt/winrtplugin.cpp index aafed07e301..e2156b6d82c 100644 --- a/src/plugins/winrt/winrtplugin.cpp +++ b/src/plugins/winrt/winrtplugin.cpp @@ -52,7 +52,9 @@ public: WinRtPhoneDeployConfigurationFactory phoneDeployConfigFactory; WinRtEmulatorDeployConfigurationFactory emulatorDeployFactory; WinRtDeployStepFactory deployStepFactory; - WinRtDeviceFactory deviceFactory; + WinRtDeviceFactory localDeviceFactory{Constants::WINRT_DEVICE_TYPE_LOCAL}; + WinRtDeviceFactory phoneDeviceFactory{Constants::WINRT_DEVICE_TYPE_PHONE}; + WinRtDeviceFactory emulatorDeviceFactory{Constants::WINRT_DEVICE_TYPE_EMULATOR}; }; WinRtPlugin::WinRtPlugin() |