Completion models are now updated on-demand (whenever user presses Tab)

We might want some dirty-checking here, but for now it's okay
This commit is contained in:
Rasmus Karlsson
2017-12-17 03:06:39 +01:00
parent 266ad36de3
commit 633423640e
3 changed files with 77 additions and 61 deletions
+10 -3
View File
@@ -3,15 +3,16 @@
#include <QAbstractListModel>
#include <QVector>
#include <map>
#include <string>
namespace chatterino {
class EmoteManager;
class CompletionModel : public QAbstractListModel
{
public:
CompletionModel(const std::string &_channelName);
virtual int columnCount(const QModelIndex & /*parent*/) const override
{
return 1;
@@ -28,15 +29,22 @@ public:
return this->emotes.size();
}
void refresh();
private:
void addString(const std::string &str);
QVector<QString> emotes;
std::string channelName;
};
class CompletionManager
{
CompletionManager() = default;
std::map<std::string, CompletionModel *> models;
public:
static CompletionManager &getInstance()
{
@@ -45,7 +53,6 @@ public:
}
CompletionModel *createModel(const std::string &channelName);
void updateModel(CompletionModel *model, const std::string &channelName = std::string());
};
} // namespace chatterino