This patch adjust the 'Confirm Delete' dialogue so that, if possible it shows the track and artist name rather than the raw file path. I'm a little dissatisfied with how the two names aren't in tidy columns. Would a complete overhaul to tidy this up be justified or plain overkill?
Oh, and I hope that no one minds me adding me adding my copy right to the file, I'm not certain how much of a change is needed to justify this.
diff --git a/src/core-impl/collections/support/CollectionLocationDelegateImpl.cpp b/src/core-impl/collections/support/CollectionLocationDelegateImpl.cpp index 349464c..a3ec56f 100644 --- a/src/core-impl/collections/support/CollectionLocationDelegateImpl.cpp +++ b/src/core-impl/collections/support/CollectionLocationDelegateImpl.cpp @@ -1,4 +1,5 @@ /**************************************************************************************** + * Copyright (c) 2011 Ryan McCoskrie <ryan.mccosk...@gmail.com> * * Copyright (c) 2010 Maximilian Kossick <maximilian.koss...@googlemail.com> * * Copyright (c) 2010 Casey Link <unnamedramb...@gmail.com> * * * @@ -32,8 +33,23 @@ CollectionLocationDelegateImpl::reallyDelete( CollectionLocation *loc, const Met Q_UNUSED( loc ); QStringList files; - foreach( Meta::TrackPtr track, tracks ) - files << track->prettyUrl(); + foreach( Meta::TrackPtr track, tracks ){ + //Check what metadata is available before formating the string + QString str; + Meta::ArtistPtr artist = track->artist(); + if( ! track->prettyName().isEmpty()){ //Found track name + str = track->prettyName(); + if( ! artist->prettyName().isEmpty() ) //... and artist name + str += ( i18n(" by ") + artist->prettyName() ); + } + else{ //Did not find track name + str = track->prettyUrl(); + if( ! artist->prettyName().isEmpty()) //but did find artist name + str += QString(" (%1)").arg(artist->prettyName()); + } + + files << str; + } // NOTE: taken from SqlCollection // TODO put the delete confirmation code somewhere else? @@ -54,8 +70,23 @@ CollectionLocationDelegateImpl::reallyTrash( CollectionLocation *loc, const Meta Q_UNUSED( loc ); QStringList files; - foreach( Meta::TrackPtr track, tracks ) - files << track->prettyUrl(); + foreach( Meta::TrackPtr track, tracks ){ + //Check what metadata is available before formating the string + QString str; + Meta::ArtistPtr artist = track->artist(); + if( ! track->prettyName().isEmpty()){ //Found track name + str = track->prettyName(); + if( ! artist->prettyName().isEmpty() ) //... and artist name + str += ( i18n(" by ") + artist->prettyName() ); + } + else{ //Did not find track name + str = track->prettyUrl(); + if( ! artist->prettyName().isEmpty()) //but did find artist name + str += QString(" (%1)").arg(artist->prettyName()); + } + + files << str; + } const QString text( i18ncp( "@info", "Do you really want to move this track to the trash? " @@ -76,8 +107,23 @@ bool CollectionLocationDelegateImpl::reallyMove(CollectionLocation* loc, const M { Q_UNUSED( loc ) QStringList files; - foreach( Meta::TrackPtr track, tracks ) - files << track->prettyUrl(); + foreach( Meta::TrackPtr track, tracks ){ + //Check what metadata is available before formating the string + QString str; + Meta::ArtistPtr artist = track->artist(); + if( ! track->prettyName().isEmpty()){ //Found track name + str = track->prettyName(); + if( ! artist->prettyName().isEmpty() ) //... and artist name + str += ( i18n(" by ") + artist->prettyName() ); + } + else{ //Did not find track name + str = track->prettyUrl(); + if( ! artist->prettyName().isEmpty()) //but did find artist name + str += QString(" (%1)").arg(artist->prettyName()); + } + + files << str; + } const QString text( i18ncp( "@info", "Do you really want to move this track? It will be renamed and the original deleted.", "Do you really want to move these %1 tracks? They will be renamed and the originals deleted.", tracks.count() ) ); @@ -92,8 +138,23 @@ void CollectionLocationDelegateImpl::errorDeleting( CollectionLocation* loc, con { Q_UNUSED( loc ); QStringList files; - foreach( Meta::TrackPtr track, tracks ) - files << track->prettyUrl(); + foreach( Meta::TrackPtr track, tracks ){ + //Check what metadata is available before formating the string + QString str; + Meta::ArtistPtr artist = track->artist(); + if( ! track->prettyName().isEmpty()){ //Found track name + str = track->prettyName(); + if( ! artist->prettyName().isEmpty() ) //... and artist name + str += ( i18n(" by ") + artist->prettyName() ); + } + else{ //Did not find track name + str = track->prettyUrl(); + if( ! artist->prettyName().isEmpty()) //but did find artist name + str += QString(" (%1)").arg(artist->prettyName()); + } + + files << str; + } const QString text( i18ncp( "@info", "There was a problem and this track could not be removed. Make sure the directory is writable.", "There was a problem and %1 tracks could not be removed. Make sure the directory is writable.", files.count() ) );
_______________________________________________ Amarok-devel mailing list Amarok-devel@kde.org https://mail.kde.org/mailman/listinfo/amarok-devel