33 #include <QMouseEvent>
37 #include <QApplication>
126 setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
127 setFrameStyle(QFrame::NoFrame);
128 setWidgetResizable(
true);
129 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
130 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
135 d->
TabsLayout =
new QBoxLayout(QBoxLayout::LeftToRight);
142 setFocusPolicy(Qt::NoFocus);
157 const int direction = Event->angleDelta().y();
160 horizontalScrollBar()->setValue(horizontalScrollBar()->value() + 20);
164 horizontalScrollBar()->setValue(horizontalScrollBar()->value() - 20);
177 if (index < -1 || index > (
count() - 1))
179 qWarning() << Q_FUNC_INFO <<
"Invalid index" << index;
203 connect(Tab, SIGNAL(clicked()),
this, SLOT(
onTabClicked()));
206 connect(Tab, SIGNAL(moved(
const QPoint&)),
this, SLOT(
onTabWidgetMoved(
const QPoint&)));
208 Tab->installEventFilter(
this);
210 if (Index <= d->CurrentIndex)
230 ADS_PRINT(
"CDockAreaTabBar::removeTab ");
235 NewCurrentIndex = -1;
237 if (NewCurrentIndex > RemoveIndex)
241 else if (NewCurrentIndex == RemoveIndex)
243 NewCurrentIndex = -1;
245 for (
int i = (RemoveIndex + 1); i <
count(); ++i)
247 if (
tab(i)->isVisibleTo(
this))
249 NewCurrentIndex = i - 1;
256 if (NewCurrentIndex < 0)
258 for (
int i = (RemoveIndex - 1); i >= 0; --i)
260 if (
tab(i)->isVisibleTo(
this))
271 Tab->disconnect(
this);
272 Tab->removeEventFilter(
this);
273 ADS_PRINT(
"NewCurrentIndex " << NewCurrentIndex);
339 auto Sender = qobject_cast<CDockWidgetTab*>(sender());
340 for (
int i = 0; i <
count(); ++i)
343 if (Tab->isClosable() && !Tab->isHidden() && Tab != Sender)
348 int Offset = Tab->dockWidget()->features().testFlag(
355 if (Tab->dockWidget()->isClosed())
367 if (Index >=
count() || Index < 0)
371 return qobject_cast<CDockWidgetTab*>(
d->
TabsLayout->itemAt(Index)->widget());
378 CDockWidgetTab* MovingTab = qobject_cast<CDockWidgetTab*>(sender());
385 auto MousePos = mapFromGlobal(GlobalPos);
386 MousePos.rx() = qMax(
d->
firstTab()->geometry().left(), MousePos.x());
387 MousePos.rx() = qMin(
d->
lastTab()->geometry().right(), MousePos.x());
390 for (
int i = 0; i <
count(); ++i)
393 if (DropTab == MovingTab || !DropTab->isVisibleTo(
this)
394 || !DropTab->geometry().contains(MousePos))
400 if (toIndex == fromIndex)
411 ADS_PRINT(
"tabMoved from " << fromIndex <<
" to " << toIndex);
425 if (Index < 0 || Index >=
count())
430 auto Tab =
tab(Index);
442 bool Result = Super::eventFilter(watched, event);
449 switch (event->type())
462 case QEvent::LayoutRequest:
477 if (Index < 0 || Index >=
count())
482 return !
tab(Index)->isHidden();