}
else
{ // load info from the database
+ CStdString label;
+ if (items.GetLabel().IsEmpty() && m_rootDir.IsSource(items.m_strPath, g_settings.GetSourcesFromType("video"), &label))
+ items.SetLabel(label);
LoadVideoInfo(items);
}
}
{
// TODO: this could possibly be threaded as per the music info loading,
// we could also cache the info
+ if (!items.GetContent().IsEmpty())
+ return; // don't load for listings that have content set
+
CStdString content = m_database.GetContentForPath(items.m_strPath);
- items.SetContent(content);
+ items.SetContent(content.IsEmpty() ? "files" : content);
bool clean = (g_guiSettings.GetBool("myvideos.cleanstrings") &&
!items.IsVirtualDirectoryRoot() &&
m_stackingAvailable);
- if (!content.IsEmpty())
+ CFileItemList dbItems;
+ if (content.IsEmpty())
+ m_database.GetPlayCounts(items);
+ else
{
- for (int i = 0; i < items.Size(); i++)
+ m_database.GetItemsForPath(content, items.m_strPath, dbItems);
+ dbItems.SetFastLookup(true);
+ }
+ for (int i = 0; i < items.Size(); i++)
+ {
+ CFileItemPtr pItem = items[i];
+ CFileItemPtr match;
+ if (!content.IsEmpty())
+ match = dbItems.Get(pItem->m_strPath);
+ if (match)
{
- CFileItemPtr pItem = items[i];
- CFileItem item;
- if (m_database.GetItemForPath(content, pItem->m_strPath, item))
- { // copy info across
- pItem->UpdateInfo(item);
- // TODO: we may wish to use a playable_url parameter here rather than
- // switching the path of the item (eg movie as a folder)
- pItem->m_strPath = item.m_strPath;
- pItem->m_bIsFolder = item.m_bIsFolder;
+ CStdString label (pItem->GetLabel ());
+ CStdString label2(pItem->GetLabel2());
+ pItem->UpdateInfo(*match);
+
+ if(g_settings.m_videoStacking && m_stackingAvailable)
+ {
+ if (match->m_bIsFolder)
+ pItem->m_strPath = match->GetVideoInfoTag()->m_strPath;
+ else
+ pItem->m_strPath = match->GetVideoInfoTag()->m_strFileNameAndPath;
+ // if we switch from a file to a folder item it means we really shouldn't be sorting files and
+ // folders separately
+ if (pItem->m_bIsFolder != match->m_bIsFolder)
+ items.SetSortIgnoreFolders(true);
+ pItem->m_bIsFolder = match->m_bIsFolder;
}
else
{
- if (clean)
- pItem->CleanString();
+ if (CFile::Exists(match->GetCachedFanart()))
+ pItem->SetProperty("fanart_image", match->GetCachedFanart());
+ pItem->SetLabel (label);
+ pItem->SetLabel2(label);
}
}
- }
- else
- {
- for (int i = 0; i < items.Size(); i++)
- {
- CFileItemPtr pItem = items[i];
- int playCount = m_database.GetPlayCount(*pItem);
- if (playCount >= 0)
- pItem->SetOverlayImage(CGUIListItem::ICON_OVERLAY_UNWATCHED, playCount > 0);
+ else
+ { // set the watched overlay (note: items in a folder with content set that aren't in the db
+ // won't get picked up here - in the future all items will be returned)
+ // and clean the label
+ if (pItem->HasVideoInfoTag())
+ pItem->SetOverlayImage(CGUIListItem::ICON_OVERLAY_UNWATCHED, pItem->GetVideoInfoTag()->m_playCount > 0);
if (clean)
pItem->CleanString();
}
buttons.Add(CONTEXT_BUTTON_RENAME, 118);
}
// add "Set/Change content" to folders
- if (item->m_bIsFolder && !item->IsPlayList() && !item->IsLiveTV() && !item->IsPlugin() && !item->IsAddonsPath())
+ if (item->m_bIsFolder && !item->IsPlayList() && !item->IsSmartPlayList() && !item->IsLiveTV() && !item->IsPlugin() && !item->IsAddonsPath())
{
CGUIDialogVideoScan *pScanDlg = (CGUIDialogVideoScan *)g_windowManager.GetWindow(WINDOW_DIALOG_VIDEO_SCAN);
if (!pScanDlg || (pScanDlg && !pScanDlg->IsScanning()))