Skip to content

Commit

Permalink
Removed label2 and show value that is sorted by or fall back to durat…
Browse files Browse the repository at this point in the history
…ion.

Add lastPlayed sortorder for music
  • Loading branch information
razzeee committed Oct 13, 2015
1 parent 8cb3f36 commit 1161510
Show file tree
Hide file tree
Showing 16 changed files with 82 additions and 155 deletions.
27 changes: 0 additions & 27 deletions system/settings/settings.xml
Expand Up @@ -1865,13 +1865,6 @@
<heading>16016</heading>
</control>
</setting>
<setting id="musicfiles.trackformatright" type="string" label="13387" help="36276">
<level>2</level>
<default>%D</default>
<control type="edit" format="string">
<heading>16016</heading>
</control>
</setting>
<setting id="musicfiles.nowplayingtrackformat" type="string" label="13307" help="36277">
<level>4</level>
<default></default>
Expand All @@ -1882,16 +1875,6 @@
<heading>16016</heading>
</control>
</setting>
<setting id="musicfiles.nowplayingtrackformatright" type="string" label="13387" help="36278">
<level>4</level>
<default></default>
<constraints>
<allowempty>true</allowempty>
</constraints>
<control type="edit" format="string">
<heading>16016</heading>
</control>
</setting>
<setting id="musicfiles.librarytrackformat" type="string" label="13307" help="36279">
<level>4</level>
<default></default>
Expand All @@ -1902,16 +1885,6 @@
<heading>16016</heading>
</control>
</setting>
<setting id="musicfiles.librarytrackformatright" type="string" label="13387" help="36280">
<level>4</level>
<default></default>
<constraints>
<allowempty>true</allowempty>
</constraints>
<control type="edit" format="string">
<heading>16016</heading>
</control>
</setting>
<setting id="musicfiles.findremotethumbs" type="boolean" label="14059" help="36281">
<level>0</level>
<default>true</default>
Expand Down
6 changes: 2 additions & 4 deletions xbmc/filesystem/PluginDirectory.cpp
Expand Up @@ -345,10 +345,8 @@ void CPluginDirectory::AddSortMethod(int handle, SORT_METHOD sortMethod, const s
}
case SORT_METHOD_PLAYLIST_ORDER:
{
std::string strTrackLeft=CSettings::GetInstance().GetString(CSettings::SETTING_MUSICFILES_TRACKFORMAT);
std::string strTrackRight=CSettings::GetInstance().GetString(CSettings::SETTING_MUSICFILES_TRACKFORMATRIGHT);

dir->m_listItems->AddSortMethod(SortByPlaylistOrder, 559, LABEL_MASKS(strTrackLeft, strTrackRight));
std::string strTrack=CSettings::GetInstance().GetString(CSettings::SETTING_MUSICFILES_TRACKFORMAT);
dir->m_listItems->AddSortMethod(SortByPlaylistOrder, 559, LABEL_MASKS(strTrack, "%D"));
break;
}
case SORT_METHOD_EPISODE:
Expand Down
6 changes: 6 additions & 0 deletions xbmc/music/Album.cpp
Expand Up @@ -109,6 +109,7 @@ CAlbum::CAlbum(const CFileItem& item)
bCompilation = tag.GetCompilation();
iTimesPlayed = 0;
dateAdded.Reset();
lastPlayed.Reset();
releaseType = tag.GetAlbumReleaseType();
}

Expand Down Expand Up @@ -208,6 +209,11 @@ void CAlbum::SetDateAdded(const std::string& strDateAdded)
dateAdded.SetFromDBDateTime(strDateAdded);
}

void CAlbum::SetLastPlayed(const std::string& strLastPlayed)
{
lastPlayed.SetFromDBDateTime(strLastPlayed);
}

