KDEUI
KRichTextEdit Class Reference
#include <krichtextedit.h>

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
Do not call setAcceptRichText() or acceptRichText() yourself. Instead simply connect to the slots which insert the rich text, use switchToPlainText() or enableRichTextMode().
- Since:
- 4.1
Definition at line 61 of file krichtextedit.h.
Member Enumeration Documentation
enum KRichTextEdit::Mode |
Constructor & Destructor Documentation
Constructs a KRichTextEdit object.
Private class that helps to provide binary compatibility between releases.
- Parameters:
-
text The initial text of the text edit, which is interpreted as HTML. parent The parent widget
For internal use only.
Definition at line 111 of file krichtextedit.cpp.
KRichTextEdit::KRichTextEdit | ( | QWidget * | parent = 0 |
) | [explicit] |
Constructs a KRichTextEdit object.
- Parameters:
-
parent The parent widget
Definition at line 117 of file krichtextedit.cpp.
KRichTextEdit::~KRichTextEdit | ( | ) | [virtual] |
Member Function Documentation
void KRichTextEdit::alignCenter | ( | ) | [slot] |
Sets the alignment of the current block to Centered.
Definition at line 174 of file krichtextedit.cpp.
void KRichTextEdit::alignJustify | ( | ) | [slot] |
Sets the alignment of the current block to Justified.
Definition at line 188 of file krichtextedit.cpp.
void KRichTextEdit::alignLeft | ( | ) | [slot] |
Sets the alignment of the current block to Left Aligned.
Definition at line 167 of file krichtextedit.cpp.
void KRichTextEdit::alignRight | ( | ) | [slot] |
Sets the alignment of the current block to Right Aligned.
Definition at line 181 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 485 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 480 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 318 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 365 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 287 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 148 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 142 of file krichtextedit.cpp.
void KRichTextEdit::insertHorizontalRule | ( | ) | [slot] |
Inserts a horizontal rule below the current block.
Definition at line 153 of file krichtextedit.cpp.
void KRichTextEdit::keyPressEvent | ( | QKeyEvent * | event | ) | [protected, virtual] |
Reimplemented.
Catches key press events. Used to handle some key presses on lists.
Reimplemented from KTextEdit.
Definition at line 447 of file krichtextedit.cpp.
void KRichTextEdit::selectionFinished | ( | ) | [signal] |
Emitted whenever the user has finished making a selection.
(on mouse up)
void KRichTextEdit::selectLinkText | ( | ) | const |
Convenience function to select the link text using the active cursor.
- See also:
- selectLinkText
Definition at line 325 of file krichtextedit.cpp.
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:
-
cursor The cursor to use to select the text.
- See also:
- updateLink
Definition at line 332 of file krichtextedit.cpp.
void KRichTextEdit::setFont | ( | const QFont & | font | ) | [slot] |
Sets the current word or selection to the font font.
- Parameters:
-
font the font of the text will be set to this font
Definition at line 267 of file krichtextedit.cpp.
void KRichTextEdit::setFontFamily | ( | const QString & | fontFamily | ) | [slot] |
Sets the current word or selection to the font family fontFamily.
- Parameters:
-
fontFamily The text's font family will be changed to this one
Reimplemented from QTextEdit.
Definition at line 249 of file krichtextedit.cpp.
void KRichTextEdit::setFontSize | ( | int | size | ) | [slot] |
Sets the current word or selection to the font size size.
- Parameters:
-
size The text's font will get this size
Definition at line 258 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:
-
_styleIndex The list will get this style
Definition at line 135 of file krichtextedit.cpp.
void KRichTextEdit::setTextBackgroundColor | ( | const QColor & | color | ) | [slot] |
Sets the background color of the current word or selection to color.
- Parameters:
-
color The text will get this foreground color
Definition at line 240 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:
-
bold If true, the text will be set to bold
Definition at line 195 of file krichtextedit.cpp.
void KRichTextEdit::setTextForegroundColor | ( | const QColor & | color | ) | [slot] |
Sets the foreground color of the current word or selection to color.
- Parameters:
-
color The text will get this background color
Definition at line 231 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:
-
italic If true, the text will be set to italic
Definition at line 204 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:
-
text The text to insert
Definition at line 305 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:
-
strikeOut If true, the text will be struck out
Definition at line 222 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:
-
underline If true, the text will be underlined
Definition at line 213 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 276 of file krichtextedit.cpp.
KRichTextEdit::Mode KRichTextEdit::textMode | ( | ) | const |
void KRichTextEdit::textModeChanged | ( | KRichTextEdit::Mode | mode | ) | [signal] |
Emitted whenever the text mode is changed.
- Parameters:
-
mode The 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 297 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 490 of file krichtextedit.cpp.
Replaces the current selection with a hyperlink with the link URL linkUrl and the link text linkText.
- See also:
- selectLinkText
- Parameters:
-
linkUrl The link will get this URL as href (target) linkText The link will get this alternative text, which is the text displayed in the text edit.
Definition at line 370 of file krichtextedit.cpp.
The documentation for this class was generated from the following files: