Commit b19e057c authored by Abdel-Rahman Abdel-Rahman's avatar Abdel-Rahman Abdel-Rahman
Browse files

Fix SearchPlaylist creation

PlaylistSearch was not set. It also cannot be constant as it is
editable, leading to a cascade of changes that assumes the constantcy.

This fixes the regression caused by commit
8dc85041
parent 0af791d1
......@@ -38,9 +38,10 @@
////////////////////////////////////////////////////////////////////////////////
AdvancedSearchDialog::AdvancedSearchDialog(const QString &defaultName,
const PlaylistSearch &defaultSearch,
PlaylistSearch &defaultSearch,
QWidget *parent) :
QDialog(parent)
QDialog(parent),
m_search(&defaultSearch)
{
setWindowTitle(i18n("Create Search Playlist"));
setObjectName(QStringLiteral("juk_advSrchDlg"));
......
......@@ -35,7 +35,7 @@ class AdvancedSearchDialog : public QDialog
public:
explicit AdvancedSearchDialog(
const QString& defaultName,
const PlaylistSearch& defaultSearch = PlaylistSearch(),
PlaylistSearch& defaultSearch,
QWidget* parent = nullptr);
PlaylistSearch* resultSearch() const
......
......@@ -73,7 +73,7 @@ static void parsePlaylistStream(QDataStream &s, PlaylistCollection *collection)
switch(playlistType) {
case Search:
{
SearchPlaylist *p = new SearchPlaylist(collection);
SearchPlaylist *p = new SearchPlaylist(collection, *(new PlaylistSearch(JuK::JuKInstance())));
s >> *p;
playlist = p;
break;
......
......@@ -532,7 +532,7 @@ void PlaylistCollection::createSearchPlaylist()
QString name = uniquePlaylistName(i18n("Search Playlist"));
auto searchDialog = new AdvancedSearchDialog(
name, PlaylistSearch(), JuK::JuKInstance());
name, *(new PlaylistSearch(JuK::JuKInstance())), JuK::JuKInstance());
QObject::connect(searchDialog, &QDialog::finished, [searchDialog, this](int result)
{
if (result) {
......
......@@ -77,9 +77,7 @@ void PlaylistSearch::addPlaylist(Playlist* p)
void PlaylistSearch::clearPlaylists()
{
beginResetModel();
setSourceModel(new QConcatenateTablesProxyModel(this));
endResetModel();
m_playlists.clear();
}
......
......@@ -28,7 +28,7 @@
////////////////////////////////////////////////////////////////////////////////
SearchPlaylist::SearchPlaylist(PlaylistCollection *collection,
const PlaylistSearch& search,
PlaylistSearch& search,
const QString &name,
bool setupPlaylist,
bool synchronizePlaying) :
......@@ -39,7 +39,7 @@ SearchPlaylist::SearchPlaylist(PlaylistCollection *collection,
}
void SearchPlaylist::setPlaylistSearch(const PlaylistSearch* s, bool update)
void SearchPlaylist::setPlaylistSearch(PlaylistSearch* s, bool update)
{
m_search = s;
if(update)
......
......@@ -24,13 +24,13 @@ class SearchPlaylist : public DynamicPlaylist
Q_OBJECT
public:
explicit SearchPlaylist(PlaylistCollection *collection,
const PlaylistSearch& search = PlaylistSearch(),
PlaylistSearch& search,
const QString &name = QString(),
bool setupPlaylist = true,
bool synchronizePlaying = false);
const PlaylistSearch* playlistSearch() const { return m_search; }
void setPlaylistSearch ( const PlaylistSearch* s, bool update = true );
PlaylistSearch* playlistSearch() const { return m_search; }
void setPlaylistSearch ( PlaylistSearch* s, bool update = true );
virtual bool searchIsEditable() const override { return true; }
protected:
......@@ -40,7 +40,7 @@ protected:
virtual void updateItems() override;
private:
const PlaylistSearch* m_search;
PlaylistSearch* m_search;
};
QDataStream &operator<<(QDataStream &s, const SearchPlaylist &p);
......
......@@ -29,7 +29,7 @@
#include "juk_debug.h"
TreeViewItemPlaylist::TreeViewItemPlaylist(PlaylistCollection *collection,
const PlaylistSearch &search,
PlaylistSearch &search,
const QString &name) :
SearchPlaylist(collection, search, name, false)
{
......
......@@ -28,7 +28,7 @@ class TreeViewItemPlaylist : public SearchPlaylist
public:
explicit TreeViewItemPlaylist(PlaylistCollection *collection,
const PlaylistSearch &search = PlaylistSearch(),
PlaylistSearch &search,
const QString &name = QString());
virtual bool searchIsEditable() const override { return false; }
......
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