mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-04 21:27:58 +02:00
Speed up the loved tracks model
This commit is contained in:
@@ -74,7 +74,7 @@ LovedTracksModel::loadTracks()
|
|||||||
}
|
}
|
||||||
|
|
||||||
DatabaseCommand_GenericSelect* cmd = new DatabaseCommand_GenericSelect( sql, DatabaseCommand_GenericSelect::Track, -1, 0 );
|
DatabaseCommand_GenericSelect* cmd = new DatabaseCommand_GenericSelect( sql, DatabaseCommand_GenericSelect::Track, -1, 0 );
|
||||||
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr> ) ), this, SLOT( appendQueries( QList<Tomahawk::query_ptr> ) ) );
|
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr> ) ), this, SLOT( tracksLoaded( QList<Tomahawk::query_ptr> ) ) );
|
||||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,3 +131,26 @@ LovedTracksModel::isTemporary() const
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
LovedTracksModel::tracksLoaded( QList< query_ptr > newLoved )
|
||||||
|
{
|
||||||
|
finishLoading();
|
||||||
|
|
||||||
|
QList< query_ptr > tracks;
|
||||||
|
|
||||||
|
foreach ( const plentry_ptr ple, playlistEntries() )
|
||||||
|
tracks << ple->query();
|
||||||
|
|
||||||
|
bool changed = false;
|
||||||
|
QList< query_ptr > mergedTracks = TomahawkUtils::mergePlaylistChanges( tracks, newLoved, changed );
|
||||||
|
|
||||||
|
if ( changed )
|
||||||
|
{
|
||||||
|
QList<Tomahawk::plentry_ptr> el = playlist()->entriesFromQueries( mergedTracks, true );
|
||||||
|
|
||||||
|
clear();
|
||||||
|
appendEntries( el );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -50,6 +50,7 @@ private slots:
|
|||||||
void onTrackLoved();
|
void onTrackLoved();
|
||||||
void loadTracks();
|
void loadTracks();
|
||||||
|
|
||||||
|
void tracksLoaded( QList<Tomahawk::query_ptr> );
|
||||||
private:
|
private:
|
||||||
Tomahawk::source_ptr m_source;
|
Tomahawk::source_ptr m_source;
|
||||||
unsigned int m_limit;
|
unsigned int m_limit;
|
||||||
|
@@ -77,6 +77,7 @@ protected:
|
|||||||
bool waitForRevision( const QString& revisionguid ) const { return m_waitForRevision.contains( revisionguid ); }
|
bool waitForRevision( const QString& revisionguid ) const { return m_waitForRevision.contains( revisionguid ); }
|
||||||
void removeFromWaitList( const QString& revisionguid ) { m_waitForRevision.removeAll( revisionguid ); }
|
void removeFromWaitList( const QString& revisionguid ) { m_waitForRevision.removeAll( revisionguid ); }
|
||||||
|
|
||||||
|
QList<Tomahawk::plentry_ptr> playlistEntries() const;
|
||||||
private slots:
|
private slots:
|
||||||
void onRevisionLoaded( Tomahawk::PlaylistRevision revision );
|
void onRevisionLoaded( Tomahawk::PlaylistRevision revision );
|
||||||
void parsedDroppedTracks( QList<Tomahawk::query_ptr> );
|
void parsedDroppedTracks( QList<Tomahawk::query_ptr> );
|
||||||
@@ -86,8 +87,6 @@ private:
|
|||||||
void beginPlaylistChanges();
|
void beginPlaylistChanges();
|
||||||
void endPlaylistChanges();
|
void endPlaylistChanges();
|
||||||
|
|
||||||
QList<Tomahawk::plentry_ptr> playlistEntries() const;
|
|
||||||
|
|
||||||
Tomahawk::playlist_ptr m_playlist;
|
Tomahawk::playlist_ptr m_playlist;
|
||||||
bool m_isTemporary;
|
bool m_isTemporary;
|
||||||
bool m_changesOngoing;
|
bool m_changesOngoing;
|
||||||
|
Reference in New Issue
Block a user