Permalink
Browse files

[music] Separate rating from user rating and make user rating editabl…

…e by the user. Also move to 1-10 ratings. Added votes for ratings.
  • Loading branch information...
Razzeee committed Nov 13, 2015
1 parent 70cd30f commit c5b281b2edf9182c9baebddf2c25dacf2cc74ce1
Showing with 671 additions and 200 deletions.
  1. +11 −0 addons/skin.confluence/720p/DialogAlbumInfo.xml
  2. +37 −12 addons/skin.confluence/720p/DialogSongInfo.xml
  3. +2 −2 addons/skin.confluence/720p/MusicVisualisation.xml
  4. +4 −6 addons/skin.confluence/720p/ViewsMusicLibrary.xml
  5. +5 −5 xbmc/Application.cpp
  6. +44 −46 xbmc/GUIInfoManager.cpp
  7. +1 −0 xbmc/SortFileItem.h
  8. +3 −2 xbmc/guiinfo/GUIInfoLabels.h
  9. +6 −2 xbmc/interfaces/json-rpc/AudioLibrary.cpp
  10. +9 −4 xbmc/interfaces/json-rpc/schema/methods.json
  11. +8 −5 xbmc/interfaces/json-rpc/schema/types.json
  12. +1 −1 xbmc/interfaces/json-rpc/schema/version.txt
  13. +3 −1 xbmc/interfaces/legacy/ListItem.cpp
  14. +2 −1 xbmc/interfaces/legacy/ListItem.h
  15. +1 −0 xbmc/interfaces/legacy/ModuleXbmcplugin.h
  16. +20 −3 xbmc/music/Album.cpp
  17. +7 −3 xbmc/music/Album.h
  18. +10 −2 xbmc/music/GUIViewStateMusic.cpp
  19. +225 −33 xbmc/music/MusicDatabase.cpp
  20. +16 −5 xbmc/music/MusicDatabase.h
  21. +8 −2 xbmc/music/Song.cpp
  22. +3 −1 xbmc/music/Song.h
  23. +71 −7 xbmc/music/dialogs/GUIDialogMusicInfo.cpp
  24. +6 −1 xbmc/music/dialogs/GUIDialogMusicInfo.h
  25. +17 −11 xbmc/music/dialogs/GUIDialogSongInfo.cpp
  26. +2 −2 xbmc/music/dialogs/GUIDialogSongInfo.h
  27. +2 −1 xbmc/music/infoscanner/MusicInfoScanner.cpp
  28. +54 −11 xbmc/music/tags/MusicInfoTag.cpp
  29. +11 −5 xbmc/music/tags/MusicInfoTag.h
  30. +17 −12 xbmc/music/tags/TagLoaderTagLib.cpp
  31. +1 −1 xbmc/music/tags/TagLoaderTagLib.h
  32. +3 −2 xbmc/music/windows/GUIWindowMusicBase.cpp
  33. +11 −3 xbmc/utils/DatabaseUtils.cpp
  34. +7 −2 xbmc/utils/LabelFormatter.cpp
  35. +1 −1 xbmc/utils/RecentlyAddedJob.cpp
  36. +1 −0 xbmc/utils/SortUtils.cpp
  37. +41 −5 xbmc/utils/test/TestDatabaseUtils.cpp
