| | 327 | |
| | 328 | void UserViewBase::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) |
| | 329 | { |
| | 330 | // Workaround for annoying auto scrolling, see comment in scrollTo() |
| | 331 | myAllowScrollTo = true; |
| | 332 | QTreeView::currentChanged(current, previous); |
| | 333 | myAllowScrollTo = false; |
| | 334 | } |
| | 335 | |
| | 336 | void UserViewBase::timerEvent(QTimerEvent* event) |
| | 337 | { |
| | 338 | // Workaround for annoying auto scrolling, see comment in scrollTo() |
| | 339 | myAllowScrollTo = true; |
| | 340 | QTreeView::timerEvent(event); |
| | 341 | myAllowScrollTo = false; |
| | 342 | } |
| | 343 | |
| | 344 | void UserViewBase::scrollTo(const QModelIndex& index, ScrollHint hint) |
| | 345 | { |
| | 346 | // scrollTo is called from the following functions: |
| | 347 | // QAbstractItemView::setVerticalScrollMode |
| | 348 | // QAbstractItemView::timerEvent |
| | 349 | // QAbstractItemView::currentChanged |
| | 350 | // QAbstractItemViewPrivate::_q_layoutChanged |
| | 351 | // |
| | 352 | // Since layoutChanged is emitted by the sort proxy whenever anything item |
| | 353 | // in the list is changed this causes the list to scroll back to current item |
| | 354 | // which can be annoying when trying to scroll the list manually. |
| | 355 | // Since we cannot override a private function this is a ugly workaround to |
| | 356 | // block scrollTo as default but allow it for timerEvent and currentChanged |
| | 357 | // instead. (setVerticalScrollMode isn't used so we don't care for that one.) |
| | 358 | if (myAllowScrollTo) |
| | 359 | QTreeView::scrollTo(index, hint); |
| | 360 | } |
| | 361 | |