else if (!items.IsVirtualDirectoryRoot())
{ // load info from the database
CStdString label;
- if (items.GetLabel().IsEmpty() && m_rootDir.IsSource(items.GetPath(), CMediaSourceSettings::Get().GetSources("video"), &label))
+ if (items.GetLabel().empty() && m_rootDir.IsSource(items.GetPath(), CMediaSourceSettings::Get().GetSources("video"), &label))
items.SetLabel(label);
if (!items.IsSourcesPath())
LoadVideoInfo(items);
{
// TODO: this could possibly be threaded as per the music info loading,
// we could also cache the info
- if (!items.GetContent().IsEmpty() && !items.IsPlugin())
+ if (!items.GetContent().empty() && !items.IsPlugin())
return; // don't load for listings that have content set and weren't created from plugins
CStdString content = items.GetContent();
// determine content only if it isn't set
- if (content.IsEmpty())
+ if (content.empty())
{
content = database.GetContentForPath(items.GetPath());
- items.SetContent(content.IsEmpty() ? "files" : content);
+ items.SetContent(content.empty() ? "files" : content);
}
/*
/* NOTE: In the future when GetItemsForPath returns all items regardless of whether they're "in the library"
we won't need the fetchedPlayCounts code, and can "simply" do this directly on absense of content. */
bool fetchedPlayCounts = false;
- if (!content.IsEmpty())
+ if (!content.empty())
{
database.GetItemsForPath(content, items.GetPath(), dbItems);
dbItems.SetFastLookup(true);
{
CFileItemPtr pItem = items[i];
CFileItemPtr match;
- if (!content.IsEmpty()) /* optical media will be stacked down, so it's path won't match the base path */
+ if (!content.empty()) /* optical media will be stacked down, so it's path won't match the base path */
match = dbItems.Get(pItem->IsOpticalMediaFile() ? pItem->GetLocalMetadataPath() : pItem->GetPath());
if (match)
{
StringUtils::StartsWith(m_vecItems->Get(m_vecItems->Size()-1)->GetPath(), "/-1/"))
iItems--;
}
- CStdString items;
- items.Format("%i %s", iItems, g_localizeStrings.Get(127).c_str());
+ CStdString items = StringUtils::Format("%i %s", iItems, g_localizeStrings.Get(127).c_str());
SET_CONTROL_LABEL(CONTROL_LABELFILES, items);
// set the filter label
CGUIWindowVideoBase::OnInfo(pItem,scraper);
}
-bool CGUIWindowVideoNav::CanDelete(const CStdString& strPath)
-{
- CQueryParams params;
- CVideoDatabaseDirectory::GetQueryParams(strPath,params);
-
- if (params.GetMovieId() != -1 ||
- params.GetEpisodeId() != -1 ||
- params.GetMVideoId() != -1 ||
- (params.GetTvShowId() != -1 && params.GetSeason() <= -1
- && !CVideoDatabaseDirectory::IsAllItem(strPath)))
- return true;
-
- return false;
-}
-
void CGUIWindowVideoNav::OnDeleteItem(CFileItemPtr pItem)
{
if (m_vecItems->IsParentFolder())
{
CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO);
pDialog->SetHeading(432);
- CStdString strLabel;
- strLabel.Format(g_localizeStrings.Get(433),pItem->GetLabel());
+ CStdString strLabel = StringUtils::Format(g_localizeStrings.Get(433),pItem->GetLabel().c_str());
pDialog->SetLine(1, strLabel);
pDialog->SetLine(2, "");;
pDialog->DoModal();
{
CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO);
pDialog->SetHeading(432);
- CStdString strLabel;
- strLabel.Format(g_localizeStrings.Get(433), pItem->GetLabel());
+ CStdString strLabel = StringUtils::Format(g_localizeStrings.Get(433), pItem->GetLabel().c_str());
pDialog->SetLine(1, strLabel);
pDialog->SetLine(2, "");
pDialog->DoModal();
}
else
{
- if (!DeleteItem(pItem.get()))
+ if (!CGUIDialogVideoInfo::DeleteVideoItem(pItem))
return;
-
- CStdString strDeletePath;
- if (pItem->m_bIsFolder)
- strDeletePath=pItem->GetVideoInfoTag()->m_strPath;
- else
- strDeletePath=pItem->GetVideoInfoTag()->m_strFileNameAndPath;
-
- if (URIUtils::GetFileName(strDeletePath).Equals("VIDEO_TS.IFO"))
- {
- strDeletePath = URIUtils::GetDirectory(strDeletePath);
- if (StringUtils::EndsWithNoCase(strDeletePath, "video_ts/"))
- {
- URIUtils::RemoveSlashAtEnd(strDeletePath);
- strDeletePath = URIUtils::GetDirectory(strDeletePath);
- }
- }
- if (URIUtils::HasSlashAtEnd(strDeletePath))
- pItem->m_bIsFolder=true;
-
- if (CSettings::Get().GetBool("filelists.allowfiledeletion") &&
- CUtil::SupportsWriteFileOperations(strDeletePath))
- {
- pItem->SetPath(strDeletePath);
- CGUIWindowVideoBase::OnDeleteItem(pItem);
- }
}
CUtil::DeleteVideoDatabaseDirectoryCache();
}
-bool CGUIWindowVideoNav::DeleteItem(CFileItem* pItem, bool bUnavailable /* = false */)
-{
- if (!pItem->HasVideoInfoTag() || !CanDelete(pItem->GetPath()))
- return false;
-
- VIDEODB_CONTENT_TYPE iType=VIDEODB_CONTENT_MOVIES;
- if (pItem->HasVideoInfoTag() && !pItem->GetVideoInfoTag()->m_strShowTitle.IsEmpty())
- iType = VIDEODB_CONTENT_TVSHOWS;
- if (pItem->HasVideoInfoTag() && pItem->GetVideoInfoTag()->m_iSeason > -1 && !pItem->m_bIsFolder)
- iType = VIDEODB_CONTENT_EPISODES;
- if (pItem->HasVideoInfoTag() && !pItem->GetVideoInfoTag()->m_artist.empty())
- iType = VIDEODB_CONTENT_MUSICVIDEOS;
-
- // dont allow update while scanning
- if (g_application.IsVideoScanning())
- {
- CGUIDialogOK::ShowAndGetInput(257, 0, 14057, 0);
- return false;
- }
-
-
- CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO);
- if (!pDialog)
- return false;
- if (iType == VIDEODB_CONTENT_MOVIES)
- pDialog->SetHeading(432);
- if (iType == VIDEODB_CONTENT_EPISODES)
- pDialog->SetHeading(20362);
- if (iType == VIDEODB_CONTENT_TVSHOWS)
- pDialog->SetHeading(20363);
- if (iType == VIDEODB_CONTENT_MUSICVIDEOS)
- pDialog->SetHeading(20392);
-
- if(bUnavailable)
- {
- pDialog->SetLine(0, g_localizeStrings.Get(662));
- pDialog->SetLine(1, g_localizeStrings.Get(663));
- pDialog->SetLine(2, "");;
- pDialog->DoModal();
- }
- else
- {
- CStdString strLine;
- strLine.Format(g_localizeStrings.Get(433),pItem->GetLabel());
- pDialog->SetLine(0, strLine);
- pDialog->SetLine(1, "");
- pDialog->SetLine(2, "");;
- pDialog->DoModal();
- }
-
- if (!pDialog->IsConfirmed())
- return false;
-
- CStdString path;
- CVideoDatabase database;
- database.Open();
-
- database.GetFilePathById(pItem->GetVideoInfoTag()->m_iDbId, path, iType);
- if (path.IsEmpty())
- return false;
- if (iType == VIDEODB_CONTENT_MOVIES)
- database.DeleteMovie(path);
- if (iType == VIDEODB_CONTENT_EPISODES)
- database.DeleteEpisode(path, pItem->GetVideoInfoTag()->m_iDbId);
- if (iType == VIDEODB_CONTENT_TVSHOWS)
- database.DeleteTvShow(path);
- if (iType == VIDEODB_CONTENT_MUSICVIDEOS)
- database.DeleteMusicVideo(path);
-
- if (iType == VIDEODB_CONTENT_TVSHOWS)
- database.SetPathHash(path,"");
- else
- database.SetPathHash(URIUtils::GetDirectory(path), "");
-
- return true;
-}
-
-void CGUIWindowVideoNav::OnPrepareFileItems(CFileItemList &items)
-{
- CGUIWindowVideoBase::OnPrepareFileItems(items);
-}
-
void CGUIWindowVideoNav::GetContextButtons(int itemNumber, CContextButtons &buttons)
{
CFileItemPtr item;
buttons.Add(CONTEXT_BUTTON_SCAN, 13349);
}
if (!item->IsPlugin() && !item->IsScript() && !item->IsLiveTV() && !item->IsAddonsPath() &&
- item->GetPath() != "sources://video/" && item->GetPath() != "special://videoplaylists/" &&
- item->GetPath().Left(19) != "newsmartplaylist://" && item->GetPath().Left(14) != "newplaylist://" &&
- item->GetPath().Left(9) != "newtag://")
+ item->GetPath() != "sources://video/" &&
+ item->GetPath() != "special://videoplaylists/" &&
+ !StringUtils::StartsWith(item->GetPath(), "newsmartplaylist://") &&
+ !StringUtils::StartsWith(item->GetPath(), "newplaylist://") &&
+ !StringUtils::StartsWith(item->GetPath(), "newtag://"))
{
if (item->m_bIsFolder)
{
{
std::string mediaType = videoUrl.GetItemType();
- CStdString strLabelAdd; strLabelAdd.Format(g_localizeStrings.Get(20460), GetLocalizedType(videoUrl.GetItemType()).c_str());
- CStdString strLabelRemove; strLabelRemove.Format(g_localizeStrings.Get(20461), GetLocalizedType(videoUrl.GetItemType()).c_str());
+ CStdString strLabelAdd = StringUtils::Format(g_localizeStrings.Get(20460), GetLocalizedType(videoUrl.GetItemType()).c_str());
+ CStdString strLabelRemove = StringUtils::Format(g_localizeStrings.Get(20461), GetLocalizedType(videoUrl.GetItemType()).c_str());
buttons.Add(CONTEXT_BUTTON_TAGS_ADD_ITEMS, strLabelAdd);
buttons.Add(CONTEXT_BUTTON_TAGS_REMOVE_ITEMS, strLabelRemove);
buttons.Add(CONTEXT_BUTTON_DELETE, 646);
else
buttons.Add(CONTEXT_BUTTON_SET_ACTOR_THUMB, 20403);
}
- if (item->IsVideoDb() && item->HasVideoInfoTag() &&
- (!item->m_bIsFolder || node == NODE_TYPE_TITLE_TVSHOWS))
- buttons.Add(CONTEXT_BUTTON_DELETE, 646);
}
if (!m_vecItems->IsVideoDb() && !m_vecItems->IsVirtualDirectoryRoot())
else if ((artType == "poster" || artType == "banner") && currentArt.find("thumb") != currentArt.end())
currentThumb = currentArt["thumb"];
}
- if (!currentThumb.IsEmpty())
+ if (!currentThumb.empty())
{
CFileItemPtr item(new CFileItem("thumb://Current", false));
item->SetArt("thumb", currentThumb);
for (unsigned int i = 0; i < thumbs.size(); i++)
{
- CStdString strItemPath;
- strItemPath.Format("thumb://Remote%i",i);
+ CStdString strItemPath = StringUtils::Format("thumb://Remote%i",i);
CFileItemPtr item(new CFileItem(strItemPath, false));
item->SetArt("thumb", thumbs[i]);
item->SetIconImage("DefaultPicture.png");
// delete the thumbnail if that's what the user wants, else overwrite with the
// new thumbnail
- if (result.Left(14) == "thumb://Remote")
+ if (StringUtils::StartsWith(result, "thumb://Remote"))
{
- int number = atoi(result.Mid(14));
+ int number = atoi(result.substr(14).c_str());
result = thumbs[number];
}
else if (result == "thumb://None")
CFileItemList items;
CStdString localizedType = GetLocalizedType(mediaType);
- CStdString strLabel; strLabel.Format(g_localizeStrings.Get(20464), localizedType.c_str());
+ CStdString strLabel = StringUtils::Format(g_localizeStrings.Get(20464), localizedType.c_str());
if (!GetItemsForTag(strLabel, mediaType, items, item->GetVideoInfoTag()->m_iDbId))
return true;
CFileItemList items;
CStdString localizedType = GetLocalizedType(mediaType);
- CStdString strLabel; strLabel.Format(g_localizeStrings.Get(20464), localizedType.c_str());
+ CStdString strLabel = StringUtils::Format(g_localizeStrings.Get(20464), localizedType.c_str());
if (!GetItemsForTag(strLabel, mediaType, items, item->GetVideoInfoTag()->m_iDbId, false))
return true;
CStdString strPath;
CMusicDatabase database;
database.Open();
- strPath.Format("musicdb://artists/%ld/",database.GetArtistByName(StringUtils::Join(m_vecItems->Get(itemNumber)->GetVideoInfoTag()->m_artist, g_advancedSettings.m_videoItemSeparator)));
+ strPath = StringUtils::Format("musicdb://artists/%ld/",
+ database.GetArtistByName(StringUtils::Join(m_vecItems->Get(itemNumber)->GetVideoInfoTag()->m_artist, g_advancedSettings.m_videoItemSeparator)));
g_windowManager.ActivateWindow(WINDOW_MUSIC_NAV,strPath);
return true;
}
CStdString strPath;
CMusicDatabase database;
database.Open();
- strPath.Format("musicdb://albums/%ld/",database.GetAlbumByName(m_vecItems->Get(itemNumber)->GetVideoInfoTag()->m_strAlbum));
+ strPath = StringUtils::Format("musicdb://albums/%ld/",
+ database.GetAlbumByName(m_vecItems->Get(itemNumber)->GetVideoInfoTag()->m_strAlbum));
g_windowManager.ActivateWindow(WINDOW_MUSIC_NAV,strPath);
return true;
}
if (result.Equals("fanart://None") || !CFile::Exists(result))
result.clear();
- if (!result.IsEmpty() && flip)
- result = CTextureCache::GetWrappedImageURL(result, "", "flipped");
+ if (!result.empty() && flip)
+ result = CTextureUtils::GetWrappedImageURL(result, "", "flipped");
// update the db
CVideoDatabase db;
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 (!DeleteItem(item.get(), true))
+ if (!CGUIDialogVideoInfo::DeleteVideoItemFromDatabase(item, true))
return true;
// update list
return true;
// get the media type and convert from plural to singular (by removing the trailing "s")
- CStdString mediaType = item->GetPath().Mid(9);
- mediaType = mediaType.Left(mediaType.size() - 1);
+ CStdString mediaType = item->GetPath().substr(9);
+ mediaType = mediaType.substr(0, mediaType.size() - 1);
CStdString localizedType = GetLocalizedType(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; strError.Format(g_localizeStrings.Get(20463), strTag.c_str());
+ 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; strLabel.Format(g_localizeStrings.Get(20464), localizedType.c_str());
+ CStdString strLabel = StringUtils::Format(g_localizeStrings.Get(20464), localizedType.c_str());
if (GetItemsForTag(strLabel, mediaType, items, idTag))
{
for (int index = 0; index < items.Size(); index++)