Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
DISCONTINUED:openSUSE:11.2:Update
qt3-devel-doc
rubberband.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File rubberband.diff of Package qt3-devel-doc
--- src/iconview/qiconview.cpp +++ src/iconview/qiconview.cpp @@ -261,6 +261,7 @@ QIconViewToolTip *toolTip; QPixmapCache maskCache; + QPixmap *backrubber; QPtrDict<QIconViewItem> selectedItems; struct ItemContainer { @@ -1975,14 +1976,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 ) @@ -2040,10 +2054,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 ) @@ -2059,31 +2082,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())); - } } /*! @@ -2781,6 +2786,7 @@ d->renamingItem = 0; d->drawActiveSelection = TRUE; d->drawDragShapes = FALSE; + d->backrubber = 0; connect( d->adjustTimer, SIGNAL( timeout() ), this, SLOT( adjustItems() ) ); @@ -3265,7 +3271,7 @@ void QIconView::doAutoScroll() { - QRect oldRubber = QRect( *d->rubber ); + QRect oldRubber = *d->rubber; QPoint vp = viewport()->mapFromGlobal( QCursor::pos() ); QPoint pos = viewportToContents( vp ); @@ -3282,7 +3288,6 @@ bool block = signalsBlocked(); QRect rr; - QRegion region( 0, 0, visibleWidth(), visibleHeight() ); blockSignals( TRUE ); viewport()->setUpdatesEnabled( FALSE ); @@ -3308,9 +3313,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 ); @@ -3327,42 +3329,77 @@ 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 ) && @@ -3389,9 +3426,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; @@ -3465,8 +3500,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(); + } } /*! @@ -4365,17 +4408,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() ) ); @@ -4560,21 +4601,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 ) @@ -5334,9 +5371,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()) ); } /*!
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor