From 61ed4163fb1eca37ee602d7696ca3a08f08a745c Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 28 Jun 2020 05:17:16 -0400 Subject: [PATCH] CResourceSelector: Make use of in-class initializers where applicable --- src/Editor/Widgets/CResourceSelector.cpp | 5 +---- src/Editor/Widgets/CResourceSelector.h | 27 ++++++++++++------------ 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/Editor/Widgets/CResourceSelector.cpp b/src/Editor/Widgets/CResourceSelector.cpp index e54a6b45..42dd5f13 100644 --- a/src/Editor/Widgets/CResourceSelector.cpp +++ b/src/Editor/Widgets/CResourceSelector.cpp @@ -16,11 +16,8 @@ #include #include -CResourceSelector::CResourceSelector(QWidget *pParent /*= 0*/) +CResourceSelector::CResourceSelector(QWidget *pParent) : QWidget(pParent) - , mpResEntry(nullptr) - , mIsEditable(true) - , mIsDragging(false) { setAcceptDrops(true); setContextMenuPolicy(Qt::CustomContextMenu); diff --git a/src/Editor/Widgets/CResourceSelector.h b/src/Editor/Widgets/CResourceSelector.h index a1214171..341d1e55 100644 --- a/src/Editor/Widgets/CResourceSelector.h +++ b/src/Editor/Widgets/CResourceSelector.h @@ -12,9 +12,9 @@ class CResourceSelector : public QWidget { Q_OBJECT - CResourceEntry *mpResEntry; + CResourceEntry *mpResEntry = nullptr; CResTypeFilter mTypeFilter; - bool mIsEditable; + bool mIsEditable = true; // UI QVBoxLayout *mpLayout; @@ -30,11 +30,12 @@ class CResourceSelector : public QWidget QAction *mpCopyPathAction; // Drag and Drop - bool mIsDragging; + bool mIsDragging = false; QPoint mDragStartPosition; public: - explicit CResourceSelector(QWidget *pParent = 0); + explicit CResourceSelector(QWidget *pParent = nullptr); + void SetFrameVisible(bool Visible); void SetEditable(bool Editable); void SetTypeFilter(const CResTypeFilter& rkFilter); @@ -44,21 +45,21 @@ public: void SetResource(CResource *pRes); // Interface - bool eventFilter(QObject *pWatched, QEvent *pEvent); + bool eventFilter(QObject *pWatched, QEvent *pEvent) override; // Drag - void mousePressEvent(QMouseEvent *pEvent); - void mouseMoveEvent(QMouseEvent *pEvent); - void mouseReleaseEvent(QMouseEvent *pEvent); + void mousePressEvent(QMouseEvent *pEvent) override; + void mouseMoveEvent(QMouseEvent *pEvent) override; + void mouseReleaseEvent(QMouseEvent *pEvent) override; // Drop - void dragEnterEvent(QDragEnterEvent *pEvent); - void dropEvent(QDropEvent *pEvent); + void dragEnterEvent(QDragEnterEvent *pEvent) override; + void dropEvent(QDropEvent *pEvent) override; // Accessors - inline CResourceEntry* Entry() const { return mpResEntry; } - inline const CResTypeFilter& TypeFilter() const { return mTypeFilter; } - inline bool IsEditable() const { return mIsEditable; } + CResourceEntry* Entry() const { return mpResEntry; } + const CResTypeFilter& TypeFilter() const { return mTypeFilter; } + bool IsEditable() const { return mIsEditable; } public slots: void CreateContextMenu(const QPoint& rkPoint);