summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStian Sandvik Thomassen <stian.thomassen@nokia.com>2009-09-01 22:51:20 (GMT)
committerStian Sandvik Thomassen <stian.thomassen@nokia.com>2009-09-01 22:51:20 (GMT)
commitb1cdd3a160ea995f9c48eab9aeb02bd28d98f8c9 (patch)
treec46ea01dcdfec99829eb96128692944d09a097a7 /src
parent491bf41b96fdc48aa166ae7702e00f3e6eb1825c (diff)
downloadQt-b1cdd3a160ea995f9c48eab9aeb02bd28d98f8c9.zip
Qt-b1cdd3a160ea995f9c48eab9aeb02bd28d98f8c9.tar.gz
Qt-b1cdd3a160ea995f9c48eab9aeb02bd28d98f8c9.tar.bz2
Made mouse wheel navigation skip disabled tabs
Mouse wheel navigation should skip disabled tabs like keyboard navigation does. Task-number: 260568 Reviewed-by: Jens Bache-Wiig
Diffstat (limited to 'src')
-rw-r--r--src/gui/widgets/qtabbar.cpp27
-rw-r--r--src/gui/widgets/qtabbar_p.h1
2 files changed, 16 insertions, 12 deletions
diff --git a/src/gui/widgets/qtabbar.cpp b/src/gui/widgets/qtabbar.cpp
index bf2c0bb..e749ce7 100644
--- a/src/gui/widgets/qtabbar.cpp
+++ b/src/gui/widgets/qtabbar.cpp
@@ -1913,13 +1913,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
@@ -1928,15 +1923,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)
diff --git a/src/gui/widgets/qtabbar_p.h b/src/gui/widgets/qtabbar_p.h
index d632753..2c4d625 100644
--- a/src/gui/widgets/qtabbar_p.h
+++ b/src/gui/widgets/qtabbar_p.h
@@ -144,6 +144,7 @@ public:
int indexAtPos(const QPoint &p) const;
inline bool validIndex(int index) const { return index >= 0 && index < tabList.count(); }
+ void setCurrentNextEnabledIndex(int offset);
QSize minimumTabSizeHint(int index);