Commit 8d20022c authored by Matthieu Gallien's avatar Matthieu Gallien 🎵
Browse files

fixes all remaining issues when handling track URLs

parent 77c61f9f
......@@ -215,7 +215,8 @@ void ElisaApplication::activateRequested(const QStringList &arguments, const QSt
continue;
}
realArguments.push_back(DataTypes::EntryData{{{DataTypes::ElementTypeRole, ElisaUtils::Track}}, {}, QUrl(oneArgument)});
realArguments.push_back({{{DataTypes::ElementTypeRole, ElisaUtils::Track},
{DataTypes::ResourceRole, QUrl::fromUserInput(oneArgument)}}, {}, {}});
}
Q_EMIT enqueue(checkFileListAndMakeAbsolute(realArguments, workingDirectory),
......@@ -313,22 +314,25 @@ 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{std::get<0>(oneFile), std::get<1>(oneFile), 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(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* {
......
......@@ -428,6 +428,8 @@ void MediaPlayList::enqueueMultipleEntries(const DataTypes::EntryDataList &entri
}
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());
......
......@@ -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;
......@@ -173,10 +174,10 @@ void FileBrowserProxyModel::recursiveEnqueue()
this, &FileBrowserProxyModel::listRecursiveNewEntries);
} else {
if (mPlayList) {
mAllData.push_back(DataTypes::EntryData { { { DataTypes::ElementTypeRole, ElisaUtils::FileName },
{ DataTypes::ResourceRole, rootUrl}},
rootUrl.toString(),
rootUrl });
mAllData.push_back({{{DataTypes::ElementTypeRole, ElisaUtils::FileName},
{DataTypes::ResourceRole, rootUrl}},
rootUrl.toString(),
rootUrl});
if (mPendingEntries.empty()) {
mEnqueueInProgress = 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