added brace wrapping after if and for
This commit is contained in:
@@ -33,14 +33,16 @@ bool CompletionModel::TaggedString::isEmote() const
|
||||
|
||||
bool CompletionModel::TaggedString::operator<(const TaggedString &that) const
|
||||
{
|
||||
if (this->isEmote() != that.isEmote()) {
|
||||
if (this->isEmote() != that.isEmote())
|
||||
{
|
||||
return this->isEmote();
|
||||
}
|
||||
|
||||
// try comparing insensitively, if they are the same then senstively
|
||||
// (fixes order of LuL and LUL)
|
||||
int k = QString::compare(this->string, that.string, Qt::CaseInsensitive);
|
||||
if (k == 0) return this->string > that.string;
|
||||
if (k == 0)
|
||||
return this->string > that.string;
|
||||
|
||||
return k < 0;
|
||||
}
|
||||
@@ -79,17 +81,21 @@ void CompletionModel::refresh(const QString &prefix)
|
||||
std::lock_guard<std::mutex> guard(this->itemsMutex_);
|
||||
this->items_.clear();
|
||||
|
||||
if (prefix.length() < 2) return;
|
||||
if (prefix.length() < 2)
|
||||
return;
|
||||
|
||||
auto addString = [&](const QString &str, TaggedString::Type type) {
|
||||
if (str.startsWith(prefix, Qt::CaseInsensitive))
|
||||
this->items_.emplace(str + " ", type);
|
||||
};
|
||||
|
||||
if (auto channel = dynamic_cast<TwitchChannel *>(&this->channel_)) {
|
||||
if (auto channel = dynamic_cast<TwitchChannel *>(&this->channel_))
|
||||
{
|
||||
// account emotes
|
||||
if (auto account = getApp()->accounts->twitch.getCurrent()) {
|
||||
for (const auto &emote : account->accessEmotes()->allEmoteNames) {
|
||||
if (auto account = getApp()->accounts->twitch.getCurrent())
|
||||
{
|
||||
for (const auto &emote : account->accessEmotes()->allEmoteNames)
|
||||
{
|
||||
// XXX: No way to discern between a twitch global emote and sub
|
||||
// emote right now
|
||||
addString(emote.string, TaggedString::Type::TwitchGlobalEmote);
|
||||
@@ -97,60 +103,73 @@ void CompletionModel::refresh(const QString &prefix)
|
||||
}
|
||||
|
||||
// Usernames
|
||||
if (prefix.length() >= UsernameSet::PrefixLength) {
|
||||
if (prefix.length() >= UsernameSet::PrefixLength)
|
||||
{
|
||||
auto usernames = channel->accessChatters();
|
||||
|
||||
QString usernamePrefix = prefix;
|
||||
|
||||
if (usernamePrefix.startsWith("@")) {
|
||||
if (usernamePrefix.startsWith("@"))
|
||||
{
|
||||
usernamePrefix.remove(0, 1);
|
||||
for (const auto &name :
|
||||
usernames->subrange(Prefix(usernamePrefix))) {
|
||||
usernames->subrange(Prefix(usernamePrefix)))
|
||||
{
|
||||
addString("@" + name, TaggedString::Type::Username);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
for (const auto &name :
|
||||
usernames->subrange(Prefix(usernamePrefix))) {
|
||||
usernames->subrange(Prefix(usernamePrefix)))
|
||||
{
|
||||
addString(name, TaggedString::Type::Username);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Bttv Global
|
||||
for (auto &emote : *channel->globalBttv().emotes()) {
|
||||
for (auto &emote : *channel->globalBttv().emotes())
|
||||
{
|
||||
addString(emote.first.string, TaggedString::Type::BTTVChannelEmote);
|
||||
}
|
||||
|
||||
// Ffz Global
|
||||
for (auto &emote : *channel->globalFfz().emotes()) {
|
||||
for (auto &emote : *channel->globalFfz().emotes())
|
||||
{
|
||||
addString(emote.first.string, TaggedString::Type::FFZChannelEmote);
|
||||
}
|
||||
|
||||
// Bttv Channel
|
||||
for (auto &emote : *channel->bttvEmotes()) {
|
||||
for (auto &emote : *channel->bttvEmotes())
|
||||
{
|
||||
addString(emote.first.string, TaggedString::Type::BTTVGlobalEmote);
|
||||
}
|
||||
|
||||
// Ffz Channel
|
||||
for (auto &emote : *channel->ffzEmotes()) {
|
||||
for (auto &emote : *channel->ffzEmotes())
|
||||
{
|
||||
addString(emote.first.string, TaggedString::Type::BTTVGlobalEmote);
|
||||
}
|
||||
|
||||
// Emojis
|
||||
if (prefix.startsWith(":")) {
|
||||
if (prefix.startsWith(":"))
|
||||
{
|
||||
const auto &emojiShortCodes = getApp()->emotes->emojis.shortCodes;
|
||||
for (auto &m : emojiShortCodes) {
|
||||
for (auto &m : emojiShortCodes)
|
||||
{
|
||||
addString(":" + m + ":", TaggedString::Type::Emoji);
|
||||
}
|
||||
}
|
||||
|
||||
// Commands
|
||||
for (auto &command : getApp()->commands->items.getVector()) {
|
||||
for (auto &command : getApp()->commands->items.getVector())
|
||||
{
|
||||
addString(command.name, TaggedString::Command);
|
||||
}
|
||||
|
||||
for (auto &command :
|
||||
getApp()->commands->getDefaultTwitchCommandList()) {
|
||||
for (auto &command : getApp()->commands->getDefaultTwitchCommandList())
|
||||
{
|
||||
addString(command, TaggedString::Command);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user