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

KTextEditor

  • KTextEditor
  • Document
Signals | Public Member Functions | Protected Member Functions
KTextEditor::Document Class Reference

#include <document.h>

Inheritance diagram for KTextEditor::Document:
KParts::ReadWritePart KParts::ReadOnlyPart KParts::Part QObject KParts::PartBase KXMLGUIClient

List of all members.

Signals

void aboutToClose (KTextEditor::Document *document)
void aboutToReload (KTextEditor::Document *document)
void documentNameChanged (KTextEditor::Document *document)
void documentSavedOrUploaded (KTextEditor::Document *document, bool saveAs)
void documentUrlChanged (KTextEditor::Document *document)
void exclusiveEditEnd (KTextEditor::Document *document)
void exclusiveEditStart (KTextEditor::Document *document)
void highlightingModeChanged (KTextEditor::Document *document)
void modeChanged (KTextEditor::Document *document)
void modifiedChanged (KTextEditor::Document *document)
void reloaded (KTextEditor::Document *document)
void textChanged (KTextEditor::Document *document)
void textChanged (KTextEditor::Document *document, const KTextEditor::Range &oldRange, const KTextEditor::Range &newRange)
void textChanged (KTextEditor::Document *document, const KTextEditor::Range &oldRange, const QString &oldText, const KTextEditor::Range &newRange)
void textInserted (KTextEditor::Document *document, const KTextEditor::Range &range)
void textRemoved (KTextEditor::Document *document, const KTextEditor::Range &range)
void textRemoved (KTextEditor::Document *document, const KTextEditor::Range &range, const QString &oldText)
void viewCreated (KTextEditor::Document *document, KTextEditor::View *view)
- Signals inherited from KParts::ReadWritePart
void canceled (const QString &errMsg)
void completed (bool pendingAction)
void completed ()
void setStatusBarText (const QString &text)
void setWindowCaption (const QString &caption)
void sigQueryClose (bool *handled, bool *abortClosing)
void started (KIO::Job *)
void urlChanged (const KUrl &url)
- Signals inherited from KParts::ReadOnlyPart
- Signals inherited from KParts::Part

Public Member Functions

 Document (QObject *parent=0)
virtual ~Document ()
virtual View * activeView () const =0
virtual QChar character (const Cursor &position) const =0
virtual bool clear ()=0
virtual View * createView (QWidget *parent)=0
virtual bool cursorInText (const Cursor &cursor)
virtual Cursor documentEnd () const =0
virtual const QString & documentName () const =0
Range documentRange () const
virtual bool documentReload ()=0
virtual bool documentSave ()=0
virtual bool documentSaveAs ()=0
virtual Editor * editor ()=0
virtual const QString & encoding () const =0
virtual bool endEditing ()=0
Cursor endOfLine (int line) const
virtual QString highlightingMode () const =0
virtual QStringList highlightingModes () const =0
virtual QString highlightingModeSection (int index) const =0
virtual bool insertLine (int line, const QString &text)=0
virtual bool insertLines (int line, const QStringList &text)=0
virtual bool insertText (const Cursor &position, const QString &text, bool block=false)=0
virtual bool insertText (const Cursor &position, const QStringList &text, bool block=false)=0
virtual bool isEmpty () const
virtual QString line (int line) const =0
virtual int lineLength (int line) const =0
virtual int lines () const =0
virtual QString mimeType ()=0
virtual QString mode () const =0
virtual QStringList modes () const =0
virtual QString modeSection (int index) const =0
bool openingError () const
QString openingErrorMessage () const
virtual bool removeLine (int line)=0
virtual bool removeText (const Range &range, bool block=false)=0
virtual bool replaceText (const Range &range, const QString &text, bool block=false)
virtual bool replaceText (const Range &range, const QStringList &text, bool block=false)
virtual bool setEncoding (const QString &encoding)=0
virtual bool setHighlightingMode (const QString &name)=0
virtual bool setMode (const QString &name)=0
void setSuppressOpeningErrorDialogs (bool suppress)
virtual bool setText (const QString &text)=0
virtual bool setText (const QStringList &text)=0
virtual bool startEditing ()=0
bool suppressOpeningErrorDialogs () const
virtual QString text () const =0
virtual QString text (const Range &range, bool block=false) const =0
virtual QStringList textLines (const Range &range, bool block=false) const =0
virtual int totalCharacters () const =0
virtual const QList< View * > & views () const =0
- Public Member Functions inherited from KParts::ReadWritePart
 ReadWritePart (QObject *parent=0)
