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

KPIMTextedit Library

  • sources
  • kde-4.14
  • kdepimlibs
  • kpimtextedit
textedit.h
1 /*
2  Copyright (c) 2009 Thomas McGuire <mcguire@kde.org>
3 
4  Based on KMail and libkdepim code by:
5  Copyright 2007 - 2010 Laurent Montel <montel@kde.org>
6 
7  This library is free software; you can redistribute it and/or modify it
8  under the terms of the GNU Library General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version.
11 
12  This library is distributed in the hope that it will be useful, but WITHOUT
13  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
15  License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to the
19  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20  02110-1301, USA.
21 */
22 #ifndef KPIMTEXTEDIT_TEXTEDIT_H
23 #define KPIMTEXTEDIT_TEXTEDIT_H
24 
25 #include "kpimtextedit_export.h"
26 
27 #include <kpimidentities/signature.h> // TODO KF5: remove this
28 
29 #include <KDE/KRichTextWidget>
30 #include <KActionCollection>
31 
32 #include <QtCore/QSharedPointer>
33 
34 #include <memory>
35 // TODO KF5: remove this
36 #define FIX_KMAIL_INSERT_IMAGE 1
37 
38 class KUrl;
39 class QFileInfo;
40 
41 namespace KPIMTextEdit {
42 
43 class TextEditPrivate;
44 class EMailQuoteHighlighter;
45 
50 struct EmbeddedImage
51 {
52  QByteArray image;
53  QString contentID;
54  QString imageName;
55 };
56 
63 struct ImageWithName
64 {
65  QImage image;
66  QString name;
67 };
68 
69 typedef QSharedPointer<ImageWithName> ImageWithNamePtr;
70 typedef QList< ImageWithNamePtr > ImageWithNameList;
71 typedef QList< QSharedPointer<EmbeddedImage> > ImageList;
72 
84 class KPIMTEXTEDIT_EXPORT TextEdit : public KRichTextWidget,
85  // TODO: KDE5: get rid of the spell interface
86  protected KTextEditSpellInterface
87 {
88  Q_OBJECT
89 
90  public:
91 
97  explicit TextEdit( const QString &text, QWidget *parent = 0 );
98 
103  explicit TextEdit( QWidget *parent = 0 );
104 
113  explicit TextEdit( QWidget *parent, const QString &configFile );
114 
123  void enableImageActions();
130  void enableEmoticonActions();
131 
132  void enableInsertHtmlActions();
133 
134  void enableInsertTableActions();
138  ~TextEdit();
139 
150  virtual void createActions( KActionCollection *actionCollection );
151 
158  void addImage( const KUrl &url );
159 
170  void addImage( const KUrl &url, int width, int height );
171 
185  void loadImage( const QImage &image, const QString &matchName, const QString &resourceName );
186 
191  void deleteCurrentLine();
192 
200  ImageList embeddedImages() const;
201 
208  ImageWithNameList imagesWithName() const;
209 
214  QString toWrappedPlainText() const;
215 
219  QString toWrappedPlainText( QTextDocument *document ) const;
220 
224  //TODO 5.0 merge it
225  QString toCleanPlainText( const QString &plainText ) const;
226 
231  QString toCleanPlainText() const;
232 
244  virtual void setHighlighterColors( EMailQuoteHighlighter *highlighter );
245 
249  bool isLineQuoted( const QString &line ) const;
250 
261  virtual int quoteLength( const QString &line ) const;
262 
267  virtual const QString defaultQuoteSign() const;
268 
286  static QByteArray imageNamesToContentIds( const QByteArray &htmlBody,
287  const ImageList &imageList );
288 
297  bool isFormattingUsed() const;
298 
303  QString configFile() const;
304 
308  bool isEnableImageActions() const;
309 
313  bool isEnableEmoticonActions() const;
314 
320  void insertImage( const QImage &image, const QFileInfo &info );
321 
325  bool isEnableInsertHtmlActions() const;
326 
330  bool isEnableInsertTableActions() const;
331 
332  protected:
333 
337  virtual bool canInsertFromMimeData( const QMimeData *source ) const;
338 
342  virtual void insertFromMimeData( const QMimeData *source );
343 
348  virtual bool eventFilter( QObject *o, QEvent *e );
349 
354  virtual void keyPressEvent ( QKeyEvent *e );
355 
356  // For the explaination for these four methods, see the comment at the
357  // spellCheckingEnabled variable of the private class.
358 
362  virtual bool isSpellCheckingEnabled() const;
363 
367  virtual void setSpellCheckingEnabled( bool enable );
368 
373  virtual bool shouldBlockBeSpellChecked( const QString &block ) const;
374 
379  virtual void createHighlighter();
380 
381  private:
382  void addImageHelper( const KUrl &url, int width = -1, int height = -1 );
383  std::auto_ptr<TextEditPrivate> const d;
384  friend class TextEditPrivate;
385  Q_PRIVATE_SLOT( d, void _k_slotAddImage() )
386  Q_PRIVATE_SLOT( d, void _k_slotDeleteLine() )
387  Q_PRIVATE_SLOT( d, void _k_slotAddEmoticon( const QString & ) )
388  Q_PRIVATE_SLOT( d, void _k_slotInsertHtml() )
389  Q_PRIVATE_SLOT( d, void _k_slotFormatReset() )
390  Q_PRIVATE_SLOT( d, void _k_slotTextModeChanged( KRichTextEdit::Mode ) )
391 };
392 
393 } // namespace
394 
395 #endif
QEvent
QWidget
KPIMTextEdit::EmbeddedImage
Holds information about an embedded HTML image that will be useful for mail clients.
Definition: textedit.h:50
QByteArray
KPIMTextEdit::ImageWithName::name
QString name
The name of the image as it is available as a resource in the editor.
Definition: textedit.h:66
QMimeData
QSharedPointer
QObject
QString
QList
KPIMTextEdit::EMailQuoteHighlighter
This highlighter highlights spelling mistakes and also highlightes quotes.
Definition: emailquotehighlighter.h:44
QFileInfo
KPIMTextEdit::EmbeddedImage::contentID
QString contentID
The content id of the embedded image.
Definition: textedit.h:53
KPIMTextEdit::ImageWithName::image
QImage image
The image.
Definition: textedit.h:65
QImage
QKeyEvent
KPIMTextEdit::TextEdit
Special textedit that provides additional features which are useful for PIM applications like mail cl...
Definition: textedit.h:84
KPIMTextEdit::ImageWithName
Holds information about an embedded HTML image that will be generally useful.
Definition: textedit.h:63
QTextDocument
KPIMTextEdit::EmbeddedImage::imageName
QString imageName
Name of the image as it is available as a resource in the editor.
Definition: textedit.h:54
KPIMTextEdit::EmbeddedImage::image
QByteArray image
The image, encoded as PNG with base64 encoding.
Definition: textedit.h:52
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