[Amarok] 4b08fa4 Use QStyle primitives to draw the expanders.
Bart Cerneels
bart.cerneels at kde.org
Sat Apr 10 16:33:04 CEST 2010
commit 4b08fa4028a31da58ea7a3b34fad63b875bd7ad6
Author: Bart Cerneels <bart.cerneels at kde.org>
Date: Sat Apr 10 15:57:59 2010 +0200
Use QStyle primitives to draw the expanders.
The green expanders on the root items in CB, User Playlists and Podcasts were a quick hack. I'm attemting to use the active QStyle now.
First attempt: using PE_IndicatorBranch
Another option is to use PE_IndicatorArrowRight and PE_IndicatorArrowDown (when expanded) though this is not sure to look good with alternative styles.
If this is OK I'll port this indicator style to the CollectionTreeItemDelegate.
CCMAIL:amarok-devel at kde.org
diff --git a/src/browsers/playlistbrowser/PlaylistTreeItemDelegate.cpp b/src/browsers/playlistbrowser/PlaylistTreeItemDelegate.cpp
index f220514..eaeaeaf 100644
--- a/src/browsers/playlistbrowser/PlaylistTreeItemDelegate.cpp
+++ b/src/browsers/playlistbrowser/PlaylistTreeItemDelegate.cpp
@@ -91,14 +91,23 @@ PlaylistTreeItemDelegate::paint( QPainter *painter, const QStyleOptionViewItem &
index.data( Qt::DecorationRole )
.value<QIcon>().pixmap( iconWidth, iconHeight ) );
- QPoint expanderPos( bottomRight - QPoint( iconPadX, iconPadX ) -
- QPoint( iconWidth/2, iconHeight/2 ) );
+ QStyleOption expanderOption( option );
if( isRTL )
- expanderPos.setX( iconPadX );
- QPixmap expander = KIcon( "arrow-up" ).pixmap( iconWidth/2, iconHeight/2 );
+ expanderOption.rect.setLeft( iconPadX );
+ else
+ expanderOption.rect.setLeft( option.rect.right() - iconPadX - iconWidth );
+
+ expanderOption.rect.setWidth( iconWidth );
+ if( m_view->model()->hasChildren( index ) )
+ expanderOption.state |= QStyle::State_Children;
if( m_view->isExpanded( index ) )
- expander = expander.transformed( QTransform().rotate( 180 ) );
- painter->drawPixmap( expanderPos, expander );
+ {
+ expanderOption.state |= QStyle::State_Open;
+ //when expanded the sibling indicator (a vertical line down) goes nowhere
+ expanderOption.state &= ~QStyle::State_Sibling;
+ }
+
+ QApplication::style()->drawPrimitive( QStyle::PE_IndicatorBranch, &expanderOption, painter );
const QString collectionName = index.data( Qt::DisplayRole ).toString();
const QString bylineText = index.data(
More information about the Amarok-devel
mailing list