Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

library: support simultaneous simple and advanced filtering (fixes #1…

…3915)
  • Loading branch information...
commit 5a37e89bf9f5a3df81ab951a06f553f18f9de850 1 parent be6d3a7
@Montellese Montellese authored
Showing with 22 additions and 33 deletions.
  1. +21 −32 xbmc/windows/GUIMediaWindow.cpp
  2. +1 −1  xbmc/windows/GUIMediaWindow.h
View
53 xbmc/windows/GUIMediaWindow.cpp
@@ -294,12 +294,7 @@ bool CGUIMediaWindow::OnMessage(CGUIMessage& message)
return true;
}
else if (iControl == CONTROL_BTN_FILTER)
- {
- if (m_canFilterAdvanced)
- return true;
-
- return Filter();
- }
+ return Filter(false);
else if (m_viewControl.HasControl(iControl)) // list/thumb control
{
int iItem = m_viewControl.GetSelectedItem();
@@ -420,11 +415,10 @@ bool CGUIMediaWindow::OnMessage(CGUIMessage& message)
}
else if (message.GetParam1() == GUI_MSG_FILTER_ITEMS && IsActive())
{
- CStdString filter;
+ CStdString filter = GetProperty("filter").asString();
// check if this is meant for advanced filtering
if (message.GetParam2() != 10)
{
- filter = GetProperty("filter").asString();
if (message.GetParam2() == 1) // append
filter += message.GetStringParam();
else if (message.GetParam2() == 2)
@@ -571,8 +565,7 @@ void CGUIMediaWindow::UpdateButtons()
items.Format("%i %s", m_vecItems->GetObjectCount(), g_localizeStrings.Get(127).c_str());
SET_CONTROL_LABEL(CONTROL_LABELFILES, items);
- if (!m_canFilterAdvanced)
- SET_CONTROL_LABEL2(CONTROL_BTN_FILTER, GetProperty("filter").asString());
+ SET_CONTROL_LABEL2(CONTROL_BTN_FILTER, GetProperty("filter").asString());
}
void CGUIMediaWindow::ClearFileItems()
@@ -887,8 +880,7 @@ bool CGUIMediaWindow::Update(const CStdString &strDirectory, bool updateFilterPa
OnCacheFileItems(*m_vecItems);
// Filter and group the items if necessary
- CStdString titleFilter = GetProperty("filter").asString();
- OnFilterItems(titleFilter);
+ OnFilterItems(GetProperty("filter").asString());
// Ask the devived class if it wants to do custom list operations,
// eg. changing the label
@@ -1737,25 +1729,21 @@ void CGUIMediaWindow::OnFilterItems(const CStdString &filter)
}
}
- if (filtered)
+ SetProperty("filter", filter);
+ if (filtered && m_canFilterAdvanced)
{
- if (!m_canFilterAdvanced)
- SetProperty("filter", filter);
- else
+ // 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
+ // but that's only necessary for folder items
+ if (currentItem.get() != NULL && currentItem->m_bIsFolder)
{
- // 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
- // but that's only necessary for folder items
- if (currentItem.get() != NULL && currentItem->m_bIsFolder)
- {
- CURL curUrl(currentItemPath), newUrl(m_strFilterPath);
- if (newUrl.HasOption("filter"))
- curUrl.SetOption("filter", newUrl.GetOption("filter"));
- else if (curUrl.HasOption("filter"))
- curUrl.RemoveOption("filter");
+ CURL curUrl(currentItemPath), newUrl(m_strFilterPath);
+ if (newUrl.HasOption("filter"))
+ curUrl.SetOption("filter", newUrl.GetOption("filter"));
+ else if (curUrl.HasOption("filter"))
+ curUrl.RemoveOption("filter");
- currentItemPath = curUrl.Get();
- }
+ currentItemPath = curUrl.Get();
}
}
@@ -1779,14 +1767,15 @@ void CGUIMediaWindow::OnFilterItems(const CStdString &filter)
bool CGUIMediaWindow::GetFilteredItems(const CStdString &filter, CFileItemList &items)
{
+ bool result = false;
if (m_canFilterAdvanced)
- return GetAdvanceFilteredItems(items);
+ result = GetAdvanceFilteredItems(items);
CStdString trimmedFilter(filter);
trimmedFilter.TrimLeft().ToLower();
if (trimmedFilter.IsEmpty())
- return true;
+ return result;
CFileItemList filteredItems(items.GetPath()); // use the original path - it'll likely be relied on for other things later.
bool numericMatch = StringUtils::IsNaturalNumber(trimmedFilter);
@@ -1894,10 +1883,10 @@ bool CGUIMediaWindow::IsFiltered()
(m_canFilterAdvanced && !m_filter.IsEmpty());
}
-bool CGUIMediaWindow::Filter()
+bool CGUIMediaWindow::Filter(bool advanced /* = true */)
{
// basic filtering
- if (!m_canFilterAdvanced)
+ if (!m_canFilterAdvanced || !advanced)
{
const CGUIControl *btnFilter = GetControl(CONTROL_BTN_FILTER);
if (btnFilter != NULL && btnFilter->GetControlType() == CGUIControl::GUICONTROL_EDIT)
View
2  xbmc/windows/GUIMediaWindow.h
@@ -103,7 +103,7 @@ class CGUIMediaWindow : public CGUIWindow
\return true if the given path can contain a "filter" parameter otherwise false
*/
virtual bool CanContainFilter(const CStdString &strDirectory) const { return false; }
- virtual bool Filter();
+ virtual bool Filter(bool advanced = true);
/* \brief Called on response to a GUI_MSG_FILTER_ITEMS message
Filters the current list with the given filter using FilterItems()
Please sign in to comment.
Something went wrong with that request. Please try again.