Sophie

Sophie

distrib > Mandriva > cs4.0 > i586 > by-pkgid > 6db27311da393084cc6f2b414a3b666f > files > 17

qt3-3.3.6-1.1.20060mlcs4.src.rpm

--- src/iconview/qiconview.cpp
+++ src/iconview/qiconview.cpp
@@ -261,6 +261,7 @@
 
     QIconViewToolTip *toolTip;
     QPixmapCache maskCache;
+    QPixmap *backrubber;    
     QPtrDict<QIconViewItem> selectedItems;
 
     struct ItemContainer {
@@ -1974,14 +1975,27 @@
     if ( picture() ) {
 	QPicture *pic = picture();
 	if ( isSelected() ) {
-	    p->fillRect( pixmapRect( FALSE ), QBrush( cg.highlight(), QBrush::Dense4Pattern) );
+            p->setBrush( QBrush( cg.highlight(), QBrush::Dense4Pattern ) );
+            p->setPen( QPen( cg.highlight(), QBrush::Dense4Pattern ) );
+            p->drawRoundRect( pixmapRect( FALSE ), 
+			    1000 / pixmapRect( FALSE ).width(),
+			    1000 / pixmapRect( FALSE ).height() );		
 	}
 	p->drawPicture( x()-pic->boundingRect().x(), y()-pic->boundingRect().y(), *pic );
 	if ( isSelected() ) {
-	    p->fillRect( textRect( FALSE ), cg.highlight() );
+            p->setBrush( QBrush( cg.highlight() ) );
+            p->setPen( QPen( cg.highlight() ) );
+            p->drawRoundRect( textRect( FALSE ), 
+			    1000 / textRect( FALSE ).width(),
+			    1000 / textRect( FALSE ).height() );		
 	    p->setPen( QPen( cg.highlightedText() ) );
-	} else if ( view->d->itemTextBrush != NoBrush )
-	    p->fillRect( textRect( FALSE ), view->d->itemTextBrush );
+	} else if ( view->d->itemTextBrush != NoBrush ) {
+            p->setBrush( view->d->itemTextBrush );
+            p->setPen( QPen( view->d->itemTextBrush.color() ) );
+            p->drawRoundRect( textRect( FALSE ), 
+			    1000 / textRect( FALSE ).width(),
+			    1000 / textRect( FALSE ).height() );		
+	}
 
 	int align = view->itemTextPos() == QIconView::Bottom ? AlignHCenter : AlignAuto;
 	if ( view->d->wordWrapIconText )
@@ -2039,10 +2053,19 @@
 
     p->save();
     if ( isSelected() ) {
-	p->fillRect( textRect( FALSE ), cg.highlight() );
+        p->setBrush( QBrush( cg.highlight() ) );
+        p->setPen( QPen( cg.highlight() ) );
+        p->drawRoundRect( textRect( FALSE ), 
+                          1000 / textRect( FALSE ).width(),
+			  1000 / textRect( FALSE ).height() );		
 	p->setPen( QPen( cg.highlightedText() ) );
-    } else if ( view->d->itemTextBrush != NoBrush )
-	p->fillRect( textRect( FALSE ), view->d->itemTextBrush );
+    } else if ( view->d->itemTextBrush != NoBrush ) {
+        p->setBrush( view->d->itemTextBrush );
+        p->setPen( QPen( view->d->itemTextBrush.color() ) );
+        p->drawRoundRect( textRect( FALSE ), 
+			  1000 / textRect( FALSE ).width(),
+			  1000 / textRect( FALSE ).height() );		
+    }
 
     int align = AlignHCenter;
     if ( view->d->wordWrapIconText )
@@ -2058,31 +2081,13 @@
 /*!
     Paints the focus rectangle of the item using the painter \a p and
     the color group \a cg.
+    
+    The default implementation does nothing; subclasses may
+    reimplement this function.
 */
 
