From f010c22a3b2ec31bc4ebc3f577ac4455c5de5dfb Mon Sep 17 00:00:00 2001 From: Tannin Date: Wed, 6 Nov 2013 18:35:27 +0100 Subject: - diagnosis plugins can now request to be re-evaluated - main application now contains means for plugins to react on some changes (to be extended) - plugins can now retrieve more information about a mod - user-agent sent to nexus now automatically contains the current MO version - included updated russian translation - problems dialog now refreshes itself after a fix was applied - fixed new esp/asset ordering diagnosis. May be fully functional now - bugfix: restoring locked load order could leave MO in an endless loop (not sure if this fix is correct yet) - bugfix: plugin list was not visually updated after some changes - bugfix: nmm importer threw away mod ordering --- src/modlist.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 6 deletions(-) (limited to 'src/modlist.cpp') diff --git a/src/modlist.cpp b/src/modlist.cpp index 541e1e6e..446946dc 100644 --- a/src/modlist.cpp +++ b/src/modlist.cpp @@ -551,19 +551,49 @@ void ModList::changeModPriority(int sourceIndex, int newPriority) emit modorder_changed(); } -IModList::ModState ModList::state(const QString &name) const +void ModList::modInfoAboutToChange(ModInfo::Ptr info) { - unsigned int modIndex = ModInfo::getIndex(name); - if (modIndex == UINT_MAX) { - return IModList::STATE_MISSING; + m_ChangeInfo.name = info->name(); + m_ChangeInfo.state = state(info->name()); +} + +void ModList::modInfoChanged(ModInfo::Ptr info) +{ + if (info->name() == m_ChangeInfo.name) { + IModList::ModStates newState = state(info->name()); + if (m_ChangeInfo.state != newState) { + m_ModStateChanged(info->name(), newState); + } } else { + qCritical("modInfoChanged not called after modInfoAboutToChange"); + } +} + +IModList::ModStates ModList::state(const QString &name) const +{ + ModStates result; + unsigned int modIndex = ModInfo::getIndex(name); + if (modIndex != UINT_MAX) { + result |= IModList::STATE_EXISTS; ModInfo::Ptr modInfo = ModInfo::getByIndex(modIndex); + if (modInfo->isEmpty()) { + result |= IModList::STATE_EMPTY; + } + if (modInfo->endorsedState() == ModInfo::ENDORSED_TRUE) { + result |= IModList::STATE_ENDORSED; + } + if (modInfo->isValid()) { + result |= IModList::STATE_VALID; + } if (modInfo->canBeEnabled()) { - return m_Profile->modEnabled(modIndex) ? IModList::STATE_ACTIVE : IModList::STATE_INACTIVE; + if (m_Profile->modEnabled(modIndex)) { + result |= IModList::STATE_ACTIVE; + } } else { - return IModList::STATE_NOTOPTIONAL; + result |= IModList::STATE_ESSENTIAL; } } + return result; } int ModList::priority(const QString &name) const @@ -592,6 +622,13 @@ bool ModList::setPriority(const QString &name, int newPriority) } } + +bool ModList::onModStateChanged(const std::function &func) +{ + auto conn = m_ModStateChanged.connect(func); + return conn.connected(); +} + bool ModList::dropURLs(const QMimeData *mimeData, int row, const QModelIndex &parent) { QStringList source; -- cgit v1.3.1