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