forked from Chatterino/chatterino2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompletionmanager.cpp
70 lines (54 loc) · 2.04 KB
/
completionmanager.cpp
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
#include "completionmanager.hpp"
#include "common.hpp"
#include "emotemanager.hpp"
namespace chatterino {
CompletionManager::CompletionManager(EmoteManager &_emoteManager)
: emoteManager(_emoteManager)
{
}
CompletionModel *CompletionManager::createModel(const std::string &channelName)
{
CompletionModel *ret = new CompletionModel();
this->updateModel(ret, channelName);
this->emoteManager.bttvGlobalEmoteCodes.updated.connect([=]() {
this->updateModel(ret, channelName); //
});
this->emoteManager.ffzGlobalEmoteCodes.updated.connect([=]() {
this->updateModel(ret, channelName); //
});
this->emoteManager.bttvChannelEmoteCodes[channelName].updated.connect([=]() {
this->updateModel(ret, channelName); //
});
this->emoteManager.ffzChannelEmoteCodes[channelName].updated.connect([=]() {
this->updateModel(ret, channelName); //
});
return ret;
}
void CompletionManager::updateModel(CompletionModel *model, const std::string &channelName)
{
model->emotes.clear();
for (const auto &m : this->emoteManager.twitchAccountEmotes) {
for (const auto &emoteName : m.second.emoteCodes) {
model->emotes.push_back(qS(emoteName));
}
}
std::vector<std::string> &bttvGlobalEmoteCodes = this->emoteManager.bttvGlobalEmoteCodes;
for (const auto &m : bttvGlobalEmoteCodes) {
model->emotes.push_back(qS(m));
}
std::vector<std::string> &ffzGlobalEmoteCodes = this->emoteManager.ffzGlobalEmoteCodes;
for (const auto &m : ffzGlobalEmoteCodes) {
model->emotes.push_back(qS(m));
}
std::vector<std::string> &bttvChannelEmoteCodes =
this->emoteManager.bttvChannelEmoteCodes[channelName];
for (const auto &m : bttvChannelEmoteCodes) {
model->emotes.push_back(qS(m));
}
std::vector<std::string> &ffzChannelEmoteCodes =
this->emoteManager.ffzChannelEmoteCodes[channelName];
for (const auto &m : ffzChannelEmoteCodes) {
model->emotes.push_back(qS(m));
}
}
} // namespace chatterino