fix: build with qt5.12 on Linux and pedantic flag

Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
flow 2022-12-18 17:03:39 -03:00
parent 0e207aba6c
commit c8eca4fb85
No known key found for this signature in database
GPG Key ID: 8D0F221F0A59F469
8 changed files with 19 additions and 12 deletions

View File

@ -39,6 +39,7 @@
#include <QString> #include <QString>
#include <list> #include <list>
#include <optional>
#include "../Version.h" #include "../Version.h"

View File

@ -21,6 +21,7 @@
#include <QDialog> #include <QDialog>
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QHash>
#include <QLayout> #include <QLayout>
#include "QObjectPtr.h" #include "QObjectPtr.h"

View File

@ -35,19 +35,16 @@ class ResourceModel : public QAbstractListModel {
[[nodiscard]] virtual auto metaEntryBase() const -> QString = 0; [[nodiscard]] virtual auto metaEntryBase() const -> QString = 0;
[[nodiscard]] inline int rowCount(const QModelIndex& parent) const override { return parent.isValid() ? 0 : m_packs.size(); } [[nodiscard]] inline int rowCount(const QModelIndex& parent) const override { return parent.isValid() ? 0 : m_packs.size(); }
[[nodiscard]] inline int columnCount(const QModelIndex& parent) const override { return parent.isValid() ? 0 : 1; }; [[nodiscard]] inline int columnCount(const QModelIndex& parent) const override { return parent.isValid() ? 0 : 1; }
[[nodiscard]] inline auto flags(const QModelIndex& index) const -> Qt::ItemFlags override { return QAbstractListModel::flags(index); }; [[nodiscard]] inline auto flags(const QModelIndex& index) const -> Qt::ItemFlags override { return QAbstractListModel::flags(index); }
inline void addActiveJob(Task::Ptr ptr) { m_current_job.addTask(ptr); if (!m_current_job.isRunning()) m_current_job.start(); } inline void addActiveJob(Task::Ptr ptr) { m_current_job.addTask(ptr); if (!m_current_job.isRunning()) m_current_job.start(); }
inline Task const& activeJob() { return m_current_job; } inline Task const& activeJob() { return m_current_job; }
signals:
void versionListUpdated();
void projectInfoUpdated();
public slots: public slots:
void fetchMore(const QModelIndex& parent) override; void fetchMore(const QModelIndex& parent) override;
[[nodiscard]] inline bool canFetchMore(const QModelIndex& parent) const override // NOTE: Can't use [[nodiscard]] here because of https://bugreports.qt.io/browse/QTBUG-58628 on Qt 5.12
inline bool canFetchMore(const QModelIndex& parent) const override
{ {
return parent.isValid() ? false : m_search_state == SearchState::CanFetchMore; return parent.isValid() ? false : m_search_state == SearchState::CanFetchMore;
} }
@ -105,6 +102,10 @@ class ResourceModel : public QAbstractListModel {
/* Default search request callbacks */ /* Default search request callbacks */
void searchRequestFailed(QString reason, int network_error_code); void searchRequestFailed(QString reason, int network_error_code);
void searchRequestAborted(); void searchRequestAborted();
signals:
void versionListUpdated();
void projectInfoUpdated();
}; };
} // namespace ResourceDownload } // namespace ResourceDownload

View File

@ -302,7 +302,9 @@ void ResourcePage::openUrl(const QUrl& url)
QRegularExpressionMatch match; QRegularExpressionMatch match;
QString page; QString page;
for (auto&& [regex, candidate] : urlHandlers().asKeyValueRange()) { auto handlers = urlHandlers();
for (auto it = handlers.constKeyValueBegin(); it != handlers.constKeyValueEnd(); it++) {
auto&& [regex, candidate] = *it;
if (match = QRegularExpression(regex).match(address); match.hasMatch()) { if (match = QRegularExpression(regex).match(address); match.hasMatch()) {
page = candidate; page = candidate;
break; break;

View File

@ -75,8 +75,10 @@ class ResourcePage : public QWidget, public BasePage {
void onVersionSelectionChanged(QString data); void onVersionSelectionChanged(QString data);
void onResourceSelected(); void onResourceSelected();
// NOTE: Can't use [[nodiscard]] here because of https://bugreports.qt.io/browse/QTBUG-58628 on Qt 5.12
/** Associates regex expressions to pages in the order they're given in the map. */ /** Associates regex expressions to pages in the order they're given in the map. */
[[nodiscard]] virtual QMap<QString, QString> urlHandlers() const = 0; virtual QMap<QString, QString> urlHandlers() const = 0;
virtual void openUrl(const QUrl&); virtual void openUrl(const QUrl&);
/** Whether the version is opted out or not. Currently only makes sense in CF. */ /** Whether the version is opted out or not. Currently only makes sense in CF. */

View File

@ -49,7 +49,7 @@ static inline QString displayName() { return "CurseForge"; }
static inline QIcon icon() { return APPLICATION->getThemedIcon("flame"); } static inline QIcon icon() { return APPLICATION->getThemedIcon("flame"); }
static inline QString id() { return "curseforge"; } static inline QString id() { return "curseforge"; }
static inline QString debugName() { return "Flame"; } static inline QString debugName() { return "Flame"; }
static inline QString metaEntryBase() { return "FlameMods"; }; static inline QString metaEntryBase() { return "FlameMods"; }
} }
class FlameModPage : public ModPage { class FlameModPage : public ModPage {

View File

@ -26,7 +26,7 @@ namespace ResourceDownload {
// NOLINTNEXTLINE(modernize-avoid-c-arrays) // NOLINTNEXTLINE(modernize-avoid-c-arrays)
const char* ModrinthModModel::sorts[5]{ "relevance", "downloads", "follows", "updated", "newest" }; const char* ModrinthModModel::sorts[5]{ "relevance", "downloads", "follows", "updated", "newest" };
ModrinthModModel::ModrinthModModel(BaseInstance const& base) : ModModel(base, new ModrinthAPI){}; ModrinthModModel::ModrinthModModel(BaseInstance const& base) : ModModel(base, new ModrinthAPI) {}
void ModrinthModModel::loadIndexedPack(ModPlatform::IndexedPack& m, QJsonObject& obj) void ModrinthModModel::loadIndexedPack(ModPlatform::IndexedPack& m, QJsonObject& obj)
{ {

View File

@ -48,7 +48,7 @@ static inline QString displayName() { return "Modrinth"; }
static inline QIcon icon() { return APPLICATION->getThemedIcon("modrinth"); } static inline QIcon icon() { return APPLICATION->getThemedIcon("modrinth"); }
static inline QString id() { return "modrinth"; } static inline QString id() { return "modrinth"; }
static inline QString debugName() { return "Modrinth"; } static inline QString debugName() { return "Modrinth"; }
static inline QString metaEntryBase() { return "ModrinthPacks"; }; static inline QString metaEntryBase() { return "ModrinthPacks"; }
} }
class ModrinthModPage : public ModPage { class ModrinthModPage : public ModPage {