From 04bfb17f3c4e2cca1fe1fd934923db2de976d244 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 28 Jun 2020 06:14:32 -0400 Subject: [PATCH] CVirtualDirectoryModel: Make use of in-class initializers where applicable --- .../CVirtualDirectoryModel.cpp | 7 +--- .../ResourceBrowser/CVirtualDirectoryModel.h | 36 +++++++++---------- 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/src/Editor/ResourceBrowser/CVirtualDirectoryModel.cpp b/src/Editor/ResourceBrowser/CVirtualDirectoryModel.cpp index b5251fb7..ad452aa6 100644 --- a/src/Editor/ResourceBrowser/CVirtualDirectoryModel.cpp +++ b/src/Editor/ResourceBrowser/CVirtualDirectoryModel.cpp @@ -2,13 +2,8 @@ #include "CResourceBrowser.h" #include "CResourceMimeData.h" -CVirtualDirectoryModel::CVirtualDirectoryModel(CResourceBrowser *pBrowser, QObject *pParent /*= 0*/) +CVirtualDirectoryModel::CVirtualDirectoryModel(CResourceBrowser *pBrowser, QObject *pParent) : QAbstractItemModel(pParent) - , mpRoot(nullptr) - , mInsertingRows(false) - , mRemovingRows(false) - , mMovingRows(false) - , mChangingLayout(false) { connect(pBrowser, SIGNAL(DirectoryAboutToBeMoved(CVirtualDirectory*,QString)), this, SLOT(OnDirectoryAboutToBeMoved(CVirtualDirectory*,QString))); connect(pBrowser, SIGNAL(DirectoryMoved(CVirtualDirectory*,CVirtualDirectory*,TString)), this, SLOT(FinishModelChanges())); diff --git a/src/Editor/ResourceBrowser/CVirtualDirectoryModel.h b/src/Editor/ResourceBrowser/CVirtualDirectoryModel.h index e02b2ea7..4fd04b23 100644 --- a/src/Editor/ResourceBrowser/CVirtualDirectoryModel.h +++ b/src/Editor/ResourceBrowser/CVirtualDirectoryModel.h @@ -9,28 +9,28 @@ class CVirtualDirectoryModel : public QAbstractItemModel { Q_OBJECT - CVirtualDirectory *mpRoot; - bool mInsertingRows; - bool mRemovingRows; - bool mMovingRows; - bool mChangingLayout; + CVirtualDirectory *mpRoot = nullptr; + bool mInsertingRows = false; + bool mRemovingRows = false; + bool mMovingRows = false; + bool mChangingLayout = false; public: - CVirtualDirectoryModel(CResourceBrowser *pBrowser, QObject *pParent = 0); + explicit CVirtualDirectoryModel(CResourceBrowser *pBrowser, QObject *pParent = nullptr); - QModelIndex index(int Row, int Column, const QModelIndex& rkParent) const; - QModelIndex parent(const QModelIndex& rkChild) const; - int rowCount(const QModelIndex& rkParent) const; - int columnCount(const QModelIndex& /*rkParent*/) const; - QVariant data(const QModelIndex& rkIndex, int Role) const; - bool setData(const QModelIndex& rkIndex, const QVariant& rkValue, int Role); - Qt::ItemFlags flags(const QModelIndex& rkIndex) const; + QModelIndex index(int Row, int Column, const QModelIndex& rkParent) const override; + QModelIndex parent(const QModelIndex& rkChild) const override; + int rowCount(const QModelIndex& rkParent) const override; + int columnCount(const QModelIndex& /*rkParent*/) const override; + QVariant data(const QModelIndex& rkIndex, int Role) const override; + bool setData(const QModelIndex& rkIndex, const QVariant& rkValue, int Role) override; + Qt::ItemFlags flags(const QModelIndex& rkIndex) const override; - bool canDropMimeData(const QMimeData *pkData, Qt::DropAction Action, int Row, int Column, const QModelIndex& rkParent) const; - bool dropMimeData(const QMimeData *pkData, Qt::DropAction Action, int Row, int Column, const QModelIndex& rkParent); - QMimeData* mimeData(const QModelIndexList& rkIndexes) const; - Qt::DropActions supportedDragActions() const; - Qt::DropActions supportedDropActions() const; + bool canDropMimeData(const QMimeData *pkData, Qt::DropAction Action, int Row, int Column, const QModelIndex& rkParent) const override; + bool dropMimeData(const QMimeData *pkData, Qt::DropAction Action, int Row, int Column, const QModelIndex& rkParent) override; + QMimeData* mimeData(const QModelIndexList& rkIndexes) const override; + Qt::DropActions supportedDragActions() const override; + Qt::DropActions supportedDropActions() const override; QModelIndex GetIndexForDirectory(CVirtualDirectory *pDir); CVirtualDirectory* IndexDirectory(const QModelIndex& rkIndex) const;