Commit 3f2a3852 authored by Scott Wheeler's avatar Scott Wheeler

Cleanup the search API a bit.

svn path=/trunk/kdemultimedia/juk/; revision=223954
parent 0fde937c
......@@ -21,6 +21,14 @@
// public methods
////////////////////////////////////////////////////////////////////////////////
PlaylistSearch::PlaylistSearch(const PlaylistSearch &search) :
m_playlists(search.m_playlists),
m_components(search.m_components),
m_mode(search.m_mode)
{
}
PlaylistSearch::PlaylistSearch(const PlaylistList &playlists,
const ComponentList &components,
SearchMode mode) :
......@@ -62,7 +70,7 @@ void PlaylistSearch::search()
ComponentList::Iterator componentIt = m_components.begin();
for(; componentIt != m_components.end(); ++componentIt) {
bool componentMatches = (*componentIt)->matches(item);
bool componentMatches = (*componentIt).matches(item);
if(componentMatches && m_mode == MatchAny) {
match = true;
......@@ -87,6 +95,22 @@ void PlaylistSearch::search()
// Component public methods
////////////////////////////////////////////////////////////////////////////////
PlaylistSearch::Component::Component() :
m_searchAllVisible(true),
m_caseSensitive(false)
{
}
PlaylistSearch::Component::Component(const Component &component) :
m_query(component.m_query),
m_columns(component.m_columns),
m_searchAllVisible(component.m_searchAllVisible),
m_caseSensitive(component.m_caseSensitive)
{
}
PlaylistSearch::Component::Component(const QString &query, bool caseSensitive, const ColumnList &columns) :
m_query(query),
m_columns(columns),
......
......@@ -29,10 +29,15 @@ class PlaylistSearch
{
public:
class Component;
typedef QValueList<Component *> ComponentList;
typedef QValueList<Component> ComponentList;
enum SearchMode { MatchAny = 0, MatchAll = 1 };
/**
* Copy constructor.
*/
PlaylistSearch(const PlaylistSearch &search);
PlaylistSearch(const PlaylistList &playlists,
const ComponentList &components,
SearchMode mode = MatchAny);
......@@ -62,6 +67,18 @@ private:
class PlaylistSearch::Component
{
public:
/**
* Create an empty search component. This is only provided for use by
* QValueList and should not be used in any other context.
*/
Component();
/**
* Copy constructor.
*/
Component(const Component &component);
/**
* Create a query component. This defaults to searching all visible coulumns.
*/
......@@ -71,6 +88,8 @@ public:
ColumnList columns() const { return m_columns; }
bool matches(PlaylistItem *item);
protected:
private:
QString m_query;
......
......@@ -691,7 +691,7 @@ void PlaylistSplitter::slotShowSearchResults(const QString &query, bool caseSens
PlaylistSearch::Component component(query, caseSensitive, m_searchWidget->searchedColumns(0));
PlaylistSearch::ComponentList components;
components.append(&component);
components.append(component);
PlaylistSearch search(playlists, components);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment