Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit c2449512 authored by Scott Wheeler's avatar Scott Wheeler

Added search and dynamic playlists. These aren't actually used yet, but

I will shortly port PlaylistSplitter over to using the DynamicPlaylist
class and the "vfolders" implementation will use the SearchPlaylist class.

svn path=/trunk/kdemultimedia/juk/; revision=223962
parent 3b191c19
...@@ -10,7 +10,8 @@ juk_SOURCES = directorylistbase.ui genrelisteditorbase.ui \ ...@@ -10,7 +10,8 @@ juk_SOURCES = directorylistbase.ui genrelisteditorbase.ui \
genrelistlist.cpp genrelist.cpp genre.cpp player.cpp tag.cpp customaction.cpp \ genrelistlist.cpp genrelist.cpp genre.cpp player.cpp tag.cpp customaction.cpp \
slideraction.cpp keydialog.cpp juk.cpp main.cpp tagguesser.cpp \ slideraction.cpp keydialog.cpp juk.cpp main.cpp tagguesser.cpp \
tagguesserconfigdlgwidget.ui tagguesserconfigdlg.cpp jukIface.skel \ tagguesserconfigdlgwidget.ui tagguesserconfigdlg.cpp jukIface.skel \
playlistsearch.cpp searchwidget.cpp filerenamer.cpp playlistsearch.cpp searchwidget.cpp filerenamer.cpp dynamicplaylist.cpp \
searchplaylist.cpp
tagguessertest_SOURCES = tagguessertest.cpp tagguesser.cpp tagguessertest_SOURCES = tagguessertest.cpp tagguesser.cpp
......
/***************************************************************************
dynamicplaylist.h
-------------------
begin : Mon May 5 2003
copyright : (C) 2003 by Scott Wheeler
email : wheeler@kde.org
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "dynamicplaylist.h"
#include "collectionlist.h"
////////////////////////////////////////////////////////////////////////////////
// public methods
////////////////////////////////////////////////////////////////////////////////
DynamicPlaylist::DynamicPlaylist(const PlaylistList &playlists, QWidget *parent, const QString &name) :
Playlist(parent, name),
m_playlists(playlists),
m_dirty(true)
{
for(PlaylistList::ConstIterator it = m_playlists.begin(); it != m_playlists.end(); ++it) {
if(*it) {
connect(*it, SIGNAL(signalDataChanged()), this, SLOT(slotSetDirty()));
connect(*it, SIGNAL(signalNumberOfItemsChanged()), this, SLOT(slotSetDirty()));
}
else
m_playlists.remove(*it);
}
connect(CollectionList::instance(), SIGNAL(collectionChanged()), this, SLOT(slotSetDirty()));
}
////////////////////////////////////////////////////////////////////////////////
// protected methods
////////////////////////////////////////////////////////////////////////////////
PlaylistItemList DynamicPlaylist::items() const
{
PlaylistItemList l;
for(PlaylistList::ConstIterator it = m_playlists.begin(); it != m_playlists.end(); ++it)
l += (*it)->items();
return l;
}
void DynamicPlaylist::showEvent(QShowEvent *e)
{
if(m_dirty) {
PlaylistItemList newItems = items();
if(m_items != newItems) {
m_items = newItems;
clear();
createItems(m_items);
}
m_dirty = false;
}
Playlist::showEvent(e);
}
#include "dynamicplaylist.moc"
/***************************************************************************
dynamicplaylist.cpp
-------------------
begin : Mon May 5 2003
copyright : (C) 2003 by Scott Wheeler
email : wheeler@kde.org
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef DYNAMICPLAYLIST_H
#define DYNAMICPLAYLIST_H
#include "playlist.h"
/**
* A Playlist that is a union of other playlists that is created dynamically.
*/
class DynamicPlaylist : public Playlist
{
Q_OBJECT
public:
/**
* Creates a dynamic playlist based on lists.
*/
DynamicPlaylist(const PlaylistList &lists, QWidget *parent, const QString &name = QString::null);
protected:
/**
* Returns true if this list's items need to be updated the next time it's
* shown.
*/
bool dirty() { return m_dirty; }
/**
* Return a list of the items in this playlist. For example in a search
* list this should return only the matched items. By default it returns
* all of the items in the playlists associated with this dynamic list.
*/
virtual PlaylistItemList items() const;
/**
* Reimplemented from QWidget. Here it updates the list of items (when
* appropriate) as the widget is shown.
*/
virtual void showEvent(QShowEvent *e);
protected slots:
void slotSetDirty(bool d = true) { m_dirty = d; }
private:
PlaylistItemList m_items;
PlaylistList m_playlists;
bool m_dirty;
};
#endif
...@@ -47,6 +47,8 @@ public: ...@@ -47,6 +47,8 @@ public:
PlaylistItemList matchedItems() const { return m_matchedItems; } PlaylistItemList matchedItems() const { return m_matchedItems; }
PlaylistItemList unmatchedItems() const { return m_unmatchedItems; } PlaylistItemList unmatchedItems() const { return m_unmatchedItems; }
PlaylistList playlists() const { return m_playlists; }
private: private:
void search(); void search();
......
/***************************************************************************
searchplaylist.h
-------------------
begin : Mon May 5 2003
copyright : (C) 2003 by Scott Wheeler
email : wheeler@kde.org
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "searchplaylist.h"
////////////////////////////////////////////////////////////////////////////////
// public methods
////////////////////////////////////////////////////////////////////////////////
SearchPlaylist::SearchPlaylist(const PlaylistSearch &search, QWidget *parent, const QString &name) :
DynamicPlaylist(search.playlists(), parent, name),
m_search(search)
{
}
////////////////////////////////////////////////////////////////////////////////
// protected methods
////////////////////////////////////////////////////////////////////////////////
PlaylistItemList SearchPlaylist::items() const
{
return m_search.matchedItems();
}
/***************************************************************************
searchplaylist.h
-------------------
begin : Mon May 5 2003
copyright : (C) 2003 by Scott Wheeler
email : wheeler@kde.org
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef SEARCHPLAYLIST_H
#define SEARCHPLAYLIST_H
#include "dynamicplaylist.h"
#include "playlistsearch.h"
class SearchPlaylist : public DynamicPlaylist
{
public:
SearchPlaylist(const PlaylistSearch &search, QWidget *parent, const QString &name = QString::null);
protected:
virtual PlaylistItemList items() const;
private:
PlaylistSearch m_search;
};
#endif
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