summaryrefslogtreecommitdiffstats
path: root/src/gui/widgets/qtabbar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/widgets/qtabbar.cpp')
-rw-r--r--src/gui/widgets/qtabbar.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/gui/widgets/qtabbar.cpp b/src/gui/widgets/qtabbar.cpp
index 64e383f..560b76c 100644
--- a/src/gui/widgets/qtabbar.cpp
+++ b/src/gui/widgets/qtabbar.cpp
@@ -1897,13 +1897,8 @@ void QTabBar::keyPressEvent(QKeyEvent *event)
event->ignore();
return;
}
- int dx = event->key() == (isRightToLeft() ? Qt::Key_Right : Qt::Key_Left) ? -1 : 1;
- for (int index = d->currentIndex + dx; d->validIndex(index); index += dx) {
- if (d->tabList.at(index).enabled) {
- setCurrentIndex(index);
- break;
- }
- }
+ int offset = event->key() == (isRightToLeft() ? Qt::Key_Right : Qt::Key_Left) ? -1 : 1;
+ d->setCurrentNextEnabledIndex(offset);
}
/*!\reimp
@@ -1912,15 +1907,23 @@ void QTabBar::keyPressEvent(QKeyEvent *event)
void QTabBar::wheelEvent(QWheelEvent *event)
{
Q_D(QTabBar);
- int overIndex = d->indexAtPos(event->pos());
- if (overIndex != -1) {
- int offset = event->delta() > 0 ? -1 : 1;
- setCurrentIndex(currentIndex() + offset);
- }
+ int offset = event->delta() > 0 ? -1 : 1;
+ d->setCurrentNextEnabledIndex(offset);
QWidget::wheelEvent(event);
}
#endif //QT_NO_WHEELEVENT
+void QTabBarPrivate::setCurrentNextEnabledIndex(int offset)
+{
+ Q_Q(QTabBar);
+ for (int index = currentIndex + offset; validIndex(index); index += offset) {
+ if (tabList.at(index).enabled) {
+ q->setCurrentIndex(index);
+ break;
+ }
+ }
+}
+
/*!\reimp
*/
void QTabBar::changeEvent(QEvent *event)