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

KTextEditor

  • KTextEditor
  • CodeCompletionModelControllerInterface
Public Member Functions | List of all members
KTextEditor::CodeCompletionModelControllerInterface Class Reference
CodeCompletionModel Extension Interfaces

#include <codecompletionmodelcontrollerinterface.h>

Inheritance diagram for KTextEditor::CodeCompletionModelControllerInterface:
Inheritance graph
[legend]

Public Member Functions

 CodeCompletionModelControllerInterface ()
 
virtual ~CodeCompletionModelControllerInterface ()
 
virtual void aborted (View *view)
 
virtual Range completionRange (View *view, const Cursor &position)
 
virtual QString filterString (View *view, const SmartRange &range, const Cursor &position)
 
virtual bool shouldAbortCompletion (View *view, const SmartRange &range, const QString &currentCompletion)
 
virtual bool shouldExecute (const QModelIndex &selected, QChar inserted)
 
virtual bool shouldStartCompletion (View *view, const QString &insertedText, bool userInsertion, const Cursor &position)
 
virtual void updateCompletionRange (View *view, SmartRange &range)
 

Detailed Description

Controller interface for a CodeCompletionModel.

The CodeCompletionModelControllerInterface gives an CodeCompletionModel better control over the completion.

By implementing methods defined in this interface you can:

  • control when automatic completion should start (shouldStartCompletion())
  • define a custom completion range (that will be replaced when the completion is executed) (completionRange())
  • dynamically modify the completion range during completion (updateCompletionRange())
  • specify the string used for filtering the completion (filterString())
  • control when completion should stop (shouldAbortCompletion())

When the interface is not implemented, or no methods are overridden the default behaviour is used, which will be correct in many situations.

Implemeting the Interface

To use this class implement it in your CodeCompletionModel.

class MyCodeCompletion : public KTextEditor::CodeCompletionTestModel,
public KTextEditor::CodeCompletionModelControllerInterface
{
Q_OBJECT
Q_INTERFACES(KTextEditor::CodeCompletionModelControllerInterface)
public:
KTextEditor::Range completionRange(KTextEditor::View* view, const KTextEditor::Cursor &position);
};
See also
CodeCompletionModel
Author
Niko Sams <niko..nosp@m.sams.nosp@m.@gmai.nosp@m.l.co.nosp@m.m>
Since
4.2

Definition at line 70 of file codecompletionmodelcontrollerinterface.h.

Constructor & Destructor Documentation

KTextEditor::CodeCompletionModelControllerInterface::CodeCompletionModelControllerInterface ( )

Definition at line 31 of file codecompletionmodelcontrollerinterface.cpp.

KTextEditor::CodeCompletionModelControllerInterface::~CodeCompletionModelControllerInterface ( )
virtual

Definition at line 35 of file codecompletionmodelcontrollerinterface.cpp.

Member Function Documentation

void KTextEditor::CodeCompletionModelControllerInterface::aborted ( KTextEditor::View *  view)
virtual

Notification that completion for this model has been aborted.

Parameters
viewThe view in which the completion for this model was aborted

Definition at line 100 of file codecompletionmodelcontrollerinterface.cpp.

Range KTextEditor::CodeCompletionModelControllerInterface::completionRange ( View *  view,
const Cursor &  position 
)
virtual

This function returns the completion range that will be used for the current completion.

This range will be used for filtering the completion list and will get replaced when executing the completion

The default implementation will work for most languages that don't have special chars in identifiers.

Parameters
viewThe view to generate completions for
positionCurrent cursor position
Returns
the completion range

Definition at line 54 of file codecompletionmodelcontrollerinterface.cpp.

QString KTextEditor::CodeCompletionModelControllerInterface::filterString ( View *  view,
const SmartRange &  range,
const Cursor &  position 
)
virtual

This function returns the filter-text used for the current completion.

Can return an empty string to disable filtering.

The default implementation will return the text from range start to the cursor position.

The smart-mutex is not locked when this is called.

Parameters
viewThe view to generate completions for
rangeThe completion range
positionCurrent cursor position
Returns
the string used for filtering the completion list

Definition at line 83 of file codecompletionmodelcontrollerinterface.cpp.

bool KTextEditor::CodeCompletionModelControllerInterface::shouldAbortCompletion ( View *  view,
const SmartRange &  range,
const QString &  currentCompletion 
)
virtual

This function decides if the completion should be aborted.

Called after every change to the range (eg. when user entered text)

The default implementation will return true when any special character was entered, or when the range is empty.

The smart-mutex is not locked when this is called.

Parameters
viewThe view to generate completions for
rangeThe completion range
currentCompletionThe text typed so far
Returns
true, if the completion should be aborted, otherwise false

Definition at line 88 of file codecompletionmodelcontrollerinterface.cpp.

bool KTextEditor::CodeCompletionModelControllerInterface::shouldExecute ( const QModelIndex &  selected,
QChar  inserted 
)
virtual

When an item within this model is currently selected in the completion-list, and the user inserted the given character, should the completion-item be executed? This can be used to execute items from other inputs than the return-key.

For example a function item could be executed by typing '(', or variable items by typing '.'.

Parameters
selectedThe currently selected index
insertedThe character that was inserted by tue user

Definition at line 104 of file codecompletionmodelcontrollerinterface.cpp.

bool KTextEditor::CodeCompletionModelControllerInterface::shouldStartCompletion ( View *  view,
const QString &  insertedText,
bool  userInsertion,
const Cursor &  position 
)
virtual

This function decides if the automatic completion should be started when the user entered some text.

The default implementation will return true if the last character in insertedText is a letter, a number, '.', '_' or '>'

Parameters
viewThe view to generate completions for
insertedTextThe text that was inserted by the user
userInsertionWhether the text was inserted by the user using typing. If false, it may have been inserted for example by code-completion.
positionCurrent cursor position
Returns
true, if the completion should be started, otherwise false

Definition at line 39 of file codecompletionmodelcontrollerinterface.cpp.

void KTextEditor::CodeCompletionModelControllerInterface::updateCompletionRange ( View *  view,
SmartRange &  range 
)
virtual

This function lets the CompletionModel dynamically modify the range.

Called after every change to the range (eg. when user entered text)

The default implementation does nothing.

The smart-mutex is not locked when this is called.

Warning
Make sure you lock it before you change the range
Parameters
viewThe view to generate completions for
rangeReference to the current range

Definition at line 75 of file codecompletionmodelcontrollerinterface.cpp.


The documentation for this class was generated from the following files:
  • codecompletionmodelcontrollerinterface.h
  • codecompletionmodelcontrollerinterface.cpp
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