• 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.12
  • 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>
28 
29 #include <KDE/KRichTextWidget>
30 
31 #include <QtCore/QSharedPointer>
32 
33 #include <memory>
34 #define FIX_KMAIL_INSERT_IMAGE 1
35 
36 class KUrl;
37 class QFileInfo;
38 
39 namespace KPIMTextEdit {
40 
41 class TextEditPrivate;
42 class EMailQuoteHighlighter;
43 
48 struct EmbeddedImage
49 {
50  QByteArray image;
51  QString contentID;
52  QString imageName;
53 };
54 
61 struct ImageWithName
62 {
63  QImage image;
64  QString name;
65 };
66 
67 typedef QSharedPointer<ImageWithName> ImageWithNamePtr;
68 typedef QList< ImageWithNamePtr > ImageWithNameList;
69 typedef QList< QSharedPointer<EmbeddedImage> > ImageList;
70 
82 class KPIMTEXTEDIT_EXPORT TextEdit : public KRichTextWidget,
83  // TODO: KDE5: get rid of the spell interface
84  protected KTextEditSpellInterface
85 {
86  Q_OBJECT
87 
88  public:
89 
95  explicit TextEdit( const QString &text, QWidget *parent = 0 );
96 
101  explicit TextEdit( QWidget *parent = 0 );
102 
111  explicit TextEdit( QWidget *parent, const QString &configFile );
112 
121  void enableImageActions();
128  void enableEmoticonActions();
129 
130  void enableInsertHtmlActions();
131 
132  void enableInsertTableActions();
136  ~TextEdit();
137 
148  virtual void createActions( KActionCollection *actionCollection );
149 
156  void addImage( const KUrl &url );
157 
168  void addImage( const KUrl &url, int width, int height );
169 
183  void loadImage( const QImage &image, const QString &matchName, const QString &resourceName );
184 
189  void deleteCurrentLine();
190 
198  ImageList embeddedImages() const;
199 
206  ImageWithNameList imagesWithName() const;
207 
212  QString toWrappedPlainText() const;
213 
217  QString toWrappedPlainText( QTextDocument *document ) const;
218 
222  //TODO 5.0 merge it
223  QString toCleanPlainText( const QString &plainText ) const;
224 
229  QString toCleanPlainText() const;
230 
242  virtual void setHighlighterColors( EMailQuoteHighlighter *highlighter );
243 
247  bool isLineQuoted( const QString &line ) const;
248 
259  virtual int quoteLength( const QString &line ) const;
260 
265  virtual const QString defaultQuoteSign() const;
266 
284  static QByteArray imageNamesToContentIds( const QByteArray &htmlBody,
285  const ImageList &imageList );
286 
295  bool isFormattingUsed() const;
296 
301  QString configFile() const;
302 
306  bool isEnableImageActions() const;
307 
311  bool isEnableEmoticonActions() const;
312 
318  void insertImage( const QImage &image, const QFileInfo &info );
319 
323  bool isEnableInsertHtmlActions() const;
324 
328  bool isEnableInsertTableActions() const;
329 
330  protected:
331 
335  virtual bool canInsertFromMimeData( const QMimeData *source ) const;
336 
340  virtual void insertFromMimeData( const QMimeData *source );
341 
346  virtual bool eventFilter( QObject *o, QEvent *e );
347 
352  virtual void keyPressEvent ( QKeyEvent *e );
353 
354  // For the explaination for these four methods, see the comment at the
355  // spellCheckingEnabled variable of the private class.
356 
360  virtual bool isSpellCheckingEnabled() const;
361 
365  virtual void setSpellCheckingEnabled( bool enable );
366 
371  virtual bool shouldBlockBeSpellChecked( const QString &block ) const;
372 
377  virtual void createHighlighter();
378 
379  private:
380  void addImageHelper( const KUrl &url, int width = -1, int height = -1 );
381  std::auto_ptr<TextEditPrivate> const d;
382  friend class TextEditPrivate;
383  Q_PRIVATE_SLOT( d, void _k_slotAddImage() )
384  Q_PRIVATE_SLOT( d, void _k_slotDeleteLine() )
385  Q_PRIVATE_SLOT( d, void _k_slotAddEmoticon( const QString & ) )
386  Q_PRIVATE_SLOT( d, void _k_slotInsertHtml() )
387  Q_PRIVATE_SLOT( d, void _k_slotFormatReset() )
388  Q_PRIVATE_SLOT( d, void _k_slotTextModeChanged( KRichTextEdit::Mode ) )
389 };
390 
391 } // namespace
392 
393 #endif
KPIMTextEdit::EmbeddedImage
Holds information about an embedded HTML image that will be useful for mail clients.
Definition: textedit.h:48
KPIMTextEdit::ImageWithName::name
QString name
The name of the image as it is available as a resource in the editor.
Definition: textedit.h:64
KPIMTextEdit::EMailQuoteHighlighter
This highlighter highlights spelling mistakes and also highlightes quotes.
Definition: emailquotehighlighter.h:44
KPIMTextEdit::EmbeddedImage::contentID
QString contentID
The content id of the embedded image.
Definition: textedit.h:51
KPIMTextEdit::ImageWithName::image
QImage image
The image.
Definition: textedit.h:63
KPIMTextEdit::TextEdit
Special textedit that provides additional features which are useful for PIM applications like mail cl...
Definition: textedit.h:82
KPIMTextEdit::ImageWithName
Holds information about an embedded HTML image that will be generally useful.
Definition: textedit.h:61
KPIMTextEdit::EmbeddedImage::imageName
QString imageName
Name of the image as it is available as a resource in the editor.
Definition: textedit.h:52
KPIMTextEdit::EmbeddedImage::image
QByteArray image
The image, encoded as PNG with base64 encoding.
Definition: textedit.h:50
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:00:16 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
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

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