KTextEditor
katecompletionmodel.cpp
111QVariant HierarchicalModelHandler::getData(CodeCompletionModel::ExtraItemDataRoles role, const QModelIndex &index) const
113 auto it = std::find_if(m_roleValues.begin(), m_roleValues.end(), [role](const RoleAndValue &v) {
129void HierarchicalModelHandler::addValue(CodeCompletionModel::ExtraItemDataRoles role, const QVariant &value)
131 auto it = std::find_if(m_roleValues.begin(), m_roleValues.end(), [role](const RoleAndValue &v) {
150 connect(m_updateBestMatchesTimer, &QTimer::timeout, this, &KateCompletionModel::updateBestMatches);
183 // groupOfParent returns a group when the index is a member of that group, but not the group head/label.
203 QModelIndex sourceIndex = mapToSource(createIndex(index.row(), column, index.internalPointer()));
211 // Return that we are doing custom-highlighting of one of the sub-strings does it. Unfortunately internal highlighting does not work for the other
214 QModelIndex sourceIndex = mapToSource(createIndex(index.row(), column, index.internalPointer()));
216 if (method.userType() == QMetaType::Int && method.toInt() == CodeCompletionModel::CustomHighlighting) {
230 strings << mapToSource(createIndex(index.row(), column, index.internalPointer())).data(Qt::DisplayRole).toString();
238 highlights << mapToSource(createIndex(index.row(), column, index.internalPointer())).data(CodeCompletionModel::CustomHighlight).toList();
310 continue; // Only match completion-items to argument-hints of depth 1(the ones the item will be given to as argument)
367 return qMakePair(static_cast<CodeCompletionModel *>(const_cast<QAbstractItemModel *>(index.model())), index);
417 // qCWarning(LOG_KTE) << "Invalid index requested: row " << row << " beyond individual range in group " << g;
519KateCompletionModel::GroupSet KateCompletionModel::createItems(const HierarchicalModelHandler &_handler, const QModelIndex &i, bool notifyModel)
547 g->removeItem(ModelRow(const_cast<CodeCompletionModel *>(static_cast<const CodeCompletionModel *>(i.model())), i));
561 // After clearing the model, it has to be reset, else we will be in an invalid state while inserting
603KateCompletionModel::Group *KateCompletionModel::createItem(const HierarchicalModelHandler &handler, const QModelIndex &sourceIndex, bool notifyModel)
607 int completionFlags = handler.getData(CodeCompletionModel::CompletionRole, sourceIndex).toInt();
609 int argumentHintDepth = handler.getData(CodeCompletionModel::ArgumentHintDepth, sourceIndex).toInt();
650 affectedGroups.merge(createItems(handler, handler.model()->index(i, 0, parent), /* notifyModel= */ true));
781 // qCDebug(LOG_KTE) << "Returning ungrouped row count for toplevel " << m_ungrouped->filtered.count();
832 return index(m_ungrouped->rowOf(modelRowPair(sourceIndex)), sourceIndex.column(), QModelIndex());
853void KateCompletionModel::setCurrentCompletion(QMap<KTextEditor::CodeCompletionModel *, QString> currentMatch)
945 std::remove_copy_if(g->prefilter.begin(), g->prefilter.end(), std::back_inserter(g->filtered), [this](Item &item) {
992 m_updateBestMatchesTimer->start(200); // We have new argument-hints, so we have new best matches
1042 m_emptyGroups.erase(std::remove(m_emptyGroups.begin(), m_emptyGroups.end(), g), m_emptyGroups.end());
1120 qCWarning(LOG_KTE) << "Invalid completion model metadata: more than one scope type modifier provided.";
1131 qCWarning(LOG_KTE) << "Invalid completion model metadata: more than one access type modifier provided.";
1156KateCompletionModel::Item::Item(bool doInitialMatch, KateCompletionModel *m, const HierarchicalModelHandler &handler, ModelRow sr)
1161 inheritanceDepth = handler.getData(CodeCompletionModel::InheritanceDepth, m_sourceRow.second).toInt();
1162 m_unimportant = handler.getData(CodeCompletionModel::UnimportantItemRole, m_sourceRow.second).toBool();
1176 // qCDebug(LOG_KTE) << c1 << " c/w " << c2 << " -> " << (model->isSortingReverse() ? ret > 0 : ret < 0) << " (" << ret << ")";
1357 && iface3->matchingItem(item.sourceRow().second) == KTextEditor::CodeCompletionModelControllerInterface::HideListIfAutomaticInvocation) {
1387bool KateCompletionModel::matchesAbbreviation(const QString &word, const QString &typed, int &score)
1443KateCompletionModel::Item::MatchType KateCompletionModel::Item::match(KateCompletionModel *model)
1509 connect(model, &KTextEditor::CodeCompletionModel::rowsInserted, this, &KateCompletionModel::slotRowsInserted);
1510 connect(model, &KTextEditor::CodeCompletionModel::rowsRemoved, this, &KateCompletionModel::slotRowsRemoved);
1511 connect(model, &KTextEditor::CodeCompletionModel::modelReset, this, &KateCompletionModel::slotModelReset);
1529void KateCompletionModel::setCompletionModels(const QList<KTextEditor::CodeCompletionModel *> &models)
1539 connect(model, &KTextEditor::CodeCompletionModel::rowsInserted, this, &KateCompletionModel::slotRowsInserted);
1540 connect(model, &KTextEditor::CodeCompletionModel::rowsRemoved, this, &KateCompletionModel::slotRowsRemoved);
1541 connect(model, &KTextEditor::CodeCompletionModel::modelReset, this, &KateCompletionModel::slotModelReset);
1590 FilterItems(KateCompletionModel &model, const QList<KTextEditor::CodeCompletionModel *> &needShadowing)
1606 if (it != had.constEnd() && *it != item.sourceRow().first && m_needShadowing.contains(item.sourceRow().first)) {
1640 KTextEditor::CodeCompletionModelControllerInterface *v4 = qobject_cast<KTextEditor::CodeCompletionModelControllerInterface *>(model);
1668 // Maps match-qualities to ModelRows paired together with the BestMatchesCount returned by the items.
1673 // If there is no grouping, just change the order of the items, moving the best matching ones to the front
1770 m_bestMatches->filtered.push_back(Item(true, this, HierarchicalModelHandler((*it).second.first), (*it).second));
Cares about expanding/un-expanding items in a tree-view together with ExpandingDelegate.
Definition expandingwidgetmodel.h:21
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Does not request data from index, this only returns local data like highlighting for expanded rows an...
Definition expandingwidgetmodel.cpp:73
Controller interface for a CodeCompletionModel.
Definition codecompletionmodelcontrollerinterface.h:61
virtual MatchReaction matchingItem(const QModelIndex &matched)
Called whenever an item in the completion-list perfectly matches the current filter text.
virtual bool shouldHideItemsWithEqualNames() const
When multiple completion models are used at the same time, it may happen that multiple models add ite...
An item model for providing code completion, and meta information for enhanced presentation.
Definition codecompletionmodel.h:68
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Reimplemented from QAbstractItemModel::rowCount().
Definition codecompletionmodel.cpp:74
ExtraItemDataRoles
Meta information is passed through extra {Qt::ItemDataRole}s.
Definition codecompletionmodel.h:143
@ InheritanceDepth
Returns the inheritance depth of the completion.
Definition codecompletionmodel.h:207
@ CompletionRole
The model should return a set of CompletionProperties.
Definition codecompletionmodel.h:145
@ GroupRole
Using this Role, it is possible to greatly optimize the time needed to process very long completion-l...
Definition codecompletionmodel.h:352
@ SetMatchContext
Is requested before MatchQuality(..) is requested.
Definition codecompletionmodel.h:176
@ HighlightingMethod
Define which highlighting method will be used:
Definition codecompletionmodel.h:183
@ UnimportantItemRole
Return a nonzero value here to enforce sorting the item at the end of the list.
Definition codecompletionmodel.h:357
@ BestMatchesCount
This will be requested for each item to ask whether it should be included in computing a best-matches...
Definition codecompletionmodel.h:293
@ ArgumentHintDepth
Is this completion-item an argument-hint? The model should return an integral positive number if the ...
Definition codecompletionmodel.h:282
@ MatchQuality
If requested, your model should try to determine whether the completion in question is a suitable mat...
Definition codecompletionmodel.h:166
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Reimplemented from QAbstractItemModel::index().
Definition codecompletionmodel.cpp:41
This class has the responsibility for filtering, sorting, and manipulating code completion data provi...
Definition katecompletionmodel.h:40
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Does not request data from index, this only returns local data like highlighting for expanded rows an...
Definition katecompletionmodel.cpp:172
virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const
Maps from this display-model into the appropriate source code-completion model.
Definition katecompletionmodel.cpp:802
bool indexIsItem(const QModelIndex &index) const override
Should return true if the given row should be painted like a contained item(as opposed to label-rows ...
Definition katecompletionmodel.cpp:1047
bool shouldMatchHideCompletionList() const
Returns whether one of the filtered items exactly matches its completion string.
Definition katecompletionmodel.cpp:1340
QString commonPrefix(QModelIndex selectedIndex) const
Returns a common prefix for all current visible completion entries If there is no common prefix,...
Definition katecompletionmodel.cpp:919
int contextMatchQuality(const QModelIndex &index) const override
Definition katecompletionmodel.cpp:281
virtual QModelIndex mapFromSource(const QModelIndex &sourceIndex) const
Maps from an index in a source-model to the index of the item in this display-model.
Definition katecompletionmodel.cpp:825
void rowSelected(const QModelIndex &row) const
Definition katecompletionmodel.cpp:1776
This is the code completion's main widget, and also contains the core interface logic.
Definition katecompletionwidget.h:45
Q_SCRIPTABLE Q_NOREPLY void start()
QString i18n(const char *text, const TYPE &arg...)
KCOREADDONS_EXPORT Result match(QStringView pattern, QStringView str)
const QList< QKeySequence > & end()
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
Definition katetextblock.h:18
void beginInsertRows(const QModelIndex &parent, int first, int last)
void beginRemoveRows(const QModelIndex &parent, int first, int last)
void beginResetModel()
QModelIndex createIndex(int row, int column, const void *ptr) const const
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList< int > &roles)
void endInsertRows()
void endRemoveRows()
void endResetModel()
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const=0
virtual QModelIndexList match(const QModelIndex &start, int role, const QVariant &value, int hits, Qt::MatchFlags flags) const const
void modelReset()
virtual int rowCount(const QModelIndex &parent) const const=0
void rowsInserted(const QModelIndex &parent, int first, int last)
void rowsRemoved(const QModelIndex &parent, int first, int last)
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
const QColor & color() const const
bool isLower(char32_t ucs4)
bool isUpper(char32_t ucs4)
char32_t toLower(char32_t ucs4)
void setBold(bool enable)
QPalette palette()
void clear()
const_iterator constEnd() const const
const_iterator constFind(const Key &key) const const
bool contains(const Key &key) const const
iterator insert(const Key &key, const T &value)
void clear()
bool contains(const AT &value) const const
bool empty() const const
reference front()
bool isEmpty() const const
void push_back(parameter_type value)
qsizetype removeAll(const AT &t)
void reserve(qsizetype size)
qsizetype size() const const
const_iterator cend() const const
void clear()
const_iterator constFind(const Key &key) const const
size_type remove(const Key &key)
T value(const Key &key, const T &defaultValue) const const
int column() const const
QVariant data(int role) const const
void * internalPointer() const const
bool isValid() const const
const QAbstractItemModel * model() const const
QModelIndex parent() const const
int row() const const
QModelIndex sibling(int row, int column) const const
void clear()
bool contains(const Key &key, const T &value) const const
iterator insert(const Key &key, const T &value)
T value(const Key &key) const const
const_iterator constBegin() const const
const_iterator constEnd() const const
iterator insert(const Key &key, const T &value)
bool isEmpty() const const
size_type size() const const
Q_EMITQ_EMIT
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool disconnect(const QMetaObject::Connection &connection)
QObject * parent() const const
T qobject_cast(QObject *object)
QObject * sender() const const
const QBrush & toolTipBase() const const
const QBrush & toolTipText() const const
bool isVisible() const const
bool contains(const QSet< T > &other) const const
iterator insert(const T &value)
void reserve(qsizetype size)
QString & append(QChar ch)
const QChar at(qsizetype position) const const
const_iterator cbegin() const const
const_iterator cend() const const
int compare(QLatin1StringView s1, const QString &s2, Qt::CaseSensitivity cs)
const_iterator constEnd() const const
bool isEmpty() const const
bool isNull() const const
QString left(qsizetype n) const const
qsizetype length() const const
QString mid(qsizetype position, qsizetype n) const const
void push_back(QChar ch)
qsizetype size() const const
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const
void truncate(qsizetype position)
QStringView mid(qsizetype start, qsizetype length) const const
QChar at(qsizetype n) const const
AlignRight
CaseSensitive
DisplayRole
typedef ItemFlags
QTextStream & left(QTextStream &stream)
QTextStream & right(QTextStream &stream)
QFuture< void > filter(QThreadPool *pool, Sequence &sequence, KeepFunctor &&filterFunction)
QFuture< typename qValueType< Iterator >::value_type > filtered(Iterator begin, Iterator end, KeepFunctor &&filterFunction)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
void start()
void stop()
void timeout()
bool canConvert() const const
void * data()
bool isValid() const const
bool toBool() const const
int toInt(bool *ok) const const
QList< QVariant > toList() const const
QString toString() const const
int userType() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:11:26 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:11:26 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.