virtual ~Part ()
virtual ~PartBase ()
virtual ~ReadOnlyPart ()
virtual ~ReadWritePart ()
OpenUrlArguments arguments () const
BrowserExtension * browserExtension () const
bool closeStream ()
virtual bool closeUrl (bool promptToSave)
virtual bool closeUrl ()
virtual void embed (QWidget *parentWidget)
virtual Part * hitTest (QWidget *widget, const QPoint &globalPos)
KIconLoader * iconLoader ()
bool isModified () const
bool isProgressInfoEnabled () const
bool isReadWrite () const
bool isSelectable () const
PartManager * manager () const
bool openStream (const QString &mimeType, const KUrl &url)
 Part (QObject *parent=0)
 PartBase ()
QObject * partObject () const
virtual bool queryClose ()
 ReadOnlyPart (QObject *parent=0)
virtual bool saveAs (const KUrl &url)
void setArguments (const OpenUrlArguments &arguments)
void setAutoDeletePart (bool autoDeletePart)
void setAutoDeleteWidget (bool autoDeleteWidget)
virtual void setManager (PartManager *manager)
virtual void setModified (bool modified)
void setPartObject (QObject *object)
void setProgressInfoEnabled (bool show)
virtual void setReadWrite (bool readwrite=true)
virtual void setSelectable (bool selectable)
void showProgressInfo (bool show)
KUrl url () const
virtual QWidget * widget ()
bool writeStream (const QByteArray &data)

Protected Member Functions

void setOpeningError (bool errors)
void setOpeningErrorMessage (const QString &message)
- Protected Member Functions inherited from KParts::ReadWritePart
void abortLoad ()
virtual void customEvent (QEvent *event)
virtual void guiActivateEvent (GUIActivateEvent *event)
QWidget * hostContainer (const QString &containerName)
bool isLocalFileTemporary () const
void loadPlugins (QObject *parent, KXMLGUIClient *parentGUIClient, const KComponentData &componentData)
void loadPlugins ()
QString localFilePath () const
virtual bool openFile ()
 Part (PartPrivate &dd, QObject *parent)
virtual void partActivateEvent (PartActivateEvent *event)
 PartBase (PartBasePrivate &dd)
virtual void partSelectEvent (PartSelectEvent *event)
 ReadOnlyPart (ReadOnlyPartPrivate &dd, QObject *parent)
virtual bool saveFile ()=0
virtual bool saveToUrl ()
virtual void setComponentData (const KComponentData &componentData)
virtual void setComponentData (const KComponentData &componentData, bool loadPlugins)
void setLocalFilePath (const QString &localFilePath)
void setLocalFileTemporary (bool temp)
void setPluginInterfaceVersion (int version)
void setPluginLoadingMode (PluginLoadingMode loadingMode)
void setUrl (const KUrl &url)
virtual void setWidget (QWidget *widget)

Additional Inherited Members

- Public Slots inherited from KParts::ReadWritePart
virtual bool openUrl (const KUrl &url)
virtual bool save ()
void setModified ()
bool waitSaveComplete ()
- Public Slots inherited from KParts::ReadOnlyPart
- Properties inherited from KParts::ReadWritePart
KUrl url
- Properties inherited from KParts::ReadOnlyPart

Detailed Description

A KParts derived class representing a text document.

Topics:

  • Introduction
  • Text Manipulation
  • Document Views
  • Document Extension Interfaces

Introduction

The Document class represents a pure text document providing methods to modify the content and create views. A document can have any number of views, each view representing the same content, i.e. all views are synchronized. Support for text selection is handled by a View and text format attributes by the Attribute class.

