1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-20 15:59:42 +01:00

* Show how many items are currently in the queue.

This commit is contained in:
Christian Muehlhaeuser 2012-06-01 01:58:21 +02:00
parent bb1800d27f
commit f74e49b99b
2 changed files with 20 additions and 5 deletions

View File

@ -19,10 +19,12 @@
#include "QueueProxyModel.h"
#include "audio/AudioEngine.h"
#include "playlist/TrackView.h"
#include "PlayableItem.h"
#include "ViewManager.h"
#include "utils/Logger.h"
#include "Source.h"
#include "utils/Logger.h"
using namespace Tomahawk;
@ -30,10 +32,9 @@ using namespace Tomahawk;
QueueProxyModel::QueueProxyModel( TrackView* parent )
: PlayableProxyModel( parent )
{
qDebug() << Q_FUNC_INFO;
connect( parent, SIGNAL( itemActivated( QModelIndex ) ), this, SLOT( onIndexActivated( QModelIndex ) ) );
connect( playlistInterface().data(), SIGNAL( sourceTrackCountChanged( unsigned int ) ), this, SLOT( onTrackCountChanged( unsigned int ) ) );
connect( parent, SIGNAL( itemActivated( QModelIndex ) ), SLOT( onIndexActivated( QModelIndex ) ) );
connect( playlistInterface().data(), SIGNAL( sourceTrackCountChanged( unsigned int ) ), SLOT( onTrackCountChanged( unsigned int ) ) );
connect( AudioEngine::instance(), SIGNAL( loading( Tomahawk::result_ptr ) ), SLOT( onPlaybackStarted( Tomahawk::result_ptr ) ) );
}
@ -42,6 +43,19 @@ QueueProxyModel::~QueueProxyModel()
}
void
QueueProxyModel::onPlaybackStarted( const Tomahawk::result_ptr& result )
{
for ( int i = 0; i < rowCount(); i++ )
{
QModelIndex idx = index( i, 0 );
PlayableItem* item = itemFromIndex( mapToSource( idx ) );
if ( item && item->query() && item->query()->equals( result->toQuery() ) )
remove( idx );
}
}
void
QueueProxyModel::onIndexActivated( const QModelIndex& index )
{

View File

@ -38,6 +38,7 @@ public:
private slots:
void onIndexActivated( const QModelIndex& index );
void onTrackCountChanged( unsigned int count );
void onPlaybackStarted( const Tomahawk::result_ptr& result );
};
#endif // QUEUEPROXYMODEL_H