Commit 684c62fe authored by Matthieu Gallien's avatar Matthieu Gallien 🎵

use rootIndex to add the correct music to playlist

parent 9c189c58
......@@ -110,15 +110,16 @@ void AbstractMediaProxyModel::connectPlayList()
mPlayList, static_cast<void(MediaPlayListProxyModel::*)(const DataTypes::EntryDataList&, ElisaUtils::PlayListEnqueueMode, ElisaUtils::PlayListEnqueueTriggerPlay)>(&MediaPlayListProxyModel::enqueue));
}
}
void AbstractMediaProxyModel::genericEnqueueToPlayList(ElisaUtils::PlayListEnqueueMode enqueueMode,
ElisaUtils::PlayListEnqueueTriggerPlay triggerPlay)
void AbstractMediaProxyModel::genericEnqueueToPlayList(QModelIndex rootIndex,
ElisaUtils::PlayListEnqueueMode enqueueMode,
ElisaUtils::PlayListEnqueueTriggerPlay triggerPlay)
{
QtConcurrent::run(&mThreadPool, [=] () {
QReadLocker locker(&mDataLock);
auto allData = DataTypes::EntryDataList{};
allData.reserve(rowCount());
for (int rowIndex = 0, maxRowCount = rowCount(); rowIndex < maxRowCount; ++rowIndex) {
auto currentIndex = index(rowIndex, 0);
auto currentIndex = index(rowIndex, 0, rootIndex);
allData.push_back(DataTypes::EntryData{data(currentIndex, DataTypes::FullDataRole).value<DataTypes::MusicDataType>(),
data(currentIndex, Qt::DisplayRole).toString(), {}});
......@@ -127,14 +128,14 @@ void AbstractMediaProxyModel::genericEnqueueToPlayList(ElisaUtils::PlayListEnque
});
}
void AbstractMediaProxyModel::enqueueToPlayList()
void AbstractMediaProxyModel::enqueueToPlayList(QModelIndex rootIndex)
{
genericEnqueueToPlayList(ElisaUtils::AppendPlayList, ElisaUtils::DoNotTriggerPlay);
genericEnqueueToPlayList(rootIndex, ElisaUtils::AppendPlayList, ElisaUtils::DoNotTriggerPlay);
}
void AbstractMediaProxyModel::replaceAndPlayOfPlayList()
void AbstractMediaProxyModel::replaceAndPlayOfPlayList(QModelIndex rootIndex)
{
genericEnqueueToPlayList(ElisaUtils::ReplacePlayList, ElisaUtils::TriggerPlay);
genericEnqueueToPlayList(rootIndex, ElisaUtils::ReplacePlayList, ElisaUtils::TriggerPlay);
}
......
......@@ -65,9 +65,9 @@ public Q_SLOTS:
void setPlayList(MediaPlayListProxyModel* playList);
void enqueueToPlayList();
void enqueueToPlayList(QModelIndex rootIndex);
void replaceAndPlayOfPlayList();
void replaceAndPlayOfPlayList(QModelIndex rootIndex);
Q_SIGNALS:
......@@ -105,7 +105,8 @@ protected:
private:
void genericEnqueueToPlayList(ElisaUtils::PlayListEnqueueMode enqueueMode,
void genericEnqueueToPlayList(QModelIndex rootIndex,
ElisaUtils::PlayListEnqueueMode enqueueMode,
ElisaUtils::PlayListEnqueueTriggerPlay triggerPlay);
};
......
......@@ -76,13 +76,15 @@ bool FileBrowserProxyModel::filterAcceptsRow(int source_row, const QModelIndex &
return result;
}
void FileBrowserProxyModel::genericEnqueueToPlayList(ElisaUtils::PlayListEnqueueMode enqueueMode, ElisaUtils::PlayListEnqueueTriggerPlay triggerPlay)
void FileBrowserProxyModel::genericEnqueueToPlayList(QModelIndex rootIndex,
ElisaUtils::PlayListEnqueueMode enqueueMode,
ElisaUtils::PlayListEnqueueTriggerPlay triggerPlay)
{
QtConcurrent::run(&mThreadPool, [=] () {
QReadLocker locker(&mDataLock);
auto allTrackUrls = DataTypes::EntryDataList{};
for (int rowIndex = 0, maxRowCount = rowCount(); rowIndex < maxRowCount; ++rowIndex) {
auto currentIndex = index(rowIndex, 0);
auto currentIndex = index(rowIndex, 0, rootIndex);
if (!data(currentIndex, FileBrowserModel::IsDirectoryRole).toBool()) {
allTrackUrls.push_back({{{DataTypes::ElementTypeRole, ElisaUtils::Track},
{DataTypes::ResourceRole, data(currentIndex, FileBrowserModel::FileUrlRole).toUrl()}}, {}, {}});
......@@ -92,16 +94,18 @@ void FileBrowserProxyModel::genericEnqueueToPlayList(ElisaUtils::PlayListEnqueue
});
}
void FileBrowserProxyModel::enqueueToPlayList()
void FileBrowserProxyModel::enqueueToPlayList(QModelIndex rootIndex)
{
genericEnqueueToPlayList(ElisaUtils::AppendPlayList,
genericEnqueueToPlayList(rootIndex,
ElisaUtils::AppendPlayList,
ElisaUtils::DoNotTriggerPlay);
}
void FileBrowserProxyModel::replaceAndPlayOfPlayList()
void FileBrowserProxyModel::replaceAndPlayOfPlayList(QModelIndex rootIndex)
{
genericEnqueueToPlayList(ElisaUtils::ReplacePlayList,
ElisaUtils::TriggerPlay);
genericEnqueueToPlayList(rootIndex,
ElisaUtils::ReplacePlayList,
ElisaUtils::TriggerPlay);
}
QString FileBrowserProxyModel::parentFolder() const
......
......@@ -73,9 +73,9 @@ public:
public Q_SLOTS:
void enqueueToPlayList();
void enqueueToPlayList(QModelIndex rootIndex);
void replaceAndPlayOfPlayList();
void replaceAndPlayOfPlayList(QModelIndex rootIndex);
void setFilterText(const QString &filterText);
......@@ -113,7 +113,8 @@ protected:
private:
void genericEnqueueToPlayList(ElisaUtils::PlayListEnqueueMode enqueueMode,
void genericEnqueueToPlayList(QModelIndex rootIndex,
ElisaUtils::PlayListEnqueueMode enqueueMode,
ElisaUtils::PlayListEnqueueTriggerPlay triggerPlay);
QString parentFolder() const;
......
......@@ -27,6 +27,9 @@ Q_SIGNALS:
public Q_SLOTS:
void enqueueToPlayList(QModelIndex rootIndex);
void replaceAndPlayOfPlayList(QModelIndex rootIndex);
protected:
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
......
......@@ -80,9 +80,9 @@ FocusScope {
}
}
onEnqueue: contentModel.enqueueToPlayList()
onEnqueue: contentModel.enqueueToPlayList(delegateModel.rootIndex)
onReplaceAndPlay:contentModel.replaceAndPlayOfPlayList()
onReplaceAndPlay:contentModel.replaceAndPlayOfPlayList(delegateModel.rootIndex)
onGoBack: {
gridView.goToBack()
......
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