Commit 99783134 authored by Scott Wheeler's avatar Scott Wheeler

Phase two: now the Advanced Search Dialog should return a PlaylistSearch

when executed.  The last step will come soon when a SearchPlaylist is
created by the PlaylistSplitter using this search.

svn path=/trunk/kdemultimedia/juk/; revision=241056
parent fd83e1e2
......@@ -26,10 +26,16 @@
#include <qhbox.h>
#include <qvbox.h>
#include <qlayout.h>
#include <qhbuttongroup.h>
#include "collectionlist.h"
#include "advancedsearchdialog.h"
#include "searchwidget.h"
////////////////////////////////////////////////////////////////////////////////
// public methods
////////////////////////////////////////////////////////////////////////////////
AdvancedSearchDialog::AdvancedSearchDialog(QWidget *parent, const char *name) :
KDialogBase(parent, name, true, i18n("Create Search Playlist"), Ok|Cancel)
{
......@@ -43,14 +49,15 @@ AdvancedSearchDialog::AdvancedSearchDialog(QWidget *parent, const char *name) :
QVGroupBox *criteriaGroupBox = new QVGroupBox(i18n("Search Criteria"), mainWidget());
box = new QHBox(criteriaGroupBox);
new QRadioButton(i18n("Match any of the following"), box);
new QRadioButton(i18n("Match all of the following"), box);
QHButtonGroup *group = new QHButtonGroup(criteriaGroupBox);
m_matchAnyButton = new QRadioButton(i18n("Match any of the following"), group);
m_matchAllButton = new QRadioButton(i18n("Match all of the following"), group);
m_matchAnyButton->setChecked(true);
m_criteria = new QVBox(criteriaGroupBox);
new SearchLine(m_criteria);
new SearchLine(m_criteria);
m_searchLines.append(new SearchLine(m_criteria));
m_searchLines.append(new SearchLine(m_criteria));
QWidget *buttons = new QWidget(criteriaGroupBox);
QBoxLayout *l = new QHBoxLayout(buttons, 0, 5);
......@@ -67,3 +74,38 @@ AdvancedSearchDialog::~AdvancedSearchDialog()
{
}
////////////////////////////////////////////////////////////////////////////////
// public slots
////////////////////////////////////////////////////////////////////////////////
AdvancedSearchDialog::Result AdvancedSearchDialog::exec()
{
Result r;
r.result = DialogCode(KDialogBase::exec());
r.search = m_search;
return r;
}
////////////////////////////////////////////////////////////////////////////////
// protected slots
////////////////////////////////////////////////////////////////////////////////
void AdvancedSearchDialog::accept()
{
m_search.clearPlaylists();
m_search.clearComponents();
m_search.addPlaylist(CollectionList::instance());
QValueListConstIterator<SearchLine *> it = m_searchLines.begin();
for(; it != m_searchLines.end(); ++it)
m_search.addComponent((*it)->searchComponent());
PlaylistSearch::SearchMode m = PlaylistSearch::SearchMode(!m_matchAnyButton->isChecked());
m_search.setSearchMode(m);
KDialogBase::accept();
}
#include "advancedsearchdialog.moc"
......@@ -20,16 +20,38 @@
#include <kdialogbase.h>
#include "playlistsearch.h"
class QGroupBox;
class QRadioButton;
class SearchLine;
class AdvancedSearchDialog : public KDialogBase
{
Q_OBJECT
public:
struct Result
{
DialogCode result;
PlaylistSearch search;
};
AdvancedSearchDialog(QWidget *parent = 0, const char *name = 0);
virtual ~AdvancedSearchDialog();
public slots:
Result exec();
protected slots:
virtual void accept();
private:
QWidget *m_criteria;
PlaylistSearch m_search;
QValueList<SearchLine *> m_searchLines;
QRadioButton *m_matchAnyButton;
QRadioButton *m_matchAllButton;
};
#endif
......@@ -23,8 +23,10 @@
class Playlist;
typedef QValueList<Playlist *> PlaylistList;
class PlaylistItem;
typedef QValueList<PlaylistItem *> PlaylistItemList;
typedef QValueList<int> ColumnList;
class PlaylistSearch
......@@ -47,10 +49,16 @@ public:
PlaylistItemList matchedItems() const { return m_matchedItems; }
PlaylistItemList unmatchedItems() const { return m_unmatchedItems; }
void addPlaylist(Playlist *p) { m_playlists.append(p); }
void clearPlaylists() { m_playlists.clear(); }
PlaylistList playlists() const { return m_playlists; }
void addComponent(const Component &c) { m_components.append(c); }
void clearComponents() { m_components.clear(); }
ComponentList components() const { return m_components; }
void setSearchMode(SearchMode m) { m_mode = m; }
bool isNull() const { return m_components.isEmpty(); }
bool isEmpty() const;
......
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