Manually calculate viewport update rect on header hover change

BUG: 340343
wilder-pre-rebase
Hugo Pereira Da Costa 11 years ago
parent aa076fd512
commit 59a34fe4e4
  1. 30
      kstyle/animations/breezeheaderviewdata.cpp
  2. 16
      kstyle/animations/breezeheaderviewdata.h

@ -47,6 +47,7 @@
#include "breezeheaderviewdata.moc"
#include <QHoverEvent>
#include <QTextStream>
namespace Breeze
{
@ -56,8 +57,6 @@ namespace Breeze
AnimationData( parent, target )
{
target->installEventFilter( this );
_current._animation = new Animation( duration, this );
setupAnimation( currentIndexAnimation(), "currentOpacity" );
currentIndexAnimation().data()->setDirection( Animation::Forward );
@ -77,7 +76,7 @@ namespace Breeze
const QHeaderView* local( qobject_cast<const QHeaderView*>( target().data() ) );
if( !local ) return false;
int index( local->logicalIndexAt( position ) );
const int index( local->logicalIndexAt( position ) );
if( index < 0 ) return false;
if( hovered )
@ -146,4 +145,29 @@ namespace Breeze
}
//__________________________________________________________
void HeaderViewData::setDirty( void ) const
{
QHeaderView* header = qobject_cast<QHeaderView*>( target().data() );
if( !header ) return;
// get first and last index, sorted
const int lastIndex( qMax( previousIndex(), currentIndex() ) );
if( lastIndex < 0 ) return;
int firstIndex( qMin( previousIndex(), currentIndex() ) );
if( firstIndex < 0 ) firstIndex = lastIndex;
// find relevant rectangle to be updated, in viewport coordinate
QWidget* viewport( header->viewport() );
const int left = header->sectionViewportPosition( firstIndex );
const int right = header->sectionViewportPosition( lastIndex ) + header->sectionSize( lastIndex );
// trigger update
if( header->orientation() == Qt::Horizontal ) viewport->update( left, 0, right-left, header->height() );
else viewport->update( 0, left, header->width(), right-left );
}
}

@ -124,7 +124,7 @@ namespace Breeze
protected:
//* dirty
inline virtual void setDirty( void ) const;
virtual void setDirty( void ) const;
private:
@ -152,20 +152,6 @@ namespace Breeze
};
//__________________________________________________________
void HeaderViewData::setDirty( void ) const
{
if( QHeaderView* header = qobject_cast<QHeaderView*>( target().data() ) )
{
const int firstIndex( qMin( previousIndex(), currentIndex() ) );
const int lastIndex( qMax( previousIndex(), currentIndex() ) );
if( firstIndex >= 0 ) header->headerDataChanged( header->orientation(), firstIndex, lastIndex );
else if( lastIndex >= 0 ) header->headerDataChanged( header->orientation(), lastIndex, lastIndex );
}
}
}
#endif

Loading…
Cancel
Save