forked from qt-creator/qt-creator
ClassView: Modernize
modernize-use-nullptr modernize-use-auto modernize-use-override modernize-use-equals-default modernize-use-using modernize-loop-convert Change-Id: I7dcc03ad38f6f943bc4c8b1049e7069f4b99c985 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -52,7 +52,7 @@ namespace Internal {
|
||||
///////////////////////////////// ManagerPrivate //////////////////////////////////
|
||||
|
||||
// static variable initialization
|
||||
static Manager *managerInstance = 0;
|
||||
static Manager *managerInstance = nullptr;
|
||||
|
||||
/*!
|
||||
\class ClassView::Internal::Manager
|
||||
@@ -141,8 +141,6 @@ static Manager *managerInstance = 0;
|
||||
class ManagerPrivate
|
||||
{
|
||||
public:
|
||||
ManagerPrivate() : state(false), disableCodeParser(false) {}
|
||||
|
||||
//! State mutex
|
||||
QMutex mutexState;
|
||||
|
||||
@@ -153,10 +151,10 @@ public:
|
||||
QThread parserThread;
|
||||
|
||||
//! Internal manager state. \sa Manager::state
|
||||
bool state;
|
||||
bool state = false;
|
||||
|
||||
//! there is some massive operation ongoing so temporary we should wait
|
||||
bool disableCodeParser;
|
||||
bool disableCodeParser = false;
|
||||
};
|
||||
|
||||
///////////////////////////////// Manager //////////////////////////////////
|
||||
@@ -185,7 +183,7 @@ Manager::~Manager()
|
||||
d->parserThread.quit();
|
||||
d->parserThread.wait();
|
||||
delete d;
|
||||
managerInstance = 0;
|
||||
managerInstance = nullptr;
|
||||
}
|
||||
|
||||
Manager *Manager::instance()
|
||||
|
||||
@@ -42,9 +42,9 @@ class Manager : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Manager(QObject *parent = 0);
|
||||
explicit Manager(QObject *parent = nullptr);
|
||||
|
||||
virtual ~Manager();
|
||||
~Manager() override;
|
||||
|
||||
//! Get an instance of Manager
|
||||
static Manager *instance();
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace Internal {
|
||||
NavigationWidget::NavigationWidget(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
QVBoxLayout *verticalLayout = new QVBoxLayout(this);
|
||||
auto verticalLayout = new QVBoxLayout(this);
|
||||
verticalLayout->setSpacing(0);
|
||||
verticalLayout->setContentsMargins(0, 0, 0, 0);
|
||||
treeView = new ::Utils::NavigationTreeView(this);
|
||||
@@ -136,9 +136,7 @@ NavigationWidget::NavigationWidget(QWidget *parent) :
|
||||
manager, &Manager::onRequestTreeDataUpdate);
|
||||
}
|
||||
|
||||
NavigationWidget::~NavigationWidget()
|
||||
{
|
||||
}
|
||||
NavigationWidget::~NavigationWidget() = default;
|
||||
|
||||
void NavigationWidget::hideEvent(QHideEvent *event)
|
||||
{
|
||||
|
||||
@@ -46,8 +46,8 @@ class NavigationWidget : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit NavigationWidget(QWidget *parent = 0);
|
||||
~NavigationWidget();
|
||||
explicit NavigationWidget(QWidget *parent = nullptr);
|
||||
~NavigationWidget() override;
|
||||
|
||||
QList<QToolButton *> createToolButtons();
|
||||
|
||||
@@ -76,10 +76,10 @@ protected:
|
||||
void fetchExpandedItems(QStandardItem *item, const QStandardItem *target) const;
|
||||
|
||||
//! implements QWidget::hideEvent
|
||||
void hideEvent(QHideEvent *event);
|
||||
void hideEvent(QHideEvent *event) override;
|
||||
|
||||
//! implements QWidget::showEvent
|
||||
void showEvent(QShowEvent *event);
|
||||
void showEvent(QShowEvent *event) override;
|
||||
|
||||
private:
|
||||
Utils::NavigationTreeView *treeView;
|
||||
|
||||
@@ -58,7 +58,7 @@ NavigationWidgetFactory::NavigationWidgetFactory()
|
||||
Core::NavigationView NavigationWidgetFactory::createWidget()
|
||||
{
|
||||
Core::NavigationView navigationView;
|
||||
NavigationWidget *widget = new NavigationWidget();
|
||||
auto widget = new NavigationWidget();
|
||||
navigationView.widget = widget;
|
||||
navigationView.dockToolBarWidgets = widget->createToolButtons();
|
||||
return navigationView;
|
||||
@@ -77,7 +77,7 @@ static QString settingsPrefix(int position)
|
||||
|
||||
void NavigationWidgetFactory::saveSettings(QSettings *settings, int position, QWidget *widget)
|
||||
{
|
||||
NavigationWidget *pw = qobject_cast<NavigationWidget *>(widget);
|
||||
auto pw = qobject_cast<NavigationWidget *>(widget);
|
||||
QTC_ASSERT(pw, return);
|
||||
|
||||
// .beginGroup is not used - to prevent simultaneous access
|
||||
@@ -87,7 +87,7 @@ void NavigationWidgetFactory::saveSettings(QSettings *settings, int position, QW
|
||||
|
||||
void NavigationWidgetFactory::restoreSettings(QSettings *settings, int position, QWidget *widget)
|
||||
{
|
||||
NavigationWidget *pw = qobject_cast<NavigationWidget *>(widget);
|
||||
auto pw = qobject_cast<NavigationWidget *>(widget);
|
||||
QTC_ASSERT(pw, return);
|
||||
|
||||
// .beginGroup is not used - to prevent simultaneous access
|
||||
|
||||
@@ -92,10 +92,7 @@ namespace Internal {
|
||||
class ParserPrivate
|
||||
{
|
||||
public:
|
||||
typedef QHash<QString, CPlusPlus::Document::Ptr>::const_iterator CitDocumentList;
|
||||
|
||||
//! Constructor
|
||||
ParserPrivate() : flatMode(false) {}
|
||||
using CitDocumentList = QHash<QString, CPlusPlus::Document::Ptr>::const_iterator;
|
||||
|
||||
//! Get document from documentList
|
||||
CPlusPlus::Document::Ptr document(const QString &fileName) const;
|
||||
@@ -142,7 +139,7 @@ public:
|
||||
ParserTreeItem::ConstPtr rootItem;
|
||||
|
||||
//! Flat mode
|
||||
bool flatMode;
|
||||
bool flatMode = false;
|
||||
};
|
||||
|
||||
CPlusPlus::Document::Ptr ParserPrivate::document(const QString &fileName) const
|
||||
|
||||
@@ -50,8 +50,8 @@ class Parser : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Parser(QObject *parent = 0);
|
||||
~Parser();
|
||||
explicit Parser(QObject *parent = nullptr);
|
||||
~Parser() override;
|
||||
|
||||
bool canFetchMore(QStandardItem *item, bool skipRoot = false) const;
|
||||
|
||||
@@ -86,8 +86,8 @@ public:
|
||||
void setFlatMode(bool flat);
|
||||
|
||||
protected:
|
||||
typedef QHash<QString, unsigned>::const_iterator CitCachedDocTreeRevision;
|
||||
typedef QHash<QString, QStringList>::const_iterator CitCachedPrjFileLists;
|
||||
using CitCachedDocTreeRevision = QHash<QString, unsigned>::const_iterator;
|
||||
using CitCachedPrjFileLists = QHash<QString, QStringList>::const_iterator;
|
||||
|
||||
void onResetDataDone();
|
||||
|
||||
|
||||
@@ -295,7 +295,7 @@ void ParserTreeItem::convertTo(QStandardItem *item) const
|
||||
++curHash;
|
||||
}
|
||||
|
||||
typedef QMap<SymbolInformation, ParserTreeItem::Ptr>::const_iterator MapCitSymbolInformations;
|
||||
using MapCitSymbolInformations = QMap<SymbolInformation, ParserTreeItem::Ptr>::const_iterator;
|
||||
// add to item
|
||||
MapCitSymbolInformations cur = map.constBegin();
|
||||
MapCitSymbolInformations end = map.constEnd();
|
||||
@@ -303,7 +303,7 @@ void ParserTreeItem::convertTo(QStandardItem *item) const
|
||||
const SymbolInformation &inf = cur.key();
|
||||
ParserTreeItem::Ptr ptr = cur.value();
|
||||
|
||||
QStandardItem *add = new QStandardItem();
|
||||
auto add = new QStandardItem;
|
||||
Utils::setSymbolInformationToItem(inf, add);
|
||||
if (!ptr.isNull()) {
|
||||
// icon
|
||||
|
||||
@@ -41,8 +41,8 @@ class ParserTreeItemPrivate;
|
||||
class ParserTreeItem
|
||||
{
|
||||
public:
|
||||
typedef QSharedPointer<ParserTreeItem> Ptr;
|
||||
typedef QSharedPointer<const ParserTreeItem> ConstPtr;
|
||||
using Ptr = QSharedPointer<ParserTreeItem>;
|
||||
using ConstPtr = QSharedPointer<const ParserTreeItem>;
|
||||
|
||||
public:
|
||||
ParserTreeItem();
|
||||
@@ -91,7 +91,7 @@ protected:
|
||||
ParserTreeItem &operator=(const ParserTreeItem &other);
|
||||
|
||||
private:
|
||||
typedef QHash<SymbolInformation, ParserTreeItem::Ptr>::const_iterator CitSymbolInformations;
|
||||
using CitSymbolInformations = QHash<SymbolInformation, ParserTreeItem::Ptr>::const_iterator;
|
||||
//! Private class data pointer
|
||||
ParserTreeItemPrivate *d;
|
||||
};
|
||||
|
||||
@@ -46,9 +46,7 @@ TreeItemModel::TreeItemModel(QObject *parent)
|
||||
{
|
||||
}
|
||||
|
||||
TreeItemModel::~TreeItemModel()
|
||||
{
|
||||
}
|
||||
TreeItemModel::~TreeItemModel() = default;
|
||||
|
||||
QVariant TreeItemModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
@@ -136,7 +134,7 @@ QMimeData *TreeItemModel::mimeData(const QModelIndexList &indexes) const
|
||||
}
|
||||
if (mimeData->files().isEmpty()) {
|
||||
delete mimeData;
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
return mimeData;
|
||||
}
|
||||
|
||||
@@ -37,19 +37,19 @@ class TreeItemModel : public QStandardItemModel
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TreeItemModel(QObject *parent = 0);
|
||||
virtual ~TreeItemModel();
|
||||
explicit TreeItemModel(QObject *parent = nullptr);
|
||||
~TreeItemModel() override;
|
||||
|
||||
void moveRootToTarget(const QStandardItem *target);
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||
bool canFetchMore(const QModelIndex &parent) const;
|
||||
void fetchMore(const QModelIndex &parent);
|
||||
bool hasChildren(const QModelIndex &parent = QModelIndex()) const;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
bool canFetchMore(const QModelIndex &parent) const override;
|
||||
void fetchMore(const QModelIndex &parent) override;
|
||||
bool hasChildren(const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
||||
Qt::DropActions supportedDragActions() const;
|
||||
QStringList mimeTypes() const;
|
||||
QMimeData *mimeData(const QModelIndexList &indexes) const;
|
||||
Qt::DropActions supportedDragActions() const override;
|
||||
QStringList mimeTypes() const override;
|
||||
QMimeData *mimeData(const QModelIndexList &indexes) const override;
|
||||
|
||||
private:
|
||||
//! private class data pointer
|
||||
|
||||
@@ -72,9 +72,7 @@ const int IconSortOrder[] = {
|
||||
|
||||
namespace Internal {
|
||||
|
||||
Utils::Utils()
|
||||
{
|
||||
}
|
||||
Utils::Utils() = default;
|
||||
|
||||
/*!
|
||||
Converts internal location container to QVariant compatible.
|
||||
@@ -120,9 +118,8 @@ int Utils::iconTypeSortOrder(int icon)
|
||||
|
||||
// initialization
|
||||
if (sortOrder.isEmpty()) {
|
||||
for (unsigned i = 0 ;
|
||||
i < sizeof(Constants::IconSortOrder) / sizeof(Constants::IconSortOrder[0]) ; ++i)
|
||||
sortOrder.insert(Constants::IconSortOrder[i], sortOrder.count());
|
||||
for (int i : Constants::IconSortOrder)
|
||||
sortOrder.insert(i, sortOrder.count());
|
||||
}
|
||||
|
||||
// if it is missing - return the same value
|
||||
|
||||
Reference in New Issue
Block a user