mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 22:26:32 +02:00
* Split up CTOR and setSource methods.
This commit is contained in:
@@ -34,25 +34,10 @@
|
|||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
|
||||||
|
|
||||||
RecentlyPlayedModel::RecentlyPlayedModel( const source_ptr& source, QObject* parent )
|
RecentlyPlayedModel::RecentlyPlayedModel( QObject* parent )
|
||||||
: PlaylistModel( parent )
|
: PlaylistModel( parent )
|
||||||
, m_source( source )
|
|
||||||
, m_limit( HISTORY_TRACK_ITEMS )
|
, m_limit( HISTORY_TRACK_ITEMS )
|
||||||
{
|
{
|
||||||
if ( source.isNull() )
|
|
||||||
{
|
|
||||||
if ( SourceList::instance()->isReady() )
|
|
||||||
onSourcesReady();
|
|
||||||
else
|
|
||||||
connect( SourceList::instance(), SIGNAL( ready() ), SLOT( onSourcesReady() ) );
|
|
||||||
|
|
||||||
connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), SLOT( onSourceAdded( Tomahawk::source_ptr ) ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
onSourceAdded( source );
|
|
||||||
loadHistory();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -68,7 +53,7 @@ RecentlyPlayedModel::loadHistory()
|
|||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
loadingStarted();
|
startLoading();
|
||||||
|
|
||||||
DatabaseCommand_PlaybackHistory* cmd = new DatabaseCommand_PlaybackHistory( m_source );
|
DatabaseCommand_PlaybackHistory* cmd = new DatabaseCommand_PlaybackHistory( m_source );
|
||||||
cmd->setLimit( m_limit );
|
cmd->setLimit( m_limit );
|
||||||
@@ -92,6 +77,27 @@ RecentlyPlayedModel::onSourcesReady()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
RecentlyPlayedModel::setSource( const Tomahawk::source_ptr& source )
|
||||||
|
{
|
||||||
|
m_source = source;
|
||||||
|
if ( source.isNull() )
|
||||||
|
{
|
||||||
|
if ( SourceList::instance()->isReady() )
|
||||||
|
onSourcesReady();
|
||||||
|
else
|
||||||
|
connect( SourceList::instance(), SIGNAL( ready() ), SLOT( onSourcesReady() ) );
|
||||||
|
|
||||||
|
connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), SLOT( onSourceAdded( Tomahawk::source_ptr ) ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
onSourceAdded( source );
|
||||||
|
loadHistory();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
RecentlyPlayedModel::onSourceAdded( const Tomahawk::source_ptr& source )
|
RecentlyPlayedModel::onSourceAdded( const Tomahawk::source_ptr& source )
|
||||||
{
|
{
|
||||||
|
@@ -32,7 +32,7 @@ class DLLEXPORT RecentlyPlayedModel : public PlaylistModel
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit RecentlyPlayedModel( const Tomahawk::source_ptr& source, QObject* parent = 0 );
|
explicit RecentlyPlayedModel( QObject* parent = 0 );
|
||||||
~RecentlyPlayedModel();
|
~RecentlyPlayedModel();
|
||||||
|
|
||||||
unsigned int limit() const { return m_limit; }
|
unsigned int limit() const { return m_limit; }
|
||||||
@@ -40,6 +40,9 @@ public:
|
|||||||
|
|
||||||
bool isTemporary() const;
|
bool isTemporary() const;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setSource( const Tomahawk::source_ptr& source );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onSourcesReady();
|
void onSourcesReady();
|
||||||
void onSourceAdded( const Tomahawk::source_ptr& source );
|
void onSourceAdded( const Tomahawk::source_ptr& source );
|
||||||
|
Reference in New Issue
Block a user