Move more code away from Stack and into TabBar
This commit is contained in:
@@ -33,7 +33,7 @@ Stack_qtquick::Stack_qtquick(Controllers::Stack *controller, QQuickItem *parent)
|
||||
if (currentDw && indexOfDockWidget(currentDw) == -1) {
|
||||
// The current dock widget was removed, set the first one as current
|
||||
if (m_stack->numDockWidgets() > 0)
|
||||
setCurrentDockWidget(0);
|
||||
m_dockWidgetModel->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
Q_EMIT m_stack->tabBar()->countChanged();
|
||||
@@ -42,6 +42,7 @@ Stack_qtquick::Stack_qtquick(Controllers::Stack *controller, QQuickItem *parent)
|
||||
|
||||
void Stack_qtquick::init()
|
||||
{
|
||||
m_dockWidgetModel->m_tabBar = m_stack->tabBar();
|
||||
m_tabBarAutoHideChanged =
|
||||
m_stack->tabBarAutoHideChanged.connect([this] { Q_EMIT tabBarAutoHideChanged(); });
|
||||
|
||||
@@ -81,18 +82,6 @@ bool Stack_qtquick::isPositionDraggable(QPoint p) const
|
||||
return true;
|
||||
}
|
||||
|
||||
void Stack_qtquick::setCurrentDockWidget(int index)
|
||||
{
|
||||
Controllers::DockWidget *dw = dockwidgetAt(index);
|
||||
Controllers::DockWidget *currentDw = m_dockWidgetModel->currentDockWidget();
|
||||
|
||||
if (currentDw != dw) {
|
||||
m_dockWidgetModel->setCurrentDockWidget(dw);
|
||||
Q_EMIT m_stack->tabBar()->currentDockWidgetChanged(dw);
|
||||
Q_EMIT m_stack->tabBar()->currentTabChanged(index);
|
||||
}
|
||||
}
|
||||
|
||||
QObject *Stack_qtquick::tabBarViewObj() const
|
||||
{
|
||||
return View_qt::asQObject(m_stack->tabBar()->view());
|
||||
@@ -254,6 +243,18 @@ int DockWidgetModel::currentIndex() const
|
||||
return index;
|
||||
}
|
||||
|
||||
void DockWidgetModel::setCurrentIndex(int index)
|
||||
{
|
||||
Controllers::DockWidget *dw = dockWidgetAt(index);
|
||||
|
||||
if (m_currentDockWidget != dw) {
|
||||
setCurrentDockWidget(dw);
|
||||
Q_ASSERT(m_tabBar);
|
||||
Q_EMIT m_tabBar->currentDockWidgetChanged(dw);
|
||||
Q_EMIT m_tabBar->currentTabChanged(index);
|
||||
}
|
||||
}
|
||||
|
||||
bool DockWidgetModel::insert(Controllers::DockWidget *dw, int index)
|
||||
{
|
||||
if (m_dockWidgets.contains(dw)) {
|
||||
|
||||
Reference in New Issue
Block a user