KTextEditor

codecompletionmodel.h
1 /*
2  SPDX-FileCopyrightText: 2007-2008 David Nolden <[email protected]>
3  SPDX-FileCopyrightText: 2005-2006 Hamish Rodda <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #ifndef KTEXTEDITOR_CODECOMPLETIONMODEL_H
9 #define KTEXTEDITOR_CODECOMPLETIONMODEL_H
10 
11 #include <QModelIndex>
12 #include <ktexteditor/range.h>
13 #include <ktexteditor_export.h>
14 
15 namespace KTextEditor
16 {
17 class Document;
18 class View;
19 
67 class KTEXTEDITOR_EXPORT CodeCompletionModel : public QAbstractItemModel
68 {
69  Q_OBJECT
70 
71 public:
72  explicit CodeCompletionModel(QObject *parent);
73  ~CodeCompletionModel() override;
74 
75  enum Columns {
76  Prefix = 0,
81  Scope,
82  Name,
83  Arguments,
84  Postfix
85  };
86  static const int ColumnCount = Postfix + 1;
87 
90  NoProperty = 0x0,
91  FirstProperty = 0x1,
92 
93  // Access specifiers - no more than 1 per item
94  Public = 0x1,
95  Protected = 0x2,
96  Private = 0x4,
97 
98  // Extra access specifiers - any number per item
99  Static = 0x8,
100  Const = 0x10,
101 
102  // Type - no more than 1 per item (except for Template)
103  Namespace = 0x20,
104  Class = 0x40,
105  Struct = 0x80,
106  Union = 0x100,
107  Function = 0x200,
108  Variable = 0x400,
109  Enum = 0x800,
110  Template = 0x1000,
111  TypeAlias = 0x2000,
112 
113  // Special attributes - any number per item
114  Virtual = 0x4000,
115  Override = 0x8000,
116  Inline = 0x10000,
117  Friend = 0x20000,
118  Signal = 0x40000,
119  Slot = 0x80000,
120 
121  // Scope - no more than 1 per item
122  LocalScope = 0x100000,
123  NamespaceScope = 0x200000,
124  GlobalScope = 0x400000,
125 
126  // Keep this in sync so the code knows when to stop
127  LastProperty = GlobalScope
128  };
131 
132 
133  enum HighlightMethod { NoHighlighting = 0x0, InternalHighlighting = 0x1, CustomHighlighting = 0x2 };
136 
137 
138  enum ExtraItemDataRoles {
141  CompletionRole = Qt::UserRole,
142 
147 
163 
173 
180 
195 
204 
248 
279 
290 
317 
349 
354 
355  LastExtraItemDataRole
356  };
357 
358  void setRowCount(int rowCount);
359 
360  enum InvocationType { AutomaticInvocation, UserInvocation, ManualInvocation };
361 
373  virtual void completionInvoked(KTextEditor::View *view, const KTextEditor::Range &range, InvocationType invocationType);
374 
385  virtual void executeCompletionItem(KTextEditor::View *view, const Range &word, const QModelIndex &index) const;
386 
387  // Reimplementations
392  int columnCount(const QModelIndex &parent = QModelIndex()) const override;
397  QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
404  QMap<int, QVariant> itemData(const QModelIndex &index) const override;
410  QModelIndex parent(const QModelIndex &index) const override;
417  int rowCount(const QModelIndex &parent = QModelIndex()) const override;
418 
423  bool hasGroups() const;
424 
425 Q_SIGNALS:
426 
445  void waitForReset();
446 
450  void hasGroupsChanged(KTextEditor::CodeCompletionModel *model, bool hasGroups);
451 
452 protected:
453  void setHasGroups(bool hasGroups);
454 
455 private:
456  class CodeCompletionModelPrivate *const d;
457 };
458 
459 Q_DECLARE_OPERATORS_FOR_FLAGS(CodeCompletionModel::CompletionProperties)
460 Q_DECLARE_OPERATORS_FOR_FLAGS(CodeCompletionModel::HighlightMethods)
461 
462 }
463 
464 #endif // KTEXTEDITOR_CODECOMPLETIONMODEL_H
Is requested before MatchQuality(..) is requested.
Returns the inheritance depth of the completion.
Variable for variable expansion.
Definition: variable.h:35
Allows an item to provide custom highlighting.
After a model returned true for a row on IsExpandable, the row may be expanded by the user...
Whenever an item is selected, this will be requested from the underlying model.
Icon representing the type of completion.
This allows items in the completion-list to be expandable.
UserRole
AccessibilityAccept will be requested on an item if it is expanded, contains an expanding-widget, and the user triggers a special shortcut to trigger the action associated with the position within the expanding-widget the user has navigated to using AccessibilityNext and AccessibilityPrevious.
Return a nonzero value here to enforce sorting the item at the end of the list.
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
Definition: katetextblock.h:21
If requested, your model should try to determine whether the completion in question is a suitable mat...
This will be requested for each item to ask whether it should be included in computing a best-matches...
An object representing a section of text, from one Cursor to another.
Define which highlighting method will be used:
The model should return an index to the scope -1 represents no scope.
ExtraItemDataRoles
Meta information is passed through extra {Qt::ItemDataRole}s.
Using this Role, it is possible to greatly optimize the time needed to process very long completion-l...
The following three enumeration-values are only used on expanded completion-list items that contain a...
Is this completion-item an argument-hint? The model should return an integral positive number if the ...
A text widget with KXMLGUIClient that represents a Document.
Definition: view.h:146
AccessibilityPrevious will be requested on an item if it is expanded, contains an expanding-widget...
An item model for providing code completion, and meta information for enhanced presentation.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Wed Jan 20 2021 23:01:51 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.