• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • Contact Us
 

KPIMTextedit Library

KPIMTextEdit::TextEdit

KPIMTextEdit::TextEdit Class Reference

Special textedit that provides additional features which are useful for PIM applications like mail clients. More...

#include <textedit.h>

Inherits KRichTextWidget, and KTextEditSpellInterface.

List of all members.

Public Member Functions

void addImage (const KUrl &url)
virtual void createActions (KActionCollection *actionCollection)
virtual const QString defaultQuoteSign () const
ImageList embeddedImages () const
void enableImageActions ()
bool isFormattingUsed () const
bool isLineQuoted (const QString &line) const
virtual int quoteLength (const QString &line) const
virtual void setHighlighterColors (EMailQuoteHighlighter *highlighter)
 TextEdit (QWidget *parent=0)
 TextEdit (const QString &text, QWidget *parent=0)
QString toCleanPlainText () const
QString toWrappedPlainText () const
 ~TextEdit ()

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

Definition at line 66 of file textedit.h.


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 136 of file textedit.cpp.

TextEdit::TextEdit ( QWidget *  parent = 0  )  [explicit]

Constructs a TextEdit object.

Parameters:
parent the parent widget

Definition at line 143 of file textedit.cpp.

TextEdit::~TextEdit (  ) 

Destructor.

Definition at line 150 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 357 of file textedit.cpp.

bool KPIMTextEdit::TextEdit::canInsertFromMimeData ( const QMimeData *  source  )  const [protected, virtual]

Reimplemented for inline image support.

Definition at line 508 of file textedit.cpp.

void TextEdit::createActions ( KActionCollection *  actionCollection  )  [virtual]

Reimplemented from KMEditor, to support more actions.

The additional action XML names are:

  • add_image

The add_image actions is only added if enableImageActions() is called before.

Definition at line 345 of file textedit.cpp.

void TextEdit::createHighlighter (  )  [protected, virtual]

Reimplemented to create our own highlighter which does quote and spellcheck highlighting.

Definition at line 296 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 291 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 400 of file textedit.cpp.

void KPIMTextEdit::TextEdit::enableImageActions (  ) 

Calling this allows createActions() to create the add image actions.

Call this method before callilng 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 466 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 154 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 471 of file textedit.cpp.

void TextEdit::insertFromMimeData ( const QMimeData *  source  )  [protected, virtual]

Reimplemented for inline image support.

Definition at line 485 of file textedit.cpp.

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 553 of file textedit.cpp.

bool KPIMTextEdit::TextEdit::isLineQuoted ( const QString &  line  )  const

Convenience method for qouteLength( line ) > 0.

Definition at line 265 of file textedit.cpp.

bool TextEdit::isSpellCheckingEnabled (  )  const [protected, virtual]

Reimplemented from KTextEditSpellInterface.

Definition at line 244 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 178 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 270 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 311 of file textedit.cpp.

void TextEdit::setSpellCheckingEnabled ( bool  enable  )  [protected, virtual]

Reimplemented from KTextEditSpellInterface.

Definition at line 249 of file textedit.cpp.

bool TextEdit::shouldBlockBeSpellChecked ( const QString &  block  )  const [protected, virtual]

Reimplemented from KTextEditSpellInterface, to avoid spellchecking quoted text.

Definition at line 260 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 338 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 316 of file textedit.cpp.


The documentation for this class was generated from the following files:
  • textedit.h
  • textedit.cpp

KPIMTextedit Library

Skip menu "KPIMTextedit Library"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  • kabc
  • kblog
  • kcal
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  • kldap
  • kmime
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal