KDDockWidgets API Documentation 2.0
Loading...
Searching...
No Matches
Controller.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 "Controller.h"
13#include "Controller_p.h"
14#include "Platform.h"
15#include "DelayedCall_p.h"
16#include "View.h"
17#include "View_p.h"
18#include "Logging_p.h"
19#include "DragController_p.h"
20
21using namespace KDDockWidgets;
22using namespace KDDockWidgets::Core;
23
25 : d(new Private(type, view))
26{
27}
28
30{
31 d->aboutToBeDeleted.emit();
32
33 m_inDtor = true;
34 if (d->m_view && !d->m_view->inDtor())
35 d->m_view->d->free();
36
37 delete d;
38}
39
41{
42 return d->m_type;
43}
44
46{
47 return int(d->m_type) & int(t);
48}
49
51{
52 return m_inDtor;
53}
54
56{
57 return d->m_view;
58}
59
61{
62 return d->m_view && d->m_view->isVisible();
63}
64
66{
67 if (d->m_view)
68 d->m_view->setVisible(is);
69}
70
71Rect Controller::rect() const
72{
73 if (d->m_view)
74 return d->m_view->rect();
75
76 return {};
77}
78
79Point Controller::mapToGlobal(Point localPt) const
80{
81 return d->m_view->mapToGlobal(localPt);
82}
83
85{
86 return d->m_view->height();
87}
88
90{
91 return d->m_view->width();
92}
93
94Size Controller::size() const
95{
96 return d->m_view->size();
97}
98
100{
101 return d->m_view->geometry();
102}
103
104Point Controller::pos() const
105{
106 return d->m_view->geometry().topLeft();
107}
108
109int Controller::x() const
110{
111 return d->m_view->x();
112}
113
114int Controller::y() const
115{
116 return d->m_view->y();
117}
118
120{
121 return view() && view()->close();
122}
123
124std::shared_ptr<View> Controller::window() const
125{
126 return view()->rootView();
127}
128
130{
131 view()->show();
132}
133
135{
136 setParentView_impl(parent);
137 d->parentViewChanged.emit(parent);
138}
139
141{
142 if (auto v = view()) {
143 v->setParent(parent);
144 } else {
145 KDDW_ERROR("No view()");
146 }
147}
148
150{
151 Platform::instance()->runDelayed(0, new DelayedDelete(this));
152}
153
154Controller::Private *Controller::dptr() const
155{
156 return d;
157}
void setParentView(View *parent)
View * view() const
Returns the view associated with this controller, if any.
ViewType type() const
Returns the type of this controller.
virtual void setParentView_impl(View *parent)
Controller(ViewType type, View *)
bool is(ViewType) const
Returns whether this controller is of the specified type.
Controller::Private * dptr() const
Point mapToGlobal(Point) const
std::shared_ptr< View > window() const
static Platform * instance()
Returns the platform singleton.
virtual void runDelayed(int ms, Core::DelayedCall *c)=0
virtual void show()=0
virtual std::shared_ptr< View > rootView() const =0
Returns the top-level gui element which this view is inside It's the root view of the window.
virtual bool close()=0
ViewType
Each View type also has a specific Controller associated with, except for ViewType::None.
Definition Controller.h:26
Class to abstract QAction, so code still works with QtQuick and Flutter.

© 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