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

KPIMTextedit Library

  • KPIMTextEdit
  • TextEdit
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
KPIMTextEdit::TextEdit Class Reference

#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)
 
void addImage (const KUrl &url, int width, int height)
 
QString configFile () const
 
virtual void createActions (KActionCollection *actionCollection)
 
virtual const QString defaultQuoteSign () const
 
void deleteCurrentLine ()
 
ImageList embeddedImages () const
 
void enableEmoticonActions ()
 
void enableImageActions ()
 
void enableInsertHtmlActions ()
 
void enableInsertTableActions ()
 
ImageWithNameList imagesWithName () const
 
void insertImage (const QImage &image, const QFileInfo &info)
 
bool isEnableEmoticonActions () const
 
bool isEnableImageActions () const
 
bool isEnableInsertHtmlActions () const
 
bool isEnableInsertTableActions () 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 &plainText) const
 
QString toCleanPlainText () const
 
QString toWrappedPlainText () const
 
QString toWrappedPlainText (QTextDocument *document) 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

Definition at line 84 of file textedit.h.

Constructor & Destructor Documentation

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

Constructs a TextEdit object.

Parameters
textthe initial plain text of the text edit, interpreted as HTML
parentthe parent widget

Definition at line 184 of file textedit.cpp.

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

Constructs a TextEdit object.

Parameters
parentthe parent widget

Definition at line 191 of file textedit.cpp.

TextEdit::TextEdit ( QWidget *  parent,
const QString &  configFile 
)
explicit

Constructs a TextEdit object.

Parameters
parentthe parent widget
configFilethe config file
Since
4.6

TODO KDE-5 merge with other constructor

Definition at line 198 of file textedit.cpp.

TextEdit::~TextEdit ( )

Destructor.

Definition at line 206 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
urlThe URL of the file which contains the image

Definition at line 481 of file textedit.cpp.

void TextEdit::addImage ( const KUrl &  url,
int  width,
int  height 
)

Adds an image.

The image is loaded from file and then pasted to the current cursor position with the given width and height.

Parameters
urlThe URL of the file which contains the image
widthThe width the inserted image will have.
heightThe height the inserted image will have.
Since
4.10

Definition at line 476 of file textedit.cpp.

bool KPIMTextEdit::TextEdit::canInsertFromMimeData ( const QMimeData *  source) const
protectedvirtual

Reimplemented for inline image support.

Definition at line 788 of file textedit.cpp.

QString TextEdit::configFile ( ) const

Return config file.

Since
4.5

Definition at line 241 of file textedit.cpp.

void TextEdit::createActions ( KActionCollection *  actionCollection)
virtual

Reimplemented from KMEditor, to support more actions.

Parameters
actionCollectionthe collection to put the new actions into 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 433 of file textedit.cpp.

void TextEdit::createHighlighter ( )
protectedvirtual

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

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

void TextEdit::deleteCurrentLine ( )

Deletes the line at the current cursor position.

Since
4.4

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

void KPIMTextEdit::TextEdit::enableEmoticonActions ( )

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

Call this method before calling createActions(), otherwise the action will not be added. Don't call this if you don't want to support emoticons actions.

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

bool TextEdit::eventFilter ( QObject *  o,
QEvent *  e 
)
protectedvirtual

Reimplemented from KRichTextWidget to hide the mouse cursor when there was no mouse movement for some time, using KCursor.

Definition at line 210 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
htmlBodythe HTML code in which the tag will be modified. The HTML code here could come from toHtml(), for example.
imageListthe 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 743 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 585 of file textedit.cpp.

void TextEdit::insertFromMimeData ( const QMimeData *  source)
protectedvirtual

Reimplemented for inline image support.

Definition at line 766 of file textedit.cpp.

void TextEdit::insertImage ( const QImage &  image,
const QFileInfo &  info 
)
Parameters
imagethe image to insert
infothe info to supply with image
Since
4.6

Definition at line 758 of file textedit.cpp.

bool KPIMTextEdit::TextEdit::isEnableEmoticonActions ( ) const

Return true if emoticons actions supported.

Since
4.9

Definition at line 718 of file textedit.cpp.

bool KPIMTextEdit::TextEdit::isEnableImageActions ( ) const

Return true if richtext mode support image.

Since
4.6

Definition at line 708 of file textedit.cpp.

bool KPIMTextEdit::TextEdit::isEnableInsertHtmlActions ( ) const
Since
4.10

Definition at line 728 of file textedit.cpp.

bool KPIMTextEdit::TextEdit::isEnableInsertTableActions ( ) const
Since
4.10

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

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

Convenience method for qouteLength( line ) > 0.

Definition at line 327 of file textedit.cpp.

bool TextEdit::isSpellCheckingEnabled ( ) const
protectedvirtual

Reimplemented from KTextEditSpellInterface.

Definition at line 306 of file textedit.cpp.

void TextEdit::keyPressEvent ( QKeyEvent *  e)
protectedvirtual

Reimplemented to add qoute signs when the user presses enter on a quoted line.

Definition at line 246 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.

Parameters
imagethe image to load
matchNamethe name of tags to match image
resourceNamethe resource name of image 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 505 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
linethe 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 332 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
highlighterthe highlighter that was just created. You need to set the colors of this highlighter.

Definition at line 375 of file textedit.cpp.

void TextEdit::setSpellCheckingEnabled ( bool  enable)
protectedvirtual

Reimplemented from KTextEditSpellInterface.

Definition at line 311 of file textedit.cpp.

bool TextEdit::shouldBlockBeSpellChecked ( const QString &  block) const
protectedvirtual

Reimplemented from KTextEditSpellInterface, to avoid spellchecking quoted text.

Definition at line 322 of file textedit.cpp.

QString TextEdit::toCleanPlainText ( const QString &  plainText) const
Since
4.10

Definition at line 421 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 428 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 380 of file textedit.cpp.

QString TextEdit::toWrappedPlainText ( QTextDocument *  document) const
Since
5.0

Definition at line 386 of file textedit.cpp.


The documentation for this class was generated from the following files:
  • textedit.h
  • textedit.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:37:23 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KPIMTextedit Library

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

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2

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