diff --git a/src/libtomahawk/filemetadata/MetadataEditor.cpp b/src/libtomahawk/filemetadata/MetadataEditor.cpp index 75a32de51..b5be4a8bc 100644 --- a/src/libtomahawk/filemetadata/MetadataEditor.cpp +++ b/src/libtomahawk/filemetadata/MetadataEditor.cpp @@ -73,8 +73,8 @@ MetadataEditor::init( const Tomahawk::playlistinterface_ptr& interface ) NewClosure( ui->buttonBox, SIGNAL( accepted() ), this, SLOT( writeMetadata( bool ) ), true )->setAutoDelete( false ); connect( ui->buttonBox, SIGNAL( rejected() ), SLOT( close() ) ); - connect( ui->forwardPushButton, SIGNAL( clicked() ), SLOT( loadNextResult() ) ); - connect( ui->previousPushButton, SIGNAL( clicked() ), SLOT( loadPreviousResult() ) ); + connect( ui->forwardPushButton, SIGNAL( clicked() ), SLOT( loadNextQuery() ) ); + connect( ui->previousPushButton, SIGNAL( clicked() ), SLOT( loadPreviousQuery() ) ); } @@ -216,7 +216,7 @@ MetadataEditor::loadResult( const Tomahawk::result_ptr& result ) return; m_result = result; - setEditable( result->collection()->source()->isLocal() ); + setEditable( result->collection() && result->collection()->source()->isLocal() ); setTitle( result->track() ); setArtist( result->artist()->name() ); @@ -226,7 +226,7 @@ MetadataEditor::loadResult( const Tomahawk::result_ptr& result ) setYear( result->year() ); setBitrate( result->bitrate() ); - if ( result->collection()->source()->isLocal() ) + if ( result->collection() && result->collection()->source()->isLocal() ) { QFileInfo fi( QUrl( m_result->url() ).toLocalFile() ); setFileName( fi.absoluteFilePath() ); @@ -248,12 +248,12 @@ MetadataEditor::loadResult( const Tomahawk::result_ptr& result ) void MetadataEditor::enablePushButtons() { - if ( m_interface->queryAt( m_index + 1 ) ) + if ( m_interface->siblingIndex( 1, m_index ) > 0 ) ui->forwardPushButton->setEnabled( true ); else ui->forwardPushButton->setEnabled( false ); - if ( m_interface->queryAt( m_index - 1 ) ) + if ( m_interface->siblingIndex( -1, m_index ) > 0 ) ui->previousPushButton->setEnabled( true ); else ui->previousPushButton->setEnabled( false ); @@ -261,26 +261,28 @@ MetadataEditor::enablePushButtons() void -MetadataEditor::loadNextResult() +MetadataEditor::loadNextQuery() { writeMetadata(); - m_index++; - - if ( m_interface->queryAt( m_index ) ) + if ( m_interface->siblingIndex( 1, m_index ) > 0 ) + { + m_index = m_interface->siblingIndex( 1, m_index ); loadQuery( m_interface->queryAt( m_index ) ); + } } void -MetadataEditor::loadPreviousResult() +MetadataEditor::loadPreviousQuery() { writeMetadata(); - m_index--; - - if ( m_interface->queryAt( m_index ) ) + if ( m_interface->siblingIndex( -1, m_index ) > 0 ) + { + m_index = m_interface->siblingIndex( -1, m_index ); loadQuery( m_interface->queryAt( m_index ) ); + } } diff --git a/src/libtomahawk/filemetadata/MetadataEditor.h b/src/libtomahawk/filemetadata/MetadataEditor.h index 5a10942ec..aa3948cec 100644 --- a/src/libtomahawk/filemetadata/MetadataEditor.h +++ b/src/libtomahawk/filemetadata/MetadataEditor.h @@ -56,8 +56,8 @@ protected: private slots: void writeMetadata( bool closeDlg = false ); void enablePushButtons(); - void loadNextResult(); - void loadPreviousResult(); + void loadNextQuery(); + void loadPreviousQuery(); /* tag attributes */ void setTitle( const QString& title ); @@ -85,7 +85,7 @@ private: Tomahawk::playlistinterface_ptr m_interface; QStringList m_editFiles; - int m_index; + qint64 m_index; bool m_editable; };