Skip to content

Commit

Permalink
Merge pull request #23740 from notspiff/small_simplifications
Browse files Browse the repository at this point in the history
Some small simplifications
  • Loading branch information
notspiff committed Sep 10, 2023
2 parents e95cb51 + 83b371a commit c8e8334
Show file tree
Hide file tree
Showing 2 changed files with 212 additions and 195 deletions.
169 changes: 92 additions & 77 deletions xbmc/music/windows/GUIWindowMusicNav.cpp
Expand Up @@ -389,57 +389,81 @@ bool CGUIWindowMusicNav::GetDirectory(const std::string &strDirectory, CFileItem
{
CVideoDatabaseDirectory dir;
VIDEODATABASEDIRECTORY::NODE_TYPE node = dir.GetDirectoryChildType(items.GetPath());
if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_TITLE_MUSICVIDEOS ||
node == VIDEODATABASEDIRECTORY::NODE_TYPE_RECENTLY_ADDED_MUSICVIDEOS)
items.SetContent("musicvideos");
else if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_GENRE)
items.SetContent("genres");
else if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_COUNTRY)
items.SetContent("countries");
else if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_ACTOR)
items.SetContent("artists");
else if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_DIRECTOR)
items.SetContent("directors");
else if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_STUDIO)
items.SetContent("studios");
else if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_YEAR)
items.SetContent("years");
else if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_MUSICVIDEOS_ALBUM)
items.SetContent("albums");
else if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_TAGS)
items.SetContent("tags");
else
items.SetContent("");
switch (node)
{
case VIDEODATABASEDIRECTORY::NODE_TYPE_TITLE_MUSICVIDEOS:
case VIDEODATABASEDIRECTORY::NODE_TYPE_RECENTLY_ADDED_MUSICVIDEOS:
items.SetContent("musicvideos");
break;
case VIDEODATABASEDIRECTORY::NODE_TYPE_GENRE:
items.SetContent("genres");
break;
case VIDEODATABASEDIRECTORY::NODE_TYPE_COUNTRY:
items.SetContent("countries");
break;
case VIDEODATABASEDIRECTORY::NODE_TYPE_ACTOR:
items.SetContent("artists");
break;
case VIDEODATABASEDIRECTORY::NODE_TYPE_DIRECTOR:
items.SetContent("directors");
break;
case VIDEODATABASEDIRECTORY::NODE_TYPE_STUDIO:
items.SetContent("studios");
break;
case VIDEODATABASEDIRECTORY::NODE_TYPE_YEAR:
items.SetContent("years");
break;
case VIDEODATABASEDIRECTORY::NODE_TYPE_MUSICVIDEOS_ALBUM:
items.SetContent("albums");
break;
case VIDEODATABASEDIRECTORY::NODE_TYPE_TAGS:
items.SetContent("tags");
break;
default:
items.SetContent("");
break;
}
}
else if (StringUtils::StartsWithNoCase(strDirectory, "musicdb://") || items.IsMusicDb())
{
CMusicDatabaseDirectory dir;
NODE_TYPE node = dir.GetDirectoryChildType(items.GetPath());
if (node == NODE_TYPE_ALBUM ||
node == NODE_TYPE_ALBUM_RECENTLY_ADDED ||
node == NODE_TYPE_ALBUM_RECENTLY_PLAYED ||
node == NODE_TYPE_ALBUM_TOP100 ||
node == NODE_TYPE_DISC) // ! @todo: own content type "discs"??
items.SetContent("albums");
else if (node == NODE_TYPE_ARTIST)
items.SetContent("artists");
else if (node == NODE_TYPE_SONG ||
node == NODE_TYPE_SONG_TOP100 ||
node == NODE_TYPE_SINGLES ||
node == NODE_TYPE_ALBUM_RECENTLY_ADDED_SONGS ||
node == NODE_TYPE_ALBUM_RECENTLY_PLAYED_SONGS ||
node == NODE_TYPE_ALBUM_TOP100_SONGS)
items.SetContent("songs");
else if (node == NODE_TYPE_GENRE)
items.SetContent("genres");
else if (node == NODE_TYPE_SOURCE)
items.SetContent("sources");
else if (node == NODE_TYPE_ROLE)
items.SetContent("roles");
else if (node == NODE_TYPE_YEAR)
items.SetContent("years");
else
items.SetContent("");
switch (node)
{
case NODE_TYPE_ALBUM:
case NODE_TYPE_ALBUM_RECENTLY_ADDED:
case NODE_TYPE_ALBUM_RECENTLY_PLAYED:
case NODE_TYPE_ALBUM_TOP100:
case NODE_TYPE_DISC: // ! @todo: own content type "discs"??
items.SetContent("albums");
break;
case NODE_TYPE_ARTIST:
items.SetContent("artists");
break;
case NODE_TYPE_SONG:
case NODE_TYPE_SONG_TOP100:
case NODE_TYPE_SINGLES:
case NODE_TYPE_ALBUM_RECENTLY_ADDED_SONGS:
case NODE_TYPE_ALBUM_RECENTLY_PLAYED_SONGS:
case NODE_TYPE_ALBUM_TOP100_SONGS:
items.SetContent("songs");
break;
case NODE_TYPE_GENRE:
items.SetContent("genres");
break;
case NODE_TYPE_SOURCE:
items.SetContent("sources");
break;
case NODE_TYPE_ROLE:
items.SetContent("roles");
break;
case NODE_TYPE_YEAR:
items.SetContent("years");
break;
default:
items.SetContent("");
break;
}
}
else if (items.IsPlayList())
items.SetContent("songs");
Expand Down Expand Up @@ -921,35 +945,26 @@ void CGUIWindowMusicNav::AddSearchFolder()