-void QIconViewItem::paintFocus( QPainter *p, const QColorGroup &cg )
+void QIconViewItem::paintFocus( QPainter *, const QColorGroup & )
 {
-    if ( !view )
-	return;
-
-    view->style().drawPrimitive(QStyle::PE_FocusRect, p,
-				QRect( textRect( FALSE ).x(), textRect( FALSE ).y(),
-				       textRect( FALSE ).width(),
-				       textRect( FALSE ).height() ), cg,
-				(isSelected() ?
-				 QStyle::Style_FocusAtBorder :
-				 QStyle::Style_Default),
-				QStyleOption(isSelected() ? cg.highlight() : cg.base()));
-
-    if ( this != view->d->currentItem ) {
-	view->style().drawPrimitive(QStyle::PE_FocusRect, p,
-				    QRect( pixmapRect( FALSE ).x(),
-					   pixmapRect( FALSE ).y(),
-					   pixmapRect( FALSE ).width(),
-					   pixmapRect( FALSE ).height() ),
-				    cg, QStyle::Style_Default,
-				    QStyleOption(cg.base()));
-    }
 }
 
 /*!
@@ -2780,6 +2785,7 @@
     d->renamingItem = 0;
     d->drawActiveSelection = TRUE;
     d->drawDragShapes = FALSE;
+    d->backrubber = 0;    
 
     connect( d->adjustTimer, SIGNAL( timeout() ),
 	     this, SLOT( adjustItems() ) );
@@ -3264,7 +3270,7 @@
 
 void QIconView::doAutoScroll()
 {
-    QRect oldRubber = QRect( *d->rubber );
+    QRect oldRubber = *d->rubber;
 
     QPoint vp = viewport()->mapFromGlobal( QCursor::pos() );
     QPoint pos = viewportToContents( vp );
@@ -3281,7 +3287,6 @@
     bool block = signalsBlocked();
 
     QRect rr;
-    QRegion region( 0, 0, visibleWidth(), visibleHeight() );
 
     blockSignals( TRUE );
     viewport()->setUpdatesEnabled( FALSE );
@@ -3307,9 +3312,6 @@
 			item->setSelected( TRUE, TRUE );
 			changed = TRUE;
 			rr = rr.unite( item->rect() );
-		    } else {
-			region = region.subtract( QRect( contentsToViewport( item->pos() ),
-							 item->size() ) );
 		    }
 
 		    minx = QMIN( minx, item->x() - 1 );
@@ -3326,42 +3328,76 @@
     viewport()->setUpdatesEnabled( TRUE );
     blockSignals( block );
 
-    QRect r = *d->rubber;
-    *d->rubber = oldRubber;
-
-    QPainter p;
-    p.begin( viewport() );
-    p.setRasterOp( NotROP );
-    p.setPen( QPen( color0, 1 ) );
-    p.setBrush( NoBrush );
-    drawRubber( &p );
-    d->dragging = FALSE;
-    p.end();
-
-    *d->rubber = r;
-
-    if ( changed ) {
-	d->drawAllBack = FALSE;
-	d->clipRegion = region;
-	repaintContents( rr, FALSE );
-	d->drawAllBack = TRUE;
+    // static bool drawAll;
+    if ( d->backrubber == 0 ) {
+        d->backrubber = new QPixmap( viewport()->rect().size() );
+        d->backrubber->fill( viewport(), viewport()->rect().topLeft() );
+        // drawAll = true;
     }
 
+    // int oldX = 0, oldY = 0;
+    // if ( !drawAll && d->scrollTimer ) {
+    //     oldX = contentsX();
+    //     oldY = contentsY();
+    // }
     ensureVisible( pos.x(), pos.y() );
+    // if ( !drawAll && d->scrollTimer && ( oldX != contentsX() || oldY != contentsY() ) )
+    //     drawAll = true;
 
-    p.begin( viewport() );
-    p.setRasterOp( NotROP );
-    p.setPen( QPen( color0, 1 ) );
-    p.setBrush( NoBrush );
-    drawRubber( &p );
-    d->dragging = TRUE;
+    QRect allRect = oldRubber.normalize();
+    if ( changed ) 
+        allRect |= rr.normalize();
+    allRect |= d->rubber->normalize();
+    QPoint point = contentsToViewport( allRect.topLeft() );
+    allRect = QRect( point.x(), point.y(), allRect.width(), allRect.height() );
+    allRect &= viewport()->rect();
+
+    d->dragging = FALSE;
+
+    QPainter p( d->backrubber );
+    p.translate( -contentsX(), -contentsY() );
+#if 0
+    if ( !drawAll ) {
+        oldRubber = oldRubber.normalize();
+        point = contentsToViewport( oldRubber.topLeft() );
+        oldRubber = QRect( point.x(), point.y(), oldRubber.width(), oldRubber.height() );
+        oldRubber &= viewport()->rect();
+
+        point = contentsToViewport( nr.topLeft() );
+        nr = QRect( point.x(), point.y(), nr.width(), nr.height() );
+        nr &= viewport()->rect();
+
+	QRegion region;
+	if ( allRect != nr )
+            region = QRegion(allRect).subtract( QRegion( nr ) );
+	if ( allRect != oldRubber )
+            region += QRegion(allRect).subtract( QRegion( oldRubber ) );
+
+	QMemArray< QRect > ar = region.rects();
+	for ( uint i = 0; i < ar.size(); ++i ) {
+             ar[i].addCoords( -2, -2, 4, 4 );
+             ar[i] = ar[i].normalize();
+	
+             p.setClipRect( ar[i] );
+             drawContents( &p, contentsX() + ar[i].left(), contentsY() + ar[i].top(), ar[i].width(), ar[i].height() );
+	}
+    }
+    else
+#endif
+    {	    
+        drawContents( &p, 
+                      contentsX() + allRect.left(), contentsY() + allRect.top(), 
+                      allRect.width(), allRect.height() ); 
+    }
 
     p.end();
+    // drawAll = false;
+    d->dragging = TRUE;
+    bitBlt( viewport(), allRect.topLeft(), d->backrubber, allRect );
 
     if ( changed ) {
-	emit selectionChanged();
-	if ( d->selectionMode == Single )
-	    emit selectionChanged( d->currentItem );
+        if ( d->selectionMode == Single )
+            emit selectionChanged( d->currentItem );
     }
 
     if ( !QRect( 50, 50, viewport()->width()-100, viewport()->height()-100 ).contains( vp ) &&
@@ -3388,9 +3424,7 @@
 
 void QIconView::drawContents( QPainter *p, int cx, int cy, int cw, int ch )
 {
-    if ( d->dragging && d->rubber )
-	drawRubber( p );
-
+    p->save();
     QRect r = QRect( cx, cy, cw, ch );
 
     QIconViewPrivate::ItemContainer *c = d->firstContainer;
@@ -3464,8 +3498,16 @@
 	d->currentItem->paintFocus( p, colorGroup() );
     }
 
-    if ( d->dragging && d->rubber )
-	drawRubber( p );
+   p->restore();
+   if ( d->rubber ) {
+       p->save();              
+       p->translate( contentsX(), contentsY() );
+       p->setRasterOp( NotROP );
+       p->setPen( QPen( color0, 1 ) );
+       p->setBrush( NoBrush );        
+       drawRubber( p );
+       p->restore();
+    }
 }
 
 /*!
@@ -4364,17 +4406,15 @@
 void QIconView::contentsMousePressEventEx( QMouseEvent *e )
 {
     if ( d->rubber ) {
-	QPainter p;
-	p.begin( viewport() );
-	p.setRasterOp( NotROP );
-	p.setPen( QPen( color0, 1 ) );
-	p.setBrush( NoBrush );
+        QRect r( d->rubber->normalize() );
+        delete d->rubber;
+        d->rubber = 0;  
+   
+        repaintContents( r, FALSE );
+        d->dragging = FALSE;
 
-	drawRubber( &p );
-	d->dragging = FALSE;
-	p.end();
-	delete d->rubber;
-	d->rubber = 0;
+	delete d->backrubber;
+	d->backrubber = 0;
 
 	if ( d->scrollTimer ) {
 	    disconnect( d->scrollTimer, SIGNAL( timeout() ), this, SLOT( doAutoScroll() ) );
@@ -4559,21 +4599,17 @@
     d->startDragItem = 0;
 
     if ( d->rubber ) {
-	QPainter p;
-	p.begin( viewport() );
-	p.setRasterOp( NotROP );
-	p.setPen( QPen( color0, 1 ) );
-	p.setBrush( NoBrush );
-
-	drawRubber( &p );
-	d->dragging = FALSE;
-	p.end();
-
+        QRect r(d->rubber->normalize());
+        
 	if ( ( d->rubber->topLeft() - d->rubber->bottomRight() ).manhattanLength() >
 	     QApplication::startDragDistance() )
 	    emitClicked = FALSE;
 	delete d->rubber;
-	d->rubber = 0;
+    	d->rubber = 0;
+	repaintContents(r, FALSE);
+	d->dragging = FALSE;
+	delete d->backrubber;
+	d->backrubber = 0;      
 	d->currentItem = d->tmpCurrentItem;
 	d->tmpCurrentItem = 0;
 	if ( d->currentItem )
@@ -5333,9 +5369,9 @@
     QPoint pnt( d->rubber->x(), d->rubber->y() );
     pnt = contentsToViewport( pnt );
 
-    style().drawPrimitive(QStyle::PE_RubberBand, p,
-			  QRect(pnt.x(), pnt.y(), d->rubber->width(), d->rubber->height()),
-			  colorGroup(), QStyle::Style_Default, QStyleOption(colorGroup().base()));
+    style().drawPrimitive( QStyle::PE_RubberBand, p,
+			   QRect( pnt.x(), pnt.y(), d->rubber->width(), d->rubber->height() ).normalize(),
+			   colorGroup(), QStyle::Style_Default, QStyleOption(colorGroup().base()) );
 }
 
 /*!
--- src/widgets/qlistbox.cpp
+++ src/widgets/qlistbox.cpp
@@ -2163,7 +2163,7 @@
     }
 
     if ( d->rubber ) {
-	drawRubber();
+	repaintContents( d->rubber->normalize(), FALSE );
 	delete d->rubber;
 	d->rubber = 0;
 	d->current = d->tmpCurrent;
@@ -2241,11 +2241,9 @@
     }
 
     if ( d->rubber ) {
-	QRect r = d->rubber->normalize();
-	drawRubber();
+    	QRect r = d->rubber->normalize();
 	d->rubber->setCoords( d->rubber->x(), d->rubber->y(), e->x(), e->y() );
 	doRubberSelection( r, d->rubber->normalize() );
-	drawRubber();
 	return;
     }
 
@@ -4386,6 +4384,7 @@
 	return;
     if ( !d->rubber->width() && !d->rubber->height() )
 	return;
+ 
     QPainter p( viewport() );
     p.setRasterOp( NotROP );
     style().drawPrimitive( QStyle::PE_RubberBand, &p, d->rubber->normalize(),
@@ -4418,13 +4417,24 @@
 	    }
 	}
     }
+
+    QRect allRect = old;
+    if ( changed ) {
+        allRect |= pr;
+    }    
+    allRect |= rubber;
+    allRect &= viewport()->rect();
+    allRect.addCoords( -2, -2, 2, 2 );
+
+    repaintContents( QRect( contentsX() + allRect.left(), contentsY() + allRect.top(), allRect.width(), allRect.height() ), FALSE ); 
+    drawRubber();
+    
     if ( changed ) {
 	emit selectionChanged();
 #if defined(QT_ACCESSIBILITY_SUPPORT)
 	QAccessible::updateAccessibility( viewport(), 0, QAccessible::Selection );
 #endif
     }
-    viewport()->repaint( pr, TRUE );
 }