Commit 4a47e32d authored by Matthieu Gallien's avatar Matthieu Gallien 🎵
Browse files

fix enqueue from FileBrowserView with Qt 5.14

parent 6d045452
......@@ -19,6 +19,7 @@
#include "filebrowserproxymodel.h"
#include "filebrowsermodel.h"
#include "mediaplaylist.h"
#include <QReadLocker>
#include <QtConcurrentRun>
......@@ -138,6 +139,22 @@ QString FileBrowserProxyModel::parentFolder() const
}
}
void FileBrowserProxyModel::disconnectPlayList()
{
if (mPlayList) {
disconnect(this, &FileBrowserProxyModel::filesToEnqueue,
mPlayList, static_cast<void(MediaPlayList::*)(const ElisaUtils::EntryDataList&, ElisaUtils::PlayListEntryType, ElisaUtils::PlayListEnqueueMode, ElisaUtils::PlayListEnqueueTriggerPlay)>(&MediaPlayList::enqueue));
}
}
void FileBrowserProxyModel::connectPlayList()
{
if (mPlayList) {
connect(this, &FileBrowserProxyModel::filesToEnqueue,
mPlayList, static_cast<void(MediaPlayList::*)(const ElisaUtils::EntryDataList&, ElisaUtils::PlayListEntryType, ElisaUtils::PlayListEnqueueMode, ElisaUtils::PlayListEnqueueTriggerPlay)>(&MediaPlayList::enqueue));
}
}
void FileBrowserProxyModel::openParentFolder()
{
auto fileBrowserModel = dynamic_cast<FileBrowserModel*>(sourceModel());
......@@ -216,10 +233,29 @@ void FileBrowserProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
openFolder(mTopFolder, true);
}
MediaPlayList *FileBrowserProxyModel::playList() const
{
return mPlayList;
}
void FileBrowserProxyModel::sortModel(Qt::SortOrder order)
{
this->sort(0,order);
Q_EMIT sortedAscendingChanged();
}
void FileBrowserProxyModel::setPlayList(MediaPlayList *playList)
{
disconnectPlayList();
if (mPlayList == playList) {
return;
}
mPlayList = playList;
Q_EMIT playListChanged();
connectPlayList();
}
#include "moc_filebrowserproxymodel.cpp"
......@@ -31,6 +31,8 @@
#include <memory>
class MediaPlayList;
class ELISALIB_EXPORT FileBrowserProxyModel : public KDirSortFilterProxyModel
{
Q_OBJECT
......@@ -52,6 +54,8 @@ class ELISALIB_EXPORT FileBrowserProxyModel : public KDirSortFilterProxyModel
READ sortedAscending
NOTIFY sortedAscendingChanged)
Q_PROPERTY(MediaPlayList* playList READ playList WRITE setPlayList NOTIFY playListChanged)
public:
explicit FileBrowserProxyModel(QObject *parent = nullptr);
......@@ -68,6 +72,8 @@ public:
void setSourceModel(QAbstractItemModel *sourceModel) override;
MediaPlayList* playList() const;
public Q_SLOTS:
void enqueueToPlayList();
......@@ -82,6 +88,8 @@ public Q_SLOTS:
void sortModel(Qt::SortOrder order);
void setPlayList(MediaPlayList* playList);
Q_SIGNALS:
void filesToEnqueue(const ElisaUtils::EntryDataList &newFiles,
......@@ -97,6 +105,8 @@ Q_SIGNALS:
void sortedAscendingChanged();
void playListChanged();
protected:
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
......@@ -105,6 +115,10 @@ private:
QString parentFolder() const;
void disconnectPlayList();
void connectPlayList();
QString mTopFolder;
FileScanner mFileScanner;
......@@ -117,6 +131,8 @@ private:
QThreadPool mThreadPool;
MediaPlayList* mPlayList = nullptr;
};
#endif // FILEBROWSERPROXYMODEL_H
......@@ -47,8 +47,7 @@ FocusScope {
id: proxyModel
sourceModel: realModel
onFilesToEnqueue: elisa.mediaPlayList.enqueue(newFiles, databaseIdType, enqueueMode, triggerPlay)
playList: elisa.mediaPlayList
}
MouseArea {
......
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