1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-11 16:44:05 +02:00

Add colum mapping to PlayableProxyModel

This commit is contained in:
Dominik Schmidt
2016-01-18 02:45:05 +01:00
parent eab1ccee74
commit 5d950bd139
4 changed files with 21 additions and 3 deletions

View File

@@ -119,8 +119,9 @@ int
PlayableModel::columnCount( const QModelIndex& parent ) const
{
Q_UNUSED( parent );
Q_D( const PlayableModel );
return 13;
return d->header.length();
}

View File

@@ -614,11 +614,11 @@ PlayableProxyModel::columnCount( const QModelIndex& parent ) const
break;
case Collection:
return 10;
return m_headerStyle[ Collection ].length();
break;
case Locker:
return 11;
return m_headerStyle[ Locker ].length();
break;
case Detailed:
@@ -733,6 +733,13 @@ PlayableProxyModel::setFilter( const QString& pattern )
}
int
PlayableProxyModel::mapSourceColumnToColumn( PlayableModel::Columns column )
{
return m_headerStyle[ m_style ].indexOf( column );
}
void
PlayableProxyModel::setCurrentIndex( const QModelIndex& index )
{

View File

@@ -98,6 +98,8 @@ public:
virtual void setFilter( const QString& pattern );
virtual void updateDetailedInfo( const QModelIndex& index );
int mapSourceColumnToColumn( PlayableModel::Columns column );
signals:
void filterChanged( const QString& filter );

View File

@@ -62,6 +62,8 @@ CollectionViewPage::CollectionViewPage( const Tomahawk::collection_ptr& collecti
m_columnView->proxyModel()->setStyle( PlayableProxyModel::SingleColumn );
PlayableProxyModel* trackViewProxyModel = m_trackView->proxyModel();
if ( collection->backendType() == Collection::ScriptCollectionType )
{
m_trackView->proxyModel()->setStyle( PlayableProxyModel::Locker );
@@ -70,6 +72,12 @@ CollectionViewPage::CollectionViewPage( const Tomahawk::collection_ptr& collecti
{
m_trackView->proxyModel()->setStyle( PlayableProxyModel::Collection );
}
// mapSourceColumnToColumn depends on the just set PlayableProxyModel::PlayableItemStyle
m_trackView->setColumnHidden( trackViewProxyModel->mapSourceColumnToColumn( PlayableModel::Composer ), true );
m_trackView->setColumnHidden( trackViewProxyModel->mapSourceColumnToColumn( PlayableModel::Origin ), true );
m_trackView->setColumnHidden( trackViewProxyModel->mapSourceColumnToColumn( PlayableModel::Score ), true );
m_trackView->setColumnHidden( trackViewProxyModel->mapSourceColumnToColumn( PlayableModel::Bitrate ), true );
m_trackView->setGuid( QString( "trackview/flat" ) );