From dd2ab792f876b47015655cf0dcd0e6dc432bda24 Mon Sep 17 00:00:00 2001 From: nhnielsen Date: Sun, 21 Oct 2007 16:45:37 +0000 Subject: [PATCH] Quick fix/hack to make adding entire albums from mp3tunes work in a slightly saner way ( dont add every single track in locker when trying to add a single album ) git-svn-id: svn+ssh://svn.kde.org/home/kde/trunk/extragear/multimedia/amarok@727742 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- .../mp3tunes/Mp3tunesServiceQueryMaker.cpp | 46 +++++++++++++--------- .../mp3tunes/Mp3tunesServiceQueryMaker.h | 3 +- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/src/servicebrowser/mp3tunes/Mp3tunesServiceQueryMaker.cpp b/src/servicebrowser/mp3tunes/Mp3tunesServiceQueryMaker.cpp index 78eeb9454..1319c6c6d 100644 --- a/src/servicebrowser/mp3tunes/Mp3tunesServiceQueryMaker.cpp +++ b/src/servicebrowser/mp3tunes/Mp3tunesServiceQueryMaker.cpp @@ -64,7 +64,8 @@ QueryMaker * Mp3tunesServiceQueryMaker::reset() d->type = Private::NONE; d->maxsize = -1; d->returnDataPtrs = false; - m_parentId = QString(); + m_parentArtistId = QString(); + m_parentAlbumId = QString(); return this; } @@ -133,23 +134,25 @@ QueryMaker * Mp3tunesServiceQueryMaker::startTrackQuery() QueryMaker * Mp3tunesServiceQueryMaker::addMatch( const ArtistPtr & artist ) { DEBUG_BLOCK - if ( d->type == Private::ALBUM ) { + + if ( m_parentAlbumId.isEmpty() ) { const ServiceArtist * serviceArtist = static_cast< const ServiceArtist * >( artist.data() ); - m_parentId = QString::number( serviceArtist->id() ); - debug() << "parent id set to: " << m_parentId; + m_parentArtistId = QString::number( serviceArtist->id() ); + debug() << "parent id set to: " << m_parentArtistId; } + return this; } QueryMaker * Mp3tunesServiceQueryMaker::addMatch(const Meta::AlbumPtr & album) { DEBUG_BLOCK - if ( d->type == Private::TRACK ) { - const ServiceAlbum * serviceAlbum = static_cast< const ServiceAlbum * >( album.data() ); - m_parentId = QString::number( serviceAlbum->id() ); - debug() << "parent id set to: " << m_parentId; - } + const ServiceAlbum * serviceAlbum = static_cast< const ServiceAlbum * >( album.data() ); + m_parentAlbumId = QString::number( serviceAlbum->id() ); + debug() << "parent id set to: " << m_parentAlbumId; + m_parentArtistId = QString(); + return this; } @@ -242,12 +245,13 @@ void Mp3tunesServiceQueryMaker::fetchAlbums() AlbumList albums; - debug() << "parent id: " << m_parentId; + //debug() << "parent id: " << m_parentId; - if ( !m_parentId.isEmpty() ) { - ArtistMatcher artistMatcher( m_collection->artistMap()[ m_parentId ] ); + if ( !m_parentArtistId.isEmpty() ) { + ArtistMatcher artistMatcher( m_collection->artistMap()[ m_parentArtistId ] ); albums = artistMatcher.matchAlbums( m_collection ); - } + } else + return; if ( albums.count() > 0 ) { handleResult( albums ); @@ -257,7 +261,7 @@ void Mp3tunesServiceQueryMaker::fetchAlbums() urlString.replace( "", m_sessionId ); urlString.replace( "", "7359149936" ); - urlString.replace( "", m_parentId ); + urlString.replace( "", m_parentArtistId ); m_storedTransferJob = KIO::storedGet( KUrl( urlString ), KIO::NoReload, KIO::HideProgressInfo ); connect( m_storedTransferJob, SIGNAL( result( KJob * ) ) @@ -271,12 +275,13 @@ void Mp3tunesServiceQueryMaker::fetchTracks() TrackList tracks; - debug() << "parent id: " << m_parentId; + //debug() << "parent id: " << m_parentId; - if ( !m_parentId.isEmpty() ) { - AlbumMatcher albumMatcher( m_collection->albumMap()[ m_parentId ] ); + if ( !m_parentAlbumId.isEmpty() ) { + AlbumMatcher albumMatcher( m_collection->albumMap()[ m_parentAlbumId ] ); tracks = albumMatcher.match( m_collection ); - } + } else + return; if ( tracks.count() > 0 ) { handleResult( tracks ); @@ -286,7 +291,10 @@ void Mp3tunesServiceQueryMaker::fetchTracks() urlString.replace( "", m_sessionId ); urlString.replace( "", "7359149936" ); - urlString.replace( "", m_parentId ); + if( !m_parentAlbumId.isEmpty() ) + urlString.replace( "", m_parentAlbumId ); + else + urlString.replace( "", m_parentArtistId ); m_storedTransferJob = KIO::storedGet( KUrl( urlString ), KIO::NoReload, KIO::HideProgressInfo ); connect( m_storedTransferJob, SIGNAL( result( KJob * ) ) diff --git a/src/servicebrowser/mp3tunes/Mp3tunesServiceQueryMaker.h b/src/servicebrowser/mp3tunes/Mp3tunesServiceQueryMaker.h index b241b0089..809e1f214 100644 --- a/src/servicebrowser/mp3tunes/Mp3tunesServiceQueryMaker.h +++ b/src/servicebrowser/mp3tunes/Mp3tunesServiceQueryMaker.h @@ -78,7 +78,8 @@ protected: Private * const d; QString m_sessionId; - QString m_parentId; + QString m_parentAlbumId; + QString m_parentArtistId; public slots: -- 2.11.4.GIT