Changeset 2921 for vidalia/trunk

Show
Ignore:
Timestamp:
08/02/08 20:35:46 (4 months ago)
Author:
edmanm
Message:

Rework the message log scrollbar logic so it's consistent again on Qt 4.4.0.
Fixes ticket #369.

Location:
vidalia/trunk/src/vidalia/log
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • vidalia/trunk/src/vidalia/log/logtreewidget.cpp

    r2362 r2921  
    2929  /* Default to always scrolling to the most recent item added */ 
    3030  _scrollOnNewItem = true; 
    31   connect(verticalScrollBar(), SIGNAL(valueChanged(int)), 
    32           this, SLOT(onVerticalScroll(int))); 
     31  setVerticalScrollMode(QAbstractItemView::ScrollPerItem); 
     32  connect(verticalScrollBar(), SIGNAL(sliderReleased()), 
     33          this, SLOT(verticalSliderReleased())); 
    3334} 
    3435 
     
    3839 * probably looking at something in their history. */ 
    3940void 
    40 LogTreeWidget::onVerticalScroll(int value) 
    41 { 
    42   QScrollBar *scrollbar = verticalScrollBar(); 
    43   _scrollOnNewItem = (value >= (scrollbar->maximum()-scrollbar->singleStep())); 
     41LogTreeWidget::verticalSliderReleased() 
     42{ 
     43  QScrollBar *scrollBar = verticalScrollBar(); 
     44  if (header()->sortIndicatorOrder() == Qt::AscendingOrder) 
     45    _scrollOnNewItem = (scrollBar->value() == scrollBar->maximum()); 
     46  else 
     47    _scrollOnNewItem = (scrollBar->value() == scrollBar->minimum()); 
    4448} 
    4549 
     
    183187  } 
    184188   
    185   /* Add the new message item and scroll to it (if necessary) */ 
     189  /* Add the new message item and scroll to it (if necessary)  
     190   * NOTE: We disable sorting, add the new item, and then re-enable sorting 
     191   *       to force the result to be sorted immediately. Otherwise, the new 
     192   *       message is not sorted until the message log has focus again. 
     193   */ 
     194  setSortingEnabled(false);  
    186195  addMessageItem(item); 
     196  setSortingEnabled(true); 
     197 
    187198  if (_scrollOnNewItem) { 
    188     scrollToItem(item); 
    189   } 
     199    QScrollBar *scrollBar = verticalScrollBar(); 
     200    if (header()->sortIndicatorOrder() == Qt::AscendingOrder) 
     201      scrollBar->setValue(scrollBar->maximum()); 
     202    else 
     203      scrollBar->setValue(scrollBar->minimum()); 
     204  } 
     205 
    190206  return item; 
    191207} 
  • vidalia/trunk/src/vidalia/log/logtreewidget.h

    r2362 r2921  
    7777private slots: 
    7878  /** Called when the user moves the vertical scroll bar. */ 
    79   void onVerticalScroll(int value); 
     79  void verticalSliderReleased(); 
    8080 
    8181private: