mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 06:07:37 +02:00
Modernize DatabaseCommand_AllTracks
This commit is contained in:
@@ -30,6 +30,8 @@
|
|||||||
#include "SourceList.h"
|
#include "SourceList.h"
|
||||||
#include "Track.h"
|
#include "Track.h"
|
||||||
|
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
namespace Tomahawk
|
namespace Tomahawk
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -100,7 +102,7 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi )
|
|||||||
|
|
||||||
// Small cache to keep already created source objects.
|
// Small cache to keep already created source objects.
|
||||||
// This saves some mutex locking.
|
// This saves some mutex locking.
|
||||||
std::map<uint, Tomahawk::source_ptr> sourceCache;
|
std::unordered_map<uint, Tomahawk::source_ptr> sourceCache;
|
||||||
|
|
||||||
while( query.next() )
|
while( query.next() )
|
||||||
{
|
{
|
||||||
@@ -119,7 +121,7 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi )
|
|||||||
uint albumpos = query.value( 13 ).toUInt();
|
uint albumpos = query.value( 13 ).toUInt();
|
||||||
uint trackId = query.value( 14 ).toUInt();
|
uint trackId = query.value( 14 ).toUInt();
|
||||||
|
|
||||||
std::map<uint, Tomahawk::source_ptr>::const_iterator _s = sourceCache.find( sourceId );
|
std::unordered_map<uint, Tomahawk::source_ptr>::const_iterator _s = sourceCache.find( sourceId );
|
||||||
Tomahawk::source_ptr s;
|
Tomahawk::source_ptr s;
|
||||||
if ( _s == sourceCache.end() )
|
if ( _s == sourceCache.end() )
|
||||||
{
|
{
|
||||||
|
@@ -47,22 +47,22 @@ public:
|
|||||||
AlbumPosition = 3
|
AlbumPosition = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit DatabaseCommand_AllTracks( const Tomahawk::collection_ptr& collection = Tomahawk::collection_ptr(), QObject* parent = 0 )
|
explicit DatabaseCommand_AllTracks( const Tomahawk::collection_ptr& collection = Tomahawk::collection_ptr(), QObject* parent = nullptr )
|
||||||
: DatabaseCommand( parent )
|
: DatabaseCommand( parent )
|
||||||
, m_collection( collection )
|
, m_collection( collection )
|
||||||
, m_artist( 0 )
|
, m_artist( nullptr )
|
||||||
, m_album( 0 )
|
, m_album( nullptr )
|
||||||
, m_amount( 0 )
|
, m_amount( 0 )
|
||||||
, m_sortOrder( DatabaseCommand_AllTracks::None )
|
, m_sortOrder( DatabaseCommand_AllTracks::None )
|
||||||
, m_sortDescending( false )
|
, m_sortDescending( false )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual void exec( DatabaseImpl* );
|
void exec( DatabaseImpl* ) override;
|
||||||
|
|
||||||
virtual bool doesMutates() const { return false; }
|
bool doesMutates() const override { return false; }
|
||||||
virtual QString commandname() const { return "alltracks"; }
|
QString commandname() const override { return "alltracks"; }
|
||||||
|
|
||||||
virtual void enqueue() { Database::instance()->enqueue( Tomahawk::dbcmd_ptr( this ) ); }
|
void enqueue() override { Database::instance()->enqueue( Tomahawk::dbcmd_ptr( this ) ); }
|
||||||
|
|
||||||
void setArtist( const Tomahawk::artist_ptr& artist ) { m_artist = artist; }
|
void setArtist( const Tomahawk::artist_ptr& artist ) { m_artist = artist; }
|
||||||
void setAlbum( const Tomahawk::album_ptr& album ) { m_album = album; }
|
void setAlbum( const Tomahawk::album_ptr& album ) { m_album = album; }
|
||||||
|
Reference in New Issue
Block a user