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

KDEUI

Public Types | Public Slots | Signals | Public Member Functions | Protected Member Functions | List of all members
KRichTextEdit Class Reference

#include <krichtextedit.h>

Inheritance diagram for KRichTextEdit:
Inheritance graph
[legend]

Public Types

enum  Mode { Plain, Rich }
 

Public Slots

void alignCenter ()
 
void alignJustify ()
 
void alignLeft ()
 
void alignRight ()
 
void indentListLess ()
 
void indentListMore ()
 
void insertHorizontalRule ()
 
void insertPlainTextImplementation ()
 
void makeLeftToRight ()
 
void makeRightToLeft ()
 
void setFont (const QFont &font)
 
void setFontFamily (const QString &fontFamily)
 
void setFontSize (int size)
 
void setListStyle (int _styleIndex)
 
void setTextBackgroundColor (const QColor &color)
 
void setTextBold (bool bold)
 
void setTextForegroundColor (const QColor &color)
 
void setTextItalic (bool italic)
 
void setTextStrikeOut (bool strikeOut)
 
void setTextSubScript (bool subscript)
 
void setTextSuperScript (bool superscript)
 
void setTextUnderline (bool underline)
 
void switchToPlainText ()
 
QString toCleanHtml () const
 
- Public Slots inherited from KTextEdit
void checkSpelling ()
 
void mousePopupMenuImplementation (const QPoint &pos)
 
void replace ()
 
void setSpellCheckingLanguage (const QString &language)
 
void showSpellConfigDialog (const QString &configFileName, const QString &windowIcon=QString())
 

Signals

void selectionFinished ()
 
void textModeChanged (KRichTextEdit::Mode mode)
 
- Signals inherited from KTextEdit
void aboutToShowContextMenu (QMenu *menu)
 
void checkSpellingChanged (bool)
 
void languageChanged (const QString &language)
 
void spellCheckerAutoCorrect (const QString &currentWord, const QString &autoCorrectWord)
 
void spellCheckingCanceled ()
 
void spellCheckingFinished ()
 
void spellCheckStatus (const QString &)
 

Public Member Functions

 KRichTextEdit (const QString &text, QWidget *parent=0)
 
 KRichTextEdit (QWidget *parent=0)
 
virtual ~KRichTextEdit ()
 
bool canDedentList () const
 
bool canIndentList () const
 
QString currentLinkText () const
 
QString currentLinkUrl () const
 
void enableRichTextMode ()
 
void selectLinkText (QTextCursor *cursor) const
 
void selectLinkText () const
 
void setTextOrHtml (const QString &text)
 
Mode textMode () const
 
QString textOrHtml () const
 
void updateLink (const QString &linkUrl, const QString &linkText)
 
- Public Member Functions inherited from KTextEdit
 KTextEdit (const QString &text, QWidget *parent=0)
 
 KTextEdit (QWidget *parent=0)
 
 ~KTextEdit ()
 
bool checkSpellingEnabled () const
 
QString clickMessage () const
 
virtual void createHighlighter ()
 
void enableFindReplace (bool enabled)
 
void forceSpellChecking ()
 
Sonnet::Highlighter * highlighter () const
 
void highlightWord (int length, int pos)
 
QMenu * mousePopupMenu ()
 
void setCheckSpellingEnabled (bool check)
 
void setClickMessage (const QString &msg)
 
void setHighlighter (Sonnet::Highlighter *_highLighter)
 
virtual void setReadOnly (bool readOnly)
 
void setSpellCheckingConfigFileName (const QString &fileName)
 
void setSpellInterface (KTextEditSpellInterface *spellInterface)
 
void showAutoCorrectButton (bool show)
 
void showTabAction (bool show)
 
const QString & spellCheckingLanguage () const
 

Protected Member Functions

virtual void keyPressEvent (QKeyEvent *event)
 
- Protected Member Functions inherited from KTextEdit
bool checkSpellingEnabledInternal () const
 
virtual void contextMenuEvent (QContextMenuEvent *)
 
virtual void deleteWordBack ()
 
virtual void deleteWordForward ()
 
virtual bool event (QEvent *)
 
virtual void focusInEvent (QFocusEvent *)
 
virtual void focusOutEvent (QFocusEvent *)
 
virtual void paintEvent (QPaintEvent *)
 
void setCheckSpellingEnabledInternal (bool check)
 
virtual void wheelEvent (QWheelEvent *)
 

Additional Inherited Members

- Protected Slots inherited from KTextEdit
void slotDoFind ()
 
void slotDoReplace ()
 
void slotFind ()
 
void slotFindNext ()
 
void slotReplace ()
 
void slotReplaceNext ()
 
void slotSpeakText ()
 
- Properties inherited from KTextEdit
bool checkSpellingEnabled
 
QString clickMessage
 
QString spellCheckingLanguage
 

Detailed Description

The KRichTextEdit class provides a widget to edit and display rich text.

It offers several additional rich text editing functions to KTextEdit and makes them easier to access including:

  • Changing fonts, sizes.
  • Font formatting, such as bold, underline, italic, foreground and background color.
  • Paragraph alignment
  • Ability to edit and remove hyperlinks
  • Nested list handling
  • Simple actions to insert tables. TODO

