20#include <QtWidgets/private/qtwidgetsglobal_p.h>
21#include "private/qobject_p.h"
23#include "QtWidgets/qabstractitemview.h"
24#include "QtCore/qabstractproxymodel.h"
25#include "QtCore/qmap.h"
28#include "QtGui/qpainter.h"
30#include "private/qabstractproxymodel_p.h"
31#include <QtCore/qpointer.h>
37class QCompletionModel;
41 Q_DECLARE_PUBLIC(QCompleter)
46 void init(QAbstractItemModel *model =
nullptr);
84 inline int count()
const {
return v ? vector.size() : t - f + 1; }
85 inline int operator[] (
int index)
const {
return v ? vector[index] : f + index; }
86 inline int indexOf(
int x)
const {
return v ? vector.indexOf(x) : ((t < f) ? -1 : x - f); }
88 inline bool isEmpty()
const {
return v ? vector.isEmpty() : (t < f); }
89 inline void append(
int x) { Q_ASSERT(v); vector.append(x); }
90 inline int first()
const {
return v ? vector.first() : f; }
91 inline int last()
const {
return v ? vector.last() : t; }
92 inline int from()
const { Q_ASSERT(!v);
return f; }
93 inline int to()
const { Q_ASSERT(!v);
return t; }
94 inline int cost()
const {
return vector.size()+2; }
107 inline bool isValid()
const {
return indices.isValid(); }
121 void filter(
const QStringList &parts);
132 int matchCount()
const {
return curMatch.indices.count() + historyMatch.indices.count(); }
161 int buildIndices(
const QString& str,
const QModelIndex& parent,
int n,
170 void paint(QPainter *p,
const QStyleOptionViewItem& opt,
const QModelIndex& idx)
const override {
171 QStyleOptionViewItem optCopy = opt;
172 optCopy.showDecorationSelected =
true;
173 if (view->currentIndex() == idx)
174 optCopy.state |= QStyle::State_HasFocus;
175 QStyledItemDelegate::paint(p, optCopy, idx);
179 QAbstractItemView *view;
193 void filter(
const QStringList& parts);
199 QModelIndex index(
int row,
int column,
const QModelIndex & = QModelIndex())
const override;
200 int rowCount(
const QModelIndex &index = QModelIndex())
const override;
201 int columnCount(
const QModelIndex &index = QModelIndex())
const override;
202 bool hasChildren(
const QModelIndex &parent = QModelIndex())
const override;
203 QModelIndex parent(
const QModelIndex & = QModelIndex())
const override {
return QModelIndex(); }
227 Q_DECLARE_PUBLIC(QCompletionModel)
QCompleterItemDelegate(QAbstractItemView *view)
void paint(QPainter *p, const QStyleOptionViewItem &opt, const QModelIndex &idx) const override
This pure abstract function must be reimplemented if you want to provide custom rendering.
void setCurrentIndex(QModelIndex, bool=true)
static const QCompleterPrivate * get(const QCompleter *o)
void _q_fileSystemModelDirectoryLoaded(const QString &path)
bool hiddenBecauseNoMatch
void _q_completionSelected(const QItemSelection &)
Qt::MatchFlags filterMode
void _q_autoResizePopup()
QPointer< QWidget > widget
void init(QAbstractItemModel *model=nullptr)
QAbstractItemView * popup
void _q_complete(QModelIndex, bool=false)
static QCompleterPrivate * get(QCompleter *o)
void showPopup(const QRect &)
void saveInCache(QString, const QModelIndex &, const QMatchData &)
virtual QMatchData filter(const QString &, const QModelIndex &, int)=0
void filter(const QStringList &parts)
virtual void filterOnDemand(int)
QMap< QString, QMatchData > CacheItem
bool matchHint(const QString &part, const QModelIndex &parent, QMatchData *m) const
QCompletionEngine(QCompleterPrivate *c)
bool lookupCache(const QString &part, const QModelIndex &parent, QMatchData *m) const
virtual ~QCompletionEngine()
QMap< QModelIndex, CacheItem > Cache
QMatchData filterHistory()
QModelIndex index(int row, int column, const QModelIndex &=QModelIndex()) const override
Returns the index of the item in the model specified by the given row, column and parent index.
int rowCount(const QModelIndex &index=QModelIndex()) const override
Returns the number of rows under the given parent.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
\reimp
int completionCount() const
int columnCount(const QModelIndex &index=QModelIndex()) const override
Returns the number of columns for the children of the given parent.
QScopedPointer< QCompletionEngine > engine
QModelIndex mapFromSource(const QModelIndex &sourceIndex) const override
Reimplement this function to return the model index in the proxy model that corresponds to the source...
bool hasChildren(const QModelIndex &parent=QModelIndex()) const override
\reimp
QModelIndex parent(const QModelIndex &=QModelIndex()) const override
QModelIndex currentIndex(bool) const
void filter(const QStringList &parts)
QModelIndex mapToSource(const QModelIndex &proxyIndex) const override
Reimplement this function to return the model index in the source model that corresponds to the proxy...
void setSourceModel(QAbstractItemModel *sourceModel) override
Sets the given sourceModel to be processed by the proxy model.
bool setCurrentRow(int row)
int operator[](int index) const
QIndexMapper(const QList< int > &vec)
QIndexMapper(int f, int t)
QSortedModelEngine(QCompleterPrivate *c)
QMatchData filter(const QString &, const QModelIndex &, int) override
Qt::SortOrder sortOrder(const QModelIndex &) const
QIndexMapper indexHint(QString, const QModelIndex &, Qt::SortOrder)
QUnsortedModelEngine(QCompleterPrivate *c)
void filterOnDemand(int) override
QMatchData filter(const QString &, const QModelIndex &, int) override
QT_REQUIRE_CONFIG(animation)
QCompleter * completer
[0]
QMatchData(const QIndexMapper &indices, int em, bool p)