diff options
author | Orgad Shaneh <orgad.shaneh@audiocodes.com> | 2018-09-20 01:32:36 +0300 |
---|---|---|
committer | Orgad Shaneh <orgads@gmail.com> | 2018-09-20 07:02:17 +0000 |
commit | 8f65486dfc1edb00ddf36e6b99887b9e063e0402 (patch) | |
tree | e4e7c95c96aed6fe255d5e981add718289b7554d /src/plugins/vcsbase | |
parent | e0520794f53463d759eba228708acdede040e237 (diff) | |
download | qt-creator-8f65486dfc1edb00ddf36e6b99887b9e063e0402.tar.gz |
VCSBase: Modernize
override, auto, nullptr, member initializers.
Change-Id: Ie21b8f4a4d6673947d82619bc3de677fcea63d7f
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Diffstat (limited to 'src/plugins/vcsbase')
-rw-r--r-- | src/plugins/vcsbase/cleandialog.cpp | 5 | ||||
-rw-r--r-- | src/plugins/vcsbase/commonsettingspage.h | 4 | ||||
-rw-r--r-- | src/plugins/vcsbase/diffandloghighlighter.cpp | 2 | ||||
-rw-r--r-- | src/plugins/vcsbase/nicknamedialog.h | 2 | ||||
-rw-r--r-- | src/plugins/vcsbase/submiteditorfile.h | 2 | ||||
-rw-r--r-- | src/plugins/vcsbase/submiteditorwidget.cpp | 48 | ||||
-rw-r--r-- | src/plugins/vcsbase/submitfieldwidget.cpp | 41 | ||||
-rw-r--r-- | src/plugins/vcsbase/submitfieldwidget.h | 2 | ||||
-rw-r--r-- | src/plugins/vcsbase/vcsbaseclient.cpp | 15 | ||||
-rw-r--r-- | src/plugins/vcsbase/vcsbaseclientsettings.cpp | 21 | ||||
-rw-r--r-- | src/plugins/vcsbase/vcsbaseeditor.cpp | 83 | ||||
-rw-r--r-- | src/plugins/vcsbase/vcsbaseeditorconfig.cpp | 12 | ||||
-rw-r--r-- | src/plugins/vcsbase/vcsbaseoptionspage.cpp | 7 | ||||
-rw-r--r-- | src/plugins/vcsbase/vcsbaseoptionspage.h | 2 | ||||
-rw-r--r-- | src/plugins/vcsbase/vcsbaseplugin.cpp | 20 | ||||
-rw-r--r-- | src/plugins/vcsbase/vcsbasesubmiteditor.cpp | 38 | ||||
-rw-r--r-- | src/plugins/vcsbase/vcsoutputwindow.cpp | 16 | ||||
-rw-r--r-- | src/plugins/vcsbase/vcsplugin.cpp | 4 | ||||
-rw-r--r-- | src/plugins/vcsbase/vcsprojectcache.cpp | 9 |
19 files changed, 144 insertions, 189 deletions
diff --git a/src/plugins/vcsbase/cleandialog.cpp b/src/plugins/vcsbase/cleandialog.cpp index 7f424f0e6c..95495d8ba3 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 e0f897f5fb..5504856dc4 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 3a2e89a102..eeb7ad915b 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<QTextDocument *>(0)), + TextEditor::SyntaxHighlighter(static_cast<QTextDocument *>(nullptr)), d(new DiffAndLogHighlighterPrivate(this, filePattern, changePattern)) { setDefaultTextFormatCategories(); diff --git a/src/plugins/vcsbase/nicknamedialog.h b/src/plugins/vcsbase/nicknamedialog.h index 84d31145e0..8351094a66 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 e2da2f72fa..1030eb46c1 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 0f453a2747..dbb1324ed8 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<QAction *>(parent())) + if (auto action = qobject_cast<QAction *>(parent())) action->setText(t); } }; @@ -128,42 +128,25 @@ struct SubmitEditorWidgetPrivate // A pair of position/action to extend context menus typedef QPair<int, QPointer<QAction> > AdditionalContextMenuAction; - SubmitEditorWidgetPrivate(); - Ui::SubmitEditorWidget m_ui; - bool m_filesSelected; - int m_activatedRow; - bool m_emptyFileListEnabled; QList<AdditionalContextMenuAction> descriptionEditContextMenuActions; - QVBoxLayout *m_fieldLayout; + QVBoxLayout *m_fieldLayout = nullptr; QList<SubmitFieldWidget *> 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<QActionSetTextSlotHelper *>(); + auto actionSlotHelper = submitAction->findChild<QActionSetTextSlotHelper *>(); 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 77980484c9..000ba51426 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 <FieldEntry> 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 17c16f30fd..88b4f11ac8 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 af80c664f5..43f4256c93 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<QTextCodec *>(0) : VcsBaseEditor::getCodec(source); + QTextCodec *codec = source.isEmpty() ? static_cast<QTextCodec *>(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 5fdd9f9b04..7d30181959 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 c4382728a7..0c46e20cbd 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<BaseAnnotationHighlighter *>(textDocument()->syntaxHighlighter())) { + if (auto ah = qobject_cast<BaseAnnotationHighlighter *>(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<BaseTextEditor *>(ed)) + if (auto editor = qobject_cast<BaseTextEditor *>(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<Core::BaseTextDocument *>(document)) + if (auto textDocument = qobject_cast<Core::BaseTextDocument *>(document)) return const_cast<QTextCodec *>(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<const BaseTextEditor *>(editor)) + if (auto be = qobject_cast<const BaseTextEditor *>(editor)) return qobject_cast<VcsBaseEditorWidget *>(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<const BaseTextEditor *>(ed); + auto eda = qobject_cast<const BaseTextEditor *>(ed); if (!eda) return -1; const int cursorLine = eda->textCursor().blockNumber() + 1; - auto const edw = qobject_cast<const TextEditorWidget *>(ed->widget()); - if (edw) { + if (auto edw = qobject_cast<const TextEditorWidget *>(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<BaseTextEditor*>(e)) { + if (auto be = qobject_cast<BaseTextEditor*>(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<const QAction *>(sender())) { + if (auto a = qobject_cast<const QAction *>(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<VcsBaseEditorWidget *>(editor->editorWidget()); + auto widget = qobject_cast<VcsBaseEditorWidget *>(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<VcsBaseEditorWidget *>(editor->editorWidget()); + auto widget = qobject_cast<VcsBaseEditorWidget *>(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 29429c00ca..6fd09901bf 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,12 +251,12 @@ const QList<VcsBaseEditorConfig::OptionMapping> &VcsBaseEditorConfig::optionMapp QStringList VcsBaseEditorConfig::argumentsForOption(const OptionMapping &mapping) const { - const QAction *action = qobject_cast<const QAction *>(mapping.object); + auto action = qobject_cast<const QAction *>(mapping.object); if (action && action->isChecked()) return mapping.options; QStringList args; - const QComboBox *cb = qobject_cast<const QComboBox *>(mapping.object); + auto cb = qobject_cast<const QComboBox *>(mapping.object); if (!cb) return args; @@ -285,14 +285,14 @@ void VcsBaseEditorConfig::updateMappedSettings() } case Internal::SettingMappingData::String : { - const QComboBox *cb = qobject_cast<const QComboBox *>(optMapping.object); + auto cb = qobject_cast<const QComboBox *>(optMapping.object); if (cb && cb->currentIndex() != -1) *settingData.stringSetting = cb->itemData(cb->currentIndex()).toString(); break; } case Internal::SettingMappingData::Int: { - const QComboBox *cb = qobject_cast<const QComboBox *>(optMapping.object); + auto cb = qobject_cast<const QComboBox *>(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 ce0b67ed42..ded4e8c770 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 042e8773a0..5821df0383 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 5015aeb3d2..102f1ea39c 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<VcsBaseSubmitEditor> 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 2a3590784b..57d742875c 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<QAction> m_diffAction; QPointer<QAction> 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<SubmitEditorWidget *>(this->widget()); + auto submitWidget = static_cast<SubmitEditorWidget *>(this->widget()); Core::EditorManager::activateEditor(this, Core::EditorManager::IgnoreNavigationHistory); diff --git a/src/plugins/vcsbase/vcsoutputwindow.cpp b/src/plugins/vcsbase/vcsoutputwindow.cpp index 5e3e4c1b7c..fe30771f81 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 805c3425dc..b6153bdd0b 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 f65c676c63..84e5272cfd 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<int>::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<int>::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) |