From 84ce2eb41813a74f2c5dca423236b3410bcd332b Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Fri, 20 Nov 2020 20:52:12 +0800 Subject: [PATCH] Simplify the code a bit There is a type called QObjectList already. Signed-off-by: Yuhang Zhao <2546789017@qq.com> --- framelesshelper.cpp | 18 +++++++++--------- framelesshelper.h | 6 +++--- winnativeeventfilter.cpp | 2 +- winnativeeventfilter.h | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/framelesshelper.cpp b/framelesshelper.cpp index 8ea568d..39baf36 100644 --- a/framelesshelper.cpp +++ b/framelesshelper.cpp @@ -144,11 +144,11 @@ void FramelessHelper::addDraggableArea(const QWindow *window, const QRectF &val) m_draggableAreas[window] = areas; } -QList FramelessHelper::getIgnoreObjects(const QWindow *window) const +QObjectList FramelessHelper::getIgnoreObjects(const QWindow *window) const { Q_ASSERT(window); - QList ret{}; - const QList objs = m_ignoreObjects.value(window); + QObjectList ret{}; + const QObjectList objs = m_ignoreObjects.value(window); if (!objs.isEmpty()) { for (auto &&_obj : qAsConst(objs)) { if (_obj) { @@ -162,16 +162,16 @@ QList FramelessHelper::getIgnoreObjects(const QWindow *window) const void FramelessHelper::addIgnoreObject(const QWindow *window, QObject *val) { Q_ASSERT(window); - QList objs = m_ignoreObjects[window]; + QObjectList objs = m_ignoreObjects[window]; objs.append(val); m_ignoreObjects[window] = objs; } -QList FramelessHelper::getDraggableObjects(const QWindow *window) const +QObjectList FramelessHelper::getDraggableObjects(const QWindow *window) const { Q_ASSERT(window); - QList ret{}; - const QList objs = m_draggableObjects.value(window); + QObjectList ret{}; + const QObjectList objs = m_draggableObjects.value(window); if (!objs.isEmpty()) { for (auto &&_obj : qAsConst(objs)) { if (_obj) { @@ -185,7 +185,7 @@ QList FramelessHelper::getDraggableObjects(const QWindow *window) con void FramelessHelper::addDraggableObject(const QWindow *window, QObject *val) { Q_ASSERT(window); - QList objs = m_draggableObjects[window]; + QObjectList objs = m_draggableObjects[window]; objs.append(val); m_draggableObjects[window] = objs; } @@ -295,7 +295,7 @@ bool FramelessHelper::eventFilter(QObject *object, QEvent *event) return false; }; const auto isInSpecificObjects = [](const QPointF &mousePos, - const QList &objects) -> bool { + const QObjectList &objects) -> bool { if (objects.isEmpty()) { return false; } diff --git a/framelesshelper.h b/framelesshelper.h index 2d057be..8f2abf3 100644 --- a/framelesshelper.h +++ b/framelesshelper.h @@ -65,10 +65,10 @@ public: QList getDraggableAreas(const QWindow *window) const; void addIgnoreObject(const QWindow *window, QObject *val); - QList getIgnoreObjects(const QWindow *window) const; + QObjectList getIgnoreObjects(const QWindow *window) const; void addDraggableObject(const QWindow *window, QObject *val); - QList getDraggableObjects(const QWindow *window) const; + QObjectList getDraggableObjects(const QWindow *window) const; bool getResizable(const QWindow *window) const; void setResizable(const QWindow *window, const bool val); @@ -85,7 +85,7 @@ private: // platforms through native API. int m_borderWidth = 8, m_borderHeight = 8, m_titleBarHeight = 30; QHash> m_ignoreAreas = {}, m_draggableAreas = {}; - QHash> m_ignoreObjects = {}, m_draggableObjects = {}; + QHash m_ignoreObjects = {}, m_draggableObjects = {}; QHash m_fixedSize = {}, m_disableTitleBar = {}; }; #endif diff --git a/winnativeeventfilter.cpp b/winnativeeventfilter.cpp index f331fb5..72564a4 100644 --- a/winnativeeventfilter.cpp +++ b/winnativeeventfilter.cpp @@ -1742,7 +1742,7 @@ bool WinNativeEventFilter::nativeEventFilter(const QByteArray &eventType, return false; }; const auto isInSpecificObjects = - [](const QPointF &mousePos, const QList &objects, const qreal dpr) -> bool { + [](const QPointF &mousePos, const QObjectList &objects, const qreal dpr) -> bool { if (objects.isEmpty()) { return false; } diff --git a/winnativeeventfilter.h b/winnativeeventfilter.h index c280f66..e5176aa 100644 --- a/winnativeeventfilter.h +++ b/winnativeeventfilter.h @@ -28,11 +28,11 @@ #include #include #include +#include #include QT_BEGIN_NAMESPACE QT_FORWARD_DECLARE_CLASS(QWindow) -QT_FORWARD_DECLARE_CLASS(QObject) QT_END_NAMESPACE #if (QT_VERSION < QT_VERSION_CHECK(5, 13, 0)) @@ -58,7 +58,7 @@ public: framelessModeEnabled = false; int borderWidth = -1, borderHeight = -1, titleBarHeight = -1; QList ignoreAreas = {}, draggableAreas = {}; - QList ignoreObjects = {}, draggableObjects = {}; + QObjectList ignoreObjects = {}, draggableObjects = {}; QSize maximumSize = {}, minimumSize = {}; QString currentScreen = {}; };