To load a document call KParts::ReadOnlyPart::openUrl(). To reload a document from a file call documentReload(), to save the document call documentSave() or documentSaveAs(). Whenever the modified state of the document changes the signal modifiedChanged() is emitted. Check the modified state with KParts::ReadWritePart::isModified(). Further signals are documentUrlChanged(). The encoding can be specified with setEncoding(), however this will only take effect on file reload and file save.

Text Manipulation

Get the whole content with text() and set new content with setText(). Call insertText() or insertLine() to insert new text or removeText() and removeLine() to remove content. Whenever the document's content changed the signal textChanged() is emitted. Additional signals are textInserted() and textRemoved(). Note, that the first line in the document is line 0.

If the editor part supports it, a document provides full undo/redo history. Text manipulation actions can be grouped together using startEditing() and endEditing(). All actions in between are grouped together to only one undo/redo action. Due to internal reference counting you can call startEditing() and endEditing() as often as you wish, but make sure you call endEditing() exactly as often as you call startEditing(), otherwise the reference counter gets confused.

Document Views

A View displays the document's content. As already mentioned, a document can have any number of views, all synchronized. Get a list of all views with views(). Only one of the views can be active (i.e. has focus), get it by using activeView(). Create a new view with createView(). Every time a new view is created the signal viewCreated() is emitted.

Document Extension Interfaces

A simple document represents text and provides text manipulation methods. However, a real text editor should support advanced concepts like session support, textsearch support, bookmark/general mark support etc. That is why the KTextEditor library provides several additional interfaces to extend a document's capabilities via multiple inheritance.

More information about interfaces for the document can be found in Document Extension Interfaces.

See also:
KParts::ReadWritePart, KTextEditor::Editor, KTextEditor::View, KTextEditor::MarkInterface, KTextEditor::ModificationInterface, KTextEditor::SearchInterface, KTextEditor::SessionConfigInterface, KTextEditor::SmartInterface, KTextEditor::VariableInterface
Author:
Christoph Cullmann <cullm.nosp@m.ann@.nosp@m.kde.o.nosp@m.rg>

Definition at line 111 of file document.h.


Constructor & Destructor Documentation

Document::Document ( QObject *  parent = 0)

Constructor.

Create a new document with parent.

Parameters:
parentparent object
See also:
Editor::createDocument()

Definition at line 127 of file document.cpp.

Document::~Document ( )
virtual

Virtual destructor.

Definition at line 135 of file document.cpp.


Member Function Documentation

void KTextEditor::Document::aboutToClose ( KTextEditor::Document *  document)
signal

Warn anyone listening that the current document is about to close.

At this point all of the information is still accessible, such as the text, cursors and ranges.

Any modifications made to the document at this point will be lost.

Parameters:
documentthe document being closed
void KTextEditor::Document::aboutToReload ( KTextEditor::Document *  document)
signal

Warn anyone listening that the current document is about to reload.

At this point all of the information is still accessible, such as the text, cursors and ranges.

Any modifications made to the document at this point will be lost.

Parameters:
documentthe document being reloaded
virtual View* KTextEditor::Document::activeView ( ) const
pure virtual

Return the view which currently has user focus, if any.

virtual QChar KTextEditor::Document::character ( const Cursor &  position) const
pure virtual

Get the character at cursor.

Parameters:
positionthe location of the character to retrieve
Returns:
the requested character, or QChar() for invalid cursors.
See also:
setText()
virtual bool KTextEditor::Document::clear ( )
pure virtual

Remove the whole content of the document.

Returns:
true on success, otherwise false
See also:
removeText(), removeLine()
virtual View* KTextEditor::Document::createView ( QWidget *  parent)
pure virtual

Create a new view attached to parent.

Parameters:
parentparent widget
Returns:
the new view
bool Document::cursorInText ( const Cursor &  cursor)
virtual

Checks whether the cursor specifies a valid position in a document.

It can optionally be overridden by an implementation.

Parameters:
cursorwhich should be checked
Returns:
true, if the cursor is valid, otherwise false
See also:
SmartCursor::isValid()

Definition at line 164 of file document.cpp.

virtual Cursor KTextEditor::Document::documentEnd ( ) const
pure virtual

End position of the document.

Returns:
The last column on the last line of the document
See also:
all()
virtual const QString& KTextEditor::Document::documentName ( ) const
pure virtual

