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 <list>
#include <optional>
#include "../Version.h"

View File

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

View File

@ -35,19 +35,16 @@ class ResourceModel : public QAbstractListModel {
[[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 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 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); }
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; }
signals:
void versionListUpdated();
void projectInfoUpdated();
public slots:
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;
}
@ -105,6 +102,10 @@ class ResourceModel : public QAbstractListModel {
/* Default search request callbacks */
void searchRequestFailed(QString reason, int network_error_code);
void searchRequestAborted();
signals:
void versionListUpdated();
void projectInfoUpdated();
};
} // namespace ResourceDownload

View File

@ -302,7 +302,9 @@ void ResourcePage::openUrl(const QUrl& url)
QRegularExpressionMatch match;
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()) {
page = candidate;
break;

View File

@ -75,8 +75,10 @@ class ResourcePage : public QWidget, public BasePage {
void onVersionSelectionChanged(QString data);
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. */
[[nodiscard]] virtual QMap<QString, QString> urlHandlers() const = 0;
virtual QMap<QString, QString> urlHandlers() const = 0;
virtual void openUrl(const QUrl&);
/** 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 QString id() { return "curseforge"; }
static inline QString debugName() { return "Flame"; }
static inline QString metaEntryBase() { return "FlameMods"; };
static inline QString metaEntryBase() { return "FlameMods"; }
}
class FlameModPage : public ModPage {

View File

@ -26,7 +26,7 @@ namespace ResourceDownload {
// NOLINTNEXTLINE(modernize-avoid-c-arrays)
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)
{

View File

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