Kate
katecompletionmodel.cpp
Go to the documentation of this file.
113 QVariant HierarchicalModelHandler::getData(CodeCompletionModel::ExtraItemDataRoles role, const QModelIndex& index) const {
121 HierarchicalModelHandler::HierarchicalModelHandler(CodeCompletionModel* model) : m_groupSortingKey(-1), m_model(model) {
124 void HierarchicalModelHandler::addValue(CodeCompletionModel::ExtraItemDataRoles role, const QVariant& value) {
188 if( role == Qt::DecorationRole && index.column() == KTextEditor::CodeCompletionModel::Prefix && isExpandable(index) )
198 //groupOfParent returns a group when the index is a member of that group, but not the group head/label.
216 } else if ((!isColumnMergingEnabled() || m_columnMerges.isEmpty()) && index.column() == CodeCompletionModel::Scope) {
228 QModelIndex sourceIndex = mapToSource(createIndex(index.row(), column, index.internalPointer()));
237 //Return that we are doing custom-highlighting of one of the sub-strings does it. Unfortunately internal highlighting does not work for the other substrings.
239 QModelIndex sourceIndex = mapToSource(createIndex(index.row(), column, index.internalPointer()));
241 if( method.type() == QVariant::Int && method.toInt() == CodeCompletionModel::CustomHighlighting)
253 strings << mapToSource(createIndex(index.row(), column, index.internalPointer())).data(Qt::DisplayRole).toString();
259 highlights << mapToSource(createIndex(index.row(), column, index.internalPointer())).data(CodeCompletionModel::CustomHighlight).toList();
277 //We return the group-header for all columns, ExpandingDelegate will paint them properly over the whole space
324 continue; //Only match completion-items to argument-hints of depth 1(the ones the item will be given to as argument)
375 return isColumnMergingEnabled() && !m_columnMerges.isEmpty() ? m_columnMerges.count() : KTextEditor::CodeCompletionModel::ColumnCount;
380 return qMakePair(static_cast<CodeCompletionModel*>(const_cast<QAbstractItemModel*>(index.model())), index);
422 //kWarning() << "Invalid index requested: row " << row << " beyond indivdual range in group " << g;
439 /*QModelIndex KateCompletionModel::sibling( int row, int column, const QModelIndex & index ) const
544 QSet<KateCompletionModel::Group*> KateCompletionModel::createItems(const HierarchicalModelHandler& _handler, const QModelIndex& i, bool notifyModel) {
568 g->removeItem(ModelRow(const_cast<CodeCompletionModel*>(static_cast<const CodeCompletionModel*>(i.model())), i));
580 //After clearing the model, it has to be reset, else we will be in an invalid state while inserting
609 KateCompletionModel::Group* KateCompletionModel::createItem(const HierarchicalModelHandler& handler, const QModelIndex& sourceIndex, bool notifyModel)
613 int completionFlags = handler.getData(CodeCompletionModel::CompletionRole, sourceIndex).toInt();
616 QString scopeIfNeeded = (groupingMethod() & Scope) ? sourceIndex.sibling(sourceIndex.row(), CodeCompletionModel::Scope).data(Qt::DisplayRole).toString() : QString();
618 int argumentHintDepth = handler.getData(CodeCompletionModel::ArgumentHintDepth, sourceIndex).toInt();
660 affectedGroups += createItems(handler, parent.isValid() ? parent.child(i, 0) : handler.model()->index(i, 0), true);
686 KateCompletionModel::Group* KateCompletionModel::fetchGroup( int attribute, const QString& scope, bool forceGrouping )
699 for (QHash<int, Group*>::ConstIterator it = m_groupHash.constFind(groupingAttribute); it != m_groupHash.constEnd() && it.key() == groupingAttribute; ++it)
789 // Proper solution: Ask all attached code-models(Through a new interface) whether they want to use grouping,
794 KateCompletionModel::Group* KateCompletionModel::groupForIndex( const QModelIndex & index ) const
854 //kDebug( 13035 ) << "Returning ungrouped row count for toplevel " << m_ungrouped->filtered.count();
898 return index(m_ungrouped->rowOf(modelRowPair(sourceIndex)), sourceIndex.column(), QModelIndex());
916 void KateCompletionModel::setCurrentCompletion( KTextEditor::CodeCompletionModel* model, const QString & completion )
928 if (m_currentMatch[model].length() > completion.length() && m_currentMatch[model].startsWith(completion, m_matchCaseSensitivity)) {
932 } else if (m_currentMatch[model].length() < completion.length() && completion.startsWith(m_currentMatch[model], m_matchCaseSensitivity)) {
937 //kDebug( 13035 ) << model << "Old match: " << m_currentMatch[model] << ", new: " << completion << ", type: " << changeType;
1036 //This code determines what of the filtered items still fit, and computes the ranges that were removed, giving
1040 int deleteUntil = -1; //In each state, the range [currentRow+1, deleteUntil] needs to be deleted
1043 //This row does not need to be deleted, which means that currentRow+1 to deleteUntil need to be deleted now
1102 m_updateBestMatchesTimer->start(200); //We have new argument-hints, so we have new best matches
1298 kWarning() << "Invalid completion model metadata: more than one scope type modifier provided.";
1310 kWarning() << "Invalid completion model metadata: more than one access type modifier provided.";
1437 KateCompletionModel::Item::Item( bool doInitialMatch, KateCompletionModel* m, const HierarchicalModelHandler& handler, ModelRow sr )
1445 inheritanceDepth = handler.getData(CodeCompletionModel::InheritanceDepth, m_sourceRow.second).toInt();
1460 //kDebug( 13035 ) << c1 << " c/w " << c2 << " -> " << (model->isSortingReverse() ? ret > 0 : ret < 0) << " (" << ret << ")";
1463 const bool otherIsBad = rhs.m_sourceRow.second.data(CodeCompletionModel::UnimportantItemRole).toBool();
1629 KTextEditor::CodeCompletionModel::CompletionProperties KateCompletionModel::filterAttributes( ) const
1634 void KateCompletionModel::setFilterAttributes( KTextEditor::CodeCompletionModel::CompletionProperties attributes )
1685 QModelIndex sourceIndex = m_sourceRow.second.sibling(m_sourceRow.second.row(), CodeCompletionModel::Name);
1731 KTextEditor::CodeCompletionModelControllerInterface3* iface3 = dynamic_cast<KTextEditor::CodeCompletionModelControllerInterface3*>(item.sourceRow().first);
1734 if(iface3 && iface3->matchingItem(item.sourceRow().second) == KTextEditor::CodeCompletionModelControllerInterface3::HideListIfAutomaticInvocation)
1755 static inline bool matchesAbbreviationHelper(const QString& word, const QString& typed, const QVarLengthArray<int, 32>& offsets,
1777 if ( haveNextWord && matchesAbbreviationHelper(word, typed, offsets, depth, atWord + 1, i + 1) ) {
1838 static inline bool containsAtWordBeginning(const QString& word, const QString& typed, Qt::CaseSensitivity caseSensitive) {
1858 QModelIndex sourceIndex = m_sourceRow.second.sibling(m_sourceRow.second.row(), CodeCompletionModel::Name);
1870 matchCompletion = (m_nameColumn.startsWith(match, model->matchCaseSensitivity()) ? StartsWithMatch : NoMatch);
1897 QString KateCompletionModel::propertyName( KTextEditor::CodeCompletionModel::CompletionProperty property )
1991 QString KateCompletionModel::currentCompletion( KTextEditor::CodeCompletionModel* model ) const
2008 connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)), SLOT(slotRowsInserted(QModelIndex,int,int)));
2009 connect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)), SLOT(slotRowsRemoved(QModelIndex,int,int)));
2022 void KateCompletionModel::setCompletionModels(const QList<KTextEditor::CodeCompletionModel*>& models)
2032 connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)), SLOT(slotRowsInserted(QModelIndex,int,int)));
2033 connect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)), SLOT(slotRowsRemoved(QModelIndex,int,int)));
2071 FilterItems(KateCompletionModel& model, const QVector<KTextEditor::CodeCompletionModel*>& needShadowing) : m_model(model), m_needShadowing(needShadowing) {
2084 if(it != had.constEnd() && *it != item.sourceRow().first && m_needShadowing.contains(item.sourceRow().first))
2117 KTextEditor::CodeCompletionModelControllerInterface4* v4 = dynamic_cast<KTextEditor::CodeCompletionModelControllerInterface4*>(model);
2136 int maxMatches = 300; //We cannot do too many operations here, because they are all executed whenever a character is added. Would be nice if we could split the operations up somewhat using a timer.
2139 //Maps match-qualities to ModelRows paired together with the BestMatchesCount returned by the items.
2144 //If there is no grouping, just change the order of the items, moving the best matching ones to the front
2169 for(QMultiMap<int, int>::const_iterator it = rowsForQuality.constBegin(); it != rowsForQuality.constEnd(); ++it) {
2234 m_bestMatches->filtered.append( Item( true, this, HierarchicalModelHandler((*it).second.first), (*it).second) );
bool operator<(const KateTextLayout &r, const KTextEditor::Cursor &c)
Definition: katetextlayout.cpp:78
void clearCompletionModels()
Definition: katecompletionmodel.cpp:2253
virtual bool indexIsItem(const QModelIndex &index) const
Should return true if the given row should be painted like a contained item(as opposed to label-rows ...
Definition: katecompletionmodel.cpp:1152
void setMaximumInheritanceDepth(int maxDepth)
Definition: katecompletionmodel.cpp:1647
bool filterContextMatchesOnly() const
Definition: katecompletionmodel.cpp:1603
void setFilterAttributes(KTextEditor::CodeCompletionModel::CompletionProperties attributes)
Definition: katecompletionmodel.cpp:1634
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Does not request data from index, this only returns local data like highlighting for expanded rows an...
Definition: katecompletionmodel.cpp:183
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:892
int customSortingKey
Definition: katecompletionmodel.h:307
QList< KTextEditor::CodeCompletionModel * > completionModels() const
Definition: katecompletionmodel.cpp:2041
void setFilterContextMatchesOnly(bool filter)
Definition: katecompletionmodel.cpp:1608
QScriptValue i18n(QScriptContext *context, QScriptEngine *engine)
i18n("text", arguments [optional])
Definition: katescripthelpers.cpp:186
KateCompletionModel(KateCompletionWidget *parent=0L)
Definition: katecompletionmodel.cpp:128
bool accessIncludeConst() const
Definition: katecompletionmodel.cpp:1360
void setCompletionModels(const QList< KTextEditor::CodeCompletionModel * > &models)
Definition: katecompletionmodel.cpp:2022
virtual void rowSelected(const QModelIndex &row)
Notifies underlying models that the item was selected, collapses any previous partially expanded line...
Definition: expandingwidgetmodel.cpp:157
Qt::CaseSensitivity matchCaseSensitivity() const
Definition: katecompletionmodel.cpp:1996
static bool containsAtWordBeginning(const QString &word, const QString &typed, Qt::CaseSensitivity caseSensitive)
Definition: katecompletionmodel.cpp:1838
QString commonPrefix(QModelIndex selectedIndex) const
Returns a common prefix for all current visible completion entries If there is no common prefix...
Definition: katecompletionmodel.cpp:1006
void clearExpanding()
Unexpand all rows and clear all cached information about them(this includes deleting the expanding-wi...
Definition: expandingwidgetmodel.cpp:123
virtual int contextMatchQuality(const QModelIndex &index) const
Definition: katecompletionmodel.cpp:299
bool accessIncludeSignalSlot() const
Definition: katecompletionmodel.cpp:1390
virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const
Maps from this display-model into the appropriate source code-completion model.
Definition: katecompletionmodel.cpp:875
int timeout
QList< QVariant > mergeCustomHighlighting(int leftSize, const QList< QVariant > &left, int rightSize, const QList< QVariant > &right)
Definition: expandingwidgetmodel.cpp:449
void setFilteringEnabled(bool enable)
Definition: katecompletionmodel.cpp:1186
void setColumnMerges(const QList< QList< int > > &columnMerges)
Definition: katecompletionmodel.cpp:1257
void setSortingCaseSensitivity(Qt::CaseSensitivity cs)
Definition: katecompletionmodel.cpp:1570
uint filteredItemCount() const
Definition: katecompletionmodel.cpp:1712
void setGroupingEnabled(bool enable)
Definition: katecompletionmodel.cpp:1200
static QIcon m_collapsedIcon
Definition: expandingwidgetmodel.h:136
This class has the responsibility for filtering, sorting, and manipulating code completion data provi...
Definition: katecompletionmodel.h:48
QString currentCompletion(KTextEditor::CodeCompletionModel *model) const
Definition: katecompletionmodel.cpp:1991
bool hasGroups() const
bool accessIncludeStatic() const
Definition: katecompletionmodel.cpp:1375
GroupingMethods groupingMethod() const
Definition: katecompletionmodel.cpp:1415
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
static const int AccessTypeMask
Definition: katecompletionmodel.h:153
static QString propertyName(KTextEditor::CodeCompletionModel::CompletionProperty property)
Definition: katecompletionmodel.cpp:1897
void setCurrentCompletion(KTextEditor::CodeCompletionModel *model, const QString &completion)
Definition: katecompletionmodel.cpp:916
static QString columnName(int column)
Definition: katecompletionmodel.cpp:1232
bool isExpandable(const QModelIndex &index) const
Definition: expandingwidgetmodel.cpp:290
static KApplication * kApplication()
void setAccessIncludeStatic(bool include)
Definition: katecompletionmodel.cpp:1380
bool isFilteringEnabled() const
Definition: katecompletionmodel.cpp:1222
void removeCompletionModel(KTextEditor::CodeCompletionModel *model)
Definition: katecompletionmodel.cpp:2046
virtual bool hasIndex(int row, int column, const QModelIndex &parent=QModelIndex()) const
Definition: katecompletionmodel.cpp:463
void addItem(Item i, bool notifyModel=false)
Definition: katecompletionmodel.cpp:1495
KateCompletionWidget * completionWidget() const
Definition: kateview.cpp:2321
This is the code completion's main widget, and also contains the core interface logic.
Definition: katecompletionwidget.h:55
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Does not request data from index, this only returns local data like highlighting for expanded rows an...
Definition: expandingwidgetmodel.cpp:88
void argumentHintsChanged()
const QList< QList< int > > & columnMerges() const
Definition: katecompletionmodel.cpp:1252
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
void setMatchCaseSensitivity(Qt::CaseSensitivity cs)
Definition: katecompletionmodel.cpp:368
virtual int rowCount(const QModelIndex &parent) const
Definition: kateargumenthintmodel.cpp:226
virtual void rowSelected(const QModelIndex &row)
Notifies underlying models that the item was selected, collapses any previous partially expanded line...
Definition: katecompletionmodel.cpp:2240
void contentGeometryChanged()
bool isSortingEnabled() const
Definition: katecompletionmodel.cpp:1227
int rowOf(ModelRow item)
Returns the row in the this group's filtered list of the given model-row in a source-model -1 if the ...
Definition: katecompletionmodel.h:293
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
Definition: katecompletionmodel.cpp:847
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const
Definition: katecompletionmodel.cpp:373
void setCompletionModel(KTextEditor::CodeCompletionModel *model)
Definition: katecompletionmodel.cpp:2016
virtual void sort(int column, Qt::SortOrder order=Qt::AscendingOrder)
Definition: katecompletionmodel.cpp:869
KateCompletionWidget * widget() const
Definition: katecompletionmodel.cpp:359
void setSortingAlphabetical(bool alphabetical)
Definition: katecompletionmodel.cpp:1556
int maximumInheritanceDepth() const
Definition: katecompletionmodel.cpp:1642
bool isSortingByInheritanceDepth() const
Definition: katecompletionmodel.cpp:1420
static bool matchesAbbreviationHelper(const QString &word, const QString &typed, const QVarLengthArray< int, 32 > &offsets, int &depth, int atWord=-1, int i=0)
Definition: katecompletionmodel.cpp:1755
virtual Qt::ItemFlags flags(const QModelIndex &index) const
Definition: katecompletionmodel.cpp:348
bool isExpanded(const QModelIndex &row) const
Definition: expandingwidgetmodel.cpp:305
void setColumnMergingEnabled(bool enable)
Definition: katecompletionmodel.cpp:1206
Definition: kateview.h:78
Extension of CodeCompletionModelControllerInterface3.
Definition: codecompletionmodelcontrollerinterfacev4.h:32
void setAccessIncludeConst(bool include)
Definition: katecompletionmodel.cpp:1365
virtual MatchReaction matchingItem(const QModelIndex &matched)
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Definition: katecompletionmodel.cpp:407
static const int ColumnCount
ExtraItemDataRoles
void setAccessIncludeSignalSlot(bool include)
Definition: katecompletionmodel.cpp:1395
int translateColumn(int sourceColumn) const
Definition: katecompletionmodel.cpp:1263
void emitDataChanged(const QModelIndex &start, const QModelIndex &end)
Definition: kateargumenthintmodel.cpp:249
static const int ScopeTypeMask
Definition: katecompletionmodel.h:152
void addCompletionModel(KTextEditor::CodeCompletionModel *model)
Definition: katecompletionmodel.cpp:2001
KateArgumentHintModel * argumentHintModel() const
Definition: katecompletionwidget.cpp:248
bool isColumnMergingEnabled() const
Definition: katecompletionmodel.cpp:1212
bool isGroupingEnabled() const
Definition: katecompletionmodel.cpp:1217
void setFilterByAttribute(bool filter)
Definition: katecompletionmodel.cpp:1621
bool shouldMatchHideCompletionList() const
Returns whether one of the filtered items exactly matches its completion string.
Definition: katecompletionmodel.cpp:1721
void setSortingEnabled(bool enable)
Definition: katecompletionmodel.cpp:1192
bool removeItem(const ModelRow &row)
Removes the item specified by row. Returns true if a change was made to rows.
Definition: katecompletionmodel.cpp:1527
void setGroupingMethod(GroupingMethods m)
Definition: katecompletionmodel.cpp:1353
virtual QModelIndex parent(const QModelIndex &index) const
Definition: katecompletionmodel.cpp:823
virtual bool hasChildren(const QModelIndex &parent=QModelIndex()) const
Definition: katecompletionmodel.cpp:383
static QDebug kWarning(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
Qt::CaseSensitivity sortingCaseSensitivity() const
Definition: katecompletionmodel.cpp:1432
~KateCompletionModel()
Definition: katecompletionmodel.cpp:172
CompletionProperty
bool isSortingAlphabetical() const
Definition: katecompletionmodel.cpp:1427
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
KGuiItem reset()
bool orderBefore(Group *other) const
Definition: katecompletionmodel.cpp:1094
KateCompletionTree * treeView() const
Definition: katecompletionwidget.cpp:921
KTextEditor::CodeCompletionModel::CompletionProperties filterAttributes() const
Definition: katecompletionmodel.cpp:1629
static QIcon m_expandedIcon
Definition: expandingwidgetmodel.h:135
void setSortingByInheritanceDepth(bool byIneritance)
Definition: katecompletionmodel.cpp:1423
bool filterByAttribute() const
Definition: katecompletionmodel.cpp:1616
virtual bool shouldHideItemsWithEqualNames() const
When multiple completion models are used at the same time, it may happen that multiple models add ite...
Definition: codecompletionmodelcontrollerinterfacev4.cpp:25
QStringList list(const QString &fileClass)
Group(KateCompletionModel *model)
Definition: katecompletionmodel.cpp:1548
int orderNumber() const
Definition: katecompletionmodel.cpp:1067
Cares about expanding/un-expanding items in a tree-view together with ExpandingDelegate.
Definition: expandingwidgetmodel.h:36
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:31:51 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:31:51 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.