diff options
Diffstat (limited to 'src/modlistproxy.cpp')
| -rw-r--r-- | src/modlistproxy.cpp | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/modlistproxy.cpp b/src/modlistproxy.cpp index 8fcbdbdf..991476da 100644 --- a/src/modlistproxy.cpp +++ b/src/modlistproxy.cpp @@ -1,11 +1,26 @@ #include "modlistproxy.h" #include "organizerproxy.h" #include "proxyutils.h" +#include "modlist.h" using namespace MOBase; +using namespace MOShared; -ModListProxy::ModListProxy(OrganizerProxy* oproxy, IModList* modlist) : - m_OrganizerProxy(oproxy), m_Proxied(modlist) { } +ModListProxy::ModListProxy(OrganizerProxy* oproxy, ModList* modlist) : + m_OrganizerProxy(oproxy), m_Proxied(modlist) +{ + m_Connections.push_back(m_Proxied->onModInstalled(callSignalIfPluginActive(m_OrganizerProxy, m_ModInstalled))); + m_Connections.push_back(m_Proxied->onModMoved(callSignalIfPluginActive(m_OrganizerProxy, m_ModMoved))); + m_Connections.push_back(m_Proxied->onModRemoved(callSignalIfPluginActive(m_OrganizerProxy, m_ModRemoved))); + m_Connections.push_back(m_Proxied->onModStateChanged(callSignalIfPluginActive(m_OrganizerProxy, m_ModStateChanged))); +} + +ModListProxy::~ModListProxy() +{ + for (auto& conn : m_Connections) { + conn.disconnect(); + } +} QString ModListProxy::displayName(const QString& internalName) const { @@ -59,20 +74,20 @@ bool ModListProxy::setPriority(const QString& name, int newPriority) bool ModListProxy::onModInstalled(const std::function<void(IModInterface*)>& func) { - return m_Proxied->onModInstalled(MOShared::callIfPluginActive(m_OrganizerProxy, func)); + return m_ModInstalled.connect(func).connected(); } bool ModListProxy::onModRemoved(const std::function<void(QString const&)>& func) { - return m_Proxied->onModRemoved(MOShared::callIfPluginActive(m_OrganizerProxy, func)); + return m_ModRemoved.connect(func).connected(); } bool ModListProxy::onModStateChanged(const std::function<void(const std::map<QString, ModStates>&)>& func) { - return m_Proxied->onModStateChanged(MOShared::callIfPluginActive(m_OrganizerProxy, func)); + return m_ModStateChanged.connect(func).connected(); } bool ModListProxy::onModMoved(const std::function<void(const QString&, int, int)>& func) { - return m_Proxied->onModMoved(MOShared::callIfPluginActive(m_OrganizerProxy, func)); + return m_ModMoved.connect(func).connected(); } |
