summaryrefslogtreecommitdiff
path: root/src/modlistproxy.cpp
blob: 1d8481ba6e088e661fe5b2c80b732afa12287935 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#include "modlistproxy.h"
#include "modlist.h"
#include "organizerproxy.h"
#include "proxyutils.h"

using namespace MOBase;
using namespace MOShared;

ModListProxy::ModListProxy(OrganizerProxy* oproxy, ModList* modlist)
    : m_OrganizerProxy(oproxy), m_Proxied(modlist)
{}

ModListProxy::~ModListProxy()
{
  disconnectSignals();
}

void ModListProxy::connectSignals()
{
  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)));
}

void ModListProxy::disconnectSignals()
{
  for (auto& conn : m_Connections) {
    conn.disconnect();
  }
  m_Connections.clear();
}

QString ModListProxy::displayName(const QString& internalName) const
{
  return m_Proxied->displayName(internalName);
}

QStringList ModListProxy::allMods() const
{
  return m_Proxied->allMods();
}

QStringList ModListProxy::allModsByProfilePriority(MOBase::IProfile* profile) const
{
  return m_Proxied->allModsByProfilePriority(profile);
}

IModInterface* ModListProxy::getMod(const QString& name) const
{
  return m_Proxied->getMod(name);
}

bool ModListProxy::removeMod(MOBase::IModInterface* mod)
{
  return m_Proxied->removeMod(mod);
}

MOBase::IModInterface* ModListProxy::renameMod(MOBase::IModInterface* mod,
                                               const QString& name)
{
  return m_Proxied->renameMod(mod, name);
}

IModList::ModStates ModListProxy::state(const QString& name) const
{
  return m_Proxied->state(name);
}

bool ModListProxy::setActive(const QString& name, bool active)
{
  return m_Proxied->setActive(name, active);
}

int ModListProxy::setActive(const QStringList& names, bool active)
{
  return m_Proxied->setActive(names, active);
}

int ModListProxy::priority(const QString& name) const
{
  return m_Proxied->priority(name);
}

bool ModListProxy::setPriority(const QString& name, int newPriority)
{
  return m_Proxied->setPriority(name, newPriority);
}

bool ModListProxy::onModInstalled(const std::function<void(IModInterface*)>& func)
{
  return m_ModInstalled.connect(func).connected();
}

bool ModListProxy::onModRemoved(const std::function<void(QString const&)>& func)
{
  return m_ModRemoved.connect(func).connected();
}

bool ModListProxy::onModStateChanged(
    const std::function<void(const std::map<QString, ModStates>&)>& func)
{
  return m_ModStateChanged.connect(func).connected();
}

bool ModListProxy::onModMoved(const std::function<void(const QString&, int, int)>& func)
{
  return m_ModMoved.connect(func).connected();
}