mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 11:20:22 +02:00
* Split up CTOR and setSource methods.
This commit is contained in:
@@ -33,21 +33,10 @@
|
|||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
|
||||||
|
|
||||||
RecentlyAddedModel::RecentlyAddedModel( const source_ptr& source, QObject* parent )
|
RecentlyAddedModel::RecentlyAddedModel( QObject* parent )
|
||||||
: PlayableModel( parent )
|
: PlayableModel( parent )
|
||||||
, m_source( source )
|
|
||||||
, m_limit( LATEST_TRACK_ITEMS )
|
, 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();
|
clear();
|
||||||
}
|
}
|
||||||
|
startLoading();
|
||||||
|
|
||||||
DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks( m_source->collection() );
|
DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks( m_source->collection() );
|
||||||
cmd->setLimit( m_limit );
|
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
|
void
|
||||||
RecentlyAddedModel::onSourceAdded( const Tomahawk::source_ptr& source )
|
RecentlyAddedModel::onSourceAdded( const Tomahawk::source_ptr& source )
|
||||||
{
|
{
|
||||||
|
@@ -32,7 +32,7 @@ class DLLEXPORT RecentlyAddedModel : public PlayableModel
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit RecentlyAddedModel( const Tomahawk::source_ptr& source, QObject* parent = 0 );
|
explicit RecentlyAddedModel( QObject* parent = 0 );
|
||||||
~RecentlyAddedModel();
|
~RecentlyAddedModel();
|
||||||
|
|
||||||
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