summaryrefslogtreecommitdiff
path: root/src/modlist.cpp
diff options
context:
space:
mode:
authorTannin <devnull@localhost>2013-11-06 18:35:27 +0100
committerTannin <devnull@localhost>2013-11-06 18:35:27 +0100
commitf010c22a3b2ec31bc4ebc3f577ac4455c5de5dfb (patch)
treeca37c8e7480b449289c091dd040bc3f782a52dd0 /src/modlist.cpp
parentd1594798e6e78bb329e744a72e92d3f292f38a20 (diff)
- 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
Diffstat (limited to 'src/modlist.cpp')
-rw-r--r--src/modlist.cpp49
1 files changed, 43 insertions, 6 deletions
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<void (const QString &, IModList::ModStates)> &func)
+{
+ auto conn = m_ModStateChanged.connect(func);
+ return conn.connected();
+}
+
bool ModList::dropURLs(const QMimeData *mimeData, int row, const QModelIndex &parent)
{
QStringList source;