bool CProfilesManager::DeleteProfile(size_t index) { CSingleLock lock(m_critical); const CProfile *profile = GetProfile(index); if (profile == NULL) return false; CGUIDialogYesNo* dlgYesNo = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogYesNo>(WINDOW_DIALOG_YES_NO); if (dlgYesNo == NULL) return false; std::string str = g_localizeStrings.Get(13201); dlgYesNo->SetHeading(CVariant{13200}); dlgYesNo->SetLine(0, CVariant{StringUtils::Format(str.c_str(), profile->getName().c_str())}); dlgYesNo->SetLine(1, CVariant{""}); dlgYesNo->SetLine(2, CVariant{""}); dlgYesNo->Open(); if (!dlgYesNo->IsConfirmed()) return false; // fall back to master profile if necessary if ((int)index == m_autoLoginProfile) m_autoLoginProfile = 0; // delete profile std::string strDirectory = profile->getDirectory(); m_profiles.erase(m_profiles.begin() + index); // fall back to master profile if necessary if (index == m_currentProfile) { LoadProfile(0); m_settings.Save(); } CFileItemPtr item = CFileItemPtr(new CFileItem(URIUtils::AddFileToFolder(GetUserDataFolder(), strDirectory))); item->SetPath(URIUtils::AddFileToFolder(GetUserDataFolder(), strDirectory + "/")); item->m_bIsFolder = true; item->Select(true); CGUIComponent *gui = CServiceBroker::GetGUI(); if (gui && gui->ConfirmDelete(item->GetPath())) CFileUtils::DeleteItem(item); return Save(); }
bool CGUIWindowMusicNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button) { CFileItemPtr item; if (itemNumber >= 0 && itemNumber < m_vecItems->Size()) item = m_vecItems->Get(itemNumber); switch (button) { case CONTEXT_BUTTON_INFO: { if (!item->IsVideoDb()) return CGUIWindowMusicBase::OnContextButton(itemNumber,button); // music videos - artists if (StringUtils::StartsWithNoCase(item->GetPath(), "videodb://musicvideos/artists/")) { long idArtist = m_musicdatabase.GetArtistByName(item->GetLabel()); if (idArtist == -1) return false; std::string path = StringUtils::Format("musicdb://artists/%ld/", idArtist); CArtist artist; m_musicdatabase.GetArtist(idArtist, artist, false); *item = CFileItem(artist); item->SetPath(path); CGUIWindowMusicBase::OnContextButton(itemNumber,button); Refresh(); m_viewControl.SetSelectedItem(itemNumber); return true; } // music videos - albums if (StringUtils::StartsWithNoCase(item->GetPath(), "videodb://musicvideos/albums/")) { long idAlbum = m_musicdatabase.GetAlbumByName(item->GetLabel()); if (idAlbum == -1) return false; std::string path = StringUtils::Format("musicdb://albums/%ld/", idAlbum); CAlbum album; m_musicdatabase.GetAlbum(idAlbum, album, false); *item = CFileItem(path,album); item->SetPath(path); CGUIWindowMusicBase::OnContextButton(itemNumber,button); Refresh(); m_viewControl.SetSelectedItem(itemNumber); return true; } if (item->HasVideoInfoTag() && !item->GetVideoInfoTag()->m_strTitle.empty()) { CGUIDialogVideoInfo::ShowFor(*item); Refresh(); } return true; } case CONTEXT_BUTTON_INFO_ALL: OnItemInfoAll(m_vecItems->GetPath()); return true; case CONTEXT_BUTTON_SET_DEFAULT: CServiceBroker::GetSettings()->SetString(CSettings::SETTING_MYMUSIC_DEFAULTLIBVIEW, GetQuickpathName(item->GetPath())); CServiceBroker::GetSettings()->Save(); return true; case CONTEXT_BUTTON_CLEAR_DEFAULT: CServiceBroker::GetSettings()->SetString(CSettings::SETTING_MYMUSIC_DEFAULTLIBVIEW, ""); CServiceBroker::GetSettings()->Save(); return true; case CONTEXT_BUTTON_GO_TO_ARTIST: { std::string strPath; CVideoDatabase database; database.Open(); strPath = StringUtils::Format("videodb://musicvideos/artists/%i/", database.GetMatchingMusicVideo(item->GetMusicInfoTag()->GetArtistString())); CServiceBroker::GetGUI()->GetWindowManager().ActivateWindow(WINDOW_VIDEO_NAV,strPath); return true; } case CONTEXT_BUTTON_PLAY_OTHER: { CVideoDatabase database; database.Open(); CVideoInfoTag details; database.GetMusicVideoInfo("", details, database.GetMatchingMusicVideo(item->GetMusicInfoTag()->GetArtistString(), item->GetMusicInfoTag()->GetAlbum(), item->GetMusicInfoTag()->GetTitle())); CApplicationMessenger::GetInstance().PostMsg(TMSG_MEDIA_PLAY, 0, 0, static_cast<void*>(new CFileItem(details))); return true; } case CONTEXT_BUTTON_RENAME: if (!item->IsVideoDb() && !item->IsReadOnly()) OnRenameItem(itemNumber); CGUIDialogVideoInfo::UpdateVideoItemTitle(item); CUtil::DeleteVideoDatabaseDirectoryCache(); Refresh(); return true; case CONTEXT_BUTTON_DELETE: if (item->IsPlayList() || item->IsSmartPlayList()) { item->m_bIsFolder = false; CGUIComponent *gui = CServiceBroker::GetGUI(); if (gui && gui->ConfirmDelete(item->GetPath())) CFileUtils::DeleteItem(item); } else if (!item->IsVideoDb()) OnDeleteItem(itemNumber); else { CGUIDialogVideoInfo::DeleteVideoItemFromDatabase(item); CUtil::DeleteVideoDatabaseDirectoryCache(); } Refresh(); return true; case CONTEXT_BUTTON_SET_CONTENT: return ManageInfoProvider(item); default: break; } return CGUIWindowMusicBase::OnContextButton(itemNumber, button); }