diff --git a/src/plugins/baremetal/baremetalcustomrunconfiguration.cpp b/src/plugins/baremetal/baremetalcustomrunconfiguration.cpp index 3d7cca4d374..1239c9045b0 100644 --- a/src/plugins/baremetal/baremetalcustomrunconfiguration.cpp +++ b/src/plugins/baremetal/baremetalcustomrunconfiguration.cpp @@ -44,7 +44,7 @@ BareMetalCustomRunConfiguration::BareMetalCustomRunConfiguration(Target *target, auto exeAspect = addAspect(); exeAspect->setSettingsKey("BareMetal.CustomRunConfig.Executable"); exeAspect->setPlaceHolderText(tr("Unknown")); - exeAspect->setDisplayStyle(BaseStringAspect::LineEditDisplay); + exeAspect->setDisplayStyle(BaseStringAspect::PathChooserDisplay); exeAspect->setHistoryCompleter("BareMetal.CustomRunConfig.History"); exeAspect->setExpectedKind(PathChooser::Any); diff --git a/src/plugins/bazaar/annotationhighlighter.h b/src/plugins/bazaar/annotationhighlighter.h index bd89f0fc399..442f3defa93 100644 --- a/src/plugins/bazaar/annotationhighlighter.h +++ b/src/plugins/bazaar/annotationhighlighter.h @@ -38,7 +38,7 @@ public: QTextDocument *document = nullptr); private: - QString changeNumber(const QString &block) const; + QString changeNumber(const QString &block) const override; mutable QRegExp m_changeset; }; diff --git a/src/plugins/bazaar/bazaarclient.cpp b/src/plugins/bazaar/bazaarclient.cpp index d8d13cd27a5..f9941b29660 100644 --- a/src/plugins/bazaar/bazaarclient.cpp +++ b/src/plugins/bazaar/bazaarclient.cpp @@ -60,7 +60,7 @@ public: settings.boolPointer(BazaarSettings::diffIgnoreBlankLinesKey)); } - QStringList arguments() const + QStringList arguments() const override { QStringList args; // Bazaar wants "--diff-options=-w -B.." diff --git a/src/plugins/bazaar/bazaarclient.h b/src/plugins/bazaar/bazaarclient.h index aa18bcc8a31..21750daf223 100644 --- a/src/plugins/bazaar/bazaarclient.h +++ b/src/plugins/bazaar/bazaarclient.h @@ -48,22 +48,22 @@ public: const QString& revision = QString(), const QStringList &extraOptions = QStringList()); void commit(const QString &repositoryRoot, const QStringList &files, - const QString &commitMessageFile, const QStringList &extraOptions = QStringList()); + const QString &commitMessageFile, const QStringList &extraOptions = QStringList()) override; VcsBase::VcsBaseEditorWidget *annotate( const QString &workingDir, const QString &file, const QString &revision = QString(), - int lineNumber = -1, const QStringList &extraOptions = QStringList()); + int lineNumber = -1, const QStringList &extraOptions = QStringList()) override; bool isVcsDirectory(const Utils::FileName &fileName) const; - QString findTopLevelForFile(const QFileInfo &file) const; + QString findTopLevelForFile(const QFileInfo &file) const override; bool managesFile(const QString &workingDirectory, const QString &fileName) const; void view(const QString &source, const QString &id, - const QStringList &extraOptions = QStringList()); + const QStringList &extraOptions = QStringList()) override; protected: - Core::Id vcsEditorKind(VcsCommandTag cmd) const; - QString vcsCommandString(VcsCommandTag cmd) const; - Utils::ExitCodeInterpreter exitCodeInterpreter(VcsCommandTag cmd) const; - QStringList revisionSpec(const QString &revision) const; - StatusItem parseStatusLine(const QString &line) const; + Core::Id vcsEditorKind(VcsCommandTag cmd) const override; + QString vcsCommandString(VcsCommandTag cmd) const override; + Utils::ExitCodeInterpreter exitCodeInterpreter(VcsCommandTag cmd) const override; + QStringList revisionSpec(const QString &revision) const override; + StatusItem parseStatusLine(const QString &line) const override; private: friend class CloneWizard; diff --git a/src/plugins/bazaar/bazaarcommitwidget.cpp b/src/plugins/bazaar/bazaarcommitwidget.cpp index ad426d5f54e..23861568cea 100644 --- a/src/plugins/bazaar/bazaarcommitwidget.cpp +++ b/src/plugins/bazaar/bazaarcommitwidget.cpp @@ -57,7 +57,7 @@ class BazaarSubmitHighlighter : QSyntaxHighlighter { public: explicit BazaarSubmitHighlighter(QTextEdit *parent); - void highlightBlock(const QString &text); + void highlightBlock(const QString &text) override; private: enum State { Header, Comment, Other }; diff --git a/src/plugins/bazaar/bazaarcontrol.h b/src/plugins/bazaar/bazaarcontrol.h index 020e15d37bb..ced12c9a795 100644 --- a/src/plugins/bazaar/bazaarcontrol.h +++ b/src/plugins/bazaar/bazaarcontrol.h @@ -50,7 +50,7 @@ public: bool isVcsFileOrDirectory(const Utils::FileName &fileName) const final; - bool managesDirectory(const QString &filename, QString *topLevel = 0) const final; + bool managesDirectory(const QString &filename, QString *topLevel = nullptr) const final; bool managesFile(const QString &workingDirectory, const QString &fileName) const final; bool isConfigured() const final; bool supportsOperation(Operation operation) const final; diff --git a/src/plugins/bazaar/bazaarplugin.cpp b/src/plugins/bazaar/bazaarplugin.cpp index 707ad88c2ee..8048fa739f7 100644 --- a/src/plugins/bazaar/bazaarplugin.cpp +++ b/src/plugins/bazaar/bazaarplugin.cpp @@ -129,7 +129,7 @@ const VcsBaseSubmitEditorParameters submitEditorParameters = { }; -BazaarPlugin *BazaarPlugin::m_instance = 0; +BazaarPlugin *BazaarPlugin::m_instance = nullptr; BazaarPlugin::BazaarPlugin() { @@ -139,8 +139,8 @@ BazaarPlugin::BazaarPlugin() BazaarPlugin::~BazaarPlugin() { delete m_client; - m_client = 0; - m_instance = 0; + m_client = nullptr; + m_instance = nullptr; } bool BazaarPlugin::initialize(const QStringList &arguments, QString *errorMessage) @@ -526,7 +526,7 @@ void BazaarPlugin::showCommitWidget(const QList &stat return; } - CommitEditor *commitEditor = qobject_cast(editor); + auto commitEditor = qobject_cast(editor); if (!commitEditor) { VcsOutputWindow::appendError(tr("Unable to create a commit editor.")); @@ -630,7 +630,7 @@ void BazaarPlugin::uncommit() bool BazaarPlugin::submitEditorAboutToClose() { - CommitEditor *commitEditor = qobject_cast(submitEditor()); + auto commitEditor = qobject_cast(submitEditor()); QTC_ASSERT(commitEditor, return true); IDocument *editorDocument = commitEditor->document(); QTC_ASSERT(editorDocument, return true); diff --git a/src/plugins/bazaar/bazaarplugin.h b/src/plugins/bazaar/bazaarplugin.h index 54184f5598f..51d2d921b1d 100644 --- a/src/plugins/bazaar/bazaarplugin.h +++ b/src/plugins/bazaar/bazaarplugin.h @@ -58,15 +58,15 @@ class BazaarPlugin : public VcsBase::VcsBasePlugin public: BazaarPlugin(); - ~BazaarPlugin(); - bool initialize(const QStringList &arguments, QString *errorMessage); + ~BazaarPlugin() override; + bool initialize(const QStringList &arguments, QString *errorMessage) override; static BazaarPlugin *instance(); BazaarClient *client() const; protected: - void updateActions(VcsBase::VcsBasePlugin::ActionState); - bool submitEditorAboutToClose(); + void updateActions(VcsBase::VcsBasePlugin::ActionState) override; + bool submitEditorAboutToClose() override; #ifdef WITH_TESTS private slots: diff --git a/src/plugins/bazaar/constants.h b/src/plugins/bazaar/constants.h index fad825097e5..f64c0eb27f7 100644 --- a/src/plugins/bazaar/constants.h +++ b/src/plugins/bazaar/constants.h @@ -25,6 +25,8 @@ #pragma once +#include + namespace Bazaar { namespace Constants { diff --git a/src/plugins/bazaar/optionspage.h b/src/plugins/bazaar/optionspage.h index 6d981e8df2f..8a2cd5010f4 100644 --- a/src/plugins/bazaar/optionspage.h +++ b/src/plugins/bazaar/optionspage.h @@ -39,10 +39,10 @@ class OptionsPageWidget : public VcsBase::VcsClientOptionsPageWidget Q_OBJECT public: - explicit OptionsPageWidget(QWidget *parent = 0); + explicit OptionsPageWidget(QWidget *parent = nullptr); - VcsBase::VcsBaseClientSettings settings() const; - void setSettings(const VcsBase::VcsBaseClientSettings &s); + VcsBase::VcsBaseClientSettings settings() const override; + void setSettings(const VcsBase::VcsBaseClientSettings &s) override; private: Ui::OptionsPage m_ui; diff --git a/src/plugins/bazaar/pullorpushdialog.h b/src/plugins/bazaar/pullorpushdialog.h index 380139c2d39..508a14d14db 100644 --- a/src/plugins/bazaar/pullorpushdialog.h +++ b/src/plugins/bazaar/pullorpushdialog.h @@ -42,7 +42,7 @@ public: PushMode }; - explicit PullOrPushDialog(Mode mode, QWidget *parent = 0); + explicit PullOrPushDialog(Mode mode, QWidget *parent = nullptr); ~PullOrPushDialog() override; // Common parameters and options diff --git a/src/plugins/bazaar/uncommitdialog.h b/src/plugins/bazaar/uncommitdialog.h index f8c23f9e128..e535b996b0b 100644 --- a/src/plugins/bazaar/uncommitdialog.h +++ b/src/plugins/bazaar/uncommitdialog.h @@ -37,7 +37,7 @@ class UnCommitDialog : public QDialog Q_OBJECT public: - explicit UnCommitDialog(QWidget *parent = 0); + explicit UnCommitDialog(QWidget *parent = nullptr); ~UnCommitDialog() override; QStringList extraOptions() const; diff --git a/src/plugins/clangcodemodel/clangassistproposalitem.h b/src/plugins/clangcodemodel/clangassistproposalitem.h index c524c9b21d0..c02f4e77b90 100644 --- a/src/plugins/clangcodemodel/clangassistproposalitem.h +++ b/src/plugins/clangcodemodel/clangassistproposalitem.h @@ -38,7 +38,7 @@ class ClangAssistProposalItem final : public TextEditor::AssistProposalItemInter { friend bool operator<(const ClangAssistProposalItem &first, const ClangAssistProposalItem &second); public: - ~ClangAssistProposalItem() Q_DECL_NOEXCEPT {} + ~ClangAssistProposalItem() noexcept {} bool prematurelyApplies(const QChar &typedCharacter) const final; bool implicitlyApplies() const final; void apply(TextEditor::TextDocumentManipulatorInterface &manipulator, int basePosition) const final; diff --git a/src/plugins/clangcodemodel/clangpreprocessorassistproposalitem.h b/src/plugins/clangcodemodel/clangpreprocessorassistproposalitem.h index 8498c8514f1..9e93b964f48 100644 --- a/src/plugins/clangcodemodel/clangpreprocessorassistproposalitem.h +++ b/src/plugins/clangcodemodel/clangpreprocessorassistproposalitem.h @@ -35,7 +35,7 @@ namespace ClangCodeModel { class ClangPreprocessorAssistProposalItem final : public TextEditor::AssistProposalItemInterface { public: - ~ClangPreprocessorAssistProposalItem() Q_DECL_NOEXCEPT {} + ~ClangPreprocessorAssistProposalItem() noexcept {} bool prematurelyApplies(const QChar &typedChar) const final; virtual bool implicitlyApplies() const final; void apply(TextEditor::TextDocumentManipulatorInterface &manipulator, diff --git a/src/plugins/clangcodemodel/clangutils.cpp b/src/plugins/clangcodemodel/clangutils.cpp index fcafbff7ef9..2ba1f44c2a1 100644 --- a/src/plugins/clangcodemodel/clangutils.cpp +++ b/src/plugins/clangcodemodel/clangutils.cpp @@ -330,11 +330,13 @@ static QJsonObject createFileObject(CompilerOptionsBuilder &optionsBuilder, const ProjectFile &projFile, const ::Utils::FileName &buildDir) { - optionsBuilder.updateLanguageOption(ProjectFile::classify(projFile.path)); + const ProjectFile::Kind kind = ProjectFile::classify(projFile.path); + optionsBuilder.updateLanguageOption(kind); QJsonObject fileObject; fileObject["file"] = projFile.path; QJsonArray args = QJsonArray::fromStringList(optionsBuilder.options()); + args.prepend(kind == ProjectFile::CXXSource ? "clang++" : "clang"); args.append(QDir::toNativeSeparators(projFile.path)); fileObject["arguments"] = args; fileObject["directory"] = buildDir.toString(); diff --git a/src/plugins/clangformat/clangformat_dependencies.pri b/src/plugins/clangformat/clangformat_dependencies.pri index 81bfc0ddeb8..5f3f81e1328 100644 --- a/src/plugins/clangformat/clangformat_dependencies.pri +++ b/src/plugins/clangformat/clangformat_dependencies.pri @@ -4,4 +4,5 @@ QTC_LIB_DEPENDS += \ utils QTC_PLUGIN_DEPENDS += \ cpptools \ + projectexplorer \ texteditor diff --git a/src/plugins/clearcase/clearcasecontrol.h b/src/plugins/clearcase/clearcasecontrol.h index 07648d4836c..757ea344866 100644 --- a/src/plugins/clearcase/clearcasecontrol.h +++ b/src/plugins/clearcase/clearcasecontrol.h @@ -44,7 +44,7 @@ public: bool isVcsFileOrDirectory(const Utils::FileName &fileName) const final; - bool managesDirectory(const QString &directory, QString *topLevel = 0) const final; + bool managesDirectory(const QString &directory, QString *topLevel = nullptr) const final; bool managesFile(const QString &workingDirectory, const QString &fileName) const final; bool isConfigured() const final; diff --git a/src/plugins/clearcase/clearcaseplugin.cpp b/src/plugins/clearcase/clearcaseplugin.cpp index 5feacbdd2e3..7a7df8abe7d 100644 --- a/src/plugins/clearcase/clearcaseplugin.cpp +++ b/src/plugins/clearcase/clearcaseplugin.cpp @@ -141,8 +141,9 @@ static const VcsBaseEditorParameters editorParameters[] = { // Utility to find a parameter set by type static const VcsBaseEditorParameters *findType(int ie) { - const EditorContentType et = static_cast(ie); - return VcsBaseEditor::findType(editorParameters, sizeof(editorParameters)/sizeof(VcsBaseEditorParameters), et); + return VcsBaseEditor::findType(editorParameters, + sizeof(editorParameters)/sizeof(*editorParameters), + static_cast(ie)); } static QString debugCodec(const QTextCodec *c) @@ -151,7 +152,7 @@ static QString debugCodec(const QTextCodec *c) } // ------------- ClearCasePlugin -ClearCasePlugin *ClearCasePlugin::m_clearcasePluginInstance = 0; +ClearCasePlugin *ClearCasePlugin::m_clearcasePluginInstance = nullptr; ClearCasePlugin::ClearCasePlugin() : m_activityMutex(new QMutex), @@ -576,7 +577,7 @@ bool ClearCasePlugin::submitEditorAboutToClose() if (!isCheckInEditorOpen()) return true; - ClearCaseSubmitEditor *editor = qobject_cast(submitEditor()); + auto editor = qobject_cast(submitEditor()); QTC_ASSERT(editor, return true); IDocument *editorDocument = editor->document(); QTC_ASSERT(editorDocument, return true); @@ -640,7 +641,7 @@ void ClearCasePlugin::diffCheckInFiles(const QStringList &files) static void setWorkingDirectory(IEditor *editor, const QString &wd) { - if (VcsBaseEditorWidget *ve = qobject_cast(editor->widget())) + if (auto ve = qobject_cast(editor->widget())) ve->setWorkingDirectory(wd); } @@ -726,8 +727,8 @@ ClearCaseSubmitEditor *ClearCasePlugin::openClearCaseSubmitEditor(const QString { IEditor *editor = EditorManager::openEditor(fileName, Constants::CLEARCASECHECKINEDITOR_ID); - ClearCaseSubmitEditor *submitEditor = qobject_cast(editor); - QTC_ASSERT(submitEditor, return 0); + auto submitEditor = qobject_cast(editor); + QTC_ASSERT(submitEditor, return nullptr); connect(submitEditor, &VcsBaseSubmitEditor::diffSelectedFiles, this, &ClearCasePlugin::diffCheckInFiles); submitEditor->setCheckScriptWorkingDirectory(m_checkInView); @@ -979,7 +980,8 @@ void ClearCasePlugin::ccDiffWithPred(const QString &workingDir, const QStringLis if (Constants::debug) qDebug() << Q_FUNC_INFO << files; const QString source = VcsBaseEditor::getSource(workingDir, files); - QTextCodec *codec = source.isEmpty() ? static_cast(0) : VcsBaseEditor::getCodec(source); + QTextCodec *codec = source.isEmpty() ? static_cast(nullptr) + : VcsBaseEditor::getCodec(source); if ((m_settings.diffType == GraphicalDiff) && (files.count() == 1)) { const QString file = files.first(); @@ -1022,7 +1024,7 @@ void ClearCasePlugin::ccDiffWithPred(const QString &workingDir, const QStringLis IEditor *editor = showOutputInEditor(title, result, DiffOutput, source, codec); setWorkingDirectory(editor, workingDir); VcsBaseEditor::tagEditor(editor, tag); - ClearCaseEditorWidget *diffEditorWidget = qobject_cast(editor->widget()); + auto diffEditorWidget = qobject_cast(editor->widget()); QTC_ASSERT(diffEditorWidget, return); if (files.count() == 1) editor->setProperty("originalFileName", diffname); @@ -1114,7 +1116,7 @@ void ClearCasePlugin::diffActivity() } m_diffPrefix.clear(); const QString title = QString::fromLatin1("%1.patch").arg(activity); - IEditor *editor = showOutputInEditor(title, result, DiffOutput, activity, 0); + IEditor *editor = showOutputInEditor(title, result, DiffOutput, activity, nullptr); setWorkingDirectory(editor, topLevel); } @@ -1469,16 +1471,16 @@ IEditor *ClearCasePlugin::showOutputInEditor(const QString& title, const QString QTextCodec *codec) const { const VcsBaseEditorParameters *params = findType(editorType); - QTC_ASSERT(params, return 0); + QTC_ASSERT(params, return nullptr); const Id id = params->id; if (Constants::debug) qDebug() << "ClearCasePlugin::showOutputInEditor" << title << id.name() << "Size= " << output.size() << " Type=" << editorType << debugCodec(codec); QString s = title; IEditor *editor = EditorManager::openEditorWithContents(id, &s, output.toUtf8()); - ClearCaseEditorWidget *e = qobject_cast(editor->widget()); + auto e = qobject_cast(editor->widget()); if (!e) - return 0; + return nullptr; connect(e, &VcsBaseEditorWidget::annotateRevisionRequested, this, &ClearCasePlugin::vcsAnnotate); e->setForceReadOnly(true); s.replace(QLatin1Char(' '), QLatin1Char('_')); @@ -1696,7 +1698,7 @@ bool ClearCasePlugin::ccFileOp(const QString &workingDir, const QString &title, { const QString file = QDir::toNativeSeparators(fileName); bool noCheckout = false; - ActivitySelector *actSelector = 0; + ActivitySelector *actSelector = nullptr; QDialog fileOpDlg; fileOpDlg.setWindowTitle(title); @@ -2167,7 +2169,7 @@ void ClearCasePlugin::closing() { // prevent syncSlot from being called on shutdown ProgressManager::cancelTasks(ClearCase::Constants::TASK_INDEX); - disconnect(qApp, &QApplication::applicationStateChanged, 0, 0); + disconnect(qApp, &QApplication::applicationStateChanged, nullptr, nullptr); } void ClearCasePlugin::sync(QFutureInterface &future, QStringList files) @@ -2302,8 +2304,7 @@ class TestCase { public: TestCase(const QString &fileName) : - m_fileName(fileName) , - m_editor(0) + m_fileName(fileName) { ClearCasePlugin::instance()->setFakeCleartool(true); VcsManager::clearVersionControlCache(); @@ -2372,7 +2373,7 @@ void ClearCasePlugin::testStatusActions() m_viewData = testCase.dummyViewData(); QFETCH(int, status); - FileStatus::Status tempStatus = static_cast(status); + auto tempStatus = static_cast(status); // special case: file should appear as "Unknown" since there is no entry in the index // and we don't want to explicitly set the status for this test case diff --git a/src/plugins/clearcase/clearcaseplugin.h b/src/plugins/clearcase/clearcaseplugin.h index 08312077b11..2aae2748be7 100644 --- a/src/plugins/clearcase/clearcaseplugin.h +++ b/src/plugins/clearcase/clearcaseplugin.h @@ -66,8 +66,7 @@ class ClearCaseControl; class ClearCaseResponse { public: - ClearCaseResponse() : error(false) {} - bool error; + bool error = false; QString stdOut; QString stdErr; QString message; @@ -89,7 +88,7 @@ public: QFile::Permissions permissions; - FileStatus(Status _status = Unknown, QFile::Permissions perm = 0) + FileStatus(Status _status = Unknown, QFile::Permissions perm = nullptr) : status(_status), permissions(perm) { } }; @@ -133,13 +132,13 @@ public: bool vcsUndoHijack(const QString &workingDir, const QString &fileName, bool keep); bool vcsMove(const QString &workingDir, const QString &from, const QString &to); bool vcsSetActivity(const QString &workingDir, const QString &title, const QString &activity); - bool managesDirectory(const QString &directory, QString *topLevel = 0) const; + bool managesDirectory(const QString &directory, QString *topLevel = nullptr) const; bool vcsCheckout(const QString &directory, const QByteArray &url); static ClearCasePlugin *instance(); QString ccGetCurrentActivity() const; - QList activities(int *current = 0) const; + QList activities(int *current = nullptr) const; QString ccGetPredecessor(const QString &version) const; QStringList ccGetActiveVobs() const; ViewData ccGetView(const QString &workingDir) const; @@ -228,7 +227,8 @@ private: QTextCodec *codec) const; QString runCleartoolSync(const QString &workingDir, const QStringList &arguments) const; ClearCaseResponse runCleartool(const QString &workingDir, const QStringList &arguments, - int timeOutS, unsigned flags, QTextCodec *outputCodec = 0) const; + int timeOutS, unsigned flags, + QTextCodec *outputCodec = nullptr) const; static void sync(QFutureInterface &future, QStringList files); void history(const QString &workingDir, @@ -247,7 +247,7 @@ private: QString getFile(const QString &nativeFile, const QString &prefix); static void rmdir(const QString &path); QString runExtDiff(const QString &workingDir, const QStringList &arguments, int timeOutS, - QTextCodec *outputCodec = 0); + QTextCodec *outputCodec = nullptr); static QString getDriveLetterOfPath(const QString &directory); FileStatus::Status getFileStatus(const QString &fileName) const; diff --git a/src/plugins/clearcase/clearcasesubmiteditorwidget.h b/src/plugins/clearcase/clearcasesubmiteditorwidget.h index 55c9749aae1..7fe8ebd2fce 100644 --- a/src/plugins/clearcase/clearcasesubmiteditorwidget.h +++ b/src/plugins/clearcase/clearcasesubmiteditorwidget.h @@ -54,7 +54,7 @@ public: void addActivitySelector(bool isUcm); protected: - QString commitName() const; + QString commitName() const override; private: ActivitySelector *m_actSelector = nullptr; diff --git a/src/plugins/compilationdatabaseprojectmanager/CompilationDatabaseProjectManager.json.in b/src/plugins/compilationdatabaseprojectmanager/CompilationDatabaseProjectManager.json.in new file mode 100644 index 00000000000..00da891d743 --- /dev/null +++ b/src/plugins/compilationdatabaseprojectmanager/CompilationDatabaseProjectManager.json.in @@ -0,0 +1,30 @@ +{ + \"Name\" : \"CompilationDatabaseProjectManager\", + \"Version\" : \"$$QTCREATOR_VERSION\", + \"CompatVersion\" : \"$$QTCREATOR_COMPAT_VERSION\", + \"Experimental\" : true, + \"Vendor\" : \"The Qt Company Ltd\", + \"Copyright\" : \"(C) $$QTCREATOR_COPYRIGHT_YEAR The Qt Company Ltd\", + \"License\" : [ \"Commercial Usage\", + \"\", + \"Licensees holding valid Qt Commercial licenses may use this plugin in accordance with the Qt 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.\", + \"\", + \"GNU General Public License Usage\", + \"\", + \"Alternatively, this plugin 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 plugin. 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.\" + ], + \"Category\" : \"Build Systems\", + \"Description\" : \"Compilation Database project support.\", + \"Url\" : \"http://www.qt.io\", + $$dependencyList, + \"Mimetypes\" : [ + \"\", + \"\", + \" \", + \" \", + \" Compilation Database file\", + \" \", + \" \", + \"\" + ] +} diff --git a/src/plugins/compilationdatabaseprojectmanager/compilationdatabaseconstants.h b/src/plugins/compilationdatabaseprojectmanager/compilationdatabaseconstants.h new file mode 100644 index 00000000000..1cb47d5dfd2 --- /dev/null +++ b/src/plugins/compilationdatabaseprojectmanager/compilationdatabaseconstants.h @@ -0,0 +1,35 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +namespace CompilationDatabaseProjectManager { +namespace Constants { + +const char COMPILATIONDATABASEMIMETYPE[] = "text/x-compilation-database-project"; +const char COMPILATIONDATABASEPROJECT_ID[] = "CompilationDatabase.CompilationDatabaseEditor"; + +} // Constants +} // CompilationDatabaseProjectManager diff --git a/src/plugins/compilationdatabaseprojectmanager/compilationdatabaseproject.cpp b/src/plugins/compilationdatabaseprojectmanager/compilationdatabaseproject.cpp new file mode 100644 index 00000000000..487652aeb94 --- /dev/null +++ b/src/plugins/compilationdatabaseprojectmanager/compilationdatabaseproject.cpp @@ -0,0 +1,295 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "compilationdatabaseproject.h" + +#include "compilationdatabaseconstants.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +namespace CompilationDatabaseProjectManager { +namespace Internal { + +class DBProjectNode : public ProjectExplorer::ProjectNode +{ +public: + explicit DBProjectNode(const Utils::FileName &projectFilePath) + : ProjectExplorer::ProjectNode(projectFilePath) + {} +}; + +static QStringList splitCommandLine(const QString &line) +{ + QStringList result; + bool insideQuotes = false; + + for (const QString &part : line.split(QRegularExpression("\""))) { + if (insideQuotes) { + const QString quotedPart = "\"" + part + "\""; + if (result.last().endsWith("=")) + result.last().append(quotedPart); + else + result.append(quotedPart); + } else { // If 's' is outside quotes ... + result.append(part.split(QRegularExpression("\\s+"), QString::SkipEmptyParts)); + } + insideQuotes = !insideQuotes; + } + return result; +} + +static QString updatedPathFlag(const QString &pathStr, const QString &workingDir, + const QString &originalFlag) +{ + QString result = pathStr; + if (!QDir(pathStr).exists() + && QDir(workingDir + "/" + pathStr).exists()) { + result = workingDir + "/" + pathStr; + } + + if (originalFlag.startsWith("-I")) + return "-I" + result; + + if (originalFlag.startsWith("-isystem")) + return "-isystem" + result; + + return result; +} + +static QStringList filteredFlags(const QStringList &flags, const QString &fileName, + const QString &workingDir) +{ + QStringList filtered; + // Skip compiler call if present. + bool skipNext = !flags.first().startsWith('-'); + bool includePath = false; + + for (const QString &flag : flags) { + if (skipNext) { + skipNext = false; + continue; + } + + QString pathStr; + if (includePath) { + includePath = false; + pathStr = flag; + } else if ((flag.startsWith("-I") || flag.startsWith("-isystem")) + && flag != "-I" && flag != "-isystem") { + pathStr = flag.mid(flag.startsWith("-I") ? 2 : 8); + } + + if (!pathStr.isEmpty()) { + filtered.push_back(updatedPathFlag(pathStr, workingDir, flag)); + continue; + } + + if (flag == "-c" || flag == "-pedantic" || flag.startsWith("/") || flag.startsWith("-m") + || flag.startsWith("-O") || flag.startsWith("-W") || flag.startsWith("-w") + || flag.startsWith("--sysroot=")) { + continue; + } + + if (flag == "-target" || flag == "-triple" || flag == "-isysroot" || flag == "-isystem" + || flag == "--sysroot") { + skipNext = true; + continue; + } + + if (flag.endsWith(fileName)) + continue; + + if (flag == "-I" || flag == "-isystem") + includePath = true; + + filtered.push_back(flag); + } + + return filtered; +} + +static CppTools::RawProjectPart makeRawProjectPart(const Utils::FileName &projectFile, + const QJsonObject &object) +{ + const Utils::FileName fileName = Utils::FileName::fromString( + QDir::fromNativeSeparators(object["file"].toString())); + QStringList flags; + const QJsonArray arguments = object["arguments"].toArray(); + if (arguments.isEmpty()) { + flags = splitCommandLine(object["command"].toString()); + } else { + for (const QJsonValue &arg : arguments) + flags.append(arg.toString()); + } + + const QString workingDir = object["directory"].toString(); + flags = filteredFlags(flags, fileName.fileName(), workingDir); + + CppTools::RawProjectPart rpp; + rpp.setProjectFileLocation(projectFile.toString()); + rpp.setBuildSystemTarget(workingDir); + rpp.setDisplayName(fileName.fileName()); + rpp.setFiles({fileName.toString()}); + + CppTools::RawProjectPartFlags cxxProjectFlags; + cxxProjectFlags.commandLineFlags = flags; + rpp.setFlagsForCxx(cxxProjectFlags); + + return rpp; +} + +CompilationDatabaseProject::CompilationDatabaseProject(const Utils::FileName &projectFile) + : Project(Constants::COMPILATIONDATABASEMIMETYPE, projectFile) + , m_cppCodeModelUpdater(std::make_unique(this)) +{ + setId(Constants::COMPILATIONDATABASEPROJECT_ID); + setProjectLanguages(Core::Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID)); + setDisplayName(projectDirectory().fileName()); + + connect(this, &Project::activeTargetChanged, [this, projectFile](ProjectExplorer::Target *target) { + if (!target) + return; + + ProjectExplorer::Kit *kit = target->kit(); + if (!kit) + return; + + auto toolchains = ProjectExplorer::ToolChainKitInformation::toolChains(kit); + if (toolchains.isEmpty()) + return; + + emitParsingStarted(); + + const QFuture future = ::Utils::runAsync([this, projectFile, kit, + tc = toolchains.first()](){ + QFile file(projectFilePath().toString()); + if (!file.open(QIODevice::ReadOnly)) { + emitParsingFinished(false); + return; + } + + const QJsonArray array = QJsonDocument::fromJson(file.readAll()).array(); + + auto root = std::make_unique(projectDirectory()); + root->addNode(std::make_unique( + projectFile, + ProjectExplorer::FileType::Project, + false)); + auto headers = std::make_unique( + Utils::FileName::fromString("Headers"), 0); + auto sources = std::make_unique( + Utils::FileName::fromString("Sources"), 0); + CppTools::RawProjectParts rpps; + for (const QJsonValue &element : array) { + const QJsonObject object = element.toObject(); + const QString filePath = object["file"].toString(); + const CppTools::ProjectFile::Kind kind = CppTools::ProjectFile::classify(filePath); + ProjectExplorer::FolderNode *parent = nullptr; + ProjectExplorer::FileType type = ProjectExplorer::FileType::Unknown; + if (CppTools::ProjectFile::isHeader(kind)) { + parent = headers.get(); + type = ProjectExplorer::FileType::Header; + } else if (CppTools::ProjectFile::isSource(kind)) { + parent = sources.get(); + type = ProjectExplorer::FileType::Source; + } else { + parent = root.get(); + } + parent->addNode(std::make_unique( + Utils::FileName::fromString(filePath), type, false)); + + rpps.append(makeRawProjectPart(projectFile, object)); + } + + root->addNode(std::move(headers)); + root->addNode(std::move(sources)); + + setRootProjectNode(std::move(root)); + + CppTools::ToolChainInfo tcInfo; + tcInfo.type = ProjectExplorer::Constants::COMPILATION_DATABASE_TOOLCHAIN_TYPEID; + tcInfo.isMsvc2015ToolChain + = tc->targetAbi().osFlavor() == ProjectExplorer::Abi::WindowsMsvc2015Flavor; + tcInfo.wordWidth = tc->targetAbi().wordWidth(); + tcInfo.targetTriple = tc->originalTargetTriple(); + tcInfo.sysRootPath = ProjectExplorer::SysRootKitInformation::sysRoot(kit).toString(); + tcInfo.headerPathsRunner = tc->createBuiltInHeaderPathsRunner(); + tcInfo.predefinedMacrosRunner = tc->createPredefinedMacrosRunner(); + + m_cppCodeModelUpdater->update({this, tcInfo, tcInfo, rpps}); + + emitParsingFinished(true); + }); + m_parserWatcher.setFuture(future); + }); +} + +CompilationDatabaseProject::~CompilationDatabaseProject() +{ + m_parserWatcher.cancel(); + m_parserWatcher.waitForFinished(); +} + +static TextEditor::TextDocument *createCompilationDatabaseDocument() +{ + auto doc = new TextEditor::TextDocument; + doc->setId(Constants::COMPILATIONDATABASEPROJECT_ID); + doc->setMimeType(Constants::COMPILATIONDATABASEMIMETYPE); + return doc; +} + +CompilationDatabaseEditorFactory::CompilationDatabaseEditorFactory() +{ + setId(Constants::COMPILATIONDATABASEPROJECT_ID); + setDisplayName("Compilation Database"); + addMimeType(Constants::COMPILATIONDATABASEMIMETYPE); + + setEditorCreator([]() { return new TextEditor::BaseTextEditor; }); + setEditorWidgetCreator([]() { return new TextEditor::TextEditorWidget; }); + setDocumentCreator(createCompilationDatabaseDocument); + setUseGenericHighlighter(true); + setCommentDefinition(Utils::CommentDefinition::HashStyle); + setCodeFoldingSupported(true); +} + +} // namespace Internal +} // namespace CompilationDatabaseProjectManager diff --git a/src/plugins/compilationdatabaseprojectmanager/compilationdatabaseproject.h b/src/plugins/compilationdatabaseprojectmanager/compilationdatabaseproject.h new file mode 100644 index 00000000000..2ba01adbaac --- /dev/null +++ b/src/plugins/compilationdatabaseprojectmanager/compilationdatabaseproject.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include + +#include + +#include + +namespace CppTools { +class CppProjectUpdater; +} + +namespace CompilationDatabaseProjectManager { +namespace Internal { + +class CompilationDatabaseProject : public ProjectExplorer::Project +{ + Q_OBJECT + +public: + explicit CompilationDatabaseProject(const Utils::FileName &filename); + ~CompilationDatabaseProject() override; + +private: + QFutureWatcher m_parserWatcher; + std::unique_ptr m_cppCodeModelUpdater; +}; + +class CompilationDatabaseEditorFactory : public TextEditor::TextEditorFactory +{ + Q_OBJECT + +public: + CompilationDatabaseEditorFactory(); +}; + +} // namespace Internal +} // namespace CompilationDatabaseProjectManager diff --git a/src/plugins/compilationdatabaseprojectmanager/compilationdatabaseprojectmanager.pro b/src/plugins/compilationdatabaseprojectmanager/compilationdatabaseprojectmanager.pro new file mode 100644 index 00000000000..a815c0db8eb --- /dev/null +++ b/src/plugins/compilationdatabaseprojectmanager/compilationdatabaseprojectmanager.pro @@ -0,0 +1,10 @@ +include(../../qtcreatorplugin.pri) + +SOURCES = \ + compilationdatabaseproject.cpp \ + compilationdatabaseprojectmanagerplugin.cpp + +HEADERS = \ + compilationdatabaseproject.h \ + compilationdatabaseprojectmanagerplugin.h \ + compilationdatabaseconstants.h diff --git a/src/plugins/compilationdatabaseprojectmanager/compilationdatabaseprojectmanager_dependencies.pri b/src/plugins/compilationdatabaseprojectmanager/compilationdatabaseprojectmanager_dependencies.pri new file mode 100644 index 00000000000..043a96f22f2 --- /dev/null +++ b/src/plugins/compilationdatabaseprojectmanager/compilationdatabaseprojectmanager_dependencies.pri @@ -0,0 +1,10 @@ +QTC_PLUGIN_NAME = CompilationDatabaseProjectManager + +QTC_LIB_DEPENDS += \ + extensionsystem \ + utils +QTC_PLUGIN_DEPENDS += \ + coreplugin \ + cpptools \ + projectexplorer \ + texteditor diff --git a/src/plugins/compilationdatabaseprojectmanager/compilationdatabaseprojectmanagerplugin.cpp b/src/plugins/compilationdatabaseprojectmanager/compilationdatabaseprojectmanagerplugin.cpp new file mode 100644 index 00000000000..1fe0d6d032e --- /dev/null +++ b/src/plugins/compilationdatabaseprojectmanager/compilationdatabaseprojectmanagerplugin.cpp @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "compilationdatabaseprojectmanagerplugin.h" + +#include "compilationdatabaseconstants.h" +#include "compilationdatabaseproject.h" + +#include +#include +#include + +namespace CompilationDatabaseProjectManager { +namespace Internal { + +bool CompilationDatabaseProjectManagerPlugin::initialize(const QStringList &arguments, QString *errorMessage) +{ + Q_UNUSED(arguments); + Q_UNUSED(errorMessage); + Core::FileIconProvider::registerIconOverlayForFilename(Utils::Icons::PROJECT.imageFileName(), + "compile_commands.json"); + + ProjectExplorer::ProjectManager::registerProjectType( + Constants::COMPILATIONDATABASEMIMETYPE); + + return true; +} + +void CompilationDatabaseProjectManagerPlugin::extensionsInitialized() +{ +} + +} // namespace Internal +} // namespace CompilationDatabaseProjectManager diff --git a/src/plugins/compilationdatabaseprojectmanager/compilationdatabaseprojectmanagerplugin.h b/src/plugins/compilationdatabaseprojectmanager/compilationdatabaseprojectmanagerplugin.h new file mode 100644 index 00000000000..a89db25e37b --- /dev/null +++ b/src/plugins/compilationdatabaseprojectmanager/compilationdatabaseprojectmanagerplugin.h @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include "compilationdatabaseproject.h" + +#include +#include +#include + +namespace CompilationDatabaseProjectManager { +namespace Internal { + +class CompilationDatabaseProjectManagerPlugin final : public ExtensionSystem::IPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "CompilationDatabaseProjectManager.json") + +public: + bool initialize(const QStringList &arguments, QString *errorMessage) final; + void extensionsInitialized() final; +private: + CompilationDatabaseEditorFactory factory; +}; + +} // namespace Internal +} // namespace CompilationDatabaseProjectManager diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp index b4cc33f7966..5b0db2ee5ea 100644 --- a/src/plugins/cppeditor/cppquickfixes.cpp +++ b/src/plugins/cppeditor/cppquickfixes.cpp @@ -66,12 +66,15 @@ #include #include #include +#include #include #include #include #include +#include #include +#include using namespace CPlusPlus; using namespace CppTools; @@ -1084,12 +1087,6 @@ static QByteArray charToStringEscapeSequences(const QByteArray &content) return QByteArray(); } -static QString msgQtStringLiteralDescription(const QString &replacement, int qtVersion) -{ - return QApplication::translate("CppTools::QuickFix", "Enclose in %1(...) (Qt %2)") - .arg(replacement).arg(qtVersion); -} - static QString msgQtStringLiteralDescription(const QString &replacement) { return QApplication::translate("CppTools::QuickFix", "Enclose in %1(...)").arg(replacement); @@ -1291,10 +1288,10 @@ void WrapStringLiteral::match(const CppQuickFixInterface &interface, QuickFixOpe } actions = EncloseInQLatin1StringAction | objectiveCActions; result << new WrapStringLiteralOp(interface, priority, actions, - msgQtStringLiteralDescription(stringLiteralReplacement(actions), 4), literal); + msgQtStringLiteralDescription(stringLiteralReplacement(actions)), literal); actions = EncloseInQStringLiteralAction | objectiveCActions; result << new WrapStringLiteralOp(interface, priority, actions, - msgQtStringLiteralDescription(stringLiteralReplacement(actions), 5), literal); + msgQtStringLiteralDescription(stringLiteralReplacement(actions)), literal); } } @@ -1484,8 +1481,14 @@ void ConvertNumericLiteral::match(const CppQuickFixInterface &interface, QuickFi // convert to number bool valid; - ulong value = QString::fromUtf8(spell).left(numberLength).toULong(&valid, 0); - if (!valid) // e.g. octal with digit > 7 + ulong value = 0; + const QString x = QString::fromUtf8(spell).left(numberLength); + if (x.startsWith("0b", Qt::CaseInsensitive)) + value = x.midRef(2).toULong(&valid, 2); + else + value = x.toULong(&valid, 0); + + if (!valid) return; const int priority = path.size() - 1; // very high priority @@ -1496,6 +1499,7 @@ void ConvertNumericLiteral::match(const CppQuickFixInterface &interface, QuickFi /* Convert integer literal to hex representation. Replace + 0b100000 32 040 With @@ -1511,10 +1515,13 @@ void ConvertNumericLiteral::match(const CppQuickFixInterface &interface, QuickFi } if (value != 0) { - if (!(numberLength > 1 && str[0] == '0' && str[1] != 'x' && str[1] != 'X')) { + if (!(numberLength > 1 && str[0] == '0' + && str[1] != 'x' && str[1] != 'X' + && str[1] != 'b' && str[1] != 'B')) { /* Convert integer literal to octal representation. Replace + 0b100000 32 0x20 With @@ -1534,6 +1541,7 @@ void ConvertNumericLiteral::match(const CppQuickFixInterface &interface, QuickFi /* Convert integer literal to decimal representation. Replace + 0b100000 0x20 040 With @@ -1547,6 +1555,30 @@ void ConvertNumericLiteral::match(const CppQuickFixInterface &interface, QuickFi result << op; } } + + if (!(numberLength > 1 && str[0] == '0' && (str[1] == 'b' || str[1] == 'B'))) { + /* + Convert integer literal to binary representation. + Replace + 32 + 0x20 + 040 + With + 0b100000 + */ + QString replacement = "0b"; + if (value == 0) { + replacement.append('0'); + } else { + std::bitset::digits> b(value); + QRegularExpression re("^[0]*"); + replacement.append(QString::fromStdString(b.to_string()).remove(re)); + } + auto op = new ConvertNumericLiteralOp(interface, start, start + numberLength, replacement); + op->setDescription(QApplication::translate("CppTools::QuickFix", "Convert to Binary")); + op->setPriority(priority); + result << op; + } } namespace { diff --git a/src/plugins/cpptools/compileroptionsbuilder.cpp b/src/plugins/cpptools/compileroptionsbuilder.cpp index a758e7de31c..812de0fb598 100644 --- a/src/plugins/cpptools/compileroptionsbuilder.cpp +++ b/src/plugins/cpptools/compileroptionsbuilder.cpp @@ -68,6 +68,14 @@ QStringList CompilerOptionsBuilder::build(CppTools::ProjectFile::Kind fileKind, addWordWidth(); addTargetTriple(); addExtraCodeModelFlags(); + + if (m_projectPart.toolchainType + == ProjectExplorer::Constants::COMPILATION_DATABASE_TOOLCHAIN_TYPEID) { + addHeaderPathOptions(); + insertWrappedQtHeaders(); + return options(); + } + updateLanguageOption(fileKind); addOptionsForLanguage(/*checkForBorlandExtensions*/ true); enableExceptions(); diff --git a/src/plugins/cpptools/cppcompletionassist.cpp b/src/plugins/cpptools/cppcompletionassist.cpp index 00acaa9abe4..af4372a4580 100644 --- a/src/plugins/cpptools/cppcompletionassist.cpp +++ b/src/plugins/cpptools/cppcompletionassist.cpp @@ -83,7 +83,7 @@ struct CompleteFunctionDeclaration class CppAssistProposalItem final : public AssistProposalItem { public: - ~CppAssistProposalItem() Q_DECL_NOEXCEPT {} + ~CppAssistProposalItem() noexcept {} bool prematurelyApplies(const QChar &c) const override; void applyContextualContent(TextDocumentManipulatorInterface &manipulator, int basePosition) const override; diff --git a/src/plugins/cpptools/cppprojectinfogenerator.cpp b/src/plugins/cpptools/cppprojectinfogenerator.cpp index 133a5237d22..fd1c9280902 100644 --- a/src/plugins/cpptools/cppprojectinfogenerator.cpp +++ b/src/plugins/cpptools/cppprojectinfogenerator.cpp @@ -28,6 +28,7 @@ #include "cppprojectfilecategorizer.h" #include +#include namespace CppTools { namespace Internal { @@ -56,6 +57,10 @@ public: m_projectPart.warningFlags = m_flags.warningFlags; + // For compilation database pass the command line flags directly. + if (m_projectPart.toolchainType == ProjectExplorer::Constants::COMPILATION_DATABASE_TOOLCHAIN_TYPEID) + m_projectPart.extraCodeModelFlags = m_flags.commandLineFlags; + mapLanguageVersion(); mapLanguageExtensions(); diff --git a/src/plugins/cpptools/cppvirtualfunctionproposalitem.h b/src/plugins/cpptools/cppvirtualfunctionproposalitem.h index dec7ca050b5..61d06b469ca 100644 --- a/src/plugins/cpptools/cppvirtualfunctionproposalitem.h +++ b/src/plugins/cpptools/cppvirtualfunctionproposalitem.h @@ -37,7 +37,7 @@ class CPPTOOLS_EXPORT VirtualFunctionProposalItem final : public TextEditor::Ass public: VirtualFunctionProposalItem(const Utils::Link &link, bool openInSplit = true); - ~VirtualFunctionProposalItem() Q_DECL_NOEXCEPT override {} + ~VirtualFunctionProposalItem() noexcept override {} void apply(TextEditor::TextDocumentManipulatorInterface &manipulator, int basePosition) const override; Utils::Link link() const { return m_link; } // Exposed for tests diff --git a/src/plugins/cpptools/projectinfo.cpp b/src/plugins/cpptools/projectinfo.cpp index adcabc90954..a51caebe111 100644 --- a/src/plugins/cpptools/projectinfo.cpp +++ b/src/plugins/cpptools/projectinfo.cpp @@ -66,6 +66,19 @@ ProjectUpdateInfo::ProjectUpdateInfo(ProjectExplorer::Project *project, { } +ProjectUpdateInfo::ProjectUpdateInfo(ProjectExplorer::Project *project, + const ToolChainInfo &cToolChainInfo, + const ToolChainInfo &cxxToolChainInfo, + const RawProjectParts &rawProjectParts) + : project(project) + , rawProjectParts(rawProjectParts) + , cToolChain(nullptr) + , cxxToolChain(nullptr) + , cToolChainInfo(cToolChainInfo) + , cxxToolChainInfo(cxxToolChainInfo) +{ +} + ProjectInfo::ProjectInfo(QPointer project) : m_project(project) { diff --git a/src/plugins/cpptools/projectinfo.h b/src/plugins/cpptools/projectinfo.h index 8b30998744b..38bf509cba2 100644 --- a/src/plugins/cpptools/projectinfo.h +++ b/src/plugins/cpptools/projectinfo.h @@ -70,6 +70,10 @@ public: const ProjectExplorer::ToolChain *cxxToolChain, const ProjectExplorer::Kit *kit, const RawProjectParts &rawProjectParts); + ProjectUpdateInfo(ProjectExplorer::Project *project, + const ToolChainInfo &cToolChainInfo, + const ToolChainInfo &cxxToolChainInfo, + const RawProjectParts &rawProjectParts); bool isValid() const { return project && !rawProjectParts.isEmpty(); } public: diff --git a/src/plugins/cvs/annotationhighlighter.h b/src/plugins/cvs/annotationhighlighter.h index afa52aba610..0793c343649 100644 --- a/src/plugins/cvs/annotationhighlighter.h +++ b/src/plugins/cvs/annotationhighlighter.h @@ -37,7 +37,7 @@ class CvsAnnotationHighlighter : public VcsBase::BaseAnnotationHighlighter public: explicit CvsAnnotationHighlighter(const ChangeNumbers &changeNumbers, - QTextDocument *document = 0); + QTextDocument *document = nullptr); private: QString changeNumber(const QString &block) const override; diff --git a/src/plugins/cvs/cvsclient.cpp b/src/plugins/cvs/cvsclient.cpp index bd6052a4ee1..95a5697e96d 100644 --- a/src/plugins/cvs/cvsclient.cpp +++ b/src/plugins/cvs/cvsclient.cpp @@ -48,7 +48,7 @@ class CvsDiffConfig : public VcsBaseEditorConfig Q_OBJECT public: CvsDiffConfig(VcsBaseClientSettings &settings, QToolBar *toolBar); - QStringList arguments() const; + QStringList arguments() const override; private: VcsBaseClientSettings &m_settings; diff --git a/src/plugins/cvs/cvscontrol.cpp b/src/plugins/cvs/cvscontrol.cpp index d9bf55a86e4..602d6764a28 100644 --- a/src/plugins/cvs/cvscontrol.cpp +++ b/src/plugins/cvs/cvscontrol.cpp @@ -141,7 +141,7 @@ Core::ShellCommand *CvsControl::createInitialCheckoutCommand(const QString &url, const QString &localName, const QStringList &extraArgs) { - QTC_ASSERT(localName == url, return 0); + QTC_ASSERT(localName == url, return nullptr); const CvsSettings settings = CvsPlugin::instance()->client()->settings(); diff --git a/src/plugins/cvs/cvscontrol.h b/src/plugins/cvs/cvscontrol.h index 1bc093b7889..37370452c95 100644 --- a/src/plugins/cvs/cvscontrol.h +++ b/src/plugins/cvs/cvscontrol.h @@ -44,7 +44,7 @@ public: bool isVcsFileOrDirectory(const Utils::FileName &fileName) const final; - bool managesDirectory(const QString &directory, QString *topLevel = 0) const final; + bool managesDirectory(const QString &directory, QString *topLevel = nullptr) const final; bool managesFile(const QString &workingDirectory, const QString &fileName) const final; bool isConfigured() const final; diff --git a/src/plugins/cvs/cvsplugin.cpp b/src/plugins/cvs/cvsplugin.cpp index 706f8523847..99c72a287d9 100644 --- a/src/plugins/cvs/cvsplugin.cpp +++ b/src/plugins/cvs/cvsplugin.cpp @@ -144,8 +144,9 @@ const VcsBaseEditorParameters editorParameters[] = { // Utility to find a parameter set by type static inline const VcsBaseEditorParameters *findType(int ie) { - const EditorContentType et = static_cast(ie); - return VcsBaseEditor::findType(editorParameters, sizeof(editorParameters) / sizeof(editorParameters[0]), et); + return VcsBaseEditor::findType(editorParameters, + sizeof(editorParameters) / sizeof(*editorParameters), + static_cast(ie)); } static inline bool messageBoxQuestion(const QString &title, const QString &question) @@ -154,7 +155,7 @@ static inline bool messageBoxQuestion(const QString &title, const QString &quest } // ------------- CVSPlugin -CvsPlugin *CvsPlugin::m_cvsPluginInstance = 0; +CvsPlugin *CvsPlugin::m_cvsPluginInstance = nullptr; CvsPlugin::~CvsPlugin() { @@ -416,7 +417,7 @@ bool CvsPlugin::submitEditorAboutToClose() if (!isCommitEditorOpen()) return true; - CvsSubmitEditor *editor = qobject_cast(submitEditor()); + auto editor = qobject_cast(submitEditor()); QTC_ASSERT(editor, return true); IDocument *editorDocument = editor->document(); QTC_ASSERT(editorDocument, return true); @@ -466,15 +467,15 @@ void CvsPlugin::diffCommitFiles(const QStringList &files) static void setDiffBaseDirectory(IEditor *editor, const QString &db) { - if (VcsBaseEditorWidget *ve = qobject_cast(editor->widget())) + if (auto ve = qobject_cast(editor->widget())) ve->setWorkingDirectory(db); } CvsSubmitEditor *CvsPlugin::openCVSSubmitEditor(const QString &fileName) { IEditor *editor = EditorManager::openEditor(fileName, CVSCOMMITEDITOR_ID); - CvsSubmitEditor *submitEditor = qobject_cast(editor); - QTC_ASSERT(submitEditor, return 0); + auto submitEditor = qobject_cast(editor); + QTC_ASSERT(submitEditor, return nullptr); connect(submitEditor, &VcsBaseSubmitEditor::diffSelectedFiles, this, &CvsPlugin::diffCommitFiles); @@ -907,7 +908,7 @@ bool CvsPlugin::status(const QString &topLevel, const QString &file, const QStri runCvs(topLevel, args, client()->vcsTimeoutS(), 0); const bool ok = response.result == CvsResponse::Ok; if (ok) - showOutputInEditor(title, response.stdOut, OtherContent, topLevel, 0); + showOutputInEditor(title, response.stdOut, OtherContent, topLevel, nullptr); return ok; } @@ -1027,7 +1028,7 @@ bool CvsPlugin::describe(const QString &repositoryPath, { // Collect logs QString output; - QTextCodec *codec = 0; + QTextCodec *codec = nullptr; const QList::iterator lend = entries.end(); for (QList::iterator it = entries.begin(); it != lend; ++it) { // Before fiddling file names, try to find codec @@ -1141,13 +1142,13 @@ IEditor *CvsPlugin::showOutputInEditor(const QString& title, const QString &outp QTextCodec *codec) { const VcsBaseEditorParameters *params = findType(editorType); - QTC_ASSERT(params, return 0); + QTC_ASSERT(params, return nullptr); const Id id = params->id; QString s = title; IEditor *editor = EditorManager::openEditorWithContents(id, &s, output.toUtf8()); - CvsEditorWidget *e = qobject_cast(editor->widget()); + auto e = qobject_cast(editor->widget()); if (!e) - return 0; + return nullptr; connect(e, &VcsBaseEditorWidget::annotateRevisionRequested, this, &CvsPlugin::annotate); s.replace(QLatin1Char(' '), QLatin1Char('_')); e->textDocument()->setFallbackSaveAsFileName(s); diff --git a/src/plugins/cvs/cvsplugin.h b/src/plugins/cvs/cvsplugin.h index c03dd6ae099..9290002569e 100644 --- a/src/plugins/cvs/cvsplugin.h +++ b/src/plugins/cvs/cvsplugin.h @@ -79,7 +79,7 @@ public: // IVersionControl bool vcsAdd(const QString &workingDir, const QString &fileName); bool vcsDelete(const QString &workingDir, const QString &fileName); - bool managesDirectory(const QString &directory, QString *topLevel = 0) const; + bool managesDirectory(const QString &directory, QString *topLevel = nullptr) const; bool managesFile(const QString &workingDirectory, const QString &fileName) const; // cvs 'edit' is used to implement 'open' (cvsnt). bool edit(const QString &topLevel, const QStringList &files); @@ -135,7 +135,7 @@ private: const QStringList &arguments, int timeOutS, unsigned flags, - QTextCodec *outputCodec = 0) const; + QTextCodec *outputCodec = nullptr) const; void annotate(const QString &workingDir, const QString &file, const QString &revision = QString(), int lineNumber= -1); diff --git a/src/plugins/cvs/cvssettings.h b/src/plugins/cvs/cvssettings.h index ab4755b2c99..3884cc32c17 100644 --- a/src/plugins/cvs/cvssettings.h +++ b/src/plugins/cvs/cvssettings.h @@ -46,7 +46,7 @@ public: QStringList addOptions(const QStringList &args) const; protected: - void readLegacySettings(const QSettings *settings); + void readLegacySettings(const QSettings *settings) override; }; } // namespace Internal diff --git a/src/plugins/cvs/settingspage.h b/src/plugins/cvs/settingspage.h index a36fdd1f922..404146aef9f 100644 --- a/src/plugins/cvs/settingspage.h +++ b/src/plugins/cvs/settingspage.h @@ -39,10 +39,10 @@ class SettingsPageWidget : public VcsBase::VcsClientOptionsPageWidget Q_OBJECT public: - explicit SettingsPageWidget(QWidget *parent = 0); + explicit SettingsPageWidget(QWidget *parent = nullptr); - VcsBase::VcsBaseClientSettings settings() const; - void setSettings(const VcsBase::VcsBaseClientSettings &); + VcsBase::VcsBaseClientSettings settings() const override; + void setSettings(const VcsBase::VcsBaseClientSettings &) override; private: Ui::SettingsPage m_ui; diff --git a/src/plugins/debugger/debuggermainwindow.cpp b/src/plugins/debugger/debuggermainwindow.cpp index 12ea2685570..a22ea42d515 100644 --- a/src/plugins/debugger/debuggermainwindow.cpp +++ b/src/plugins/debugger/debuggermainwindow.cpp @@ -330,7 +330,7 @@ QWidget *DebuggerMainWindow::centralWidgetStack() return theMainWindow ? theMainWindow->d->m_centralWidgetStack : nullptr; } -void DebuggerMainWindow::setSubPerspectiveSwitcher(QWidget *widget) +void DebuggerMainWindow::addSubPerspectiveSwitcher(QWidget *widget) { widget->setVisible(false); widget->setProperty("panelwidget", true); diff --git a/src/plugins/debugger/debuggermainwindow.h b/src/plugins/debugger/debuggermainwindow.h index 460163f9efe..2b99e201a8e 100644 --- a/src/plugins/debugger/debuggermainwindow.h +++ b/src/plugins/debugger/debuggermainwindow.h @@ -129,7 +129,7 @@ public: static void onModeChanged(Core::Id mode); static QWidget *centralWidgetStack(); - void setSubPerspectiveSwitcher(QWidget *widget); + void addSubPerspectiveSwitcher(QWidget *widget); private: DebuggerMainWindow(); diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index d4ca02f5f19..e45d829b905 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -521,7 +521,7 @@ public: splitter->setObjectName(QLatin1String("DebugModeWidget")); mainWindow->setCentralWidget(centralEditorWidget); - mainWindow->setSubPerspectiveSwitcher(EngineManager::engineChooser()); + mainWindow->addSubPerspectiveSwitcher(EngineManager::engineChooser()); setWidget(splitter); } diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index f06ce3c12cc..e73f19443d0 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -3031,6 +3031,8 @@ void GdbEngine::handleThreadNames(const DebuggerResponse &response) for (const GdbMi &name : names.children()) { ThreadData thread; thread.id = name["id"].data(); + // Core is unavailable in core dump. Allow the user to provide it. + thread.core = name["core"].data(); thread.name = decodeData(name["value"].data(), name["valueencoded"].data()); handler->updateThread(thread); } diff --git a/src/plugins/git/annotationhighlighter.h b/src/plugins/git/annotationhighlighter.h index 7f28ad26da8..629b8c3f5e6 100644 --- a/src/plugins/git/annotationhighlighter.h +++ b/src/plugins/git/annotationhighlighter.h @@ -36,7 +36,7 @@ class GitAnnotationHighlighter : public VcsBase::BaseAnnotationHighlighter Q_OBJECT public: explicit GitAnnotationHighlighter(const ChangeNumbers &changeNumbers, - QTextDocument *document = 0); + QTextDocument *document = nullptr); private: QString changeNumber(const QString &block) const override; diff --git a/src/plugins/git/branchadddialog.cpp b/src/plugins/git/branchadddialog.cpp index d3c122b974a..2ea024bef4a 100644 --- a/src/plugins/git/branchadddialog.cpp +++ b/src/plugins/git/branchadddialog.cpp @@ -46,7 +46,7 @@ namespace Internal { class BranchNameValidator : public QValidator { public: - BranchNameValidator(const QStringList &localBranches, QObject *parent = 0) : + BranchNameValidator(const QStringList &localBranches, QObject *parent = nullptr) : QValidator(parent), m_invalidChars(GitPlugin::invalidBranchAndRemoteNamePattern()), m_localBranches(localBranches) diff --git a/src/plugins/git/branchcheckoutdialog.cpp b/src/plugins/git/branchcheckoutdialog.cpp index c6a0db9a3cd..97881c7839b 100644 --- a/src/plugins/git/branchcheckoutdialog.cpp +++ b/src/plugins/git/branchcheckoutdialog.cpp @@ -33,9 +33,7 @@ BranchCheckoutDialog::BranchCheckoutDialog(QWidget *parent, const QString ¤tBranch, const QString &nextBranch) : QDialog(parent), - m_ui(new Ui::BranchCheckoutDialog), - m_foundStashForNextBranch(false), - m_hasLocalChanges(true) + m_ui(new Ui::BranchCheckoutDialog) { m_ui->setupUi(this); diff --git a/src/plugins/git/branchcheckoutdialog.h b/src/plugins/git/branchcheckoutdialog.h index 755a132e845..882e5ded40a 100644 --- a/src/plugins/git/branchcheckoutdialog.h +++ b/src/plugins/git/branchcheckoutdialog.h @@ -56,8 +56,8 @@ private: void updatePopStashCheckBox(bool moveChangesChecked); Ui::BranchCheckoutDialog *m_ui; - bool m_foundStashForNextBranch; - bool m_hasLocalChanges; + bool m_foundStashForNextBranch = false; + bool m_hasLocalChanges = true; }; } // namespace Internal diff --git a/src/plugins/git/branchview.cpp b/src/plugins/git/branchview.cpp index fa2fd99775b..ddb3565f493 100644 --- a/src/plugins/git/branchview.cpp +++ b/src/plugins/git/branchview.cpp @@ -122,8 +122,14 @@ void BranchView::refresh(const QString &repository, bool force) return; m_repository = repository; - m_repositoryLabel->setText(QDir::toNativeSeparators(m_repository)); - m_repositoryLabel->setToolTip(GitPlugin::msgRepositoryLabel(m_repository)); + if (m_repository.isEmpty()) { + m_repositoryLabel->setText(tr("")); + m_branchView->setEnabled(false); + } else { + m_repositoryLabel->setText(QDir::toNativeSeparators(m_repository)); + m_repositoryLabel->setToolTip(GitPlugin::msgRepositoryLabel(m_repository)); + m_branchView->setEnabled(true); + } QString errorMessage; if (!m_model->refresh(m_repository, &errorMessage)) VcsBase::VcsOutputWindow::appendError(errorMessage); diff --git a/src/plugins/git/changeselectiondialog.cpp b/src/plugins/git/changeselectiondialog.cpp index 247427eed52..5a46b2cbbf8 100644 --- a/src/plugins/git/changeselectiondialog.cpp +++ b/src/plugins/git/changeselectiondialog.cpp @@ -204,7 +204,7 @@ void ChangeSelectionDialog::terminateProcess() m_process->kill(); m_process->waitForFinished(); delete m_process; - m_process = 0; + m_process = nullptr; } void ChangeSelectionDialog::recalculateCompletion() diff --git a/src/plugins/git/commitdata.cpp b/src/plugins/git/commitdata.cpp index d8a2edc6202..98876c678a8 100644 --- a/src/plugins/git/commitdata.cpp +++ b/src/plugins/git/commitdata.cpp @@ -64,8 +64,6 @@ QString GitSubmitEditorPanelData::authorString() const CommitData::CommitData(CommitType type) : commitType(type) - , commitEncoding(0) - , enablePush(false) { } diff --git a/src/plugins/git/commitdata.h b/src/plugins/git/commitdata.h index 98e6fe9ca41..77a6f52a62d 100644 --- a/src/plugins/git/commitdata.h +++ b/src/plugins/git/commitdata.h @@ -105,10 +105,10 @@ public: CommitType commitType; QString amendSHA1; - QTextCodec *commitEncoding; + QTextCodec *commitEncoding = nullptr; GitSubmitEditorPanelInfo panelInfo; GitSubmitEditorPanelData panelData; - bool enablePush; + bool enablePush = false; QList files; diff --git a/src/plugins/git/gerrit/authenticationdialog.h b/src/plugins/git/gerrit/authenticationdialog.h index 055c553b489..7556c5bd0b4 100644 --- a/src/plugins/git/gerrit/authenticationdialog.h +++ b/src/plugins/git/gerrit/authenticationdialog.h @@ -45,7 +45,7 @@ class AuthenticationDialog : public QDialog public: AuthenticationDialog(GerritServer *server); - ~AuthenticationDialog(); + ~AuthenticationDialog() override; bool isAuthenticated() const { return m_authenticated; } private: diff --git a/src/plugins/git/gerrit/gerritdialog.cpp b/src/plugins/git/gerrit/gerritdialog.cpp index d3df24049d2..f26df525fa9 100644 --- a/src/plugins/git/gerrit/gerritdialog.cpp +++ b/src/plugins/git/gerrit/gerritdialog.cpp @@ -69,7 +69,7 @@ GerritDialog::GerritDialog(const QSharedPointer &p, m_ui->remoteComboBox->setParameters(m_parameters); m_ui->remoteComboBox->setFallbackEnabled(true); m_queryModel->setStringList(m_parameters->savedQueries); - QCompleter *completer = new QCompleter(this); + auto completer = new QCompleter(this); completer->setModel(m_queryModel); m_ui->queryLineEdit->setSpecialCompleter(completer); m_ui->queryLineEdit->setOkColor(Utils::creatorTheme()->color(Utils::Theme::TextColorNormal)); diff --git a/src/plugins/git/gerrit/gerritdialog.h b/src/plugins/git/gerrit/gerritdialog.h index 1b15e6f5075..98d3015d254 100644 --- a/src/plugins/git/gerrit/gerritdialog.h +++ b/src/plugins/git/gerrit/gerritdialog.h @@ -56,7 +56,7 @@ public: const QSharedPointer &s, const QString &repository, QWidget *parent = nullptr); - ~GerritDialog(); + ~GerritDialog() override; QString repositoryPath() const; void setCurrentPath(const QString &path); void fetchStarted(const QSharedPointer &change); diff --git a/src/plugins/git/gerrit/gerritmodel.cpp b/src/plugins/git/gerrit/gerritmodel.cpp index f6b70e7d203..2887d750ec1 100644 --- a/src/plugins/git/gerrit/gerritmodel.cpp +++ b/src/plugins/git/gerrit/gerritmodel.cpp @@ -227,7 +227,7 @@ public: const GerritServer &server, QObject *parent = nullptr); - ~QueryContext(); + ~QueryContext() override; void start(); void terminate(); @@ -845,7 +845,7 @@ QList GerritModel::changeToRow(const GerritChangePtr &c) const const QVariant filterV = QVariant(c->filterString()); const QVariant changeV = qVariantFromValue(c); for (int i = 0; i < GerritModel::ColumnCount; ++i) { - QStandardItem *item = new QStandardItem; + auto item = new QStandardItem; item->setData(changeV, GerritModel::GerritChangeRole); item->setData(filterV, GerritModel::FilterRole); item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); diff --git a/src/plugins/git/gerrit/gerritmodel.h b/src/plugins/git/gerrit/gerritmodel.h index 213de67db93..c8e89bfae78 100644 --- a/src/plugins/git/gerrit/gerritmodel.h +++ b/src/plugins/git/gerrit/gerritmodel.h @@ -105,7 +105,7 @@ public: SortRole = Qt::UserRole + 3 }; GerritModel(const QSharedPointer &, QObject *parent = nullptr); - ~GerritModel(); + ~GerritModel() override; QVariant data(const QModelIndex &index, int role) const override; diff --git a/src/plugins/git/gerrit/gerritoptionspage.cpp b/src/plugins/git/gerrit/gerritoptionspage.cpp index 58106495468..730080d66f5 100644 --- a/src/plugins/git/gerrit/gerritoptionspage.cpp +++ b/src/plugins/git/gerrit/gerritoptionspage.cpp @@ -91,7 +91,7 @@ GerritOptionsWidget::GerritOptionsWidget(QWidget *parent) , m_portSpinBox(new QSpinBox(this)) , m_httpsCheckBox(new QCheckBox(tr("HTTPS"))) { - QFormLayout *formLayout = new QFormLayout(this); + auto formLayout = new QFormLayout(this); formLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); formLayout->addRow(tr("&Host:"), m_hostLineEdit); formLayout->addRow(tr("&User:"), m_userLineEdit); diff --git a/src/plugins/git/gerrit/gerritoptionspage.h b/src/plugins/git/gerrit/gerritoptionspage.h index b2a6fce12d2..ae2b4776cfc 100644 --- a/src/plugins/git/gerrit/gerritoptionspage.h +++ b/src/plugins/git/gerrit/gerritoptionspage.h @@ -67,7 +67,7 @@ class GerritOptionsPage : public VcsBase::VcsBaseOptionsPage public: GerritOptionsPage(const QSharedPointer &p, QObject *parent = nullptr); - ~GerritOptionsPage(); + ~GerritOptionsPage() override; QWidget *widget() override; void apply() override; diff --git a/src/plugins/git/gerrit/gerritparameters.cpp b/src/plugins/git/gerrit/gerritparameters.cpp index b98f36b896b..a505bda6e49 100644 --- a/src/plugins/git/gerrit/gerritparameters.cpp +++ b/src/plugins/git/gerrit/gerritparameters.cpp @@ -99,8 +99,7 @@ void GerritParameters::setPortFlagBySshType() } GerritParameters::GerritParameters() - : https(true) - , portFlag(defaultPortFlag) + : portFlag(defaultPortFlag) { } diff --git a/src/plugins/git/gerrit/gerritparameters.h b/src/plugins/git/gerrit/gerritparameters.h index 7f08f92967e..6c5d3739906 100644 --- a/src/plugins/git/gerrit/gerritparameters.h +++ b/src/plugins/git/gerrit/gerritparameters.h @@ -50,7 +50,7 @@ public: QString ssh; QString curl; QStringList savedQueries; - bool https; + bool https = true; QString portFlag; }; diff --git a/src/plugins/git/gerrit/gerritplugin.cpp b/src/plugins/git/gerrit/gerritplugin.cpp index ad87882b38a..d409f939060 100644 --- a/src/plugins/git/gerrit/gerritplugin.cpp +++ b/src/plugins/git/gerrit/gerritplugin.cpp @@ -94,7 +94,7 @@ public: const QString &repository, const Utils::FileName &git, const GerritServer &server, FetchMode fm, QObject *parent = nullptr); - ~FetchContext(); + ~FetchContext() override; void start(); private: @@ -467,8 +467,7 @@ void GerritPlugin::fetch(const QSharedPointer &change, int mode) if (repository.isEmpty()) return; - FetchContext *fc = new FetchContext(change, repository, git, - *m_server, FetchMode(mode), this); + auto fc = new FetchContext(change, repository, git, *m_server, FetchMode(mode), this); connect(fc, &QObject::destroyed, this, &GerritPlugin::fetchFinished); emit fetchStarted(change); fc->start(); diff --git a/src/plugins/git/gerrit/gerritplugin.h b/src/plugins/git/gerrit/gerritplugin.h index bd9d554bfba..5151235496b 100644 --- a/src/plugins/git/gerrit/gerritplugin.h +++ b/src/plugins/git/gerrit/gerritplugin.h @@ -53,7 +53,7 @@ class GerritPlugin : public QObject Q_OBJECT public: explicit GerritPlugin(QObject *parent = nullptr); - ~GerritPlugin(); + ~GerritPlugin() override; bool initialize(Core::ActionContainer *ac); diff --git a/src/plugins/git/gerrit/gerritpushdialog.cpp b/src/plugins/git/gerrit/gerritpushdialog.cpp index 6f6b76fa1df..70f0ffa3b6b 100644 --- a/src/plugins/git/gerrit/gerritpushdialog.cpp +++ b/src/plugins/git/gerrit/gerritpushdialog.cpp @@ -135,7 +135,7 @@ GerritPushDialog::GerritPushDialog(const QString &workingDir, const QString &rev m_ui->remoteComboBox->setParameters(parameters); m_ui->remoteComboBox->setAllowDups(true); - PushItemDelegate *delegate = new PushItemDelegate(m_ui->commitView); + auto delegate = new PushItemDelegate(m_ui->commitView); delegate->setParent(this); initRemoteBranches(); diff --git a/src/plugins/git/gerrit/gerritpushdialog.h b/src/plugins/git/gerrit/gerritpushdialog.h index 9c8254e762b..3814fbce3f2 100644 --- a/src/plugins/git/gerrit/gerritpushdialog.h +++ b/src/plugins/git/gerrit/gerritpushdialog.h @@ -48,7 +48,7 @@ class GerritPushDialog : public QDialog public: GerritPushDialog(const QString &workingDir, const QString &reviewerList, QSharedPointer parameters, QWidget *parent); - ~GerritPushDialog(); + ~GerritPushDialog() override; QString selectedCommit() const; QString selectedRemoteName() const; diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp index b3e9ada8768..8263ea29ac9 100644 --- a/src/plugins/git/gitclient.cpp +++ b/src/plugins/git/gitclient.cpp @@ -139,7 +139,7 @@ static QString branchesDisplay(const QString &prefix, QStringList *branches, boo //: Displayed after the untranslated message "Branches: branch1, branch2 'and %n more'" // in git show. if (more > 0) - output += ' ' + GitClient::tr("and %n more", 0, more); + output += ' ' + GitClient::tr("and %n more", nullptr, more); return output; } @@ -187,7 +187,7 @@ bool DescriptionWidgetDecorator::eventFilter(QObject *watched, QEvent *event) return QObject::eventFilter(watched, event); if (event->type() == QEvent::MouseMove) { - QMouseEvent *mouseEvent = static_cast(event); + auto mouseEvent = static_cast(event); if (mouseEvent->buttons()) return QObject::eventFilter(watched, event); @@ -207,7 +207,7 @@ bool DescriptionWidgetDecorator::eventFilter(QObject *watched, QEvent *event) textEditor->viewport()->setCursor(cursorShape); return ret; } else if (event->type() == QEvent::MouseButtonRelease) { - QMouseEvent *mouseEvent = static_cast(event); + auto mouseEvent = static_cast(event); if (mouseEvent->button() == Qt::LeftButton && !(mouseEvent->modifiers() & Qt::ShiftModifier)) { const QTextCursor cursor = textEditor->cursorForPosition(mouseEvent->pos()); @@ -588,6 +588,15 @@ public: tr("Ignore whitespace only changes.")), settings.boolPointer(GitSettings::ignoreSpaceChangesInBlameKey)); + const QList logChoices = { + ComboBoxItem(tr("No Move Detection"), ""), + ComboBoxItem(tr("Detect Moves Within File"), "-M"), + ComboBoxItem(tr("Detect Moves Between Files"), "-M -C"), + ComboBoxItem(tr("Detect Moves and Copies Between Files"), "-M -C -C") + }; + mapSetting(addComboBox({}, logChoices), + settings.intPointer(GitSettings::blameMoveDetection)); + addButton(tr("Reload"), Utils::Icons::RELOAD.icon()); } }; @@ -624,12 +633,12 @@ public: } }; -class ConflictHandler : public QObject +class ConflictHandler final : public QObject { Q_OBJECT public: static void attachToCommand(VcsCommand *command, const QString &abortCommand = QString()) { - ConflictHandler *handler = new ConflictHandler(command->defaultWorkingDirectory(), abortCommand); + auto handler = new ConflictHandler(command->defaultWorkingDirectory(), abortCommand); handler->setParent(command); // delete when command goes out of scope command->addFlags(VcsCommand::ExpectRepoChanges); @@ -655,7 +664,7 @@ private: m_abortCommand(abortCommand) { } - ~ConflictHandler() + ~ConflictHandler() final { // If interactive rebase editor window is closed, plugin is terminated // but referenced here when the command ends @@ -1296,7 +1305,7 @@ bool GitClient::synchronousReset(const QString &workingDirectory, if (files.isEmpty()) { msgCannotRun(arguments, workingDirectory, resp.stdErr(), errorMessage); } else { - msgCannotRun(tr("Cannot reset %n files in \"%1\": %2", 0, files.size()) + msgCannotRun(tr("Cannot reset %n files in \"%1\": %2", nullptr, files.size()) .arg(QDir::toNativeSeparators(workingDirectory), resp.stdErr()), errorMessage); } @@ -2632,9 +2641,9 @@ bool GitClient::getCommitData(const QString &workingDirectory, static inline QString msgCommitted(const QString &amendSHA1, int fileCount) { if (amendSHA1.isEmpty()) - return GitClient::tr("Committed %n files.", 0, fileCount) + '\n'; + return GitClient::tr("Committed %n files.", nullptr, fileCount) + '\n'; if (fileCount) - return GitClient::tr("Amended \"%1\" (%n files).", 0, fileCount).arg(amendSHA1) + '\n'; + return GitClient::tr("Amended \"%1\" (%n files).", nullptr, fileCount).arg(amendSHA1) + '\n'; return GitClient::tr("Amended \"%1\".").arg(amendSHA1); } @@ -2725,7 +2734,7 @@ bool GitClient::addAndCommit(const QString &repositoryDirectory, VcsOutputWindow::appendError(stdErr); return true; } else { - VcsOutputWindow::appendError(tr("Cannot commit %n files: %1\n", 0, commitCount).arg(stdErr)); + VcsOutputWindow::appendError(tr("Cannot commit %n files: %1\n", nullptr, commitCount).arg(stdErr)); return false; } } @@ -2863,7 +2872,7 @@ bool GitClient::executeAndHandleConflicts(const QString &workingDirectory, return resp.result == SynchronousProcessResponse::Finished; } -bool GitClient::synchronousPull(const QString &workingDirectory, bool rebase) +void GitClient::pull(const QString &workingDirectory, bool rebase) { QString abortCommand; QStringList arguments = {"pull"}; @@ -2874,12 +2883,10 @@ bool GitClient::synchronousPull(const QString &workingDirectory, bool rebase) abortCommand = "merge"; } - bool ok = executeAndHandleConflicts(workingDirectory, arguments, abortCommand); - - if (ok) - updateSubmodulesIfNeeded(workingDirectory, true); - - return ok; + VcsCommand *command = vcsExecAbortable(workingDirectory, arguments, rebase); + connect(command, &VcsCommand::success, this, + [this, workingDirectory] { updateSubmodulesIfNeeded(workingDirectory, true); }, + Qt::QueuedConnection); } void GitClient::synchronousAbortCommand(const QString &workingDir, const QString &abortCommand) @@ -3045,18 +3052,21 @@ void GitClient::revert(const QString &workingDirectory, const QString &argument) // Stashing is handled prior to this call. VcsCommand *GitClient::vcsExecAbortable(const QString &workingDirectory, const QStringList &arguments, - bool createProgressParser) + bool isRebase) { QTC_ASSERT(!arguments.isEmpty(), return nullptr); QString abortCommand = arguments.at(0); - // Git might request an editor, so this must be done asynchronously and without timeout VcsCommand *command = createCommand(workingDirectory, nullptr, VcsWindowOutputBind); command->setCookie(workingDirectory); - command->addFlags(VcsCommand::ShowSuccessMessage); - command->addJob(vcsBinary(), arguments, 0); + command->addFlags(VcsCommand::SshPasswordPrompt + | VcsCommand::ShowStdOut + | VcsCommand::ShowSuccessMessage); + // For rebase, Git might request an editor (which means the process keeps running until the + // user closes it), so run without timeout. + command->addJob(vcsBinary(), arguments, isRebase ? 0 : command->defaultTimeoutS()); ConflictHandler::attachToCommand(command, abortCommand); - if (createProgressParser) + if (isRebase) GitProgressParser::attachToCommand(command); command->execute(); @@ -3240,9 +3250,9 @@ unsigned GitClient::synchronousGitVersion(QString *errorMessage) const QRegExp versionPattern("^[^\\d]+(\\d+)\\.(\\d+)\\.(\\d+|rc\\d).*$"); QTC_ASSERT(versionPattern.isValid(), return 0); QTC_ASSERT(versionPattern.exactMatch(output), return 0); - const unsigned majorV = versionPattern.cap(1).toUInt(0, 16); - const unsigned minorV = versionPattern.cap(2).toUInt(0, 16); - const unsigned patchV = versionPattern.cap(3).toUInt(0, 16); + const unsigned majorV = versionPattern.cap(1).toUInt(nullptr, 16); + const unsigned minorV = versionPattern.cap(2).toUInt(nullptr, 16); + const unsigned patchV = versionPattern.cap(3).toUInt(nullptr, 16); return version(majorV, minorV, patchV); } diff --git a/src/plugins/git/gitclient.h b/src/plugins/git/gitclient.h index 655b49c9e08..03ee95dd5f8 100644 --- a/src/plugins/git/gitclient.h +++ b/src/plugins/git/gitclient.h @@ -126,7 +126,7 @@ public: VcsBase::VcsCommand *vcsExecAbortable(const QString &workingDirectory, const QStringList &arguments, - bool createProgressParser = false); + bool isRebase = false); QString findRepositoryForDirectory(const QString &dir) const; QString findGitDirForRepository(const QString &repositoryDir) const; @@ -242,7 +242,7 @@ public: bool isFastForwardMerge(const QString &workingDirectory, const QString &branch); void fetch(const QString &workingDirectory, const QString &remote); - bool synchronousPull(const QString &workingDirectory, bool rebase); + void pull(const QString &workingDirectory, bool rebase); void push(const QString &workingDirectory, const QStringList &pushArgs = QStringList()); bool synchronousMerge(const QString &workingDirectory, const QString &branch, bool allowFastForward = true); diff --git a/src/plugins/git/gitgrep.cpp b/src/plugins/git/gitgrep.cpp index 0940c94036c..063deb98a25 100644 --- a/src/plugins/git/gitgrep.cpp +++ b/src/plugins/git/gitgrep.cpp @@ -214,7 +214,7 @@ static bool isGitDirectory(const QString &path) { static IVersionControl *gitVc = VcsManager::versionControl(VcsBase::Constants::VCS_ID_GIT); QTC_ASSERT(gitVc, return false); - return gitVc == VcsManager::findVersionControlForDirectory(path, 0); + return gitVc == VcsManager::findVersionControlForDirectory(path, nullptr); } GitGrep::GitGrep(QObject *parent) @@ -303,7 +303,8 @@ IEditor *GitGrep::openEditor(const SearchResultItem &item, if (content.isEmpty()) return nullptr; QByteArray fileContent; - if (TextFileFormat::readFileUTF8(path, 0, &fileContent, 0) == TextFileFormat::ReadSuccess) { + if (TextFileFormat::readFileUTF8(path, nullptr, &fileContent, nullptr) + == TextFileFormat::ReadSuccess) { if (fileContent == content) return nullptr; // open the file for read/write } diff --git a/src/plugins/git/githighlighters.cpp b/src/plugins/git/githighlighters.cpp index d0f87a3cc9b..763a3b9f79f 100644 --- a/src/plugins/git/githighlighters.cpp +++ b/src/plugins/git/githighlighters.cpp @@ -46,7 +46,7 @@ GitSubmitHighlighter::GitSubmitHighlighter(QTextEdit * parent) : void GitSubmitHighlighter::highlightBlock(const QString &text) { // figure out current state - State state = static_cast(previousBlockState()); + auto state = static_cast(previousBlockState()); if (text.trimmed().isEmpty()) { if (state == Header) state = Other; diff --git a/src/plugins/git/githighlighters.h b/src/plugins/git/githighlighters.h index 055d3721eed..27ab98036e5 100644 --- a/src/plugins/git/githighlighters.h +++ b/src/plugins/git/githighlighters.h @@ -51,7 +51,7 @@ enum Format { class GitSubmitHighlighter : public TextEditor::SyntaxHighlighter { public: - explicit GitSubmitHighlighter(QTextEdit *parent = 0); + explicit GitSubmitHighlighter(QTextEdit *parent = nullptr); void highlightBlock(const QString &text) override; private: @@ -65,7 +65,7 @@ private: class GitRebaseHighlighter : public TextEditor::SyntaxHighlighter { public: - explicit GitRebaseHighlighter(QTextDocument *parent = 0); + explicit GitRebaseHighlighter(QTextDocument *parent = nullptr); void highlightBlock(const QString &text) override; private: diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp index 1b106745111..2869d73bc7d 100644 --- a/src/plugins/git/gitplugin.cpp +++ b/src/plugins/git/gitplugin.cpp @@ -128,7 +128,7 @@ const VcsBaseEditorParameters editorParameters[] = { // GitPlugin -static GitPlugin *m_instance = 0; +static GitPlugin *m_instance = nullptr; GitPlugin::GitPlugin() { @@ -142,7 +142,7 @@ GitPlugin::~GitPlugin() { cleanCommitMessageFile(); delete m_gitClient; - m_instance = 0; + m_instance = nullptr; } void GitPlugin::cleanCommitMessageFile() @@ -986,8 +986,8 @@ void GitPlugin::updateVersionWarning() IEditor *GitPlugin::openSubmitEditor(const QString &fileName, const CommitData &cd) { IEditor *editor = EditorManager::openEditor(fileName, Constants::GITSUBMITEDITOR_ID); - GitSubmitEditor *submitEditor = qobject_cast(editor); - QTC_ASSERT(submitEditor, return 0); + auto submitEditor = qobject_cast(editor); + QTC_ASSERT(submitEditor, return nullptr); setSubmitEditor(submitEditor); submitEditor->setCommitData(cd); submitEditor->setCheckScriptWorkingDirectory(m_submitRepository); @@ -1020,7 +1020,7 @@ bool GitPlugin::submitEditorAboutToClose() { if (!isCommitEditorOpen()) return true; - GitSubmitEditor *editor = qobject_cast(submitEditor()); + auto editor = qobject_cast(submitEditor()); QTC_ASSERT(editor, return true); IDocument *editorDocument = editor->document(); QTC_ASSERT(editorDocument, return true); @@ -1052,7 +1052,7 @@ bool GitPlugin::submitEditorAboutToClose() // Go ahead! - SubmitFileModel *model = qobject_cast(editor->fileModel()); + auto model = qobject_cast(editor->fileModel()); CommitType commitType = editor->commitType(); QString amendSHA1 = editor->amendSHA1(); if (model->hasCheckedFiles() || !amendSHA1.isEmpty()) { @@ -1111,7 +1111,7 @@ void GitPlugin::pull() if (!m_gitClient->beginStashScope(topLevel, "Pull", rebase ? Default : AllowUnstashed)) return; - m_gitClient->synchronousPull(topLevel, rebase); + m_gitClient->pull(topLevel, rebase); } void GitPlugin::push() diff --git a/src/plugins/git/gitplugin.h b/src/plugins/git/gitplugin.h index a4474379e30..3a73ebc1b73 100644 --- a/src/plugins/git/gitplugin.h +++ b/src/plugins/git/gitplugin.h @@ -74,7 +74,7 @@ class GitPlugin : public VcsBase::VcsBasePlugin public: GitPlugin(); - ~GitPlugin(); + ~GitPlugin() override; static GitPlugin *instance(); static GitClient *client(); diff --git a/src/plugins/git/gitsettings.cpp b/src/plugins/git/gitsettings.cpp index eee0c534519..cc84fade0e8 100644 --- a/src/plugins/git/gitsettings.cpp +++ b/src/plugins/git/gitsettings.cpp @@ -37,6 +37,7 @@ const QLatin1String GitSettings::showTagsKey("ShowTags"); const QLatin1String GitSettings::omitAnnotationDateKey("OmitAnnotationDate"); const QLatin1String GitSettings::ignoreSpaceChangesInDiffKey("SpaceIgnorantDiff"); const QLatin1String GitSettings::ignoreSpaceChangesInBlameKey("SpaceIgnorantBlame"); +const QLatin1String GitSettings::blameMoveDetection("BlameDetectMove"); const QLatin1String GitSettings::diffPatienceKey("DiffPatience"); const QLatin1String GitSettings::winSetHomeEnvironmentKey("WinSetHomeEnvironment"); const QLatin1String GitSettings::gitkOptionsKey("GitKOptions"); @@ -56,6 +57,7 @@ GitSettings::GitSettings() declareKey(showTagsKey, false); declareKey(omitAnnotationDateKey, false); declareKey(ignoreSpaceChangesInDiffKey, true); + declareKey(blameMoveDetection, 0); declareKey(ignoreSpaceChangesInBlameKey, true); declareKey(diffPatienceKey, true); declareKey(winSetHomeEnvironmentKey, true); diff --git a/src/plugins/git/gitsettings.h b/src/plugins/git/gitsettings.h index aafd6ddd083..4a33bdc8761 100644 --- a/src/plugins/git/gitsettings.h +++ b/src/plugins/git/gitsettings.h @@ -48,6 +48,7 @@ public: static const QLatin1String omitAnnotationDateKey; static const QLatin1String ignoreSpaceChangesInDiffKey; static const QLatin1String ignoreSpaceChangesInBlameKey; + static const QLatin1String blameMoveDetection; static const QLatin1String diffPatienceKey; static const QLatin1String winSetHomeEnvironmentKey; static const QLatin1String gitkOptionsKey; diff --git a/src/plugins/git/gitsubmiteditor.cpp b/src/plugins/git/gitsubmiteditor.cpp index 4263219e8e7..cca31f87240 100644 --- a/src/plugins/git/gitsubmiteditor.cpp +++ b/src/plugins/git/gitsubmiteditor.cpp @@ -51,13 +51,13 @@ namespace Internal { class GitSubmitFileModel : public SubmitFileModel { public: - GitSubmitFileModel(QObject *parent = 0) : SubmitFileModel(parent) + GitSubmitFileModel(QObject *parent = nullptr) : SubmitFileModel(parent) { } void updateSelections(SubmitFileModel *source) override { QTC_ASSERT(source, return); - GitSubmitFileModel *gitSource = static_cast(source); + auto gitSource = static_cast(source); int j = 0; for (int i = 0; i < rowCount() && j < source->rowCount(); ++i) { CommitData::StateFilePair stateFile = stateFilePair(i); diff --git a/src/plugins/git/gitutils.cpp b/src/plugins/git/gitutils.cpp index 371a00885ec..c0f5ffd7544 100644 --- a/src/plugins/git/gitutils.cpp +++ b/src/plugins/git/gitutils.cpp @@ -74,7 +74,7 @@ bool inputText(QWidget *parent, const QString &title, const QString &prompt, QSt dialog.setLabelText(prompt); dialog.setTextValue(*s); // Nasty hack: - if (QLineEdit *le = dialog.findChild()) + if (auto le = dialog.findChild()) le->setMinimumWidth(500); if (dialog.exec() != QDialog::Accepted) return false; diff --git a/src/plugins/git/logchangedialog.cpp b/src/plugins/git/logchangedialog.cpp index c6dd0a4a168..e57dda49e0f 100644 --- a/src/plugins/git/logchangedialog.cpp +++ b/src/plugins/git/logchangedialog.cpp @@ -159,7 +159,7 @@ bool LogChangeWidget::populateLog(const QString &repository, const QString &comm arguments << "--not" << "--remotes"; arguments << "--"; QString output; - if (!GitPlugin::client()->synchronousLog(repository, arguments, &output, 0, VcsCommand::NoOutput)) + if (!GitPlugin::client()->synchronousLog(repository, arguments, &output, nullptr, VcsCommand::NoOutput)) return false; const QStringList lines = output.split('\n'); for (const QString &line : lines) { @@ -193,14 +193,13 @@ const QStandardItem *LogChangeWidget::currentItem(int column) const const QModelIndex currentIndex = selectionModel()->currentIndex(); if (currentIndex.isValid()) return m_model->item(currentIndex.row(), column); - return 0; + return nullptr; } LogChangeDialog::LogChangeDialog(bool isReset, QWidget *parent) : QDialog(parent) , m_widget(new LogChangeWidget) , m_dialogButtonBox(new QDialogButtonBox(this)) - , m_resetTypeComboBox(0) { auto layout = new QVBoxLayout(this); layout->addWidget(new QLabel(isReset ? tr("Reset to:") : tr("Select change:"), this)); diff --git a/src/plugins/git/logchangedialog.h b/src/plugins/git/logchangedialog.h index 9576d9d3610..dfd83f4bf03 100644 --- a/src/plugins/git/logchangedialog.h +++ b/src/plugins/git/logchangedialog.h @@ -96,9 +96,9 @@ public: LogChangeWidget *widget() const; private: - LogChangeWidget *m_widget; - QDialogButtonBox *m_dialogButtonBox; - QComboBox *m_resetTypeComboBox; + LogChangeWidget *m_widget = nullptr; + QDialogButtonBox *m_dialogButtonBox = nullptr; + QComboBox *m_resetTypeComboBox = nullptr; }; class LogItemDelegate : public QStyledItemDelegate diff --git a/src/plugins/git/mergetool.h b/src/plugins/git/mergetool.h index d5d3d45f645..667ba09fdb1 100644 --- a/src/plugins/git/mergetool.h +++ b/src/plugins/git/mergetool.h @@ -50,8 +50,8 @@ class MergeTool : public QObject }; public: - explicit MergeTool(QObject *parent = 0); - ~MergeTool(); + explicit MergeTool(QObject *parent = nullptr); + ~MergeTool() override; bool start(const QString &workingDirectory, const QStringList &files = QStringList()); enum MergeType { diff --git a/src/plugins/git/remotedialog.h b/src/plugins/git/remotedialog.h index 8495fdc73a8..1026c2e721f 100644 --- a/src/plugins/git/remotedialog.h +++ b/src/plugins/git/remotedialog.h @@ -39,7 +39,7 @@ class RemoteDialog : public QDialog Q_OBJECT public: - explicit RemoteDialog(QWidget *parent = 0); + explicit RemoteDialog(QWidget *parent = nullptr); ~RemoteDialog() override; void refresh(const QString &repository, bool force); diff --git a/src/plugins/git/remotemodel.h b/src/plugins/git/remotemodel.h index 6ac83e32faf..d0622996a0d 100644 --- a/src/plugins/git/remotemodel.h +++ b/src/plugins/git/remotemodel.h @@ -35,7 +35,7 @@ namespace Internal { class RemoteModel : public QAbstractTableModel { Q_OBJECT public: - explicit RemoteModel(QObject *parent = 0); + explicit RemoteModel(QObject *parent = nullptr); void clear(); bool refresh(const QString &workingDirectory, QString *errorMessage); diff --git a/src/plugins/git/settingspage.cpp b/src/plugins/git/settingspage.cpp index 123d4d29380..9026d0f26f7 100644 --- a/src/plugins/git/settingspage.cpp +++ b/src/plugins/git/settingspage.cpp @@ -120,7 +120,7 @@ void SettingsPage::apply() if (widget()->isVisible()) { const VcsBaseClientSettings settings = widget()->settings(); - const GitSettings *rc = static_cast(&settings); + auto rc = static_cast(&settings); bool gitFoundOk; QString errorMessage; rc->gitExecutable(&gitFoundOk, &errorMessage); diff --git a/src/plugins/git/settingspage.h b/src/plugins/git/settingspage.h index 187cf75af9e..e97ae59dece 100644 --- a/src/plugins/git/settingspage.h +++ b/src/plugins/git/settingspage.h @@ -43,7 +43,7 @@ class SettingsPageWidget : public VcsBase::VcsClientOptionsPageWidget { Q_OBJECT public: - explicit SettingsPageWidget(QWidget *parent = 0); + explicit SettingsPageWidget(QWidget *parent = nullptr); VcsBase::VcsBaseClientSettings settings() const override; void setSettings(const VcsBase::VcsBaseClientSettings &s) override; diff --git a/src/plugins/git/stashdialog.cpp b/src/plugins/git/stashdialog.cpp index ffa9ac66247..e20cb6dcc89 100644 --- a/src/plugins/git/stashdialog.cpp +++ b/src/plugins/git/stashdialog.cpp @@ -63,7 +63,7 @@ static inline QList stashModelRowItems(const Stash &s) // ----------- StashModel class StashModel : public QStandardItemModel { public: - explicit StashModel(QObject *parent = 0); + explicit StashModel(QObject *parent = nullptr); void setStashes(const QList &stashes); const Stash &at(int i) { return m_stashes.at(i); } @@ -189,7 +189,7 @@ void StashDialog::deleteSelection() const QList rows = selectedRows(); QTC_ASSERT(!rows.isEmpty(), return); const QString title = tr("Delete Stashes"); - if (!ask(title, tr("Do you want to delete %n stash(es)?", 0, rows.size()))) + if (!ask(title, tr("Do you want to delete %n stash(es)?", nullptr, rows.size()))) return; QString errorMessage; QStringList errors; @@ -267,7 +267,7 @@ bool StashDialog::promptForRestore(QString *stash, { const QString stashIn = *stash; bool modifiedPromptShown = false; - switch (GitPlugin::client()->gitStatus(m_repository, StatusMode(NoUntracked | NoSubmodules), 0, errorMessage)) { + switch (GitPlugin::client()->gitStatus(m_repository, StatusMode(NoUntracked | NoSubmodules), nullptr, errorMessage)) { case GitClient::StatusFailed: return false; case GitClient::StatusChanged: { @@ -317,7 +317,7 @@ void StashDialog::restoreCurrent() QString name = m_model->at(index).name; // Make sure repository is not modified, restore. The command will // output to window on success. - if (promptForRestore(&name, 0, &errorMessage) + if (promptForRestore(&name, nullptr, &errorMessage) && GitPlugin::client()->synchronousStashRestore(m_repository, name)) { refresh(m_repository, true); // Might have stashed away local changes. } else if (!errorMessage.isEmpty()) { diff --git a/src/plugins/git/stashdialog.h b/src/plugins/git/stashdialog.h index bf725090947..5aa8c52213f 100644 --- a/src/plugins/git/stashdialog.h +++ b/src/plugins/git/stashdialog.h @@ -48,7 +48,7 @@ class StashDialog : public QDialog Q_OBJECT public: - explicit StashDialog(QWidget *parent = 0); + explicit StashDialog(QWidget *parent = nullptr); ~StashDialog() override; void refresh(const QString &repository, bool force); diff --git a/src/plugins/help/webenginehelpviewer.cpp b/src/plugins/help/webenginehelpviewer.cpp index 08d5f44e600..60773b91fef 100644 --- a/src/plugins/help/webenginehelpviewer.cpp +++ b/src/plugins/help/webenginehelpviewer.cpp @@ -96,7 +96,6 @@ WebEngineHelpViewer::WebEngineHelpViewer(QWidget *parent) : QTimer::singleShot(/*magic timeout=*/150, this, [this] { QUrl urlWithoutFragment = source(); urlWithoutFragment.setFragment(QString()); - qDebug() << urlWithoutFragment << m_previousUrlWithoutFragment; if (urlWithoutFragment == m_previousUrlWithoutFragment) slotLoadFinished(); m_previousUrlWithoutFragment = urlWithoutFragment; diff --git a/src/plugins/languageclient/baseclient.cpp b/src/plugins/languageclient/baseclient.cpp index e124a4c3af8..6683172f20c 100644 --- a/src/plugins/languageclient/baseclient.cpp +++ b/src/plugins/languageclient/baseclient.cpp @@ -51,6 +51,7 @@ #include #include #include +#include using namespace LanguageServerProtocol; using namespace Utils; @@ -150,9 +151,13 @@ void BaseClient::openDocument(Core::IDocument *document) if (textDocument) { textDocument->setCompletionAssistProvider(new LanguageClientCompletionAssistProvider(this)); if (BaseTextEditor *editor = BaseTextEditor::textEditorForDocument(textDocument)) { - if (TextEditorWidget *widget = editor->editorWidget()) { + if (QPointer widget = editor->editorWidget()) { connect(widget, &TextEditorWidget::cursorPositionChanged, this, [this, widget](){ - cursorPositionChanged(widget); + // TODO This would better be a compressing timer + QTimer::singleShot(50, this, [this, widget]() { + if (widget) + cursorPositionChanged(widget); + }); }); } } @@ -494,8 +499,11 @@ bool BaseClient::isSupportedMimeType(const QString &mimeType) const return m_supportedMimeTypes.isEmpty() || m_supportedMimeTypes.contains(mimeType); } -void BaseClient::reset() +bool BaseClient::reset() { + if (!m_restartsLeft) + return false; + --m_restartsLeft; m_state = Uninitialized; m_responseHandlers.clear(); m_buffer.close(); @@ -504,6 +512,7 @@ void BaseClient::reset() m_openedDocument.clear(); m_serverCapabilities = ServerCapabilities(); m_dynamicCapabilities.reset(); + return true; } void BaseClient::setError(const QString &message) @@ -762,10 +771,9 @@ void StdIOClient::setWorkingDirectory(const QString &workingDirectory) m_process.setWorkingDirectory(workingDirectory); } -bool StdIOClient::matches(const LanguageClientSettings &setting) +bool StdIOClient::matches(const BaseSettings *setting) { - return setting.m_executable == m_executable - && setting.m_arguments == m_executable; + return setting->m_executable == m_executable && setting->m_arguments == m_arguments; } void StdIOClient::sendData(const QByteArray &data) diff --git a/src/plugins/languageclient/baseclient.h b/src/plugins/languageclient/baseclient.h index 543d67cbc36..08077f37ab9 100644 --- a/src/plugins/languageclient/baseclient.h +++ b/src/plugins/languageclient/baseclient.h @@ -113,8 +113,8 @@ public: Core::Id id() const { return m_id; } virtual bool start() { return true; } - virtual bool matches(const LanguageClientSettings &/*setting*/) { return false; } - virtual void reset(); + virtual bool matches(const BaseSettings * /*setting*/) { return false; } + virtual bool reset(); void log(const QString &message, Core::MessageManager::PrintToOutputPaneFlag flag = Core::MessageManager::NoModeSwitch); @@ -159,6 +159,7 @@ private: DynamicCapabilities m_dynamicCapabilities; LanguageServerProtocol::BaseMessage m_currentMessage; QHash m_highlightRequests; + int m_restartsLeft = 5; }; class StdIOClient : public BaseClient @@ -178,7 +179,7 @@ public: void setWorkingDirectory(const QString &workingDirectory); - bool matches(const LanguageClientSettings &setting) override; + bool matches(const BaseSettings *setting) override; protected: void sendData(const QByteArray &data) final; diff --git a/src/plugins/languageclient/languageclientmanager.cpp b/src/plugins/languageclient/languageclientmanager.cpp index ec618b6d6bc..b3e034f1d7b 100644 --- a/src/plugins/languageclient/languageclientmanager.cpp +++ b/src/plugins/languageclient/languageclientmanager.cpp @@ -82,8 +82,7 @@ LanguageClientManager::LanguageClientManager() LanguageClientManager::~LanguageClientManager() { - for (auto interface : Utils::filtered(m_clients, &BaseClient::reachable)) - interface->shutdown(); + QTC_ASSERT(m_clients.isEmpty(), qDeleteAll(m_clients)); } void LanguageClientManager::init() @@ -166,18 +165,14 @@ void LanguageClientManager::removeMarks(const Core::Id &id) removeMarks(fileName, id); } -void LanguageClientManager::startClient(LanguageClientSettings setting) -{ - auto client = new StdIOClient(setting.m_executable, setting.m_arguments); - client->setName(setting.m_name); - if (setting.m_mimeType != noLanguageFilter) - client->setSupportedMimeType({setting.m_mimeType}); - startClient(client); -} - void LanguageClientManager::startClient(BaseClient *client) { - managerInstance->m_clients.append(client); + if (managerInstance->m_shuttingDown) { + managerInstance->clientFinished(client); + return; + } + if (!managerInstance->m_clients.contains(client)) + managerInstance->m_clients.append(client); connect(client, &BaseClient::finished, managerInstance, [client](){ managerInstance->clientFinished(client); }); @@ -206,6 +201,28 @@ void LanguageClientManager::reportFinished(const MessageId &id, BaseClient *byCl managerInstance->m_exclusiveRequests.remove(id); } +void LanguageClientManager::deleteClient(BaseClient *client) +{ + QTC_ASSERT(client, return); + managerInstance->removeMarks(client->id()); + managerInstance->m_clients.removeAll(client); + delete client; +} + +void LanguageClientManager::shutdown() +{ + if (managerInstance->m_shuttingDown) + return; + managerInstance->m_shuttingDown = true; + for (auto interface : managerInstance->m_clients) + interface->shutdown(); +} + +LanguageClientManager *LanguageClientManager::instance() +{ + return managerInstance; +} + QVector LanguageClientManager::reachableClients() { return Utils::filtered(m_clients, &BaseClient::reachable); @@ -227,16 +244,16 @@ void LanguageClientManager::clientFinished(BaseClient *client) constexpr int restartTimeoutS = 5; const bool unexpectedFinish = client->state() != BaseClient::Shutdown && client->state() != BaseClient::ShutdownRequested; - managerInstance->removeMarks(client->id()); - managerInstance->m_clients.removeAll(client); - if (unexpectedFinish) { - client->disconnect(managerInstance); + if (unexpectedFinish && !m_shuttingDown && client->reset()) { + removeMarks(client->id()); + client->disconnect(this); client->log(tr("Unexpectedly finished. Restarting in %1 seconds.").arg(restartTimeoutS), Core::MessageManager::Flash); - client->reset(); - QTimer::singleShot(restartTimeoutS * 1000, this, [client](){ startClient(client); }); + QTimer::singleShot(restartTimeoutS * 1000, client, [client](){ startClient(client); }); } else { - delete client; + deleteClient(client); + if (m_shuttingDown && m_clients.isEmpty()) + emit shutdownFinished(); } } diff --git a/src/plugins/languageclient/languageclientmanager.h b/src/plugins/languageclient/languageclientmanager.h index 3ccf56c765f..2d41f117318 100644 --- a/src/plugins/languageclient/languageclientmanager.h +++ b/src/plugins/languageclient/languageclientmanager.h @@ -61,13 +61,21 @@ public: static void removeMarks(const Utils::FileName &fileName, const Core::Id &id); static void removeMarks(const Core::Id &id); - static void startClient(LanguageClientSettings setting); static void startClient(BaseClient *client); static QVector clients(); static void addExclusiveRequest(const LanguageServerProtocol::MessageId &id, BaseClient *client); static void reportFinished(const LanguageServerProtocol::MessageId &id, BaseClient *byClient); + static void deleteClient(BaseClient *client); + + static void shutdown(); + + static LanguageClientManager *instance(); + +signals: + void shutdownFinished(); + private: LanguageClientManager(); LanguageClientManager(const LanguageClientManager &other) = delete; @@ -88,6 +96,7 @@ private: void clientFinished(BaseClient *client); + bool m_shuttingDown = false; QVector m_clients; QHash>> m_marks; QHash> m_exclusiveRequests; diff --git a/src/plugins/languageclient/languageclientplugin.cpp b/src/plugins/languageclient/languageclientplugin.cpp index 4fd3cedfcf8..53a0252592a 100644 --- a/src/plugins/languageclient/languageclientplugin.cpp +++ b/src/plugins/languageclient/languageclientplugin.cpp @@ -25,6 +25,8 @@ #include "languageclientplugin.h" +#include "baseclient.h" + namespace LanguageClient { bool LanguageClientPlugin::initialize(const QStringList & /*arguments*/, QString * /*errorString*/) @@ -38,4 +40,14 @@ void LanguageClientPlugin::extensionsInitialized() LanguageClientSettings::init(); } +ExtensionSystem::IPlugin::ShutdownFlag LanguageClientPlugin::aboutToShutdown() +{ + LanguageClientManager::shutdown(); + if (LanguageClientManager::clients().isEmpty()) + return ExtensionSystem::IPlugin::SynchronousShutdown; + connect(LanguageClientManager::instance(), &LanguageClientManager::shutdownFinished, + this, &ExtensionSystem::IPlugin::asynchronousShutdownFinished); + return ExtensionSystem::IPlugin::AsynchronousShutdown; +} + } // namespace LanguageClient diff --git a/src/plugins/languageclient/languageclientplugin.h b/src/plugins/languageclient/languageclientplugin.h index 31a4c1ae99b..5b34c049a7e 100644 --- a/src/plugins/languageclient/languageclientplugin.h +++ b/src/plugins/languageclient/languageclientplugin.h @@ -43,6 +43,7 @@ public: private: bool initialize(const QStringList &arguments, QString *errorString) override; void extensionsInitialized() override; + ShutdownFlag aboutToShutdown() override; private: LanguageClientManager m_clientManager; diff --git a/src/plugins/languageclient/languageclientsettings.cpp b/src/plugins/languageclient/languageclientsettings.cpp index e43d064f01a..4348e95e521 100644 --- a/src/plugins/languageclient/languageclientsettings.cpp +++ b/src/plugins/languageclient/languageclientsettings.cpp @@ -85,7 +85,7 @@ public: }; private: - QList m_settings; + QList m_settings; }; class LanguageClientSettingsPageWidget : public QWidget @@ -238,16 +238,17 @@ QVariant LanguageClientSettingsModel::data(const QModelIndex &index, int role) c { if (!index.isValid()) return QVariant(); - LanguageClientSettings setting = m_settings[index.row()]; + BaseSettings *setting = m_settings[index.row()]; + QTC_ASSERT(setting, return false); if (role == Qt::DisplayRole || role == Qt::EditRole) { switch (index.column()) { - case DisplayNameColumn: return setting.m_name; - case MimeTypeColumn: return setting.m_mimeType; - case ExecutableColumn: return setting.m_executable; - case ArgumentsColumn: return setting.m_arguments; + case DisplayNameColumn: return setting->m_name; + case MimeTypeColumn: return setting->m_mimeType; + case ExecutableColumn: return setting->m_executable; + case ArgumentsColumn: return setting->m_arguments; } } else if (role == Qt::CheckStateRole && index.column() == EnabledColumn) { - return setting.m_enabled ? Qt::Checked : Qt::Unchecked; + return setting->m_enabled ? Qt::Checked : Qt::Unchecked; } return QVariant(); } @@ -271,10 +272,10 @@ bool LanguageClientSettingsModel::removeRows(int row, int count, const QModelInd { if (row >= int(m_settings.size())) return false; - const auto first = m_settings.begin() + row; const int end = qMin(row + count - 1, int(m_settings.size()) - 1); beginRemoveRows(parent, row, end); - m_settings.erase(first, first + count); + for (auto i = end; i >= row; --i) + delete m_settings.takeAt(i); endRemoveRows(); return true; } @@ -285,7 +286,7 @@ bool LanguageClientSettingsModel::insertRows(int row, int count, const QModelInd return false; beginInsertRows(parent, row, row + count - 1); for (int i = 0; i < count; ++i) - m_settings.insert(row + i, {}); + m_settings.insert(row + i, new BaseSettings()); endInsertRows(); return true; } @@ -294,13 +295,14 @@ bool LanguageClientSettingsModel::setData(const QModelIndex &index, const QVaria { if (!index.isValid()) return false; - LanguageClientSettings &setting = m_settings[index.row()]; + BaseSettings *setting = m_settings[index.row()]; + QTC_ASSERT(setting, return false); if (role == Qt::DisplayRole || role == Qt::EditRole) { switch (index.column()) { - case DisplayNameColumn: setting.m_name = value.toString(); break; - case MimeTypeColumn: setting.m_mimeType = value.toString(); break; - case ExecutableColumn: setting.m_executable = value.toString(); break; - case ArgumentsColumn: setting.m_arguments = value.toString(); break; + case DisplayNameColumn: setting->m_name = value.toString(); break; + case MimeTypeColumn: setting->m_mimeType = value.toString(); break; + case ExecutableColumn: setting->m_executable = value.toString(); break; + case ArgumentsColumn: setting->m_arguments = value.toString(); break; default: return false; } @@ -308,7 +310,7 @@ bool LanguageClientSettingsModel::setData(const QModelIndex &index, const QVaria return true; } if (role == Qt::CheckStateRole && index.column() == EnabledColumn) { - setting.m_enabled = value.toBool(); + setting->m_enabled = value.toBool(); emit dataChanged(index, index, { Qt::CheckStateRole }); return true; } @@ -327,8 +329,8 @@ void LanguageClientSettingsModel::toSettings(QSettings *settings) const { settings->beginGroup(settingsGroupKey); settings->setValue(clientsKey, Utils::transform(m_settings, - [](const LanguageClientSettings & setting){ - return QVariant(setting.toMap()); + [](const BaseSettings *setting){ + return QVariant(setting->toMap()); })); settings->endGroup(); } @@ -339,7 +341,9 @@ void LanguageClientSettingsModel::fromSettings(QSettings *settings) auto variants = settings->value(clientsKey).toList(); m_settings.reserve(variants.size()); m_settings = Utils::transform(variants, [](const QVariant& var){ - return LanguageClientSettings::fromMap(var.toMap()); + auto settings = new BaseSettings(); + settings->fromMap(var.toMap()); + return settings; }); settings->endGroup(); } @@ -348,43 +352,48 @@ void LanguageClientSettingsModel::applyChanges() { const QVector interfaces(LanguageClientManager::clients()); QVector toShutdown; - QList toStart = m_settings; + QList toStart = m_settings; // check currently registered interfaces for (auto interface : interfaces) { - auto setting = Utils::findOr(m_settings, LanguageClientSettings(), [interface](const LanguageClientSettings &setting){ + auto setting = Utils::findOr(m_settings, nullptr, + [interface](const BaseSettings *setting){ return interface->matches(setting); }); - if (setting.isValid() && setting.m_enabled) { + if (setting && setting->isValid() && setting->m_enabled) { toStart.removeAll(setting); - if (!interface->isSupportedMimeType(setting.m_mimeType)) - interface->setSupportedMimeType({setting.m_mimeType}); + if (!interface->isSupportedMimeType(setting->m_mimeType)) + interface->setSupportedMimeType({setting->m_mimeType}); } else { toShutdown << interface; } } - for (auto interface : toShutdown) - interface->shutdown(); + for (auto interface : toShutdown) { + if (interface->reachable()) + interface->shutdown(); + else + LanguageClientManager::deleteClient(interface); + } for (auto setting : toStart) { - if (setting.isValid() && setting.m_enabled) - LanguageClientManager::startClient(setting); + if (setting && setting->isValid() && setting->m_enabled) + LanguageClientManager::startClient(setting->createClient()); } } -bool LanguageClientSettings::isValid() +bool BaseSettings::isValid() { return !m_name.isEmpty() && !m_executable.isEmpty() && QFile::exists(m_executable); } -bool LanguageClientSettings::operator==(const LanguageClientSettings &other) const +BaseClient *BaseSettings::createClient() { - return m_name == other.m_name - && m_enabled == other.m_enabled - && m_mimeType == other.m_mimeType - && m_executable == other.m_executable - && m_arguments == other.m_arguments; + auto client = new StdIOClient(m_executable, m_arguments); + client->setName(m_name); + if (m_mimeType != noLanguageFilter) + client->setSupportedMimeType({m_mimeType}); + return client; } -QVariantMap LanguageClientSettings::toMap() const +QVariantMap BaseSettings::toMap() const { QVariantMap map; map.insert(nameKey, m_name); @@ -395,13 +404,13 @@ QVariantMap LanguageClientSettings::toMap() const return map; } -LanguageClientSettings LanguageClientSettings::fromMap(const QVariantMap &map) +void BaseSettings::fromMap(const QVariantMap &map) { - return { map[nameKey].toString(), - map[enabledKey].toBool(), - map[mimeTypeKey].toString(), - map[executableKey].toString(), - map[argumentsKey].toString() }; + m_name = map[nameKey].toString(); + m_enabled = map[enabledKey].toBool(); + m_mimeType = map[mimeTypeKey].toString(); + m_executable = map[executableKey].toString(); + m_arguments = map[argumentsKey].toString(); } void LanguageClientSettings::init() diff --git a/src/plugins/languageclient/languageclientsettings.h b/src/plugins/languageclient/languageclientsettings.h index 152281de5a4..0671092928e 100644 --- a/src/plugins/languageclient/languageclientsettings.h +++ b/src/plugins/languageclient/languageclientsettings.h @@ -35,12 +35,20 @@ namespace LanguageClient { constexpr char noLanguageFilter[] = "No Filter"; +class BaseClient; + class LanguageClientSettings { public: - LanguageClientSettings() = default; - LanguageClientSettings(const QString &name, bool enabled, const QString &mimeTypeName, - const QString &executable, const QString &arguments) + static void init(); +}; + +class BaseSettings +{ +public: + BaseSettings() = default; + BaseSettings(const QString &name, bool enabled, const QString &mimeTypeName, + const QString &executable, const QString &arguments) : m_name(name) , m_enabled(enabled) , m_mimeType(mimeTypeName) @@ -55,12 +63,10 @@ public: bool isValid(); - bool operator==(const LanguageClientSettings &other) const; + BaseClient *createClient(); QVariantMap toMap() const; - static LanguageClientSettings fromMap(const QVariantMap &map); - static void init(); + void fromMap(const QVariantMap &map); }; - } // namespace LanguageClient diff --git a/src/plugins/perforce/perforcechecker.h b/src/plugins/perforce/perforcechecker.h index e1a7ec67b69..ed346ab4311 100644 --- a/src/plugins/perforce/perforcechecker.h +++ b/src/plugins/perforce/perforcechecker.h @@ -40,7 +40,7 @@ class PerforceChecker : public QObject Q_OBJECT public: explicit PerforceChecker(QObject *parent = nullptr); - ~PerforceChecker(); + ~PerforceChecker() override; void start(const QString &binary, const QString &workingDirectory, diff --git a/src/plugins/perforce/perforceplugin.cpp b/src/plugins/perforce/perforceplugin.cpp index 22348b5a705..1ad1cf7dc57 100644 --- a/src/plugins/perforce/perforceplugin.cpp +++ b/src/plugins/perforce/perforceplugin.cpp @@ -108,8 +108,9 @@ const VcsBaseEditorParameters editorParameters[] = { // Utility to find a parameter set by type static inline const VcsBaseEditorParameters *findType(int ie) { - const EditorContentType et = static_cast(ie); - return VcsBaseEditor::findType(editorParameters, sizeof(editorParameters)/sizeof(editorParameters[0]), et); + return VcsBaseEditor::findType(editorParameters, + sizeof(editorParameters)/sizeof(*editorParameters), + static_cast(ie)); } // Ensure adding "..." to relative paths which is p4's convention @@ -601,7 +602,7 @@ void PerforcePlugin::startSubmitProject() IEditor *PerforcePlugin::openPerforceSubmitEditor(const QString &fileName, const QStringList &depotFileNames) { IEditor *editor = EditorManager::openEditor(fileName, PERFORCE_SUBMIT_EDITOR_ID); - PerforceSubmitEditor *submitEditor = static_cast(editor); + auto submitEditor = static_cast(editor); setSubmitEditor(submitEditor); submitEditor->restrictToProjectFiles(depotFileNames); connect(submitEditor, &VcsBaseSubmitEditor::diffSelectedFiles, diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro index 2829f1f2330..ae9a31f0258 100644 --- a/src/plugins/plugins.pro +++ b/src/plugins/plugins.pro @@ -58,7 +58,8 @@ SUBDIRS = \ welcome \ silversearcher \ languageclient \ - cppcheck + cppcheck \ + compilationdatabaseprojectmanager qtHaveModule(serialport) { SUBDIRS += serialterminal diff --git a/src/plugins/projectexplorer/environmentwidget.cpp b/src/plugins/projectexplorer/environmentwidget.cpp index d392a670ca5..ad643e78bea 100644 --- a/src/plugins/projectexplorer/environmentwidget.cpp +++ b/src/plugins/projectexplorer/environmentwidget.cpp @@ -207,8 +207,9 @@ EnvironmentWidget::EnvironmentWidget(QWidget *parent, QWidget *additionalDetails d->m_terminalButton = new QPushButton(this); d->m_terminalButton->setText(tr("Open &Terminal")); d->m_terminalButton->setToolTip(tr("Open a terminal with this environment set up.")); -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) buttonLayout->addWidget(d->m_terminalButton); +#if defined(Q_OS_UNIX) && QT_VERSION < QT_VERSION_CHECK(5, 10, 0) + d->m_terminalButton->setVisible(false); #endif buttonLayout->addStretch(); diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index e3cb0bec002..ac34204fb72 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -872,7 +872,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er dd->m_openTerminalHereBuildEnv = new QAction(tr("Build Environment"), this); dd->m_openTerminalHereRunEnv = new QAction(tr("Run Environment"), this); -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) +#if !defined(Q_OS_UNIX) || QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) cmd = ActionManager::registerAction(dd->m_openTerminalHereBuildEnv, Constants::OPENTERMINALHEREBUILD, projecTreeContext); dd->m_openTerminalMenu->addAction(dd->m_openTerminalHereBuildEnv); diff --git a/src/plugins/projectexplorer/projectexplorerconstants.h b/src/plugins/projectexplorer/projectexplorerconstants.h index 61f1429fbe9..5fcb7f95f19 100644 --- a/src/plugins/projectexplorer/projectexplorerconstants.h +++ b/src/plugins/projectexplorer/projectexplorerconstants.h @@ -163,6 +163,7 @@ const char MINGW_TOOLCHAIN_TYPEID[] = "ProjectExplorer.ToolChain.Mingw"; const char MSVC_TOOLCHAIN_TYPEID[] = "ProjectExplorer.ToolChain.Msvc"; const char CLANG_CL_TOOLCHAIN_TYPEID[] = "ProjectExplorer.ToolChain.ClangCl"; const char CUSTOM_TOOLCHAIN_TYPEID[] = "ProjectExplorer.ToolChain.Custom"; +const char COMPILATION_DATABASE_TOOLCHAIN_TYPEID[] = "ProjectExplorer.ToolChain.Empty"; // Default directory to run custom (build) commands in. const char DEFAULT_WORKING_DIR[] = "%{buildDir}"; diff --git a/src/plugins/qmldesigner/components/componentcore/zoomaction.cpp b/src/plugins/qmldesigner/components/componentcore/zoomaction.cpp index bb7861b9fcd..11fcad983ff 100644 --- a/src/plugins/qmldesigner/components/componentcore/zoomaction.cpp +++ b/src/plugins/qmldesigner/components/componentcore/zoomaction.cpp @@ -39,7 +39,7 @@ ZoomAction::ZoomAction(QObject *parent) } -double ZoomAction::zoomLevel() const +float ZoomAction::zoomLevel() const { return m_zoomLevel; } @@ -63,9 +63,9 @@ void ZoomAction::resetZoomLevel() emit reseted(); } -void ZoomAction::setZoomLevel(double zoomLevel) +void ZoomAction::setZoomLevel(float zoomLevel) { - m_zoomLevel = qBound(0.1, zoomLevel, 16.0); + m_zoomLevel = qBound(0.1f, zoomLevel, 16.0f); emit zoomLevelChanged(m_zoomLevel); } @@ -121,7 +121,7 @@ void ZoomAction::emitZoomLevelChanged(int index) return; const QModelIndex modelIndex(m_comboBoxModel.data()->index(index, 0)); - setZoomLevel(m_comboBoxModel.data()->data(modelIndex, Qt::UserRole).toDouble()); + setZoomLevel(m_comboBoxModel.data()->data(modelIndex, Qt::UserRole).toFloat()); } } // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/components/componentcore/zoomaction.h b/src/plugins/qmldesigner/components/componentcore/zoomaction.h index d3b14ebd989..2bf02191240 100644 --- a/src/plugins/qmldesigner/components/componentcore/zoomaction.h +++ b/src/plugins/qmldesigner/components/componentcore/zoomaction.h @@ -42,7 +42,7 @@ class QMLDESIGNERCORE_EXPORT ZoomAction : public QWidgetAction public: ZoomAction(QObject *parent); - double zoomLevel() const; + float zoomLevel() const; void zoomIn(); void zoomOut(); @@ -50,9 +50,9 @@ public: protected: QWidget *createWidget(QWidget *parent) override; - void setZoomLevel(double zoomLevel); + void setZoomLevel(float zoomLevel); signals: - void zoomLevelChanged(double zoom); + void zoomLevelChanged(float zoom); void indexChanged(int); void reseted(); @@ -61,7 +61,7 @@ private: private: QPointer m_comboBoxModel; - double m_zoomLevel; + float m_zoomLevel; int m_currentComboBoxIndex; }; diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp index 86b3ac91659..60723c9f34a 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp @@ -130,16 +130,6 @@ void PropertyEditorQmlBackend::setupPropertyEditorValue(const PropertyName &name } -static PropertyNameList layoutAttachedPropertiesNames() -{ - PropertyNameList propertyNames; - propertyNames << "alignment" << "column" << "columnSpan" << "fillHeight" << "fillWidth" - << "maximumHeight" << "maximumWidth" << "minimumHeight" << "minimumWidth" - << "preferredHeight" << "preferredWidth" << "row"<< "rowSpan"; - - return propertyNames; -} - QVariant properDefaultLayoutAttachedProperties(const QmlObjectNode &qmlObjectNode, const PropertyName &propertyName) { QVariant value = qmlObjectNode.modelValue(propertyName); @@ -169,7 +159,9 @@ void PropertyEditorQmlBackend::setupLayoutAttachedProperties(const QmlObjectNode { if (QmlItemNode(qmlObjectNode).isInLayout()) { - static const PropertyNameList propertyNames = layoutAttachedPropertiesNames(); + static const PropertyNameList propertyNames = + {"alignment", "column", "columnSpan", "fillHeight", "fillWidth", "maximumHeight", "maximumWidth", + "minimumHeight", "minimumWidth", "preferredHeight", "preferredWidth", "row", "rowSpan"}; foreach (const PropertyName &propertyName, propertyNames) { createPropertyEditorValue(qmlObjectNode, "Layout." + propertyName, properDefaultLayoutAttachedProperties(qmlObjectNode, propertyName), propertyEditor); diff --git a/src/plugins/subversion/annotationhighlighter.h b/src/plugins/subversion/annotationhighlighter.h index 44cbeff72fd..128d8c1d761 100644 --- a/src/plugins/subversion/annotationhighlighter.h +++ b/src/plugins/subversion/annotationhighlighter.h @@ -36,10 +36,10 @@ class SubversionAnnotationHighlighter : public VcsBase::BaseAnnotationHighlighte Q_OBJECT public: explicit SubversionAnnotationHighlighter(const ChangeNumbers &changeNumbers, - QTextDocument *document = 0); + QTextDocument *document = nullptr); private: - QString changeNumber(const QString &block) const; + QString changeNumber(const QString &block) const override; const QChar m_blank; }; diff --git a/src/plugins/subversion/settingspage.h b/src/plugins/subversion/settingspage.h index e23e4176ff7..23ec7548c72 100644 --- a/src/plugins/subversion/settingspage.h +++ b/src/plugins/subversion/settingspage.h @@ -41,10 +41,10 @@ class SettingsPageWidget : public VcsBase::VcsClientOptionsPageWidget Q_OBJECT public: - explicit SettingsPageWidget(QWidget *parent = 0); + explicit SettingsPageWidget(QWidget *parent = nullptr); - VcsBase::VcsBaseClientSettings settings() const; - void setSettings(const VcsBase::VcsBaseClientSettings &s); + VcsBase::VcsBaseClientSettings settings() const override; + void setSettings(const VcsBase::VcsBaseClientSettings &s) override; private: Ui::SettingsPage m_ui; diff --git a/src/plugins/subversion/subversionclient.cpp b/src/plugins/subversion/subversionclient.cpp index 185a76c1a52..e5b0a356402 100644 --- a/src/plugins/subversion/subversionclient.cpp +++ b/src/plugins/subversion/subversionclient.cpp @@ -275,7 +275,7 @@ SubversionDiffEditorController *SubversionClient::findOrCreateDiffEditor(const Q const QString &workingDirectory) const { IDocument *document = DiffEditorController::findOrCreateDocument(documentId, title); - SubversionDiffEditorController *controller = qobject_cast( + auto controller = qobject_cast( DiffEditorController::controller(document)); if (!controller) controller = new SubversionDiffEditorController(document, workingDirectory); diff --git a/src/plugins/subversion/subversioncontrol.cpp b/src/plugins/subversion/subversioncontrol.cpp index 8bd9e36f37f..461bac97fdc 100644 --- a/src/plugins/subversion/subversioncontrol.cpp +++ b/src/plugins/subversion/subversioncontrol.cpp @@ -49,12 +49,12 @@ public: { } protected: - QString trackFile(const QString &repository) + QString trackFile(const QString &repository) override { return m_plugin->monitorFile(repository); } - QString refreshTopic(const QString &repository) + QString refreshTopic(const QString &repository) override { return m_plugin->synchronousTopic(repository); } diff --git a/src/plugins/subversion/subversioncontrol.h b/src/plugins/subversion/subversioncontrol.h index 8e63be64271..9a8f9ff0e6d 100644 --- a/src/plugins/subversion/subversioncontrol.h +++ b/src/plugins/subversion/subversioncontrol.h @@ -42,7 +42,7 @@ public: Core::Id id() const final; bool isVcsFileOrDirectory(const Utils::FileName &fileName) const final; - bool managesDirectory(const QString &directory, QString *topLevel = 0) const final; + bool managesDirectory(const QString &directory, QString *topLevel = nullptr) const final; bool managesFile(const QString &workingDirectory, const QString &fileName) const final; bool isConfigured() const final; diff --git a/src/plugins/subversion/subversionplugin.cpp b/src/plugins/subversion/subversionplugin.cpp index 37166b64502..66b671d1368 100644 --- a/src/plugins/subversion/subversionplugin.cpp +++ b/src/plugins/subversion/subversionplugin.cpp @@ -123,8 +123,9 @@ const VcsBaseEditorParameters editorParameters[] = { // Utility to find a parameter set by type static const VcsBaseEditorParameters *findType(int ie) { - const EditorContentType et = static_cast(ie); - return VcsBaseEditor::findType(editorParameters, sizeof(editorParameters)/sizeof(editorParameters[0]), et); + return VcsBaseEditor::findType(editorParameters, + sizeof(editorParameters)/sizeof(*editorParameters), + static_cast(ie)); } static inline QString debugCodec(const QTextCodec *c) @@ -168,7 +169,7 @@ static inline QStringList svnDirectories() } // ------------- SubversionPlugin -SubversionPlugin *SubversionPlugin::m_subversionPluginInstance = 0; +SubversionPlugin *SubversionPlugin::m_subversionPluginInstance = nullptr; SubversionPlugin::SubversionPlugin() : m_svnDirectories(svnDirectories()) @@ -409,7 +410,7 @@ bool SubversionPlugin::submitEditorAboutToClose() if (!isCommitEditorOpen()) return true; - SubversionSubmitEditor *editor = qobject_cast(submitEditor()); + auto editor = qobject_cast(submitEditor()); QTC_ASSERT(editor, return true); IDocument *editorDocument = editor->document(); QTC_ASSERT(editorDocument, return true); @@ -465,8 +466,8 @@ void SubversionPlugin::diffCommitFiles(const QStringList &files) SubversionSubmitEditor *SubversionPlugin::openSubversionSubmitEditor(const QString &fileName) { IEditor *editor = EditorManager::openEditor(fileName, Constants::SUBVERSION_COMMIT_EDITOR_ID); - SubversionSubmitEditor *submitEditor = qobject_cast(editor); - QTC_ASSERT(submitEditor, return 0); + auto submitEditor = qobject_cast(editor); + QTC_ASSERT(submitEditor, return nullptr); setSubmitEditor(submitEditor); connect(submitEditor, &VcsBaseSubmitEditor::diffSelectedFiles, this, &SubversionPlugin::diffCommitFiles); @@ -884,16 +885,16 @@ IEditor *SubversionPlugin::showOutputInEditor(const QString &title, const QStrin QTextCodec *codec) { const VcsBaseEditorParameters *params = findType(editorType); - QTC_ASSERT(params, return 0); + QTC_ASSERT(params, return nullptr); const Id id = params->id; if (Subversion::Constants::debug) qDebug() << "SubversionPlugin::showOutputInEditor" << title << id.name() << "Size= " << output.size() << " Type=" << editorType << debugCodec(codec); QString s = title; IEditor *editor = EditorManager::openEditorWithContents(id, &s, output.toUtf8()); - SubversionEditorWidget *e = qobject_cast(editor->widget()); + auto e = qobject_cast(editor->widget()); if (!e) - return 0; + return nullptr; connect(e, &VcsBaseEditorWidget::annotateRevisionRequested, this, &SubversionPlugin::vcsAnnotate); e->setForceReadOnly(true); s.replace(QLatin1Char(' '), QLatin1Char('_')); diff --git a/src/plugins/subversion/subversionsettings.h b/src/plugins/subversion/subversionsettings.h index 81dbeb15f8d..40deb8d9972 100644 --- a/src/plugins/subversion/subversionsettings.h +++ b/src/plugins/subversion/subversionsettings.h @@ -44,7 +44,7 @@ public: bool hasAuthentication() const; protected: - void readLegacySettings(const QSettings *settings); + void readLegacySettings(const QSettings *settings) override; }; } // namespace Internal diff --git a/src/plugins/texteditor/basefilefind.cpp b/src/plugins/texteditor/basefilefind.cpp index ab29b58cff4..fbbdaef8266 100644 --- a/src/plugins/texteditor/basefilefind.cpp +++ b/src/plugins/texteditor/basefilefind.cpp @@ -115,7 +115,7 @@ public: ~BaseFileFindPrivate() { delete m_internalSearchEngine; } QPointer m_currentFindSupport; - QLabel *m_resultLabel = 0; + QLabel *m_resultLabel = nullptr; // models in native path format QStringListModel m_filterStrings; QStringListModel m_exclusionStrings; @@ -253,7 +253,7 @@ static void displayResult(QFutureWatcher *watcher, void BaseFileFind::runNewSearch(const QString &txt, FindFlags findFlags, SearchResultWindow::SearchMode searchMode) { - d->m_currentFindSupport = 0; + d->m_currentFindSupport = nullptr; if (d->m_filterCombo) updateComboEntries(d->m_filterCombo, true); if (d->m_exclusionCombo) @@ -290,12 +290,12 @@ void BaseFileFind::runNewSearch(const QString &txt, FindFlags findFlags, void BaseFileFind::runSearch(SearchResult *search) { FileFindParameters parameters = search->userData().value(); - CountingLabel *label = new CountingLabel; + auto label = new CountingLabel; connect(search, &SearchResult::countChanged, label, &CountingLabel::updateCount); - CountingLabel *statusLabel = new CountingLabel; + auto statusLabel = new CountingLabel; connect(search, &SearchResult::countChanged, statusLabel, &CountingLabel::updateCount); SearchResultWindow::instance()->popup(IOutputPane::Flags(IOutputPane::ModeSwitch|IOutputPane::WithFocus)); - QFutureWatcher *watcher = new QFutureWatcher(); + auto watcher = new QFutureWatcher(); watcher->setPendingResultsLimit(1); // search is deleted if it is removed from search panel connect(search, &QObject::destroyed, watcher, &QFutureWatcherBase::cancel); @@ -344,7 +344,7 @@ void BaseFileFind::doReplace(const QString &text, QStringList files = replaceAll(text, items, preserveCase); if (!files.isEmpty()) { Utils::FadingIndicator::showText(ICore::mainWindow(), - tr("%n occurrences replaced.", 0, items.size()), + tr("%n occurrences replaced.", nullptr, items.size()), Utils::FadingIndicator::SmallText); DocumentManager::notifyFilesChangedInternally(files); SearchResultWindow::instance()->hide(); @@ -444,7 +444,7 @@ void BaseFileFind::readCommonSettings(QSettings *settings, const QString &defaul void BaseFileFind::openEditor(const SearchResultItem &item) { - SearchResult *result = qobject_cast(sender()); + auto result = qobject_cast(sender()); FileFindParameters parameters = result->userData().value(); IEditor *openedEditor = d->m_searchEngines[parameters.searchEngineIndex]->openEditor(item, parameters); @@ -452,11 +452,11 @@ void BaseFileFind::openEditor(const SearchResultItem &item) EditorManager::openEditorAtSearchResult(item, EditorManager::DoNotSwitchToDesignMode); if (d->m_currentFindSupport) d->m_currentFindSupport->clearHighlights(); - d->m_currentFindSupport = 0; + d->m_currentFindSupport = nullptr; if (!openedEditor) return; // highlight results - if (IFindSupport *findSupport = Aggregation::query(openedEditor->widget())) { + if (auto findSupport = Aggregation::query(openedEditor->widget())) { d->m_currentFindSupport = findSupport; d->m_currentFindSupport->highlightAll(parameters.text, parameters.flags); } @@ -470,14 +470,14 @@ void BaseFileFind::hideHighlightAll(bool visible) void BaseFileFind::searchAgain() { - SearchResult *search = qobject_cast(sender()); + auto search = qobject_cast(sender()); search->restart(); runSearch(search); } void BaseFileFind::recheckEnabled() { - SearchResult *search = qobject_cast(sender()); + auto search = qobject_cast(sender()); if (!search) return; search->setSearchAgainEnabled(isEnabled()); diff --git a/src/plugins/texteditor/behaviorsettingspage.cpp b/src/plugins/texteditor/behaviorsettingspage.cpp index 1c26e30a543..833620ef977 100644 --- a/src/plugins/texteditor/behaviorsettingspage.cpp +++ b/src/plugins/texteditor/behaviorsettingspage.cpp @@ -97,7 +97,7 @@ BehaviorSettingsPage::BehaviorSettingsPage(const BehaviorSettingsPageParameters d->m_codeStyle->setId(Constants::GLOBAL_SETTINGS_ID); // default pool for all other languages - d->m_defaultCodeStylePool = new CodeStylePool(0, this); // Any language + d->m_defaultCodeStylePool = new CodeStylePool(nullptr, this); // Any language d->m_defaultCodeStylePool->addCodeStyle(d->m_codeStyle); d->init(); @@ -225,7 +225,7 @@ void BehaviorSettingsPage::finish() if (!d->m_page) // page was never shown return; delete d->m_page; - d->m_page = 0; + d->m_page = nullptr; } ICodeStylePreferences *BehaviorSettingsPage::codeStyle() const diff --git a/src/plugins/texteditor/circularclipboardassist.cpp b/src/plugins/texteditor/circularclipboardassist.cpp index 65034a39cdd..298330c7730 100644 --- a/src/plugins/texteditor/circularclipboardassist.cpp +++ b/src/plugins/texteditor/circularclipboardassist.cpp @@ -59,7 +59,7 @@ public: setText(text); } - ~ClipboardProposalItem() Q_DECL_NOEXCEPT {} + ~ClipboardProposalItem() noexcept override {} void apply(TextDocumentManipulatorInterface &manipulator, int /*basePosition*/) const override { @@ -88,7 +88,7 @@ public: IAssistProposal *perform(const AssistInterface *interface) override { if (!interface) - return 0; + return nullptr; const QScopedPointer AssistInterface(interface); QIcon icon = QIcon::fromTheme(QLatin1String("edit-paste"), Utils::Icons::PASTE.icon()).pixmap(16); diff --git a/src/plugins/texteditor/codeassist/assistinterface.cpp b/src/plugins/texteditor/codeassist/assistinterface.cpp index 3577718dfb4..eb7119a4517 100644 --- a/src/plugins/texteditor/codeassist/assistinterface.cpp +++ b/src/plugins/texteditor/codeassist/assistinterface.cpp @@ -134,7 +134,7 @@ void AssistInterface::prepareForAsyncUse() m_userStates.reserve(m_textDocument->blockCount()); for (QTextBlock block = m_textDocument->firstBlock(); block.isValid(); block = block.next()) m_userStates.append(block.userState()); - m_textDocument = 0; + m_textDocument = nullptr; m_isAsync = true; } diff --git a/src/plugins/texteditor/codeassist/assistproposalitem.h b/src/plugins/texteditor/codeassist/assistproposalitem.h index a98c9a60729..bb12c5500d5 100644 --- a/src/plugins/texteditor/codeassist/assistproposalitem.h +++ b/src/plugins/texteditor/codeassist/assistproposalitem.h @@ -39,7 +39,7 @@ namespace TextEditor { class TEXTEDITOR_EXPORT AssistProposalItem : public AssistProposalItemInterface { public: - ~AssistProposalItem() Q_DECL_NOEXCEPT override {} + ~AssistProposalItem() noexcept override {} QString text() const override; bool implicitlyApplies() const override; bool prematurelyApplies(const QChar &c) const override; diff --git a/src/plugins/texteditor/codeassist/assistproposaliteminterface.h b/src/plugins/texteditor/codeassist/assistproposaliteminterface.h index 12b925ebf57..601dbd9c2b6 100644 --- a/src/plugins/texteditor/codeassist/assistproposaliteminterface.h +++ b/src/plugins/texteditor/codeassist/assistproposaliteminterface.h @@ -52,7 +52,7 @@ public: }; AssistProposalItemInterface() = default; - virtual ~AssistProposalItemInterface() Q_DECL_NOEXCEPT = default; + virtual ~AssistProposalItemInterface() noexcept = default; UTILS_DELETE_MOVE_AND_COPY(AssistProposalItemInterface) diff --git a/src/plugins/texteditor/codeassist/codeassistant.cpp b/src/plugins/texteditor/codeassist/codeassistant.cpp index cede626ea35..2a01ada15c9 100644 --- a/src/plugins/texteditor/codeassist/codeassistant.cpp +++ b/src/plugins/texteditor/codeassist/codeassistant.cpp @@ -516,7 +516,7 @@ bool CodeAssistantPrivate::isDestroyEvent(int key, const QString &keyText) { if (keyText.isEmpty()) return key != Qt::LeftArrow && key != Qt::RightArrow && key != Qt::Key_Shift; - if (auto *provider = qobject_cast(m_requestProvider)) + if (auto provider = qobject_cast(m_requestProvider)) return !provider->isContinuationChar(keyText.at(0)); return false; } @@ -530,7 +530,7 @@ bool CodeAssistantPrivate::eventFilter(QObject *o, QEvent *e) if (type == QEvent::FocusOut) { destroyContext(); } else if (type == QEvent::KeyPress) { - QKeyEvent *keyEvent = static_cast(e); + auto keyEvent = static_cast(e); const QString &keyText = keyEvent->text(); if (isDestroyEvent(keyEvent->key(), keyText)) diff --git a/src/plugins/texteditor/codeassist/functionhintproposalwidget.cpp b/src/plugins/texteditor/codeassist/functionhintproposalwidget.cpp index 42172e10968..d673df7e081 100644 --- a/src/plugins/texteditor/codeassist/functionhintproposalwidget.cpp +++ b/src/plugins/texteditor/codeassist/functionhintproposalwidget.cpp @@ -269,7 +269,7 @@ bool FunctionHintProposalWidget::eventFilter(QObject *obj, QEvent *e) } QTC_CHECK(d->m_model); if (d->m_model && d->m_model->size() > 1) { - QKeyEvent *ke = static_cast(e); + auto ke = static_cast(e); if (ke->key() == Qt::Key_Up) { previousPage(); return true; @@ -281,7 +281,7 @@ bool FunctionHintProposalWidget::eventFilter(QObject *obj, QEvent *e) } break; case QEvent::KeyRelease: { - QKeyEvent *ke = static_cast(e); + auto ke = static_cast(e); if (ke->key() == Qt::Key_Escape && d->m_escapePressed) { abort(); emit explicitlyAborted(); diff --git a/src/plugins/texteditor/codeassist/genericproposal.cpp b/src/plugins/texteditor/codeassist/genericproposal.cpp index 6feff83251a..07f4c68bb2d 100644 --- a/src/plugins/texteditor/codeassist/genericproposal.cpp +++ b/src/plugins/texteditor/codeassist/genericproposal.cpp @@ -55,7 +55,7 @@ GenericProposal *GenericProposal::createProposal(const AssistInterface *interfac foreach (const QuickFixOperation::Ptr &op, quickFixes) { QVariant v; v.setValue(op); - AssistProposalItem *item = new AssistProposalItem; + auto item = new AssistProposalItem; item->setText(op->description()); item->setData(v); item->setOrder(op->priority()); diff --git a/src/plugins/texteditor/codeassist/genericproposalwidget.cpp b/src/plugins/texteditor/codeassist/genericproposalwidget.cpp index cecaad9666b..8f5d7291482 100644 --- a/src/plugins/texteditor/codeassist/genericproposalwidget.cpp +++ b/src/plugins/texteditor/codeassist/genericproposalwidget.cpp @@ -64,8 +64,8 @@ class ModelAdapter : public QAbstractListModel public: ModelAdapter(GenericProposalModelPtr completionModel, QWidget *parent); - virtual int rowCount(const QModelIndex &) const; - virtual QVariant data(const QModelIndex &index, int role) const; + int rowCount(const QModelIndex &) const override; + QVariant data(const QModelIndex &index, int role) const override; private: GenericProposalModelPtr m_completionModel; @@ -102,10 +102,10 @@ QVariant ModelAdapter::data(const QModelIndex &index, int role) const class GenericProposalInfoFrame : public FakeToolTip { public: - GenericProposalInfoFrame(QWidget *parent = 0) + GenericProposalInfoFrame(QWidget *parent = nullptr) : FakeToolTip(parent), m_label(new QLabel(this)) { - QVBoxLayout *layout = new QVBoxLayout(this); + auto layout = new QVBoxLayout(this); layout->setMargin(0); layout->setSpacing(0); layout->addWidget(m_label); @@ -297,7 +297,7 @@ GenericProposalWidget::GenericProposalWidget() connect(d->m_completionListView->verticalScrollBar(), &QAbstractSlider::sliderReleased, this, &GenericProposalWidget::turnOnAutoWidth); - QVBoxLayout *layout = new QVBoxLayout(this); + auto layout = new QVBoxLayout(this); layout->setMargin(0); layout->addWidget(d->m_completionListView); @@ -501,7 +501,7 @@ bool GenericProposalWidget::eventFilter(QObject *o, QEvent *e) d->m_infoFrame->close(); return true; } else if (e->type() == QEvent::ShortcutOverride) { - QKeyEvent *ke = static_cast(e); + auto ke = static_cast(e); switch (ke->key()) { case Qt::Key_N: case Qt::Key_P: @@ -511,7 +511,7 @@ bool GenericProposalWidget::eventFilter(QObject *o, QEvent *e) } } } else if (e->type() == QEvent::KeyPress) { - QKeyEvent *ke = static_cast(e); + auto ke = static_cast(e); switch (ke->key()) { case Qt::Key_Escape: abort(); diff --git a/src/plugins/texteditor/codeassist/iassistproposalwidget.cpp b/src/plugins/texteditor/codeassist/iassistproposalwidget.cpp index 4be7453bd0a..00a4768e5e7 100644 --- a/src/plugins/texteditor/codeassist/iassistproposalwidget.cpp +++ b/src/plugins/texteditor/codeassist/iassistproposalwidget.cpp @@ -49,7 +49,7 @@ using namespace TextEditor; */ IAssistProposalWidget::IAssistProposalWidget() - : QFrame(0, Qt::Popup) + : QFrame(nullptr, Qt::Popup) {} IAssistProposalWidget::~IAssistProposalWidget() diff --git a/src/plugins/texteditor/codeassist/keywordscompletionassist.cpp b/src/plugins/texteditor/codeassist/keywordscompletionassist.cpp index 15e0dda482b..16659c4a0c3 100644 --- a/src/plugins/texteditor/codeassist/keywordscompletionassist.cpp +++ b/src/plugins/texteditor/codeassist/keywordscompletionassist.cpp @@ -193,7 +193,7 @@ IAssistProposal *KeywordsCompletionAssistProcessor::perform(const AssistInterfac if (characterUnderCursor.isLetterOrNumber()) return nullptr; if (interface->position() - startPosition < 3) - return 0; + return nullptr; } // extract word diff --git a/src/plugins/texteditor/codeassist/runner.h b/src/plugins/texteditor/codeassist/runner.h index 48ede437533..b607d69bb16 100644 --- a/src/plugins/texteditor/codeassist/runner.h +++ b/src/plugins/texteditor/codeassist/runner.h @@ -43,13 +43,13 @@ class ProcessorRunner : public QThread public: ProcessorRunner(); - virtual ~ProcessorRunner(); + ~ProcessorRunner() override; void setProcessor(IAssistProcessor *processor); // Takes ownership of the processor. void setAssistInterface(AssistInterface *interface); void setDiscardProposal(bool discard); - virtual void run(); + void run() override; IAssistProposal *proposal() const; diff --git a/src/plugins/texteditor/codeassist/textdocumentmanipulator.h b/src/plugins/texteditor/codeassist/textdocumentmanipulator.h index d820e2edade..46aa99f29da 100644 --- a/src/plugins/texteditor/codeassist/textdocumentmanipulator.h +++ b/src/plugins/texteditor/codeassist/textdocumentmanipulator.h @@ -48,7 +48,7 @@ public: void insertCodeSnippet(int position, const QString &text) final; void paste() final; void encourageApply() final; - void autoIndent(int position, int length); + void autoIndent(int position, int length) override; private: bool textIsDifferentAt(int position, int length, const QString &text) const; diff --git a/src/plugins/texteditor/codecselector.cpp b/src/plugins/texteditor/codecselector.cpp index 334fd3817a5..45ad44a5fbb 100644 --- a/src/plugins/texteditor/codecselector.cpp +++ b/src/plugins/texteditor/codecselector.cpp @@ -48,7 +48,7 @@ class CodecListWidget : public Utils::ListWidget { public: CodecListWidget(QWidget *parent) : Utils::ListWidget(parent){} - QSize sizeHint() const { + QSize sizeHint() const override { return QListWidget::sizeHint().expandedTo( QSize(sizeHintForColumn(0) + verticalScrollBar()->sizeHint().width() + 4, 0)); } @@ -126,7 +126,7 @@ CodecSelector::CodecSelector(QWidget *parent, TextDocument *doc) connect(m_dialogButtonBox, &QDialogButtonBox::clicked, this, &CodecSelector::buttonClicked); connect(m_listWidget, &QAbstractItemView::activated, m_reloadButton, &QAbstractButton::click); - QVBoxLayout *vbox = new QVBoxLayout(this); + auto vbox = new QVBoxLayout(this); vbox->addWidget(m_label); vbox->addWidget(m_listWidget); vbox->addWidget(m_dialogButtonBox); @@ -140,7 +140,7 @@ CodecSelector::~CodecSelector() void CodecSelector::updateButtons() { - bool hasCodec = (selectedCodec() != 0); + bool hasCodec = (selectedCodec() != nullptr); m_reloadButton->setEnabled(!m_isModified && hasCodec); m_saveButton->setEnabled(!m_hasDecodingError && hasCodec); } @@ -149,13 +149,13 @@ QTextCodec *CodecSelector::selectedCodec() const { if (QListWidgetItem *item = m_listWidget->currentItem()) { if (!item->isSelected()) - return 0; + return nullptr; QString codecName = item->text(); if (codecName.contains(QLatin1String(" / "))) codecName = codecName.left(codecName.indexOf(QLatin1String(" / "))); return QTextCodec::codecForName(codecName.toLatin1()); } - return 0; + return nullptr; } void CodecSelector::buttonClicked(QAbstractButton *button) diff --git a/src/plugins/texteditor/codestyleeditor.cpp b/src/plugins/texteditor/codestyleeditor.cpp index 599af2974a0..526ee106d61 100644 --- a/src/plugins/texteditor/codestyleeditor.cpp +++ b/src/plugins/texteditor/codestyleeditor.cpp @@ -48,7 +48,7 @@ CodeStyleEditor::CodeStyleEditor(ICodeStylePreferencesFactory *factory, m_codeStyle(codeStyle) { m_layout = new QVBoxLayout(this); - CodeStyleSelectorWidget *selector = new CodeStyleSelectorWidget(factory, this); + auto selector = new CodeStyleSelectorWidget(factory, this); selector->setCodeStyle(codeStyle); m_preview = new SnippetEditorWidget(this); DisplaySettings displaySettings = m_preview->displaySettings(); diff --git a/src/plugins/texteditor/codestylepool.cpp b/src/plugins/texteditor/codestylepool.cpp index b05f7b1f730..5d3ad33659a 100644 --- a/src/plugins/texteditor/codestylepool.cpp +++ b/src/plugins/texteditor/codestylepool.cpp @@ -51,7 +51,7 @@ class CodeStylePoolPrivate { public: CodeStylePoolPrivate() - : m_factory(0) + : m_factory(nullptr) {} ~CodeStylePoolPrivate(); @@ -151,7 +151,7 @@ ICodeStylePreferences *CodeStylePool::createCodeStyle(const QByteArray &id, cons const QVariant &codeStyleData, const QString &displayName) { if (!d->m_factory) - return 0; + return nullptr; ICodeStylePreferences *codeStyle = d->m_factory->createCodeStyle(); codeStyle->setId(id); @@ -236,7 +236,7 @@ ICodeStylePreferences *CodeStylePool::importCodeStyle(const Utils::FileName &fil ICodeStylePreferences *CodeStylePool::loadCodeStyle(const Utils::FileName &fileName) { - ICodeStylePreferences *codeStyle = 0; + ICodeStylePreferences *codeStyle = nullptr; Utils::PersistentSettingsReader reader; reader.load(fileName); QVariantMap m = reader.restoreValues(); @@ -258,7 +258,7 @@ ICodeStylePreferences *CodeStylePool::loadCodeStyle(const Utils::FileName &fileN void CodeStylePool::slotSaveCodeStyle() { - ICodeStylePreferences *codeStyle = qobject_cast(sender()); + auto codeStyle = qobject_cast(sender()); if (!codeStyle) return; diff --git a/src/plugins/texteditor/codestyleselectorwidget.cpp b/src/plugins/texteditor/codestyleselectorwidget.cpp index be8a0762848..26a11effdd9 100644 --- a/src/plugins/texteditor/codestyleselectorwidget.cpp +++ b/src/plugins/texteditor/codestyleselectorwidget.cpp @@ -52,8 +52,8 @@ class CodeStyleDialog : public QDialog Q_OBJECT public: CodeStyleDialog(ICodeStylePreferencesFactory *factory, - ICodeStylePreferences *codeStyle, QWidget *parent = 0); - ~CodeStyleDialog(); + ICodeStylePreferences *codeStyle, QWidget *parent = nullptr); + ~CodeStyleDialog() override; ICodeStylePreferences *codeStyle() const; private: void slotCopyClicked(); @@ -62,28 +62,26 @@ private: ICodeStylePreferences *m_codeStyle; QLineEdit *m_lineEdit; QDialogButtonBox *m_buttons; - QLabel *m_warningLabel; - QPushButton *m_copyButton; + QLabel *m_warningLabel = nullptr; + QPushButton *m_copyButton = nullptr; QString m_originalDisplayName; }; CodeStyleDialog::CodeStyleDialog(ICodeStylePreferencesFactory *factory, ICodeStylePreferences *codeStyle, QWidget *parent) - : QDialog(parent), - m_warningLabel(0), - m_copyButton(0) + : QDialog(parent) { setWindowTitle(tr("Edit Code Style")); - QVBoxLayout *layout = new QVBoxLayout(this); + auto layout = new QVBoxLayout(this); QLabel *label = new QLabel(tr("Code style name:")); m_lineEdit = new QLineEdit(codeStyle->displayName(), this); - QHBoxLayout *nameLayout = new QHBoxLayout(); + auto nameLayout = new QHBoxLayout; nameLayout->addWidget(label); nameLayout->addWidget(m_lineEdit); layout->addLayout(nameLayout); if (codeStyle->isReadOnly()) { - QHBoxLayout *warningLayout = new QHBoxLayout(); + auto warningLayout = new QHBoxLayout; m_warningLabel = new QLabel( tr("You cannot save changes to a built-in code style. " "Copy it first to create your own version."), this); @@ -158,9 +156,7 @@ CodeStyleDialog::~CodeStyleDialog() CodeStyleSelectorWidget::CodeStyleSelectorWidget(ICodeStylePreferencesFactory *factory, QWidget *parent) : QWidget(parent), m_factory(factory), - m_codeStyle(0), - m_ui(new Internal::Ui::CodeStyleSelectorWidget), - m_ignoreGuiSignals(false) + m_ui(new Internal::Ui::CodeStyleSelectorWidget) { m_ui->setupUi(this); m_ui->importButton->setEnabled(false); @@ -239,8 +235,7 @@ void CodeStyleSelectorWidget::slotComboBoxActivated(int index) if (index < 0 || index >= m_ui->delegateComboBox->count()) return; - ICodeStylePreferences *delegate = - m_ui->delegateComboBox->itemData(index).value(); + auto delegate = m_ui->delegateComboBox->itemData(index).value(); QSignalBlocker blocker(this); m_codeStyle->setCurrentDelegate(delegate); @@ -319,7 +314,7 @@ void CodeStyleSelectorWidget::slotRemoveClicked() this); // Change the text and role of the discard button - QPushButton *deleteButton = static_cast(messageBox.button(QMessageBox::Discard)); + auto deleteButton = static_cast(messageBox.button(QMessageBox::Discard)); deleteButton->setText(tr("Delete")); messageBox.addButton(deleteButton, QMessageBox::AcceptRole); messageBox.setDefaultButton(deleteButton); @@ -390,7 +385,7 @@ void CodeStyleSelectorWidget::slotCodeStyleRemoved(ICodeStylePreferences *codeSt void CodeStyleSelectorWidget::slotUpdateName() { - ICodeStylePreferences *changedCodeStyle = qobject_cast(sender()); + auto changedCodeStyle = qobject_cast(sender()); if (!changedCodeStyle) return; diff --git a/src/plugins/texteditor/codestyleselectorwidget.h b/src/plugins/texteditor/codestyleselectorwidget.h index 79763d439fd..bac911bc899 100644 --- a/src/plugins/texteditor/codestyleselectorwidget.h +++ b/src/plugins/texteditor/codestyleselectorwidget.h @@ -59,13 +59,13 @@ private: void updateName(ICodeStylePreferences *codeStyle); ICodeStylePreferencesFactory *m_factory; - ICodeStylePreferences *m_codeStyle; + ICodeStylePreferences *m_codeStyle = nullptr; QString displayName(ICodeStylePreferences *codeStyle) const; Internal::Ui::CodeStyleSelectorWidget *m_ui; - bool m_ignoreGuiSignals; + bool m_ignoreGuiSignals = false; }; } // namespace TextEditor diff --git a/src/plugins/texteditor/colorscheme.cpp b/src/plugins/texteditor/colorscheme.cpp index 632cf963af8..ad756be2c72 100644 --- a/src/plugins/texteditor/colorscheme.cpp +++ b/src/plugins/texteditor/colorscheme.cpp @@ -292,10 +292,6 @@ namespace { class ColorSchemeReader : public QXmlStreamReader { public: - ColorSchemeReader() : - m_scheme(0) - {} - bool read(const QString &fileName, ColorScheme *scheme); QString readName(const QString &fileName); @@ -305,7 +301,7 @@ private: void readStyleScheme(); void readStyle(); - ColorScheme *m_scheme; + ColorScheme *m_scheme = nullptr; QString m_name; }; @@ -332,7 +328,7 @@ bool ColorSchemeReader::read(const QString &fileName, ColorScheme *scheme) QString ColorSchemeReader::readName(const QString &fileName) { - read(fileName, 0); + read(fileName, nullptr); return m_name; } diff --git a/src/plugins/texteditor/colorschemeedit.cpp b/src/plugins/texteditor/colorschemeedit.cpp index d0c615406d8..5a6ecf654a0 100644 --- a/src/plugins/texteditor/colorschemeedit.cpp +++ b/src/plugins/texteditor/colorschemeedit.cpp @@ -54,10 +54,8 @@ namespace Internal { class FormatsModel : public QAbstractListModel { public: - FormatsModel(QObject *parent = 0): - QAbstractListModel(parent), - m_descriptions(0), - m_scheme(0) + FormatsModel(QObject *parent = nullptr): + QAbstractListModel(parent) { } @@ -82,12 +80,12 @@ public: emitDataChanged(index(0)); } - int rowCount(const QModelIndex &parent) const + int rowCount(const QModelIndex &parent) const override { return (parent.isValid() || !m_descriptions) ? 0 : int(m_descriptions->size()); } - QVariant data(const QModelIndex &index, int role) const + QVariant data(const QModelIndex &index, int role) const override { if (!m_descriptions || !m_scheme) return QVariant(); @@ -139,8 +137,8 @@ public: } private: - const FormatDescriptions *m_descriptions; - const ColorScheme *m_scheme; + const FormatDescriptions *m_descriptions = nullptr; + const ColorScheme *m_scheme = nullptr; QFont m_baseFont; }; diff --git a/src/plugins/texteditor/completionsettingspage.cpp b/src/plugins/texteditor/completionsettingspage.cpp index b824926028d..8a9a82740c3 100644 --- a/src/plugins/texteditor/completionsettingspage.cpp +++ b/src/plugins/texteditor/completionsettingspage.cpp @@ -39,7 +39,6 @@ using namespace CppTools; CompletionSettingsPage::CompletionSettingsPage(QObject *parent) : TextEditor::TextEditorOptionsPage(parent) - , m_page(0) { setId("P.Completion"); setDisplayName(tr("Completion")); @@ -204,7 +203,7 @@ void CompletionSettingsPage::finish() if (!m_page) // page was never shown return; delete m_page; - m_page = 0; + m_page = nullptr; } const CompletionSettings &CompletionSettingsPage::completionSettings() diff --git a/src/plugins/texteditor/completionsettingspage.h b/src/plugins/texteditor/completionsettingspage.h index 9258e67a315..bf0ac7638be 100644 --- a/src/plugins/texteditor/completionsettingspage.h +++ b/src/plugins/texteditor/completionsettingspage.h @@ -63,7 +63,7 @@ private: void onCompletionTriggerChanged(); - Ui::CompletionSettingsPage *m_page; + Ui::CompletionSettingsPage *m_page = nullptr; QPointer m_widget; CommentsSettings m_commentsSettings; CompletionSettings m_completionSettings; diff --git a/src/plugins/texteditor/displaysettings.cpp b/src/plugins/texteditor/displaysettings.cpp index 410283a7f6e..dd88b770887 100644 --- a/src/plugins/texteditor/displaysettings.cpp +++ b/src/plugins/texteditor/displaysettings.cpp @@ -142,7 +142,7 @@ bool DisplaySettings::equals(const DisplaySettings &ds) const QLabel *DisplaySettings::createAnnotationSettingsLink() { - auto *label = new QLabel("Annotation Settings", Core::ICore::mainWindow()); + auto label = new QLabel("Annotation Settings", Core::ICore::mainWindow()); QObject::connect(label, &QLabel::linkActivated, []() { Utils::ToolTip::hideImmediately(); Core::ICore::showOptionsDialog(Constants::TEXT_EDITOR_DISPLAY_SETTINGS); diff --git a/src/plugins/texteditor/displaysettingspage.cpp b/src/plugins/texteditor/displaysettingspage.cpp index 07b535f59a4..ddc7595e032 100644 --- a/src/plugins/texteditor/displaysettingspage.cpp +++ b/src/plugins/texteditor/displaysettingspage.cpp @@ -41,14 +41,14 @@ struct DisplaySettingsPage::DisplaySettingsPagePrivate const DisplaySettingsPageParameters m_parameters; QPointer m_widget; - Internal::Ui::DisplaySettingsPage *m_page; + Internal::Ui::DisplaySettingsPage *m_page = nullptr; DisplaySettings m_displaySettings; MarginSettings m_marginSettings; }; DisplaySettingsPage::DisplaySettingsPagePrivate::DisplaySettingsPagePrivate (const DisplaySettingsPageParameters &p) - : m_parameters(p), m_page(0) + : m_parameters(p) { m_displaySettings.fromSettings(m_parameters.settingsPrefix, Core::ICore::settings()); m_marginSettings.fromSettings(m_parameters.settingsPrefix, Core::ICore::settings()); @@ -96,7 +96,7 @@ void DisplaySettingsPage::finish() if (!d->m_page) // page was never shown return; delete d->m_page; - d->m_page = 0; + d->m_page = nullptr; } void DisplaySettingsPage::settingsFromUI(DisplaySettings &displaySettings, diff --git a/src/plugins/texteditor/findincurrentfile.cpp b/src/plugins/texteditor/findincurrentfile.cpp index df568a1311b..b9b629fc4fa 100644 --- a/src/plugins/texteditor/findincurrentfile.cpp +++ b/src/plugins/texteditor/findincurrentfile.cpp @@ -39,7 +39,6 @@ using namespace TextEditor; using namespace TextEditor::Internal; FindInCurrentFile::FindInCurrentFile() - : m_currentDocument(0) { connect(Core::EditorManager::instance(), &Core::EditorManager::currentEditorChanged, this, &FindInCurrentFile::handleFileChange); @@ -95,7 +94,7 @@ void FindInCurrentFile::handleFileChange(Core::IEditor *editor) { if (!editor) { if (m_currentDocument) { - m_currentDocument = 0; + m_currentDocument = nullptr; emit enabledChanged(isEnabled()); } } else { diff --git a/src/plugins/texteditor/findinfiles.cpp b/src/plugins/texteditor/findinfiles.cpp index 4e133872ac3..7d7c1efb5ca 100644 --- a/src/plugins/texteditor/findinfiles.cpp +++ b/src/plugins/texteditor/findinfiles.cpp @@ -48,12 +48,10 @@ using namespace Core; using namespace TextEditor; using namespace Utils; -static FindInFiles *m_instance = 0; +static FindInFiles *m_instance = nullptr; static const char HistoryKey[] = "FindInFiles.Directories.History"; FindInFiles::FindInFiles() - : m_configWidget(0), - m_directory(0) { m_instance = this; connect(EditorManager::instance(), &EditorManager::findOnFileSystemRequest, @@ -147,7 +145,7 @@ QWidget *FindInFiles::createConfigWidget() { if (!m_configWidget) { m_configWidget = new QWidget; - QGridLayout * const gridLayout = new QGridLayout(m_configWidget); + auto gridLayout = new QGridLayout(m_configWidget); gridLayout->setMargin(0); m_configWidget->setLayout(gridLayout); diff --git a/src/plugins/texteditor/fontsettingspage.cpp b/src/plugins/texteditor/fontsettingspage.cpp index 64d1209a7c9..e9c6920b929 100644 --- a/src/plugins/texteditor/fontsettingspage.cpp +++ b/src/plugins/texteditor/fontsettingspage.cpp @@ -66,15 +66,15 @@ struct ColorSchemeEntry class SchemeListModel : public QAbstractListModel { public: - SchemeListModel(QObject *parent = 0): + SchemeListModel(QObject *parent = nullptr): QAbstractListModel(parent) { } - int rowCount(const QModelIndex &parent) const + int rowCount(const QModelIndex &parent) const override { return parent.isValid() ? 0 : m_colorSchemes.size(); } - QVariant data(const QModelIndex &index, int role) const + QVariant data(const QModelIndex &index, int role) const override { if (role == Qt::DisplayRole) return m_colorSchemes.at(index.row()).name; @@ -526,7 +526,7 @@ void FontSettingsPage::confirmDeleteColorScheme() d_ptr->m_ui->deleteButton->window()); // Change the text and role of the discard button - QPushButton *deleteButton = static_cast(messageBox->button(QMessageBox::Discard)); + auto deleteButton = static_cast(messageBox->button(QMessageBox::Discard)); deleteButton->setText(tr("Delete")); messageBox->addButton(deleteButton, QMessageBox::AcceptRole); messageBox->setDefaultButton(deleteButton); @@ -562,7 +562,7 @@ void FontSettingsPage::maybeSaveColorScheme() d_ptr->m_ui->schemeComboBox->window()); // Change the text of the discard button - QPushButton *discardButton = static_cast(messageBox.button(QMessageBox::Discard)); + auto discardButton = static_cast(messageBox.button(QMessageBox::Discard)); discardButton->setText(tr("Discard")); messageBox.addButton(discardButton, QMessageBox::DestructiveRole); messageBox.setDefaultButton(QMessageBox::Save); @@ -658,7 +658,7 @@ void FontSettingsPage::finish() // If changes were applied, these are equal. Otherwise restores last value. d_ptr->m_value = d_ptr->m_lastValue; delete d_ptr->m_ui; - d_ptr->m_ui = 0; + d_ptr->m_ui = nullptr; } const FontSettings &FontSettingsPage::fontSettings() const diff --git a/src/plugins/texteditor/formattexteditor.cpp b/src/plugins/texteditor/formattexteditor.cpp index d3ad772eba4..33cb6dccdc7 100644 --- a/src/plugins/texteditor/formattexteditor.cpp +++ b/src/plugins/texteditor/formattexteditor.cpp @@ -347,7 +347,7 @@ void formatEditorAsync(TextEditorWidget *editor, const Command &command, int sta if (sd.isEmpty()) return; - auto *watcher = new QFutureWatcher; + auto watcher = new QFutureWatcher; const TextDocument *doc = editor->textDocument(); QObject::connect(doc, &TextDocument::contentsChanged, watcher, &QFutureWatcher::cancel); QObject::connect(watcher, &QFutureWatcherBase::finished, [watcher] { diff --git a/src/plugins/texteditor/generichighlighter/dynamicrule.cpp b/src/plugins/texteditor/generichighlighter/dynamicrule.cpp index 16d95c6b36a..9dcaf359be7 100644 --- a/src/plugins/texteditor/generichighlighter/dynamicrule.cpp +++ b/src/plugins/texteditor/generichighlighter/dynamicrule.cpp @@ -53,7 +53,7 @@ namespace Internal { void updateDynamicRules(const QList > &rules, const QStringList &captures) { foreach (QSharedPointer rule, rules) { - DynamicRule *dynamicRule = dynamic_cast(rule.data()); + auto dynamicRule = dynamic_cast(rule.data()); if (dynamicRule && dynamicRule->isActive()) dynamicRule->replaceExpressions(captures); } diff --git a/src/plugins/texteditor/generichighlighter/dynamicrule.h b/src/plugins/texteditor/generichighlighter/dynamicrule.h index c78b06f5442..2c3d46bd8d4 100644 --- a/src/plugins/texteditor/generichighlighter/dynamicrule.h +++ b/src/plugins/texteditor/generichighlighter/dynamicrule.h @@ -38,7 +38,7 @@ class DynamicRule : public Rule { public: DynamicRule(); - virtual ~DynamicRule(); + ~DynamicRule() override; void setActive(const QString &active); bool isActive() const; diff --git a/src/plugins/texteditor/generichighlighter/highlightdefinitionhandler.cpp b/src/plugins/texteditor/generichighlighter/highlightdefinitionhandler.cpp index 794247b220f..76c55f7cab2 100644 --- a/src/plugins/texteditor/generichighlighter/highlightdefinitionhandler.cpp +++ b/src/plugins/texteditor/generichighlighter/highlightdefinitionhandler.cpp @@ -306,7 +306,7 @@ void HighlightDefinitionHandler::foldingElementStarted(const QXmlAttributes &att void HighlightDefinitionHandler::detectCharStarted(const QXmlAttributes &atts) { - DetectCharRule *rule = new DetectCharRule; + auto rule = new DetectCharRule; rule->setChar(atts.value(kChar)); rule->setActive(atts.value(kDynamic)); ruleElementStarted(atts, QSharedPointer(rule)); @@ -314,7 +314,7 @@ void HighlightDefinitionHandler::detectCharStarted(const QXmlAttributes &atts) void HighlightDefinitionHandler::detect2CharsStarted(const QXmlAttributes &atts) { - Detect2CharsRule *rule = new Detect2CharsRule; + auto rule = new Detect2CharsRule; rule->setChar(atts.value(kChar)); rule->setChar1(atts.value(kChar1)); rule->setActive(atts.value(kDynamic)); @@ -323,14 +323,14 @@ void HighlightDefinitionHandler::detect2CharsStarted(const QXmlAttributes &atts) void HighlightDefinitionHandler::anyCharStarted(const QXmlAttributes &atts) { - AnyCharRule *rule = new AnyCharRule; + auto rule = new AnyCharRule; rule->setCharacterSet(atts.value(kString)); ruleElementStarted(atts, QSharedPointer(rule)); } void HighlightDefinitionHandler::stringDetectedStarted(const QXmlAttributes &atts) { - StringDetectRule *rule = new StringDetectRule; + auto rule = new StringDetectRule; rule->setString(atts.value(kString)); rule->setInsensitive(atts.value(kInsensitive)); rule->setActive(atts.value(kDynamic)); @@ -339,7 +339,7 @@ void HighlightDefinitionHandler::stringDetectedStarted(const QXmlAttributes &att void HighlightDefinitionHandler::wordDetectStarted(const QXmlAttributes &atts) { - WordDetectRule *rule = new WordDetectRule; + auto rule = new WordDetectRule; rule->setString(atts.value(kString)); rule->setInsensitive(atts.value(kInsensitive)); rule->setActive(atts.value(kDynamic)); @@ -348,7 +348,7 @@ void HighlightDefinitionHandler::wordDetectStarted(const QXmlAttributes &atts) void HighlightDefinitionHandler::regExprStarted(const QXmlAttributes &atts) { - RegExprRule *rule = new RegExprRule; + auto rule = new RegExprRule; rule->setPattern(atts.value(kString)); rule->setMinimal(atts.value(kMinimal)); rule->setInsensitive(atts.value(kInsensitive)); @@ -358,7 +358,7 @@ void HighlightDefinitionHandler::regExprStarted(const QXmlAttributes &atts) void HighlightDefinitionHandler::keywordStarted(const QXmlAttributes &atts) { - KeywordRule *rule = new KeywordRule(m_definition); + auto rule = new KeywordRule(m_definition); try { rule->setList(atts.value(kString)); } catch (const HighlighterException &e) { @@ -404,7 +404,7 @@ void HighlightDefinitionHandler::hlCCharStarted(const QXmlAttributes &atts) void HighlightDefinitionHandler::rangeDetectStarted(const QXmlAttributes &atts) { - RangeDetectRule *rule = new RangeDetectRule; + auto rule = new RangeDetectRule; rule->setChar(atts.value(kChar)); rule->setChar1(atts.value(kChar1)); ruleElementStarted(atts, QSharedPointer(rule)); diff --git a/src/plugins/texteditor/generichighlighter/highlightdefinitionhandler.h b/src/plugins/texteditor/generichighlighter/highlightdefinitionhandler.h index db3d97704b4..bb7317ec514 100644 --- a/src/plugins/texteditor/generichighlighter/highlightdefinitionhandler.h +++ b/src/plugins/texteditor/generichighlighter/highlightdefinitionhandler.h @@ -43,14 +43,15 @@ class HighlightDefinitionHandler : public QXmlDefaultHandler { public: HighlightDefinitionHandler(const QSharedPointer &definition); - ~HighlightDefinitionHandler(); + ~HighlightDefinitionHandler() override; - bool startDocument(); - bool endDocument(); + bool startDocument() override; + bool endDocument() override; bool startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts); - bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName); - bool characters(const QString &ch); + const QString &qName, const QXmlAttributes &atts) override; + bool endElement(const QString &namespaceURI, const QString &localName, + const QString &qName) override; + bool characters(const QString &ch) override; private: void listElementStarted(const QXmlAttributes &atts); diff --git a/src/plugins/texteditor/generichighlighter/highlighter.cpp b/src/plugins/texteditor/generichighlighter/highlighter.cpp index 8ece3f462ed..f7004e878ca 100644 --- a/src/plugins/texteditor/generichighlighter/highlighter.cpp +++ b/src/plugins/texteditor/generichighlighter/highlighter.cpp @@ -62,7 +62,7 @@ public: m_continueObservableState(-1) {} - ~HighlighterCodeFormatterData() {} + ~HighlighterCodeFormatterData() override {} int m_foldingIndentDelta; int m_originalObservableState; QStack m_foldingRegions; @@ -71,7 +71,7 @@ public: HighlighterCodeFormatterData *formatterData(const QTextBlock &block) { - HighlighterCodeFormatterData *data = 0; + HighlighterCodeFormatterData *data = nullptr; if (TextBlockUserData *userData = TextDocumentLayout::userData(block)) { data = static_cast(userData->codeFormatterData()); if (!data) { @@ -127,13 +127,7 @@ static TextStyle styleForFormat(int format) } Highlighter::Highlighter(QTextDocument *parent) : - SyntaxHighlighter(parent), - m_regionDepth(0), - m_indentationBasedFolding(false), - m_tabSettings(0), - m_persistentObservableStatesCounter(PersistentsStart), - m_dynamicContextsCounter(0), - m_isBroken(false) + SyntaxHighlighter(parent) { setTextFormatCategories(TextFormatIdCount, styleForFormat); } @@ -217,7 +211,7 @@ void Highlighter::highlightBlock(const QString &text) handleContextChange(m_currentContext->lineBeginContext(), m_currentContext->definition()); - ProgressData *progress = new ProgressData; + auto progress = new ProgressData; const int length = text.length(); while (progress->offset() < length) iterateThroughRules(text, length, progress, false, m_currentContext->rules()); @@ -569,7 +563,7 @@ void Highlighter::applyFormat(int offset, // think this approach would fit better. If there are other ideas... QBrush bg = format.background(); if (bg.style() == Qt::NoBrush) - bg = TextEditorSettings::fontSettings().toTextCharFormat(C_TEXT).background(); + bg = fontSettings().toTextCharFormat(C_TEXT).background(); if (itemData->color().isValid() && isReadableOn(bg.color(), itemData->color())) format.setForeground(itemData->color()); if (itemData->isItalicSpecified()) diff --git a/src/plugins/texteditor/generichighlighter/highlighter.h b/src/plugins/texteditor/generichighlighter/highlighter.h index 7e925f9e484..f8144966000 100644 --- a/src/plugins/texteditor/generichighlighter/highlighter.h +++ b/src/plugins/texteditor/generichighlighter/highlighter.h @@ -172,14 +172,14 @@ private: static int extractRegionDepth(const int state); static int extractObservableState(const int state); - int m_regionDepth; - bool m_indentationBasedFolding; - const TabSettings *m_tabSettings; + int m_regionDepth = 0; + bool m_indentationBasedFolding = false; + const TabSettings *m_tabSettings = nullptr; - int m_persistentObservableStatesCounter; - int m_dynamicContextsCounter; + int m_persistentObservableStatesCounter = PersistentsStart; + int m_dynamicContextsCounter = 0; - bool m_isBroken; + bool m_isBroken = false; QSharedPointer m_defaultContext; QSharedPointer m_currentContext; diff --git a/src/plugins/texteditor/generichighlighter/highlightersettingspage.cpp b/src/plugins/texteditor/generichighlighter/highlightersettingspage.cpp index 05fd707e1f6..d43c528e08c 100644 --- a/src/plugins/texteditor/generichighlighter/highlightersettingspage.cpp +++ b/src/plugins/texteditor/generichighlighter/highlightersettingspage.cpp @@ -130,7 +130,7 @@ void HighlighterSettingsPage::finish() if (!m_d->m_page) // page was not shown return; delete m_d->m_page; - m_d->m_page = 0; + m_d->m_page = nullptr; } const HighlighterSettings &HighlighterSettingsPage::highlighterSettings() const @@ -172,11 +172,12 @@ void HighlighterSettingsPage::settingsToUI() void HighlighterSettingsPage::resetDefinitionsLocation() { const QString &location = findFallbackDefinitionsLocation(); - if (location.isEmpty()) - QMessageBox::information(0, tr("Autodetect Definitions"), + if (location.isEmpty()) { + QMessageBox::information(Core::ICore::dialogParent(), tr("Autodetect Definitions"), tr("No pre-installed definitions could be found.")); - else + } else { m_d->m_page->fallbackDefinitionFilesPath->setPath(location); + } } void HighlighterSettingsPage::requestAvailableDefinitionsMetaData() diff --git a/src/plugins/texteditor/generichighlighter/managedefinitionsdialog.cpp b/src/plugins/texteditor/generichighlighter/managedefinitionsdialog.cpp index 4b555ad0c14..1a6aa42ce02 100644 --- a/src/plugins/texteditor/generichighlighter/managedefinitionsdialog.cpp +++ b/src/plugins/texteditor/generichighlighter/managedefinitionsdialog.cpp @@ -77,7 +77,7 @@ void ManageDefinitionsDialog::populateDefinitionsWidget(const QListsetText(downloadData.name); item->setData(Qt::UserRole, downloadData.url); diff --git a/src/plugins/texteditor/generichighlighter/managedefinitionsdialog.h b/src/plugins/texteditor/generichighlighter/managedefinitionsdialog.h index 2a6d1c03087..3a5512dcecb 100644 --- a/src/plugins/texteditor/generichighlighter/managedefinitionsdialog.h +++ b/src/plugins/texteditor/generichighlighter/managedefinitionsdialog.h @@ -38,7 +38,7 @@ class ManageDefinitionsDialog : public QDialog public: explicit ManageDefinitionsDialog(const QList &metaDataList, const QString &path, - QWidget *parent = 0); + QWidget *parent = nullptr); private: void downloadDefinitions(); diff --git a/src/plugins/texteditor/generichighlighter/manager.cpp b/src/plugins/texteditor/generichighlighter/manager.cpp index d6fdc002b21..32da7ca4e5a 100644 --- a/src/plugins/texteditor/generichighlighter/manager.cpp +++ b/src/plugins/texteditor/generichighlighter/manager.cpp @@ -85,7 +85,7 @@ public: this, &MultiDefinitionDownloader::downloadDefinitionsFinished); } - ~MultiDefinitionDownloader() + ~MultiDefinitionDownloader() override { if (m_downloadWatcher.isRunning()) m_downloadWatcher.cancel(); @@ -107,9 +107,7 @@ private: QString m_downloadPath; }; -Manager::Manager() : - m_multiDownloader(0), - m_hasQueuedRegistration(false) +Manager::Manager() { connect(&m_registeringWatcher, &QFutureWatcherBase::finished, this, &Manager::registerHighlightingFilesFinished); @@ -404,7 +402,7 @@ void Manager::downloadAvailableDefinitionsMetaData() void Manager::downloadAvailableDefinitionsListFinished() { - if (QNetworkReply *reply = qobject_cast(sender())) { + if (auto reply = qobject_cast(sender())) { if (reply->error() == QNetworkReply::NoError) emit definitionsMetaDataReady(parseAvailableDefinitionsList(reply)); else @@ -425,7 +423,7 @@ void MultiDefinitionDownloader::downloadDefinitions(const QList &urls) { m_downloaders.clear(); foreach (const QUrl &url, urls) { - DefinitionDownloader *downloader = new DefinitionDownloader(url, m_downloadPath); + auto downloader = new DefinitionDownloader(url, m_downloadPath); connect(downloader, &DefinitionDownloader::foundReferencedDefinition, this, &MultiDefinitionDownloader::downloadReferencedDefinition); m_downloaders.append(downloader); @@ -479,7 +477,7 @@ void MultiDefinitionDownloader::downloadDefinitionsFinished() void Manager::downloadDefinitionsFinished() { delete m_multiDownloader; - m_multiDownloader = 0; + m_multiDownloader = nullptr; } void MultiDefinitionDownloader::downloadReferencedDefinition(const QString &name) @@ -492,7 +490,7 @@ void MultiDefinitionDownloader::downloadReferencedDefinition(const QString &name bool Manager::isDownloadingDefinitions() const { - return m_multiDownloader != 0; + return m_multiDownloader != nullptr; } void Manager::clear() diff --git a/src/plugins/texteditor/generichighlighter/manager.h b/src/plugins/texteditor/generichighlighter/manager.h index 133c612efcc..18a6c3016fa 100644 --- a/src/plugins/texteditor/generichighlighter/manager.h +++ b/src/plugins/texteditor/generichighlighter/manager.h @@ -97,7 +97,7 @@ private: void clear(); - MultiDefinitionDownloader *m_multiDownloader; + MultiDefinitionDownloader *m_multiDownloader = nullptr; QList parseAvailableDefinitionsList(QIODevice *device); QSet m_isBuildingDefinition; @@ -105,7 +105,7 @@ private: QHash m_availableDefinitions; RegisterData m_register; - bool m_hasQueuedRegistration; + bool m_hasQueuedRegistration = false; QFutureWatcher m_registeringWatcher; friend class ManagerProcessor; diff --git a/src/plugins/texteditor/generichighlighter/specificrules.h b/src/plugins/texteditor/generichighlighter/specificrules.h index c4a76e07715..aa9178a5962 100644 --- a/src/plugins/texteditor/generichighlighter/specificrules.h +++ b/src/plugins/texteditor/generichighlighter/specificrules.h @@ -42,16 +42,14 @@ class HighlightDefinition; class DetectCharRule : public DynamicRule { public: - virtual ~DetectCharRule() {} + ~DetectCharRule() override {} void setChar(const QString &character); private: - virtual bool doMatchSucceed(const QString &text, - const int length, - ProgressData *progress); - virtual DetectCharRule *doClone() const { return new DetectCharRule(*this); } - virtual void doReplaceExpressions(const QStringList &captures); + bool doMatchSucceed(const QString &text, const int length, ProgressData *progress) override; + DetectCharRule *doClone() const override { return new DetectCharRule(*this); } + void doReplaceExpressions(const QStringList &captures) override; QChar m_char; }; @@ -59,17 +57,15 @@ private: class Detect2CharsRule : public DynamicRule { public: - virtual ~Detect2CharsRule() {} + ~Detect2CharsRule() override {} void setChar(const QString &character); void setChar1(const QString &character); private: - virtual bool doMatchSucceed(const QString &text, - const int length, - ProgressData *progress); - virtual Detect2CharsRule *doClone() const { return new Detect2CharsRule(*this); } - virtual void doReplaceExpressions(const QStringList &captures); + bool doMatchSucceed(const QString &text, const int length, ProgressData *progress) override; + Detect2CharsRule *doClone() const override { return new Detect2CharsRule(*this); } + void doReplaceExpressions(const QStringList &captures) override; QChar m_char; QChar m_char1; @@ -78,15 +74,13 @@ private: class AnyCharRule : public Rule { public: - virtual ~AnyCharRule() {} + ~AnyCharRule() override {} void setCharacterSet(const QString &s); private: - virtual bool doMatchSucceed(const QString &text, - const int length, - ProgressData *progress); - virtual AnyCharRule *doClone() const { return new AnyCharRule(*this); } + bool doMatchSucceed(const QString &text, const int length, ProgressData *progress) override; + AnyCharRule *doClone() const override { return new AnyCharRule(*this); } QString m_characterSet; }; @@ -94,17 +88,15 @@ private: class StringDetectRule : public DynamicRule { public: - virtual ~StringDetectRule() {} + ~StringDetectRule() override {} void setString(const QString &s); void setInsensitive(const QString &insensitive); protected: - virtual bool doMatchSucceed(const QString &text, - const int length, - ProgressData *progress); - virtual StringDetectRule *doClone() const { return new StringDetectRule(*this); } - virtual void doReplaceExpressions(const QStringList &captures); + bool doMatchSucceed(const QString &text, const int length, ProgressData *progress) override; + StringDetectRule *doClone() const override { return new StringDetectRule(*this); } + void doReplaceExpressions(const QStringList &captures) override; QString m_string; int m_length = 0; @@ -114,28 +106,24 @@ protected: class WordDetectRule : public StringDetectRule { private: - virtual bool doMatchSucceed(const QString &text, - const int length, - ProgressData *progress); - virtual WordDetectRule *doClone() const { return new WordDetectRule(*this); } + bool doMatchSucceed(const QString &text, const int length, ProgressData *progress) override; + WordDetectRule *doClone() const override { return new WordDetectRule(*this); } }; class RegExprRule : public DynamicRule { public: - virtual ~RegExprRule(); + ~RegExprRule() override; void setPattern(const QString &pattern); void setInsensitive(const QString &insensitive); void setMinimal(const QString &minimal); private: - virtual bool doMatchSucceed(const QString &text, - const int length, - ProgressData *progress); - virtual RegExprRule *doClone() const; - virtual void doReplaceExpressions(const QStringList &captures); - virtual void doProgressFinished(); + bool doMatchSucceed(const QString &text, const int length, ProgressData *progress) override; + RegExprRule *doClone() const override; + void doReplaceExpressions(const QStringList &captures) override; + void doProgressFinished() override; bool isExactMatch(ProgressData *progress); @@ -152,16 +140,14 @@ class KeywordRule : public Rule { public: KeywordRule(const QSharedPointer &definition); - virtual ~KeywordRule(); + ~KeywordRule() override; void setInsensitive(const QString &insensitive); void setList(const QString &listName); private: - virtual bool doMatchSucceed(const QString &text, - const int length, - ProgressData *progress); - virtual KeywordRule *doClone() const { return new KeywordRule(*this); } + bool doMatchSucceed(const QString &text, const int length, ProgressData *progress) override; + KeywordRule *doClone() const override { return new KeywordRule(*this); } bool m_overrideGlobal; Qt::CaseSensitivity m_localCaseSensitivity; @@ -171,88 +157,74 @@ private: class IntRule : public Rule { public: - virtual ~IntRule() {} + ~IntRule() override {} private: - virtual bool doMatchSucceed(const QString &text, - const int length, - ProgressData *progress); - virtual IntRule *doClone() const { return new IntRule(*this); } + bool doMatchSucceed(const QString &text, const int length, ProgressData *progress) override; + IntRule *doClone() const override { return new IntRule(*this); } }; class FloatRule : public Rule { public: - virtual ~FloatRule() {} + ~FloatRule() override {} private: - virtual bool doMatchSucceed(const QString &text, - const int length, - ProgressData *progress); - virtual FloatRule *doClone() const { return new FloatRule(*this); } + bool doMatchSucceed(const QString &text, const int length, ProgressData *progress) override; + FloatRule *doClone() const override { return new FloatRule(*this); } }; class HlCOctRule : public Rule { public: - virtual ~HlCOctRule() {} + ~HlCOctRule() override {} private: - virtual bool doMatchSucceed(const QString &text, - const int length, - ProgressData *progress); - virtual HlCOctRule *doClone() const { return new HlCOctRule(*this); } + bool doMatchSucceed(const QString &text, const int length, ProgressData *progress) override; + HlCOctRule *doClone() const override { return new HlCOctRule(*this); } }; class HlCHexRule : public Rule { public: - virtual ~HlCHexRule() {} + ~HlCHexRule() override {} private: - virtual bool doMatchSucceed(const QString &text, - const int length, - ProgressData *progress); - virtual HlCHexRule *doClone() const { return new HlCHexRule(*this); } + bool doMatchSucceed(const QString &text, const int length, ProgressData *progress) override; + HlCHexRule *doClone() const override { return new HlCHexRule(*this); } }; class HlCStringCharRule : public Rule { public: - virtual ~HlCStringCharRule() {} + ~HlCStringCharRule() override {} private: - virtual bool doMatchSucceed(const QString &text, - const int length, - ProgressData *progress); - virtual HlCStringCharRule *doClone() const { return new HlCStringCharRule(*this); } + bool doMatchSucceed(const QString &text, const int length, ProgressData *progress) override; + HlCStringCharRule *doClone() const override { return new HlCStringCharRule(*this); } }; class HlCCharRule : public Rule { public: - virtual ~HlCCharRule() {} + ~HlCCharRule() override {} private: - virtual bool doMatchSucceed(const QString &text, - const int length, - ProgressData *progress); - virtual HlCCharRule *doClone() const { return new HlCCharRule(*this); } + bool doMatchSucceed(const QString &text, const int length, ProgressData *progress) override; + HlCCharRule *doClone() const override { return new HlCCharRule(*this); } }; class RangeDetectRule : public Rule { public: - virtual ~RangeDetectRule() {} + ~RangeDetectRule() override {} void setChar(const QString &character); void setChar1(const QString &character); private: - virtual bool doMatchSucceed(const QString &text, - const int length, - ProgressData *progress); - virtual RangeDetectRule *doClone() const { return new RangeDetectRule(*this); } + bool doMatchSucceed(const QString &text, const int length, ProgressData *progress) override; + RangeDetectRule *doClone() const override { return new RangeDetectRule(*this); } QChar m_char; QChar m_char1; @@ -261,38 +233,32 @@ private: class LineContinueRule : public Rule { public: - virtual ~LineContinueRule() {} + ~LineContinueRule() override {} private: - virtual bool doMatchSucceed(const QString &text, - const int length, - ProgressData *progress); - virtual LineContinueRule *doClone() const { return new LineContinueRule(*this); } + bool doMatchSucceed(const QString &text, const int length, ProgressData *progress) override; + LineContinueRule *doClone() const override { return new LineContinueRule(*this); } }; class DetectSpacesRule : public Rule { public: DetectSpacesRule(); - virtual ~DetectSpacesRule() {} + ~DetectSpacesRule() override {} private: - virtual bool doMatchSucceed(const QString &text, - const int length, - ProgressData *progress); - virtual DetectSpacesRule *doClone() const { return new DetectSpacesRule(*this); } + bool doMatchSucceed(const QString &text, const int length, ProgressData *progress) override; + DetectSpacesRule *doClone() const override { return new DetectSpacesRule(*this); } }; class DetectIdentifierRule : public Rule { public: - virtual ~DetectIdentifierRule() {} + ~DetectIdentifierRule() override {} private: - virtual bool doMatchSucceed(const QString &text, - const int length, - ProgressData *progress); - virtual DetectIdentifierRule *doClone() const { return new DetectIdentifierRule(*this); } + bool doMatchSucceed(const QString &text, const int length, ProgressData *progress) override; + DetectIdentifierRule *doClone() const override { return new DetectIdentifierRule(*this); } }; } // namespace Internal diff --git a/src/plugins/texteditor/icodestylepreferences.cpp b/src/plugins/texteditor/icodestylepreferences.cpp index 76ed2001b27..bebd25f29f7 100644 --- a/src/plugins/texteditor/icodestylepreferences.cpp +++ b/src/plugins/texteditor/icodestylepreferences.cpp @@ -40,18 +40,12 @@ namespace Internal { class ICodeStylePreferencesPrivate { public: - ICodeStylePreferencesPrivate() - : m_pool(0), - m_currentDelegate(0), - m_readOnly(false) - {} - - CodeStylePool *m_pool; - ICodeStylePreferences *m_currentDelegate; + CodeStylePool *m_pool = nullptr; + ICodeStylePreferences *m_currentDelegate = nullptr; TabSettings m_tabSettings; QByteArray m_id; QString m_displayName; - bool m_readOnly; + bool m_readOnly = false; }; } @@ -128,7 +122,7 @@ QVariant ICodeStylePreferences::currentValue() const ICodeStylePreferences *ICodeStylePreferences::currentPreferences() const { - ICodeStylePreferences *prefs = (ICodeStylePreferences *)this; + auto prefs = (ICodeStylePreferences *)this; while (prefs->currentDelegate()) prefs = prefs->currentDelegate(); return prefs; @@ -144,7 +138,7 @@ void ICodeStylePreferences::setDelegatingPool(CodeStylePool *pool) if (pool == d->m_pool) return; - setCurrentDelegate(0); + setCurrentDelegate(nullptr); if (d->m_pool) { disconnect(d->m_pool, &CodeStylePool::codeStyleRemoved, this, &ICodeStylePreferences::codeStyleRemoved); @@ -247,7 +241,7 @@ void ICodeStylePreferences::codeStyleRemoved(ICodeStylePreferences *preferences) CodeStylePool *pool = delegatingPool(); QList codeStyles = pool->codeStyles(); const int idx = codeStyles.indexOf(preferences); - ICodeStylePreferences *newCurrentPreferences = 0; + ICodeStylePreferences *newCurrentPreferences = nullptr; int i = idx + 1; // go forward while (i < codeStyles.count()) { diff --git a/src/plugins/texteditor/linenumberfilter.cpp b/src/plugins/texteditor/linenumberfilter.cpp index 129fd089392..381dade4555 100644 --- a/src/plugins/texteditor/linenumberfilter.cpp +++ b/src/plugins/texteditor/linenumberfilter.cpp @@ -56,7 +56,7 @@ LineNumberFilter::LineNumberFilter(QObject *parent) void LineNumberFilter::prepareSearch(const QString &entry) { Q_UNUSED(entry) - m_hasCurrentEditor = EditorManager::currentEditor() != 0; + m_hasCurrentEditor = EditorManager::currentEditor() != nullptr; } QList LineNumberFilter::matchesFor(QFutureInterface &, const QString &entry) diff --git a/src/plugins/texteditor/outlinefactory.cpp b/src/plugins/texteditor/outlinefactory.cpp index 6c04f74b681..e6a96ae1ec2 100644 --- a/src/plugins/texteditor/outlinefactory.cpp +++ b/src/plugins/texteditor/outlinefactory.cpp @@ -134,7 +134,7 @@ void OutlineWidgetStack::restoreSettings(QSettings *settings, int position) } toggleSyncButton()->setChecked(syncWithEditor); - if (IOutlineWidget *outlineWidget = qobject_cast(currentWidget())) + if (auto outlineWidget = qobject_cast(currentWidget())) outlineWidget->restoreSettings(m_widgetSettings); } @@ -146,14 +146,14 @@ bool OutlineWidgetStack::isCursorSynchronized() const void OutlineWidgetStack::toggleCursorSynchronization() { m_syncWithEditor = !m_syncWithEditor; - if (IOutlineWidget *outlineWidget = qobject_cast(currentWidget())) + if (auto outlineWidget = qobject_cast(currentWidget())) outlineWidget->setCursorSynchronization(m_syncWithEditor); } void OutlineWidgetStack::updateFilterMenu() { m_filterMenu->clear(); - if (IOutlineWidget *outlineWidget = qobject_cast(currentWidget())) { + if (auto outlineWidget = qobject_cast(currentWidget())) { foreach (QAction *filterAction, outlineWidget->filterMenuActions()) { m_filterMenu->addAction(filterAction); } @@ -163,7 +163,7 @@ void OutlineWidgetStack::updateFilterMenu() void OutlineWidgetStack::updateCurrentEditor(Core::IEditor *editor) { - IOutlineWidget *newWidget = 0; + IOutlineWidget *newWidget = nullptr; if (editor) { for (IOutlineWidgetFactory *widgetFactory : g_outlineWidgetFactories) { @@ -176,7 +176,7 @@ void OutlineWidgetStack::updateCurrentEditor(Core::IEditor *editor) if (newWidget != currentWidget()) { // delete old widget - if (IOutlineWidget *outlineWidget = qobject_cast(currentWidget())) { + if (auto outlineWidget = qobject_cast(currentWidget())) { QVariantMap widgetSettings = outlineWidget->settings(); for (auto iter = widgetSettings.constBegin(); iter != widgetSettings.constEnd(); ++iter) m_widgetSettings.insert(iter.key(), iter.value()); @@ -205,7 +205,7 @@ OutlineFactory::OutlineFactory() Core::NavigationView OutlineFactory::createWidget() { Core::NavigationView n; - OutlineWidgetStack *placeHolder = new OutlineWidgetStack(this); + auto placeHolder = new OutlineWidgetStack(this); n.widget = placeHolder; n.dockToolBarWidgets.append(placeHolder->filterButton()); n.dockToolBarWidgets.append(placeHolder->toggleSyncButton()); @@ -214,14 +214,14 @@ Core::NavigationView OutlineFactory::createWidget() void OutlineFactory::saveSettings(QSettings *settings, int position, QWidget *widget) { - OutlineWidgetStack *widgetStack = qobject_cast(widget); + auto widgetStack = qobject_cast(widget); Q_ASSERT(widgetStack); widgetStack->saveSettings(settings, position); } void OutlineFactory::restoreSettings(QSettings *settings, int position, QWidget *widget) { - OutlineWidgetStack *widgetStack = qobject_cast(widget); + auto widgetStack = qobject_cast(widget); Q_ASSERT(widgetStack); widgetStack->restoreSettings(settings, position); } diff --git a/src/plugins/texteditor/plaintexteditorfactory.cpp b/src/plugins/texteditor/plaintexteditorfactory.cpp index 3e39cf810ab..f60d3c67c86 100644 --- a/src/plugins/texteditor/plaintexteditorfactory.cpp +++ b/src/plugins/texteditor/plaintexteditorfactory.cpp @@ -41,7 +41,7 @@ namespace TextEditor { -static PlainTextEditorFactory *m_instance = 0; +static PlainTextEditorFactory *m_instance = nullptr; class PlainTextEditorWidget : public TextEditorWidget { diff --git a/src/plugins/texteditor/refactoringchanges.cpp b/src/plugins/texteditor/refactoringchanges.cpp index 9370a5f0c19..58bc49bc24d 100644 --- a/src/plugins/texteditor/refactoringchanges.cpp +++ b/src/plugins/texteditor/refactoringchanges.cpp @@ -82,7 +82,7 @@ bool RefactoringChanges::createFile(const QString &fileName, const QString &cont return false; // Create a text document for the new file: - QTextDocument *document = new QTextDocument; + auto document = new QTextDocument; QTextCursor cursor(document); cursor.beginEditBlock(); cursor.insertText(contents); @@ -90,7 +90,7 @@ bool RefactoringChanges::createFile(const QString &fileName, const QString &cont // Reindent the contents: if (reindent) { cursor.select(QTextCursor::Document); - m_data->indentSelection(cursor, fileName, 0); + m_data->indentSelection(cursor, fileName, nullptr); } cursor.endEditBlock(); @@ -135,7 +135,7 @@ TextEditorWidget *RefactoringChanges::openEditor(const QString &fileName, bool a if (editor) return qobject_cast(editor->widget()); else - return 0; + return nullptr; } RefactoringFilePtr RefactoringChanges::file(TextEditorWidget *editor) @@ -151,32 +151,16 @@ RefactoringFilePtr RefactoringChanges::file(const QString &fileName) const RefactoringFile::RefactoringFile(QTextDocument *document, const QString &fileName) : m_fileName(fileName) , m_document(document) - , m_editor(0) - , m_openEditor(false) - , m_activateEditor(false) - , m_editorCursorPosition(-1) - , m_appliedOnce(false) { } RefactoringFile::RefactoringFile(TextEditorWidget *editor) : m_fileName(editor->textDocument()->filePath().toString()) - , m_document(0) , m_editor(editor) - , m_openEditor(false) - , m_activateEditor(false) - , m_editorCursorPosition(-1) - , m_appliedOnce(false) { } RefactoringFile::RefactoringFile(const QString &fileName, const QSharedPointer &data) : m_fileName(fileName) , m_data(data) - , m_document(0) - , m_editor(0) - , m_openEditor(false) - , m_activateEditor(false) - , m_editorCursorPosition(-1) - , m_appliedOnce(false) { QList editors = DocumentModel::editorsForFilePath(fileName); if (!editors.isEmpty()) { @@ -218,7 +202,7 @@ QTextDocument *RefactoringFile::mutableDocument() const &error); if (result != TextFileFormat::ReadSuccess) { qWarning() << "Could not read " << m_fileName << ". Error: " << error; - m_textFileFormat.codec = 0; + m_textFileFormat.codec = nullptr; } } // always make a QTextDocument to avoid excessive null checks @@ -340,7 +324,7 @@ bool RefactoringFile::apply() // open / activate / goto position if (m_openEditor && !m_fileName.isEmpty()) { - unsigned line = unsigned(-1), column = unsigned(-1); + auto line = unsigned(-1), column = unsigned(-1); if (m_editorCursorPosition != -1) lineAndColumn(m_editorCursorPosition, &line, &column); m_editor = RefactoringChanges::openEditor(m_fileName, m_activateEditor, line, column); @@ -409,7 +393,7 @@ void RefactoringFile::indentOrReindent(void (RefactoringChangesData::*mf)(const QTextCursor selection(p.first.document()); selection.setPosition(p.first.position()); selection.setPosition(p.second.position(), QTextCursor::KeepAnchor); - ((*m_data).*(mf))(selection, m_fileName, m_editor ? m_editor->textDocument() : 0); + ((*m_data).*(mf))(selection, m_fileName, m_editor ? m_editor->textDocument() : nullptr); } } diff --git a/src/plugins/texteditor/refactoringchanges.h b/src/plugins/texteditor/refactoringchanges.h index ecf6ff277cc..3821f69b82b 100644 --- a/src/plugins/texteditor/refactoringchanges.h +++ b/src/plugins/texteditor/refactoringchanges.h @@ -102,15 +102,15 @@ protected: QString m_fileName; QSharedPointer m_data; mutable Utils::TextFileFormat m_textFileFormat; - mutable QTextDocument *m_document; - TextEditorWidget *m_editor; + mutable QTextDocument *m_document = nullptr; + TextEditorWidget *m_editor = nullptr; Utils::ChangeSet m_changes; QList m_indentRanges; QList m_reindentRanges; - bool m_openEditor; - bool m_activateEditor; - int m_editorCursorPosition; - bool m_appliedOnce; + bool m_openEditor = false; + bool m_activateEditor = false; + int m_editorCursorPosition = -1; + bool m_appliedOnce = false; friend class RefactoringChanges; // access to constructor }; diff --git a/src/plugins/texteditor/refactoroverlay.cpp b/src/plugins/texteditor/refactoroverlay.cpp index fce06803fd4..718dfd461cc 100644 --- a/src/plugins/texteditor/refactoroverlay.cpp +++ b/src/plugins/texteditor/refactoroverlay.cpp @@ -50,7 +50,7 @@ void RefactorOverlay::paint(QPainter *painter, const QRect &clip) paintMarker(m_markers.at(i), painter, clip); } - if (TextDocumentLayout *documentLayout = qobject_cast(m_editor->document()->documentLayout())) + if (auto documentLayout = qobject_cast(m_editor->document()->documentLayout())) documentLayout->setRequiredWidth(m_maxWidth); } diff --git a/src/plugins/texteditor/simplecodestylepreferenceswidget.cpp b/src/plugins/texteditor/simplecodestylepreferenceswidget.cpp index fea18aadcc2..d520232c632 100644 --- a/src/plugins/texteditor/simplecodestylepreferenceswidget.cpp +++ b/src/plugins/texteditor/simplecodestylepreferenceswidget.cpp @@ -33,11 +33,10 @@ namespace TextEditor { SimpleCodeStylePreferencesWidget::SimpleCodeStylePreferencesWidget(QWidget *parent) : - QWidget(parent), - m_preferences(0) + QWidget(parent) { m_tabSettingsWidget = new TabSettingsWidget(this); - QVBoxLayout *layout = new QVBoxLayout(this); + auto layout = new QVBoxLayout(this); layout->addWidget(m_tabSettingsWidget); layout->setContentsMargins(QMargins()); m_tabSettingsWidget->setEnabled(false); diff --git a/src/plugins/texteditor/simplecodestylepreferenceswidget.h b/src/plugins/texteditor/simplecodestylepreferenceswidget.h index 7bafac8e833..9b77a98a277 100644 --- a/src/plugins/texteditor/simplecodestylepreferenceswidget.h +++ b/src/plugins/texteditor/simplecodestylepreferenceswidget.h @@ -54,7 +54,7 @@ private: void slotTabSettingsChanged(const TextEditor::TabSettings &settings); TabSettingsWidget *m_tabSettingsWidget; - ICodeStylePreferences *m_preferences; + ICodeStylePreferences *m_preferences = nullptr; }; } // namespace TextEditor diff --git a/src/plugins/texteditor/snippets/snippet.cpp b/src/plugins/texteditor/snippets/snippet.cpp index 78ce8aa2621..c80fbcb2afe 100644 --- a/src/plugins/texteditor/snippets/snippet.cpp +++ b/src/plugins/texteditor/snippets/snippet.cpp @@ -222,7 +222,7 @@ Snippet::ParsedSnippet Snippet::parse(const QString &snippet) } else { int length = result.text.count() - start; result.ranges << ParsedSnippet::Range(start, length, mangler); - mangler = 0; + mangler = nullptr; start = -1; } continue; diff --git a/src/plugins/texteditor/snippets/snippetassistcollector.cpp b/src/plugins/texteditor/snippets/snippetassistcollector.cpp index ba3725a5389..3498fad1ac2 100644 --- a/src/plugins/texteditor/snippets/snippetassistcollector.cpp +++ b/src/plugins/texteditor/snippets/snippetassistcollector.cpp @@ -41,7 +41,7 @@ static void appendSnippets(QList *items, const int size = collection->totalActiveSnippets(groupId); for (int i = 0; i < size; ++i) { const Snippet &snippet = collection->snippet(i, groupId); - AssistProposalItem *item = new AssistProposalItem; + auto item = new AssistProposalItem; item->setText(snippet.trigger() + QLatin1Char(' ') + snippet.complement()); item->setData(snippet.content()); item->setDetail(snippet.generateTip()); diff --git a/src/plugins/texteditor/snippets/snippetscollection.h b/src/plugins/texteditor/snippets/snippetscollection.h index 98e9d80f24e..0f4ba67899a 100644 --- a/src/plugins/texteditor/snippets/snippetscollection.h +++ b/src/plugins/texteditor/snippets/snippetscollection.h @@ -48,7 +48,7 @@ class SnippetsCollection : public QObject { Q_OBJECT public: - virtual ~SnippetsCollection(); + ~SnippetsCollection() override; static SnippetsCollection *instance(); diff --git a/src/plugins/texteditor/snippets/snippetssettingspage.cpp b/src/plugins/texteditor/snippets/snippetssettingspage.cpp index b8151c4b172..542d54c2c30 100644 --- a/src/plugins/texteditor/snippets/snippetssettingspage.cpp +++ b/src/plugins/texteditor/snippets/snippetssettingspage.cpp @@ -54,16 +54,16 @@ class SnippetsTableModel : public QAbstractTableModel Q_OBJECT public: SnippetsTableModel(QObject *parent); - virtual ~SnippetsTableModel() {} + ~SnippetsTableModel() override {} - virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; - virtual int columnCount(const QModelIndex &parent = QModelIndex()) const; - virtual Qt::ItemFlags flags(const QModelIndex &modelIndex) const; - virtual QVariant data(const QModelIndex &modelIndex, int role = Qt::DisplayRole) const; - virtual bool setData(const QModelIndex &modelIndex, const QVariant &value, - int role = Qt::EditRole); - virtual QVariant headerData(int section, Qt::Orientation orientation, - int role = Qt::DisplayRole) const; + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + int columnCount(const QModelIndex &parent = QModelIndex()) const override; + Qt::ItemFlags flags(const QModelIndex &modelIndex) const override; + QVariant data(const QModelIndex &modelIndex, int role = Qt::DisplayRole) const override; + bool setData(const QModelIndex &modelIndex, const QVariant &value, + int role = Qt::EditRole) override; + QVariant headerData(int section, Qt::Orientation orientation, + int role = Qt::DisplayRole) const override; QList groupIds() const; void load(const QString &groupId); @@ -131,7 +131,8 @@ bool SnippetsTableModel::setData(const QModelIndex &modelIndex, const QVariant & if (modelIndex.column() == 0) { const QString &s = value.toString(); if (!isValidTrigger(s)) { - QMessageBox::critical(0, tr("Error"), tr("Not a valid trigger.")); + QMessageBox::critical(Core::ICore::dialogParent(), tr("Error"), + tr("Not a valid trigger.")); if (snippet.trigger().isEmpty()) removeSnippet(modelIndex); return false; @@ -207,7 +208,8 @@ void SnippetsTableModel::revertBuitInSnippet(const QModelIndex &modelIndex) { const Snippet &snippet = m_collection->revertedSnippet(modelIndex.row(), m_activeGroupId); if (snippet.id().isEmpty()) { - QMessageBox::critical(0, tr("Error"), tr("Error reverting snippet.")); + QMessageBox::critical(Core::ICore::dialogParent(), tr("Error"), + tr("Error reverting snippet.")); return; } replaceSnippet(snippet, modelIndex); @@ -265,7 +267,7 @@ class SnippetsSettingsPagePrivate : public QObject Q_OBJECT public: SnippetsSettingsPagePrivate(Core::Id id); - ~SnippetsSettingsPagePrivate() { delete m_model; } + ~SnippetsSettingsPagePrivate() override { delete m_model; } Core::Id id() const { return m_id; } const QString &displayName() const { return m_displayName; } @@ -310,7 +312,7 @@ SnippetsSettingsPagePrivate::SnippetsSettingsPagePrivate(Core::Id id) : m_id(id), m_displayName(tr("Snippets")), m_settingsPrefix(QLatin1String("Text")), - m_model(new SnippetsTableModel(0)), + m_model(new SnippetsTableModel(nullptr)), m_snippetsCollectionChanged(false) {} @@ -330,7 +332,7 @@ void SnippetsSettingsPagePrivate::configureUi(QWidget *w) for (const SnippetProvider &provider : SnippetProvider::snippetProviders()) { m_ui.groupCombo->addItem(provider.displayName(), provider.groupId()); - SnippetEditorWidget *snippetEditor = new SnippetEditorWidget(w); + auto snippetEditor = new SnippetEditorWidget(w); SnippetProvider::decorateEditor(snippetEditor, provider.groupId()); m_ui.snippetsEditorStack->insertWidget(m_ui.groupCombo->count() - 1, snippetEditor); connect(snippetEditor, &SnippetEditorWidget::snippetContentChanged, @@ -391,11 +393,12 @@ void SnippetsSettingsPagePrivate::apply() if (m_snippetsCollectionChanged) { QString errorString; - if (SnippetsCollection::instance()->synchronize(&errorString)) + if (SnippetsCollection::instance()->synchronize(&errorString)) { m_snippetsCollectionChanged = false; - else - QMessageBox::critical(Core::ICore::mainWindow(), - tr("Error While Saving Snippet Collection"), errorString); + } else { + QMessageBox::critical(Core::ICore::dialogParent(), + tr("Error While Saving Snippet Collection"), errorString); + } } } @@ -406,7 +409,7 @@ void SnippetsSettingsPagePrivate::finish() m_snippetsCollectionChanged = false; } - disconnect(TextEditorSettings::instance(), 0, this, 0); + disconnect(TextEditorSettings::instance(), nullptr, this, nullptr); } void SnippetsSettingsPagePrivate::loadSettings() @@ -466,7 +469,7 @@ void SnippetsSettingsPagePrivate::removeSnippet() { const QModelIndex &modelIndex = m_ui.snippetsTable->selectionModel()->currentIndex(); if (!modelIndex.isValid()) { - QMessageBox::critical(0, tr("Error"), tr("No snippet selected.")); + QMessageBox::critical(Core::ICore::dialogParent(), tr("Error"), tr("No snippet selected.")); return; } m_model->removeSnippet(modelIndex); diff --git a/src/plugins/texteditor/syntaxhighlighter.cpp b/src/plugins/texteditor/syntaxhighlighter.cpp index 621df4f236d..a7c1a8fecb5 100644 --- a/src/plugins/texteditor/syntaxhighlighter.cpp +++ b/src/plugins/texteditor/syntaxhighlighter.cpp @@ -66,6 +66,7 @@ public: void applyFormatChanges(int from, int charsRemoved, int charsAdded); void updateFormats(const FontSettings &fontSettings); + FontSettings fontSettings; QVector formatChanges; QTextBlock currentBlock; bool rehighlightPending = false; @@ -293,7 +294,7 @@ SyntaxHighlighter::SyntaxHighlighter(QTextEdit *parent) */ SyntaxHighlighter::~SyntaxHighlighter() { - setDocument(0); + setDocument(nullptr); } /*! @@ -640,7 +641,7 @@ QTextBlockUserData *SyntaxHighlighter::currentBlockUserData() const { Q_D(const SyntaxHighlighter); if (!d->currentBlock.isValid()) - return 0; + return nullptr; return d->currentBlock.userData(); } @@ -678,7 +679,7 @@ void SyntaxHighlighter::setExtraFormats(const QTextBlock &block, Q_D(SyntaxHighlighter); const int blockLength = block.length(); - if (block.layout() == 0 || blockLength == 0) + if (block.layout() == nullptr || blockLength == 0) return; Utils::sort(formats, byStartOfRange); @@ -765,6 +766,12 @@ void SyntaxHighlighter::setFontSettings(const FontSettings &fontSettings) Q_D(SyntaxHighlighter); d->updateFormats(fontSettings); } + +FontSettings SyntaxHighlighter::fontSettings() const +{ + Q_D(const SyntaxHighlighter); + return d->fontSettings; +} /*! The syntax highlighter is not anymore reacting to the text document if \a noAutmatic is \c true. @@ -836,6 +843,7 @@ void SyntaxHighlighter::highlightBlock(const QString &text) void SyntaxHighlighterPrivate::updateFormats(const FontSettings &fontSettings) { + this->fontSettings = fontSettings; // C_TEXT is handled by text editor's foreground and background color, // so use empty format for that for (const auto &pair : qAsConst(formatCategories)) { diff --git a/src/plugins/texteditor/syntaxhighlighter.h b/src/plugins/texteditor/syntaxhighlighter.h index b67a277d2c4..134768b1678 100644 --- a/src/plugins/texteditor/syntaxhighlighter.h +++ b/src/plugins/texteditor/syntaxhighlighter.h @@ -69,6 +69,7 @@ public: // Don't call in constructors of derived classes virtual void setFontSettings(const TextEditor::FontSettings &fontSettings); + TextEditor::FontSettings fontSettings() const; void setNoAutomaticHighlighting(bool noAutomatic); diff --git a/src/plugins/texteditor/textdocument.cpp b/src/plugins/texteditor/textdocument.cpp index 6293a747a7c..6bc47e3f561 100644 --- a/src/plugins/texteditor/textdocument.cpp +++ b/src/plugins/texteditor/textdocument.cpp @@ -207,7 +207,7 @@ QTextCursor TextDocumentPrivate::indentOrUnindent(const QTextCursor &textCursor, void TextDocumentPrivate::resetRevisions() { - TextDocumentLayout *documentLayout = qobject_cast(m_document.documentLayout()); + auto documentLayout = qobject_cast(m_document.documentLayout()); QTC_ASSERT(documentLayout, return); documentLayout->lastSaveRevision = m_document.revision(); @@ -217,7 +217,7 @@ void TextDocumentPrivate::resetRevisions() void TextDocumentPrivate::updateRevisions() { - TextDocumentLayout *documentLayout = qobject_cast(m_document.documentLayout()); + auto documentLayout = qobject_cast(m_document.documentLayout()); QTC_ASSERT(documentLayout, return); int oldLastSaveRevision = documentLayout->lastSaveRevision; documentLayout->lastSaveRevision = m_document.revision(); @@ -272,7 +272,7 @@ QMap TextDocument::openedTextDocumentContents() { QMap workingCopy; foreach (IDocument *document, DocumentModel::openedDocuments()) { - TextDocument *textEditorDocument = qobject_cast(document); + auto textEditorDocument = qobject_cast(document); if (!textEditorDocument) continue; QString fileName = textEditorDocument->filePath().toString(); @@ -285,7 +285,7 @@ QMap TextDocument::openedTextDocumentEncodings() { QMap workingCopy; foreach (IDocument *document, DocumentModel::openedDocuments()) { - TextDocument *textEditorDocument = qobject_cast(document); + auto textEditorDocument = qobject_cast(document); if (!textEditorDocument) continue; QString fileName = textEditorDocument->filePath().toString(); @@ -340,7 +340,7 @@ void TextDocument::setTabSettings(const TabSettings &newTabSettings) return; d->m_tabSettings = newTabSettings; - if (Highlighter *highlighter = qobject_cast(d->m_highlighter)) + if (auto highlighter = qobject_cast(d->m_highlighter)) highlighter->setTabSettings(tabSettings()); emit tabSettingsChanged(); @@ -696,7 +696,7 @@ Core::IDocument::OpenResult TextDocument::openImpl(QString *errorString, const Q if (!reload || fileName == realFileName) d->m_document.setUndoRedoEnabled(true); - TextDocumentLayout *documentLayout = + auto documentLayout = qobject_cast(d->m_document.documentLayout()); QTC_ASSERT(documentLayout, return OpenResult::CannotHandle); documentLayout->lastSaveRevision = d->m_autoSaveRevision = d->m_document.revision(); @@ -724,7 +724,7 @@ bool TextDocument::reload(QString *errorString) bool TextDocument::reload(QString *errorString, const QString &realFileName) { emit aboutToReload(); - TextDocumentLayout *documentLayout = + auto documentLayout = qobject_cast(d->m_document.documentLayout()); TextMarks marks; if (documentLayout) @@ -801,7 +801,7 @@ void TextDocument::cleanWhitespace(const QTextCursor &cursor) void TextDocument::cleanWhitespace(QTextCursor &cursor, bool cleanIndentation, bool inEntireDocument) { - TextDocumentLayout *documentLayout = qobject_cast(d->m_document.documentLayout()); + auto documentLayout = qobject_cast(d->m_document.documentLayout()); Q_ASSERT(cursor.visualNavigation() == false); QTextBlock block = d->m_document.findBlock(cursor.selectionStart()); @@ -973,7 +973,7 @@ void TextDocument::removeMarkFromMarksCache(TextMark *mark) void TextDocument::removeMark(TextMark *mark) { QTextBlock block = d->m_document.findBlockByNumber(mark->lineNumber() - 1); - if (TextBlockUserData *data = static_cast(block.userData())) { + if (auto data = static_cast(block.userData())) { if (!data->removeMark(mark)) qDebug() << "Could not find mark" << mark << "on line" << mark->lineNumber(); } diff --git a/src/plugins/texteditor/textdocumentlayout.cpp b/src/plugins/texteditor/textdocumentlayout.cpp index 38b0d542caf..805a71f9668 100644 --- a/src/plugins/texteditor/textdocumentlayout.cpp +++ b/src/plugins/texteditor/textdocumentlayout.cpp @@ -521,9 +521,7 @@ void TextDocumentLayout::setFolded(const QTextBlock &block, bool folded) else return; - TextDocumentLayout *layout = qobject_cast( - block.document()->documentLayout()); - if (layout) + if (auto layout = qobject_cast(block.document()->documentLayout())) emit layout->foldChanged(block.blockNumber(), folded); } @@ -577,7 +575,7 @@ TextMarks TextDocumentLayout::documentClosing() { TextMarks marks; for (QTextBlock block = document()->begin(); block.isValid(); block = block.next()) { - if (TextBlockUserData *data = static_cast(block.userData())) + if (auto data = static_cast(block.userData())) marks.append(data->documentClosing()); } return marks; diff --git a/src/plugins/texteditor/textdocumentlayout.h b/src/plugins/texteditor/textdocumentlayout.h index 640f8f34a67..06ff57b9023 100644 --- a/src/plugins/texteditor/textdocumentlayout.h +++ b/src/plugins/texteditor/textdocumentlayout.h @@ -194,7 +194,7 @@ public: return static_cast(block.userData()); } static TextBlockUserData *userData(const QTextBlock &block) { - TextBlockUserData *data = static_cast(block.userData()); + auto data = static_cast(block.userData()); if (!data && block.isValid()) const_cast(block).setUserData((data = new TextBlockUserData)); return data; diff --git a/src/plugins/texteditor/texteditor_test.cpp b/src/plugins/texteditor/texteditor_test.cpp index 78b8564e439..d5ef1a6eeac 100644 --- a/src/plugins/texteditor/texteditor_test.cpp +++ b/src/plugins/texteditor/texteditor_test.cpp @@ -126,9 +126,9 @@ void Internal::TextEditorPlugin::testBlockSelectionTransformation() // open editor Core::IEditor *editor = Core::EditorManager::openEditorWithContents( - Core::Constants::K_DEFAULT_TEXT_EDITOR_ID, 0, input.toLatin1()); + Core::Constants::K_DEFAULT_TEXT_EDITOR_ID, nullptr, input.toLatin1()); QVERIFY(editor); - if (BaseTextEditor *textEditor = qobject_cast(editor)) { + if (auto textEditor = qobject_cast(editor)) { TextEditorWidget *editorWidget = textEditor->editorWidget(); editorWidget->setBlockSelection(selection.positionBlock, selection.positionColumn, @@ -349,9 +349,9 @@ void Internal::TextEditorPlugin::testBlockSelectionInsert() // open editor Core::IEditor *editor = Core::EditorManager::openEditorWithContents( - Core::Constants::K_DEFAULT_TEXT_EDITOR_ID, 0, text); + Core::Constants::K_DEFAULT_TEXT_EDITOR_ID, nullptr, text); QVERIFY(editor); - if (BaseTextEditor *textEditor = qobject_cast(editor)) { + if (auto textEditor = qobject_cast(editor)) { TextEditorWidget *editorWidget = textEditor->editorWidget(); editorWidget->setBlockSelection(selection.positionBlock, selection.positionColumn, @@ -427,9 +427,9 @@ void Internal::TextEditorPlugin::testBlockSelectionRemove() // open editor Core::IEditor *editor = Core::EditorManager::openEditorWithContents( - Core::Constants::K_DEFAULT_TEXT_EDITOR_ID, 0, text); + Core::Constants::K_DEFAULT_TEXT_EDITOR_ID, nullptr, text); QVERIFY(editor); - if (BaseTextEditor *textEditor = qobject_cast(editor)) { + if (auto textEditor = qobject_cast(editor)) { TextEditorWidget *editorWidget = textEditor->editorWidget(); editorWidget->setBlockSelection(selection.positionBlock, selection.positionColumn, @@ -482,9 +482,9 @@ void Internal::TextEditorPlugin::testBlockSelectionCopy() // open editor Core::IEditor *editor = Core::EditorManager::openEditorWithContents( - Core::Constants::K_DEFAULT_TEXT_EDITOR_ID, 0, text); + Core::Constants::K_DEFAULT_TEXT_EDITOR_ID, nullptr, text); QVERIFY(editor); - if (BaseTextEditor *textEditor = qobject_cast(editor)) { + if (auto textEditor = qobject_cast(editor)) { TextEditorWidget *editorWidget = textEditor->editorWidget(); editorWidget->setBlockSelection(selection.positionBlock, selection.positionColumn, diff --git a/src/plugins/texteditor/texteditoractionhandler.cpp b/src/plugins/texteditor/texteditoractionhandler.cpp index 6c39209ffec..e8599f3836f 100644 --- a/src/plugins/texteditor/texteditoractionhandler.cpp +++ b/src/plugins/texteditor/texteditoractionhandler.cpp @@ -63,7 +63,7 @@ public: Core::ActionContainer *container, std::function slot) { - QAction *result = new QAction(title, this); + auto result = new QAction(title, this); Core::Command *command = Core::ActionManager::registerAction(result, id, Core::Context(m_contextId), scriptable); if (!keySequence.isEmpty()) command->setDefaultKeySequence(keySequence); @@ -81,7 +81,7 @@ public: const QString &title = QString(), const QKeySequence &keySequence = QKeySequence(), Core::Id menueGroup = Core::Id(), - Core::ActionContainer *container = 0) + Core::ActionContainer *container = nullptr) { return registerActionHelper(id, scriptable, title, keySequence, menueGroup, container, [this, slot](bool) { if (m_currentEditorWidget) slot(m_currentEditorWidget); }); @@ -93,7 +93,7 @@ public: const QString &title = QString(), const QKeySequence &keySequence = QKeySequence(), Core::Id menueGroup = Core::Id(), - Core::ActionContainer *container = 0) + Core::ActionContainer *container = nullptr) { return registerActionHelper(id, scriptable, title, keySequence, menueGroup, container, [this, slot](bool on) { if (m_currentEditorWidget) slot(m_currentEditorWidget, on); }); @@ -105,7 +105,7 @@ public: const QString &title = QString(), const QKeySequence &keySequence = QKeySequence(), Core::Id menueGroup = Core::Id(), - Core::ActionContainer *container = 0) + Core::ActionContainer *container = nullptr) { return registerActionHelper(id, scriptable, title, keySequence, menueGroup, container, [this, slot](bool on) { if (m_currentEditorWidget) slot(m_currentEditorWidget, on); }); @@ -562,7 +562,7 @@ void TextEditorActionHandlerPrivate::updateCurrentEditor(Core::IEditor *editor) { if (m_currentEditorWidget) m_currentEditorWidget->disconnect(this); - m_currentEditorWidget = 0; + m_currentEditorWidget = nullptr; if (editor && editor->document()->id() == m_editorId) { TextEditorWidget *editorWidget = m_findTextWidget(editor); diff --git a/src/plugins/texteditor/texteditorsettings.cpp b/src/plugins/texteditor/texteditorsettings.cpp index 8124f4ab43c..0c02eb3cd12 100644 --- a/src/plugins/texteditor/texteditorsettings.cpp +++ b/src/plugins/texteditor/texteditorsettings.cpp @@ -78,8 +78,8 @@ public: } // namespace TextEditor -static TextEditorSettingsPrivate *d = 0; -static TextEditorSettings *m_instance = 0; +static TextEditorSettingsPrivate *d = nullptr; +static TextEditorSettings *m_instance = nullptr; TextEditorSettings::TextEditorSettings() { @@ -386,7 +386,7 @@ TextEditorSettings::~TextEditorSettings() { delete d; - m_instance = 0; + m_instance = nullptr; } TextEditorSettings *TextEditorSettings::instance() @@ -521,7 +521,7 @@ Core::Id TextEditorSettings::languageId(const QString &mimeType) int TextEditorSettings::increaseFontZoom(int step) { - FontSettings &fs = const_cast(d->m_fontSettingsPage->fontSettings()); + auto &fs = const_cast(d->m_fontSettingsPage->fontSettings()); const int previousZoom = fs.fontZoom(); const int newZoom = qMax(10, previousZoom + step); if (newZoom != previousZoom) { @@ -533,7 +533,7 @@ int TextEditorSettings::increaseFontZoom(int step) void TextEditorSettings::resetFontZoom() { - FontSettings &fs = const_cast(d->m_fontSettingsPage->fontSettings()); + auto &fs = const_cast(d->m_fontSettingsPage->fontSettings()); fs.setFontZoom(100); d->m_fontSettingsPage->saveSettings(); } diff --git a/src/plugins/texteditor/textmark.cpp b/src/plugins/texteditor/textmark.cpp index 142cbdc2dcc..425b5773e48 100644 --- a/src/plugins/texteditor/textmark.cpp +++ b/src/plugins/texteditor/textmark.cpp @@ -267,7 +267,7 @@ void TextMark::dragToLine(int lineNumber) void TextMark::addToToolTipLayout(QGridLayout *target) const { - auto *contentLayout = new QVBoxLayout; + auto contentLayout = new QVBoxLayout; addToolTipContent(contentLayout); if (contentLayout->count() > 0) { const int row = target->rowCount(); @@ -346,7 +346,7 @@ TextMarkRegistry *TextMarkRegistry::instance() void TextMarkRegistry::editorOpened(IEditor *editor) { - auto document = qobject_cast(editor ? editor->document() : 0); + auto document = qobject_cast(editor ? editor->document() : nullptr); if (!document) return; if (!m_marks.contains(document->filePath())) @@ -359,7 +359,7 @@ void TextMarkRegistry::editorOpened(IEditor *editor) void TextMarkRegistry::documentRenamed(IDocument *document, const QString &oldName, const QString &newName) { - TextDocument *baseTextDocument = qobject_cast(document); + auto baseTextDocument = qobject_cast(document); if (!baseTextDocument) return; FileName oldFileName = FileName::fromString(oldName); diff --git a/src/plugins/vcsbase/baseannotationhighlighter.cpp b/src/plugins/vcsbase/baseannotationhighlighter.cpp index 6b3154ab274..32a03770407 100644 --- a/src/plugins/vcsbase/baseannotationhighlighter.cpp +++ b/src/plugins/vcsbase/baseannotationhighlighter.cpp @@ -64,7 +64,7 @@ public: void BaseAnnotationHighlighterPrivate::updateOtherFormats() { - m_background = TextEditor::TextEditorSettings::fontSettings() + m_background = q->fontSettings() .toTextCharFormat(TextEditor::C_TEXT) .brushProperty(QTextFormat::BackgroundBrush) .color(); diff --git a/src/plugins/vcsbase/cleandialog.cpp b/src/plugins/vcsbase/cleandialog.cpp index 7f424f0e6ce..95495d8ba3d 100644 --- a/src/plugins/vcsbase/cleandialog.cpp +++ b/src/plugins/vcsbase/cleandialog.cpp @@ -213,7 +213,8 @@ void CleanDialog::addFile(const QString &workingDirectory, QString fileName, boo // Tooltip with size information if (fi.isFile()) { const QString lastModified = fi.lastModified().toString(Qt::DefaultLocaleShortDate); - nameItem->setToolTip(tr("%n bytes, last modified %1.", 0, fi.size()).arg(lastModified)); + nameItem->setToolTip(tr("%n bytes, last modified %1.", nullptr, + fi.size()).arg(lastModified)); } d->m_filesModel->appendRow(nameItem); } @@ -245,7 +246,7 @@ bool CleanDialog::promptToDelete() return true; if (QMessageBox::question(this, tr("Delete"), - tr("Do you want to delete %n files?", 0, selectedFiles.size()), + tr("Do you want to delete %n files?", nullptr, selectedFiles.size()), QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes) != QMessageBox::Yes) return false; diff --git a/src/plugins/vcsbase/commonsettingspage.h b/src/plugins/vcsbase/commonsettingspage.h index e0f897f5fbf..5504856dc44 100644 --- a/src/plugins/vcsbase/commonsettingspage.h +++ b/src/plugins/vcsbase/commonsettingspage.h @@ -42,7 +42,7 @@ class CommonSettingsWidget : public QWidget Q_OBJECT public: - explicit CommonSettingsWidget(QWidget *parent = 0); + explicit CommonSettingsWidget(QWidget *parent = nullptr); ~CommonSettingsWidget() override; CommonVcsSettings settings() const; @@ -59,7 +59,7 @@ class CommonOptionsPage : public VcsBaseOptionsPage Q_OBJECT public: - explicit CommonOptionsPage(QObject *parent = 0); + explicit CommonOptionsPage(QObject *parent = nullptr); QWidget *widget() override; void apply() override; diff --git a/src/plugins/vcsbase/diffandloghighlighter.cpp b/src/plugins/vcsbase/diffandloghighlighter.cpp index 3a2e89a1024..eeb7ad915b2 100644 --- a/src/plugins/vcsbase/diffandloghighlighter.cpp +++ b/src/plugins/vcsbase/diffandloghighlighter.cpp @@ -142,7 +142,7 @@ void DiffAndLogHighlighterPrivate::updateOtherFormats() // --- DiffAndLogHighlighter DiffAndLogHighlighter::DiffAndLogHighlighter(const QRegExp &filePattern, const QRegExp &changePattern) : - TextEditor::SyntaxHighlighter(static_cast(0)), + TextEditor::SyntaxHighlighter(static_cast(nullptr)), d(new DiffAndLogHighlighterPrivate(this, filePattern, changePattern)) { setDefaultTextFormatCategories(); diff --git a/src/plugins/vcsbase/nicknamedialog.h b/src/plugins/vcsbase/nicknamedialog.h index 84d31145e04..8351094a660 100644 --- a/src/plugins/vcsbase/nicknamedialog.h +++ b/src/plugins/vcsbase/nicknamedialog.h @@ -44,7 +44,7 @@ class NickNameDialog : public QDialog Q_OBJECT public: - explicit NickNameDialog(QStandardItemModel *model, QWidget *parent = 0); + explicit NickNameDialog(QStandardItemModel *model, QWidget *parent = nullptr); ~NickNameDialog() override; QString nickName() const; diff --git a/src/plugins/vcsbase/submiteditorfile.h b/src/plugins/vcsbase/submiteditorfile.h index e2da2f72fa8..1030eb46c1d 100644 --- a/src/plugins/vcsbase/submiteditorfile.h +++ b/src/plugins/vcsbase/submiteditorfile.h @@ -38,7 +38,7 @@ class SubmitEditorFile : public Core::IDocument { public: explicit SubmitEditorFile(const VcsBaseSubmitEditorParameters *parameters, - VcsBaseSubmitEditor *parent = 0); + VcsBaseSubmitEditor *parent = nullptr); OpenResult open(QString *errorString, const QString &fileName, const QString &realFileName) override; diff --git a/src/plugins/vcsbase/submiteditorwidget.cpp b/src/plugins/vcsbase/submiteditorwidget.cpp index 0f453a2747a..dbb1324ed8f 100644 --- a/src/plugins/vcsbase/submiteditorwidget.cpp +++ b/src/plugins/vcsbase/submiteditorwidget.cpp @@ -114,7 +114,7 @@ public: public slots: void setText(const QString &t) { - if (QAction *action = qobject_cast(parent())) + if (auto action = qobject_cast(parent())) action->setText(t); } }; @@ -128,42 +128,25 @@ struct SubmitEditorWidgetPrivate // A pair of position/action to extend context menus typedef QPair > AdditionalContextMenuAction; - SubmitEditorWidgetPrivate(); - Ui::SubmitEditorWidget m_ui; - bool m_filesSelected; - int m_activatedRow; - bool m_emptyFileListEnabled; QList descriptionEditContextMenuActions; - QVBoxLayout *m_fieldLayout; + QVBoxLayout *m_fieldLayout = nullptr; QList m_fieldWidgets; - QShortcut *m_submitShortcut; - int m_lineWidth; - - bool m_commitEnabled; - bool m_ignoreChange; - bool m_descriptionMandatory; - bool m_updateInProgress; + QShortcut *m_submitShortcut = nullptr; + QActionPushButton *m_submitButton = nullptr; QString m_description; - QActionPushButton *m_submitButton; -}; + int m_lineWidth = defaultLineWidth; + int m_activatedRow = -1; -SubmitEditorWidgetPrivate::SubmitEditorWidgetPrivate() : - m_filesSelected(false), - m_activatedRow(-1), - m_emptyFileListEnabled(false), - m_fieldLayout(0), - m_submitShortcut(0), - m_lineWidth(defaultLineWidth), - m_commitEnabled(false), - m_ignoreChange(false), - m_descriptionMandatory(true), - m_updateInProgress(false), - m_submitButton(0) -{ -} + bool m_filesSelected = false; + bool m_emptyFileListEnabled = false; + bool m_commitEnabled = false; + bool m_ignoreChange = false; + bool m_descriptionMandatory = true; + bool m_updateInProgress = false; +}; SubmitEditorWidget::SubmitEditorWidget() : d(new SubmitEditorWidgetPrivate) @@ -224,8 +207,7 @@ void SubmitEditorWidget::registerActions(QAction *editorUndoAction, QAction *edi connect(this, &SubmitEditorWidget::submitActionEnabledChanged, submitAction, &QAction::setEnabled); // Wire setText via QActionSetTextSlotHelper. - QActionSetTextSlotHelper *actionSlotHelper - = submitAction->findChild(); + auto actionSlotHelper = submitAction->findChild(); if (!actionSlotHelper) actionSlotHelper = new QActionSetTextSlotHelper(submitAction); connect(this, &SubmitEditorWidget::submitActionTextChanged, @@ -463,7 +445,7 @@ void SubmitEditorWidget::updateSubmitAction() // Update button text. const int fileCount = d->m_ui.fileView->model()->rowCount(); const QString msg = checkedCount ? - tr("%1 %2/%n File(s)", 0, fileCount) + tr("%1 %2/%n File(s)", nullptr, fileCount) .arg(commitName()).arg(checkedCount) : commitName(); emit submitActionTextChanged(msg); diff --git a/src/plugins/vcsbase/submitfieldwidget.cpp b/src/plugins/vcsbase/submitfieldwidget.cpp index 77980484c94..000ba51426f 100644 --- a/src/plugins/vcsbase/submitfieldwidget.cpp +++ b/src/plugins/vcsbase/submitfieldwidget.cpp @@ -65,30 +65,18 @@ namespace VcsBase { // Field/Row entry struct FieldEntry { - FieldEntry(); void createGui(const QIcon &removeIcon); void deleteGuiLater(); - QComboBox *combo; - QHBoxLayout *layout; - QLineEdit *lineEdit; - QToolBar *toolBar; - QToolButton *clearButton; - QToolButton *browseButton; - int comboIndex; + QComboBox *combo = nullptr; + QHBoxLayout *layout = nullptr; + QLineEdit *lineEdit = nullptr; + QToolBar *toolBar = nullptr; + QToolButton *clearButton = nullptr; + QToolButton *browseButton = nullptr; + int comboIndex = 0; }; -FieldEntry::FieldEntry() : - combo(0), - layout(0), - lineEdit(0), - toolBar(0), - clearButton(0), - browseButton(0), - comboIndex(0) -{ -} - void FieldEntry::createGui(const QIcon &removeIcon) { layout = new QHBoxLayout; @@ -131,20 +119,17 @@ struct SubmitFieldWidgetPrivate { const QIcon removeFieldIcon; QStringList fields; - QCompleter *completer; - bool hasBrowseButton; - bool allowDuplicateFields; + QCompleter *completer = nullptr; QList fieldEntries; - QVBoxLayout *layout; + QVBoxLayout *layout = nullptr; + + bool hasBrowseButton = false; + bool allowDuplicateFields = false; }; SubmitFieldWidgetPrivate::SubmitFieldWidgetPrivate() : - removeFieldIcon(Utils::Icons::BROKEN.icon()), - completer(0), - hasBrowseButton(false), - allowDuplicateFields(false), - layout(0) + removeFieldIcon(Utils::Icons::BROKEN.icon()) { } diff --git a/src/plugins/vcsbase/submitfieldwidget.h b/src/plugins/vcsbase/submitfieldwidget.h index 17c16f30fd3..88b4f11ac8b 100644 --- a/src/plugins/vcsbase/submitfieldwidget.h +++ b/src/plugins/vcsbase/submitfieldwidget.h @@ -45,7 +45,7 @@ class VCSBASE_EXPORT SubmitFieldWidget : public QWidget Q_PROPERTY(bool allowDuplicateFields READ allowDuplicateFields WRITE setAllowDuplicateFields DESIGNABLE true) public: - explicit SubmitFieldWidget(QWidget *parent = 0); + explicit SubmitFieldWidget(QWidget *parent = nullptr); ~SubmitFieldWidget() override; QStringList fields() const; diff --git a/src/plugins/vcsbase/vcsbaseclient.cpp b/src/plugins/vcsbase/vcsbaseclient.cpp index af80c664f5b..43f4256c936 100644 --- a/src/plugins/vcsbase/vcsbaseclient.cpp +++ b/src/plugins/vcsbase/vcsbaseclient.cpp @@ -68,7 +68,7 @@ static Core::IEditor *locateEditor(const char *property, const QString &entry) foreach (Core::IDocument *document, Core::DocumentModel::openedDocuments()) if (document->property(property).toString() == entry) return Core::DocumentModel::editorsForDocument(document).first(); - return 0; + return nullptr; } namespace VcsBase { @@ -247,20 +247,20 @@ VcsBaseEditorWidget *VcsBaseClientImpl::createVcsEditor(Core::Id kind, QString t const char *registerDynamicProperty, const QString &dynamicPropertyValue) const { - VcsBaseEditorWidget *baseEditor = 0; + VcsBaseEditorWidget *baseEditor = nullptr; Core::IEditor *outputEditor = locateEditor(registerDynamicProperty, dynamicPropertyValue); const QString progressMsg = tr("Working..."); if (outputEditor) { // Exists already outputEditor->document()->setContents(progressMsg.toUtf8()); baseEditor = VcsBaseEditor::getVcsBaseEditor(outputEditor); - QTC_ASSERT(baseEditor, return 0); + QTC_ASSERT(baseEditor, return nullptr); Core::EditorManager::activateEditor(outputEditor); } else { outputEditor = Core::EditorManager::openEditorWithContents(kind, &title, progressMsg.toUtf8()); outputEditor->document()->setProperty(registerDynamicProperty, dynamicPropertyValue); baseEditor = VcsBaseEditor::getVcsBaseEditor(outputEditor); - QTC_ASSERT(baseEditor, return 0); + QTC_ASSERT(baseEditor, return nullptr); connect(baseEditor, &VcsBaseEditorWidget::annotateRevisionRequested, this, &VcsBaseClientImpl::annotateRevisionRequested); baseEditor->setSource(source); @@ -455,7 +455,8 @@ void VcsBaseClient::diff(const QString &workingDir, const QStringList &files, else args << extraOptions; args << files; - QTextCodec *codec = source.isEmpty() ? static_cast(0) : VcsBaseEditor::getCodec(source); + QTextCodec *codec = source.isEmpty() ? static_cast(nullptr) + : VcsBaseEditor::getCodec(source); VcsCommand *command = createCommand(workingDir, editor); command->setCodec(codec); enqueueJob(command, args, workingDir, exitCodeInterpreter(DiffCommand)); @@ -528,7 +529,7 @@ void VcsBaseClient::status(const QString &workingDir, const QString &file, QStringList args(vcsCommandString(StatusCommand)); args << extraOptions << file; VcsOutputWindow::setRepository(workingDir); - VcsCommand *cmd = createCommand(workingDir, 0, VcsWindowOutputBind); + VcsCommand *cmd = createCommand(workingDir, nullptr, VcsWindowOutputBind); connect(cmd, &VcsCommand::finished, VcsOutputWindow::instance(), &VcsOutputWindow::clearRepository, Qt::QueuedConnection); @@ -632,7 +633,7 @@ void VcsBaseClient::commit(const QString &repositoryRoot, // for example) QStringList args(vcsCommandString(CommitCommand)); args << extraOptions << files; - VcsCommand *cmd = createCommand(repositoryRoot, 0, VcsWindowOutputBind); + VcsCommand *cmd = createCommand(repositoryRoot, nullptr, VcsWindowOutputBind); if (!commitMessageFile.isEmpty()) connect(cmd, &VcsCommand::finished, [commitMessageFile]() { QFile(commitMessageFile).remove(); }); enqueueJob(cmd, args); diff --git a/src/plugins/vcsbase/vcsbaseclientsettings.cpp b/src/plugins/vcsbase/vcsbaseclientsettings.cpp index 5fdd9f9b045..7d301819596 100644 --- a/src/plugins/vcsbase/vcsbaseclientsettings.cpp +++ b/src/plugins/vcsbase/vcsbaseclientsettings.cpp @@ -48,10 +48,7 @@ public: bool boolValue; }; - SettingValue() : - m_type(QVariant::Invalid) - { - } + SettingValue() = default; explicit SettingValue(const QVariant &v) : m_type(v.type()) @@ -100,7 +97,7 @@ public: QString stringValue(const QString &defaultString = QString()) const { - if (type() == QVariant::String && m_comp.strPtr != 0) + if (type() == QVariant::String && m_comp.strPtr != nullptr) return *(m_comp.strPtr); return defaultString; } @@ -121,9 +118,9 @@ public: private: void deleteInternalString() { - if (m_type == QVariant::String && m_comp.strPtr != 0) { + if (m_type == QVariant::String && m_comp.strPtr != nullptr) { delete m_comp.strPtr; - m_comp.strPtr = 0; + m_comp.strPtr = nullptr; } } @@ -131,11 +128,11 @@ private: { if (type() == QVariant::String) { const QString *otherString = other.m_comp.strPtr; - m_comp.strPtr = new QString(otherString != 0 ? *otherString : QString()); + m_comp.strPtr = new QString(otherString != nullptr ? *otherString : QString()); } } - QVariant::Type m_type; + QVariant::Type m_type = QVariant::Invalid; }; bool operator==(const SettingValue &lhs, const SettingValue &rhs) @@ -285,21 +282,21 @@ int *VcsBaseClientSettings::intPointer(const QString &key) { if (hasKey(key)) return &(d->m_valueHash[key].m_comp.intValue); - return 0; + return nullptr; } bool *VcsBaseClientSettings::boolPointer(const QString &key) { if (hasKey(key)) return &(d->m_valueHash[key].m_comp.boolValue); - return 0; + return nullptr; } QString *VcsBaseClientSettings::stringPointer(const QString &key) { if (hasKey(key) && valueType(key) == QVariant::String) return d->m_valueHash[key].m_comp.strPtr; - return 0; + return nullptr; } int VcsBaseClientSettings::intValue(const QString &key, int defaultValue) const diff --git a/src/plugins/vcsbase/vcsbaseeditor.cpp b/src/plugins/vcsbase/vcsbaseeditor.cpp index c4382728a72..0c46e20cbdc 100644 --- a/src/plugins/vcsbase/vcsbaseeditor.cpp +++ b/src/plugins/vcsbase/vcsbaseeditor.cpp @@ -171,7 +171,7 @@ namespace Internal { class AbstractTextCursorHandler : public QObject { public: - AbstractTextCursorHandler(VcsBaseEditorWidget *editorWidget = 0); + AbstractTextCursorHandler(VcsBaseEditorWidget *editorWidget = nullptr); /*! Tries to find some matching contents under \a cursor. * @@ -240,13 +240,13 @@ class ChangeTextCursorHandler : public AbstractTextCursorHandler Q_OBJECT public: - ChangeTextCursorHandler(VcsBaseEditorWidget *editorWidget = 0); + ChangeTextCursorHandler(VcsBaseEditorWidget *editorWidget = nullptr); - bool findContentsUnderCursor(const QTextCursor &cursor); - void highlightCurrentContents(); - void handleCurrentContents(); - QString currentContents() const; - void fillContextMenu(QMenu *menu, EditorContentType type) const; + bool findContentsUnderCursor(const QTextCursor &cursor) override; + void highlightCurrentContents() override; + void handleCurrentContents() override; + QString currentContents() const override; + void fillContextMenu(QMenu *menu, EditorContentType type) const override; private slots: void slotDescribe(); @@ -336,7 +336,7 @@ void ChangeTextCursorHandler::slotCopyRevision() QAction *ChangeTextCursorHandler::createDescribeAction(const QString &change) const { - auto a = new QAction(VcsBaseEditorWidget::tr("&Describe Change %1").arg(change), 0); + auto a = new QAction(VcsBaseEditorWidget::tr("&Describe Change %1").arg(change), nullptr); connect(a, &QAction::triggered, this, &ChangeTextCursorHandler::slotDescribe); return a; } @@ -348,7 +348,7 @@ QAction *ChangeTextCursorHandler::createAnnotateAction(const QString &change, bo previous && !editorWidget()->annotatePreviousRevisionTextFormat().isEmpty() ? editorWidget()->annotatePreviousRevisionTextFormat() : editorWidget()->annotateRevisionTextFormat(); - auto a = new QAction(format.arg(change), 0); + auto a = new QAction(format.arg(change), nullptr); a->setData(change); connect(a, &QAction::triggered, editorWidget(), &VcsBaseEditorWidget::slotAnnotateRevision); return a; @@ -356,7 +356,7 @@ QAction *ChangeTextCursorHandler::createAnnotateAction(const QString &change, bo QAction *ChangeTextCursorHandler::createCopyRevisionAction(const QString &change) const { - auto a = new QAction(editorWidget()->copyRevisionTextFormat().arg(change), 0); + auto a = new QAction(editorWidget()->copyRevisionTextFormat().arg(change), nullptr); a->setData(change); connect(a, &QAction::triggered, this, &ChangeTextCursorHandler::slotCopyRevision); return a; @@ -374,13 +374,13 @@ class UrlTextCursorHandler : public AbstractTextCursorHandler Q_OBJECT public: - UrlTextCursorHandler(VcsBaseEditorWidget *editorWidget = 0); + UrlTextCursorHandler(VcsBaseEditorWidget *editorWidget = nullptr); - bool findContentsUnderCursor(const QTextCursor &cursor); - void highlightCurrentContents(); - void handleCurrentContents(); - void fillContextMenu(QMenu *menu, EditorContentType type) const; - QString currentContents() const; + bool findContentsUnderCursor(const QTextCursor &cursor) override; + void highlightCurrentContents() override; + void handleCurrentContents() override; + void fillContextMenu(QMenu *menu, EditorContentType type) const override; + QString currentContents() const override; protected slots: virtual void slotCopyUrl(); @@ -488,7 +488,7 @@ void UrlTextCursorHandler::slotOpenUrl() QAction *UrlTextCursorHandler::createOpenUrlAction(const QString &text) const { - auto a = new QAction(text, 0); + auto a = new QAction(text); a->setData(m_urlData.url); connect(a, &QAction::triggered, this, &UrlTextCursorHandler::slotOpenUrl); return a; @@ -496,7 +496,7 @@ QAction *UrlTextCursorHandler::createOpenUrlAction(const QString &text) const QAction *UrlTextCursorHandler::createCopyUrlAction(const QString &text) const { - auto a = new QAction(text, 0); + auto a = new QAction(text); a->setData(m_urlData.url); connect(a, &QAction::triggered, this, &UrlTextCursorHandler::slotCopyUrl); return a; @@ -511,11 +511,11 @@ class EmailTextCursorHandler : public UrlTextCursorHandler Q_OBJECT public: - EmailTextCursorHandler(VcsBaseEditorWidget *editorWidget = 0); - void fillContextMenu(QMenu *menu, EditorContentType type) const; + EmailTextCursorHandler(VcsBaseEditorWidget *editorWidget = nullptr); + void fillContextMenu(QMenu *menu, EditorContentType type) const override; protected slots: - void slotOpenUrl(); + void slotOpenUrl() override; }; EmailTextCursorHandler::EmailTextCursorHandler(VcsBaseEditorWidget *editorWidget) @@ -588,7 +588,7 @@ AbstractTextCursorHandler *VcsBaseEditorWidgetPrivate::findTextCursorHandler(con if (handler->findContentsUnderCursor(cursor)) return handler; } - return 0; + return nullptr; } QComboBox *VcsBaseEditorWidgetPrivate::entriesComboBox() @@ -643,7 +643,7 @@ VcsBaseEditorWidget::VcsBaseEditorWidget() void VcsBaseEditorWidget::setParameters(const VcsBaseEditorParameters *parameters) { - QTC_CHECK(d->m_parameters == 0); + QTC_CHECK(d->m_parameters == nullptr); d->m_parameters = parameters; } @@ -756,7 +756,7 @@ void VcsBaseEditorWidget::init() VcsBaseEditorWidget::~VcsBaseEditorWidget() { - setCommand(0); // abort all running commands + setCommand(nullptr); // abort all running commands delete d; } @@ -1012,7 +1012,7 @@ void VcsBaseEditorWidget::mouseMoveEvent(QMouseEvent *e) // Link emulation behaviour for 'click on change-interaction' const QTextCursor cursor = cursorForPosition(e->pos()); Internal::AbstractTextCursorHandler *handler = d->findTextCursorHandler(cursor); - if (handler != 0) { + if (handler != nullptr) { handler->highlightCurrentContents(); overrideCursor = true; cursorShape = Qt::PointingHandCursor; @@ -1036,7 +1036,7 @@ void VcsBaseEditorWidget::mouseReleaseEvent(QMouseEvent *e) if (e->button() == Qt::LeftButton &&!(e->modifiers() & Qt::ShiftModifier)) { const QTextCursor cursor = cursorForPosition(e->pos()); Internal::AbstractTextCursorHandler *handler = d->findTextCursorHandler(cursor); - if (handler != 0) { + if (handler != nullptr) { handler->handleCurrentContents(); e->accept(); return; @@ -1078,7 +1078,7 @@ void VcsBaseEditorWidget::slotActivateAnnotation() disconnect(this, &QPlainTextEdit::textChanged, this, &VcsBaseEditorWidget::slotActivateAnnotation); - if (BaseAnnotationHighlighter *ah = qobject_cast(textDocument()->syntaxHighlighter())) { + if (auto ah = qobject_cast(textDocument()->syntaxHighlighter())) { ah->setChangeNumbers(changes); ah->rehighlight(); } else { @@ -1162,7 +1162,7 @@ void VcsBaseEditorWidget::jumpToChangeFromDiff(QTextCursor cursor) return; Core::IEditor *ed = Core::EditorManager::openEditor(fileName); - if (BaseTextEditor *editor = qobject_cast(ed)) + if (auto editor = qobject_cast(ed)) editor->gotoLine(chunkStart + lineCount); } @@ -1230,16 +1230,16 @@ const VcsBaseEditorParameters *VcsBaseEditor::findType(const VcsBaseEditorParame for (int i = 0; i < arraySize; i++) if (array[i].type == et) return array + i; - return 0; + return nullptr; } // Find the codec used for a file querying the editor. static QTextCodec *findFileCodec(const QString &source) { Core::IDocument *document = Core::DocumentModel::documentForFilePath(source); - if (Core::BaseTextDocument *textDocument = qobject_cast(document)) + if (auto textDocument = qobject_cast(document)) return const_cast(textDocument->codec()); - return 0; + return nullptr; } // Find the codec by checking the projects (root dir of project file) @@ -1285,9 +1285,9 @@ QTextCodec *VcsBaseEditor::getCodec(const QString &workingDirectory, const QStri VcsBaseEditorWidget *VcsBaseEditor::getVcsBaseEditor(const Core::IEditor *editor) { - if (const BaseTextEditor *be = qobject_cast(editor)) + if (auto be = qobject_cast(editor)) return qobject_cast(be->editorWidget()); - return 0; + return nullptr; } // Return line number of current editor if it matches. @@ -1301,12 +1301,11 @@ int VcsBaseEditor::lineNumberOfCurrentEditor(const QString ¤tFile) if (!idocument || idocument->filePath().toString() != currentFile) return -1; } - const BaseTextEditor *eda = qobject_cast(ed); + auto eda = qobject_cast(ed); if (!eda) return -1; const int cursorLine = eda->textCursor().blockNumber() + 1; - auto const edw = qobject_cast(ed->widget()); - if (edw) { + if (auto edw = qobject_cast(ed->widget())) { const int firstLine = edw->firstVisibleBlockNumber() + 1; const int lastLine = edw->lastVisibleBlockNumber() + 1; if (firstLine <= cursorLine && cursorLine < lastLine) @@ -1319,7 +1318,7 @@ int VcsBaseEditor::lineNumberOfCurrentEditor(const QString ¤tFile) bool VcsBaseEditor::gotoLineOfEditor(Core::IEditor *e, int lineNumber) { if (lineNumber >= 0 && e) { - if (BaseTextEditor *be = qobject_cast(e)) { + if (auto be = qobject_cast(e)) { be->gotoLine(lineNumber); return true; } @@ -1462,7 +1461,7 @@ void VcsBaseEditorWidget::addDiffActions(QMenu *, const DiffChunk &) void VcsBaseEditorWidget::slotAnnotateRevision() { - if (const QAction *a = qobject_cast(sender())) { + if (auto a = qobject_cast(sender())) { const int currentLine = textCursor().blockNumber() + 1; const QString fileName = fileNameForLine(currentLine); QString workingDirectory = d->m_workingDirectory; @@ -1497,7 +1496,7 @@ void VcsBaseEditorWidget::showProgressIndicator() void VcsBaseEditorWidget::hideProgressIndicator() { delete d->m_progressIndicator; - d->m_progressIndicator = 0; + d->m_progressIndicator = nullptr; } bool VcsBaseEditorWidget::canApplyDiffChunk(const DiffChunk &dc) const @@ -1624,7 +1623,7 @@ Core::IEditor *VcsBaseEditor::locateEditorByTag(const QString &tag) if (tagPropertyValue.type() == QVariant::String && tagPropertyValue.toString() == tag) return Core::DocumentModel::editorsForDocument(document).first(); } - return 0; + return nullptr; } } // namespace VcsBase @@ -1635,7 +1634,7 @@ Core::IEditor *VcsBaseEditor::locateEditorByTag(const QString &tag) void VcsBase::VcsBaseEditorWidget::testDiffFileResolving(const char *id) { VcsBaseEditor *editor = VcsBase::VcsEditorFactory::createEditorById(id); - VcsBaseEditorWidget *widget = qobject_cast(editor->editorWidget()); + auto widget = qobject_cast(editor->editorWidget()); QFETCH(QByteArray, header); QFETCH(QByteArray, fileName); @@ -1653,7 +1652,7 @@ void VcsBase::VcsBaseEditorWidget::testLogResolving(const char *id, QByteArray & const QByteArray &entry2) { VcsBaseEditor *editor = VcsBase::VcsEditorFactory::createEditorById(id); - VcsBaseEditorWidget *widget = qobject_cast(editor->editorWidget()); + auto widget = qobject_cast(editor->editorWidget()); widget->textDocument()->setPlainText(QLatin1String(data)); QCOMPARE(widget->d->entriesComboBox()->itemText(0), QString::fromLatin1(entry1)); diff --git a/src/plugins/vcsbase/vcsbaseeditorconfig.cpp b/src/plugins/vcsbase/vcsbaseeditorconfig.cpp index 31388d7a592..6fd09901bf5 100644 --- a/src/plugins/vcsbase/vcsbaseeditorconfig.cpp +++ b/src/plugins/vcsbase/vcsbaseeditorconfig.cpp @@ -47,7 +47,7 @@ public: Int }; - SettingMappingData() : boolSetting(0), m_type(Invalid) + SettingMappingData() : boolSetting(nullptr) { } SettingMappingData(bool *setting) : boolSetting(setting), m_type(Bool) @@ -71,7 +71,7 @@ public: }; private: - Type m_type; + Type m_type = Invalid; }; class VcsBaseEditorConfigPrivate @@ -251,20 +251,24 @@ const QList &VcsBaseEditorConfig::optionMapp QStringList VcsBaseEditorConfig::argumentsForOption(const OptionMapping &mapping) const { - const QAction *action = qobject_cast(mapping.object); + auto action = qobject_cast(mapping.object); if (action && action->isChecked()) return mapping.options; - const QComboBox *cb = qobject_cast(mapping.object); - if (cb) { - const QString value = cb->itemData(cb->currentIndex()).toString(); - QStringList args; - foreach (const QString &option, mapping.options) - args << option.arg(value); + QStringList args; + auto cb = qobject_cast(mapping.object); + if (!cb) return args; - } - return QStringList(); + const QString value = cb->itemData(cb->currentIndex()).toString(); + if (value.isEmpty()) + return args; + + if (mapping.options.isEmpty()) + args += value.split(' '); + else + args += mapping.options.first().arg(value); + return args; } void VcsBaseEditorConfig::updateMappedSettings() @@ -281,14 +285,14 @@ void VcsBaseEditorConfig::updateMappedSettings() } case Internal::SettingMappingData::String : { - const QComboBox *cb = qobject_cast(optMapping.object); + auto cb = qobject_cast(optMapping.object); if (cb && cb->currentIndex() != -1) *settingData.stringSetting = cb->itemData(cb->currentIndex()).toString(); break; } case Internal::SettingMappingData::Int: { - const QComboBox *cb = qobject_cast(optMapping.object); + auto cb = qobject_cast(optMapping.object); if (cb && cb->currentIndex() != -1) *settingData.intSetting = cb->currentIndex(); break; diff --git a/src/plugins/vcsbase/vcsbaseoptionspage.cpp b/src/plugins/vcsbase/vcsbaseoptionspage.cpp index ce0b67ed424..ded4e8c7702 100644 --- a/src/plugins/vcsbase/vcsbaseoptionspage.cpp +++ b/src/plugins/vcsbase/vcsbaseoptionspage.cpp @@ -60,7 +60,6 @@ VcsClientOptionsPageWidget::VcsClientOptionsPageWidget(QWidget *parent) : QWidge VcsClientOptionsPage::VcsClientOptionsPage(Core::IVersionControl *control, VcsBaseClientImpl *client, QObject *parent) : VcsBaseOptionsPage(parent), - m_widget(0), m_client(client) { QTC_CHECK(m_client); @@ -76,10 +75,10 @@ void VcsClientOptionsPage::setWidgetFactory(VcsClientOptionsPage::WidgetFactory VcsClientOptionsPageWidget *VcsClientOptionsPage::widget() { - QTC_ASSERT(m_factory, return 0); + QTC_ASSERT(m_factory, return nullptr); if (!m_widget) m_widget = m_factory(); - QTC_ASSERT(m_widget, return 0); + QTC_ASSERT(m_widget, return nullptr); m_widget->setSettings(m_client->settings()); return m_widget; } @@ -98,7 +97,7 @@ void VcsClientOptionsPage::apply() void VcsClientOptionsPage::finish() { delete m_widget; - m_widget = 0; + m_widget = nullptr; } } // namespace VcsBase diff --git a/src/plugins/vcsbase/vcsbaseoptionspage.h b/src/plugins/vcsbase/vcsbaseoptionspage.h index 042e8773a03..5821df03833 100644 --- a/src/plugins/vcsbase/vcsbaseoptionspage.h +++ b/src/plugins/vcsbase/vcsbaseoptionspage.h @@ -80,7 +80,7 @@ protected: private: WidgetFactory m_factory; - VcsClientOptionsPageWidget *m_widget; + VcsClientOptionsPageWidget *m_widget = nullptr; VcsBaseClientImpl *const m_client; }; diff --git a/src/plugins/vcsbase/vcsbaseplugin.cpp b/src/plugins/vcsbase/vcsbaseplugin.cpp index 5015aeb3d26..102f1ea39c7 100644 --- a/src/plugins/vcsbase/vcsbaseplugin.cpp +++ b/src/plugins/vcsbase/vcsbaseplugin.cpp @@ -262,7 +262,7 @@ void StateListener::slotStateChanged() } // Get the file and its control. Do not use the file unless we find one - IVersionControl *fileControl = 0; + IVersionControl *fileControl = nullptr; if (!state.currentFile.isEmpty()) { QFileInfo currentFi(state.currentFile); @@ -296,7 +296,7 @@ void StateListener::slotStateChanged() } // Check for project, find the control - IVersionControl *projectControl = 0; + IVersionControl *projectControl = nullptr; Project *currentProject = ProjectTree::currentProject(); if (!currentProject) currentProject = SessionManager::startupProject(); @@ -513,31 +513,23 @@ VCSBASE_EXPORT QDebug operator<<(QDebug in, const VcsBasePluginState &state) class VcsBasePluginPrivate { public: - explicit VcsBasePluginPrivate(); - inline bool supportsRepositoryCreation() const; QPointer m_submitEditor; - IVersionControl *m_versionControl; + IVersionControl *m_versionControl = nullptr; Context m_context; VcsBasePluginState m_state; - int m_actionState; + int m_actionState = -1; static Internal::StateListener *m_listener; }; -VcsBasePluginPrivate::VcsBasePluginPrivate() : - m_versionControl(0), - m_actionState(-1) -{ -} - bool VcsBasePluginPrivate::supportsRepositoryCreation() const { return m_versionControl && m_versionControl->supportsOperation(IVersionControl::CreateRepositoryOperation); } -Internal::StateListener *VcsBasePluginPrivate::m_listener = 0; +Internal::StateListener *VcsBasePluginPrivate::m_listener = nullptr; VcsBasePlugin::VcsBasePlugin() : d(new VcsBasePluginPrivate()) @@ -685,7 +677,7 @@ void VcsBasePlugin::createRepository() if (directory.isEmpty()) return; const IVersionControl *managingControl = VcsManager::findVersionControlForDirectory(directory); - if (managingControl == 0) + if (managingControl == nullptr) break; const QString question = tr("The directory \"%1\" is already managed by a version control system (%2)." " Would you like to specify another directory?").arg(directory, managingControl->displayName()); diff --git a/src/plugins/vcsbase/vcsbasesubmiteditor.cpp b/src/plugins/vcsbase/vcsbasesubmiteditor.cpp index 2a3590784bf..57d742875c6 100644 --- a/src/plugins/vcsbase/vcsbasesubmiteditor.cpp +++ b/src/plugins/vcsbase/vcsbasesubmiteditor.cpp @@ -75,7 +75,7 @@ enum { wantToolBar = 0 }; // Return true if word is meaningful and can be added to a completion model static bool acceptsWordForCompletion(const char *word) { - if (word == 0) + if (!word) return false; static const std::size_t minWordLength = 7; return std::strlen(word) >= minWordLength; @@ -84,17 +84,19 @@ static bool acceptsWordForCompletion(const char *word) // Return the class name which function belongs to static const char *belongingClassName(const CPlusPlus::Function *function) { - if (function == 0) - return 0; + if (!function) + return nullptr; - const CPlusPlus::Name *funcName = function->name(); - if (funcName != 0 && funcName->asQualifiedNameId() != 0) { - const CPlusPlus::Name *funcBaseName = funcName->asQualifiedNameId()->base(); - if (funcBaseName != 0 && funcBaseName->identifier() != 0) - return funcBaseName->identifier()->chars(); + if (auto funcName = function->name()) { + if (auto qualifiedNameId = funcName->asQualifiedNameId()) { + if (const CPlusPlus::Name *funcBaseName = qualifiedNameId->base()) { + if (auto identifier = funcBaseName->identifier()) + return identifier->chars(); + } + } } - return 0; + return nullptr; } /*! @@ -151,7 +153,7 @@ public: VcsBaseSubmitEditor *q); SubmitEditorWidget *m_widget; - QToolBar *m_toolWidget; + QToolBar *m_toolWidget = nullptr; const VcsBaseSubmitEditorParameters *m_parameters; QString m_displayName; QString m_checkScriptWorkingDirectory; @@ -160,17 +162,15 @@ public: QPointer m_diffAction; QPointer m_submitAction; - NickNameDialog *m_nickNameDialog; + NickNameDialog *m_nickNameDialog = nullptr; }; VcsBaseSubmitEditorPrivate::VcsBaseSubmitEditorPrivate(const VcsBaseSubmitEditorParameters *parameters, SubmitEditorWidget *editorWidget, VcsBaseSubmitEditor *q) : m_widget(editorWidget), - m_toolWidget(0), m_parameters(parameters), - m_file(new SubmitEditorFile(parameters, q)), - m_nickNameDialog(0) + m_file(new SubmitEditorFile(parameters, q)) { auto completer = new QCompleter(q); completer->setCaseSensitivity(Qt::CaseSensitive); @@ -384,13 +384,13 @@ static QToolBar *createToolBar(const QWidget *someWidget, QAction *submitAction, QWidget *VcsBaseSubmitEditor::toolBar() { if (!wantToolBar) - return 0; + return nullptr; if (d->m_toolWidget) return d->m_toolWidget; if (!d->m_diffAction && !d->m_submitAction) - return 0; + return nullptr; // Create d->m_toolWidget = createToolBar(d->m_widget, d->m_submitAction, d->m_diffAction); @@ -429,7 +429,7 @@ void VcsBaseSubmitEditor::setFileModel(SubmitFileModel *model) const QString filePath = fileInfo.absoluteFilePath(); // Add symbols from the C++ code model const CPlusPlus::Document::Ptr doc = cppSnapShot.document(filePath); - if (!doc.isNull() && doc->control() != 0) { + if (!doc.isNull() && doc->control()) { const CPlusPlus::Control *ctrl = doc->control(); CPlusPlus::Symbol **symPtr = ctrl->firstSymbol(); // Read-only while (symPtr != ctrl->lastSymbol()) { @@ -438,7 +438,7 @@ void VcsBaseSubmitEditor::setFileModel(SubmitFileModel *model) const CPlusPlus::Identifier *symId = sym->identifier(); // Add any class, function or namespace identifiers if ((sym->isClass() || sym->isFunction() || sym->isNamespace()) - && (symId != 0 && acceptsWordForCompletion(symId->chars()))) + && (symId && acceptsWordForCompletion(symId->chars()))) { uniqueSymbols.insert(QString::fromUtf8(symId->chars())); } @@ -531,7 +531,7 @@ VcsBaseSubmitEditor::PromptSubmitResult bool forcePrompt, bool canCommitOnFailure) { - SubmitEditorWidget *submitWidget = static_cast(this->widget()); + auto submitWidget = static_cast(this->widget()); Core::EditorManager::activateEditor(this, Core::EditorManager::IgnoreNavigationHistory); diff --git a/src/plugins/vcsbase/vcsoutputwindow.cpp b/src/plugins/vcsbase/vcsoutputwindow.cpp index 5e3e4c1b7cd..fe30771f819 100644 --- a/src/plugins/vcsbase/vcsoutputwindow.cpp +++ b/src/plugins/vcsbase/vcsoutputwindow.cpp @@ -91,8 +91,8 @@ private: class OutputWindowPlainTextEdit : public Core::OutputWindow { public: - explicit OutputWindowPlainTextEdit(QWidget *parent = 0); - ~OutputWindowPlainTextEdit(); + explicit OutputWindowPlainTextEdit(QWidget *parent = nullptr); + ~OutputWindowPlainTextEdit() override; void appendLines(QString const& s, const QString &repository = QString()); void appendLinesWithStyle(QString const& s, enum VcsOutputWindow::MessageStyle style, const QString &repository = QString()); @@ -102,7 +102,7 @@ protected: private: void setFormat(enum VcsOutputWindow::MessageStyle style); - QString identifierUnderCursor(const QPoint &pos, QString *repository = 0) const; + QString identifierUnderCursor(const QPoint &pos, QString *repository = nullptr) const; const QTextCharFormat m_defaultFormat; QTextCharFormat m_errorFormat; @@ -129,7 +129,7 @@ OutputWindowPlainTextEdit::OutputWindowPlainTextEdit(QWidget *parent) : m_messageFormat.setForeground(Utils::creatorTheme()->color(Theme::OutputPanes_MessageOutput)); m_formatter = new OutputFormatter; m_formatter->setPlainTextEdit(this); - Aggregation::Aggregate *agg = new Aggregation::Aggregate; + auto agg = new Aggregation::Aggregate; agg->add(this); agg->add(new Core::BaseTextFind(this)); } @@ -184,7 +184,7 @@ void OutputWindowPlainTextEdit::contextMenuEvent(QContextMenuEvent *event) // Add 'open file' QString repository; const QString token = identifierUnderCursor(event->pos(), &repository); - QAction *openAction = 0; + QAction *openAction = nullptr; if (!token.isEmpty()) { // Check for a file, expand via repository if relative QFileInfo fi(token); @@ -287,8 +287,8 @@ public: QRegExp passwordRegExp; }; -static VcsOutputWindow *m_instance = 0; -static VcsOutputWindowPrivate *d = 0; +static VcsOutputWindow *m_instance = nullptr; +static VcsOutputWindowPrivate *d = nullptr; VcsOutputWindow::VcsOutputWindow() { @@ -314,7 +314,7 @@ static QString filterPasswordFromUrls(const QString &input) VcsOutputWindow::~VcsOutputWindow() { - m_instance = 0; + m_instance = nullptr; delete d; } diff --git a/src/plugins/vcsbase/vcsplugin.cpp b/src/plugins/vcsbase/vcsplugin.cpp index 805c3425dc5..b6153bdd0b2 100644 --- a/src/plugins/vcsbase/vcsplugin.cpp +++ b/src/plugins/vcsbase/vcsplugin.cpp @@ -106,7 +106,7 @@ bool VcsPlugin::initialize(const QStringList &arguments, QString *errorMessage) expander->registerVariable(Constants::VAR_VCS_NAME, tr("Name of the version control system in use by the current project."), []() -> QString { - IVersionControl *vc = 0; + IVersionControl *vc = nullptr; if (Project *project = ProjectTree::currentProject()) vc = VcsManager::findVersionControlForDirectory(project->projectDirectory().toString()); return vc ? vc->displayName() : QString(); @@ -115,7 +115,7 @@ bool VcsPlugin::initialize(const QStringList &arguments, QString *errorMessage) expander->registerVariable(Constants::VAR_VCS_TOPIC, tr("The current version control topic (branch or tag) identification of the current project."), []() -> QString { - IVersionControl *vc = 0; + IVersionControl *vc = nullptr; QString topLevel; if (Project *project = ProjectTree::currentProject()) vc = VcsManager::findVersionControlForDirectory(project->projectDirectory().toString(), &topLevel); diff --git a/src/plugins/vcsbase/vcsprojectcache.cpp b/src/plugins/vcsbase/vcsprojectcache.cpp index f65c676c633..84e5272cfd4 100644 --- a/src/plugins/vcsbase/vcsprojectcache.cpp +++ b/src/plugins/vcsbase/vcsprojectcache.cpp @@ -42,7 +42,6 @@ namespace { class PathMatcher { public: - PathMatcher() : m_count(std::numeric_limits::max()), m_project(0) { } ProjectExplorer::Project *project() { return m_project; } void match(ProjectExplorer::Project *project, @@ -59,8 +58,8 @@ public: } private: - int m_count; - ProjectExplorer::Project *m_project; + int m_count = std::numeric_limits::max(); + ProjectExplorer::Project *m_project = nullptr; }; } // namespace @@ -68,7 +67,7 @@ private: namespace VcsBase { namespace Internal { -VcsProjectCache *VcsProjectCache::m_instance = 0; +VcsProjectCache *VcsProjectCache::m_instance = nullptr; VcsProjectCache::VcsProjectCache() { @@ -83,7 +82,7 @@ VcsProjectCache::VcsProjectCache() VcsProjectCache::~VcsProjectCache() { - m_instance = 0; + m_instance = nullptr; } ProjectExplorer::Project *VcsProjectCache::projectFor(const QString &repo) diff --git a/src/tools/clangbackend/source/clangexceptions.cpp b/src/tools/clangbackend/source/clangexceptions.cpp index 62527b6ce77..efd89ddb5bc 100644 --- a/src/tools/clangbackend/source/clangexceptions.cpp +++ b/src/tools/clangbackend/source/clangexceptions.cpp @@ -27,7 +27,7 @@ namespace ClangBackEnd { -const char *ClangBaseException::what() const Q_DECL_NOEXCEPT +const char *ClangBaseException::what() const noexcept { return m_info.constData(); } diff --git a/src/tools/clangbackend/source/clangexceptions.h b/src/tools/clangbackend/source/clangexceptions.h index ffc1c09da14..4e9b90be941 100644 --- a/src/tools/clangbackend/source/clangexceptions.h +++ b/src/tools/clangbackend/source/clangexceptions.h @@ -36,7 +36,7 @@ namespace ClangBackEnd { class ClangBaseException : public std::exception { public: - const char *what() const Q_DECL_NOEXCEPT override; + const char *what() const noexcept override; protected: Utf8String m_info; diff --git a/tests/auto/generichighlighter/highlighterengine/syntaxhighlighter.cpp b/tests/auto/generichighlighter/highlighterengine/syntaxhighlighter.cpp index 52beb4184cc..4e4a9cfb475 100644 --- a/tests/auto/generichighlighter/highlighterengine/syntaxhighlighter.cpp +++ b/tests/auto/generichighlighter/highlighterengine/syntaxhighlighter.cpp @@ -26,6 +26,7 @@ #include "syntaxhighlighter.h" #include "formats.h" +#include #include using namespace TextEditor; @@ -51,3 +52,7 @@ QTextCharFormat SyntaxHighlighter::formatForCategory(int categoryIndex) const } } +FontSettings SyntaxHighlighter::fontSettings() const +{ + return FontSettings(); +} diff --git a/tests/auto/generichighlighter/highlighterengine/syntaxhighlighter.h b/tests/auto/generichighlighter/highlighterengine/syntaxhighlighter.h index d8c2f64d7f8..f9111d68c0c 100644 --- a/tests/auto/generichighlighter/highlighterengine/syntaxhighlighter.h +++ b/tests/auto/generichighlighter/highlighterengine/syntaxhighlighter.h @@ -36,6 +36,8 @@ namespace TextEditor { +class FontSettings; + class SyntaxHighlighter : public QSyntaxHighlighter { public: @@ -48,7 +50,7 @@ protected: void setTextFormatCategories(int, std::function) {} QTextCharFormat formatForCategory(int categoryIndex) const; - + FontSettings fontSettings() const; }; } diff --git a/tests/auto/generichighlighter/highlighterengine/textdocumentlayout.h b/tests/auto/generichighlighter/highlighterengine/textdocumentlayout.h index c53dd72edee..aa0751c4842 100644 --- a/tests/auto/generichighlighter/highlighterengine/textdocumentlayout.h +++ b/tests/auto/generichighlighter/highlighterengine/textdocumentlayout.h @@ -44,7 +44,7 @@ struct Parenthesis int pos; }; -struct CodeFormatterData {}; +struct CodeFormatterData { virtual ~CodeFormatterData() {} }; struct TextBlockUserData : QTextBlockUserData {