mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-09-03 19:02:56 +02:00
* Merged PlaylistInterface refactor.
This commit is contained in:
@@ -138,6 +138,7 @@ AudioControls::AudioControls( QWidget* parent )
|
||||
connect( AudioEngine::instance(), SIGNAL( seeked( qint64 ) ), SLOT( onPlaybackSeeked( qint64 ) ) );
|
||||
connect( AudioEngine::instance(), SIGNAL( timerMilliSeconds( qint64 ) ), SLOT( onPlaybackTimer( qint64 ) ) );
|
||||
connect( AudioEngine::instance(), SIGNAL( volumeChanged( int ) ), SLOT( onVolumeChanged( int ) ) );
|
||||
connect( AudioEngine::instance(), SIGNAL( controlStateChanged() ), SLOT( onControlStateChanged() ) );
|
||||
|
||||
ui->buttonAreaLayout->setSpacing( 0 );
|
||||
ui->stackedLayout->setSpacing( 0 );
|
||||
@@ -189,6 +190,22 @@ AudioControls::onVolumeChanged( int volume )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AudioControls::onControlStateChanged()
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO;
|
||||
|
||||
if ( QThread::currentThread() != thread() )
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO << "Reinvoking in correct thread!";
|
||||
QMetaObject::invokeMethod( this, "onControlStateChanged", Qt::QueuedConnection );
|
||||
}
|
||||
|
||||
ui->prevButton->setEnabled( AudioEngine::instance()->canGoPrevious() );
|
||||
ui->nextButton->setEnabled( AudioEngine::instance()->canGoNext() );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AudioControls::onPlaybackStarted( const Tomahawk::result_ptr& result )
|
||||
{
|
||||
@@ -264,8 +281,7 @@ AudioControls::onPlaybackLoading( const Tomahawk::result_ptr& result )
|
||||
ui->loveButton->setToolTip( tr( "Love" ) );
|
||||
ui->ownerButton->setToolTip( QString( tr( "Playing from %1" ) ).arg( result->friendlySource() ) );
|
||||
|
||||
ui->prevButton->setEnabled( AudioEngine::instance()->canGoPrevious() );
|
||||
ui->nextButton->setEnabled( AudioEngine::instance()->canGoNext() );
|
||||
onControlStateChanged();
|
||||
|
||||
QPixmap sourceIcon = result->sourceIcon( Result::Plain, ui->ownerButton->size() );
|
||||
if ( !sourceIcon.isNull() )
|
||||
@@ -397,8 +413,7 @@ AudioControls::onPlaybackStopped()
|
||||
ui->loveButton->setToolTip( "" );
|
||||
ui->ownerButton->setToolTip( "" );
|
||||
|
||||
ui->prevButton->setEnabled( AudioEngine::instance()->canGoPrevious() );
|
||||
ui->nextButton->setEnabled( AudioEngine::instance()->canGoNext() );
|
||||
onControlStateChanged();
|
||||
}
|
||||
|
||||
|
||||
|
@@ -72,6 +72,7 @@ private slots:
|
||||
|
||||
void onPlaybackTimer( qint64 msElapsed );
|
||||
void onVolumeChanged( int volume );
|
||||
void onControlStateChanged();
|
||||
|
||||
void onRepeatClicked();
|
||||
void onShuffleClicked();
|
||||
|
@@ -75,16 +75,16 @@ JreenMessageHandler( QtMsgType type, const char *msg )
|
||||
switch ( type )
|
||||
{
|
||||
case QtDebugMsg:
|
||||
tDebug( LOGTHIRDPARTY ).nospace() << JREEN_LOG_INFIX << ": " << "Debug: " << msg;
|
||||
tDebug( LOGTHIRDPARTY ).nospace() << JREEN_LOG_INFIX << ":" << "Debug:" << msg;
|
||||
break;
|
||||
case QtWarningMsg:
|
||||
tDebug( LOGTHIRDPARTY ).nospace() << JREEN_LOG_INFIX << ": " << "Warning: " << msg;
|
||||
tDebug( LOGTHIRDPARTY ).nospace() << JREEN_LOG_INFIX << ":" << "Warning:" << msg;
|
||||
break;
|
||||
case QtCriticalMsg:
|
||||
tDebug( LOGTHIRDPARTY ).nospace() << JREEN_LOG_INFIX << ": " << "Critical: " << msg;
|
||||
tDebug( LOGTHIRDPARTY ).nospace() << JREEN_LOG_INFIX << ":" << "Critical:" << msg;
|
||||
break;
|
||||
case QtFatalMsg:
|
||||
tDebug( LOGTHIRDPARTY ).nospace() << JREEN_LOG_INFIX << ": " << "Fatal: " << msg;
|
||||
tDebug( LOGTHIRDPARTY ).nospace() << JREEN_LOG_INFIX << ":" << "Fatal:" << msg;
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
@@ -568,7 +568,6 @@ MprisPlugin::onTrackCountChanged( unsigned int tracks )
|
||||
Q_UNUSED( tracks );
|
||||
notifyPropertyChanged( "org.mpris.MediaPlayer2.Player", "CanGoNext" );
|
||||
notifyPropertyChanged( "org.mpris.MediaPlayer2.Player", "CanGoPrevious" );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@@ -72,6 +72,7 @@ public:
|
||||
void setWeakRef( QWeakPointer< Tomahawk::Album > weakRef ) { m_ownRef = weakRef; }
|
||||
|
||||
void loadId( bool autoCreate );
|
||||
|
||||
signals:
|
||||
void tracksAdded( const QList<Tomahawk::query_ptr>& tracks, Tomahawk::ModelMode mode, const Tomahawk::collection_ptr& collection );
|
||||
void updated();
|
||||
|
@@ -52,26 +52,27 @@ AlbumPlaylistInterface::~AlbumPlaylistInterface()
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::result_ptr
|
||||
AlbumPlaylistInterface::siblingItem( int itemsAway, bool readOnly )
|
||||
void
|
||||
AlbumPlaylistInterface::setCurrentIndex( qint64 index )
|
||||
{
|
||||
Q_UNUSED( readOnly );
|
||||
m_currentTrack = index;
|
||||
m_currentItem = m_queries.at( index )->results().first();
|
||||
}
|
||||
|
||||
int p = m_currentTrack;
|
||||
|
||||
qint64
|
||||
AlbumPlaylistInterface::siblingIndex( int itemsAway ) const
|
||||
{
|
||||
qint64 p = m_currentTrack;
|
||||
p += itemsAway;
|
||||
|
||||
if ( p < 0 )
|
||||
return Tomahawk::result_ptr();
|
||||
return -1;
|
||||
|
||||
if ( p >= m_queries.count() )
|
||||
return Tomahawk::result_ptr();
|
||||
return -1;
|
||||
|
||||
if ( !m_queries.at( p )->numResults() )
|
||||
return siblingItem( itemsAway + 1 );
|
||||
|
||||
m_currentTrack = p;
|
||||
m_currentItem = m_queries.at( p )->results().first();
|
||||
return m_currentItem;
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
@@ -82,30 +83,6 @@ AlbumPlaylistInterface::currentItem() const
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
AlbumPlaylistInterface::hasNextItem()
|
||||
{
|
||||
int p = m_currentTrack;
|
||||
p++;
|
||||
if ( p < 0 || p >= m_queries.count() )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
AlbumPlaylistInterface::hasPreviousItem()
|
||||
{
|
||||
int p = m_currentTrack;
|
||||
p--;
|
||||
if ( p < 0 || p >= m_queries.count() )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
AlbumPlaylistInterface::setCurrentTrack( unsigned int albumpos )
|
||||
{
|
||||
|
@@ -44,14 +44,14 @@ public:
|
||||
|
||||
virtual int trackCount() const { return m_queries.count(); }
|
||||
|
||||
virtual Tomahawk::result_ptr siblingItem( int itemsAway, bool readOnly = false );
|
||||
virtual void setCurrentIndex( qint64 index );
|
||||
virtual qint64 siblingIndex( int itemsAway ) const;
|
||||
|
||||
virtual Tomahawk::query_ptr itemAt( unsigned int position ) const { Q_UNUSED( position ); Q_ASSERT( false ); return Tomahawk::query_ptr(); }
|
||||
virtual int indexOfResult( const Tomahawk::result_ptr& result ) const { Q_UNUSED( result ); Q_ASSERT( false ); return -1; }
|
||||
virtual int indexOfQuery( const Tomahawk::query_ptr& query ) const { Q_UNUSED( query ); Q_ASSERT( false ); return -1; }
|
||||
virtual Tomahawk::result_ptr resultAt( qint64 index ) const { Q_UNUSED( index ); Q_ASSERT( false ); return Tomahawk::result_ptr(); }
|
||||
virtual Tomahawk::query_ptr queryAt( qint64 index ) const { Q_UNUSED( index ); Q_ASSERT( false ); return Tomahawk::query_ptr(); }
|
||||
virtual qint64 indexOfResult( const Tomahawk::result_ptr& result ) const { Q_UNUSED( result ); Q_ASSERT( false ); return -1; }
|
||||
virtual qint64 indexOfQuery( const Tomahawk::query_ptr& query ) const { Q_UNUSED( query ); Q_ASSERT( false ); return -1; }
|
||||
|
||||
virtual bool hasNextItem();
|
||||
virtual bool hasPreviousItem();
|
||||
virtual Tomahawk::result_ptr currentItem() const;
|
||||
|
||||
virtual PlaylistModes::RepeatMode repeatMode() const { return PlaylistModes::NoRepeat; }
|
||||
@@ -71,8 +71,8 @@ private slots:
|
||||
|
||||
private:
|
||||
QList< Tomahawk::query_ptr > m_queries;
|
||||
result_ptr m_currentItem;
|
||||
unsigned int m_currentTrack;
|
||||
mutable result_ptr m_currentItem;
|
||||
mutable qint64 m_currentTrack;
|
||||
|
||||
bool m_infoSystemLoaded;
|
||||
bool m_databaseLoaded;
|
||||
|
@@ -51,38 +51,27 @@ ArtistPlaylistInterface::~ArtistPlaylistInterface()
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::result_ptr
|
||||
ArtistPlaylistInterface::siblingItem( int itemsAway, bool readOnly )
|
||||
void
|
||||
ArtistPlaylistInterface::setCurrentIndex( qint64 index )
|
||||
{
|
||||
Q_UNUSED( readOnly );
|
||||
|
||||
int p = m_currentTrack;
|
||||
p += itemsAway;
|
||||
|
||||
if ( p < 0 )
|
||||
return Tomahawk::result_ptr();
|
||||
|
||||
if ( p >= m_queries.count() )
|
||||
return Tomahawk::result_ptr();
|
||||
|
||||
if ( !m_queries.at( p )->numResults() )
|
||||
return siblingItem( itemsAway + 1 );
|
||||
|
||||
m_currentTrack = p;
|
||||
m_currentItem = m_queries.at( p )->results().first();
|
||||
return m_currentItem;
|
||||
m_currentTrack = index;
|
||||
m_currentItem = m_queries.at( index )->results().first();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
ArtistPlaylistInterface::hasNextItem()
|
||||
qint64
|
||||
ArtistPlaylistInterface::siblingIndex( int itemsAway ) const
|
||||
{
|
||||
int p = m_currentTrack;
|
||||
p++;
|
||||
if ( p < 0 || p >= m_queries.count() )
|
||||
return false;
|
||||
qint64 p = m_currentTrack;
|
||||
p += itemsAway;
|
||||
|
||||
return true;
|
||||
if ( p < 0 )
|
||||
return -1;
|
||||
|
||||
if ( p >= m_queries.count() )
|
||||
return -1;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -43,13 +43,13 @@ public:
|
||||
|
||||
virtual int trackCount() const { return m_queries.count(); }
|
||||
|
||||
virtual Tomahawk::result_ptr siblingItem( int itemsAway, bool readOnly = false );
|
||||
virtual void setCurrentIndex( qint64 index );
|
||||
virtual qint64 siblingIndex( int itemsAway ) const;
|
||||
virtual Tomahawk::result_ptr resultAt( qint64 index ) const { Q_UNUSED( index ); Q_ASSERT( false ); return Tomahawk::result_ptr(); }
|
||||
virtual Tomahawk::query_ptr queryAt( qint64 index ) const { Q_UNUSED( index ); Q_ASSERT( false ); return Tomahawk::query_ptr(); }
|
||||
virtual qint64 indexOfResult( const Tomahawk::result_ptr& result ) const { Q_UNUSED( result ); Q_ASSERT( false ); return -1; }
|
||||
virtual qint64 indexOfQuery( const Tomahawk::query_ptr& query ) const { Q_UNUSED( query ); Q_ASSERT( false ); return -1; }
|
||||
|
||||
virtual Tomahawk::query_ptr itemAt( unsigned int position ) const { Q_UNUSED( position ); Q_ASSERT( false ); return Tomahawk::query_ptr(); }
|
||||
virtual int indexOfResult( const Tomahawk::result_ptr& result ) const { Q_UNUSED( result ); Q_ASSERT( false ); return -1; }
|
||||
virtual int indexOfQuery( const Tomahawk::query_ptr& query ) const { Q_UNUSED( query ); Q_ASSERT( false ); return -1; }
|
||||
|
||||
virtual bool hasNextItem();
|
||||
virtual Tomahawk::result_ptr currentItem() const;
|
||||
|
||||
virtual PlaylistModes::RepeatMode repeatMode() const { return PlaylistModes::NoRepeat; }
|
||||
@@ -70,8 +70,8 @@ private:
|
||||
Q_DISABLE_COPY( ArtistPlaylistInterface )
|
||||
|
||||
QList< Tomahawk::query_ptr > m_queries;
|
||||
result_ptr m_currentItem;
|
||||
unsigned int m_currentTrack;
|
||||
mutable result_ptr m_currentItem;
|
||||
mutable qint64 m_currentTrack;
|
||||
|
||||
bool m_infoSystemLoaded;
|
||||
bool m_databaseLoaded;
|
||||
|
@@ -42,6 +42,7 @@ LatchManager::~LatchManager()
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
LatchManager::isLatched( const source_ptr& src )
|
||||
{
|
||||
@@ -58,9 +59,10 @@ LatchManager::latchRequest( const source_ptr& source )
|
||||
|
||||
m_state = Latching;
|
||||
m_waitingForLatch = source;
|
||||
AudioEngine::instance()->playItem( source->playlistInterface(), source->playlistInterface()->nextItem() );
|
||||
AudioEngine::instance()->playItem( source->playlistInterface(), source->playlistInterface()->nextResult() );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
LatchManager::playlistChanged( Tomahawk::playlistinterface_ptr )
|
||||
{
|
||||
|
@@ -41,16 +41,42 @@ PlaylistInterface::~PlaylistInterface()
|
||||
|
||||
|
||||
result_ptr
|
||||
PlaylistInterface::previousItem()
|
||||
PlaylistInterface::previousResult() const
|
||||
{
|
||||
return siblingItem( -1 );
|
||||
return siblingResult( -1 );
|
||||
}
|
||||
|
||||
|
||||
result_ptr
|
||||
PlaylistInterface::nextItem()
|
||||
PlaylistInterface::nextResult() const
|
||||
{
|
||||
return siblingItem( 1 );
|
||||
return siblingResult( 1 );
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::result_ptr
|
||||
PlaylistInterface::siblingResult( int itemsAway ) const
|
||||
{
|
||||
int idx = siblingIndex( itemsAway );
|
||||
|
||||
while ( idx >= 0 )
|
||||
{
|
||||
Tomahawk::query_ptr query = queryAt( idx );
|
||||
// Tomahawk::result_ptr result = resultAt( idx );
|
||||
if ( query->numResults() )
|
||||
{
|
||||
return query->results().first();
|
||||
}
|
||||
|
||||
if ( itemsAway < 0 )
|
||||
itemsAway--;
|
||||
else
|
||||
itemsAway++;
|
||||
|
||||
idx = siblingIndex( itemsAway );
|
||||
}
|
||||
|
||||
return Tomahawk::result_ptr();
|
||||
}
|
||||
|
||||
|
||||
@@ -89,3 +115,17 @@ PlaylistInterface::filterTracks( const QList<Tomahawk::query_ptr>& queries )
|
||||
Pipeline::instance()->resolve( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PlaylistInterface::hasNextResult() const
|
||||
{
|
||||
return !( siblingResult( 1 ).isNull() );
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PlaylistInterface::hasPreviousResult() const
|
||||
{
|
||||
return !( siblingResult( -1 ).isNull() );
|
||||
}
|
||||
|
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <QtCore/QModelIndex>
|
||||
|
||||
#include "playlist/PlayableItem.h"
|
||||
#include "Typedefs.h"
|
||||
#include "DllMacro.h"
|
||||
#include "utils/Logger.h"
|
||||
@@ -45,20 +46,22 @@ public:
|
||||
virtual int trackCount() const = 0;
|
||||
|
||||
virtual Tomahawk::result_ptr currentItem() const = 0;
|
||||
virtual void setCurrentIndex( qint64 index ) = 0;
|
||||
|
||||
virtual bool hasNextItem() { return true; }
|
||||
virtual bool hasPreviousItem() { return true; }
|
||||
virtual Tomahawk::result_ptr nextItem();
|
||||
virtual Tomahawk::result_ptr previousItem();
|
||||
virtual bool hasNextResult() const;
|
||||
virtual bool hasPreviousResult() const;
|
||||
virtual Tomahawk::result_ptr nextResult() const;
|
||||
virtual Tomahawk::result_ptr previousResult() const;
|
||||
|
||||
virtual Tomahawk::result_ptr siblingItem( int itemsAway, bool readOnly = false ) = 0;
|
||||
virtual qint64 siblingIndex( int itemsAway ) const = 0;
|
||||
virtual Tomahawk::result_ptr siblingResult( int itemsAway ) const;
|
||||
|
||||
virtual Tomahawk::query_ptr itemAt( unsigned int position ) const = 0;
|
||||
virtual int indexOfResult( const Tomahawk::result_ptr& result ) const = 0;
|
||||
virtual int indexOfQuery( const Tomahawk::query_ptr& query ) const = 0;
|
||||
virtual Tomahawk::result_ptr resultAt( qint64 index ) const = 0;
|
||||
virtual Tomahawk::query_ptr queryAt( qint64 index ) const = 0;
|
||||
virtual qint64 indexOfResult( const Tomahawk::result_ptr& result ) const = 0;
|
||||
virtual qint64 indexOfQuery( const Tomahawk::query_ptr& query ) const = 0;
|
||||
|
||||
virtual PlaylistModes::RepeatMode repeatMode() const = 0;
|
||||
|
||||
virtual bool shuffled() const = 0;
|
||||
|
||||
virtual PlaylistModes::ViewMode viewMode() const { return PlaylistModes::Unknown; }
|
||||
@@ -90,7 +93,9 @@ signals:
|
||||
void repeatModeChanged( Tomahawk::PlaylistModes::RepeatMode mode );
|
||||
void shuffleModeChanged( bool enabled );
|
||||
void latchModeChanged( Tomahawk::PlaylistModes::LatchMode mode );
|
||||
void nextTrackReady();
|
||||
|
||||
void previousTrackAvailable();
|
||||
void nextTrackAvailable();
|
||||
|
||||
protected:
|
||||
virtual QList<Tomahawk::query_ptr> filterTracks( const QList<Tomahawk::query_ptr>& queries );
|
||||
|
@@ -46,14 +46,14 @@ public:
|
||||
|
||||
virtual int trackCount() const;
|
||||
|
||||
virtual Tomahawk::query_ptr itemAt( unsigned int position ) const { Q_UNUSED( position ); Q_ASSERT( false ); return Tomahawk::query_ptr(); }
|
||||
virtual int indexOfResult( const Tomahawk::result_ptr& result ) const { Q_UNUSED( result ); Q_ASSERT( false ); return -1; }
|
||||
virtual int indexOfQuery( const Tomahawk::query_ptr& query ) const { Q_UNUSED( query ); Q_ASSERT( false ); return -1; }
|
||||
virtual void setCurrentIndex( qint64 index ) { Q_UNUSED( index ); }
|
||||
virtual Tomahawk::result_ptr resultAt( qint64 index ) const { Q_UNUSED( index ); Q_ASSERT( false ); return Tomahawk::result_ptr(); }
|
||||
virtual Tomahawk::query_ptr queryAt( qint64 index ) const { Q_UNUSED( index ); Q_ASSERT( false ); return Tomahawk::query_ptr(); }
|
||||
virtual qint64 indexOfResult( const Tomahawk::result_ptr& result ) const { Q_UNUSED( result ); Q_ASSERT( false ); return -1; }
|
||||
virtual qint64 indexOfQuery( const Tomahawk::query_ptr& query ) const { Q_UNUSED( query ); Q_ASSERT( false ); return -1; }
|
||||
|
||||
virtual bool hasNextItem() { return false; }
|
||||
virtual Tomahawk::result_ptr currentItem() const { return m_currentItem; }
|
||||
|
||||
virtual Tomahawk::result_ptr siblingItem( int /*itemsAway*/, bool /*readOnly*/ ) { return result_ptr(); }
|
||||
virtual qint64 siblingIndex( int /*itemsAway*/ ) const { return -1; }
|
||||
|
||||
virtual PlaylistModes::RepeatMode repeatMode() const { return PlaylistModes::NoRepeat; }
|
||||
virtual bool shuffled() const { return false; }
|
||||
|
@@ -50,18 +50,27 @@ SourcePlaylistInterface::~SourcePlaylistInterface()
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::result_ptr
|
||||
SourcePlaylistInterface::siblingItem( int itemsAway, bool readOnly )
|
||||
void
|
||||
SourcePlaylistInterface::setCurrentIndex( qint64 index )
|
||||
{
|
||||
Q_UNUSED( index );
|
||||
}
|
||||
|
||||
|
||||
qint64
|
||||
SourcePlaylistInterface::siblingIndex( int itemsAway ) const
|
||||
{
|
||||
Q_UNUSED( itemsAway );
|
||||
Q_UNUSED( readOnly );
|
||||
|
||||
return nextItem();
|
||||
if ( nextResult() )
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::result_ptr
|
||||
SourcePlaylistInterface::nextItem()
|
||||
SourcePlaylistInterface::nextResult() const
|
||||
{
|
||||
tDebug( LOGEXTRA ) << Q_FUNC_INFO;
|
||||
if ( !sourceValid() )
|
||||
@@ -70,7 +79,7 @@ SourcePlaylistInterface::nextItem()
|
||||
m_currentItem = Tomahawk::result_ptr();
|
||||
return m_currentItem;
|
||||
}
|
||||
else if ( !hasNextItem() )
|
||||
else if ( !hasNextResult() )
|
||||
{
|
||||
tDebug( LOGEXTRA ) << Q_FUNC_INFO << "This song was already fetched or the source isn't playing anything";
|
||||
return Tomahawk::result_ptr();
|
||||
@@ -95,7 +104,7 @@ SourcePlaylistInterface::currentItem() const
|
||||
|
||||
|
||||
bool
|
||||
SourcePlaylistInterface::sourceValid()
|
||||
SourcePlaylistInterface::sourceValid() const
|
||||
{
|
||||
tDebug( LOGEXTRA ) << Q_FUNC_INFO;
|
||||
if ( m_source.isNull() || m_source.data()->currentTrack().isNull() )
|
||||
@@ -106,7 +115,7 @@ SourcePlaylistInterface::sourceValid()
|
||||
|
||||
|
||||
bool
|
||||
SourcePlaylistInterface::hasNextItem()
|
||||
SourcePlaylistInterface::hasNextResult() const
|
||||
{
|
||||
if ( !sourceValid() )
|
||||
return false;
|
||||
@@ -157,6 +166,25 @@ SourcePlaylistInterface::resolvingFinished( bool hasResults )
|
||||
if ( hasResults )
|
||||
{
|
||||
m_gotNextItem = true;
|
||||
emit nextTrackReady();
|
||||
emit nextTrackAvailable();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::query_ptr
|
||||
SourcePlaylistInterface::queryAt( qint64 index ) const
|
||||
{
|
||||
Q_UNUSED( index );
|
||||
|
||||
Tomahawk::result_ptr res = nextResult();
|
||||
return res->toQuery();
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::result_ptr
|
||||
SourcePlaylistInterface::resultAt( qint64 index ) const
|
||||
{
|
||||
Q_UNUSED( index );
|
||||
|
||||
return nextResult();
|
||||
}
|
||||
|
@@ -43,14 +43,16 @@ public:
|
||||
|
||||
virtual int trackCount() const { return 1; }
|
||||
|
||||
virtual Tomahawk::query_ptr itemAt( unsigned int position ) const { Q_UNUSED( position ); Q_ASSERT( false ); return Tomahawk::query_ptr(); }
|
||||
virtual int indexOfResult( const Tomahawk::result_ptr& result ) const { Q_UNUSED( result ); Q_ASSERT( false ); return -1; }
|
||||
virtual int indexOfQuery( const Tomahawk::query_ptr& query ) const { Q_UNUSED( query ); Q_ASSERT( false ); return -1; }
|
||||
virtual void setCurrentIndex( qint64 index );
|
||||
virtual Tomahawk::result_ptr resultAt( qint64 index ) const;
|
||||
virtual Tomahawk::query_ptr queryAt( qint64 index ) const;
|
||||
virtual qint64 indexOfResult( const Tomahawk::result_ptr& result ) const { Q_UNUSED( result ); Q_ASSERT( false ); return -1; }
|
||||
virtual qint64 indexOfQuery( const Tomahawk::query_ptr& query ) const { Q_UNUSED( query ); Q_ASSERT( false ); return -1; }
|
||||
|
||||
virtual Tomahawk::result_ptr siblingItem( int itemsAway, bool readOnly = false );
|
||||
virtual bool sourceValid();
|
||||
virtual bool hasNextItem();
|
||||
virtual Tomahawk::result_ptr nextItem();
|
||||
virtual qint64 siblingIndex( int itemsAway ) const;
|
||||
virtual bool sourceValid() const;
|
||||
virtual bool hasNextResult() const;
|
||||
virtual Tomahawk::result_ptr nextResult() const;
|
||||
virtual Tomahawk::result_ptr currentItem() const;
|
||||
|
||||
virtual PlaylistModes::RepeatMode repeatMode() const { return PlaylistModes::NoRepeat; }
|
||||
@@ -78,8 +80,8 @@ private slots:
|
||||
|
||||
private:
|
||||
QWeakPointer< Tomahawk::Source > m_source;
|
||||
Tomahawk::result_ptr m_currentItem;
|
||||
bool m_gotNextItem;
|
||||
mutable Tomahawk::result_ptr m_currentItem;
|
||||
mutable bool m_gotNextItem;
|
||||
};
|
||||
|
||||
}; // ns
|
||||
|
@@ -223,7 +223,7 @@ AudioEngine::canGoNext()
|
||||
m_playlist.data()->skipRestrictions() == PlaylistModes::NoSkipForwards )
|
||||
return false;
|
||||
|
||||
if ( !m_currentTrack.isNull() && !m_playlist->hasNextItem() &&
|
||||
if ( !m_currentTrack.isNull() && !m_playlist->hasNextResult() &&
|
||||
( m_playlist->currentItem().isNull() || ( m_currentTrack->id() == m_playlist->currentItem()->id() ) ) )
|
||||
{
|
||||
//For instance, when doing a catch-up while listening along, but the person
|
||||
@@ -232,7 +232,7 @@ AudioEngine::canGoNext()
|
||||
return false;
|
||||
}
|
||||
|
||||
return m_playlist.data()->hasNextItem();
|
||||
return m_playlist.data()->hasNextResult();
|
||||
}
|
||||
|
||||
|
||||
@@ -246,7 +246,7 @@ AudioEngine::canGoPrevious()
|
||||
m_playlist.data()->skipRestrictions() == PlaylistModes::NoSkipBackwards )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return m_playlist.data()->hasPreviousResult();
|
||||
}
|
||||
|
||||
|
||||
@@ -327,7 +327,7 @@ AudioEngine::sendWaitingNotification() const
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
|
||||
//since it's async, after this is triggered our result could come in, so don't show the popup in that case
|
||||
if ( !m_playlist.isNull() && m_playlist->hasNextItem() )
|
||||
if ( !m_playlist.isNull() && m_playlist->hasNextResult() )
|
||||
return;
|
||||
|
||||
Tomahawk::InfoSystem::InfoPushData pushData (
|
||||
@@ -519,7 +519,13 @@ AudioEngine::loadPreviousTrack()
|
||||
return;
|
||||
}
|
||||
|
||||
Tomahawk::result_ptr result = m_playlist.data()->previousItem();
|
||||
Tomahawk::result_ptr result;
|
||||
if ( m_playlist.data()->hasPreviousResult() )
|
||||
{
|
||||
result = m_playlist.data()->previousResult();
|
||||
m_currentTrackPlaylist = m_playlist;
|
||||
}
|
||||
|
||||
if ( !result.isNull() )
|
||||
loadTrack( result );
|
||||
else
|
||||
@@ -546,14 +552,19 @@ AudioEngine::loadNextTrack()
|
||||
|
||||
if ( m_queue && m_queue->trackCount() )
|
||||
{
|
||||
result = m_queue->nextItem();
|
||||
result = m_queue->nextResult();
|
||||
}
|
||||
|
||||
if ( !m_playlist.isNull() && result.isNull() )
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Loading playlist's next item" << m_playlist.data() << m_playlist->shuffled();
|
||||
result = m_playlist.data()->nextItem();
|
||||
m_currentTrackPlaylist = m_playlist;
|
||||
|
||||
if ( m_playlist.data()->hasNextResult() )
|
||||
{
|
||||
result = m_playlist.data()->nextResult();
|
||||
tDebug() << Q_FUNC_INFO << result->toString();
|
||||
m_currentTrackPlaylist = m_playlist;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !result.isNull() )
|
||||
@@ -681,21 +692,25 @@ AudioEngine::playItem( const Tomahawk::album_ptr& album )
|
||||
|
||||
|
||||
void
|
||||
AudioEngine::onPlaylistNextTrackReady()
|
||||
AudioEngine::onPlaylistNextTrackAvailable()
|
||||
{
|
||||
// If in real-time and you have a few seconds left, you're probably lagging -- finish it up
|
||||
if ( m_playlist && m_playlist->latchMode() == PlaylistModes::RealTime && ( m_waitingOnNewTrack || m_currentTrack.isNull() || m_currentTrack->id() == 0 || ( currentTrackTotalTime() - currentTime() > 6000 ) ) )
|
||||
tDebug() << Q_FUNC_INFO;
|
||||
|
||||
{
|
||||
// If in real-time and you have a few seconds left, you're probably lagging -- finish it up
|
||||
if ( m_playlist && m_playlist->latchMode() == PlaylistModes::RealTime && ( m_waitingOnNewTrack || m_currentTrack.isNull() || m_currentTrack->id() == 0 || ( currentTrackTotalTime() - currentTime() > 6000 ) ) )
|
||||
{
|
||||
m_waitingOnNewTrack = false;
|
||||
loadNextTrack();
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !m_waitingOnNewTrack )
|
||||
return;
|
||||
|
||||
m_waitingOnNewTrack = false;
|
||||
loadNextTrack();
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !m_waitingOnNewTrack )
|
||||
return;
|
||||
|
||||
m_waitingOnNewTrack = false;
|
||||
loadNextTrack();
|
||||
}
|
||||
|
||||
|
||||
@@ -815,8 +830,12 @@ AudioEngine::setPlaylist( Tomahawk::playlistinterface_ptr playlist )
|
||||
|
||||
if ( !m_playlist.isNull() )
|
||||
{
|
||||
if ( m_playlist.data() && m_playlist.data()->retryMode() == PlaylistModes::Retry )
|
||||
disconnect( m_playlist.data(), SIGNAL( nextTrackReady() ) );
|
||||
if ( m_playlist.data() )
|
||||
{
|
||||
disconnect( m_playlist.data(), SIGNAL( previousTrackAvailable( bool ) ) );
|
||||
disconnect( m_playlist.data(), SIGNAL( nextTrackAvailable( bool ) ) );
|
||||
}
|
||||
|
||||
m_playlist.data()->reset();
|
||||
}
|
||||
|
||||
@@ -830,8 +849,13 @@ AudioEngine::setPlaylist( Tomahawk::playlistinterface_ptr playlist )
|
||||
m_playlist = playlist;
|
||||
m_stopAfterTrack.clear();
|
||||
|
||||
if ( !m_playlist.isNull() && m_playlist.data() && m_playlist.data()->retryMode() == PlaylistModes::Retry )
|
||||
connect( m_playlist.data(), SIGNAL( nextTrackReady() ), SLOT( onPlaylistNextTrackReady() ) );
|
||||
if ( !m_playlist.isNull() )
|
||||
{
|
||||
connect( m_playlist.data(), SIGNAL( nextTrackAvailable() ), SLOT( onPlaylistNextTrackAvailable() ) );
|
||||
|
||||
connect( m_playlist.data(), SIGNAL( previousTrackAvailable() ), SIGNAL( controlStateChanged() ) );
|
||||
connect( m_playlist.data(), SIGNAL( nextTrackAvailable() ), SIGNAL( controlStateChanged() ) );
|
||||
}
|
||||
|
||||
emit playlistChanged( playlist );
|
||||
}
|
||||
@@ -863,6 +887,14 @@ AudioEngine::setCurrentTrack( const Tomahawk::result_ptr& result )
|
||||
}
|
||||
|
||||
m_currentTrack = result;
|
||||
|
||||
if ( result )
|
||||
{
|
||||
if ( m_playlist )
|
||||
{
|
||||
m_playlist.data()->setCurrentIndex( m_playlist.data()->indexOfResult( result ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -64,7 +64,6 @@ public:
|
||||
Tomahawk::playlistinterface_ptr playlist() const { return m_playlist; }
|
||||
|
||||
Tomahawk::result_ptr currentTrack() const { return m_currentTrack; }
|
||||
|
||||
Tomahawk::query_ptr stopAfterTrack() const { return m_stopAfterTrack; }
|
||||
|
||||
qint64 currentTime() const { return m_mediaObject->currentTime(); }
|
||||
@@ -111,6 +110,7 @@ signals:
|
||||
|
||||
void seeked( qint64 ms );
|
||||
|
||||
void controlStateChanged();
|
||||
void stateChanged( AudioState newState, AudioState oldState );
|
||||
void volumeChanged( int volume /* in percent */ );
|
||||
|
||||
@@ -134,7 +134,7 @@ private slots:
|
||||
|
||||
void setCurrentTrack( const Tomahawk::result_ptr& result );
|
||||
void onNowPlayingInfoReady( const Tomahawk::InfoSystem::InfoType type );
|
||||
void onPlaylistNextTrackReady();
|
||||
void onPlaylistNextTrackAvailable();
|
||||
|
||||
void sendNowPlayingNotification( const Tomahawk::InfoSystem::InfoType type );
|
||||
void sendWaitingNotification() const;
|
||||
|
@@ -54,41 +54,45 @@ DatabaseCommand_LoadPlaylistEntries::generateEntries( DatabaseImpl* dbi )
|
||||
|
||||
if ( query_entries.next() )
|
||||
{
|
||||
// entries should be a list of strings:
|
||||
QVariant v = parser.parse( query_entries.value( 0 ).toByteArray(), &ok );
|
||||
Q_ASSERT( ok && v.type() == QVariant::List ); //TODO
|
||||
m_guids = v.toStringList();
|
||||
QString inclause = QString( "('%1')" ).arg( m_guids.join( "', '" ) );
|
||||
|
||||
TomahawkSqlQuery query = dbi->newquery();
|
||||
QString sql = QString( "SELECT guid, trackname, artistname, albumname, annotation, "
|
||||
"duration, addedon, addedby, result_hint "
|
||||
"FROM playlist_item "
|
||||
"WHERE guid IN %1" ).arg( inclause );
|
||||
|
||||
query.exec( sql );
|
||||
while ( query.next() )
|
||||
if ( !query_entries.value( 0 ).isNull() )
|
||||
{
|
||||
plentry_ptr e( new PlaylistEntry );
|
||||
e->setGuid( query.value( 0 ).toString() );
|
||||
e->setAnnotation( query.value( 4 ).toString() );
|
||||
e->setDuration( query.value( 5 ).toUInt() );
|
||||
e->setLastmodified( 0 ); // TODO e->lastmodified = query.value( 6 ).toInt();
|
||||
const QString resultHint = query.value( 8 ).toString();
|
||||
e->setResultHint( resultHint );
|
||||
// entries should be a list of strings:
|
||||
QVariant v = parser.parse( query_entries.value( 0 ).toByteArray(), &ok );
|
||||
Q_ASSERT( ok && v.type() == QVariant::List ); //TODO
|
||||
|
||||
Tomahawk::query_ptr q = Tomahawk::Query::get( query.value( 2 ).toString(), query.value( 1 ).toString(), query.value( 3 ).toString() );
|
||||
if ( q.isNull() )
|
||||
continue;
|
||||
m_guids = v.toStringList();
|
||||
QString inclause = QString( "('%1')" ).arg( m_guids.join( "', '" ) );
|
||||
|
||||
q->setResultHint( resultHint );
|
||||
if ( resultHint.startsWith( "http" ) )
|
||||
q->setSaveHTTPResultHint( true );
|
||||
TomahawkSqlQuery query = dbi->newquery();
|
||||
QString sql = QString( "SELECT guid, trackname, artistname, albumname, annotation, "
|
||||
"duration, addedon, addedby, result_hint "
|
||||
"FROM playlist_item "
|
||||
"WHERE guid IN %1" ).arg( inclause );
|
||||
|
||||
q->setProperty( "annotation", e->annotation() );
|
||||
e->setQuery( q );
|
||||
query.exec( sql );
|
||||
while ( query.next() )
|
||||
{
|
||||
plentry_ptr e( new PlaylistEntry );
|
||||
e->setGuid( query.value( 0 ).toString() );
|
||||
e->setAnnotation( query.value( 4 ).toString() );
|
||||
e->setDuration( query.value( 5 ).toUInt() );
|
||||
e->setLastmodified( 0 ); // TODO e->lastmodified = query.value( 6 ).toInt();
|
||||
const QString resultHint = query.value( 8 ).toString();
|
||||
e->setResultHint( resultHint );
|
||||
|
||||
m_entrymap.insert( e->guid(), e );
|
||||
Tomahawk::query_ptr q = Tomahawk::Query::get( query.value( 2 ).toString(), query.value( 1 ).toString(), query.value( 3 ).toString() );
|
||||
if ( q.isNull() )
|
||||
continue;
|
||||
|
||||
q->setResultHint( resultHint );
|
||||
if ( resultHint.startsWith( "http" ) )
|
||||
q->setSaveHTTPResultHint( true );
|
||||
|
||||
q->setProperty( "annotation", e->annotation() );
|
||||
e->setQuery( q );
|
||||
|
||||
m_entrymap.insert( e->guid(), e );
|
||||
}
|
||||
}
|
||||
|
||||
prevrev = query_entries.value( 4 ).toString();
|
||||
@@ -116,9 +120,12 @@ DatabaseCommand_LoadPlaylistEntries::generateEntries( DatabaseImpl* dbi )
|
||||
Q_ASSERT( false );
|
||||
}
|
||||
|
||||
QVariant v = parser.parse( query_entries_old.value( 0 ).toByteArray(), &ok );
|
||||
Q_ASSERT( ok && v.type() == QVariant::List ); //TODO
|
||||
m_oldentries = v.toStringList();
|
||||
if ( !query_entries_old.value( 0 ).isNull() )
|
||||
{
|
||||
QVariant v = parser.parse( query_entries_old.value( 0 ).toByteArray(), &ok );
|
||||
Q_ASSERT( ok && v.type() == QVariant::List ); //TODO
|
||||
m_oldentries = v.toStringList();
|
||||
}
|
||||
m_islatest = query_entries_old.value( 1 ).toBool();
|
||||
}
|
||||
|
||||
|
@@ -248,12 +248,12 @@ MetadataEditor::loadResult( const Tomahawk::result_ptr& result )
|
||||
void
|
||||
MetadataEditor::enablePushButtons()
|
||||
{
|
||||
if ( m_interface->itemAt( m_index + 1 ) )
|
||||
if ( m_interface->queryAt( m_index + 1 ) )
|
||||
ui->forwardPushButton->setEnabled( true );
|
||||
else
|
||||
ui->forwardPushButton->setEnabled( false );
|
||||
|
||||
if ( m_interface->itemAt( m_index - 1 ) )
|
||||
if ( m_interface->queryAt( m_index - 1 ) )
|
||||
ui->previousPushButton->setEnabled( true );
|
||||
else
|
||||
ui->previousPushButton->setEnabled( false );
|
||||
@@ -267,8 +267,8 @@ MetadataEditor::loadNextResult()
|
||||
|
||||
m_index++;
|
||||
|
||||
if ( m_interface->itemAt( m_index ) )
|
||||
loadQuery( m_interface->itemAt( m_index ) );
|
||||
if ( m_interface->queryAt( m_index ) )
|
||||
loadQuery( m_interface->queryAt( m_index ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -279,8 +279,8 @@ MetadataEditor::loadPreviousResult()
|
||||
|
||||
m_index--;
|
||||
|
||||
if ( m_interface->itemAt( m_index ) )
|
||||
loadQuery( m_interface->itemAt( m_index ) );
|
||||
if ( m_interface->queryAt( m_index ) )
|
||||
loadQuery( m_interface->queryAt( m_index ) );
|
||||
}
|
||||
|
||||
|
||||
|
@@ -213,7 +213,7 @@ DBSyncConnection::handleMsg( msg_ptr msg )
|
||||
if ( m.value( "method" ).toString() == "fetchops" )
|
||||
{
|
||||
++m_fetchCount;
|
||||
tDebug() << "Fetching new dbops:" << m["lastop"].toString() << m_fetchCount;
|
||||
tDebug( LOGVERBOSE ) << "Fetching new dbops:" << m["lastop"].toString() << m_fetchCount;
|
||||
m_uscache = m;
|
||||
sendOps();
|
||||
return;
|
||||
|
@@ -35,38 +35,6 @@
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
class FlexibleViewInterface : public PlayableProxyModelPlaylistInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FlexibleViewInterface( PlayableProxyModel* proxy, FlexibleView* view )
|
||||
: PlayableProxyModelPlaylistInterface( proxy )
|
||||
, m_view( view )
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool hasChildInterface( playlistinterface_ptr playlistInterface )
|
||||
{
|
||||
if ( m_view.isNull() )
|
||||
return false;
|
||||
|
||||
if ( m_view.data()->detailedView() && m_view.data()->detailedView()->proxyModel()->playlistInterface() == playlistInterface )
|
||||
return true;
|
||||
|
||||
if ( m_view.data()->gridView() && m_view.data()->gridView()->playlistInterface()->hasChildInterface( playlistInterface ) )
|
||||
return true;
|
||||
|
||||
if ( m_view.data()->trackView() && m_view.data()->trackView()->proxyModel()->playlistInterface() == playlistInterface )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
QWeakPointer<FlexibleView> m_view;
|
||||
};
|
||||
|
||||
|
||||
FlexibleView::FlexibleView( QWidget* parent )
|
||||
: QWidget( parent )
|
||||
, m_header( new FlexibleHeader( this ) )
|
||||
@@ -77,9 +45,8 @@ FlexibleView::FlexibleView( QWidget* parent )
|
||||
{
|
||||
qRegisterMetaType< FlexibleViewMode >( "FlexibleViewMode" );
|
||||
|
||||
m_playlistInterface = playlistinterface_ptr( new FlexibleViewInterface( m_trackView->proxyModel(), this ) );
|
||||
m_trackView->setPlaylistInterface( m_playlistInterface );
|
||||
m_detailedView->setPlaylistInterface( m_playlistInterface );
|
||||
// m_trackView->setPlaylistInterface( m_playlistInterface );
|
||||
m_detailedView->setPlaylistInterface( m_trackView->proxyModel()->playlistInterface() );
|
||||
|
||||
m_detailedView->setColumnHidden( PlayableModel::Age, true ); // Hide age column per default
|
||||
m_detailedView->setColumnHidden( PlayableModel::Filesize, true ); // Hide filesize column per default
|
||||
@@ -130,7 +97,7 @@ FlexibleView::setTrackView( TrackView* view )
|
||||
delete m_trackView;
|
||||
}
|
||||
|
||||
view->setPlaylistInterface( m_playlistInterface );
|
||||
// view->setPlaylistInterface( m_playlistInterface );
|
||||
|
||||
m_trackView = view;
|
||||
m_stack->addWidget( view );
|
||||
@@ -148,7 +115,7 @@ FlexibleView::setDetailedView( TrackView* view )
|
||||
|
||||
connect( view, SIGNAL( destroyed( QWidget* ) ), SLOT( onWidgetDestroyed( QWidget* ) ), Qt::UniqueConnection );
|
||||
|
||||
view->setPlaylistInterface( m_playlistInterface );
|
||||
view->setPlaylistInterface( m_trackView->proxyModel()->playlistInterface() );
|
||||
|
||||
m_detailedView = view;
|
||||
m_stack->addWidget( view );
|
||||
@@ -241,7 +208,7 @@ FlexibleView::setCurrentMode( FlexibleViewMode mode )
|
||||
Tomahawk::playlistinterface_ptr
|
||||
FlexibleView::playlistInterface() const
|
||||
{
|
||||
return m_playlistInterface;
|
||||
return m_trackView->proxyModel()->playlistInterface();
|
||||
}
|
||||
|
||||
|
||||
|
@@ -30,7 +30,6 @@ class TrackView;
|
||||
class PlayableModel;
|
||||
class PlaylistModel;
|
||||
class FlexibleHeader;
|
||||
class FlexibleViewInterface;
|
||||
|
||||
class DLLEXPORT FlexibleView : public QWidget, public Tomahawk::ViewPage
|
||||
{
|
||||
@@ -89,14 +88,10 @@ private:
|
||||
TrackView* m_detailedView;
|
||||
GridView* m_gridView;
|
||||
|
||||
Tomahawk::playlistinterface_ptr m_playlistInterface;
|
||||
|
||||
PlayableModel* m_model;
|
||||
QStackedWidget* m_stack;
|
||||
|
||||
FlexibleViewMode m_mode;
|
||||
|
||||
friend class ::FlexibleViewInterface;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE( FlexibleView::FlexibleViewMode );
|
||||
|
@@ -62,6 +62,18 @@ PlayableModel::~PlayableModel()
|
||||
}
|
||||
|
||||
|
||||
QModelIndex
|
||||
PlayableModel::createIndex( int row, int column, PlayableItem* item ) const
|
||||
{
|
||||
if ( item->query() )
|
||||
{
|
||||
connect( item->query().data(), SIGNAL( playableStateChanged( bool ) ), SLOT( onQueryBecamePlayable( bool ) ), Qt::UniqueConnection );
|
||||
}
|
||||
|
||||
return QAbstractItemModel::createIndex( row, column, item );
|
||||
}
|
||||
|
||||
|
||||
QModelIndex
|
||||
PlayableModel::index( int row, int column, const QModelIndex& parent ) const
|
||||
{
|
||||
@@ -324,6 +336,7 @@ PlayableModel::setCurrentItem( const QModelIndex& index )
|
||||
PlayableItem* oldEntry = itemFromIndex( m_currentIndex );
|
||||
if ( oldEntry )
|
||||
{
|
||||
tDebug() << "ISNT PLAYING ANYMORE:" << oldEntry->name();
|
||||
oldEntry->setIsPlaying( false );
|
||||
}
|
||||
|
||||
@@ -332,6 +345,7 @@ PlayableModel::setCurrentItem( const QModelIndex& index )
|
||||
{
|
||||
m_currentIndex = index;
|
||||
m_currentUuid = entry->query()->id();
|
||||
tDebug() << "IS PLAYING NOW:" << entry->name();
|
||||
entry->setIsPlaying( true );
|
||||
}
|
||||
else
|
||||
@@ -562,7 +576,7 @@ PlayableModel::insertInternal( const QList< T >& items, int row )
|
||||
|
||||
int i = 0;
|
||||
PlayableItem* plitem;
|
||||
foreach( const T& item, items )
|
||||
foreach ( const T& item, items )
|
||||
{
|
||||
plitem = new PlayableItem( item, m_rootItem, row + i );
|
||||
plitem->index = createIndex( row + i, 0, plitem );
|
||||
@@ -878,9 +892,32 @@ PlayableModel::setIcon( const QPixmap& pixmap )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlayableModel::onQueryBecamePlayable( bool playable )
|
||||
{
|
||||
Tomahawk::Query* q = qobject_cast< Query* >( sender() );
|
||||
if ( !q )
|
||||
{
|
||||
// Track has been removed from the playlist by now
|
||||
return;
|
||||
}
|
||||
|
||||
Tomahawk::query_ptr query = q->weakRef().toStrongRef();
|
||||
PlayableItem* item = itemFromQuery( query );
|
||||
|
||||
if ( item )
|
||||
{
|
||||
emit indexPlayable( item->index );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PlayableItem*
|
||||
PlayableModel::itemFromQuery( const Tomahawk::query_ptr& query ) const
|
||||
{
|
||||
if ( !query )
|
||||
return 0;
|
||||
|
||||
for ( int i = 0; i < rowCount( QModelIndex() ); i++ )
|
||||
{
|
||||
QModelIndex idx = index( i, 0, QModelIndex() );
|
||||
@@ -894,3 +931,24 @@ PlayableModel::itemFromQuery( const Tomahawk::query_ptr& query ) const
|
||||
tDebug() << "Could not find item for query:" << query->toString();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
PlayableItem*
|
||||
PlayableModel::itemFromResult( const Tomahawk::result_ptr& result ) const
|
||||
{
|
||||
if ( !result )
|
||||
return 0;
|
||||
|
||||
for ( int i = 0; i < rowCount( QModelIndex() ); i++ )
|
||||
{
|
||||
QModelIndex idx = index( i, 0, QModelIndex() );
|
||||
PlayableItem* item = itemFromIndex( idx );
|
||||
if ( item && item->result() == result )
|
||||
{
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
tDebug() << "Could not find item for result:" << result->toString();
|
||||
return 0;
|
||||
}
|
||||
|
@@ -122,6 +122,7 @@ public:
|
||||
|
||||
PlayableItem* itemFromIndex( const QModelIndex& index ) const;
|
||||
PlayableItem* itemFromQuery( const Tomahawk::query_ptr& query ) const;
|
||||
PlayableItem* itemFromResult( const Tomahawk::result_ptr& result ) const;
|
||||
Q_INVOKABLE PlayableItem* itemFromIndex( int itemIndex ) const;
|
||||
|
||||
/// Returns a flat list of all tracks in this model
|
||||
@@ -140,6 +141,7 @@ signals:
|
||||
void loadingStarted();
|
||||
void loadingFinished();
|
||||
|
||||
void indexPlayable( const QModelIndex& index );
|
||||
void changed();
|
||||
void currentItemChanged( const QPersistentModelIndex ¤tIndex );
|
||||
|
||||
@@ -172,9 +174,11 @@ public slots:
|
||||
|
||||
protected:
|
||||
PlayableItem* rootItem() const { return m_rootItem; }
|
||||
QModelIndex createIndex( int row, int column, PlayableItem* item = 0 ) const;
|
||||
|
||||
private slots:
|
||||
void onDataChanged();
|
||||
void onQueryBecamePlayable( bool playable );
|
||||
|
||||
void onPlaybackStarted( const Tomahawk::result_ptr& result );
|
||||
void onPlaybackStopped();
|
||||
|
@@ -38,6 +38,8 @@ PlayableProxyModel::PlayableProxyModel( QObject* parent )
|
||||
, m_maxVisibleItems( -1 )
|
||||
, m_style( Detailed )
|
||||
{
|
||||
m_playlistInterface = Tomahawk::playlistinterface_ptr( new Tomahawk::PlayableProxyModelPlaylistInterface( this ) );
|
||||
|
||||
setFilterCaseSensitivity( Qt::CaseInsensitive );
|
||||
setSortCaseSensitivity( Qt::CaseInsensitive );
|
||||
setDynamicSortFilter( true );
|
||||
@@ -50,6 +52,20 @@ PlayableProxyModel::PlayableProxyModel( QObject* parent )
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::playlistinterface_ptr
|
||||
PlayableProxyModel::playlistInterface() const
|
||||
{
|
||||
return m_playlistInterface;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlayableProxyModel::setPlaylistInterface( const Tomahawk::playlistinterface_ptr& playlistInterface )
|
||||
{
|
||||
m_playlistInterface = playlistInterface;
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
PlayableProxyModel::guid() const
|
||||
{
|
||||
@@ -90,6 +106,7 @@ PlayableProxyModel::setSourcePlayableModel( PlayableModel* sourceModel )
|
||||
{
|
||||
disconnect( m_model, SIGNAL( loadingStarted() ), this, SIGNAL( loadingStarted() ) );
|
||||
disconnect( m_model, SIGNAL( loadingFinished() ), this, SIGNAL( loadingFinished() ) );
|
||||
disconnect( m_model, SIGNAL( indexPlayable( QModelIndex ) ), this, SLOT( onIndexPlayable( QModelIndex ) ) );
|
||||
}
|
||||
|
||||
m_model = sourceModel;
|
||||
@@ -98,6 +115,7 @@ PlayableProxyModel::setSourcePlayableModel( PlayableModel* sourceModel )
|
||||
{
|
||||
connect( m_model, SIGNAL( loadingStarted() ), SIGNAL( loadingStarted() ) );
|
||||
connect( m_model, SIGNAL( loadingFinished() ), SIGNAL( loadingFinished() ) );
|
||||
connect( m_model, SIGNAL( indexPlayable( QModelIndex ) ), SLOT( onIndexPlayable( QModelIndex ) ) );
|
||||
}
|
||||
|
||||
QSortFilterProxyModel::setSourceModel( m_model );
|
||||
@@ -482,18 +500,6 @@ PlayableProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::playlistinterface_ptr
|
||||
PlayableProxyModel::playlistInterface()
|
||||
{
|
||||
if ( m_playlistInterface.isNull() )
|
||||
{
|
||||
m_playlistInterface = Tomahawk::playlistinterface_ptr( new Tomahawk::PlayableProxyModelPlaylistInterface( this ) );
|
||||
}
|
||||
|
||||
return m_playlistInterface;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
PlayableProxyModel::columnCount( const QModelIndex& parent ) const
|
||||
{
|
||||
@@ -618,9 +624,26 @@ PlayableProxyModel::setFilter( const QString& pattern )
|
||||
}
|
||||
|
||||
PlayableItem*
|
||||
PlayableProxyModel::itemFromIndex(int itemIndex) const
|
||||
PlayableProxyModel::itemFromIndex( int itemIndex ) const
|
||||
{
|
||||
// qDebug() << "returning item" << sourceModel()->itemFromIndex( itemIndex )->name();
|
||||
QModelIndex modelIndex = index( itemIndex, 0 );
|
||||
return sourceModel()->itemFromIndex( mapToSource( modelIndex ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlayableProxyModel::setCurrentIndex( const QModelIndex& index )
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO << QThread::currentThread();
|
||||
m_model->setCurrentItem( mapToSource( index ) );
|
||||
|
||||
emit currentIndexChanged();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlayableProxyModel::onIndexPlayable( const QModelIndex& index )
|
||||
{
|
||||
emit indexPlayable( mapFromSource( index ) );
|
||||
}
|
||||
|
@@ -53,7 +53,7 @@ public:
|
||||
void setStyle( PlayableProxyModel::PlayableItemStyle style ) { m_style = style; }
|
||||
|
||||
virtual QPersistentModelIndex currentIndex() const { return mapFromSource( m_model->currentItem() ); }
|
||||
virtual void setCurrentIndex( const QModelIndex& index ) { m_model->setCurrentItem( mapToSource( index ) ); }
|
||||
virtual void setCurrentIndex( const QModelIndex& index );
|
||||
|
||||
virtual void removeIndex( const QModelIndex& index );
|
||||
virtual void removeIndexes( const QModelIndexList& indexes );
|
||||
@@ -70,9 +70,11 @@ public:
|
||||
|
||||
virtual PlayableItem* itemFromIndex( const QModelIndex& index ) const { return sourceModel()->itemFromIndex( index ); }
|
||||
virtual PlayableItem* itemFromQuery( const Tomahawk::query_ptr& query ) const { return sourceModel()->itemFromQuery( query ); }
|
||||
virtual PlayableItem* itemFromResult( const Tomahawk::result_ptr& result ) const { return sourceModel()->itemFromResult( result ); }
|
||||
Q_INVOKABLE virtual PlayableItem* itemFromIndex( int itemIndex ) const;
|
||||
|
||||
virtual Tomahawk::playlistinterface_ptr playlistInterface();
|
||||
virtual Tomahawk::playlistinterface_ptr playlistInterface() const;
|
||||
void setPlaylistInterface( const Tomahawk::playlistinterface_ptr& playlistInterface );
|
||||
|
||||
QList< double > columnWeights() const;
|
||||
|
||||
@@ -92,12 +94,18 @@ signals:
|
||||
void loadingStarted();
|
||||
void loadingFinished();
|
||||
|
||||
void indexPlayable( const QModelIndex& index );
|
||||
void currentIndexChanged();
|
||||
|
||||
protected:
|
||||
virtual bool filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const;
|
||||
virtual bool lessThan( const QModelIndex& left, const QModelIndex& right ) const;
|
||||
|
||||
Tomahawk::playlistinterface_ptr m_playlistInterface;
|
||||
|
||||
private slots:
|
||||
void onIndexPlayable( const QModelIndex& index );
|
||||
|
||||
private:
|
||||
virtual bool lessThan( int column, const Tomahawk::query_ptr& left, const Tomahawk::query_ptr& right ) const;
|
||||
|
||||
|
@@ -35,12 +35,18 @@ PlayableProxyModelPlaylistInterface::PlayableProxyModelPlaylistInterface( Playab
|
||||
, m_proxyModel( proxyModel )
|
||||
, m_repeatMode( PlaylistModes::NoRepeat )
|
||||
, m_shuffled( false )
|
||||
, m_prevAvail( false )
|
||||
, m_nextAvail( false )
|
||||
{
|
||||
connect( proxyModel, SIGNAL( currentIndexChanged() ), SLOT( onModelChanged() ) );
|
||||
connect( proxyModel, SIGNAL( indexPlayable( QModelIndex ) ), SLOT( onModelChanged() ) );
|
||||
// connect( proxyModel, SIGNAL( trackCountChanged( unsigned int ) ), SLOT( onModelChanged() ) );
|
||||
}
|
||||
|
||||
|
||||
PlayableProxyModelPlaylistInterface::~PlayableProxyModelPlaylistInterface()
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO;
|
||||
m_proxyModel.clear();
|
||||
}
|
||||
|
||||
@@ -59,6 +65,54 @@ PlayableProxyModelPlaylistInterface::filter() const
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlayableProxyModelPlaylistInterface::onModelChanged()
|
||||
{
|
||||
// tDebug() << Q_FUNC_INFO << this;
|
||||
if ( QThread::currentThread() != thread() )
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO << "Reinvoking in correct thread!";
|
||||
QMetaObject::invokeMethod( this, "onModelChanged", Qt::QueuedConnection );
|
||||
return;
|
||||
}
|
||||
|
||||
Tomahawk::result_ptr prevResult = siblingResult( -1 );
|
||||
Tomahawk::result_ptr nextResult = siblingResult( 1 );
|
||||
|
||||
if ( prevResult )
|
||||
{
|
||||
// tDebug() << Q_FUNC_INFO << "Prev result:" << prevResult->toString();
|
||||
bool avail = prevResult->toQuery()->playable();
|
||||
if ( avail != m_prevAvail )
|
||||
{
|
||||
m_prevAvail = avail;
|
||||
emit previousTrackAvailable();
|
||||
}
|
||||
}
|
||||
else if ( m_prevAvail )
|
||||
{
|
||||
m_prevAvail = false;
|
||||
emit previousTrackAvailable();
|
||||
}
|
||||
|
||||
if ( nextResult )
|
||||
{
|
||||
// tDebug() << Q_FUNC_INFO << "Next result:" << m_nextResult->toString();
|
||||
bool avail = nextResult->toQuery()->playable();
|
||||
if ( avail != m_nextAvail )
|
||||
{
|
||||
m_nextAvail = avail;
|
||||
emit nextTrackAvailable();
|
||||
}
|
||||
}
|
||||
else if ( m_nextAvail )
|
||||
{
|
||||
m_nextAvail = false;
|
||||
emit nextTrackAvailable();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QList< Tomahawk::query_ptr >
|
||||
PlayableProxyModelPlaylistInterface::tracks()
|
||||
{
|
||||
@@ -79,20 +133,30 @@ PlayableProxyModelPlaylistInterface::tracks()
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PlayableProxyModelPlaylistInterface::hasNextItem()
|
||||
void
|
||||
PlayableProxyModelPlaylistInterface::setCurrentIndex( qint64 index )
|
||||
{
|
||||
return !( siblingItem( 1, true ).isNull() );
|
||||
tDebug() << Q_FUNC_INFO << index;
|
||||
|
||||
PlayableItem* item = static_cast<PlayableItem*>( (void*)index );
|
||||
if ( !item )
|
||||
{
|
||||
m_proxyModel.data()->setCurrentIndex( QModelIndex() );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_proxyModel.data()->setCurrentIndex( m_proxyModel.data()->mapFromSource( item->index ) );
|
||||
m_shuffleHistory << queryAt( index );
|
||||
m_shuffleCache = QPersistentModelIndex();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::result_ptr
|
||||
PlayableProxyModelPlaylistInterface::siblingItem( int itemsAway, bool readOnly )
|
||||
qint64
|
||||
PlayableProxyModelPlaylistInterface::siblingIndex( int itemsAway ) const
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << m_shuffled << itemsAway << readOnly;
|
||||
|
||||
if ( m_proxyModel.isNull() )
|
||||
return result_ptr();
|
||||
return -1;
|
||||
|
||||
PlayableProxyModel* proxyModel = m_proxyModel.data();
|
||||
|
||||
@@ -101,7 +165,7 @@ PlayableProxyModelPlaylistInterface::siblingItem( int itemsAway, bool readOnly )
|
||||
m_shuffleHistory.removeFirst();
|
||||
}
|
||||
|
||||
QModelIndex idx = proxyModel->index( 0, 0 );
|
||||
QModelIndex idx = QModelIndex();
|
||||
if ( proxyModel->rowCount() )
|
||||
{
|
||||
if ( m_shuffled )
|
||||
@@ -115,7 +179,7 @@ PlayableProxyModelPlaylistInterface::siblingItem( int itemsAway, bool readOnly )
|
||||
idx = proxyModel->mapFromSource( proxyModel->itemFromQuery( m_shuffleHistory.takeLast() )->index );
|
||||
}
|
||||
else
|
||||
return result_ptr();
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -139,12 +203,9 @@ PlayableProxyModelPlaylistInterface::siblingItem( int itemsAway, bool readOnly )
|
||||
|
||||
if ( item && item->query()->playable() )
|
||||
{
|
||||
if ( readOnly )
|
||||
{
|
||||
m_shuffleCache = idx;
|
||||
tDebug( LOGVERBOSE ) << "Next shuffled PlaylistItem cached:" << item->query()->toString() << item->query()->results().at( 0 )->url()
|
||||
<< "- after" << safetyCounter << "tries to find a track";
|
||||
}
|
||||
m_shuffleCache = idx;
|
||||
tDebug( LOGVERBOSE ) << "Next shuffled PlaylistItem cached:" << item->query()->toString() << item->query()->results().at( 0 )->url()
|
||||
<< "- after" << safetyCounter << "tries to find a track";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -185,26 +246,16 @@ PlayableProxyModelPlaylistInterface::siblingItem( int itemsAway, bool readOnly )
|
||||
while ( idx.isValid() )
|
||||
{
|
||||
PlayableItem* item = proxyModel->itemFromIndex( proxyModel->mapToSource( idx ) );
|
||||
if ( item && item->query()->playable() )
|
||||
if ( item )
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << "Next PlaylistItem found:" << item->query()->toString() << item->query()->results().at( 0 )->url();
|
||||
if ( !readOnly )
|
||||
{
|
||||
proxyModel->setCurrentIndex( idx );
|
||||
m_shuffleHistory << item->query();
|
||||
m_shuffleCache = QPersistentModelIndex();
|
||||
}
|
||||
|
||||
return item->query()->results().at( 0 );
|
||||
tDebug( LOGVERBOSE ) << "Next PlaylistItem found:" << item->query()->toString() << (qint64)( item->index.internalPointer() );
|
||||
return (qint64)( item->index.internalPointer() );
|
||||
}
|
||||
|
||||
idx = proxyModel->index( idx.row() + ( itemsAway > 0 ? 1 : -1 ), 0 );
|
||||
}
|
||||
|
||||
if ( !readOnly )
|
||||
proxyModel->setCurrentIndex( QModelIndex() );
|
||||
|
||||
return result_ptr();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -225,14 +276,12 @@ PlayableProxyModelPlaylistInterface::currentItem() const
|
||||
|
||||
|
||||
Tomahawk::query_ptr
|
||||
PlayableProxyModelPlaylistInterface::itemAt( unsigned int position ) const
|
||||
PlayableProxyModelPlaylistInterface::queryAt( qint64 index ) const
|
||||
{
|
||||
if ( m_proxyModel.isNull() )
|
||||
return query_ptr();
|
||||
|
||||
PlayableProxyModel* proxyModel = m_proxyModel.data();
|
||||
|
||||
PlayableItem* item = proxyModel->itemFromIndex( proxyModel->mapToSource( proxyModel->index( position, 0 ) ) );
|
||||
PlayableItem* item = static_cast<PlayableItem*>( (void*)index );
|
||||
if ( item && item->query() )
|
||||
return item->query();
|
||||
|
||||
@@ -240,43 +289,43 @@ PlayableProxyModelPlaylistInterface::itemAt( unsigned int position ) const
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
Tomahawk::result_ptr
|
||||
PlayableProxyModelPlaylistInterface::resultAt( qint64 index ) const
|
||||
{
|
||||
if ( m_proxyModel.isNull() )
|
||||
return result_ptr();
|
||||
|
||||
PlayableItem* item = static_cast<PlayableItem*>( (void*)index );
|
||||
if ( item && item->result() )
|
||||
return item->result();
|
||||
|
||||
return result_ptr();
|
||||
}
|
||||
|
||||
|
||||
qint64
|
||||
PlayableProxyModelPlaylistInterface::indexOfResult( const Tomahawk::result_ptr& result ) const
|
||||
{
|
||||
if ( m_proxyModel.isNull() )
|
||||
return -1;
|
||||
|
||||
PlayableProxyModel* proxyModel = m_proxyModel.data();
|
||||
|
||||
for ( int i = 0; i < proxyModel->rowCount( QModelIndex() ); i++ )
|
||||
{
|
||||
PlayableItem* item = proxyModel->itemFromIndex( proxyModel->mapToSource( proxyModel->index( i, 0 ) ) );
|
||||
if ( item && item->result() == result )
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
PlayableItem* item = m_proxyModel.data()->itemFromResult( result );
|
||||
if ( item )
|
||||
return (qint64)( item->index.internalPointer() );
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
qint64
|
||||
PlayableProxyModelPlaylistInterface::indexOfQuery( const Tomahawk::query_ptr& query ) const
|
||||
{
|
||||
if ( m_proxyModel.isNull() )
|
||||
return -1;
|
||||
|
||||
PlayableProxyModel* proxyModel = m_proxyModel.data();
|
||||
|
||||
for ( int i = 0; i < proxyModel->rowCount( QModelIndex() ); i++ )
|
||||
{
|
||||
PlayableItem* item = proxyModel->itemFromIndex( proxyModel->mapToSource( proxyModel->index( i, 0 ) ) );
|
||||
if ( item && item->query() == query )
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
PlayableItem* item = m_proxyModel.data()->itemFromQuery( query );
|
||||
if ( item )
|
||||
return (qint64)( item->index.internalPointer() );
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@@ -43,13 +43,14 @@ public:
|
||||
|
||||
virtual int trackCount() const;
|
||||
|
||||
virtual Tomahawk::query_ptr itemAt( unsigned int position ) const;
|
||||
virtual int indexOfResult( const Tomahawk::result_ptr& result ) const;
|
||||
virtual int indexOfQuery( const Tomahawk::query_ptr& query ) const;
|
||||
virtual void setCurrentIndex( qint64 index );
|
||||
virtual Tomahawk::result_ptr resultAt( qint64 index ) const;
|
||||
virtual Tomahawk::query_ptr queryAt( qint64 index ) const;
|
||||
virtual qint64 indexOfResult( const Tomahawk::result_ptr& result ) const;
|
||||
virtual qint64 indexOfQuery( const Tomahawk::query_ptr& query ) const;
|
||||
|
||||
virtual Tomahawk::result_ptr currentItem() const;
|
||||
virtual Tomahawk::result_ptr siblingItem( int itemsAway, bool readOnly );
|
||||
virtual bool hasNextItem();
|
||||
virtual qint64 siblingIndex( int itemsAway ) const;
|
||||
|
||||
virtual QString filter() const;
|
||||
|
||||
@@ -60,13 +61,23 @@ public slots:
|
||||
virtual void setRepeatMode( Tomahawk::PlaylistModes::RepeatMode mode ) { m_repeatMode = mode; emit repeatModeChanged( mode ); }
|
||||
virtual void setShuffled( bool enabled ) { m_shuffled = enabled; emit shuffleModeChanged( enabled ); }
|
||||
|
||||
signals:
|
||||
void previousTrackAvailable();
|
||||
void nextTrackAvailable();
|
||||
|
||||
private slots:
|
||||
virtual void onModelChanged();
|
||||
|
||||
protected:
|
||||
QWeakPointer< PlayableProxyModel > m_proxyModel;
|
||||
|
||||
PlaylistModes::RepeatMode m_repeatMode;
|
||||
bool m_shuffled;
|
||||
QList< Tomahawk::query_ptr > m_shuffleHistory;
|
||||
QPersistentModelIndex m_shuffleCache;
|
||||
mutable QList< Tomahawk::query_ptr > m_shuffleHistory;
|
||||
mutable QPersistentModelIndex m_shuffleCache;
|
||||
|
||||
mutable bool m_prevAvail;
|
||||
mutable bool m_nextAvail;
|
||||
};
|
||||
|
||||
} //ns
|
||||
|
@@ -148,9 +148,8 @@ PlaylistModel::onPlaylistChanged()
|
||||
void
|
||||
PlaylistModel::clear()
|
||||
{
|
||||
PlayableModel::clear();
|
||||
|
||||
m_waitingForResolved.clear();
|
||||
PlayableModel::clear();
|
||||
}
|
||||
|
||||
|
||||
|
@@ -41,11 +41,13 @@ public:
|
||||
query_ptr track() const { return m_track; }
|
||||
void setQuery( const query_ptr& track ) { m_track = track; }
|
||||
|
||||
virtual void setCurrentIndex( qint64 index ) { Q_UNUSED( index ); }
|
||||
virtual result_ptr currentItem() const { return result_ptr(); }
|
||||
|
||||
virtual Tomahawk::query_ptr itemAt( unsigned int position ) const { Q_UNUSED( position ); Q_ASSERT( false ); return Tomahawk::query_ptr(); }
|
||||
virtual int indexOfResult( const Tomahawk::result_ptr& result ) const { Q_UNUSED( result ); Q_ASSERT( false ); return -1; }
|
||||
virtual int indexOfQuery( const Tomahawk::query_ptr& query ) const { Q_UNUSED( query ); Q_ASSERT( false ); return -1; }
|
||||
virtual Tomahawk::result_ptr resultAt( qint64 index ) const { Q_UNUSED( index ); Q_ASSERT( false ); return Tomahawk::result_ptr(); }
|
||||
virtual Tomahawk::query_ptr queryAt( qint64 index ) const { Q_UNUSED( index ); Q_ASSERT( false ); return Tomahawk::query_ptr(); }
|
||||
virtual qint64 indexOfResult( const Tomahawk::result_ptr& result ) const { Q_UNUSED( result ); Q_ASSERT( false ); return -1; }
|
||||
virtual qint64 indexOfQuery( const Tomahawk::query_ptr& query ) const { Q_UNUSED( query ); Q_ASSERT( false ); return -1; }
|
||||
|
||||
virtual PlaylistModes::RepeatMode repeatMode() const { return PlaylistModes::NoRepeat; }
|
||||
virtual void setRepeatMode( PlaylistModes::RepeatMode ) {}
|
||||
@@ -53,7 +55,7 @@ public:
|
||||
virtual bool shuffled() const { return false; }
|
||||
virtual void setShuffled( bool ) {}
|
||||
|
||||
virtual result_ptr siblingItem( int, bool ) { return result_ptr(); }
|
||||
virtual qint64 siblingIndex( int ) const { return -1; }
|
||||
virtual int trackCount() const { return 1; }
|
||||
virtual QList< query_ptr > tracks() { return QList< query_ptr >(); }
|
||||
|
||||
|
@@ -248,7 +248,6 @@ TrackView::autoPlayResolveFinished( const query_ptr& query, int row )
|
||||
const QModelIndex sib = index.sibling( index.row() + 1, index.column() );
|
||||
if ( sib.isValid() )
|
||||
startAutoPlay( sib );
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -308,7 +307,6 @@ TrackView::tryToPlayItem( const QModelIndex& index )
|
||||
PlayableItem* item = m_model->itemFromIndex( m_proxyModel->mapToSource( index ) );
|
||||
if ( item && !item->query().isNull() )
|
||||
{
|
||||
m_proxyModel->setCurrentIndex( index );
|
||||
AudioEngine::instance()->playItem( playlistInterface(), item->query() );
|
||||
|
||||
return true;
|
||||
@@ -719,19 +717,14 @@ TrackView::mousePressEvent( QMouseEvent* event )
|
||||
Tomahawk::playlistinterface_ptr
|
||||
TrackView::playlistInterface() const
|
||||
{
|
||||
if ( m_playlistInterface.isNull() )
|
||||
{
|
||||
return proxyModel()->playlistInterface();
|
||||
}
|
||||
|
||||
return m_playlistInterface;
|
||||
return proxyModel()->playlistInterface();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TrackView::setPlaylistInterface( const Tomahawk::playlistinterface_ptr& playlistInterface )
|
||||
{
|
||||
m_playlistInterface = playlistInterface;
|
||||
proxyModel()->setPlaylistInterface( playlistInterface );
|
||||
}
|
||||
|
||||
|
||||
|
@@ -146,7 +146,6 @@ private:
|
||||
|
||||
bool m_updateContextView;
|
||||
|
||||
Tomahawk::playlistinterface_ptr m_playlistInterface;
|
||||
QModelIndex m_hoveredIndex;
|
||||
QModelIndex m_contextMenuIndex;
|
||||
|
||||
|
@@ -421,3 +421,32 @@ TreeModel::indexFromAlbum( const Tomahawk::album_ptr& album ) const
|
||||
tDebug() << "Could not find item for album:" << album->name() << album->artist()->name();
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
|
||||
QModelIndex
|
||||
TreeModel::indexFromResult( const Tomahawk::result_ptr& result ) const
|
||||
{
|
||||
QModelIndex artistIdx = indexFromArtist( result->artist() );
|
||||
for ( int i = 0; i < rowCount( artistIdx ); i++ )
|
||||
{
|
||||
QModelIndex idx = index( i, 0, artistIdx );
|
||||
PlayableItem* albumItem = itemFromIndex( idx );
|
||||
if ( albumItem && albumItem->album() == result->album() )
|
||||
{
|
||||
for ( int j = 0; j < rowCount( idx ); j++ )
|
||||
{
|
||||
QModelIndex subidx = index( j, 0, idx );
|
||||
PlayableItem* item = itemFromIndex( subidx );
|
||||
if ( item && item->result() == result )
|
||||
{
|
||||
return subidx;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
tDebug() << "Could not find item for result:" << result->toString();
|
||||
return QModelIndex();
|
||||
}
|
||||
|
@@ -63,6 +63,7 @@ public:
|
||||
|
||||
QModelIndex indexFromArtist( const Tomahawk::artist_ptr& artist ) const;
|
||||
QModelIndex indexFromAlbum( const Tomahawk::album_ptr& album ) const;
|
||||
QModelIndex indexFromResult( const Tomahawk::result_ptr& result ) const;
|
||||
|
||||
public slots:
|
||||
void addAlbums( const QModelIndex& parent, const QList<Tomahawk::album_ptr>& albums );
|
||||
|
@@ -36,6 +36,7 @@ TreeProxyModel::TreeProxyModel( QObject* parent )
|
||||
, m_artistsFilterCmd( 0 )
|
||||
, m_model( 0 )
|
||||
{
|
||||
// setPlaylistInterface( Tomahawk::playlistinterface_ptr( new Tomahawk::TreeProxyModelPlaylistInterface( this ) ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -347,13 +348,22 @@ TreeProxyModel::textForItem( PlayableItem* item ) const
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::playlistinterface_ptr
|
||||
TreeProxyModel::playlistInterface()
|
||||
QModelIndex
|
||||
TreeProxyModel::indexFromArtist( const Tomahawk::artist_ptr& artist ) const
|
||||
{
|
||||
if ( m_playlistInterface.isNull() )
|
||||
{
|
||||
m_playlistInterface = Tomahawk::playlistinterface_ptr( new Tomahawk::TreeProxyModelPlaylistInterface( this ) );
|
||||
}
|
||||
|
||||
return m_playlistInterface;
|
||||
return mapFromSource( m_model->indexFromArtist( artist ) );
|
||||
}
|
||||
|
||||
|
||||
QModelIndex
|
||||
TreeProxyModel::indexFromAlbum( const Tomahawk::album_ptr& album ) const
|
||||
{
|
||||
return mapFromSource( m_model->indexFromAlbum( album ) );
|
||||
}
|
||||
|
||||
|
||||
QModelIndex
|
||||
TreeProxyModel::indexFromResult( const Tomahawk::result_ptr& result ) const
|
||||
{
|
||||
return mapFromSource( m_model->indexFromResult( result ) );
|
||||
}
|
||||
|
@@ -45,11 +45,11 @@ public:
|
||||
// workaround overloaded-virtual warning
|
||||
virtual void setSourcePlayableModel( PlayableModel* ) { Q_ASSERT( false ); }
|
||||
|
||||
virtual Tomahawk::playlistinterface_ptr playlistInterface();
|
||||
|
||||
virtual void setFilter( const QString& pattern );
|
||||
|
||||
signals:
|
||||
QModelIndex indexFromArtist( const Tomahawk::artist_ptr& artist ) const;
|
||||
QModelIndex indexFromAlbum( const Tomahawk::album_ptr& album ) const;
|
||||
QModelIndex indexFromResult( const Tomahawk::result_ptr& result ) const;
|
||||
|
||||
protected:
|
||||
bool filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const;
|
||||
@@ -78,8 +78,6 @@ private:
|
||||
|
||||
QString m_filter;
|
||||
TreeModel* m_model;
|
||||
|
||||
Tomahawk::playlistinterface_ptr m_playlistInterface;
|
||||
};
|
||||
|
||||
#endif // TREEPROXYMODEL_H
|
||||
|
@@ -31,7 +31,8 @@
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
TreeProxyModelPlaylistInterface::TreeProxyModelPlaylistInterface( TreeProxyModel *proxyModel )
|
||||
|
||||
TreeProxyModelPlaylistInterface::TreeProxyModelPlaylistInterface( TreeProxyModel* proxyModel )
|
||||
: PlaylistInterface()
|
||||
, m_proxyModel( proxyModel )
|
||||
, m_repeatMode( PlaylistModes::NoRepeat )
|
||||
@@ -66,23 +67,31 @@ TreeProxyModelPlaylistInterface::trackCount() const
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TreeProxyModelPlaylistInterface::hasNextItem()
|
||||
void
|
||||
TreeProxyModelPlaylistInterface::setCurrentIndex( qint64 index )
|
||||
{
|
||||
return !( siblingItem( 1, true ).isNull() );
|
||||
PlayableItem* item = static_cast<PlayableItem*>( (void*)index );
|
||||
if ( !item )
|
||||
{
|
||||
m_proxyModel.data()->setCurrentIndex( QModelIndex() );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_proxyModel.data()->setCurrentIndex( m_proxyModel.data()->mapFromSource( item->index ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::result_ptr
|
||||
TreeProxyModelPlaylistInterface::siblingItem( int itemsAway, bool readOnly )
|
||||
qint64
|
||||
TreeProxyModelPlaylistInterface::siblingIndex( int itemsAway ) const
|
||||
{
|
||||
if ( m_proxyModel.isNull() )
|
||||
return Tomahawk::result_ptr();
|
||||
TreeProxyModel* proxyModel = m_proxyModel.data();
|
||||
return -1;
|
||||
|
||||
TreeProxyModel* proxyModel = m_proxyModel.data();
|
||||
QModelIndex idx = proxyModel->currentIndex();
|
||||
if ( !idx.isValid() )
|
||||
return Tomahawk::result_ptr();
|
||||
return -1;
|
||||
|
||||
if ( m_shuffled )
|
||||
{
|
||||
@@ -112,20 +121,16 @@ TreeProxyModelPlaylistInterface::siblingItem( int itemsAway, bool readOnly )
|
||||
while ( idx.isValid() )
|
||||
{
|
||||
PlayableItem* item = proxyModel->itemFromIndex( proxyModel->mapToSource( idx ) );
|
||||
if ( item && !item->result().isNull() && item->result()->isOnline() )
|
||||
if ( item )
|
||||
{
|
||||
qDebug() << "Next PlaylistItem found:" << item->result()->url();
|
||||
if ( !readOnly )
|
||||
proxyModel->setCurrentIndex( idx );
|
||||
return item->result();
|
||||
tDebug() << Q_FUNC_INFO << "Next PlaylistItem found:" << item->result()->url();
|
||||
return (qint64)( proxyModel->mapToSource( idx ).internalPointer() );
|
||||
}
|
||||
|
||||
idx = proxyModel->index( idx.row() + ( itemsAway > 0 ? 1 : -1 ), 0, idx.parent() );
|
||||
}
|
||||
|
||||
if ( !readOnly )
|
||||
proxyModel->setCurrentIndex( QModelIndex() );
|
||||
return Tomahawk::result_ptr();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -139,5 +144,61 @@ TreeProxyModelPlaylistInterface::currentItem() const
|
||||
PlayableItem* item = proxyModel->itemFromIndex( proxyModel->mapToSource( proxyModel->currentIndex() ) );
|
||||
if ( item && !item->result().isNull() && item->result()->isOnline() )
|
||||
return item->result();
|
||||
|
||||
return Tomahawk::result_ptr();
|
||||
}
|
||||
|
||||
|
||||
QList< Tomahawk::query_ptr >
|
||||
TreeProxyModelPlaylistInterface::tracks()
|
||||
{
|
||||
Q_ASSERT( false );
|
||||
QList< Tomahawk::query_ptr > queries;
|
||||
return queries;
|
||||
}
|
||||
|
||||
|
||||
qint64
|
||||
TreeProxyModelPlaylistInterface::indexOfResult( const result_ptr& result ) const
|
||||
{
|
||||
if ( m_proxyModel.isNull() )
|
||||
return -1;
|
||||
|
||||
QModelIndex idx = m_proxyModel.data()->indexFromResult( result );
|
||||
if ( idx.isValid() )
|
||||
{
|
||||
return (qint64)( m_proxyModel.data()->mapToSource( idx ).internalPointer() );
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::query_ptr
|
||||
TreeProxyModelPlaylistInterface::queryAt( qint64 index ) const
|
||||
{
|
||||
if ( m_proxyModel.isNull() )
|
||||
return query_ptr();
|
||||
|
||||
PlayableItem* item = static_cast<PlayableItem*>( (void*)index );
|
||||
if ( item && item->query() )
|
||||
return item->query();
|
||||
if ( item && item->result() )
|
||||
return item->result()->toQuery();
|
||||
|
||||
return query_ptr();
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::result_ptr
|
||||
TreeProxyModelPlaylistInterface::resultAt( qint64 index ) const
|
||||
{
|
||||
if ( m_proxyModel.isNull() )
|
||||
return result_ptr();
|
||||
|
||||
PlayableItem* item = static_cast<PlayableItem*>( (void*)index );
|
||||
if ( item && item->result() )
|
||||
return item->result();
|
||||
|
||||
return result_ptr();
|
||||
}
|
||||
|
@@ -36,20 +36,20 @@ class DLLEXPORT TreeProxyModelPlaylistInterface : public Tomahawk::PlaylistInter
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TreeProxyModelPlaylistInterface( TreeProxyModel *proxyModel );
|
||||
explicit TreeProxyModelPlaylistInterface( TreeProxyModel* proxyModel );
|
||||
virtual ~TreeProxyModelPlaylistInterface();
|
||||
|
||||
virtual QList< Tomahawk::query_ptr > tracks() { Q_ASSERT( FALSE ); QList< Tomahawk::query_ptr > queries; return queries; }
|
||||
|
||||
virtual QList< Tomahawk::query_ptr > tracks();
|
||||
virtual int trackCount() const;
|
||||
|
||||
virtual Tomahawk::query_ptr itemAt( unsigned int position ) const { Q_UNUSED( position ); Q_ASSERT( false ); return Tomahawk::query_ptr(); }
|
||||
virtual int indexOfResult( const Tomahawk::result_ptr& result ) const { Q_UNUSED( result ); Q_ASSERT( false ); return -1; }
|
||||
virtual int indexOfQuery( const Tomahawk::query_ptr& query ) const { Q_UNUSED( query ); Q_ASSERT( false ); return -1; }
|
||||
virtual Tomahawk::result_ptr resultAt( qint64 index ) const;
|
||||
virtual Tomahawk::query_ptr queryAt( qint64 index ) const;
|
||||
virtual qint64 indexOfResult( const Tomahawk::result_ptr& result ) const;
|
||||
virtual qint64 indexOfQuery( const Tomahawk::query_ptr& query ) const { Q_UNUSED( query ); Q_ASSERT( false ); return -1; }
|
||||
|
||||
virtual bool hasNextItem();
|
||||
virtual void setCurrentIndex( qint64 index );
|
||||
virtual Tomahawk::result_ptr currentItem() const;
|
||||
virtual Tomahawk::result_ptr siblingItem( int direction, bool readOnly );
|
||||
virtual qint64 siblingIndex( int itemsAway ) const;
|
||||
|
||||
virtual QString filter() const;
|
||||
|
||||
@@ -58,18 +58,10 @@ public:
|
||||
virtual PlaylistModes::ViewMode viewMode() const { return PlaylistModes::Tree; }
|
||||
|
||||
signals:
|
||||
void repeatModeChanged( Tomahawk::PlaylistModes::RepeatMode mode );
|
||||
void shuffleModeChanged( bool enabled );
|
||||
|
||||
void trackCountChanged( unsigned int tracks );
|
||||
void sourceTrackCountChanged( unsigned int tracks );
|
||||
|
||||
void filterChanged( const QString& filter );
|
||||
void filteringStarted();
|
||||
void filteringFinished();
|
||||
|
||||
void nextTrackReady();
|
||||
|
||||
public slots:
|
||||
virtual void setRepeatMode( Tomahawk::PlaylistModes::RepeatMode mode ) { m_repeatMode = mode; emit repeatModeChanged( mode ); }
|
||||
virtual void setShuffled( bool enabled ) { m_shuffled = enabled; emit shuffleModeChanged( enabled ); }
|
||||
|
@@ -232,12 +232,15 @@ TreeView::onItemActivated( const QModelIndex& index )
|
||||
if ( item )
|
||||
{
|
||||
if ( !item->artist().isNull() )
|
||||
{
|
||||
ViewManager::instance()->show( item->artist() );
|
||||
}
|
||||
else if ( !item->album().isNull() )
|
||||
{
|
||||
ViewManager::instance()->show( item->album() );
|
||||
}
|
||||
else if ( !item->result().isNull() && item->result()->isOnline() )
|
||||
{
|
||||
m_model->setCurrentItem( item->index );
|
||||
AudioEngine::instance()->playItem( m_proxyModel->playlistInterface(), item->result() );
|
||||
}
|
||||
}
|
||||
|
@@ -60,7 +60,7 @@ ViewHeader::visibleSectionCount() const
|
||||
void
|
||||
ViewHeader::onSectionsChanged()
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << "Saving columns state for view guid:" << m_guid;
|
||||
tDebug() << "Saving columns state for view guid:" << m_guid;
|
||||
if ( !m_guid.isEmpty() )
|
||||
TomahawkSettings::instance()->setPlaylistColumnSizes( m_guid, saveState() );
|
||||
}
|
||||
@@ -76,7 +76,7 @@ ViewHeader::checkState()
|
||||
disconnect( this, SIGNAL( sectionResized( int, int, int ) ), this, SLOT( onSectionsChanged() ) );
|
||||
|
||||
QByteArray state;
|
||||
tDebug( LOGVERBOSE ) << "Restoring columns state for view:" << m_guid;
|
||||
tDebug() << "Restoring columns state for view:" << m_guid;
|
||||
|
||||
if ( !m_guid.isEmpty() )
|
||||
state = TomahawkSettings::instance()->playlistColumnSizes( m_guid );
|
||||
@@ -87,7 +87,7 @@ ViewHeader::checkState()
|
||||
}
|
||||
else
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << "Giving columns initial weighting:" << m_columnWeights;
|
||||
tDebug() << "Giving columns initial weighting:" << m_columnWeights;
|
||||
for ( int i = 0; i < count() - 1; i++ )
|
||||
{
|
||||
if ( isSectionHidden( i ) )
|
||||
@@ -97,6 +97,7 @@ ViewHeader::checkState()
|
||||
|
||||
double nw = (double)m_parent->width() * m_columnWeights.at( i );
|
||||
resizeSection( i, qMax( minimumSectionSize(), int( nw - 0.5 ) ) );
|
||||
tDebug() << "Initial size for column" << i << qMax( minimumSectionSize(), int( nw - 0.5 ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -67,8 +67,7 @@ DynamicQmlWidget::DynamicQmlWidget( const dynplaylist_ptr& playlist, QWidget* pa
|
||||
connect( AudioEngine::instance(), SIGNAL( playlistChanged( Tomahawk::playlistinterface_ptr ) ), this, SLOT( playlistChanged( Tomahawk::playlistinterface_ptr ) ) );
|
||||
|
||||
// Initially seed the playlist
|
||||
m_playlist->generator()->generate( 20 );
|
||||
|
||||
m_playlist->generator()->startFromArtist( Artist::get( "Eminem" , false ) );
|
||||
}
|
||||
|
||||
|
||||
|
@@ -19,6 +19,14 @@
|
||||
|
||||
#include "QtScriptResolver.h"
|
||||
|
||||
#include <QtGui/QMessageBox>
|
||||
|
||||
#include <QtNetwork/QNetworkRequest>
|
||||
#include <QtNetwork/QNetworkReply>
|
||||
|
||||
#include <QtCore/QMetaProperty>
|
||||
#include <QtCore/QCryptographicHash>
|
||||
|
||||
#include "Artist.h"
|
||||
#include "Album.h"
|
||||
#include "config.h"
|
||||
@@ -30,15 +38,6 @@
|
||||
#include "utils/TomahawkUtils.h"
|
||||
#include "utils/Logger.h"
|
||||
|
||||
|
||||
#include <QtGui/QMessageBox>
|
||||
|
||||
#include <QtNetwork/QNetworkRequest>
|
||||
#include <QtNetwork/QNetworkReply>
|
||||
|
||||
#include <QtCore/QMetaProperty>
|
||||
#include <QtCore/QCryptographicHash>
|
||||
|
||||
// FIXME: bloody hack, remove this for 0.3
|
||||
// this one adds new functionality to old resolvers
|
||||
#define RESOLVER_LEGACY_CODE "var resolver = Tomahawk.resolver.instance ? Tomahawk.resolver.instance : TomahawkResolver;"
|
||||
|
@@ -244,7 +244,7 @@ PixmapDelegateFader::onAnimationStep( int step )
|
||||
}
|
||||
|
||||
Q_ASSERT( !m_currentReference.isNull() );
|
||||
if ( !m_currentReference.isNull() ) // Should never be null..
|
||||
if ( !m_currentReference.isNull() ) // Should never be null...
|
||||
{
|
||||
p.setOpacity( opacity );
|
||||
p.drawPixmap( 0, 0, m_currentReference );
|
||||
|
@@ -194,7 +194,7 @@ OverlayWidget::paintEvent( QPaintEvent* event )
|
||||
int width = qMin( maxiSize.width(), prefSize.width() );
|
||||
int height = qMin( maxiSize.height(), prefSize.height() );
|
||||
QSize newSize = QSize( width, height );
|
||||
|
||||
|
||||
if ( newSize != size() )
|
||||
resize( newSize );
|
||||
}
|
||||
|
@@ -60,14 +60,16 @@ public:
|
||||
}
|
||||
virtual ~WelcomeWidgetInterface() {}
|
||||
|
||||
virtual void setCurrentIndex( qint64 index ) { m_w->ui->tracksView->proxyModel()->playlistInterface()->setCurrentIndex( index ); }
|
||||
virtual Tomahawk::PlaylistModes::RepeatMode repeatMode() const { return m_w->ui->tracksView->proxyModel()->playlistInterface()->repeatMode(); }
|
||||
virtual bool shuffled() const { return m_w->ui->tracksView->proxyModel()->playlistInterface()->shuffled(); }
|
||||
|
||||
virtual Tomahawk::query_ptr itemAt( unsigned int position ) const { Q_UNUSED( position ); Q_ASSERT( false ); return Tomahawk::query_ptr(); }
|
||||
virtual int indexOfResult( const Tomahawk::result_ptr& result ) const { Q_UNUSED( result ); Q_ASSERT( false ); return -1; }
|
||||
virtual int indexOfQuery( const Tomahawk::query_ptr& query ) const { Q_UNUSED( query ); Q_ASSERT( false ); return -1; }
|
||||
virtual Tomahawk::result_ptr resultAt( qint64 index ) const { Q_UNUSED( index ); Q_ASSERT( false ); return Tomahawk::result_ptr(); }
|
||||
virtual Tomahawk::query_ptr queryAt( qint64 index ) const { Q_UNUSED( index ); Q_ASSERT( false ); return Tomahawk::query_ptr(); }
|
||||
virtual qint64 indexOfResult( const Tomahawk::result_ptr& result ) const { Q_UNUSED( result ); Q_ASSERT( false ); return -1; }
|
||||
virtual qint64 indexOfQuery( const Tomahawk::query_ptr& query ) const { Q_UNUSED( query ); Q_ASSERT( false ); return -1; }
|
||||
virtual Tomahawk::result_ptr currentItem() const { return m_w->ui->tracksView->proxyModel()->playlistInterface()->currentItem(); }
|
||||
virtual Tomahawk::result_ptr siblingItem( int itemsAway, bool readOnly ) { return m_w->ui->tracksView->proxyModel()->playlistInterface()->siblingItem( itemsAway, readOnly ); }
|
||||
virtual qint64 siblingIndex( int itemsAway ) const { return m_w->ui->tracksView->proxyModel()->playlistInterface()->siblingIndex( itemsAway ); }
|
||||
virtual int trackCount() const { return m_w->ui->tracksView->proxyModel()->playlistInterface()->trackCount(); }
|
||||
virtual QList< Tomahawk::query_ptr > tracks() { return m_w->ui->tracksView->proxyModel()->playlistInterface()->tracks(); }
|
||||
|
||||
|
@@ -57,11 +57,13 @@ public:
|
||||
virtual bool shuffled() const { return m_w->ui->tracksViewLeft->proxyModel()->playlistInterface()->shuffled(); }
|
||||
|
||||
// Do nothing
|
||||
virtual Tomahawk::query_ptr itemAt( unsigned int position ) const { Q_UNUSED( position ); Q_ASSERT( false ); return Tomahawk::query_ptr(); }
|
||||
virtual int indexOfResult( const Tomahawk::result_ptr& result ) const { Q_UNUSED( result ); Q_ASSERT( false ); return -1; }
|
||||
virtual int indexOfQuery( const Tomahawk::query_ptr& query ) const { Q_UNUSED( query ); Q_ASSERT( false ); return -1; }
|
||||
virtual void setCurrentIndex( qint64 index ) { Q_UNUSED( index ); }
|
||||
virtual Tomahawk::result_ptr resultAt( qint64 index ) const { Q_UNUSED( index ); Q_ASSERT( false ); return Tomahawk::result_ptr(); }
|
||||
virtual Tomahawk::query_ptr queryAt( qint64 index ) const { Q_UNUSED( index ); Q_ASSERT( false ); return Tomahawk::query_ptr(); }
|
||||
virtual qint64 indexOfResult( const Tomahawk::result_ptr& result ) const { Q_UNUSED( result ); Q_ASSERT( false ); return -1; }
|
||||
virtual qint64 indexOfQuery( const Tomahawk::query_ptr& query ) const { Q_UNUSED( query ); Q_ASSERT( false ); return -1; }
|
||||
virtual Tomahawk::result_ptr currentItem() const { return Tomahawk::result_ptr(); }
|
||||
virtual Tomahawk::result_ptr siblingItem( int, bool ) { return Tomahawk::result_ptr(); }
|
||||
virtual qint64 siblingIndex( int ) const { return -1; }
|
||||
virtual int trackCount() const { return 0; }
|
||||
virtual QList< Tomahawk::query_ptr > tracks() { return QList< Tomahawk::query_ptr >(); }
|
||||
|
||||
@@ -86,14 +88,6 @@ public slots:
|
||||
m_w->ui->artistsViewLeft->proxyModel()->playlistInterface()->setShuffled( enabled );
|
||||
}
|
||||
|
||||
signals:
|
||||
void repeatModeChanged( Tomahawk::PlaylistModes::RepeatMode mode );
|
||||
void shuffleModeChanged( bool enabled );
|
||||
|
||||
void trackCountChanged( unsigned int tracks );
|
||||
void sourceTrackCountChanged( unsigned int tracks );
|
||||
void nextTrackReady();
|
||||
|
||||
private slots:
|
||||
void anyRepeatModeChanged( Tomahawk::PlaylistModes::RepeatMode mode )
|
||||
{
|
||||
|
@@ -47,11 +47,13 @@ public:
|
||||
virtual Tomahawk::PlaylistModes::RepeatMode repeatMode() const { return m_w->ui->tracks->proxyModel()->playlistInterface()->repeatMode(); }
|
||||
virtual bool shuffled() const { return m_w->ui->tracks->proxyModel()->playlistInterface()->shuffled(); }
|
||||
|
||||
virtual Tomahawk::query_ptr itemAt( unsigned int position ) const { Q_UNUSED( position ); Q_ASSERT( false ); return Tomahawk::query_ptr(); }
|
||||
virtual int indexOfResult( const Tomahawk::result_ptr& result ) const { Q_UNUSED( result ); Q_ASSERT( false ); return -1; }
|
||||
virtual int indexOfQuery( const Tomahawk::query_ptr& query ) const { Q_UNUSED( query ); Q_ASSERT( false ); return -1; }
|
||||
virtual void setCurrentIndex( qint64 index ) { Q_UNUSED( index ); }
|
||||
virtual Tomahawk::result_ptr resultAt( qint64 index ) const { Q_UNUSED( index ); Q_ASSERT( false ); return Tomahawk::result_ptr(); }
|
||||
virtual Tomahawk::query_ptr queryAt( qint64 index ) const { Q_UNUSED( index ); Q_ASSERT( false ); return Tomahawk::query_ptr(); }
|
||||
virtual qint64 indexOfResult( const Tomahawk::result_ptr& result ) const { Q_UNUSED( result ); Q_ASSERT( false ); return -1; }
|
||||
virtual qint64 indexOfQuery( const Tomahawk::query_ptr& query ) const { Q_UNUSED( query ); Q_ASSERT( false ); return -1; }
|
||||
virtual Tomahawk::result_ptr currentItem() const { return m_w->ui->tracks->proxyModel()->playlistInterface()->currentItem(); }
|
||||
virtual Tomahawk::result_ptr siblingItem( int itemsAway, bool readOnly ) { return m_w->ui->tracks->proxyModel()->playlistInterface()->siblingItem( itemsAway, readOnly ); }
|
||||
virtual qint64 siblingIndex( int itemsAway ) const { return m_w->ui->tracks->proxyModel()->playlistInterface()->siblingIndex( itemsAway ); }
|
||||
virtual int trackCount() const { return m_w->ui->tracks->proxyModel()->playlistInterface()->trackCount(); }
|
||||
virtual QList< Tomahawk::query_ptr > tracks() { return m_w->ui->tracks->proxyModel()->playlistInterface()->tracks(); }
|
||||
|
||||
|
@@ -59,11 +59,13 @@ public:
|
||||
virtual bool shuffled() const { return m_w->ui->albums->proxyModel()->playlistInterface()->shuffled(); }
|
||||
|
||||
// Do nothing
|
||||
virtual Tomahawk::query_ptr itemAt( unsigned int position ) const { Q_UNUSED( position ); Q_ASSERT( false ); return Tomahawk::query_ptr(); }
|
||||
virtual int indexOfResult( const Tomahawk::result_ptr& result ) const { Q_UNUSED( result ); Q_ASSERT( false ); return -1; }
|
||||
virtual int indexOfQuery( const Tomahawk::query_ptr& query ) const { Q_UNUSED( query ); Q_ASSERT( false ); return -1; }
|
||||
virtual void setCurrentIndex( qint64 index ) { Q_UNUSED( index ); }
|
||||
virtual Tomahawk::result_ptr resultAt( qint64 index ) const { Q_UNUSED( index ); Q_ASSERT( false ); return Tomahawk::result_ptr(); }
|
||||
virtual Tomahawk::query_ptr queryAt( qint64 index ) const { Q_UNUSED( index ); Q_ASSERT( false ); return Tomahawk::query_ptr(); }
|
||||
virtual qint64 indexOfResult( const Tomahawk::result_ptr& result ) const { Q_UNUSED( result ); Q_ASSERT( false ); return -1; }
|
||||
virtual qint64 indexOfQuery( const Tomahawk::query_ptr& query ) const { Q_UNUSED( query ); Q_ASSERT( false ); return -1; }
|
||||
virtual Tomahawk::result_ptr currentItem() const { return Tomahawk::result_ptr(); }
|
||||
virtual Tomahawk::result_ptr siblingItem( int, bool ) { return Tomahawk::result_ptr(); }
|
||||
virtual qint64 siblingIndex( int ) const { return -1; }
|
||||
virtual int trackCount() const { return 0; }
|
||||
virtual QList< Tomahawk::query_ptr > tracks() { return QList< Tomahawk::query_ptr >(); }
|
||||
virtual int unfilteredTrackCount() const { return 0; }
|
||||
@@ -92,9 +94,6 @@ public slots:
|
||||
m_w->ui->topHits->proxyModel()->playlistInterface()->setShuffled( enabled );
|
||||
}
|
||||
|
||||
signals:
|
||||
void nextTrackReady();
|
||||
|
||||
private slots:
|
||||
void anyRepeatModeChanged( Tomahawk::PlaylistModes::RepeatMode mode )
|
||||
{
|
||||
|
Reference in New Issue
Block a user