chore: Re-simplify IndexVersionType and MessageLevel with c++20

This sets our compiler requirements to gcc 11 and clang 13. If we
forgo the use of `using enum` we can drop to gcc 10 and clang 10 but
that means using `MessageLevel::Enum::Unknown` for direct enum access

Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
Rachel Powers
2025-12-11 09:35:48 -07:00
parent 30f24dae11
commit d1b6d7c402
15 changed files with 76 additions and 46 deletions

View File

@@ -23,6 +23,7 @@
#include <QMetaType>
#include <QString>
#include <QVariant>
#include <compare>
#include <memory>
class QIODevice;
@@ -74,9 +75,22 @@ struct DonationData {
QString url;
};
enum class IndexedVersionType { Unknown, Release = 1, Beta, Alpha };
IndexedVersionType indexedVersionTypeFromString(const QString& type);
QString indexedVersionTypeToString(IndexedVersionType type);
struct IndexedVersionType {
enum class Enum { Unknown, Release = 1, Beta, Alpha };
using enum Enum;
constexpr IndexedVersionType(Enum e = Unknown) : m_type(e) {}
static IndexedVersionType fromString(const QString& type);
inline bool isValid() const { return m_type != Unknown; }
std::strong_ordering operator<=>(const IndexedVersionType& other) const = default;
std::strong_ordering operator<=>(const IndexedVersionType::Enum& other) const { return m_type <=> other; }
QString toString() const;
explicit operator int() const { return static_cast<int>(m_type); }
explicit operator IndexedVersionType::Enum() { return m_type; }
private:
Enum m_type;
};
struct Dependency {
QVariant addonId;
@@ -107,7 +121,8 @@ struct IndexedVersion {
QString getVersionDisplayString() const
{
auto release_type = version_type != IndexedVersionType::Unknown ? QString(" [%1]").arg(indexedVersionTypeToString(version_type)) : "";
auto release_type =
version_type.isValid() ? QString(" [%1]").arg(version_type.toString()) : "";
auto versionStr = !version.contains(version_number) ? version_number : "";
QString gameVersion = "";
for (auto v : mcVersion) {