From: Marcus Eggenberger Date: Sun, 24 Feb 2008 18:16:33 +0000 (+0000) Subject: You can now switch buffers via mousewhell, when the cursor is over a buffer view. X-Git-Tag: 0.2.0-alpha2~21 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=597705d895583bd2860fc117a7c73aa5cf86ae52 You can now switch buffers via mousewhell, when the cursor is over a buffer view. Thanks to Ian "eean" Monroe for the patch! --- diff --git a/src/uisupport/bufferview.cpp b/src/uisupport/bufferview.cpp index 9b1b93ca..380828d3 100644 --- a/src/uisupport/bufferview.cpp +++ b/src/uisupport/bufferview.cpp @@ -220,3 +220,27 @@ void BufferView::showContextMenu(const QPoint &pos) { } } +void BufferView::wheelEvent(QWheelEvent* event) +{ + int rowDelta = ( event->delta() > 0 ) ? -1 : 1; + QModelIndex currentIndex = selectionModel()->currentIndex(); + QModelIndex resultingIndex; + if( model()->hasIndex( currentIndex.row() + rowDelta, currentIndex.column(), currentIndex.parent() ) ) + { + resultingIndex = currentIndex.sibling( currentIndex.row() + rowDelta, currentIndex.column() ); + } + else //if we scroll into a the parent node... + { + QModelIndex parent = currentIndex.parent(); + QModelIndex aunt = parent.sibling( parent.row() + rowDelta, parent.column() ); + if( rowDelta == -1 ) + resultingIndex = aunt.child( model()->rowCount( aunt ) - 1, 0 ); + else + resultingIndex = aunt.child( 0, 0 ); + if( !resultingIndex.isValid() ) + return; + } + selectionModel()->setCurrentIndex( resultingIndex, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows ); + selectionModel()->select( resultingIndex, QItemSelectionModel::ClearAndSelect ); +} + diff --git a/src/uisupport/bufferview.h b/src/uisupport/bufferview.h index 76201b2b..f0fc2b6d 100644 --- a/src/uisupport/bufferview.h +++ b/src/uisupport/bufferview.h @@ -47,6 +47,7 @@ private slots: void rowsInserted (const QModelIndex & parent, int start, int end); void toggleHeader(bool checked); void showContextMenu(const QPoint &); + void wheelEvent(QWheelEvent *); }; diff --git a/version.inc b/version.inc index 1a7e6b4c..a6827464 100644 --- a/version.inc +++ b/version.inc @@ -5,7 +5,7 @@ quasselVersion = "0.2.0-alpha1"; quasselDate = "2008-02-24"; - quasselBuild = 583; + quasselBuild = 584; //! Minimum client build number the core needs clientBuildNeeded = 563;