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:56:47 +02:00
parent 972a57bfeb
commit 8fc89f3a2b
2 changed files with 28 additions and 13 deletions

View File

@ -33,21 +33,10 @@
using namespace Tomahawk;
RecentlyAddedModel::RecentlyAddedModel( const source_ptr& source, QObject* parent )
RecentlyAddedModel::RecentlyAddedModel( QObject* parent )
: PlayableModel( parent )
, m_source( source )
, m_limit( LATEST_TRACK_ITEMS )
{
if ( source.isNull() )
{
connect( SourceList::instance(), SIGNAL( ready() ), SLOT( onSourcesReady() ) );
connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), SLOT( onSourceAdded( Tomahawk::source_ptr ) ) );
}
else
{
onSourceAdded( source );
loadHistory();
}
}
@ -63,6 +52,7 @@ RecentlyAddedModel::loadHistory()
{
clear();
}
startLoading();
DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks( m_source->collection() );
cmd->setLimit( m_limit );
@ -88,6 +78,28 @@ RecentlyAddedModel::onSourcesReady()
}
void
RecentlyAddedModel::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
RecentlyAddedModel::onSourceAdded( const Tomahawk::source_ptr& source )
{

View File

@ -32,7 +32,7 @@ class DLLEXPORT RecentlyAddedModel : public PlayableModel
Q_OBJECT
public:
explicit RecentlyAddedModel( const Tomahawk::source_ptr& source, QObject* parent = 0 );
explicit RecentlyAddedModel( QObject* parent = 0 );
~RecentlyAddedModel();
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 );