From d755174bee1b1c5ba507d1d407236190501c7940 Mon Sep 17 00:00:00 2001 From: flow Date: Sun, 6 Mar 2022 16:04:24 -0300 Subject: [PATCH] clarify some method names and comments --- launcher/ui/pages/modplatform/ModModel.cpp | 4 ++-- launcher/ui/pages/modplatform/ModModel.h | 16 +++++++++------- launcher/ui/pages/modplatform/ModPage.cpp | 2 +- launcher/ui/pages/modplatform/ModPage.h | 7 ++++--- .../ui/pages/modplatform/flame/FlameModPage.cpp | 2 +- .../ui/pages/modplatform/flame/FlameModPage.h | 2 +- .../pages/modplatform/modrinth/ModrinthPage.cpp | 2 +- .../ui/pages/modplatform/modrinth/ModrinthPage.h | 2 +- 8 files changed, 20 insertions(+), 17 deletions(-) diff --git a/launcher/ui/pages/modplatform/ModModel.cpp b/launcher/ui/pages/modplatform/ModModel.cpp index c71acd35..4462c20b 100644 --- a/launcher/ui/pages/modplatform/ModModel.cpp +++ b/launcher/ui/pages/modplatform/ModModel.cpp @@ -97,7 +97,7 @@ void ListModel::getLogo(const QString& logo, const QString& logoUrl, LogoCallbac } } -void ListModel::populateVersions(ModPlatform::IndexedPack const& current) +void ListModel::requestModVersions(ModPlatform::IndexedPack const& current) { auto netJob = new NetJob(QString("%1::ModVersions(%2)").arg(m_parent->debugName()).arg(current.name), APPLICATION->network()); auto response = new QByteArray(); @@ -106,7 +106,7 @@ void ListModel::populateVersions(ModPlatform::IndexedPack const& current) netJob->addNetAction(Net::Download::makeByteArray(m_parent->apiProvider()->getVersionsURL(addonId), response)); QObject::connect(netJob, &NetJob::succeeded, this, [this, response, addonId]{ - m_parent->onGetVersionsSucceeded(m_parent, response, addonId); + m_parent->onRequestVersionsSucceeded(m_parent, response, addonId); }); QObject::connect(netJob, &NetJob::finished, this, [response, netJob] { diff --git a/launcher/ui/pages/modplatform/ModModel.h b/launcher/ui/pages/modplatform/ModModel.h index 2b8ff65e..64c17b4a 100644 --- a/launcher/ui/pages/modplatform/ModModel.h +++ b/launcher/ui/pages/modplatform/ModModel.h @@ -22,25 +22,26 @@ class ListModel : public QAbstractListModel { int rowCount(const QModelIndex& parent) const override; int columnCount(const QModelIndex& parent) const override; + QVariant data(const QModelIndex& index, int role) const override; Qt::ItemFlags flags(const QModelIndex& index) const override; + bool canFetchMore(const QModelIndex& parent) const override; void fetchMore(const QModelIndex& parent) override; void getLogo(const QString& logo, const QString& logoUrl, LogoCallback callback); void searchWithTerm(const QString& term, const int sort); - virtual void populateVersions(const ModPlatform::IndexedPack& current); + virtual void requestModVersions(const ModPlatform::IndexedPack& current); protected slots: virtual void searchRequestFinished() = 0; - - void performPaginatedSearch(); + void searchRequestFailed(QString reason); void logoFailed(QString logo); void logoLoaded(QString logo, QIcon out); - void searchRequestFailed(QString reason); + void performPaginatedSearch(); protected: virtual const char** getSorts() const = 0; @@ -51,17 +52,18 @@ class ListModel : public QAbstractListModel { ModPage* m_parent; QList modpacks; - QStringList m_failedLogos; - QStringList m_loadingLogos; + LogoMap m_logoMap; QMap waitingCallbacks; + QStringList m_failedLogos; + QStringList m_loadingLogos; QString currentSearchTerm; int currentSort = 0; int nextSearchOffset = 0; enum SearchState { None, CanPossiblyFetchMore, ResetRequested, Finished } searchState = None; + NetJob::Ptr jobPtr; QByteArray response; - }; } // namespace ModPlatform diff --git a/launcher/ui/pages/modplatform/ModPage.cpp b/launcher/ui/pages/modplatform/ModPage.cpp index 68c62fb8..a57f2903 100644 --- a/launcher/ui/pages/modplatform/ModPage.cpp +++ b/launcher/ui/pages/modplatform/ModPage.cpp @@ -98,7 +98,7 @@ void ModPage::onSelectionChanged(QModelIndex first, QModelIndex second) ui->modSelectionButton->setText(tr("Loading versions...")); ui->modSelectionButton->setEnabled(false); - listModel->populateVersions(current); + listModel->requestModVersions(current); } else { for (int i = 0; i < current.versions.size(); i++) { ui->versionSelectionBox->addItem(current.versions[i].version, QVariant(i)); diff --git a/launcher/ui/pages/modplatform/ModPage.h b/launcher/ui/pages/modplatform/ModPage.h index b1681b8c..e0d7c95c 100644 --- a/launcher/ui/pages/modplatform/ModPage.h +++ b/launcher/ui/pages/modplatform/ModPage.h @@ -23,20 +23,21 @@ class ModPage : public QWidget, public BasePage { explicit ModPage(ModDownloadDialog* dialog, BaseInstance* instance, ModAPI* api); virtual ~ModPage(); - /* The name visible to the user */ + /* Affects what the user sees */ virtual QString displayName() const override = 0; virtual QIcon icon() const override = 0; virtual QString id() const override = 0; virtual QString helpPage() const override = 0; + /* Used internally */ virtual QString metaEntryBase() const = 0; - /* This only appears in the debug console */ virtual QString debugName() const = 0; + virtual bool shouldDisplay() const override = 0; const ModAPI* apiProvider() const { return api.get(); }; - virtual void onGetVersionsSucceeded(ModPage*, QByteArray*, QString) = 0; + virtual void onRequestVersionsSucceeded(ModPage*, QByteArray*, QString) = 0; void openedImpl() override; bool eventFilter(QObject* watched, QEvent* event) override; diff --git a/launcher/ui/pages/modplatform/flame/FlameModPage.cpp b/launcher/ui/pages/modplatform/flame/FlameModPage.cpp index 14766851..6564265c 100644 --- a/launcher/ui/pages/modplatform/flame/FlameModPage.cpp +++ b/launcher/ui/pages/modplatform/flame/FlameModPage.cpp @@ -36,7 +36,7 @@ FlameModPage::FlameModPage(ModDownloadDialog* dialog, BaseInstance* instance) bool FlameModPage::shouldDisplay() const { return true; } -void FlameModPage::onGetVersionsSucceeded(ModPage* instance, QByteArray* response, QString addonId) +void FlameModPage::onRequestVersionsSucceeded(ModPage* instance, QByteArray* response, QString addonId) { if (addonId != current.addonId) { return; // wrong request diff --git a/launcher/ui/pages/modplatform/flame/FlameModPage.h b/launcher/ui/pages/modplatform/flame/FlameModPage.h index 7e8d6707..9c6f0e6c 100644 --- a/launcher/ui/pages/modplatform/flame/FlameModPage.h +++ b/launcher/ui/pages/modplatform/flame/FlameModPage.h @@ -22,5 +22,5 @@ class FlameModPage : public ModPage { bool shouldDisplay() const override; private: - void onGetVersionsSucceeded(ModPage*, QByteArray*, QString) override; + void onRequestVersionsSucceeded(ModPage*, QByteArray*, QString) override; }; diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp index 7ac9b406..944f8afb 100644 --- a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp +++ b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp @@ -35,7 +35,7 @@ ModrinthPage::ModrinthPage(ModDownloadDialog* dialog, BaseInstance* instance) bool ModrinthPage::shouldDisplay() const { return true; } -void ModrinthPage::onGetVersionsSucceeded(ModPage* instance, QByteArray* response, QString addonId) +void ModrinthPage::onRequestVersionsSucceeded(ModPage* instance, QByteArray* response, QString addonId) { if (addonId != current.addonId) { return; } QJsonParseError parse_error; diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.h b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.h index 0112c5ea..7b1d0a00 100644 --- a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.h +++ b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.h @@ -22,5 +22,5 @@ class ModrinthPage : public ModPage { bool shouldDisplay() const override; private: - void onGetVersionsSucceeded(ModPage*, QByteArray*, QString) override; + void onRequestVersionsSucceeded(ModPage*, QByteArray*, QString) override; };