mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-20 04:41:36 +02:00
* PlayableModel now emits signals for its queries so we don't have to store them everywhere.
This commit is contained in:
@@ -62,6 +62,7 @@ PlayableModel::createIndex( int row, int column, PlayableItem* item ) const
|
||||
if ( item->query() )
|
||||
{
|
||||
connect( item->query().data(), SIGNAL( playableStateChanged( bool ) ), SLOT( onQueryBecamePlayable( bool ) ), Qt::UniqueConnection );
|
||||
connect( item->query().data(), SIGNAL( resolvingFinished( bool ) ), SLOT( onQueryResolved( bool ) ), Qt::UniqueConnection );
|
||||
}
|
||||
|
||||
return QAbstractItemModel::createIndex( row, column, item );
|
||||
@@ -884,6 +885,28 @@ PlayableModel::onQueryBecamePlayable( bool playable )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlayableModel::onQueryResolved( bool hasResults )
|
||||
{
|
||||
Q_UNUSED( hasResults );
|
||||
|
||||
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 indexResolved( item->index );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PlayableItem*
|
||||
PlayableModel::itemFromQuery( const Tomahawk::query_ptr& query ) const
|
||||
{
|
||||
|
@@ -120,9 +120,10 @@ signals:
|
||||
void loadingStarted();
|
||||
void loadingFinished();
|
||||
|
||||
void indexResolved( const QModelIndex& index );
|
||||
void indexPlayable( const QModelIndex& index );
|
||||
void changed();
|
||||
|
||||
void changed();
|
||||
void currentIndexChanged();
|
||||
|
||||
public slots:
|
||||
@@ -158,8 +159,10 @@ protected:
|
||||
|
||||
private slots:
|
||||
void onDataChanged();
|
||||
void onQueryBecamePlayable( bool playable );
|
||||
|
||||
void onQueryBecamePlayable( bool playable );
|
||||
void onQueryResolved( bool hasResults );
|
||||
|
||||
void onPlaybackStarted( const Tomahawk::result_ptr& result );
|
||||
void onPlaybackStopped();
|
||||
|
||||
|
@@ -108,6 +108,7 @@ PlayableProxyModel::setSourcePlayableModel( PlayableModel* sourceModel )
|
||||
disconnect( m_model, SIGNAL( loadingFinished() ), this, SIGNAL( loadingFinished() ) );
|
||||
disconnect( m_model, SIGNAL( itemCountChanged( unsigned int ) ), this, SIGNAL( itemCountChanged( unsigned int ) ) );
|
||||
disconnect( m_model, SIGNAL( indexPlayable( QModelIndex ) ), this, SLOT( onIndexPlayable( QModelIndex ) ) );
|
||||
disconnect( m_model, SIGNAL( indexResolved( QModelIndex ) ), this, SLOT( onIndexResolved( QModelIndex ) ) );
|
||||
disconnect( m_model, SIGNAL( currentIndexChanged() ), this, SIGNAL( currentIndexChanged() ) );
|
||||
}
|
||||
|
||||
@@ -119,6 +120,7 @@ PlayableProxyModel::setSourcePlayableModel( PlayableModel* sourceModel )
|
||||
connect( m_model, SIGNAL( loadingFinished() ), SIGNAL( loadingFinished() ) );
|
||||
connect( m_model, SIGNAL( itemCountChanged( unsigned int ) ), SIGNAL( itemCountChanged( unsigned int ) ) );
|
||||
connect( m_model, SIGNAL( indexPlayable( QModelIndex ) ), SLOT( onIndexPlayable( QModelIndex ) ) );
|
||||
connect( m_model, SIGNAL( indexResolved( QModelIndex ) ), SLOT( onIndexResolved( QModelIndex ) ) );
|
||||
connect( m_model, SIGNAL( currentIndexChanged() ), SIGNAL( currentIndexChanged() ) );
|
||||
}
|
||||
|
||||
@@ -643,3 +645,10 @@ PlayableProxyModel::onIndexPlayable( const QModelIndex& index )
|
||||
{
|
||||
emit indexPlayable( mapFromSource( index ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlayableProxyModel::onIndexResolved( const QModelIndex& index )
|
||||
{
|
||||
emit indexResolved( mapFromSource( index ) );
|
||||
}
|
||||
|
@@ -94,6 +94,7 @@ signals:
|
||||
void loadingFinished();
|
||||
|
||||
void indexPlayable( const QModelIndex& index );
|
||||
void indexResolved( const QModelIndex& index );
|
||||
void currentIndexChanged();
|
||||
|
||||
void itemCountChanged( unsigned int items );
|
||||
@@ -106,6 +107,7 @@ protected:
|
||||
|
||||
private slots:
|
||||
void onIndexPlayable( const QModelIndex& index );
|
||||
void onIndexResolved( const QModelIndex& index );
|
||||
|
||||
private:
|
||||
virtual bool lessThan( int column, const Tomahawk::query_ptr& left, const Tomahawk::query_ptr& right ) const;
|
||||
|
@@ -426,8 +426,6 @@ TrackView::resizeEvent( QResizeEvent* event )
|
||||
{
|
||||
m_header->resizeSection( 0, event->size().width() );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user