Get this document's name.

The editor part should provide some meaningful name, like some unique "Untitled XYZ" for the document - without URL or basename for documents with url.

Returns:
readable document name
void KTextEditor::Document::documentNameChanged ( KTextEditor::Document *  document)
signal

This signal is emitted whenever the document name changes.

Parameters:
documentdocument which changed its name
See also:
documentName()
Range KTextEditor::Document::documentRange ( ) const
inline

A Range which encompasses the whole document.

Returns:
A range from the start to the end of the document

Definition at line 396 of file document.h.

virtual bool KTextEditor::Document::documentReload ( )
pure virtual

Reload the current file.

The user will be prompted by the part on changes and more and can cancel this action if it can harm.

Returns:
true if the reload has been done, otherwise false. If the document has no url set, it will just return false.
virtual bool KTextEditor::Document::documentSave ( )
pure virtual

Save the current file.

The user will be asked for a filename if needed and more.

Returns:
true on success, i.e. the save has been done, otherwise false
virtual bool KTextEditor::Document::documentSaveAs ( )
pure virtual

Save the current file to another location.

The user will be asked for a filename and more.

Returns:
true on success, i.e. the save has been done, otherwise false
void KTextEditor::Document::documentSavedOrUploaded ( KTextEditor::Document *  document,
bool  saveAs 
)
signal

This signal should be emitted after a document has been saved to disk or for remote files uploaded.

saveAs should be set to true, if the operation is a save as operation

void KTextEditor::Document::documentUrlChanged ( KTextEditor::Document *  document)
signal

This signal is emitted whenever the document URL changes.

Parameters:
documentdocument which changed its URL
See also:
KParts::ReadOnlyPart::url()
virtual Editor* KTextEditor::Document::editor ( )
pure virtual

Get the global editor object.

The editor part implementation must ensure that this object exists as long as any factory or document object exists.

Returns:
global KTextEditor::Editor object
See also:
KTextEditor::Editor
virtual const QString& KTextEditor::Document::encoding ( ) const
pure virtual

Get the current chosen encoding.

The return value is an empty string, if the document uses the default encoding of the editor and no own special encoding.

Returns:
current encoding of the document
See also:
setEncoding()
virtual bool KTextEditor::Document::endEditing ( )
pure virtual

End an editing sequence.

Returns:
true on success, otherwise false. Parts not supporting it should return false.
See also:
startEditing() for more details
Cursor KTextEditor::Document::endOfLine ( int  line) const
inline

Get the end cursor position of line line.

Parameters:
lineline
See also:
lineLength(), line()

Definition at line 425 of file document.h.

void KTextEditor::Document::exclusiveEditEnd ( KTextEditor::Document *  document)
signal

In conjunction with exclusiveEditStart(), signals that the document's content may be changed again without restriction.

Since:
4.5
void KTextEditor::Document::exclusiveEditStart ( KTextEditor::Document *  document)
signal

Upon emission, the document's content may only be changed by the initiator of this signal until exclusiveEditEnd() is signalled.

It is, however, possible to listen to changes of the content.

Signalled e.g. on undo or redo.

Since:
4.5
virtual QString KTextEditor::Document::highlightingMode ( ) const
pure virtual

Return the name of the currently used mode.

Returns:
name of the used mode
See also:
highlightingModes(), setHighlightingMode()
void KTextEditor::Document::highlightingModeChanged ( KTextEditor::Document *  document)
signal

Warn anyone listening that the current document's highlighting mode has changed.

Parameters:
documentthe document which's mode has changed
See also:
setHighlightingMode()
virtual QStringList KTextEditor::Document::highlightingModes ( ) const
pure virtual

Return a list of the names of all possible modes.

Returns:
list of mode names
See also:
highlightingMode(), setHighlightingMode()
virtual QString KTextEditor::Document::highlightingModeSection ( int  index) const
pure virtual

Returns the name of the section for a highlight given its index in the highlight list (as returned by highlightModes()).

You can use this function to build a tree of the highlight names, organized in sections.

Parameters:
indexthe index of the highlight in the list returned by modes()
virtual bool KTextEditor::Document::insertLine ( int  line,
const QString &  text 
)
pure virtual

