clarify some method names and comments

This commit is contained in:
flow 2022-03-06 16:04:24 -03:00
parent 1229e90817
commit d755174bee
No known key found for this signature in database
GPG Key ID: 8D0F221F0A59F469
8 changed files with 20 additions and 17 deletions

View File

@ -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 netJob = new NetJob(QString("%1::ModVersions(%2)").arg(m_parent->debugName()).arg(current.name), APPLICATION->network());
auto response = new QByteArray(); 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)); netJob->addNetAction(Net::Download::makeByteArray(m_parent->apiProvider()->getVersionsURL(addonId), response));
QObject::connect(netJob, &NetJob::succeeded, this, [this, response, addonId]{ 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] { QObject::connect(netJob, &NetJob::finished, this, [response, netJob] {

View File

@ -22,25 +22,26 @@ class ListModel : public QAbstractListModel {
int rowCount(const QModelIndex& parent) const override; int rowCount(const QModelIndex& parent) const override;
int columnCount(const QModelIndex& parent) const override; int columnCount(const QModelIndex& parent) const override;
QVariant data(const QModelIndex& index, int role) const override; QVariant data(const QModelIndex& index, int role) const override;
Qt::ItemFlags flags(const QModelIndex& index) const override; Qt::ItemFlags flags(const QModelIndex& index) const override;
bool canFetchMore(const QModelIndex& parent) const override; bool canFetchMore(const QModelIndex& parent) const override;
void fetchMore(const QModelIndex& parent) override; void fetchMore(const QModelIndex& parent) override;
void getLogo(const QString& logo, const QString& logoUrl, LogoCallback callback); void getLogo(const QString& logo, const QString& logoUrl, LogoCallback callback);
void searchWithTerm(const QString& term, const int sort); void searchWithTerm(const QString& term, const int sort);
virtual void populateVersions(const ModPlatform::IndexedPack& current); virtual void requestModVersions(const ModPlatform::IndexedPack& current);
protected slots: protected slots:
virtual void searchRequestFinished() = 0; virtual void searchRequestFinished() = 0;
void searchRequestFailed(QString reason);
void performPaginatedSearch();
void logoFailed(QString logo); void logoFailed(QString logo);
void logoLoaded(QString logo, QIcon out); void logoLoaded(QString logo, QIcon out);
void searchRequestFailed(QString reason); void performPaginatedSearch();
protected: protected:
virtual const char** getSorts() const = 0; virtual const char** getSorts() const = 0;
@ -51,17 +52,18 @@ class ListModel : public QAbstractListModel {
ModPage* m_parent; ModPage* m_parent;
QList<ModPlatform::IndexedPack> modpacks; QList<ModPlatform::IndexedPack> modpacks;
QStringList m_failedLogos;
QStringList m_loadingLogos;
LogoMap m_logoMap; LogoMap m_logoMap;
QMap<QString, LogoCallback> waitingCallbacks; QMap<QString, LogoCallback> waitingCallbacks;
QStringList m_failedLogos;
QStringList m_loadingLogos;
QString currentSearchTerm; QString currentSearchTerm;
int currentSort = 0; int currentSort = 0;
int nextSearchOffset = 0; int nextSearchOffset = 0;
enum SearchState { None, CanPossiblyFetchMore, ResetRequested, Finished } searchState = None; enum SearchState { None, CanPossiblyFetchMore, ResetRequested, Finished } searchState = None;
NetJob::Ptr jobPtr; NetJob::Ptr jobPtr;
QByteArray response; QByteArray response;
}; };
} // namespace ModPlatform } // namespace ModPlatform

View File

@ -98,7 +98,7 @@ void ModPage::onSelectionChanged(QModelIndex first, QModelIndex second)
ui->modSelectionButton->setText(tr("Loading versions...")); ui->modSelectionButton->setText(tr("Loading versions..."));
ui->modSelectionButton->setEnabled(false); ui->modSelectionButton->setEnabled(false);
listModel->populateVersions(current); listModel->requestModVersions(current);
} else { } else {
for (int i = 0; i < current.versions.size(); i++) { for (int i = 0; i < current.versions.size(); i++) {
ui->versionSelectionBox->addItem(current.versions[i].version, QVariant(i)); ui->versionSelectionBox->addItem(current.versions[i].version, QVariant(i));

View File

@ -23,20 +23,21 @@ class ModPage : public QWidget, public BasePage {
explicit ModPage(ModDownloadDialog* dialog, BaseInstance* instance, ModAPI* api); explicit ModPage(ModDownloadDialog* dialog, BaseInstance* instance, ModAPI* api);
virtual ~ModPage(); virtual ~ModPage();
/* The name visible to the user */ /* Affects what the user sees */
virtual QString displayName() const override = 0; virtual QString displayName() const override = 0;
virtual QIcon icon() const override = 0; virtual QIcon icon() const override = 0;
virtual QString id() const override = 0; virtual QString id() const override = 0;
virtual QString helpPage() const override = 0; virtual QString helpPage() const override = 0;
/* Used internally */
virtual QString metaEntryBase() const = 0; virtual QString metaEntryBase() const = 0;
/* This only appears in the debug console */
virtual QString debugName() const = 0; virtual QString debugName() const = 0;
virtual bool shouldDisplay() const override = 0; virtual bool shouldDisplay() const override = 0;
const ModAPI* apiProvider() const { return api.get(); }; const ModAPI* apiProvider() const { return api.get(); };
virtual void onGetVersionsSucceeded(ModPage*, QByteArray*, QString) = 0; virtual void onRequestVersionsSucceeded(ModPage*, QByteArray*, QString) = 0;
void openedImpl() override; void openedImpl() override;
bool eventFilter(QObject* watched, QEvent* event) override; bool eventFilter(QObject* watched, QEvent* event) override;

View File

@ -36,7 +36,7 @@ FlameModPage::FlameModPage(ModDownloadDialog* dialog, BaseInstance* instance)
bool FlameModPage::shouldDisplay() const { return true; } 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) { if (addonId != current.addonId) {
return; // wrong request return; // wrong request

View File

@ -22,5 +22,5 @@ class FlameModPage : public ModPage {
bool shouldDisplay() const override; bool shouldDisplay() const override;
private: private:
void onGetVersionsSucceeded(ModPage*, QByteArray*, QString) override; void onRequestVersionsSucceeded(ModPage*, QByteArray*, QString) override;
}; };

View File

@ -35,7 +35,7 @@ ModrinthPage::ModrinthPage(ModDownloadDialog* dialog, BaseInstance* instance)
bool ModrinthPage::shouldDisplay() const { return true; } 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; } if (addonId != current.addonId) { return; }
QJsonParseError parse_error; QJsonParseError parse_error;

View File

@ -22,5 +22,5 @@ class ModrinthPage : public ModPage {
bool shouldDisplay() const override; bool shouldDisplay() const override;
private: private:
void onGetVersionsSucceeded(ModPage*, QByteArray*, QString) override; void onRequestVersionsSucceeded(ModPage*, QByteArray*, QString) override;
}; };