mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-19 23:39:42 +01:00
* Refresh treeviews after adding / removing a collection's tracks.
This commit is contained in:
parent
69f1d776eb
commit
e0ca2178d0
@ -171,12 +171,6 @@ Collection::station( const QString& guid )
|
||||
return m_stations.value( guid, dynplaylist_ptr() );
|
||||
}
|
||||
|
||||
QList< query_ptr >
|
||||
Collection::tracks()
|
||||
{
|
||||
return m_tracks;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Collection::setPlaylists( const QList<Tomahawk::playlist_ptr>& plists )
|
||||
@ -226,8 +220,8 @@ Collection::setTracks( const QList<Tomahawk::query_ptr>& tracks )
|
||||
{
|
||||
// qDebug() << Q_FUNC_INFO << tracks.count() << name();
|
||||
|
||||
m_tracks << tracks;
|
||||
emit tracksAdded( tracks );
|
||||
emit changed();
|
||||
}
|
||||
|
||||
|
||||
@ -235,8 +229,9 @@ void
|
||||
Collection::delTracks( const QStringList& files )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << files.count() << name();
|
||||
emit changed();
|
||||
|
||||
QList<Tomahawk::query_ptr> tracks;
|
||||
/* QList<Tomahawk::query_ptr> tracks;
|
||||
int i = 0;
|
||||
foreach ( const query_ptr& query, m_tracks )
|
||||
{
|
||||
@ -263,7 +258,7 @@ Collection::delTracks( const QStringList& files )
|
||||
}
|
||||
|
||||
tDebug() << "Emitting tracks removed:" << tracks.size();
|
||||
emit tracksRemoved( tracks );
|
||||
emit tracksRemoved( tracks );*/
|
||||
}
|
||||
|
||||
|
||||
|
@ -55,9 +55,8 @@ public:
|
||||
virtual QString name() const;
|
||||
|
||||
virtual void loadPlaylists() { qDebug() << Q_FUNC_INFO; }
|
||||
virtual void loadTracks() { qDebug() << Q_FUNC_INFO; }
|
||||
virtual void loadAutoPlaylists() { qDebug() << Q_FUNC_INFO ; }
|
||||
virtual void loadStations() { qDebug() << Q_FUNC_INFO ; }
|
||||
virtual void loadAutoPlaylists() { qDebug() << Q_FUNC_INFO; }
|
||||
virtual void loadStations() { qDebug() << Q_FUNC_INFO; }
|
||||
|
||||
virtual Tomahawk::playlist_ptr playlist( const QString& guid );
|
||||
virtual Tomahawk::dynplaylist_ptr autoPlaylist( const QString& guid );
|
||||
@ -75,7 +74,6 @@ public:
|
||||
virtual QList< Tomahawk::playlist_ptr > playlists() { return m_playlists.values(); }
|
||||
virtual QList< Tomahawk::dynplaylist_ptr > autoPlaylists() { return m_autoplaylists.values(); }
|
||||
virtual QList< Tomahawk::dynplaylist_ptr > stations() { return m_stations.values(); }
|
||||
virtual QList< Tomahawk::query_ptr > tracks();
|
||||
|
||||
const source_ptr& source() const;
|
||||
unsigned int lastmodified() const { return m_lastmodified; }
|
||||
@ -93,6 +91,8 @@ signals:
|
||||
void stationsAdded( const QList<Tomahawk::dynplaylist_ptr>& );
|
||||
void stationsDeleted( const QList<Tomahawk::dynplaylist_ptr>& );
|
||||
|
||||
void changed();
|
||||
|
||||
public slots:
|
||||
virtual void addTracks( const QList<QVariant>& newitems ) = 0;
|
||||
virtual void removeTracks( const QDir& dir ) = 0;
|
||||
@ -103,7 +103,6 @@ public slots:
|
||||
|
||||
void setTracks( const QList<Tomahawk::query_ptr>& tracks );
|
||||
void delTracks( const QStringList& files );
|
||||
void resetTrackCache() { m_tracks.clear(); m_isLoaded = false; }
|
||||
|
||||
protected:
|
||||
QString m_name;
|
||||
@ -113,7 +112,6 @@ private:
|
||||
bool m_isLoaded;
|
||||
|
||||
source_ptr m_source;
|
||||
QList< Tomahawk::query_ptr > m_tracks;
|
||||
QHash< QString, Tomahawk::playlist_ptr > m_playlists;
|
||||
QHash< QString, Tomahawk::dynplaylist_ptr > m_autoplaylists;
|
||||
QHash< QString, Tomahawk::dynplaylist_ptr > m_stations;
|
||||
|
@ -72,7 +72,7 @@ DatabaseCollection::loadStations()
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );}
|
||||
|
||||
|
||||
void
|
||||
/*void
|
||||
DatabaseCollection::loadTracks()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << source()->userName();
|
||||
@ -84,7 +84,7 @@ DatabaseCollection::loadTracks()
|
||||
SLOT( setTracks( QList<Tomahawk::query_ptr> ) ) );
|
||||
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
void
|
||||
@ -143,7 +143,7 @@ DatabaseCollection::stations()
|
||||
}
|
||||
|
||||
|
||||
QList< Tomahawk::query_ptr >
|
||||
/*QList< Tomahawk::query_ptr >
|
||||
DatabaseCollection::tracks()
|
||||
{
|
||||
if ( !isLoaded() )
|
||||
@ -152,7 +152,7 @@ DatabaseCollection::tracks()
|
||||
}
|
||||
|
||||
return Collection::tracks();
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
void DatabaseCollection::autoPlaylistCreated( const source_ptr& source, const QVariantList& data )
|
||||
|
@ -38,13 +38,11 @@ public:
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
}
|
||||
|
||||
virtual void loadTracks();
|
||||
virtual void loadPlaylists();
|
||||
virtual void loadAutoPlaylists();
|
||||
virtual void loadStations();
|
||||
|
||||
virtual QList< Tomahawk::playlist_ptr > playlists();
|
||||
virtual QList< Tomahawk::query_ptr > tracks();
|
||||
virtual QList< Tomahawk::dynplaylist_ptr > autoPlaylists();
|
||||
virtual QList< Tomahawk::dynplaylist_ptr > stations();
|
||||
|
||||
|
@ -72,15 +72,13 @@ CollectionFlatModel::addCollection( const collection_ptr& collection, bool sendN
|
||||
if( sendNotifications )
|
||||
emit loadingStarted();
|
||||
|
||||
if ( collection->isLoaded() )
|
||||
{
|
||||
onTracksAdded( collection->tracks() );
|
||||
}
|
||||
else
|
||||
{
|
||||
collection->tracks(); // data will arrive via signals
|
||||
m_loadingCollections << collection.data();
|
||||
}
|
||||
DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks( collection );
|
||||
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr>, QVariant ) ),
|
||||
SLOT( onTracksAdded( QList<Tomahawk::query_ptr> ) ), Qt::QueuedConnection );
|
||||
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
|
||||
m_loadingCollections << collection.data();
|
||||
|
||||
if ( collection->source()->isLocal() )
|
||||
setTitle( tr( "My Collection" ) );
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <QNetworkReply>
|
||||
|
||||
#include "source.h"
|
||||
#include "sourcelist.h"
|
||||
#include "audio/audioengine.h"
|
||||
#include "database/databasecommand_allalbums.h"
|
||||
#include "database/databasecommand_alltracks.h"
|
||||
@ -553,6 +554,14 @@ TreeModel::addAllCollections()
|
||||
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
|
||||
connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), SLOT( onSourceAdded( Tomahawk::source_ptr ) ) );
|
||||
|
||||
QList<Tomahawk::source_ptr> sources = SourceList::instance()->sources();
|
||||
foreach ( const source_ptr& source, sources )
|
||||
{
|
||||
connect( source->collection().data(), SIGNAL( changed() ), SLOT( onCollectionChanged() ) );
|
||||
}
|
||||
|
||||
m_title = tr( "All Artists" );
|
||||
}
|
||||
|
||||
@ -659,6 +668,8 @@ TreeModel::addCollection( const collection_ptr& collection )
|
||||
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
|
||||
connect( collection.data(), SIGNAL( changed() ), SLOT( onCollectionChanged() ) );
|
||||
|
||||
if ( !collection->source()->avatar().isNull() )
|
||||
setIcon( collection->source()->avatar() );
|
||||
|
||||
@ -694,6 +705,25 @@ TreeModel::addFilteredCollection( const collection_ptr& collection, unsigned int
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TreeModel::onSourceAdded( const Tomahawk::source_ptr& source )
|
||||
{
|
||||
connect( source->collection().data(), SIGNAL( changed() ), SLOT( onCollectionChanged() ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TreeModel::onCollectionChanged()
|
||||
{
|
||||
clear();
|
||||
|
||||
if ( m_collection )
|
||||
addCollection( m_collection );
|
||||
else
|
||||
addAllCollections();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TreeModel::onArtistsAdded( const QList<Tomahawk::artist_ptr>& artists )
|
||||
{
|
||||
|
@ -154,6 +154,9 @@ private slots:
|
||||
|
||||
void onDataChanged();
|
||||
|
||||
void onSourceAdded( const Tomahawk::source_ptr& source );
|
||||
void onCollectionChanged();
|
||||
|
||||
private:
|
||||
QPersistentModelIndex m_currentIndex;
|
||||
TreeModelItem* m_rootItem;
|
||||
|
@ -69,6 +69,7 @@ private slots:
|
||||
|
||||
void latchedOn( const Tomahawk::source_ptr& );
|
||||
void latchedOff( const Tomahawk::source_ptr& );
|
||||
|
||||
private:
|
||||
void add( const Tomahawk::source_ptr& source );
|
||||
|
||||
|
@ -35,9 +35,11 @@ SourcePlaylistInterface::SourcePlaylistInterface( Tomahawk::source_ptr& source )
|
||||
connect( source.data(), SIGNAL( playbackStarted( const Tomahawk::query_ptr& ) ), SLOT( onSourcePlaybackStarted( const Tomahawk::query_ptr& ) ) );
|
||||
}
|
||||
|
||||
|
||||
SourcePlaylistInterface::~SourcePlaylistInterface()
|
||||
{}
|
||||
|
||||
|
||||
Tomahawk::result_ptr
|
||||
SourcePlaylistInterface::siblingItem( int itemsAway )
|
||||
{
|
||||
@ -67,12 +69,14 @@ SourcePlaylistInterface::nextItem()
|
||||
return m_currentItem;
|
||||
}
|
||||
|
||||
|
||||
result_ptr
|
||||
SourcePlaylistInterface::currentItem() const
|
||||
{
|
||||
return m_currentItem;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
SourcePlaylistInterface::hasNextItem()
|
||||
{
|
||||
@ -87,7 +91,8 @@ SourcePlaylistInterface::hasNextItem()
|
||||
QList<Tomahawk::query_ptr>
|
||||
SourcePlaylistInterface::tracks()
|
||||
{
|
||||
return m_source->collection()->tracks();
|
||||
QList<Tomahawk::query_ptr> tracks;
|
||||
return tracks; // FIXME
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user