cmodlistview_moc.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*
  2. * cmodlistview_moc.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "../StdInc.h"
  12. #include "../../lib/CConfigHandler.h"
  13. namespace Ui
  14. {
  15. class CModListView;
  16. }
  17. class ModStateController;
  18. class CModList;
  19. class ModStateItemModel;
  20. class ModStateModel;
  21. class CModFilterModel;
  22. class CDownloadManager;
  23. class QTableWidgetItem;
  24. class ModState;
  25. class CModListView : public QWidget
  26. {
  27. Q_OBJECT
  28. std::shared_ptr<ModStateModel> modStateModel;
  29. std::unique_ptr<ModStateController> manager;
  30. ModStateItemModel * modModel;
  31. CModFilterModel * filterModel;
  32. CDownloadManager * dlManager;
  33. JsonNode accumulatedRepositoryData;
  34. QString activatingPreset;
  35. QStringList enqueuedModDownloads;
  36. void setupModModel();
  37. void setupFilterModel();
  38. void setupModsView();
  39. void checkManagerErrors();
  40. /// replace mod ID's with proper human-readable mod names
  41. QStringList getModNames(QString queryingMod, QStringList input);
  42. /// returns list of mods that are needed for install of this mod (potentially including this mod itself)
  43. QStringList getModsToInstall(QString mod);
  44. // find mods unknown to mod list (not present in repo and not installed)
  45. QStringList findUnavailableMods(QStringList candidates);
  46. void installMods(QStringList archives);
  47. void installMaps(QStringList maps);
  48. QString genChangelogText(const ModState & mod);
  49. QString genModInfoText(const ModState & mod);
  50. void changeEvent(QEvent *event) override;
  51. auto buttonEnabledState(QString modName, ModState & mod);
  52. public:
  53. explicit CModListView(QWidget * parent = nullptr);
  54. ~CModListView();
  55. void loadScreenshots();
  56. void loadRepositories();
  57. void reload(const QString& modToSelect = QString());
  58. void disableModInfo();
  59. void selectMod(const QModelIndex & index);
  60. // First Launch View interface
  61. /// install mod by name
  62. void doInstallMod(const QString & modName);
  63. /// uninstall mod by name
  64. void doUninstallMod(const QString & modName);
  65. /// update mod by name
  66. void doUpdateMod(const QString & modName);
  67. /// open mod dictionary by name
  68. void openModDictionary(const QString & modName);
  69. /// returns true if mod is available in repository and can be installed
  70. bool isModAvailable(const QString & modName);
  71. /// finds translation mod for specified languages. Returns empty string on error
  72. QString getTranslationModName(const QString & language);
  73. /// finds all already imported Heroes Chronicles mods (if any)
  74. QStringList getInstalledChronicles();
  75. /// finds all mods that can be updated
  76. QStringList getUpdateableMods();
  77. void createNewPreset(const QString & presetName);
  78. void deletePreset(const QString & presetName);
  79. void activatePreset(const QString & presetName);
  80. void renamePreset(const QString & oldPresetName, const QString & newPresetName);
  81. QStringList getAllPresets() const;
  82. QString getActivePreset() const;
  83. JsonNode exportCurrentPreset() const;
  84. void importPreset(const JsonNode & data);
  85. /// returns true if mod is currently enabled
  86. bool isModEnabled(const QString & modName);
  87. /// returns true if mod is currently installed
  88. bool isModInstalled(const QString & modName);
  89. void downloadMod(const ModState & mod);
  90. void downloadFile(QString file, QUrl url, QString description, qint64 sizeBytes = 0);
  91. void installFiles(QStringList mods);
  92. public slots:
  93. void enableModByName(QString modName);
  94. void disableModByName(QString modName);
  95. private slots:
  96. void onCustomContextMenu(const QPoint &point);
  97. void dataChanged(const QModelIndex & topleft, const QModelIndex & bottomRight);
  98. void modSelected(const QModelIndex & current, const QModelIndex & previous);
  99. void downloadProgress(qint64 current, qint64 max);
  100. void extractionProgress(qint64 current, qint64 max);
  101. void downloadFinished(QStringList savedFiles, QStringList failedFiles, QStringList errors);
  102. void modelReset();
  103. void hideProgressBar();
  104. void on_lineEdit_textChanged(const QString & arg1);
  105. void on_comboBox_currentIndexChanged(int index);
  106. void on_enableButton_clicked();
  107. void on_disableButton_clicked();
  108. void on_updateButton_clicked();
  109. void on_uninstallButton_clicked();
  110. void on_installButton_clicked();
  111. void on_abortButton_clicked();
  112. void on_refreshButton_clicked();
  113. void on_allModsView_activated(const QModelIndex & index);
  114. void on_tabWidget_currentChanged(int index);
  115. void on_screenshotsList_clicked(const QModelIndex & index);
  116. void on_allModsView_doubleClicked(const QModelIndex &index);
  117. private:
  118. Ui::CModListView * ui;
  119. };