mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-12 09:04:33 +02:00
Initial generalizing work
This commit is contained in:
@@ -52,6 +52,7 @@ Album::Album( unsigned int id, const QString& name, const Tomahawk::artist_ptr&
|
|||||||
, m_id( id )
|
, m_id( id )
|
||||||
, m_name( name )
|
, m_name( name )
|
||||||
, m_artist( artist )
|
, m_artist( artist )
|
||||||
|
, m_currentItem( 0 )
|
||||||
, m_currentTrack( 0 )
|
, m_currentTrack( 0 )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -80,7 +81,20 @@ Album::siblingItem( int itemsAway )
|
|||||||
return Tomahawk::result_ptr();
|
return Tomahawk::result_ptr();
|
||||||
|
|
||||||
m_currentTrack = p;
|
m_currentTrack = p;
|
||||||
return m_queries.at( p )->results().first();
|
m_currentItem = m_queries.at( p )->results().first();
|
||||||
|
return m_currentItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
Album::hasNextItem()
|
||||||
|
{
|
||||||
|
int p = m_currentTrack;
|
||||||
|
p++;
|
||||||
|
if ( p < 0 || p >= m_queries.count() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -52,6 +52,9 @@ public:
|
|||||||
|
|
||||||
virtual Tomahawk::result_ptr siblingItem( int itemsAway );
|
virtual Tomahawk::result_ptr siblingItem( int itemsAway );
|
||||||
|
|
||||||
|
virtual bool hasNextItem();
|
||||||
|
virtual Tomahawk::result_ptr currentItem() const { return m_currentItem; }
|
||||||
|
|
||||||
virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; }
|
virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; }
|
||||||
virtual bool shuffled() const { return false; }
|
virtual bool shuffled() const { return false; }
|
||||||
|
|
||||||
@@ -77,7 +80,7 @@ private:
|
|||||||
|
|
||||||
artist_ptr m_artist;
|
artist_ptr m_artist;
|
||||||
QList<Tomahawk::query_ptr> m_queries;
|
QList<Tomahawk::query_ptr> m_queries;
|
||||||
|
result_ptr m_currentItem;
|
||||||
unsigned int m_currentTrack;
|
unsigned int m_currentTrack;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -54,6 +54,7 @@ Artist::Artist( unsigned int id, const QString& name )
|
|||||||
: PlaylistInterface( this )
|
: PlaylistInterface( this )
|
||||||
, m_id( id )
|
, m_id( id )
|
||||||
, m_name( name )
|
, m_name( name )
|
||||||
|
, m_currentItem( 0 )
|
||||||
, m_currentTrack( 0 )
|
, m_currentTrack( 0 )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -82,7 +83,20 @@ Artist::siblingItem( int itemsAway )
|
|||||||
return Tomahawk::result_ptr();
|
return Tomahawk::result_ptr();
|
||||||
|
|
||||||
m_currentTrack = p;
|
m_currentTrack = p;
|
||||||
return m_queries.at( p )->results().first();
|
m_currentItem = m_queries.at( p )->results().first();
|
||||||
|
return m_currentItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
Artist::hasNextItem()
|
||||||
|
{
|
||||||
|
int p = m_currentTrack;
|
||||||
|
p++;
|
||||||
|
if ( p < 0 || p >= m_queries.count() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -52,6 +52,9 @@ public:
|
|||||||
|
|
||||||
virtual Tomahawk::result_ptr siblingItem( int itemsAway );
|
virtual Tomahawk::result_ptr siblingItem( int itemsAway );
|
||||||
|
|
||||||
|
virtual bool hasNextItem();
|
||||||
|
virtual Tomahawk::result_ptr currentItem() const { return m_currentItem; }
|
||||||
|
|
||||||
virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; }
|
virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; }
|
||||||
virtual bool shuffled() const { return false; }
|
virtual bool shuffled() const { return false; }
|
||||||
|
|
||||||
@@ -76,6 +79,7 @@ private:
|
|||||||
QString m_name;
|
QString m_name;
|
||||||
|
|
||||||
QList<Tomahawk::query_ptr> m_queries;
|
QList<Tomahawk::query_ptr> m_queries;
|
||||||
|
result_ptr m_currentItem;
|
||||||
unsigned int m_currentTrack;
|
unsigned int m_currentTrack;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -181,18 +181,13 @@ AudioEngine::next()
|
|||||||
m_playlist->skipRestrictions() == PlaylistInterface::NoSkipForwards )
|
m_playlist->skipRestrictions() == PlaylistInterface::NoSkipForwards )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( dynamic_cast< SourcePlaylistInterface* >( m_playlist ) )
|
if ( !m_currentTrack.isNull() && !m_playlist->hasNextItem() &&
|
||||||
|
m_currentTrack->id() == m_playlist->currentItem()->id() )
|
||||||
{
|
{
|
||||||
SourcePlaylistInterface* sourcepi = dynamic_cast< SourcePlaylistInterface* >( m_playlist );
|
//For instance, when doing a catch-up while listening along, but the person
|
||||||
if ( !sourcepi->source().isNull() )
|
//you're following hasn't started a new track yet...don't do anything
|
||||||
{
|
|
||||||
//it's a catch-up -- if they're trying to catch-up in the same track, don't do anything
|
|
||||||
//so that you don't repeat the track and/or cause the retry timer to fire
|
|
||||||
if ( !m_currentTrack.isNull() && !sourcepi->hasNextSong() &&
|
|
||||||
m_currentTrack->id() == sourcepi->currentItem()->id() )
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
loadNextTrack();
|
loadNextTrack();
|
||||||
}
|
}
|
||||||
|
@@ -114,6 +114,7 @@ Playlist::Playlist( const source_ptr& src,
|
|||||||
, m_lastmodified( lastmod )
|
, m_lastmodified( lastmod )
|
||||||
, m_createdOn( createdOn )
|
, m_createdOn( createdOn )
|
||||||
, m_shared( shared )
|
, m_shared( shared )
|
||||||
|
, m_currentItem( 0 )
|
||||||
, m_busy( false )
|
, m_busy( false )
|
||||||
{
|
{
|
||||||
// qDebug() << Q_FUNC_INFO << "1";
|
// qDebug() << Q_FUNC_INFO << "1";
|
||||||
@@ -137,6 +138,7 @@ Playlist::Playlist( const source_ptr& author,
|
|||||||
, m_lastmodified( 0 )
|
, m_lastmodified( 0 )
|
||||||
, m_createdOn( 0 ) // will be set by db command
|
, m_createdOn( 0 ) // will be set by db command
|
||||||
, m_shared( shared )
|
, m_shared( shared )
|
||||||
|
, m_currentItem ( 0 )
|
||||||
, m_initEntries( entries )
|
, m_initEntries( entries )
|
||||||
, m_busy( false )
|
, m_busy( false )
|
||||||
{
|
{
|
||||||
|
@@ -170,6 +170,9 @@ public:
|
|||||||
virtual int unfilteredTrackCount() const { return m_entries.count(); }
|
virtual int unfilteredTrackCount() const { return m_entries.count(); }
|
||||||
virtual int trackCount() const { return m_entries.count(); }
|
virtual int trackCount() const { return m_entries.count(); }
|
||||||
|
|
||||||
|
virtual bool hasNextItem() { return false; }
|
||||||
|
virtual Tomahawk::result_ptr currentItem() const { return m_currentItem; }
|
||||||
|
|
||||||
virtual Tomahawk::result_ptr siblingItem( int /*itemsAway*/ ) { return result_ptr(); }
|
virtual Tomahawk::result_ptr siblingItem( int /*itemsAway*/ ) { return result_ptr(); }
|
||||||
|
|
||||||
virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; }
|
virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; }
|
||||||
@@ -268,6 +271,8 @@ private:
|
|||||||
unsigned int m_createdOn;
|
unsigned int m_createdOn;
|
||||||
bool m_shared;
|
bool m_shared;
|
||||||
|
|
||||||
|
result_ptr m_currentItem;
|
||||||
|
|
||||||
QList< plentry_ptr > m_initEntries;
|
QList< plentry_ptr > m_initEntries;
|
||||||
QList< plentry_ptr > m_entries;
|
QList< plentry_ptr > m_entries;
|
||||||
|
|
||||||
|
@@ -46,6 +46,8 @@ public:
|
|||||||
virtual void removeIndex( const QModelIndex& index );
|
virtual void removeIndex( const QModelIndex& index );
|
||||||
virtual void removeIndexes( const QList<QModelIndex>& indexes );
|
virtual void removeIndexes( const QList<QModelIndex>& indexes );
|
||||||
|
|
||||||
|
virtual bool hasNextItem() { return true; }
|
||||||
|
virtual Tomahawk::result_ptr currentItem() const { return Tomahawk::result_ptr(); }
|
||||||
virtual Tomahawk::result_ptr siblingItem( int direction );
|
virtual Tomahawk::result_ptr siblingItem( int direction );
|
||||||
|
|
||||||
virtual void setFilter( const QString& pattern );
|
virtual void setFilter( const QString& pattern );
|
||||||
|
@@ -250,6 +250,6 @@ ArtistView::onScrollTimeout()
|
|||||||
bool
|
bool
|
||||||
ArtistView::jumpToCurrentTrack()
|
ArtistView::jumpToCurrentTrack()
|
||||||
{
|
{
|
||||||
scrollTo( m_proxyModel->currentItem(), QAbstractItemView::PositionAtCenter );
|
scrollTo( m_proxyModel->currentIndex(), QAbstractItemView::PositionAtCenter );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -132,6 +132,6 @@ CollectionView::onTrackCountChanged( unsigned int tracks )
|
|||||||
bool
|
bool
|
||||||
CollectionView::jumpToCurrentTrack()
|
CollectionView::jumpToCurrentTrack()
|
||||||
{
|
{
|
||||||
scrollTo( proxyModel()->currentItem(), QAbstractItemView::PositionAtCenter );
|
scrollTo( proxyModel()->currentIndex(), QAbstractItemView::PositionAtCenter );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -410,7 +410,7 @@ DynamicWidget::paintRoundedFilledRect( QPainter& p, QPalette& pal, QRect& r, qre
|
|||||||
bool
|
bool
|
||||||
DynamicWidget::jumpToCurrentTrack()
|
DynamicWidget::jumpToCurrentTrack()
|
||||||
{
|
{
|
||||||
m_view->scrollTo( m_view->proxyModel()->currentItem(), QAbstractItemView::PositionAtCenter );
|
m_view->scrollTo( m_view->proxyModel()->currentIndex(), QAbstractItemView::PositionAtCenter );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -168,7 +168,7 @@ PlaylistView::onTrackCountChanged( unsigned int tracks )
|
|||||||
bool
|
bool
|
||||||
PlaylistView::jumpToCurrentTrack()
|
PlaylistView::jumpToCurrentTrack()
|
||||||
{
|
{
|
||||||
scrollTo( proxyModel()->currentItem(), QAbstractItemView::PositionAtCenter );
|
scrollTo( proxyModel()->currentIndex(), QAbstractItemView::PositionAtCenter );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -44,12 +44,12 @@ QueueProxyModel::siblingItem( int itemsAway )
|
|||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << rowCount( QModelIndex() );
|
qDebug() << Q_FUNC_INFO << rowCount( QModelIndex() );
|
||||||
|
|
||||||
setCurrentItem( QModelIndex() );
|
setCurrentIndex( QModelIndex() );
|
||||||
Tomahawk::result_ptr res = PlaylistProxyModel::siblingItem( itemsAway );
|
Tomahawk::result_ptr res = PlaylistProxyModel::siblingItem( itemsAway );
|
||||||
|
|
||||||
qDebug() << "new rowcount:" << rowCount( QModelIndex() );
|
qDebug() << "new rowcount:" << rowCount( QModelIndex() );
|
||||||
|
|
||||||
removeIndex( currentItem() );
|
removeIndex( currentIndex() );
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@@ -94,6 +94,20 @@ TrackProxyModel::tracks()
|
|||||||
|
|
||||||
Tomahawk::result_ptr
|
Tomahawk::result_ptr
|
||||||
TrackProxyModel::siblingItem( int itemsAway )
|
TrackProxyModel::siblingItem( int itemsAway )
|
||||||
|
{
|
||||||
|
return siblingItem( itemsAway, false );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
TrackProxyModel::hasNextItem()
|
||||||
|
{
|
||||||
|
return !( siblingItem( 1, true ).isNull() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Tomahawk::result_ptr
|
||||||
|
TrackProxyModel::siblingItem( int itemsAway, bool readOnly )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
|
||||||
@@ -106,9 +120,9 @@ TrackProxyModel::siblingItem( int itemsAway )
|
|||||||
// TODO come up with a clever random logic, that keeps track of previously played items
|
// TODO come up with a clever random logic, that keeps track of previously played items
|
||||||
idx = index( qrand() % rowCount(), 0 );
|
idx = index( qrand() % rowCount(), 0 );
|
||||||
}
|
}
|
||||||
else if ( currentItem().isValid() )
|
else if ( currentIndex().isValid() )
|
||||||
{
|
{
|
||||||
idx = currentItem();
|
idx = currentIndex();
|
||||||
|
|
||||||
// random mode is disabled
|
// random mode is disabled
|
||||||
if ( m_repeatMode == PlaylistInterface::RepeatOne )
|
if ( m_repeatMode == PlaylistInterface::RepeatOne )
|
||||||
@@ -146,7 +160,8 @@ TrackProxyModel::siblingItem( int itemsAway )
|
|||||||
if ( item && item->query()->playable() )
|
if ( item && item->query()->playable() )
|
||||||
{
|
{
|
||||||
qDebug() << "Next PlaylistItem found:" << item->query()->toString() << item->query()->results().at( 0 )->url();
|
qDebug() << "Next PlaylistItem found:" << item->query()->toString() << item->query()->results().at( 0 )->url();
|
||||||
setCurrentItem( idx );
|
if ( !readOnly )
|
||||||
|
setCurrentIndex( idx );
|
||||||
return item->query()->results().at( 0 );
|
return item->query()->results().at( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,11 +169,21 @@ TrackProxyModel::siblingItem( int itemsAway )
|
|||||||
}
|
}
|
||||||
while ( idx.isValid() );
|
while ( idx.isValid() );
|
||||||
|
|
||||||
setCurrentItem( QModelIndex() );
|
if ( !readOnly )
|
||||||
|
setCurrentIndex( QModelIndex() );
|
||||||
return Tomahawk::result_ptr();
|
return Tomahawk::result_ptr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Tomahawk::result_ptr
|
||||||
|
TrackProxyModel::currentItem() const
|
||||||
|
{
|
||||||
|
TrackModelItem* item = itemFromIndex( mapToSource( currentIndex() ) );
|
||||||
|
if ( item && item->query()->playable() )
|
||||||
|
return item->query()->results().at( 0 );
|
||||||
|
return Tomahawk::result_ptr();
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
TrackProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const
|
TrackProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const
|
||||||
{
|
{
|
||||||
|
@@ -37,8 +37,8 @@ public:
|
|||||||
virtual void setSourceTrackModel( TrackModel* sourceModel );
|
virtual void setSourceTrackModel( TrackModel* sourceModel );
|
||||||
virtual void setSourceModel( QAbstractItemModel* model );
|
virtual void setSourceModel( QAbstractItemModel* model );
|
||||||
|
|
||||||
virtual QPersistentModelIndex currentItem() const { return mapFromSource( m_model->currentItem() ); }
|
virtual QPersistentModelIndex currentIndex() const { return mapFromSource( m_model->currentItem() ); }
|
||||||
virtual void setCurrentItem( const QModelIndex& index ) { m_model->setCurrentItem( mapToSource( index ) ); }
|
virtual void setCurrentIndex( const QModelIndex& index ) { m_model->setCurrentItem( mapToSource( index ) ); }
|
||||||
|
|
||||||
virtual QList<Tomahawk::query_ptr> tracks();
|
virtual QList<Tomahawk::query_ptr> tracks();
|
||||||
|
|
||||||
@@ -49,7 +49,10 @@ public:
|
|||||||
virtual void removeIndexes( const QModelIndexList& indexes );
|
virtual void removeIndexes( const QModelIndexList& indexes );
|
||||||
virtual void removeIndexes( const QList<QPersistentModelIndex>& indexes );
|
virtual void removeIndexes( const QList<QPersistentModelIndex>& indexes );
|
||||||
|
|
||||||
|
virtual Tomahawk::result_ptr currentItem() const;
|
||||||
virtual Tomahawk::result_ptr siblingItem( int itemsAway );
|
virtual Tomahawk::result_ptr siblingItem( int itemsAway );
|
||||||
|
virtual Tomahawk::result_ptr siblingItem( int itemsAway, bool readOnly );
|
||||||
|
virtual bool hasNextItem();
|
||||||
|
|
||||||
virtual QString filter() const { return filterRegExp().pattern(); }
|
virtual QString filter() const { return filterRegExp().pattern(); }
|
||||||
virtual void setFilter( const QString& pattern );
|
virtual void setFilter( const QString& pattern );
|
||||||
|
@@ -156,7 +156,7 @@ TrackView::onItemActivated( const QModelIndex& index )
|
|||||||
if ( item && item->query()->numResults() )
|
if ( item && item->query()->numResults() )
|
||||||
{
|
{
|
||||||
qDebug() << "Result activated:" << item->query()->toString() << item->query()->results().first()->url();
|
qDebug() << "Result activated:" << item->query()->toString() << item->query()->results().first()->url();
|
||||||
m_proxyModel->setCurrentItem( index );
|
m_proxyModel->setCurrentIndex( index );
|
||||||
AudioEngine::instance()->playItem( m_proxyModel, item->query()->results().first() );
|
AudioEngine::instance()->playItem( m_proxyModel, item->query()->results().first() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -137,12 +137,26 @@ TreeProxyModel::removeIndexes( const QList<QModelIndex>& indexes )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
TreeProxyModel::hasNextItem()
|
||||||
|
{
|
||||||
|
return !( siblingItem( 1, true ).isNull() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Tomahawk::result_ptr
|
Tomahawk::result_ptr
|
||||||
TreeProxyModel::siblingItem( int itemsAway )
|
TreeProxyModel::siblingItem( int itemsAway )
|
||||||
|
{
|
||||||
|
return siblingItem( itemsAway, false );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Tomahawk::result_ptr
|
||||||
|
TreeProxyModel::siblingItem( int itemsAway, bool readOnly )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
|
||||||
QModelIndex idx = currentItem();
|
QModelIndex idx = currentIndex();
|
||||||
|
|
||||||
// Try to find the next available PlaylistItem (with results)
|
// Try to find the next available PlaylistItem (with results)
|
||||||
if ( idx.isValid() ) do
|
if ( idx.isValid() ) do
|
||||||
@@ -155,13 +169,25 @@ TreeProxyModel::siblingItem( int itemsAway )
|
|||||||
if ( item && item->result()->isOnline() )
|
if ( item && item->result()->isOnline() )
|
||||||
{
|
{
|
||||||
qDebug() << "Next PlaylistItem found:" << item->result()->url();
|
qDebug() << "Next PlaylistItem found:" << item->result()->url();
|
||||||
setCurrentItem( idx );
|
if ( !readOnly )
|
||||||
|
setCurrentIndex( idx );
|
||||||
return item->result();
|
return item->result();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while ( idx.isValid() );
|
while ( idx.isValid() );
|
||||||
|
|
||||||
setCurrentItem( QModelIndex() );
|
if ( !readOnly )
|
||||||
|
setCurrentIndex( QModelIndex() );
|
||||||
|
return Tomahawk::result_ptr();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Tomahawk::result_ptr
|
||||||
|
TreeProxyModel::currentItem() const
|
||||||
|
{
|
||||||
|
TreeModelItem* item = itemFromIndex( mapToSource( currentIndex() ) );
|
||||||
|
if ( item && item->result()->isOnline() )
|
||||||
|
return item->result();
|
||||||
return Tomahawk::result_ptr();
|
return Tomahawk::result_ptr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -36,8 +36,8 @@ public:
|
|||||||
virtual TreeModel* sourceModel() const { return m_model; }
|
virtual TreeModel* sourceModel() const { return m_model; }
|
||||||
virtual void setSourceModel( TreeModel* sourceModel );
|
virtual void setSourceModel( TreeModel* sourceModel );
|
||||||
|
|
||||||
virtual QPersistentModelIndex currentItem() const { return mapFromSource( m_model->currentItem() ); }
|
virtual QPersistentModelIndex currentIndex() const { return mapFromSource( m_model->currentItem() ); }
|
||||||
virtual void setCurrentItem( const QModelIndex& index ) { m_model->setCurrentItem( mapToSource( index ) ); }
|
virtual void setCurrentIndex( const QModelIndex& index ) { m_model->setCurrentItem( mapToSource( index ) ); }
|
||||||
|
|
||||||
virtual QList<Tomahawk::query_ptr> tracks() { Q_ASSERT( FALSE ); QList<Tomahawk::query_ptr> queries; return queries; }
|
virtual QList<Tomahawk::query_ptr> tracks() { Q_ASSERT( FALSE ); QList<Tomahawk::query_ptr> queries; return queries; }
|
||||||
|
|
||||||
@@ -48,7 +48,10 @@ public:
|
|||||||
virtual void removeIndex( const QModelIndex& index );
|
virtual void removeIndex( const QModelIndex& index );
|
||||||
virtual void removeIndexes( const QList<QModelIndex>& indexes );
|
virtual void removeIndexes( const QList<QModelIndex>& indexes );
|
||||||
|
|
||||||
|
virtual bool hasNextItem();
|
||||||
|
virtual Tomahawk::result_ptr currentItem() const;
|
||||||
virtual Tomahawk::result_ptr siblingItem( int direction );
|
virtual Tomahawk::result_ptr siblingItem( int direction );
|
||||||
|
virtual Tomahawk::result_ptr siblingItem( int direction, bool readOnly );
|
||||||
|
|
||||||
virtual void setFilter( const QString& pattern );
|
virtual void setFilter( const QString& pattern );
|
||||||
|
|
||||||
|
@@ -47,7 +47,9 @@ public:
|
|||||||
virtual int unfilteredTrackCount() const = 0;
|
virtual int unfilteredTrackCount() const = 0;
|
||||||
virtual int trackCount() const = 0;
|
virtual int trackCount() const = 0;
|
||||||
|
|
||||||
|
virtual Tomahawk::result_ptr currentItem() const = 0;
|
||||||
virtual Tomahawk::result_ptr previousItem() { return siblingItem( -1 ); }
|
virtual Tomahawk::result_ptr previousItem() { return siblingItem( -1 ); }
|
||||||
|
virtual bool hasNextItem() { return true; }
|
||||||
virtual Tomahawk::result_ptr nextItem() { return siblingItem( 1 ); }
|
virtual Tomahawk::result_ptr nextItem() { return siblingItem( 1 ); }
|
||||||
virtual Tomahawk::result_ptr siblingItem( int itemsAway ) = 0;
|
virtual Tomahawk::result_ptr siblingItem( int itemsAway ) = 0;
|
||||||
|
|
||||||
|
@@ -29,7 +29,7 @@ SourcePlaylistInterface::SourcePlaylistInterface( Tomahawk::source_ptr& source )
|
|||||||
: PlaylistInterface( this )
|
: PlaylistInterface( this )
|
||||||
, m_source( source )
|
, m_source( source )
|
||||||
, m_currentItem( 0 )
|
, m_currentItem( 0 )
|
||||||
, m_gotNextSong( false )
|
, m_gotNextItem( false )
|
||||||
{
|
{
|
||||||
connect( source.data(), SIGNAL( playbackStarted( const Tomahawk::query_ptr& ) ), SLOT( onSourcePlaybackStarted( const Tomahawk::query_ptr& ) ) );
|
connect( source.data(), SIGNAL( playbackStarted( const Tomahawk::query_ptr& ) ), SLOT( onSourcePlaybackStarted( const Tomahawk::query_ptr& ) ) );
|
||||||
}
|
}
|
||||||
@@ -53,18 +53,28 @@ SourcePlaylistInterface::nextItem()
|
|||||||
m_currentItem = Tomahawk::result_ptr();
|
m_currentItem = Tomahawk::result_ptr();
|
||||||
return m_currentItem;
|
return m_currentItem;
|
||||||
}
|
}
|
||||||
else if ( !m_gotNextSong )
|
else if ( !m_gotNextItem )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << " This song was already fetched";
|
qDebug() << Q_FUNC_INFO << " This song was already fetched";
|
||||||
return Tomahawk::result_ptr();
|
return Tomahawk::result_ptr();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_gotNextSong = false;
|
m_gotNextItem = false;
|
||||||
m_currentItem = m_source->currentTrack()->results().first();
|
m_currentItem = m_source->currentTrack()->results().first();
|
||||||
return m_currentItem;
|
return m_currentItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
SourcePlaylistInterface::hasNextItem()
|
||||||
|
{
|
||||||
|
if ( m_source.isNull() || m_source->currentTrack().isNull() || m_source->currentTrack()->results().isEmpty() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return m_gotNextItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QList<Tomahawk::query_ptr>
|
QList<Tomahawk::query_ptr>
|
||||||
SourcePlaylistInterface::tracks()
|
SourcePlaylistInterface::tracks()
|
||||||
{
|
{
|
||||||
@@ -76,9 +86,9 @@ void
|
|||||||
SourcePlaylistInterface::reset()
|
SourcePlaylistInterface::reset()
|
||||||
{
|
{
|
||||||
if ( !m_currentItem.isNull() )
|
if ( !m_currentItem.isNull() )
|
||||||
m_gotNextSong = true;
|
m_gotNextItem = true;
|
||||||
else
|
else
|
||||||
m_gotNextSong = false;
|
m_gotNextItem = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -89,7 +99,7 @@ SourcePlaylistInterface::onSourcePlaybackStarted( const Tomahawk::query_ptr& que
|
|||||||
connect( query.data(), SIGNAL( resultsAdded( const QList<Tomahawk::result_ptr>& ) ), SLOT( resolveResultsAdded( const QList<Tomahawk::result_ptr>& ) ) );
|
connect( query.data(), SIGNAL( resultsAdded( const QList<Tomahawk::result_ptr>& ) ), SLOT( resolveResultsAdded( const QList<Tomahawk::result_ptr>& ) ) );
|
||||||
connect( query.data(), SIGNAL( resolvingFinished( bool ) ), SLOT( resolvingFinished( bool ) ) );
|
connect( query.data(), SIGNAL( resolvingFinished( bool ) ), SLOT( resolvingFinished( bool ) ) );
|
||||||
Pipeline::instance()->resolve( query, true );
|
Pipeline::instance()->resolve( query, true );
|
||||||
m_gotNextSong = true;
|
m_gotNextItem = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -44,8 +44,9 @@ public:
|
|||||||
virtual int unfilteredTrackCount() const { return 1; }
|
virtual int unfilteredTrackCount() const { return 1; }
|
||||||
|
|
||||||
virtual Tomahawk::result_ptr siblingItem( int itemsAway );
|
virtual Tomahawk::result_ptr siblingItem( int itemsAway );
|
||||||
|
virtual bool hasNextItem();
|
||||||
virtual Tomahawk::result_ptr nextItem();
|
virtual Tomahawk::result_ptr nextItem();
|
||||||
virtual Tomahawk::result_ptr currentItem() { return m_currentItem; }
|
virtual Tomahawk::result_ptr currentItem() const { return m_currentItem; }
|
||||||
|
|
||||||
virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; }
|
virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; }
|
||||||
virtual PlaylistInterface::SeekRestrictions seekRestrictions() const { return PlaylistInterface::NoSeek; }
|
virtual PlaylistInterface::SeekRestrictions seekRestrictions() const { return PlaylistInterface::NoSeek; }
|
||||||
@@ -58,7 +59,6 @@ public:
|
|||||||
|
|
||||||
virtual Tomahawk::source_ptr source() const { return m_source; }
|
virtual Tomahawk::source_ptr source() const { return m_source; }
|
||||||
|
|
||||||
virtual bool hasNextSong() { return m_gotNextSong; }
|
|
||||||
virtual void reset();
|
virtual void reset();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@@ -79,7 +79,7 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
Tomahawk::source_ptr m_source;
|
Tomahawk::source_ptr m_source;
|
||||||
Tomahawk::result_ptr m_currentItem;
|
Tomahawk::result_ptr m_currentItem;
|
||||||
bool m_gotNextSong;
|
bool m_gotNextItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
}; // ns
|
}; // ns
|
||||||
|
@@ -353,7 +353,7 @@ SourceTreeView::latchOn()
|
|||||||
{
|
{
|
||||||
//it's a catch-up -- if they're trying to catch-up in the same track, don't do anything
|
//it's a catch-up -- if they're trying to catch-up in the same track, don't do anything
|
||||||
//so that you don't repeat the track and/or cause the retry timer to fire
|
//so that you don't repeat the track and/or cause the retry timer to fire
|
||||||
if ( !AudioEngine::instance()->currentTrack().isNull() && !sourcepi->hasNextSong() &&
|
if ( !AudioEngine::instance()->currentTrack().isNull() && !sourcepi->hasNextItem() &&
|
||||||
AudioEngine::instance()->currentTrack()->id() == sourcepi->currentItem()->id() )
|
AudioEngine::instance()->currentTrack()->id() == sourcepi->currentItem()->id() )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user