mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-02-24 20:03:07 +01:00
Show treeview in artistinfowidget with only one column
This commit is contained in:
parent
99a298edb5
commit
9313de5b17
@ -37,6 +37,7 @@ using namespace Tomahawk;
|
||||
TreeModel::TreeModel( QObject* parent )
|
||||
: QAbstractItemModel( parent )
|
||||
, m_rootItem( new TreeModelItem( 0, this ) )
|
||||
, m_columnStyle( AllColumns )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
@ -163,7 +164,13 @@ int
|
||||
TreeModel::columnCount( const QModelIndex& parent ) const
|
||||
{
|
||||
Q_UNUSED( parent );
|
||||
return 7;
|
||||
if ( m_columnStyle == AllColumns )
|
||||
return 7;
|
||||
else if ( m_columnStyle == TrackOnly )
|
||||
return 1;
|
||||
|
||||
// UH..
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -666,3 +673,9 @@ TreeModel::onDataChanged()
|
||||
TreeModelItem* p = (TreeModelItem*)sender();
|
||||
emit dataChanged( p->index, p->index.sibling( p->index.row(), columnCount( QModelIndex() ) - 1 ) );
|
||||
}
|
||||
|
||||
void
|
||||
TreeModel::setColumnStyle( TreeModel::ColumnStyle style )
|
||||
{
|
||||
m_columnStyle = style;
|
||||
}
|
||||
|
@ -50,6 +50,9 @@ public:
|
||||
AlbumPosition
|
||||
};
|
||||
|
||||
enum ColumnStyle // Default style is AllColumns
|
||||
{ AllColumns = 0, TrackOnly };
|
||||
|
||||
explicit TreeModel( QObject* parent = 0 );
|
||||
virtual ~TreeModel();
|
||||
|
||||
@ -84,6 +87,8 @@ public:
|
||||
void addAlbums( const Tomahawk::artist_ptr& artist, const QModelIndex& parent );
|
||||
void addTracks( const Tomahawk::album_ptr& album, const QModelIndex& parent );
|
||||
|
||||
void setColumnStyle( ColumnStyle style );
|
||||
|
||||
virtual QString title() const { return m_title; }
|
||||
virtual QString description() const { return m_description; }
|
||||
virtual void setTitle( const QString& title ) { m_title = title; }
|
||||
@ -139,6 +144,7 @@ private:
|
||||
|
||||
QString m_title;
|
||||
QString m_description;
|
||||
ColumnStyle m_columnStyle;
|
||||
|
||||
Tomahawk::collection_ptr m_collection;
|
||||
};
|
||||
|
@ -58,6 +58,7 @@ ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget*
|
||||
ui->albums->setTreeModel( m_albumsModel );
|
||||
|
||||
m_relatedModel = new TreeModel( ui->relatedArtists );
|
||||
m_relatedModel->setColumnStyle( TreeModel::TrackOnly );
|
||||
ui->relatedArtists->setTreeModel( m_relatedModel );
|
||||
ui->relatedArtists->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
||||
ui->relatedArtists->header()->setVisible( false );
|
||||
|
Loading…
x
Reference in New Issue
Block a user