1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-31 06:02:27 +02:00

* Split up CTOR and setSource methods.

This commit is contained in:
Christian Muehlhaeuser 2012-06-26 02:57:12 +02:00
parent 8fc89f3a2b
commit e316534dc0
2 changed files with 27 additions and 18 deletions

View File

@ -34,25 +34,10 @@
using namespace Tomahawk;
RecentlyPlayedModel::RecentlyPlayedModel( const source_ptr& source, QObject* parent )
RecentlyPlayedModel::RecentlyPlayedModel( QObject* parent )
: PlaylistModel( parent )
, m_source( source )
, 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();
}
loadingStarted();
startLoading();
DatabaseCommand_PlaybackHistory* cmd = new DatabaseCommand_PlaybackHistory( m_source );
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
RecentlyPlayedModel::onSourceAdded( const Tomahawk::source_ptr& source )
{

View File

@ -32,7 +32,7 @@ class DLLEXPORT RecentlyPlayedModel : public PlaylistModel
Q_OBJECT
public:
explicit RecentlyPlayedModel( const Tomahawk::source_ptr& source, QObject* parent = 0 );
explicit RecentlyPlayedModel( QObject* parent = 0 );
~RecentlyPlayedModel();
unsigned int limit() const { return m_limit; }
@ -40,6 +40,9 @@ public:
bool isTemporary() const;
public slots:
void setSource( const Tomahawk::source_ptr& source );
private slots:
void onSourcesReady();
void onSourceAdded( const Tomahawk::source_ptr& source );