mirror-chatterino2/src/controllers/completion/CompletionModel.cpp
Daniel Sage 37009e8e6b
Consolidate input completion code in preparation for advanced completion strategies (#4639)
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
2023-09-24 12:17:17 +00:00

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