KDDockWidgets API Documentation  1.5
ItemFreeContainer.cpp
Go to the documentation of this file.
1 /*
2  This file is part of KDDockWidgets.
3 
4  SPDX-FileCopyrightText: 2019-2022 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 
14 using namespace Layouting;
15 
16 ItemFreeContainer::ItemFreeContainer(Widget *hostWidget, ItemContainer *parent)
17  : ItemContainer(hostWidget, parent)
18 {
19 }
20 
21 ItemFreeContainer::ItemFreeContainer(Widget *hostWidget)
22  : ItemContainer(hostWidget)
23 {
24 }
25 
26 ItemFreeContainer::~ItemFreeContainer()
27 {
28 }
29 
30 void ItemFreeContainer::addDockWidget(Item *item, QPoint localPt)
31 {
32  Q_ASSERT(item != this);
33  if (contains(item)) {
34  qWarning() << Q_FUNC_INFO << "Item already exists";
35  return;
36  }
37  item->setIsVisible(true); // TODO: Use OptionStartHidden here too
38 
39  m_children.append(item);
40  item->setParentContainer(this);
41  item->setPos(localPt);
42 
43  Q_EMIT itemsChanged();
44 
45  if (item->isVisible())
46  Q_EMIT numVisibleItemsChanged(numVisibleChildren());
47 
48  Q_EMIT numItemsChanged();
49 }
50 
51 void ItemFreeContainer::clear()
52 {
53  qDeleteAll(m_children);
54  m_children.clear();
55 }
56 
57 void ItemFreeContainer::removeItem(Item *item, bool hardRemove)
58 {
59  const bool wasVisible = item->isVisible();
60 
61  if (hardRemove) {
62  m_children.removeOne(item);
63  delete item;
64  } else {
65  item->setIsVisible(false);
66  item->setGuestWidget(nullptr);
67  }
68 
69  if (wasVisible)
70  Q_EMIT numVisibleItemsChanged(numVisibleChildren());
71 
72  Q_EMIT itemsChanged();
73 }
74 
75 void ItemFreeContainer::restore(Item *child)
76 {
77  child->setIsVisible(true);
78 }
79 
80 void ItemFreeContainer::onChildMinSizeChanged(Item *)
81 {
82  // Nothing here either, although we could update the size constraints
83 }
84 
85 void ItemFreeContainer::onChildVisibleChanged(Item *, bool)
86 {
87  // Nothing needed to do in this layout type
88 }
ItemContainer
Layouting::Widget
An abstraction/wrapper around QWidget, QtQuickItem or anything else.
Definition: Widget.h:79
Layouting
Definition: FrameworkWidgetFactory.h:32
QPoint

© 2019-2022 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 on Mon Mar 7 2022 02:01:20 for KDDockWidgets API Documentation by doxygen 1.8.20