Skip to content
Browse files

media library: stay on the selected item during filtering

  • Loading branch information...
1 parent 9a1699b commit 8f87a232654bc67f5602e081ba00e3f4cee693f7 @Montellese committed Sep 13, 2012
Showing with 23 additions and 3 deletions.
  1. +23 −3 xbmc/windows/GUIMediaWindow.cpp
View
26 xbmc/windows/GUIMediaWindow.cpp
@@ -1564,7 +1564,30 @@ void CGUIMediaWindow::OnFilterItems(const CStdString &filter)
if (!m_canFilterAdvanced)
SetProperty("filter", filter);
else
+ {
m_vecItems->SetPath(items.GetPath());
+
+ // to be able to select the same item as before we need to adjust
+ // the path of the item i.e. add or remove the "filter=" URL option
+ CURL curUrl(currentItem), newUrl(items.GetPath());
+ CUrlOptions curOptions(curUrl.GetOptions()), newOptions(newUrl.GetOptions());
+
+ if (newOptions.HasOption("filter"))
+ {
+ CVariant filter;
+ if (newOptions.GetOption("filter", filter) && filter.isString())
+ curOptions.AddOption("filter", filter.asString());
+ }
+ else if (curOptions.HasOption("filter"))
+ curOptions.AddOption("filter", "");
+
+ string options = curOptions.GetOptionsString();
+ if (!options.empty())
+ curUrl.SetOptions("?" + options);
+ else
+ curUrl.SetOptions("");
+ currentItem = curUrl.Get();
+ }
}
// and update our view control + buttons
@@ -1628,9 +1651,6 @@ bool CGUIMediaWindow::GetAdvanceFilteredItems(CFileItemList &items, bool &hasNew
{
hasNewItems = false;
- if (m_filter.IsEmpty())
- return true;
-
CFileItemList resultItems;
XFILE::CSmartPlaylistDirectory::GetDirectory(m_filter, resultItems, m_vecItems->GetPath(), true);

0 comments on commit 8f87a23

Please sign in to comment.
Something went wrong with that request. Please try again.