cabana: support dragging chart between tabs (#27838)

drag chart between tabs
old-commit-hash: f4f836e2a9
beeps
Dean Lee 2 years ago committed by GitHub
parent 575d4b88d1
commit f81f65dc77
  1. 6
      tools/cabana/chartswidget.cc

@ -81,6 +81,8 @@ ChartsWidget::ChartsWidget(QWidget *parent) : align_timer(this), auto_scroll_tim
QHBoxLayout *tab_layout = new QHBoxLayout(); QHBoxLayout *tab_layout = new QHBoxLayout();
tab_layout->addWidget(tabbar = new QTabBar(this)); tab_layout->addWidget(tabbar = new QTabBar(this));
tabbar->setAutoHide(true); tabbar->setAutoHide(true);
tabbar->setAcceptDrops(true);
tabbar->setChangeCurrentOnDrag(true);
tabbar->setTabsClosable(true); tabbar->setTabsClosable(true);
tabbar->setUsesScrollButtons(true); tabbar->setUsesScrollButtons(true);
tab_layout->addStretch(0); tab_layout->addStretch(0);
@ -1264,7 +1266,9 @@ void ChartsContainer::dropEvent(QDropEvent *event) {
auto w = getDropBefore(event->pos()); auto w = getDropBefore(event->pos());
auto chart = qobject_cast<ChartView *>(event->source()); auto chart = qobject_cast<ChartView *>(event->source());
if (w != chart) { 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(); int to = w ? charts_widget->currentCharts().indexOf(w) : charts_widget->currentCharts().size();
charts_widget->currentCharts().insert(to, chart); charts_widget->currentCharts().insert(to, chart);
charts_widget->updateLayout(true); charts_widget->updateLayout(true);

Loading…
Cancel
Save