mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-03 20:57:52 +02:00
Add a loved tracks playlist, and aggregate loved tracks playlist, minus the actual valid tracks
This commit is contained in:
@@ -83,6 +83,7 @@
|
|||||||
<file>./data/images/automatic-playlist.png</file>
|
<file>./data/images/automatic-playlist.png</file>
|
||||||
<file>./data/images/station.png</file>
|
<file>./data/images/station.png</file>
|
||||||
<file>./data/images/new-additions.png</file>
|
<file>./data/images/new-additions.png</file>
|
||||||
|
<file>./data/images/loved_playlist.png</file>
|
||||||
<file>./data/stylesheets/topbar-radiobuttons.css</file>
|
<file>./data/stylesheets/topbar-radiobuttons.css</file>
|
||||||
<file>./data/icons/tomahawk-icon-16x16.png</file>
|
<file>./data/icons/tomahawk-icon-16x16.png</file>
|
||||||
<file>./data/icons/tomahawk-icon-32x32.png</file>
|
<file>./data/icons/tomahawk-icon-32x32.png</file>
|
||||||
|
@@ -120,6 +120,7 @@ set( libSources
|
|||||||
playlist/albumitemdelegate.cpp
|
playlist/albumitemdelegate.cpp
|
||||||
playlist/albumview.cpp
|
playlist/albumview.cpp
|
||||||
playlist/artistview.cpp
|
playlist/artistview.cpp
|
||||||
|
playlist/customplaylistview.cpp
|
||||||
|
|
||||||
playlist/topbar/topbar.cpp
|
playlist/topbar/topbar.cpp
|
||||||
playlist/topbar/clearbutton.cpp
|
playlist/topbar/clearbutton.cpp
|
||||||
@@ -310,6 +311,7 @@ set( libHeaders
|
|||||||
playlist/albumitemdelegate.h
|
playlist/albumitemdelegate.h
|
||||||
playlist/albumview.h
|
playlist/albumview.h
|
||||||
playlist/artistview.h
|
playlist/artistview.h
|
||||||
|
playlist/customplaylistview.h
|
||||||
|
|
||||||
playlist/topbar/topbar.h
|
playlist/topbar/topbar.h
|
||||||
playlist/topbar/clearbutton.h
|
playlist/topbar/clearbutton.h
|
||||||
|
99
src/libtomahawk/playlist/customplaylistview.cpp
Normal file
99
src/libtomahawk/playlist/customplaylistview.cpp
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
|
*
|
||||||
|
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
|
||||||
|
*
|
||||||
|
* Tomahawk 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 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Tomahawk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "customplaylistview.h"
|
||||||
|
|
||||||
|
#include "database/databasecommand_genericselect.h"
|
||||||
|
#include "database/database.h"
|
||||||
|
#include "utils/tomahawkutils.h"
|
||||||
|
|
||||||
|
using namespace Tomahawk;
|
||||||
|
|
||||||
|
CustomPlaylistView::CustomPlaylistView( CustomPlaylistView::PlaylistType type, const source_ptr& s, QWidget* parent )
|
||||||
|
: PlaylistView ( parent )
|
||||||
|
, m_type( type )
|
||||||
|
, m_source( s )
|
||||||
|
, m_model( new PlaylistModel( this ) )
|
||||||
|
{
|
||||||
|
// Generate the tracks, add them to the playlist
|
||||||
|
setFrameShape( QFrame::NoFrame );
|
||||||
|
setAttribute( Qt::WA_MacShowFocusRect, 0 );
|
||||||
|
|
||||||
|
setPlaylistModel( m_model );
|
||||||
|
generateTracks();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
CustomPlaylistView::generateTracks()
|
||||||
|
{
|
||||||
|
QString sql;
|
||||||
|
switch ( m_type )
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
case SourceLovedTracks:
|
||||||
|
sql = "SELECT track.name, artist.name FROM track, artist WHERE track.artist = artist.id";
|
||||||
|
break;
|
||||||
|
case AllLovedTracks:
|
||||||
|
sql = "select track.name, artist.name, count(*) as counter from (select track from playback_log group by track, source), track, artist where track not in (select track from playback_log where source is null group by track) and track.id = track and artist.id = track.artist group by track order by counter desc";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
DatabaseCommand_GenericSelect* cmd = new DatabaseCommand_GenericSelect( sql, DatabaseCommand_GenericSelect::Track, 30, 0 );
|
||||||
|
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr> ) ), this, SLOT( tracksGenerated( QList<Tomahawk::query_ptr> ) ) );
|
||||||
|
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CustomPlaylistView::tracksGenerated( QList< query_ptr > tracks )
|
||||||
|
{
|
||||||
|
foreach ( const query_ptr& q, tracks )
|
||||||
|
m_model->append( q );
|
||||||
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
CustomPlaylistView::title() const
|
||||||
|
{
|
||||||
|
if ( m_source.isNull() )
|
||||||
|
return tr( "Top Loved Tracks" );
|
||||||
|
else
|
||||||
|
return tr( "Your Loved Tracks" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString
|
||||||
|
CustomPlaylistView::description() const
|
||||||
|
{
|
||||||
|
if ( m_source.isNull() )
|
||||||
|
return tr( "The most loved tracks from all your friends" );
|
||||||
|
else
|
||||||
|
return tr( "Your top loved tracks" );
|
||||||
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
CustomPlaylistView::longDescription() const
|
||||||
|
{
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
QPixmap
|
||||||
|
CustomPlaylistView::pixmap() const
|
||||||
|
{
|
||||||
|
return QPixmap( RESPATH "images/loved_playlist.png" );
|
||||||
|
}
|
64
src/libtomahawk/playlist/customplaylistview.h
Normal file
64
src/libtomahawk/playlist/customplaylistview.h
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
|
*
|
||||||
|
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
|
||||||
|
*
|
||||||
|
* Tomahawk 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 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Tomahawk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef CUSTOMPLAYLISTVIEW_H
|
||||||
|
#define CUSTOMPLAYLISTVIEW_H
|
||||||
|
|
||||||
|
#include "playlistview.h"
|
||||||
|
|
||||||
|
#include "dllmacro.h"
|
||||||
|
|
||||||
|
namespace Tomahawk
|
||||||
|
{
|
||||||
|
|
||||||
|
class DLLEXPORT CustomPlaylistView : public PlaylistView
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
enum PlaylistType {
|
||||||
|
SourceLovedTracks,
|
||||||
|
AllLovedTracks
|
||||||
|
};
|
||||||
|
|
||||||
|
explicit CustomPlaylistView( PlaylistType type, const source_ptr& s, QWidget* parent = 0 );
|
||||||
|
virtual ~CustomPlaylistView() {}
|
||||||
|
|
||||||
|
virtual bool showFilter() const { return false; }
|
||||||
|
virtual bool showStatsBar() const { return false; }
|
||||||
|
|
||||||
|
virtual QString title() const;
|
||||||
|
virtual QPixmap pixmap() const;
|
||||||
|
virtual QString description() const;
|
||||||
|
virtual QString longDescription() const;
|
||||||
|
virtual bool isTemporaryPage() const { return false; }
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void tracksGenerated( QList<Tomahawk::query_ptr> tracks );
|
||||||
|
|
||||||
|
private:
|
||||||
|
void generateTracks();
|
||||||
|
|
||||||
|
PlaylistType m_type;
|
||||||
|
source_ptr m_source;
|
||||||
|
PlaylistModel* m_model;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // CUSTOMPLAYLISTVIEW_H
|
@@ -24,6 +24,7 @@
|
|||||||
#include "utils/tomahawkutils.h"
|
#include "utils/tomahawkutils.h"
|
||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
#include <widgets/SocialPlaylistWidget.h>
|
#include <widgets/SocialPlaylistWidget.h>
|
||||||
|
#include <playlist/customplaylistview.h>
|
||||||
|
|
||||||
/// CollectionItem
|
/// CollectionItem
|
||||||
|
|
||||||
@@ -37,18 +38,36 @@ CollectionItem::CollectionItem( SourcesModel* mdl, SourceTreeItem* parent, cons
|
|||||||
, m_tempItem( 0 )
|
, m_tempItem( 0 )
|
||||||
, m_sourceInfoItem( 0 )
|
, m_sourceInfoItem( 0 )
|
||||||
, m_coolPlaylistsItem( 0 )
|
, m_coolPlaylistsItem( 0 )
|
||||||
|
, m_lovedTracksItem()
|
||||||
, m_curTempPage( 0 )
|
, m_curTempPage( 0 )
|
||||||
, m_sourceInfoPage( 0 )
|
, m_sourceInfoPage( 0 )
|
||||||
, m_coolPlaylistsPage( 0 )
|
, m_coolPlaylistsPage( 0 )
|
||||||
|
, m_lovedTracksPage( 0 )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
m_lovedTracksItem = new GenericPageItem( model(), this, ( m_source.isNull() ? tr( "Top Loved Tracks" ) : tr( "Loved Tracks" ) ), QIcon( RESPATH "images/loved_playlist.png" ),
|
||||||
|
boost::bind( &CollectionItem::lovedTracksClicked, this ),
|
||||||
|
boost::bind( &CollectionItem::getLovedTracksPage, this )
|
||||||
|
);
|
||||||
|
m_lovedTracksItem->setSortValue( -250 );
|
||||||
|
|
||||||
|
|
||||||
if( m_source.isNull() ) { // super collection
|
if( m_source.isNull() ) { // super collection
|
||||||
connect( ViewManager::instance(), SIGNAL( tempPageActivated( Tomahawk::ViewPage*) ), this, SLOT( tempPageActivated( Tomahawk::ViewPage* ) ) );
|
connect( ViewManager::instance(), SIGNAL( tempPageActivated( Tomahawk::ViewPage*) ), this, SLOT( tempPageActivated( Tomahawk::ViewPage* ) ) );
|
||||||
|
|
||||||
m_coolPlaylistsItem = new GenericPageItem( model(), this, tr( "Cool Stuff" ), QIcon( RESPATH "images/new-additions.png" ),
|
// add misc children of root node
|
||||||
boost::bind( &CollectionItem::coolPlaylistsClicked, this ),
|
GenericPageItem* recent = new GenericPageItem( model(), this, tr( "Recently Played" ), QIcon( RESPATH "images/recently-played.png" ),
|
||||||
boost::bind( &CollectionItem::getCoolPlaylistsPage, this )
|
boost::bind( &ViewManager::showWelcomePage, ViewManager::instance() ),
|
||||||
|
boost::bind( &ViewManager::welcomeWidget, ViewManager::instance() )
|
||||||
);
|
);
|
||||||
m_coolPlaylistsItem->setSortValue( 200 );
|
recent->setSortValue( -300 );
|
||||||
|
|
||||||
|
// TODO finish implementing and making pretty
|
||||||
|
// m_coolPlaylistsItem = new GenericPageItem( model(), this, tr( "Cool Stuff" ), QIcon( RESPATH "images/new-additions.png" ),
|
||||||
|
// boost::bind( &CollectionItem::coolPlaylistsClicked, this ),
|
||||||
|
// boost::bind( &CollectionItem::getCoolPlaylistsPage, this )
|
||||||
|
// );
|
||||||
|
// m_coolPlaylistsItem->setSortValue( 200 );
|
||||||
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -60,8 +79,6 @@ CollectionItem::CollectionItem( SourcesModel* mdl, SourceTreeItem* parent, cons
|
|||||||
);
|
);
|
||||||
m_sourceInfoItem->setSortValue( -300 );
|
m_sourceInfoItem->setSortValue( -300 );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// create category items if there are playlists to show, or stations to show
|
// create category items if there are playlists to show, or stations to show
|
||||||
QList< playlist_ptr > playlists = source->collection()->playlists();
|
QList< playlist_ptr > playlists = source->collection()->playlists();
|
||||||
QList< dynplaylist_ptr > autoplaylists = source->collection()->autoPlaylists();
|
QList< dynplaylist_ptr > autoplaylists = source->collection()->autoPlaylists();
|
||||||
@@ -387,7 +404,9 @@ CollectionItem::coolPlaylistsClicked()
|
|||||||
if( !m_source.isNull() )
|
if( !m_source.isNull() )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
if( !m_coolPlaylistsPage )
|
||||||
m_coolPlaylistsPage = new SocialPlaylistWidget( ViewManager::instance()->widget() );
|
m_coolPlaylistsPage = new SocialPlaylistWidget( ViewManager::instance()->widget() );
|
||||||
|
|
||||||
ViewManager::instance()->show( m_coolPlaylistsPage );
|
ViewManager::instance()->show( m_coolPlaylistsPage );
|
||||||
return m_coolPlaylistsPage;
|
return m_coolPlaylistsPage;
|
||||||
}
|
}
|
||||||
@@ -397,3 +416,19 @@ CollectionItem::getCoolPlaylistsPage() const
|
|||||||
{
|
{
|
||||||
return m_coolPlaylistsPage;
|
return m_coolPlaylistsPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ViewPage*
|
||||||
|
CollectionItem::lovedTracksClicked()
|
||||||
|
{
|
||||||
|
if( !m_lovedTracksPage )
|
||||||
|
m_lovedTracksPage = new CustomPlaylistView( m_source.isNull() ? CustomPlaylistView::AllLovedTracks : CustomPlaylistView::SourceLovedTracks, m_source, ViewManager::instance()->widget() );
|
||||||
|
|
||||||
|
ViewManager::instance()->show( m_lovedTracksPage );
|
||||||
|
return m_lovedTracksPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
ViewPage*
|
||||||
|
CollectionItem::getLovedTracksPage() const
|
||||||
|
{
|
||||||
|
return m_lovedTracksPage;
|
||||||
|
}
|
||||||
|
@@ -61,6 +61,9 @@ private slots:
|
|||||||
Tomahawk::ViewPage* coolPlaylistsClicked();
|
Tomahawk::ViewPage* coolPlaylistsClicked();
|
||||||
Tomahawk::ViewPage* getCoolPlaylistsPage() const;
|
Tomahawk::ViewPage* getCoolPlaylistsPage() const;
|
||||||
|
|
||||||
|
Tomahawk::ViewPage* lovedTracksClicked();
|
||||||
|
Tomahawk::ViewPage* getLovedTracksPage() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void playlistsAddedInternal( SourceTreeItem* parent, const QList< Tomahawk::dynplaylist_ptr >& playlists );
|
void playlistsAddedInternal( SourceTreeItem* parent, const QList< Tomahawk::dynplaylist_ptr >& playlists );
|
||||||
template< typename T >
|
template< typename T >
|
||||||
@@ -73,10 +76,12 @@ private:
|
|||||||
GenericPageItem* m_tempItem;
|
GenericPageItem* m_tempItem;
|
||||||
GenericPageItem* m_sourceInfoItem;
|
GenericPageItem* m_sourceInfoItem;
|
||||||
GenericPageItem* m_coolPlaylistsItem;
|
GenericPageItem* m_coolPlaylistsItem;
|
||||||
|
GenericPageItem* m_lovedTracksItem;
|
||||||
|
|
||||||
Tomahawk::ViewPage* m_curTempPage;
|
Tomahawk::ViewPage* m_curTempPage;
|
||||||
Tomahawk::ViewPage* m_sourceInfoPage;
|
Tomahawk::ViewPage* m_sourceInfoPage;
|
||||||
Tomahawk::ViewPage* m_coolPlaylistsPage;
|
Tomahawk::ViewPage* m_coolPlaylistsPage;
|
||||||
|
Tomahawk::ViewPage* m_lovedTracksPage;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -46,12 +46,6 @@ SourcesModel::SourcesModel( QObject* parent )
|
|||||||
|
|
||||||
appendItem( source_ptr() );
|
appendItem( source_ptr() );
|
||||||
|
|
||||||
// add misc children of root node
|
|
||||||
new GenericPageItem( this, m_rootItem->children().at( 0 ), tr( "Recently Played" ), QIcon( RESPATH "images/recently-played.png" ),
|
|
||||||
boost::bind( &ViewManager::showWelcomePage, ViewManager::instance() ),
|
|
||||||
boost::bind( &ViewManager::welcomeWidget, ViewManager::instance() )
|
|
||||||
);
|
|
||||||
|
|
||||||
onSourcesAdded( SourceList::instance()->sources() );
|
onSourcesAdded( SourceList::instance()->sources() );
|
||||||
|
|
||||||
connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), SLOT( onSourceAdded( Tomahawk::source_ptr ) ) );
|
connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), SLOT( onSourceAdded( Tomahawk::source_ptr ) ) );
|
||||||
|
Reference in New Issue
Block a user