rename CompletionModel to CompletionProxyModel

pull/335/head
Jussi Kuokkanen 4 years ago committed by Nicolas Werner
parent cabeb1464c
commit 748bf0cd98
  1. 20
      src/CompletionProxyModel.h
  2. 4
      src/TextInputWidget.cpp
  3. 4
      src/TextInputWidget.h

@ -0,0 +1,20 @@
#pragma once
// Class for showing a limited amount of completions at a time
#include <QSortFilterProxyModel>
class CompletionProxyModel : public QSortFilterProxyModel
{
public:
CompletionProxyModel(QAbstractItemModel *model, QObject *parent = nullptr)
: QSortFilterProxyModel(parent)
{
setSourceModel(model);
}
int rowCount(const QModelIndex &parent) const override
{
auto row_count = QSortFilterProxyModel::rowCount(parent);
return (row_count < 7) ? row_count : 7;
}
};

@ -30,7 +30,7 @@
#include "Cache.h"
#include "ChatPage.h"
#include "CompletionModel.h"
#include "CompletionProxyModel.h"
#include "Logging.h"
#include "TextInputWidget.h"
#include "Utils.h"
@ -70,7 +70,7 @@ FilteredTextEdit::FilteredTextEdit(QWidget *parent)
completer_->setWidget(this);
auto model = new emoji::EmojiSearchModel(this);
model->sort(0, Qt::AscendingOrder);
completer_->setModel((emoji_completion_model_ = new CompletionModel(model, this)));
completer_->setModel((emoji_completion_model_ = new CompletionProxyModel(model, this)));
completer_->setModelSorting(QCompleter::UnsortedModel);
completer_->popup()->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
completer_->popup()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

@ -31,7 +31,7 @@
struct SearchResult;
class CompletionModel;
class CompletionProxyModel;
class FlatButton;
class LoadingIndicator;
class QCompleter;
@ -72,7 +72,7 @@ protected:
private:
bool emoji_popup_open_ = false;
CompletionModel *emoji_completion_model_;
CompletionProxyModel *emoji_completion_model_;
std::deque<QString> true_history_, working_history_;
int trigger_pos_; // Where emoji completer was triggered
size_t history_index_;

Loading…
Cancel
Save