aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartijn Kaijser <machine.sanctum@gmail.com>2013-04-01 13:48:12 -0700
committerMartijn Kaijser <machine.sanctum@gmail.com>2013-04-01 13:48:12 -0700
commit6737e7411926da2b5e0b8a842e4c62ddbd11253d (patch)
treeb938ae3a5c2ee5fec0471ea522744f985c1cc862
parentcdd62b918dc3ff79fa5ffc9fea1b54995d3e3a2b (diff)
parent5a37e89bf9f5a3df81ab951a06f553f18f9de850 (diff)
Merge pull request #2503 from Montellese/filtering
library: support simultaneous simple and advanced filtering (fixes #13915)
-rw-r--r--xbmc/windows/GUIMediaWindow.cpp53
-rw-r--r--xbmc/windows/GUIMediaWindow.h2
2 files changed, 22 insertions, 33 deletions
diff --git a/xbmc/windows/GUIMediaWindow.cpp b/xbmc/windows/GUIMediaWindow.cpp
index c3fb28f371..b75da6a865 100644
--- a/xbmc/windows/GUIMediaWindow.cpp
+++ b/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)
diff --git a/xbmc/windows/GUIMediaWindow.h b/xbmc/windows/GUIMediaWindow.h
index 3eceb58939..35df23ed1f 100644
--- a/xbmc/windows/GUIMediaWindow.h
+++ b/xbmc/windows/GUIMediaWindow.h
@@ -103,7 +103,7 @@ protected:
\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()