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
This commit is contained in:
Marco Martin 2009-02-13 11:43:58 +00:00
parent a136f604e6
commit 7c9a500b3d
3 changed files with 33 additions and 29 deletions

View File

@ -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"

View File

@ -52,6 +52,7 @@ protected:
bool isHorizontal() const;
bool isVertical() const;
void wheelEvent(QWheelEvent *event);
protected slots:
void animationFinished();

View File

@ -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