KDDockWidgets API Documentation 2.1
Loading...
Searching...
No Matches
ItemFreeContainer.cpp
Go to the documentation of this file.
1/*
2 This file is part of KDDockWidgets.
3
4 SPDX-FileCopyrightText: 2019 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 "ItemFreeContainer_p.h"
13#include "LayoutingHost_p.h"
14
15#include "core/View.h"
16#include "core/Logging_p.h"
17#include "core/Utils_p.h"
18
19using namespace KDDockWidgets::Core;
20
21ItemFreeContainer::ItemFreeContainer(LayoutingHost *hostWidget, ItemContainer *parent)
22 : ItemContainer(hostWidget, parent)
23{
24}
25
26ItemFreeContainer::ItemFreeContainer(LayoutingHost *hostWidget)
27 : ItemContainer(hostWidget)
28{
29}
30
31ItemFreeContainer::~ItemFreeContainer()
32{
33}
34
35void ItemFreeContainer::addDockWidget(Item *item, Point localPt)
36{
37 assert(item != this);
38 if (contains(item)) {
39 KDDW_ERROR("Item already exists");
40 return;
41 }
42 item->setIsVisible(true); // Use OptionStartHidden here too ?
43
44 m_children.append(item);
45 item->setParentContainer(this);
46 item->setPos(localPt);
47
48 itemsChanged.emit();
49
50 if (item->isVisible())
51 numVisibleItemsChanged.emit(numVisibleChildren());
52
53 numItemsChanged.emit();
54}
55
56void ItemFreeContainer::clear()
57{
58 deleteAll(m_children);
59 m_children.clear();
60}
61
62void ItemFreeContainer::removeItem(Item *item, bool hardRemove)
63{
64 const bool wasVisible = item->isVisible();
65
66 if (hardRemove) {
67 m_children.removeOne(item);
68 delete item;
69 } else {
70 item->setIsVisible(false);
71 item->setGuest(nullptr);
72 }
73
74 if (wasVisible)
75 numVisibleItemsChanged.emit(numVisibleChildren());
76
77 itemsChanged.emit();
78}
79
80void ItemFreeContainer::restore(Item *child)
81{
82 child->setIsVisible(true);
83}
84
85void ItemFreeContainer::onChildMinSizeChanged(Item *)
86{
87 // Nothing here either, although we could update the size constraints
88}
89
90void ItemFreeContainer::onChildVisibleChanged(Item *, bool)
91{
92 // Nothing needed to do in this layout type
93}

© 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