2017-07-09 17:58:59 +02:00
|
|
|
#include "completionmanager.hpp"
|
2017-07-23 14:16:13 +02:00
|
|
|
#include "common.hpp"
|
|
|
|
#include "emotemanager.hpp"
|
2017-07-09 17:58:59 +02:00
|
|
|
|
|
|
|
namespace chatterino {
|
|
|
|
|
2017-07-23 14:16:13 +02:00
|
|
|
CompletionManager::CompletionManager(EmoteManager &_emoteManager)
|
|
|
|
: emoteManager(_emoteManager)
|
2017-07-09 17:58:59 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CompletionModel *CompletionManager::createModel(const std::string &channelName)
|
|
|
|
{
|
|
|
|
CompletionModel *ret = new CompletionModel();
|
|
|
|
|
2017-07-23 14:16:13 +02:00
|
|
|
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); //
|
|
|
|
});
|
|
|
|
|
2017-07-09 17:58:59 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CompletionManager::updateModel(CompletionModel *model, const std::string &channelName)
|
|
|
|
{
|
2017-07-23 14:16:13 +02:00
|
|
|
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));
|
|
|
|
}
|
2017-07-09 17:58:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace chatterino
|