Show
Ignore:
Timestamp:
05/11/08 19:17:12 (8 months ago)
Author:
flynd
Message:

Revised r6191. scrollTo needs to be called for some cases. It's just the call triggered by layoutChanged that we want to ignore. And I don't see any reason to have this configurable.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/qt4-gui/src/views/userviewbase.cpp

    r6191 r6193  
    4747UserViewBase::UserViewBase(ContactListModel* contactList, QWidget* parent) 
    4848  : QTreeView(parent), 
    49     myContactList(contactList) 
     49    myContactList(contactList), 
     50    myAllowScrollTo(false) 
    5051{ 
    5152  setItemDelegate(new ContactDelegate(this, this)); 
     
    8485    setPalette(pal); 
    8586  } 
    86 } 
    87  
    88 void UserViewBase::scrollTo(const QModelIndex& index, QAbstractItemView::ScrollHint hint) 
    89 { 
    90   if (Config::ContactList::instance()->autoScroll()) 
    91     QTreeView::scrollTo(index, hint); 
    9287} 
    9388 
     
    330325  } 
    331326} 
     327 
     328void UserViewBase::currentChanged(const QModelIndex &current, 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 
     336void 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 
     344void 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