Commit 22324f49 authored by Matthieu Gallien's avatar Matthieu Gallien 🎵

when adding a directory from files view, follow sort order

will use the same sort order than the currently shown view to sort the
files per directory when adding a directory to a playlist

the sort is done inside each direcory that will be added
parent a4bc6256
Pipeline #43320 passed with stage
in 26 seconds
......@@ -62,20 +62,33 @@ void FileBrowserProxyModel::listRecursiveNewEntries(KIO::Job *job, const KIO::UD
{
Q_UNUSED(job)
DataTypes::EntryDataList newData;
auto vNewEntries = QVector<QString>{};
vNewEntries.reserve(list.size());
for (const auto &oneEntry : list) {
if (oneEntry.isDir()) {
continue;
}
auto returnedPath = oneEntry.stringValue(KIO::UDSEntry::UDS_NAME);
vNewEntries.push_back(oneEntry.stringValue(KIO::UDSEntry::UDS_NAME));
}
std::sort(std::begin(vNewEntries), std::end(vNewEntries), [this](auto first, auto second) {
return (sortOrder() == Qt::AscendingOrder) ? (first < second) : (first > second);
});
for (const auto &oneEntry : vNewEntries) {
auto fullPath = QString{};
auto fullPathUrl = QUrl{};
if (mCurentUrl.isLocalFile()) {
fullPath = QStringLiteral("%0/%1").arg(mCurentUrl.toLocalFile(), returnedPath);
fullPath = QStringLiteral("%0/%1").arg(mCurentUrl.toLocalFile(), oneEntry);
fullPathUrl = QUrl::fromLocalFile(fullPath);
} else {
fullPath = QStringLiteral("%0/%1").arg(mCurentUrl.toString(), returnedPath);
fullPath = QStringLiteral("%0/%1").arg(mCurentUrl.toString(), oneEntry);
fullPathUrl = QUrl{fullPath};
}
......@@ -85,9 +98,11 @@ void FileBrowserProxyModel::listRecursiveNewEntries(KIO::Job *job, const KIO::UD
continue;
}
mAllData.push_back({{{DataTypes::ElementTypeRole, ElisaUtils::FileName},
{DataTypes::ResourceRole, fullPathUrl}}, fullPath, {}});
newData.push_back({{{DataTypes::ElementTypeRole, ElisaUtils::FileName},
{DataTypes::ResourceRole, fullPathUrl}}, fullPath, {}});
}
mAllData.append(newData);
}
void FileBrowserProxyModel::genericEnqueueToPlayList(const QModelIndex &rootIndex,
......
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