From 7c9a500b3da791b327b82549cca52f2ab2fb5da1 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 13 Feb 2009 11:43:58 +0000 Subject: [PATCH] move the wheelEvent to nativeTabbar, it seems it works only there with qt 4.5, while with 4.4 did work only in the proxywidget svn path=/trunk/KDE/kdelibs/; revision=925477 --- private/nativetabbar.cpp | 31 +++++++++++++++++++++++++++++++ private/nativetabbar_p.h | 1 + widgets/tabbar.cpp | 30 +----------------------------- 3 files changed, 33 insertions(+), 29 deletions(-) diff --git a/private/nativetabbar.cpp b/private/nativetabbar.cpp index a28eaea87..dedd59756 100644 --- a/private/nativetabbar.cpp +++ b/private/nativetabbar.cpp @@ -427,6 +427,37 @@ QPoint NativeTabBar::closeButtonPos( int tabIndex ) const return buttonPos; } +void NativeTabBar::wheelEvent(QWheelEvent *event) +{ + if (underMouse()) { + //Cycle tabs with the circular array tecnique + if (event->delta() < 0) { + int index = currentIndex(); + //search for an enabled tab + for (int i = 0; i < count()-1; ++i) { + index = (index + 1) % count(); + if (isTabEnabled(index)) { + break; + } + } + + setCurrentIndex(index); + } else { + int index = currentIndex(); + for (int i = 0; i < count()-1; ++i) { + index = (count() + index -1) % count(); + if (isTabEnabled(index)) { + break; + } + } + + setCurrentIndex(index); + } + } else { + QTabBar::wheelEvent(event); + } +} + } // namespace Plasma #include "nativetabbar_p.moc" diff --git a/private/nativetabbar_p.h b/private/nativetabbar_p.h index 08bed6ec1..a33b70efd 100644 --- a/private/nativetabbar_p.h +++ b/private/nativetabbar_p.h @@ -52,6 +52,7 @@ protected: bool isHorizontal() const; bool isVertical() const; + void wheelEvent(QWheelEvent *event); protected slots: void animationFinished(); diff --git a/widgets/tabbar.cpp b/widgets/tabbar.cpp index acc6cb49a..5aef37810 100644 --- a/widgets/tabbar.cpp +++ b/widgets/tabbar.cpp @@ -438,35 +438,7 @@ KTabBar *TabBar::nativeWidget() const void TabBar::wheelEvent(QGraphicsSceneWheelEvent * event) { - //FIXME: probably this would make more sense in NativeTabBar, but it works only here - - if (d->tabProxy->native->underMouse()) { - //Cycle tabs with the circular array tecnique - if (event->delta() < 0) { - int index = d->tabProxy->native->currentIndex(); - //search for an enabled tab - for (int i = 0; i < d->tabProxy->native->count()-1; ++i) { - index = (index + 1) % d->tabProxy->native->count(); - if (d->tabProxy->native->isTabEnabled(index)) { - break; - } - } - - d->tabProxy->native->setCurrentIndex(index); - } else { - int index = d->tabProxy->native->currentIndex(); - for (int i = 0; i < d->tabProxy->native->count()-1; ++i) { - index = (d->tabProxy->native->count() + index -1) % d->tabProxy->native->count(); - if (d->tabProxy->native->isTabEnabled(index)) { - break; - } - } - - d->tabProxy->native->setCurrentIndex(index); - } - } else { - QGraphicsWidget::wheelEvent(event); - } + //Still here for binary compatibility } } // namespace Plasma