* change dotted last read message indicator to a line, remove
airbrushgrenade

* sort emotes in tab completion

* implement tabbing usernames

* FeelsOkayMan

* fix emotes and usernames comparing; formatting

* remove private/personal stuff

* change lastmessageindicator back to default verpattern
This commit is contained in:
hemirt
2018-03-24 11:12:24 +01:00
committed by pajlada
parent 0423702e50
commit ab42a30108
4 changed files with 78 additions and 10 deletions
+10 -3
View File
@@ -6,6 +6,8 @@
#include "singletons/completionmanager.hpp"
#include "singletons/emotemanager.hpp"
#include <QtAlgorithms>
namespace chatterino {
namespace singletons {
CompletionModel::CompletionModel(const QString &_channelName)
@@ -18,7 +20,6 @@ void CompletionModel::refresh()
// debug::Log("[CompletionModel:{}] Refreshing...]", this->channelName);
auto &emoteManager = singletons::EmoteManager::getInstance();
this->emotes.clear();
// User-specific: Twitch Emotes
// TODO: Fix this so it properly updates with the proper api. oauth token needs proper scope
@@ -79,13 +80,19 @@ void CompletionModel::refresh()
void CompletionModel::addString(const std::string &str)
{
// Always add a space at the end of completions
this->emotes.push_back(qS(str) + " ");
this->emotes.insert(this->createEmote(str + " "));
}
void CompletionModel::addString(const QString &str)
{
// Always add a space at the end of completions
this->emotes.push_back(str + " ");
this->emotes.insert(this->createEmote(str + " "));
}
void CompletionModel::addUser(const QString &str)
{
// Always add a space at the end of completions
this->emotes.insert(this->createUser(str + " "));
}
} // namespace singletons
} // namespace chatterino
+49 -7
View File
@@ -1,11 +1,13 @@
#pragma once
#include <QAbstractListModel>
#include <QVector>
#include <set>
#include <map>
#include <string>
#include "common.hpp"
namespace chatterino {
namespace singletons {
class CompletionModel : public QAbstractListModel
@@ -21,7 +23,9 @@ public:
virtual QVariant data(const QModelIndex &index, int) const override
{
// TODO: Implement more safely
return QVariant(this->emotes.at(index.row()));
auto it = this->emotes.begin();
std::advance(it, index.row());
return QVariant(it->str);
}
virtual int rowCount(const QModelIndex &) const override
@@ -30,14 +34,52 @@ public:
}
void refresh();
private:
void addString(const std::string &str);
void addString(const QString &str);
QVector<QString> emotes;
void addUser(const QString &str);
private:
struct TaggedString {
QString str;
// emote == true
// username == false
bool isEmote = true;
bool operator<(const TaggedString &that) const
{
if (this->isEmote) {
if (that.isEmote) {
int k = QString::compare(this->str, that.str, Qt::CaseInsensitive);
if (k == 0) return this->str > that.str;
else return k < 0;
} else
return true;
} else {
if (that.isEmote)
return false;
else {
int k = QString::compare(this->str, that.str, Qt::CaseInsensitive);;
if (k == 0) return this->str > that.str;
else return k < 0;
}
}
}
};
TaggedString createEmote(const std::string &str)
{
return TaggedString{qS(str), true};
}
TaggedString createEmote(const QString &str)
{
return TaggedString{str, true};
}
TaggedString createUser(const QString &str)
{
return TaggedString{str, false};
}
std::set<TaggedString> emotes;
QString channelName;
};
}
}
} // namespace singletons
} // namespace chatterino