From 97cbedc748ba2aeb89110a6d3c1c5ba554bf4efc Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Wed, 24 Sep 2014 05:57:53 +0200 Subject: [PATCH] * PlayableModel::currentIndexChanged signal now has two parameters: newIndex and oldIndex. --- src/libtomahawk/playlist/PlayableModel.cpp | 6 ++++-- src/libtomahawk/playlist/PlayableModel.h | 4 ++-- src/libtomahawk/playlist/PlayableProxyModel.cpp | 11 +++++++++-- src/libtomahawk/playlist/PlayableProxyModel.h | 3 ++- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/libtomahawk/playlist/PlayableModel.cpp b/src/libtomahawk/playlist/PlayableModel.cpp index 9e2e4a91c..9c06a898e 100644 --- a/src/libtomahawk/playlist/PlayableModel.cpp +++ b/src/libtomahawk/playlist/PlayableModel.cpp @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2011, Christian Muehlhaeuser + * Copyright 2010-2014, Christian Muehlhaeuser * Copyright 2011 Leo Franchi * Copyright 2010-2011, Jeff Mitchell * @@ -411,6 +411,8 @@ void PlayableModel::setCurrentIndex( const QModelIndex& index ) { Q_D( PlayableModel ); + + const QModelIndex oldIndex = d->currentIndex; PlayableItem* oldEntry = itemFromIndex( d->currentIndex ); if ( oldEntry ) { @@ -430,7 +432,7 @@ PlayableModel::setCurrentIndex( const QModelIndex& index ) d->currentUuid = QString(); } - emit currentIndexChanged(); + emit currentIndexChanged( d->currentIndex, oldIndex ); } diff --git a/src/libtomahawk/playlist/PlayableModel.h b/src/libtomahawk/playlist/PlayableModel.h index 8e642f02a..43a3550ef 100644 --- a/src/libtomahawk/playlist/PlayableModel.h +++ b/src/libtomahawk/playlist/PlayableModel.h @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2012, Christian Muehlhaeuser + * Copyright 2010-2014, Christian Muehlhaeuser * Copyright 2011 Leo Franchi * Copyright 2010-2011, Jeff Mitchell * Copyright 2013, Uwe L. Korn @@ -145,7 +145,7 @@ signals: void indexPlayable( const QModelIndex& index ); void changed(); - void currentIndexChanged(); + void currentIndexChanged( const QModelIndex& newIndex, const QModelIndex& oldIndex ); void expandRequest( const QPersistentModelIndex& index ); void selectRequest( const QPersistentModelIndex& index ); diff --git a/src/libtomahawk/playlist/PlayableProxyModel.cpp b/src/libtomahawk/playlist/PlayableProxyModel.cpp index 453875577..a7a4364ac 100644 --- a/src/libtomahawk/playlist/PlayableProxyModel.cpp +++ b/src/libtomahawk/playlist/PlayableProxyModel.cpp @@ -120,7 +120,7 @@ PlayableProxyModel::setSourcePlayableModel( PlayableModel* sourceModel ) disconnect( m_model, SIGNAL( itemCountChanged( unsigned int ) ), this, SIGNAL( itemCountChanged( unsigned int ) ) ); disconnect( m_model, SIGNAL( indexPlayable( QModelIndex ) ), this, SLOT( onIndexPlayable( QModelIndex ) ) ); disconnect( m_model, SIGNAL( indexResolved( QModelIndex ) ), this, SLOT( onIndexResolved( QModelIndex ) ) ); - disconnect( m_model, SIGNAL( currentIndexChanged() ), this, SIGNAL( currentIndexChanged() ) ); + disconnect( m_model, SIGNAL( currentIndexChanged( QModelIndex, QModelIndex ) ), this, SLOT( onCurrentIndexChanged( QModelIndex, QModelIndex ) ) ); disconnect( m_model, SIGNAL( expandRequest( QPersistentModelIndex ) ), this, SLOT( expandRequested( QPersistentModelIndex ) ) ); disconnect( m_model, SIGNAL( selectRequest( QPersistentModelIndex ) ), this, SLOT( selectRequested( QPersistentModelIndex ) ) ); } @@ -133,7 +133,7 @@ PlayableProxyModel::setSourcePlayableModel( PlayableModel* sourceModel ) connect( m_model, SIGNAL( itemCountChanged( unsigned int ) ), SIGNAL( itemCountChanged( unsigned int ) ) ); connect( m_model, SIGNAL( indexPlayable( QModelIndex ) ), SLOT( onIndexPlayable( QModelIndex ) ) ); connect( m_model, SIGNAL( indexResolved( QModelIndex ) ), SLOT( onIndexResolved( QModelIndex ) ) ); - connect( m_model, SIGNAL( currentIndexChanged() ), SIGNAL( currentIndexChanged() ) ); + connect( m_model, SIGNAL( currentIndexChanged( QModelIndex, QModelIndex ) ), SLOT( onCurrentIndexChanged( QModelIndex, QModelIndex ) ) ); connect( m_model, SIGNAL( expandRequest( QPersistentModelIndex ) ), SLOT( expandRequested( QPersistentModelIndex ) ) ); connect( m_model, SIGNAL( selectRequest( QPersistentModelIndex ) ), SLOT( selectRequested( QPersistentModelIndex ) ) ); } @@ -689,3 +689,10 @@ PlayableProxyModel::selectRequested( const QPersistentModelIndex& idx ) { emit selectRequest( QPersistentModelIndex( mapFromSource( idx ) ) ); } + + +void +PlayableProxyModel::onCurrentIndexChanged( const QModelIndex& newIndex, const QModelIndex& oldIndex ) +{ + emit currentIndexChanged( mapFromSource( newIndex ), mapFromSource( oldIndex ) ); +} diff --git a/src/libtomahawk/playlist/PlayableProxyModel.h b/src/libtomahawk/playlist/PlayableProxyModel.h index 43154271b..fb38073b5 100644 --- a/src/libtomahawk/playlist/PlayableProxyModel.h +++ b/src/libtomahawk/playlist/PlayableProxyModel.h @@ -95,7 +95,7 @@ signals: void indexPlayable( const QModelIndex& index ); void indexResolved( const QModelIndex& index ); - void currentIndexChanged(); + void currentIndexChanged( const QModelIndex& newIndex, const QModelIndex& oldIndex ); void itemCountChanged( unsigned int items ); @@ -114,6 +114,7 @@ private slots: void expandRequested( const QPersistentModelIndex& index ); void selectRequested( const QPersistentModelIndex& index ); + void onCurrentIndexChanged( const QModelIndex& newIndex, const QModelIndex& oldIndex ); private: virtual bool lessThan( int column, const Tomahawk::query_ptr& left, const Tomahawk::query_ptr& right ) const;