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