add simple username tabbing for recent chatters

This commit is contained in:
Rasmus Karlsson
2017-12-17 17:49:32 +01:00
parent 5839b9f522
commit e41c855545
6 changed files with 63 additions and 9 deletions
+22 -5
View File
@@ -1,11 +1,12 @@
#include "completionmanager.hpp"
#include "channelmanager.hpp"
#include "common.hpp"
#include "debug/log.hpp"
#include "emotemanager.hpp"
namespace chatterino {
CompletionModel::CompletionModel(const std::string &_channelName)
CompletionModel::CompletionModel(const QString &_channelName)
: channelName(_channelName)
{
}
@@ -39,14 +40,14 @@ void CompletionModel::refresh()
// Channel-specific: BTTV Channel Emotes
std::vector<std::string> &bttvChannelEmoteCodes =
emoteManager.bttvChannelEmoteCodes[this->channelName];
emoteManager.bttvChannelEmoteCodes[this->channelName.toStdString()];
for (const auto &m : bttvChannelEmoteCodes) {
this->addString(m);
}
// Channel-specific: FFZ Channel Emotes
std::vector<std::string> &ffzChannelEmoteCodes =
emoteManager.ffzChannelEmoteCodes[this->channelName];
emoteManager.ffzChannelEmoteCodes[this->channelName.toStdString()];
for (const auto &m : ffzChannelEmoteCodes) {
this->addString(m);
}
@@ -57,7 +58,17 @@ void CompletionModel::refresh()
this->addString(":" + m + ":");
}
// TODO: Add Channel-specific: Usernames
// Channel-specific: Usernames
auto *channelManager = ChannelManager::instance;
auto c = channelManager->getTwitchChannel(this->channelName);
if (!c) {
return;
}
auto usernames = c->getUsernamesForCompletions();
for (const auto &username : usernames) {
this->addString(username);
this->addString('@' + username);
}
}
void CompletionModel::addString(const std::string &str)
@@ -66,6 +77,12 @@ void CompletionModel::addString(const std::string &str)
this->emotes.push_back(qS(str) + " ");
}
void CompletionModel::addString(const QString &str)
{
// Always add a space at the end of completions
this->emotes.push_back(str + " ");
}
CompletionModel *CompletionManager::createModel(const std::string &channelName)
{
auto it = this->models.find(channelName);
@@ -73,7 +90,7 @@ CompletionModel *CompletionManager::createModel(const std::string &channelName)
return it->second;
}
CompletionModel *ret = new CompletionModel(channelName);
CompletionModel *ret = new CompletionModel(qS(channelName));
this->models[channelName] = ret;
return ret;