mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-08 23:26:40 +02:00
* PlayableModel can now handle items as tree-structures.
This commit is contained in:
@@ -656,7 +656,7 @@ PlayableModel::queries() const
|
|||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void
|
void
|
||||||
PlayableModel::insertInternal( const QList< T >& items, int row, const QList< Tomahawk::PlaybackLog >& logs )
|
PlayableModel::insertInternal( const QList< T >& items, int row, const QList< Tomahawk::PlaybackLog >& logs, const QModelIndex& parent )
|
||||||
{
|
{
|
||||||
Q_D( PlayableModel );
|
Q_D( PlayableModel );
|
||||||
if ( !items.count() )
|
if ( !items.count() )
|
||||||
@@ -672,14 +672,16 @@ PlayableModel::insertInternal( const QList< T >& items, int row, const QList< To
|
|||||||
crows.first = c;
|
crows.first = c;
|
||||||
crows.second = c + items.count() - 1;
|
crows.second = c + items.count() - 1;
|
||||||
|
|
||||||
emit beginInsertRows( QModelIndex(), crows.first, crows.second );
|
emit beginInsertRows( parent, crows.first, crows.second );
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
PlayableItem* plitem;
|
PlayableItem* plitem;
|
||||||
foreach ( const T& item, items )
|
foreach ( const T& item, items )
|
||||||
{
|
{
|
||||||
plitem = new PlayableItem( item, d->rootItem, row + i );
|
PlayableItem* pItem = itemFromIndex( parent );
|
||||||
|
plitem = new PlayableItem( item, pItem, row + i );
|
||||||
plitem->index = createIndex( row + i, 0, plitem );
|
plitem->index = createIndex( row + i, 0, plitem );
|
||||||
|
|
||||||
if ( plitem->query() )
|
if ( plitem->query() )
|
||||||
{
|
{
|
||||||
if ( !plitem->query()->playable() )
|
if ( !plitem->query()->playable() )
|
||||||
@@ -709,6 +711,7 @@ PlayableModel::insertInternal( const QList< T >& items, int row, const QList< To
|
|||||||
|
|
||||||
emit endInsertRows();
|
emit endInsertRows();
|
||||||
emit itemCountChanged( rowCount( QModelIndex() ) );
|
emit itemCountChanged( rowCount( QModelIndex() ) );
|
||||||
|
|
||||||
finishLoading();
|
finishLoading();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -729,9 +732,9 @@ PlayableModel::removeRows( int row, int count, const QModelIndex& parent )
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PlayableModel::remove( int row, bool moreToCome )
|
PlayableModel::remove( int row, bool moreToCome, const QModelIndex& parent )
|
||||||
{
|
{
|
||||||
removeIndex( index( row, 0, QModelIndex() ), moreToCome );
|
removeIndex( index( row, 0, parent ), moreToCome );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1046,14 +1049,14 @@ PlayableModel::insertAlbum( const Tomahawk::album_ptr& album, int row )
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PlayableModel::insertQuery( const Tomahawk::query_ptr& query, int row, const Tomahawk::PlaybackLog& log )
|
PlayableModel::insertQuery( const Tomahawk::query_ptr& query, int row, const Tomahawk::PlaybackLog& log, const QModelIndex& parent )
|
||||||
{
|
{
|
||||||
QList< query_ptr > queries;
|
QList< query_ptr > queries;
|
||||||
queries << query;
|
queries << query;
|
||||||
QList< Tomahawk::PlaybackLog > logs;
|
QList< Tomahawk::PlaybackLog > logs;
|
||||||
logs << log;
|
logs << log;
|
||||||
|
|
||||||
insertQueries( queries, row, logs );
|
insertQueries( queries, row, logs, parent );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1072,9 +1075,9 @@ PlayableModel::insertAlbums( const QList< Tomahawk::album_ptr >& albums, int row
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PlayableModel::insertQueries( const QList< Tomahawk::query_ptr >& queries, int row, const QList< Tomahawk::PlaybackLog >& logs )
|
PlayableModel::insertQueries( const QList< Tomahawk::query_ptr >& queries, int row, const QList< Tomahawk::PlaybackLog >& logs, const QModelIndex& parent )
|
||||||
{
|
{
|
||||||
insertInternal( queries, row, logs );
|
insertInternal( queries, row, logs, parent );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -161,16 +161,16 @@ public slots:
|
|||||||
virtual void appendAlbum( const Tomahawk::album_ptr& album );
|
virtual void appendAlbum( const Tomahawk::album_ptr& album );
|
||||||
virtual void appendTracks( const Tomahawk::collection_ptr& collection );
|
virtual void appendTracks( const Tomahawk::collection_ptr& collection );
|
||||||
|
|
||||||
virtual void insertQueries( const QList< Tomahawk::query_ptr >& queries, int row = 0, const QList< Tomahawk::PlaybackLog >& logs = QList< Tomahawk::PlaybackLog >() );
|
virtual void insertQueries( const QList< Tomahawk::query_ptr >& queries, int row = 0, const QList< Tomahawk::PlaybackLog >& logs = QList< Tomahawk::PlaybackLog >(), const QModelIndex& parent = QModelIndex() );
|
||||||
virtual void insertArtists( const QList< Tomahawk::artist_ptr >& artists, int row = 0 );
|
virtual void insertArtists( const QList< Tomahawk::artist_ptr >& artists, int row = 0 );
|
||||||
virtual void insertAlbums( const QList< Tomahawk::album_ptr >& albums, int row = 0 );
|
virtual void insertAlbums( const QList< Tomahawk::album_ptr >& albums, int row = 0 );
|
||||||
virtual void insertQuery( const Tomahawk::query_ptr& query, int row = 0, const Tomahawk::PlaybackLog& log = Tomahawk::PlaybackLog() );
|
virtual void insertQuery( const Tomahawk::query_ptr& query, int row = 0, const Tomahawk::PlaybackLog& log = Tomahawk::PlaybackLog(), const QModelIndex& parent = QModelIndex() );
|
||||||
virtual void insertArtist( const Tomahawk::artist_ptr& artist, int row = 0 );
|
virtual void insertArtist( const Tomahawk::artist_ptr& artist, int row = 0 );
|
||||||
virtual void insertAlbum( const Tomahawk::album_ptr& album, int row = 0 );
|
virtual void insertAlbum( const Tomahawk::album_ptr& album, int row = 0 );
|
||||||
virtual void insertTracks( const Tomahawk::collection_ptr& collection, int row = 0 );
|
virtual void insertTracks( const Tomahawk::collection_ptr& collection, int row = 0 );
|
||||||
|
|
||||||
virtual bool removeRows( int row, int count, const QModelIndex& parent = QModelIndex() );
|
virtual bool removeRows( int row, int count, const QModelIndex& parent = QModelIndex() );
|
||||||
virtual void remove( int row, bool moreToCome = false );
|
virtual void remove( int row, bool moreToCome = false, const QModelIndex& parent = QModelIndex() );
|
||||||
virtual void removeIndex( const QModelIndex& index, bool moreToCome = false );
|
virtual void removeIndex( const QModelIndex& index, bool moreToCome = false );
|
||||||
virtual void removeIndexes( const QList<QModelIndex>& indexes );
|
virtual void removeIndexes( const QList<QModelIndex>& indexes );
|
||||||
virtual void removeIndexes( const QList<QPersistentModelIndex>& indexes );
|
virtual void removeIndexes( const QList<QPersistentModelIndex>& indexes );
|
||||||
@@ -199,7 +199,7 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void insertInternal( const QList< T >& items, int row, const QList< Tomahawk::PlaybackLog >& logs = QList< Tomahawk::PlaybackLog >() );
|
void insertInternal( const QList< T >& items, int row, const QList< Tomahawk::PlaybackLog >& logs = QList< Tomahawk::PlaybackLog >(), const QModelIndex& parent = QModelIndex() );
|
||||||
|
|
||||||
QString scoreText( float score ) const;
|
QString scoreText( float score ) const;
|
||||||
Qt::Alignment columnAlignment( int column ) const;
|
Qt::Alignment columnAlignment( int column ) const;
|
||||||
|
Reference in New Issue
Block a user