diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt index d98f14c19..c148deb59 100644 --- a/src/libtomahawk/CMakeLists.txt +++ b/src/libtomahawk/CMakeLists.txt @@ -74,6 +74,7 @@ set( libGuiSources playlist/PlaylistLargeItemDelegate.cpp playlist/PlaylistChartItemDelegate.cpp playlist/PlayableItem.cpp + playlist/SingleTrackPlaylistInterface.h playlist/dynamic/DynamicPlaylist.cpp playlist/dynamic/DynamicView.cpp diff --git a/src/libtomahawk/audio/AudioEngine.cpp b/src/libtomahawk/audio/AudioEngine.cpp index e8f07c45c..dde5ed1ad 100644 --- a/src/libtomahawk/audio/AudioEngine.cpp +++ b/src/libtomahawk/audio/AudioEngine.cpp @@ -42,6 +42,7 @@ #include "jobview/ErrorStatusMessage.h" #include "utils/Logger.h" +#include "SingleTrackPlaylistInterface.h" using namespace Tomahawk; @@ -582,7 +583,11 @@ AudioEngine::playItem( Tomahawk::playlistinterface_ptr playlist, const Tomahawk: m_playlist.data()->reset(); setPlaylist( playlist ); - m_currentTrackPlaylist = playlist; + + if ( playlist.isNull() ) + m_currentTrackPlaylist = playlistinterface_ptr( new SingleTrackPlaylistInterface( result->toQuery() ) ); + else + m_currentTrackPlaylist = playlist; if ( !result.isNull() ) { diff --git a/src/libtomahawk/database/DatabaseCommand_Resolve.cpp b/src/libtomahawk/database/DatabaseCommand_Resolve.cpp index f9f631f70..bcb708429 100644 --- a/src/libtomahawk/database/DatabaseCommand_Resolve.cpp +++ b/src/libtomahawk/database/DatabaseCommand_Resolve.cpp @@ -219,7 +219,7 @@ DatabaseCommand_Resolve::fullTextResolve( DatabaseImpl* lib ) emit albums( m_query->id(), albumList ); } - + if ( trackPairs.length() == 0 ) { qDebug() << "No candidates found in first pass, aborting resolve" << m_query->fullTextQuery(); diff --git a/src/libtomahawk/playlist/GridView.cpp b/src/libtomahawk/playlist/GridView.cpp index bccd83657..c1d85aa14 100644 --- a/src/libtomahawk/playlist/GridView.cpp +++ b/src/libtomahawk/playlist/GridView.cpp @@ -35,6 +35,7 @@ #include "AlbumModel.h" #include "PlayableModel.h" #include "PlayableProxyModelPlaylistInterface.h" +#include "SingleTrackPlaylistInterface.h" #include "ContextMenu.h" #include "ViewManager.h" #include "utils/Logger.h" @@ -64,6 +65,8 @@ public: return item->album()->playlistInterface( Tomahawk::Mixed ) == playlistInterface; else if ( !item->artist().isNull() ) return item->artist()->playlistInterface( Tomahawk::Mixed ) == playlistInterface; + else if ( !item->query().isNull() && !playlistInterface.dynamicCast< SingleTrackPlaylistInterface >().isNull() ) + return item->query() == playlistInterface.dynamicCast< SingleTrackPlaylistInterface >()->track(); } return false; diff --git a/src/libtomahawk/playlist/SingleTrackPlaylistInterface.h b/src/libtomahawk/playlist/SingleTrackPlaylistInterface.h new file mode 100644 index 000000000..5438debdf --- /dev/null +++ b/src/libtomahawk/playlist/SingleTrackPlaylistInterface.h @@ -0,0 +1,59 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright 2012 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 + * 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 . + */ + +#ifndef SINGLE_TRACK_PLAYLIST_INTERFACE +#define SINGLE_TRACK_PLAYLIST_INTERFACE + +#include "PlaylistInterface.h" +#include "DllMacro.h" +#include "Query.h" +#include "Typedefs.h" +#include "Result.h" + +namespace Tomahawk +{ + +class DLLEXPORT SingleTrackPlaylistInterface : public PlaylistInterface +{ + Q_OBJECT +public: + explicit SingleTrackPlaylistInterface( const query_ptr& query ) + : PlaylistInterface() + , m_track( query ) + { + } + + query_ptr track() const { return m_track; } + void setQuery( const query_ptr& track ) { m_track = track; } + + virtual result_ptr currentItem() const { return result_ptr(); } + virtual PlaylistModes::RepeatMode repeatMode() const { return PlaylistModes::NoRepeat; } + virtual void setRepeatMode( PlaylistModes::RepeatMode ) {} + virtual void setShuffled( bool ) {} + virtual bool shuffled() const { return false; } + virtual result_ptr siblingItem( int itemsAway ) { return result_ptr(); } + virtual int trackCount() const { return 1; } + virtual QList< query_ptr > tracks() { return QList< query_ptr >(); } + +private: + query_ptr m_track; +}; + +} + +#endif