bool CGUIWindowVideoNav::OnClick(int iItem, const std::string &player) { CFileItemPtr item = m_vecItems->Get(iItem); if (!item->m_bIsFolder && item->IsVideoDb() && !item->Exists()) { CLog::Log(LOGDEBUG, "%s called on '%s' but file doesn't exist", __FUNCTION__, item->GetPath().c_str()); if (CProfilesManager::GetInstance().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser) { if (!CGUIDialogVideoInfo::DeleteVideoItemFromDatabase(item, true)) return true; // update list Refresh(true); m_viewControl.SetSelectedItem(iItem); return true; } else { CGUIDialogOK::ShowAndGetInput(CVariant{257}, CVariant{662}); return true; } } else if (StringUtils::StartsWithNoCase(item->GetPath(), "newtag://")) { // dont allow update while scanning if (g_application.IsVideoScanning()) { CGUIDialogOK::ShowAndGetInput(CVariant{257}, CVariant{14057}); return true; } //Get the new title std::string strTag; if (!CGUIKeyboardFactory::ShowAndGetInput(strTag, CVariant{g_localizeStrings.Get(20462)}, false)) return true; CVideoDatabase videodb; if (!videodb.Open()) return true; // get the media type and convert from plural to singular (by removing the trailing "s") std::string mediaType = item->GetPath().substr(9); mediaType = mediaType.substr(0, mediaType.size() - 1); std::string localizedType = CGUIDialogVideoInfo::GetLocalizedVideoType(mediaType); if (localizedType.empty()) return true; if (!videodb.GetSingleValue("tag", "tag.tag_id", videodb.PrepareSQL("tag.name = '%s' AND tag.tag_id IN (SELECT tag_link.tag_id FROM tag_link WHERE tag_link.media_type = '%s')", strTag.c_str(), mediaType.c_str())).empty()) { std::string strError = StringUtils::Format(g_localizeStrings.Get(20463).c_str(), strTag.c_str()); CGUIDialogOK::ShowAndGetInput(CVariant{20462}, CVariant{std::move(strError)}); return true; } int idTag = videodb.AddTag(strTag); CFileItemList items; std::string strLabel = StringUtils::Format(g_localizeStrings.Get(20464).c_str(), localizedType.c_str()); if (CGUIDialogVideoInfo::GetItemsForTag(strLabel, mediaType, items, idTag)) { for (int index = 0; index < items.Size(); index++) { if (!items[index]->HasVideoInfoTag() || items[index]->GetVideoInfoTag()->m_iDbId <= 0) continue; videodb.AddTagToItem(items[index]->GetVideoInfoTag()->m_iDbId, idTag, mediaType); } } Refresh(true); return true; } return CGUIWindowVideoBase::OnClick(iItem, player); }
bool CGUIWindowVideoNav::OnClick(int iItem) { CFileItemPtr item = m_vecItems->Get(iItem); if (!item->m_bIsFolder && item->IsVideoDb() && !item->Exists()) { CLog::Log(LOGDEBUG, "%s called on '%s' but file doesn't exist", __FUNCTION__, item->GetPath().c_str()); if (!CGUIDialogVideoInfo::DeleteVideoItemFromDatabase(item, true)) return true; // update list Refresh(true); m_viewControl.SetSelectedItem(iItem); return true; } else if (StringUtils::StartsWithNoCase(item->GetPath(), "newtag://")) { // dont allow update while scanning if (g_application.IsVideoScanning()) { CGUIDialogOK::ShowAndGetInput(257, 0, 14057, 0); return true; } //Get the new title CStdString strTag; if (!CGUIKeyboardFactory::ShowAndGetInput(strTag, g_localizeStrings.Get(20462), false)) return true; CVideoDatabase videodb; if (!videodb.Open()) return true; // get the media type and convert from plural to singular (by removing the trailing "s") CStdString mediaType = item->GetPath().substr(9); mediaType = mediaType.substr(0, mediaType.size() - 1); CStdString localizedType = CGUIDialogVideoInfo::GetLocalizedVideoType(mediaType); if (localizedType.empty()) return true; if (!videodb.GetSingleValue("tag", "tag.idTag", videodb.PrepareSQL("tag.strTag = '%s' AND tag.idTag IN (SELECT taglinks.idTag FROM taglinks WHERE taglinks.media_type = '%s')", strTag.c_str(), mediaType.c_str())).empty()) { CStdString strError = StringUtils::Format(g_localizeStrings.Get(20463), strTag.c_str()); CGUIDialogOK::ShowAndGetInput(20462, "", strError, ""); return true; } int idTag = videodb.AddTag(strTag); CFileItemList items; CStdString strLabel = StringUtils::Format(g_localizeStrings.Get(20464), localizedType.c_str()); if (CGUIDialogVideoInfo::GetItemsForTag(strLabel, mediaType, items, idTag)) { for (int index = 0; index < items.Size(); index++) { if (!items[index]->HasVideoInfoTag() || items[index]->GetVideoInfoTag()->m_iDbId <= 0) continue; videodb.AddTagToItem(items[index]->GetVideoInfoTag()->m_iDbId, idTag, mediaType); } } Refresh(true); return true; } return CGUIWindowVideoBase::OnClick(iItem); }