Insert line(s) at the given line number.

The newline character '\n' is treated as line delimiter, so it is possible to insert multiple lines. To append lines at the end of the document, use

insertLine( lines(), text )
Parameters:
lineline where to insert the text
texttext which should be inserted
Returns:
true on success, otherwise false
See also:
insertText()
virtual bool KTextEditor::Document::insertLines ( int  line,
const QStringList &  text 
)
pure virtual

Insert line(s) at the given line number.

The newline character '\n' is treated as line delimiter, so it is possible to insert multiple lines. To append lines at the end of the document, use

insertLine( lines(), text )
Parameters:
lineline where to insert the text
texttext which should be inserted
Returns:
true on success, otherwise false
See also:
insertText()
virtual bool KTextEditor::Document::insertText ( const Cursor &  position,
const QString &  text,
bool  block = false 
)
pure virtual

Insert text at position.

Parameters:
positionposition to insert the text
texttext to insert
blockinsert this text as a visual block of text rather than a linear sequence
Returns:
true on success, otherwise false
See also:
setText(), removeText()
virtual bool KTextEditor::Document::insertText ( const Cursor &  position,
const QStringList &  text,
bool  block = false 
)
pure virtual

Insert text at position.

Parameters:
positionposition to insert the text
texttext to insert
blockinsert this text as a visual block of text rather than a linear sequence
Returns:
true on success, otherwise false
See also:
setText(), removeText()
bool Document::isEmpty ( ) const
virtual

Returns if the document is empty.

Definition at line 190 of file document.cpp.

virtual QString KTextEditor::Document::line ( int  line) const
pure virtual

Get a single text line.

Parameters:
linethe wanted line
Returns:
the requested line, or "" for invalid line numbers
See also:
text(), lineLength()
virtual int KTextEditor::Document::lineLength ( int  line) const
pure virtual

Get the length of a given line in characters.

Parameters:
lineline to get length from
Returns:
the number of characters in the line or -1 if the line was invalid
See also:
line()
virtual int KTextEditor::Document::lines ( ) const
pure virtual

Get the count of lines of the document.

Returns:
the current number of lines in the document
See also:
length()
virtual QString KTextEditor::Document::mimeType ( )
pure virtual

Get this document's mimetype.

Returns:
mimetype
virtual QString KTextEditor::Document::mode ( ) const
pure virtual

Return the name of the currently used mode.

Returns:
name of the used mode
See also:
modes(), setMode()
void KTextEditor::Document::modeChanged ( KTextEditor::Document *  document)
signal

Warn anyone listening that the current document's mode has changed.

Parameters:
documentthe document whose mode has changed
See also:
setMode()
virtual QStringList KTextEditor::Document::modes ( ) const
pure virtual

Return a list of the names of all possible modes.

Returns:
list of mode names
See also:
mode(), setMode()
virtual QString KTextEditor::Document::modeSection ( int  index) const
pure virtual

Returns the name of the section for a mode given its index in the highlight list (as returned by modes()).

You can use this function to build a tree of the mode names, organized in sections.

Parameters:
indexthe index of the highlight in the list returned by modes()
void KTextEditor::Document::modifiedChanged ( KTextEditor::Document *  document)
signal

This signal is emitted whenever the document's buffer changed from either state unmodified to modified or vice versa.

Parameters:
documentdocument which changed its modified state
See also:
KParts::ReadWritePart::isModified().
KParts::ReadWritePart::setModified()
bool Document::openingError ( ) const

True, eg if the file for opening could not be read This doesn't have to handle the KPart job cancled cases.

Definition at line 148 of file document.cpp.

QString Document::openingErrorMessage ( ) const

Definition at line 152 of file document.cpp.

void KTextEditor::Document::reloaded ( KTextEditor::Document *  document)
signal

Emitted after the current document was reloaded.

At this point, some information might have been invalidated, like for example the editing history.

Parameters:
documentthe document that was reloaded.
Since:
4.6
virtual bool KTextEditor::Document::removeLine ( int  line)
pure virtual

Remove line from the document.

