Remove "CompletionManager". Completion models are now stored in Channel

Chatters list is now updated every 5 minutes
This commit is contained in:
Rasmus Karlsson
2018-03-24 12:02:07 +01:00
parent ad12a818b2
commit d9bd39e8a4
12 changed files with 65 additions and 95 deletions
+7 -20
View File
@@ -1,14 +1,13 @@
#include "widgets/helper/splitinput.hpp"
#include "singletons/commandmanager.hpp"
#include "singletons/completionmanager.hpp"
#include "singletons/ircmanager.hpp"
#include "singletons/settingsmanager.hpp"
#include "singletons/thememanager.hpp"
#include "util/layoutcreator.hpp"
#include "util/urlfetch.hpp"
#include "widgets/notebook.hpp"
#include "widgets/split.hpp"
#include "widgets/splitcontainer.hpp"
#include "util/urlfetch.hpp"
#include <QCompleter>
#include <QPainter>
@@ -22,26 +21,14 @@ SplitInput::SplitInput(Split *_chatWidget)
{
this->initLayout();
// auto completion
auto completer = new QCompleter(
singletons::CompletionManager::getInstance().createModel(this->chatWidget->channelName));
auto cc = singletons::CompletionManager::getInstance().createModel(this->chatWidget->channelName);
cc->refresh();
static QStringList jsonLabels = {"moderators", "staff", "admins", "global_mods", "viewers"};
util::twitch::get("https://tmi.twitch.tv/group/user/" + this->chatWidget->channelName + "/chatters", this,
[cc](QJsonObject obj) {
QJsonObject chattersObj = obj.value("chatters").toObject();
for (int i = 0; i < jsonLabels.size(); i++) {
foreach (const QJsonValue &v,
chattersObj.value(jsonLabels.at(i)).toArray())
cc->addUser(v.toString());
}
});
auto completer = new QCompleter(&this->chatWidget->getChannel()->completionModel);
this->ui.textEdit->setCompleter(completer);
this->chatWidget->channelChanged.connect([this] {
auto completer = new QCompleter(&this->chatWidget->getChannel()->completionModel);
this->ui.textEdit->setCompleter(completer);
});
// misc
this->installKeyPressedEvent();
this->themeRefreshEvent();