The KRichTextEdit can be in two modes: Rich text mode and plain text mode. Calling functions which modify the format/style of the text will automatically enable the rich text mode. Rich text mode is sometimes also referred to as HTML mode.

Do not call setAcceptRichText() or acceptRichText() yourself. Instead simply connect to the slots which insert the rich text, use switchToPlainText() or enableRichTextMode().

krichtextedit.png
KDE Rich Text Edit Widget
Since
4.1

Definition at line 65 of file krichtextedit.h.

Member Enumeration Documentation

enum KRichTextEdit::Mode

The mode the edit widget is in.

Enumerator
Plain 

Plain text mode.

Rich 

Rich text mode.

Definition at line 74 of file krichtextedit.h.

Constructor & Destructor Documentation

KRichTextEdit::KRichTextEdit ( const QString &  text,
QWidget *  parent = 0 
)
explicit

Constructs a KRichTextEdit object.

Private class that helps to provide binary compatibility between releases.

Parameters
textThe initial text of the text edit, which is interpreted as HTML.
parentThe parent widget

Definition at line 118 of file krichtextedit.cpp.

KRichTextEdit::KRichTextEdit ( QWidget *  parent = 0)
explicit

Constructs a KRichTextEdit object.

Parameters
parentThe parent widget

Definition at line 124 of file krichtextedit.cpp.

KRichTextEdit::~KRichTextEdit ( )
virtual

Destructor.

Definition at line 130 of file krichtextedit.cpp.

Member Function Documentation

void KRichTextEdit::alignCenter ( )
slot

Sets the alignment of the current block to Centered.

Definition at line 182 of file krichtextedit.cpp.

void KRichTextEdit::alignJustify ( )
slot

Sets the alignment of the current block to Justified.

Definition at line 196 of file krichtextedit.cpp.

void KRichTextEdit::alignLeft ( )
slot

Sets the alignment of the current block to Left Aligned.

Definition at line 175 of file krichtextedit.cpp.

void KRichTextEdit::alignRight ( )
slot

Sets the alignment of the current block to Right Aligned.

Definition at line 189 of file krichtextedit.cpp.

bool KRichTextEdit::canDedentList ( ) const

Returns true if the list item at the current position can be dedented.

See also
canIndentList

Definition at line 523 of file krichtextedit.cpp.

bool KRichTextEdit::canIndentList ( ) const

Returns true if the list item at the current position can be indented.

See also
canDedentList

Definition at line 518 of file krichtextedit.cpp.

QString KRichTextEdit::currentLinkText ( ) const

Returns the text of the link at the current position or an empty string if the cursor is not on a link.

See also
currentLinkUrl
Returns
The link text

Definition at line 371 of file krichtextedit.cpp.

QString KRichTextEdit::currentLinkUrl ( ) const

Returns the URL target (href) of the link at the current position or an empty string if the cursor is not on a link.

See also
currentLinkText
Returns
The link target URL

Definition at line 418 of file krichtextedit.cpp.

void KRichTextEdit::enableRichTextMode ( )

This enables rich text mode.

Nothing is done except changing the internal mode and allowing rich text pastes.

Definition at line 340 of file krichtextedit.cpp.

void KRichTextEdit::indentListLess ( )
slot

Decreases the nesting level of the current block or selected blocks.

See also
canDedentList

Definition at line 156 of file krichtextedit.cpp.

void KRichTextEdit::indentListMore ( )
slot

Increases the nesting level of the current block or selected blocks.

See also
canIndentList

Definition at line 150 of file krichtextedit.cpp.

void KRichTextEdit::insertHorizontalRule ( )
slot

Inserts a horizontal rule below the current block.

Definition at line 161 of file krichtextedit.cpp.

void KRichTextEdit::insertPlainTextImplementation ( )
slot
Since
4.10 Because of binary compatibility constraints, insertPlainText is not virtual. Therefore it must dynamically detect and call this slot.

Definition at line 317 of file krichtextedit.cpp.

void KRichTextEdit::keyPressEvent ( QKeyEvent *  event)
protectedvirtual

Reimplemented.

Catches key press events. Used to handle some key presses on lists.

Reimplemented from KTextEdit.

Definition at line 485 of file krichtextedit.cpp.

void KRichTextEdit::makeLeftToRight ( )
slot

Sets the direction of the current block to Left-To-Right.

Since
4.6

Definition at line 214 of file krichtextedit.cpp.

void KRichTextEdit::makeRightToLeft ( )
slot

Sets the direction of the current block to Right-To-Left.

Since
4.6

Definition at line 203 of file krichtextedit.cpp.

void KRichTextEdit::selectionFinished ( )
signal

Emitted whenever the user has finished making a selection.

(on mouse up)

void KRichTextEdit::selectLinkText ( QTextCursor *  cursor) const

If the cursor is on a link, sets the cursor to a selection of the text of the link.

If the cursor is not on a link, selects the current word or existing selection.

Parameters
cursorThe cursor to use to select the text.
See also
updateLink