Parameters:
lineline to remove
Returns:
true on success, otherwise false
See also:
removeText(), clear()
virtual bool KTextEditor::Document::removeText ( const Range &  range,
bool  block = false 
)
pure virtual

Remove the text specified in range.

Parameters:
rangerange of text to remove
blockset this to true to remove a text block on the basis of columns, rather than everything inside range
Returns:
true on success, otherwise false
See also:
setText(), insertText()
bool KTextEditor::Document::replaceText ( const Range &  range,
const QString &  text,
bool  block = false 
)
virtual

Replace text from range with specified text.

Parameters:
rangerange of text to replace
texttext to replace with
blockreplace text as a visual block of text rather than a linear sequence
Returns:
true on success, otherwise false
See also:
setText(), removeText(), insertText()

Definition at line 170 of file document.cpp.

bool Document::replaceText ( const Range &  range,
const QStringList &  text,
bool  block = false 
)
virtual

Replace text from range with specified text.

Parameters:
rangerange of text to replace
texttext to replace with
blockreplace text as a visual block of text rather than a linear sequence
Returns:
true on success, otherwise false
See also:
setText(), removeText(), insertText()

Definition at line 180 of file document.cpp.

virtual bool KTextEditor::Document::setEncoding ( const QString &  encoding)
pure virtual

This signal is emitted whenever the readWrite state of a document changes.

Set the encoding for this document. This encoding will be used while loading and saving files, it will not affect the already existing content of the document, e.g. if the file has already been opened without the correct encoding, this will not fix it, you would for example need to trigger a reload for this.

Parameters:
encodingnew encoding for the document, the name must be accepted by QTextCodec, if an empty encoding name is given, the part should fallback to its own default encoding, e.g. the system encoding or the global user settings
Returns:
true on success, or false, if the encoding could not be set.
See also:
encoding()
virtual bool KTextEditor::Document::setHighlightingMode ( const QString &  name)
pure virtual

Set the current mode of the document by giving its name.

Parameters:
namename of the mode to use for this document
Returns:
true on success, otherwise false
See also:
highlightingMode(), highlightingModes(), highlightingModeChanged()
virtual bool KTextEditor::Document::setMode ( const QString &  name)
pure virtual

Set the current mode of the document by giving its name.

Parameters:
namename of the mode to use for this document
Returns:
true on success, otherwise false
See also:
mode(), modes(), modeChanged()
void Document::setOpeningError ( bool  errors)
protected

Definition at line 156 of file document.cpp.

void Document::setOpeningErrorMessage ( const QString &  message)
protected

Definition at line 160 of file document.cpp.

void Document::setSuppressOpeningErrorDialogs ( bool  suppress)

by default dialogs should be displayed.

In any case (dialog shown or suppressed) openingErrors and openingErrorMessage should have meaningfull values

Parameters:
suppresstrue/false value if dialogs should be displayed

Definition at line 140 of file document.cpp.

virtual bool KTextEditor::Document::setText ( const QString &  text)
pure virtual

Set the given text as new document content.

Parameters:
textnew content for the document
Returns:
true on success, otherwise false
See also:
text()
virtual bool KTextEditor::Document::setText ( const QStringList &  text)
pure virtual

Set the given text as new document content.

Parameters:
textnew content for the document
Returns:
true on success, otherwise false
See also:
text()
virtual bool KTextEditor::Document::startEditing ( )
pure virtual

Begin an editing sequence.

Edit commands during this sequence will be bunched together so that they represent a single undo command in the editor, and so that repaint events do not occur inbetween.

Your application should not return control to the event loop while it has an unterminated (i.e. no matching endEditing() call) editing sequence (result undefined) - so do all of your work in one go!

This call stacks, like the endEditing() calls, this means you can safely call it three times in a row for example if you call endEditing() three times, too, it internaly just does counting the running editing sessions.

If the texteditor part does not support these transactions, both calls just do nothing.

Returns:
true on success, otherwise false. Parts not supporting it should return false
See also:
endEditing()
bool Document::suppressOpeningErrorDialogs ( ) const

Definition at line 144 of file document.cpp.

virtual QString KTextEditor::Document::text ( ) const
pure virtual

Get the document content.

