Commit 259677fe authored by Thomas McGuire's avatar Thomas McGuire
Browse files

SVN_MERGE:

Merged revisions 1149942,1150563 via svnmerge from 
svn+ssh://tmcguire@svn.kde.org/home/kde/branches/KDE/4.5/kdepimlibs

........
  r1149942 | tokoe | 2010-07-14 18:29:32 +0200 (Wed, 14 Jul 2010) | 6 lines
  
  - Use guards to do proper painter->save()/restore() calls
  - Set the right text color for unselected state
  
  No idea why suddenly the painter object passed into paint()
  has not the palette text color set on its pen object...
........
  r1150563 | tokoe | 2010-07-16 10:46:59 +0200 (Fri, 16 Jul 2010) | 2 lines
  
  Remove intermediate local fix, the real problem was oxygen which has been fixed now
........

svn path=/trunk/KDE/kdepimlibs/; revision=1152263
parent bc745ae1
......@@ -159,11 +159,30 @@ void CollectionStatisticsDelegate::initStyleOption( QStyleOptionViewItem *option
}
}
class PainterStateSaver
{
public:
PainterStateSaver( QPainter *painter )
{
mPainter = painter;
mPainter->save();
}
~PainterStateSaver()
{
mPainter->restore();
}
private:
QPainter *mPainter;
};
void CollectionStatisticsDelegate::paint( QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index ) const
{
Q_D( const CollectionStatisticsDelegate );
PainterStateSaver stateSaver( painter );
// First, paint the basic, but without the text. We remove the text
// in initStyleOption(), which gets called by QStyledItemDelegate::paint().
......@@ -186,7 +205,6 @@ void CollectionStatisticsDelegate::paint( QPainter *painter,
bool expanded = d->parent->isExpanded( firstColumn );
if ( option.state & QStyle::State_Selected ) {
painter->save();
painter->setPen( option.palette.highlightedText().color() );
}
......@@ -214,7 +232,7 @@ void CollectionStatisticsDelegate::paint( QPainter *painter,
unread = QString( QLatin1String( " (%1)" ) ).arg( unreadCount );
}
painter->save();
PainterStateSaver stateSaver( painter );
if ( !unread.isEmpty() ) {
QFont font = painter->font();
......@@ -245,11 +263,7 @@ void CollectionStatisticsDelegate::paint( QPainter *painter,
foreground( KColorScheme::LinkText ).color();
painter->setPen( unreadColor );
painter->drawText( unreadRect, Qt::AlignLeft, unread );
painter->restore();
if ( option.state & QStyle::State_Selected ) {
painter->restore();
}
return;
}
......@@ -257,7 +271,7 @@ void CollectionStatisticsDelegate::paint( QPainter *painter,
// is collapsed
if ( ( index.column() == 1 || index.column() == 2 ) ) {
painter->save();
PainterStateSaver stateSaver( painter );
QStyleOptionViewItem opt = option;
......@@ -277,19 +291,11 @@ void CollectionStatisticsDelegate::paint( QPainter *painter,
}
painter->drawText( textRect, Qt::AlignRight, sumText );
painter->restore();
if ( option.state & QStyle::State_Selected ) {
painter->restore();
}
return;
}
painter->drawText( textRect, option4.displayAlignment, text );
if ( option.state & QStyle::State_Selected ) {
painter->restore();
}
}
#include "collectionstatisticsdelegate.moc"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment