Skip to content

Commit

Permalink
media library: stay on the selected item during filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
Montellese committed Oct 8, 2012
1 parent 9a1699b commit 8f87a23
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions xbmc/windows/GUIMediaWindow.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 8f87a23

Please sign in to comment.