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