Returns:
the complete document content
See also:
setText()
virtual QString KTextEditor::Document::text ( const Range &  range,
bool  block = false 
) const
pure virtual

Get the document content within the given range.

Parameters:
rangethe range of text to retrieve
blockSet this to true to receive text in a visual block, rather than everything inside range.
Returns:
the requested text part, or QString() for invalid ranges.
See also:
setText()
void KTextEditor::Document::textChanged ( KTextEditor::Document *  document)
signal

The document emits this signal whenever its text changes.

Parameters:
documentdocument which emitted this signal
See also:
text(), textLine()
void KTextEditor::Document::textChanged ( KTextEditor::Document *  document,
const KTextEditor::Range &  oldRange,
const KTextEditor::Range &  newRange 
)
signal

The document emits this signal whenever the text in range oldRange was removed and replaced with the text now in newRange, e.g.

the user selects text and pastes new text to replace the selection.

Note:
oldRange.start() is guaranteed to equal newRange.start().
Parameters:
documentdocument which emitted this signal
oldRangerange that the text previously occupied
newRangerange that the changed text now occupies
See also:
insertText(), insertLine(), removeText(), removeLine(), clear()
void KTextEditor::Document::textChanged ( KTextEditor::Document *  document,
const KTextEditor::Range &  oldRange,
const QString &  oldText,
const KTextEditor::Range &  newRange 
)
signal

The document emits this signal whenever the text in range oldRange was removed and replaced with the text now in newRange, e.g.

the user selects text and pastes new text to replace the selection.

Note:
oldRange.start() is guaranteed to equal newRange.start().
Parameters:
documentdocument which emitted this signal
oldRangerange that the text previously occupied
oldTextold text that has been replaced
newRangerange that the changed text now occupies
See also:
insertText(), insertLine(), removeText(), removeLine(), clear()
void KTextEditor::Document::textInserted ( KTextEditor::Document *  document,
const KTextEditor::Range &  range 
)
signal

The document emits this signal whenever text was inserted.

The insertion occurred at range.start(), and new text now occupies up to range.end().

Parameters:
documentdocument which emitted this signal
rangerange that the newly inserted text occupies
See also:
insertText(), insertLine()
virtual QStringList KTextEditor::Document::textLines ( const Range &  range,
bool  block = false 
) const
pure virtual

Get the document content within the given range.

Parameters:
rangethe range of text to retrieve
blockSet this to true to receive text in a visual block, rather than everything inside range.
Returns:
the requested text lines, or QStringList() for invalid ranges. no end of line termination is included.
See also:
setText()
void KTextEditor::Document::textRemoved ( KTextEditor::Document *  document,
const KTextEditor::Range &  range 
)
signal

The document emits this signal whenever range was removed, i.e.

text was removed.

Parameters:
documentdocument which emitted this signal
rangerange that the removed text previously occupied
See also:
removeText(), removeLine(), clear()
void KTextEditor::Document::textRemoved ( KTextEditor::Document *  document,
const KTextEditor::Range &  range,
const QString &  oldText 
)
signal

The document emits this signal whenever range was removed, i.e.

text was removed.

Parameters:
documentdocument which emitted this signal
rangerange that the removed text previously occupied
oldTextthe text that has been removed
See also:
removeText(), removeLine(), clear()
virtual int KTextEditor::Document::totalCharacters ( ) const
pure virtual

Get the count of characters in the document.

A TAB character counts as only one character.

Returns:
the number of characters in the document
See also:
lines()
void KTextEditor::Document::viewCreated ( KTextEditor::Document *  document,
KTextEditor::View *  view 
)
signal

This signal is emitted whenever the document creates a new view.

It should be called for every view to help applications / plugins to attach to the view.

Attention:
This signal should be emitted after the view constructor is completed, e.g. in the createView() method.
Parameters:
documentthe document for which a new view is created
viewthe new view
See also:
createView()
virtual const QList<View*>& KTextEditor::Document::views ( ) const
pure virtual

Returns the views pre-casted to KTextEditor::Views.


The documentation for this class was generated from the following files:
  • document.h
  • document.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sun Apr 28 2013 14:32:01 by doxygen 1.8.1.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.10.2 API Reference

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