@@ -213,6 +213,12 @@
<onclick>noop</onclick>
<visible>!IsEmpty(ListItem.Rating)</visible>
</item>
<item>
<label>$LOCALIZE[38018]:</label>
<label2>$INFO[ListItem.Userrating]</label2>
<onclick>noop</onclick>
<visible>!IsEmpty(ListItem.Userrating)</visible>
</item>
<item>
<label>$LOCALIZE[175]:</label>
<label2>$INFO[ListItem.Property(Album_Mood)]</label2>
@@ -535,6 +541,11 @@
<include>ButtonInfoDialogsCommonValues</include>
<label>20413</label>
</control>
<control type="button" id="7">
<description>Set my rating</description>
<include>ButtonInfoDialogsCommonValues</include>
<label>38023</label>
</control>
</control>
</control>
</control>
@@ -189,21 +189,21 @@
<textcolor>blue</textcolor>
<label>$LOCALIZE[563]:</label>
</control>
<control type="group">
<control type="fadelabel">
<description>Rating value</description>
<left>160</left>
<top>148</top>
<control type="image">
<description>Rating value</description>
<left>0</left>
<top>0</top>
<width>150</width>
<height>32</height>
<aspectratio align="left">keep</aspectratio>
<texture>LeftRating/$INFO[ListItem.StarRating]</texture>
</control>
<width>460</width>
<height>25</height>
<align>left</align>
<aligny>center</aligny>
<font>font13</font>
<textcolor>white</textcolor>
<label>$INFO[ListItem.Rating]</label>
<visible>!IsEmpty(ListItem.Rating)</visible>
</control>
<control type="label">
<description>Comment Title</description>
<description>User Rating Title</description>
<left>0</left>
<top>180</top>
<width>150</width>
@@ -212,12 +212,37 @@
<aligny>center</aligny>
<font>font13</font>
<textcolor>blue</textcolor>
<label>$LOCALIZE[38018]:</label>
</control>
<control type="fadelabel">
<description>User Rating value</description>
<left>160</left>
<top>179</top>
<width>460</width>
<height>25</height>
<align>left</align>
<aligny>center</aligny>
<font>font13</font>
<textcolor>white</textcolor>
<label>$INFO[ListItem.Userrating]</label>
<visible>!IsEmpty(ListItem.Userrating)</visible>
</control>
<control type="label">
<description>Comment Title</description>
<left>0</left>
<top>210</top>
<width>150</width>
<height>25</height>
<align>right</align>
<aligny>center</aligny>
<font>font13</font>
<textcolor>blue</textcolor>
<label>$LOCALIZE[569]:</label>
</control>
<control type="textbox">
<description>Comment value</description>
<left>160</left>
<top>179</top>
<top>209</top>
<width>460</width>
<height>138</height>
<font>font13</font>
@@ -170,7 +170,7 @@
<width>100</width>
<height>35</height>
<aspectratio align="center">keep</aspectratio>
<texture fallback="LeftRating/rating0.png">$INFO[Player.StarRating,LeftRating/]</texture>
<texture fallback="LeftRating/rating0.png">$INFO[ListItem.UserRating,LeftRating/rating,.png]</texture>
</control>
</control>
</control>
@@ -236,7 +236,7 @@
<width>100</width>
<height>35</height>
<aspectratio align="center">keep</aspectratio>
<texture fallback="LeftRating/rating0.png">$INFO[Player.StarRating,LeftRating/]</texture>
<texture fallback="LeftRating/rating0.png">$INFO[ListItem.UserRating,LeftRating/rating,.png]</texture>
</control>
</control>
</control>
@@ -215,14 +215,13 @@
<font>font13</font>
<textcolor>white</textcolor>
</control>
<control type="image">
<control type="label">
<description>Rating value</description>
<left>80</left>
<top>535</top>
<width>150</width>
<height>30</height>
<aspectratio>keep</aspectratio>
<texture>$INFO[ListItem.StarRating,CenterRating/]</texture>
<label>$INFO[ListItem.Userrating]</label>
</control>
</control>
</control>
@@ -459,14 +458,13 @@
<scrollout>false</scrollout>
<pauseatend>2000</pauseatend>
</control>
<control type="image">
<control type="label">
<description>Rating value</description>
<left>100</left>
<top>95</top>
<width>160</width>
<height>32</height>
<aspectratio>keep</aspectratio>
<texture>$INFO[ListItem.StarRating,LeftRating/]</texture>
<label>$INFO[ListItem.Userrating]</label>
</control>
<control type="textbox">
<description>Description Value for Album</description>
@@ -2191,16 +2191,16 @@ bool CApplication::OnAction(const CAction &action)
if (tag)
{
*m_itemCurrentFile->GetMusicInfoTag() = *tag;
char rating = tag->GetUserrating();
int userrating = tag->GetUserrating();
bool needsUpdate(false);
if (rating > '0' && action.GetID() == ACTION_DECREASE_RATING)
if (userrating > 0 && action.GetID() == ACTION_DECREASE_RATING)
{
m_itemCurrentFile->GetMusicInfoTag()->SetUserrating(rating - 1);
m_itemCurrentFile->GetMusicInfoTag()->SetUserrating(userrating - 1);
needsUpdate = true;
}
else if (rating < '5' && action.GetID() == ACTION_INCREASE_RATING)
else if (userrating < 10 && action.GetID() == ACTION_INCREASE_RATING)
{
m_itemCurrentFile->GetMusicInfoTag()->SetUserrating(rating + 1);
m_itemCurrentFile->GetMusicInfoTag()->SetUserrating(userrating + 1);
needsUpdate = true;
}
if (needsUpdate)
@@ -214,7 +214,6 @@ const infomap player_labels[] = {{ "hasmedia", PLAYER_HAS_MEDIA },
{ "chapter", PLAYER_CHAPTER },
{ "chaptercount", PLAYER_CHAPTERCOUNT },
{ "chaptername", PLAYER_CHAPTERNAME },
{ "starrating", PLAYER_STAR_RATING },
{ "folderpath", PLAYER_PATH },
{ "filenameandpath", PLAYER_FILEPATH },
{ "filename", PLAYER_FILENAME },
@@ -349,6 +348,9 @@ const infomap musicplayer[] = {{ "title", MUSICPLAYER_TITLE },
{ "codec", MUSICPLAYER_CODEC },
{ "discnumber", MUSICPLAYER_DISC_NUMBER },
{ "rating", MUSICPLAYER_RATING },
{ "ratingandvotes", MUSICPLAYER_RATING_AND_VOTES },
{ "userrating", MUSICPLAYER_USER_RATING },
{ "votes", MUSICPLAYER_VOTES },
{ "comment", MUSICPLAYER_COMMENT },
{ "lyrics", MUSICPLAYER_LYRICS },
{ "playlistplaying", MUSICPLAYER_PLAYLISTPLAYING },
@@ -574,7 +576,6 @@ const infomap listitem_labels[]= {{ "thumb", LISTITEM_THUMB },
{ "tagline", LISTITEM_TAGLINE },
{ "top250", LISTITEM_TOP250 },
{ "trailer", LISTITEM_TRAILER },
{ "starrating", LISTITEM_STAR_RATING },
{ "sortletter", LISTITEM_SORT_LETTER },
{ "videocodec", LISTITEM_VIDEO_CODEC },
{ "videoresolution", LISTITEM_VIDEO_RESOLUTION },
@@ -1708,6 +1709,8 @@ std::string CGUIInfoManager::GetLabel(int info, int contextWindow, std::string *
case MUSICPLAYER_CODEC:
case MUSICPLAYER_DISC_NUMBER:
case MUSICPLAYER_RATING:
case MUSICPLAYER_RATING_AND_VOTES:
case MUSICPLAYER_USER_RATING:
case MUSICPLAYER_COMMENT:
case MUSICPLAYER_LYRICS:
case MUSICPLAYER_CHANNEL_NAME:
@@ -3668,16 +3671,6 @@ std::string CGUIInfoManager::GetImage(int info, int contextWindow, std::string *
*fallback = "DefaultAlbumCover.png";
return m_currentFile->HasArt("thumb") ? m_currentFile->GetArt("thumb") : "DefaultAlbumCover.png";
}
else if (info == MUSICPLAYER_RATING)
{
if (!g_application.m_pPlayer->IsPlayingAudio()) return "";
return GetItemImage(m_currentFile, LISTITEM_RATING);
}
else if (info == PLAYER_STAR_RATING)
{
if (!g_application.m_pPlayer->IsPlaying()) return "";
return GetItemImage(m_currentFile, LISTITEM_STAR_RATING);
}
else if (info == VIDEOPLAYER_COVER)
{
if (!g_application.m_pPlayer->IsPlayingVideo()) return "";
@@ -3688,7 +3681,7 @@ std::string CGUIInfoManager::GetImage(int info, int contextWindow, std::string *
else return m_currentMovieThumb;
}
else if (info == LISTITEM_THUMB || info == LISTITEM_ICON || info == LISTITEM_ACTUAL_ICON ||
info == LISTITEM_OVERLAY || info == LISTITEM_RATING || info == LISTITEM_STAR_RATING)
info == LISTITEM_OVERLAY)
{
CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_HAS_LIST_ITEMS);
if (window)
@@ -4159,6 +4152,25 @@ std::string CGUIInfoManager::GetMusicTagLabel(int info, const CFileItem *item)
return GetItemLabel(item, LISTITEM_DISC_NUMBER);
case MUSICPLAYER_RATING:
return GetItemLabel(item, LISTITEM_RATING);
case MUSICPLAYER_RATING_AND_VOTES:
{
std::string strRatingAndVotes;
if (m_currentFile->GetMusicInfoTag()->GetRating() > 0.f)
{
if (m_currentFile->GetMusicInfoTag()->GetRating() > 0)
strRatingAndVotes = StringUtils::Format("%.1f",
m_currentFile->GetMusicInfoTag()->GetRating());
else
strRatingAndVotes = StringUtils::Format("%.1f (%i %s)",
m_currentFile->GetMusicInfoTag()->GetRating(),
m_currentFile->GetMusicInfoTag()->GetVotes(),
g_localizeStrings.Get(20350).c_str());
}
return strRatingAndVotes;
}
break;
case MUSICPLAYER_USER_RATING:
return GetItemLabel(item, LISTITEM_USER_RATING);
case MUSICPLAYER_COMMENT:
return GetItemLabel(item, LISTITEM_COMMENT);
case MUSICPLAYER_DURATION:
@@ -5198,15 +5210,13 @@ std::string CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std::
std::string rating;
if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_fRating > 0.f) // movie rating
rating = StringUtils::Format("%.1f", item->GetVideoInfoTag()->m_fRating);
else if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetUserrating() > '0')
{ // song rating. Images will probably be better than numbers for this in the long run
rating.assign(1, item->GetMusicInfoTag()->GetUserrating());
}
else if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetRating() > 0.f) // song rating
rating = StringUtils::Format("%.1f", item->GetMusicInfoTag()->GetRating());
return rating;
}
case LISTITEM_RATING_AND_VOTES:
{
if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_fRating > 0.f) // movie rating
if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_fRating > 0.f) // video rating & votes
{
std::string strRatingAndVotes;
if (item->GetVideoInfoTag()->m_strVotes.empty())
@@ -5219,21 +5229,35 @@ std::string CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std::
g_localizeStrings.Get(20350).c_str());
return strRatingAndVotes;
}
else if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetRating() > 0.f) // music rating & votes
{
std::string strRatingAndVotes;
if (item->GetMusicInfoTag()->GetVotes() <= 0)
strRatingAndVotes = StringUtils::Format("%.1f", item->GetMusicInfoTag()->GetRating());
else
strRatingAndVotes = StringUtils::Format("%.1f (%i %s)",
item->GetMusicInfoTag()->GetRating(),
item->GetMusicInfoTag()->GetVotes(),
g_localizeStrings.Get(20350).c_str());
return strRatingAndVotes;
}
}
break;
case LISTITEM_USER_RATING:
{
std::string strUserRating;
if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_iUserRating > 0)
strUserRating = StringUtils::Format("%i", item->GetVideoInfoTag()->m_iUserRating);
else if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetUserrating() > '0')
strUserRating.assign(1, item->GetMusicInfoTag()->GetUserrating());
else if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetUserrating() > 0)
strUserRating = StringUtils::Format("%i", item->GetMusicInfoTag()->GetUserrating());
return strUserRating;
}
break;
case LISTITEM_VOTES:
if (item->HasVideoInfoTag())
return item->GetVideoInfoTag()->m_strVotes;
else if (item->HasMusicInfoTag())
return StringUtils::Format("%i", item->GetMusicInfoTag()->GetVotes());
break;
case LISTITEM_PROGRAM_COUNT:
{
@@ -5809,32 +5833,6 @@ std::string CGUIInfoManager::GetItemImage(const CFileItem *item, int info, std::
if (info >= CONDITIONAL_LABEL_START && info <= CONDITIONAL_LABEL_END)
return GetSkinVariableString(info, true, item);

switch (info)
{
case LISTITEM_RATING: // old song rating format
{
if (item->HasMusicInfoTag())
{
return StringUtils::Format("songrating%c.png", item->GetMusicInfoTag()->GetUserrating());
}
}
break;
case LISTITEM_STAR_RATING:
{
std::string rating;
if (item->HasVideoInfoTag())
{ // rating for videos is assumed 0..10, so convert to 0..5
rating = StringUtils::Format("rating%ld.png", (long)((item->GetVideoInfoTag()->m_fRating * 0.5f) + 0.5f));
}
else if (item->HasMusicInfoTag())
{ // song rating.
rating = StringUtils::Format("rating%c.png", item->GetMusicInfoTag()->GetUserrating());
}
return rating;
}
break;
} /* switch (info) */

return GetItemLabel(item, info, fallback);
}

@@ -50,6 +50,7 @@ typedef enum {
SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE,
SORT_METHOD_PRODUCTIONCODE,
SORT_METHOD_SONG_RATING,
SORT_METHOD_SONG_USER_RATING,
SORT_METHOD_MPAA_RATING,
SORT_METHOD_VIDEO_RUNTIME,
SORT_METHOD_STUDIO,
@@ -62,7 +62,6 @@
#define PLAYER_TIME_SPEED 37
#define PLAYER_FINISH_TIME 38
#define PLAYER_CACHELEVEL 39
#define PLAYER_STAR_RATING 40
#define PLAYER_CHAPTERNAME 41
#define PLAYER_SUBTITLE_DELAY 42
#define PLAYER_AUDIO_DELAY 43
@@ -189,6 +188,9 @@
#define MUSICPLAYER_SUB_CHANNEL_NUMBER 232
#define MUSICPLAYER_CHANNEL_NUMBER_LBL 233
#define MUSICPLAYER_CONTENT 234
#define MUSICPLAYER_USER_RATING 235
#define MUSICPLAYER_RATING_AND_VOTES 236
#define MUSICPLAYER_VOTES 237

#define VIDEOPLAYER_TITLE 250
#define VIDEOPLAYER_GENRE 251
@@ -653,7 +655,6 @@
#define LISTITEM_TOP250 (LISTITEM_START + 89)
#define LISTITEM_RATING_AND_VOTES (LISTITEM_START + 90)
#define LISTITEM_TRAILER (LISTITEM_START + 91)
#define LISTITEM_STAR_RATING (LISTITEM_START + 92)
#define LISTITEM_FILENAME_AND_PATH (LISTITEM_START + 93)
#define LISTITEM_SORT_LETTER (LISTITEM_START + 94)
#define LISTITEM_ALBUM_ARTIST (LISTITEM_START + 95)
Oops, something went wrong.

0 comments on commit c5b281b

Please sign in to comment.