mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
37009e8e6b
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
34 lines
719 B
C++
34 lines
719 B
C++
#include "controllers/completion/CompletionModel.hpp"
|
|
|
|
#include "controllers/completion/sources/Source.hpp"
|
|
|
|
namespace chatterino {
|
|
|
|
CompletionModel::CompletionModel(QObject *parent)
|
|
: GenericListModel(parent)
|
|
{
|
|
}
|
|
|
|
void CompletionModel::setSource(std::unique_ptr<completion::Source> source)
|
|
{
|
|
this->source_ = std::move(source);
|
|
}
|
|
|
|
bool CompletionModel::hasSource() const
|
|
{
|
|
return this->source_ != nullptr;
|
|
}
|
|
|
|
void CompletionModel::updateResults(const QString &query, size_t maxCount)
|
|
{
|
|
if (this->source_)
|
|
{
|
|
this->source_->update(query);
|
|
|
|
// Copy results to this model
|
|
this->clear();
|
|
this->source_->addToListModel(*this, maxCount);
|
|
}
|
|
}
|
|
|
|
} // namespace chatterino
|