diff options
author | Alessandro Portale <alessandro.portale@qt.io> | 2018-07-21 21:11:46 +0200 |
---|---|---|
committer | Alessandro Portale <alessandro.portale@qt.io> | 2018-08-08 16:04:21 +0000 |
commit | f36f04debabcf839a50c73e47202b24527e89ece (patch) | |
tree | ccd98e0c6ae1efb957aae97c12fb1fa4e6ca022b | |
parent | 86b8164a937afd4c8ef76bcff66eca280e3f7ddc (diff) |
Core: Modernize
modernize-use-auto
modernize-use-nullptr
modernize-use-override
modernize-use-using
modernize-use-default-member-init (partially)
Change-Id: Idf10d7ffb1d98a04edc09a25c35e4e9e3abe87b5
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
152 files changed, 624 insertions, 701 deletions
diff --git a/src/plugins/coreplugin/actionmanager/actioncontainer.cpp b/src/plugins/coreplugin/actionmanager/actioncontainer.cpp index e1374ac73a..b602dc54cd 100644 --- a/src/plugins/coreplugin/actionmanager/actioncontainer.cpp +++ b/src/plugins/coreplugin/actionmanager/actioncontainer.cpp @@ -202,29 +202,29 @@ QList<Group>::const_iterator ActionContainerPrivate::findGroup(Id groupId) const QAction *ActionContainerPrivate::insertLocation(Id groupId) const { QList<Group>::const_iterator it = findGroup(groupId); - QTC_ASSERT(it != m_groups.constEnd(), return 0); + QTC_ASSERT(it != m_groups.constEnd(), return nullptr); return insertLocation(it); } QAction *ActionContainerPrivate::insertLocation(QList<Group>::const_iterator group) const { if (group == m_groups.constEnd()) - return 0; + return nullptr; ++group; while (group != m_groups.constEnd()) { if (!group->items.isEmpty()) { QObject *item = group->items.first(); - if (Command *cmd = qobject_cast<Command *>(item)) { + if (auto cmd = qobject_cast<Command *>(item)) { return cmd->action(); - } else if (ActionContainer *container = qobject_cast<ActionContainer *>(item)) { + } else if (auto container = qobject_cast<ActionContainer *>(item)) { if (container->menu()) return container->menu()->menuAction(); } - QTC_ASSERT(false, return 0); + QTC_ASSERT(false, return nullptr); } ++group; } - return 0; + return nullptr; } void ActionContainerPrivate::addAction(Command *command, Id groupId) @@ -247,11 +247,11 @@ void ActionContainerPrivate::addAction(Command *command, Id groupId) void ActionContainerPrivate::addMenu(ActionContainer *menu, Id groupId) { - ActionContainerPrivate *containerPrivate = static_cast<ActionContainerPrivate *>(menu); + auto containerPrivate = static_cast<ActionContainerPrivate *>(menu); if (!containerPrivate->canBeAddedToMenu()) return; - MenuActionContainer *container = static_cast<MenuActionContainer *>(containerPrivate); + auto container = static_cast<MenuActionContainer *>(containerPrivate); const Id actualGroupId = groupId.isValid() ? groupId : Id(Constants::G_DEFAULT_TWO); QList<Group>::const_iterator groupIt = findGroup(actualGroupId); QTC_ASSERT(groupIt != m_groups.constEnd(), return); @@ -265,11 +265,11 @@ void ActionContainerPrivate::addMenu(ActionContainer *menu, Id groupId) void ActionContainerPrivate::addMenu(ActionContainer *before, ActionContainer *menu, Id groupId) { - ActionContainerPrivate *containerPrivate = static_cast<ActionContainerPrivate *>(menu); + auto containerPrivate = static_cast<ActionContainerPrivate *>(menu); if (!containerPrivate->canBeAddedToMenu()) return; - MenuActionContainer *container = static_cast<MenuActionContainer *>(containerPrivate); + auto container = static_cast<MenuActionContainer *>(containerPrivate); const Id actualGroupId = groupId.isValid() ? groupId : Id(Constants::G_DEFAULT_TWO); QList<Group>::const_iterator groupIt = findGroup(actualGroupId); QTC_ASSERT(groupIt != m_groups.constEnd(), return); @@ -293,7 +293,7 @@ void ActionContainerPrivate::addMenu(ActionContainer *before, ActionContainer *m Command *ActionContainerPrivate::addSeparator(const Context &context, Id group, QAction **outSeparator) { static int separatorIdCount = 0; - QAction *separator = new QAction(this); + auto separator = new QAction(this); separator->setSeparator(true); Id sepId = id().withSuffix(".Separator.").withSuffix(++separatorIdCount); Command *cmd = ActionManager::registerAction(separator, sepId, context); @@ -309,12 +309,12 @@ void ActionContainerPrivate::clear() while (it.hasNext()) { Group &group = it.next(); foreach (QObject *item, group.items) { - if (Command *command = qobject_cast<Command *>(item)) { + if (auto command = qobject_cast<Command *>(item)) { removeAction(command->action()); disconnect(command, &Command::activeStateChanged, this, &ActionContainerPrivate::scheduleUpdate); disconnect(command, &QObject::destroyed, this, &ActionContainerPrivate::itemDestroyed); - } else if (ActionContainer *container = qobject_cast<ActionContainer *>(item)) { + } else if (auto container = qobject_cast<ActionContainer *>(item)) { container->clear(); disconnect(container, &QObject::destroyed, this, &ActionContainerPrivate::itemDestroyed); @@ -344,12 +344,12 @@ Id ActionContainerPrivate::id() const QMenu *ActionContainerPrivate::menu() const { - return 0; + return nullptr; } QMenuBar *ActionContainerPrivate::menuBar() const { - return 0; + return nullptr; } bool ActionContainerPrivate::canAddAction(Command *action) const @@ -429,7 +429,7 @@ bool MenuActionContainer::updateInternal() while (it.hasNext()) { const Group &group = it.next(); foreach (QObject *item, group.items) { - if (ActionContainerPrivate *container = qobject_cast<ActionContainerPrivate*>(item)) { + if (auto container = qobject_cast<ActionContainerPrivate*>(item)) { actions.removeAll(container->menu()->menuAction()); if (container == this) { QByteArray warning = Q_FUNC_INFO + QByteArray(" container '"); @@ -443,7 +443,7 @@ bool MenuActionContainer::updateInternal() hasitems = true; break; } - } else if (Command *command = qobject_cast<Command *>(item)) { + } else if (auto command = qobject_cast<Command *>(item)) { actions.removeAll(command->action()); if (command->isActive()) { hasitems = true; @@ -488,7 +488,7 @@ bool MenuActionContainer::canBeAddedToMenu() const */ MenuBarActionContainer::MenuBarActionContainer(Id id) - : ActionContainerPrivate(id), m_menuBar(0) + : ActionContainerPrivate(id), m_menuBar(nullptr) { setOnAllDisabledBehavior(Show); } diff --git a/src/plugins/coreplugin/actionmanager/actioncontainer_p.h b/src/plugins/coreplugin/actionmanager/actioncontainer_p.h index 27fed6a705..ffa24eecdd 100644 --- a/src/plugins/coreplugin/actionmanager/actioncontainer_p.h +++ b/src/plugins/coreplugin/actionmanager/actioncontainer_p.h @@ -46,7 +46,7 @@ class ActionContainerPrivate : public ActionContainer public: ActionContainerPrivate(Id id); - ~ActionContainerPrivate() override {} + ~ActionContainerPrivate() override = default; void setOnAllDisabledBehavior(OnAllDisabledBehavior behavior) override; ActionContainer::OnAllDisabledBehavior onAllDisabledBehavior() const override; diff --git a/src/plugins/coreplugin/actionmanager/actionmanager.cpp b/src/plugins/coreplugin/actionmanager/actionmanager.cpp index 748a295afd..9b2bec82dc 100644 --- a/src/plugins/coreplugin/actionmanager/actionmanager.cpp +++ b/src/plugins/coreplugin/actionmanager/actionmanager.cpp @@ -152,7 +152,7 @@ using namespace Core::Internal; Emitted when a command (with the \a id) is added. */ -static ActionManager *m_instance = 0; +static ActionManager *m_instance = nullptr; static ActionManagerPrivate *d; /*! @@ -198,7 +198,7 @@ ActionContainer *ActionManager::createMenu(Id id) if (it != d->m_idContainerMap.constEnd()) return it.value(); - MenuActionContainer *mc = new MenuActionContainer(id); + auto mc = new MenuActionContainer(id); d->m_idContainerMap.insert(id, mc); connect(mc, &QObject::destroyed, d, &ActionManagerPrivate::containerDestroyed); @@ -219,10 +219,10 @@ ActionContainer *ActionManager::createMenuBar(Id id) if (it != d->m_idContainerMap.constEnd()) return it.value(); - QMenuBar *mb = new QMenuBar; // No parent (System menu bar on Mac OS X) + auto mb = new QMenuBar; // No parent (System menu bar on macOS) mb->setObjectName(id.toString()); - MenuBarActionContainer *mbc = new MenuBarActionContainer(id); + auto mbc = new MenuBarActionContainer(id); mbc->setMenuBar(mb); d->m_idContainerMap.insert(id, mbc); @@ -268,7 +268,7 @@ Command *ActionManager::command(Id id) if (warnAboutFindFailures) qWarning() << "ActionManagerPrivate::command(): failed to find :" << id.name(); - return 0; + return nullptr; } return it.value(); } @@ -287,7 +287,7 @@ ActionContainer *ActionManager::actionContainer(Id id) if (warnAboutFindFailures) qWarning() << "ActionManagerPrivate::actionContainer(): failed to find :" << id.name(); - return 0; + return nullptr; } return it.value(); } @@ -415,13 +415,13 @@ bool ActionManagerPrivate::hasContext(const Context &context) const void ActionManagerPrivate::containerDestroyed() { - ActionContainerPrivate *container = static_cast<ActionContainerPrivate *>(sender()); + auto container = static_cast<ActionContainerPrivate *>(sender()); m_idContainerMap.remove(m_idContainerMap.key(container)); } void ActionManagerPrivate::actionTriggered() { - QAction *action = qobject_cast<QAction *>(QObject::sender()); + auto action = qobject_cast<QAction *>(QObject::sender()); if (action) showShortcutPopup(action->shortcut().toString()); } diff --git a/src/plugins/coreplugin/actionmanager/actionmanager_p.h b/src/plugins/coreplugin/actionmanager/actionmanager_p.h index 0573bbe675..216f936273 100644 --- a/src/plugins/coreplugin/actionmanager/actionmanager_p.h +++ b/src/plugins/coreplugin/actionmanager/actionmanager_p.h @@ -46,8 +46,8 @@ class ActionManagerPrivate : public QObject Q_OBJECT public: - typedef QHash<Id, Action *> IdCmdMap; - typedef QHash<Id, ActionContainerPrivate *> IdContainerMap; + using IdCmdMap = QHash<Id, Action *>; + using IdContainerMap = QHash<Id, ActionContainerPrivate *>; ~ActionManagerPrivate() override; diff --git a/src/plugins/coreplugin/actionmanager/command.cpp b/src/plugins/coreplugin/actionmanager/command.cpp index 45d72ecead..4d9715f8b8 100644 --- a/src/plugins/coreplugin/actionmanager/command.cpp +++ b/src/plugins/coreplugin/actionmanager/command.cpp @@ -200,12 +200,9 @@ namespace Internal { \internal */ Action::Action(Id id) - : m_attributes(0), + : m_attributes({}), m_id(id), - m_isKeyInitialized(false), - m_action(new Utils::ProxyAction(this)), - m_active(false), - m_contextInitialized(false) + m_action(new Utils::ProxyAction(this)) { m_action->setShortcutVisibleInToolTip(true); connect(m_action, &QAction::changed, this, &Action::updateActiveState); @@ -276,9 +273,9 @@ void Action::setCurrentContext(const Context &context) { m_context = context; - QAction *currentAction = 0; + QAction *currentAction = nullptr; for (int i = 0; i < m_context.size(); ++i) { - if (QAction *a = m_contextActionMap.value(m_context.at(i), 0)) { + if (QAction *a = m_contextActionMap.value(m_context.at(i), nullptr)) { currentAction = a; break; } @@ -319,7 +316,7 @@ void Action::addOverrideAction(QAction *action, const Context &context, bool scr for (int i = 0; i < context.size(); ++i) { Id id = context.at(i); if (m_contextActionMap.contains(id)) - qWarning("%s", qPrintable(msgActionWarning(action, id, m_contextActionMap.value(id, 0)))); + qWarning("%s", qPrintable(msgActionWarning(action, id, m_contextActionMap.value(id, nullptr)))); m_contextActionMap.insert(id, action); } } @@ -332,7 +329,7 @@ void Action::removeOverrideAction(QAction *action) QMutableMapIterator<Id, QPointer<QAction> > it(m_contextActionMap); while (it.hasNext()) { it.next(); - if (it.value() == 0) + if (it.value() == nullptr) it.remove(); else if (it.value() == action) it.remove(); @@ -369,7 +366,7 @@ bool Action::isScriptable(const Context &context) const return m_scriptableMap.value(m_action->action()); for (int i = 0; i < context.size(); ++i) { - if (QAction *a = m_contextActionMap.value(context.at(i), 0)) { + if (QAction *a = m_contextActionMap.value(context.at(i), nullptr)) { if (m_scriptableMap.contains(a) && m_scriptableMap.value(a)) return true; } @@ -433,7 +430,7 @@ void Command::augmentActionWithShortcutToolTip(QAction *a) const QToolButton *Command::toolButtonWithAppendedShortcut(QAction *action, Command *cmd) { - QToolButton *button = new QToolButton; + auto button = new QToolButton; button->setDefaultAction(action); if (cmd) cmd->augmentActionWithShortcutToolTip(action); diff --git a/src/plugins/coreplugin/actionmanager/command_p.h b/src/plugins/coreplugin/actionmanager/command_p.h index 046f6041cf..6b8734ad14 100644 --- a/src/plugins/coreplugin/actionmanager/command_p.h +++ b/src/plugins/coreplugin/actionmanager/command_p.h @@ -86,15 +86,15 @@ private: Id m_id; QKeySequence m_defaultKey; QString m_defaultText; - bool m_isKeyInitialized; + bool m_isKeyInitialized = false; - Utils::ProxyAction *m_action; + Utils::ProxyAction *m_action = nullptr; QString m_toolTip; QMap<Id, QPointer<QAction> > m_contextActionMap; QMap<QAction*, bool> m_scriptableMap; - bool m_active; - bool m_contextInitialized; + bool m_active = false; + bool m_contextInitialized = false; }; } // namespace Internal diff --git a/src/plugins/coreplugin/actionmanager/commandbutton.cpp b/src/plugins/coreplugin/actionmanager/commandbutton.cpp index 29ac42ad73..3f4f5b7a13 100644 --- a/src/plugins/coreplugin/actionmanager/commandbutton.cpp +++ b/src/plugins/coreplugin/actionmanager/commandbutton.cpp @@ -44,13 +44,13 @@ using namespace Core; CommandButton::CommandButton(QWidget *parent) : QToolButton(parent) - , m_command(0) + , m_command(nullptr) { } CommandButton::CommandButton(Id id, QWidget *parent) : QToolButton(parent) - , m_command(0) + , m_command(nullptr) { setCommandId(id); } diff --git a/src/plugins/coreplugin/actionmanager/commandmappings.cpp b/src/plugins/coreplugin/actionmanager/commandmappings.cpp index f17c195024..7febf11b29 100644 --- a/src/plugins/coreplugin/actionmanager/commandmappings.cpp +++ b/src/plugins/coreplugin/actionmanager/commandmappings.cpp @@ -77,21 +77,21 @@ public: importButton = new QPushButton(CommandMappings::tr("Import..."), groupBox); exportButton = new QPushButton(CommandMappings::tr("Export..."), groupBox); - QHBoxLayout *hboxLayout1 = new QHBoxLayout(); + auto hboxLayout1 = new QHBoxLayout(); hboxLayout1->addWidget(defaultButton); hboxLayout1->addStretch(); hboxLayout1->addWidget(importButton); hboxLayout1->addWidget(exportButton); - QHBoxLayout *hboxLayout = new QHBoxLayout(); + auto hboxLayout = new QHBoxLayout(); hboxLayout->addWidget(filterEdit); - QVBoxLayout *vboxLayout1 = new QVBoxLayout(groupBox); + auto vboxLayout1 = new QVBoxLayout(groupBox); vboxLayout1->addLayout(hboxLayout); vboxLayout1->addWidget(commandList); vboxLayout1->addLayout(hboxLayout1); - QVBoxLayout *vboxLayout = new QVBoxLayout(parent); + auto vboxLayout = new QVBoxLayout(parent); vboxLayout->addWidget(groupBox); q->connect(exportButton, &QPushButton::clicked, diff --git a/src/plugins/coreplugin/basefilewizard.cpp b/src/plugins/coreplugin/basefilewizard.cpp index b252d0de2b..b388b7f7d8 100644 --- a/src/plugins/coreplugin/basefilewizard.cpp +++ b/src/plugins/coreplugin/basefilewizard.cpp @@ -89,7 +89,7 @@ void BaseFileWizard::accept() reject(); return; case BaseFileWizardFactory::OverwriteError: - QMessageBox::critical(0, tr("Existing files"), errorMessage); + QMessageBox::critical(nullptr, tr("Existing files"), errorMessage); reject(); return; case BaseFileWizardFactory::OverwriteOk: @@ -132,7 +132,7 @@ void BaseFileWizard::accept() // Post generation handler if (!m_factory->postGenerateFiles(this, m_files, &errorMessage)) if (!errorMessage.isEmpty()) - QMessageBox::critical(0, tr("File Generation Failure"), errorMessage); + QMessageBox::critical(nullptr, tr("File Generation Failure"), errorMessage); Wizard::accept(); } diff --git a/src/plugins/coreplugin/basefilewizardfactory.cpp b/src/plugins/coreplugin/basefilewizardfactory.cpp index 3e90da89d4..633980bf39 100644 --- a/src/plugins/coreplugin/basefilewizardfactory.cpp +++ b/src/plugins/coreplugin/basefilewizardfactory.cpp @@ -78,7 +78,7 @@ Utils::Wizard *BaseFileWizardFactory::runWizardImpl(const QString &path, QWidget Id platform, const QVariantMap &extraValues) { - QTC_ASSERT(!path.isEmpty(), return 0); + QTC_ASSERT(!path.isEmpty(), return nullptr); // Create dialog and run it. Ensure that the dialog is deleted when // leaving the func, but not before the IFileWizardExtension::process diff --git a/src/plugins/coreplugin/basefilewizardfactory.h b/src/plugins/coreplugin/basefilewizardfactory.h index 586e350cdc..d37592d5fd 100644 --- a/src/plugins/coreplugin/basefilewizardfactory.h +++ b/src/plugins/coreplugin/basefilewizardfactory.h @@ -47,7 +47,7 @@ class BaseFileWizard; class CORE_EXPORT WizardDialogParameters { public: - typedef QList<QWizardPage *> WizardPageList; + using WizardPageList = QList<QWizardPage *>; enum DialogParameterEnum { ForceCapitalLetterForFileName = 0x01 diff --git a/src/plugins/coreplugin/coreplugin.cpp b/src/plugins/coreplugin/coreplugin.cpp index f82e84a337..67d2e33495 100644 --- a/src/plugins/coreplugin/coreplugin.cpp +++ b/src/plugins/coreplugin/coreplugin.cpp @@ -70,9 +70,6 @@ using namespace Core::Internal; using namespace Utils; CorePlugin::CorePlugin() - : m_mainWindow(nullptr) - , m_editMode(nullptr) - , m_locator(nullptr) { qRegisterMetaType<Id>(); qRegisterMetaType<Core::Search::TextPosition>(); diff --git a/src/plugins/coreplugin/coreplugin.h b/src/plugins/coreplugin/coreplugin.h index 7e1ae1664c..b427bdd4d1 100644 --- a/src/plugins/coreplugin/coreplugin.h +++ b/src/plugins/coreplugin/coreplugin.h @@ -78,9 +78,9 @@ private slots: private: static void addToPathChooserContextMenu(Utils::PathChooser *pathChooser, QMenu *menu); - MainWindow *m_mainWindow; - EditMode *m_editMode; - Locator *m_locator; + MainWindow *m_mainWindow = nullptr; + EditMode *m_editMode = nullptr; + Locator *m_locator = nullptr; ReaperPrivate m_reaper; }; diff --git a/src/plugins/coreplugin/designmode.cpp b/src/plugins/coreplugin/designmode.cpp index 735121192a..9932fe3f03 100644 --- a/src/plugins/coreplugin/designmode.cpp +++ b/src/plugins/coreplugin/designmode.cpp @@ -80,7 +80,7 @@ static DesignModePrivate *d = nullptr; DesignMode::DesignMode() { ICore::addPreCloseListener([]() -> bool { - m_instance->currentEditorChanged(0); + m_instance->currentEditorChanged(nullptr); return true; }); @@ -130,7 +130,7 @@ void DesignMode::registerDesignWidget(QWidget *widget, setDesignModeIsRequired(); int index = d->m_stackWidget->addWidget(widget); - DesignEditorInfo *info = new DesignEditorInfo; + auto info = new DesignEditorInfo; info->mimeTypes = mimeTypes; info->context = context; info->widgetIndex = index; @@ -184,7 +184,7 @@ void DesignMode::currentEditorChanged(IEditor *editor) if (ModeManager::currentMode() == id()) ModeManager::activateMode(Constants::MODE_EDIT); setEnabled(false); - d->m_currentEditor = 0; + d->m_currentEditor = nullptr; emit actionsUpdated(d->m_currentEditor.data()); } else { d->m_currentEditor = editor; diff --git a/src/plugins/coreplugin/dialogs/externaltoolconfig.cpp b/src/plugins/coreplugin/dialogs/externaltoolconfig.cpp index 2cce88ec24..3e5255ea59 100644 --- a/src/plugins/coreplugin/dialogs/externaltoolconfig.cpp +++ b/src/plugins/coreplugin/dialogs/externaltoolconfig.cpp @@ -121,14 +121,14 @@ QVariant ExternalToolModel::data(const QString &category, int role) const QMimeData *ExternalToolModel::mimeData(const QModelIndexList &indexes) const { if (indexes.isEmpty()) - return 0; + return nullptr; QModelIndex modelIndex = indexes.first(); ExternalTool *tool = toolForIndex(modelIndex); - QTC_ASSERT(tool, return 0); + QTC_ASSERT(tool, return nullptr); bool found; QString category = categoryForIndex(modelIndex.parent(), &found); - QTC_ASSERT(found, return 0); - QMimeData *md = new QMimeData(); + QTC_ASSERT(found, return nullptr); + auto md = new QMimeData(); QByteArray ba; QDataStream stream(&ba, QIODevice::WriteOnly); stream << category << m_tools.value(category).indexOf(tool); @@ -230,7 +230,7 @@ Qt::ItemFlags ExternalToolModel::flags(const QModelIndex &index) const return TOOLSMENU_ITEM_FLAGS; return CATEGORY_ITEM_FLAGS; } - return 0; + return nullptr; } bool ExternalToolModel::setData(const QModelIndex &modelIndex, const QVariant &value, int role) @@ -342,7 +342,7 @@ QModelIndex ExternalToolModel::addTool(const QModelIndex &atIndex) if (!found) category = categoryForIndex(atIndex.parent(), &found); - ExternalTool *tool = new ExternalTool; + auto tool = new ExternalTool; tool->setDisplayCategory(category); tool->setDisplayName(tr("New Tool")); tool->setDescription(tr("This tool prints a line of useful text")); @@ -440,7 +440,7 @@ ExternalToolConfig::ExternalToolConfig(QWidget *parent) : connect(ui->revertButton, &QAbstractButton::clicked, this, &ExternalToolConfig::revertCurrentItem); connect(ui->removeButton, &QAbstractButton::clicked, this, &ExternalToolConfig::removeTool); - QMenu *menu = new QMenu(ui->addButton); + auto menu = new QMenu(ui->addButton); ui->addButton->setMenu(menu); QAction *addTool = new QAction(tr("Add Tool"), this); menu->addAction(addTool); diff --git a/src/plugins/coreplugin/dialogs/externaltoolconfig.h b/src/plugins/coreplugin/dialogs/externaltoolconfig.h index 1a2b72b1ac..acc2a68edc 100644 --- a/src/plugins/coreplugin/dialogs/externaltoolconfig.h +++ b/src/plugins/coreplugin/dialogs/externaltoolconfig.h @@ -46,7 +46,7 @@ class ExternalToolModel : public QAbstractItemModel public: explicit ExternalToolModel(QObject *parent); - ~ExternalToolModel(); + ~ExternalToolModel() override; int columnCount(const QModelIndex &parent = QModelIndex()) const override; QVariant data(const QModelIndex &modelIndex, int role = Qt::DisplayRole) const override; @@ -86,8 +86,8 @@ class ExternalToolConfig : public QWidget Q_OBJECT public: - explicit ExternalToolConfig(QWidget *parent = 0); - ~ExternalToolConfig(); + explicit ExternalToolConfig(QWidget *parent = nullptr); + ~ExternalToolConfig() override; void setTools(const QMap<QString, QList<ExternalTool *> > &tools); QMap<QString, QList<ExternalTool *> > tools() const; diff --git a/src/plugins/coreplugin/dialogs/ioptionspage.cpp b/src/plugins/coreplugin/dialogs/ioptionspage.cpp index 86281fb01a..a8dbfbffde 100644 --- a/src/plugins/coreplugin/dialogs/ioptionspage.cpp +++ b/src/plugins/coreplugin/dialogs/ioptionspage.cpp @@ -169,7 +169,7 @@ const QList<Core::IOptionsPage *> Core::IOptionsPage::allOptionsPages() bool Core::IOptionsPage::matches(const QString &searchKeyWord) const { if (!m_keywordsInitialized) { - IOptionsPage *that = const_cast<IOptionsPage *>(this); + auto that = const_cast<IOptionsPage *>(this); QWidget *widget = that->widget(); if (!widget) return false; diff --git a/src/plugins/coreplugin/dialogs/newdialog.cpp b/src/plugins/coreplugin/dialogs/newdialog.cpp index 7ae0953ad1..7e1cca297e 100644 --- a/src/plugins/coreplugin/dialogs/newdialog.cpp +++ b/src/plugins/coreplugin/dialogs/newdialog.cpp @@ -61,10 +61,10 @@ using namespace Core::Internal; class WizardFactoryContainer { public: - WizardFactoryContainer() : wizard(nullptr), wizardOption(0) {} + WizardFactoryContainer() = default; WizardFactoryContainer(Core::IWizardFactory *w, int i): wizard(w), wizardOption(i) {} - Core::IWizardFactory *wizard; - int wizardOption; + Core::IWizardFactory *wizard = nullptr; + int wizardOption = 0; }; inline Core::IWizardFactory *factoryOfItem(const QStandardItem *item = nullptr) @@ -175,8 +175,7 @@ QWidget *NewDialog::m_currentDialog = nullptr; NewDialog::NewDialog(QWidget *parent) : QDialog(parent), - m_ui(new Ui::NewDialog), - m_okButton(nullptr) + m_ui(new Ui::NewDialog) { QTC_CHECK(m_currentDialog == nullptr); @@ -257,10 +256,10 @@ void NewDialog::setWizardFactories(QList<IWizardFactory *> factories, QStandardItem *projectKindItem = new QStandardItem(tr("Projects")); projectKindItem->setData(IWizardFactory::ProjectWizard, Qt::UserRole); - projectKindItem->setFlags(0); // disable item to prevent focus + projectKindItem->setFlags(nullptr); // disable item to prevent focus QStandardItem *filesKindItem = new QStandardItem(tr("Files and Classes")); filesKindItem->setData(IWizardFactory::FileWizard, Qt::UserRole); - filesKindItem->setFlags(0); // disable item to prevent focus + filesKindItem->setFlags(nullptr); // disable item to prevent focus parentItem->appendRow(projectKindItem); parentItem->appendRow(filesKindItem); @@ -355,7 +354,7 @@ QWidget *NewDialog::currentDialog() bool NewDialog::event(QEvent *event) { if (event->type() == QEvent::ShortcutOverride) { - QKeyEvent *ke = static_cast<QKeyEvent *>(event); + auto ke = static_cast<QKeyEvent *>(event); if (ke->key() == Qt::Key_Escape && !ke->modifiers()) { ke->accept(); return true; @@ -518,7 +517,7 @@ void NewDialog::reject() void NewDialog::updateOkButton() { - m_okButton->setEnabled(currentWizardFactory() != 0); + m_okButton->setEnabled(currentWizardFactory() != nullptr); } void NewDialog::setSelectedPlatform(const QString & /*platform*/) diff --git a/src/plugins/coreplugin/dialogs/newdialog.h b/src/plugins/coreplugin/dialogs/newdialog.h index df0c9c777b..46047cbd4d 100644 --- a/src/plugins/coreplugin/dialogs/newdialog.h +++ b/src/plugins/coreplugin/dialogs/newdialog.h @@ -82,7 +82,7 @@ private: Ui::NewDialog *m_ui; QStandardItemModel *m_model; QSortFilterProxyModel *m_filterProxyModel; - QPushButton *m_okButton; + QPushButton *m_okButton = nullptr; QIcon m_dummyIcon; QList<QStandardItem*> m_categoryItems; QString m_defaultLocation; diff --git a/src/plugins/coreplugin/dialogs/promptoverwritedialog.cpp b/src/plugins/coreplugin/dialogs/promptoverwritedialog.cpp index 95b6a948d2..a9434616c9 100644 --- a/src/plugins/coreplugin/dialogs/promptoverwritedialog.cpp +++ b/src/plugins/coreplugin/dialogs/promptoverwritedialog.cpp @@ -63,7 +63,7 @@ PromptOverwriteDialog::PromptOverwriteDialog(QWidget *parent) : setWindowTitle(tr("Overwrite Existing Files")); setModal(true); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); - QVBoxLayout *mainLayout = new QVBoxLayout(this); + auto mainLayout = new QVBoxLayout(this); mainLayout->addWidget(m_label); m_view->setRootIsDecorated(false); m_view->setUniformRowHeights(true); @@ -105,7 +105,7 @@ QStandardItem *PromptOverwriteDialog::itemForFile(const QString &f) const if (fileNameOfItem(item) == f) return item; } - return 0; + return nullptr; } QStringList PromptOverwriteDialog::files(Qt::CheckState cs) const diff --git a/src/plugins/coreplugin/dialogs/readonlyfilesdialog.cpp b/src/plugins/coreplugin/dialogs/readonlyfilesdialog.cpp index 15039e5d7a..af41349cff 100644 --- a/src/plugins/coreplugin/dialogs/readonlyfilesdialog.cpp +++ b/src/plugins/coreplugin/dialogs/readonlyfilesdialog.cpp @@ -53,7 +53,7 @@ class ReadOnlyFilesDialogPrivate Q_DECLARE_TR_FUNCTIONS(Core::ReadOnlyFilesDialog) public: - ReadOnlyFilesDialogPrivate(ReadOnlyFilesDialog *parent, IDocument *document = 0, bool useSaveAs = false); + ReadOnlyFilesDialogPrivate(ReadOnlyFilesDialog *parent, IDocument *document = nullptr, bool useSaveAs = false); ~ReadOnlyFilesDialogPrivate(); enum ReadOnlyFilesTreeColumn { @@ -324,7 +324,7 @@ QRadioButton *ReadOnlyFilesDialogPrivate::createRadioButtonForItem(QTreeWidgetIt ReadOnlyFilesTreeColumn type) { - QRadioButton *radioButton = new QRadioButton(q); + auto radioButton = new QRadioButton(q); group->addButton(radioButton, type); item->setTextAlignment(type, Qt::AlignHCenter); ui.treeWidget->setItemWidget(item, type, radioButton); @@ -353,7 +353,7 @@ void ReadOnlyFilesDialogPrivate::setAll(int index) // Check for every file if the selected operation is available and change it to the operation. foreach (ReadOnlyFilesDialogPrivate::ButtonGroupForFile groupForFile, buttonGroups) { - QRadioButton *radioButton = qobject_cast<QRadioButton*> (groupForFile.group->button(type)); + auto radioButton = qobject_cast<QRadioButton*> (groupForFile.group->button(type)); if (radioButton) radioButton->setChecked(true); } @@ -400,11 +400,11 @@ void ReadOnlyFilesDialogPrivate::initDialog(const QStringList &fileNames) const QString directory = info.absolutePath(); // Setup a default entry with filename folder and make writable radio button. - QTreeWidgetItem *item = new QTreeWidgetItem(ui.treeWidget); + auto item = new QTreeWidgetItem(ui.treeWidget); item->setText(FileName, visibleName); item->setIcon(FileName, FileIconProvider::icon(fileName)); item->setText(Folder, Utils::FileUtils::shortNativePath(Utils::FileName(QFileInfo(directory)))); - QButtonGroup *radioButtonGroup = new QButtonGroup; + auto radioButtonGroup = new QButtonGroup; // Add a button for opening the file with a version control system // if the file is managed by an version control system which allows opening files. @@ -442,7 +442,7 @@ void ReadOnlyFilesDialogPrivate::initDialog(const QStringList &fileNames) if (useSaveAs) createRadioButtonForItem(item, radioButtonGroup, SaveAs); // If the file is managed by a version control system save the vcs for this file. - versionControls[fileName] = fileManagedByVCS ? versionControlForFile : 0; + versionControls[fileName] = fileManagedByVCS ? versionControlForFile : nullptr; // Also save the buttongroup for every file to get the result for each entry. ReadOnlyFilesDialogPrivate::ButtonGroupForFile groupForFile; diff --git a/src/plugins/coreplugin/dialogs/saveitemsdialog.cpp b/src/plugins/coreplugin/dialogs/saveitemsdialog.cpp index edee9a6bca..f3e476fed3 100644 --- a/src/plugins/coreplugin/dialogs/saveitemsdialog.cpp +++ b/src/plugins/coreplugin/dialogs/saveitemsdialog.cpp @@ -166,7 +166,7 @@ void SaveItemsDialog::collectFilesToDiff() { m_filesToDiff.clear(); foreach (QTreeWidgetItem *item, m_ui.treeWidget->selectedItems()) { - if (IDocument *doc = item->data(0, Qt::UserRole).value<IDocument*>()) + if (auto doc = item->data(0, Qt::UserRole).value<IDocument*>()) m_filesToDiff.append(doc->filePath().toString()); } reject(); diff --git a/src/plugins/coreplugin/dialogs/settingsdialog.cpp b/src/plugins/coreplugin/dialogs/settingsdialog.cpp index 1cc52d6331..ddb91fe469 100644 --- a/src/plugins/coreplugin/dialogs/settingsdialog.cpp +++ b/src/plugins/coreplugin/dialogs/settingsdialog.cpp @@ -101,7 +101,7 @@ class CategoryModel : public QAbstractListModel { public: CategoryModel(); - ~CategoryModel(); + ~CategoryModel() override; int rowCount(const QModelIndex &parent = QModelIndex()) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; @@ -172,7 +172,7 @@ void CategoryModel::setPages(const QList<IOptionsPage*> &pages, if (!category) { category = new Category; category->id = categoryId; - category->tabWidget = 0; + category->tabWidget = nullptr; category->index = -1; m_categories.append(category); } @@ -189,7 +189,7 @@ void CategoryModel::setPages(const QList<IOptionsPage*> &pages, if (!category) { category = new Category; category->id = categoryId; - category->tabWidget = 0; + category->tabWidget = nullptr; category->index = -1; m_categories.append(category); } @@ -233,7 +233,7 @@ Category *CategoryModel::findCategoryById(Id id) return category; } - return 0; + return nullptr; } // ----------- Category filter model @@ -245,7 +245,7 @@ Category *CategoryModel::findCategoryById(Id id) class CategoryFilterModel : public QSortFilterProxyModel { public: - CategoryFilterModel() {} + CategoryFilterModel() = default; protected: bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; @@ -284,7 +284,7 @@ class CategoryListViewDelegate : public QStyledItemDelegate public: explicit CategoryListViewDelegate(QObject *parent) : QStyledItemDelegate(parent) {} - QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const + QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override { QSize size = QStyledItemDelegate::sizeHint(option, index); size.setHeight(qMax(size.height(), 32)); @@ -540,7 +540,7 @@ void SettingsDialog::createGui() headerLabelFont.setPointSize(pointSize + 2); m_headerLabel->setFont(headerLabelFont); - QHBoxLayout *headerHLayout = new QHBoxLayout; + auto headerHLayout = new QHBoxLayout; const int leftMargin = QApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin); headerHLayout->addSpacerItem(new QSpacerItem(leftMargin, 0, QSizePolicy::Fixed, QSizePolicy::Ignored)); headerHLayout->addWidget(m_headerLabel); @@ -559,7 +559,7 @@ void SettingsDialog::createGui() connect(buttonBox, &QDialogButtonBox::accepted, this, &SettingsDialog::accept); connect(buttonBox, &QDialogButtonBox::rejected, this, &SettingsDialog::reject); - QGridLayout *mainGridLayout = new QGridLayout; + auto mainGridLayout = new QGridLayout; mainGridLayout->addWidget(m_filterLineEdit, 0, 0, 1, 1); mainGridLayout->addLayout(headerHLayout, 0, 1, 1, 1); mainGridLayout->addWidget(m_categoryList, 1, 0, 1, 1); @@ -598,12 +598,12 @@ void SettingsDialog::ensureCategoryWidget(Category *category) return; m_model.ensurePages(category); - QTabWidget *tabWidget = new QTabWidget; + auto tabWidget = new QTabWidget; tabWidget->tabBar()->setObjectName("qc_settings_main_tabbar"); // easier lookup in Squish for (IOptionsPage *page : category->pages) { QWidget *widget = page->widget(); ICore::setupScreenShooter(page->displayName(), widget); - SmartScrollArea *ssa = new SmartScrollArea(this); + auto ssa = new SmartScrollArea(this); ssa->setWidget(widget); widget->setAutoFillBackground(false); tabWidget->addTab(ssa, page->displayName()); diff --git a/src/plugins/coreplugin/dialogs/shortcutsettings.cpp b/src/plugins/coreplugin/dialogs/shortcutsettings.cpp index 625833bad1..decb0a1f76 100644 --- a/src/plugins/coreplugin/dialogs/shortcutsettings.cpp +++ b/src/plugins/coreplugin/dialogs/shortcutsettings.cpp @@ -125,7 +125,7 @@ QSize ShortcutButton::sizeHint() const { if (m_preferredWidth < 0) { // initialize size hint const QString originalText = text(); - ShortcutButton *that = const_cast<ShortcutButton *>(this); + auto that = const_cast<ShortcutButton *>(this); that->setText(m_checkedText); m_preferredWidth = QPushButton::sizeHint().width(); that->setText(m_uncheckedText); @@ -153,7 +153,7 @@ bool ShortcutButton::eventFilter(QObject *obj, QEvent *evt) return true; } if (evt->type() == QEvent::KeyPress) { - QKeyEvent *k = static_cast<QKeyEvent*>(evt); + auto k = static_cast<QKeyEvent*>(evt); int nextKey = k->key(); if (m_keyNum > 3 || nextKey == Qt::Key_Control @@ -486,8 +486,8 @@ void ShortcutSettingsWidget::initialize() if (c->action() && c->action()->isSeparator()) continue; - QTreeWidgetItem *item = 0; - ShortcutItem *s = new ShortcutItem; + QTreeWidgetItem *item = nullptr; + auto s = new ShortcutItem; m_scitems << s; item = new QTreeWidgetItem; s->m_cmd = c; diff --git a/src/plugins/coreplugin/documentmanager.cpp b/src/plugins/coreplugin/documentmanager.cpp index a647930e35..1fcbe6c770 100644 --- a/src/plugins/coreplugin/documentmanager.cpp +++ b/src/plugins/coreplugin/documentmanager.cpp @@ -436,7 +436,7 @@ void DocumentManager::renamedFile(const QString &from, const QString &to) void DocumentManager::filePathChanged(const FileName &oldName, const FileName &newName) { - IDocument *doc = qobject_cast<IDocument *>(sender()); + auto doc = qobject_cast<IDocument *>(sender()); QTC_ASSERT(doc, return); if (doc == d->m_blockedIDocument) return; @@ -456,7 +456,7 @@ void DocumentManager::addDocument(IDocument *document, bool addWatcher) void DocumentManager::documentDestroyed(QObject *obj) { - IDocument *document = static_cast<IDocument*>(obj); + auto document = static_cast<IDocument*>(obj); // Check the special unwatched first: if (!d->m_documentsWithoutWatch.removeOne(document)) removeFileInfo(document); @@ -487,7 +487,7 @@ bool DocumentManager::removeDocument(IDocument *document) because the file was saved under different name. */ void DocumentManager::checkForNewFileName() { - IDocument *document = qobject_cast<IDocument *>(sender()); + auto document = qobject_cast<IDocument *>(sender()); // We modified the IDocument // Trust the other code to also update the m_states map if (document == d->m_blockedIDocument) @@ -720,7 +720,7 @@ bool DocumentManager::saveDocument(IDocument *document, const QString &fileName, return ret; } -QString DocumentManager::allDocumentFactoryFiltersString(QString *allFilesFilter = 0) +QString DocumentManager::allDocumentFactoryFiltersString(QString *allFilesFilter = nullptr) { QSet<QString> uniqueFilters; diff --git a/src/plugins/coreplugin/documentmanager.h b/src/plugins/coreplugin/documentmanager.h index b74734ac3c..038cad8b18 100644 --- a/src/plugins/coreplugin/documentmanager.h +++ b/src/plugins/coreplugin/documentmanager.h @@ -54,7 +54,7 @@ public: KeepLinks }; - typedef QPair<QString, Id> RecentFile; + using RecentFile = QPair<QString, Id>; static DocumentManager *instance(); diff --git a/src/plugins/coreplugin/editmode.cpp b/src/plugins/coreplugin/editmode.cpp index eb4522d65a..c3d47d291c 100644 --- a/src/plugins/coreplugin/editmode.cpp +++ b/src/plugins/coreplugin/editmode.cpp @@ -61,13 +61,13 @@ EditMode::EditMode() : auto editorPlaceHolder = new EditorManagerPlaceHolder; m_rightSplitWidgetLayout->insertWidget(0, editorPlaceHolder); - MiniSplitter *rightPaneSplitter = new MiniSplitter; + auto rightPaneSplitter = new MiniSplitter; rightPaneSplitter->insertWidget(0, rightSplitWidget); rightPaneSplitter->insertWidget(1, new RightPanePlaceHolder(Constants::MODE_EDIT)); rightPaneSplitter->setStretchFactor(0, 1); rightPaneSplitter->setStretchFactor(1, 0); - MiniSplitter *splitter = new MiniSplitter; + auto splitter = new MiniSplitter; splitter->setOrientation(Qt::Vertical); splitter->insertWidget(0, rightPaneSplitter); QWidget *outputPane = new OutputPanePlaceHolder(Constants::MODE_EDIT, splitter); @@ -87,7 +87,7 @@ EditMode::EditMode() : this, &EditMode::grabEditorManager); m_splitter->setFocusProxy(editorPlaceHolder); - IContext *modeContextObject = new IContext(this); + auto modeContextObject = new IContext(this); modeContextObject->setContext(Context(Constants::C_EDITORMANAGER)); modeContextObject->setWidget(m_splitter); ICore::addContextObject(modeContextObject); diff --git a/src/plugins/coreplugin/editmode.h b/src/plugins/coreplugin/editmode.h index d11ab206e4..4bce114511 100644 --- a/src/plugins/coreplugin/editmode.h +++ b/src/plugins/coreplugin/editmode.h @@ -44,7 +44,7 @@ class EditMode : public IMode public: EditMode(); - ~EditMode(); + ~EditMode() override; private: void grabEditorManager(Id mode); diff --git a/src/plugins/coreplugin/editormanager/documentmodel.cpp b/src/plugins/coreplugin/editormanager/documentmodel.cpp index 7ca7ff5f0b..dcf6a0eb0a 100644 --- a/src/plugins/coreplugin/editormanager/documentmodel.cpp +++ b/src/plugins/coreplugin/editormanager/documentmodel.cpp @@ -295,7 +295,7 @@ QVariant DocumentModelPrivate::data(const QModelIndex &index, int role) const void DocumentModelPrivate::itemChanged() { - IDocument *document = qobject_cast<IDocument *>(sender()); + auto document = qobject_cast<IDocument *>(sender()); const Utils::optional<int> idx = indexOfDocument(document); if (!idx) @@ -439,7 +439,7 @@ void DocumentModelPrivate::DynamicEntry::setNumberedName(int number) } // Internal DocumentModel::Entry::Entry() : - document(0), + document(nullptr), isSuspended(false) { } @@ -450,9 +450,7 @@ DocumentModel::Entry::~Entry() delete document; } -DocumentModel::DocumentModel() -{ -} +DocumentModel::DocumentModel() = default; void DocumentModel::init() { @@ -561,7 +559,7 @@ DocumentModel::Entry *DocumentModel::entryAtRow(int row) { int entryIndex = row - 1/*<no document>*/; if (entryIndex < 0) - return 0; + return nullptr; return d->m_entries[entryIndex]; } diff --git a/src/plugins/coreplugin/editormanager/documentmodel_p.h b/src/plugins/coreplugin/editormanager/documentmodel_p.h index ae6ff016fa..10f8ebfb4d 100644 --- a/src/plugins/coreplugin/editormanager/documentmodel_p.h +++ b/src/plugins/coreplugin/editormanager/documentmodel_p.h @@ -42,7 +42,7 @@ class DocumentModelPrivate : public QAbstractItemModel Q_OBJECT public: - ~DocumentModelPrivate(); + ~DocumentModelPrivate() override; int columnCount(const QModelIndex &parent = QModelIndex()) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index 2abb16ccd4..f33143bc40 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -665,9 +665,9 @@ IEditor *EditorManagerPrivate::openEditor(EditorView *view, const QString &fileN IEditorFactory *selectedFactory = nullptr; if (!factories.isEmpty()) { - QPushButton *button = qobject_cast<QPushButton *>(msgbox.button(QMessageBox::Open)); + auto button = qobject_cast<QPushButton *>(msgbox.button(QMessageBox::Open)); QTC_ASSERT(button, return nullptr); - QMenu *menu = new QMenu(button); + auto menu = new QMenu(button); foreach (IEditorFactory *factory, factories) { QAction *action = menu->addAction(factory->displayName()); connect(action, &QAction::triggered, &msgbox, [&selectedFactory, factory, &msgbox]() { @@ -785,7 +785,7 @@ EditorView *EditorManagerPrivate::viewForEditor(IEditor *editor) QWidget *w = editor->widget(); while (w) { w = w->parentWidget(); - if (EditorView *view = qobject_cast<EditorView *>(w)) + if (auto view = qobject_cast<EditorView *>(w)) return view; } return nullptr; @@ -1566,7 +1566,7 @@ EditorArea *EditorManagerPrivate::findEditorArea(const EditorView *view, int *ar { SplitterOrView *current = view->parentSplitterOrView(); while (current) { - if (EditorArea *area = qobject_cast<EditorArea *>(current)) { + if (auto area = qobject_cast<EditorArea *>(current)) { int index = d->m_editorAreas.indexOf(area); QTC_ASSERT(index >= 0, return nullptr); if (areaIndex) @@ -1980,7 +1980,7 @@ void EditorManagerPrivate::vcsOpenCurrentEditor() void EditorManagerPrivate::handleDocumentStateChange() { updateActions(); - IDocument *document = qobject_cast<IDocument *>(sender()); + auto document = qobject_cast<IDocument *>(sender()); if (!document->isModified()) document->removeAutoSaveFile(); if (EditorManager::currentDocument() == document) @@ -2082,7 +2082,7 @@ void EditorManagerPrivate::copyFilePathFromContextMenu() void EditorManagerPrivate::copyLocationFromContextMenu() { - const QAction *action = qobject_cast<const QAction *>(sender()); + const auto action = qobject_cast<const QAction *>(sender()); if (!d->m_contextMenuEntry || !action) return; const QString text = d->m_contextMenuEntry->fileName().toUserOutput() @@ -2501,8 +2501,8 @@ void EditorManager::addNativeDirAndOpenWithActions(QMenu *contextMenu, DocumentM void EditorManager::populateOpenWithMenu(QMenu *menu, const QString &fileName) { - typedef QList<IEditorFactory*> EditorFactoryList; - typedef QList<IExternalEditor*> ExternalEditorList; + using EditorFactoryList = QList<IEditorFactory*>; + using ExternalEditorList = QList<IExternalEditor*>; menu->clear(); diff --git a/src/plugins/coreplugin/editormanager/editormanager.h b/src/plugins/coreplugin/editormanager/editormanager.h index 0da42f8be1..30023e2bc7 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.h +++ b/src/plugins/coreplugin/editormanager/editormanager.h @@ -75,7 +75,7 @@ class CORE_EXPORT EditorManager : public QObject Q_OBJECT public: - typedef std::function<QString (const QString &)> WindowTitleHandler; + using WindowTitleHandler = std::function<QString (const QString &)>; static EditorManager *instance(); diff --git a/src/plugins/coreplugin/editormanager/editorview.cpp b/src/plugins/coreplugin/editormanager/editorview.cpp index 1394572c57..aea929a3aa 100644 --- a/src/plugins/coreplugin/editormanager/editorview.cpp +++ b/src/plugins/coreplugin/editormanager/editorview.cpp @@ -68,10 +68,9 @@ EditorView::EditorView(SplitterOrView *parentSplitterOrView, QWidget *parent) : m_container(new QStackedWidget(this)), m_infoBarDisplay(new InfoBarDisplay(this)), m_statusHLine(new QFrame(this)), - m_statusWidget(new QFrame(this)), - m_currentNavigationHistoryPosition(0) + m_statusWidget(new QFrame(this)) { - QVBoxLayout *tl = new QVBoxLayout(this); + auto tl = new QVBoxLayout(this); tl->setSpacing(0); tl->setMargin(0); { @@ -106,7 +105,7 @@ EditorView::EditorView(SplitterOrView *parentSplitterOrView, QWidget *parent) : m_statusWidget->setLineWidth(0); m_statusWidget->setAutoFillBackground(true); - QHBoxLayout *hbox = new QHBoxLayout(m_statusWidget); + auto hbox = new QHBoxLayout(m_statusWidget); hbox->setContentsMargins(1, 0, 1, 1); m_statusWidgetLabel = new QLabel; m_statusWidgetLabel->setContentsMargins(3, 0, 3, 0); @@ -153,9 +152,7 @@ EditorView::EditorView(SplitterOrView *parentSplitterOrView, QWidget *parent) : updateNavigatorActions(); } -EditorView::~EditorView() -{ -} +EditorView::~EditorView() = default; SplitterOrView *EditorView::parentSplitterOrView() const { @@ -173,7 +170,7 @@ EditorView *EditorView::findNextView() QTC_ASSERT(splitter->count() == 2, return nullptr); // is current the first child? then the next view is the first one in current's sibling if (splitter->widget(0) == current) { - SplitterOrView *second = qobject_cast<SplitterOrView *>(splitter->widget(1)); + auto second = qobject_cast<SplitterOrView *>(splitter->widget(1)); QTC_ASSERT(second, return nullptr); return second->findFirstView(); } @@ -196,7 +193,7 @@ EditorView *EditorView::findPreviousView() QTC_ASSERT(splitter->count() == 2, return nullptr); // is current the last child? then the previous view is the first child in current's sibling if (splitter->widget(1) == current) { - SplitterOrView *first = qobject_cast<SplitterOrView *>(splitter->widget(0)); + auto first = qobject_cast<SplitterOrView *>(splitter->widget(0)); QTC_ASSERT(first, return nullptr); return first->findFirstView(); } @@ -652,7 +649,7 @@ EditorView *SplitterOrView::findFirstView() { if (m_splitter) { for (int i = 0; i < m_splitter->count(); ++i) { - if (SplitterOrView *splitterOrView = qobject_cast<SplitterOrView*>(m_splitter->widget(i))) + if (auto splitterOrView = qobject_cast<SplitterOrView*>(m_splitter->widget(i))) if (EditorView *result = splitterOrView->findFirstView()) return result; } @@ -665,7 +662,7 @@ EditorView *SplitterOrView::findLastView() { if (m_splitter) { for (int i = m_splitter->count() - 1; 0 < i; --i) { - if (SplitterOrView *splitterOrView = qobject_cast<SplitterOrView*>(m_splitter->widget(i))) + if (auto splitterOrView = qobject_cast<SplitterOrView*>(m_splitter->widget(i))) if (EditorView *result = splitterOrView->findLastView()) return result; } @@ -678,7 +675,7 @@ SplitterOrView *SplitterOrView::findParentSplitter() const { QWidget *w = parentWidget(); while (w) { - if (SplitterOrView *splitter = qobject_cast<SplitterOrView *>(w)) { + if (auto splitter = qobject_cast<SplitterOrView *>(w)) { QTC_CHECK(splitter->splitter()); return splitter; } @@ -801,7 +798,7 @@ const QList<IEditor *> SplitterOrView::unsplitAll_helper() QList<IEditor *> editorsToDelete; if (m_splitter) { for (int i = 0; i < m_splitter->count(); ++i) { - if (SplitterOrView *splitterOrView = qobject_cast<SplitterOrView*>(m_splitter->widget(i))) + if (auto splitterOrView = qobject_cast<SplitterOrView*>(m_splitter->widget(i))) editorsToDelete.append(splitterOrView->unsplitAll_helper()); } } @@ -814,7 +811,7 @@ void SplitterOrView::unsplit() return; Q_ASSERT(m_splitter->count() == 1); - SplitterOrView *childSplitterOrView = qobject_cast<SplitterOrView*>(m_splitter->widget(0)); + auto childSplitterOrView = qobject_cast<SplitterOrView*>(m_splitter->widget(0)); QSplitter *oldSplitter = m_splitter; m_splitter = nullptr; QList<IEditor *> editorsToDelete; @@ -838,7 +835,7 @@ void SplitterOrView::unsplit() m_view = childSplitterOrView->takeView(); m_view->setParentSplitterOrView(this); m_layout->addWidget(m_view); - QSplitter *parentSplitter = qobject_cast<QSplitter *>(parentWidget()); + auto parentSplitter = qobject_cast<QSplitter *>(parentWidget()); if (parentSplitter) { // not the toplevel splitterOrView if (parentSplitter->orientation() == Qt::Horizontal) m_view->setCloseSplitIcon(parentSplitter->widget(0) == this ? diff --git a/src/plugins/coreplugin/editormanager/editorview.h b/src/plugins/coreplugin/editormanager/editorview.h index 457df776e5..245c140f06 100644 --- a/src/plugins/coreplugin/editormanager/editorview.h +++ b/src/plugins/coreplugin/editormanager/editorview.h @@ -142,7 +142,7 @@ private: QList<EditLocation> m_navigationHistory; QList<EditLocation> m_editorHistory; - int m_currentNavigationHistoryPosition; + int m_currentNavigationHistoryPosition = 0; void updateCurrentPositionInNavigationHistory(); public: diff --git a/src/plugins/coreplugin/editormanager/editorwindow.cpp b/src/plugins/coreplugin/editormanager/editorwindow.cpp index 84666e115c..28cf1f9525 100644 --- a/src/plugins/coreplugin/editormanager/editorwindow.cpp +++ b/src/plugins/coreplugin/editormanager/editorwindow.cpp @@ -82,7 +82,7 @@ EditorWindow::EditorWindow(QWidget *parent) : EditorWindow::~EditorWindow() { if (m_area) - disconnect(m_area, 0, this, 0); + disconnect(m_area, nullptr, this, nullptr); } EditorArea *EditorWindow::editorArea() const diff --git a/src/plugins/coreplugin/editormanager/editorwindow.h b/src/plugins/coreplugin/editormanager/editorwindow.h index 2327e0145f..d17aeb27f3 100644 --- a/src/plugins/coreplugin/editormanager/editorwindow.h +++ b/src/plugins/coreplugin/editormanager/editorwindow.h @@ -36,8 +36,8 @@ class EditorWindow : public QWidget { Q_OBJECT public: - explicit EditorWindow(QWidget *parent = 0); - ~EditorWindow(); + explicit EditorWindow(QWidget *parent = nullptr); + ~EditorWindow() override; EditorArea *editorArea() const; diff --git a/src/plugins/coreplugin/editormanager/openeditorsview.cpp b/src/plugins/coreplugin/editormanager/openeditorsview.cpp index 1a7e0d618c..234fe28e5a 100644 --- a/src/plugins/coreplugin/editormanager/openeditorsview.cpp +++ b/src/plugins/coreplugin/editormanager/openeditorsview.cpp @@ -65,9 +65,7 @@ OpenEditorsWidget::OpenEditorsWidget() this, &OpenEditorsWidget::contextMenuRequested); } -OpenEditorsWidget::~OpenEditorsWidget() -{ -} +OpenEditorsWidget::~OpenEditorsWidget() = default; void OpenEditorsWidget::updateCurrentItem(IEditor *editor) { @@ -93,7 +91,7 @@ void OpenEditorsWidget::handleActivated(const QModelIndex &index) // work around a bug in itemviews where the delegate wouldn't get the QStyle::State_MouseOver QPoint cursorPos = QCursor::pos(); QWidget *vp = viewport(); - QMouseEvent e(QEvent::MouseMove, vp->mapFromGlobal(cursorPos), cursorPos, Qt::NoButton, 0, 0); + QMouseEvent e(QEvent::MouseMove, vp->mapFromGlobal(cursorPos), cursorPos, Qt::NoButton, nullptr, nullptr); QCoreApplication::sendEvent(vp, &e); } } diff --git a/src/plugins/coreplugin/editormanager/openeditorsview.h b/src/plugins/coreplugin/editormanager/openeditorsview.h index fbde103154..f50a50e3dd 100644 --- a/src/plugins/coreplugin/editormanager/openeditorsview.h +++ b/src/plugins/coreplugin/editormanager/openeditorsview.h @@ -39,7 +39,7 @@ class ProxyModel : public QAbstractProxyModel { Q_OBJECT public: - explicit ProxyModel(QObject *parent = 0); + explicit ProxyModel(QObject *parent = nullptr); QModelIndex mapFromSource(const QModelIndex & sourceIndex) const override; QModelIndex mapToSource(const QModelIndex & proxyIndex) const override; @@ -69,7 +69,7 @@ class OpenEditorsWidget : public OpenDocumentsTreeView public: OpenEditorsWidget(); - ~OpenEditorsWidget(); + ~OpenEditorsWidget() override; private: void handleActivated(const QModelIndex &); @@ -88,7 +88,7 @@ class OpenEditorsViewFactory : public INavigationWidgetFactory public: OpenEditorsViewFactory(); - NavigationView createWidget(); + NavigationView createWidget() override; }; } // namespace Internal diff --git a/src/plugins/coreplugin/editormanager/openeditorswindow.cpp b/src/plugins/coreplugin/editormanager/openeditorswindow.cpp index f937f43663..d766531f51 100644 --- a/src/plugins/coreplugin/editormanager/openeditorswindow.cpp +++ b/src/plugins/coreplugin/editormanager/openeditorswindow.cpp @@ -72,7 +72,7 @@ OpenEditorsWindow::OpenEditorsWindow(QWidget *parent) : setFrameStyle(m_editorList->frameStyle()); m_editorList->setFrameStyle(QFrame::NoFrame); - QVBoxLayout *layout = new QVBoxLayout(this); + auto layout = new QVBoxLayout(this); layout->setMargin(0); layout->addWidget(m_editorList); @@ -97,7 +97,7 @@ bool OpenEditorsWindow::eventFilter(QObject *obj, QEvent *e) { if (obj == m_editorList) { if (e->type() == QEvent::KeyPress) { - QKeyEvent *ke = static_cast<QKeyEvent*>(e); + auto ke = static_cast<QKeyEvent*>(e); if (ke->key() == Qt::Key_Escape) { setVisible(false); return true; @@ -108,7 +108,7 @@ bool OpenEditorsWindow::eventFilter(QObject *obj, QEvent *e) return true; } } else if (e->type() == QEvent::KeyRelease) { - QKeyEvent *ke = static_cast<QKeyEvent*>(e); + auto ke = static_cast<QKeyEvent*>(e); if (ke->modifiers() == 0 /*HACK this is to overcome some event inconsistencies between platforms*/ || (ke->modifiers() == Qt::AltModifier @@ -133,7 +133,7 @@ void OpenEditorsWindow::selectUpDown(bool up) int index = m_editorList->indexOfTopLevelItem(m_editorList->currentItem()); if (index < 0) return; - QTreeWidgetItem *editor = 0; + QTreeWidgetItem *editor = nullptr; int count = 0; while (!editor && count < itemCount) { if (up) { @@ -245,7 +245,7 @@ void OpenEditorsWindow::addItem(DocumentModel::Entry *entry, entriesDone.insert(entry); QString title = entry->displayName(); QTC_ASSERT(!title.isEmpty(), return); - QTreeWidgetItem *item = new QTreeWidgetItem(); + auto item = new QTreeWidgetItem(); if (entry->document->isModified()) title += tr("*"); item->setIcon(0, !entry->fileName().isEmpty() && entry->document->isFileReadOnly() diff --git a/src/plugins/coreplugin/editormanager/openeditorswindow.h b/src/plugins/coreplugin/editormanager/openeditorswindow.h index 9bd769bf8c..4786620c16 100644 --- a/src/plugins/coreplugin/editormanager/openeditorswindow.h +++ b/src/plugins/coreplugin/editormanager/openeditorswindow.h @@ -45,9 +45,9 @@ namespace Internal { class OpenEditorsTreeWidget : public QTreeWidget { public: - explicit OpenEditorsTreeWidget(QWidget *parent = 0) : QTreeWidget(parent) {} - ~OpenEditorsTreeWidget() {} - QSize sizeHint() const; + explicit OpenEditorsTreeWidget(QWidget *parent = nullptr) : QTreeWidget(parent) {} + ~OpenEditorsTreeWidget() override = default; + QSize sizeHint() const override; }; @@ -58,16 +58,16 @@ class OpenEditorsWindow : public QFrame public: enum Mode {ListMode, HistoryMode }; - explicit OpenEditorsWindow(QWidget *parent = 0); + explicit OpenEditorsWindow(QWidget *parent = nullptr); void setEditors(const QList<EditLocation> &globalHistory, EditorView *view); - bool eventFilter(QObject *src, QEvent *e); - void focusInEvent(QFocusEvent *); - void setVisible(bool visible); + bool eventFilter(QObject *src, QEvent *e) override; + void focusInEvent(QFocusEvent*) override; + void setVisible(bool visible) override; void selectNextEditor(); void selectPreviousEditor(); - QSize sizeHint() const; + QSize sizeHint() const override; public slots: void selectAndHide(); diff --git a/src/plugins/coreplugin/editormanager/systemeditor.h b/src/plugins/coreplugin/editormanager/systemeditor.h index 1589dd21ce..10fb0dc949 100644 --- a/src/plugins/coreplugin/editormanager/systemeditor.h +++ b/src/plugins/coreplugin/editormanager/systemeditor.h @@ -35,13 +35,13 @@ class SystemEditor : public IExternalEditor Q_OBJECT public: - explicit SystemEditor(QObject *parent = 0); + explicit SystemEditor(QObject *parent = nullptr); - QStringList mimeTypes() const; - Id id() const; - QString displayName() const; + QStringList mimeTypes() const override; + Id id() const override; + QString displayName() const override; - bool startEditor(const QString &fileName, QString *errorMessage); + bool startEditor(const QString &fileName, QString *errorMessage) override; }; } // namespace Internal diff --git a/src/plugins/coreplugin/editortoolbar.cpp b/src/plugins/coreplugin/editortoolbar.cpp index 83384eb337..55430f1a42 100644 --- a/src/plugins/coreplugin/editortoolbar.cpp +++ b/src/plugins/coreplugin/editortoolbar.cpp @@ -93,7 +93,7 @@ EditorToolBarPrivate::EditorToolBarPrivate(QWidget *parent, EditorToolBar *q) : m_closeEditorButton(new QToolButton(q)), m_lockButton(new QToolButton(q)), m_dragHandle(new QToolButton(q)), - m_dragHandleMenu(0), + m_dragHandleMenu(nullptr), m_goBackAction(new QAction(Utils::Icons::PREV_TOOLBAR.icon(), EditorManager::tr("Go Back"), parent)), m_goForwardAction(new QAction(Utils::Icons::NEXT_TOOLBAR.icon(), EditorManager::tr("Go Forward"), parent)), m_backButton(new QToolButton(q)), @@ -105,7 +105,7 @@ EditorToolBarPrivate::EditorToolBarPrivate(QWidget *parent, EditorToolBar *q) : EditorManager::tr("Split Side by Side"), parent)), m_splitNewWindowAction(new QAction(EditorManager::tr("Open in New Window"), parent)), m_closeSplitButton(new QToolButton(q)), - m_activeToolBar(0), + m_activeToolBar(nullptr), m_toolBarPlaceholder(new QWidget(q)), m_defaultToolBar(new QWidget(q)), m_isStandalone(false) @@ -118,7 +118,7 @@ EditorToolBarPrivate::EditorToolBarPrivate(QWidget *parent, EditorToolBar *q) : EditorToolBar::EditorToolBar(QWidget *parent) : Utils::StyledBar(parent), d(new EditorToolBarPrivate(parent, this)) { - QHBoxLayout *toolBarLayout = new QHBoxLayout(this); + auto toolBarLayout = new QHBoxLayout(this); toolBarLayout->setMargin(0); toolBarLayout->setSpacing(0); toolBarLayout->addWidget(d->m_defaultToolBar); @@ -164,7 +164,7 @@ EditorToolBar::EditorToolBar(QWidget *parent) : d->m_splitButton->setToolTip(tr("Split")); d->m_splitButton->setPopupMode(QToolButton::InstantPopup); d->m_splitButton->setProperty("noArrow", true); - QMenu *splitMenu = new QMenu(d->m_splitButton); + auto splitMenu = new QMenu(d->m_splitButton); splitMenu->addAction(d->m_horizontalSplitAction); splitMenu->addAction(d->m_verticalSplitAction); splitMenu->addAction(d->m_splitNewWindowAction); @@ -173,7 +173,7 @@ EditorToolBar::EditorToolBar(QWidget *parent) : d->m_closeSplitButton->setAutoRaise(true); d->m_closeSplitButton->setIcon(Utils::Icons::CLOSE_SPLIT_BOTTOM.icon()); - QHBoxLayout *toplayout = new QHBoxLayout(this); + auto toplayout = new QHBoxLayout(this); toplayout->setSpacing(0); toplayout->setMargin(0); toplayout->addWidget(d->m_backButton); @@ -236,14 +236,14 @@ void EditorToolBar::removeToolbarForEditor(IEditor *editor) disconnect(editor->document(), &IDocument::changed, this, &EditorToolBar::checkDocumentStatus); QWidget *toolBar = editor->toolBar(); - if (toolBar != 0) { + if (toolBar != nullptr) { if (d->m_activeToolBar == toolBar) { d->m_activeToolBar = d->m_defaultToolBar; d->m_activeToolBar->setVisible(true); } d->m_toolBarPlaceholder->layout()->removeWidget(toolBar); toolBar->setVisible(false); - toolBar->setParent(0); + toolBar->setParent(nullptr); } } @@ -319,7 +319,7 @@ void EditorToolBar::setMenuProvider(const EditorToolBar::MenuProvider &provider) void EditorToolBar::setCurrentEditor(IEditor *editor) { - IDocument *document = editor ? editor->document() : 0; + IDocument *document = editor ? editor->document() : nullptr; const Utils::optional<int> index = DocumentModel::rowOfDocument(document); if (QTC_GUARD(index)) d->m_editorList->setCurrentIndex(*index); @@ -327,7 +327,7 @@ void EditorToolBar::setCurrentEditor(IEditor *editor) // If we never added the toolbar from the editor, we will never change // the editor, so there's no need to update the toolbar either. if (!d->m_isStandalone) - updateToolBar(editor ? editor->toolBar() : 0); + updateToolBar(editor ? editor->toolBar() : nullptr); updateDocumentStatus(document); } @@ -353,7 +353,7 @@ void EditorToolBar::fillListContextMenu(QMenu *menu) } else { IEditor *editor = EditorManager::currentEditor(); DocumentModel::Entry *entry = editor ? DocumentModel::entryForDocument(editor->document()) - : 0; + : nullptr; EditorManager::addSaveAndCloseEditorActions(menu, entry, editor); menu->addSeparator(); EditorManager::addNativeDirAndOpenWithActions(menu, entry); @@ -386,7 +386,7 @@ void EditorToolBar::updateActionShortcuts() void EditorToolBar::checkDocumentStatus() { - IDocument *document = qobject_cast<IDocument *>(sender()); + auto document = qobject_cast<IDocument *>(sender()); QTC_ASSERT(document, return); DocumentModel::Entry *entry = DocumentModel::entryAtRow( d->m_editorList->currentIndex()); @@ -397,7 +397,7 @@ void EditorToolBar::checkDocumentStatus() void EditorToolBar::updateDocumentStatus(IDocument *document) { - d->m_closeEditorButton->setEnabled(document != 0); + d->m_closeEditorButton->setEnabled(document != nullptr); if (!document) { d->m_lockButton->setIcon(QIcon()); diff --git a/src/plugins/coreplugin/editortoolbar.h b/src/plugins/coreplugin/editortoolbar.h index 1d0c49ffdf..b8d7fad468 100644 --- a/src/plugins/coreplugin/editortoolbar.h +++ b/src/plugins/coreplugin/editortoolbar.h @@ -53,7 +53,7 @@ public: explicit EditorToolBar(QWidget *parent = nullptr); ~EditorToolBar() override; - typedef std::function<void(QMenu*)> MenuProvider; + using MenuProvider = std::function<void(QMenu*)>; enum ToolbarCreationFlags { FlagsNone = 0, FlagsStandalone = 1 }; /** diff --git a/src/plugins/coreplugin/externaltool.cpp b/src/plugins/coreplugin/externaltool.cpp index 08e3ecc29b..1b61747dd2 100644 --- a/src/plugins/coreplugin/externaltool.cpp +++ b/src/plugins/coreplugin/externaltool.cpp @@ -81,11 +81,7 @@ const char kFalse[] = "false"; // #pragma mark -- ExternalTool ExternalTool::ExternalTool() : - m_displayCategory(QLatin1String("")), // difference between isNull and isEmpty - m_order(-1), - m_outputHandling(ShowInPane), - m_errorHandling(ShowInPane), - m_modifiesCurrentDocument(false) + m_displayCategory(QLatin1String("")) // difference between isNull and isEmpty { } @@ -129,9 +125,7 @@ ExternalTool &ExternalTool::operator=(const ExternalTool &other) return *this; } -ExternalTool::~ExternalTool() -{ -} +ExternalTool::~ExternalTool() = default; QString ExternalTool::id() const { @@ -354,7 +348,7 @@ ExternalTool * ExternalTool::createFromXml(const QByteArray &xml, QString *error int nameLocale = -1; int categoryLocale = -1; const QStringList &locales = splitLocale(locale); - ExternalTool *tool = new ExternalTool; + auto tool = new ExternalTool; QXmlStreamReader reader(xml); if (!reader.readNextStartElement() || reader.name() != QLatin1String(kExternalTool)) @@ -442,7 +436,7 @@ ExternalTool * ExternalTool::createFromXml(const QByteArray &xml, QString *error if (errorMessage) *errorMessage = reader.errorString(); delete tool; - return 0; + return nullptr; } return tool; } @@ -452,10 +446,10 @@ ExternalTool * ExternalTool::createFromFile(const QString &fileName, QString *er QString absFileName = QFileInfo(fileName).absoluteFilePath(); FileReader reader; if (!reader.fetch(absFileName, errorMessage)) - return 0; + return nullptr; ExternalTool *tool = ExternalTool::createFromXml(reader.data(), errorMessage, locale); if (!tool) - return 0; + return nullptr; tool->m_fileName = absFileName; return tool; } @@ -541,7 +535,7 @@ bool ExternalTool::operator==(const ExternalTool &other) const ExternalToolRunner::ExternalToolRunner(const ExternalTool *tool) : m_tool(new ExternalTool(tool)), - m_process(0), + m_process(nullptr), m_outputCodec(QTextCodec::codecForLocale()), m_hasError(false) { diff --git a/src/plugins/coreplugin/externaltool.h b/src/plugins/coreplugin/externaltool.h index e284de3e91..b511b9e0e2 100644 --- a/src/plugins/coreplugin/externaltool.h +++ b/src/plugins/coreplugin/externaltool.h @@ -103,15 +103,15 @@ private: QString m_description; QString m_displayName; QString m_displayCategory; - int m_order; + int m_order = -1; QStringList m_executables; QString m_arguments; QString m_input; QString m_workingDirectory; QList<Utils::EnvironmentItem> m_environment; - OutputHandling m_outputHandling; - OutputHandling m_errorHandling; - bool m_modifiesCurrentDocument; + OutputHandling m_outputHandling = ShowInPane; + OutputHandling m_errorHandling = ShowInPane; + bool m_modifiesCurrentDocument = false; QString m_fileName; QString m_presetFileName; diff --git a/src/plugins/coreplugin/externaltoolmanager.cpp b/src/plugins/coreplugin/externaltoolmanager.cpp index 80d98243b6..1ba8a04acb 100644 --- a/src/plugins/coreplugin/externaltoolmanager.cpp +++ b/src/plugins/coreplugin/externaltoolmanager.cpp @@ -56,8 +56,8 @@ struct ExternalToolManagerPrivate QAction *m_configureAction; }; -static ExternalToolManager *m_instance = 0; -static ExternalToolManagerPrivate *d = 0; +static ExternalToolManager *m_instance = nullptr; +static ExternalToolManagerPrivate *d = nullptr; static void writeSettings(); static void readSettings(const QMap<QString, ExternalTool *> &tools, @@ -211,7 +211,7 @@ void ExternalToolManager::setToolsByCategory(const QMap<QString, QList<ExternalT it.toFront(); while (it.hasNext()) { it.next(); - ActionContainer *container = 0; + ActionContainer *container = nullptr; const QString &containerName = it.key(); if (containerName.isEmpty()) { // no displayCategory, so put into external tools menu directly container = mexternaltools; @@ -227,8 +227,8 @@ void ExternalToolManager::setToolsByCategory(const QMap<QString, QList<ExternalT foreach (ExternalTool *tool, it.value()) { const QString &toolId = tool->id(); // tool action and command - QAction *action = 0; - Command *command = 0; + QAction *action = nullptr; + Command *command = nullptr; if (d->m_actions.contains(toolId)) { action = d->m_actions.value(toolId); command = ActionManager::command(externalToolsPrefix.withSuffix(toolId)); @@ -236,7 +236,7 @@ void ExternalToolManager::setToolsByCategory(const QMap<QString, QList<ExternalT action = new QAction(tool->displayName(), m_instance); d->m_actions.insert(toolId, action); connect(action, &QAction::triggered, [tool] { - ExternalToolRunner *runner = new ExternalToolRunner(tool); + auto runner = new ExternalToolRunner(tool); if (runner->hasError()) MessageManager::write(runner->errorString()); }); diff --git a/src/plugins/coreplugin/find/basetextfind.cpp b/src/plugins/coreplugin/find/basetextfind.cpp index f0b3ad64c3..b9c38b3a5e 100644 --- a/src/plugins/coreplugin/find/basetextfind.cpp +++ b/src/plugins/coreplugin/find/basetextfind.cpp @@ -111,7 +111,7 @@ void BaseTextFind::setTextCursor(const QTextCursor &cursor) QTextDocument *BaseTextFind::document() const { - QTC_ASSERT(d->m_editor || d->m_plaineditor, return 0); + QTC_ASSERT(d->m_editor || d->m_plaineditor, return nullptr); return d->m_editor ? d->m_editor->document() : d->m_plaineditor->document(); } @@ -140,7 +140,7 @@ void BaseTextFind::resetIncrementalSearch() void BaseTextFind::clearHighlights() { - highlightAll(QString(), 0); + highlightAll(QString(), nullptr); } QString BaseTextFind::currentFindString() const @@ -191,7 +191,7 @@ IFindSupport::Result BaseTextFind::findIncremental(const QString &txt, FindFlags if (found) highlightAll(txt, findFlags); else - highlightAll(QString(), 0); + highlightAll(QString(), nullptr); return found ? Found : NotFound; } diff --git a/src/plugins/coreplugin/find/currentdocumentfind.cpp b/src/plugins/coreplugin/find/currentdocumentfind.cpp index eca3527bac..834b651ce7 100644 --- a/src/plugins/coreplugin/find/currentdocumentfind.cpp +++ b/src/plugins/coreplugin/find/currentdocumentfind.cpp @@ -40,7 +40,7 @@ using namespace Core; using namespace Core::Internal; CurrentDocumentFind::CurrentDocumentFind() - : m_currentFind(0) + : m_currentFind(nullptr) { connect(qApp, &QApplication::focusChanged, this, &CurrentDocumentFind::updateCandidateFindFilter); @@ -48,7 +48,7 @@ CurrentDocumentFind::CurrentDocumentFind() void CurrentDocumentFind::removeConnections() { - disconnect(qApp, 0, this, 0); + disconnect(qApp, nullptr, this, nullptr); removeFindSupportConnections(); } @@ -82,7 +82,7 @@ bool CurrentDocumentFind::supportsReplace() const FindFlags CurrentDocumentFind::supportedFindFlags() const { - QTC_ASSERT(m_currentFind, return 0); + QTC_ASSERT(m_currentFind, return nullptr); return m_currentFind->supportedFindFlags(); } @@ -134,7 +134,7 @@ int CurrentDocumentFind::replaceAll(const QString &before, const QString &after, QTC_CHECK(m_currentWidget); int count = m_currentFind->replaceAll(before, after, findFlags); Utils::FadingIndicator::showText(m_currentWidget, - tr("%n occurrences replaced.", 0, count), + tr("%n occurrences replaced.", nullptr, count), Utils::FadingIndicator::SmallText); return count; } @@ -155,7 +155,7 @@ void CurrentDocumentFind::updateCandidateFindFilter(QWidget *old, QWidget *now) { Q_UNUSED(old) QWidget *candidate = now; - QPointer<IFindSupport> impl = 0; + QPointer<IFindSupport> impl = nullptr; while (!impl && candidate) { impl = Aggregation::query<IFindSupport>(candidate); if (!impl) @@ -215,8 +215,8 @@ void CurrentDocumentFind::removeFindSupportConnections() void CurrentDocumentFind::clearFindSupport() { removeFindSupportConnections(); - m_currentWidget = 0; - m_currentFind = 0; + m_currentWidget = nullptr; + m_currentFind = nullptr; emit changed(); } diff --git a/src/plugins/coreplugin/find/currentdocumentfind.h b/src/plugins/coreplugin/find/currentdocumentfind.h index a0d40d8706..32aa5b97f8 100644 --- a/src/plugins/coreplugin/find/currentdocumentfind.h +++ b/src/plugins/coreplugin/find/currentdocumentfind.h @@ -61,7 +61,7 @@ public: void removeConnections(); bool setFocusToCurrentFindSupport(); - bool eventFilter(QObject *obj, QEvent *event); + bool eventFilter(QObject *obj, QEvent *event) override; signals: void changed(); diff --git a/src/plugins/coreplugin/find/findplugin.cpp b/src/plugins/coreplugin/find/findplugin.cpp index dad9776247..3fcc8fa14b 100644 --- a/src/plugins/coreplugin/find/findplugin.cpp +++ b/src/plugins/coreplugin/find/findplugin.cpp @@ -181,24 +181,24 @@ public: void setupFilterMenuItems(); void readSettings(); - Internal::CurrentDocumentFind *m_currentDocumentFind = 0; - Internal::FindToolBar *m_findToolBar = 0; - Internal::FindToolWindow *m_findDialog = 0; - SearchResultWindow *m_searchResultWindow = 0; + Internal::CurrentDocumentFind *m_currentDocumentFind = nullptr; + Internal::FindToolBar *m_findToolBar = nullptr; + Internal::FindToolWindow *m_findDialog = nullptr; + SearchResultWindow *m_searchResultWindow = nullptr; FindFlags m_findFlags; CompletionModel m_findCompletionModel; QStringListModel m_replaceCompletionModel; QStringList m_replaceCompletions; - QAction *m_openFindDialog = 0; + QAction *m_openFindDialog = nullptr; }; -Find *m_instance = 0; -FindPrivate *d = 0; +Find *m_instance = nullptr; +FindPrivate *d = nullptr; void Find::destroy() { delete m_instance; - m_instance = 0; + m_instance = nullptr; if (d) { delete d->m_currentDocumentFind; delete d->m_findToolBar; @@ -245,7 +245,7 @@ void Find::extensionsInitialized() void Find::aboutToShutdown() { d->m_findToolBar->setVisible(false); - d->m_findToolBar->setParent(0); + d->m_findToolBar->setParent(nullptr); d->m_currentDocumentFind->removeConnections(); } diff --git a/src/plugins/coreplugin/find/findtoolbar.cpp b/src/plugins/coreplugin/find/findtoolbar.cpp index 793b2990f8..e1aee5b9a7 100644 --- a/src/plugins/coreplugin/find/findtoolbar.cpp +++ b/src/plugins/coreplugin/find/findtoolbar.cpp @@ -121,26 +121,26 @@ FindToolBar::FindToolBar(CurrentDocumentFind *currentDocumentFind) static_cast<void (QCompleter::*)(const QModelIndex &)>(&QCompleter::activated), this, &FindToolBar::findCompleterActivated); - QAction *shiftEnterAction = new QAction(m_ui.findEdit); + auto shiftEnterAction = new QAction(m_ui.findEdit); shiftEnterAction->setShortcut(QKeySequence(tr("Shift+Enter"))); shiftEnterAction->setShortcutContext(Qt::WidgetShortcut); connect(shiftEnterAction, &QAction::triggered, this, &FindToolBar::invokeFindPrevious); m_ui.findEdit->addAction(shiftEnterAction); - QAction *shiftReturnAction = new QAction(m_ui.findEdit); + auto shiftReturnAction = new QAction(m_ui.findEdit); shiftReturnAction->setShortcut(QKeySequence(tr("Shift+Return"))); shiftReturnAction->setShortcutContext(Qt::WidgetShortcut); connect(shiftReturnAction, &QAction::triggered, this, &FindToolBar::invokeFindPrevious); m_ui.findEdit->addAction(shiftReturnAction); - QAction *shiftEnterReplaceAction = new QAction(m_ui.replaceEdit); + auto shiftEnterReplaceAction = new QAction(m_ui.replaceEdit); shiftEnterReplaceAction->setShortcut(QKeySequence(tr("Shift+Enter"))); shiftEnterReplaceAction->setShortcutContext(Qt::WidgetShortcut); connect(shiftEnterReplaceAction, &QAction::triggered, this, &FindToolBar::invokeReplacePrevious); m_ui.replaceEdit->addAction(shiftEnterReplaceAction); - QAction *shiftReturnReplaceAction = new QAction(m_ui.replaceEdit); + auto shiftReturnReplaceAction = new QAction(m_ui.replaceEdit); shiftReturnReplaceAction->setShortcut(QKeySequence(tr("Shift+Return"))); shiftReturnReplaceAction->setShortcutContext(Qt::WidgetShortcut); connect(shiftReturnReplaceAction, &QAction::triggered, @@ -313,9 +313,7 @@ FindToolBar::FindToolBar(CurrentDocumentFind *currentDocumentFind) connect(&m_findStepTimer, &QTimer::timeout, this, &FindToolBar::invokeFindStep); } -FindToolBar::~FindToolBar() -{ -} +FindToolBar::~FindToolBar() = default; void FindToolBar::findCompleterActivated(const QModelIndex &index) { @@ -342,7 +340,7 @@ void FindToolBar::installEventFilters() bool FindToolBar::eventFilter(QObject *obj, QEvent *event) { if (event->type() == QEvent::KeyPress) { - QKeyEvent *ke = static_cast<QKeyEvent *>(event); + auto ke = static_cast<QKeyEvent *>(event); if (ke->key() == Qt::Key_Down) { if (obj == m_ui.findEdit) { if (m_ui.findEdit->text().isEmpty()) @@ -358,7 +356,7 @@ bool FindToolBar::eventFilter(QObject *obj, QEvent *event) if ((obj == m_ui.findEdit || obj == m_findCompleter->popup()) && event->type() == QEvent::KeyPress) { - QKeyEvent *ke = static_cast<QKeyEvent *>(event); + auto ke = static_cast<QKeyEvent *>(event); if (ke->key() == Qt::Key_Space && (ke->modifiers() & Utils::HostOsInfo::controlModifier())) { QString completedText = m_currentDocumentFind->completedFindString(); if (!completedText.isEmpty()) { @@ -368,7 +366,7 @@ bool FindToolBar::eventFilter(QObject *obj, QEvent *event) } } } else if (obj == this && event->type() == QEvent::ShortcutOverride) { - QKeyEvent *ke = static_cast<QKeyEvent *>(event); + auto ke = static_cast<QKeyEvent *>(event); if (ke->key() == Qt::Key_Space && (ke->modifiers() & Utils::HostOsInfo::controlModifier())) { event->accept(); return true; @@ -394,7 +392,7 @@ void FindToolBar::adaptToCandidate() void FindToolBar::updateGlobalActions() { IFindSupport *candidate = m_currentDocumentFind->candidate(); - bool enabled = (candidate != 0); + bool enabled = (candidate != nullptr); bool replaceEnabled = enabled && candidate->supportsReplace(); m_findInDocumentAction->setEnabled(enabled || (toolBarHasFocus() && isEnabled())); m_findNextSelectedAction->setEnabled(enabled); @@ -670,7 +668,7 @@ void FindToolBar::findFlagsChanged() void FindToolBar::findEditButtonClicked() { - OptionsPopup *popup = new OptionsPopup(m_ui.findEdit); + auto popup = new OptionsPopup(m_ui.findEdit); popup->show(); } @@ -753,7 +751,7 @@ FindToolBarPlaceHolder *FindToolBar::findToolBarPlaceHolder() const } candidate = candidate->parentWidget(); } - return 0; + return nullptr; } bool FindToolBar::toolBarHasFocus() const @@ -826,7 +824,7 @@ void FindToolBar::openFindToolBar(OpenFlags flags) FindToolBarPlaceHolder *previousHolder = FindToolBarPlaceHolder::getCurrent(); if (previousHolder != holder) { if (previousHolder) - previousHolder->setWidget(0); + previousHolder->setWidget(nullptr); holder->setWidget(this); FindToolBarPlaceHolder::setCurrent(holder); } @@ -987,7 +985,7 @@ OptionsPopup::OptionsPopup(QWidget *parent) : QWidget(parent, Qt::Popup) { setAttribute(Qt::WA_DeleteOnClose); - QVBoxLayout *layout = new QVBoxLayout(this); + auto layout = new QVBoxLayout(this); layout->setContentsMargins(2, 2, 2, 2); layout->setSpacing(2); setLayout(layout); @@ -1003,7 +1001,7 @@ OptionsPopup::OptionsPopup(QWidget *parent) bool OptionsPopup::event(QEvent *ev) { if (ev->type() == QEvent::ShortcutOverride) { - QKeyEvent *ke = static_cast<QKeyEvent *>(ev); + auto ke = static_cast<QKeyEvent *>(ev); if (ke->key() == Qt::Key_Escape && !ke->modifiers()) { ev->accept(); return true; @@ -1014,9 +1012,9 @@ bool OptionsPopup::event(QEvent *ev) bool OptionsPopup::eventFilter(QObject *obj, QEvent *ev) { - QCheckBox *checkbox = qobject_cast<QCheckBox *>(obj); + auto checkbox = qobject_cast<QCheckBox *>(obj); if (ev->type() == QEvent::KeyPress && checkbox) { - QKeyEvent *ke = static_cast<QKeyEvent *>(ev); + auto ke = static_cast<QKeyEvent *>(ev); if (!ke->modifiers() && (ke->key() == Qt::Key_Enter || ke->key() == Qt::Key_Return)) { checkbox->click(); ev->accept(); @@ -1028,7 +1026,7 @@ bool OptionsPopup::eventFilter(QObject *obj, QEvent *ev) void OptionsPopup::actionChanged() { - QAction *action = qobject_cast<QAction *>(sender()); + auto action = qobject_cast<QAction *>(sender()); QTC_ASSERT(action, return); QCheckBox *checkbox = m_checkboxMap.value(action); QTC_ASSERT(checkbox, return); diff --git a/src/plugins/coreplugin/find/findtoolbar.h b/src/plugins/coreplugin/find/findtoolbar.h index c1c78e6bcc..1095317682 100644 --- a/src/plugins/coreplugin/find/findtoolbar.h +++ b/src/plugins/coreplugin/find/findtoolbar.h @@ -51,8 +51,8 @@ public: explicit OptionsPopup(QWidget *parent); protected: - bool event(QEvent *ev); - bool eventFilter(QObject *obj, QEvent *ev); + bool event(QEvent *ev) override; + bool eventFilter(QObject *obj, QEvent *ev) override; private: void actionChanged(); @@ -77,7 +77,7 @@ public: Q_DECLARE_FLAGS(OpenFlags, OpenFlag) explicit FindToolBar(CurrentDocumentFind *currentDocumentFind); - ~FindToolBar(); + ~FindToolBar() override; void readSettings(); void writeSettings(); @@ -91,8 +91,8 @@ public slots: void setBackward(bool backward); protected: - bool focusNextPrevChild(bool next); - void resizeEvent(QResizeEvent *event); + bool focusNextPrevChild(bool next) override; + void resizeEvent(QResizeEvent *event) override; private: void invokeFindNext(); @@ -147,7 +147,7 @@ private: void acceptCandidateAndMoveToolBar(); void indicateSearchState(IFindSupport::Result searchState); - bool eventFilter(QObject *obj, QEvent *event); + bool eventFilter(QObject *obj, QEvent *event) override; void setFindText(const QString &text); QString getFindText(); QString getReplaceText(); diff --git a/src/plugins/coreplugin/find/findtoolwindow.cpp b/src/plugins/coreplugin/find/findtoolwindow.cpp index 7bb01b67a3..85897fb8ae 100644 --- a/src/plugins/coreplugin/find/findtoolwindow.cpp +++ b/src/plugins/coreplugin/find/findtoolwindow.cpp @@ -41,7 +41,7 @@ using namespace Core; using namespace Core::Internal; -static FindToolWindow *m_instance = 0; +static FindToolWindow *m_instance = nullptr; static bool validateRegExp(Utils::FancyLineEdit *edit, QString *errorMessage) { @@ -63,8 +63,8 @@ static bool validateRegExp(Utils::FancyLineEdit *edit, QString *errorMessage) FindToolWindow::FindToolWindow(QWidget *parent) : QWidget(parent), m_findCompleter(new QCompleter(this)), - m_currentFilter(0), - m_configWidget(0) + m_currentFilter(nullptr), + m_configWidget(nullptr) { m_instance = this; m_ui.setupUi(this); @@ -93,7 +93,7 @@ FindToolWindow::FindToolWindow(QWidget *parent) connect(m_ui.searchTerm, &Utils::FancyLineEdit::validChanged, this, &FindToolWindow::updateButtonStates); - QVBoxLayout *layout = new QVBoxLayout; + auto layout = new QVBoxLayout; layout->setMargin(0); layout->setSpacing(0); m_ui.configWidget->setLayout(layout); @@ -115,7 +115,7 @@ FindToolWindow *FindToolWindow::instance() bool FindToolWindow::event(QEvent *event) { if (event->type() == QEvent::KeyPress) { - QKeyEvent *ke = static_cast<QKeyEvent *>(event); + auto ke = static_cast<QKeyEvent *>(event); if ((ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter) && (ke->modifiers() == Qt::NoModifier || ke->modifiers() == Qt::KeypadModifier)) { ke->accept(); @@ -130,7 +130,7 @@ bool FindToolWindow::event(QEvent *event) bool FindToolWindow::eventFilter(QObject *obj, QEvent *event) { if (obj == m_ui.searchTerm && event->type() == QEvent::KeyPress) { - QKeyEvent *ke = static_cast<QKeyEvent *>(event); + auto ke = static_cast<QKeyEvent *>(event); if (ke->key() == Qt::Key_Down) { if (m_ui.searchTerm->text().isEmpty()) m_findCompleter->setCompletionPrefix(QString()); @@ -247,12 +247,12 @@ void FindToolWindow::setCurrentFilter(int index) m_ui.configWidget->layout()->addWidget(m_configWidget); } else { if (configWidget) - configWidget->setParent(0); + configWidget->setParent(nullptr); } } QWidget *w = m_ui.configWidget; while (w) { - QScrollArea *sa = qobject_cast<QScrollArea *>(w); + auto sa = qobject_cast<QScrollArea *>(w); if (sa) { sa->updateGeometry(); break; @@ -268,7 +268,7 @@ void FindToolWindow::setCurrentFilter(int index) void FindToolWindow::acceptAndGetParameters(QString *term, IFindFilter **filter) { QTC_ASSERT(filter, return); - *filter = 0; + *filter = nullptr; Find::updateFindCompletion(m_ui.searchTerm->text()); int index = m_ui.filterList->currentIndex(); QString searchTerm = m_ui.searchTerm->text(); @@ -277,13 +277,13 @@ void FindToolWindow::acceptAndGetParameters(QString *term, IFindFilter **filter) if (term) *term = searchTerm; if (searchTerm.isEmpty() && *filter && !(*filter)->isValid()) - *filter = 0; + *filter = nullptr; } void FindToolWindow::search() { QString term; - IFindFilter *filter = 0; + IFindFilter *filter = nullptr; acceptAndGetParameters(&term, &filter); QTC_ASSERT(filter, return); filter->findAll(term, Find::findFlags()); @@ -292,7 +292,7 @@ void FindToolWindow::search() void FindToolWindow::replace() { QString term; - IFindFilter *filter = 0; + IFindFilter *filter = nullptr; acceptAndGetParameters(&term, &filter); QTC_ASSERT(filter, return); filter->replaceAll(term, Find::findFlags()); diff --git a/src/plugins/coreplugin/find/findtoolwindow.h b/src/plugins/coreplugin/find/findtoolwindow.h index 10097f1e80..91db0bd4db 100644 --- a/src/plugins/coreplugin/find/findtoolwindow.h +++ b/src/plugins/coreplugin/find/findtoolwindow.h @@ -42,8 +42,8 @@ class FindToolWindow : public QWidget Q_OBJECT public: - explicit FindToolWindow(QWidget *parent = 0); - ~FindToolWindow(); + explicit FindToolWindow(QWidget *parent = nullptr); + ~FindToolWindow() override; static FindToolWindow *instance(); void setFindFilters(const QList<IFindFilter *> &filters); @@ -55,8 +55,8 @@ public: void writeSettings(); protected: - bool event(QEvent *event); - bool eventFilter(QObject *obj, QEvent *event); + bool event(QEvent *event) override; + bool eventFilter(QObject *obj, QEvent *event) override; private: void search(); diff --git a/src/plugins/coreplugin/find/highlightscrollbarcontroller.cpp b/src/plugins/coreplugin/find/highlightscrollbarcontroller.cpp index e9c8b237ae..c760460fac 100644 --- a/src/plugins/coreplugin/find/highlightscrollbarcontroller.cpp +++ b/src/plugins/coreplugin/find/highlightscrollbarcontroller.cpp @@ -204,7 +204,7 @@ void HighlightScrollBarOverlay::drawHighlights(QPainter *painter, const QColor &color = creatorTheme()->color(itColor.key()); const QMap<int, int> &positions = itColor.value(); const auto itPosEnd = positions.constEnd(); - const int firstPos = int(docStart / lineHeight); + const auto firstPos = int(docStart / lineHeight); auto itPos = positions.upperBound(firstPos); if (itPos != positions.constBegin()) --itPos; diff --git a/src/plugins/coreplugin/find/ifindsupport.h b/src/plugins/coreplugin/find/ifindsupport.h index 384caddf27..213e1feb0d 100644 --- a/src/plugins/coreplugin/find/ifindsupport.h +++ b/src/plugins/coreplugin/find/ifindsupport.h @@ -40,7 +40,7 @@ public: enum Result { Found, NotFound, NotYetFound }; IFindSupport() : QObject(nullptr) {} - ~IFindSupport() override {} + ~IFindSupport() override = default; virtual bool supportsReplace() const = 0; virtual FindFlags supportedFindFlags() const = 0; diff --git a/src/plugins/coreplugin/find/itemviewfind.cpp b/src/plugins/coreplugin/find/itemviewfind.cpp index cc2dd466e5..13174c8cd9 100644 --- a/src/plugins/coreplugin/find/itemviewfind.cpp +++ b/src/plugins/coreplugin/find/itemviewfind.cpp @@ -230,7 +230,7 @@ IFindSupport::Result ItemViewFind::find(const QString &searchTxt, d->m_view->setCurrentIndex(resultIndex); d->m_view->scrollTo(resultIndex); if (resultIndex.parent().isValid()) - if (QTreeView *treeView = qobject_cast<QTreeView *>(d->m_view)) + if (auto treeView = qobject_cast<QTreeView *>(d->m_view)) treeView->expand(resultIndex.parent()); if (wrapped) *wrapped = anyWrapped; diff --git a/src/plugins/coreplugin/find/searchresulttreeitemdelegate.cpp b/src/plugins/coreplugin/find/searchresulttreeitemdelegate.cpp index de67e62b99..81ec2541c6 100644 --- a/src/plugins/coreplugin/find/searchresulttreeitemdelegate.cpp +++ b/src/plugins/coreplugin/find/searchresulttreeitemdelegate.cpp @@ -134,7 +134,7 @@ int SearchResultTreeItemDelegate::drawLineNumber(QPainter *painter, const QStyle opt.palette.setColor(cg, QPalette::Text, Qt::darkGray); const QStyle *style = QApplication::style(); - const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, 0) + 1; + const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, nullptr, nullptr) + 1; const QRect rowRect = lineNumberAreaRect.adjusted(-textMargin, 0, textMargin-lineNumberAreaHorizontalPadding, 0); QItemDelegate::drawDisplay(painter, opt, rowRect, lineText); diff --git a/src/plugins/coreplugin/find/searchresulttreeitemdelegate.h b/src/plugins/coreplugin/find/searchresulttreeitemdelegate.h index 99e05c2248..0551e4c8d7 100644 --- a/src/plugins/coreplugin/find/searchresulttreeitemdelegate.h +++ b/src/plugins/coreplugin/find/searchresulttreeitemdelegate.h @@ -33,8 +33,8 @@ namespace Internal { class SearchResultTreeItemDelegate: public QItemDelegate { public: - SearchResultTreeItemDelegate(int tabWidth, QObject *parent = 0); - void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; + SearchResultTreeItemDelegate(int tabWidth, QObject *parent = nullptr); + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; void setTabWidth(int width); private: diff --git a/src/plugins/coreplugin/find/searchresulttreeitems.cpp b/src/plugins/coreplugin/find/searchresulttreeitems.cpp index e87681023b..51d6f9ced8 100644 --- a/src/plugins/coreplugin/find/searchresulttreeitems.cpp +++ b/src/plugins/coreplugin/find/searchresulttreeitems.cpp @@ -44,7 +44,7 @@ SearchResultTreeItem::~SearchResultTreeItem() bool SearchResultTreeItem::isLeaf() const { - return childrenCount() == 0 && parent() != 0; + return childrenCount() == 0 && parent() != nullptr; } Qt::CheckState SearchResultTreeItem::checkState() const @@ -96,7 +96,7 @@ int SearchResultTreeItem::insertionIndex(const QString &text, SearchResultTreeIt if (insertionPosition != m_children.end() && (*insertionPosition)->item.text == text) (*existingItem) = (*insertionPosition); else - *existingItem = 0; + *existingItem = nullptr; } return insertionPosition - m_children.begin(); } @@ -113,7 +113,7 @@ void SearchResultTreeItem::insertChild(int index, SearchResultTreeItem *child) void SearchResultTreeItem::insertChild(int index, const SearchResultItem &item) { - SearchResultTreeItem *child = new SearchResultTreeItem(item, this); + auto child = new SearchResultTreeItem(item, this); insertChild(index, child); } diff --git a/src/plugins/coreplugin/find/searchresulttreeitems.h b/src/plugins/coreplugin/find/searchresulttreeitems.h index 1709bc11d0..d4aa10f4ca 100644 --- a/src/plugins/coreplugin/find/searchresulttreeitems.h +++ b/src/plugins/coreplugin/find/searchresulttreeitems.h @@ -37,7 +37,7 @@ class SearchResultTreeItem { public: explicit SearchResultTreeItem(const SearchResultItem &item = SearchResultItem(), - SearchResultTreeItem *parent = NULL); + SearchResultTreeItem *parent = nullptr); virtual ~SearchResultTreeItem(); bool isLeaf() const; diff --git a/src/plugins/coreplugin/find/searchresulttreemodel.cpp b/src/plugins/coreplugin/find/searchresulttreemodel.cpp index a60b46553c..ea2c5ae9df 100644 --- a/src/plugins/coreplugin/find/searchresulttreemodel.cpp +++ b/src/plugins/coreplugin/find/searchresulttreemodel.cpp @@ -37,7 +37,7 @@ using namespace Core::Internal; SearchResultTreeModel::SearchResultTreeModel(QObject *parent) : QAbstractItemModel(parent) - , m_currentParent(0) + , m_currentParent(nullptr) , m_showReplaceUI(false) , m_editorFontIsUsed(false) { @@ -178,7 +178,7 @@ QVariant SearchResultTreeModel::data(const QModelIndex &idx, int role) const bool SearchResultTreeModel::setData(const QModelIndex &idx, const QVariant &value, int role) { if (role == Qt::CheckStateRole) { - Qt::CheckState checkState = static_cast<Qt::CheckState>(value.toInt()); + auto checkState = static_cast<Qt::CheckState>(value.toInt()); return setCheckState(idx, checkState); } return QAbstractItemModel::setData(idx, value, role); @@ -308,7 +308,7 @@ QSet<SearchResultTreeItem *> SearchResultTreeModel::addPath(const QStringList &p QSet<SearchResultTreeItem *> pathNodes; SearchResultTreeItem *currentItem = m_rootItem; QModelIndex currentItemIndex = QModelIndex(); - SearchResultTreeItem *partItem = 0; + SearchResultTreeItem *partItem = nullptr; QStringList currentPath; foreach (const QString &part, path) { const int insertionIndex = currentItem->insertionIndex(part, &partItem); @@ -418,7 +418,7 @@ QList<QModelIndex> SearchResultTreeModel::addResults(const QList<SearchResultIte void SearchResultTreeModel::clear() { beginResetModel(); - m_currentParent = NULL; + m_currentParent = nullptr; m_rootItem->clearChildren(); m_editorFontIsUsed = false; endResetModel(); diff --git a/src/plugins/coreplugin/find/searchresulttreemodel.h b/src/plugins/coreplugin/find/searchresulttreemodel.h index 9eeb10eec3..a8514e74c3 100644 --- a/src/plugins/coreplugin/find/searchresulttreemodel.h +++ b/src/plugins/coreplugin/find/searchresulttreemodel.h @@ -41,8 +41,8 @@ class SearchResultTreeModel : public QAbstractItemModel Q_OBJECT public: - SearchResultTreeModel(QObject *parent = 0); - ~SearchResultTreeModel(); + SearchResultTreeModel(QObject *parent = nullptr); + ~SearchResultTreeModel() override; void setShowReplaceUI(bool show); void setTextEditorFont(const QFont &font, const SearchResultColor &color); @@ -56,8 +56,8 @@ public: bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; QVariant headerData(int section, Qt::Orientation orientation, int role) const override; - QModelIndex next(const QModelIndex &idx, bool includeGenerated = false, bool *wrapped = 0) const; - QModelIndex prev(const QModelIndex &idx, bool includeGenerated = false, bool *wrapped = 0) const; + QModelIndex next(const QModelIndex &idx, bool includeGenerated = false, bool *wrapped = nullptr) const; + QModelIndex prev(const QModelIndex &idx, bool includeGenerated = false, bool *wrapped = nullptr) const; QList<QModelIndex> addResults(const QList<SearchResultItem> &items, SearchResult::AddMode mode); @@ -74,8 +74,8 @@ private: QSet<SearchResultTreeItem *> addPath(const QStringList &path); QVariant data(const SearchResultTreeItem *row, int role) const; bool setCheckState(const QModelIndex &idx, Qt::CheckState checkState, bool firstCall = true); - QModelIndex nextIndex(const QModelIndex &idx, bool *wrapped = 0) const; - QModelIndex prevIndex(const QModelIndex &idx, bool *wrapped = 0) const; + QModelIndex nextIndex(const QModelIndex &idx, bool *wrapped = nullptr) const; + QModelIndex prevIndex(const QModelIndex &idx, bool *wrapped = nullptr) const; SearchResultTreeItem *treeItemAtIndex(const QModelIndex &idx) const; SearchResultTreeItem *m_rootItem; diff --git a/src/plugins/coreplugin/find/searchresulttreeview.cpp b/src/plugins/coreplugin/find/searchresulttreeview.cpp index a8a3d3ba69..6a9b7067bf 100644 --- a/src/plugins/coreplugin/find/searchresulttreeview.cpp +++ b/src/plugins/coreplugin/find/searchresulttreeview.cpp @@ -89,7 +89,7 @@ void SearchResultTreeView::emitJumpToSearchResult(const QModelIndex &index) void SearchResultTreeView::setTabWidth(int tabWidth) { - SearchResultTreeItemDelegate *delegate = static_cast<SearchResultTreeItemDelegate *>(itemDelegate()); + auto delegate = static_cast<SearchResultTreeItemDelegate *>(itemDelegate()); delegate->setTabWidth(tabWidth); doItemsLayout(); } diff --git a/src/plugins/coreplugin/find/searchresulttreeview.h b/src/plugins/coreplugin/find/searchresulttreeview.h index bf80cba1ad..961940fe01 100644 --- a/src/plugins/coreplugin/find/searchresulttreeview.h +++ b/src/plugins/coreplugin/find/searchresulttreeview.h @@ -40,7 +40,7 @@ class SearchResultTreeView : public Utils::TreeView Q_OBJECT public: - explicit SearchResultTreeView(QWidget *parent = 0); + explicit SearchResultTreeView(QWidget *parent = nullptr); void setAutoExpandResults(bool expand); void setTextEditorFont(const QFont &font, const SearchResultColor &color); diff --git a/src/plugins/coreplugin/find/searchresultwidget.cpp b/src/plugins/coreplugin/find/searchresultwidget.cpp index d22531954d..9428a31a1d 100644 --- a/src/plugins/coreplugin/find/searchresultwidget.cpp +++ b/src/plugins/coreplugin/find/searchresultwidget.cpp @@ -69,7 +69,7 @@ public: } - QSize sizeHint() const + QSize sizeHint() const override { QSize sh = QLineEdit::minimumSizeHint(); sh.rwidth() += qMax(25 * fontMetrics().width(QLatin1Char('x')), @@ -81,7 +81,7 @@ public: SearchResultWidget::SearchResultWidget(QWidget *parent) : QWidget(parent) { - QVBoxLayout *layout = new QVBoxLayout(this); + auto layout = new QVBoxLayout(this); layout->setMargin(0); layout->setSpacing(0); setLayout(layout); @@ -122,7 +122,7 @@ SearchResultWidget::SearchResultWidget(QWidget *parent) : m_messageWidget->setLineWidth(1); } m_messageWidget->setAutoFillBackground(true); - QHBoxLayout *messageLayout = new QHBoxLayout(m_messageWidget); + auto messageLayout = new QHBoxLayout(m_messageWidget); messageLayout->setMargin(2); m_messageWidget->setLayout(messageLayout); QLabel *messageLabel = new QLabel(tr("Search was canceled.")); @@ -134,7 +134,7 @@ SearchResultWidget::SearchResultWidget(QWidget *parent) : m_searchResultTreeView = new SearchResultTreeView(this); m_searchResultTreeView->setFrameStyle(QFrame::NoFrame); m_searchResultTreeView->setAttribute(Qt::WA_MacShowFocusRect, false); - Aggregation::Aggregate * agg = new Aggregation::Aggregate; + auto agg = new Aggregation::Aggregate; agg->add(m_searchResultTreeView); agg->add(new ItemViewFind(m_searchResultTreeView, ItemDataRoles::ResultLineRole)); @@ -144,7 +144,7 @@ SearchResultWidget::SearchResultWidget(QWidget *parent) : m_infoBarDisplay.setInfoBar(&m_infoBar); m_descriptionContainer = new QWidget(topFindWidget); - QHBoxLayout *descriptionLayout = new QHBoxLayout(m_descriptionContainer); + auto descriptionLayout = new QHBoxLayout(m_descriptionContainer); m_descriptionContainer->setLayout(descriptionLayout); descriptionLayout->setMargin(0); m_descriptionContainer->setMinimumWidth(200); @@ -282,7 +282,7 @@ void SearchResultWidget::addResults(const QList<SearchResultItem> &items, Search emit paused(true); InfoBarEntry info(sizeWarningId, tr("The search resulted in more than %n items, do you still want to continue?", - 0, SEARCHRESULT_WARNING_LIMIT)); + nullptr, SEARCHRESULT_WARNING_LIMIT)); info.setCancelButtonInfo(tr("Cancel"), [this]() { cancelAfterSizeWarning(); }); info.setCustomButtonInfo(tr("Continue"), [this]() { continueAfterSizeWarning(); }); m_infoBar.addInfo(info); @@ -499,12 +499,12 @@ QList<SearchResultItem> SearchResultWidget::checkedItems() const const int fileCount = model->rowCount(); for (int i = 0; i < fileCount; ++i) { QModelIndex fileIndex = model->index(i, 0); - SearchResultTreeItem *fileItem = static_cast<SearchResultTreeItem *>(fileIndex.internalPointer()); - QTC_ASSERT(fileItem != 0, continue); + auto fileItem = static_cast<SearchResultTreeItem *>(fileIndex.internalPointer()); + QTC_ASSERT(fileItem != nullptr, continue); for (int rowIndex = 0; rowIndex < fileItem->childrenCount(); ++rowIndex) { QModelIndex textIndex = model->index(rowIndex, 0, fileIndex); - SearchResultTreeItem *rowItem = static_cast<SearchResultTreeItem *>(textIndex.internalPointer()); - QTC_ASSERT(rowItem != 0, continue); + auto rowItem = static_cast<SearchResultTreeItem *>(textIndex.internalPointer()); + QTC_ASSERT(rowItem != nullptr, continue); if (rowItem->checkState()) result << rowItem->item; } @@ -517,7 +517,7 @@ void SearchResultWidget::updateMatchesFoundLabel() if (m_count == 0) m_matchesFoundLabel->setText(tr("No matches found.")); else - m_matchesFoundLabel->setText(tr("%n matches found.", 0, m_count)); + m_matchesFoundLabel->setText(tr("%n matches found.", nullptr, m_count)); } } // namespace Internal diff --git a/src/plugins/coreplugin/find/searchresultwidget.h b/src/plugins/coreplugin/find/searchresultwidget.h index 5309ed69e1..22193a231e 100644 --- a/src/plugins/coreplugin/find/searchresultwidget.h +++ b/src/plugins/coreplugin/find/searchresultwidget.h @@ -49,8 +49,8 @@ class SearchResultWidget : public QWidget { Q_OBJECT public: - explicit SearchResultWidget(QWidget *parent = 0); - ~SearchResultWidget(); + explicit SearchResultWidget(QWidget *parent = nullptr); + ~SearchResultWidget() override; void setInfo(const QString &label, const QString &toolTip, const QString &term); QWidget *additionalReplaceWidget() const; diff --git a/src/plugins/coreplugin/find/searchresultwindow.cpp b/src/plugins/coreplugin/find/searchresultwindow.cpp index 7c790df2fa..7cea0166d1 100644 --- a/src/plugins/coreplugin/find/searchresultwindow.cpp +++ b/src/plugins/coreplugin/find/searchresultwindow.cpp @@ -67,7 +67,7 @@ namespace Internal { setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); } - QSize sizeHint() const + QSize sizeHint() const override { if (widget()) return widget()->size(); @@ -109,7 +109,7 @@ namespace Internal { SearchResultWindowPrivate::SearchResultWindowPrivate(SearchResultWindow *window, QWidget *nsp) : q(window), - m_expandCollapseButton(0), + m_expandCollapseButton(nullptr), m_expandCollapseAction(new QAction(tr("Expand All"), window)), m_spacer(new QWidget), m_historyLabel(new QLabel(tr("History:"))), @@ -178,7 +178,7 @@ namespace Internal { void SearchResultWindowPrivate::moveWidgetToTop() { - SearchResultWidget *widget = qobject_cast<SearchResultWidget *>(sender()); + auto widget = qobject_cast<SearchResultWidget *>(sender()); QTC_ASSERT(widget, return); int index = m_searchResultWidgets.indexOf(widget); if (index == 0) @@ -212,7 +212,7 @@ namespace Internal { void SearchResultWindowPrivate::popupRequested(bool focus) { - SearchResultWidget *widget = qobject_cast<SearchResultWidget *>(sender()); + auto widget = qobject_cast<SearchResultWidget *>(sender()); QTC_ASSERT(widget, return); int internalIndex = m_searchResultWidgets.indexOf(widget) + 1/*account for "new search" entry*/; setCurrentIndex(internalIndex, focus); @@ -297,7 +297,7 @@ using namespace Core::Internal; \internal */ -SearchResultWindow *SearchResultWindow::m_instance = 0; +SearchResultWindow *SearchResultWindow::m_instance = nullptr; /*! \internal @@ -316,7 +316,7 @@ SearchResultWindow::~SearchResultWindow() { qDeleteAll(d->m_searchResults); delete d->m_widget; - d->m_widget = 0; + d->m_widget = nullptr; delete d; } diff --git a/src/plugins/coreplugin/findplaceholder.cpp b/src/plugins/coreplugin/findplaceholder.cpp index 90ade039d5..101ccf87df 100644 --- a/src/plugins/coreplugin/findplaceholder.cpp +++ b/src/plugins/coreplugin/findplaceholder.cpp @@ -30,12 +30,12 @@ using namespace Core; -FindToolBarPlaceHolder *FindToolBarPlaceHolder::m_current = 0; +FindToolBarPlaceHolder *FindToolBarPlaceHolder::m_current = nullptr; static QList<FindToolBarPlaceHolder *> g_findToolBarPlaceHolders; FindToolBarPlaceHolder::FindToolBarPlaceHolder(QWidget *owner, QWidget *parent) - : QWidget(parent), m_owner(owner), m_subWidget(0), m_lightColored(false) + : QWidget(parent), m_owner(owner), m_subWidget(nullptr) { g_findToolBarPlaceHolders.append(this); setLayout(new QVBoxLayout); @@ -48,10 +48,10 @@ FindToolBarPlaceHolder::~FindToolBarPlaceHolder() g_findToolBarPlaceHolders.removeOne(this); if (m_subWidget) { m_subWidget->setVisible(false); - m_subWidget->setParent(0); + m_subWidget->setParent(nullptr); } if (m_current == this) - m_current = 0; + m_current = nullptr; } const QList<FindToolBarPlaceHolder *> FindToolBarPlaceHolder::allFindToolbarPlaceHolders() @@ -82,7 +82,7 @@ void FindToolBarPlaceHolder::setWidget(Internal::FindToolBar *widget) { if (m_subWidget) { m_subWidget->setVisible(false); - m_subWidget->setParent(0); + m_subWidget->setParent(nullptr); } m_subWidget = widget; if (m_subWidget) { diff --git a/src/plugins/coreplugin/findplaceholder.h b/src/plugins/coreplugin/findplaceholder.h index 685fae6fb0..a9f8fa9c73 100644 --- a/src/plugins/coreplugin/findplaceholder.h +++ b/src/plugins/coreplugin/findplaceholder.h @@ -56,7 +56,7 @@ public: private: QWidget *m_owner; QPointer<Internal::FindToolBar> m_subWidget; - bool m_lightColored; + bool m_lightColored = false; static FindToolBarPlaceHolder *m_current; }; diff --git a/src/plugins/coreplugin/generalsettings.cpp b/src/plugins/coreplugin/generalsettings.cpp index b4eedbb0d9..27788d5711 100644 --- a/src/plugins/coreplugin/generalsettings.cpp +++ b/src/plugins/coreplugin/generalsettings.cpp @@ -48,7 +48,7 @@ namespace Internal { const char settingsKeyDPI[] = "Core/EnableHighDpiScaling"; GeneralSettings::GeneralSettings() - : m_page(0), m_dialog(0) + : m_page(nullptr), m_dialog(nullptr) { setId(Constants::SETTINGS_ID_INTERFACE); setDisplayName(tr("Interface")); @@ -143,7 +143,7 @@ void GeneralSettings::finish() { delete m_widget; delete m_page; - m_page = 0; + m_page = nullptr; } void GeneralSettings::resetInterfaceColor() diff --git a/src/plugins/coreplugin/generalsettings.h b/src/plugins/coreplugin/generalsettings.h index 584048bf72..ed0f177532 100644 --- a/src/plugins/coreplugin/generalsettings.h +++ b/src/plugins/coreplugin/generalsettings.h @@ -44,9 +44,9 @@ class GeneralSettings : public IOptionsPage public: GeneralSettings(); - QWidget *widget(); - void apply(); - void finish(); + QWidget *widget() override; + void apply() override; + void finish() override; private: void resetInterfaceColor(); diff --git a/src/plugins/coreplugin/generatedfile.cpp b/src/plugins/coreplugin/generatedfile.cpp index 094d1ab148..7d3c77c8cb 100644 --- a/src/plugins/coreplugin/generatedfile.cpp +++ b/src/plugins/coreplugin/generatedfile.cpp @@ -49,19 +49,18 @@ namespace Core { class GeneratedFilePrivate : public QSharedData { public: - GeneratedFilePrivate() : binary(false) {} + GeneratedFilePrivate() = default; explicit GeneratedFilePrivate(const QString &p); QString path; QByteArray contents; Id editorId; - bool binary; + bool binary = false; GeneratedFile::Attributes attributes; }; GeneratedFilePrivate::GeneratedFilePrivate(const QString &p) : path(QDir::cleanPath(p)), - binary(false), - attributes(0) + attributes({}) { } @@ -75,10 +74,7 @@ GeneratedFile::GeneratedFile(const QString &p) : { } -GeneratedFile::GeneratedFile(const GeneratedFile &rhs) : - m_d(rhs.m_d) -{ -} +GeneratedFile::GeneratedFile(const GeneratedFile &rhs) = default; GeneratedFile &GeneratedFile::operator=(const GeneratedFile &rhs) { @@ -87,9 +83,7 @@ GeneratedFile &GeneratedFile::operator=(const GeneratedFile &rhs) return *this; } -GeneratedFile::~GeneratedFile() -{ -} +GeneratedFile::~GeneratedFile() = default; QString GeneratedFile::path() const { diff --git a/src/plugins/coreplugin/generatedfile.h b/src/plugins/coreplugin/generatedfile.h index 9fb2815837..1cd97d95cf 100644 --- a/src/plugins/coreplugin/generatedfile.h +++ b/src/plugins/coreplugin/generatedfile.h @@ -84,6 +84,6 @@ private: QSharedDataPointer<GeneratedFilePrivate> m_d; }; -typedef QList<GeneratedFile> GeneratedFiles; +using GeneratedFiles = QList<GeneratedFile>; } // namespace Core diff --git a/src/plugins/coreplugin/helpmanager.cpp b/src/plugins/coreplugin/helpmanager.cpp index 82ce813904..51a2c426d7 100644 --- a/src/plugins/coreplugin/helpmanager.cpp +++ b/src/plugins/coreplugin/helpmanager.cpp @@ -57,10 +57,7 @@ namespace Core { struct HelpManagerPrivate { - HelpManagerPrivate() : - m_needsSetup(true), m_helpEngine(nullptr), m_collectionWatcher(nullptr) - {} - + HelpManagerPrivate() = default; ~HelpManagerPrivate(); const QStringList documentationFromInstaller(); @@ -68,9 +65,9 @@ struct HelpManagerPrivate void writeSettings(); void cleanUpDocumentation(); - bool m_needsSetup; - QHelpEngineCore *m_helpEngine; - Utils::FileSystemWatcher *m_collectionWatcher; + bool m_needsSetup = true; + QHelpEngineCore *m_helpEngine = nullptr; + Utils::FileSystemWatcher *m_collectionWatcher = nullptr; // data for delayed initialization QSet<QString> m_filesToRegister; @@ -506,7 +503,7 @@ void HelpManagerPrivate::writeSettings() namespace Core { -HelpManager *HelpManager::instance() { return 0; } +HelpManager *HelpManager::instance() { return nullptr; } QString HelpManager::collectionFilePath() { return QString(); } @@ -542,7 +539,7 @@ void HelpManager::handleHelpRequest(const QUrl &, HelpManager::HelpViewerLocatio void HelpManager::handleHelpRequest(const QString &, HelpViewerLocation) {} HelpManager::HelpManager(QObject *) {} -HelpManager::~HelpManager() {} +HelpManager::~HelpManager() = default; void HelpManager::aboutToShutdown() {} void HelpManager::setupHelpManager() {} diff --git a/src/plugins/coreplugin/helpmanager.h b/src/plugins/coreplugin/helpmanager.h index 466f0feff3..33ba4f07a1 100644 --- a/src/plugins/coreplugin/helpmanager.h +++ b/src/plugins/coreplugin/helpmanager.h @@ -56,7 +56,7 @@ public: ExternalHelpAlways = 3 }; - typedef QHash<QString, QStringList> Filters; + using Filters = QHash<QString, QStringList>; static HelpManager *instance(); static QString collectionFilePath(); diff --git a/src/plugins/coreplugin/icontext.h b/src/plugins/coreplugin/icontext.h index 01daa739b5..d7bb022c5b 100644 --- a/src/plugins/coreplugin/icontext.h +++ b/src/plugins/coreplugin/icontext.h @@ -40,7 +40,7 @@ namespace Core { class CORE_EXPORT Context { public: - Context() {} + Context() = default; explicit Context(Id c1) { add(c1); } Context(Id c1, Id c2) { add(c1); add(c2); } @@ -51,7 +51,7 @@ public: Id at(int i) const { return d.at(i); } // FIXME: Make interface slimmer. - typedef QList<Id>::const_iterator const_iterator; + using const_iterator = QList<Id>::const_iterator; const_iterator begin() const { return d.begin(); } const_iterator end() const { return d.end(); } int indexOf(Id c) const { return d.indexOf(c); } diff --git a/src/plugins/coreplugin/icore.cpp b/src/plugins/coreplugin/icore.cpp index 9e34890430..6bb0779ec6 100644 --- a/src/plugins/coreplugin/icore.cpp +++ b/src/plugins/coreplugin/icore.cpp @@ -337,8 +337,8 @@ ICore::ICore(MainWindow *mainwindow) ICore::~ICore() { - m_instance = 0; - m_mainwindow = 0; + m_instance = nullptr; + m_mainwindow = nullptr; } void ICore::showNewItemDialog(const QString &title, diff --git a/src/plugins/coreplugin/id.cpp b/src/plugins/coreplugin/id.cpp index 90a755f123..6e081746ae 100644 --- a/src/plugins/coreplugin/id.cpp +++ b/src/plugins/coreplugin/id.cpp @@ -56,9 +56,7 @@ namespace Core { class StringHolder { public: - StringHolder() - : n(0), str(0) - {} + StringHolder() = default; StringHolder(const char *s, int length) : n(length), str(s) @@ -72,8 +70,8 @@ public: h &= 0x0fffffff; } } - int n; - const char *str; + int n = 0; + const char *str = nullptr; quintptr h; }; diff --git a/src/plugins/coreplugin/id.h b/src/plugins/coreplugin/id.h index af56c32b10..fc912da1b0 100644 --- a/src/plugins/coreplugin/id.h +++ b/src/plugins/coreplugin/id.h @@ -40,8 +40,9 @@ namespace Core { class CORE_EXPORT Id { public: - Id() : m_id(0) {} + Id() = default; Id(const char *name); // Good to use. + Id(const QLatin1String &) = delete; Id withSuffix(int suffix) const; Id withSuffix(const char *suffix) const; @@ -72,11 +73,9 @@ public: static QStringList toStringList(const QSet<Id> &ids); private: - // Intentionally unimplemented - Id(const QLatin1String &) = delete; explicit Id(quintptr uid) : m_id(uid) {} - quintptr m_id; + quintptr m_id = 0; }; inline uint qHash(Id id) { return static_cast<uint>(id.uniqueIdentifier()); } diff --git a/src/plugins/coreplugin/idocumentfactory.cpp b/src/plugins/coreplugin/idocumentfactory.cpp index 016d562d8b..26ef65f608 100644 --- a/src/plugins/coreplugin/idocumentfactory.cpp +++ b/src/plugins/coreplugin/idocumentfactory.cpp @@ -49,7 +49,7 @@ const QList<IDocumentFactory *> IDocumentFactory::allDocumentFactories() IDocument *IDocumentFactory::open(const QString &filename) { - QTC_ASSERT(m_opener, return 0); + QTC_ASSERT(m_opener, return nullptr); return m_opener(filename); } diff --git a/src/plugins/coreplugin/idocumentfactory.h b/src/plugins/coreplugin/idocumentfactory.h index 9e203870f6..7534528c1f 100644 --- a/src/plugins/coreplugin/idocumentfactory.h +++ b/src/plugins/coreplugin/idocumentfactory.h @@ -46,7 +46,7 @@ public: static const QList<IDocumentFactory *> allDocumentFactories(); - typedef std::function<IDocument *(const QString &fileName)> Opener; + using Opener = std::function<IDocument *(const QString &fileName)>; IDocument *open(const QString &filename); QStringList mimeTypes() const { return m_mimeTypes; } diff --git a/src/plugins/coreplugin/inavigationwidgetfactory.cpp b/src/plugins/coreplugin/inavigationwidgetfactory.cpp index eb7c78993d..7fd39cccb7 100644 --- a/src/plugins/coreplugin/inavigationwidgetfactory.cpp +++ b/src/plugins/coreplugin/inavigationwidgetfactory.cpp @@ -91,7 +91,6 @@ static QList<INavigationWidgetFactory *> g_navigationWidgetFactories; Creates a \l{Core::NavigationViewFactory}. */ INavigationWidgetFactory::INavigationWidgetFactory() - : m_priority(0) { g_navigationWidgetFactories.append(this); } diff --git a/src/plugins/coreplugin/inavigationwidgetfactory.h b/src/plugins/coreplugin/inavigationwidgetfactory.h index b39786cfa6..f69687e517 100644 --- a/src/plugins/coreplugin/inavigationwidgetfactory.h +++ b/src/plugins/coreplugin/inavigationwidgetfactory.h @@ -78,7 +78,7 @@ public: private: QString m_displayName; - int m_priority; + int m_priority = 0; Id m_id; QKeySequence m_activationSequence; }; diff --git a/src/plugins/coreplugin/infobar.cpp b/src/plugins/coreplugin/infobar.cpp index 7efd7220cb..3ca512c554 100644 --- a/src/plugins/coreplugin/infobar.cpp +++ b/src/plugins/coreplugin/infobar.cpp @@ -202,7 +202,7 @@ void InfoBarDisplay::setInfoBar(InfoBar *infoBar) void InfoBarDisplay::infoBarDestroyed() { - m_infoBar = 0; + m_infoBar = nullptr; // Calling update() here causes a complicated crash on shutdown. // So instead we rely on the view now being either destroyed (in which case it // will delete the widgets itself) or setInfoBar() being called explicitly. @@ -233,10 +233,10 @@ void InfoBarDisplay::update() infoWidget->setLineWidth(1); infoWidget->setAutoFillBackground(true); - QHBoxLayout *hbox = new QHBoxLayout; + auto hbox = new QHBoxLayout; hbox->setMargin(2); - auto *vbox = new QVBoxLayout(infoWidget); + auto vbox = new QVBoxLayout(infoWidget); vbox->setMargin(0); vbox->addLayout(hbox); @@ -250,7 +250,7 @@ void InfoBarDisplay::update() vbox->addWidget(detailsWidget); } - auto *showDetailsButton = new QToolButton; + auto showDetailsButton = new QToolButton; showDetailsButton->setCheckable(true); showDetailsButton->setChecked(m_isShowingDetailsWidget); showDetailsButton->setText(tr("&Show Details")); @@ -271,7 +271,7 @@ void InfoBarDisplay::update() } if (!info.buttonText.isEmpty()) { - QToolButton *infoWidgetButton = new QToolButton; + auto infoWidgetButton = new QToolButton; infoWidgetButton->setText(info.buttonText); connect(infoWidgetButton, &QAbstractButton::clicked, [info]() { info.m_buttonCallBack(); }); @@ -279,7 +279,7 @@ void InfoBarDisplay::update() } const Id id = info.id; - QToolButton *infoWidgetSuppressButton = 0; + QToolButton *infoWidgetSuppressButton = nullptr; if (info.globalSuppression == InfoBarEntry::GlobalSuppressionEnabled) { infoWidgetSuppressButton = new QToolButton; infoWidgetSuppressButton->setText(tr("Do Not Show Again")); diff --git a/src/plugins/coreplugin/iversioncontrol.cpp b/src/plugins/coreplugin/iversioncontrol.cpp index 678e4ecc8c..befa60fbab 100644 --- a/src/plugins/coreplugin/iversioncontrol.cpp +++ b/src/plugins/coreplugin/iversioncontrol.cpp @@ -87,7 +87,7 @@ ShellCommand *IVersionControl::createInitialCheckoutCommand(const QString &url, Q_UNUSED(baseDirectory); Q_UNUSED(localName); Q_UNUSED(extraArgs); - return 0; + return nullptr; } QString IVersionControl::vcsTopic(const QString &topLevel) @@ -106,9 +106,7 @@ IVersionControl::OpenSupportMode IVersionControl::openSupportMode(const QString return NoOpen; } -IVersionControl::TopicCache::~TopicCache() -{ -} +IVersionControl::TopicCache::~TopicCache() = default; /*! Returns the topic for repository under \a topLevel. @@ -175,7 +173,7 @@ bool TestVersionControl::managesFile(const QString &workingDirectory, const QStr QFileInfo fi(workingDirectory + QLatin1Char('/') + fileName); QString dir = fi.absolutePath(); - if (!managesDirectory(dir, 0)) + if (!managesDirectory(dir, nullptr)) return false; QString file = fi.absoluteFilePath(); return m_managedFiles.contains(file); diff --git a/src/plugins/coreplugin/iversioncontrol.h b/src/plugins/coreplugin/iversioncontrol.h index 6386487e70..cdb780f7fc 100644 --- a/src/plugins/coreplugin/iversioncontrol.h +++ b/src/plugins/coreplugin/iversioncontrol.h @@ -241,7 +241,7 @@ class CORE_EXPORT TestVersionControl : public IVersionControl Q_OBJECT public: TestVersionControl(Id id, const QString &name) : - m_id(id), m_displayName(name), m_dirCount(0), m_fileCount(0) + m_id(id), m_displayName(name) { } ~TestVersionControl() override; @@ -273,8 +273,8 @@ private: QString m_displayName; QHash<QString, QString> m_managedDirs; QSet<QString> m_managedFiles; - mutable int m_dirCount; - mutable int m_fileCount; + mutable int m_dirCount = 0; + mutable int m_fileCount = 0; }; } // namespace Core diff --git a/src/plugins/coreplugin/iwizardfactory.cpp b/src/plugins/coreplugin/iwizardfactory.cpp index 2b74a17118..ce784e9e79 100644 --- a/src/plugins/coreplugin/iwizardfactory.cpp +++ b/src/plugins/coreplugin/iwizardfactory.cpp @@ -151,7 +151,7 @@ namespace { static QList<IFeatureProvider *> s_providerList; QList<IWizardFactory *> s_allFactories; QList<IWizardFactory::FactoryCreator> s_factoryCreators; -QAction *s_inspectWizardAction = 0; +QAction *s_inspectWizardAction = nullptr; bool s_areFactoriesLoaded = false; bool s_isWizardRunning = false; QWidget *s_currentWizard = nullptr; @@ -270,7 +270,7 @@ QString IWizardFactory::runPath(const QString &defaultPath) Utils::Wizard *IWizardFactory::runWizard(const QString &path, QWidget *parent, Id platform, const QVariantMap &variables) { - QTC_ASSERT(!s_isWizardRunning, return 0); + QTC_ASSERT(!s_isWizardRunning, return nullptr); s_isWizardRunning = true; ICore::updateNewItemDialogState(); diff --git a/src/plugins/coreplugin/iwizardfactory.h b/src/plugins/coreplugin/iwizardfactory.h index 4ab761d792..77339199ae 100644 --- a/src/plugins/coreplugin/iwizardfactory.h +++ b/src/plugins/coreplugin/iwizardfactory.h @@ -92,7 +92,7 @@ public: virtual bool isAvailable(Id platformId) const; QSet<Id> supportedPlatforms() const; - typedef std::function<QList<IWizardFactory *>()> FactoryCreator; + using FactoryCreator = std::function<QList<IWizardFactory *>()>; static void registerFactoryCreator(const FactoryCreator &creator); // Utility to find all registered wizards diff --git a/src/plugins/coreplugin/jsexpander.cpp b/src/plugins/coreplugin/jsexpander.cpp index 0c44512497..effa3464cc 100644 --- a/src/plugins/coreplugin/jsexpander.cpp +++ b/src/plugins/coreplugin/jsexpander.cpp @@ -101,7 +101,7 @@ JsExpander::JsExpander() JsExpander::~JsExpander() { delete d; - d = 0; + d = nullptr; } } // namespace Core diff --git a/src/plugins/coreplugin/locator/basefilefilter.cpp b/src/plugins/coreplugin/locator/basefilefilter.cpp index 2053528687..27cec55045 100644 --- a/src/plugins/coreplugin/locator/basefilefilter.cpp +++ b/src/plugins/coreplugin/locator/basefilefilter.cpp @@ -67,8 +67,7 @@ public: } // Internal } // Core -BaseFileFilter::Iterator::~Iterator() -{} +BaseFileFilter::Iterator::~Iterator() = default; BaseFileFilter::BaseFileFilter() : d(new Internal::BaseFileFilterPrivate) diff --git a/src/plugins/coreplugin/locator/directoryfilter.cpp b/src/plugins/coreplugin/locator/directoryfilter.cpp index 5bcfd9eb45..645bae42d3 100644 --- a/src/plugins/coreplugin/locator/directoryfilter.cpp +++ b/src/plugins/coreplugin/locator/directoryfilter.cpp @@ -212,7 +212,7 @@ void DirectoryFilter::refresh(QFutureInterface<void> &future) if (future.isProgressUpdateNeeded() || future.progressValue() == 0 /*workaround for regression in Qt*/) { future.setProgressValueAndText(subDirIterator.currentProgress(), - tr("%1 filter update: %n files", 0, filesFound.size()).arg(displayName())); + tr("%1 filter update: %n files", nullptr, filesFound.size()).arg(displayName())); } } diff --git a/src/plugins/coreplugin/locator/executefilter.cpp b/src/plugins/coreplugin/locator/executefilter.cpp index 810ed8e8c2..b85bf4ff28 100644 --- a/src/plugins/coreplugin/locator/executefilter.cpp +++ b/src/plugins/coreplugin/locator/executefilter.cpp @@ -85,7 +85,7 @@ void ExecuteFilter::accept(LocatorFilterEntry selection, Q_UNUSED(newText) Q_UNUSED(selectionStart) Q_UNUSED(selectionLength) - ExecuteFilter *p = const_cast<ExecuteFilter *>(this); + auto p = const_cast<ExecuteFilter *>(this); const QString value = selection.displayName.trimmed(); const int index = m_commandHistory.indexOf(value); diff --git a/src/plugins/coreplugin/locator/ilocatorfilter.cpp b/src/plugins/coreplugin/locator/ilocatorfilter.cpp index 5ba268b5e3..79aee8f637 100644 --- a/src/plugins/coreplugin/locator/ilocatorfilter.cpp +++ b/src/plugins/coreplugin/locator/ilocatorfilter.cpp @@ -167,8 +167,8 @@ bool ILocatorFilter::openConfigDialog(QWidget *parent, bool &needsRefresh) QDialog dialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint); dialog.setWindowTitle(msgConfigureDialogTitle()); - QVBoxLayout *vlayout = new QVBoxLayout(&dialog); - QHBoxLayout *hlayout = new QHBoxLayout; + auto vlayout = new QVBoxLayout(&dialog); + auto hlayout = new QHBoxLayout; QLineEdit *shortcutEdit = new QLineEdit(shortcutString()); QCheckBox *includeByDefault = new QCheckBox(msgIncludeByDefault()); includeByDefault->setToolTip(msgIncludeByDefaultToolTip()); diff --git a/src/plugins/coreplugin/locator/javascriptfilter.h b/src/plugins/coreplugin/locator/javascriptfilter.h index feaf326036..a11b9c0f21 100644 --- a/src/plugins/coreplugin/locator/javascriptfilter.h +++ b/src/plugins/coreplugin/locator/javascriptfilter.h @@ -43,9 +43,9 @@ class JavaScriptFilter : public Core::ILocatorFilter Q_OBJECT public: JavaScriptFilter(); - ~JavaScriptFilter(); + ~JavaScriptFilter() override; - virtual void prepareSearch(const QString &entry) override; + void prepareSearch(const QString &entry) override; QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry) override; void accept(Core::LocatorFilterEntry selection, QString *newText, diff --git a/src/plugins/coreplugin/locator/locator.cpp b/src/plugins/coreplugin/locator/locator.cpp index dcfdba10ab..bdc1664c26 100644 --- a/src/plugins/coreplugin/locator/locator.cpp +++ b/src/plugins/coreplugin/locator/locator.cpp @@ -196,7 +196,7 @@ void Locator::updateFilterActions() continue; Id filterId = filter->id(); Id actionId = filter->actionId(); - QAction *action = 0; + QAction *action = nullptr; if (!actionCopy.contains(filterId)) { // register new action action = new QAction(filter->displayName(), this); diff --git a/src/plugins/coreplugin/locator/locator_test.cpp b/src/plugins/coreplugin/locator/locator_test.cpp index 68a65b88cd..8d6e4453a2 100644 --- a/src/plugins/coreplugin/locator/locator_test.cpp +++ b/src/plugins/coreplugin/locator/locator_test.cpp @@ -55,7 +55,7 @@ public: class ReferenceData { public: - ReferenceData() {} + ReferenceData() = default; ReferenceData(const QString &searchText, const ResultDataList &results) : searchText(searchText), results(results) {} diff --git a/src/plugins/coreplugin/locator/locatorfiltertest.cpp b/src/plugins/coreplugin/locator/locatorfiltertest.cpp index 889f3ba040..8318e008c1 100644 --- a/src/plugins/coreplugin/locator/locatorfiltertest.cpp +++ b/src/plugins/coreplugin/locator/locatorfiltertest.cpp @@ -41,9 +41,7 @@ BasicLocatorFilterTest::BasicLocatorFilterTest(ILocatorFilter *filter) : m_filte { } -BasicLocatorFilterTest::~BasicLocatorFilterTest() -{ -} +BasicLocatorFilterTest::~BasicLocatorFilterTest() = default; QList<LocatorFilterEntry> BasicLocatorFilterTest::matchesFor(const QString &searchText) { @@ -57,9 +55,7 @@ QList<LocatorFilterEntry> BasicLocatorFilterTest::matchesFor(const QString &sear return locatorSearch.results(); } -ResultData::ResultData() -{ -} +ResultData::ResultData() = default; ResultData::ResultData(const QString &textColumn1, const QString &textColumn2) : textColumn1(textColumn1), textColumn2(textColumn2) diff --git a/src/plugins/coreplugin/locator/locatorfiltertest.h b/src/plugins/coreplugin/locator/locatorfiltertest.h index 2841f72643..1b7a074bb7 100644 --- a/src/plugins/coreplugin/locator/locatorfiltertest.h +++ b/src/plugins/coreplugin/locator/locatorfiltertest.h @@ -51,7 +51,7 @@ private: class CORE_EXPORT ResultData { public: - typedef QList<ResultData> ResultDataList; + using ResultDataList = QList<ResultData>; ResultData(); ResultData(const QString &textColumn1, const QString &textColumn2); @@ -67,7 +67,7 @@ public: QString textColumn2; }; -typedef ResultData::ResultDataList ResultDataList; +using ResultDataList = ResultData::ResultDataList; } // namespace Tests } // namespace Core diff --git a/src/plugins/coreplugin/locator/locatorsettingspage.cpp b/src/plugins/coreplugin/locator/locatorsettingspage.cpp index 638448f103..d1b2df2183 100644 --- a/src/plugins/coreplugin/locator/locatorsettingspage.cpp +++ b/src/plugins/coreplugin/locator/locatorsettingspage.cpp @@ -161,7 +161,7 @@ QVariant CategoryItem::data(int column, int role) const } LocatorSettingsPage::LocatorSettingsPage(Locator *plugin) - : m_plugin(plugin), m_widget(0) + : m_plugin(plugin), m_widget(nullptr) { setId(Constants::FILTER_OPTIONS_PAGE); setDisplayName(QCoreApplication::translate("Locator", Constants::FILTER_OPTIONS_PAGE)); diff --git a/src/plugins/coreplugin/locator/locatorsettingspage.h b/src/plugins/coreplugin/locator/locatorsettingspage.h index bf2736e644..b2ce1a507b 100644 --- a/src/plugins/coreplugin/locator/locatorsettingspage.h +++ b/src/plugins/coreplugin/locator/locatorsettingspage.h @@ -52,9 +52,9 @@ class LocatorSettingsPage : public IOptionsPage public: explicit LocatorSettingsPage(Locator *plugin); - QWidget *widget(); - void apply(); - void finish(); + QWidget *widget() override; + void apply() override; + void finish() override; private: void updateButtonStates(); diff --git a/src/plugins/coreplugin/locator/locatorwidget.cpp b/src/plugins/coreplugin/locator/locatorwidget.cpp index 55be82072a..2318f07203 100644 --- a/src/plugins/coreplugin/locator/locatorwidget.cpp +++ b/src/plugins/coreplugin/locator/locatorwidget.cpp @@ -115,7 +115,7 @@ class CompletionList : public Utils::TreeView public: CompletionList(QWidget *parent = nullptr); - void setModel(QAbstractItemModel *model); + void setModel(QAbstractItemModel *model) override; void resizeHeaders(); @@ -124,8 +124,8 @@ public: void showCurrentItemToolTip(); - void keyPressEvent(QKeyEvent *event); - bool eventFilter(QObject *watched, QEvent *event); + void keyPressEvent(QKeyEvent *event) override; + bool eventFilter(QObject *watched, QEvent *event) override; private: QMetaObject::Connection m_updateSizeConnection; @@ -276,7 +276,7 @@ void CompletionList::setModel(QAbstractItemModel *newModel) }; if (model()) { - disconnect(model(), 0, this, 0); + disconnect(model(), nullptr, this, nullptr); } QTreeView::setModel(newModel); if (newModel) { @@ -506,7 +506,7 @@ void CompletionList::keyPressEvent(QKeyEvent *event) bool CompletionList::eventFilter(QObject *watched, QEvent *event) { if (watched == this && event->type() == QEvent::ShortcutOverride) { - QKeyEvent *ke = static_cast<QKeyEvent *>(event); + auto ke = static_cast<QKeyEvent *>(event); switch (ke->key()) { case Qt::Key_Escape: if (!ke->modifiers()) { @@ -537,7 +537,7 @@ LocatorWidget::LocatorWidget(Locator *locator) : setSizePolicy(sizePolicy); setMinimumSize(QSize(200, 0)); - QHBoxLayout *layout = new QHBoxLayout(this); + auto layout = new QHBoxLayout(this); setLayout(layout); layout->setMargin(0); layout->addWidget(m_fileLineEdit); @@ -623,7 +623,7 @@ void LocatorWidget::updateFilterList() bool LocatorWidget::eventFilter(QObject *obj, QEvent *event) { if (obj == m_fileLineEdit && event->type() == QEvent::ShortcutOverride) { - QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); + auto keyEvent = static_cast<QKeyEvent *>(event); switch (keyEvent->key()) { case Qt::Key_P: case Qt::Key_N: @@ -638,7 +638,7 @@ bool LocatorWidget::eventFilter(QObject *obj, QEvent *event) if (QToolTip::isVisible()) QToolTip::hideText(); - QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); + auto keyEvent = static_cast<QKeyEvent *>(event); switch (keyEvent->key()) { case Qt::Key_PageUp: case Qt::Key_PageDown: @@ -683,7 +683,7 @@ bool LocatorWidget::eventFilter(QObject *obj, QEvent *event) break; } } else if (obj == m_fileLineEdit && event->type() == QEvent::KeyRelease) { - QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); + auto keyEvent = static_cast<QKeyEvent *>(event); if (m_possibleToolTipRequest) { m_possibleToolTipRequest = false; if ((keyEvent->key() == Qt::Key_Alt) @@ -695,13 +695,13 @@ bool LocatorWidget::eventFilter(QObject *obj, QEvent *event) } else if (obj == m_fileLineEdit && event->type() == QEvent::FocusOut) { emit lostFocus(); } else if (obj == m_fileLineEdit && event->type() == QEvent::FocusIn) { - QFocusEvent *fev = static_cast<QFocusEvent *>(event); + auto fev = static_cast<QFocusEvent *>(event); if (fev->reason() != Qt::ActiveWindowFocusReason) showPopupNow(); } else if (obj == this && event->type() == QEvent::ParentChange) { emit parentChanged(); } else if (obj == this && event->type() == QEvent::ShortcutOverride) { - QKeyEvent *ke = static_cast<QKeyEvent *>(event); + auto ke = static_cast<QKeyEvent *>(event); switch (ke->key()) { case Qt::Key_Escape: if (!ke->modifiers()) { diff --git a/src/plugins/coreplugin/locator/locatorwidget.h b/src/plugins/coreplugin/locator/locatorwidget.h index 59805a76e2..22ab9bbc01 100644 --- a/src/plugins/coreplugin/locator/locatorwidget.h +++ b/src/plugins/coreplugin/locator/locatorwidget.h @@ -82,7 +82,7 @@ private: void setFocusToCurrentMode(); void updateFilterList(); - bool eventFilter(QObject *obj, QEvent *event); + bool eventFilter(QObject *obj, QEvent *event) override; void updateCompletionList(const QString &text); QList<ILocatorFilter*> filtersFor(const QString &text, QString &searchText); diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp index 53e2edcbf7..68af2e6f89 100644 --- a/src/plugins/coreplugin/mainwindow.cpp +++ b/src/plugins/coreplugin/mainwindow.cpp @@ -192,7 +192,7 @@ MainWindow::MainWindow() : statusBar()->setProperty("p_styled", true); auto dropSupport = new DropSupport(this, [](QDropEvent *event, DropSupport *) { - return event->source() == 0; // only accept drops from the "outside" (e.g. file manager) + return event->source() == nullptr; // only accept drops from the "outside" (e.g. file manager) }); connect(dropSupport, &DropSupport::filesDropped, this, &MainWindow::openDroppedFiles); @@ -950,7 +950,7 @@ void MainWindow::updateContextObject(const QList<IContext *> &context) if (debugMainWindow) { qDebug() << "new context objects =" << context; foreach (IContext *c, context) - qDebug() << (c ? c->widget() : 0) << (c ? c->widget()->metaObject()->className() : 0); + qDebug() << (c ? c->widget() : nullptr) << (c ? c->widget()->metaObject()->className() : nullptr); } } @@ -1149,7 +1149,7 @@ void MainWindow::destroyVersionDialog() { if (m_versionDialog) { m_versionDialog->deleteLater(); - m_versionDialog = 0; + m_versionDialog = nullptr; } } diff --git a/src/plugins/coreplugin/manhattanstyle.cpp b/src/plugins/coreplugin/manhattanstyle.cpp index add7b8c753..78e819a9c3 100644 --- a/src/plugins/coreplugin/manhattanstyle.cpp +++ b/src/plugins/coreplugin/manhattanstyle.cpp @@ -142,7 +142,7 @@ ManhattanStyle::ManhattanStyle(const QString &baseStyleName) ManhattanStyle::~ManhattanStyle() { delete d; - d = 0; + d = nullptr; } QPixmap ManhattanStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const @@ -398,7 +398,7 @@ void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption QRect oldRect; QRect newRect; if (widget && (element == PE_PanelButtonTool) && !animating) { - QWidget *w = const_cast<QWidget *> (widget); + auto w = const_cast<QWidget *> (widget); int oldState = w->property("_q_stylestate").toInt(); oldRect = w->property("_q_stylerect").toRect(); newRect = w->rect(); @@ -422,7 +422,7 @@ void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption opt.state = (QStyle::State)oldState; opt.state |= State_Animating; startImage.fill(0); - Transition *t = new Transition; + auto t = new Transition; t->setWidget(w); QPainter startPainter(&startImage); if (!anim) { @@ -630,7 +630,7 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt switch (element) { case CE_MenuItem: painter->save(); - if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { + if (const auto mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { const bool enabled = mbi->state & State_Enabled; QStyleOptionMenuItem item = *mbi; item.rect = mbi->rect; @@ -649,7 +649,7 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt case CE_MenuBarItem: painter->save(); - if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { + if (const auto mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { const bool act = mbi->state & (State_Sunken | State_Selected); const bool dis = !(mbi->state & State_Enabled); @@ -687,7 +687,7 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt break; case CE_ComboBoxLabel: - if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { + if (const auto cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { if (panelWidget(widget)) { painter->save(); QRect editRect = subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, widget); @@ -872,7 +872,7 @@ void ManhattanStyle::drawComplexControl(ComplexControl control, const QStyleOpti QRect rect = option->rect; switch (control) { case CC_ToolButton: - if (const QStyleOptionToolButton *toolbutton = qstyleoption_cast<const QStyleOptionToolButton *>(option)) { + if (const auto toolbutton = qstyleoption_cast<const QStyleOptionToolButton *>(option)) { bool reverse = option->direction == Qt::RightToLeft; bool drawborder = (widget && widget->property("showborder").toBool()); @@ -946,7 +946,7 @@ void ManhattanStyle::drawComplexControl(ComplexControl control, const QStyleOpti break; case CC_ComboBox: - if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { + if (const auto cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { painter->save(); bool isEmpty = cb->currentText.isEmpty() && cb->currentIcon.isNull(); bool reverse = option->direction == Qt::RightToLeft; diff --git a/src/plugins/coreplugin/messagemanager.cpp b/src/plugins/coreplugin/messagemanager.cpp index f8d2b97506..c4bf4269a4 100644 --- a/src/plugins/coreplugin/messagemanager.cpp +++ b/src/plugins/coreplugin/messagemanager.cpp @@ -30,8 +30,8 @@ using namespace Core; -static MessageManager *m_instance = 0; -Internal::MessageOutputWindow *m_messageOutputWindow = 0; +static MessageManager *m_instance = nullptr; +Internal::MessageOutputWindow *m_messageOutputWindow = nullptr; MessageManager *MessageManager::instance() { @@ -54,7 +54,7 @@ void MessageManager::showOutputPane(Core::MessageManager::PrintToOutputPaneFlags MessageManager::MessageManager() { m_instance = this; - m_messageOutputWindow = 0; + m_messageOutputWindow = nullptr; qRegisterMetaType<MessageManager::PrintToOutputPaneFlags>(); } @@ -64,7 +64,7 @@ MessageManager::~MessageManager() ExtensionSystem::PluginManager::removeObject(m_messageOutputWindow); delete m_messageOutputWindow; } - m_instance = 0; + m_instance = nullptr; } void MessageManager::init() diff --git a/src/plugins/coreplugin/messageoutputwindow.cpp b/src/plugins/coreplugin/messageoutputwindow.cpp index 3675b23685..35a1bd50be 100644 --- a/src/plugins/coreplugin/messageoutputwindow.cpp +++ b/src/plugins/coreplugin/messageoutputwindow.cpp @@ -46,7 +46,7 @@ MessageOutputWindow::MessageOutputWindow() QColor activeHighlightedText = p.color(QPalette::Active, QPalette::HighlightedText); p.setColor(QPalette::HighlightedText, activeHighlightedText); m_widget->setPalette(p); - Aggregation::Aggregate *agg = new Aggregation::Aggregate; + auto agg = new Aggregation::Aggregate; agg->add(m_widget); agg->add(new BaseTextFind(m_widget)); } diff --git a/src/plugins/coreplugin/mimetypemagicdialog.cpp b/src/plugins/coreplugin/mimetypemagicdialog.cpp index 7968560562..5c1566d022 100644 --- a/src/plugins/coreplugin/mimetypemagicdialog.cpp +++ b/src/plugins/coreplugin/mimetypemagicdialog.cpp @@ -45,10 +45,7 @@ static Utils::Internal::MimeMagicRule::Type typeValue(int i) } MimeTypeMagicDialog::MimeTypeMagicDialog(QWidget *parent) : - QDialog(parent), - m_customRangeStart(0), - m_customRangeEnd(0), - m_customPriority(50) + QDialog(parent) { ui.setupUi(this); setWindowTitle(tr("Add Magic Header")); diff --git a/src/plugins/coreplugin/mimetypemagicdialog.h b/src/plugins/coreplugin/mimetypemagicdialog.h index 5f5bf8bfe6..f2140b28f6 100644 --- a/src/plugins/coreplugin/mimetypemagicdialog.h +++ b/src/plugins/coreplugin/mimetypemagicdialog.h @@ -36,8 +36,7 @@ class MagicData { public: MagicData() - : m_rule(Utils::Internal::MimeMagicRule::String, QByteArray(" "), 0, 0), - m_priority(0) + : m_rule(Utils::Internal::MimeMagicRule::String, QByteArray(" "), 0, 0) { } @@ -53,14 +52,14 @@ public: static QByteArray normalizedMask(const Utils::Internal::MimeMagicRule &rule); Utils::Internal::MimeMagicRule m_rule; - int m_priority; + int m_priority = 0; }; class MimeTypeMagicDialog : public QDialog { Q_DECLARE_TR_FUNCTIONS(Core::Internal::MimeTypeMagicDialog) public: - explicit MimeTypeMagicDialog(QWidget *parent = 0); + explicit MimeTypeMagicDialog(QWidget *parent = nullptr); void setMagicData(const MagicData &data); MagicData magicData() const; @@ -69,12 +68,12 @@ private: void setToRecommendedValues(); void applyRecommended(bool checked); void validateAccept(); - Utils::Internal::MimeMagicRule createRule(QString *errorMessage = 0) const; + Utils::Internal::MimeMagicRule createRule(QString *errorMessage = nullptr) const; Ui::MimeTypeMagicDialog ui; - int m_customRangeStart; - int m_customRangeEnd; - int m_customPriority; + int m_customRangeStart = 0; + int m_customRangeEnd = 0; + int m_customPriority = 50; }; } // Internal diff --git a/src/plugins/coreplugin/mimetypesettings.cpp b/src/plugins/coreplugin/mimetypesettings.cpp index eb5c6f695f..a5750d13c7 100644 --- a/src/plugins/coreplugin/mimetypesettings.cpp +++ b/src/plugins/coreplugin/mimetypesettings.cpp @@ -242,7 +242,7 @@ class MimeTypeSettingsPrivate : public QObject public: MimeTypeSettingsPrivate(); - virtual ~MimeTypeSettingsPrivate(); + ~MimeTypeSettingsPrivate() override; void configureUi(QWidget *w); @@ -264,7 +264,7 @@ private: static void writeUserModifiedMimeTypes(); public: - typedef QHash<QString, UserMimeType> UserMimeTypeHash; // name -> mime type + using UserMimeTypeHash = QHash<QString, UserMimeType>; // name -> mime type static const QChar kSemiColon; static UserMimeTypeHash readUserModifiedMimeTypes(); static void applyUserModifiedMimeTypes(const UserMimeTypeHash &mimeTypes); @@ -293,8 +293,7 @@ MimeTypeSettingsPrivate::MimeTypeSettingsPrivate() this, &MimeTypeSettingsPrivate::writeUserModifiedMimeTypes); } -MimeTypeSettingsPrivate::~MimeTypeSettingsPrivate() -{} +MimeTypeSettingsPrivate::~MimeTypeSettingsPrivate() = default; void MimeTypeSettingsPrivate::configureUi(QWidget *w) { @@ -393,7 +392,7 @@ void MimeTypeSettingsPrivate::addMagicHeaderRow(const MagicData &data) void MimeTypeSettingsPrivate::editMagicHeaderRowData(const int row, const MagicData &data) { - QTreeWidgetItem *item = new QTreeWidgetItem; + auto item = new QTreeWidgetItem; item->setText(0, QString::fromUtf8(data.m_rule.value())); item->setText(1, QString::fromLatin1(Utils::Internal::MimeMagicRule::typeName(data.m_rule.type()))); item->setText(2, QString::fromLatin1("%1:%2").arg(data.m_rule.startPos()).arg(data.m_rule.endPos())); diff --git a/src/plugins/coreplugin/mimetypesettings.h b/src/plugins/coreplugin/mimetypesettings.h index 8153ecbb1b..3d9059bbfe 100644 --- a/src/plugins/coreplugin/mimetypesettings.h +++ b/src/plugins/coreplugin/mimetypesettings.h @@ -37,12 +37,12 @@ class MimeTypeSettings : public IOptionsPage Q_OBJECT public: - MimeTypeSettings(QObject *parent = 0); - virtual ~MimeTypeSettings(); + MimeTypeSettings(QObject *parent = nullptr); + ~MimeTypeSettings() override; - virtual QWidget *widget(); - virtual void apply(); - virtual void finish(); + QWidget *widget() override; + void apply() override; + void finish() override; static void restoreSettings(); private: diff --git a/src/plugins/coreplugin/minisplitter.cpp b/src/plugins/coreplugin/minisplitter.cpp index 64ee062ca1..6bac3ffdfc 100644 --- a/src/plugins/coreplugin/minisplitter.cpp +++ b/src/plugins/coreplugin/minisplitter.cpp @@ -46,8 +46,8 @@ public: setAttribute(Qt::WA_MouseNoMask, true); } protected: - void resizeEvent(QResizeEvent *event); - void paintEvent(QPaintEvent *event); + void resizeEvent(QResizeEvent *event) override; + void paintEvent(QPaintEvent *event) override; private: bool m_lightColored; diff --git a/src/plugins/coreplugin/modemanager.cpp b/src/plugins/coreplugin/modemanager.cpp index cab2458037..dac3ae8023 100644 --- a/src/plugins/coreplugin/modemanager.cpp +++ b/src/plugins/coreplugin/modemanager.cpp @@ -80,7 +80,7 @@ struct ModeManagerPrivate }; static ModeManagerPrivate *d; -static ModeManager *m_instance = 0; +static ModeManager *m_instance = nullptr; static int indexOf(Id id) { @@ -121,8 +121,8 @@ ModeManager::ModeManager(Internal::MainWindow *mainWindow, ModeManager::~ModeManager() { delete d; - d = 0; - m_instance = 0; + d = nullptr; + m_instance = nullptr; } Id ModeManager::currentMode() @@ -138,7 +138,7 @@ static IMode *findMode(Id id) const int index = indexOf(id); if (index >= 0) return d->m_modes.at(index); - return 0; + return nullptr; } void ModeManager::activateMode(Id id) diff --git a/src/plugins/coreplugin/navigationsubwidget.cpp b/src/plugins/coreplugin/navigationsubwidget.cpp index 0ed1a4ca22..c8aed179c5 100644 --- a/src/plugins/coreplugin/navigationsubwidget.cpp +++ b/src/plugins/coreplugin/navigationsubwidget.cpp @@ -60,17 +60,17 @@ NavigationSubWidget::NavigationSubWidget(NavigationWidget *parentWidget, int pos m_navigationComboBox->setFocusPolicy(Qt::TabFocus); m_navigationComboBox->setMinimumContentsLength(0); m_navigationComboBox->setModel(parentWidget->factoryModel()); - m_navigationWidget = 0; - m_navigationWidgetFactory = 0; + m_navigationWidget = nullptr; + m_navigationWidgetFactory = nullptr; m_toolBar = new Utils::StyledBar(this); - QHBoxLayout *toolBarLayout = new QHBoxLayout; + auto toolBarLayout = new QHBoxLayout; toolBarLayout->setMargin(0); toolBarLayout->setSpacing(0); m_toolBar->setLayout(toolBarLayout); toolBarLayout->addWidget(m_navigationComboBox); - QToolButton *splitAction = new QToolButton(); + auto splitAction = new QToolButton(); splitAction->setIcon(Utils::Icons::SPLIT_HORIZONTAL_TOOLBAR.icon()); splitAction->setToolTip(tr("Split")); splitAction->setPopupMode(QToolButton::InstantPopup); @@ -86,7 +86,7 @@ NavigationSubWidget::NavigationSubWidget(NavigationWidget *parentWidget, int pos toolBarLayout->addWidget(splitAction); toolBarLayout->addWidget(m_closeButton); - QVBoxLayout *lay = new QVBoxLayout(); + auto lay = new QVBoxLayout(); lay->setMargin(0); lay->setSpacing(0); setLayout(lay); @@ -103,9 +103,7 @@ NavigationSubWidget::NavigationSubWidget(NavigationWidget *parentWidget, int pos comboBoxIndexChanged(factoryIndex); } -NavigationSubWidget::~NavigationSubWidget() -{ -} +NavigationSubWidget::~NavigationSubWidget() = default; void NavigationSubWidget::comboBoxIndexChanged(int factoryIndex) { @@ -118,8 +116,8 @@ void NavigationSubWidget::comboBoxIndexChanged(int factoryIndex) // Remove old Widget delete m_navigationWidget; - m_navigationWidget = 0; - m_navigationWidgetFactory = 0; + m_navigationWidget = nullptr; + m_navigationWidgetFactory = nullptr; if (factoryIndex == -1) return; @@ -132,7 +130,7 @@ void NavigationSubWidget::comboBoxIndexChanged(int factoryIndex) // Add Toolbutton m_additionalToolBarWidgets = n.dockToolBarWidgets; - QHBoxLayout *layout = qobject_cast<QHBoxLayout *>(m_toolBar->layout()); + auto layout = qobject_cast<QHBoxLayout *>(m_toolBar->layout()); foreach (QToolButton *w, m_additionalToolBarWidgets) { layout->insertWidget(layout->count()-2, w); } @@ -193,7 +191,7 @@ Core::Command *NavigationSubWidget::command(const QString &title) const QHash<Id, Command *>::const_iterator r = commandMap.find(Id::fromString(title)); if (r != commandMap.end()) return r.value(); - return 0; + return nullptr; } void NavigationSubWidget::setCloseIcon(const QIcon &icon) diff --git a/src/plugins/coreplugin/navigationsubwidget.h b/src/plugins/coreplugin/navigationsubwidget.h index a1906a8a21..39339c4db1 100644 --- a/src/plugins/coreplugin/navigationsubwidget.h +++ b/src/plugins/coreplugin/navigationsubwidget.h @@ -48,7 +48,7 @@ class NavigationSubWidget : public QWidget Q_OBJECT public: NavigationSubWidget(NavigationWidget *parentWidget, int position, int factoryIndex); - virtual ~NavigationSubWidget(); + ~NavigationSubWidget() override; INavigationWidgetFactory *factory(); @@ -95,10 +95,10 @@ class CommandComboBox : public QComboBox Q_OBJECT public: - explicit CommandComboBox(QWidget *parent = 0); + explicit CommandComboBox(QWidget *parent = nullptr); protected: - bool event(QEvent *event); + bool event(QEvent *event) override; private: virtual const Command *command(const QString &text) const = 0; @@ -114,7 +114,7 @@ public: m_navSubWidget(navSubWidget) {} private: - virtual const Command *command(const QString &text) const + const Command *command(const QString &text) const override { return m_navSubWidget->command(text); } NavigationSubWidget *m_navSubWidget; diff --git a/src/plugins/coreplugin/navigationwidget.cpp b/src/plugins/coreplugin/navigationwidget.cpp index ff9c6cc581..f223cfa777 100644 --- a/src/plugins/coreplugin/navigationwidget.cpp +++ b/src/plugins/coreplugin/navigationwidget.cpp @@ -87,7 +87,7 @@ NavigationWidgetPlaceHolder::~NavigationWidgetPlaceHolder() void NavigationWidgetPlaceHolder::applyStoredSize() { - QSplitter *splitter = qobject_cast<QSplitter *>(parentWidget()); + auto splitter = qobject_cast<QSplitter *>(parentWidget()); if (splitter) { // A splitter we need to resize the splitter sizes QList<int> sizes = splitter->sizes(); @@ -332,7 +332,7 @@ Internal::NavigationSubWidget *NavigationWidget::insertSubItem(int position, int if (!d->m_subWidgets.isEmpty()) // Make all icons the bottom icon d->m_subWidgets.at(0)->setCloseIcon(Utils::Icons::CLOSE_SPLIT_BOTTOM.icon()); - Internal::NavigationSubWidget *nsw = new Internal::NavigationSubWidget(this, position, factoryIndex); + auto nsw = new Internal::NavigationSubWidget(this, position, factoryIndex); connect(nsw, &Internal::NavigationSubWidget::splitMe, this, &NavigationWidget::splitSubWidget); connect(nsw, &Internal::NavigationSubWidget::closeMe, this, &NavigationWidget::closeSubWidget); connect(nsw, &Internal::NavigationSubWidget::factoryIndexChanged, @@ -371,7 +371,7 @@ QWidget *NavigationWidget::activateSubWidget(Id factoryId, int preferredPosition void NavigationWidget::splitSubWidget(int factoryIndex) { - Internal::NavigationSubWidget *original = qobject_cast<Internal::NavigationSubWidget *>(sender()); + auto original = qobject_cast<Internal::NavigationSubWidget *>(sender()); int pos = indexOf(original) + 1; insertSubItem(pos, factoryIndex); } @@ -379,7 +379,7 @@ void NavigationWidget::splitSubWidget(int factoryIndex) void NavigationWidget::closeSubWidget() { if (d->m_subWidgets.count() != 1) { - Internal::NavigationSubWidget *subWidget = qobject_cast<Internal::NavigationSubWidget *>(sender()); + auto subWidget = qobject_cast<Internal::NavigationSubWidget *>(sender()); subWidget->saveSettings(); int position = d->m_subWidgets.indexOf(subWidget); @@ -543,7 +543,7 @@ QString NavigationWidget::settingsKey(const QString &key) const void NavigationWidget::onSubWidgetFactoryIndexChanged(int factoryIndex) { Q_UNUSED(factoryIndex); - Internal::NavigationSubWidget *subWidget = qobject_cast<Internal::NavigationSubWidget *>(sender()); + auto subWidget = qobject_cast<Internal::NavigationSubWidget *>(sender()); QTC_ASSERT(subWidget, return); Id factoryId = subWidget->factory()->id(); NavigationWidgetPrivate::updateActivationsMap(factoryId, {d->m_side, subWidget->position()}); diff --git a/src/plugins/coreplugin/opendocumentstreeview.cpp b/src/plugins/coreplugin/opendocumentstreeview.cpp index 13290846a3..7861199bdd 100644 --- a/src/plugins/coreplugin/opendocumentstreeview.cpp +++ b/src/plugins/coreplugin/opendocumentstreeview.cpp @@ -38,20 +38,19 @@ namespace Internal { class OpenDocumentsDelegate : public QStyledItemDelegate { public: - explicit OpenDocumentsDelegate(QObject *parent = 0); + explicit OpenDocumentsDelegate(QObject *parent = nullptr); void setCloseButtonVisible(bool visible); void handlePressed(const QModelIndex &index); void paint(QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index) const; + const QModelIndex &index) const override; mutable QModelIndex pressedIndex; - bool closeButtonVisible; + bool closeButtonVisible = true; }; OpenDocumentsDelegate::OpenDocumentsDelegate(QObject *parent) - : QStyledItemDelegate(parent), - closeButtonVisible(true) + : QStyledItemDelegate(parent) { } @@ -141,7 +140,7 @@ bool OpenDocumentsTreeView::eventFilter(QObject *obj, QEvent *event) { if (obj == this && event->type() == QEvent::KeyPress && currentIndex().isValid()) { - QKeyEvent *ke = static_cast<QKeyEvent*>(event); + auto ke = static_cast<QKeyEvent*>(event); if ((ke->key() == Qt::Key_Delete || ke->key() == Qt::Key_Backspace) && ke->modifiers() == 0) { @@ -149,7 +148,7 @@ bool OpenDocumentsTreeView::eventFilter(QObject *obj, QEvent *event) } } else if (obj == viewport() && event->type() == QEvent::MouseButtonRelease) { - QMouseEvent * me = static_cast<QMouseEvent*>(event); + auto me = static_cast<QMouseEvent*>(event); if (me->button() == Qt::MiddleButton && me->modifiers() == Qt::NoModifier) { QModelIndex index = indexAt(me->pos()); diff --git a/src/plugins/coreplugin/outputpane.cpp b/src/plugins/coreplugin/outputpane.cpp index 6ac11d9780..9639896348 100644 --- a/src/plugins/coreplugin/outputpane.cpp +++ b/src/plugins/coreplugin/outputpane.cpp @@ -51,7 +51,7 @@ OutputPanePlaceHolderPrivate::OutputPanePlaceHolderPrivate(Id mode, QSplitter *p { } -OutputPanePlaceHolder *OutputPanePlaceHolderPrivate::m_current = 0; +OutputPanePlaceHolder *OutputPanePlaceHolderPrivate::m_current = nullptr; OutputPanePlaceHolder::OutputPanePlaceHolder(Id mode, QSplitter *parent) : QWidget(parent), d(new OutputPanePlaceHolderPrivate(mode, parent)) @@ -75,7 +75,7 @@ OutputPanePlaceHolder::~OutputPanePlaceHolder() { if (d->m_current == this) { if (Internal::OutputPaneManager *om = Internal::OutputPaneManager::instance()) { - om->setParent(0); + om->setParent(nullptr); om->hide(); } OutputPanePlaceHolderPrivate::m_current = nullptr; @@ -86,12 +86,12 @@ OutputPanePlaceHolder::~OutputPanePlaceHolder() void OutputPanePlaceHolder::currentModeChanged(Id mode) { if (d->m_current == this) { - d->m_current = 0; + d->m_current = nullptr; if (d->m_initialized) Internal::OutputPaneManager::setOutputPaneHeightSetting(d->m_nonMaximizedSize); Internal::OutputPaneManager *om = Internal::OutputPaneManager::instance(); om->hide(); - om->setParent(0); + om->setParent(nullptr); om->updateStatusButtons(false); } if (d->m_mode == mode) { diff --git a/src/plugins/coreplugin/outputpanemanager.cpp b/src/plugins/coreplugin/outputpanemanager.cpp index 7262decedf..00e1c9699e 100644 --- a/src/plugins/coreplugin/outputpanemanager.cpp +++ b/src/plugins/coreplugin/outputpanemanager.cpp @@ -118,7 +118,7 @@ static int numberAreaWidth() // OutputPaneManager //// -static OutputPaneManager *m_instance = 0; +static OutputPaneManager *m_instance = nullptr; void OutputPaneManager::create() { @@ -128,7 +128,7 @@ void OutputPaneManager::create() void OutputPaneManager::destroy() { delete m_instance; - m_instance = 0; + m_instance = nullptr; } OutputPaneManager *OutputPaneManager::instance() @@ -174,15 +174,11 @@ OutputPaneManager::OutputPaneManager(QWidget *parent) : m_titleLabel(new QLabel), m_manageButton(new OutputPaneManageButton), m_closeButton(new QToolButton), - m_minMaxAction(0), m_minMaxButton(new QToolButton), - m_nextAction(0), - m_prevAction(0), m_outputWidgetPane(new QStackedWidget), m_opToolBarWidgets(new QStackedWidget), m_minimizeIcon(Utils::Icons::ARROW_DOWN.icon()), - m_maximizeIcon(Utils::Icons::ARROW_UP.icon()), - m_outputPaneHeightSetting(0) + m_maximizeIcon(Utils::Icons::ARROW_UP.icon()) { setWindowTitle(tr("Output")); @@ -212,11 +208,11 @@ OutputPaneManager::OutputPaneManager(QWidget *parent) : connect(ICore::instance(), &ICore::saveSettingsRequested, this, &OutputPaneManager::saveSettings); - QVBoxLayout *mainlayout = new QVBoxLayout; + auto mainlayout = new QVBoxLayout; mainlayout->setSpacing(0); mainlayout->setMargin(0); m_toolBar = new StyledBar; - QHBoxLayout *toolLayout = new QHBoxLayout(m_toolBar); + auto toolLayout = new QHBoxLayout(m_toolBar); toolLayout->setMargin(0); toolLayout->setSpacing(0); toolLayout->addWidget(m_titleLabel); @@ -317,7 +313,7 @@ OutputPaneManager::OutputPaneManager(QWidget *parent) : }); QWidget *toolButtonsContainer = new QWidget(m_opToolBarWidgets); - QHBoxLayout *toolButtonsLayout = new QHBoxLayout; + auto toolButtonsLayout = new QHBoxLayout; toolButtonsLayout->setMargin(0); toolButtonsLayout->setSpacing(0); foreach (QWidget *toolButton, outPane->toolBarWidgets()) @@ -369,9 +365,7 @@ OutputPaneManager::OutputPaneManager(QWidget *parent) : readSettings(); } -OutputPaneManager::~OutputPaneManager() -{ -} +OutputPaneManager::~OutputPaneManager() = default; void OutputPaneManager::shortcutTriggered(int idx) { @@ -691,7 +685,7 @@ void OutputPaneToggleButton::paintEvent(QPaintEvent*) if (c != Theme::BackgroundColorDark) p.fillRect(rect(), creatorTheme()->color(c)); } else { - const QImage *image = 0; + const QImage *image = nullptr; if (isDown()) { static const QImage pressed( StyleHelper::dpiSpecificImageFile(":/utils/images/panel_button_pressed.png")); diff --git a/src/plugins/coreplugin/outputpanemanager.h b/src/plugins/coreplugin/outputpanemanager.h index 5570ceeaa8..80ff8dad40 100644 --- a/src/plugins/coreplugin/outputpanemanager.h +++ b/src/plugins/coreplugin/outputpanemanager.h @@ -89,28 +89,27 @@ private: void buttonTriggered(int idx); void readSettings(); - QLabel *m_titleLabel; - OutputPaneManageButton *m_manageButton; - QAction *m_clearAction; - QToolButton *m_clearButton; - QToolButton *m_closeButton; - - QAction *m_minMaxAction; - QToolButton *m_minMaxButton; - - QAction *m_nextAction; - QAction *m_prevAction; - QToolButton *m_prevToolButton; - QToolButton *m_nextToolButton; - QWidget *m_toolBar; - - QStackedWidget *m_outputWidgetPane; - QStackedWidget *m_opToolBarWidgets; - QWidget *m_buttonsWidget; + QLabel *m_titleLabel = nullptr; + OutputPaneManageButton *m_manageButton = nullptr; + QAction *m_clearAction = nullptr; + QToolButton *m_clearButton = nullptr; + QToolButton *m_closeButton = nullptr; + + QAction *m_minMaxAction = nullptr; + QToolButton *m_minMaxButton = nullptr; + + QAction *m_nextAction = nullptr; + QAction *m_prevAction = nullptr; + QToolButton *m_prevToolButton = nullptr; + QToolButton *m_nextToolButton = nullptr; + QWidget *m_toolBar = nullptr; + + QStackedWidget *m_outputWidgetPane = nullptr; + QStackedWidget *m_opToolBarWidgets = nullptr; + QWidget *m_buttonsWidget = nullptr; QIcon m_minimizeIcon; QIcon m_maximizeIcon; - bool m_maximized; - int m_outputPaneHeightSetting; + int m_outputPaneHeightSetting = 0; }; class BadgeLabel diff --git a/src/plugins/coreplugin/outputwindow.cpp b/src/plugins/coreplugin/outputwindow.cpp index 2d69b09e54..690f10d506 100644 --- a/src/plugins/coreplugin/outputwindow.cpp +++ b/src/plugins/coreplugin/outputwindow.cpp @@ -87,12 +87,12 @@ OutputWindow::OutputWindow(Context context, QWidget *parent) d->outputWindowContext->setWidget(this); ICore::addContextObject(d->outputWindowContext); - QAction *undoAction = new QAction(this); - QAction *redoAction = new QAction(this); - QAction *cutAction = new QAction(this); - QAction *copyAction = new QAction(this); - QAction *pasteAction = new QAction(this); - QAction *selectAllAction = new QAction(this); + auto undoAction = new QAction(this); + auto redoAction = new QAction(this); + auto cutAction = new QAction(this); + auto copyAction = new QAction(this); + auto pasteAction = new QAction(this); + auto selectAllAction = new QAction(this); ActionManager::registerAction(undoAction, Constants::UNDO, context); ActionManager::registerAction(redoAction, Constants::REDO, context); diff --git a/src/plugins/coreplugin/plugindialog.cpp b/src/plugins/coreplugin/plugindialog.cpp index f3db85bccc..9163e1a2af 100644 --- a/src/plugins/coreplugin/plugindialog.cpp +++ b/src/plugins/coreplugin/plugindialog.cpp @@ -53,7 +53,7 @@ PluginDialog::PluginDialog(QWidget *parent) { setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); - QVBoxLayout *vl = new QVBoxLayout(this); + auto vl = new QVBoxLayout(this); auto filterLayout = new QHBoxLayout; vl->addLayout(filterLayout); @@ -85,7 +85,7 @@ PluginDialog::PluginDialog(QWidget *parent) if (!s_isRestartRequired) m_restartRequired->setVisible(false); - QHBoxLayout *hl = new QHBoxLayout; + auto hl = new QHBoxLayout; hl->addWidget(m_detailsButton); hl->addWidget(m_errorDetailsButton); hl->addSpacing(10); @@ -144,9 +144,9 @@ void PluginDialog::openDetails(ExtensionSystem::PluginSpec *spec) return; QDialog dialog(this); dialog.setWindowTitle(tr("Plugin Details of %1").arg(spec->name())); - QVBoxLayout *layout = new QVBoxLayout; + auto layout = new QVBoxLayout; dialog.setLayout(layout); - ExtensionSystem::PluginDetailsView *details = new ExtensionSystem::PluginDetailsView(&dialog); + auto details = new ExtensionSystem::PluginDetailsView(&dialog); layout->addWidget(details); details->update(spec); QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, &dialog); @@ -164,9 +164,9 @@ void PluginDialog::openErrorDetails() return; QDialog dialog(this); dialog.setWindowTitle(tr("Plugin Errors of %1").arg(spec->name())); - QVBoxLayout *layout = new QVBoxLayout; + auto layout = new QVBoxLayout; dialog.setLayout(layout); - ExtensionSystem::PluginErrorView *errors = new ExtensionSystem::PluginErrorView(&dialog); + auto errors = new ExtensionSystem::PluginErrorView(&dialog); layout->addWidget(errors); errors->update(spec); QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, &dialog); diff --git a/src/plugins/coreplugin/progressmanager/futureprogress.cpp b/src/plugins/coreplugin/progressmanager/futureprogress.cpp index b06670c656..d7eeec9ff4 100644 --- a/src/plugins/coreplugin/progressmanager/futureprogress.cpp +++ b/src/plugins/coreplugin/progressmanager/futureprogress.cpp @@ -74,8 +74,8 @@ public: }; FutureProgressPrivate::FutureProgressPrivate(FutureProgress *q) : - m_progress(new Internal::ProgressBar), m_widget(0), m_widgetLayout(new QHBoxLayout), - m_statusBarWidget(0), + m_progress(new Internal::ProgressBar), m_widget(nullptr), m_widgetLayout(new QHBoxLayout), + m_statusBarWidget(nullptr), m_keep(FutureProgress::HideOnFinish), m_waitingForUserInteraction(false), m_q(q), m_fadeStarting(false), m_isFading(false) { @@ -124,7 +124,7 @@ FutureProgressPrivate::FutureProgressPrivate(FutureProgress *q) : FutureProgress::FutureProgress(QWidget *parent) : QWidget(parent), d(new FutureProgressPrivate(this)) { - QVBoxLayout *layout = new QVBoxLayout; + auto layout = new QVBoxLayout; setLayout(layout); layout->addWidget(d->m_progress); layout->setMargin(0); @@ -370,11 +370,11 @@ void FutureProgressPrivate::fadeAway() { m_isFading = true; - QGraphicsOpacityEffect *opacityEffect = new QGraphicsOpacityEffect; + auto opacityEffect = new QGraphicsOpacityEffect; opacityEffect->setOpacity(.999); m_q->setGraphicsEffect(opacityEffect); - QSequentialAnimationGroup *group = new QSequentialAnimationGroup(this); + auto group = new QSequentialAnimationGroup(this); QPropertyAnimation *animation = new QPropertyAnimation(opacityEffect, "opacity"); animation->setDuration(StyleHelper::progressFadeAnimationDuration); animation->setEndValue(0.); diff --git a/src/plugins/coreplugin/progressmanager/progressbar.h b/src/plugins/coreplugin/progressmanager/progressbar.h index 148813092a..9ff599adbb 100644 --- a/src/plugins/coreplugin/progressmanager/progressbar.h +++ b/src/plugins/coreplugin/progressmanager/progressbar.h @@ -38,7 +38,7 @@ class ProgressBar : public QWidget Q_PROPERTY(float cancelButtonFader READ cancelButtonFader WRITE setCancelButtonFader) public: - explicit ProgressBar(QWidget *parent = 0); + explicit ProgressBar(QWidget *parent = nullptr); QString title() const; void setTitle(const QString &title); @@ -50,9 +50,9 @@ public: bool isCancelEnabled() const; void setError(bool on); bool hasError() const; - QSize sizeHint() const; - void paintEvent(QPaintEvent *); - void mouseMoveEvent(QMouseEvent *); + QSize sizeHint() const override; + void paintEvent(QPaintEvent *) override; + void mouseMoveEvent(QMouseEvent *) override; int minimum() const { return m_minimum; } int maximum() const { return m_maximum; } int value() const { return m_value; } @@ -63,13 +63,13 @@ public: void setFinished(bool b); float cancelButtonFader() { return m_cancelButtonFader; } void setCancelButtonFader(float value) { update(); m_cancelButtonFader= value;} - bool event(QEvent *); + bool event(QEvent *) override; signals: void clicked(); protected: - void mousePressEvent(QMouseEvent *event); + void mousePressEvent(QMouseEvent *event) override; private: QFont titleFont() const; diff --git a/src/plugins/coreplugin/progressmanager/progressmanager.cpp b/src/plugins/coreplugin/progressmanager/progressmanager.cpp index 039cd76dd8..06c825ae80 100644 --- a/src/plugins/coreplugin/progressmanager/progressmanager.cpp +++ b/src/plugins/coreplugin/progressmanager/progressmanager.cpp @@ -263,14 +263,10 @@ using namespace Utils; Sent when all tasks of a \a type have finished. */ -static ProgressManagerPrivate *m_instance = 0; +static ProgressManagerPrivate *m_instance = nullptr; ProgressManagerPrivate::ProgressManagerPrivate() - : m_applicationTask(0), - m_currentStatusDetailsWidget(0), - m_opacityEffect(new QGraphicsOpacityEffect(this)), - m_progressViewPinned(false), - m_hovered(false) + : m_opacityEffect(new QGraphicsOpacityEffect(this)) { m_opacityEffect->setOpacity(.999); m_instance = this; @@ -288,7 +284,7 @@ ProgressManagerPrivate::~ProgressManagerPrivate() StatusBarManager::destroyStatusBarWidget(m_statusBarWidget); m_statusBarWidget = nullptr; cleanup(); - m_instance = 0; + m_instance = nullptr; } void ProgressManagerPrivate::readSettings() @@ -304,7 +300,7 @@ void ProgressManagerPrivate::init() readSettings(); m_statusBarWidget = new QWidget; - QHBoxLayout *layout = new QHBoxLayout(m_statusBarWidget); + auto layout = new QHBoxLayout(m_statusBarWidget); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); m_statusBarWidget->setLayout(layout); @@ -322,7 +318,7 @@ void ProgressManagerPrivate::init() m_summaryProgressBar->setCancelEnabled(false); m_summaryProgressLayout->addWidget(m_summaryProgressBar); layout->addWidget(m_summaryProgressWidget); - ToggleButton *toggleButton = new ToggleButton(m_statusBarWidget); + auto toggleButton = new ToggleButton(m_statusBarWidget); layout->addWidget(toggleButton); m_statusBarWidget->installEventFilter(this); StatusBarManager::addStatusBarWidget(m_statusBarWidget, StatusBarManager::RightCorner); @@ -381,7 +377,7 @@ bool ProgressManagerPrivate::eventFilter(QObject *obj, QEvent *event) updateVisibilityWithDelay(); } else if (obj == m_statusBarWidget && event->type() == QEvent::MouseButtonPress && !m_taskList.isEmpty()) { - QMouseEvent *me = static_cast<QMouseEvent *>(event); + auto me = static_cast<QMouseEvent *>(event); if (me->button() == Qt::LeftButton && !me->modifiers()) { FutureProgress *progress = m_currentStatusDetailsProgress; if (!progress) @@ -415,7 +411,7 @@ FutureProgress *ProgressManagerPrivate::doAddTask(const QFuture<void> &future, c Id type, ProgressFlags flags) { // watch - QFutureWatcher<void> *watcher = new QFutureWatcher<void>(); + auto watcher = new QFutureWatcher<void>(); m_runningTasks.insert(watcher, type); connect(watcher, &QFutureWatcherBase::progressRangeChanged, this, &ProgressManagerPrivate::updateSummaryProgressBar); @@ -442,7 +438,7 @@ FutureProgress *ProgressManagerPrivate::doAddTask(const QFuture<void> &future, c removeOldTasks(type); if (m_taskList.size() == 10) removeOneOldTask(); - FutureProgress *progress = new FutureProgress; + auto progress = new FutureProgress; progress->setTitle(title); progress->setFuture(future); @@ -475,7 +471,7 @@ void ProgressManagerPrivate::taskFinished() { QObject *taskObject = sender(); QTC_ASSERT(taskObject, return); - QFutureWatcher<void> *task = static_cast<QFutureWatcher<void> *>(taskObject); + auto task = static_cast<QFutureWatcher<void> *>(taskObject); if (m_applicationTask == task) disconnectApplicationTask(); Id type = m_runningTasks.value(task); @@ -494,7 +490,7 @@ void ProgressManagerPrivate::disconnectApplicationTask() disconnect(m_applicationTask, &QFutureWatcherBase::progressValueChanged, this, &ProgressManagerPrivate::setApplicationProgressValue); setApplicationProgressVisible(false); - m_applicationTask = 0; + m_applicationTask = nullptr; } void ProgressManagerPrivate::updateSummaryProgressBar() @@ -566,7 +562,7 @@ bool ProgressManagerPrivate::isLastFading() const void ProgressManagerPrivate::slotRemoveTask() { - FutureProgress *progress = qobject_cast<FutureProgress *>(sender()); + auto progress = qobject_cast<FutureProgress *>(sender()); QTC_ASSERT(progress, return); Id type = progress->type(); removeTask(progress); @@ -655,7 +651,7 @@ void ProgressManagerPrivate::updateVisibilityWithDelay() void ProgressManagerPrivate::updateStatusDetailsWidget() { - QWidget *candidateWidget = 0; + QWidget *candidateWidget = nullptr; // get newest progress with a status bar widget QList<FutureProgress *>::iterator i = m_taskList.end(); while (i != m_taskList.begin()) { @@ -727,13 +723,9 @@ void ToggleButton::paintEvent(QPaintEvent *event) } -ProgressManager::ProgressManager() -{ -} +ProgressManager::ProgressManager() = default; -ProgressManager::~ProgressManager() -{ -} +ProgressManager::~ProgressManager() = default; ProgressManager *ProgressManager::instance() { @@ -781,8 +773,7 @@ ProgressTimer::ProgressTimer(const QFutureInterfaceBase &futureInterface, QObject *parent) : QObject(parent), m_futureInterface(futureInterface), - m_expectedTime(expectedSeconds), - m_currentTime(0) + m_expectedTime(expectedSeconds) { m_futureInterface.setProgressRange(0, 100); m_futureInterface.setProgressValue(0); diff --git a/src/plugins/coreplugin/progressmanager/progressmanager.h b/src/plugins/coreplugin/progressmanager/progressmanager.h index efc2d57705..d7b581ae42 100644 --- a/src/plugins/coreplugin/progressmanager/progressmanager.h +++ b/src/plugins/coreplugin/progressmanager/progressmanager.h @@ -82,7 +82,7 @@ private: QFutureInterfaceBase m_futureInterface; int m_expectedTime; - int m_currentTime; + int m_currentTime = 0; QTimer *m_timer; }; diff --git a/src/plugins/coreplugin/progressmanager/progressmanager_p.h b/src/plugins/coreplugin/progressmanager/progressmanager_p.h index 7680b81a35..85bf378159 100644 --- a/src/plugins/coreplugin/progressmanager/progressmanager_p.h +++ b/src/plugins/coreplugin/progressmanager/progressmanager_p.h @@ -96,18 +96,18 @@ private: QPointer<ProgressView> m_progressView; QList<FutureProgress *> m_taskList; QMap<QFutureWatcher<void> *, Id> m_runningTasks; - QFutureWatcher<void> *m_applicationTask; + QFutureWatcher<void> *m_applicationTask = nullptr; StatusBarWidget *m_statusBarWidgetContainer; QWidget *m_statusBarWidget; QWidget *m_summaryProgressWidget; QHBoxLayout *m_summaryProgressLayout; - QWidget *m_currentStatusDetailsWidget; + QWidget *m_currentStatusDetailsWidget = nullptr; QPointer<FutureProgress> m_currentStatusDetailsProgress; ProgressBar *m_summaryProgressBar; QGraphicsOpacityEffect *m_opacityEffect; QPointer<QPropertyAnimation> m_opacityAnimation; - bool m_progressViewPinned; - bool m_hovered; + bool m_progressViewPinned = false; + bool m_hovered = false; }; class ToggleButton : public QToolButton diff --git a/src/plugins/coreplugin/progressmanager/progressmanager_win.cpp b/src/plugins/coreplugin/progressmanager/progressmanager_win.cpp index 5286ce007d..9102626863 100644 --- a/src/plugins/coreplugin/progressmanager/progressmanager_win.cpp +++ b/src/plugins/coreplugin/progressmanager/progressmanager_win.cpp @@ -49,7 +49,7 @@ namespace { int total = 0; - ITaskbarList3* pITask = 0; + ITaskbarList3* pITask = nullptr; } QT_BEGIN_NAMESPACE @@ -62,12 +62,12 @@ static inline QWindow *windowOfWidget(const QWidget *widget) return window; if (QWidget *topLevel = widget->nativeParentWidget()) return topLevel->windowHandle(); - return 0; + return nullptr; } static inline HWND hwndOfWidget(const QWidget *w) { - void *result = 0; + void *result = nullptr; if (QWindow *window = windowOfWidget(w)) result = QGuiApplication::platformNativeInterface()->nativeResourceForWindow("handle", window); return static_cast<HWND>(result); @@ -81,7 +81,7 @@ void Core::Internal::ProgressManagerPrivate::initInternal() IID_ITaskbarList3,(LPVOID*) &pITask); if (FAILED(hRes)) { - pITask = 0; + pITask = nullptr; CoUninitialize(); return; } diff --git a/src/plugins/coreplugin/progressmanager/progressview.cpp b/src/plugins/coreplugin/progressmanager/progressview.cpp index 1369c22982..9694e5a467 100644 --- a/src/plugins/coreplugin/progressmanager/progressview.cpp +++ b/src/plugins/coreplugin/progressmanager/progressview.cpp @@ -32,7 +32,7 @@ using namespace Core; using namespace Core::Internal; ProgressView::ProgressView(QWidget *parent) - : QWidget(parent), m_referenceWidget(nullptr), m_hovered(false) + : QWidget(parent) { m_layout = new QVBoxLayout; setLayout(m_layout); @@ -42,9 +42,7 @@ ProgressView::ProgressView(QWidget *parent) setWindowTitle(tr("Processes")); } -ProgressView::~ProgressView() -{ -} +ProgressView::~ProgressView() = default; void ProgressView::addProgressWidget(QWidget *widget) { diff --git a/src/plugins/coreplugin/progressmanager/progressview.h b/src/plugins/coreplugin/progressmanager/progressview.h index 4d619998a5..fe78c265c8 100644 --- a/src/plugins/coreplugin/progressmanager/progressview.h +++ b/src/plugins/coreplugin/progressmanager/progressview.h @@ -64,8 +64,8 @@ private: void reposition(); QVBoxLayout *m_layout; - QWidget *m_referenceWidget; - bool m_hovered; + QWidget *m_referenceWidget = nullptr; + bool m_hovered = false; }; } // namespace Internal diff --git a/src/plugins/coreplugin/reaper.cpp b/src/plugins/coreplugin/reaper.cpp index 907542928b..ff89b7d5e1 100644 --- a/src/plugins/coreplugin/reaper.cpp +++ b/src/plugins/coreplugin/reaper.cpp @@ -40,7 +40,7 @@ static ReaperPrivate *d = nullptr; namespace { void killProcess(QProcess *process) { - if (Utils::QtcProcess *qtcProcess = qobject_cast<Utils::QtcProcess*>(process)) + if (auto qtcProcess = qobject_cast<Utils::QtcProcess*>(process)) qtcProcess->kill(); else process->kill(); @@ -48,7 +48,7 @@ void killProcess(QProcess *process) void terminateProcess(QProcess *process) { - if (Utils::QtcProcess *qtcProcess = qobject_cast<Utils::QtcProcess*>(process)) + if (auto qtcProcess = qobject_cast<Utils::QtcProcess*>(process)) qtcProcess->terminate(); else process->terminate(); diff --git a/src/plugins/coreplugin/rightpane.cpp b/src/plugins/coreplugin/rightpane.cpp index 4c139cb284..e786051d04 100644 --- a/src/plugins/coreplugin/rightpane.cpp +++ b/src/plugins/coreplugin/rightpane.cpp @@ -38,7 +38,7 @@ using namespace Core; using namespace Core::Internal; -RightPanePlaceHolder *RightPanePlaceHolder::m_current = 0; +RightPanePlaceHolder *RightPanePlaceHolder::m_current = nullptr; RightPanePlaceHolder* RightPanePlaceHolder::current() { @@ -57,7 +57,7 @@ RightPanePlaceHolder::RightPanePlaceHolder(Id mode, QWidget *parent) RightPanePlaceHolder::~RightPanePlaceHolder() { if (m_current == this) { - RightPaneWidget::instance()->setParent(0); + RightPaneWidget::instance()->setParent(nullptr); RightPaneWidget::instance()->hide(); } } @@ -65,7 +65,7 @@ RightPanePlaceHolder::~RightPanePlaceHolder() void RightPanePlaceHolder::applyStoredSize(int width) { if (width) { - QSplitter *splitter = qobject_cast<QSplitter *>(parentWidget()); + auto splitter = qobject_cast<QSplitter *>(parentWidget()); if (splitter) { // A splitter we need to resize the splitter sizes QList<int> sizes = splitter->sizes(); @@ -95,8 +95,8 @@ void RightPanePlaceHolder::applyStoredSize(int width) void RightPanePlaceHolder::currentModeChanged(Id mode) { if (m_current == this) { - m_current = 0; - RightPaneWidget::instance()->setParent(0); + m_current = nullptr; + RightPaneWidget::instance()->setParent(nullptr); RightPaneWidget::instance()->hide(); } if (m_mode == mode) { @@ -117,14 +117,13 @@ void RightPanePlaceHolder::currentModeChanged(Id mode) ///// -RightPaneWidget *RightPaneWidget::m_instance = 0; +RightPaneWidget *RightPaneWidget::m_instance = nullptr; RightPaneWidget::RightPaneWidget() - : m_shown(true), m_width(0) { m_instance = this; - QVBoxLayout *layout = new QVBoxLayout; + auto layout = new QVBoxLayout; layout->setMargin(0); setLayout(layout); } @@ -132,7 +131,7 @@ RightPaneWidget::RightPaneWidget() RightPaneWidget::~RightPaneWidget() { clearWidget(); - m_instance = 0; + m_instance = nullptr; } RightPaneWidget *RightPaneWidget::instance() @@ -207,7 +206,7 @@ void RightPaneWidget::clearWidget() { if (m_widget) { m_widget->hide(); - m_widget->setParent(0); - m_widget = 0; + m_widget->setParent(nullptr); + m_widget = nullptr; } } diff --git a/src/plugins/coreplugin/rightpane.h b/src/plugins/coreplugin/rightpane.h index 905d37d4d4..14026a03e0 100644 --- a/src/plugins/coreplugin/rightpane.h +++ b/src/plugins/coreplugin/rightpane.h @@ -80,8 +80,8 @@ protected: private: void clearWidget(); - bool m_shown; - int m_width; + bool m_shown = true; + int m_width = 0; QPointer<QWidget> m_widget; static RightPaneWidget *m_instance; }; diff --git a/src/plugins/coreplugin/settingsdatabase.cpp b/src/plugins/coreplugin/settingsdatabase.cpp index 7c272c6720..9b5054fa57 100644 --- a/src/plugins/coreplugin/settingsdatabase.cpp +++ b/src/plugins/coreplugin/settingsdatabase.cpp @@ -57,7 +57,7 @@ enum { debug_settings = 0 }; namespace Core { namespace Internal { -typedef QMap<QString, QVariant> SettingsMap; +using SettingsMap = QMap<QString, QVariant>; class SettingsDatabasePrivate { diff --git a/src/plugins/coreplugin/sidebar.cpp b/src/plugins/coreplugin/sidebar.cpp index 36e34f482f..a5466a597e 100644 --- a/src/plugins/coreplugin/sidebar.cpp +++ b/src/plugins/coreplugin/sidebar.cpp @@ -68,7 +68,7 @@ QList<QToolButton *> SideBarItem::createToolBarWidgets() } struct SideBarPrivate { - SideBarPrivate() :m_closeWhenEmpty(false) {} + SideBarPrivate() = default; QList<Internal::SideBarWidget*> m_widgets; QMap<QString, QPointer<SideBarItem> > m_itemMap; @@ -77,7 +77,7 @@ struct SideBarPrivate { QStringList m_unavailableItemIds; QStringList m_defaultVisible; QMap<QString, Core::Command*> m_shortcutMap; - bool m_closeWhenEmpty; + bool m_closeWhenEmpty = false; }; SideBar::SideBar(QList<SideBarItem*> itemList, @@ -143,10 +143,8 @@ void SideBar::setCloseWhenEmpty(bool value) void SideBar::makeItemAvailable(SideBarItem *item) { - typedef QMap<QString, QPointer<SideBarItem> >::const_iterator Iterator; - - const Iterator cend = d->m_itemMap.constEnd(); - for (Iterator it = d->m_itemMap.constBegin(); it != cend ; ++it) { + auto cend = d->m_itemMap.constEnd(); + for (auto it = d->m_itemMap.constBegin(); it != cend ; ++it) { if (it.value().data() == item) { d->m_availableItemIds.append(it.key()); d->m_availableItemTitles.append(it.value().data()->title()); @@ -193,7 +191,7 @@ SideBarItem *SideBar::item(const QString &id) emit availableItemsChanged(); return d->m_itemMap.value(id).data(); } - return 0; + return nullptr; } Internal::SideBarWidget *SideBar::insertSideBarWidget(int position, const QString &id) @@ -201,7 +199,7 @@ Internal::SideBarWidget *SideBar::insertSideBarWidget(int position, const QStrin if (!d->m_widgets.isEmpty()) d->m_widgets.at(0)->setCloseIcon(Utils::Icons::CLOSE_SPLIT_BOTTOM.icon()); - Internal::SideBarWidget *item = new Internal::SideBarWidget(this, id); + auto item = new Internal::SideBarWidget(this, id); connect(item, &Internal::SideBarWidget::splitMe, this, &SideBar::splitSubWidget); connect(item, &Internal::SideBarWidget::closeMe, this, &SideBar::closeSubWidget); connect(item, &Internal::SideBarWidget::currentWidgetChanged, this, &SideBar::updateWidgets); @@ -225,7 +223,7 @@ void SideBar::removeSideBarWidget(Internal::SideBarWidget *widget) void SideBar::splitSubWidget() { - Internal::SideBarWidget *original = qobject_cast<Internal::SideBarWidget*>(sender()); + auto original = qobject_cast<Internal::SideBarWidget*>(sender()); int pos = indexOf(original) + 1; insertSideBarWidget(pos); updateWidgets(); @@ -234,7 +232,7 @@ void SideBar::splitSubWidget() void SideBar::closeSubWidget() { if (d->m_widgets.count() != 1) { - Internal::SideBarWidget *widget = qobject_cast<Internal::SideBarWidget*>(sender()); + auto widget = qobject_cast<Internal::SideBarWidget*>(sender()); if (!widget) return; removeSideBarWidget(widget); diff --git a/src/plugins/coreplugin/sidebarwidget.cpp b/src/plugins/coreplugin/sidebarwidget.cpp index 35e68cafb2..daad4cf813 100644 --- a/src/plugins/coreplugin/sidebarwidget.cpp +++ b/src/plugins/coreplugin/sidebarwidget.cpp @@ -55,8 +55,7 @@ private: }; SideBarWidget::SideBarWidget(SideBar *sideBar, const QString &id) - : m_currentItem(0) - , m_sideBar(sideBar) + : m_sideBar(sideBar) { m_comboBox = new SideBarComboBox(this); m_comboBox->setMinimumContentsLength(15); @@ -81,7 +80,7 @@ SideBarWidget::SideBarWidget(SideBar *sideBar, const QString &id) connect(m_closeAction, &QAction::triggered, this, &SideBarWidget::closeMe); m_toolbar->addAction(m_closeAction); - QVBoxLayout *lay = new QVBoxLayout(); + auto lay = new QVBoxLayout(); lay->setMargin(0); lay->setSpacing(0); setLayout(lay); @@ -104,9 +103,7 @@ SideBarWidget::SideBarWidget(SideBar *sideBar, const QString &id) this, &SideBarWidget::setCurrentIndex); } -SideBarWidget::~SideBarWidget() -{ -} +SideBarWidget::~SideBarWidget() = default; QString SideBarWidget::currentItemTitle() const { @@ -176,14 +173,14 @@ void SideBarWidget::removeCurrentItem() QWidget *w = m_currentItem->widget(); w->hide(); layout()->removeWidget(w); - w->setParent(0); + w->setParent(nullptr); m_sideBar->makeItemAvailable(m_currentItem); // Delete custom toolbar widgets qDeleteAll(m_addedToolBarActions); m_addedToolBarActions.clear(); - m_currentItem = 0; + m_currentItem = nullptr; } void SideBarWidget::setCurrentIndex(int) @@ -197,12 +194,12 @@ Command *SideBarWidget::command(const QString &title) const { const QString id = m_sideBar->idForTitle(title); if (id.isEmpty()) - return 0; + return nullptr; const QMap<QString, Command*> shortcutMap = m_sideBar->shortcutMap(); QMap<QString, Command*>::const_iterator r = shortcutMap.find(id); if (r != shortcutMap.end()) return r.value(); - return 0; + return nullptr; } void SideBarWidget::setCloseIcon(const QIcon &icon) diff --git a/src/plugins/coreplugin/sidebarwidget.h b/src/plugins/coreplugin/sidebarwidget.h index e6db3c2200..86d59102e4 100644 --- a/src/plugins/coreplugin/sidebarwidget.h +++ b/src/plugins/coreplugin/sidebarwidget.h @@ -45,7 +45,7 @@ class SideBarWidget : public QWidget Q_OBJECT public: explicit SideBarWidget(SideBar *sideBar, const QString &title); - virtual ~SideBarWidget(); + ~SideBarWidget() override; QString currentItemId() const; QString currentItemTitle() const; @@ -66,13 +66,13 @@ signals: private: void setCurrentIndex(int); - SideBarComboBox *m_comboBox; - SideBarItem *m_currentItem; - QToolBar *m_toolbar; - QAction *m_splitAction; - QAction *m_closeAction; + SideBarComboBox *m_comboBox = nullptr; + SideBarItem *m_currentItem = nullptr; + QToolBar *m_toolbar = nullptr; + QAction *m_splitAction = nullptr; + QAction *m_closeAction = nullptr; QList<QAction *> m_addedToolBarActions; - SideBar *m_sideBar; + SideBar *m_sideBar = nullptr; }; } // namespace Internal diff --git a/src/plugins/coreplugin/styleanimator.cpp b/src/plugins/coreplugin/styleanimator.cpp index 8843251f7c..03fe40dfbd 100644 --- a/src/plugins/coreplugin/styleanimator.cpp +++ b/src/plugins/coreplugin/styleanimator.cpp @@ -32,7 +32,7 @@ Animation * StyleAnimator::widgetAnimation(const QWidget *widget) const { if (!widget) - return 0; + return nullptr; return Utils::findOrDefault(animations, Utils::equal(&Animation::widget, widget)); } diff --git a/src/plugins/coreplugin/styleanimator.h b/src/plugins/coreplugin/styleanimator.h index 020c00edef..b29dade9fb 100644 --- a/src/plugins/coreplugin/styleanimator.h +++ b/src/plugins/coreplugin/styleanimator.h @@ -42,8 +42,8 @@ class Animation { public : - Animation() : m_running(true) { } - virtual ~Animation() { } + Animation() = default; + virtual ~Animation() = default; QWidget * widget() const { return m_widget; } bool running() const { return m_running; } const QTime &startTime() const { return m_startTime; } @@ -59,21 +59,21 @@ protected: QImage m_primaryImage; QImage m_secondaryImage; QImage m_tempImage; - bool m_running; + bool m_running = true; }; // Handles state transition animations class Transition : public Animation { public : - Transition() : Animation(), m_duration(100) {} - virtual ~Transition() {} + Transition() = default; + ~Transition() override = default; void setDuration(int duration) { m_duration = duration; } void setStartImage(const QImage &image) { m_primaryImage = image; } void setEndImage(const QImage &image) { m_secondaryImage = image; } - virtual void paint(QPainter *painter, const QStyleOption *option); + void paint(QPainter *painter, const QStyleOption *option) override; int duration() const { return m_duration; } - int m_duration; //set time in ms to complete a state transition + int m_duration = 100; //set time in ms to complete a state transition }; class StyleAnimator : public QObject @@ -81,9 +81,9 @@ class StyleAnimator : public QObject Q_OBJECT public: - StyleAnimator(QObject *parent = 0) : QObject(parent) {} + StyleAnimator(QObject *parent = nullptr) : QObject(parent) {} - void timerEvent(QTimerEvent *); + void timerEvent(QTimerEvent *) override; void startAnimation(Animation *); void stopAnimation(const QWidget *); Animation* widgetAnimation(const QWidget *) const; diff --git a/src/plugins/coreplugin/systemsettings.cpp b/src/plugins/coreplugin/systemsettings.cpp index dd88478ed8..0f65161b66 100644 --- a/src/plugins/coreplugin/systemsettings.cpp +++ b/src/plugins/coreplugin/systemsettings.cpp @@ -50,7 +50,7 @@ namespace Core { namespace Internal { SystemSettings::SystemSettings() - : m_page(nullptr), m_dialog(0) + : m_page(nullptr), m_dialog(nullptr) { setId(Constants::SETTINGS_ID_SYSTEM); setDisplayName(tr("System")); @@ -187,7 +187,7 @@ void SystemSettings::finish() { delete m_widget; delete m_page; - m_page = 0; + m_page = nullptr; } void SystemSettings::resetTerminal() diff --git a/src/plugins/coreplugin/systemsettings.h b/src/plugins/coreplugin/systemsettings.h index a4b99be557..dbf7e09a1d 100644 --- a/src/plugins/coreplugin/systemsettings.h +++ b/src/plugins/coreplugin/systemsettings.h @@ -44,9 +44,9 @@ class SystemSettings : public IOptionsPage public: SystemSettings(); - QWidget *widget(); - void apply(); - void finish(); + QWidget *widget() override; + void apply() override; + void finish() override; private: void showHelpForFileBrowser(); diff --git a/src/plugins/coreplugin/textdocument.h b/src/plugins/coreplugin/textdocument.h index cc695c1c1f..9b498124aa 100644 --- a/src/plugins/coreplugin/textdocument.h +++ b/src/plugins/coreplugin/textdocument.h @@ -38,7 +38,7 @@ class CORE_EXPORT BaseTextDocument : public IDocument Q_OBJECT public: - typedef Utils::TextFileFormat::ReadResult ReadResult; + using ReadResult = Utils::TextFileFormat::ReadResult; explicit BaseTextDocument(QObject *parent = nullptr); ~BaseTextDocument() override; diff --git a/src/plugins/coreplugin/themechooser.cpp b/src/plugins/coreplugin/themechooser.cpp index 18f0a4040b..7fedfea06f 100644 --- a/src/plugins/coreplugin/themechooser.cpp +++ b/src/plugins/coreplugin/themechooser.cpp @@ -79,7 +79,7 @@ QString ThemeEntry::filePath() const class ThemeListModel : public QAbstractListModel { public: - ThemeListModel(QObject *parent = 0): + ThemeListModel(QObject *parent = nullptr): QAbstractListModel(parent) { } @@ -135,7 +135,7 @@ ThemeChooserPrivate::ThemeChooserPrivate(QWidget *widget) : m_themeListModel(new ThemeListModel) , m_themeComboBox(new QComboBox) { - QHBoxLayout *layout = new QHBoxLayout(widget); + auto layout = new QHBoxLayout(widget); layout->addWidget(m_themeComboBox); auto overriddenLabel = new QLabel; overriddenLabel->setText(ThemeChooser::tr("Current theme: %1") diff --git a/src/plugins/coreplugin/toolsettings.cpp b/src/plugins/coreplugin/toolsettings.cpp index 0e3904e825..857d154125 100644 --- a/src/plugins/coreplugin/toolsettings.cpp +++ b/src/plugins/coreplugin/toolsettings.cpp @@ -130,7 +130,7 @@ void ToolSettings::apply() it.next(); QList<ExternalTool *> items; foreach (ExternalTool *tool, it.value()) { - ExternalTool *toolToAdd = 0; + ExternalTool *toolToAdd = nullptr; if (ExternalTool *originalTool = originalTools.take(tool->id())) { // check if it has different category and is custom tool if (tool->displayCategory() != it.key() && !tool->preset()) diff --git a/src/plugins/coreplugin/toolsettings.h b/src/plugins/coreplugin/toolsettings.h index 8ce3a8d8ba..28972bc213 100644 --- a/src/plugins/coreplugin/toolsettings.h +++ b/src/plugins/coreplugin/toolsettings.h @@ -39,11 +39,11 @@ class ToolSettings : public IOptionsPage Q_OBJECT public: - explicit ToolSettings(QObject *parent = 0); + explicit ToolSettings(QObject *parent = nullptr); - QWidget *widget(); - void apply(); - void finish(); + QWidget *widget() override; + void apply() override; + void finish() override; private: QPointer<ExternalToolConfig> m_widget; diff --git a/src/plugins/coreplugin/variablechooser.cpp b/src/plugins/coreplugin/variablechooser.cpp index 186a74d6a3..f2e0edef02 100644 --- a/src/plugins/coreplugin/variablechooser.cpp +++ b/src/plugins/coreplugin/variablechooser.cpp @@ -72,9 +72,9 @@ public: new HeaderViewStretcher(header(), 0); } - void contextMenuEvent(QContextMenuEvent *ev); + void contextMenuEvent(QContextMenuEvent *ev) override; - void currentChanged(const QModelIndex ¤t, const QModelIndex &previous); + void currentChanged(const QModelIndex ¤t, const QModelIndex &previous) override; private: VariableChooserPrivate *m_target; @@ -146,12 +146,9 @@ public: class VariableGroupItem : public TreeItem { public: - VariableGroupItem() - : m_chooser(0), m_populated(false) - { - } + VariableGroupItem() = default; - QVariant data(int column, int role) const + QVariant data(int column, int role) const override { if (role == Qt::DisplayRole || role == Qt::EditRole) { if (column == 0) @@ -162,12 +159,12 @@ public: return QVariant(); } - bool canFetchMore() const + bool canFetchMore() const override { return !m_populated; } - void fetchMore() + void fetchMore() override { if (MacroExpander *expander = m_provider()) populateGroup(expander); @@ -177,15 +174,15 @@ public: void populateGroup(MacroExpander *expander); public: - VariableChooserPrivate *m_chooser; // Not owned. - bool m_populated; + VariableChooserPrivate *m_chooser = nullptr; // Not owned. + bool m_populated = false; MacroExpanderProvider m_provider; }; class VariableItem : public TypedTreeItem<TreeItem, VariableGroupItem> { public: - VariableItem() {} + VariableItem() = default; Qt::ItemFlags flags(int) const override { @@ -231,8 +228,8 @@ void VariableTreeView::contextMenuEvent(QContextMenuEvent *ev) QString expandedText = index.data(ExpandedTextRole).toString(); QMenu menu; - QAction *insertUnexpandedAction = 0; - QAction *insertExpandedAction = 0; + QAction *insertUnexpandedAction = nullptr; + QAction *insertExpandedAction = nullptr; if (unexpandedText.isEmpty()) { insertUnexpandedAction = menu.addAction(VariableChooser::tr("Insert Unexpanded Value")); @@ -265,13 +262,13 @@ void VariableTreeView::currentChanged(const QModelIndex ¤t, const QModelIn VariableChooserPrivate::VariableChooserPrivate(VariableChooser *parent) : q(parent), - m_lineEdit(0), - m_textEdit(0), - m_plainTextEdit(0), - m_iconButton(0), - m_variableFilter(0), - m_variableTree(0), - m_variableDescription(0) + m_lineEdit(nullptr), + m_textEdit(nullptr), + m_plainTextEdit(nullptr), + m_iconButton(nullptr), + m_variableFilter(nullptr), + m_variableTree(nullptr), + m_variableDescription(nullptr) { m_defaultDescription = VariableChooser::tr("Select a variable to insert."); @@ -295,7 +292,7 @@ VariableChooserPrivate::VariableChooserPrivate(VariableChooser *parent) m_variableDescription->setAttribute(Qt::WA_MacSmallSize); m_variableDescription->setTextInteractionFlags(Qt::TextBrowserInteraction); - QVBoxLayout *verticalLayout = new QVBoxLayout(q); + auto verticalLayout = new QVBoxLayout(q); verticalLayout->setContentsMargins(3, 3, 3, 12); verticalLayout->addWidget(m_variableFilter); verticalLayout->addWidget(m_variableTree); @@ -307,7 +304,7 @@ VariableChooserPrivate::VariableChooserPrivate(VariableChooser *parent) this, &VariableChooserPrivate::handleItemActivated); connect(qobject_cast<QApplication *>(qApp), &QApplication::focusChanged, this, &VariableChooserPrivate::updateCurrentEditor); - updateCurrentEditor(0, QApplication::focusWidget()); + updateCurrentEditor(nullptr, QApplication::focusWidget()); } void VariableGroupItem::populateGroup(MacroExpander *expander) @@ -489,18 +486,18 @@ void VariableChooserPrivate::updateCurrentEditor(QWidget *old, QWidget *widget) QLineEdit *previousLineEdit = m_lineEdit; QWidget *previousWidget = currentWidget(); - m_lineEdit = 0; - m_textEdit = 0; - m_plainTextEdit = 0; - QWidget *chooser = widget->property(kVariableSupportProperty).value<QWidget *>(); + m_lineEdit = nullptr; + m_textEdit = nullptr; + m_plainTextEdit = nullptr; + auto chooser = widget->property(kVariableSupportProperty).value<QWidget *>(); m_currentVariableName = widget->property(kVariableNameProperty).toByteArray(); bool supportsVariables = chooser == q; - if (QLineEdit *lineEdit = qobject_cast<QLineEdit *>(widget)) - m_lineEdit = (supportsVariables ? lineEdit : 0); - else if (QTextEdit *textEdit = qobject_cast<QTextEdit *>(widget)) - m_textEdit = (supportsVariables ? textEdit : 0); - else if (QPlainTextEdit *plainTextEdit = qobject_cast<QPlainTextEdit *>(widget)) - m_plainTextEdit = (supportsVariables ? plainTextEdit : 0); + if (auto lineEdit = qobject_cast<QLineEdit *>(widget)) + m_lineEdit = (supportsVariables ? lineEdit : nullptr); + else if (auto textEdit = qobject_cast<QTextEdit *>(widget)) + m_textEdit = (supportsVariables ? textEdit : nullptr); + else if (auto plainTextEdit = qobject_cast<QPlainTextEdit *>(widget)) + m_plainTextEdit = (supportsVariables ? plainTextEdit : nullptr); QWidget *current = currentWidget(); if (current != previousWidget) { @@ -510,7 +507,7 @@ void VariableChooserPrivate::updateCurrentEditor(QWidget *old, QWidget *widget) previousLineEdit->setTextMargins(0, 0, 0, 0); if (m_iconButton) { m_iconButton->hide(); - m_iconButton->setParent(0); + m_iconButton->setParent(nullptr); } if (current) { current->installEventFilter(q); // escape key handling and geometry changes @@ -608,7 +605,7 @@ static bool handleEscapePressed(QKeyEvent *ke, QWidget *widget) bool VariableChooser::event(QEvent *ev) { if (ev->type() == QEvent::KeyPress || ev->type() == QEvent::ShortcutOverride) { - QKeyEvent *ke = static_cast<QKeyEvent *>(ev); + auto ke = static_cast<QKeyEvent *>(ev); if (handleEscapePressed(ke, this)) return true; } @@ -623,7 +620,7 @@ bool VariableChooser::eventFilter(QObject *obj, QEvent *event) if (obj != d->currentWidget()) return false; if ((event->type() == QEvent::KeyPress || event->type() == QEvent::ShortcutOverride) && isVisible()) { - QKeyEvent *ke = static_cast<QKeyEvent *>(event); + auto ke = static_cast<QKeyEvent *>(event); return handleEscapePressed(ke, this); } else if (event->type() == QEvent::Resize) { d->updateButtonGeometry(); diff --git a/src/plugins/coreplugin/vcsmanager.cpp b/src/plugins/coreplugin/vcsmanager.cpp index e83f110ea5..fc9388aa1e 100644 --- a/src/plugins/coreplugin/vcsmanager.cpp +++ b/src/plugins/coreplugin/vcsmanager.cpp @@ -211,8 +211,8 @@ void VcsManager::resetVersionControlForDirectory(const QString &inputDirectory) IVersionControl* VcsManager::findVersionControlForDirectory(const QString &inputDirectory, QString *topLevelDirectory) { - typedef QPair<QString, IVersionControl *> StringVersionControlPair; - typedef QList<StringVersionControlPair> StringVersionControlPairs; + using StringVersionControlPair = QPair<QString, IVersionControl *>; + using StringVersionControlPairs = QList<StringVersionControlPair>; if (inputDirectory.isEmpty()) { if (topLevelDirectory) topLevelDirectory->clear(); @@ -441,7 +441,7 @@ void VcsManager::clearVersionControlCache() void VcsManager::handleConfigurationChanges() { d->m_cachedAdditionalToolsPathsDirty = true; - IVersionControl *vcs = qobject_cast<IVersionControl *>(sender()); + auto vcs = qobject_cast<IVersionControl *>(sender()); if (vcs) emit configurationChanged(vcs); } @@ -462,7 +462,7 @@ namespace Internal { const char ID_VCS_A[] = "A"; const char ID_VCS_B[] = "B"; -typedef QHash<QString, QString> FileHash; +using FileHash = QHash<QString, QString>; static FileHash makeHash(const QStringList &list) { diff --git a/src/plugins/coreplugin/vcsmanager.h b/src/plugins/coreplugin/vcsmanager.h index 2015fc0f48..9971e9ac99 100644 --- a/src/plugins/coreplugin/vcsmanager.h +++ b/src/plugins/coreplugin/vcsmanager.h @@ -59,7 +59,7 @@ public: template <typename T, typename... Args> static T *registerVersionControl(Args&&... args) { - T *vc = new T(std::forward<Args>(args)...); + auto vc = new T(std::forward<Args>(args)...); addVersionControl(vc); return vc; } diff --git a/src/plugins/coreplugin/versiondialog.cpp b/src/plugins/coreplugin/versiondialog.cpp index 06962971ea..045bc60da3 100644 --- a/src/plugins/coreplugin/versiondialog.cpp +++ b/src/plugins/coreplugin/versiondialog.cpp @@ -53,7 +53,7 @@ VersionDialog::VersionDialog(QWidget *parent) setWindowTitle(tr("About %1").arg(Core::Constants::IDE_DISPLAY_NAME)); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); - QGridLayout *layout = new QGridLayout(this); + auto layout = new QGridLayout(this); layout->setSizeConstraint(QLayout::SetFixedSize); QString ideRev; @@ -112,7 +112,7 @@ VersionDialog::VersionDialog(QWidget *parent) bool VersionDialog::event(QEvent *event) { if (event->type() == QEvent::ShortcutOverride) { - QKeyEvent *ke = static_cast<QKeyEvent *>(event); + auto ke = static_cast<QKeyEvent *>(event); if (ke->key() == Qt::Key_Escape && !ke->modifiers()) { ke->accept(); return true; diff --git a/src/plugins/coreplugin/versiondialog.h b/src/plugins/coreplugin/versiondialog.h index 52efab01fe..fe7f003e88 100644 --- a/src/plugins/coreplugin/versiondialog.h +++ b/src/plugins/coreplugin/versiondialog.h @@ -40,7 +40,7 @@ class VersionDialog : public QDialog public: explicit VersionDialog(QWidget *parent); - bool event(QEvent *event); + bool event(QEvent *event) override; }; diff --git a/src/plugins/coreplugin/windowsupport.cpp b/src/plugins/coreplugin/windowsupport.cpp index 5d2ab1c9fa..6ce31bc8a4 100644 --- a/src/plugins/coreplugin/windowsupport.cpp +++ b/src/plugins/coreplugin/windowsupport.cpp @@ -45,7 +45,7 @@ namespace Core { namespace Internal { -QMenu *WindowList::m_dockMenu = 0; +QMenu *WindowList::m_dockMenu = nullptr; QList<QWidget *> WindowList::m_windows; QList<QAction *> WindowList::m_windowActions; QList<Id> WindowList::m_windowActionIds; diff --git a/src/plugins/coreplugin/windowsupport.h b/src/plugins/coreplugin/windowsupport.h index 6dc13914bf..1e9d27139a 100644 --- a/src/plugins/coreplugin/windowsupport.h +++ b/src/plugins/coreplugin/windowsupport.h @@ -61,12 +61,12 @@ class WindowSupport : public QObject Q_OBJECT public: WindowSupport(QWidget *window, const Context &context); - ~WindowSupport(); + ~WindowSupport() override; void setCloseActionEnabled(bool enabled); protected: - bool eventFilter(QObject *obj, QEvent *event); + bool eventFilter(QObject *obj, QEvent *event) override; private: void toggleFullScreen(); |