mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-07 14:46:33 +02:00
* Disable / enable alternate row colors when required.
This commit is contained in:
@@ -64,7 +64,6 @@ TrackView::TrackView( QWidget* parent )
|
|||||||
|
|
||||||
setContentsMargins( 0, 0, 0, 0 );
|
setContentsMargins( 0, 0, 0, 0 );
|
||||||
setMouseTracking( true );
|
setMouseTracking( true );
|
||||||
setAlternatingRowColors( true );
|
|
||||||
setSelectionMode( QAbstractItemView::ExtendedSelection );
|
setSelectionMode( QAbstractItemView::ExtendedSelection );
|
||||||
setSelectionBehavior( QAbstractItemView::SelectRows );
|
setSelectionBehavior( QAbstractItemView::SelectRows );
|
||||||
setDragEnabled( true );
|
setDragEnabled( true );
|
||||||
@@ -147,6 +146,8 @@ TrackView::setProxyModel( PlayableProxyModel* model )
|
|||||||
{
|
{
|
||||||
if ( m_proxyModel )
|
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( 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( onViewChanged() ) );
|
||||||
disconnect( m_proxyModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), this, SLOT( verifySize() ) );
|
disconnect( m_proxyModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), this, SLOT( verifySize() ) );
|
||||||
@@ -155,6 +156,8 @@ TrackView::setProxyModel( PlayableProxyModel* model )
|
|||||||
|
|
||||||
m_proxyModel = 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( filterChanged( QString ) ), SLOT( onFilterChanged( QString ) ) );
|
||||||
connect( m_proxyModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( onViewChanged() ) );
|
connect( m_proxyModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( onViewChanged() ) );
|
||||||
connect( m_proxyModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( verifySize() ) );
|
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
|
void
|
||||||
TrackView::onViewChanged()
|
TrackView::onViewChanged()
|
||||||
{
|
{
|
||||||
|
@@ -121,6 +121,8 @@ protected slots:
|
|||||||
private slots:
|
private slots:
|
||||||
void onItemResized( const QModelIndex& index );
|
void onItemResized( const QModelIndex& index );
|
||||||
void onFilterChanged( const QString& filter );
|
void onFilterChanged( const QString& filter );
|
||||||
|
void onModelFilling();
|
||||||
|
void onModelEmptyCheck();
|
||||||
|
|
||||||
void onCustomContextMenu( const QPoint& pos );
|
void onCustomContextMenu( const QPoint& pos );
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user