diff --git a/src/libtomahawk/playlist/dynamic/DynamicPlaylist.h b/src/libtomahawk/playlist/dynamic/DynamicPlaylist.h index 63e29e9fe..35ed57ed9 100644 --- a/src/libtomahawk/playlist/dynamic/DynamicPlaylist.h +++ b/src/libtomahawk/playlist/dynamic/DynamicPlaylist.h @@ -219,4 +219,6 @@ private: }; // namespace +Q_DECLARE_METATYPE( QSharedPointer< Tomahawk::DynamicPlaylist > ) + #endif diff --git a/src/libtomahawk/playlist/dynamic/widgets/DynamicWidget.cpp b/src/libtomahawk/playlist/dynamic/widgets/DynamicWidget.cpp index 9fa4d0e24..23cfa14a9 100644 --- a/src/libtomahawk/playlist/dynamic/widgets/DynamicWidget.cpp +++ b/src/libtomahawk/playlist/dynamic/widgets/DynamicWidget.cpp @@ -427,6 +427,17 @@ DynamicWidget::paintRoundedFilledRect( QPainter& p, QPalette& pal, QRect& r, qre p.drawRoundedRect( r, 10, 10 ); } +QPixmap +DynamicWidget::pixmap() const +{ + if ( m_playlist->mode() == OnDemand ) + return QPixmap( RESPATH "images/station.png" ); + else if ( m_playlist->mode() == Static ) + return QPixmap( RESPATH "images/automatic-playlist.png" ); + else + return QPixmap(); +} + bool DynamicWidget::jumpToCurrentTrack() diff --git a/src/libtomahawk/playlist/dynamic/widgets/DynamicWidget.h b/src/libtomahawk/playlist/dynamic/widgets/DynamicWidget.h index 31f1040a3..26f61baae 100644 --- a/src/libtomahawk/playlist/dynamic/widgets/DynamicWidget.h +++ b/src/libtomahawk/playlist/dynamic/widgets/DynamicWidget.h @@ -77,7 +77,7 @@ public: virtual QString title() const { return m_model->title(); } virtual QString description() const { return m_model->description(); } - virtual QPixmap pixmap() const { return QPixmap( RESPATH "images/playlist-icon.png" ); } + virtual QPixmap pixmap() const; virtual bool jumpToCurrentTrack(); diff --git a/src/libtomahawk/widgets/welcomeplaylistmodel.cpp b/src/libtomahawk/widgets/welcomeplaylistmodel.cpp index fe855885c..e2946fc27 100644 --- a/src/libtomahawk/widgets/welcomeplaylistmodel.cpp +++ b/src/libtomahawk/widgets/welcomeplaylistmodel.cpp @@ -110,8 +110,32 @@ WelcomePlaylistModel::data( const QModelIndex& index, int role ) const return m_artists[pl]; } + case PlaylistTypeRole: + { + if ( !pl.dynamicCast< Tomahawk::DynamicPlaylist >().isNull() ) + { + dynplaylist_ptr dynp = pl.dynamicCast< Tomahawk::DynamicPlaylist >(); + if ( dynp->mode() == Static ) + return AutoPlaylist; + else if ( dynp->mode() == OnDemand ) + return Station; + } else + { + return StaticPlaylist; + } + } + case DynamicPlaylistRole: + { + dynplaylist_ptr dynp = pl.dynamicCast< Tomahawk::DynamicPlaylist >(); + return QVariant::fromValue< Tomahawk::dynplaylist_ptr >( dynp ); + } case TrackCountRole: - return pl->entries().count(); + { + if ( !pl.dynamicCast< Tomahawk::DynamicPlaylist >().isNull() ) + return QString( QChar( 0x221E ) ); + else + return pl->entries().count(); + } default: return QVariant(); } diff --git a/src/libtomahawk/widgets/welcomeplaylistmodel.h b/src/libtomahawk/widgets/welcomeplaylistmodel.h index b979dfc95..ef075510b 100644 --- a/src/libtomahawk/widgets/welcomeplaylistmodel.h +++ b/src/libtomahawk/widgets/welcomeplaylistmodel.h @@ -30,7 +30,9 @@ class WelcomePlaylistModel : public QAbstractListModel Q_OBJECT public: enum ItemRoles - { ArtistRole = Qt::UserRole, TrackCountRole, PlaylistRole }; + { ArtistRole = Qt::UserRole, TrackCountRole, PlaylistRole, PlaylistTypeRole, DynamicPlaylistRole }; + enum PlaylistTypes + { StaticPlaylist, AutoPlaylist, Station }; explicit WelcomePlaylistModel( QObject* parent = 0 ); diff --git a/src/libtomahawk/widgets/welcomewidget.cpp b/src/libtomahawk/widgets/welcomewidget.cpp index 5bf94cb74..51db3b8f8 100644 --- a/src/libtomahawk/widgets/welcomewidget.cpp +++ b/src/libtomahawk/widgets/welcomewidget.cpp @@ -32,6 +32,7 @@ #include "widgets/overlaywidget.h" #include "utils/tomahawkutils.h" #include "utils/logger.h" +#include #define HISTORY_TRACK_ITEMS 25 #define HISTORY_PLAYLIST_ITEMS 5 @@ -222,9 +223,29 @@ PlaylistDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, QFont italicFont = opt.font; italicFont.setItalic( true ); - painter->drawPixmap( option.rect.adjusted( 10, 13, -option.rect.width() + 48, -13 ), m_playlistIcon ); + QPixmap icon; + WelcomePlaylistModel::PlaylistTypes type = (WelcomePlaylistModel::PlaylistTypes)index.data( WelcomePlaylistModel::PlaylistTypeRole ).toInt(); + if( type == WelcomePlaylistModel::StaticPlaylist ) + icon = m_playlistIcon; + else if( type == WelcomePlaylistModel::AutoPlaylist ) + icon = m_autoIcon; + else if( type == WelcomePlaylistModel::Station ) + icon = m_stationIcon; - painter->drawText( option.rect.adjusted( 56, 26, -100, -8 ), index.data( WelcomePlaylistModel::ArtistRole ).toString() ); + QRect pixmapRect = option.rect.adjusted( 10, 13, -option.rect.width() + 48, -13 ); + icon = icon.scaled( pixmapRect.size(), Qt::KeepAspectRatio, Qt::SmoothTransformation ); + + painter->drawPixmap( pixmapRect, icon ); + + QString descText; + if ( type == WelcomePlaylistModel::Station ) + { + descText = index.data( WelcomePlaylistModel::DynamicPlaylistRole ).value< Tomahawk::dynplaylist_ptr >()->generator()->sentenceSummary(); + } else + { + descText = index.data( WelcomePlaylistModel::ArtistRole ).toString(); + } + painter->drawText( option.rect.adjusted( 56, 26, -100, -8 ), descText ); QString trackCount = tr( "%1 tracks" ).arg( index.data( WelcomePlaylistModel::TrackCountRole ).toString() ); painter->drawText( option.rect.adjusted( option.rect.width() - 96, 12, 0, -2 - opt.rect.height() / 2 ), trackCount, to ); diff --git a/src/libtomahawk/widgets/welcomewidget.h b/src/libtomahawk/widgets/welcomewidget.h index 8889cc76a..0f4de5c69 100644 --- a/src/libtomahawk/widgets/welcomewidget.h +++ b/src/libtomahawk/widgets/welcomewidget.h @@ -50,6 +50,8 @@ public: PlaylistDelegate() { m_playlistIcon = QPixmap( RESPATH "images/playlist-icon.png" ); + m_autoIcon = QPixmap( RESPATH "images/automatic-playlist.png" ); + m_stationIcon = QPixmap( RESPATH "images/station.png" ); } protected: @@ -57,7 +59,7 @@ protected: QSize sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const; private: - QPixmap m_playlistIcon; + QPixmap m_playlistIcon, m_autoIcon, m_stationIcon; }; class DLLEXPORT PlaylistWidget : public QListView diff --git a/src/sourcetree/items/collectionitem.cpp b/src/sourcetree/items/collectionitem.cpp index c91c39771..44e57ddfd 100644 --- a/src/sourcetree/items/collectionitem.cpp +++ b/src/sourcetree/items/collectionitem.cpp @@ -1,4 +1,6 @@ /* + * Copyright 2010-2011, Leo Franchi + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/sourcetree/items/collectionitem.h b/src/sourcetree/items/collectionitem.h index 5a8b5fb23..15fae1456 100644 --- a/src/sourcetree/items/collectionitem.h +++ b/src/sourcetree/items/collectionitem.h @@ -1,4 +1,6 @@ /* + * Copyright 2010-2011, Leo Franchi + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/sourcetree/items/genericpageitems.cpp b/src/sourcetree/items/genericpageitems.cpp index c37a6aa67..86211dea7 100644 --- a/src/sourcetree/items/genericpageitems.cpp +++ b/src/sourcetree/items/genericpageitems.cpp @@ -1,4 +1,6 @@ /* + * Copyright 2010-2011, Leo Franchi + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/sourcetree/items/genericpageitems.h b/src/sourcetree/items/genericpageitems.h index 378224bb1..2b2609ea9 100644 --- a/src/sourcetree/items/genericpageitems.h +++ b/src/sourcetree/items/genericpageitems.h @@ -1,4 +1,6 @@ /* + * Copyright 2010-2011, Leo Franchi + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/sourcetree/items/playlistitems.cpp b/src/sourcetree/items/playlistitems.cpp index 2146c9f37..ee7976892 100644 --- a/src/sourcetree/items/playlistitems.cpp +++ b/src/sourcetree/items/playlistitems.cpp @@ -1,4 +1,7 @@ /* + * + * Copyright 2010-2011, Leo Franchi + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/sourcetree/items/playlistitems.h b/src/sourcetree/items/playlistitems.h index 1c3e9d463..7ae0d8a96 100644 --- a/src/sourcetree/items/playlistitems.h +++ b/src/sourcetree/items/playlistitems.h @@ -1,4 +1,6 @@ /* + * Copyright 2010-2011, Leo Franchi + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/sourcetree/items/sourcetreeitem.cpp b/src/sourcetree/items/sourcetreeitem.cpp index 5cc9e3f7d..5f82833c3 100644 --- a/src/sourcetree/items/sourcetreeitem.cpp +++ b/src/sourcetree/items/sourcetreeitem.cpp @@ -1,4 +1,6 @@ /* + Copyright 2010-2011, Leo Franchi + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or diff --git a/src/sourcetree/items/sourcetreeitem.h b/src/sourcetree/items/sourcetreeitem.h index bfab5e1b1..b8b971172 100644 --- a/src/sourcetree/items/sourcetreeitem.h +++ b/src/sourcetree/items/sourcetreeitem.h @@ -1,4 +1,6 @@ /* + Copyright 2010-2011, Leo Franchi + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or diff --git a/src/sourcetree/sourcesproxymodel.cpp b/src/sourcetree/sourcesproxymodel.cpp index 93ec73b64..b449455cc 100644 --- a/src/sourcetree/sourcesproxymodel.cpp +++ b/src/sourcetree/sourcesproxymodel.cpp @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2011, Christian Muehlhaeuser + * Copyright 2010-2011, Leo Franchi * * Tomahawk is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/sourcetree/sourcesproxymodel.h b/src/sourcetree/sourcesproxymodel.h index 65e3198d8..57917d815 100644 --- a/src/sourcetree/sourcesproxymodel.h +++ b/src/sourcetree/sourcesproxymodel.h @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2011, Christian Muehlhaeuser + * Copyright 2010-2011, Leo Franchi * * Tomahawk is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by