33 #include <QStackedLayout> 35 #include <QScrollArea> 36 #include <QWheelEvent> 38 #include <QPushButton> 42 #include <QXmlStreamWriter> 84 : m_ParentLayout(ParentLayout)
94 return m_Widgets.count();
103 Widget->setParent(
nullptr);
106 index = m_Widgets.count();
108 m_Widgets.insert(index, Widget);
109 if (m_CurrentIndex < 0)
115 if (index <= m_CurrentIndex )
129 auto LayoutItem = m_ParentLayout->takeAt(1);
132 LayoutItem->widget()->setParent(
nullptr);
134 m_CurrentWidget =
nullptr;
137 else if (
indexOf(Widget) < m_CurrentIndex)
141 m_Widgets.removeOne(Widget);
159 if (!next || (next == prev && !m_CurrentWidget))
164 bool reenableUpdates =
false;
165 QWidget *parent = m_ParentLayout->parentWidget();
167 if (parent && parent->updatesEnabled())
169 reenableUpdates =
true;
170 parent->setUpdatesEnabled(
false);
173 auto LayoutItem = m_ParentLayout->takeAt(1);
176 LayoutItem->widget()->setParent(
nullptr);
180 m_ParentLayout->addWidget(next);
185 m_CurrentIndex = index;
186 m_CurrentWidget = next;
191 parent->setUpdatesEnabled(
true);
208 return m_Widgets.empty();
216 return m_Widgets.indexOf(w);
224 return (index < m_Widgets.size()) ? m_Widgets.at(index) :
nullptr;
232 return m_Widgets.empty() ? QRect() :
currentWidget()->geometry();
248 QBoxLayout* Layout =
nullptr;
252 bool UpdateTitleBarButtons =
false;
265 void createTitleBar();
280 return dockWidgetAt(index)->tabWidget();
289 return qvariant_cast<QAction*>(DockWidget->property(ACTION_PROPERTY));
297 return DockWidget->property(INDEX_PROPERTY).toInt();
305 return TitleBar->
tabBar();
311 void updateTitleBarButtonStates();
318 MinSizeHint = QSize();
319 for (
int i = 0; i < ContentsLayout->
count(); ++i)
321 auto Widget = ContentsLayout->
widget(i);
322 MinSizeHint.setHeight(qMax(MinSizeHint.height(), Widget->minimumSizeHint().height()));
323 MinSizeHint.setWidth(qMax(MinSizeHint.width(), Widget->minimumSizeHint().width()));
352 if (
_this->isHidden())
373 d->
Layout =
new QBoxLayout(QBoxLayout::TopToBottom);
374 d->
Layout->setContentsMargins(0, 0, 0, 0);
405 return internal::findParent<CDockContainerWidget*>(
this);
426 d->
tabBar()->blockSignals(
true);
428 d->
tabBar()->blockSignals(
false);
430 DockWidget->setProperty(INDEX_PROPERTY, index);
451 ADS_PRINT(
"CDockAreaWidget::removeDockWidget");
453 auto NextOpenDockWidget = (DockWidget == CurrentDockWidget) ?
nextOpenDockWidget(DockWidget) :
nullptr;
462 if (NextOpenDockWidget)
475 FloatingDockContainer->hide();
476 FloatingDockContainer->deleteLater();
480 else if (DockWidget == CurrentDockWidget)
492 if (TopLevelDockWidget)
497 #if (ADS_DEBUG_LEVEL > 0) 509 auto Splitter = internal::findParent<CDockSplitter*>(
this);
532 FloatingWidget->hide();
540 ADS_PRINT(
"CDockAreaWidget::onTabCloseRequested " << Index);
557 if (CurrentIndex < 0)
581 int Index =
index(DockWidget);
595 if (index < 0 || index > (TabBar->count() - 1))
597 qWarning() << Q_FUNC_INFO <<
"Invalid index" <<
index;
603 if (cw == nw && !nw->isHidden())
609 TabBar->setCurrentIndex(index);
651 return DockWidgetList;
682 return DockWidgetList;
718 ADS_PRINT(
"CDockAreaWidget::reorderDockWidget");
722 ADS_PRINT(
"Invalid index for tab movement" << fromIndex << toIndex);
736 Q_UNUSED(DockWidget);
780 s.writeStartElement(
"Area");
783 QString Name = CurrentDockWidget ? CurrentDockWidget->objectName() :
"";
784 s.writeAttribute(
"Current", Name);
789 s.writeAttribute(
"AllowedAreas", QString::number(
d->
AllowedAreas, 16));
794 s.writeAttribute(
"Flags", QString::number(
d->
Flags, 16));
797 <<
" Current: " << Name);
810 if (OpenDockWidgets.count() > 1 || (OpenDockWidgets.count() == 1 && OpenDockWidgets[0] != DockWidget))
813 if (OpenDockWidgets.last() == DockWidget)
815 NextDockWidget = OpenDockWidgets[OpenDockWidgets.count() - 2];
819 int NextIndex = OpenDockWidgets.indexOf(DockWidget) + 1;
820 NextDockWidget = OpenDockWidgets[NextIndex];
823 return NextDockWidget;
868 Super::setVisible(Visible);
900 auto ChangedFlags =
d->
Flags ^ Flags;
933 OpenDockWidgets[0]->closeDockWidgetInternal();
static bool testConfigFlag(eConfigFlag Flag)
QWidget * m_CurrentWidget
bool isRestoringState() const
QBoxLayout * m_ParentLayout
Declaration of DockComponentsFactory.
CDockWidget * centralWidget() const
void setCurrentIndex(int index)
Declaration of CDockAreaTabBar class.
Declaration of CFloatingDockContainer class.
const CDockComponentsFactory * componentsFactory()
void insertTab(int Index, CDockWidgetTab *Tab)
void tabCloseRequested(int index)
virtual CDockAreaTitleBar * createDockAreaTitleBar(CDockAreaWidget *DockArea) const
CDockAreaLayout DockAreaLayout
void tabMoved(int from, int to)
CDockAreaTabBar * tabBar() const
void insertWidget(int index, QWidget *Widget)
void dockAreaCreated(ads::CDockAreaWidget *DockArea)
static const char *const INDEX_PROPERTY
If this option is enabled, the tab of a dock widget is always displayed - even if it is the only visi...
CDockAreaLayout(QBoxLayout *ParentLayout)
Declaration of CDockSplitter.
QWidget * currentWidget() const
void updateDockWidgetActionsButtons()
void setFlag(T &Flags, typename T::enum_type flag, bool on=true)
void removeTab(CDockWidgetTab *Tab)
static const char *const ACTION_PROPERTY
virtual void setVisible(bool Visible) override
QAbstractButton * button(TitleBarButton which) const
void hideEmptyParentSplitters(CDockSplitter *FirstParentSplitter)
void removeWidget(QWidget *Widget)
void tabBarClicked(int index)
QList< QWidget * > m_Widgets
Declaration of CDockManager class.
static const DockWidgetAreas DefaultAllowedAreas
QWidget * widget(int index) const
void markTabsMenuOutdated()
Declaration of CDockAreaTitleBar class.
int indexOf(QWidget *w) const