[vlc-commits] [Git][videolan/vlc][master] qt: NetworkMediaModel now lists folders before files
François Cartegnie (@fcartegnie)
gitlab at videolan.org
Tue Mar 5 16:57:36 UTC 2024
François Cartegnie pushed to branch master at VideoLAN / VLC
Commits:
797e1a4e by Ash V at 2024-03-05T16:12:48+00:00
qt: NetworkMediaModel now lists folders before files
Added isADir() method in NetWorkmediaModel's anonymous namespace to list folders-before-files through the NetWorkmediaModel's getSortFunction().
fix: #28371
- - - - -
1 changed file:
- modules/gui/qt/network/networkmediamodel.cpp
Changes:
=====================================
modules/gui/qt/network/networkmediamodel.cpp
=====================================
@@ -56,6 +56,11 @@ struct NetworkMediaItem
using NetworkMediaItemPtr = std::shared_ptr<NetworkMediaItem>;
using NetworkMediaItemSet = std::unordered_set<NetworkMediaItemPtr>;
+inline bool isADir(const NetworkMediaItemPtr& x)
+{
+ return (x->type == NetworkMediaModel::ItemType::TYPE_DIRECTORY);
+}
+
}
// ListCache specialisation
@@ -233,10 +238,12 @@ public:
{
if (m_sortOrder == Qt::SortOrder::DescendingOrder)
return [](const NetworkMediaItemPtr& a, const NetworkMediaItemPtr& b) -> bool {
+ if(isADir(a) != isADir(b)) return isADir(a);
return QString::compare(a->mainMrl.toString(), b->mainMrl.toString()) > 0;
};
else
return [](const NetworkMediaItemPtr& a, const NetworkMediaItemPtr& b) -> bool {
+ if(isADir(a) != isADir(b)) return isADir(a);
return QString::compare(a->mainMrl.toString(), b->mainMrl.toString()) < 0;
};
}
@@ -244,10 +251,12 @@ public:
{
if (m_sortOrder == Qt::SortOrder::DescendingOrder)
return [](const NetworkMediaItemPtr& a, const NetworkMediaItemPtr& b) -> bool {
+ if(isADir(a) != isADir(b)) return isADir(a);
return a->fileSize < b->fileSize;
};
else
return [](const NetworkMediaItemPtr& a, const NetworkMediaItemPtr& b) -> bool {
+ if(isADir(a) != isADir(b)) return isADir(a);
return a->fileSize > b->fileSize;
};
}
@@ -255,10 +264,12 @@ public:
{
if (m_sortOrder == Qt::SortOrder::DescendingOrder)
return [](const NetworkMediaItemPtr& a, const NetworkMediaItemPtr& b) -> bool {
+ if(isADir(a) != isADir(b)) return isADir(a);
return a->fileModified < b->fileModified;
};
else
return [](const NetworkMediaItemPtr& a, const NetworkMediaItemPtr& b) -> bool {
+ if(isADir(a) != isADir(b)) return isADir(a);
return a->fileModified > b->fileModified;
};
}
@@ -266,10 +277,12 @@ public:
{
if (m_sortOrder == Qt::SortOrder::DescendingOrder)
return [](const NetworkMediaItemPtr& a, const NetworkMediaItemPtr& b) -> bool {
+ if(isADir(a) != isADir(b)) return isADir(a);
return QString::compare(a->name, b->name, Qt::CaseInsensitive) > 0;
};
else
return [](const NetworkMediaItemPtr& a, const NetworkMediaItemPtr& b) -> bool {
+ if(isADir(a) != isADir(b)) return isADir(a);
return QString::compare(a->name, b->name, Qt::CaseInsensitive) < 0;
};
}
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/797e1a4e81f3ba3794e8b6d67e13f3750f686543
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/797e1a4e81f3ba3794e8b6d67e13f3750f686543
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list