diff options
author | Alessandro Portale <alessandro.portale@qt.io> | 2018-07-19 23:19:33 +0200 |
---|---|---|
committer | Alessandro Portale <alessandro.portale@qt.io> | 2018-08-08 10:16:07 +0000 |
commit | e21b146776947ef5b2b64624e39b51b44da946df (patch) | |
tree | e0307bfa596f33465f240ba81f0729d763d73b82 /src/libs/extensionsystem | |
parent | 6655f3725919990ccb90c5bebae2476200d56a47 (diff) | |
download | qt-creator-e21b146776947ef5b2b64624e39b51b44da946df.tar.gz |
Extensionsystem: Modernize
modernize-use-auto
modernize-use-nullptr
modernize-use-override
modernize-use-equals-default
Change-Id: I20b4508e98ad3f8d6cd0ca2339bfc4c7dcb2ef2c
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Diffstat (limited to 'src/libs/extensionsystem')
-rw-r--r-- | src/libs/extensionsystem/invoker.cpp | 2 | ||||
-rw-r--r-- | src/libs/extensionsystem/optionsparser.cpp | 4 | ||||
-rw-r--r-- | src/libs/extensionsystem/pluginerroroverview.cpp | 2 | ||||
-rw-r--r-- | src/libs/extensionsystem/pluginmanager.cpp | 34 | ||||
-rw-r--r-- | src/libs/extensionsystem/pluginmanager_p.h | 14 | ||||
-rw-r--r-- | src/libs/extensionsystem/pluginspec.cpp | 6 | ||||
-rw-r--r-- | src/libs/extensionsystem/pluginspec.h | 2 | ||||
-rw-r--r-- | src/libs/extensionsystem/pluginview.cpp | 28 |
8 files changed, 42 insertions, 50 deletions
diff --git a/src/libs/extensionsystem/invoker.cpp b/src/libs/extensionsystem/invoker.cpp index d4a19804a0..1506c4910a 100644 --- a/src/libs/extensionsystem/invoker.cpp +++ b/src/libs/extensionsystem/invoker.cpp @@ -34,7 +34,7 @@ InvokerBase::InvokerBase() nag = true; success = true; connectionType = Qt::AutoConnection; - target = 0; + target = nullptr; } InvokerBase::~InvokerBase() diff --git a/src/libs/extensionsystem/optionsparser.cpp b/src/libs/extensionsystem/optionsparser.cpp index 9dc6327b65..c3daed5daa 100644 --- a/src/libs/extensionsystem/optionsparser.cpp +++ b/src/libs/extensionsystem/optionsparser.cpp @@ -265,9 +265,9 @@ bool OptionsParser::checkForUnknownOption() void OptionsParser::forceDisableAllPluginsExceptTestedAndForceEnabled() { - for (const PluginManagerPrivate::TestSpec &testSpec : m_pmPrivate->testSpecs) + for (const PluginManagerPrivate::TestSpec &testSpec : qAsConst(m_pmPrivate->testSpecs)) testSpec.pluginSpec->d->setForceEnabled(true); - for (PluginSpec *spec : m_pmPrivate->pluginSpecs) { + for (PluginSpec *spec : qAsConst(m_pmPrivate->pluginSpecs)) { if (!spec->isForceEnabled() && !spec->isRequired()) spec->d->setForceDisabled(true); } diff --git a/src/libs/extensionsystem/pluginerroroverview.cpp b/src/libs/extensionsystem/pluginerroroverview.cpp index a5d82a1c62..828bd013f4 100644 --- a/src/libs/extensionsystem/pluginerroroverview.cpp +++ b/src/libs/extensionsystem/pluginerroroverview.cpp @@ -65,7 +65,7 @@ PluginErrorOverview::~PluginErrorOverview() void PluginErrorOverview::showDetails(QListWidgetItem *item) { if (item) { - PluginSpec *spec = item->data(Qt::UserRole).value<PluginSpec *>(); + auto *spec = item->data(Qt::UserRole).value<PluginSpec *>(); m_ui->pluginError->setText(spec->errorString()); } else { m_ui->pluginError->clear(); diff --git a/src/libs/extensionsystem/pluginmanager.cpp b/src/libs/extensionsystem/pluginmanager.cpp index d92a4ec67b..9edb0cdb62 100644 --- a/src/libs/extensionsystem/pluginmanager.cpp +++ b/src/libs/extensionsystem/pluginmanager.cpp @@ -256,8 +256,8 @@ namespace ExtensionSystem { using namespace Internal; -static Internal::PluginManagerPrivate *d = 0; -static PluginManager *m_instance = 0; +static Internal::PluginManagerPrivate *d = nullptr; +static PluginManager *m_instance = nullptr; /*! Gets the unique plugin manager instance. @@ -282,7 +282,7 @@ PluginManager::PluginManager() PluginManager::~PluginManager() { delete d; - d = 0; + d = nullptr; } /*! @@ -625,7 +625,7 @@ void PluginManager::remoteArguments(const QString &serializedArgument, QObject * arguments); if (socketParent && socket) { socket->setParent(socketParent); - socket = 0; + socket = nullptr; } } } @@ -829,7 +829,7 @@ void PluginManagerPrivate::nextDelayedInitialize() if (delayedInitializeQueue.isEmpty()) { m_isInitializationDone = true; delete delayedInitializeTimer; - delayedInitializeTimer = 0; + delayedInitializeTimer = nullptr; profilingSummary(); emit q->initializationDone(); #ifdef WITH_TESTS @@ -845,12 +845,6 @@ void PluginManagerPrivate::nextDelayedInitialize() \internal */ PluginManagerPrivate::PluginManagerPrivate(PluginManager *pluginManager) : - delayedInitializeTimer(0), - shutdownEventLoop(0), - m_profileElapsedMS(0), - m_profilingVerbosity(0), - settings(0), - globalSettings(0), q(pluginManager) { } @@ -907,7 +901,7 @@ void PluginManagerPrivate::stopAll() if (delayedInitializeTimer && delayedInitializeTimer->isActive()) { delayedInitializeTimer->stop(); delete delayedInitializeTimer; - delayedInitializeTimer = 0; + delayedInitializeTimer = nullptr; } QList<PluginSpec *> queue = loadQueue(); foreach (PluginSpec *spec, queue) { @@ -927,8 +921,8 @@ void PluginManagerPrivate::deleteAll() #ifdef WITH_TESTS -typedef QMap<QObject *, QStringList> TestPlan; // Object -> selected test functions -typedef QMapIterator<QObject *, QStringList> TestPlanIterator; +using TestPlan = QMap<QObject *, QStringList>; // Object -> selected test functions +using TestPlanIterator = QMapIterator<QObject *, QStringList>; static bool isTestFunction(const QMetaMethod &metaMethod) { @@ -999,7 +993,7 @@ static QStringList matchingTestFunctions(const QStringList &testFunctions, static QObject *objectWithClassName(const QList<QObject *> &objects, const QString &className) { - return Utils::findOr(objects, 0, [className] (QObject *object) -> bool { + return Utils::findOr(objects, nullptr, [className] (QObject *object) -> bool { QString candidate = QString::fromUtf8(object->metaObject()->className()); const int colonIndex = candidate.lastIndexOf(QLatin1Char(':')); if (colonIndex != -1 && colonIndex < candidate.size() - 1) @@ -1159,7 +1153,7 @@ void PluginManagerPrivate::addObject(QObject *obj) { { QWriteLocker lock(&m_lock); - if (obj == 0) { + if (obj == nullptr) { qWarning() << "PluginManagerPrivate::addObject(): trying to add null object"; return; } @@ -1188,7 +1182,7 @@ void PluginManagerPrivate::addObject(QObject *obj) */ void PluginManagerPrivate::removeObject(QObject *obj) { - if (obj == 0) { + if (obj == nullptr) { qWarning() << "PluginManagerPrivate::removeObject(): trying to remove null object"; return; } @@ -1265,7 +1259,7 @@ void PluginManagerPrivate::shutdown() */ void PluginManagerPrivate::asyncShutdownFinished() { - IPlugin *plugin = qobject_cast<IPlugin *>(sender()); + auto *plugin = qobject_cast<IPlugin *>(sender()); Q_ASSERT(plugin); asynchronousPlugins.removeAll(plugin->pluginSpec()); if (asynchronousPlugins.isEmpty()) @@ -1442,7 +1436,7 @@ void PluginManagerPrivate::readPluginPaths() pluginCategories.insert(QString(), QList<PluginSpec *>()); foreach (const QString &pluginFile, pluginFiles(pluginPaths)) { - PluginSpec *spec = new PluginSpec; + auto *spec = new PluginSpec; if (!spec->d->read(pluginFile)) { // not a Qt Creator plugin delete spec; continue; @@ -1505,7 +1499,7 @@ PluginSpec *PluginManagerPrivate::pluginForOption(const QString &option, bool *r return spec; } } - return 0; + return nullptr; } PluginSpec *PluginManagerPrivate::pluginByName(const QString &name) const diff --git a/src/libs/extensionsystem/pluginmanager_p.h b/src/libs/extensionsystem/pluginmanager_p.h index 6b7a2cc75b..b21a3f7ce4 100644 --- a/src/libs/extensionsystem/pluginmanager_p.h +++ b/src/libs/extensionsystem/pluginmanager_p.h @@ -55,7 +55,7 @@ class EXTENSIONSYSTEM_EXPORT PluginManagerPrivate : public QObject Q_OBJECT public: PluginManagerPrivate(PluginManager *pluginManager); - virtual ~PluginManagerPrivate(); + ~PluginManagerPrivate() override; // Object pool operations void addObject(QObject *obj); @@ -106,19 +106,19 @@ public: QStringList disabledPlugins; QStringList forceEnabledPlugins; // delayed initialization - QTimer *delayedInitializeTimer; + QTimer *delayedInitializeTimer = nullptr; QList<PluginSpec *> delayedInitializeQueue; // ansynchronous shutdown QList<PluginSpec *> asynchronousPlugins; // plugins that have requested async shutdown - QEventLoop *shutdownEventLoop; // used for async shutdown + QEventLoop *shutdownEventLoop = nullptr; // used for async shutdown QStringList arguments; QScopedPointer<QTime> m_profileTimer; QHash<const PluginSpec *, int> m_profileTotal; - int m_profileElapsedMS; - unsigned m_profilingVerbosity; - QSettings *settings; - QSettings *globalSettings; + int m_profileElapsedMS = 0; + unsigned m_profilingVerbosity = 0; + QSettings *settings = nullptr; + QSettings *globalSettings = nullptr; // Look in argument descriptions of the specs for the option. PluginSpec *pluginForOption(const QString &option, bool *requiresArgument) const; diff --git a/src/libs/extensionsystem/pluginspec.cpp b/src/libs/extensionsystem/pluginspec.cpp index b439c54f64..501ceba009 100644 --- a/src/libs/extensionsystem/pluginspec.cpp +++ b/src/libs/extensionsystem/pluginspec.cpp @@ -182,7 +182,7 @@ PluginSpec::PluginSpec() PluginSpec::~PluginSpec() { delete d; - d = 0; + d = nullptr; } /*! @@ -963,7 +963,7 @@ bool PluginSpecPrivate::loadLibrary() + QString::fromLatin1(": ") + loader.errorString(); return false; } - IPlugin *pluginObject = qobject_cast<IPlugin*>(loader.instance()); + auto *pluginObject = qobject_cast<IPlugin*>(loader.instance()); if (!pluginObject) { hasError = true; errorString = QCoreApplication::translate("PluginSpec", "Plugin is not valid (does not derive from IPlugin)"); @@ -1065,6 +1065,6 @@ void PluginSpecPrivate::kill() if (!plugin) return; delete plugin; - plugin = 0; + plugin = nullptr; state = PluginSpec::Deleted; } diff --git a/src/libs/extensionsystem/pluginspec.h b/src/libs/extensionsystem/pluginspec.h index 25c08cd412..e7c2987ebe 100644 --- a/src/libs/extensionsystem/pluginspec.h +++ b/src/libs/extensionsystem/pluginspec.h @@ -106,7 +106,7 @@ public: QVector<PluginDependency> dependencies() const; QJsonObject metaData() const; - typedef QVector<PluginArgumentDescription> PluginArgumentDescriptions; + using PluginArgumentDescriptions = QVector<PluginArgumentDescription>; PluginArgumentDescriptions argumentDescriptions() const; // other information, valid after 'Read' state is reached diff --git a/src/libs/extensionsystem/pluginview.cpp b/src/libs/extensionsystem/pluginview.cpp index af80a2747a..65b44307be 100644 --- a/src/libs/extensionsystem/pluginview.cpp +++ b/src/libs/extensionsystem/pluginview.cpp @@ -110,7 +110,7 @@ public: int columnCount() const { return 4; } - QVariant data(int column, int role) const + QVariant data(int column, int role) const override { if (role == HiddenByDefaultRole) return m_spec->isHiddenByDefault() || !m_spec->isAvailableForHostPlatform(); @@ -177,7 +177,7 @@ public: return QVariant(); } - bool setData(int column, const QVariant &data, int role) + bool setData(int column, const QVariant &data, int role) override { if (column == LoadedColumn && role == Qt::CheckStateRole) return m_view->setPluginsEnabled(QSet<PluginSpec *>() << m_spec, data.toBool()); @@ -189,7 +189,7 @@ public: return m_spec->isAvailableForHostPlatform() && !m_spec->isRequired(); } - Qt::ItemFlags flags(int column) const + Qt::ItemFlags flags(int column) const override { Qt::ItemFlags ret = Qt::ItemIsSelectable; @@ -221,7 +221,7 @@ public: int columnCount() const { return 4; } - QVariant data(int column, int role) const + QVariant data(int column, int role) const override { if (role == HiddenByDefaultRole) return false; @@ -260,7 +260,7 @@ public: return QVariant(); } - bool setData(int column, const QVariant &data, int role) + bool setData(int column, const QVariant &data, int role) override { if (column == LoadedColumn && role == Qt::CheckStateRole) { const QList<PluginSpec *> affectedPlugins = @@ -273,7 +273,7 @@ public: return false; } - Qt::ItemFlags flags(int column) const + Qt::ItemFlags flags(int column) const override { Qt::ItemFlags ret = Qt::ItemIsSelectable | Qt::ItemIsEnabled; if (column == LoadedColumn) @@ -290,7 +290,7 @@ public: class PluginFilterModel : public CategorySortFilterModel { public: - PluginFilterModel(QObject *parent = 0) : CategorySortFilterModel(parent) {} + PluginFilterModel(QObject *parent = nullptr) : CategorySortFilterModel(parent) {} void setShowHidden(bool show) { @@ -355,7 +355,7 @@ PluginView::PluginView(QWidget *parent) m_sortModel->setFilterKeyColumn(-1/*all*/); m_categoryView->setModel(m_sortModel); - QGridLayout *gridLayout = new QGridLayout(this); + auto *gridLayout = new QGridLayout(this); gridLayout->setContentsMargins(2, 2, 2, 2); gridLayout->addWidget(m_categoryView, 1, 0, 1, 1); @@ -367,10 +367,10 @@ PluginView::PluginView(QWidget *parent) this, &PluginView::updatePlugins); connect(m_categoryView, &QAbstractItemView::activated, - [this](const QModelIndex &idx) { pluginActivated(pluginForIndex(idx)); }); + [this](const QModelIndex &idx) { emit pluginActivated(pluginForIndex(idx)); }); connect(m_categoryView->selectionModel(), &QItemSelectionModel::currentChanged, - [this](const QModelIndex &idx) { currentPluginChanged(pluginForIndex(idx)); }); + [this](const QModelIndex &idx) { emit currentPluginChanged(pluginForIndex(idx)); }); updatePlugins(); } @@ -378,9 +378,7 @@ PluginView::PluginView(QWidget *parent) /*! \internal */ -PluginView::~PluginView() -{ -} +PluginView::~PluginView() = default; /*! Returns the current selection in the list of plugins. @@ -411,7 +409,7 @@ PluginSpec *PluginView::pluginForIndex(const QModelIndex &index) const { const QModelIndex &sourceIndex = m_sortModel->mapToSource(index); PluginItem *item = m_model->itemForIndexAtLevel<2>(sourceIndex); - return item ? item->m_spec: 0; + return item ? item->m_spec: nullptr; } void PluginView::updatePlugins() @@ -432,7 +430,7 @@ void PluginView::updatePlugins() foreach (CollectionItem *collection, collections) m_model->rootItem()->appendChild(collection); - m_model->layoutChanged(); + emit m_model->layoutChanged(); m_categoryView->expandAll(); } |