File: cmodlistview_moc.h

package info (click to toggle)
vcmi 1.6.5%2Bdfsg-2
  • links: PTS, VCS
  • area: contrib
  • in suites: forky, sid, trixie
  • size: 32,060 kB
  • sloc: cpp: 238,971; python: 265; sh: 224; xml: 157; ansic: 78; objc: 61; makefile: 49
file content (150 lines) | stat: -rw-r--r-- 4,283 bytes parent folder | download
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
 * cmodlistview_moc.h, part of VCMI engine
 *
 * Authors: listed in file AUTHORS in main folder
 *
 * License: GNU General Public License v2.0 or later
 * Full text of license available in license.txt file, in main folder
 *
 */
#pragma once

#include "../StdInc.h"
#include "../../lib/CConfigHandler.h"

namespace Ui
{
class CModListView;
}

class ModStateController;
class CModList;
class ModStateItemModel;
class ModStateModel;
class CModFilterModel;
class CDownloadManager;
class QTableWidgetItem;

class ModState;

class CModListView : public QWidget
{
	Q_OBJECT

	std::shared_ptr<ModStateModel> modStateModel;
	std::unique_ptr<ModStateController> manager;
	ModStateItemModel * modModel;
	CModFilterModel * filterModel;
	CDownloadManager * dlManager;
	JsonNode accumulatedRepositoryData;
	QString activatingPreset;

	QStringList enqueuedModDownloads;

	void setupModModel();
	void setupFilterModel();
	void setupModsView();

	void checkManagerErrors();

	/// replace mod ID's with proper human-readable mod names
	QStringList getModNames(QString queryingMod, QStringList input);

	/// returns list of mods that are needed for install of this mod (potentially including this mod itself)
	QStringList getModsToInstall(QString mod);

	// find mods unknown to mod list (not present in repo and not installed)
	QStringList findUnavailableMods(QStringList candidates);

	void installMods(QStringList archives);
	void installMaps(QStringList maps);

	QString genChangelogText(const ModState & mod);
	QString genModInfoText(const ModState & mod);

	void changeEvent(QEvent *event) override;

public:
	explicit CModListView(QWidget * parent = nullptr);
	~CModListView();

	void loadScreenshots();
	void loadRepositories();

	void reload();

	void disableModInfo();

	void selectMod(const QModelIndex & index);

	// First Launch View interface

	/// install mod by name
	void doInstallMod(const QString & modName);

	/// update mod by name
	void doUpdateMod(const QString & modName);

	/// returns true if mod is available in repository and can be installed
	bool isModAvailable(const QString & modName);

	/// finds translation mod for specified languages. Returns empty string on error
	QString getTranslationModName(const QString & language);

	/// finds all already imported Heroes Chronicles mods (if any)
	QStringList getInstalledChronicles();

	/// finds all mods that can be updated
	QStringList getUpdateableMods();

	void createNewPreset(const QString & presetName);
	void deletePreset(const QString & presetName);
	void activatePreset(const QString & presetName);
	void renamePreset(const QString & oldPresetName, const QString & newPresetName);

	QStringList getAllPresets() const;
	QString getActivePreset() const;

	JsonNode exportCurrentPreset() const;
	void importPreset(const JsonNode & data);

	/// returns true if mod is currently enabled
	bool isModEnabled(const QString & modName);

	/// returns true if mod is currently installed
	bool isModInstalled(const QString & modName);

	void downloadMod(const ModState & mod);
	void downloadFile(QString file, QUrl url, QString description, qint64 sizeBytes = 0);
	void installFiles(QStringList mods);

public slots:
	void enableModByName(QString modName);
	void disableModByName(QString modName);

private slots:
	void dataChanged(const QModelIndex & topleft, const QModelIndex & bottomRight);
	void modSelected(const QModelIndex & current, const QModelIndex & previous);
	void downloadProgress(qint64 current, qint64 max);
	void extractionProgress(qint64 current, qint64 max);
	void downloadFinished(QStringList savedFiles, QStringList failedFiles, QStringList errors);
	void modelReset();
	void hideProgressBar();

	void on_lineEdit_textChanged(const QString & arg1);
	void on_comboBox_currentIndexChanged(int index);
	void on_enableButton_clicked();
	void on_disableButton_clicked();
	void on_updateButton_clicked();
	void on_uninstallButton_clicked();
	void on_installButton_clicked();
	void on_pushButton_clicked();
	void on_refreshButton_clicked();
	void on_allModsView_activated(const QModelIndex & index);
	void on_tabWidget_currentChanged(int index);
	void on_screenshotsList_clicked(const QModelIndex & index);
	void on_allModsView_doubleClicked(const QModelIndex &index);

private:
	Ui::CModListView * ui;
};