From 3a10c530264f6a87941d71a04e0ea5c638877db5 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Sun, 23 Dec 2012 10:07:32 +0100 Subject: [PATCH] * PlaylistModel's setAcceptPlayableQueriesOnly( bool ) toggles whether dropping unplayable queries is allowed. --- src/libtomahawk/playlist/PlaylistModel.cpp | 4 ++++ src/libtomahawk/playlist/PlaylistModel.h | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/libtomahawk/playlist/PlaylistModel.cpp b/src/libtomahawk/playlist/PlaylistModel.cpp index 393e5fd14..cccf817e5 100644 --- a/src/libtomahawk/playlist/PlaylistModel.cpp +++ b/src/libtomahawk/playlist/PlaylistModel.cpp @@ -45,6 +45,7 @@ PlaylistModel::PlaylistModel( QObject* parent ) , m_isTemporary( false ) , m_changesOngoing( false ) , m_isLoading( false ) + , m_acceptPlayableQueriesOnly( false ) , m_savedInsertPos( -1 ) { m_dropStorage.parent = QPersistentModelIndex(); @@ -218,6 +219,9 @@ PlaylistModel::insertQueries( const QList< Tomahawk::query_ptr >& queries, int r QList< Tomahawk::plentry_ptr > entries; foreach ( const query_ptr& query, queries ) { + if ( m_acceptPlayableQueriesOnly && query && query->resolvingFinished() && !query->playable() ) + continue; + plentry_ptr entry = plentry_ptr( new PlaylistEntry() ); entry->setDuration( query->displayQuery()->duration() ); diff --git a/src/libtomahawk/playlist/PlaylistModel.h b/src/libtomahawk/playlist/PlaylistModel.h index 3bc92478a..69ca826dc 100644 --- a/src/libtomahawk/playlist/PlaylistModel.h +++ b/src/libtomahawk/playlist/PlaylistModel.h @@ -57,6 +57,9 @@ public: virtual void loadPlaylist( const Tomahawk::playlist_ptr& playlist, bool loadEntries = true ); bool isTemporary() const; + bool acceptPlayableQueriesOnly() const { return m_acceptPlayableQueriesOnly; } + void setAcceptPlayableQueriesOnly( bool b ) { m_acceptPlayableQueriesOnly = b; } + public slots: virtual void clear(); @@ -95,6 +98,7 @@ private: bool m_isTemporary; bool m_changesOngoing; bool m_isLoading; + bool m_acceptPlayableQueriesOnly; QList< Tomahawk::Query* > m_waitingForResolved; QStringList m_waitForRevision;