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>
This commit is contained in:
Alessandro Portale
2018-07-21 21:11:46 +02:00
parent 86b8164a93
commit f36f04deba
152 changed files with 621 additions and 698 deletions

View File

@@ -202,29 +202,29 @@ QList<Group>::const_iterator ActionContainerPrivate::findGroup(Id groupId) const
QAction *ActionContainerPrivate::insertLocation(Id groupId) const QAction *ActionContainerPrivate::insertLocation(Id groupId) const
{ {
QList<Group>::const_iterator it = findGroup(groupId); 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); return insertLocation(it);
} }
QAction *ActionContainerPrivate::insertLocation(QList<Group>::const_iterator group) const QAction *ActionContainerPrivate::insertLocation(QList<Group>::const_iterator group) const
{ {
if (group == m_groups.constEnd()) if (group == m_groups.constEnd())
return 0; return nullptr;
++group; ++group;
while (group != m_groups.constEnd()) { while (group != m_groups.constEnd()) {
if (!group->items.isEmpty()) { if (!group->items.isEmpty()) {
QObject *item = group->items.first(); QObject *item = group->items.first();
if (Command *cmd = qobject_cast<Command *>(item)) { if (auto cmd = qobject_cast<Command *>(item)) {
return cmd->action(); return cmd->action();
} else if (ActionContainer *container = qobject_cast<ActionContainer *>(item)) { } else if (auto container = qobject_cast<ActionContainer *>(item)) {
if (container->menu()) if (container->menu())
return container->menu()->menuAction(); return container->menu()->menuAction();
} }
QTC_ASSERT(false, return 0); QTC_ASSERT(false, return nullptr);
} }
++group; ++group;
} }
return 0; return nullptr;
} }
void ActionContainerPrivate::addAction(Command *command, Id groupId) 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) void ActionContainerPrivate::addMenu(ActionContainer *menu, Id groupId)
{ {
ActionContainerPrivate *containerPrivate = static_cast<ActionContainerPrivate *>(menu); auto containerPrivate = static_cast<ActionContainerPrivate *>(menu);
if (!containerPrivate->canBeAddedToMenu()) if (!containerPrivate->canBeAddedToMenu())
return; return;
MenuActionContainer *container = static_cast<MenuActionContainer *>(containerPrivate); auto container = static_cast<MenuActionContainer *>(containerPrivate);
const Id actualGroupId = groupId.isValid() ? groupId : Id(Constants::G_DEFAULT_TWO); const Id actualGroupId = groupId.isValid() ? groupId : Id(Constants::G_DEFAULT_TWO);
QList<Group>::const_iterator groupIt = findGroup(actualGroupId); QList<Group>::const_iterator groupIt = findGroup(actualGroupId);
QTC_ASSERT(groupIt != m_groups.constEnd(), return); 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) void ActionContainerPrivate::addMenu(ActionContainer *before, ActionContainer *menu, Id groupId)
{ {
ActionContainerPrivate *containerPrivate = static_cast<ActionContainerPrivate *>(menu); auto containerPrivate = static_cast<ActionContainerPrivate *>(menu);
if (!containerPrivate->canBeAddedToMenu()) if (!containerPrivate->canBeAddedToMenu())
return; return;
MenuActionContainer *container = static_cast<MenuActionContainer *>(containerPrivate); auto container = static_cast<MenuActionContainer *>(containerPrivate);
const Id actualGroupId = groupId.isValid() ? groupId : Id(Constants::G_DEFAULT_TWO); const Id actualGroupId = groupId.isValid() ? groupId : Id(Constants::G_DEFAULT_TWO);
QList<Group>::const_iterator groupIt = findGroup(actualGroupId); QList<Group>::const_iterator groupIt = findGroup(actualGroupId);
QTC_ASSERT(groupIt != m_groups.constEnd(), return); 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) Command *ActionContainerPrivate::addSeparator(const Context &context, Id group, QAction **outSeparator)
{ {
static int separatorIdCount = 0; static int separatorIdCount = 0;
QAction *separator = new QAction(this); auto separator = new QAction(this);
separator->setSeparator(true); separator->setSeparator(true);
Id sepId = id().withSuffix(".Separator.").withSuffix(++separatorIdCount); Id sepId = id().withSuffix(".Separator.").withSuffix(++separatorIdCount);
Command *cmd = ActionManager::registerAction(separator, sepId, context); Command *cmd = ActionManager::registerAction(separator, sepId, context);
@@ -309,12 +309,12 @@ void ActionContainerPrivate::clear()
while (it.hasNext()) { while (it.hasNext()) {
Group &group = it.next(); Group &group = it.next();
foreach (QObject *item, group.items) { foreach (QObject *item, group.items) {
if (Command *command = qobject_cast<Command *>(item)) { if (auto command = qobject_cast<Command *>(item)) {
removeAction(command->action()); removeAction(command->action());
disconnect(command, &Command::activeStateChanged, disconnect(command, &Command::activeStateChanged,
this, &ActionContainerPrivate::scheduleUpdate); this, &ActionContainerPrivate::scheduleUpdate);
disconnect(command, &QObject::destroyed, this, &ActionContainerPrivate::itemDestroyed); 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(); container->clear();
disconnect(container, &QObject::destroyed, disconnect(container, &QObject::destroyed,
this, &ActionContainerPrivate::itemDestroyed); this, &ActionContainerPrivate::itemDestroyed);
@@ -344,12 +344,12 @@ Id ActionContainerPrivate::id() const
QMenu *ActionContainerPrivate::menu() const QMenu *ActionContainerPrivate::menu() const
{ {
return 0; return nullptr;
} }
QMenuBar *ActionContainerPrivate::menuBar() const QMenuBar *ActionContainerPrivate::menuBar() const
{ {
return 0; return nullptr;
} }
bool ActionContainerPrivate::canAddAction(Command *action) const bool ActionContainerPrivate::canAddAction(Command *action) const
@@ -429,7 +429,7 @@ bool MenuActionContainer::updateInternal()
while (it.hasNext()) { while (it.hasNext()) {
const Group &group = it.next(); const Group &group = it.next();
foreach (QObject *item, group.items) { foreach (QObject *item, group.items) {
if (ActionContainerPrivate *container = qobject_cast<ActionContainerPrivate*>(item)) { if (auto container = qobject_cast<ActionContainerPrivate*>(item)) {
actions.removeAll(container->menu()->menuAction()); actions.removeAll(container->menu()->menuAction());
if (container == this) { if (container == this) {
QByteArray warning = Q_FUNC_INFO + QByteArray(" container '"); QByteArray warning = Q_FUNC_INFO + QByteArray(" container '");
@@ -443,7 +443,7 @@ bool MenuActionContainer::updateInternal()
hasitems = true; hasitems = true;
break; break;
} }
} else if (Command *command = qobject_cast<Command *>(item)) { } else if (auto command = qobject_cast<Command *>(item)) {
actions.removeAll(command->action()); actions.removeAll(command->action());
if (command->isActive()) { if (command->isActive()) {
hasitems = true; hasitems = true;
@@ -488,7 +488,7 @@ bool MenuActionContainer::canBeAddedToMenu() const
*/ */
MenuBarActionContainer::MenuBarActionContainer(Id id) MenuBarActionContainer::MenuBarActionContainer(Id id)
: ActionContainerPrivate(id), m_menuBar(0) : ActionContainerPrivate(id), m_menuBar(nullptr)
{ {
setOnAllDisabledBehavior(Show); setOnAllDisabledBehavior(Show);
} }

View File

@@ -46,7 +46,7 @@ class ActionContainerPrivate : public ActionContainer
public: public:
ActionContainerPrivate(Id id); ActionContainerPrivate(Id id);
~ActionContainerPrivate() override {} ~ActionContainerPrivate() override = default;
void setOnAllDisabledBehavior(OnAllDisabledBehavior behavior) override; void setOnAllDisabledBehavior(OnAllDisabledBehavior behavior) override;
ActionContainer::OnAllDisabledBehavior onAllDisabledBehavior() const override; ActionContainer::OnAllDisabledBehavior onAllDisabledBehavior() const override;

View File

@@ -152,7 +152,7 @@ using namespace Core::Internal;
Emitted when a command (with the \a id) is added. Emitted when a command (with the \a id) is added.
*/ */
static ActionManager *m_instance = 0; static ActionManager *m_instance = nullptr;
static ActionManagerPrivate *d; static ActionManagerPrivate *d;
/*! /*!
@@ -198,7 +198,7 @@ ActionContainer *ActionManager::createMenu(Id id)
if (it != d->m_idContainerMap.constEnd()) if (it != d->m_idContainerMap.constEnd())
return it.value(); return it.value();
MenuActionContainer *mc = new MenuActionContainer(id); auto mc = new MenuActionContainer(id);
d->m_idContainerMap.insert(id, mc); d->m_idContainerMap.insert(id, mc);
connect(mc, &QObject::destroyed, d, &ActionManagerPrivate::containerDestroyed); connect(mc, &QObject::destroyed, d, &ActionManagerPrivate::containerDestroyed);
@@ -219,10 +219,10 @@ ActionContainer *ActionManager::createMenuBar(Id id)
if (it != d->m_idContainerMap.constEnd()) if (it != d->m_idContainerMap.constEnd())
return it.value(); 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()); mb->setObjectName(id.toString());
MenuBarActionContainer *mbc = new MenuBarActionContainer(id); auto mbc = new MenuBarActionContainer(id);
mbc->setMenuBar(mb); mbc->setMenuBar(mb);
d->m_idContainerMap.insert(id, mbc); d->m_idContainerMap.insert(id, mbc);
@@ -268,7 +268,7 @@ Command *ActionManager::command(Id id)
if (warnAboutFindFailures) if (warnAboutFindFailures)
qWarning() << "ActionManagerPrivate::command(): failed to find :" qWarning() << "ActionManagerPrivate::command(): failed to find :"
<< id.name(); << id.name();
return 0; return nullptr;
} }
return it.value(); return it.value();
} }
@@ -287,7 +287,7 @@ ActionContainer *ActionManager::actionContainer(Id id)
if (warnAboutFindFailures) if (warnAboutFindFailures)
qWarning() << "ActionManagerPrivate::actionContainer(): failed to find :" qWarning() << "ActionManagerPrivate::actionContainer(): failed to find :"
<< id.name(); << id.name();
return 0; return nullptr;
} }
return it.value(); return it.value();
} }
@@ -415,13 +415,13 @@ bool ActionManagerPrivate::hasContext(const Context &context) const
void ActionManagerPrivate::containerDestroyed() void ActionManagerPrivate::containerDestroyed()
{ {
ActionContainerPrivate *container = static_cast<ActionContainerPrivate *>(sender()); auto container = static_cast<ActionContainerPrivate *>(sender());
m_idContainerMap.remove(m_idContainerMap.key(container)); m_idContainerMap.remove(m_idContainerMap.key(container));
} }
void ActionManagerPrivate::actionTriggered() void ActionManagerPrivate::actionTriggered()
{ {
QAction *action = qobject_cast<QAction *>(QObject::sender()); auto action = qobject_cast<QAction *>(QObject::sender());
if (action) if (action)
showShortcutPopup(action->shortcut().toString()); showShortcutPopup(action->shortcut().toString());
} }

View File

@@ -46,8 +46,8 @@ class ActionManagerPrivate : public QObject
Q_OBJECT Q_OBJECT
public: public:
typedef QHash<Id, Action *> IdCmdMap; using IdCmdMap = QHash<Id, Action *>;
typedef QHash<Id, ActionContainerPrivate *> IdContainerMap; using IdContainerMap = QHash<Id, ActionContainerPrivate *>;
~ActionManagerPrivate() override; ~ActionManagerPrivate() override;

View File

@@ -200,12 +200,9 @@ namespace Internal {
\internal \internal
*/ */
Action::Action(Id id) Action::Action(Id id)
: m_attributes(0), : m_attributes({}),
m_id(id), m_id(id),
m_isKeyInitialized(false), m_action(new Utils::ProxyAction(this))
m_action(new Utils::ProxyAction(this)),
m_active(false),
m_contextInitialized(false)
{ {
m_action->setShortcutVisibleInToolTip(true); m_action->setShortcutVisibleInToolTip(true);
connect(m_action, &QAction::changed, this, &Action::updateActiveState); connect(m_action, &QAction::changed, this, &Action::updateActiveState);
@@ -276,9 +273,9 @@ void Action::setCurrentContext(const Context &context)
{ {
m_context = context; m_context = context;
QAction *currentAction = 0; QAction *currentAction = nullptr;
for (int i = 0; i < m_context.size(); ++i) { 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; currentAction = a;
break; break;
} }
@@ -319,7 +316,7 @@ void Action::addOverrideAction(QAction *action, const Context &context, bool scr
for (int i = 0; i < context.size(); ++i) { for (int i = 0; i < context.size(); ++i) {
Id id = context.at(i); Id id = context.at(i);
if (m_contextActionMap.contains(id)) 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); m_contextActionMap.insert(id, action);
} }
} }
@@ -332,7 +329,7 @@ void Action::removeOverrideAction(QAction *action)
QMutableMapIterator<Id, QPointer<QAction> > it(m_contextActionMap); QMutableMapIterator<Id, QPointer<QAction> > it(m_contextActionMap);
while (it.hasNext()) { while (it.hasNext()) {
it.next(); it.next();
if (it.value() == 0) if (it.value() == nullptr)
it.remove(); it.remove();
else if (it.value() == action) else if (it.value() == action)
it.remove(); it.remove();
@@ -369,7 +366,7 @@ bool Action::isScriptable(const Context &context) const
return m_scriptableMap.value(m_action->action()); return m_scriptableMap.value(m_action->action());
for (int i = 0; i < context.size(); ++i) { 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)) if (m_scriptableMap.contains(a) && m_scriptableMap.value(a))
return true; return true;
} }
@@ -433,7 +430,7 @@ void Command::augmentActionWithShortcutToolTip(QAction *a) const
QToolButton *Command::toolButtonWithAppendedShortcut(QAction *action, Command *cmd) QToolButton *Command::toolButtonWithAppendedShortcut(QAction *action, Command *cmd)
{ {
QToolButton *button = new QToolButton; auto button = new QToolButton;
button->setDefaultAction(action); button->setDefaultAction(action);
if (cmd) if (cmd)
cmd->augmentActionWithShortcutToolTip(action); cmd->augmentActionWithShortcutToolTip(action);

View File

@@ -86,15 +86,15 @@ private:
Id m_id; Id m_id;
QKeySequence m_defaultKey; QKeySequence m_defaultKey;
QString m_defaultText; QString m_defaultText;
bool m_isKeyInitialized; bool m_isKeyInitialized = false;
Utils::ProxyAction *m_action; Utils::ProxyAction *m_action = nullptr;
QString m_toolTip; QString m_toolTip;
QMap<Id, QPointer<QAction> > m_contextActionMap; QMap<Id, QPointer<QAction> > m_contextActionMap;
QMap<QAction*, bool> m_scriptableMap; QMap<QAction*, bool> m_scriptableMap;
bool m_active; bool m_active = false;
bool m_contextInitialized; bool m_contextInitialized = false;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -44,13 +44,13 @@ using namespace Core;
CommandButton::CommandButton(QWidget *parent) CommandButton::CommandButton(QWidget *parent)
: QToolButton(parent) : QToolButton(parent)
, m_command(0) , m_command(nullptr)
{ {
} }
CommandButton::CommandButton(Id id, QWidget *parent) CommandButton::CommandButton(Id id, QWidget *parent)
: QToolButton(parent) : QToolButton(parent)
, m_command(0) , m_command(nullptr)
{ {
setCommandId(id); setCommandId(id);
} }

View File

@@ -77,21 +77,21 @@ public:
importButton = new QPushButton(CommandMappings::tr("Import..."), groupBox); importButton = new QPushButton(CommandMappings::tr("Import..."), groupBox);
exportButton = new QPushButton(CommandMappings::tr("Export..."), groupBox); exportButton = new QPushButton(CommandMappings::tr("Export..."), groupBox);
QHBoxLayout *hboxLayout1 = new QHBoxLayout(); auto hboxLayout1 = new QHBoxLayout();
hboxLayout1->addWidget(defaultButton); hboxLayout1->addWidget(defaultButton);
hboxLayout1->addStretch(); hboxLayout1->addStretch();
hboxLayout1->addWidget(importButton); hboxLayout1->addWidget(importButton);
hboxLayout1->addWidget(exportButton); hboxLayout1->addWidget(exportButton);
QHBoxLayout *hboxLayout = new QHBoxLayout(); auto hboxLayout = new QHBoxLayout();
hboxLayout->addWidget(filterEdit); hboxLayout->addWidget(filterEdit);
QVBoxLayout *vboxLayout1 = new QVBoxLayout(groupBox); auto vboxLayout1 = new QVBoxLayout(groupBox);
vboxLayout1->addLayout(hboxLayout); vboxLayout1->addLayout(hboxLayout);
vboxLayout1->addWidget(commandList); vboxLayout1->addWidget(commandList);
vboxLayout1->addLayout(hboxLayout1); vboxLayout1->addLayout(hboxLayout1);
QVBoxLayout *vboxLayout = new QVBoxLayout(parent); auto vboxLayout = new QVBoxLayout(parent);
vboxLayout->addWidget(groupBox); vboxLayout->addWidget(groupBox);
q->connect(exportButton, &QPushButton::clicked, q->connect(exportButton, &QPushButton::clicked,

View File

@@ -89,7 +89,7 @@ void BaseFileWizard::accept()
reject(); reject();
return; return;
case BaseFileWizardFactory::OverwriteError: case BaseFileWizardFactory::OverwriteError:
QMessageBox::critical(0, tr("Existing files"), errorMessage); QMessageBox::critical(nullptr, tr("Existing files"), errorMessage);
reject(); reject();
return; return;
case BaseFileWizardFactory::OverwriteOk: case BaseFileWizardFactory::OverwriteOk:
@@ -132,7 +132,7 @@ void BaseFileWizard::accept()
// Post generation handler // Post generation handler
if (!m_factory->postGenerateFiles(this, m_files, &errorMessage)) if (!m_factory->postGenerateFiles(this, m_files, &errorMessage))
if (!errorMessage.isEmpty()) if (!errorMessage.isEmpty())
QMessageBox::critical(0, tr("File Generation Failure"), errorMessage); QMessageBox::critical(nullptr, tr("File Generation Failure"), errorMessage);
Wizard::accept(); Wizard::accept();
} }

View File

@@ -78,7 +78,7 @@ Utils::Wizard *BaseFileWizardFactory::runWizardImpl(const QString &path, QWidget
Id platform, Id platform,
const QVariantMap &extraValues) 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 // Create dialog and run it. Ensure that the dialog is deleted when
// leaving the func, but not before the IFileWizardExtension::process // leaving the func, but not before the IFileWizardExtension::process

View File

@@ -47,7 +47,7 @@ class BaseFileWizard;
class CORE_EXPORT WizardDialogParameters class CORE_EXPORT WizardDialogParameters
{ {
public: public:
typedef QList<QWizardPage *> WizardPageList; using WizardPageList = QList<QWizardPage *>;
enum DialogParameterEnum { enum DialogParameterEnum {
ForceCapitalLetterForFileName = 0x01 ForceCapitalLetterForFileName = 0x01

View File

@@ -70,9 +70,6 @@ using namespace Core::Internal;
using namespace Utils; using namespace Utils;
CorePlugin::CorePlugin() CorePlugin::CorePlugin()
: m_mainWindow(nullptr)
, m_editMode(nullptr)
, m_locator(nullptr)
{ {
qRegisterMetaType<Id>(); qRegisterMetaType<Id>();
qRegisterMetaType<Core::Search::TextPosition>(); qRegisterMetaType<Core::Search::TextPosition>();

View File

@@ -78,9 +78,9 @@ private slots:
private: private:
static void addToPathChooserContextMenu(Utils::PathChooser *pathChooser, QMenu *menu); static void addToPathChooserContextMenu(Utils::PathChooser *pathChooser, QMenu *menu);
MainWindow *m_mainWindow; MainWindow *m_mainWindow = nullptr;
EditMode *m_editMode; EditMode *m_editMode = nullptr;
Locator *m_locator; Locator *m_locator = nullptr;
ReaperPrivate m_reaper; ReaperPrivate m_reaper;
}; };

View File

@@ -80,7 +80,7 @@ static DesignModePrivate *d = nullptr;
DesignMode::DesignMode() DesignMode::DesignMode()
{ {
ICore::addPreCloseListener([]() -> bool { ICore::addPreCloseListener([]() -> bool {
m_instance->currentEditorChanged(0); m_instance->currentEditorChanged(nullptr);
return true; return true;
}); });
@@ -130,7 +130,7 @@ void DesignMode::registerDesignWidget(QWidget *widget,
setDesignModeIsRequired(); setDesignModeIsRequired();
int index = d->m_stackWidget->addWidget(widget); int index = d->m_stackWidget->addWidget(widget);
DesignEditorInfo *info = new DesignEditorInfo; auto info = new DesignEditorInfo;
info->mimeTypes = mimeTypes; info->mimeTypes = mimeTypes;
info->context = context; info->context = context;
info->widgetIndex = index; info->widgetIndex = index;
@@ -184,7 +184,7 @@ void DesignMode::currentEditorChanged(IEditor *editor)
if (ModeManager::currentMode() == id()) if (ModeManager::currentMode() == id())
ModeManager::activateMode(Constants::MODE_EDIT); ModeManager::activateMode(Constants::MODE_EDIT);
setEnabled(false); setEnabled(false);
d->m_currentEditor = 0; d->m_currentEditor = nullptr;
emit actionsUpdated(d->m_currentEditor.data()); emit actionsUpdated(d->m_currentEditor.data());
} else { } else {
d->m_currentEditor = editor; d->m_currentEditor = editor;

View File

@@ -121,14 +121,14 @@ QVariant ExternalToolModel::data(const QString &category, int role) const
QMimeData *ExternalToolModel::mimeData(const QModelIndexList &indexes) const QMimeData *ExternalToolModel::mimeData(const QModelIndexList &indexes) const
{ {
if (indexes.isEmpty()) if (indexes.isEmpty())
return 0; return nullptr;
QModelIndex modelIndex = indexes.first(); QModelIndex modelIndex = indexes.first();
ExternalTool *tool = toolForIndex(modelIndex); ExternalTool *tool = toolForIndex(modelIndex);
QTC_ASSERT(tool, return 0); QTC_ASSERT(tool, return nullptr);
bool found; bool found;
QString category = categoryForIndex(modelIndex.parent(), &found); QString category = categoryForIndex(modelIndex.parent(), &found);
QTC_ASSERT(found, return 0); QTC_ASSERT(found, return nullptr);
QMimeData *md = new QMimeData(); auto md = new QMimeData();
QByteArray ba; QByteArray ba;
QDataStream stream(&ba, QIODevice::WriteOnly); QDataStream stream(&ba, QIODevice::WriteOnly);
stream << category << m_tools.value(category).indexOf(tool); 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 TOOLSMENU_ITEM_FLAGS;
return CATEGORY_ITEM_FLAGS; return CATEGORY_ITEM_FLAGS;
} }
return 0; return nullptr;
} }
bool ExternalToolModel::setData(const QModelIndex &modelIndex, const QVariant &value, int role) bool ExternalToolModel::setData(const QModelIndex &modelIndex, const QVariant &value, int role)
@@ -342,7 +342,7 @@ QModelIndex ExternalToolModel::addTool(const QModelIndex &atIndex)
if (!found) if (!found)
category = categoryForIndex(atIndex.parent(), &found); category = categoryForIndex(atIndex.parent(), &found);
ExternalTool *tool = new ExternalTool; auto tool = new ExternalTool;
tool->setDisplayCategory(category); tool->setDisplayCategory(category);
tool->setDisplayName(tr("New Tool")); tool->setDisplayName(tr("New Tool"));
tool->setDescription(tr("This tool prints a line of useful text")); 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->revertButton, &QAbstractButton::clicked, this, &ExternalToolConfig::revertCurrentItem);
connect(ui->removeButton, &QAbstractButton::clicked, this, &ExternalToolConfig::removeTool); connect(ui->removeButton, &QAbstractButton::clicked, this, &ExternalToolConfig::removeTool);
QMenu *menu = new QMenu(ui->addButton); auto menu = new QMenu(ui->addButton);
ui->addButton->setMenu(menu); ui->addButton->setMenu(menu);
QAction *addTool = new QAction(tr("Add Tool"), this); QAction *addTool = new QAction(tr("Add Tool"), this);
menu->addAction(addTool); menu->addAction(addTool);

View File

@@ -46,7 +46,7 @@ class ExternalToolModel : public QAbstractItemModel
public: public:
explicit ExternalToolModel(QObject *parent); explicit ExternalToolModel(QObject *parent);
~ExternalToolModel(); ~ExternalToolModel() override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &modelIndex, int role = Qt::DisplayRole) const override; QVariant data(const QModelIndex &modelIndex, int role = Qt::DisplayRole) const override;
@@ -86,8 +86,8 @@ class ExternalToolConfig : public QWidget
Q_OBJECT Q_OBJECT
public: public:
explicit ExternalToolConfig(QWidget *parent = 0); explicit ExternalToolConfig(QWidget *parent = nullptr);
~ExternalToolConfig(); ~ExternalToolConfig() override;
void setTools(const QMap<QString, QList<ExternalTool *> > &tools); void setTools(const QMap<QString, QList<ExternalTool *> > &tools);
QMap<QString, QList<ExternalTool *> > tools() const; QMap<QString, QList<ExternalTool *> > tools() const;

View File

@@ -169,7 +169,7 @@ const QList<Core::IOptionsPage *> Core::IOptionsPage::allOptionsPages()
bool Core::IOptionsPage::matches(const QString &searchKeyWord) const bool Core::IOptionsPage::matches(const QString &searchKeyWord) const
{ {
if (!m_keywordsInitialized) { if (!m_keywordsInitialized) {
IOptionsPage *that = const_cast<IOptionsPage *>(this); auto that = const_cast<IOptionsPage *>(this);
QWidget *widget = that->widget(); QWidget *widget = that->widget();
if (!widget) if (!widget)
return false; return false;

View File

@@ -61,10 +61,10 @@ using namespace Core::Internal;
class WizardFactoryContainer class WizardFactoryContainer
{ {
public: public:
WizardFactoryContainer() : wizard(nullptr), wizardOption(0) {} WizardFactoryContainer() = default;
WizardFactoryContainer(Core::IWizardFactory *w, int i): wizard(w), wizardOption(i) {} WizardFactoryContainer(Core::IWizardFactory *w, int i): wizard(w), wizardOption(i) {}
Core::IWizardFactory *wizard; Core::IWizardFactory *wizard = nullptr;
int wizardOption; int wizardOption = 0;
}; };
inline Core::IWizardFactory *factoryOfItem(const QStandardItem *item = nullptr) inline Core::IWizardFactory *factoryOfItem(const QStandardItem *item = nullptr)
@@ -175,8 +175,7 @@ QWidget *NewDialog::m_currentDialog = nullptr;
NewDialog::NewDialog(QWidget *parent) : NewDialog::NewDialog(QWidget *parent) :
QDialog(parent), QDialog(parent),
m_ui(new Ui::NewDialog), m_ui(new Ui::NewDialog)
m_okButton(nullptr)
{ {
QTC_CHECK(m_currentDialog == nullptr); QTC_CHECK(m_currentDialog == nullptr);
@@ -257,10 +256,10 @@ void NewDialog::setWizardFactories(QList<IWizardFactory *> factories,
QStandardItem *projectKindItem = new QStandardItem(tr("Projects")); QStandardItem *projectKindItem = new QStandardItem(tr("Projects"));
projectKindItem->setData(IWizardFactory::ProjectWizard, Qt::UserRole); 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")); QStandardItem *filesKindItem = new QStandardItem(tr("Files and Classes"));
filesKindItem->setData(IWizardFactory::FileWizard, Qt::UserRole); 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(projectKindItem);
parentItem->appendRow(filesKindItem); parentItem->appendRow(filesKindItem);
@@ -355,7 +354,7 @@ QWidget *NewDialog::currentDialog()
bool NewDialog::event(QEvent *event) bool NewDialog::event(QEvent *event)
{ {
if (event->type() == QEvent::ShortcutOverride) { 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()) { if (ke->key() == Qt::Key_Escape && !ke->modifiers()) {
ke->accept(); ke->accept();
return true; return true;
@@ -518,7 +517,7 @@ void NewDialog::reject()
void NewDialog::updateOkButton() void NewDialog::updateOkButton()
{ {
m_okButton->setEnabled(currentWizardFactory() != 0); m_okButton->setEnabled(currentWizardFactory() != nullptr);
} }
void NewDialog::setSelectedPlatform(const QString & /*platform*/) void NewDialog::setSelectedPlatform(const QString & /*platform*/)

View File

@@ -82,7 +82,7 @@ private:
Ui::NewDialog *m_ui; Ui::NewDialog *m_ui;
QStandardItemModel *m_model; QStandardItemModel *m_model;
QSortFilterProxyModel *m_filterProxyModel; QSortFilterProxyModel *m_filterProxyModel;
QPushButton *m_okButton; QPushButton *m_okButton = nullptr;
QIcon m_dummyIcon; QIcon m_dummyIcon;
QList<QStandardItem*> m_categoryItems; QList<QStandardItem*> m_categoryItems;
QString m_defaultLocation; QString m_defaultLocation;

View File

@@ -63,7 +63,7 @@ PromptOverwriteDialog::PromptOverwriteDialog(QWidget *parent) :
setWindowTitle(tr("Overwrite Existing Files")); setWindowTitle(tr("Overwrite Existing Files"));
setModal(true); setModal(true);
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
QVBoxLayout *mainLayout = new QVBoxLayout(this); auto mainLayout = new QVBoxLayout(this);
mainLayout->addWidget(m_label); mainLayout->addWidget(m_label);
m_view->setRootIsDecorated(false); m_view->setRootIsDecorated(false);
m_view->setUniformRowHeights(true); m_view->setUniformRowHeights(true);
@@ -105,7 +105,7 @@ QStandardItem *PromptOverwriteDialog::itemForFile(const QString &f) const
if (fileNameOfItem(item) == f) if (fileNameOfItem(item) == f)
return item; return item;
} }
return 0; return nullptr;
} }
QStringList PromptOverwriteDialog::files(Qt::CheckState cs) const QStringList PromptOverwriteDialog::files(Qt::CheckState cs) const

View File

@@ -53,7 +53,7 @@ class ReadOnlyFilesDialogPrivate
Q_DECLARE_TR_FUNCTIONS(Core::ReadOnlyFilesDialog) Q_DECLARE_TR_FUNCTIONS(Core::ReadOnlyFilesDialog)
public: public:
ReadOnlyFilesDialogPrivate(ReadOnlyFilesDialog *parent, IDocument *document = 0, bool useSaveAs = false); ReadOnlyFilesDialogPrivate(ReadOnlyFilesDialog *parent, IDocument *document = nullptr, bool useSaveAs = false);
~ReadOnlyFilesDialogPrivate(); ~ReadOnlyFilesDialogPrivate();
enum ReadOnlyFilesTreeColumn { enum ReadOnlyFilesTreeColumn {
@@ -324,7 +324,7 @@ QRadioButton *ReadOnlyFilesDialogPrivate::createRadioButtonForItem(QTreeWidgetIt
ReadOnlyFilesTreeColumn type) ReadOnlyFilesTreeColumn type)
{ {
QRadioButton *radioButton = new QRadioButton(q); auto radioButton = new QRadioButton(q);
group->addButton(radioButton, type); group->addButton(radioButton, type);
item->setTextAlignment(type, Qt::AlignHCenter); item->setTextAlignment(type, Qt::AlignHCenter);
ui.treeWidget->setItemWidget(item, type, radioButton); 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. // Check for every file if the selected operation is available and change it to the operation.
foreach (ReadOnlyFilesDialogPrivate::ButtonGroupForFile groupForFile, buttonGroups) { 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) if (radioButton)
radioButton->setChecked(true); radioButton->setChecked(true);
} }
@@ -400,11 +400,11 @@ void ReadOnlyFilesDialogPrivate::initDialog(const QStringList &fileNames)
const QString directory = info.absolutePath(); const QString directory = info.absolutePath();
// Setup a default entry with filename folder and make writable radio button. // 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->setText(FileName, visibleName);
item->setIcon(FileName, FileIconProvider::icon(fileName)); item->setIcon(FileName, FileIconProvider::icon(fileName));
item->setText(Folder, Utils::FileUtils::shortNativePath(Utils::FileName(QFileInfo(directory)))); 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 // 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. // 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) if (useSaveAs)
createRadioButtonForItem(item, radioButtonGroup, SaveAs); createRadioButtonForItem(item, radioButtonGroup, SaveAs);
// If the file is managed by a version control system save the vcs for this file. // 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. // Also save the buttongroup for every file to get the result for each entry.
ReadOnlyFilesDialogPrivate::ButtonGroupForFile groupForFile; ReadOnlyFilesDialogPrivate::ButtonGroupForFile groupForFile;

View File

@@ -166,7 +166,7 @@ void SaveItemsDialog::collectFilesToDiff()
{ {
m_filesToDiff.clear(); m_filesToDiff.clear();
foreach (QTreeWidgetItem *item, m_ui.treeWidget->selectedItems()) { 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()); m_filesToDiff.append(doc->filePath().toString());
} }
reject(); reject();

View File

@@ -101,7 +101,7 @@ class CategoryModel : public QAbstractListModel
{ {
public: public:
CategoryModel(); CategoryModel();
~CategoryModel(); ~CategoryModel() override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) 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) { if (!category) {
category = new Category; category = new Category;
category->id = categoryId; category->id = categoryId;
category->tabWidget = 0; category->tabWidget = nullptr;
category->index = -1; category->index = -1;
m_categories.append(category); m_categories.append(category);
} }
@@ -189,7 +189,7 @@ void CategoryModel::setPages(const QList<IOptionsPage*> &pages,
if (!category) { if (!category) {
category = new Category; category = new Category;
category->id = categoryId; category->id = categoryId;
category->tabWidget = 0; category->tabWidget = nullptr;
category->index = -1; category->index = -1;
m_categories.append(category); m_categories.append(category);
} }
@@ -233,7 +233,7 @@ Category *CategoryModel::findCategoryById(Id id)
return category; return category;
} }
return 0; return nullptr;
} }
// ----------- Category filter model // ----------- Category filter model
@@ -245,7 +245,7 @@ Category *CategoryModel::findCategoryById(Id id)
class CategoryFilterModel : public QSortFilterProxyModel class CategoryFilterModel : public QSortFilterProxyModel
{ {
public: public:
CategoryFilterModel() {} CategoryFilterModel() = default;
protected: protected:
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
@@ -284,7 +284,7 @@ class CategoryListViewDelegate : public QStyledItemDelegate
public: public:
explicit CategoryListViewDelegate(QObject *parent) : QStyledItemDelegate(parent) {} 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); QSize size = QStyledItemDelegate::sizeHint(option, index);
size.setHeight(qMax(size.height(), 32)); size.setHeight(qMax(size.height(), 32));
@@ -540,7 +540,7 @@ void SettingsDialog::createGui()
headerLabelFont.setPointSize(pointSize + 2); headerLabelFont.setPointSize(pointSize + 2);
m_headerLabel->setFont(headerLabelFont); m_headerLabel->setFont(headerLabelFont);
QHBoxLayout *headerHLayout = new QHBoxLayout; auto headerHLayout = new QHBoxLayout;
const int leftMargin = QApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin); const int leftMargin = QApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin);
headerHLayout->addSpacerItem(new QSpacerItem(leftMargin, 0, QSizePolicy::Fixed, QSizePolicy::Ignored)); headerHLayout->addSpacerItem(new QSpacerItem(leftMargin, 0, QSizePolicy::Fixed, QSizePolicy::Ignored));
headerHLayout->addWidget(m_headerLabel); headerHLayout->addWidget(m_headerLabel);
@@ -559,7 +559,7 @@ void SettingsDialog::createGui()
connect(buttonBox, &QDialogButtonBox::accepted, this, &SettingsDialog::accept); connect(buttonBox, &QDialogButtonBox::accepted, this, &SettingsDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &SettingsDialog::reject); connect(buttonBox, &QDialogButtonBox::rejected, this, &SettingsDialog::reject);
QGridLayout *mainGridLayout = new QGridLayout; auto mainGridLayout = new QGridLayout;
mainGridLayout->addWidget(m_filterLineEdit, 0, 0, 1, 1); mainGridLayout->addWidget(m_filterLineEdit, 0, 0, 1, 1);
mainGridLayout->addLayout(headerHLayout, 0, 1, 1, 1); mainGridLayout->addLayout(headerHLayout, 0, 1, 1, 1);
mainGridLayout->addWidget(m_categoryList, 1, 0, 1, 1); mainGridLayout->addWidget(m_categoryList, 1, 0, 1, 1);
@@ -598,12 +598,12 @@ void SettingsDialog::ensureCategoryWidget(Category *category)
return; return;
m_model.ensurePages(category); m_model.ensurePages(category);
QTabWidget *tabWidget = new QTabWidget; auto tabWidget = new QTabWidget;
tabWidget->tabBar()->setObjectName("qc_settings_main_tabbar"); // easier lookup in Squish tabWidget->tabBar()->setObjectName("qc_settings_main_tabbar"); // easier lookup in Squish
for (IOptionsPage *page : category->pages) { for (IOptionsPage *page : category->pages) {
QWidget *widget = page->widget(); QWidget *widget = page->widget();
ICore::setupScreenShooter(page->displayName(), widget); ICore::setupScreenShooter(page->displayName(), widget);
SmartScrollArea *ssa = new SmartScrollArea(this); auto ssa = new SmartScrollArea(this);
ssa->setWidget(widget); ssa->setWidget(widget);
widget->setAutoFillBackground(false); widget->setAutoFillBackground(false);
tabWidget->addTab(ssa, page->displayName()); tabWidget->addTab(ssa, page->displayName());

View File

@@ -125,7 +125,7 @@ QSize ShortcutButton::sizeHint() const
{ {
if (m_preferredWidth < 0) { // initialize size hint if (m_preferredWidth < 0) { // initialize size hint
const QString originalText = text(); const QString originalText = text();
ShortcutButton *that = const_cast<ShortcutButton *>(this); auto that = const_cast<ShortcutButton *>(this);
that->setText(m_checkedText); that->setText(m_checkedText);
m_preferredWidth = QPushButton::sizeHint().width(); m_preferredWidth = QPushButton::sizeHint().width();
that->setText(m_uncheckedText); that->setText(m_uncheckedText);
@@ -153,7 +153,7 @@ bool ShortcutButton::eventFilter(QObject *obj, QEvent *evt)
return true; return true;
} }
if (evt->type() == QEvent::KeyPress) { if (evt->type() == QEvent::KeyPress) {
QKeyEvent *k = static_cast<QKeyEvent*>(evt); auto k = static_cast<QKeyEvent*>(evt);
int nextKey = k->key(); int nextKey = k->key();
if (m_keyNum > 3 if (m_keyNum > 3
|| nextKey == Qt::Key_Control || nextKey == Qt::Key_Control
@@ -486,8 +486,8 @@ void ShortcutSettingsWidget::initialize()
if (c->action() && c->action()->isSeparator()) if (c->action() && c->action()->isSeparator())
continue; continue;
QTreeWidgetItem *item = 0; QTreeWidgetItem *item = nullptr;
ShortcutItem *s = new ShortcutItem; auto s = new ShortcutItem;
m_scitems << s; m_scitems << s;
item = new QTreeWidgetItem; item = new QTreeWidgetItem;
s->m_cmd = c; s->m_cmd = c;

View File

@@ -436,7 +436,7 @@ void DocumentManager::renamedFile(const QString &from, const QString &to)
void DocumentManager::filePathChanged(const FileName &oldName, const FileName &newName) 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); QTC_ASSERT(doc, return);
if (doc == d->m_blockedIDocument) if (doc == d->m_blockedIDocument)
return; return;
@@ -456,7 +456,7 @@ void DocumentManager::addDocument(IDocument *document, bool addWatcher)
void DocumentManager::documentDestroyed(QObject *obj) void DocumentManager::documentDestroyed(QObject *obj)
{ {
IDocument *document = static_cast<IDocument*>(obj); auto document = static_cast<IDocument*>(obj);
// Check the special unwatched first: // Check the special unwatched first:
if (!d->m_documentsWithoutWatch.removeOne(document)) if (!d->m_documentsWithoutWatch.removeOne(document))
removeFileInfo(document); removeFileInfo(document);
@@ -487,7 +487,7 @@ bool DocumentManager::removeDocument(IDocument *document)
because the file was saved under different name. */ because the file was saved under different name. */
void DocumentManager::checkForNewFileName() void DocumentManager::checkForNewFileName()
{ {
IDocument *document = qobject_cast<IDocument *>(sender()); auto document = qobject_cast<IDocument *>(sender());
// We modified the IDocument // We modified the IDocument
// Trust the other code to also update the m_states map // Trust the other code to also update the m_states map
if (document == d->m_blockedIDocument) if (document == d->m_blockedIDocument)
@@ -720,7 +720,7 @@ bool DocumentManager::saveDocument(IDocument *document, const QString &fileName,
return ret; return ret;
} }
QString DocumentManager::allDocumentFactoryFiltersString(QString *allFilesFilter = 0) QString DocumentManager::allDocumentFactoryFiltersString(QString *allFilesFilter = nullptr)
{ {
QSet<QString> uniqueFilters; QSet<QString> uniqueFilters;

View File

@@ -54,7 +54,7 @@ public:
KeepLinks KeepLinks
}; };
typedef QPair<QString, Id> RecentFile; using RecentFile = QPair<QString, Id>;
static DocumentManager *instance(); static DocumentManager *instance();

View File

@@ -61,13 +61,13 @@ EditMode::EditMode() :
auto editorPlaceHolder = new EditorManagerPlaceHolder; auto editorPlaceHolder = new EditorManagerPlaceHolder;
m_rightSplitWidgetLayout->insertWidget(0, editorPlaceHolder); m_rightSplitWidgetLayout->insertWidget(0, editorPlaceHolder);
MiniSplitter *rightPaneSplitter = new MiniSplitter; auto rightPaneSplitter = new MiniSplitter;
rightPaneSplitter->insertWidget(0, rightSplitWidget); rightPaneSplitter->insertWidget(0, rightSplitWidget);
rightPaneSplitter->insertWidget(1, new RightPanePlaceHolder(Constants::MODE_EDIT)); rightPaneSplitter->insertWidget(1, new RightPanePlaceHolder(Constants::MODE_EDIT));
rightPaneSplitter->setStretchFactor(0, 1); rightPaneSplitter->setStretchFactor(0, 1);
rightPaneSplitter->setStretchFactor(1, 0); rightPaneSplitter->setStretchFactor(1, 0);
MiniSplitter *splitter = new MiniSplitter; auto splitter = new MiniSplitter;
splitter->setOrientation(Qt::Vertical); splitter->setOrientation(Qt::Vertical);
splitter->insertWidget(0, rightPaneSplitter); splitter->insertWidget(0, rightPaneSplitter);
QWidget *outputPane = new OutputPanePlaceHolder(Constants::MODE_EDIT, splitter); QWidget *outputPane = new OutputPanePlaceHolder(Constants::MODE_EDIT, splitter);
@@ -87,7 +87,7 @@ EditMode::EditMode() :
this, &EditMode::grabEditorManager); this, &EditMode::grabEditorManager);
m_splitter->setFocusProxy(editorPlaceHolder); m_splitter->setFocusProxy(editorPlaceHolder);
IContext *modeContextObject = new IContext(this); auto modeContextObject = new IContext(this);
modeContextObject->setContext(Context(Constants::C_EDITORMANAGER)); modeContextObject->setContext(Context(Constants::C_EDITORMANAGER));
modeContextObject->setWidget(m_splitter); modeContextObject->setWidget(m_splitter);
ICore::addContextObject(modeContextObject); ICore::addContextObject(modeContextObject);

View File

@@ -44,7 +44,7 @@ class EditMode : public IMode
public: public:
EditMode(); EditMode();
~EditMode(); ~EditMode() override;
private: private:
void grabEditorManager(Id mode); void grabEditorManager(Id mode);

View File

@@ -295,7 +295,7 @@ QVariant DocumentModelPrivate::data(const QModelIndex &index, int role) const
void DocumentModelPrivate::itemChanged() void DocumentModelPrivate::itemChanged()
{ {
IDocument *document = qobject_cast<IDocument *>(sender()); auto document = qobject_cast<IDocument *>(sender());
const Utils::optional<int> idx = indexOfDocument(document); const Utils::optional<int> idx = indexOfDocument(document);
if (!idx) if (!idx)
@@ -439,7 +439,7 @@ void DocumentModelPrivate::DynamicEntry::setNumberedName(int number)
} // Internal } // Internal
DocumentModel::Entry::Entry() : DocumentModel::Entry::Entry() :
document(0), document(nullptr),
isSuspended(false) isSuspended(false)
{ {
} }
@@ -450,9 +450,7 @@ DocumentModel::Entry::~Entry()
delete document; delete document;
} }
DocumentModel::DocumentModel() DocumentModel::DocumentModel() = default;
{
}
void DocumentModel::init() void DocumentModel::init()
{ {
@@ -561,7 +559,7 @@ DocumentModel::Entry *DocumentModel::entryAtRow(int row)
{ {
int entryIndex = row - 1/*<no document>*/; int entryIndex = row - 1/*<no document>*/;
if (entryIndex < 0) if (entryIndex < 0)
return 0; return nullptr;
return d->m_entries[entryIndex]; return d->m_entries[entryIndex];
} }

View File

@@ -42,7 +42,7 @@ class DocumentModelPrivate : public QAbstractItemModel
Q_OBJECT Q_OBJECT
public: public:
~DocumentModelPrivate(); ~DocumentModelPrivate() override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;

View File

@@ -665,9 +665,9 @@ IEditor *EditorManagerPrivate::openEditor(EditorView *view, const QString &fileN
IEditorFactory *selectedFactory = nullptr; IEditorFactory *selectedFactory = nullptr;
if (!factories.isEmpty()) { 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); QTC_ASSERT(button, return nullptr);
QMenu *menu = new QMenu(button); auto menu = new QMenu(button);
foreach (IEditorFactory *factory, factories) { foreach (IEditorFactory *factory, factories) {
QAction *action = menu->addAction(factory->displayName()); QAction *action = menu->addAction(factory->displayName());
connect(action, &QAction::triggered, &msgbox, [&selectedFactory, factory, &msgbox]() { connect(action, &QAction::triggered, &msgbox, [&selectedFactory, factory, &msgbox]() {
@@ -785,7 +785,7 @@ EditorView *EditorManagerPrivate::viewForEditor(IEditor *editor)
QWidget *w = editor->widget(); QWidget *w = editor->widget();
while (w) { while (w) {
w = w->parentWidget(); w = w->parentWidget();
if (EditorView *view = qobject_cast<EditorView *>(w)) if (auto view = qobject_cast<EditorView *>(w))
return view; return view;
} }
return nullptr; return nullptr;
@@ -1566,7 +1566,7 @@ EditorArea *EditorManagerPrivate::findEditorArea(const EditorView *view, int *ar
{ {
SplitterOrView *current = view->parentSplitterOrView(); SplitterOrView *current = view->parentSplitterOrView();
while (current) { while (current) {
if (EditorArea *area = qobject_cast<EditorArea *>(current)) { if (auto area = qobject_cast<EditorArea *>(current)) {
int index = d->m_editorAreas.indexOf(area); int index = d->m_editorAreas.indexOf(area);
QTC_ASSERT(index >= 0, return nullptr); QTC_ASSERT(index >= 0, return nullptr);
if (areaIndex) if (areaIndex)
@@ -1980,7 +1980,7 @@ void EditorManagerPrivate::vcsOpenCurrentEditor()
void EditorManagerPrivate::handleDocumentStateChange() void EditorManagerPrivate::handleDocumentStateChange()
{ {
updateActions(); updateActions();
IDocument *document = qobject_cast<IDocument *>(sender()); auto document = qobject_cast<IDocument *>(sender());
if (!document->isModified()) if (!document->isModified())
document->removeAutoSaveFile(); document->removeAutoSaveFile();
if (EditorManager::currentDocument() == document) if (EditorManager::currentDocument() == document)
@@ -2082,7 +2082,7 @@ void EditorManagerPrivate::copyFilePathFromContextMenu()
void EditorManagerPrivate::copyLocationFromContextMenu() void EditorManagerPrivate::copyLocationFromContextMenu()
{ {
const QAction *action = qobject_cast<const QAction *>(sender()); const auto action = qobject_cast<const QAction *>(sender());
if (!d->m_contextMenuEntry || !action) if (!d->m_contextMenuEntry || !action)
return; return;
const QString text = d->m_contextMenuEntry->fileName().toUserOutput() 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) void EditorManager::populateOpenWithMenu(QMenu *menu, const QString &fileName)
{ {
typedef QList<IEditorFactory*> EditorFactoryList; using EditorFactoryList = QList<IEditorFactory*>;
typedef QList<IExternalEditor*> ExternalEditorList; using ExternalEditorList = QList<IExternalEditor*>;
menu->clear(); menu->clear();

View File

@@ -75,7 +75,7 @@ class CORE_EXPORT EditorManager : public QObject
Q_OBJECT Q_OBJECT
public: public:
typedef std::function<QString (const QString &)> WindowTitleHandler; using WindowTitleHandler = std::function<QString (const QString &)>;
static EditorManager *instance(); static EditorManager *instance();

View File

@@ -68,10 +68,9 @@ EditorView::EditorView(SplitterOrView *parentSplitterOrView, QWidget *parent) :
m_container(new QStackedWidget(this)), m_container(new QStackedWidget(this)),
m_infoBarDisplay(new InfoBarDisplay(this)), m_infoBarDisplay(new InfoBarDisplay(this)),
m_statusHLine(new QFrame(this)), m_statusHLine(new QFrame(this)),
m_statusWidget(new QFrame(this)), m_statusWidget(new QFrame(this))
m_currentNavigationHistoryPosition(0)
{ {
QVBoxLayout *tl = new QVBoxLayout(this); auto tl = new QVBoxLayout(this);
tl->setSpacing(0); tl->setSpacing(0);
tl->setMargin(0); tl->setMargin(0);
{ {
@@ -106,7 +105,7 @@ EditorView::EditorView(SplitterOrView *parentSplitterOrView, QWidget *parent) :
m_statusWidget->setLineWidth(0); m_statusWidget->setLineWidth(0);
m_statusWidget->setAutoFillBackground(true); m_statusWidget->setAutoFillBackground(true);
QHBoxLayout *hbox = new QHBoxLayout(m_statusWidget); auto hbox = new QHBoxLayout(m_statusWidget);
hbox->setContentsMargins(1, 0, 1, 1); hbox->setContentsMargins(1, 0, 1, 1);
m_statusWidgetLabel = new QLabel; m_statusWidgetLabel = new QLabel;
m_statusWidgetLabel->setContentsMargins(3, 0, 3, 0); m_statusWidgetLabel->setContentsMargins(3, 0, 3, 0);
@@ -153,9 +152,7 @@ EditorView::EditorView(SplitterOrView *parentSplitterOrView, QWidget *parent) :
updateNavigatorActions(); updateNavigatorActions();
} }
EditorView::~EditorView() EditorView::~EditorView() = default;
{
}
SplitterOrView *EditorView::parentSplitterOrView() const SplitterOrView *EditorView::parentSplitterOrView() const
{ {
@@ -173,7 +170,7 @@ EditorView *EditorView::findNextView()
QTC_ASSERT(splitter->count() == 2, return nullptr); QTC_ASSERT(splitter->count() == 2, return nullptr);
// is current the first child? then the next view is the first one in current's sibling // is current the first child? then the next view is the first one in current's sibling
if (splitter->widget(0) == current) { 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); QTC_ASSERT(second, return nullptr);
return second->findFirstView(); return second->findFirstView();
} }
@@ -196,7 +193,7 @@ EditorView *EditorView::findPreviousView()
QTC_ASSERT(splitter->count() == 2, return nullptr); QTC_ASSERT(splitter->count() == 2, return nullptr);
// is current the last child? then the previous view is the first child in current's sibling // is current the last child? then the previous view is the first child in current's sibling
if (splitter->widget(1) == current) { 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); QTC_ASSERT(first, return nullptr);
return first->findFirstView(); return first->findFirstView();
} }
@@ -652,7 +649,7 @@ EditorView *SplitterOrView::findFirstView()
{ {
if (m_splitter) { if (m_splitter) {
for (int i = 0; i < m_splitter->count(); ++i) { 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()) if (EditorView *result = splitterOrView->findFirstView())
return result; return result;
} }
@@ -665,7 +662,7 @@ EditorView *SplitterOrView::findLastView()
{ {
if (m_splitter) { if (m_splitter) {
for (int i = m_splitter->count() - 1; 0 < i; --i) { 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()) if (EditorView *result = splitterOrView->findLastView())
return result; return result;
} }
@@ -678,7 +675,7 @@ SplitterOrView *SplitterOrView::findParentSplitter() const
{ {
QWidget *w = parentWidget(); QWidget *w = parentWidget();
while (w) { while (w) {
if (SplitterOrView *splitter = qobject_cast<SplitterOrView *>(w)) { if (auto splitter = qobject_cast<SplitterOrView *>(w)) {
QTC_CHECK(splitter->splitter()); QTC_CHECK(splitter->splitter());
return splitter; return splitter;
} }
@@ -801,7 +798,7 @@ const QList<IEditor *> SplitterOrView::unsplitAll_helper()
QList<IEditor *> editorsToDelete; QList<IEditor *> editorsToDelete;
if (m_splitter) { if (m_splitter) {
for (int i = 0; i < m_splitter->count(); ++i) { 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()); editorsToDelete.append(splitterOrView->unsplitAll_helper());
} }
} }
@@ -814,7 +811,7 @@ void SplitterOrView::unsplit()
return; return;
Q_ASSERT(m_splitter->count() == 1); 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; QSplitter *oldSplitter = m_splitter;
m_splitter = nullptr; m_splitter = nullptr;
QList<IEditor *> editorsToDelete; QList<IEditor *> editorsToDelete;
@@ -838,7 +835,7 @@ void SplitterOrView::unsplit()
m_view = childSplitterOrView->takeView(); m_view = childSplitterOrView->takeView();
m_view->setParentSplitterOrView(this); m_view->setParentSplitterOrView(this);
m_layout->addWidget(m_view); 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) { // not the toplevel splitterOrView
if (parentSplitter->orientation() == Qt::Horizontal) if (parentSplitter->orientation() == Qt::Horizontal)
m_view->setCloseSplitIcon(parentSplitter->widget(0) == this ? m_view->setCloseSplitIcon(parentSplitter->widget(0) == this ?

View File

@@ -142,7 +142,7 @@ private:
QList<EditLocation> m_navigationHistory; QList<EditLocation> m_navigationHistory;
QList<EditLocation> m_editorHistory; QList<EditLocation> m_editorHistory;
int m_currentNavigationHistoryPosition; int m_currentNavigationHistoryPosition = 0;
void updateCurrentPositionInNavigationHistory(); void updateCurrentPositionInNavigationHistory();
public: public:

View File

@@ -82,7 +82,7 @@ EditorWindow::EditorWindow(QWidget *parent) :
EditorWindow::~EditorWindow() EditorWindow::~EditorWindow()
{ {
if (m_area) if (m_area)
disconnect(m_area, 0, this, 0); disconnect(m_area, nullptr, this, nullptr);
} }
EditorArea *EditorWindow::editorArea() const EditorArea *EditorWindow::editorArea() const

View File

@@ -36,8 +36,8 @@ class EditorWindow : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit EditorWindow(QWidget *parent = 0); explicit EditorWindow(QWidget *parent = nullptr);
~EditorWindow(); ~EditorWindow() override;
EditorArea *editorArea() const; EditorArea *editorArea() const;

View File

@@ -65,9 +65,7 @@ OpenEditorsWidget::OpenEditorsWidget()
this, &OpenEditorsWidget::contextMenuRequested); this, &OpenEditorsWidget::contextMenuRequested);
} }
OpenEditorsWidget::~OpenEditorsWidget() OpenEditorsWidget::~OpenEditorsWidget() = default;
{
}
void OpenEditorsWidget::updateCurrentItem(IEditor *editor) 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 // work around a bug in itemviews where the delegate wouldn't get the QStyle::State_MouseOver
QPoint cursorPos = QCursor::pos(); QPoint cursorPos = QCursor::pos();
QWidget *vp = viewport(); 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); QCoreApplication::sendEvent(vp, &e);
} }
} }

View File

@@ -39,7 +39,7 @@ class ProxyModel : public QAbstractProxyModel
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit ProxyModel(QObject *parent = 0); explicit ProxyModel(QObject *parent = nullptr);
QModelIndex mapFromSource(const QModelIndex & sourceIndex) const override; QModelIndex mapFromSource(const QModelIndex & sourceIndex) const override;
QModelIndex mapToSource(const QModelIndex & proxyIndex) const override; QModelIndex mapToSource(const QModelIndex & proxyIndex) const override;
@@ -69,7 +69,7 @@ class OpenEditorsWidget : public OpenDocumentsTreeView
public: public:
OpenEditorsWidget(); OpenEditorsWidget();
~OpenEditorsWidget(); ~OpenEditorsWidget() override;
private: private:
void handleActivated(const QModelIndex &); void handleActivated(const QModelIndex &);
@@ -88,7 +88,7 @@ class OpenEditorsViewFactory : public INavigationWidgetFactory
public: public:
OpenEditorsViewFactory(); OpenEditorsViewFactory();
NavigationView createWidget(); NavigationView createWidget() override;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -72,7 +72,7 @@ OpenEditorsWindow::OpenEditorsWindow(QWidget *parent) :
setFrameStyle(m_editorList->frameStyle()); setFrameStyle(m_editorList->frameStyle());
m_editorList->setFrameStyle(QFrame::NoFrame); m_editorList->setFrameStyle(QFrame::NoFrame);
QVBoxLayout *layout = new QVBoxLayout(this); auto layout = new QVBoxLayout(this);
layout->setMargin(0); layout->setMargin(0);
layout->addWidget(m_editorList); layout->addWidget(m_editorList);
@@ -97,7 +97,7 @@ bool OpenEditorsWindow::eventFilter(QObject *obj, QEvent *e)
{ {
if (obj == m_editorList) { if (obj == m_editorList) {
if (e->type() == QEvent::KeyPress) { if (e->type() == QEvent::KeyPress) {
QKeyEvent *ke = static_cast<QKeyEvent*>(e); auto ke = static_cast<QKeyEvent*>(e);
if (ke->key() == Qt::Key_Escape) { if (ke->key() == Qt::Key_Escape) {
setVisible(false); setVisible(false);
return true; return true;
@@ -108,7 +108,7 @@ bool OpenEditorsWindow::eventFilter(QObject *obj, QEvent *e)
return true; return true;
} }
} else if (e->type() == QEvent::KeyRelease) { } else if (e->type() == QEvent::KeyRelease) {
QKeyEvent *ke = static_cast<QKeyEvent*>(e); auto ke = static_cast<QKeyEvent*>(e);
if (ke->modifiers() == 0 if (ke->modifiers() == 0
/*HACK this is to overcome some event inconsistencies between platforms*/ /*HACK this is to overcome some event inconsistencies between platforms*/
|| (ke->modifiers() == Qt::AltModifier || (ke->modifiers() == Qt::AltModifier
@@ -133,7 +133,7 @@ void OpenEditorsWindow::selectUpDown(bool up)
int index = m_editorList->indexOfTopLevelItem(m_editorList->currentItem()); int index = m_editorList->indexOfTopLevelItem(m_editorList->currentItem());
if (index < 0) if (index < 0)
return; return;
QTreeWidgetItem *editor = 0; QTreeWidgetItem *editor = nullptr;
int count = 0; int count = 0;
while (!editor && count < itemCount) { while (!editor && count < itemCount) {
if (up) { if (up) {
@@ -245,7 +245,7 @@ void OpenEditorsWindow::addItem(DocumentModel::Entry *entry,
entriesDone.insert(entry); entriesDone.insert(entry);
QString title = entry->displayName(); QString title = entry->displayName();
QTC_ASSERT(!title.isEmpty(), return); QTC_ASSERT(!title.isEmpty(), return);
QTreeWidgetItem *item = new QTreeWidgetItem(); auto item = new QTreeWidgetItem();
if (entry->document->isModified()) if (entry->document->isModified())
title += tr("*"); title += tr("*");
item->setIcon(0, !entry->fileName().isEmpty() && entry->document->isFileReadOnly() item->setIcon(0, !entry->fileName().isEmpty() && entry->document->isFileReadOnly()

View File

@@ -45,9 +45,9 @@ namespace Internal {
class OpenEditorsTreeWidget : public QTreeWidget { class OpenEditorsTreeWidget : public QTreeWidget {
public: public:
explicit OpenEditorsTreeWidget(QWidget *parent = 0) : QTreeWidget(parent) {} explicit OpenEditorsTreeWidget(QWidget *parent = nullptr) : QTreeWidget(parent) {}
~OpenEditorsTreeWidget() {} ~OpenEditorsTreeWidget() override = default;
QSize sizeHint() const; QSize sizeHint() const override;
}; };
@@ -58,16 +58,16 @@ class OpenEditorsWindow : public QFrame
public: public:
enum Mode {ListMode, HistoryMode }; enum Mode {ListMode, HistoryMode };
explicit OpenEditorsWindow(QWidget *parent = 0); explicit OpenEditorsWindow(QWidget *parent = nullptr);
void setEditors(const QList<EditLocation> &globalHistory, EditorView *view); void setEditors(const QList<EditLocation> &globalHistory, EditorView *view);
bool eventFilter(QObject *src, QEvent *e); bool eventFilter(QObject *src, QEvent *e) override;
void focusInEvent(QFocusEvent *); void focusInEvent(QFocusEvent*) override;
void setVisible(bool visible); void setVisible(bool visible) override;
void selectNextEditor(); void selectNextEditor();
void selectPreviousEditor(); void selectPreviousEditor();
QSize sizeHint() const; QSize sizeHint() const override;
public slots: public slots:
void selectAndHide(); void selectAndHide();

View File

@@ -35,13 +35,13 @@ class SystemEditor : public IExternalEditor
Q_OBJECT Q_OBJECT
public: public:
explicit SystemEditor(QObject *parent = 0); explicit SystemEditor(QObject *parent = nullptr);
QStringList mimeTypes() const; QStringList mimeTypes() const override;
Id id() const; Id id() const override;
QString displayName() const; QString displayName() const override;
bool startEditor(const QString &fileName, QString *errorMessage); bool startEditor(const QString &fileName, QString *errorMessage) override;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -93,7 +93,7 @@ EditorToolBarPrivate::EditorToolBarPrivate(QWidget *parent, EditorToolBar *q) :
m_closeEditorButton(new QToolButton(q)), m_closeEditorButton(new QToolButton(q)),
m_lockButton(new QToolButton(q)), m_lockButton(new QToolButton(q)),
m_dragHandle(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_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_goForwardAction(new QAction(Utils::Icons::NEXT_TOOLBAR.icon(), EditorManager::tr("Go Forward"), parent)),
m_backButton(new QToolButton(q)), m_backButton(new QToolButton(q)),
@@ -105,7 +105,7 @@ EditorToolBarPrivate::EditorToolBarPrivate(QWidget *parent, EditorToolBar *q) :
EditorManager::tr("Split Side by Side"), parent)), EditorManager::tr("Split Side by Side"), parent)),
m_splitNewWindowAction(new QAction(EditorManager::tr("Open in New Window"), parent)), m_splitNewWindowAction(new QAction(EditorManager::tr("Open in New Window"), parent)),
m_closeSplitButton(new QToolButton(q)), m_closeSplitButton(new QToolButton(q)),
m_activeToolBar(0), m_activeToolBar(nullptr),
m_toolBarPlaceholder(new QWidget(q)), m_toolBarPlaceholder(new QWidget(q)),
m_defaultToolBar(new QWidget(q)), m_defaultToolBar(new QWidget(q)),
m_isStandalone(false) m_isStandalone(false)
@@ -118,7 +118,7 @@ EditorToolBarPrivate::EditorToolBarPrivate(QWidget *parent, EditorToolBar *q) :
EditorToolBar::EditorToolBar(QWidget *parent) : EditorToolBar::EditorToolBar(QWidget *parent) :
Utils::StyledBar(parent), d(new EditorToolBarPrivate(parent, this)) Utils::StyledBar(parent), d(new EditorToolBarPrivate(parent, this))
{ {
QHBoxLayout *toolBarLayout = new QHBoxLayout(this); auto toolBarLayout = new QHBoxLayout(this);
toolBarLayout->setMargin(0); toolBarLayout->setMargin(0);
toolBarLayout->setSpacing(0); toolBarLayout->setSpacing(0);
toolBarLayout->addWidget(d->m_defaultToolBar); toolBarLayout->addWidget(d->m_defaultToolBar);
@@ -164,7 +164,7 @@ EditorToolBar::EditorToolBar(QWidget *parent) :
d->m_splitButton->setToolTip(tr("Split")); d->m_splitButton->setToolTip(tr("Split"));
d->m_splitButton->setPopupMode(QToolButton::InstantPopup); d->m_splitButton->setPopupMode(QToolButton::InstantPopup);
d->m_splitButton->setProperty("noArrow", true); 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_horizontalSplitAction);
splitMenu->addAction(d->m_verticalSplitAction); splitMenu->addAction(d->m_verticalSplitAction);
splitMenu->addAction(d->m_splitNewWindowAction); splitMenu->addAction(d->m_splitNewWindowAction);
@@ -173,7 +173,7 @@ EditorToolBar::EditorToolBar(QWidget *parent) :
d->m_closeSplitButton->setAutoRaise(true); d->m_closeSplitButton->setAutoRaise(true);
d->m_closeSplitButton->setIcon(Utils::Icons::CLOSE_SPLIT_BOTTOM.icon()); d->m_closeSplitButton->setIcon(Utils::Icons::CLOSE_SPLIT_BOTTOM.icon());
QHBoxLayout *toplayout = new QHBoxLayout(this); auto toplayout = new QHBoxLayout(this);
toplayout->setSpacing(0); toplayout->setSpacing(0);
toplayout->setMargin(0); toplayout->setMargin(0);
toplayout->addWidget(d->m_backButton); toplayout->addWidget(d->m_backButton);
@@ -236,14 +236,14 @@ void EditorToolBar::removeToolbarForEditor(IEditor *editor)
disconnect(editor->document(), &IDocument::changed, this, &EditorToolBar::checkDocumentStatus); disconnect(editor->document(), &IDocument::changed, this, &EditorToolBar::checkDocumentStatus);
QWidget *toolBar = editor->toolBar(); QWidget *toolBar = editor->toolBar();
if (toolBar != 0) { if (toolBar != nullptr) {
if (d->m_activeToolBar == toolBar) { if (d->m_activeToolBar == toolBar) {
d->m_activeToolBar = d->m_defaultToolBar; d->m_activeToolBar = d->m_defaultToolBar;
d->m_activeToolBar->setVisible(true); d->m_activeToolBar->setVisible(true);
} }
d->m_toolBarPlaceholder->layout()->removeWidget(toolBar); d->m_toolBarPlaceholder->layout()->removeWidget(toolBar);
toolBar->setVisible(false); 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) 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); const Utils::optional<int> index = DocumentModel::rowOfDocument(document);
if (QTC_GUARD(index)) if (QTC_GUARD(index))
d->m_editorList->setCurrentIndex(*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 // 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. // the editor, so there's no need to update the toolbar either.
if (!d->m_isStandalone) if (!d->m_isStandalone)
updateToolBar(editor ? editor->toolBar() : 0); updateToolBar(editor ? editor->toolBar() : nullptr);
updateDocumentStatus(document); updateDocumentStatus(document);
} }
@@ -353,7 +353,7 @@ void EditorToolBar::fillListContextMenu(QMenu *menu)
} else { } else {
IEditor *editor = EditorManager::currentEditor(); IEditor *editor = EditorManager::currentEditor();
DocumentModel::Entry *entry = editor ? DocumentModel::entryForDocument(editor->document()) DocumentModel::Entry *entry = editor ? DocumentModel::entryForDocument(editor->document())
: 0; : nullptr;
EditorManager::addSaveAndCloseEditorActions(menu, entry, editor); EditorManager::addSaveAndCloseEditorActions(menu, entry, editor);
menu->addSeparator(); menu->addSeparator();
EditorManager::addNativeDirAndOpenWithActions(menu, entry); EditorManager::addNativeDirAndOpenWithActions(menu, entry);
@@ -386,7 +386,7 @@ void EditorToolBar::updateActionShortcuts()
void EditorToolBar::checkDocumentStatus() void EditorToolBar::checkDocumentStatus()
{ {
IDocument *document = qobject_cast<IDocument *>(sender()); auto document = qobject_cast<IDocument *>(sender());
QTC_ASSERT(document, return); QTC_ASSERT(document, return);
DocumentModel::Entry *entry = DocumentModel::entryAtRow( DocumentModel::Entry *entry = DocumentModel::entryAtRow(
d->m_editorList->currentIndex()); d->m_editorList->currentIndex());
@@ -397,7 +397,7 @@ void EditorToolBar::checkDocumentStatus()
void EditorToolBar::updateDocumentStatus(IDocument *document) void EditorToolBar::updateDocumentStatus(IDocument *document)
{ {
d->m_closeEditorButton->setEnabled(document != 0); d->m_closeEditorButton->setEnabled(document != nullptr);
if (!document) { if (!document) {
d->m_lockButton->setIcon(QIcon()); d->m_lockButton->setIcon(QIcon());

View File

@@ -53,7 +53,7 @@ public:
explicit EditorToolBar(QWidget *parent = nullptr); explicit EditorToolBar(QWidget *parent = nullptr);
~EditorToolBar() override; ~EditorToolBar() override;
typedef std::function<void(QMenu*)> MenuProvider; using MenuProvider = std::function<void(QMenu*)>;
enum ToolbarCreationFlags { FlagsNone = 0, FlagsStandalone = 1 }; enum ToolbarCreationFlags { FlagsNone = 0, FlagsStandalone = 1 };
/** /**

View File

@@ -81,11 +81,7 @@ const char kFalse[] = "false";
// #pragma mark -- ExternalTool // #pragma mark -- ExternalTool
ExternalTool::ExternalTool() : ExternalTool::ExternalTool() :
m_displayCategory(QLatin1String("")), // difference between isNull and isEmpty m_displayCategory(QLatin1String("")) // difference between isNull and isEmpty
m_order(-1),
m_outputHandling(ShowInPane),
m_errorHandling(ShowInPane),
m_modifiesCurrentDocument(false)
{ {
} }
@@ -129,9 +125,7 @@ ExternalTool &ExternalTool::operator=(const ExternalTool &other)
return *this; return *this;
} }
ExternalTool::~ExternalTool() ExternalTool::~ExternalTool() = default;
{
}
QString ExternalTool::id() const QString ExternalTool::id() const
{ {
@@ -354,7 +348,7 @@ ExternalTool * ExternalTool::createFromXml(const QByteArray &xml, QString *error
int nameLocale = -1; int nameLocale = -1;
int categoryLocale = -1; int categoryLocale = -1;
const QStringList &locales = splitLocale(locale); const QStringList &locales = splitLocale(locale);
ExternalTool *tool = new ExternalTool; auto tool = new ExternalTool;
QXmlStreamReader reader(xml); QXmlStreamReader reader(xml);
if (!reader.readNextStartElement() || reader.name() != QLatin1String(kExternalTool)) if (!reader.readNextStartElement() || reader.name() != QLatin1String(kExternalTool))
@@ -442,7 +436,7 @@ ExternalTool * ExternalTool::createFromXml(const QByteArray &xml, QString *error
if (errorMessage) if (errorMessage)
*errorMessage = reader.errorString(); *errorMessage = reader.errorString();
delete tool; delete tool;
return 0; return nullptr;
} }
return tool; return tool;
} }
@@ -452,10 +446,10 @@ ExternalTool * ExternalTool::createFromFile(const QString &fileName, QString *er
QString absFileName = QFileInfo(fileName).absoluteFilePath(); QString absFileName = QFileInfo(fileName).absoluteFilePath();
FileReader reader; FileReader reader;
if (!reader.fetch(absFileName, errorMessage)) if (!reader.fetch(absFileName, errorMessage))
return 0; return nullptr;
ExternalTool *tool = ExternalTool::createFromXml(reader.data(), errorMessage, locale); ExternalTool *tool = ExternalTool::createFromXml(reader.data(), errorMessage, locale);
if (!tool) if (!tool)
return 0; return nullptr;
tool->m_fileName = absFileName; tool->m_fileName = absFileName;
return tool; return tool;
} }
@@ -541,7 +535,7 @@ bool ExternalTool::operator==(const ExternalTool &other) const
ExternalToolRunner::ExternalToolRunner(const ExternalTool *tool) ExternalToolRunner::ExternalToolRunner(const ExternalTool *tool)
: m_tool(new ExternalTool(tool)), : m_tool(new ExternalTool(tool)),
m_process(0), m_process(nullptr),
m_outputCodec(QTextCodec::codecForLocale()), m_outputCodec(QTextCodec::codecForLocale()),
m_hasError(false) m_hasError(false)
{ {

View File

@@ -103,15 +103,15 @@ private:
QString m_description; QString m_description;
QString m_displayName; QString m_displayName;
QString m_displayCategory; QString m_displayCategory;
int m_order; int m_order = -1;
QStringList m_executables; QStringList m_executables;
QString m_arguments; QString m_arguments;
QString m_input; QString m_input;
QString m_workingDirectory; QString m_workingDirectory;
QList<Utils::EnvironmentItem> m_environment; QList<Utils::EnvironmentItem> m_environment;
OutputHandling m_outputHandling; OutputHandling m_outputHandling = ShowInPane;
OutputHandling m_errorHandling; OutputHandling m_errorHandling = ShowInPane;
bool m_modifiesCurrentDocument; bool m_modifiesCurrentDocument = false;
QString m_fileName; QString m_fileName;
QString m_presetFileName; QString m_presetFileName;

View File

@@ -56,8 +56,8 @@ struct ExternalToolManagerPrivate
QAction *m_configureAction; QAction *m_configureAction;
}; };
static ExternalToolManager *m_instance = 0; static ExternalToolManager *m_instance = nullptr;
static ExternalToolManagerPrivate *d = 0; static ExternalToolManagerPrivate *d = nullptr;
static void writeSettings(); static void writeSettings();
static void readSettings(const QMap<QString, ExternalTool *> &tools, static void readSettings(const QMap<QString, ExternalTool *> &tools,
@@ -211,7 +211,7 @@ void ExternalToolManager::setToolsByCategory(const QMap<QString, QList<ExternalT
it.toFront(); it.toFront();
while (it.hasNext()) { while (it.hasNext()) {
it.next(); it.next();
ActionContainer *container = 0; ActionContainer *container = nullptr;
const QString &containerName = it.key(); const QString &containerName = it.key();
if (containerName.isEmpty()) { // no displayCategory, so put into external tools menu directly if (containerName.isEmpty()) { // no displayCategory, so put into external tools menu directly
container = mexternaltools; container = mexternaltools;
@@ -227,8 +227,8 @@ void ExternalToolManager::setToolsByCategory(const QMap<QString, QList<ExternalT
foreach (ExternalTool *tool, it.value()) { foreach (ExternalTool *tool, it.value()) {
const QString &toolId = tool->id(); const QString &toolId = tool->id();
// tool action and command // tool action and command
QAction *action = 0; QAction *action = nullptr;
Command *command = 0; Command *command = nullptr;
if (d->m_actions.contains(toolId)) { if (d->m_actions.contains(toolId)) {
action = d->m_actions.value(toolId); action = d->m_actions.value(toolId);
command = ActionManager::command(externalToolsPrefix.withSuffix(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); action = new QAction(tool->displayName(), m_instance);
d->m_actions.insert(toolId, action); d->m_actions.insert(toolId, action);
connect(action, &QAction::triggered, [tool] { connect(action, &QAction::triggered, [tool] {
ExternalToolRunner *runner = new ExternalToolRunner(tool); auto runner = new ExternalToolRunner(tool);
if (runner->hasError()) if (runner->hasError())
MessageManager::write(runner->errorString()); MessageManager::write(runner->errorString());
}); });

View File

@@ -111,7 +111,7 @@ void BaseTextFind::setTextCursor(const QTextCursor &cursor)
QTextDocument *BaseTextFind::document() const 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(); return d->m_editor ? d->m_editor->document() : d->m_plaineditor->document();
} }
@@ -140,7 +140,7 @@ void BaseTextFind::resetIncrementalSearch()
void BaseTextFind::clearHighlights() void BaseTextFind::clearHighlights()
{ {
highlightAll(QString(), 0); highlightAll(QString(), nullptr);
} }
QString BaseTextFind::currentFindString() const QString BaseTextFind::currentFindString() const
@@ -191,7 +191,7 @@ IFindSupport::Result BaseTextFind::findIncremental(const QString &txt, FindFlags
if (found) if (found)
highlightAll(txt, findFlags); highlightAll(txt, findFlags);
else else
highlightAll(QString(), 0); highlightAll(QString(), nullptr);
return found ? Found : NotFound; return found ? Found : NotFound;
} }

View File

@@ -40,7 +40,7 @@ using namespace Core;
using namespace Core::Internal; using namespace Core::Internal;
CurrentDocumentFind::CurrentDocumentFind() CurrentDocumentFind::CurrentDocumentFind()
: m_currentFind(0) : m_currentFind(nullptr)
{ {
connect(qApp, &QApplication::focusChanged, connect(qApp, &QApplication::focusChanged,
this, &CurrentDocumentFind::updateCandidateFindFilter); this, &CurrentDocumentFind::updateCandidateFindFilter);
@@ -48,7 +48,7 @@ CurrentDocumentFind::CurrentDocumentFind()
void CurrentDocumentFind::removeConnections() void CurrentDocumentFind::removeConnections()
{ {
disconnect(qApp, 0, this, 0); disconnect(qApp, nullptr, this, nullptr);
removeFindSupportConnections(); removeFindSupportConnections();
} }
@@ -82,7 +82,7 @@ bool CurrentDocumentFind::supportsReplace() const
FindFlags CurrentDocumentFind::supportedFindFlags() const FindFlags CurrentDocumentFind::supportedFindFlags() const
{ {
QTC_ASSERT(m_currentFind, return 0); QTC_ASSERT(m_currentFind, return nullptr);
return m_currentFind->supportedFindFlags(); return m_currentFind->supportedFindFlags();
} }
@@ -134,7 +134,7 @@ int CurrentDocumentFind::replaceAll(const QString &before, const QString &after,
QTC_CHECK(m_currentWidget); QTC_CHECK(m_currentWidget);
int count = m_currentFind->replaceAll(before, after, findFlags); int count = m_currentFind->replaceAll(before, after, findFlags);
Utils::FadingIndicator::showText(m_currentWidget, Utils::FadingIndicator::showText(m_currentWidget,
tr("%n occurrences replaced.", 0, count), tr("%n occurrences replaced.", nullptr, count),
Utils::FadingIndicator::SmallText); Utils::FadingIndicator::SmallText);
return count; return count;
} }
@@ -155,7 +155,7 @@ void CurrentDocumentFind::updateCandidateFindFilter(QWidget *old, QWidget *now)
{ {
Q_UNUSED(old) Q_UNUSED(old)
QWidget *candidate = now; QWidget *candidate = now;
QPointer<IFindSupport> impl = 0; QPointer<IFindSupport> impl = nullptr;
while (!impl && candidate) { while (!impl && candidate) {
impl = Aggregation::query<IFindSupport>(candidate); impl = Aggregation::query<IFindSupport>(candidate);
if (!impl) if (!impl)
@@ -215,8 +215,8 @@ void CurrentDocumentFind::removeFindSupportConnections()
void CurrentDocumentFind::clearFindSupport() void CurrentDocumentFind::clearFindSupport()
{ {
removeFindSupportConnections(); removeFindSupportConnections();
m_currentWidget = 0; m_currentWidget = nullptr;
m_currentFind = 0; m_currentFind = nullptr;
emit changed(); emit changed();
} }

View File

@@ -61,7 +61,7 @@ public:
void removeConnections(); void removeConnections();
bool setFocusToCurrentFindSupport(); bool setFocusToCurrentFindSupport();
bool eventFilter(QObject *obj, QEvent *event); bool eventFilter(QObject *obj, QEvent *event) override;
signals: signals:
void changed(); void changed();

View File

@@ -181,24 +181,24 @@ public:
void setupFilterMenuItems(); void setupFilterMenuItems();
void readSettings(); void readSettings();
Internal::CurrentDocumentFind *m_currentDocumentFind = 0; Internal::CurrentDocumentFind *m_currentDocumentFind = nullptr;
Internal::FindToolBar *m_findToolBar = 0; Internal::FindToolBar *m_findToolBar = nullptr;
Internal::FindToolWindow *m_findDialog = 0; Internal::FindToolWindow *m_findDialog = nullptr;
SearchResultWindow *m_searchResultWindow = 0; SearchResultWindow *m_searchResultWindow = nullptr;
FindFlags m_findFlags; FindFlags m_findFlags;
CompletionModel m_findCompletionModel; CompletionModel m_findCompletionModel;
QStringListModel m_replaceCompletionModel; QStringListModel m_replaceCompletionModel;
QStringList m_replaceCompletions; QStringList m_replaceCompletions;
QAction *m_openFindDialog = 0; QAction *m_openFindDialog = nullptr;
}; };
Find *m_instance = 0; Find *m_instance = nullptr;
FindPrivate *d = 0; FindPrivate *d = nullptr;
void Find::destroy() void Find::destroy()
{ {
delete m_instance; delete m_instance;
m_instance = 0; m_instance = nullptr;
if (d) { if (d) {
delete d->m_currentDocumentFind; delete d->m_currentDocumentFind;
delete d->m_findToolBar; delete d->m_findToolBar;
@@ -245,7 +245,7 @@ void Find::extensionsInitialized()
void Find::aboutToShutdown() void Find::aboutToShutdown()
{ {
d->m_findToolBar->setVisible(false); d->m_findToolBar->setVisible(false);
d->m_findToolBar->setParent(0); d->m_findToolBar->setParent(nullptr);
d->m_currentDocumentFind->removeConnections(); d->m_currentDocumentFind->removeConnections();
} }

View File

@@ -121,26 +121,26 @@ FindToolBar::FindToolBar(CurrentDocumentFind *currentDocumentFind)
static_cast<void (QCompleter::*)(const QModelIndex &)>(&QCompleter::activated), static_cast<void (QCompleter::*)(const QModelIndex &)>(&QCompleter::activated),
this, &FindToolBar::findCompleterActivated); this, &FindToolBar::findCompleterActivated);
QAction *shiftEnterAction = new QAction(m_ui.findEdit); auto shiftEnterAction = new QAction(m_ui.findEdit);
shiftEnterAction->setShortcut(QKeySequence(tr("Shift+Enter"))); shiftEnterAction->setShortcut(QKeySequence(tr("Shift+Enter")));
shiftEnterAction->setShortcutContext(Qt::WidgetShortcut); shiftEnterAction->setShortcutContext(Qt::WidgetShortcut);
connect(shiftEnterAction, &QAction::triggered, connect(shiftEnterAction, &QAction::triggered,
this, &FindToolBar::invokeFindPrevious); this, &FindToolBar::invokeFindPrevious);
m_ui.findEdit->addAction(shiftEnterAction); 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->setShortcut(QKeySequence(tr("Shift+Return")));
shiftReturnAction->setShortcutContext(Qt::WidgetShortcut); shiftReturnAction->setShortcutContext(Qt::WidgetShortcut);
connect(shiftReturnAction, &QAction::triggered, connect(shiftReturnAction, &QAction::triggered,
this, &FindToolBar::invokeFindPrevious); this, &FindToolBar::invokeFindPrevious);
m_ui.findEdit->addAction(shiftReturnAction); 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->setShortcut(QKeySequence(tr("Shift+Enter")));
shiftEnterReplaceAction->setShortcutContext(Qt::WidgetShortcut); shiftEnterReplaceAction->setShortcutContext(Qt::WidgetShortcut);
connect(shiftEnterReplaceAction, &QAction::triggered, connect(shiftEnterReplaceAction, &QAction::triggered,
this, &FindToolBar::invokeReplacePrevious); this, &FindToolBar::invokeReplacePrevious);
m_ui.replaceEdit->addAction(shiftEnterReplaceAction); 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->setShortcut(QKeySequence(tr("Shift+Return")));
shiftReturnReplaceAction->setShortcutContext(Qt::WidgetShortcut); shiftReturnReplaceAction->setShortcutContext(Qt::WidgetShortcut);
connect(shiftReturnReplaceAction, &QAction::triggered, connect(shiftReturnReplaceAction, &QAction::triggered,
@@ -313,9 +313,7 @@ FindToolBar::FindToolBar(CurrentDocumentFind *currentDocumentFind)
connect(&m_findStepTimer, &QTimer::timeout, this, &FindToolBar::invokeFindStep); connect(&m_findStepTimer, &QTimer::timeout, this, &FindToolBar::invokeFindStep);
} }
FindToolBar::~FindToolBar() FindToolBar::~FindToolBar() = default;
{
}
void FindToolBar::findCompleterActivated(const QModelIndex &index) void FindToolBar::findCompleterActivated(const QModelIndex &index)
{ {
@@ -342,7 +340,7 @@ void FindToolBar::installEventFilters()
bool FindToolBar::eventFilter(QObject *obj, QEvent *event) bool FindToolBar::eventFilter(QObject *obj, QEvent *event)
{ {
if (event->type() == QEvent::KeyPress) { if (event->type() == QEvent::KeyPress) {
QKeyEvent *ke = static_cast<QKeyEvent *>(event); auto ke = static_cast<QKeyEvent *>(event);
if (ke->key() == Qt::Key_Down) { if (ke->key() == Qt::Key_Down) {
if (obj == m_ui.findEdit) { if (obj == m_ui.findEdit) {
if (m_ui.findEdit->text().isEmpty()) 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()) if ((obj == m_ui.findEdit || obj == m_findCompleter->popup())
&& event->type() == QEvent::KeyPress) { && 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())) { if (ke->key() == Qt::Key_Space && (ke->modifiers() & Utils::HostOsInfo::controlModifier())) {
QString completedText = m_currentDocumentFind->completedFindString(); QString completedText = m_currentDocumentFind->completedFindString();
if (!completedText.isEmpty()) { if (!completedText.isEmpty()) {
@@ -368,7 +366,7 @@ bool FindToolBar::eventFilter(QObject *obj, QEvent *event)
} }
} }
} else if (obj == this && event->type() == QEvent::ShortcutOverride) { } 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())) { if (ke->key() == Qt::Key_Space && (ke->modifiers() & Utils::HostOsInfo::controlModifier())) {
event->accept(); event->accept();
return true; return true;
@@ -394,7 +392,7 @@ void FindToolBar::adaptToCandidate()
void FindToolBar::updateGlobalActions() void FindToolBar::updateGlobalActions()
{ {
IFindSupport *candidate = m_currentDocumentFind->candidate(); IFindSupport *candidate = m_currentDocumentFind->candidate();
bool enabled = (candidate != 0); bool enabled = (candidate != nullptr);
bool replaceEnabled = enabled && candidate->supportsReplace(); bool replaceEnabled = enabled && candidate->supportsReplace();
m_findInDocumentAction->setEnabled(enabled || (toolBarHasFocus() && isEnabled())); m_findInDocumentAction->setEnabled(enabled || (toolBarHasFocus() && isEnabled()));
m_findNextSelectedAction->setEnabled(enabled); m_findNextSelectedAction->setEnabled(enabled);
@@ -670,7 +668,7 @@ void FindToolBar::findFlagsChanged()
void FindToolBar::findEditButtonClicked() void FindToolBar::findEditButtonClicked()
{ {
OptionsPopup *popup = new OptionsPopup(m_ui.findEdit); auto popup = new OptionsPopup(m_ui.findEdit);
popup->show(); popup->show();
} }
@@ -753,7 +751,7 @@ FindToolBarPlaceHolder *FindToolBar::findToolBarPlaceHolder() const
} }
candidate = candidate->parentWidget(); candidate = candidate->parentWidget();
} }
return 0; return nullptr;
} }
bool FindToolBar::toolBarHasFocus() const bool FindToolBar::toolBarHasFocus() const
@@ -826,7 +824,7 @@ void FindToolBar::openFindToolBar(OpenFlags flags)
FindToolBarPlaceHolder *previousHolder = FindToolBarPlaceHolder::getCurrent(); FindToolBarPlaceHolder *previousHolder = FindToolBarPlaceHolder::getCurrent();
if (previousHolder != holder) { if (previousHolder != holder) {
if (previousHolder) if (previousHolder)
previousHolder->setWidget(0); previousHolder->setWidget(nullptr);
holder->setWidget(this); holder->setWidget(this);
FindToolBarPlaceHolder::setCurrent(holder); FindToolBarPlaceHolder::setCurrent(holder);
} }
@@ -987,7 +985,7 @@ OptionsPopup::OptionsPopup(QWidget *parent)
: QWidget(parent, Qt::Popup) : QWidget(parent, Qt::Popup)
{ {
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
QVBoxLayout *layout = new QVBoxLayout(this); auto layout = new QVBoxLayout(this);
layout->setContentsMargins(2, 2, 2, 2); layout->setContentsMargins(2, 2, 2, 2);
layout->setSpacing(2); layout->setSpacing(2);
setLayout(layout); setLayout(layout);
@@ -1003,7 +1001,7 @@ OptionsPopup::OptionsPopup(QWidget *parent)
bool OptionsPopup::event(QEvent *ev) bool OptionsPopup::event(QEvent *ev)
{ {
if (ev->type() == QEvent::ShortcutOverride) { 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()) { if (ke->key() == Qt::Key_Escape && !ke->modifiers()) {
ev->accept(); ev->accept();
return true; return true;
@@ -1014,9 +1012,9 @@ bool OptionsPopup::event(QEvent *ev)
bool OptionsPopup::eventFilter(QObject *obj, 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) { 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)) { if (!ke->modifiers() && (ke->key() == Qt::Key_Enter || ke->key() == Qt::Key_Return)) {
checkbox->click(); checkbox->click();
ev->accept(); ev->accept();
@@ -1028,7 +1026,7 @@ bool OptionsPopup::eventFilter(QObject *obj, QEvent *ev)
void OptionsPopup::actionChanged() void OptionsPopup::actionChanged()
{ {
QAction *action = qobject_cast<QAction *>(sender()); auto action = qobject_cast<QAction *>(sender());
QTC_ASSERT(action, return); QTC_ASSERT(action, return);
QCheckBox *checkbox = m_checkboxMap.value(action); QCheckBox *checkbox = m_checkboxMap.value(action);
QTC_ASSERT(checkbox, return); QTC_ASSERT(checkbox, return);

View File

@@ -51,8 +51,8 @@ public:
explicit OptionsPopup(QWidget *parent); explicit OptionsPopup(QWidget *parent);
protected: protected:
bool event(QEvent *ev); bool event(QEvent *ev) override;
bool eventFilter(QObject *obj, QEvent *ev); bool eventFilter(QObject *obj, QEvent *ev) override;
private: private:
void actionChanged(); void actionChanged();
@@ -77,7 +77,7 @@ public:
Q_DECLARE_FLAGS(OpenFlags, OpenFlag) Q_DECLARE_FLAGS(OpenFlags, OpenFlag)
explicit FindToolBar(CurrentDocumentFind *currentDocumentFind); explicit FindToolBar(CurrentDocumentFind *currentDocumentFind);
~FindToolBar(); ~FindToolBar() override;
void readSettings(); void readSettings();
void writeSettings(); void writeSettings();
@@ -91,8 +91,8 @@ public slots:
void setBackward(bool backward); void setBackward(bool backward);
protected: protected:
bool focusNextPrevChild(bool next); bool focusNextPrevChild(bool next) override;
void resizeEvent(QResizeEvent *event); void resizeEvent(QResizeEvent *event) override;
private: private:
void invokeFindNext(); void invokeFindNext();
@@ -147,7 +147,7 @@ private:
void acceptCandidateAndMoveToolBar(); void acceptCandidateAndMoveToolBar();
void indicateSearchState(IFindSupport::Result searchState); void indicateSearchState(IFindSupport::Result searchState);
bool eventFilter(QObject *obj, QEvent *event); bool eventFilter(QObject *obj, QEvent *event) override;
void setFindText(const QString &text); void setFindText(const QString &text);
QString getFindText(); QString getFindText();
QString getReplaceText(); QString getReplaceText();

View File

@@ -41,7 +41,7 @@
using namespace Core; using namespace Core;
using namespace Core::Internal; using namespace Core::Internal;
static FindToolWindow *m_instance = 0; static FindToolWindow *m_instance = nullptr;
static bool validateRegExp(Utils::FancyLineEdit *edit, QString *errorMessage) static bool validateRegExp(Utils::FancyLineEdit *edit, QString *errorMessage)
{ {
@@ -63,8 +63,8 @@ static bool validateRegExp(Utils::FancyLineEdit *edit, QString *errorMessage)
FindToolWindow::FindToolWindow(QWidget *parent) FindToolWindow::FindToolWindow(QWidget *parent)
: QWidget(parent), : QWidget(parent),
m_findCompleter(new QCompleter(this)), m_findCompleter(new QCompleter(this)),
m_currentFilter(0), m_currentFilter(nullptr),
m_configWidget(0) m_configWidget(nullptr)
{ {
m_instance = this; m_instance = this;
m_ui.setupUi(this); m_ui.setupUi(this);
@@ -93,7 +93,7 @@ FindToolWindow::FindToolWindow(QWidget *parent)
connect(m_ui.searchTerm, &Utils::FancyLineEdit::validChanged, connect(m_ui.searchTerm, &Utils::FancyLineEdit::validChanged,
this, &FindToolWindow::updateButtonStates); this, &FindToolWindow::updateButtonStates);
QVBoxLayout *layout = new QVBoxLayout; auto layout = new QVBoxLayout;
layout->setMargin(0); layout->setMargin(0);
layout->setSpacing(0); layout->setSpacing(0);
m_ui.configWidget->setLayout(layout); m_ui.configWidget->setLayout(layout);
@@ -115,7 +115,7 @@ FindToolWindow *FindToolWindow::instance()
bool FindToolWindow::event(QEvent *event) bool FindToolWindow::event(QEvent *event)
{ {
if (event->type() == QEvent::KeyPress) { 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) if ((ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter)
&& (ke->modifiers() == Qt::NoModifier || ke->modifiers() == Qt::KeypadModifier)) { && (ke->modifiers() == Qt::NoModifier || ke->modifiers() == Qt::KeypadModifier)) {
ke->accept(); ke->accept();
@@ -130,7 +130,7 @@ bool FindToolWindow::event(QEvent *event)
bool FindToolWindow::eventFilter(QObject *obj, QEvent *event) bool FindToolWindow::eventFilter(QObject *obj, QEvent *event)
{ {
if (obj == m_ui.searchTerm && event->type() == QEvent::KeyPress) { 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 (ke->key() == Qt::Key_Down) {
if (m_ui.searchTerm->text().isEmpty()) if (m_ui.searchTerm->text().isEmpty())
m_findCompleter->setCompletionPrefix(QString()); m_findCompleter->setCompletionPrefix(QString());
@@ -247,12 +247,12 @@ void FindToolWindow::setCurrentFilter(int index)
m_ui.configWidget->layout()->addWidget(m_configWidget); m_ui.configWidget->layout()->addWidget(m_configWidget);
} else { } else {
if (configWidget) if (configWidget)
configWidget->setParent(0); configWidget->setParent(nullptr);
} }
} }
QWidget *w = m_ui.configWidget; QWidget *w = m_ui.configWidget;
while (w) { while (w) {
QScrollArea *sa = qobject_cast<QScrollArea *>(w); auto sa = qobject_cast<QScrollArea *>(w);
if (sa) { if (sa) {
sa->updateGeometry(); sa->updateGeometry();
break; break;
@@ -268,7 +268,7 @@ void FindToolWindow::setCurrentFilter(int index)
void FindToolWindow::acceptAndGetParameters(QString *term, IFindFilter **filter) void FindToolWindow::acceptAndGetParameters(QString *term, IFindFilter **filter)
{ {
QTC_ASSERT(filter, return); QTC_ASSERT(filter, return);
*filter = 0; *filter = nullptr;
Find::updateFindCompletion(m_ui.searchTerm->text()); Find::updateFindCompletion(m_ui.searchTerm->text());
int index = m_ui.filterList->currentIndex(); int index = m_ui.filterList->currentIndex();
QString searchTerm = m_ui.searchTerm->text(); QString searchTerm = m_ui.searchTerm->text();
@@ -277,13 +277,13 @@ void FindToolWindow::acceptAndGetParameters(QString *term, IFindFilter **filter)
if (term) if (term)
*term = searchTerm; *term = searchTerm;
if (searchTerm.isEmpty() && *filter && !(*filter)->isValid()) if (searchTerm.isEmpty() && *filter && !(*filter)->isValid())
*filter = 0; *filter = nullptr;
} }
void FindToolWindow::search() void FindToolWindow::search()
{ {
QString term; QString term;
IFindFilter *filter = 0; IFindFilter *filter = nullptr;
acceptAndGetParameters(&term, &filter); acceptAndGetParameters(&term, &filter);
QTC_ASSERT(filter, return); QTC_ASSERT(filter, return);
filter->findAll(term, Find::findFlags()); filter->findAll(term, Find::findFlags());
@@ -292,7 +292,7 @@ void FindToolWindow::search()
void FindToolWindow::replace() void FindToolWindow::replace()
{ {
QString term; QString term;
IFindFilter *filter = 0; IFindFilter *filter = nullptr;
acceptAndGetParameters(&term, &filter); acceptAndGetParameters(&term, &filter);
QTC_ASSERT(filter, return); QTC_ASSERT(filter, return);
filter->replaceAll(term, Find::findFlags()); filter->replaceAll(term, Find::findFlags());

View File

@@ -42,8 +42,8 @@ class FindToolWindow : public QWidget
Q_OBJECT Q_OBJECT
public: public:
explicit FindToolWindow(QWidget *parent = 0); explicit FindToolWindow(QWidget *parent = nullptr);
~FindToolWindow(); ~FindToolWindow() override;
static FindToolWindow *instance(); static FindToolWindow *instance();
void setFindFilters(const QList<IFindFilter *> &filters); void setFindFilters(const QList<IFindFilter *> &filters);
@@ -55,8 +55,8 @@ public:
void writeSettings(); void writeSettings();
protected: protected:
bool event(QEvent *event); bool event(QEvent *event) override;
bool eventFilter(QObject *obj, QEvent *event); bool eventFilter(QObject *obj, QEvent *event) override;
private: private:
void search(); void search();

View File

@@ -204,7 +204,7 @@ void HighlightScrollBarOverlay::drawHighlights(QPainter *painter,
const QColor &color = creatorTheme()->color(itColor.key()); const QColor &color = creatorTheme()->color(itColor.key());
const QMap<int, int> &positions = itColor.value(); const QMap<int, int> &positions = itColor.value();
const auto itPosEnd = positions.constEnd(); const auto itPosEnd = positions.constEnd();
const int firstPos = int(docStart / lineHeight); const auto firstPos = int(docStart / lineHeight);
auto itPos = positions.upperBound(firstPos); auto itPos = positions.upperBound(firstPos);
if (itPos != positions.constBegin()) if (itPos != positions.constBegin())
--itPos; --itPos;

View File

@@ -40,7 +40,7 @@ public:
enum Result { Found, NotFound, NotYetFound }; enum Result { Found, NotFound, NotYetFound };
IFindSupport() : QObject(nullptr) {} IFindSupport() : QObject(nullptr) {}
~IFindSupport() override {} ~IFindSupport() override = default;
virtual bool supportsReplace() const = 0; virtual bool supportsReplace() const = 0;
virtual FindFlags supportedFindFlags() const = 0; virtual FindFlags supportedFindFlags() const = 0;

View File

@@ -230,7 +230,7 @@ IFindSupport::Result ItemViewFind::find(const QString &searchTxt,
d->m_view->setCurrentIndex(resultIndex); d->m_view->setCurrentIndex(resultIndex);
d->m_view->scrollTo(resultIndex); d->m_view->scrollTo(resultIndex);
if (resultIndex.parent().isValid()) 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()); treeView->expand(resultIndex.parent());
if (wrapped) if (wrapped)
*wrapped = anyWrapped; *wrapped = anyWrapped;

View File

@@ -134,7 +134,7 @@ int SearchResultTreeItemDelegate::drawLineNumber(QPainter *painter, const QStyle
opt.palette.setColor(cg, QPalette::Text, Qt::darkGray); opt.palette.setColor(cg, QPalette::Text, Qt::darkGray);
const QStyle *style = QApplication::style(); 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); const QRect rowRect = lineNumberAreaRect.adjusted(-textMargin, 0, textMargin-lineNumberAreaHorizontalPadding, 0);
QItemDelegate::drawDisplay(painter, opt, rowRect, lineText); QItemDelegate::drawDisplay(painter, opt, rowRect, lineText);

View File

@@ -33,8 +33,8 @@ namespace Internal {
class SearchResultTreeItemDelegate: public QItemDelegate class SearchResultTreeItemDelegate: public QItemDelegate
{ {
public: public:
SearchResultTreeItemDelegate(int tabWidth, QObject *parent = 0); SearchResultTreeItemDelegate(int tabWidth, QObject *parent = nullptr);
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
void setTabWidth(int width); void setTabWidth(int width);
private: private:

View File

@@ -44,7 +44,7 @@ SearchResultTreeItem::~SearchResultTreeItem()
bool SearchResultTreeItem::isLeaf() const bool SearchResultTreeItem::isLeaf() const
{ {
return childrenCount() == 0 && parent() != 0; return childrenCount() == 0 && parent() != nullptr;
} }
Qt::CheckState SearchResultTreeItem::checkState() const 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) if (insertionPosition != m_children.end() && (*insertionPosition)->item.text == text)
(*existingItem) = (*insertionPosition); (*existingItem) = (*insertionPosition);
else else
*existingItem = 0; *existingItem = nullptr;
} }
return insertionPosition - m_children.begin(); return insertionPosition - m_children.begin();
} }
@@ -113,7 +113,7 @@ void SearchResultTreeItem::insertChild(int index, SearchResultTreeItem *child)
void SearchResultTreeItem::insertChild(int index, const SearchResultItem &item) void SearchResultTreeItem::insertChild(int index, const SearchResultItem &item)
{ {
SearchResultTreeItem *child = new SearchResultTreeItem(item, this); auto child = new SearchResultTreeItem(item, this);
insertChild(index, child); insertChild(index, child);
} }

View File

@@ -37,7 +37,7 @@ class SearchResultTreeItem
{ {
public: public:
explicit SearchResultTreeItem(const SearchResultItem &item = SearchResultItem(), explicit SearchResultTreeItem(const SearchResultItem &item = SearchResultItem(),
SearchResultTreeItem *parent = NULL); SearchResultTreeItem *parent = nullptr);
virtual ~SearchResultTreeItem(); virtual ~SearchResultTreeItem();
bool isLeaf() const; bool isLeaf() const;

View File

@@ -37,7 +37,7 @@ using namespace Core::Internal;
SearchResultTreeModel::SearchResultTreeModel(QObject *parent) SearchResultTreeModel::SearchResultTreeModel(QObject *parent)
: QAbstractItemModel(parent) : QAbstractItemModel(parent)
, m_currentParent(0) , m_currentParent(nullptr)
, m_showReplaceUI(false) , m_showReplaceUI(false)
, m_editorFontIsUsed(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) bool SearchResultTreeModel::setData(const QModelIndex &idx, const QVariant &value, int role)
{ {
if (role == Qt::CheckStateRole) { 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 setCheckState(idx, checkState);
} }
return QAbstractItemModel::setData(idx, value, role); return QAbstractItemModel::setData(idx, value, role);
@@ -308,7 +308,7 @@ QSet<SearchResultTreeItem *> SearchResultTreeModel::addPath(const QStringList &p
QSet<SearchResultTreeItem *> pathNodes; QSet<SearchResultTreeItem *> pathNodes;
SearchResultTreeItem *currentItem = m_rootItem; SearchResultTreeItem *currentItem = m_rootItem;
QModelIndex currentItemIndex = QModelIndex(); QModelIndex currentItemIndex = QModelIndex();
SearchResultTreeItem *partItem = 0; SearchResultTreeItem *partItem = nullptr;
QStringList currentPath; QStringList currentPath;
foreach (const QString &part, path) { foreach (const QString &part, path) {
const int insertionIndex = currentItem->insertionIndex(part, &partItem); const int insertionIndex = currentItem->insertionIndex(part, &partItem);
@@ -418,7 +418,7 @@ QList<QModelIndex> SearchResultTreeModel::addResults(const QList<SearchResultIte
void SearchResultTreeModel::clear() void SearchResultTreeModel::clear()
{ {
beginResetModel(); beginResetModel();
m_currentParent = NULL; m_currentParent = nullptr;
m_rootItem->clearChildren(); m_rootItem->clearChildren();
m_editorFontIsUsed = false; m_editorFontIsUsed = false;
endResetModel(); endResetModel();

View File

@@ -41,8 +41,8 @@ class SearchResultTreeModel : public QAbstractItemModel
Q_OBJECT Q_OBJECT
public: public:
SearchResultTreeModel(QObject *parent = 0); SearchResultTreeModel(QObject *parent = nullptr);
~SearchResultTreeModel(); ~SearchResultTreeModel() override;
void setShowReplaceUI(bool show); void setShowReplaceUI(bool show);
void setTextEditorFont(const QFont &font, const SearchResultColor &color); 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; bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const 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 next(const QModelIndex &idx, bool includeGenerated = false, bool *wrapped = nullptr) const;
QModelIndex prev(const QModelIndex &idx, bool includeGenerated = false, bool *wrapped = 0) const; QModelIndex prev(const QModelIndex &idx, bool includeGenerated = false, bool *wrapped = nullptr) const;
QList<QModelIndex> addResults(const QList<SearchResultItem> &items, SearchResult::AddMode mode); QList<QModelIndex> addResults(const QList<SearchResultItem> &items, SearchResult::AddMode mode);
@@ -74,8 +74,8 @@ private:
QSet<SearchResultTreeItem *> addPath(const QStringList &path); QSet<SearchResultTreeItem *> addPath(const QStringList &path);
QVariant data(const SearchResultTreeItem *row, int role) const; QVariant data(const SearchResultTreeItem *row, int role) const;
bool setCheckState(const QModelIndex &idx, Qt::CheckState checkState, bool firstCall = true); bool setCheckState(const QModelIndex &idx, Qt::CheckState checkState, bool firstCall = true);
QModelIndex nextIndex(const QModelIndex &idx, bool *wrapped = 0) const; QModelIndex nextIndex(const QModelIndex &idx, bool *wrapped = nullptr) const;
QModelIndex prevIndex(const QModelIndex &idx, bool *wrapped = 0) const; QModelIndex prevIndex(const QModelIndex &idx, bool *wrapped = nullptr) const;
SearchResultTreeItem *treeItemAtIndex(const QModelIndex &idx) const; SearchResultTreeItem *treeItemAtIndex(const QModelIndex &idx) const;
SearchResultTreeItem *m_rootItem; SearchResultTreeItem *m_rootItem;

View File

@@ -89,7 +89,7 @@ void SearchResultTreeView::emitJumpToSearchResult(const QModelIndex &index)
void SearchResultTreeView::setTabWidth(int tabWidth) void SearchResultTreeView::setTabWidth(int tabWidth)
{ {
SearchResultTreeItemDelegate *delegate = static_cast<SearchResultTreeItemDelegate *>(itemDelegate()); auto delegate = static_cast<SearchResultTreeItemDelegate *>(itemDelegate());
delegate->setTabWidth(tabWidth); delegate->setTabWidth(tabWidth);
doItemsLayout(); doItemsLayout();
} }

View File

@@ -40,7 +40,7 @@ class SearchResultTreeView : public Utils::TreeView
Q_OBJECT Q_OBJECT
public: public:
explicit SearchResultTreeView(QWidget *parent = 0); explicit SearchResultTreeView(QWidget *parent = nullptr);
void setAutoExpandResults(bool expand); void setAutoExpandResults(bool expand);
void setTextEditorFont(const QFont &font, const SearchResultColor &color); void setTextEditorFont(const QFont &font, const SearchResultColor &color);

View File

@@ -69,7 +69,7 @@ public:
} }
QSize sizeHint() const QSize sizeHint() const override
{ {
QSize sh = QLineEdit::minimumSizeHint(); QSize sh = QLineEdit::minimumSizeHint();
sh.rwidth() += qMax(25 * fontMetrics().width(QLatin1Char('x')), sh.rwidth() += qMax(25 * fontMetrics().width(QLatin1Char('x')),
@@ -81,7 +81,7 @@ public:
SearchResultWidget::SearchResultWidget(QWidget *parent) : SearchResultWidget::SearchResultWidget(QWidget *parent) :
QWidget(parent) QWidget(parent)
{ {
QVBoxLayout *layout = new QVBoxLayout(this); auto layout = new QVBoxLayout(this);
layout->setMargin(0); layout->setMargin(0);
layout->setSpacing(0); layout->setSpacing(0);
setLayout(layout); setLayout(layout);
@@ -122,7 +122,7 @@ SearchResultWidget::SearchResultWidget(QWidget *parent) :
m_messageWidget->setLineWidth(1); m_messageWidget->setLineWidth(1);
} }
m_messageWidget->setAutoFillBackground(true); m_messageWidget->setAutoFillBackground(true);
QHBoxLayout *messageLayout = new QHBoxLayout(m_messageWidget); auto messageLayout = new QHBoxLayout(m_messageWidget);
messageLayout->setMargin(2); messageLayout->setMargin(2);
m_messageWidget->setLayout(messageLayout); m_messageWidget->setLayout(messageLayout);
QLabel *messageLabel = new QLabel(tr("Search was canceled.")); QLabel *messageLabel = new QLabel(tr("Search was canceled."));
@@ -134,7 +134,7 @@ SearchResultWidget::SearchResultWidget(QWidget *parent) :
m_searchResultTreeView = new SearchResultTreeView(this); m_searchResultTreeView = new SearchResultTreeView(this);
m_searchResultTreeView->setFrameStyle(QFrame::NoFrame); m_searchResultTreeView->setFrameStyle(QFrame::NoFrame);
m_searchResultTreeView->setAttribute(Qt::WA_MacShowFocusRect, false); m_searchResultTreeView->setAttribute(Qt::WA_MacShowFocusRect, false);
Aggregation::Aggregate * agg = new Aggregation::Aggregate; auto agg = new Aggregation::Aggregate;
agg->add(m_searchResultTreeView); agg->add(m_searchResultTreeView);
agg->add(new ItemViewFind(m_searchResultTreeView, agg->add(new ItemViewFind(m_searchResultTreeView,
ItemDataRoles::ResultLineRole)); ItemDataRoles::ResultLineRole));
@@ -144,7 +144,7 @@ SearchResultWidget::SearchResultWidget(QWidget *parent) :
m_infoBarDisplay.setInfoBar(&m_infoBar); m_infoBarDisplay.setInfoBar(&m_infoBar);
m_descriptionContainer = new QWidget(topFindWidget); m_descriptionContainer = new QWidget(topFindWidget);
QHBoxLayout *descriptionLayout = new QHBoxLayout(m_descriptionContainer); auto descriptionLayout = new QHBoxLayout(m_descriptionContainer);
m_descriptionContainer->setLayout(descriptionLayout); m_descriptionContainer->setLayout(descriptionLayout);
descriptionLayout->setMargin(0); descriptionLayout->setMargin(0);
m_descriptionContainer->setMinimumWidth(200); m_descriptionContainer->setMinimumWidth(200);
@@ -282,7 +282,7 @@ void SearchResultWidget::addResults(const QList<SearchResultItem> &items, Search
emit paused(true); emit paused(true);
InfoBarEntry info(sizeWarningId, InfoBarEntry info(sizeWarningId,
tr("The search resulted in more than %n items, do you still want to continue?", 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.setCancelButtonInfo(tr("Cancel"), [this]() { cancelAfterSizeWarning(); });
info.setCustomButtonInfo(tr("Continue"), [this]() { continueAfterSizeWarning(); }); info.setCustomButtonInfo(tr("Continue"), [this]() { continueAfterSizeWarning(); });
m_infoBar.addInfo(info); m_infoBar.addInfo(info);
@@ -499,12 +499,12 @@ QList<SearchResultItem> SearchResultWidget::checkedItems() const
const int fileCount = model->rowCount(); const int fileCount = model->rowCount();
for (int i = 0; i < fileCount; ++i) { for (int i = 0; i < fileCount; ++i) {
QModelIndex fileIndex = model->index(i, 0); QModelIndex fileIndex = model->index(i, 0);
SearchResultTreeItem *fileItem = static_cast<SearchResultTreeItem *>(fileIndex.internalPointer()); auto fileItem = static_cast<SearchResultTreeItem *>(fileIndex.internalPointer());
QTC_ASSERT(fileItem != 0, continue); QTC_ASSERT(fileItem != nullptr, continue);
for (int rowIndex = 0; rowIndex < fileItem->childrenCount(); ++rowIndex) { for (int rowIndex = 0; rowIndex < fileItem->childrenCount(); ++rowIndex) {
QModelIndex textIndex = model->index(rowIndex, 0, fileIndex); QModelIndex textIndex = model->index(rowIndex, 0, fileIndex);
SearchResultTreeItem *rowItem = static_cast<SearchResultTreeItem *>(textIndex.internalPointer()); auto rowItem = static_cast<SearchResultTreeItem *>(textIndex.internalPointer());
QTC_ASSERT(rowItem != 0, continue); QTC_ASSERT(rowItem != nullptr, continue);
if (rowItem->checkState()) if (rowItem->checkState())
result << rowItem->item; result << rowItem->item;
} }
@@ -517,7 +517,7 @@ void SearchResultWidget::updateMatchesFoundLabel()
if (m_count == 0) if (m_count == 0)
m_matchesFoundLabel->setText(tr("No matches found.")); m_matchesFoundLabel->setText(tr("No matches found."));
else else
m_matchesFoundLabel->setText(tr("%n matches found.", 0, m_count)); m_matchesFoundLabel->setText(tr("%n matches found.", nullptr, m_count));
} }
} // namespace Internal } // namespace Internal

View File

@@ -49,8 +49,8 @@ class SearchResultWidget : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit SearchResultWidget(QWidget *parent = 0); explicit SearchResultWidget(QWidget *parent = nullptr);
~SearchResultWidget(); ~SearchResultWidget() override;
void setInfo(const QString &label, const QString &toolTip, const QString &term); void setInfo(const QString &label, const QString &toolTip, const QString &term);
QWidget *additionalReplaceWidget() const; QWidget *additionalReplaceWidget() const;

View File

@@ -67,7 +67,7 @@ namespace Internal {
setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
} }
QSize sizeHint() const QSize sizeHint() const override
{ {
if (widget()) if (widget())
return widget()->size(); return widget()->size();
@@ -109,7 +109,7 @@ namespace Internal {
SearchResultWindowPrivate::SearchResultWindowPrivate(SearchResultWindow *window, QWidget *nsp) : SearchResultWindowPrivate::SearchResultWindowPrivate(SearchResultWindow *window, QWidget *nsp) :
q(window), q(window),
m_expandCollapseButton(0), m_expandCollapseButton(nullptr),
m_expandCollapseAction(new QAction(tr("Expand All"), window)), m_expandCollapseAction(new QAction(tr("Expand All"), window)),
m_spacer(new QWidget), m_spacer(new QWidget),
m_historyLabel(new QLabel(tr("History:"))), m_historyLabel(new QLabel(tr("History:"))),
@@ -178,7 +178,7 @@ namespace Internal {
void SearchResultWindowPrivate::moveWidgetToTop() void SearchResultWindowPrivate::moveWidgetToTop()
{ {
SearchResultWidget *widget = qobject_cast<SearchResultWidget *>(sender()); auto widget = qobject_cast<SearchResultWidget *>(sender());
QTC_ASSERT(widget, return); QTC_ASSERT(widget, return);
int index = m_searchResultWidgets.indexOf(widget); int index = m_searchResultWidgets.indexOf(widget);
if (index == 0) if (index == 0)
@@ -212,7 +212,7 @@ namespace Internal {
void SearchResultWindowPrivate::popupRequested(bool focus) void SearchResultWindowPrivate::popupRequested(bool focus)
{ {
SearchResultWidget *widget = qobject_cast<SearchResultWidget *>(sender()); auto widget = qobject_cast<SearchResultWidget *>(sender());
QTC_ASSERT(widget, return); QTC_ASSERT(widget, return);
int internalIndex = m_searchResultWidgets.indexOf(widget) + 1/*account for "new search" entry*/; int internalIndex = m_searchResultWidgets.indexOf(widget) + 1/*account for "new search" entry*/;
setCurrentIndex(internalIndex, focus); setCurrentIndex(internalIndex, focus);
@@ -297,7 +297,7 @@ using namespace Core::Internal;
\internal \internal
*/ */
SearchResultWindow *SearchResultWindow::m_instance = 0; SearchResultWindow *SearchResultWindow::m_instance = nullptr;
/*! /*!
\internal \internal
@@ -316,7 +316,7 @@ SearchResultWindow::~SearchResultWindow()
{ {
qDeleteAll(d->m_searchResults); qDeleteAll(d->m_searchResults);
delete d->m_widget; delete d->m_widget;
d->m_widget = 0; d->m_widget = nullptr;
delete d; delete d;
} }

View File

@@ -30,12 +30,12 @@
using namespace Core; using namespace Core;
FindToolBarPlaceHolder *FindToolBarPlaceHolder::m_current = 0; FindToolBarPlaceHolder *FindToolBarPlaceHolder::m_current = nullptr;
static QList<FindToolBarPlaceHolder *> g_findToolBarPlaceHolders; static QList<FindToolBarPlaceHolder *> g_findToolBarPlaceHolders;
FindToolBarPlaceHolder::FindToolBarPlaceHolder(QWidget *owner, QWidget *parent) 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); g_findToolBarPlaceHolders.append(this);
setLayout(new QVBoxLayout); setLayout(new QVBoxLayout);
@@ -48,10 +48,10 @@ FindToolBarPlaceHolder::~FindToolBarPlaceHolder()
g_findToolBarPlaceHolders.removeOne(this); g_findToolBarPlaceHolders.removeOne(this);
if (m_subWidget) { if (m_subWidget) {
m_subWidget->setVisible(false); m_subWidget->setVisible(false);
m_subWidget->setParent(0); m_subWidget->setParent(nullptr);
} }
if (m_current == this) if (m_current == this)
m_current = 0; m_current = nullptr;
} }
const QList<FindToolBarPlaceHolder *> FindToolBarPlaceHolder::allFindToolbarPlaceHolders() const QList<FindToolBarPlaceHolder *> FindToolBarPlaceHolder::allFindToolbarPlaceHolders()
@@ -82,7 +82,7 @@ void FindToolBarPlaceHolder::setWidget(Internal::FindToolBar *widget)
{ {
if (m_subWidget) { if (m_subWidget) {
m_subWidget->setVisible(false); m_subWidget->setVisible(false);
m_subWidget->setParent(0); m_subWidget->setParent(nullptr);
} }
m_subWidget = widget; m_subWidget = widget;
if (m_subWidget) { if (m_subWidget) {

View File

@@ -56,7 +56,7 @@ public:
private: private:
QWidget *m_owner; QWidget *m_owner;
QPointer<Internal::FindToolBar> m_subWidget; QPointer<Internal::FindToolBar> m_subWidget;
bool m_lightColored; bool m_lightColored = false;
static FindToolBarPlaceHolder *m_current; static FindToolBarPlaceHolder *m_current;
}; };

View File

@@ -48,7 +48,7 @@ namespace Internal {
const char settingsKeyDPI[] = "Core/EnableHighDpiScaling"; const char settingsKeyDPI[] = "Core/EnableHighDpiScaling";
GeneralSettings::GeneralSettings() GeneralSettings::GeneralSettings()
: m_page(0), m_dialog(0) : m_page(nullptr), m_dialog(nullptr)
{ {
setId(Constants::SETTINGS_ID_INTERFACE); setId(Constants::SETTINGS_ID_INTERFACE);
setDisplayName(tr("Interface")); setDisplayName(tr("Interface"));
@@ -143,7 +143,7 @@ void GeneralSettings::finish()
{ {
delete m_widget; delete m_widget;
delete m_page; delete m_page;
m_page = 0; m_page = nullptr;
} }
void GeneralSettings::resetInterfaceColor() void GeneralSettings::resetInterfaceColor()

View File

@@ -44,9 +44,9 @@ class GeneralSettings : public IOptionsPage
public: public:
GeneralSettings(); GeneralSettings();
QWidget *widget(); QWidget *widget() override;
void apply(); void apply() override;
void finish(); void finish() override;
private: private:
void resetInterfaceColor(); void resetInterfaceColor();

View File

@@ -49,19 +49,18 @@ namespace Core {
class GeneratedFilePrivate : public QSharedData class GeneratedFilePrivate : public QSharedData
{ {
public: public:
GeneratedFilePrivate() : binary(false) {} GeneratedFilePrivate() = default;
explicit GeneratedFilePrivate(const QString &p); explicit GeneratedFilePrivate(const QString &p);
QString path; QString path;
QByteArray contents; QByteArray contents;
Id editorId; Id editorId;
bool binary; bool binary = false;
GeneratedFile::Attributes attributes; GeneratedFile::Attributes attributes;
}; };
GeneratedFilePrivate::GeneratedFilePrivate(const QString &p) : GeneratedFilePrivate::GeneratedFilePrivate(const QString &p) :
path(QDir::cleanPath(p)), path(QDir::cleanPath(p)),
binary(false), attributes({})
attributes(0)
{ {
} }
@@ -75,10 +74,7 @@ GeneratedFile::GeneratedFile(const QString &p) :
{ {
} }
GeneratedFile::GeneratedFile(const GeneratedFile &rhs) : GeneratedFile::GeneratedFile(const GeneratedFile &rhs) = default;
m_d(rhs.m_d)
{
}
GeneratedFile &GeneratedFile::operator=(const GeneratedFile &rhs) GeneratedFile &GeneratedFile::operator=(const GeneratedFile &rhs)
{ {
@@ -87,9 +83,7 @@ GeneratedFile &GeneratedFile::operator=(const GeneratedFile &rhs)
return *this; return *this;
} }
GeneratedFile::~GeneratedFile() GeneratedFile::~GeneratedFile() = default;
{
}
QString GeneratedFile::path() const QString GeneratedFile::path() const
{ {

View File

@@ -84,6 +84,6 @@ private:
QSharedDataPointer<GeneratedFilePrivate> m_d; QSharedDataPointer<GeneratedFilePrivate> m_d;
}; };
typedef QList<GeneratedFile> GeneratedFiles; using GeneratedFiles = QList<GeneratedFile>;
} // namespace Core } // namespace Core

View File

@@ -57,10 +57,7 @@ namespace Core {
struct HelpManagerPrivate struct HelpManagerPrivate
{ {
HelpManagerPrivate() : HelpManagerPrivate() = default;
m_needsSetup(true), m_helpEngine(nullptr), m_collectionWatcher(nullptr)
{}
~HelpManagerPrivate(); ~HelpManagerPrivate();
const QStringList documentationFromInstaller(); const QStringList documentationFromInstaller();
@@ -68,9 +65,9 @@ struct HelpManagerPrivate
void writeSettings(); void writeSettings();
void cleanUpDocumentation(); void cleanUpDocumentation();
bool m_needsSetup; bool m_needsSetup = true;
QHelpEngineCore *m_helpEngine; QHelpEngineCore *m_helpEngine = nullptr;
Utils::FileSystemWatcher *m_collectionWatcher; Utils::FileSystemWatcher *m_collectionWatcher = nullptr;
// data for delayed initialization // data for delayed initialization
QSet<QString> m_filesToRegister; QSet<QString> m_filesToRegister;
@@ -506,7 +503,7 @@ void HelpManagerPrivate::writeSettings()
namespace Core { namespace Core {
HelpManager *HelpManager::instance() { return 0; } HelpManager *HelpManager::instance() { return nullptr; }
QString HelpManager::collectionFilePath() { return QString(); } QString HelpManager::collectionFilePath() { return QString(); }
@@ -542,7 +539,7 @@ void HelpManager::handleHelpRequest(const QUrl &, HelpManager::HelpViewerLocatio
void HelpManager::handleHelpRequest(const QString &, HelpViewerLocation) {} void HelpManager::handleHelpRequest(const QString &, HelpViewerLocation) {}
HelpManager::HelpManager(QObject *) {} HelpManager::HelpManager(QObject *) {}
HelpManager::~HelpManager() {} HelpManager::~HelpManager() = default;
void HelpManager::aboutToShutdown() {} void HelpManager::aboutToShutdown() {}
void HelpManager::setupHelpManager() {} void HelpManager::setupHelpManager() {}

View File

@@ -56,7 +56,7 @@ public:
ExternalHelpAlways = 3 ExternalHelpAlways = 3
}; };
typedef QHash<QString, QStringList> Filters; using Filters = QHash<QString, QStringList>;
static HelpManager *instance(); static HelpManager *instance();
static QString collectionFilePath(); static QString collectionFilePath();

View File

@@ -40,7 +40,7 @@ namespace Core {
class CORE_EXPORT Context class CORE_EXPORT Context
{ {
public: public:
Context() {} Context() = default;
explicit Context(Id c1) { add(c1); } explicit Context(Id c1) { add(c1); }
Context(Id c1, Id c2) { add(c1); add(c2); } Context(Id c1, Id c2) { add(c1); add(c2); }
@@ -51,7 +51,7 @@ public:
Id at(int i) const { return d.at(i); } Id at(int i) const { return d.at(i); }
// FIXME: Make interface slimmer. // 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 begin() const { return d.begin(); }
const_iterator end() const { return d.end(); } const_iterator end() const { return d.end(); }
int indexOf(Id c) const { return d.indexOf(c); } int indexOf(Id c) const { return d.indexOf(c); }

View File

@@ -337,8 +337,8 @@ ICore::ICore(MainWindow *mainwindow)
ICore::~ICore() ICore::~ICore()
{ {
m_instance = 0; m_instance = nullptr;
m_mainwindow = 0; m_mainwindow = nullptr;
} }
void ICore::showNewItemDialog(const QString &title, void ICore::showNewItemDialog(const QString &title,

View File

@@ -56,9 +56,7 @@ namespace Core {
class StringHolder class StringHolder
{ {
public: public:
StringHolder() StringHolder() = default;
: n(0), str(0)
{}
StringHolder(const char *s, int length) StringHolder(const char *s, int length)
: n(length), str(s) : n(length), str(s)
@@ -72,8 +70,8 @@ public:
h &= 0x0fffffff; h &= 0x0fffffff;
} }
} }
int n; int n = 0;
const char *str; const char *str = nullptr;
quintptr h; quintptr h;
}; };

View File

@@ -40,8 +40,9 @@ namespace Core {
class CORE_EXPORT Id class CORE_EXPORT Id
{ {
public: public:
Id() : m_id(0) {} Id() = default;
Id(const char *name); // Good to use. Id(const char *name); // Good to use.
Id(const QLatin1String &) = delete;
Id withSuffix(int suffix) const; Id withSuffix(int suffix) const;
Id withSuffix(const char *suffix) const; Id withSuffix(const char *suffix) const;
@@ -72,11 +73,9 @@ public:
static QStringList toStringList(const QSet<Id> &ids); static QStringList toStringList(const QSet<Id> &ids);
private: private:
// Intentionally unimplemented
Id(const QLatin1String &) = delete;
explicit Id(quintptr uid) : m_id(uid) {} 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()); } inline uint qHash(Id id) { return static_cast<uint>(id.uniqueIdentifier()); }

View File

@@ -49,7 +49,7 @@ const QList<IDocumentFactory *> IDocumentFactory::allDocumentFactories()
IDocument *IDocumentFactory::open(const QString &filename) IDocument *IDocumentFactory::open(const QString &filename)
{ {
QTC_ASSERT(m_opener, return 0); QTC_ASSERT(m_opener, return nullptr);
return m_opener(filename); return m_opener(filename);
} }

View File

@@ -46,7 +46,7 @@ public:
static const QList<IDocumentFactory *> allDocumentFactories(); 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); IDocument *open(const QString &filename);
QStringList mimeTypes() const { return m_mimeTypes; } QStringList mimeTypes() const { return m_mimeTypes; }

View File

@@ -91,7 +91,6 @@ static QList<INavigationWidgetFactory *> g_navigationWidgetFactories;
Creates a \l{Core::NavigationViewFactory}. Creates a \l{Core::NavigationViewFactory}.
*/ */
INavigationWidgetFactory::INavigationWidgetFactory() INavigationWidgetFactory::INavigationWidgetFactory()
: m_priority(0)
{ {
g_navigationWidgetFactories.append(this); g_navigationWidgetFactories.append(this);
} }

View File

@@ -78,7 +78,7 @@ public:
private: private:
QString m_displayName; QString m_displayName;
int m_priority; int m_priority = 0;
Id m_id; Id m_id;
QKeySequence m_activationSequence; QKeySequence m_activationSequence;
}; };

View File

@@ -202,7 +202,7 @@ void InfoBarDisplay::setInfoBar(InfoBar *infoBar)
void InfoBarDisplay::infoBarDestroyed() void InfoBarDisplay::infoBarDestroyed()
{ {
m_infoBar = 0; m_infoBar = nullptr;
// Calling update() here causes a complicated crash on shutdown. // Calling update() here causes a complicated crash on shutdown.
// So instead we rely on the view now being either destroyed (in which case it // 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. // will delete the widgets itself) or setInfoBar() being called explicitly.
@@ -233,10 +233,10 @@ void InfoBarDisplay::update()
infoWidget->setLineWidth(1); infoWidget->setLineWidth(1);
infoWidget->setAutoFillBackground(true); infoWidget->setAutoFillBackground(true);
QHBoxLayout *hbox = new QHBoxLayout; auto hbox = new QHBoxLayout;
hbox->setMargin(2); hbox->setMargin(2);
auto *vbox = new QVBoxLayout(infoWidget); auto vbox = new QVBoxLayout(infoWidget);
vbox->setMargin(0); vbox->setMargin(0);
vbox->addLayout(hbox); vbox->addLayout(hbox);
@@ -250,7 +250,7 @@ void InfoBarDisplay::update()
vbox->addWidget(detailsWidget); vbox->addWidget(detailsWidget);
} }
auto *showDetailsButton = new QToolButton; auto showDetailsButton = new QToolButton;
showDetailsButton->setCheckable(true); showDetailsButton->setCheckable(true);
showDetailsButton->setChecked(m_isShowingDetailsWidget); showDetailsButton->setChecked(m_isShowingDetailsWidget);
showDetailsButton->setText(tr("&Show Details")); showDetailsButton->setText(tr("&Show Details"));
@@ -271,7 +271,7 @@ void InfoBarDisplay::update()
} }
if (!info.buttonText.isEmpty()) { if (!info.buttonText.isEmpty()) {
QToolButton *infoWidgetButton = new QToolButton; auto infoWidgetButton = new QToolButton;
infoWidgetButton->setText(info.buttonText); infoWidgetButton->setText(info.buttonText);
connect(infoWidgetButton, &QAbstractButton::clicked, [info]() { info.m_buttonCallBack(); }); connect(infoWidgetButton, &QAbstractButton::clicked, [info]() { info.m_buttonCallBack(); });
@@ -279,7 +279,7 @@ void InfoBarDisplay::update()
} }
const Id id = info.id; const Id id = info.id;
QToolButton *infoWidgetSuppressButton = 0; QToolButton *infoWidgetSuppressButton = nullptr;
if (info.globalSuppression == InfoBarEntry::GlobalSuppressionEnabled) { if (info.globalSuppression == InfoBarEntry::GlobalSuppressionEnabled) {
infoWidgetSuppressButton = new QToolButton; infoWidgetSuppressButton = new QToolButton;
infoWidgetSuppressButton->setText(tr("Do Not Show Again")); infoWidgetSuppressButton->setText(tr("Do Not Show Again"));

View File

@@ -87,7 +87,7 @@ ShellCommand *IVersionControl::createInitialCheckoutCommand(const QString &url,
Q_UNUSED(baseDirectory); Q_UNUSED(baseDirectory);
Q_UNUSED(localName); Q_UNUSED(localName);
Q_UNUSED(extraArgs); Q_UNUSED(extraArgs);
return 0; return nullptr;
} }
QString IVersionControl::vcsTopic(const QString &topLevel) QString IVersionControl::vcsTopic(const QString &topLevel)
@@ -106,9 +106,7 @@ IVersionControl::OpenSupportMode IVersionControl::openSupportMode(const QString
return NoOpen; return NoOpen;
} }
IVersionControl::TopicCache::~TopicCache() IVersionControl::TopicCache::~TopicCache() = default;
{
}
/*! /*!
Returns the topic for repository under \a topLevel. 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); QFileInfo fi(workingDirectory + QLatin1Char('/') + fileName);
QString dir = fi.absolutePath(); QString dir = fi.absolutePath();
if (!managesDirectory(dir, 0)) if (!managesDirectory(dir, nullptr))
return false; return false;
QString file = fi.absoluteFilePath(); QString file = fi.absoluteFilePath();
return m_managedFiles.contains(file); return m_managedFiles.contains(file);

View File

@@ -241,7 +241,7 @@ class CORE_EXPORT TestVersionControl : public IVersionControl
Q_OBJECT Q_OBJECT
public: public:
TestVersionControl(Id id, const QString &name) : 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; ~TestVersionControl() override;
@@ -273,8 +273,8 @@ private:
QString m_displayName; QString m_displayName;
QHash<QString, QString> m_managedDirs; QHash<QString, QString> m_managedDirs;
QSet<QString> m_managedFiles; QSet<QString> m_managedFiles;
mutable int m_dirCount; mutable int m_dirCount = 0;
mutable int m_fileCount; mutable int m_fileCount = 0;
}; };
} // namespace Core } // namespace Core

View File

@@ -151,7 +151,7 @@ namespace {
static QList<IFeatureProvider *> s_providerList; static QList<IFeatureProvider *> s_providerList;
QList<IWizardFactory *> s_allFactories; QList<IWizardFactory *> s_allFactories;
QList<IWizardFactory::FactoryCreator> s_factoryCreators; QList<IWizardFactory::FactoryCreator> s_factoryCreators;
QAction *s_inspectWizardAction = 0; QAction *s_inspectWizardAction = nullptr;
bool s_areFactoriesLoaded = false; bool s_areFactoriesLoaded = false;
bool s_isWizardRunning = false; bool s_isWizardRunning = false;
QWidget *s_currentWizard = nullptr; 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) 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; s_isWizardRunning = true;
ICore::updateNewItemDialogState(); ICore::updateNewItemDialogState();

View File

@@ -92,7 +92,7 @@ public:
virtual bool isAvailable(Id platformId) const; virtual bool isAvailable(Id platformId) const;
QSet<Id> supportedPlatforms() const; QSet<Id> supportedPlatforms() const;
typedef std::function<QList<IWizardFactory *>()> FactoryCreator; using FactoryCreator = std::function<QList<IWizardFactory *>()>;
static void registerFactoryCreator(const FactoryCreator &creator); static void registerFactoryCreator(const FactoryCreator &creator);
// Utility to find all registered wizards // Utility to find all registered wizards

View File

@@ -101,7 +101,7 @@ JsExpander::JsExpander()
JsExpander::~JsExpander() JsExpander::~JsExpander()
{ {
delete d; delete d;
d = 0; d = nullptr;
} }
} // namespace Core } // namespace Core

View File

@@ -67,8 +67,7 @@ public:
} // Internal } // Internal
} // Core } // Core
BaseFileFilter::Iterator::~Iterator() BaseFileFilter::Iterator::~Iterator() = default;
{}
BaseFileFilter::BaseFileFilter() BaseFileFilter::BaseFileFilter()
: d(new Internal::BaseFileFilterPrivate) : d(new Internal::BaseFileFilterPrivate)

View File

@@ -212,7 +212,7 @@ void DirectoryFilter::refresh(QFutureInterface<void> &future)
if (future.isProgressUpdateNeeded() if (future.isProgressUpdateNeeded()
|| future.progressValue() == 0 /*workaround for regression in Qt*/) { || future.progressValue() == 0 /*workaround for regression in Qt*/) {
future.setProgressValueAndText(subDirIterator.currentProgress(), 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()));
} }
} }

View File

@@ -85,7 +85,7 @@ void ExecuteFilter::accept(LocatorFilterEntry selection,
Q_UNUSED(newText) Q_UNUSED(newText)
Q_UNUSED(selectionStart) Q_UNUSED(selectionStart)
Q_UNUSED(selectionLength) Q_UNUSED(selectionLength)
ExecuteFilter *p = const_cast<ExecuteFilter *>(this); auto p = const_cast<ExecuteFilter *>(this);
const QString value = selection.displayName.trimmed(); const QString value = selection.displayName.trimmed();
const int index = m_commandHistory.indexOf(value); const int index = m_commandHistory.indexOf(value);

View File

@@ -167,8 +167,8 @@ bool ILocatorFilter::openConfigDialog(QWidget *parent, bool &needsRefresh)
QDialog dialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint); QDialog dialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint);
dialog.setWindowTitle(msgConfigureDialogTitle()); dialog.setWindowTitle(msgConfigureDialogTitle());
QVBoxLayout *vlayout = new QVBoxLayout(&dialog); auto vlayout = new QVBoxLayout(&dialog);
QHBoxLayout *hlayout = new QHBoxLayout; auto hlayout = new QHBoxLayout;
QLineEdit *shortcutEdit = new QLineEdit(shortcutString()); QLineEdit *shortcutEdit = new QLineEdit(shortcutString());
QCheckBox *includeByDefault = new QCheckBox(msgIncludeByDefault()); QCheckBox *includeByDefault = new QCheckBox(msgIncludeByDefault());
includeByDefault->setToolTip(msgIncludeByDefaultToolTip()); includeByDefault->setToolTip(msgIncludeByDefaultToolTip());

View File

@@ -43,9 +43,9 @@ class JavaScriptFilter : public Core::ILocatorFilter
Q_OBJECT Q_OBJECT
public: public:
JavaScriptFilter(); 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, QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future,
const QString &entry) override; const QString &entry) override;
void accept(Core::LocatorFilterEntry selection, QString *newText, void accept(Core::LocatorFilterEntry selection, QString *newText,

View File

@@ -196,7 +196,7 @@ void Locator::updateFilterActions()
continue; continue;
Id filterId = filter->id(); Id filterId = filter->id();
Id actionId = filter->actionId(); Id actionId = filter->actionId();
QAction *action = 0; QAction *action = nullptr;
if (!actionCopy.contains(filterId)) { if (!actionCopy.contains(filterId)) {
// register new action // register new action
action = new QAction(filter->displayName(), this); action = new QAction(filter->displayName(), this);

View File

@@ -55,7 +55,7 @@ public:
class ReferenceData class ReferenceData
{ {
public: public:
ReferenceData() {} ReferenceData() = default;
ReferenceData(const QString &searchText, const ResultDataList &results) ReferenceData(const QString &searchText, const ResultDataList &results)
: searchText(searchText), results(results) {} : searchText(searchText), results(results) {}

View File

@@ -41,9 +41,7 @@ BasicLocatorFilterTest::BasicLocatorFilterTest(ILocatorFilter *filter) : m_filte
{ {
} }
BasicLocatorFilterTest::~BasicLocatorFilterTest() BasicLocatorFilterTest::~BasicLocatorFilterTest() = default;
{
}
QList<LocatorFilterEntry> BasicLocatorFilterTest::matchesFor(const QString &searchText) QList<LocatorFilterEntry> BasicLocatorFilterTest::matchesFor(const QString &searchText)
{ {
@@ -57,9 +55,7 @@ QList<LocatorFilterEntry> BasicLocatorFilterTest::matchesFor(const QString &sear
return locatorSearch.results(); return locatorSearch.results();
} }
ResultData::ResultData() ResultData::ResultData() = default;
{
}
ResultData::ResultData(const QString &textColumn1, const QString &textColumn2) ResultData::ResultData(const QString &textColumn1, const QString &textColumn2)
: textColumn1(textColumn1), textColumn2(textColumn2) : textColumn1(textColumn1), textColumn2(textColumn2)

View File

@@ -51,7 +51,7 @@ private:
class CORE_EXPORT ResultData class CORE_EXPORT ResultData
{ {
public: public:
typedef QList<ResultData> ResultDataList; using ResultDataList = QList<ResultData>;
ResultData(); ResultData();
ResultData(const QString &textColumn1, const QString &textColumn2); ResultData(const QString &textColumn1, const QString &textColumn2);
@@ -67,7 +67,7 @@ public:
QString textColumn2; QString textColumn2;
}; };
typedef ResultData::ResultDataList ResultDataList; using ResultDataList = ResultData::ResultDataList;
} // namespace Tests } // namespace Tests
} // namespace Core } // namespace Core

View File

@@ -161,7 +161,7 @@ QVariant CategoryItem::data(int column, int role) const
} }
LocatorSettingsPage::LocatorSettingsPage(Locator *plugin) LocatorSettingsPage::LocatorSettingsPage(Locator *plugin)
: m_plugin(plugin), m_widget(0) : m_plugin(plugin), m_widget(nullptr)
{ {
setId(Constants::FILTER_OPTIONS_PAGE); setId(Constants::FILTER_OPTIONS_PAGE);
setDisplayName(QCoreApplication::translate("Locator", Constants::FILTER_OPTIONS_PAGE)); setDisplayName(QCoreApplication::translate("Locator", Constants::FILTER_OPTIONS_PAGE));

Some files were not shown because too many files have changed in this diff Show More