8#include <QtWidgets/qtwidgetsglobal.h>
9#include <QtCore/qobject.h>
10#include <QtCore/qpoint.h>
11#include <QtCore/qstring.h>
12#include <QtCore/qabstractitemmodel.h>
13#include <QtCore/qrect.h>
19class QCompleterPrivate;
20class QAbstractItemView;
21class QAbstractProxyModel;
27 Q_PROPERTY(QString completionPrefix READ completionPrefix WRITE setCompletionPrefix)
28 Q_PROPERTY(ModelSorting modelSorting READ modelSorting WRITE setModelSorting)
29 Q_PROPERTY(Qt::MatchFlags filterMode READ filterMode WRITE setFilterMode)
30 Q_PROPERTY(CompletionMode completionMode READ completionMode WRITE setCompletionMode)
31 Q_PROPERTY(
int completionColumn READ completionColumn WRITE setCompletionColumn)
32 Q_PROPERTY(
int completionRole READ completionRole WRITE setCompletionRole)
33 Q_PROPERTY(
int maxVisibleItems READ maxVisibleItems WRITE setMaxVisibleItems)
34 Q_PROPERTY(Qt::CaseSensitivity caseSensitivity READ caseSensitivity WRITE setCaseSensitivity)
35 Q_PROPERTY(
bool wrapAround READ wrapAround WRITE setWrapAround)
40 UnfilteredPopupCompletion,
43 Q_ENUM(CompletionMode)
47 CaseSensitivelySortedModel,
48 CaseInsensitivelySortedModel
52 QCompleter(QObject *parent =
nullptr);
53 QCompleter(QAbstractItemModel *model, QObject *parent =
nullptr);
54#if QT_CONFIG(stringlistmodel)
55 QCompleter(
const QStringList& completions, QObject *parent =
nullptr);
57 ~QCompleter() override;
59 void setWidget(QWidget *widget);
60 QWidget *widget()
const;
62 void setModel(QAbstractItemModel *c);
63 QAbstractItemModel *model()
const;
65 void setCompletionMode(CompletionMode mode);
66 CompletionMode completionMode()
const;
68 void setFilterMode(Qt::MatchFlags filterMode);
69 Qt::MatchFlags filterMode()
const;
71 QAbstractItemView *popup()
const;
72 void setPopup(QAbstractItemView *popup);
74 void setCaseSensitivity(Qt::CaseSensitivity caseSensitivity);
75 Qt::CaseSensitivity caseSensitivity()
const;
77 void setModelSorting(ModelSorting sorting);
78 ModelSorting modelSorting()
const;
80 void setCompletionColumn(
int column);
81 int completionColumn()
const;
83 void setCompletionRole(
int role);
84 int completionRole()
const;
86 bool wrapAround()
const;
88 int maxVisibleItems()
const;
89 void setMaxVisibleItems(
int maxItems);
91 int completionCount()
const;
92 bool setCurrentRow(
int row);
93 int currentRow()
const;
95 QModelIndex currentIndex()
const;
96 QString currentCompletion()
const;
98 QAbstractItemModel *completionModel()
const;
100 QString completionPrefix()
const;
103 void setCompletionPrefix(
const QString &prefix);
104 void complete(
const QRect& rect = QRect());
105 void setWrapAround(
bool wrap);
108 virtual QString pathFromIndex(
const QModelIndex &index)
const;
109 virtual QStringList splitPath(
const QString &path)
const;
112 bool eventFilter(QObject *o, QEvent *e) override;
113 bool event(QEvent *) override;
116 void activated(
const QString &text);
117 void activated(
const QModelIndex &index);
118 void highlighted(
const QString &text);
119 void highlighted(
const QModelIndex &index);
122 Q_DISABLE_COPY(QCompleter)
123 Q_DECLARE_PRIVATE(QCompleter)
125 Q_PRIVATE_SLOT(d_func(),
void _q_complete(QModelIndex))
126 Q_PRIVATE_SLOT(d_func(),
void _q_completionSelected(
const QItemSelection&))
127 Q_PRIVATE_SLOT(d_func(),
void _q_autoResizePopup())
128 Q_PRIVATE_SLOT(d_func(),
void _q_fileSystemModelDirectoryLoaded(
const QString&))
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 &)
The QCompleter class provides completions based on an item model.
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)