Skip to content

Commit

Permalink
[stdstring] get rid of CStdString in music/windows/
Browse files Browse the repository at this point in the history
  • Loading branch information
notspiff authored and Montellese committed Jan 7, 2015
1 parent 4839aad commit ddfcf24
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 66 deletions.
26 changes: 14 additions & 12 deletions xbmc/music/windows/GUIWindowMusicBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ using namespace MUSIC_INFO;
#define CONTROL_BTNSORTASC 4
#define CONTROL_BTNTYPE 5

CGUIWindowMusicBase::CGUIWindowMusicBase(int id, const CStdString &xmlFile)
: CGUIMediaWindow(id, xmlFile)
CGUIWindowMusicBase::CGUIWindowMusicBase(int id, const std::string &xmlFile)
: CGUIMediaWindow(id, xmlFile.c_str())
{
m_dlgProgress = NULL;
}
Expand Down Expand Up @@ -256,7 +256,7 @@ bool CGUIWindowMusicBase::OnAction(const CAction &action)
void CGUIWindowMusicBase::OnInfoAll(int iItem, bool bCurrent /* = false */, bool refresh /* = false */)
{
CMusicDatabaseDirectory dir;
CStdString strPath = m_vecItems->GetPath();
std::string strPath = m_vecItems->GetPath();
if (bCurrent)
strPath = m_vecItems->Get(iItem)->GetPath();

Expand Down Expand Up @@ -756,7 +756,7 @@ bool CGUIWindowMusicBase::OnContextButton(int itemNumber, CONTEXT_BUTTON button)

case CONTEXT_BUTTON_EDIT:
{
CStdString playlist = item->IsPlayList() ? item->GetPath() : m_vecItems->GetPath(); // save path as activatewindow will destroy our items
std::string playlist = item->IsPlayList() ? item->GetPath() : m_vecItems->GetPath(); // save path as activatewindow will destroy our items
g_windowManager.ActivateWindow(WINDOW_MUSIC_PLAYLIST_EDITOR, playlist);
// need to update
m_vecItems->RemoveDiscCache(GetID());
Expand All @@ -765,7 +765,7 @@ bool CGUIWindowMusicBase::OnContextButton(int itemNumber, CONTEXT_BUTTON button)

case CONTEXT_BUTTON_EDIT_SMART_PLAYLIST:
{
CStdString playlist = item->IsSmartPlayList() ? item->GetPath() : m_vecItems->GetPath(); // save path as activatewindow will destroy our items
std::string playlist = item->IsSmartPlayList() ? item->GetPath() : m_vecItems->GetPath(); // save path as activatewindow will destroy our items
if (CGUIDialogSmartPlaylistEditor::EditPlaylist(playlist, "music"))
Refresh(true); // need to update
return true;
Expand Down Expand Up @@ -882,7 +882,7 @@ void CGUIWindowMusicBase::PlayItem(int iItem)
}

/*
CStdString strPlayListDirectory = m_vecItems->GetPath();
std::string strPlayListDirectory = m_vecItems->GetPath();
URIUtils::RemoveSlashAtEnd(strPlayListDirectory);
*/

Expand Down Expand Up @@ -977,7 +977,7 @@ bool CGUIWindowMusicBase::OnPlayMedia(int iItem)
return CGUIMediaWindow::OnPlayMedia(iItem);
}

void CGUIWindowMusicBase::UpdateThumb(const CAlbum &album, const CStdString &path)
void CGUIWindowMusicBase::UpdateThumb(const CAlbum &album, const std::string &path)
{
// check user permissions
bool saveDb = album.idAlbum != -1;
Expand All @@ -988,10 +988,10 @@ void CGUIWindowMusicBase::UpdateThumb(const CAlbum &album, const CStdString &pat
saveDirThumb = false;
}

CStdString albumThumb = m_musicdatabase.GetArtForItem(album.idAlbum, MediaTypeAlbum, "thumb");
std::string albumThumb = m_musicdatabase.GetArtForItem(album.idAlbum, MediaTypeAlbum, "thumb");

// Update the thumb in the music database (songs + albums)
CStdString albumPath(path);
std::string albumPath(path);
if (saveDb && CFile::Exists(albumThumb))
m_musicdatabase.SaveAlbumThumb(album.idAlbum, albumThumb);

Expand Down Expand Up @@ -1067,7 +1067,7 @@ void CGUIWindowMusicBase::OnRetrieveMusicInfo(CFileItemList& items)
if (!bProgressVisible && elapsed>1500 && m_dlgProgress)
{ // tag loading takes more then 1.5 secs, show a progress dialog
CURL url(items.GetPath());
CStdString strStrippedPath = url.GetWithoutUserDetails();
std::string strStrippedPath = url.GetWithoutUserDetails();
m_dlgProgress->SetHeading(189);
m_dlgProgress->SetLine(0, 505);
m_dlgProgress->SetLine(1, "");
Expand Down Expand Up @@ -1138,9 +1138,11 @@ bool CGUIWindowMusicBase::GetDirectory(const std::string &strDirectory, CFileIte

bool CGUIWindowMusicBase::CheckFilterAdvanced(CFileItemList &items) const
{
CStdString content = items.GetContent();
std::string content = items.GetContent();
if ((items.IsMusicDb() || CanContainFilter(m_strFilterPath)) &&
(content.Equals("artists") || content.Equals("albums") || content.Equals("songs")))
(StringUtils::EqualsNoCase(content, "artists") ||
StringUtils::EqualsNoCase(content, "albums") ||
StringUtils::EqualsNoCase(content, "songs")))
return true;

return false;
Expand Down
4 changes: 2 additions & 2 deletions xbmc/music/windows/GUIWindowMusicBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
class CGUIWindowMusicBase : public CGUIMediaWindow
{
public:
CGUIWindowMusicBase(int id, const CStdString &xmlFile);
CGUIWindowMusicBase(int id, const std::string &xmlFile);
virtual ~CGUIWindowMusicBase(void);
virtual bool OnMessage(CGUIMessage& message);
virtual bool OnAction(const CAction &action);
Expand Down Expand Up @@ -88,7 +88,7 @@ class CGUIWindowMusicBase : public CGUIMediaWindow
bool ShowAlbumInfo(const CFileItem *pItem, bool bShowInfo = true);
void ShowArtistInfo(const CFileItem *pItem, bool bShowInfo = true);
void ShowSongInfo(CFileItem* pItem);
void UpdateThumb(const CAlbum &album, const CStdString &path);
void UpdateThumb(const CAlbum &album, const std::string &path);

void OnRipTrack(int iItem);
void OnSearch();
Expand Down
57 changes: 29 additions & 28 deletions xbmc/music/windows/GUIWindowMusicNav.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ bool CGUIWindowMusicNav::OnMessage(CGUIMessage& message)
SetProperty("search", selected.GetLabel());
return true;
}
CStdString search(GetProperty("search").asString());
std::string search(GetProperty("search").asString());
CGUIKeyboardFactory::ShowAndGetFilter(search, true);
SetProperty("search", search);
return true;
Expand Down Expand Up @@ -217,34 +217,35 @@ bool CGUIWindowMusicNav::OnAction(const CAction& action)
return CGUIWindowMusicBase::OnAction(action);
}

CStdString CGUIWindowMusicNav::GetQuickpathName(const CStdString& strPath) const
std::string CGUIWindowMusicNav::GetQuickpathName(const std::string& strPath) const
{
CStdString path = CLegacyPathTranslation::TranslateMusicDbPath(strPath);
if (path.Equals("musicdb://genres/"))
std::string path = CLegacyPathTranslation::TranslateMusicDbPath(strPath);
StringUtils::ToLower(path);
if (path == "musicdb://genres/")
return "Genres";
else if (path.Equals("musicdb://artists/"))
else if (path == "musicdb://artists/")
return "Artists";
else if (path.Equals("musicdb://albums/"))
else if (path == "musicdb://albums/")
return "Albums";
else if (path.Equals("musicdb://songs/"))
else if (path == "musicdb://songs/")
return "Songs";
else if (path.Equals("musicdb://top100/"))
else if (path == "musicdb://top100/")
return "Top100";
else if (path.Equals("musicdb://top100/songs/"))
else if (path == "musicdb://top100/songs/")
return "Top100Songs";
else if (path.Equals("musicdb://top100/albums/"))
else if (path == "musicdb://top100/albums/")
return "Top100Albums";
else if (path.Equals("musicdb://recentlyaddedalbums/"))
else if (path == "musicdb://recentlyaddedalbums/")
return "RecentlyAddedAlbums";
else if (path.Equals("musicdb://recentlyplayedalbums/"))
else if (path == "musicdb://recentlyplayedalbums/")
return "RecentlyPlayedAlbums";
else if (path.Equals("musicdb://compilations/"))
else if (path == "musicdb://compilations/")
return "Compilations";
else if (path.Equals("musicdb://years/"))
else if (path == "musicdb://years/")
return "Years";
else if (path.Equals("musicdb://singles/"))
else if (path == "musicdb://singles/")
return "Singles";
else if (path.Equals("special://musicplaylists/"))
else if (path == "special://musicplaylists/")
return "Playlists";
else
{
Expand All @@ -264,7 +265,7 @@ bool CGUIWindowMusicNav::OnClick(int iItem)
OnSearchUpdate();
else
{
CStdString search(GetProperty("search").asString());
std::string search(GetProperty("search").asString());
CGUIKeyboardFactory::ShowAndGetFilter(search, true);
SetProperty("search", search);
}
Expand Down Expand Up @@ -388,11 +389,11 @@ void CGUIWindowMusicNav::UpdateButtons()
StringUtils::StartsWith(m_vecItems->Get(m_vecItems->Size()-1)->GetPath(), "/-1/"))
iItems--;
}
CStdString items = StringUtils::Format("%i %s", iItems, g_localizeStrings.Get(127).c_str());
std::string items = StringUtils::Format("%i %s", iItems, g_localizeStrings.Get(127).c_str());
SET_CONTROL_LABEL(CONTROL_LABELFILES, items);

// set the filter label
CStdString strLabel;
std::string strLabel;

// "Playlists"
if (m_vecItems->IsPath("special://musicplaylists/"))
Expand All @@ -401,7 +402,7 @@ void CGUIWindowMusicNav::UpdateButtons()
else if (m_vecItems->IsPlayList())
{
// get playlist name from path
CStdString strDummy;
std::string strDummy;
URIUtils::Split(m_vecItems->GetPath(), strDummy, strLabel);
}
// everything else is from a musicdb:// path
Expand Down Expand Up @@ -561,7 +562,7 @@ void CGUIWindowMusicNav::GetContextButtons(int itemNumber, CContextButtons &butt
buttons.Add(CONTEXT_BUTTON_DELETE, 646);
}
}
if (inPlaylists && !URIUtils::GetFileName(item->GetPath()).Equals("PartyMode.xsp")
if (inPlaylists && URIUtils::GetFileName(item->GetPath()) != "PartyMode.xsp"
&& (item->IsPlayList() || item->IsSmartPlayList()))
buttons.Add(CONTEXT_BUTTON_DELETE, 117);

Expand Down Expand Up @@ -592,7 +593,7 @@ bool CGUIWindowMusicNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button)
long idArtist = m_musicdatabase.GetArtistByName(item->GetLabel());
if (idArtist == -1)
return false;
CStdString path = StringUtils::Format("musicdb://artists/%ld/", idArtist);
std::string path = StringUtils::Format("musicdb://artists/%ld/", idArtist);
CArtist artist;
m_musicdatabase.GetArtist(idArtist, artist, false);
*item = CFileItem(artist);
Expand All @@ -609,7 +610,7 @@ bool CGUIWindowMusicNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button)
long idAlbum = m_musicdatabase.GetAlbumByName(item->GetLabel());
if (idAlbum == -1)
return false;
CStdString path = StringUtils::Format("musicdb://albums/%ld/", idAlbum);
std::string path = StringUtils::Format("musicdb://albums/%ld/", idAlbum);
CAlbum album;
m_musicdatabase.GetAlbum(idAlbum, album, false);
*item = CFileItem(path,album);
Expand Down Expand Up @@ -649,7 +650,7 @@ bool CGUIWindowMusicNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button)

