[Amarok] c7a453b Show title instead of ID when copying/deleting tra
Mark Kretschmann
kretschmann at kde.org
Sun Feb 28 15:12:12 CET 2010
commit c7a453b7a49394c1039ec9e1262993e5340fcfda
Author: Mark Kretschmann <kretschmann at kde.org>
Date: Sun Feb 28 15:09:15 2010 +0100
Show title instead of ID when copying/deleting tracks on MTP.
What I got before with my MTP device was this:
"Do you really want to delete these tracks?
453
73
377
"
Now it shows "ARTIST - TITLE" instead. The problem was that we used
Meta::Track::prettyUrl() there, which is not implemented for MTP devices.
I'm not sure if my solution is the best, someone with more clue of the media
device system please review :)
CCMAIL: amarok-devel at kde.org
CCMAIL: aikawarazuni at gmail.com
diff --git a/ChangeLog b/ChangeLog
index cc6f64f..16a12ad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -28,6 +28,8 @@ VERSION 2.3
last check.
BUGFIXES:
+ * Show artist and title instead of raw track ID when copying/deleting
+ tracks on an MTP device.
* Fixed time labels getting truncated in the slim toolbar. (BR 195935)
* Fixed broken keyboard navigation in the playlist after activating a track.
(BR 225791)
diff --git a/src/collection/CollectionLocationDelegateImpl.cpp b/src/collection/CollectionLocationDelegateImpl.cpp
index 29a4a05..86de9c0 100644
--- a/src/collection/CollectionLocationDelegateImpl.cpp
+++ b/src/collection/CollectionLocationDelegateImpl.cpp
@@ -26,9 +26,10 @@ bool
CollectionLocationDelegateImpl::reallyDelete( CollectionLocation *loc, const Meta::TrackList &tracks ) const
{
Q_UNUSED( loc );
+
QStringList files;
foreach( Meta::TrackPtr track, tracks )
- files << track->prettyUrl();
+ files << realTrackName( track );
// NOTE: taken from SqlCollection
// TODO put the delete confirmation code somewhere else?
@@ -48,7 +49,7 @@ bool CollectionLocationDelegateImpl::reallyMove(CollectionLocation* loc, const M
Q_UNUSED( loc )
QStringList files;
foreach( Meta::TrackPtr track, tracks )
- files << track->prettyUrl();
+ files << realTrackName( track );
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() ) );
@@ -64,7 +65,8 @@ void CollectionLocationDelegateImpl::errorDeleting( CollectionLocation* loc, con
Q_UNUSED( loc );
QStringList files;
foreach( Meta::TrackPtr track, tracks )
- files << track->prettyUrl();
+ files << realTrackName( track );
+
const QString text( i18ncp( "@info", "There was a problem and this track could not be removed. Make sure the directory is writeable.",
"There was a problem and %1 tracks could not be removed. Make sure the directory is writeable.", files.count() ) );
KMessageBox::informationList(0,
@@ -79,3 +81,20 @@ void CollectionLocationDelegateImpl::notWriteable(CollectionLocation* loc) const
The::statusBar()->longMessage( i18n( "The collection does not have enough free space available or is not writeable." ), StatusBar::Error );
}
+
+///////////////////////////////////////////////////
+// PRIVATE
+///////////////////////////////////////////////////
+
+QString CollectionLocationDelegateImpl::realTrackName( const Meta::TrackPtr track ) const
+{
+ QString name;
+
+ if( track->artist() )
+ name = track->artist()->prettyName() + " - " + track->prettyName();
+ else
+ name = track->prettyName();
+
+ return name;
+}
+
diff --git a/src/collection/CollectionLocationDelegateImpl.h b/src/collection/CollectionLocationDelegateImpl.h
index 3808e0d..92420a5 100644
--- a/src/collection/CollectionLocationDelegateImpl.h
+++ b/src/collection/CollectionLocationDelegateImpl.h
@@ -31,6 +31,16 @@ public:
virtual bool reallyMove(CollectionLocation* loc, const Meta::TrackList& tracks) const;
virtual void errorDeleting( CollectionLocation* loc, const Meta::TrackList& tracks ) const;
virtual void notWriteable(CollectionLocation* loc) const;
+
+ private:
+ /**
+ * Builds a string of the format "ARTIST - TITLE",
+ * for media device tracks.
+ * @param track Pointer of the Meta::Track item
+ * @return String with artist and title
+ */
+ virtual QString realTrackName( const Meta::TrackPtr track ) const;
};
+
#endif
More information about the Amarok-devel
mailing list