Commit 9f5c789f authored by Matthieu Gallien's avatar Matthieu Gallien 🎵

Merge remote-tracking branch 'origin/release/20.08' into master

parents f3176353 1ae2db61
......@@ -616,7 +616,8 @@ void MediaPlayListProxyModelTest::enqueueTrackByUrl()
auto newTrackID = myDatabaseContent.trackIdFromTitleAlbumTrackDiscNumber(QStringLiteral("track6"), QStringLiteral("artist1 and artist2"), QStringLiteral("album2"), 6, 1);
auto trackData = myDatabaseContent.trackDataFromDatabaseId(newTrackID);
myPlayListProxyModel.enqueue({{{{DataTypes::ElementTypeRole, ElisaUtils::Track}}, {}, trackData.resourceURI()}}, {}, {});
myPlayListProxyModel.enqueue({{DataTypes::ElementTypeRole, ElisaUtils::Track},
{DataTypes::ResourceRole, trackData.resourceURI()}}, {}, {}, {});
QCOMPARE(rowsAboutToBeRemovedSpy.count(), 0);
QCOMPARE(rowsAboutToBeMovedSpy.count(), 0);
......@@ -717,8 +718,10 @@ void MediaPlayListProxyModelTest::enqueueTracksByUrl()
auto firstTrackData = myDatabaseContent.trackDataFromDatabaseId(firstNewTrackID);
auto secondNewTrackID = myDatabaseContent.trackIdFromTitleAlbumTrackDiscNumber(QStringLiteral("track1"), QStringLiteral("artist1"), QStringLiteral("album1"), 1, 1);
auto secondTrackData = myDatabaseContent.trackDataFromDatabaseId(secondNewTrackID);
myPlayListProxyModel.enqueue({{{{DataTypes::ElementTypeRole, ElisaUtils::Track}}, {}, firstTrackData.resourceURI()},
{{{DataTypes::ElementTypeRole, ElisaUtils::Track}}, {}, secondTrackData.resourceURI()}}, {}, {});
myPlayListProxyModel.enqueue({{{{DataTypes::ElementTypeRole, ElisaUtils::Track},
{DataTypes::ResourceRole, firstTrackData.resourceURI()}}, {}, {}},
{{{DataTypes::ElementTypeRole, ElisaUtils::Track},
{DataTypes::ResourceRole, secondTrackData.resourceURI()}}, {}, {}}}, {}, {});
QCOMPARE(rowsAboutToBeRemovedSpy.count(), 0);
QCOMPARE(rowsAboutToBeMovedSpy.count(), 0);
......@@ -6749,8 +6752,10 @@ void MediaPlayListProxyModelTest::enqueueFiles()
QCOMPARE(newEntryInListSpy.count(), 0);
QCOMPARE(newUrlInListSpy.count(), 0);
myPlayListProxyModel.enqueue({{{{DataTypes::ElementTypeRole, ElisaUtils::Track}}, {}, QUrl::fromLocalFile(QStringLiteral("/$1"))},
{{{DataTypes::ElementTypeRole, ElisaUtils::Track}}, {}, QUrl::fromLocalFile(QStringLiteral("/$2"))}}, {}, {});
myPlayListProxyModel.enqueue({{{{DataTypes::ElementTypeRole, ElisaUtils::Track},
{DataTypes::ResourceRole, QUrl::fromLocalFile(QStringLiteral("/$1"))}}, {}, {}},
{{{DataTypes::ElementTypeRole, ElisaUtils::Track},
{DataTypes::ResourceRole, QUrl::fromLocalFile(QStringLiteral("/$2"))}}, {}, {}}}, {}, {});
QCOMPARE(rowsAboutToBeRemovedSpy.count(), 0);
QCOMPARE(rowsAboutToBeMovedSpy.count(), 0);
......@@ -6862,8 +6867,11 @@ void MediaPlayListProxyModelTest::enqueueSampleFiles()
QCOMPARE(newEntryInListSpy.count(), 0);
QCOMPARE(newUrlInListSpy.count(), 0);
myPlayListProxyModel.enqueue({{{{DataTypes::ElementTypeRole, ElisaUtils::Track}}, {}, QUrl::fromLocalFile(QStringLiteral(MEDIAPLAYLIST_TESTS_SAMPLE_FILES_PATH) + QStringLiteral("/test.ogg"))},
{{{DataTypes::ElementTypeRole, ElisaUtils::Track}}, {}, QUrl::fromLocalFile(QStringLiteral(MEDIAPLAYLIST_TESTS_SAMPLE_FILES_PATH) + QStringLiteral("/test2.ogg"))}},
myPlayListProxyModel.enqueue({
{{{DataTypes::ElementTypeRole, ElisaUtils::Track},
{DataTypes::ResourceRole, QUrl::fromLocalFile(QStringLiteral(MEDIAPLAYLIST_TESTS_SAMPLE_FILES_PATH) + QStringLiteral("/test.ogg"))}}, {}, {}},
{{{DataTypes::ElementTypeRole, ElisaUtils::Track},
{DataTypes::ResourceRole, QUrl::fromLocalFile(QStringLiteral(MEDIAPLAYLIST_TESTS_SAMPLE_FILES_PATH) + QStringLiteral("/test2.ogg"))}}, {}, {}}},
{}, {});
QCOMPARE(rowsAboutToBeRemovedSpy.count(), 0);
......
......@@ -215,7 +215,8 @@ void ElisaApplication::activateRequested(const QStringList &arguments, const QSt
continue;
}
realArguments.push_back(DataTypes::EntryData{{}, {}, QUrl(oneArgument)});
realArguments.push_back({{{DataTypes::ElementTypeRole, ElisaUtils::Track},
{DataTypes::ResourceRole, QUrl::fromUserInput(oneArgument)}}, {}, {}});
}
Q_EMIT enqueue(checkFileListAndMakeAbsolute(realArguments, workingDirectory),
......@@ -313,25 +314,28 @@ DataTypes::EntryDataList ElisaApplication::checkFileListAndMakeAbsolute(const Da
auto filesToOpen = DataTypes::EntryDataList{};
for (const auto &oneFile : filesList) {
if (std::get<2>(oneFile).scheme().isEmpty() || std::get<2>(oneFile).isLocalFile()) {
auto newFile = QFileInfo(std::get<2>(oneFile).toLocalFile());
if (std::get<2>(oneFile).scheme().isEmpty()) {
newFile = QFileInfo(std::get<2>(oneFile).toString());
auto trackUrl = std::get<0>(oneFile)[DataTypes::ResourceRole].toUrl();
if (trackUrl.scheme().isEmpty() || trackUrl.isLocalFile()) {
auto newFile = QFileInfo(trackUrl.toLocalFile());
if (trackUrl.scheme().isEmpty()) {
newFile = QFileInfo(trackUrl.toString());
}
if (newFile.isRelative()) {
if (std::get<2>(oneFile).scheme().isEmpty()) {
newFile.setFile(workingDirectory, std::get<2>(oneFile).toString());
if (trackUrl.scheme().isEmpty()) {
newFile.setFile(workingDirectory, trackUrl.toString());
} else {
newFile.setFile(workingDirectory, std::get<2>(oneFile).toLocalFile());
newFile.setFile(workingDirectory, trackUrl.toLocalFile());
}
}
if (newFile.exists()) {
filesToOpen.push_back(DataTypes::EntryData{{}, {}, QUrl::fromLocalFile(newFile.canonicalFilePath())});
auto trackData = std::get<0>(oneFile);
trackData[DataTypes::ResourceRole] = QUrl::fromLocalFile(newFile.canonicalFilePath());
filesToOpen.push_back({trackData, std::get<1>(oneFile), {}});
}
} else {
filesToOpen.push_back(DataTypes::EntryData{{}, {}, std::get<2>(oneFile)});
filesToOpen.push_back(oneFile);
}
}
......
......@@ -144,7 +144,8 @@ int main(int argc, char *argv[])
auto realArgumentsList = parser.positionalArguments();
for (const auto &oneArgument : realArgumentsList) {
arguments.push_back(DataTypes::EntryData{{}, {}, QUrl(oneArgument)});
arguments.push_back(DataTypes::EntryData{{{DataTypes::ElementTypeRole, ElisaUtils::FileName},
{DataTypes::ResourceRole, QUrl::fromUserInput(oneArgument)}}, {}, {}});
}
int typeId = qmlRegisterSingletonType<ElisaArguments>("org.kde.elisa.host", 1, 0, "ElisaArguments", [](QQmlEngine *qmlEngine, QJSEngine *scriptEngine) -> QObject* {
......
......@@ -405,8 +405,10 @@ void MediaPlayList::enqueueMultipleEntries(const DataTypes::EntryDataList &entri
beginInsertRows(QModelIndex(), d->mData.size(), d->mData.size() + entriesData.size() - 1);
for (const auto &entryData : entriesData) {
if (!std::get<0>(entryData).databaseId() && std::get<2>(entryData).isValid()) {
auto newEntry = MediaPlayListEntry{std::get<2>(entryData)};
qCDebug(orgKdeElisaPlayList()) << "MediaPlayList::enqueueMultipleEntries" << std::get<0>(entryData);
auto trackUrl = std::get<0>(entryData)[DataTypes::ResourceRole].toUrl();
if (!std::get<0>(entryData).databaseId() && trackUrl.isValid()) {
auto newEntry = MediaPlayListEntry{trackUrl};
newEntry.mEntryType = ElisaUtils::FileName;
d->mData.push_back(std::move(newEntry));
d->mTrackData.push_back({});
......@@ -417,14 +419,18 @@ void MediaPlayList::enqueueMultipleEntries(const DataTypes::EntryDataList &entri
{
case ElisaUtils::Track:
case ElisaUtils::Radio:
case ElisaUtils::FileName:
d->mTrackData.push_back(static_cast<const DataTypes::TrackDataType&>(data));
break;
default:
d->mTrackData.push_back({});
}
}
if (std::get<2>(entryData).isValid()) {
Q_EMIT newUrlInList(std::get<2>(entryData), std::get<0>(entryData).elementType());
if (trackUrl.isValid()) {
qCDebug(orgKdeElisaPlayList()) << "MediaPlayList::enqueueMultipleEntries" << "new url" << trackUrl
<< std::get<0>(entryData).elementType();
Q_EMIT newUrlInList(trackUrl, std::get<0>(entryData).elementType());
} else {
Q_EMIT newEntryInList(std::get<0>(entryData).databaseId(), std::get<1>(entryData), std::get<0>(entryData).elementType());
}
......
......@@ -424,7 +424,7 @@ void MediaPlayListProxyModel::sourceDataChanged(const QModelIndex &topLeft, cons
auto startSourceRow = topLeft.row();
auto endSourceRow = bottomRight.row();
for (int i = startSourceRow; i <= endSourceRow; i++) {
Q_EMIT dataChanged(index(mapRowFromSource(i), 0), index(mapRowFromSource(i), 0), roles);
Q_EMIT dataChanged(index(mapRowFromSource(i), 0), index(mapRowFromSource(i), 0), roles);
if (i == d->mCurrentTrack.row()) {
Q_EMIT currentTrackDataChanged();
} else if (i == d->mNextTrack.row()) {
......@@ -712,9 +712,11 @@ void MediaPlayListProxyModel::loadPlayListLoaded()
auto newTracks = DataTypes::EntryDataList{};
for (int i = 0; i < d->mLoadPlaylist.mediaCount(); ++i) {
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
newTracks.push_back({{{{DataTypes::ElementTypeRole, ElisaUtils::FileName}}}, {}, d->mLoadPlaylist.media(i).canonicalUrl()});
newTracks.push_back({{{{DataTypes::ElementTypeRole, ElisaUtils::FileName},
{DataTypes::ResourceRole, d->mLoadPlaylist.media(i).request().url()}}}, {}, {}});
#else
newTracks.push_back({{{{DataTypes::ElementTypeRole, ElisaUtils::FileName}}}, {}, d->mLoadPlaylist.media(i).request().url()});
newTracks.push_back({{{{DataTypes::ElementTypeRole, ElisaUtils::FileName},
{DataTypes::ResourceRole, d->mLoadPlaylist.media(i).request().url()}}}, {}, {}});
#endif
}
......
......@@ -68,7 +68,7 @@ void FileBrowserProxyModel::listRecursiveNewEntries(KIO::Job *job, const KIO::UD
}
auto returnedPath = oneEntry.stringValue(KIO::UDSEntry::UDS_NAME);
auto fullPath = QStringLiteral("%0/%1").arg(mCuurentUrl.toString(), returnedPath);
auto fullPath = QStringLiteral("%0/%1").arg(mCurentUrl.toString(), returnedPath);
auto fullPathUrl = QUrl { fullPath };
auto mimeType = mMimeDatabase.mimeTypeForUrl(fullPathUrl);
......@@ -77,7 +77,8 @@ void FileBrowserProxyModel::listRecursiveNewEntries(KIO::Job *job, const KIO::UD
continue;
}
mAllData.push_back(DataTypes::EntryData { { { DataTypes::ElementTypeRole, ElisaUtils::FileName } }, fullPath, fullPathUrl });
mAllData.push_back({{{DataTypes::ElementTypeRole, ElisaUtils::FileName},
{DataTypes::ResourceRole, fullPathUrl}}, fullPath, {}});
}
}
......@@ -96,7 +97,7 @@ void FileBrowserProxyModel::genericEnqueueToPlayList(QModelIndex rootIndex,
for (int rowIndex = 0, maxRowCount = rowCount(); rowIndex < maxRowCount; ++rowIndex) {
auto currentIndex = index(rowIndex, 0, rootIndex);
mPendingEntries.emplace(currentIndex.data(DataTypes::FilePathRole).toUrl(),
currentIndex.data(DataTypes::ElementTypeRole).value<ElisaUtils::PlayListEntryType>() == ElisaUtils::Container);
currentIndex.data(DataTypes::ElementTypeRole).value<ElisaUtils::PlayListEntryType>() == ElisaUtils::Container);
}
mEnqueueInProgress = true;
......@@ -127,8 +128,8 @@ void FileBrowserProxyModel::enqueue(const DataTypes::MusicDataType &newEntry,
mPendingEntries = {};
mAllData.clear();
mPendingEntries.emplace(newEntry[DataTypes::FilePathRole].toUrl(),
newEntry.elementType() == ElisaUtils::Container);
mPendingEntries.emplace(newEntry[DataTypes::ResourceRole].toUrl(),
newEntry.elementType() == ElisaUtils::Container);
mEnqueueInProgress = true;
mEnqueueMode = enqueueMode;
......@@ -164,7 +165,7 @@ void FileBrowserProxyModel::recursiveEnqueue()
auto [rootUrl, isDirectory] = mPendingEntries.front();
mPendingEntries.pop();
if (isDirectory) {
mCuurentUrl = rootUrl;
mCurentUrl = rootUrl;
mCurrentJob = KIO::listRecursive(rootUrl, { KIO::HideProgressInfo });
connect(mCurrentJob, &KJob::result, this, &FileBrowserProxyModel::listRecursiveResult);
......@@ -173,7 +174,10 @@ void FileBrowserProxyModel::recursiveEnqueue()
this, &FileBrowserProxyModel::listRecursiveNewEntries);
} else {
if (mPlayList) {
mAllData.push_back(DataTypes::EntryData { { { DataTypes::ElementTypeRole, ElisaUtils::FileName } }, rootUrl.toString(), rootUrl });
mAllData.push_back({{{DataTypes::ElementTypeRole, ElisaUtils::FileName},
{DataTypes::ResourceRole, rootUrl}},
rootUrl.toString(),
rootUrl});
if (mPendingEntries.empty()) {
mEnqueueInProgress = false;
......
......@@ -135,7 +135,7 @@ private:
ElisaUtils::PlayListEnqueueTriggerPlay mTriggerPlay;
QUrl mCuurentUrl;
QUrl mCurentUrl;
KIO::Job *mCurrentJob = nullptr;
......
  • @mgallien one of the commits in this merge seems to have broken MPRIS exporting on the master branch. MPRIS exporting is working for me on the release/20.08 branch when I build that, but not on the master branch now that it's been merged. Rather odd. Any chance you could investigate? Thanks!

  • I will do it today. Sorry for the breakage.

    I was working on another fix but I am almost done.

  • No worries! Hope things aren't too stressful in France these days.

  • As far as I am concerned, things are mostly fine. Though, with the holidays, I am quite often far from the computer.

    What about you ?

  • I'm deeply disappointed in my country and depressed about its future. COVID-19 has taken a heavy toll on our already fragile society. I hope that once we begin to recover, the experience will leave us with a willingness to actually solve our longstanding problems rather than continuing to ignore them as they get worse and harm more and more people.

    I hadn't realized you were on holiday, sorry! I'll stop pinging you.

  • Even in France, dealing with the COVID-19 is a very complicated matter. I had disagreements with my mother and the parents of my wife on this subject for example.

    I also suppose that the situation and what to do is still complicated in France.

    Do not worry about pinging me. If I am away from keyboard, please bare with my inability to answer.

    I was talking about the holidays of my kids and my wife (almost all of July and August). We are spending quite some time outside and I have less time to contribute.

  • I hope it's a happy vacation!

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