mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-08 07:02:06 +08:00
cabana: support dragging chart between tabs (#27838)
drag chart between tabs old-commit-hash: f4f836e2a9f0362f237321ec3d8c9be5703ec77b
This commit is contained in:
@@ -81,6 +81,8 @@ ChartsWidget::ChartsWidget(QWidget *parent) : align_timer(this), auto_scroll_tim
|
||||
QHBoxLayout *tab_layout = new QHBoxLayout();
|
||||
tab_layout->addWidget(tabbar = new QTabBar(this));
|
||||
tabbar->setAutoHide(true);
|
||||
tabbar->setAcceptDrops(true);
|
||||
tabbar->setChangeCurrentOnDrag(true);
|
||||
tabbar->setTabsClosable(true);
|
||||
tabbar->setUsesScrollButtons(true);
|
||||
tab_layout->addStretch(0);
|
||||
@@ -1264,7 +1266,9 @@ void ChartsContainer::dropEvent(QDropEvent *event) {
|
||||
auto w = getDropBefore(event->pos());
|
||||
auto chart = qobject_cast<ChartView *>(event->source());
|
||||
if (w != chart) {
|
||||
charts_widget->currentCharts().removeOne(chart);
|
||||
for (auto &[_, list] : charts_widget->tab_charts) {
|
||||
list.removeOne(chart);
|
||||
}
|
||||
int to = w ? charts_widget->currentCharts().indexOf(w) : charts_widget->currentCharts().size();
|
||||
charts_widget->currentCharts().insert(to, chart);
|
||||
charts_widget->updateLayout(true);
|
||||
|
||||
Reference in New Issue
Block a user