1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-21 00:09:47 +01:00

* PlayableModel::currentIndexChanged signal now has two parameters: newIndex and oldIndex.

This commit is contained in:
Christian Muehlhaeuser 2014-09-24 05:57:53 +02:00
parent 78907f06eb
commit 97cbedc748
4 changed files with 17 additions and 7 deletions

View File

@ -1,6 +1,6 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2010-2014, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2011 Leo Franchi <lfranchi@kde.org>
* Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.org>
*
@ -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 );
}

View File

@ -1,6 +1,6 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2012, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2010-2014, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2011 Leo Franchi <lfranchi@kde.org>
* Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.org>
* Copyright 2013, Uwe L. Korn <uwelk@xhochy.com>
@ -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 );

View File

@ -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 ) );
}

View File

@ -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;