mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-05 16:42:26 +02:00
* Only keep track of the 50 most recent tracks in WelcomeWidget. Don't auto-resolve playback-logs any longer.
This commit is contained in:
parent
6af30bfd2f
commit
0a593aeb05
@ -44,7 +44,8 @@ DatabaseCommand_LogPlayback::postCommitHook()
|
||||
connect( this, SIGNAL( trackPlayed( Tomahawk::query_ptr ) ),
|
||||
source().data(), SLOT( onPlaybackFinished( Tomahawk::query_ptr ) ), Qt::QueuedConnection );
|
||||
|
||||
Tomahawk::query_ptr q = Tomahawk::Query::get( m_artist, m_track, QString(), uuid() );
|
||||
// do not auto resolve this track
|
||||
Tomahawk::query_ptr q = Tomahawk::Query::get( m_artist, m_track, QString() );
|
||||
|
||||
if ( m_action == Finished )
|
||||
{
|
||||
|
@ -396,12 +396,16 @@ PlaylistModel::playlistEntries() const
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlaylistModel::remove( unsigned int row, bool moreToCome )
|
||||
{
|
||||
removeIndex( index( row, 0, QModelIndex() ), moreToCome );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlaylistModel::removeIndex( const QModelIndex& index, bool moreToCome )
|
||||
{
|
||||
if ( isReadOnly() )
|
||||
return;
|
||||
|
||||
TrackModel::removeIndex( index );
|
||||
|
||||
if ( !moreToCome && !m_playlist.isNull() )
|
||||
|
@ -62,6 +62,7 @@ public:
|
||||
|
||||
void insert( unsigned int row, const Tomahawk::query_ptr& query );
|
||||
|
||||
void remove( unsigned int row, bool moreToCome = false );
|
||||
virtual void removeIndex( const QModelIndex& index, bool moreToCome = false );
|
||||
|
||||
signals:
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "utils/tomahawkutils.h"
|
||||
|
||||
#include "album.h"
|
||||
#include "pipeline.h"
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
@ -370,3 +371,16 @@ TrackModel::onPlaybackStopped()
|
||||
oldEntry->setIsPlaying( false );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TrackModel::ensureResolved()
|
||||
{
|
||||
for( int i = 0; i < rowCount( QModelIndex() ); i++ )
|
||||
{
|
||||
query_ptr query = itemFromIndex( index( i, 0, QModelIndex() ) )->query();
|
||||
|
||||
if ( !query->numResults() )
|
||||
Pipeline::instance()->resolve( query );
|
||||
}
|
||||
}
|
||||
|
@ -76,6 +76,8 @@ public:
|
||||
virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; }
|
||||
virtual bool shuffled() const { return false; }
|
||||
|
||||
virtual void ensureResolved();
|
||||
|
||||
virtual void append( const Tomahawk::query_ptr& query ) = 0;
|
||||
|
||||
PlItem* itemFromIndex( const QModelIndex& index ) const;
|
||||
|
@ -31,7 +31,9 @@
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
#define FILTER_TIMEOUT 280
|
||||
#define HISTORY_TRACK_ITEMS 50
|
||||
#define HISTORY_PLAYLIST_ITEMS 10
|
||||
#define HISTORY_RESOLVING_TIMEOUT 2500
|
||||
|
||||
|
||||
WelcomeWidget::WelcomeWidget( QWidget* parent )
|
||||
@ -46,7 +48,10 @@ WelcomeWidget::WelcomeWidget( QWidget* parent )
|
||||
|
||||
m_tracksModel = new PlaylistModel( ui->tracksView );
|
||||
ui->tracksView->setModel( m_tracksModel );
|
||||
m_tracksModel->loadHistory( Tomahawk::source_ptr() );
|
||||
m_tracksModel->loadHistory( Tomahawk::source_ptr(), HISTORY_TRACK_ITEMS );
|
||||
|
||||
m_timer = new QTimer( this );
|
||||
connect( m_timer, SIGNAL( timeout() ), SLOT( checkQueries() ) );
|
||||
|
||||
connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), SLOT( onSourceAdded( Tomahawk::source_ptr ) ) );
|
||||
|
||||
@ -96,10 +101,25 @@ WelcomeWidget::onSourceAdded( const Tomahawk::source_ptr& source )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WelcomeWidget::checkQueries()
|
||||
{
|
||||
m_timer->stop();
|
||||
m_tracksModel->ensureResolved();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WelcomeWidget::onPlaybackFinished( const Tomahawk::query_ptr& query )
|
||||
{
|
||||
m_tracksModel->insert( 0, query );
|
||||
|
||||
if ( m_tracksModel->trackCount() > HISTORY_TRACK_ITEMS )
|
||||
m_tracksModel->remove( HISTORY_TRACK_ITEMS );
|
||||
|
||||
if ( m_timer->isActive() )
|
||||
m_timer->stop();
|
||||
m_timer->start( HISTORY_RESOLVING_TIMEOUT );
|
||||
}
|
||||
|
||||
|
||||
|
@ -124,10 +124,13 @@ private slots:
|
||||
void onPlaylistActivated( QListWidgetItem* item );
|
||||
void onPlaybackFinished( const Tomahawk::query_ptr& query );
|
||||
|
||||
void checkQueries();
|
||||
|
||||
private:
|
||||
Ui::WelcomeWidget *ui;
|
||||
|
||||
PlaylistModel* m_tracksModel;
|
||||
QTimer* m_timer;
|
||||
};
|
||||
|
||||
#endif // WELCOMEWIDGET_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user