From 0dca8c2abd52150f44d200893e502cc58c6cf63a Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Thu, 20 Dec 2012 11:27:10 +0100 Subject: [PATCH] * PlaylistLargeItemDelegate now properly inherits from standard PlaylistItemDelegate. --- .../playlist/PlaylistLargeItemDelegate.cpp | 26 +++---------------- .../playlist/PlaylistLargeItemDelegate.h | 14 ++++------ 2 files changed, 8 insertions(+), 32 deletions(-) diff --git a/src/libtomahawk/playlist/PlaylistLargeItemDelegate.cpp b/src/libtomahawk/playlist/PlaylistLargeItemDelegate.cpp index 5efef5f3e..1c1a92f05 100644 --- a/src/libtomahawk/playlist/PlaylistLargeItemDelegate.cpp +++ b/src/libtomahawk/playlist/PlaylistLargeItemDelegate.cpp @@ -44,7 +44,7 @@ using namespace Tomahawk; PlaylistLargeItemDelegate::PlaylistLargeItemDelegate( DisplayMode mode, TrackView* parent, PlayableProxyModel* proxy ) - : QStyledItemDelegate( (QObject*)parent ) + : PlaylistItemDelegate( parent, proxy ) , m_view( parent ) , m_model( proxy ) , m_mode( mode ) @@ -58,9 +58,8 @@ PlaylistLargeItemDelegate::PlaylistLargeItemDelegate( DisplayMode mode, TrackVie m_bottomOption = QTextOption( Qt::AlignBottom ); m_bottomOption.setWrapMode( QTextOption::NoWrap ); - connect( proxy, SIGNAL( modelReset() ), this, SLOT( modelChanged() ) ); - if ( PlaylistView* plView = qobject_cast< PlaylistView* >( parent ) ) - connect( plView, SIGNAL( modelChanged() ), this, SLOT( modelChanged() ) ); + connect( proxy, SIGNAL( modelReset() ), SLOT( modelChanged() ) ); + connect( parent, SIGNAL( modelChanged() ), SLOT( modelChanged() ) ); } @@ -79,25 +78,6 @@ PlaylistLargeItemDelegate::sizeHint( const QStyleOptionViewItem& option, const Q } -QWidget* -PlaylistLargeItemDelegate::createEditor( QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index ) const -{ - Q_UNUSED( parent ); - Q_UNUSED( option ); - Q_UNUSED( index ); - return 0; -} - - -void -PlaylistLargeItemDelegate::prepareStyleOption( QStyleOptionViewItemV4* option, const QModelIndex& index, PlayableItem* item ) const -{ - initStyleOption( option, index ); - - TomahawkUtils::prepareStyleOption( option, index, item ); -} - - void PlaylistLargeItemDelegate::drawRichText( QPainter* painter, const QStyleOptionViewItem& option, const QRect& rect, int flags, QTextDocument& text ) const { diff --git a/src/libtomahawk/playlist/PlaylistLargeItemDelegate.h b/src/libtomahawk/playlist/PlaylistLargeItemDelegate.h index 9fed77936..eb6cf7e54 100644 --- a/src/libtomahawk/playlist/PlaylistLargeItemDelegate.h +++ b/src/libtomahawk/playlist/PlaylistLargeItemDelegate.h @@ -23,6 +23,7 @@ #include #include +#include "PlaylistItemDelegate.h" #include "DllMacro.h" #include "Typedefs.h" @@ -30,12 +31,11 @@ namespace Tomahawk { class PixmapDelegateFader; } -class TrackModel; class PlayableItem; class PlayableProxyModel; class TrackView; -class DLLEXPORT PlaylistLargeItemDelegate : public QStyledItemDelegate +class DLLEXPORT PlaylistLargeItemDelegate : public PlaylistItemDelegate { Q_OBJECT @@ -45,20 +45,16 @@ public: PlaylistLargeItemDelegate( DisplayMode mode, TrackView* parent = 0, PlayableProxyModel* proxy = 0 ); + virtual QSize sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const; + protected: void paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const; - QSize sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const; - QWidget* createEditor( QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index ) const; - -signals: - void updateIndex( const QModelIndex& idx ); private slots: - void modelChanged(); void doUpdateIndex( const QPersistentModelIndex& idx ); + void modelChanged(); private: - void prepareStyleOption( QStyleOptionViewItemV4* option, const QModelIndex& index, PlayableItem* item ) const; void drawRichText( QPainter* painter, const QStyleOptionViewItem& option, const QRect& rect, int flags, QTextDocument& text ) const; QTextOption m_topOption;