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
-30
View File
@@ -1,30 +0,0 @@
#include "singletons/completionmanager.hpp"
#include "common.hpp"
#include "debug/log.hpp"
#include "singletons/channelmanager.hpp"
#include "singletons/emotemanager.hpp"
namespace chatterino {
namespace singletons {
CompletionManager &CompletionManager::getInstance()
{
static CompletionManager instance;
return instance;
}
CompletionModel *CompletionManager::createModel(const QString &channelName)
{
auto it = this->models.find(channelName);
if (it != this->models.end()) {
return it->second;
}
CompletionModel *ret = new CompletionModel(channelName);
this->models[channelName] = ret;
return ret;
}
} // namespace singletons
} // namespace chatterino
-26
View File
@@ -1,26 +0,0 @@
#pragma once
#include <QAbstractListModel>
#include <QVector>
#include <map>
#include <string>
#include "helper/completionmodel.hpp"
namespace chatterino {
namespace singletons {
class CompletionManager
{
CompletionManager() = default;
public:
static CompletionManager &getInstance();
CompletionModel *createModel(const QString &channelName);
private:
std::map<QString, CompletionModel *> models;
};
} // namespace singletons
} // namespace chatterino
+2 -1
View File
@@ -3,13 +3,13 @@
#include "common.hpp"
#include "debug/log.hpp"
#include "singletons/channelmanager.hpp"
#include "singletons/completionmanager.hpp"
#include "singletons/emotemanager.hpp"
#include <QtAlgorithms>
namespace chatterino {
namespace singletons {
CompletionModel::CompletionModel(const QString &_channelName)
: channelName(_channelName)
{
@@ -94,5 +94,6 @@ 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
+19 -11
View File
@@ -1,15 +1,16 @@
#pragma once
#include <QAbstractListModel>
#include <set>
#include <map>
#include <string>
#include "common.hpp"
#include <QAbstractListModel>
#include <map>
#include <set>
#include <string>
namespace chatterino {
namespace singletons {
class CompletionModel : public QAbstractListModel
{
public:
@@ -50,17 +51,23 @@ private:
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;
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;
int k = QString::compare(this->str, that.str, Qt::CaseInsensitive);
if (k == 0) {
return this->str > that.str;
} else {
return k < 0;
}
}
}
}
@@ -81,5 +88,6 @@ private:
QString channelName;
};
} // namespace singletons
} // namespace chatterino