Make more use of single pattern
This commit is contained in:
+13
-16
@@ -10,30 +10,26 @@ void CompletionModel::addString(const std::string &str)
|
||||
this->emotes.push_back(qS(str) + " ");
|
||||
}
|
||||
|
||||
CompletionManager::CompletionManager(EmoteManager &_emoteManager)
|
||||
: emoteManager(_emoteManager)
|
||||
{
|
||||
}
|
||||
|
||||
CompletionModel *CompletionManager::createModel(const std::string &channelName)
|
||||
{
|
||||
CompletionModel *ret = new CompletionModel();
|
||||
auto &emoteManager = EmoteManager::getInstance();
|
||||
|
||||
this->updateModel(ret, channelName);
|
||||
|
||||
this->emoteManager.bttvGlobalEmoteCodes.updated.connect([=]() {
|
||||
emoteManager.bttvGlobalEmoteCodes.updated.connect([=]() {
|
||||
this->updateModel(ret, channelName); //
|
||||
});
|
||||
|
||||
this->emoteManager.ffzGlobalEmoteCodes.updated.connect([=]() {
|
||||
emoteManager.ffzGlobalEmoteCodes.updated.connect([=]() {
|
||||
this->updateModel(ret, channelName); //
|
||||
});
|
||||
|
||||
this->emoteManager.bttvChannelEmoteCodes[channelName].updated.connect([=]() {
|
||||
emoteManager.bttvChannelEmoteCodes[channelName].updated.connect([=]() {
|
||||
this->updateModel(ret, channelName); //
|
||||
});
|
||||
|
||||
this->emoteManager.ffzChannelEmoteCodes[channelName].updated.connect([=]() {
|
||||
emoteManager.ffzChannelEmoteCodes[channelName].updated.connect([=]() {
|
||||
this->updateModel(ret, channelName); //
|
||||
});
|
||||
|
||||
@@ -42,37 +38,38 @@ CompletionModel *CompletionManager::createModel(const std::string &channelName)
|
||||
|
||||
void CompletionManager::updateModel(CompletionModel *model, const std::string &channelName)
|
||||
{
|
||||
auto &emoteManager = EmoteManager::getInstance();
|
||||
|
||||
model->emotes.clear();
|
||||
|
||||
for (const auto &m : this->emoteManager.twitchAccountEmotes) {
|
||||
for (const auto &m : emoteManager.twitchAccountEmotes) {
|
||||
for (const auto &emoteName : m.second.emoteCodes) {
|
||||
model->addString(emoteName);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> &bttvGlobalEmoteCodes = this->emoteManager.bttvGlobalEmoteCodes;
|
||||
std::vector<std::string> &bttvGlobalEmoteCodes = emoteManager.bttvGlobalEmoteCodes;
|
||||
for (const auto &m : bttvGlobalEmoteCodes) {
|
||||
model->addString(m);
|
||||
}
|
||||
|
||||
std::vector<std::string> &ffzGlobalEmoteCodes = this->emoteManager.ffzGlobalEmoteCodes;
|
||||
std::vector<std::string> &ffzGlobalEmoteCodes = emoteManager.ffzGlobalEmoteCodes;
|
||||
for (const auto &m : ffzGlobalEmoteCodes) {
|
||||
model->addString(m);
|
||||
}
|
||||
|
||||
std::vector<std::string> &bttvChannelEmoteCodes =
|
||||
this->emoteManager.bttvChannelEmoteCodes[channelName];
|
||||
emoteManager.bttvChannelEmoteCodes[channelName];
|
||||
for (const auto &m : bttvChannelEmoteCodes) {
|
||||
model->addString(m);
|
||||
}
|
||||
|
||||
std::vector<std::string> &ffzChannelEmoteCodes =
|
||||
this->emoteManager.ffzChannelEmoteCodes[channelName];
|
||||
std::vector<std::string> &ffzChannelEmoteCodes = emoteManager.ffzChannelEmoteCodes[channelName];
|
||||
for (const auto &m : ffzChannelEmoteCodes) {
|
||||
model->addString(m);
|
||||
}
|
||||
|
||||
const auto &emojiShortCodes = this->emoteManager.emojiShortCodes;
|
||||
const auto &emojiShortCodes = emoteManager.emojiShortCodes;
|
||||
for (const auto &m : emojiShortCodes) {
|
||||
model->addString(":" + m + ":");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user