std::string CAlbum::ReleaseTypeToString(CAlbum::ReleaseType releaseType)
{
for (size_t i = 0; i < RELEASE_TYPES_SIZE; i++)
Expand Down
5 changes: 4 additions & 1 deletion xbmc/music/Album.h
Expand Up @@ -37,7 +37,7 @@ class CAlbum
{
public:
CAlbum(const CFileItem& item);
CAlbum() { idAlbum = 0; iRating = 0; iYear = 0; iTimesPlayed = 0; dateAdded.Reset(); releaseType = Album; };
CAlbum() { idAlbum = 0; iRating = 0; iYear = 0; iTimesPlayed = 0; dateAdded.Reset(); lastPlayed.Reset(); releaseType = Album; };
bool operator<(const CAlbum &a) const;
void MergeScrapedAlbum(const CAlbum& album, bool override = true);

Expand Down Expand Up @@ -65,6 +65,7 @@ class CAlbum
bCompilation = false;
iTimesPlayed = 0;
dateAdded.Reset();
lastPlayed.Reset();
songs.clear();
infoSongs.clear();
releaseType = Album;
Expand All @@ -89,6 +90,7 @@ class CAlbum
std::string GetReleaseType() const;
void SetReleaseType(const std::string& strReleaseType);
void SetDateAdded(const std::string& strDateAdded);
void SetLastPlayed(const std::string& strLastPlayed);

static std::string ReleaseTypeToString(ReleaseType releaseType);
static ReleaseType ReleaseTypeFromString(const std::string& strReleaseType);
Expand Down Expand Up @@ -125,6 +127,7 @@ class CAlbum
bool bCompilation;
int iTimesPlayed;
CDateTime dateAdded;
CDateTime lastPlayed;
VECSONGS songs; ///< Local songs
VECSONGS infoSongs; ///< Scraped songs
ReleaseType releaseType;
Expand Down
150 changes: 53 additions & 97 deletions xbmc/music/GUIViewStateMusic.cpp

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions xbmc/music/MusicDatabase.cpp
Expand Up @@ -310,7 +310,8 @@ void CMusicDatabase::CreateViews()
" bCompilation, "
" (SELECT MIN(song.iTimesPlayed) FROM song WHERE song.idAlbum = album.idAlbum) AS iTimesPlayed, "
" strReleaseType, "
" (SELECT MAX(song.dateAdded) FROM song WHERE song.idAlbum = album.idAlbum) AS dateAdded "
" (SELECT MAX(song.dateAdded) FROM song WHERE song.idAlbum = album.idAlbum) AS dateAdded, "
" (SELECT MAX(song.lastplayed) FROM song WHERE song.idAlbum = album.idAlbum) AS lastplayed "
"FROM album"
);

Expand Down Expand Up @@ -1797,6 +1798,7 @@ CAlbum CMusicDatabase::GetAlbumFromDataset(const dbiplus::sql_record* const reco
album.iTimesPlayed = record->at(offset + album_iTimesPlayed).get_asInt();
album.SetReleaseType(record->at(offset + album_strReleaseType).get_asString());
album.SetDateAdded(record->at(offset + album_dtDateAdded).get_asString());
album.SetLastPlayed(record->at(offset + album_dtLastPlayed).get_asString());
return album;
}

Expand Down Expand Up @@ -3950,7 +3952,7 @@ void CMusicDatabase::UpdateTables(int version)

int CMusicDatabase::GetSchemaVersion() const
{
return 54;
return 55;
}

unsigned int CMusicDatabase::GetSongIDs(const Filter &filter, std::vector<std::pair<int,int> > &songIDs)
Expand Down
1 change: 1 addition & 0 deletions xbmc/music/MusicDatabase.h
Expand Up @@ -575,6 +575,7 @@ class CMusicDatabase : public CDatabase
album_iTimesPlayed,
album_strReleaseType,
album_dtDateAdded,
album_dtLastPlayed,
album_enumCount // end of the enum, do not add past here
} AlbumFields;

