mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-11 16:44:05 +02:00
fix backlog removing
This commit is contained in:
@@ -25,7 +25,6 @@ DynamicModel::DynamicModel( QObject* parent )
|
|||||||
, m_startOnResolved( false )
|
, m_startOnResolved( false )
|
||||||
, m_onDemandRunning( false )
|
, m_onDemandRunning( false )
|
||||||
, m_changeOnNext( false )
|
, m_changeOnNext( false )
|
||||||
, m_searchingForNext( false )
|
|
||||||
, m_currentAttempts( 0 )
|
, m_currentAttempts( 0 )
|
||||||
, m_lastResolvedRow( 0 )
|
, m_lastResolvedRow( 0 )
|
||||||
{
|
{
|
||||||
@@ -62,7 +61,6 @@ DynamicModel::startOnDemand()
|
|||||||
|
|
||||||
m_onDemandRunning = true;
|
m_onDemandRunning = true;
|
||||||
m_startOnResolved = true;
|
m_startOnResolved = true;
|
||||||
m_searchingForNext = false;
|
|
||||||
m_currentAttempts = 0;
|
m_currentAttempts = 0;
|
||||||
m_lastResolvedRow = 0;
|
m_lastResolvedRow = 0;
|
||||||
}
|
}
|
||||||
@@ -75,7 +73,6 @@ DynamicModel::newTrackGenerated( const Tomahawk::query_ptr& query )
|
|||||||
connect( query.data(), SIGNAL( resultsAdded( QList<Tomahawk::result_ptr> ) ), this, SLOT( trackResolved() ) );
|
connect( query.data(), SIGNAL( resultsAdded( QList<Tomahawk::result_ptr> ) ), this, SLOT( trackResolved() ) );
|
||||||
|
|
||||||
append( query );
|
append( query );
|
||||||
m_searchingForNext = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,7 +80,6 @@ void
|
|||||||
DynamicModel::stopOnDemand()
|
DynamicModel::stopOnDemand()
|
||||||
{
|
{
|
||||||
m_onDemandRunning = false;
|
m_onDemandRunning = false;
|
||||||
m_searchingForNext = false;
|
|
||||||
AudioEngine::instance()->stop();
|
AudioEngine::instance()->stop();
|
||||||
|
|
||||||
disconnect( AudioEngine::instance(), SIGNAL( loading( Tomahawk::result_ptr ) ), this, SLOT( newTrackLoading() ) );
|
disconnect( AudioEngine::instance(), SIGNAL( loading( Tomahawk::result_ptr ) ), this, SLOT( newTrackLoading() ) );
|
||||||
@@ -104,7 +100,6 @@ DynamicModel::trackResolved()
|
|||||||
{
|
{
|
||||||
Query* q = qobject_cast<Query*>(sender());
|
Query* q = qobject_cast<Query*>(sender());
|
||||||
qDebug() << "Got successful resolved track:" << q->track() << q->artist() << m_lastResolvedRow << m_currentAttempts;
|
qDebug() << "Got successful resolved track:" << q->track() << q->artist() << m_lastResolvedRow << m_currentAttempts;
|
||||||
m_searchingForNext = false;
|
|
||||||
if( m_startOnResolved ) { // on first start
|
if( m_startOnResolved ) { // on first start
|
||||||
m_startOnResolved = false;
|
m_startOnResolved = false;
|
||||||
AudioEngine::instance()->play();
|
AudioEngine::instance()->play();
|
||||||
@@ -115,6 +110,8 @@ DynamicModel::trackResolved()
|
|||||||
emit collapseFromTo( m_lastResolvedRow, m_currentAttempts );
|
emit collapseFromTo( m_lastResolvedRow, m_currentAttempts );
|
||||||
}
|
}
|
||||||
m_currentAttempts = 0;
|
m_currentAttempts = 0;
|
||||||
|
|
||||||
|
emit checkForOverflow();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@@ -47,6 +47,7 @@ public:
|
|||||||
bool searchingForNext() const { return m_searchingForNext; }
|
bool searchingForNext() const { return m_searchingForNext; }
|
||||||
signals:
|
signals:
|
||||||
void collapseFromTo( int startRow, int num );
|
void collapseFromTo( int startRow, int num );
|
||||||
|
void checkForOverflow();
|
||||||
|
|
||||||
void trackGenerationFailure( const QString& msg );
|
void trackGenerationFailure( const QString& msg );
|
||||||
|
|
||||||
|
@@ -37,6 +37,7 @@ using namespace Tomahawk;
|
|||||||
DynamicView::DynamicView( QWidget* parent )
|
DynamicView::DynamicView( QWidget* parent )
|
||||||
: PlaylistView( parent )
|
: PlaylistView( parent )
|
||||||
, m_onDemand( false )
|
, m_onDemand( false )
|
||||||
|
, m_checkOnCollapse( false )
|
||||||
{
|
{
|
||||||
m_fadeOutAnim.setDuration( FADE_LENGTH );
|
m_fadeOutAnim.setDuration( FADE_LENGTH );
|
||||||
m_fadeOutAnim.setCurveShape( QTimeLine::LinearCurve );
|
m_fadeOutAnim.setCurveShape( QTimeLine::LinearCurve );
|
||||||
@@ -51,6 +52,7 @@ DynamicView::DynamicView( QWidget* parent )
|
|||||||
|
|
||||||
|
|
||||||
connect( &m_fadeOutAnim, SIGNAL( frameChanged( int ) ), viewport(), SLOT( update() ) );
|
connect( &m_fadeOutAnim, SIGNAL( frameChanged( int ) ), viewport(), SLOT( update() ) );
|
||||||
|
connect( &m_fadeOutAnim, SIGNAL( finished() ), this, SLOT( animFinished() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
DynamicView::~DynamicView()
|
DynamicView::~DynamicView()
|
||||||
@@ -65,6 +67,7 @@ DynamicView::setModel( DynamicModel* model)
|
|||||||
PlaylistView::setModel( model );
|
PlaylistView::setModel( model );
|
||||||
|
|
||||||
connect( model, SIGNAL( trackCountChanged( unsigned int ) ), SLOT( onTrackCountChanged( unsigned int ) ) );
|
connect( model, SIGNAL( trackCountChanged( unsigned int ) ), SLOT( onTrackCountChanged( unsigned int ) ) );
|
||||||
|
connect( model, SIGNAL( checkForOverflow() ), this, SLOT( checkForOverflow() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -122,10 +125,17 @@ DynamicView::onTrackCountChanged( unsigned int tracks )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
overlay()->hide();
|
overlay()->hide();
|
||||||
|
}
|
||||||
|
|
||||||
if( !m_onDemand || m_model->searchingForNext() || proxyModel()->rowCount( QModelIndex() ) == 0 )
|
void
|
||||||
|
DynamicView::checkForOverflow()
|
||||||
|
{
|
||||||
|
if( !m_onDemand || proxyModel()->rowCount( QModelIndex() ) == 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if( m_fadeOutAnim.state() == QTimeLine::Running )
|
||||||
|
m_checkOnCollapse = true;
|
||||||
|
|
||||||
/// We don't want stations to grow forever, because we don't want the view to have to scroll
|
/// We don't want stations to grow forever, because we don't want the view to have to scroll
|
||||||
/// So if there are too many tracks, we remove some that have already been played
|
/// So if there are too many tracks, we remove some that have already been played
|
||||||
/// Our threshold is 4 rows to the end. That's when we collapse.
|
/// Our threshold is 4 rows to the end. That's when we collapse.
|
||||||
@@ -145,6 +155,7 @@ DynamicView::onTrackCountChanged( unsigned int tracks )
|
|||||||
void
|
void
|
||||||
DynamicView::collapseEntries( int startRow, int num, int numToKeep )
|
DynamicView::collapseEntries( int startRow, int num, int numToKeep )
|
||||||
{
|
{
|
||||||
|
qDebug() << "BEGINNING TO COLLAPSE FROM" << startRow << num << numToKeep;
|
||||||
if( m_fadeOutAnim.state() == QTimeLine::Running )
|
if( m_fadeOutAnim.state() == QTimeLine::Running )
|
||||||
qDebug() << "COLLAPSING TWICE!";
|
qDebug() << "COLLAPSING TWICE!";
|
||||||
|
|
||||||
@@ -209,6 +220,14 @@ DynamicView::collapseEntries( int startRow, int num, int numToKeep )
|
|||||||
proxyModel()->removeIndexes( todel );
|
proxyModel()->removeIndexes( todel );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
DynamicView::animFinished()
|
||||||
|
{
|
||||||
|
if( m_checkOnCollapse )
|
||||||
|
checkForOverflow();
|
||||||
|
m_checkOnCollapse = false;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicView::paintEvent( QPaintEvent* event )
|
DynamicView::paintEvent( QPaintEvent* event )
|
||||||
{
|
{
|
||||||
|
@@ -21,6 +21,7 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QPropertyAnimation>
|
#include <QPropertyAnimation>
|
||||||
#include <QTimeLine>
|
#include <QTimeLine>
|
||||||
|
#include <QMutex>
|
||||||
|
|
||||||
class PlaylistModel;
|
class PlaylistModel;
|
||||||
class TrackModel;
|
class TrackModel;
|
||||||
@@ -56,6 +57,8 @@ public slots:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onTrackCountChanged( unsigned int );
|
void onTrackCountChanged( unsigned int );
|
||||||
|
void checkForOverflow();
|
||||||
|
void animFinished();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DynamicModel* m_model;
|
DynamicModel* m_model;
|
||||||
@@ -64,6 +67,7 @@ private:
|
|||||||
|
|
||||||
bool m_onDemand;
|
bool m_onDemand;
|
||||||
bool m_readOnly;
|
bool m_readOnly;
|
||||||
|
bool m_checkOnCollapse;
|
||||||
|
|
||||||
// for collapsing animation
|
// for collapsing animation
|
||||||
QPoint m_fadingPointAnchor;
|
QPoint m_fadingPointAnchor;
|
||||||
|
@@ -64,7 +64,7 @@ DynamicWidget::DynamicWidget( const Tomahawk::dynplaylist_ptr& playlist, QWidget
|
|||||||
m_view->setContentsMargins( 0, 0, 0, 0 );
|
m_view->setContentsMargins( 0, 0, 0, 0 );
|
||||||
m_layout->addWidget( m_view, 1 );
|
m_layout->addWidget( m_view, 1 );
|
||||||
|
|
||||||
connect( m_model, SIGNAL( collapseFromTo( int, int ) ), m_view, SLOT( collapseEntries( int, int ) ), Qt::QueuedConnection );
|
connect( m_model, SIGNAL( collapseFromTo( int, int ) ), m_view, SLOT( collapseEntries( int, int ) ) );
|
||||||
connect( m_model, SIGNAL( trackGenerationFailure( QString ) ), m_view, SLOT( showMessage( QString ) ) );
|
connect( m_model, SIGNAL( trackGenerationFailure( QString ) ), m_view, SLOT( showMessage( QString ) ) );
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user