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

KTextEditor

  • KTextEditor
  • SmartCursor
Public Member Functions | Protected Member Functions | List of all members
KTextEditor::SmartCursor Class Referenceabstract
Document Extension Interfaces » Smart Cursors and Ranges

#include <smartcursor.h>

Inheritance diagram for KTextEditor::SmartCursor:
KTextEditor::Cursor

Public Member Functions

virtual ~SmartCursor ()
 
virtual bool isSmartCursor () const
 
SmartCursor & operator= (const SmartCursor &cursor)
 
SmartRange * smartRange () const
 
virtual SmartCursor * toSmartCursor () const
 
Notification

The following functions allow for changes related to this cursor to be notified to 3rd party programs.

virtual bool hasNotifier () const =0
 
virtual SmartCursorNotifier * notifier ()=0
 
virtual void deleteNotifier ()=0
 
virtual SmartCursorWatcher * watcher () const =0
 
virtual void setWatcher (SmartCursorWatcher *watcher=0L)=0
 
- Public Member Functions inherited from KTextEditor::Cursor
 Cursor ()
 
 Cursor (int line, int column)
 
 Cursor (const Cursor &copy)
 
virtual ~Cursor ()
 
Cursor & operator= (const Cursor &cursor)
 
Range * range () const
 
virtual void setPosition (const Cursor &position)
 
void setPosition (int line, int column)
 
virtual int line () const
 
virtual void setLine (int line)
 
int column () const
 
virtual void setColumn (int column)
 
bool atStartOfLine () const
 
bool atStartOfDocument () const
 
void position (int &line, int &column) const
 

Protected Member Functions

 SmartCursor (const Cursor &position, Document *doc, InsertBehavior insertBehavior)
 
- Protected Member Functions inherited from KTextEditor::Cursor
void cursorChangedDirectly (const Cursor &from)
 
virtual void setRange (Range *range)
 

Document-related functions

The following functions are provided for convenient access to the associated Document.

enum  AdvanceMode { ByCharacter, ByCursorPosition }
 
Document * document () const
 
virtual bool atEndOfLine () const
 
virtual bool atEndOfDocument () const
 
virtual bool isValid () const
 
QChar character () const
 
virtual bool insertText (const QStringList &text, bool block=false)
 
virtual bool advance (int distance, AdvanceMode mode=ByCharacter)
 

Behavior

The following functions relate to the behavior of this SmartCursor.

enum  InsertBehavior { StayOnInsert = 0, MoveOnInsert }
 
InsertBehavior insertBehavior () const
 
void setInsertBehavior (InsertBehavior insertBehavior)
 

Additional Inherited Members

- Static Public Member Functions inherited from KTextEditor::Cursor
static Cursor invalid ()
 
static Cursor start ()
 
- Protected Attributes inherited from KTextEditor::Cursor
int m_column
 
int m_line
 
Range * m_range
 

Detailed Description

A Cursor which is bound to a specific Document, and maintains its position.

A SmartCursor is an extension of the basic Cursor class. It maintains its position in the document and provides a number of convenience methods, including those for accessing and manipulating the content of the associated Document. As a result of this, SmartCursors may not be copied, as they need to maintain a connection to the associated Document.

To receive notifications when the position of the cursor changes, or other similar notifications, see either SmartCursorNotifier for QObject signal notification via notifier(), or SmartCursorWatcher for virtual inheritance notification via setWatcher().

Create a new SmartCursor like this:

// Retrieve the SmartInterface
KTextEditor::SmartInterface* smart =
qobject_cast<KTextEditor::SmartInterface*>( yourDocument );
if ( smart ) {
KTextEditor::SmartCursor* cursor = smart->newSmartCursor();
}

When finished with a SmartCursor, simply delete it.

See also
Cursor, SmartCursorNotifier, SmartCursorWatcher, and SmartInterface.
Author
Hamish Rodda <rodda.nosp@m.@kde.nosp@m..org>

