KPIMTextedit Library
#include <textedit.h>
Inherits KRichTextWidget, and KTextEditSpellInterface.
Public Member Functions | |
TextEdit (const QString &text, QWidget *parent=0) | |
TextEdit (QWidget *parent=0) | |
TextEdit (QWidget *parent, const QString &configFile) | |
~TextEdit () | |
void | addImage (const KUrl &url) |
QString | configFile () const |
virtual void | createActions (KActionCollection *actionCollection) |
virtual const QString | defaultQuoteSign () const |
void | deleteCurrentLine () |
ImageList | embeddedImages () const |
void | enableImageActions () |
ImageWithNameList | imagesWithName () const |
void | insertImage (const QImage &image, const QFileInfo &info) |
bool | isEnableImageActions () const |
bool | isFormattingUsed () const |
bool | isLineQuoted (const QString &line) const |
void | loadImage (const QImage &image, const QString &matchName, const QString &resourceName) |
virtual int | quoteLength (const QString &line) const |
virtual void | setHighlighterColors (EMailQuoteHighlighter *highlighter) |
QString | toCleanPlainText () const |
QString | toWrappedPlainText () const |
Static Public Member Functions | |
static QByteArray | imageNamesToContentIds (const QByteArray &htmlBody, const ImageList &imageList) |
Protected Member Functions | |
virtual bool | canInsertFromMimeData (const QMimeData *source) const |
virtual void | createHighlighter () |
virtual bool | eventFilter (QObject *o, QEvent *e) |
virtual void | insertFromMimeData (const QMimeData *source) |
virtual bool | isSpellCheckingEnabled () const |
virtual void | keyPressEvent (QKeyEvent *e) |
virtual void | setSpellCheckingEnabled (bool enable) |
virtual bool | shouldBlockBeSpellChecked (const QString &block) const |
Detailed Description
Special textedit that provides additional features which are useful for PIM applications like mail clients.
Additional features this class provides:
- Highlighting quoted text
- Handling of inline images
- Auto-Hiding the cursor
- Handling of pastes and drops of images
- Since:
- 4.3
Constructor & Destructor Documentation
TextEdit::TextEdit | ( | const QString & | text, |
QWidget * | parent = 0 |
||
) | [explicit] |
Constructs a TextEdit object.
- Parameters:
-
text the initial plain text of the text edit, interpreted as HTML parent the parent widget
Definition at line 148 of file textedit.cpp.
TextEdit::TextEdit | ( | QWidget * | parent = 0 | ) | [explicit] |
Constructs a TextEdit object.
- Parameters:
-
parent the parent widget
Definition at line 155 of file textedit.cpp.
TextEdit::TextEdit | ( | QWidget * | parent, |
const QString & | configFile | ||
) | [explicit] |
Constructs a TextEdit object.
- Parameters:
-
parent the parent widget configFile the config file
- Since:
- 4.6
TODO KDE-5 merge with other constructor
Definition at line 162 of file textedit.cpp.
TextEdit::~TextEdit | ( | ) |
Destructor.
Definition at line 170 of file textedit.cpp.
Member Function Documentation
void TextEdit::addImage | ( | const KUrl & | url | ) |
Adds an image.
The image is loaded from file and then pasted to the current cursor position.
- Parameters:
-
url The URL of the file which contains the image
Definition at line 389 of file textedit.cpp.
bool KPIMTextEdit::TextEdit::canInsertFromMimeData | ( | const QMimeData * | source | ) | const [protected, virtual] |
Reimplemented for inline image support.
Definition at line 610 of file textedit.cpp.
QString TextEdit::configFile | ( | ) | const |
void TextEdit::createActions | ( | KActionCollection * | actionCollection | ) | [virtual] |
Reimplemented from KMEditor, to support more actions.
The additional action XML names are:
- add_image
- delete_line
The add_image actions is only added if enableImageActions() is called before.
Definition at line 372 of file textedit.cpp.
void TextEdit::createHighlighter | ( | ) | [protected, virtual] |
Reimplemented to create our own highlighter which does quote and spellcheck highlighting.
Definition at line 321 of file textedit.cpp.
const QString KPIMTextEdit::TextEdit::defaultQuoteSign | ( | ) | const [virtual] |
Returns the prefix that is added to a line that is quoted.
By default, this is "> ".
Definition at line 316 of file textedit.cpp.
void TextEdit::deleteCurrentLine | ( | ) |
Deletes the line at the current cursor position.
- Since:
- 4.4
Definition at line 643 of file textedit.cpp.
QList< QSharedPointer< EmbeddedImage > > TextEdit::embeddedImages | ( | ) | const |
Get a list with all embedded HTML images.
If the same image is contained twice or more in the editor, it will have only one entry in this list.
- Returns:
- a list of embedded HTML images of the editor.
Definition at line 491 of file textedit.cpp.
void KPIMTextEdit::TextEdit::enableImageActions | ( | ) |
Calling this allows createActions() to create the add image actions.
Call this method before calling createActions(), otherwise the action will not be added. Also, if image actions is enabled, the user can paste PNG images.
Don't call this if you don't want to support adding images.
Definition at line 555 of file textedit.cpp.
bool TextEdit::eventFilter | ( | QObject * | o, |
QEvent * | e | ||
) | [protected, virtual] |
Reimplemented from KRichTextWidget to hide the mouse cursor when there was no mouse movement for some time, using KCursor.
Definition at line 174 of file textedit.cpp.
QByteArray KPIMTextEdit::TextEdit::imageNamesToContentIds | ( | const QByteArray & | htmlBody, |
const ImageList & | imageList | ||
) | [static] |
For all given embedded images, this function replace the image name in the.
tag of the HTML body with cid:content-id, so that the HTML references the image body parts, see RFC 2557.
This is useful when building a MIME message with inline images.
Note that this function works on encoded content already.
- Parameters:
-
htmlBody the HTML code in which the tag will be modified. The HTML code here could come from toHtml(), for example. imageList the list of images of which the tag will be modified. You can get such a list from the embeddedImages() function.
- Returns:
- a modified HTML code, where the tags got replaced
Definition at line 565 of file textedit.cpp.
ImageWithNameList TextEdit::imagesWithName | ( | ) | const |
Same as embeddedImages(), only that this returns a list of general purpose information, whereas the embeddedImages() function returns a list with mail-specific information.
- Since:
- 4.4
Definition at line 470 of file textedit.cpp.
void TextEdit::insertFromMimeData | ( | const QMimeData * | source | ) | [protected, virtual] |
Reimplemented for inline image support.
Definition at line 588 of file textedit.cpp.
void TextEdit::insertImage | ( | const QImage & | image, |
const QFileInfo & | info | ||
) |
- Since:
- 4.6
Definition at line 580 of file textedit.cpp.
bool KPIMTextEdit::TextEdit::isEnableImageActions | ( | ) | const |
bool TextEdit::isFormattingUsed | ( | ) | const |
Checks if rich text formatting is used anywhere.
This is not the same as checking whether textMode() returns "Rich", since that only tells that rich text mode is enabled, but not if any special formatting is actually used.
- Returns:
- true if formatting is used anywhere
Definition at line 627 of file textedit.cpp.
bool KPIMTextEdit::TextEdit::isLineQuoted | ( | const QString & | line | ) | const |
Convenience method for qouteLength( line ) > 0.
Definition at line 289 of file textedit.cpp.
bool TextEdit::isSpellCheckingEnabled | ( | ) | const [protected, virtual] |
Reimplemented from KTextEditSpellInterface.
Definition at line 268 of file textedit.cpp.
void TextEdit::keyPressEvent | ( | QKeyEvent * | e | ) | [protected, virtual] |
Reimplemented to add qoute signs when the user presses enter on a quoted line.
Definition at line 208 of file textedit.cpp.
void TextEdit::loadImage | ( | const QImage & | image, |
const QString & | matchName, | ||
const QString & | resourceName | ||
) |
Loads an image into the textedit.
The difference to addImage() is that this function expects that the image tag is already present in the HTML source.
So what this message does is that it scans the HTML source for the image tag that matches the matchName
, and then inserts the image
as a resource, giving that resource the name resourceName
.
- Since:
- 4.4
Definition at line 405 of file textedit.cpp.
int KPIMTextEdit::TextEdit::quoteLength | ( | const QString & | line | ) | const [virtual] |
This is called whenever the editor needs to find out the length of the quote, i.e.
the length of the quote prefix before the real text starts. The default implementation counts the number of spaces, '>' and '|' chars in front of the line.
- Parameters:
-
line the line of which the length of the quote prefix should be returned
- Returns:
- 0 if the line is not quoted, the length of the quote prefix otherwise FIXME: Not yet used in all places, e.g. keypressEvent() or the quote highlighter
Definition at line 294 of file textedit.cpp.
void TextEdit::setHighlighterColors | ( | EMailQuoteHighlighter * | highlighter | ) | [virtual] |
This method is called after the highlighter is created.
If you use custom colors for highlighting, override this method and set the colors to the highlighter in it.
The default implementation does nothing, therefore the default colors of the EMailQuoteHighlighter class will be used.
- Parameters:
-
highlighter the highlighter that was just created. You need to set the colors of this highlighter.
Definition at line 336 of file textedit.cpp.
void TextEdit::setSpellCheckingEnabled | ( | bool | enable | ) | [protected, virtual] |
Reimplemented from KTextEditSpellInterface.
Definition at line 273 of file textedit.cpp.
bool TextEdit::shouldBlockBeSpellChecked | ( | const QString & | block | ) | const [protected, virtual] |
Reimplemented from KTextEditSpellInterface, to avoid spellchecking quoted text.
Definition at line 284 of file textedit.cpp.
QString TextEdit::toCleanPlainText | ( | ) | const |
Same as toPlainText() from QTextEdit, only that it removes embedded images and converts non-breaking space characters to normal spaces.
Definition at line 365 of file textedit.cpp.
QString TextEdit::toWrappedPlainText | ( | ) | const |
Returns the text of the editor as plain text, with linebreaks inserted where word-wrapping occurred.
Definition at line 341 of file textedit.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2012 The KDE developers.
Generated on Thu Aug 2 2012 15:24:41 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.