• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • applications API Reference
  • KDE Home
  • Contact Us
 

KTextEditor

  • kde-4.14
  • applications
  • kate
  • ktexteditor
codecompletionmodel.h
Go to the documentation of this file.
1 /* This file is part of the KDE libraries
2  Copyright (C) 2007-2008 David Nolden <david.nolden.kdevelop@art-master.de>
3  Copyright (C) 2005-2006 Hamish Rodda <rodda@kde.org>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License version 2 as published by the Free Software Foundation.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #ifndef KDELIBS_KTEXTEDITOR_CODECOMPLETIONMODEL_H
21 #define KDELIBS_KTEXTEDITOR_CODECOMPLETIONMODEL_H
22 
23 #include <ktexteditor/ktexteditor_export.h>
24 #include <QtCore/QModelIndex>
25 #include <ktexteditor/range.h>
26 
27 namespace KTextEditor {
28 
29 class Document;
30 class View;
31 
77 class KTEXTEDITOR_EXPORT CodeCompletionModel : public QAbstractItemModel
78 {
79  Q_OBJECT
80 
81  public:
82  CodeCompletionModel(QObject* parent);
83  virtual ~CodeCompletionModel();
84 
85  enum Columns {
86  Prefix = 0,
90  Icon,
91  Scope,
92  Name,
93  Arguments,
94  Postfix
95  };
96  static const int ColumnCount = Postfix + 1;
97 
98  enum CompletionProperty {
99  NoProperty = 0x0,
100  FirstProperty = 0x1,
101 
102  // Access specifiers - no more than 1 per item
103  Public = 0x1,
104  Protected = 0x2,
105  Private = 0x4,
106 
107  // Extra access specifiers - any number per item
108  Static = 0x8,
109  Const = 0x10,
110 
111  // Type - no more than 1 per item (except for Template)
112  Namespace = 0x20,
113  Class = 0x40,
114  Struct = 0x80,
115  Union = 0x100,
116  Function = 0x200,
117  Variable = 0x400,
118  Enum = 0x800,
119  Template = 0x1000,
120  TypeAlias = 0x2000,
121 
122  // Special attributes - any number per item
123  Virtual = 0x4000,
124  Override = 0x8000,
125  Inline = 0x10000,
126  Friend = 0x20000,
127  Signal = 0x40000,
128  Slot = 0x80000,
129 
130  // Scope - no more than 1 per item
131  LocalScope = 0x100000,
132  NamespaceScope = 0x200000,
133  GlobalScope = 0x400000,
134 
135  // Keep this in sync so the code knows when to stop
136  LastProperty = GlobalScope
137  };
138  Q_DECLARE_FLAGS(CompletionProperties, CompletionProperty)
139 
140  enum HighlightMethod {
141  NoHighlighting = 0x0,
142  InternalHighlighting = 0x1,
143  CustomHighlighting = 0x2
144  };
145  Q_DECLARE_FLAGS(HighlightMethods, HighlightMethod)
146 
147 
148  enum ExtraItemDataRoles {
151  CompletionRole = Qt::UserRole,
152 
156  ScopeIndex,
157 
172  MatchQuality,
173 
182  SetMatchContext,
183 
189  HighlightingMethod,
190 
204  CustomHighlight,
205 
213  InheritanceDepth,
214 
220  IsExpandable,
245  ExpandingWidget,
253  ItemSelected,
254 
284  ArgumentHintDepth,
285 
295  BestMatchesCount,
296 
307  AccessibilityNext,
314  AccessibilityPrevious,
321  AccessibilityAccept,
322 
353  GroupRole,
354 
355 
359  UnimportantItemRole,
360 
361  LastExtraItemDataRole
362  };
363  // KDE5 remove
364  static const int LastItemDataRole = AccessibilityAccept;
365 
366  void setRowCount(int rowCount);
367 
368  enum InvocationType {
369  AutomaticInvocation,
370  UserInvocation,
371  ManualInvocation
372  };
373 
385  virtual void completionInvoked(KTextEditor::View* view, const KTextEditor::Range& range, InvocationType invocationType);
398  virtual void executeCompletionItem(Document* document, const Range& word, int row) const;
399 
400  // Reimplementations
405  virtual int columnCount ( const QModelIndex & parent = QModelIndex() ) const;
410  virtual QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const;
417  virtual QMap<int, QVariant> itemData ( const QModelIndex & index ) const;
423  virtual QModelIndex parent ( const QModelIndex & index ) const;
430  virtual int rowCount ( const QModelIndex & parent = QModelIndex() ) const;
431 
437  bool hasGroups() const;
438 
439  Q_SIGNALS:
440 
459  void waitForReset();
460 
464  void hasGroupsChanged(KTextEditor::CodeCompletionModel *model,bool hasGroups);
465 
466  protected:
467  void setHasGroups(bool hasGroups);
468 
469  private:
470  class CodeCompletionModelPrivate* const d;
471 };
472 
478 class KTEXTEDITOR_EXPORT CodeCompletionModel2 : public CodeCompletionModel {
479  Q_OBJECT
480  public:
481  CodeCompletionModel2(QObject* parent);
492  virtual void executeCompletionItem2(Document* document, const Range& word, const QModelIndex& index) const;
493 };
494 
495 Q_DECLARE_OPERATORS_FOR_FLAGS(CodeCompletionModel::CompletionProperties)
496 Q_DECLARE_OPERATORS_FOR_FLAGS(CodeCompletionModel::HighlightMethods)
497 
498 }
499 
500 #endif // KDELIBS_KTEXTEDITOR_CODECOMPLETIONMODEL_H
KTextEditor::CodeCompletionModel::SetMatchContext
Is requested before MatchQuality(..) is requested.
Definition: codecompletionmodel.h:182
KTextEditor::CodeCompletionModel::InheritanceDepth
Returns the inheritance depth of the completion.
Definition: codecompletionmodel.h:213
QModelIndex
KTextEditor::CodeCompletionModel::Name
Definition: codecompletionmodel.h:92
KTextEditor::CodeCompletionModel::UserInvocation
Definition: codecompletionmodel.h:370
KTextEditor::CodeCompletionModel::CustomHighlight
Allows an item to provide custom highlighting.
Definition: codecompletionmodel.h:204
KTextEditor::CodeCompletionModel::HighlightMethod
HighlightMethod
Definition: codecompletionmodel.h:140
KTextEditor::CodeCompletionModel::InvocationType
InvocationType
Definition: codecompletionmodel.h:368
KTextEditor::CodeCompletionModel::AutomaticInvocation
Definition: codecompletionmodel.h:369
QMap
KTextEditor::CodeCompletionModel::ExpandingWidget
After a model returned true for a row on IsExpandable, the row may be expanded by the user...
Definition: codecompletionmodel.h:245
KTextEditor::CodeCompletionModel::ItemSelected
Whenever an item is selected, this will be requested from the underlying model.
Definition: codecompletionmodel.h:253
KTextEditor::CodeCompletionModel::Icon
Icon representing the type of completion.
Definition: codecompletionmodel.h:90
KTextEditor::CodeCompletionModel::IsExpandable
This allows items in the completion-list to be expandable.
Definition: codecompletionmodel.h:220
range.h
ktexteditor_export.h
KTextEditor::Document
A KParts derived class representing a text document.
Definition: document.h:111
QObject
KTextEditor::CodeCompletionModel::Scope
Definition: codecompletionmodel.h:91
KTextEditor::CodeCompletionModel::AccessibilityAccept
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.
Definition: codecompletionmodel.h:321
KTEXTEDITOR_EXPORT
#define KTEXTEDITOR_EXPORT
Definition: ktexteditor_export.h:35
KTextEditor::CodeCompletionModel::UnimportantItemRole
Return a nonzero value here to enforce sorting the item at the end of the list.
Definition: codecompletionmodel.h:359
KTextEditor::CodeCompletionModel::MatchQuality
If requested, your model should try to determine whether the completion in question is a suitable mat...
Definition: codecompletionmodel.h:172
KTextEditor::CodeCompletionModel::BestMatchesCount
This will be requested for each item to ask whether it should be included in computing a best-matches...
Definition: codecompletionmodel.h:295
KTextEditor::Range
An object representing a section of text, from one Cursor to another.
Definition: range.h:54
KTextEditor::CodeCompletionModel::HighlightingMethod
Define which highlighting method will be used:
Definition: codecompletionmodel.h:189
KTextEditor::CodeCompletionModel::ScopeIndex
The model should return an index to the scope -1 represents no scope.
Definition: codecompletionmodel.h:156
KTextEditor::CodeCompletionModel::GroupRole
Using this Role, it is possible to greatly optimize the time needed to process very long completion-l...
Definition: codecompletionmodel.h:353
KTextEditor::CodeCompletionModel2
You must inherit your completion-model from CodeCompletionModel2 if you want to use a hierarchical st...
Definition: codecompletionmodel.h:478
KTextEditor::CodeCompletionModel::Arguments
Definition: codecompletionmodel.h:93
KTextEditor::CodeCompletionModel::AccessibilityNext
The following three enumeration-values are only used on expanded completion-list items that contain a...
Definition: codecompletionmodel.h:307
QAbstractItemModel
KTextEditor::CodeCompletionModel::CompletionProperty
CompletionProperty
Definition: codecompletionmodel.h:98
KTextEditor::CodeCompletionModel::ArgumentHintDepth
Is this completion-item an argument-hint? The model should return an integral positive number if the ...
Definition: codecompletionmodel.h:284
KTextEditor::View
A text widget with KXMLGUIClient that represents a Document.
Definition: view.h:145
KTextEditor::CodeCompletionModel::Columns
Columns
Definition: codecompletionmodel.h:85
KTextEditor::CodeCompletionModel::AccessibilityPrevious
AccessibilityPrevious will be requested on an item if it is expanded, contains an expanding-widget...
Definition: codecompletionmodel.h:314
KTextEditor::CodeCompletionModel
An item model for providing code completion, and meta information for enhanced presentation.
Definition: codecompletionmodel.h:77
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:56:48 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KTextEditor

Skip menu "KTextEditor"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

applications API Reference

Skip menu "applications API Reference"
  •   kate
  •       kate
  •   KTextEditor
  •   Kate
  • Konsole

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal