KDDockWidgets API Documentation 2.1
Loading...
Searching...
No Matches
qtcommon/View.cpp
Go to the documentation of this file.
1/*
2 This file is part of KDDockWidgets.
3
4 SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
5 Author: SĂ©rgio Martins <sergio.martins@kdab.com>
6
7 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
8
9 Contact KDAB at <info@kdab.com> for commercial licensing options.
10*/
11
12#include "View.h"
13#include "core/Utils_p.h"
14#include "core/View_p.h"
15#include "kddockwidgets/core/Controller.h"
17
18#ifdef KDDW_FRONTEND_QTWIDGETS
19#include <QWidget>
20#endif
21
22#ifdef KDDW_FRONTEND_QTQUICK
23#include <QQuickItem>
24#endif
25
26using namespace KDDockWidgets::QtCommon;
27
28// clazy:excludeall=missing-qobject-macro
29
30
31#if defined(DOCKS_DEVELOPER_MODE)
32int View_qt::s_logicalDpiFactorOverride = 0;
33#endif
34
35class View_qt::EventFilter : public QObject
36{
37public:
38 explicit EventFilter(View_qt *view, QObject *target)
39 : q(view)
40 {
41 target->installEventFilter(this);
42 }
43
44 ~EventFilter() override;
45
46 bool eventFilter(QObject *, QEvent *ev) override
47 {
48 return q->deliverViewEventToFilters(ev);
49 }
50
51 View_qt *const q;
52};
53
55 : View(controller, type)
56 , m_eventFilter(thisObj ? new EventFilter(this, thisObj) : nullptr)
57 , m_thisObj(thisObj)
58{
59}
60
62{
63 delete m_eventFilter;
64}
65
66View_qt::EventFilter::~EventFilter() = default;
67
69{
70 return m_thisObj;
71}
72
77
79{
80 if (m_thisObj) {
82 }
83}
84
85/*static*/
87{
88 if (auto viewqt = dynamic_cast<View_qt *>(view))
89 return viewqt->thisObject();
90
91 return nullptr;
92}
93
94#ifdef KDDW_FRONTEND_QTWIDGETS
95
96/*static */
97QWidget *View_qt::asQWidget(View *view)
98{
99 return qobject_cast<QWidget *>(asQObject(view));
100}
101
102/*static */
103QWidget *View_qt::asQWidget(Core::Controller *controller)
104{
105 if (!controller)
106 return nullptr;
107
108 return asQWidget(controller->view());
109}
110
111#endif
112
113#ifdef KDDW_FRONTEND_QTQUICK
114
115/*static */
116QQuickItem *View_qt::asQQuickItem(View *view)
117{
118 return qobject_cast<QQuickItem *>(asQObject(view));
119}
120
121#endif
View * view() const
Returns the view associated with this controller, if any.
Controller * controller() const
Returns this view's controller.
void setViewName(const QString &name) override
Equivalent to Qt's QObject::objectName()
Core::HANDLE handle() const override
Returns a handle for the GUI element This value only makes sense to the frontend. For example,...
View_qt(Core::Controller *controller, Core::ViewType type, QObject *thisObj)
static QObject * asQObject(View *)
ViewType
Each View type also has a specific Controller associated with, except for ViewType::None.
Definition Controller.h:26
const void * HANDLE
Definition core/View.h:28
virtual bool eventFilter(QObject *watched, QEvent *event)
void installEventFilter(QObject *filterObj)
void setObjectName(const QString &name)

© Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
KDDockWidgets
Advanced Dock Widget Framework for Qt
https://www.kdab.com/development-resources/qt-tools/kddockwidgets/
Generated by doxygen 1.9.8