mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 19:08:58 +03:00
rename CompletionModel to CompletionProxyModel
This commit is contained in:
parent
cabeb1464c
commit
748bf0cd98
3 changed files with 24 additions and 4 deletions
20
src/CompletionProxyModel.h
Normal file
20
src/CompletionProxyModel.h
Normal file
|
@ -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 "Cache.h"
|
||||||
#include "ChatPage.h"
|
#include "ChatPage.h"
|
||||||
#include "CompletionModel.h"
|
#include "CompletionProxyModel.h"
|
||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
#include "TextInputWidget.h"
|
#include "TextInputWidget.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
@ -70,7 +70,7 @@ FilteredTextEdit::FilteredTextEdit(QWidget *parent)
|
||||||
completer_->setWidget(this);
|
completer_->setWidget(this);
|
||||||
auto model = new emoji::EmojiSearchModel(this);
|
auto model = new emoji::EmojiSearchModel(this);
|
||||||
model->sort(0, Qt::AscendingOrder);
|
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_->setModelSorting(QCompleter::UnsortedModel);
|
||||||
completer_->popup()->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
completer_->popup()->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
completer_->popup()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
completer_->popup()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
struct SearchResult;
|
struct SearchResult;
|
||||||
|
|
||||||
class CompletionModel;
|
class CompletionProxyModel;
|
||||||
class FlatButton;
|
class FlatButton;
|
||||||
class LoadingIndicator;
|
class LoadingIndicator;
|
||||||
class QCompleter;
|
class QCompleter;
|
||||||
|
@ -72,7 +72,7 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool emoji_popup_open_ = false;
|
bool emoji_popup_open_ = false;
|
||||||
CompletionModel *emoji_completion_model_;
|
CompletionProxyModel *emoji_completion_model_;
|
||||||
std::deque<QString> true_history_, working_history_;
|
std::deque<QString> true_history_, working_history_;
|
||||||
int trigger_pos_; // Where emoji completer was triggered
|
int trigger_pos_; // Where emoji completer was triggered
|
||||||
size_t history_index_;
|
size_t history_index_;
|
||||||
|
|
Loading…
Reference in a new issue