Changeset 6193 for trunk/qt4-gui

Show
Ignore:
Timestamp:
05/11/08 19:17:12 (7 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.

Location:
trunk/qt4-gui/src
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • trunk/qt4-gui/src/config/contactlist.cpp

    r6191 r6193  
    6363  iniFile.ReadBool("ScrollBar", myAllowScrollBar, true); 
    6464  iniFile.ReadBool("SystemBackground", myUseSystemBackground, false); 
    65   iniFile.ReadBool("AutoScrolling", myAutoScroll, true); 
    6665 
    6766  unsigned short flash; 
     
    129128  iniFile.WriteBool("ScrollBar", myAllowScrollBar); 
    130129  iniFile.WriteBool("SystemBackground", myUseSystemBackground); 
    131   iniFile.WriteBool("AutoScrolling", myAutoScroll); 
    132130 
    133131  iniFile.WriteNum("NumColumns", myColumnCount); 
     
    313311} 
    314312 
    315 void Config::ContactList::setAutoScroll(bool autoScroll) 
    316 { 
    317   myAutoScroll = autoScroll; 
    318 } 
    319  
    320313void Config::ContactList::setShowDividers(bool showDividers) 
    321314{ 
  • trunk/qt4-gui/src/config/contactlist.h

    r6191 r6193  
    110110  bool allowScrollBar() const { return myAllowScrollBar; } 
    111111  bool useSystemBackground() const { return myUseSystemBackground; } 
    112   bool autoScroll() const { return myAutoScroll; } 
    113112 
    114113  bool popupPicture() const { return myPopupPicture; } 
     
    161160  void setAllowScrollBar(bool allowScrollBar); 
    162161  void setUseSystemBackground(bool useSystemBackground); 
    163   void setAutoScroll(bool autoScroll); 
    164162 
    165163  void setPopupPicture(bool popupPicture); 
     
    242240  bool myAllowScrollBar; 
    243241  bool myUseSystemBackground; 
    244   bool myAutoScroll; 
    245242 
    246243  // Contact list sorting 
  • trunk/qt4-gui/src/settings/contactlist.cpp

    r6191 r6193  
    161161  myBehaviourLayout->addWidget(myMainWinStickyCheck, 0, 1); 
    162162 
    163   myAutoScrollCheck = new QCheckBox(tr("Automatic scrolling")); 
    164   myAutoScrollCheck->setToolTip(tr("Automatically scroll to the selected item if it was moved out of the view.")); 
    165   myBehaviourLayout->addWidget(myAutoScrollCheck, 1, 1); 
    166  
    167163  QHBoxLayout* mySortByLayout = new QHBoxLayout(); 
    168164  mySortByLabel = new QLabel(tr("Additional sorting:")); 
     
    180176  mySortByLabel->setBuddy(mySortByCombo); 
    181177  mySortByLayout->addWidget(mySortByCombo); 
    182   myBehaviourLayout->addLayout(mySortByLayout, 2, 1); 
     178  myBehaviourLayout->addLayout(mySortByLayout, 1, 1); 
    183179 
    184180 
     
    351347  myScrollBarCheck->setChecked(contactListConfig->allowScrollBar()); 
    352348  mySysBackCheck->setChecked(contactListConfig->useSystemBackground()); 
    353   myAutoScrollCheck->setChecked(contactListConfig->autoScroll()); 
    354349 
    355350  int numColumns = contactListConfig->columnCount(); 
     
    424419  contactListConfig->setAllowScrollBar(myScrollBarCheck->isChecked()); 
    425420  contactListConfig->setUseSystemBackground(mySysBackCheck->isChecked()); 
    426   contactListConfig->setAutoScroll(myAutoScrollCheck->isChecked()); 
    427421 
    428422  for (unsigned short i = 0; i < MAX_COLUMNCOUNT; ++i) 
  • trunk/qt4-gui/src/settings/contactlist.h

    r6191 r6193  
    9090  QLineEdit* myFrameStyleEdit; 
    9191  QComboBox* mySortByCombo; 
    92   QCheckBox* myAutoScrollCheck; 
    9392  QCheckBox* mySSListCheck; 
    9493  QCheckBox* myGridLinesCheck; 
  • 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 
  • trunk/qt4-gui/src/views/userviewbase.h

    r6192 r6193  
    6262 
    6363  /** 
    64    * Overloaded from base class to make scrolling conditional 
     64   * Make sure a specified index is visible 
     65   * Overloaded to stop annoying auto scrolling triggered by layoutChanged 
    6566   * 
    66    * @param index Index of the item to scroll to 
    67    * @param hint Relative viewport position to maintain 
     67   * @param index Index to scroll to 
     68   * @param hint Where to place the index 
    6869   */ 
    6970  virtual void scrollTo(const QModelIndex& index, ScrollHint hint = EnsureVisible); 
     
    8384   */ 
    8485  virtual void applySkin(); 
     86 
     87  /** 
     88   * Current index has changed 
     89   * Overloaded as workaround for scrollTo() 
     90   * 
     91   * @param current New current index 
     92   * @param previous Previously current index 
     93   */ 
     94  virtual void currentChanged(const QModelIndex& current, const QModelIndex& previous); 
    8595 
    8696protected: 
     
    145155  virtual void drawBranches(QPainter*, const QRect&, const QModelIndex&) const {} 
    146156 
     157  /** 
     158   * A timer event happened 
     159   * Overloaded as workaround for scrollTo() 
     160   * 
     161   * @param event Timer event 
     162   */ 
     163  virtual void timerEvent(QTimerEvent* event); 
     164 
    147165private slots: 
    148166  /** 
     
    155173private: 
    156174  bool midEvent; 
     175  bool myAllowScrollTo; 
    157176}; 
    158177