Definition at line 385 of file krichtextedit.cpp.

void KRichTextEdit::selectLinkText ( ) const

Convenience function to select the link text using the active cursor.

See also
selectLinkText

Definition at line 378 of file krichtextedit.cpp.

void KRichTextEdit::setFont ( const QFont &  font)
slot

Sets the current word or selection to the font font.

Parameters
fontthe font of the text will be set to this font

Definition at line 297 of file krichtextedit.cpp.

void KRichTextEdit::setFontFamily ( const QString &  fontFamily)
slot

Sets the current word or selection to the font family fontFamily.

Parameters
fontFamilyThe text's font family will be changed to this one

Definition at line 279 of file krichtextedit.cpp.

void KRichTextEdit::setFontSize ( int  size)
slot

Sets the current word or selection to the font size size.

Parameters
sizeThe text's font will get this size

Definition at line 288 of file krichtextedit.cpp.

void KRichTextEdit::setListStyle ( int  _styleIndex)
slot

Sets the list style of the current list, or creates a new list using the current block.

The _styleindex corresponds to the QTextListFormat::Style

Parameters
_styleIndexThe list will get this style

Definition at line 143 of file krichtextedit.cpp.

void KRichTextEdit::setTextBackgroundColor ( const QColor &  color)
slot

Sets the background color of the current word or selection to color.

Parameters
colorThe text will get this foreground color

Definition at line 270 of file krichtextedit.cpp.

void KRichTextEdit::setTextBold ( bool  bold)
slot

Toggles the bold formatting of the current word or selection at the current cursor position.

Parameters
boldIf true, the text will be set to bold

Definition at line 225 of file krichtextedit.cpp.

void KRichTextEdit::setTextForegroundColor ( const QColor &  color)
slot

Sets the foreground color of the current word or selection to color.

Parameters
colorThe text will get this background color

Definition at line 261 of file krichtextedit.cpp.

void KRichTextEdit::setTextItalic ( bool  italic)
slot

Toggles the italic formatting of the current word or selection at the current cursor position.

Parameters
italicIf true, the text will be set to italic

Definition at line 234 of file krichtextedit.cpp.

void KRichTextEdit::setTextOrHtml ( const QString &  text)

Replaces all the content of the text edit with the given string.

If the string is in rich text format, the text is inserted as rich text, otherwise it is inserted as plain text.

Parameters
textThe text to insert

Definition at line 358 of file krichtextedit.cpp.

void KRichTextEdit::setTextStrikeOut ( bool  strikeOut)
slot

Toggles the strikeout formatting of the current word or selection at the current cursor position.

Parameters
strikeOutIf true, the text will be struck out

Definition at line 252 of file krichtextedit.cpp.

void KRichTextEdit::setTextSubScript ( bool  subscript)
slot

Toggles the subscript formatting of the current word or selection at the current cursor position.

Parameters
subscriptIf true, the text will be set to subscript

Definition at line 331 of file krichtextedit.cpp.

void KRichTextEdit::setTextSuperScript ( bool  superscript)
slot

Toggles the superscript formatting of the current word or selection at the current cursor position.

Parameters
superscriptIf true, the text will be set to superscript

Definition at line 322 of file krichtextedit.cpp.

void KRichTextEdit::setTextUnderline ( bool  underline)
slot

Toggles the underline formatting of the current word or selection at the current cursor position.

Parameters
underlineIf true, the text will be underlined

Definition at line 243 of file krichtextedit.cpp.

void KRichTextEdit::switchToPlainText ( )
slot

This will switch the editor to plain text mode.

All rich text formatting will be destroyed.

Definition at line 306 of file krichtextedit.cpp.

KRichTextEdit::Mode KRichTextEdit::textMode ( ) const
Returns
The current text mode

Definition at line 345 of file krichtextedit.cpp.

void KRichTextEdit::textModeChanged ( KRichTextEdit::Mode  mode)
signal

Emitted whenever the text mode is changed.

Parameters
modeThe new text mode
QString KRichTextEdit::textOrHtml ( ) const
Returns
The plain text string if in plain text mode or the HTML code if in rich text mode. The text is not word-wrapped.

Definition at line 350 of file krichtextedit.cpp.

QString KRichTextEdit::toCleanHtml ( ) const
slot

This will clean some of the bad html produced by the underlying QTextEdit It walks over all lines and cleans up a bit.

Should be improved to produce our own Html.

Definition at line 528 of file krichtextedit.cpp.

void KRichTextEdit::updateLink ( const QString &  linkUrl,
const QString &  linkText 
)

Replaces the current selection with a hyperlink with the link URL linkUrl and the link text linkText.

See also
selectLinkText
currentLinkUrl
currentLinkText
Parameters
linkUrlThe link will get this URL as href (target)
linkTextThe link will get this alternative text, which is the text displayed in the text edit.

Definition at line 423 of file krichtextedit.cpp.


The documentation for this class was generated from the following files:
  • krichtextedit.h
  • krichtextedit.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:49:18 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

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

kdelibs API Reference

Skip menu "kdelibs 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
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

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