Expand Down
1 change: 1 addition & 0 deletions xbmc/music/tags/MusicInfoTag.cpp
Expand Up @@ -615,6 +615,7 @@ void CMusicInfoTag::SetAlbum(const CAlbum& album)
SetDateAdded(album.dateAdded);
SetPlayCount(album.iTimesPlayed);
SetDatabaseId(album.idAlbum, MediaTypeAlbum);
SetLastPlayed(album.lastPlayed);

SetLoaded();
}
Expand Down
11 changes: 4 additions & 7 deletions xbmc/music/windows/GUIWindowMusicPlaylist.cpp
Expand Up @@ -448,13 +448,10 @@ void CGUIWindowMusicPlayList::OnItemLoaded(CFileItem* pItem)
if (pItem->HasMusicInfoTag() && pItem->GetMusicInfoTag()->Loaded())
{ // set label 1+2 from tags
if (m_guiState.get()) m_hideExtensions = m_guiState->HideExtensions();
std::string strTrackLeft=CSettings::GetInstance().GetString(CSettings::SETTING_MUSICFILES_NOWPLAYINGTRACKFORMAT);
if (strTrackLeft.empty())
strTrackLeft = CSettings::GetInstance().GetString(CSettings::SETTING_MUSICFILES_TRACKFORMAT);
std::string strTrackRight=CSettings::GetInstance().GetString(CSettings::SETTING_MUSICFILES_NOWPLAYINGTRACKFORMATRIGHT);
if (strTrackRight.empty())
strTrackRight = CSettings::GetInstance().GetString(CSettings::SETTING_MUSICFILES_TRACKFORMATRIGHT);
CLabelFormatter formatter(strTrackLeft, strTrackRight);
std::string strTrack=CSettings::GetInstance().GetString(CSettings::SETTING_MUSICFILES_NOWPLAYINGTRACKFORMAT);
if (strTrack.empty())
strTrack = CSettings::GetInstance().GetString(CSettings::SETTING_MUSICFILES_TRACKFORMAT);
CLabelFormatter formatter(strTrack, "%D");
formatter.FormatLabels(pItem);
} // if (pItem->m_musicInfoTag.Loaded())
else
Expand Down
2 changes: 1 addition & 1 deletion xbmc/music/windows/GUIWindowMusicPlaylistEditor.cpp
Expand Up @@ -416,7 +416,7 @@ void CGUIWindowMusicPlaylistEditor::OnSavePlaylist()
void CGUIWindowMusicPlaylistEditor::AppendToPlaylist(CFileItemList &newItems)
{
OnRetrieveMusicInfo(newItems);
FormatItemLabels(newItems, LABEL_MASKS(CSettings::GetInstance().GetString(CSettings::SETTING_MUSICFILES_TRACKFORMAT), CSettings::GetInstance().GetString(CSettings::SETTING_MUSICFILES_TRACKFORMATRIGHT), "%L", ""));
FormatItemLabels(newItems, LABEL_MASKS(CSettings::GetInstance().GetString(CSettings::SETTING_MUSICFILES_TRACKFORMAT), "%D", "%L", ""));
m_playlist->Append(newItems);
UpdatePlaylist();
}
Expand Down
2 changes: 0 additions & 2 deletions xbmc/settings/AdvancedSettings.cpp
Expand Up @@ -275,7 +275,6 @@ void CAdvancedSettings::Initialize()
m_bMusicLibraryCleanOnUpdate = false;
m_iMusicLibraryRecentlyAddedItems = 25;
m_strMusicLibraryAlbumFormat = "";
m_strMusicLibraryAlbumFormatRight = "";
m_prioritiseAPEv2tags = false;
m_musicItemSeparator = " / ";
m_videoItemSeparator = " / ";
Expand Down Expand Up @@ -739,7 +738,6 @@ void CAdvancedSettings::ParseSettingsFile(const std::string &file)
XMLUtils::GetBoolean(pElement, "allitemsonbottom", m_bMusicLibraryAllItemsOnBottom);
XMLUtils::GetBoolean(pElement, "cleanonupdate", m_bMusicLibraryCleanOnUpdate);
XMLUtils::GetString(pElement, "albumformat", m_strMusicLibraryAlbumFormat);
XMLUtils::GetString(pElement, "albumformatright", m_strMusicLibraryAlbumFormatRight);
XMLUtils::GetString(pElement, "itemseparator", m_musicItemSeparator);
XMLUtils::GetInt(pElement, "dateadded", m_iMusicLibraryDateAdded);
}
Expand Down
1 change: 0 additions & 1 deletion xbmc/settings/AdvancedSettings.h
Expand Up @@ -272,7 +272,6 @@ class CAdvancedSettings : public ISettingCallback, public ISettingsHandler
bool m_bMusicLibraryAllItemsOnBottom;
bool m_bMusicLibraryCleanOnUpdate;
std::string m_strMusicLibraryAlbumFormat;
std::string m_strMusicLibraryAlbumFormatRight;
bool m_prioritiseAPEv2tags;
std::string m_musicItemSeparator;
std::string m_videoItemSeparator;
Expand Down
4 changes: 0 additions & 4 deletions xbmc/settings/Settings.cpp
Expand Up @@ -281,11 +281,8 @@ const std::string CSettings::SETTING_MUSICPLAYER_CROSSFADEALBUMTRACKS = "musicpl
const std::string CSettings::SETTING_MUSICPLAYER_VISUALISATION = "musicplayer.visualisation";
const std::string CSettings::SETTING_MUSICFILES_USETAGS = "musicfiles.usetags";
const std::string CSettings::SETTING_MUSICFILES_TRACKFORMAT = "musicfiles.trackformat";
const std::string CSettings::SETTING_MUSICFILES_TRACKFORMATRIGHT = "musicfiles.trackformatright";
const std::string CSettings::SETTING_MUSICFILES_NOWPLAYINGTRACKFORMAT = "musicfiles.nowplayingtrackformat";
const std::string CSettings::SETTING_MUSICFILES_NOWPLAYINGTRACKFORMATRIGHT = "musicfiles.nowplayingtrackformatright";
const std::string CSettings::SETTING_MUSICFILES_LIBRARYTRACKFORMAT = "musicfiles.librarytrackformat";
const std::string CSettings::SETTING_MUSICFILES_LIBRARYTRACKFORMATRIGHT = "musicfiles.librarytrackformatright";
const std::string CSettings::SETTING_MUSICFILES_FINDREMOTETHUMBS = "musicfiles.findremotethumbs";
const std::string CSettings::SETTING_AUDIOCDS_AUTOACTION = "audiocds.autoaction";
const std::string CSettings::SETTING_AUDIOCDS_USECDDB = "audiocds.usecddb";
Expand Down Expand Up @@ -1031,7 +1028,6 @@ void CSettings::InitializeISettingCallbacks()
settingSet.insert(CSettings::SETTING_MUSICLIBRARY_EXPORT);
settingSet.insert(CSettings::SETTING_MUSICLIBRARY_IMPORT);
settingSet.insert(CSettings::SETTING_MUSICFILES_TRACKFORMAT);
settingSet.insert(CSettings::SETTING_MUSICFILES_TRACKFORMATRIGHT);
settingSet.insert(CSettings::SETTING_VIDEOLIBRARY_FLATTENTVSHOWS);
settingSet.insert(CSettings::SETTING_VIDEOLIBRARY_REMOVE_DUPLICATES);
settingSet.insert(CSettings::SETTING_VIDEOLIBRARY_GROUPMOVIESETS);
Expand Down
3 changes: 0 additions & 3 deletions xbmc/settings/Settings.h
Expand Up @@ -238,11 +238,8 @@ class CSettings : public CSettingCreator, public CSettingControlCreator
static const std::string SETTING_MUSICPLAYER_VISUALISATION;
static const std::string SETTING_MUSICFILES_USETAGS;
static const std::string SETTING_MUSICFILES_TRACKFORMAT;
static const std::string SETTING_MUSICFILES_TRACKFORMATRIGHT;
static const std::string SETTING_MUSICFILES_NOWPLAYINGTRACKFORMAT;
static const std::string SETTING_MUSICFILES_NOWPLAYINGTRACKFORMATRIGHT;
static const std::string SETTING_MUSICFILES_LIBRARYTRACKFORMAT;
static const std::string SETTING_MUSICFILES_LIBRARYTRACKFORMATRIGHT;
static const std::string SETTING_MUSICFILES_FINDREMOTETHUMBS;
static const std::string SETTING_AUDIOCDS_AUTOACTION;
static const std::string SETTING_AUDIOCDS_USECDDB;
Expand Down
2 changes: 2 additions & 0 deletions xbmc/utils/LabelFormatter.cpp
Expand Up @@ -330,6 +330,8 @@ std::string CLabelFormatter::GetMaskContent(const CMaskString &mask, const CFile
case 'p': // Last played
if (movie && movie->m_lastPlayed.IsValid())
value = movie->m_lastPlayed.GetAsLocalizedDate();
if (music && music->GetLastPlayed().IsValid())
value = music->GetLastPlayed().GetAsLocalizedDate();
break;
case 'r': // userrating
if (movie && movie->m_iUserRating != 0)
Expand Down
10 changes: 4 additions & 6 deletions xbmc/video/GUIViewStateVideo.cpp
Expand Up @@ -312,9 +312,8 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it
if (CMediaSettings::GetInstance().GetWatchedMode(items.GetContent()) == WatchedModeAll)
AddSortMethod(SortByPlaycount, 567, LABEL_MASKS("%T", "%V")); // Title, Playcount | empty, empty

std::string strTrackLeft=CSettings::GetInstance().GetString(CSettings::SETTING_MUSICFILES_TRACKFORMAT);
std::string strTrackRight=CSettings::GetInstance().GetString(CSettings::SETTING_MUSICFILES_TRACKFORMATRIGHT);
AddSortMethod(SortByTrackNumber, 554, LABEL_MASKS(strTrackLeft, strTrackRight)); // Userdefined, Userdefined | empty, empty
std::string strTrack=CSettings::GetInstance().GetString(CSettings::SETTING_MUSICFILES_TRACKFORMAT);
AddSortMethod(SortByTrackNumber, 554, LABEL_MASKS(strTrack, "%N")); // Userdefined, Track Number | empty, empty

const CViewState *viewState = CViewStateSettings::GetInstance().Get("videonavmusicvideos");
SetSortMethod(viewState->m_sortDescription);
Expand Down Expand Up @@ -525,9 +524,8 @@ CGUIViewStateVideoMusicVideos::CGUIViewStateVideoMusicVideos(const CFileItemList
if (CMediaSettings::GetInstance().GetWatchedMode(items.GetContent()) == WatchedModeAll)
AddSortMethod(SortByPlaycount, 567, LABEL_MASKS("%T", "%V")); // Title, Playcount | empty, empty

std::string strTrackLeft=CSettings::GetInstance().GetString(CSettings::SETTING_MUSICFILES_TRACKFORMAT);
std::string strTrackRight=CSettings::GetInstance().GetString(CSettings::SETTING_MUSICFILES_TRACKFORMATRIGHT);
AddSortMethod(SortByTrackNumber, 554, LABEL_MASKS(strTrackLeft, strTrackRight)); // Userdefined, Userdefined | empty, empty
std::string strTrack=CSettings::GetInstance().GetString(CSettings::SETTING_MUSICFILES_TRACKFORMAT);
AddSortMethod(SortByTrackNumber, 554, LABEL_MASKS(strTrack, "%N")); // Userdefined, Track Number | empty, empty

const CViewState *viewState = CViewStateSettings::GetInstance().Get("videonavmusicvideos");
if (items.IsSmartPlayList() || items.IsLibraryFolder())
Expand Down

0 comments on commit 1161510

Please sign in to comment.