$OpenBSD: patch-src_widgets_qlistview_cpp,v 1.1 2004/01/08 01:23:57 brad Exp $
--- src/widgets/qlistview.cpp.orig	2003-12-29 04:39:39.000000000 -0500
+++ src/widgets/qlistview.cpp	2003-12-29 04:59:41.000000000 -0500
@@ -2012,7 +2012,7 @@ void QListViewItem::paintCell( QPainter 
 	    ci->truncated = FALSE;
 	    // if we have to do the ellipsis thingy calc the truncated text
 	    int pw = pixmap( column ) ? pixmap( column )->width() + lv->itemMargin() : lv->itemMargin();
-	    if ( !mlenabled && fm.width( t ) + pw > width ) {
+	    if ( !mlenabled && this->width( fm, lv, column ) > width ) {
 		// take care of arabic shaping in width calculation (lars)
 		ci->truncated = TRUE;
 		ci->tmpText = "...";
@@ -2849,7 +2849,7 @@ void QListView::drawContentsOffset( QPai
 	int cs;
 
 	// need to paint current?
-	if ( ih > 0 && current->y < cy+ch && current->y+ih >= cy ) {
+	if ( ih > 0 && current->y < cy+ch && current->y+ih > cy ) {
 	    if ( fx < 0 ) {
 		// find first interesting column, once
 		x = 0;
@@ -4974,10 +4974,10 @@ void QListView::keyPressEvent( QKeyEvent
 		QString keyItemKey;
 		QString prefix;
 		while( keyItem ) {
-		    // Look for text in column 0, then left-to-right
-		    keyItemKey = keyItem->text(0);
-		    for (int col = 0; col < d->h->count() && !keyItemKey; col++ )
-			keyItemKey = keyItem->text( d->h->mapToLogical(col) );
+		    // Look first in the sort column, then the leftmost column, then left to right
+		    keyItemKey = keyItem->text( d->sortcolumn );
+		    for ( int col = 0; col < d->h->count() && !keyItemKey; col++ )
+			keyItemKey = keyItem->text( d->h->mapToSection(col) );
 		    if ( !keyItemKey.isEmpty() ) {
 			prefix = keyItemKey;
 			prefix.truncate( input.length() );
@@ -7772,7 +7772,7 @@ void QListView::handleItemChange( QListV
     } else if ( d->selectionMode == Extended ) {
 	if ( shift ) {
 	    selectRange( d->selectAnchor ? d->selectAnchor : old,
-			 d->focusItem, FALSE, TRUE, d->selectAnchor ? TRUE : FALSE );
+			 d->focusItem, FALSE, TRUE, d->selectAnchor && !control ? TRUE : FALSE );
 	} else if ( !control ) {
 	    bool block = signalsBlocked();
 	    blockSignals( TRUE );
@@ -8049,15 +8049,14 @@ void QListView::adjustColumn( int col )
 	w += d->h->iconSet( col )->pixmap().width();
     w = QMAX( w, 20 );
     QFontMetrics fm( fontMetrics() );
-    QListViewItemIterator it( this );
+    QListViewItem* item = firstChild();
     int rootDepth = rootIsDecorated() ? treeStepSize() : 0;
-    while ( it.current() ) {
-	QListViewItem *item = it.current();
-	++it;
+    while ( item ) {
 	int iw = item->width( fm, this, col );
 	if ( 0 == col )
 	    iw += itemMargin() + rootDepth + item->depth()*treeStepSize() - 1;
 	w = QMAX( w, iw );
+	item = item->itemBelow();
     }
     w = QMAX( w, QApplication::globalStrut().width() );
 
