KDDockWidgets API Documentation 2.1
Loading...
Searching...
No Matches
Object.cpp
Go to the documentation of this file.
1/*
2 This file is part of KDDockWidgets.
3
4 SPDX-FileCopyrightText: 2023 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 "Object_p.h"
13#include "Logging_p.h"
14
15using namespace KDDockWidgets::Core;
16
17Object::Object(Object *parent)
18{
19 setParent(parent);
20}
21
22Object::~Object()
23{
24 if (m_parent)
25 m_parent->removeChild(this);
26
27 aboutToBeDeleted.emit();
28
29 const auto children = m_children;
30 for (Object *child : children) {
31 delete child;
32 }
33}
34
35void Object::setParent(Object *parent)
36{
37 if (parent == m_parent)
38 return;
39
40 if (m_parent)
41 m_parent->removeChild(this);
42
43 m_parent = parent;
44
45 if (parent)
46 parent->addChild(this);
47}
48
49Object *Object::parent() const
50{
51 return m_parent;
52}
53
54void Object::removeChild(Object *child)
55{
56 auto it = std::find(m_children.begin(), m_children.end(), child);
57 if (it == m_children.cend()) {
58 KDDW_ERROR("Object::removeChild: Could not find child");
59 } else {
60 m_children.erase(it);
61 }
62}
63
64void Object::addChild(Object *child)
65{
66 m_children.push_back(child);
67}
68
69QString Object::objectName() const
70{
71 return m_name;
72}
73
74void Object::setObjectName(const QString &name)
75{
76 m_name = name;
77}
78
79QString Object::tr(const char *text)
80{
81 // Not translated for Flutter yet
82 return QString(text);
83}

© 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