diff --git a/launcher/minecraft/mod/DataPack.cpp b/launcher/minecraft/mod/DataPack.cpp index 4ef13d10d..ee4d4f1a6 100644 --- a/launcher/minecraft/mod/DataPack.cpp +++ b/launcher/minecraft/mod/DataPack.cpp @@ -65,12 +65,12 @@ std::pair DataPack::compatibleVersions() const return s_pack_format_versions.constFind(m_pack_format).value(); } -int DataPack::compare(const Resource& other, SortType type, Qt::SortOrder order) const +int DataPack::compare(const Resource& other, SortType type) const { auto const& cast_other = static_cast(other); switch (type) { default: - return Resource::compare(other, type, order); + return Resource::compare(other, type); case SortType::PACK_FORMAT: { auto this_ver = packFormat(); auto other_ver = cast_other.packFormat(); diff --git a/launcher/minecraft/mod/DataPack.h b/launcher/minecraft/mod/DataPack.h index 3bc4888da..4855b0203 100644 --- a/launcher/minecraft/mod/DataPack.h +++ b/launcher/minecraft/mod/DataPack.h @@ -56,7 +56,7 @@ class DataPack : public Resource { bool valid() const override; - [[nodiscard]] int compare(Resource const& other, SortType type, Qt::SortOrder order = Qt::SortOrder::AscendingOrder) const override; + [[nodiscard]] int compare(Resource const& other, SortType type) const override; [[nodiscard]] bool applyFilter(QRegularExpression filter) const override; protected: diff --git a/launcher/minecraft/mod/Mod.cpp b/launcher/minecraft/mod/Mod.cpp index af033c051..e92079055 100644 --- a/launcher/minecraft/mod/Mod.cpp +++ b/launcher/minecraft/mod/Mod.cpp @@ -78,11 +78,11 @@ void Mod::setDetails(const ModDetails& details) m_local_details = details; } -int Mod::compare(const Resource& other, SortType type, Qt::SortOrder order) const +int Mod::compare(const Resource& other, SortType type) const { auto cast_other = dynamic_cast(&other); if (!cast_other) - return Resource::compare(other, type, order); + return Resource::compare(other, type); switch (type) { default: @@ -90,7 +90,7 @@ int Mod::compare(const Resource& other, SortType type, Qt::SortOrder order) cons case SortType::NAME: case SortType::DATE: case SortType::SIZE: - return Resource::compare(other, type, order); + return Resource::compare(other, type); case SortType::VERSION: { auto this_ver = Version(version()); auto other_ver = Version(cast_other->version()); diff --git a/launcher/minecraft/mod/Mod.h b/launcher/minecraft/mod/Mod.h index ac7fd1be9..a0c68688d 100644 --- a/launcher/minecraft/mod/Mod.h +++ b/launcher/minecraft/mod/Mod.h @@ -88,7 +88,7 @@ class Mod : public Resource { bool valid() const override; - [[nodiscard]] int compare(Resource const& other, SortType type, Qt::SortOrder order = Qt::SortOrder::AscendingOrder) const override; + [[nodiscard]] int compare(Resource const& other, SortType type) const override; [[nodiscard]] bool applyFilter(QRegularExpression filter) const override; // Delete all the files of this mod diff --git a/launcher/minecraft/mod/Resource.cpp b/launcher/minecraft/mod/Resource.cpp index 68594d741..863b0165f 100644 --- a/launcher/minecraft/mod/Resource.cpp +++ b/launcher/minecraft/mod/Resource.cpp @@ -79,7 +79,7 @@ static void removeThePrefix(QString& string) string = string.trimmed(); } -int Resource::compare(const Resource& other, SortType type, Qt::SortOrder order) const +int Resource::compare(const Resource& other, SortType type) const { switch (type) { default: @@ -105,12 +105,11 @@ int Resource::compare(const Resource& other, SortType type, Qt::SortOrder order) return -1; break; case SortType::SIZE: { - auto order_op = order == Qt::SortOrder::AscendingOrder ? 1 : -1; if (this->type() != other.type()) { if (this->type() == ResourceType::FOLDER) - return -1 * order_op; + return -1; if (other.type() == ResourceType::FOLDER) - return 1 * order_op; + return 1; } if (sizeInfo() > other.sizeInfo()) diff --git a/launcher/minecraft/mod/Resource.h b/launcher/minecraft/mod/Resource.h index 19f0e352b..222f07afa 100644 --- a/launcher/minecraft/mod/Resource.h +++ b/launcher/minecraft/mod/Resource.h @@ -55,11 +55,8 @@ class Resource : public QObject { * > 0: 'this' comes after 'other' * = 0: 'this' is equal to 'other' * < 0: 'this' comes before 'other' - * the order is used to force items to be allways at top and not used for sorting */ - [[nodiscard]] virtual int compare(Resource const& other, - SortType type = SortType::NAME, - Qt::SortOrder order = Qt::SortOrder::AscendingOrder) const; + [[nodiscard]] virtual int compare(Resource const& other, SortType type = SortType::NAME) const; /** Returns whether the given filter should filter out 'this' (false), * or if such filter includes the Resource (true). diff --git a/launcher/minecraft/mod/ResourceFolderModel.cpp b/launcher/minecraft/mod/ResourceFolderModel.cpp index dde9a67b1..254342ee1 100644 --- a/launcher/minecraft/mod/ResourceFolderModel.cpp +++ b/launcher/minecraft/mod/ResourceFolderModel.cpp @@ -615,7 +615,7 @@ SortType ResourceFolderModel::columnToSortKey(size_t column) const auto const& resource_left = model->at(source_left.row()); auto const& resource_right = model->at(source_right.row()); - auto compare_result = resource_left.compare(resource_right, column_sort_key, sortOrder()); + auto compare_result = resource_left.compare(resource_right, column_sort_key); if (compare_result == 0) return QSortFilterProxyModel::lessThan(source_left, source_right); diff --git a/launcher/minecraft/mod/ResourcePack.cpp b/launcher/minecraft/mod/ResourcePack.cpp index ac4e1adaa..5b26503f5 100644 --- a/launcher/minecraft/mod/ResourcePack.cpp +++ b/launcher/minecraft/mod/ResourcePack.cpp @@ -94,12 +94,12 @@ std::pair ResourcePack::compatibleVersions() const return s_pack_format_versions.constFind(m_pack_format).value(); } -int ResourcePack::compare(const Resource& other, SortType type, Qt::SortOrder order) const +int ResourcePack::compare(const Resource& other, SortType type) const { auto const& cast_other = static_cast(other); switch (type) { default: - return Resource::compare(other, type, order); + return Resource::compare(other, type); case SortType::PACK_FORMAT: { auto this_ver = packFormat(); auto other_ver = cast_other.packFormat(); diff --git a/launcher/minecraft/mod/ResourcePack.h b/launcher/minecraft/mod/ResourcePack.h index b14623d6b..2254fc5c4 100644 --- a/launcher/minecraft/mod/ResourcePack.h +++ b/launcher/minecraft/mod/ResourcePack.h @@ -44,7 +44,7 @@ class ResourcePack : public Resource { bool valid() const override; - [[nodiscard]] int compare(Resource const& other, SortType type, Qt::SortOrder order = Qt::SortOrder::AscendingOrder) const override; + [[nodiscard]] int compare(Resource const& other, SortType type) const override; [[nodiscard]] bool applyFilter(QRegularExpression filter) const override; protected: