mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Changed the login name in autocompletion to the display name Autocompletion model is now only updated on the "first completion"
59 lines
1.1 KiB
C++
59 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <QAbstractListModel>
|
|
#include <QVector>
|
|
|
|
#include <map>
|
|
#include <string>
|
|
|
|
namespace chatterino {
|
|
|
|
class CompletionModel : public QAbstractListModel
|
|
{
|
|
public:
|
|
CompletionModel(const QString &_channelName);
|
|
|
|
virtual int columnCount(const QModelIndex &) const override
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
virtual QVariant data(const QModelIndex &index, int) const override
|
|
{
|
|
// TODO: Implement more safely
|
|
return QVariant(this->emotes.at(index.row()));
|
|
}
|
|
|
|
virtual int rowCount(const QModelIndex &) const override
|
|
{
|
|
return this->emotes.size();
|
|
}
|
|
|
|
void refresh();
|
|
|
|
private:
|
|
void addString(const std::string &str);
|
|
void addString(const QString &str);
|
|
|
|
QVector<QString> emotes;
|
|
|
|
QString channelName;
|
|
};
|
|
|
|
class CompletionManager
|
|
{
|
|
CompletionManager() = default;
|
|
|
|
std::map<std::string, CompletionModel *> models;
|
|
|
|
public:
|
|
static CompletionManager &getInstance()
|
|
{
|
|
static CompletionManager instance;
|
|
return instance;
|
|
}
|
|
|
|
CompletionModel *createModel(const std::string &channelName);
|
|
};
|
|
|
|
} // namespace chatterino
|