Definition at line 65 of file smartcursor.h.

Constructor & Destructor Documentation

SmartCursor::~SmartCursor ( )
virtual

Virtual destructor.

Subclasses should call SmartCursorNotifier::deleted() and SmartCursorWatcher::deleted() methods before cleaning themselves up.

Definition at line 34 of file smartcursor.cpp.

SmartCursor::SmartCursor ( const Cursor &  position,
Document *  doc,
InsertBehavior  insertBehavior 
)
protected

Constructor for subclasses to utilise. Protected to prevent direct instantiation.

Note
3rd party developers: you do not (and should not) need to subclass the Smart* classes; instead, use the SmartInterface to create instances.
Parameters
positionthe cursor position to assign
docthe Document this cursor is associated with
insertBehaviorthe behavior of this cursor when on the position of an insert.

Definition at line 26 of file smartcursor.cpp.

Member Function Documentation

virtual void KTextEditor::SmartCursor::deleteNotifier ( )
pure virtual

Deletes the current SmartCursorNotifier.

When finished with a notifier, call this method to save memory, and potentially editor logic processing time, by having the SmartCursorNotifier deleted.

virtual bool KTextEditor::SmartCursor::hasNotifier ( ) const
pure virtual

Determine if a notifier already exists for this smart cursor.

Returns
true if a notifier already exists, otherwise false
bool SmartCursor::isSmartCursor ( ) const
virtual

Returns that this cursor is a SmartCursor.

Reimplemented from KTextEditor::Cursor.

Definition at line 48 of file smartcursor.cpp.

virtual SmartCursorNotifier* KTextEditor::SmartCursor::notifier ( )
pure virtual

Returns the current SmartCursorNotifier.

If one does not already exist, it will be created.

Connect to the notifier to receive signals indicating change of state of this cursor. The notifier is created at the time it is first requested. If you have finished with notifications for a reasonable period of time you can save memory, and potentially editor logic processing time, by calling deleteNotifier().

Returns
a pointer to the current SmartCursorNotifier for this SmartCursor. If one does not already exist, it will be created.
SmartCursor& KTextEditor::SmartCursor::operator= ( const SmartCursor &  cursor)
inline

Assignment operator.

Assigns the current position of the provided cursor, c, only; does not assign watchers, notifiers, behavior, etc.

Note
The assignment will be performed even if the provided cursor belongs to another Document.
Parameters
cursorthe position to assign.
Returns
a reference to this cursor, after assignment has occurred.
See also
setPosition()

Definition at line 274 of file smartcursor.h.

virtual void KTextEditor::SmartCursor::setWatcher ( SmartCursorWatcher *  watcher = 0L)
pure virtual

Provide a SmartCursorWatcher to receive calls indicating change of state of this cursor.

To finish receiving notifications, call this function with watcher set to 0L.

Parameters
watcherthe class which will receive notifications about changes to this cursor.
SmartRange * SmartCursor::smartRange ( ) const

Returns the range that this cursor belongs to, if any.

See also
Cursor::range()

Definition at line 63 of file smartcursor.cpp.

SmartCursor * SmartCursor::toSmartCursor ( ) const
virtual

Returns this cursor as a SmartCursor.

Reimplemented from KTextEditor::Cursor.

Definition at line 88 of file smartcursor.cpp.

virtual SmartCursorWatcher* KTextEditor::SmartCursor::watcher ( ) const
pure virtual

Returns a pointer to the current SmartCursorWatcher, if one has been set.

Returns
the current SmartCursorWatcher pointer if one exists, otherwise null.

The documentation for this class was generated from the following files:
  • smartcursor.h
  • smartcursor.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2015 The KDE developers.
Generated on Fri Oct 16 2015 09:23:58 by doxygen 1.8.9.1 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.14.12 API Reference

Skip menu "kdelibs-4.14.12 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