Summary: | JJ: Saved playlist default name could be smarter | ||
---|---|---|---|
Product: | [Applications] amarok | Reporter: | Jisakiel <jisakiel> |
Component: | Playlists/Saved Playlists | Assignee: | Amarok Developers <amarok-bugs-dist> |
Status: | RESOLVED FIXED | ||
Severity: | wishlist | CC: | bart.cerneels, karaluh |
Priority: | NOR | Keywords: | junior-jobs |
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Debian testing | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | 2.4 | |
Sentry Crash Report: | |||
Attachments: |
Patch for implementing this wishlist item
A more robust version of the previous patch |
Description
Jisakiel
2009-02-24 00:24:29 UTC
At the moment we use the date and time. That ensures uniqueness of the name and could help the user remember why that playlist was saved. I'll mark this as a junior job. *** Bug 256054 has been marked as a duplicate of this bug. *** How about "save as" option? Created attachment 53711 [details] Patch for implementing this wishlist item Here is a patch that attempts to implement this wishlist item. It is also posted on the reviewboard : http://git.reviewboard.kde.org/r/100168 Created attachment 53713 [details]
A more robust version of the previous patch
commit 1ceee4c6ff6fa3a184ca2ed442bea31ef4f14466 branch master Author: Bart Cerneels <bart.cerneels@kde.org> Date: Mon Nov 29 18:43:44 2010 +0100 Give saved playlists a sensible default name. Patch by Dennis Francis. BUG:185397 diff --git a/src/playlist/PlaylistDock.cpp b/src/playlist/PlaylistDock.cpp index 6170f78..91d4b74 100644 --- a/src/playlist/PlaylistDock.cpp +++ b/src/playlist/PlaylistDock.cpp @@ -257,7 +257,8 @@ Playlist::Dock::slotSaveCurrentPlaylist() QWeakPointer<Playlists::UserPlaylistProvider> pointer = action->data().value< QWeakPointer<Playlists::UserPlaylistProvider> >(); Playlists::UserPlaylistProvider* provider = pointer.data(); - The::playlistManager()->save( The::playlist()->tracks(), QString(), provider ); + The::playlistManager()->save( The::playlist()->tracks(), + Playlist::ModelStack::instance()->bottom()->generatePlaylistName(), provider ); } void diff --git a/src/playlist/PlaylistModel.cpp b/src/playlist/PlaylistModel.cpp index 0162321..94e97ae 100644 --- a/src/playlist/PlaylistModel.cpp +++ b/src/playlist/PlaylistModel.cpp @@ -4,6 +4,7 @@ * Copyright (c) 2008 Seb Ruiz <ruiz@kde.org> * * Copyright (c) 2008 Soren Harward <stharward@gmail.com> * * Copyright (c) 2010 Nanno Langstraat <langstr@gmail.com> * + * Copyright (c) 2010 Dennis Francis <dennisfrancis.in@gmail.com> * * * * This program is free software; you can redistribute it and/or modify it under * * the terms of the GNU General Public License as published by the Free Software * @@ -817,6 +818,74 @@ Playlist::Model::tracks() const } QString +Playlist::Model::generatePlaylistName() const +{ + QString datePart = KGlobal::locale()->formatDateTime( QDateTime::currentDateTime(), + KLocale::ShortDate, true ); + Meta::TrackList trackList = tracks(); + + if( trackList.count() == 0 ) + { + return i18nc( "A saved playlist with the current time (KLocale::Shortdate) added between \ + the parentheses", + "Empty Playlist (%1)").arg( datePart ); + } + + bool singleArtist = true; + bool singleAlbum = true; + + Meta::ArtistPtr artist = trackList.first()->artist(); + Meta::AlbumPtr album = trackList.first()->album(); + + QString artistPart; + QString albumPart; + + foreach( const Meta::TrackPtr track, trackList ) + { + if( artist != track->artist() ) + singleArtist = false; + + if( album != track->album() ) + singleAlbum = false; + + if ( !singleArtist && !singleAlbum ) + break; + } + + if( ( !singleArtist && !singleAlbum ) || + ( !artist && !album ) ) + return i18nc( "A saved playlist with the current time (KLocale::Shortdate) added between \ + the parentheses", + "Various Tracks (%1)" ).arg( datePart ); + + if( singleArtist ) + { + if( artist ) + artistPart = artist->prettyName(); + else + artistPart = i18n( "Unknown Artist(s)" ); + } + else if( album && album->hasAlbumArtist() && singleAlbum ) + artistPart = album->albumArtist()->prettyName(); + else + artistPart = i18n( "Various Artists" ); + + if( singleAlbum ) + { + if( album ) + albumPart = album->prettyName(); + else + albumPart = i18n( "Unknown Album(s)" ); + } + else + albumPart = i18n( "Various Albums" ); + + return i18nc( "A saved playlist titled <artist> - <album>", "%1 - %2") + .arg( artistPart, albumPart ); + +} + +QString Playlist::Model::prettyColumnName( Column index ) //static { switch ( index ) diff --git a/src/playlist/PlaylistModel.h b/src/playlist/PlaylistModel.h index 7b7633f..e99abbc 100644 --- a/src/playlist/PlaylistModel.h +++ b/src/playlist/PlaylistModel.h @@ -94,6 +94,7 @@ class AMAROK_EXPORT Model : public QAbstractListModel, public Meta::Observer, pu Meta::TrackPtr trackAt( int row ) const; Meta::TrackPtr trackForId( const quint64 id ) const; virtual Meta::TrackList tracks() const; + virtual QString generatePlaylistName() const; // Inherited from Meta::Observer using Observer::metadataChanged; |