case CONTEXT_BUTTON_GO_TO_ARTIST:
{
CStdString strPath;
std::string strPath;
CVideoDatabase database;
database.Open();
strPath = StringUtils::Format("videodb://musicvideos/artists/%i/",
Expand Down Expand Up @@ -691,7 +692,7 @@ bool CGUIWindowMusicNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button)
case CONTEXT_BUTTON_SET_CONTENT:
{
ADDON::ScraperPtr scraper;
CStdString path(item->GetPath());
std::string path(item->GetPath());
CQueryParams params;
CDirectoryNode::GetDatabaseInfo(item->GetPath(), params);
CONTENT_TYPE content = CONTENT_ALBUMS;
Expand Down Expand Up @@ -738,7 +739,7 @@ bool CGUIWindowMusicNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button)

bool CGUIWindowMusicNav::GetSongsFromPlayList(const std::string& strPlayList, CFileItemList &items)
{
CStdString strParentPath=m_history.GetParentPath();
std::string strParentPath=m_history.GetParentPath();

if (m_guiState.get() && !m_guiState->HideParentDirItems())
{
Expand Down Expand Up @@ -777,10 +778,10 @@ void CGUIWindowMusicNav::DisplayEmptyDatabaseMessage(bool bDisplay)

void CGUIWindowMusicNav::OnSearchUpdate()
{
CStdString search(CURL::Encode(GetProperty("search").asString()));
std::string search(CURL::Encode(GetProperty("search").asString()));
if (!search.empty())
{
CStdString path = "musicsearch://" + search + "/";
std::string path = "musicsearch://" + search + "/";
m_history.ClearSearchHistory();
Update(path);
}
Expand Down
2 changes: 1 addition & 1 deletion xbmc/music/windows/GUIWindowMusicNav.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class CGUIWindowMusicNav : public CGUIWindowMusicBase, public IBackgroundLoaderO

bool GetSongsFromPlayList(const std::string& strPlayList, CFileItemList &items);
void DisplayEmptyDatabaseMessage(bool bDisplay);
CStdString GetQuickpathName(const CStdString& strPath) const;
std::string GetQuickpathName(const std::string& strPath) const;

VECSOURCES m_shares;

Expand Down
20 changes: 10 additions & 10 deletions xbmc/music/windows/GUIWindowMusicPlaylist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,18 +280,18 @@ bool CGUIWindowMusicPlayList::MoveCurrentPlayListItem(int iItem, int iAction, bo

void CGUIWindowMusicPlayList::SavePlayList()
{
CStdString strNewFileName;
std::string strNewFileName;
if (CGUIKeyboardFactory::ShowAndGetInput(strNewFileName, g_localizeStrings.Get(16012), false))
{
// need 2 rename it
CStdString strFolder = URIUtils::AddFileToFolder(CSettings::Get().GetString("system.playlistspath"), "music");
std::string strFolder = URIUtils::AddFileToFolder(CSettings::Get().GetString("system.playlistspath"), "music");
strNewFileName = CUtil::MakeLegalFileName(strNewFileName);
strNewFileName += ".m3u";
CStdString strPath = URIUtils::AddFileToFolder(strFolder, strNewFileName);
std::string strPath = URIUtils::AddFileToFolder(strFolder, strNewFileName);

// get selected item
int iItem = m_viewControl.GetSelectedItem();
CStdString strSelectedItem = "";
std::string strSelectedItem = "";
if (iItem >= 0 && iItem < m_vecItems->Size())
{
CFileItemPtr pItem = m_vecItems->Get(iItem);
Expand All @@ -301,7 +301,7 @@ void CGUIWindowMusicPlayList::SavePlayList()
}
}

CStdString strOldDirectory = m_vecItems->GetPath();
std::string strOldDirectory = m_vecItems->GetPath();
m_history.SetSelectedItem(strSelectedItem, strOldDirectory);

CPlayListM3U playlist;
Expand Down Expand Up @@ -406,7 +406,7 @@ void CGUIWindowMusicPlayList::UpdateButtons()
SET_CONTROL_LABEL(CONTROL_BTNREPEAT, g_localizeStrings.Get(iRepeat));

// Update object count label
CStdString items = StringUtils::Format("%i %s", m_vecItems->GetObjectCount(), g_localizeStrings.Get(127).c_str());
std::string items = StringUtils::Format("%i %s", m_vecItems->GetObjectCount(), g_localizeStrings.Get(127).c_str());
SET_CONTROL_LABEL(CONTROL_LABELFILES, items);

MarkPlaying();
Expand Down Expand Up @@ -446,10 +446,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();
CStdString strTrackLeft=CSettings::Get().GetString("musicfiles.nowplayingtrackformat");
std::string strTrackLeft=CSettings::Get().GetString("musicfiles.nowplayingtrackformat");
if (strTrackLeft.empty())
strTrackLeft = CSettings::Get().GetString("musicfiles.trackformat");
CStdString strTrackRight=CSettings::Get().GetString("musicfiles.nowplayingtrackformatright");
std::string strTrackRight=CSettings::Get().GetString("musicfiles.nowplayingtrackformatright");
if (strTrackRight.empty())
strTrackRight = CSettings::Get().GetString("musicfiles.trackformatright");
CLabelFormatter formatter(strTrackLeft, strTrackRight);
Expand All @@ -470,7 +470,7 @@ void CGUIWindowMusicPlayList::OnItemLoaded(CFileItem* pItem)
// currently it is hacked into m_iprogramCount

// No music info and it's not CDDA so we'll just show the filename
CStdString str;
std::string str;
str = CUtil::GetTitleFromPath(pItem->GetPath());
str = StringUtils::Format("%02.2i. %s ", pItem->m_iprogramCount, str.c_str());
pItem->SetLabel(str);
Expand Down Expand Up @@ -599,7 +599,7 @@ bool CGUIWindowMusicPlayList::OnContextButton(int itemNumber, CONTEXT_BUTTON but

case CONTEXT_BUTTON_EDIT_PARTYMODE:
{
CStdString playlist = CProfilesManager::Get().GetUserDataItem("PartyMode.xsp");
std::string playlist = CProfilesManager::Get().GetUserDataItem("PartyMode.xsp");
if (CGUIDialogSmartPlaylistEditor::EditPlaylist(playlist))
{
// apply new rules
Expand Down
12 changes: 6 additions & 6 deletions xbmc/music/windows/GUIWindowMusicPlaylistEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ void CGUIWindowMusicPlaylistEditor::UpdateButtons()
CGUIWindowMusicBase::UpdateButtons();

// Update object count label
CStdString items = StringUtils::Format("%i %s", m_vecItems->GetObjectCount(), g_localizeStrings.Get(127).c_str()); // " 14 Objects"
std::string items = StringUtils::Format("%i %s", m_vecItems->GetObjectCount(), g_localizeStrings.Get(127).c_str()); // " 14 Objects"
SET_CONTROL_LABEL(CONTROL_LABELFILES, items);
}

Expand Down Expand Up @@ -256,7 +256,7 @@ void CGUIWindowMusicPlaylistEditor::UpdatePlaylist()
OnMessage(msg);

// indicate how many songs we have
CStdString items = StringUtils::Format("%i %s", m_playlist->Size(), g_localizeStrings.Get(134).c_str()); // "123 Songs"
std::string items = StringUtils::Format("%i %s", m_playlist->Size(), g_localizeStrings.Get(134).c_str()); // "123 Songs"
SET_CONTROL_LABEL(CONTROL_LABEL_PLAYLIST, items);

m_playlistThumbLoader.Load(*m_playlist);
Expand Down Expand Up @@ -355,7 +355,7 @@ bool CGUIWindowMusicPlaylistEditor::OnContextButton(int itemNumber, CONTEXT_BUTT
void CGUIWindowMusicPlaylistEditor::OnLoadPlaylist()
{
// prompt user for file to load
CStdString playlist;
std::string playlist;
VECSOURCES shares;
m_rootDir.GetSources(shares);
// add the playlist share
Expand Down Expand Up @@ -391,15 +391,15 @@ void CGUIWindowMusicPlaylistEditor::LoadPlaylist(const std::string &playlist)
void CGUIWindowMusicPlaylistEditor::OnSavePlaylist()
{
// saves playlist to the playlist folder
CStdString name = URIUtils::GetFileName(m_strLoadedPlaylist);
std::string name = URIUtils::GetFileName(m_strLoadedPlaylist);
URIUtils::RemoveExtension(name);

if (CGUIKeyboardFactory::ShowAndGetInput(name, g_localizeStrings.Get(16012), false))
{ // save playlist as an .m3u
PLAYLIST::CPlayListM3U playlist;
playlist.Add(*m_playlist);
CStdString strBase = URIUtils::AddFileToFolder(CSettings::Get().GetString("system.playlistspath"), "music");
CStdString path = URIUtils::AddFileToFolder(strBase, name + ".m3u");
std::string strBase = URIUtils::AddFileToFolder(CSettings::Get().GetString("system.playlistspath"), "music");
std::string path = URIUtils::AddFileToFolder(strBase, name + ".m3u");
playlist.Save(path);
m_strLoadedPlaylist = name;
}
Expand Down
Loading

0 comments on commit ddfcf24

Please sign in to comment.