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

KPIMTextedit Library

  • 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 namespace KPIMTextEdit {
39 
40 class TextEditPrivate;
41 class EMailQuoteHighlighter;
42 
47 struct EmbeddedImage
48 {
49  QByteArray image;
50  QString contentID;
51  QString imageName;
52 };
53 
60 struct ImageWithName
61 {
62  QImage image;
63  QString name;
64 };
65 
66 typedef QSharedPointer<ImageWithName> ImageWithNamePtr;
67 typedef QList< ImageWithNamePtr > ImageWithNameList;
68 typedef QList< QSharedPointer<EmbeddedImage> > ImageList;
69 
81 class KPIMTEXTEDIT_EXPORT TextEdit : public KRichTextWidget,
82  // TODO: KDE5: get rid of the spell interface
83  protected KTextEditSpellInterface
84 {
85  Q_OBJECT
86 
87  public:
88 
94  explicit TextEdit( const QString &text, QWidget *parent = 0 );
95 
100  explicit TextEdit( QWidget *parent = 0 );
101 
110  explicit TextEdit( QWidget *parent, const QString &configFile );
111 
120  void enableImageActions();
127  void enableEmoticonActions();
128 
129  void enableInsertHtmlActions();
130 
131  void enableInsertTableActions();
135  ~TextEdit();
136 
146  virtual void createActions( KActionCollection *actionCollection );
147 
154  void addImage(const KUrl &url);
155 
166  void addImage(const KUrl &url, int width, int height);
167 
178  void loadImage( const QImage &image, const QString &matchName, const QString &resourceName );
179 
184  void deleteCurrentLine();
185 
193  ImageList embeddedImages() const;
194 
201  ImageWithNameList imagesWithName() const;
202 
207  QString toWrappedPlainText() const;
208 
212  QString toWrappedPlainText(QTextDocument *document) const;
216  //TODO 5.0 merge it
217  QString toCleanPlainText(const QString& plainText) const;
218 
223  QString toCleanPlainText() const;
224 
236  virtual void setHighlighterColors( EMailQuoteHighlighter *highlighter );
237 
241  bool isLineQuoted( const QString &line ) const;
242 
253  virtual int quoteLength( const QString &line ) const;
254 
259  virtual const QString defaultQuoteSign() const;
260 
278  static QByteArray imageNamesToContentIds( const QByteArray &htmlBody,
279  const ImageList &imageList );
280 
289  bool isFormattingUsed() const;
290 
295  QString configFile() const;
296 
300  bool isEnableImageActions() const;
301 
305  bool isEnableEmoticonActions() const;
306 
310  void insertImage( const QImage &image, const QFileInfo &info );
311 
315  bool isEnableInsertHtmlActions() const;
316 
320  bool isEnableInsertTableActions() const;
321 
322  protected:
323 
327  virtual bool canInsertFromMimeData( const QMimeData *source ) const;
328 
332  virtual void insertFromMimeData( const QMimeData *source );
333 
338  virtual bool eventFilter( QObject *o, QEvent *e );
339 
344  virtual void keyPressEvent ( QKeyEvent *e );
345 
346  // For the explaination for these four methods, see the comment at the
347  // spellCheckingEnabled variable of the private class.
348 
352  virtual bool isSpellCheckingEnabled() const;
353 
357  virtual void setSpellCheckingEnabled( bool enable );
358 
363  virtual bool shouldBlockBeSpellChecked( const QString &block ) const;
364 
369  virtual void createHighlighter();
370 
371  private:
372  void addImageHelper(const KUrl &url, int width = -1, int height = -1);
373  std::auto_ptr<TextEditPrivate> const d;
374  friend class TextEditPrivate;
375  Q_PRIVATE_SLOT( d, void _k_slotAddImage() )
376  Q_PRIVATE_SLOT( d, void _k_slotDeleteLine() )
377  Q_PRIVATE_SLOT( d, void _k_slotAddEmoticon(const QString &) )
378  Q_PRIVATE_SLOT( d, void _k_slotInsertHtml() )
379  Q_PRIVATE_SLOT( d, void _k_slotFormatReset() )
380  Q_PRIVATE_SLOT( d, void _k_slotTextModeChanged(KRichTextEdit::Mode) )
381 };
382 
383 } // namespace
384 
385 #endif
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jul 13 2013 01:26:01 by doxygen 1.8.3.1 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-4.10.5 API Reference

Skip menu "kdepimlibs-4.10.5 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
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