• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.10.5 API Reference
  • KDE Home
  • Contact Us
 

KTextEditor

  • interfaces
  • 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  static const int LastItemDataRole = AccessibilityAccept;
356 
357  void setRowCount(int rowCount);
358 
359  enum InvocationType {
360  AutomaticInvocation,
361  UserInvocation,
362  ManualInvocation
363  };
364 
376  virtual void completionInvoked(KTextEditor::View* view, const KTextEditor::Range& range, InvocationType invocationType);
389  virtual void executeCompletionItem(Document* document, const Range& word, int row) const;
390 
391  // Reimplementations
396  virtual int columnCount ( const QModelIndex & parent = QModelIndex() ) const;
401  virtual QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const;
408  virtual QMap<int, QVariant> itemData ( const QModelIndex & index ) const;
414  virtual QModelIndex parent ( const QModelIndex & index ) const;
421  virtual int rowCount ( const QModelIndex & parent = QModelIndex() ) const;
422 
428  bool hasGroups() const;
429 
430  Q_SIGNALS:
431 
450  void waitForReset();
451 
455  void hasGroupsChanged(KTextEditor::CodeCompletionModel *model,bool hasGroups);
456 
457  protected:
458  void setHasGroups(bool hasGroups);
459 
460  private:
461  class CodeCompletionModelPrivate* const d;
462 };
463 
469 class KTEXTEDITOR_EXPORT CodeCompletionModel2 : public CodeCompletionModel {
470  Q_OBJECT
471  public:
472  CodeCompletionModel2(QObject* parent);
483  virtual void executeCompletionItem2(Document* document, const Range& word, const QModelIndex& index) const;
484 };
485 
486 Q_DECLARE_OPERATORS_FOR_FLAGS(CodeCompletionModel::CompletionProperties)
487 Q_DECLARE_OPERATORS_FOR_FLAGS(CodeCompletionModel::HighlightMethods)
488 
489 }
490 
491 #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
Const
QString Const
KTextEditor::CodeCompletionModel::Name
Definition: codecompletionmodel.h:92
KTextEditor::CodeCompletionModel::UserInvocation
Definition: codecompletionmodel.h:361
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:359
KTextEditor::CodeCompletionModel::AutomaticInvocation
Definition: codecompletionmodel.h:360
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
QObject
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
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::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
QAbstractItemModel
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::CodeCompletionModel2
You must inherit your completion-model from CodeCompletionModel2 if you want to use a hierarchical st...
Definition: codecompletionmodel.h:469
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
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:141
KTextEditor::CodeCompletionModel::Columns
Columns
Definition: codecompletionmodel.h:85
QMap
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-2014 The KDE developers.
Generated on Sat May 31 2014 00:05:49 by doxygen 1.8.5 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

kdelibs-4.10.5 API Reference

Skip menu "kdelibs-4.10.5 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
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