mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 05:37:29 +02:00
* Don't show offline results in SuperCollection and general collection loading speed-ups.
This commit is contained in:
@@ -24,27 +24,6 @@ CollectionFlatModel::~CollectionFlatModel()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
CollectionFlatModel::columnCount( const QModelIndex& parent ) const
|
|
||||||
{
|
|
||||||
return TrackModel::columnCount( parent );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QVariant
|
|
||||||
CollectionFlatModel::data( const QModelIndex& index, int role ) const
|
|
||||||
{
|
|
||||||
return TrackModel::data( index, role );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QVariant
|
|
||||||
CollectionFlatModel::headerData( int section, Qt::Orientation orientation, int role ) const
|
|
||||||
{
|
|
||||||
return TrackModel::headerData( section, orientation, role );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CollectionFlatModel::addCollections( const QList< collection_ptr >& collections )
|
CollectionFlatModel::addCollections( const QList< collection_ptr >& collections )
|
||||||
{
|
{
|
||||||
@@ -72,15 +51,17 @@ CollectionFlatModel::addCollection( const collection_ptr& collection, bool sendN
|
|||||||
connect( collection.data(), SIGNAL( tracksRemoved( QList<Tomahawk::query_ptr> ) ),
|
connect( collection.data(), SIGNAL( tracksRemoved( QList<Tomahawk::query_ptr> ) ),
|
||||||
SLOT( onTracksRemoved( QList<Tomahawk::query_ptr> ) ) );
|
SLOT( onTracksRemoved( QList<Tomahawk::query_ptr> ) ) );
|
||||||
|
|
||||||
|
if( sendNotifications )
|
||||||
|
emit loadingStarted();
|
||||||
|
|
||||||
if ( collection->isLoaded() )
|
if ( collection->isLoaded() )
|
||||||
|
{
|
||||||
onTracksAdded( collection->tracks() );
|
onTracksAdded( collection->tracks() );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
collection->tracks(); // data will arrive via signals
|
collection->tracks(); // data will arrive via signals
|
||||||
|
|
||||||
m_loadingCollections << collection.data();
|
m_loadingCollections << collection.data();
|
||||||
if( sendNotifications )
|
|
||||||
emit loadingStarted();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( collection->source()->isLocal() )
|
if ( collection->source()->isLocal() )
|
||||||
@@ -190,8 +171,6 @@ CollectionFlatModel::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks )
|
|||||||
// we are keeping track and are called as a slot
|
// we are keeping track and are called as a slot
|
||||||
m_loadingCollections.removeAll( qobject_cast< Collection* >( sender() ) );
|
m_loadingCollections.removeAll( qobject_cast< Collection* >( sender() ) );
|
||||||
}
|
}
|
||||||
if( m_loadingCollections.isEmpty() )
|
|
||||||
emit loadingFinished();
|
|
||||||
|
|
||||||
bool kickOff = m_tracksToAdd.isEmpty();
|
bool kickOff = m_tracksToAdd.isEmpty();
|
||||||
m_tracksToAdd << tracks;
|
m_tracksToAdd << tracks;
|
||||||
@@ -206,7 +185,7 @@ CollectionFlatModel::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks )
|
|||||||
void
|
void
|
||||||
CollectionFlatModel::processTracksToAdd()
|
CollectionFlatModel::processTracksToAdd()
|
||||||
{
|
{
|
||||||
int chunkSize = 500000;
|
int chunkSize = 5000;
|
||||||
int maxc = qMin( chunkSize, m_tracksToAdd.count() );
|
int maxc = qMin( chunkSize, m_tracksToAdd.count() );
|
||||||
int c = rowCount( QModelIndex() );
|
int c = rowCount( QModelIndex() );
|
||||||
|
|
||||||
@@ -218,7 +197,6 @@ CollectionFlatModel::processTracksToAdd()
|
|||||||
|
|
||||||
for( int i = 0; i < maxc; ++i )
|
for( int i = 0; i < maxc; ++i )
|
||||||
{
|
{
|
||||||
|
|
||||||
plitem = new PlItem( *iter, m_rootItem );
|
plitem = new PlItem( *iter, m_rootItem );
|
||||||
plitem->index = createIndex( m_rootItem->children.count() - 1, 0, plitem );
|
plitem->index = createIndex( m_rootItem->children.count() - 1, 0, plitem );
|
||||||
|
|
||||||
@@ -229,6 +207,9 @@ CollectionFlatModel::processTracksToAdd()
|
|||||||
|
|
||||||
m_tracksToAdd.erase( m_tracksToAdd.begin(), iter );
|
m_tracksToAdd.erase( m_tracksToAdd.begin(), iter );
|
||||||
|
|
||||||
|
if ( m_tracksToAdd.isEmpty() && m_loadingCollections.isEmpty() )
|
||||||
|
emit loadingFinished();
|
||||||
|
|
||||||
//endResetModel();
|
//endResetModel();
|
||||||
emit endInsertRows();
|
emit endInsertRows();
|
||||||
qDebug() << Q_FUNC_INFO << rowCount( QModelIndex() );
|
qDebug() << Q_FUNC_INFO << rowCount( QModelIndex() );
|
||||||
@@ -278,7 +259,7 @@ CollectionFlatModel::onDataChanged()
|
|||||||
// emit itemSizeChanged( p->index );
|
// emit itemSizeChanged( p->index );
|
||||||
|
|
||||||
if ( p )
|
if ( p )
|
||||||
emit dataChanged( p->index, p->index.sibling( p->index.row(), columnCount() - 1 ) );
|
emit dataChanged( p->index, p->index.sibling( p->index.row(), columnCount( QModelIndex() ) - 1 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -27,13 +27,8 @@ public:
|
|||||||
explicit CollectionFlatModel( QObject* parent = 0 );
|
explicit CollectionFlatModel( QObject* parent = 0 );
|
||||||
~CollectionFlatModel();
|
~CollectionFlatModel();
|
||||||
|
|
||||||
int columnCount( const QModelIndex& parent = QModelIndex() ) const;
|
|
||||||
|
|
||||||
virtual int trackCount() const { return rowCount( QModelIndex() ) + m_tracksToAdd.count(); }
|
virtual int trackCount() const { return rowCount( QModelIndex() ) + m_tracksToAdd.count(); }
|
||||||
|
|
||||||
QVariant data( const QModelIndex& index, int role ) const;
|
|
||||||
QVariant headerData( int section, Qt::Orientation orientation, int role ) const;
|
|
||||||
|
|
||||||
void addCollections( const QList< Tomahawk::collection_ptr >& collections );
|
void addCollections( const QList< Tomahawk::collection_ptr >& collections );
|
||||||
|
|
||||||
void addCollection( const Tomahawk::collection_ptr& collection, bool sendNotifications = true );
|
void addCollection( const Tomahawk::collection_ptr& collection, bool sendNotifications = true );
|
||||||
|
@@ -86,6 +86,7 @@ PlaylistManager::PlaylistManager( QObject* parent )
|
|||||||
m_superCollectionView->setModel( m_superCollectionFlatModel );
|
m_superCollectionView->setModel( m_superCollectionFlatModel );
|
||||||
m_superCollectionView->setFrameShape( QFrame::NoFrame );
|
m_superCollectionView->setFrameShape( QFrame::NoFrame );
|
||||||
m_superCollectionView->setAttribute( Qt::WA_MacShowFocusRect, 0 );
|
m_superCollectionView->setAttribute( Qt::WA_MacShowFocusRect, 0 );
|
||||||
|
m_superCollectionView->proxyModel()->setShowOfflineResults( false );
|
||||||
|
|
||||||
m_superAlbumView = new AlbumView();
|
m_superAlbumView = new AlbumView();
|
||||||
m_superAlbumModel = new AlbumModel( m_superAlbumView );
|
m_superAlbumModel = new AlbumModel( m_superAlbumView );
|
||||||
|
@@ -72,6 +72,7 @@ signals:
|
|||||||
|
|
||||||
void loadingStarted();
|
void loadingStarted();
|
||||||
void loadingFinished();
|
void loadingFinished();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void setCurrentItem( const QModelIndex& index );
|
virtual void setCurrentItem( const QModelIndex& index );
|
||||||
|
|
||||||
|
@@ -14,6 +14,7 @@ TrackProxyModel::TrackProxyModel( QObject* parent )
|
|||||||
, m_model( 0 )
|
, m_model( 0 )
|
||||||
, m_repeatMode( PlaylistInterface::NoRepeat )
|
, m_repeatMode( PlaylistInterface::NoRepeat )
|
||||||
, m_shuffled( false )
|
, m_shuffled( false )
|
||||||
|
, m_showOfflineResults( true )
|
||||||
{
|
{
|
||||||
qsrand( QTime( 0, 0, 0 ).secsTo( QTime::currentTime() ) );
|
qsrand( QTime( 0, 0, 0 ).secsTo( QTime::currentTime() ) );
|
||||||
|
|
||||||
@@ -146,8 +147,8 @@ TrackProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParen
|
|||||||
if ( q->numResults() )
|
if ( q->numResults() )
|
||||||
r = q->results().first();
|
r = q->results().first();
|
||||||
|
|
||||||
// if ( !r.isNull() && !r->collection()->source()->isOnline() )
|
if ( !m_showOfflineResults && !r.isNull() && !r->collection()->source()->isOnline() )
|
||||||
// return false;
|
return false;
|
||||||
|
|
||||||
if ( filterRegExp().isEmpty() )
|
if ( filterRegExp().isEmpty() )
|
||||||
return true;
|
return true;
|
||||||
|
@@ -38,6 +38,9 @@ public:
|
|||||||
virtual PlaylistInterface::RepeatMode repeatMode() const { return m_repeatMode; }
|
virtual PlaylistInterface::RepeatMode repeatMode() const { return m_repeatMode; }
|
||||||
virtual bool shuffled() const { return m_shuffled; }
|
virtual bool shuffled() const { return m_shuffled; }
|
||||||
|
|
||||||
|
bool showOfflineResults() const { return m_showOfflineResults; }
|
||||||
|
void setShowOfflineResults( bool b ) { m_showOfflineResults = b; }
|
||||||
|
|
||||||
PlItem* itemFromIndex( const QModelIndex& index ) const { return sourceModel()->itemFromIndex( index ); }
|
PlItem* itemFromIndex( const QModelIndex& index ) const { return sourceModel()->itemFromIndex( index ); }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@@ -60,6 +63,7 @@ private:
|
|||||||
TrackModel* m_model;
|
TrackModel* m_model;
|
||||||
RepeatMode m_repeatMode;
|
RepeatMode m_repeatMode;
|
||||||
bool m_shuffled;
|
bool m_shuffled;
|
||||||
|
bool m_showOfflineResults;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TRACKPROXYMODEL_H
|
#endif // TRACKPROXYMODEL_H
|
||||||
|
Reference in New Issue
Block a user