1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-07-31 19:30:21 +02:00

* Disable / enable alternate row colors when required.

This commit is contained in:
Christian Muehlhaeuser
2013-05-30 04:22:06 +02:00
parent ba44bf1030
commit 67e30668dd
2 changed files with 21 additions and 1 deletions

View File

@@ -64,7 +64,6 @@ TrackView::TrackView( QWidget* parent )
setContentsMargins( 0, 0, 0, 0 );
setMouseTracking( true );
setAlternatingRowColors( true );
setSelectionMode( QAbstractItemView::ExtendedSelection );
setSelectionBehavior( QAbstractItemView::SelectRows );
setDragEnabled( true );
@@ -147,6 +146,8 @@ TrackView::setProxyModel( PlayableProxyModel* model )
{
if ( m_proxyModel )
{
disconnect( m_proxyModel, SIGNAL( rowsAboutToBeInserted( QModelIndex, int, int ) ), this, SLOT( onModelFilling() ) );
disconnect( m_proxyModel, SIGNAL( rowsRemoved( QModelIndex, int, int ) ), this, SLOT( onModelEmptyCheck() ) );
disconnect( m_proxyModel, SIGNAL( filterChanged( QString ) ), this, SLOT( onFilterChanged( QString ) ) );
disconnect( m_proxyModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), this, SLOT( onViewChanged() ) );
disconnect( m_proxyModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), this, SLOT( verifySize() ) );
@@ -155,6 +156,8 @@ TrackView::setProxyModel( PlayableProxyModel* model )
m_proxyModel = model;
connect( m_proxyModel, SIGNAL( rowsAboutToBeInserted( QModelIndex, int, int ) ), SLOT( onModelFilling() ) );
connect( m_proxyModel, SIGNAL( rowsRemoved( QModelIndex, int, int ) ), SLOT( onModelEmptyCheck() ) );
connect( m_proxyModel, SIGNAL( filterChanged( QString ) ), SLOT( onFilterChanged( QString ) ) );
connect( m_proxyModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( onViewChanged() ) );
connect( m_proxyModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( verifySize() ) );
@@ -227,6 +230,21 @@ TrackView::setEmptyTip( const QString& tip )
}
void
TrackView::onModelFilling()
{
setAlternatingRowColors( true );
}
void
TrackView::onModelEmptyCheck()
{
if ( !m_proxyModel->rowCount( QModelIndex() ) )
setAlternatingRowColors( false );
}
void
TrackView::onViewChanged()
{

View File

@@ -121,6 +121,8 @@ protected slots:
private slots:
void onItemResized( const QModelIndex& index );
void onFilterChanged( const QString& filter );
void onModelFilling();
void onModelEmptyCheck();
void onCustomContextMenu( const QPoint& pos );