Changeset 6193
- Timestamp:
- 05/11/08 19:17:12 (7 months ago)
- Location:
- trunk/qt4-gui/src
- Files:
-
- 6 modified
-
config/contactlist.cpp (modified) (3 diffs)
-
config/contactlist.h (modified) (3 diffs)
-
settings/contactlist.cpp (modified) (4 diffs)
-
settings/contactlist.h (modified) (1 diff)
-
views/userviewbase.cpp (modified) (3 diffs)
-
views/userviewbase.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/qt4-gui/src/config/contactlist.cpp
r6191 r6193 63 63 iniFile.ReadBool("ScrollBar", myAllowScrollBar, true); 64 64 iniFile.ReadBool("SystemBackground", myUseSystemBackground, false); 65 iniFile.ReadBool("AutoScrolling", myAutoScroll, true);66 65 67 66 unsigned short flash; … … 129 128 iniFile.WriteBool("ScrollBar", myAllowScrollBar); 130 129 iniFile.WriteBool("SystemBackground", myUseSystemBackground); 131 iniFile.WriteBool("AutoScrolling", myAutoScroll);132 130 133 131 iniFile.WriteNum("NumColumns", myColumnCount); … … 313 311 } 314 312 315 void Config::ContactList::setAutoScroll(bool autoScroll)316 {317 myAutoScroll = autoScroll;318 }319 320 313 void Config::ContactList::setShowDividers(bool showDividers) 321 314 { -
trunk/qt4-gui/src/config/contactlist.h
r6191 r6193 110 110 bool allowScrollBar() const { return myAllowScrollBar; } 111 111 bool useSystemBackground() const { return myUseSystemBackground; } 112 bool autoScroll() const { return myAutoScroll; }113 112 114 113 bool popupPicture() const { return myPopupPicture; } … … 161 160 void setAllowScrollBar(bool allowScrollBar); 162 161 void setUseSystemBackground(bool useSystemBackground); 163 void setAutoScroll(bool autoScroll);164 162 165 163 void setPopupPicture(bool popupPicture); … … 242 240 bool myAllowScrollBar; 243 241 bool myUseSystemBackground; 244 bool myAutoScroll;245 242 246 243 // Contact list sorting -
trunk/qt4-gui/src/settings/contactlist.cpp
r6191 r6193 161 161 myBehaviourLayout->addWidget(myMainWinStickyCheck, 0, 1); 162 162 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 167 163 QHBoxLayout* mySortByLayout = new QHBoxLayout(); 168 164 mySortByLabel = new QLabel(tr("Additional sorting:")); … … 180 176 mySortByLabel->setBuddy(mySortByCombo); 181 177 mySortByLayout->addWidget(mySortByCombo); 182 myBehaviourLayout->addLayout(mySortByLayout, 2, 1);178 myBehaviourLayout->addLayout(mySortByLayout, 1, 1); 183 179 184 180 … … 351 347 myScrollBarCheck->setChecked(contactListConfig->allowScrollBar()); 352 348 mySysBackCheck->setChecked(contactListConfig->useSystemBackground()); 353 myAutoScrollCheck->setChecked(contactListConfig->autoScroll());354 349 355 350 int numColumns = contactListConfig->columnCount(); … … 424 419 contactListConfig->setAllowScrollBar(myScrollBarCheck->isChecked()); 425 420 contactListConfig->setUseSystemBackground(mySysBackCheck->isChecked()); 426 contactListConfig->setAutoScroll(myAutoScrollCheck->isChecked());427 421 428 422 for (unsigned short i = 0; i < MAX_COLUMNCOUNT; ++i) -
trunk/qt4-gui/src/settings/contactlist.h
r6191 r6193 90 90 QLineEdit* myFrameStyleEdit; 91 91 QComboBox* mySortByCombo; 92 QCheckBox* myAutoScrollCheck;93 92 QCheckBox* mySSListCheck; 94 93 QCheckBox* myGridLinesCheck; -
trunk/qt4-gui/src/views/userviewbase.cpp
r6191 r6193 47 47 UserViewBase::UserViewBase(ContactListModel* contactList, QWidget* parent) 48 48 : QTreeView(parent), 49 myContactList(contactList) 49 myContactList(contactList), 50 myAllowScrollTo(false) 50 51 { 51 52 setItemDelegate(new ContactDelegate(this, this)); … … 84 85 setPalette(pal); 85 86 } 86 }87 88 void UserViewBase::scrollTo(const QModelIndex& index, QAbstractItemView::ScrollHint hint)89 {90 if (Config::ContactList::instance()->autoScroll())91 QTreeView::scrollTo(index, hint);92 87 } 93 88 … … 330 325 } 331 326 } 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 -
trunk/qt4-gui/src/views/userviewbase.h
r6192 r6193 62 62 63 63 /** 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 65 66 * 66 * @param index Index of the itemto scroll to67 * @param hint Relative viewport position to maintain67 * @param index Index to scroll to 68 * @param hint Where to place the index 68 69 */ 69 70 virtual void scrollTo(const QModelIndex& index, ScrollHint hint = EnsureVisible); … … 83 84 */ 84 85 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); 85 95 86 96 protected: … … 145 155 virtual void drawBranches(QPainter*, const QRect&, const QModelIndex&) const {} 146 156 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 147 165 private slots: 148 166 /** … … 155 173 private: 156 174 bool midEvent; 175 bool myAllowScrollTo; 157 176 }; 158 177
