Commit e5ff0a0f authored by Scott Wheeler's avatar Scott Wheeler

Make it possible to edit the search fields of a search playlist.

CCMAIL:73635-done@bugs.kde.org

svn path=/trunk/kdemultimedia/juk/; revision=304811
parent 7b227286
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
AdvancedSearchDialog::AdvancedSearchDialog(const QString &defaultName, AdvancedSearchDialog::AdvancedSearchDialog(const QString &defaultName,
const PlaylistSearch &defaultSearch,
QWidget *parent, QWidget *parent,
const char *name) : const char *name) :
KDialogBase(parent, name, true, i18n("Create Search Playlist"), Ok|Cancel) KDialogBase(parent, name, true, i18n("Create Search Playlist"), Ok|Cancel)
...@@ -55,12 +56,29 @@ AdvancedSearchDialog::AdvancedSearchDialog(const QString &defaultName, ...@@ -55,12 +56,29 @@ AdvancedSearchDialog::AdvancedSearchDialog(const QString &defaultName,
QHButtonGroup *group = new QHButtonGroup(criteriaGroupBox); QHButtonGroup *group = new QHButtonGroup(criteriaGroupBox);
m_matchAnyButton = new QRadioButton(i18n("Match any of the following"), group); m_matchAnyButton = new QRadioButton(i18n("Match any of the following"), group);
m_matchAllButton = new QRadioButton(i18n("Match all of the following"), group); m_matchAllButton = new QRadioButton(i18n("Match all of the following"), group);
m_matchAnyButton->setChecked(true);
m_criteria = new QVBox(criteriaGroupBox); m_criteria = new QVBox(criteriaGroupBox);
m_searchLines.append(new SearchLine(m_criteria)); if(defaultSearch.isNull()) {
m_searchLines.append(new SearchLine(m_criteria)); m_searchLines.append(new SearchLine(m_criteria));
m_searchLines.append(new SearchLine(m_criteria));
m_matchAnyButton->setChecked(true);
}
else {
PlaylistSearch::ComponentList components = defaultSearch.components();
for(PlaylistSearch::ComponentList::ConstIterator it = components.begin();
it != components.end();
++it)
{
SearchLine *s = new SearchLine(m_criteria);
s->setSearchComponent(*it);
m_searchLines.append(s);
}
if(defaultSearch.searchMode() == PlaylistSearch::MatchAny)
m_matchAnyButton->setChecked(true);
else
m_matchAllButton->setChecked(true);
}
QWidget *buttons = new QWidget(criteriaGroupBox); QWidget *buttons = new QWidget(criteriaGroupBox);
QBoxLayout *l = new QHBoxLayout(buttons, 0, 5); QBoxLayout *l = new QHBoxLayout(buttons, 0, 5);
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include <kdialogbase.h> #include <kdialogbase.h>
class KLineEdit; class KLineEdit;
class KPushButton; class KPushButton;
class QGroupBox; class QGroupBox;
...@@ -40,6 +39,7 @@ public: ...@@ -40,6 +39,7 @@ public:
}; };
AdvancedSearchDialog(const QString &defaultName, AdvancedSearchDialog(const QString &defaultName,
const PlaylistSearch &defaultSearch = PlaylistSearch(),
QWidget *parent = 0, QWidget *parent = 0,
const char *name = 0); const char *name = 0);
......
...@@ -177,6 +177,7 @@ void JuK::setupActions() ...@@ -177,6 +177,7 @@ void JuK::setupActions()
createSplitterAction(i18n("Save As..."), SLOT(slotSaveAsPlaylist()), "file_save_as", "filesaveas"); createSplitterAction(i18n("Save As..."), SLOT(slotSaveAsPlaylist()), "file_save_as", "filesaveas");
createSplitterAction(i18n("R&emove"), SLOT(slotDeletePlaylist()), "deleteItemPlaylist", "edittrash"); createSplitterAction(i18n("R&emove"), SLOT(slotDeletePlaylist()), "deleteItemPlaylist", "edittrash");
createSplitterAction(i18n("Reload"), SLOT(slotReloadPlaylist()), "reloadPlaylist", "reload"); createSplitterAction(i18n("Reload"), SLOT(slotReloadPlaylist()), "reloadPlaylist", "reload");
createSplitterAction(i18n("Edit Search"), SLOT(slotEditSearch()), "editSearch", "editclear");
KStdAction::quit(this, SLOT(slotQuit()), actions()); KStdAction::quit(this, SLOT(slotQuit()), actions());
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
<Separator/> <Separator/>
<Action name="renamePlaylist"/> <Action name="renamePlaylist"/>
<Action name="editSearch"/>
<Action name="duplicatePlaylist"/> <Action name="duplicatePlaylist"/>
<Action name="reloadPlaylist"/> <Action name="reloadPlaylist"/>
<Action name="deleteItemPlaylist"/> <Action name="deleteItemPlaylist"/>
......
...@@ -62,6 +62,7 @@ PlaylistBox::PlaylistBox(PlaylistSplitter *parent, const QString &name) : ...@@ -62,6 +62,7 @@ PlaylistBox::PlaylistBox(PlaylistSplitter *parent, const QString &name) :
action("file_new")->plug(m_contextMenu); action("file_new")->plug(m_contextMenu);
action("renamePlaylist")->plug(m_contextMenu); action("renamePlaylist")->plug(m_contextMenu);
action("editSearch")->plug(m_contextMenu);
action("duplicatePlaylist")->plug(m_contextMenu); action("duplicatePlaylist")->plug(m_contextMenu);
action("reloadPlaylist")->plug(m_contextMenu); action("reloadPlaylist")->plug(m_contextMenu);
action("deleteItemPlaylist")->plug(m_contextMenu); action("deleteItemPlaylist")->plug(m_contextMenu);
...@@ -128,8 +129,10 @@ void PlaylistBox::createItem(Playlist *playlist, const char *icon, bool raise, b ...@@ -128,8 +129,10 @@ void PlaylistBox::createItem(Playlist *playlist, const char *icon, bool raise, b
} }
i->setSortedFirst(sortedFirst); i->setSortedFirst(sortedFirst);
if(playlist == CollectionList::instance()) if(playlist == CollectionList::instance()) {
slotPlaylistChanged();
emit signalCollectionInitialized(); emit signalCollectionInitialized();
}
} }
void PlaylistBox::createSearchItem(SearchPlaylist *playlist, const QString &searchCategory) void PlaylistBox::createSearchItem(SearchPlaylist *playlist, const QString &searchCategory)
...@@ -533,6 +536,11 @@ void PlaylistBox::slotPlaylistChanged() ...@@ -533,6 +536,11 @@ void PlaylistBox::slotPlaylistChanged()
action("reloadPlaylist")->setEnabled(allowReload); action("reloadPlaylist")->setEnabled(allowReload);
action("duplicatePlaylist")->setEnabled(!playlists.isEmpty()); action("duplicatePlaylist")->setEnabled(!playlists.isEmpty());
bool searchList =
playlists.count() == 1 && dynamic_cast<SearchPlaylist *>(playlists.front());
action("editSearch")->setEnabled(searchList);
emit signalCurrentChanged(playlists); emit signalCurrentChanged(playlists);
} }
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "mediafiles.h" #include "mediafiles.h"
#include "advancedsearchdialog.h" #include "advancedsearchdialog.h"
#include "actioncollection.h" #include "actioncollection.h"
#include "viewmode.h"
#include "tag.h" #include "tag.h"
using namespace ActionCollection; using namespace ActionCollection;
...@@ -412,6 +413,23 @@ void PlaylistSplitter::slotReloadPlaylist() ...@@ -412,6 +413,23 @@ void PlaylistSplitter::slotReloadPlaylist()
visiblePlaylist()->slotReload(); visiblePlaylist()->slotReload();
} }
void PlaylistSplitter::slotEditSearch()
{
SearchPlaylist *p = dynamic_cast<SearchPlaylist *>(visiblePlaylist());
if(!p)
return;
AdvancedSearchDialog::Result r =
AdvancedSearchDialog(p->name(), p->playlistSearch(), this).exec();
if(r.result == AdvancedSearchDialog::Accepted) {
p->setPlaylistSearch(r.search);
p->setName(r.playlistName);
m_playlistBox->viewMode()->queueRefresh();
}
}
void PlaylistSplitter::slotAddToPlaylist(const QString &file, Playlist *list, PlaylistItem *after) void PlaylistSplitter::slotAddToPlaylist(const QString &file, Playlist *list, PlaylistItem *after)
{ {
if(!after) if(!after)
...@@ -480,7 +498,8 @@ void PlaylistSplitter::slotSetHistoryVisible(bool visible) ...@@ -480,7 +498,8 @@ void PlaylistSplitter::slotSetHistoryVisible(bool visible)
void PlaylistSplitter::slotAdvancedSearch() void PlaylistSplitter::slotAdvancedSearch()
{ {
AdvancedSearchDialog *d = AdvancedSearchDialog *d =
new AdvancedSearchDialog(uniquePlaylistName(i18n("Search Playlist")), this); new AdvancedSearchDialog(uniquePlaylistName(i18n("Search Playlist")),
PlaylistSearch(), this);
AdvancedSearchDialog::Result r = d->exec(); AdvancedSearchDialog::Result r = d->exec();
delete d; delete d;
......
...@@ -176,6 +176,12 @@ public slots: ...@@ -176,6 +176,12 @@ public slots:
*/ */
void slotReloadPlaylist(); void slotReloadPlaylist();
/**
* If the visible playlist is a SearchPlaylist then popup a dialog to edit
* the search.
*/
void slotEditSearch();
/** /**
* Show or hide the editor. * Show or hide the editor.
*/ */
......
...@@ -34,6 +34,14 @@ SearchPlaylist::SearchPlaylist(QWidget *parent, const PlaylistSearch &search, co ...@@ -34,6 +34,14 @@ SearchPlaylist::SearchPlaylist(QWidget *parent, const PlaylistSearch &search, co
} }
void SearchPlaylist::setPlaylistSearch(const PlaylistSearch &s, bool update)
{
m_search = s;
if(update)
updateItems();
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// protected methods // protected methods
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
...@@ -92,7 +100,7 @@ QDataStream &operator>>(QDataStream &s, SearchPlaylist &p) ...@@ -92,7 +100,7 @@ QDataStream &operator>>(QDataStream &s, SearchPlaylist &p)
>> search; >> search;
p.setName(name); p.setName(name);
p.setPlaylistSearch(search); p.setPlaylistSearch(search, false);
return s; return s;
} }
......
...@@ -29,7 +29,7 @@ public: ...@@ -29,7 +29,7 @@ public:
const QString &name = QString::null); const QString &name = QString::null);
PlaylistSearch playlistSearch() const { return m_search; } PlaylistSearch playlistSearch() const { return m_search; }
void setPlaylistSearch(const PlaylistSearch &s) { m_search = s; } void setPlaylistSearch(const PlaylistSearch &s, bool update = true);
protected: protected:
/** /**
......
...@@ -67,10 +67,6 @@ public: ...@@ -67,10 +67,6 @@ public:
SearchWidget(QWidget *parent, const char *name = 0); SearchWidget(QWidget *parent, const char *name = 0);
virtual ~SearchWidget(); virtual ~SearchWidget();
/**
* Returns a list of searched columns for the given search row.
*/
PlaylistSearch search(const PlaylistList &playlists) const; PlaylistSearch search(const PlaylistList &playlists) const;
void setSearch(const PlaylistSearch &search); void setSearch(const PlaylistSearch &search);
......
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