1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-24 14:42:53 +02:00

* Fixed selecting correct sidebar item after destroying temporary page.

This commit is contained in:
Christian Muehlhaeuser
2014-09-08 15:40:57 +02:00
parent 675a288a69
commit 336bccaf40
3 changed files with 16 additions and 13 deletions

View File

@@ -568,7 +568,7 @@ ViewManager::setPage( ViewPage* page, bool trackHistory )
emit historyBackAvailable( m_pageHistoryBack.count() );
emit historyForwardAvailable( m_pageHistoryFwd.count() );
qDebug() << "View page shown:" << page->title();
tDebug() << "View page shown:" << page->title();
emit viewPageActivated( page );
if ( page->isTemporaryPage() )
@@ -581,25 +581,25 @@ ViewManager::setPage( ViewPage* page, bool trackHistory )
if ( QObject* obj = dynamic_cast< QObject* >( currentPage() ) )
{
// if the signal exists (just to hide the qobject runtime warning...)
if( obj->metaObject()->indexOfSignal( "descriptionChanged(QString)" ) > -1 )
if ( obj->metaObject()->indexOfSignal( "descriptionChanged(QString)" ) > -1 )
connect( obj, SIGNAL( descriptionChanged( QString ) ), m_infobar, SLOT( setDescription( QString ) ), Qt::UniqueConnection );
if( obj->metaObject()->indexOfSignal( "descriptionChanged(Tomahawk::artist_ptr)" ) > -1 )
if ( obj->metaObject()->indexOfSignal( "descriptionChanged(Tomahawk::artist_ptr)" ) > -1 )
connect( obj, SIGNAL( descriptionChanged( Tomahawk::artist_ptr ) ), m_infobar, SLOT( setDescription( Tomahawk::artist_ptr ) ), Qt::UniqueConnection );
if( obj->metaObject()->indexOfSignal( "descriptionChanged(Tomahawk::album_ptr)" ) > -1 )
if ( obj->metaObject()->indexOfSignal( "descriptionChanged(Tomahawk::album_ptr)" ) > -1 )
connect( obj, SIGNAL( descriptionChanged( Tomahawk::album_ptr ) ), m_infobar, SLOT( setDescription( Tomahawk::album_ptr ) ), Qt::UniqueConnection );
if( obj->metaObject()->indexOfSignal( "longDescriptionChanged(QString)" ) > -1 )
if ( obj->metaObject()->indexOfSignal( "longDescriptionChanged(QString)" ) > -1 )
connect( obj, SIGNAL( longDescriptionChanged( QString ) ), m_infobar, SLOT( setLongDescription( QString ) ), Qt::UniqueConnection );
if( obj->metaObject()->indexOfSignal( "nameChanged(QString)" ) > -1 )
if ( obj->metaObject()->indexOfSignal( "nameChanged(QString)" ) > -1 )
connect( obj, SIGNAL( nameChanged( QString ) ), m_infobar, SLOT( setCaption( QString ) ), Qt::UniqueConnection );
if( obj->metaObject()->indexOfSignal( "pixmapChanged(QPixmap)" ) > -1 )
if ( obj->metaObject()->indexOfSignal( "pixmapChanged(QPixmap)" ) > -1 )
connect( obj, SIGNAL( pixmapChanged( QPixmap ) ), m_infobar, SLOT( setPixmap( QPixmap ) ), Qt::UniqueConnection );
if( obj->metaObject()->indexOfSignal( "destroyed(QWidget*)" ) > -1 )
if ( obj->metaObject()->indexOfSignal( "destroyed(QWidget*)" ) > -1 )
connect( obj, SIGNAL( destroyed( QWidget* ) ), SLOT( onWidgetDestroyed( QWidget* ) ), Qt::UniqueConnection );
}

View File

@@ -436,12 +436,13 @@ SourcesModel::viewPageActivated( Tomahawk::ViewPage* page )
{
Q_ASSERT( m_sourceTreeLinks[ page ] );
tDebug() << "Got view page activated for item:" << m_sourceTreeLinks[ page ]->text();
QModelIndex idx = indexFromItem( m_sourceTreeLinks[ page ] );
QPersistentModelIndex idx = indexFromItem( m_sourceTreeLinks[ page ] );
tDebug() << "Got view page activated for index:" << idx;
if ( !idx.isValid() )
m_sourceTreeLinks.remove( page );
else
emit selectRequest( QPersistentModelIndex( idx ) );
emit selectRequest( idx );
}
else
{
@@ -683,7 +684,7 @@ void
SourcesModel::onWidgetDestroyed( QWidget* w )
{
int ret = m_sourceTreeLinks.remove( dynamic_cast< Tomahawk::ViewPage* > ( w ) );
qDebug() << "REMOVED STALE SOURCE PAGE?" << ret;
tDebug() << "Removed stale source page:" << ret;
}

View File

@@ -274,9 +274,13 @@ SourceTreeItem::removeFromList()
void
SourceTreeItem::pageDestroyed()
{
//FIXME: this seems to be triggered twice for temporary pages
model()->removeSourceItemLink( this );
int idx = parent()->children().indexOf( this );
if ( idx < 0 )
return;
parent()->beginRowsRemoved( idx, idx );
parent()->removeChild( this );
parent()->endRowsRemoved();
@@ -284,5 +288,3 @@ SourceTreeItem::pageDestroyed()
emit removed();
deleteLater();
}