blob: cd034a3a8f5b6675d0099b20a004a72e15bd4d78 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#pragma once
#include <Application.h>
#include <QWidget>
#include "modplatform/ModAPI.h"
#include "modplatform/ModIndex.h"
#include "tasks/Task.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();
/* The name visible to the user */
virtual QString displayName() const override = 0;
virtual QIcon icon() const override = 0;
virtual QString id() const override = 0;
virtual QString helpPage() const override = 0;
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(); };
void openedImpl() override;
bool eventFilter(QObject* watched, QEvent* event) override;
BaseInstance* m_instance;
protected:
virtual void onModVersionSucceed(ModPage*, QByteArray*, QString) = 0;
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;
};
|