std::string CGUIWindowMusicNav::GetStartFolder(const std::string &dir)
{
std::string lower(dir); StringUtils::ToLower(lower);
if (lower == "genres")
return "musicdb://genres/";
else if (lower == "artists")
return "musicdb://artists/";
else if (lower == "albums")
return "musicdb://albums/";
else if (lower == "singles")
return "musicdb://singles/";
else if (lower == "songs")
return "musicdb://songs/";
else if (lower == "top100")
return "musicdb://top100/";
else if (lower == "top100songs")
return "musicdb://top100/songs/";
else if (lower == "top100albums")
return "musicdb://top100/albums/";
else if (lower == "recentlyaddedalbums")
return "musicdb://recentlyaddedalbums/";
else if (lower == "recentlyplayedalbums")
return "musicdb://recentlyplayedalbums/";
else if (lower == "compilations")
return "musicdb://compilations/";
else if (lower == "years")
return "musicdb://years/";
else if (lower == "files")
return "sources://music/";
else if (lower == "boxsets")
return "musicdb://boxsets/";

return CGUIWindowMusicBase::GetStartFolder(dir);
static const auto map = std::map<std::string, std::string>{
{"albums", "musicdb://albums/"},
{"artists", "musicdb://artists/"},
{"boxsets", "musicdb://boxsets/"},
{"compilations", "musicdb://compilations/"},
{"files", "sources://music/"},
{"genres", "musicdb://genres/"},
{"recentlyaddedalbums", "musicdb://recentlyaddedalbums/"},
{"recentlyplayedalbums", "musicdb://recentlyplayedalbums/"},
{"singles", "musicdb://singles/"},
{"songs", "musicdb://songs/"},
{"top100", "musicdb://top100/"},
{"top100albums", "musicdb://top100/albums/"},
{"top100songs", "musicdb://top100/songs/"},
{"years", "musicdb://years/"},
};

const auto it = map.find(StringUtils::ToLower(dir));
if (it == map.end())
return CGUIWindowMusicBase::GetStartFolder(dir);
else
return it->second;
}

0 comments on commit c8e8334

Please sign in to comment.