diff options
| author | Mikaël Capelle <capelle.mikael@gmail.com> | 2020-12-02 21:09:42 +0100 |
|---|---|---|
| committer | Mikaël Capelle <capelle.mikael@gmail.com> | 2020-12-02 21:09:42 +0100 |
| commit | 4240f10260cbffbff52bf2d549100f4690a642b5 (patch) | |
| tree | 5d436edb1f04d3ce8f7a54ce463f4049da1e54ad /src/modlistproxy.cpp | |
| parent | cb453a9ba70106832eec2cb0feecbd91d2e8b7d7 (diff) | |
Fix callbacks for pluginlist, modlist and download manager.
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(); } |
