22 #ifndef KATECOMPLETIONMODEL_H
23 #define KATECOMPLETIONMODEL_H
25 #include <QtGui/QAbstractProxyModel>
26 #include <QtCore/QPair>
27 #include <QtCore/QList>
40 class HierarchicalModelHandler;
57 void clearCompletionModels();
69 Qt::CaseSensitivity matchCaseSensitivity()
const;
70 void setMatchCaseSensitivity( Qt::CaseSensitivity cs );
72 static QString columnName(
int column);
73 int translateColumn(
int sourceColumn)
const;
79 QString commonPrefix(QModelIndex selectedIndex)
const;
83 virtual bool indexIsItem(
const QModelIndex& index)
const;
85 virtual int columnCount (
const QModelIndex & parent = QModelIndex() )
const;
86 virtual QVariant data (
const QModelIndex & index,
int role = Qt::DisplayRole )
const;
87 virtual Qt::ItemFlags flags (
const QModelIndex & index )
const;
88 virtual bool hasChildren (
const QModelIndex & parent = QModelIndex() )
const;
89 virtual bool hasIndex (
int row,
int column,
const QModelIndex & parent = QModelIndex() )
const;
90 virtual QModelIndex index (
int row,
int column,
const QModelIndex & parent = QModelIndex() )
const;
94 virtual QModelIndex parent (
const QModelIndex & index )
const;
95 virtual int rowCount (
const QModelIndex & parent = QModelIndex() )
const;
99 virtual void sort (
int column, Qt::SortOrder order = Qt::AscendingOrder );
102 virtual QModelIndex mapToSource(
const QModelIndex &proxyIndex)
const;
105 virtual QModelIndex mapFromSource(
const QModelIndex &sourceIndex)
const;
108 bool isSortingEnabled()
const;
109 bool isSortingAlphabetical()
const;
110 bool isSortingByInheritanceDepth()
const;
111 void setSortingByInheritanceDepth(
bool byIneritance);
112 void setSortingAlphabetical(
bool alphabetical);
114 Qt::CaseSensitivity sortingCaseSensitivity()
const;
115 void setSortingCaseSensitivity(Qt::CaseSensitivity cs);
117 bool isSortingReverse()
const;
118 void setSortingReverse(
bool reverse);
121 bool isFilteringEnabled()
const;
123 bool filterContextMatchesOnly()
const;
124 void setFilterContextMatchesOnly(
bool filter);
126 bool filterByAttribute()
const;
127 void setFilterByAttribute(
bool filter);
129 KTextEditor::CodeCompletionModel::CompletionProperties filterAttributes()
const;
130 void setFilterAttributes(KTextEditor::CodeCompletionModel::CompletionProperties attributes);
133 int maximumInheritanceDepth()
const;
134 void setMaximumInheritanceDepth(
int maxDepth);
137 bool isGroupingEnabled()
const;
150 Q_DECLARE_FLAGS(GroupingMethods, gm)
152 static const
int ScopeTypeMask = 0x380000;
153 static const
int AccessTypeMask = 0x7;
154 static const
int ItemTypeMask = 0xfe0;
156 GroupingMethods groupingMethod() const;
157 void setGroupingMethod(GroupingMethods m);
159 bool accessIncludeConst() const;
160 void setAccessIncludeConst(
bool include);
161 bool accessIncludeStatic() const;
162 void setAccessIncludeStatic(
bool include);
163 bool accessIncludeSignalSlot() const;
164 void setAccessIncludeSignalSlot(
bool include);
167 bool isColumnMergingEnabled() const;
169 const
QList<
QList<
int> >& columnMerges() const;
170 void setColumnMerges(const
QList<
QList<
int> >& columnMerges);
175 bool shouldMatchHideCompletionList() const;
177 uint filteredItemCount() const;
180 virtual
int contextMatchQuality(const QModelIndex & index) const;
183 void expandIndex(const QModelIndex& index);
185 void argumentHintsChanged();
186 void contentGeometryChanged();
189 void setSortingEnabled(
bool enable);
190 void setFilteringEnabled(
bool enable);
191 void setGroupingEnabled(
bool enable);
192 void setColumnMergingEnabled(
bool enable);
195 void slotRowsInserted( const QModelIndex & parent,
int start,
int end );
196 void slotRowsRemoved( const QModelIndex & parent,
int start,
int end );
197 void slotModelReset();
200 void updateBestMatches();
203 void makeGroupItemsUnique(
bool onlyFiltered = false);
207 typedef
QPair<KTextEditor::CodeCompletionModel*, QModelIndex>
ModelRow;
208 virtual
int contextMatchQuality(const ModelRow& sourceRow) const;
213 ModelRow modelRowPair(const QModelIndex& index) const;
218 Item(
bool doInitialMatch,
KateCompletionModel* model,
const HierarchicalModelHandler& handler, ModelRow sourceRow);
220 bool isValid()
const;
222 bool isVisible()
const;
224 bool isFiltered()
const;
226 bool isMatching()
const;
239 const ModelRow& sourceRow()
const;
244 bool haveExactMatch()
const {
245 return m_haveExactMatch;
248 void clearExactMatch() {
249 m_haveExactMatch =
false;
258 ModelRow m_sourceRow;
262 int inheritanceDepth;
265 MatchType matchCompletion : 6;
267 bool matchFilters : 1;
268 bool m_haveExactMatch : 1;
270 QString completionSortingName()
const;
279 void addItem(
Item i,
bool notifyModel =
false);
281 bool removeItem(
const ModelRow& row);
286 bool orderBefore(
Group* other)
const;
288 int orderNumber()
const;
294 for(
int a = 0; a < filtered.size(); ++a)
295 if(filtered[a].sourceRow() == item)
310 bool hasGroups()
const;
317 QSet<Group*> createItems(
const HierarchicalModelHandler&,
const QModelIndex& i,
bool notifyModel =
false);
321 Group* createItem(
const HierarchicalModelHandler&,
const QModelIndex& i,
bool notifyModel =
false);
322 void clearGroups(
bool reset =
true);
323 void hideOrShowGroup(
Group* g,
bool notifyModel =
true);
325 Group* fetchGroup(
int attribute,
const QString& scope =
QString(),
bool forceGrouping =
false);
327 Group* groupForIndex(
const QModelIndex& index)
const;
328 inline Group* groupOfParent(
const QModelIndex& child)
const {
return static_cast<Group*
>(child.internalPointer()); }
329 QModelIndex indexForRow(Group* g,
int row)
const;
330 QModelIndex indexForGroup(Group* g)
const;
339 bool changeCompletions(Group* g, changeTypes changeType);
341 bool hasCompletionModel()
const;
344 int groupingAttributes(
int attribute)
const;
345 int countBits(
int value)
const;
350 static bool matchesAbbreviation(
const QString& word,
const QString& typed);
358 Qt::CaseSensitivity m_matchCaseSensitivity;
363 QTimer* m_updateBestMatchesTimer;
366 Group* m_argumentHints;
367 Group* m_bestMatches;
373 QMultiHash<int, Group*> m_groupHash;
379 bool m_sortingEnabled;
380 bool m_sortingAlphabetical;
381 bool m_isSortingByInheritance;
382 Qt::CaseSensitivity m_sortingCaseSensitivity;
386 bool m_filteringEnabled;
387 bool m_filterContextMatchesOnly;
388 bool m_filterByAttribute;
389 KTextEditor::CodeCompletionModel::CompletionProperties m_filterAttributes;
390 int m_maximumInheritanceDepth;
393 bool m_groupingEnabled;
394 GroupingMethods m_groupingMethod;
395 bool m_accessConst, m_accessStatic, m_accesSignalSlot;
398 bool m_columnMergingEnabled;
400 friend class CompletionTest;
403 Q_DECLARE_OPERATORS_FOR_FLAGS(KateCompletionModel::GroupingMethods)
bool operator<(const KateTextLayout &r, const KTextEditor::Cursor &c)
KateCompletionModel * model
const char * name(StandardAction id)
#define KATEPART_TESTS_EXPORT
This class has the responsibility for filtering, sorting, and manipulating code completion data provi...
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 ...
KAction * clear(const QObject *recvr, const char *slot, QObject *parent)
const KShortcut & completion()