diff options
| author | Mikaƫl Capelle <capelle.mikael@gmail.com> | 2021-01-10 10:25:37 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-10 10:25:37 +0100 |
| commit | 80e44a9e3ade61695b4807a3a900d2866138ecac (patch) | |
| tree | 1ef9904664d8d34dba6692bbf5325aea8c199d08 /src/modlistviewactions.h | |
| parent | eaec140f7c823012c09536175d8917dddcacdb7c (diff) | |
| parent | 4a0ce804ea486744e5f6140a0ce4538d99e21ce3 (diff) | |
Merge pull request #1338 from Holt59/collapsible-separators
Collapsible separators (and refactoring).
Diffstat (limited to 'src/modlistviewactions.h')
| -rw-r--r-- | src/modlistviewactions.h | 158 |
1 files changed, 158 insertions, 0 deletions
diff --git a/src/modlistviewactions.h b/src/modlistviewactions.h new file mode 100644 index 00000000..f1215cec --- /dev/null +++ b/src/modlistviewactions.h @@ -0,0 +1,158 @@ +#ifndef MODLISTVIEWACTIONS_H +#define MODLISTVIEWACTIONS_H + +#include <QObject> +#include <QString> + +#include "modinfo.h" +#include "modinfodialogfwd.h" + +class CategoryFactory; +class FilterList; +class MainWindow; +class ModListView; +class PluginListView; +class OrganizerCore; + +class ModListViewActions : public QObject +{ + Q_OBJECT + +public: + + // currently passing the main window itself because a lots of stuff needs it but + // it would be nice to avoid passing it at some point + // + ModListViewActions( + OrganizerCore& core, + FilterList& filters, + CategoryFactory& categoryFactory, + ModListView* view, + PluginListView* pluginView, + QObject* nxmReceiver); + + // install the mod from the given archive + // + void installMod(const QString& archivePath = "") const; + + // create an empty mod/a separator before the given mod or at + // the end of the list if the index is invalid + // + void createEmptyMod(const QModelIndex& index = QModelIndex()) const; + void createSeparator(const QModelIndex& index = QModelIndex()) const; + + // check all mods for update + // + void checkModsForUpdates() const; + void checkModsForUpdates(const QModelIndexList& indices) const; + + // start the "Export Mod List" dialog + // + void exportModListCSV() const; + + // display mod information + // + void displayModInformation(const QString& modName, ModInfoTabIDs tabID = ModInfoTabIDs::None) const; + void displayModInformation(unsigned int index, ModInfoTabIDs tab = ModInfoTabIDs::None) const; + void displayModInformation(ModInfo::Ptr modInfo, unsigned int modIndex, ModInfoTabIDs tabID = ModInfoTabIDs::None) const; + + // move mods to top/bottom, start the "Send to priority" and "Send to separator" dialog + // + void sendModsToTop(const QModelIndexList& index) const; + void sendModsToBottom(const QModelIndexList& index) const; + void sendModsToPriority(const QModelIndexList& index) const; + void sendModsToSeparator(const QModelIndexList& index) const; + + // actions for most regular mods + // + void renameMod(const QModelIndex& index) const; + void removeMods(const QModelIndexList& indices) const; + void ignoreMissingData(const QModelIndexList& indices) const; + void setIgnoreUpdate(const QModelIndexList& indices, bool ignore) const; + void changeVersioningScheme(const QModelIndex& indices) const; + void markConverted(const QModelIndexList& indices) const; + void visitOnNexus(const QModelIndexList& indices) const; + void visitWebPage(const QModelIndexList& indices) const; + void visitNexusOrWebPage(const QModelIndexList& indices) const; + void reinstallMod(const QModelIndex& index) const; + void createBackup(const QModelIndex& index) const; + void restoreHiddenFiles(const QModelIndexList& indices) const; + void setTracked(const QModelIndexList& indices, bool tracked) const; + void setEndorsed(const QModelIndexList& indices, bool endorsed) const; + void willNotEndorsed(const QModelIndexList& indices) const; + + // set/reset color of the given selection, using the given reference index (index + // at which the context menu was shown) + // + void setColor(const QModelIndexList& indices, const QModelIndex& refIndex) const; + void resetColor(const QModelIndexList& indices) const; + + // set the category of the mods in the given list, using the given index as reference + // - the categories are set as-is on the refernce mod + // - for the other mods, the category is only set if the current state of the category + // on the reference is different + // + void setCategories(const QModelIndexList& selected, const QModelIndex& ref, + const std::vector<std::pair<int, bool>>& categories) const; + + // set the primary category of the mods in the given list, adding the appropriate + // category to the mods unless force is false, in which case the primary category + // is set only on mods that have this category + // + void setPrimaryCategory(const QModelIndexList& selected, int category, bool force = true); + + // open the Windows explorer for the specified mods + // + void openExplorer(const QModelIndexList& index) const; + + // backup-specific actions + // + void restoreBackup(const QModelIndex& index) const; + + // overwrite-specific actions + // + void createModFromOverwrite() const; + void moveOverwriteContentToExistingMod() const; + void clearOverwrite() const; + +signals: + + // emitted when the overwrite mod has been clear + // + void overwriteCleared() const; + + // emitted when the origin of a file is modified + // + void originModified(int originId) const; + +private: + + // move the contents of the overwrite to the given path + // + void moveOverwriteContentsTo(const QString& absolutePath) const; + + // set the category of the given mod based on the given array + // + void setCategories(ModInfo::Ptr mod, const std::vector<std::pair<int, bool>>& categories) const; + + // set the category of the given mod if the category from the reference mod does not match + // the one in the array of categories + // + void setCategoriesIf(ModInfo::Ptr mod, ModInfo::Ptr ref, const std::vector<std::pair<int, bool>>& categories) const; + + // check the given mods from update, the map should map game names to nexus ID + // + void checkModsForUpdates(std::multimap<QString, int> const& IDs) const; + +private: + + OrganizerCore& m_core; + FilterList& m_filters; + CategoryFactory& m_categories; + ModListView* m_view; + PluginListView* m_pluginView; + QObject* m_receiver; + QWidget* m_parent; +}; + +#endif |
