9c57b54a81
This also adds some comments around ModModel.cpp and ModPage.cpp to add some ease of reading the code. Also move some things from headers to cpp files.
69 lines
1.9 KiB
C++
69 lines
1.9 KiB
C++
#pragma once
|
|
|
|
#include <QWidget>
|
|
|
|
#include "Application.h"
|
|
#include "modplatform/ModAPI.h"
|
|
#include "modplatform/ModIndex.h"
|
|
#include "ui/pages/BasePage.h"
|
|
#include "ui/pages/modplatform/ModModel.h"
|
|
|
|
class ModDownloadDialog;
|
|
|
|
namespace Ui {
|
|
class ModPage;
|
|
}
|
|
|
|
/* This page handles most logic related to browsing and selecting mods to download.
|
|
* By default, the methods provided work with net requests, to fetch data from remote APIs. */
|
|
class ModPage : public QWidget, public BasePage {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit ModPage(ModDownloadDialog* dialog, BaseInstance* instance, ModAPI* api);
|
|
virtual ~ModPage();
|
|
|
|
/* 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;
|
|
virtual QString debugName() const = 0;
|
|
|
|
|
|
virtual bool shouldDisplay() const override = 0;
|
|
virtual bool validateVersion(ModPlatform::IndexedVersion& ver, QString mineVer, QString loaderVer = "") const = 0;
|
|
|
|
const ModAPI* apiProvider() const { return api.get(); };
|
|
|
|
ModPlatform::IndexedPack& getCurrent() { return current; }
|
|
void updateModVersions();
|
|
|
|
void openedImpl() override;
|
|
bool eventFilter(QObject* watched, QEvent* event) override;
|
|
|
|
BaseInstance* m_instance;
|
|
|
|
protected:
|
|
void updateSelectionButton();
|
|
|
|
protected slots:
|
|
void triggerSearch();
|
|
void onSelectionChanged(QModelIndex first, QModelIndex second);
|
|
void onVersionSelectionChanged(QString data);
|
|
void onModSelected();
|
|
|
|
protected:
|
|
Ui::ModPage* ui = nullptr;
|
|
ModDownloadDialog* dialog = nullptr;
|
|
ModPlatform::ListModel* listModel = nullptr;
|
|
ModPlatform::IndexedPack current;
|
|
|
|
std::unique_ptr<ModAPI> api;
|
|
|
|
int selectedVersion = -1;
|
|
};
|