Allow for rearranging tabified QDockWidgets
Allow to drag and drop tabs [ChangeLog][QtWidgets][Important Behavior Changes] The tabs for the tabified docks can be moved by the user. Task-number: QTBUG-1049 Task-number: QTBUG-2295 Task-number: QTBUG-4532 Task-number: QTBUG-18883 Task-number: QTBUG-35148 Change-Id: I7ef9d4987db081654bd5d648e14370b3d381a720 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com> Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
This commit is contained in:
parent
60e8519544
commit
02a13a86fa
@ -2244,6 +2244,22 @@ QRect QDockAreaLayoutInfo::tabContentRect() const
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int QDockAreaLayoutInfo::tabIndexToListIndex(int tabIndex) const
|
||||||
|
{
|
||||||
|
Q_ASSERT(tabbed && tabBar);
|
||||||
|
quintptr data = qvariant_cast<quintptr>(tabBar->tabData(tabIndex));
|
||||||
|
for (int i = 0; i < item_list.count(); ++i) {
|
||||||
|
if (tabId(item_list.at(i)) == data)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QDockAreaLayoutInfo::moveTab(int from, int to)
|
||||||
|
{
|
||||||
|
item_list.move(tabIndexToListIndex(from), tabIndexToListIndex(to));
|
||||||
|
}
|
||||||
#endif // QT_NO_TABBAR
|
#endif // QT_NO_TABBAR
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
|
@ -208,6 +208,9 @@ public:
|
|||||||
QSize tabBarSizeHint() const;
|
QSize tabBarSizeHint() const;
|
||||||
|
|
||||||
QSet<QTabBar*> usedTabBars() const;
|
QSet<QTabBar*> usedTabBars() const;
|
||||||
|
|
||||||
|
int tabIndexToListIndex(int) const;
|
||||||
|
void moveTab(int from, int to);
|
||||||
#endif // QT_NO_TABBAR
|
#endif // QT_NO_TABBAR
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1280,7 +1280,9 @@ QTabBar *QMainWindowLayout::getTabBar()
|
|||||||
result->setDrawBase(true);
|
result->setDrawBase(true);
|
||||||
result->setElideMode(Qt::ElideRight);
|
result->setElideMode(Qt::ElideRight);
|
||||||
result->setDocumentMode(_documentMode);
|
result->setDocumentMode(_documentMode);
|
||||||
|
result->setMovable(true);
|
||||||
connect(result, SIGNAL(currentChanged(int)), this, SLOT(tabChanged()));
|
connect(result, SIGNAL(currentChanged(int)), this, SLOT(tabChanged()));
|
||||||
|
connect(result, &QTabBar::tabMoved, this, &QMainWindowLayout::tabMoved);
|
||||||
}
|
}
|
||||||
|
|
||||||
usedTabBars.insert(result);
|
usedTabBars.insert(result);
|
||||||
@ -1316,6 +1318,16 @@ void QMainWindowLayout::tabChanged()
|
|||||||
if (QWidget *w = centralWidget())
|
if (QWidget *w = centralWidget())
|
||||||
w->raise();
|
w->raise();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QMainWindowLayout::tabMoved(int from, int to)
|
||||||
|
{
|
||||||
|
QTabBar *tb = qobject_cast<QTabBar*>(sender());
|
||||||
|
Q_ASSERT(tb);
|
||||||
|
QDockAreaLayoutInfo *info = layoutState.dockAreaLayout.info(tb);
|
||||||
|
Q_ASSERT(info);
|
||||||
|
|
||||||
|
info->moveTab(from, to);
|
||||||
|
}
|
||||||
#endif // QT_NO_TABBAR
|
#endif // QT_NO_TABBAR
|
||||||
|
|
||||||
bool QMainWindowLayout::startSeparatorMove(const QPoint &pos)
|
bool QMainWindowLayout::startSeparatorMove(const QPoint &pos)
|
||||||
|
@ -286,6 +286,7 @@ private Q_SLOTS:
|
|||||||
#ifndef QT_NO_DOCKWIDGET
|
#ifndef QT_NO_DOCKWIDGET
|
||||||
#ifndef QT_NO_TABBAR
|
#ifndef QT_NO_TABBAR
|
||||||
void tabChanged();
|
void tabChanged();
|
||||||
|
void tabMoved(int from, int to);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user