mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 05:37:29 +02:00
* Improved loading huge collections / super-collections with many sources.
This commit is contained in:
@@ -40,12 +40,12 @@ Album::Album( unsigned int id, const QString& name, const Tomahawk::artist_ptr&
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Album::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const Tomahawk::collection_ptr& collection )
|
Album::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
|
||||||
m_queries << tracks;
|
m_queries << tracks;
|
||||||
emit tracksAdded( tracks, collection );
|
emit tracksAdded( tracks );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -75,8 +75,8 @@ Album::tracks()
|
|||||||
cmd->setAlbum( this );
|
cmd->setAlbum( this );
|
||||||
cmd->setSortOrder( DatabaseCommand_AllTracks::AlbumPosition );
|
cmd->setSortOrder( DatabaseCommand_AllTracks::AlbumPosition );
|
||||||
|
|
||||||
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ),
|
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr> ) ),
|
||||||
SLOT( onTracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ) );
|
SLOT( onTracksAdded( QList<Tomahawk::query_ptr> ) ) );
|
||||||
|
|
||||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||||
}
|
}
|
||||||
|
@@ -47,12 +47,12 @@ signals:
|
|||||||
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
||||||
void shuffleModeChanged( bool enabled );
|
void shuffleModeChanged( bool enabled );
|
||||||
|
|
||||||
void tracksAdded( const QList<Tomahawk::query_ptr>& tracks, const Tomahawk::collection_ptr& );
|
void tracksAdded( const QList<Tomahawk::query_ptr>& tracks );
|
||||||
void trackCountChanged( unsigned int tracks );
|
void trackCountChanged( unsigned int tracks );
|
||||||
void sourceTrackCountChanged( unsigned int tracks );
|
void sourceTrackCountChanged( unsigned int tracks );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const Tomahawk::collection_ptr& collection );
|
void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned int m_id;
|
unsigned int m_id;
|
||||||
|
@@ -49,12 +49,12 @@ Artist::collection() const
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Artist::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const Tomahawk::collection_ptr& collection )
|
Artist::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
|
||||||
m_queries << tracks;
|
m_queries << tracks;
|
||||||
emit tracksAdded( tracks, collection );
|
emit tracksAdded( tracks );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -84,8 +84,8 @@ Artist::tracks()
|
|||||||
cmd->setArtist( this );
|
cmd->setArtist( this );
|
||||||
cmd->setSortOrder( DatabaseCommand_AllTracks::Album );
|
cmd->setSortOrder( DatabaseCommand_AllTracks::Album );
|
||||||
|
|
||||||
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ),
|
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr> ) ),
|
||||||
SLOT( onTracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ) );
|
SLOT( onTracksAdded( QList<Tomahawk::query_ptr> ) ) );
|
||||||
|
|
||||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||||
}
|
}
|
||||||
|
@@ -48,12 +48,12 @@ signals:
|
|||||||
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
||||||
void shuffleModeChanged( bool enabled );
|
void shuffleModeChanged( bool enabled );
|
||||||
|
|
||||||
void tracksAdded( const QList<Tomahawk::query_ptr>& tracks, const Tomahawk::collection_ptr& );
|
void tracksAdded( const QList<Tomahawk::query_ptr>& tracks );
|
||||||
void trackCountChanged( unsigned int tracks );
|
void trackCountChanged( unsigned int tracks );
|
||||||
void sourceTrackCountChanged( unsigned int tracks );
|
void sourceTrackCountChanged( unsigned int tracks );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const Tomahawk::collection_ptr& collection );
|
void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned int m_id;
|
unsigned int m_id;
|
||||||
|
@@ -13,9 +13,10 @@ Collection::Collection( const source_ptr& source, const QString& name, QObject*
|
|||||||
: QObject( parent )
|
: QObject( parent )
|
||||||
, m_name( name )
|
, m_name( name )
|
||||||
, m_lastmodified( 0 )
|
, m_lastmodified( 0 )
|
||||||
|
, m_isLoaded( false )
|
||||||
, m_source( source )
|
, m_source( source )
|
||||||
{
|
{
|
||||||
// qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO << name << source->friendlyName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -153,19 +154,20 @@ Collection::setDynamicPlaylists( const QList< Tomahawk::dynplaylist_ptr >& plist
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Collection::setTracks( const QList<Tomahawk::query_ptr>& tracks, const Tomahawk::collection_ptr& collection )
|
Collection::setTracks( const QList<Tomahawk::query_ptr>& tracks )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << tracks.count() << collection->name();
|
qDebug() << Q_FUNC_INFO << tracks.count() << name();
|
||||||
|
|
||||||
|
m_isLoaded = true;
|
||||||
m_tracks << tracks;
|
m_tracks << tracks;
|
||||||
emit tracksAdded( tracks, collection );
|
emit tracksAdded( tracks );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Collection::delTracks( const QStringList& files, const Tomahawk::collection_ptr& collection )
|
Collection::delTracks( const QStringList& files )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << files.count() << collection->name();
|
qDebug() << Q_FUNC_INFO << files.count() << name();
|
||||||
|
|
||||||
QList<Tomahawk::query_ptr> tracks;
|
QList<Tomahawk::query_ptr> tracks;
|
||||||
|
|
||||||
@@ -188,5 +190,5 @@ Collection::delTracks( const QStringList& files, const Tomahawk::collection_ptr&
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
emit tracksRemoved( tracks, collection );
|
emit tracksRemoved( tracks );
|
||||||
}
|
}
|
||||||
|
@@ -33,6 +33,7 @@ public:
|
|||||||
Collection( const source_ptr& source, const QString& name, QObject* parent = 0 );
|
Collection( const source_ptr& source, const QString& name, QObject* parent = 0 );
|
||||||
virtual ~Collection();
|
virtual ~Collection();
|
||||||
|
|
||||||
|
virtual bool isLoaded() const { return m_isLoaded; }
|
||||||
virtual QString name() const;
|
virtual QString name() const;
|
||||||
|
|
||||||
virtual void loadPlaylists() { qDebug() << Q_FUNC_INFO; }
|
virtual void loadPlaylists() { qDebug() << Q_FUNC_INFO; }
|
||||||
@@ -56,9 +57,8 @@ public:
|
|||||||
unsigned int lastmodified() const { return m_lastmodified; }
|
unsigned int lastmodified() const { return m_lastmodified; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void tracksAdded( const QList<Tomahawk::query_ptr>& tracks, const Tomahawk::collection_ptr& );
|
void tracksAdded( const QList<Tomahawk::query_ptr>& tracks );
|
||||||
void tracksRemoved( const QList<Tomahawk::query_ptr>& tracks, const Tomahawk::collection_ptr& );
|
void tracksRemoved( const QList<Tomahawk::query_ptr>& tracks );
|
||||||
void tracksFinished( const Tomahawk::collection_ptr& );
|
|
||||||
|
|
||||||
void playlistsAdded( const QList<Tomahawk::playlist_ptr>& );
|
void playlistsAdded( const QList<Tomahawk::playlist_ptr>& );
|
||||||
void playlistsDeleted( const QList<Tomahawk::playlist_ptr>& );
|
void playlistsDeleted( const QList<Tomahawk::playlist_ptr>& );
|
||||||
@@ -72,15 +72,17 @@ public slots:
|
|||||||
|
|
||||||
void setPlaylists( const QList<Tomahawk::playlist_ptr>& plists );
|
void setPlaylists( const QList<Tomahawk::playlist_ptr>& plists );
|
||||||
void setDynamicPlaylists( const QList< Tomahawk::dynplaylist_ptr >& dynplists );
|
void setDynamicPlaylists( const QList< Tomahawk::dynplaylist_ptr >& dynplists );
|
||||||
void setTracks( const QList<Tomahawk::query_ptr>& tracks, const Tomahawk::collection_ptr& collection );
|
void setTracks( const QList<Tomahawk::query_ptr>& tracks );
|
||||||
|
|
||||||
void delTracks( const QStringList& files, const Tomahawk::collection_ptr& collection );
|
void delTracks( const QStringList& files );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QString m_name;
|
QString m_name;
|
||||||
unsigned int m_lastmodified; // unix time of last change to collection
|
unsigned int m_lastmodified; // unix time of last change to collection
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool m_isLoaded;
|
||||||
|
|
||||||
source_ptr m_source;
|
source_ptr m_source;
|
||||||
QList< Tomahawk::query_ptr > m_tracks;
|
QList< Tomahawk::query_ptr > m_tracks;
|
||||||
QList< Tomahawk::playlist_ptr > m_playlists;
|
QList< Tomahawk::playlist_ptr > m_playlists;
|
||||||
|
@@ -51,8 +51,8 @@ DatabaseCollection::loadTracks()
|
|||||||
m_loadedTracks = true;
|
m_loadedTracks = true;
|
||||||
DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks( source()->collection() );
|
DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks( source()->collection() );
|
||||||
|
|
||||||
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ),
|
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr> ) ),
|
||||||
SLOT( setTracks( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ) );
|
SLOT( setTracks( QList<Tomahawk::query_ptr> ) ) );
|
||||||
|
|
||||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||||
}
|
}
|
||||||
|
@@ -110,6 +110,6 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi )
|
|||||||
|
|
||||||
qDebug() << Q_FUNC_INFO << ql.length();
|
qDebug() << Q_FUNC_INFO << ql.length();
|
||||||
|
|
||||||
emit tracks( ql, m_collection );
|
emit tracks( ql );
|
||||||
emit done( m_collection );
|
emit done( m_collection );
|
||||||
}
|
}
|
||||||
|
@@ -45,7 +45,7 @@ public:
|
|||||||
void setSortDescending( bool descending ) { m_sortDescending = descending; }
|
void setSortDescending( bool descending ) { m_sortDescending = descending; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void tracks( const QList<Tomahawk::query_ptr>&, const Tomahawk::collection_ptr& );
|
void tracks( const QList<Tomahawk::query_ptr>& );
|
||||||
void done( const Tomahawk::collection_ptr& );
|
void done( const Tomahawk::collection_ptr& );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -52,16 +52,15 @@ CollectionFlatModel::addCollection( const collection_ptr& collection )
|
|||||||
<< collection->source()->id()
|
<< collection->source()->id()
|
||||||
<< collection->source()->userName();
|
<< collection->source()->userName();
|
||||||
|
|
||||||
emit loadingStarts();
|
connect( collection.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr> ) ),
|
||||||
|
SLOT( onTracksAdded( QList<Tomahawk::query_ptr> ) ) );
|
||||||
|
connect( collection.data(), SIGNAL( tracksRemoved( QList<Tomahawk::query_ptr> ) ),
|
||||||
|
SLOT( onTracksRemoved( QList<Tomahawk::query_ptr> ) ) );
|
||||||
|
|
||||||
onTracksAdded( collection->tracks(), collection );
|
if ( collection->isLoaded() )
|
||||||
|
onTracksAdded( collection->tracks() );
|
||||||
connect( collection.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ),
|
else
|
||||||
SLOT( onTracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ) );
|
collection->tracks(); // data will arrive via signals
|
||||||
connect( collection.data(), SIGNAL( tracksFinished( Tomahawk::collection_ptr ) ),
|
|
||||||
SLOT( onTracksAddingFinished( Tomahawk::collection_ptr ) ) );
|
|
||||||
connect( collection.data(), SIGNAL( tracksRemoved( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ),
|
|
||||||
SLOT( onTracksRemoved( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ) );
|
|
||||||
|
|
||||||
if ( collection->source()->isLocal() )
|
if ( collection->source()->isLocal() )
|
||||||
setTitle( tr( "Your Collection" ) );
|
setTitle( tr( "Your Collection" ) );
|
||||||
@@ -78,8 +77,6 @@ CollectionFlatModel::addFilteredCollection( const collection_ptr& collection, un
|
|||||||
<< collection->source()->userName()
|
<< collection->source()->userName()
|
||||||
<< amount << order;
|
<< amount << order;
|
||||||
|
|
||||||
emit loadingStarts();
|
|
||||||
|
|
||||||
DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks( collection );
|
DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks( collection );
|
||||||
cmd->setLimit( amount );
|
cmd->setLimit( amount );
|
||||||
cmd->setSortOrder( order );
|
cmd->setSortOrder( order );
|
||||||
@@ -97,10 +94,8 @@ CollectionFlatModel::removeCollection( const collection_ptr& collection )
|
|||||||
{
|
{
|
||||||
return; // FIXME
|
return; // FIXME
|
||||||
|
|
||||||
disconnect( collection.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ),
|
disconnect( collection.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr> ) ),
|
||||||
this, SLOT( onTracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ) );
|
this, SLOT( onTracksAdded( QList<Tomahawk::query_ptr> ) ) );
|
||||||
disconnect( collection.data(), SIGNAL( tracksFinished( Tomahawk::collection_ptr ) ),
|
|
||||||
this, SLOT( onTracksAddingFinished( Tomahawk::collection_ptr ) ) );
|
|
||||||
|
|
||||||
QTime timer;
|
QTime timer;
|
||||||
timer.start();
|
timer.start();
|
||||||
@@ -160,56 +155,58 @@ CollectionFlatModel::removeCollection( const collection_ptr& collection )
|
|||||||
|
|
||||||
qDebug() << "Collection removed, time elapsed:" << timer.elapsed();
|
qDebug() << "Collection removed, time elapsed:" << timer.elapsed();
|
||||||
|
|
||||||
emit trackCountChanged( rowCount( QModelIndex() ) );
|
// emit trackCountChanged( rowCount( QModelIndex() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CollectionFlatModel::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const Tomahawk::collection_ptr& collection )
|
CollectionFlatModel::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO << tracks.count() << rowCount( QModelIndex() );
|
||||||
|
|
||||||
if ( !tracks.count() )
|
bool kickOff = m_tracksToAdd.isEmpty();
|
||||||
{
|
m_tracksToAdd << tracks;
|
||||||
emit trackCountChanged( rowCount( QModelIndex() ) );
|
|
||||||
return;
|
emit trackCountChanged( trackCount() );
|
||||||
|
|
||||||
|
if ( m_tracksToAdd.count() && kickOff )
|
||||||
|
processTracksToAdd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
CollectionFlatModel::processTracksToAdd()
|
||||||
|
{
|
||||||
|
int chunkSize = 5000;
|
||||||
|
int maxc = qMin( chunkSize, m_tracksToAdd.count() );
|
||||||
int c = rowCount( QModelIndex() );
|
int c = rowCount( QModelIndex() );
|
||||||
QPair< int, int > crows;
|
|
||||||
crows.first = c;
|
|
||||||
crows.second = c + tracks.count() - 1;
|
|
||||||
|
|
||||||
emit beginInsertRows( QModelIndex(), crows.first, crows.second );
|
emit beginInsertRows( QModelIndex(), c, c + maxc - 1 );
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
PlItem* plitem;
|
PlItem* plitem;
|
||||||
foreach( const query_ptr& query, tracks )
|
foreach( const query_ptr& query, m_tracksToAdd )
|
||||||
{
|
{
|
||||||
plitem = new PlItem( query, m_rootItem );
|
plitem = new PlItem( query, m_rootItem );
|
||||||
plitem->index = createIndex( m_rootItem->children.count() - 1, 0, plitem );
|
plitem->index = createIndex( m_rootItem->children.count() - 1, 0, plitem );
|
||||||
|
|
||||||
connect( plitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
|
connect( plitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
|
||||||
|
|
||||||
|
m_tracksToAdd.removeFirst();
|
||||||
|
if ( ++i % chunkSize == 0 )
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_collectionRows.insertMulti( collection, crows );
|
|
||||||
emit endInsertRows();
|
emit endInsertRows();
|
||||||
|
|
||||||
emit trackCountChanged( rowCount( QModelIndex() ) );
|
|
||||||
qDebug() << Q_FUNC_INFO << rowCount( QModelIndex() );
|
qDebug() << Q_FUNC_INFO << rowCount( QModelIndex() );
|
||||||
|
|
||||||
|
if ( m_tracksToAdd.count() )
|
||||||
|
QTimer::singleShot( 250, this, SLOT( processTracksToAdd() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CollectionFlatModel::onTracksAddingFinished( const Tomahawk::collection_ptr& collection )
|
CollectionFlatModel::onTracksRemoved( const QList<Tomahawk::query_ptr>& tracks )
|
||||||
{
|
|
||||||
qDebug() << "Finished loading tracks" << collection->source()->friendlyName();
|
|
||||||
|
|
||||||
emit loadingFinished();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
CollectionFlatModel::onTracksRemoved( const QList<Tomahawk::query_ptr>& tracks, const Tomahawk::collection_ptr& collection )
|
|
||||||
{
|
{
|
||||||
QList<Tomahawk::query_ptr> t = tracks;
|
QList<Tomahawk::query_ptr> t = tracks;
|
||||||
for ( int i = rowCount( QModelIndex() ); i >= 0 && t.count(); i-- )
|
for ( int i = rowCount( QModelIndex() ); i >= 0 && t.count(); i-- )
|
||||||
@@ -236,7 +233,7 @@ CollectionFlatModel::onTracksRemoved( const QList<Tomahawk::query_ptr>& tracks,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
emit trackCountChanged( rowCount( QModelIndex() ) );
|
// emit trackCountChanged( rowCount( QModelIndex() ) );
|
||||||
qDebug() << Q_FUNC_INFO << rowCount( QModelIndex() );
|
qDebug() << Q_FUNC_INFO << rowCount( QModelIndex() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -29,6 +29,8 @@ public:
|
|||||||
|
|
||||||
int columnCount( const QModelIndex& parent = QModelIndex() ) const;
|
int columnCount( const QModelIndex& parent = QModelIndex() ) const;
|
||||||
|
|
||||||
|
virtual int trackCount() const { return rowCount( QModelIndex() ) + m_tracksToAdd.count(); }
|
||||||
|
|
||||||
QVariant data( const QModelIndex& index, int role ) const;
|
QVariant data( const QModelIndex& index, int role ) const;
|
||||||
QVariant headerData( int section, Qt::Orientation orientation, int role ) const;
|
QVariant headerData( int section, Qt::Orientation orientation, int role ) const;
|
||||||
|
|
||||||
@@ -45,21 +47,19 @@ signals:
|
|||||||
|
|
||||||
void itemSizeChanged( const QModelIndex& index );
|
void itemSizeChanged( const QModelIndex& index );
|
||||||
|
|
||||||
void loadingStarts();
|
|
||||||
void loadingFinished();
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onDataChanged();
|
void onDataChanged();
|
||||||
|
|
||||||
void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const Tomahawk::collection_ptr& collection );
|
void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks );
|
||||||
void onTracksAddingFinished( const Tomahawk::collection_ptr& collection );
|
void onTracksRemoved( const QList<Tomahawk::query_ptr>& tracks );
|
||||||
|
|
||||||
void onTracksRemoved( const QList<Tomahawk::query_ptr>& tracks, const Tomahawk::collection_ptr& collection );
|
|
||||||
|
|
||||||
void onSourceOffline( const Tomahawk::source_ptr& src );
|
void onSourceOffline( const Tomahawk::source_ptr& src );
|
||||||
|
|
||||||
|
void processTracksToAdd();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QMap< Tomahawk::collection_ptr, QPair< int, int > > m_collectionRows;
|
QMap< Tomahawk::collection_ptr, QPair< int, int > > m_collectionRows;
|
||||||
|
QList<Tomahawk::query_ptr> m_tracksToAdd;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // COLLECTIONFLATMODEL_H
|
#endif // COLLECTIONFLATMODEL_H
|
||||||
|
@@ -576,7 +576,12 @@ PlaylistManager::updateView()
|
|||||||
if ( currentPage()->showStatsBar() && currentPlaylistInterface() )
|
if ( currentPage()->showStatsBar() && currentPlaylistInterface() )
|
||||||
{
|
{
|
||||||
emit numTracksChanged( currentPlaylistInterface()->unfilteredTrackCount() );
|
emit numTracksChanged( currentPlaylistInterface()->unfilteredTrackCount() );
|
||||||
|
|
||||||
|
if ( !currentPlaylistInterface()->filter().isEmpty() )
|
||||||
emit numShownChanged( currentPlaylistInterface()->trackCount() );
|
emit numShownChanged( currentPlaylistInterface()->trackCount() );
|
||||||
|
else
|
||||||
|
emit numShownChanged( currentPlaylistInterface()->unfilteredTrackCount() );
|
||||||
|
|
||||||
emit repeatModeChanged( currentPlaylistInterface()->repeatMode() );
|
emit repeatModeChanged( currentPlaylistInterface()->repeatMode() );
|
||||||
emit shuffleModeChanged( currentPlaylistInterface()->shuffled() );
|
emit shuffleModeChanged( currentPlaylistInterface()->shuffled() );
|
||||||
emit modeChanged( currentPlaylistInterface()->viewMode() );
|
emit modeChanged( currentPlaylistInterface()->viewMode() );
|
||||||
|
@@ -155,10 +155,10 @@ PlaylistModel::append( const Tomahawk::album_ptr& album )
|
|||||||
if ( album.isNull() )
|
if ( album.isNull() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
connect( album.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ),
|
connect( album.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr> ) ),
|
||||||
SLOT( onTracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ) );
|
SLOT( onTracksAdded( QList<Tomahawk::query_ptr> ) ) );
|
||||||
|
|
||||||
onTracksAdded( album->tracks(), album->collection() );
|
onTracksAdded( album->tracks() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -168,10 +168,10 @@ PlaylistModel::append( const Tomahawk::artist_ptr& artist )
|
|||||||
if ( artist.isNull() )
|
if ( artist.isNull() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
connect( artist.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ),
|
connect( artist.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr> ) ),
|
||||||
SLOT( onTracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ) );
|
SLOT( onTracksAdded( QList<Tomahawk::query_ptr> ) ) );
|
||||||
|
|
||||||
onTracksAdded( artist->tracks(), artist->collection() );
|
onTracksAdded( artist->tracks() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -189,14 +189,14 @@ PlaylistModel::insert( unsigned int row, const Tomahawk::query_ptr& query )
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PlaylistModel::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const Tomahawk::collection_ptr& collection )
|
PlaylistModel::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks )
|
||||||
{
|
{
|
||||||
onTracksInserted( rowCount( QModelIndex() ), tracks, collection );
|
onTracksInserted( rowCount( QModelIndex() ), tracks );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PlaylistModel::onTracksInserted( unsigned int row, const QList<Tomahawk::query_ptr>& tracks, const Tomahawk::collection_ptr& collection )
|
PlaylistModel::onTracksInserted( unsigned int row, const QList<Tomahawk::query_ptr>& tracks )
|
||||||
{
|
{
|
||||||
if ( !tracks.count() )
|
if ( !tracks.count() )
|
||||||
{
|
{
|
||||||
|
@@ -61,8 +61,8 @@ private slots:
|
|||||||
void onRevisionLoaded( Tomahawk::PlaylistRevision revision );
|
void onRevisionLoaded( Tomahawk::PlaylistRevision revision );
|
||||||
void onPlaylistChanged( bool waitForUpdate = true );
|
void onPlaylistChanged( bool waitForUpdate = true );
|
||||||
|
|
||||||
void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const Tomahawk::collection_ptr& collection = Tomahawk::collection_ptr() );
|
void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks );
|
||||||
void onTracksInserted( unsigned int row, const QList<Tomahawk::query_ptr>& tracks, const Tomahawk::collection_ptr& collection = Tomahawk::collection_ptr() );
|
void onTracksInserted( unsigned int row, const QList<Tomahawk::query_ptr>& tracks );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<Tomahawk::plentry_ptr> playlistEntries() const;
|
QList<Tomahawk::plentry_ptr> playlistEntries() const;
|
||||||
|
@@ -137,9 +137,6 @@ TrackProxyModel::siblingItem( int itemsAway )
|
|||||||
bool
|
bool
|
||||||
TrackProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const
|
TrackProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const
|
||||||
{
|
{
|
||||||
if ( filterRegExp().isEmpty() )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
PlItem* pi = itemFromIndex( sourceModel()->index( sourceRow, 0, sourceParent ) );
|
PlItem* pi = itemFromIndex( sourceModel()->index( sourceRow, 0, sourceParent ) );
|
||||||
if ( !pi )
|
if ( !pi )
|
||||||
return false;
|
return false;
|
||||||
@@ -147,34 +144,39 @@ TrackProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParen
|
|||||||
const Tomahawk::query_ptr& q = pi->query();
|
const Tomahawk::query_ptr& q = pi->query();
|
||||||
Tomahawk::result_ptr r;
|
Tomahawk::result_ptr r;
|
||||||
if ( q->numResults() )
|
if ( q->numResults() )
|
||||||
r = q->results().at( 0 );
|
r = q->results().first();
|
||||||
|
|
||||||
|
// if ( !r.isNull() && !r->collection()->source()->isOnline() )
|
||||||
|
// return false;
|
||||||
|
|
||||||
|
if ( filterRegExp().isEmpty() )
|
||||||
|
return true;
|
||||||
|
|
||||||
QStringList sl = filterRegExp().pattern().split( " ", QString::SkipEmptyParts );
|
QStringList sl = filterRegExp().pattern().split( " ", QString::SkipEmptyParts );
|
||||||
bool found = true;
|
foreach( QString s, sl )
|
||||||
|
|
||||||
foreach( const QString& s, sl )
|
|
||||||
{
|
{
|
||||||
|
s = s.toLower();
|
||||||
if ( !r.isNull() )
|
if ( !r.isNull() )
|
||||||
{
|
{
|
||||||
if ( !r->artist()->name().contains( s, Qt::CaseInsensitive ) &&
|
if ( !r->artist()->name().toLower().contains( s ) &&
|
||||||
!r->album()->name().contains( s, Qt::CaseInsensitive ) &&
|
!r->album()->name().toLower().contains( s ) &&
|
||||||
!r->track() .contains( s, Qt::CaseInsensitive ) )
|
!r->track().toLower().contains( s ) )
|
||||||
{
|
{
|
||||||
found = false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( !q->artist().contains( s, Qt::CaseInsensitive ) &&
|
if ( !q->artist().toLower().contains( s ) &&
|
||||||
!q->album() .contains( s, Qt::CaseInsensitive ) &&
|
!q->album().toLower().contains( s ) &&
|
||||||
!q->track() .contains( s, Qt::CaseInsensitive ) )
|
!q->track().toLower().contains( s ) )
|
||||||
{
|
{
|
||||||
found = false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return found;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -23,7 +23,7 @@ public:
|
|||||||
|
|
||||||
virtual QList<Tomahawk::query_ptr> tracks();
|
virtual QList<Tomahawk::query_ptr> tracks();
|
||||||
|
|
||||||
virtual int unfilteredTrackCount() const { return sourceModel()->rowCount( QModelIndex() ); }
|
virtual int unfilteredTrackCount() const { return sourceModel()->trackCount(); }
|
||||||
virtual int trackCount() const { return rowCount( QModelIndex() ); }
|
virtual int trackCount() const { return rowCount( QModelIndex() ); }
|
||||||
|
|
||||||
virtual void removeIndex( const QModelIndex& index );
|
virtual void removeIndex( const QModelIndex& index );
|
||||||
|
@@ -70,6 +70,7 @@ Query::refreshResults()
|
|||||||
void
|
void
|
||||||
Query::onResultStatusChanged()
|
Query::onResultStatusChanged()
|
||||||
{
|
{
|
||||||
|
if ( m_results.count() )
|
||||||
qStableSort( m_results.begin(), m_results.end(), Query::resultSorter );
|
qStableSort( m_results.begin(), m_results.end(), Query::resultSorter );
|
||||||
checkResults();
|
checkResults();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user