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

KPIMTextedit Library

textedit.h

00001 /*
00002     Copyright (c) 2009 Thomas McGuire <mcguire@kde.org>
00003 
00004     Based on KMail and libkdepim code by:
00005     Copyright 2007 - 2010 Laurent Montel <montel@kde.org>
00006 
00007     This library is free software; you can redistribute it and/or modify it
00008     under the terms of the GNU Library General Public License as published by
00009     the Free Software Foundation; either version 2 of the License, or (at your
00010     option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful, but WITHOUT
00013     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00015     License for more details.
00016 
00017     You should have received a copy of the GNU Library General Public License
00018     along with this library; see the file COPYING.LIB.  If not, write to the
00019     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00020     02110-1301, USA.
00021 */
00022 #ifndef KPIMTEXTEDIT_TEXTEDIT_H
00023 #define KPIMTEXTEDIT_TEXTEDIT_H
00024 
00025 #include "kpimtextedit_export.h"
00026 
00027 #include <kpimidentities/signature.h>
00028 
00029 #include <KDE/KRichTextWidget>
00030 
00031 #include <QtCore/QSharedPointer>
00032 
00033 #include <memory>
00034 #include <QFileInfo>
00035 
00036 #define FIX_KMAIL_INSERT_IMAGE 1
00037 class KUrl;
00038 
00039 namespace KPIMTextEdit {
00040 
00041 class TextEditPrivate;
00042 class EMailQuoteHighlighter;
00043 
00048 struct EmbeddedImage
00049 {
00050   QByteArray image;   
00051   QString contentID;  
00052   QString imageName;  
00053 };
00054 
00061 struct ImageWithName
00062 {
00063   QImage image; 
00064   QString name; 
00065 };
00066 
00067 typedef QSharedPointer<ImageWithName> ImageWithNamePtr;
00068 typedef QList< ImageWithNamePtr > ImageWithNameList;
00069 typedef QList< QSharedPointer<EmbeddedImage> > ImageList;
00070 
00082 class KPIMTEXTEDIT_EXPORT TextEdit : public KRichTextWidget,
00083                                      protected KTextEditSpellInterface // TODO: KDE5: get rid of the spell interface
00084 {
00085   Q_OBJECT
00086 
00087   public:
00088 
00094     explicit TextEdit( const QString& text, QWidget *parent = 0 );
00095 
00100     explicit TextEdit( QWidget *parent = 0 );
00101 
00102 
00111     explicit TextEdit( QWidget * parent, const QString & configFile );
00112 
00121     void enableImageActions();
00122 
00126     ~TextEdit();
00127 
00137     virtual void createActions( KActionCollection *actionCollection );
00138 
00145     void addImage( const KUrl &url );
00146 
00157     void loadImage( const QImage &image, const QString &matchName, const QString &resourceName );
00158 
00163     void deleteCurrentLine();
00164 
00172     ImageList embeddedImages() const;
00173 
00180     ImageWithNameList imagesWithName() const;
00181 
00186     QString toWrappedPlainText() const;
00187 
00192     QString toCleanPlainText() const;
00193 
00205     virtual void setHighlighterColors( EMailQuoteHighlighter *highlighter );
00206 
00210     bool isLineQuoted( const QString &line ) const;
00211 
00222     virtual int quoteLength( const QString &line ) const;
00223 
00228     virtual const QString defaultQuoteSign() const;
00229 
00247     static QByteArray imageNamesToContentIds( const QByteArray &htmlBody, const ImageList &imageList );
00248 
00257     bool isFormattingUsed() const;
00258 
00259     /*  Return config file
00260      *  @since 4.5
00261      */
00262     QString configFile() const;
00263     /*
00264      * @since 4.6
00265      */
00266     void insertImage( const QImage &image, const QFileInfo&info );
00267     
00268   protected:
00269 
00273     virtual bool canInsertFromMimeData( const QMimeData *source ) const;
00274 
00278     virtual void insertFromMimeData( const QMimeData *source );
00279 
00284     virtual bool eventFilter( QObject*o, QEvent* e );
00285 
00290     virtual void keyPressEvent ( QKeyEvent * e );
00291 
00292     // For the explaination for these four methods, see the comment at the
00293     // spellCheckingEnabled variable of the private class.
00294 
00298     virtual bool isSpellCheckingEnabled() const;
00299 
00303     virtual void setSpellCheckingEnabled( bool enable );
00304 
00309     virtual bool shouldBlockBeSpellChecked( const QString& block ) const;
00310 
00315     virtual void createHighlighter();
00316 
00317   private:
00318 
00319     std::auto_ptr<TextEditPrivate> const d;
00320     friend class TextEditPrivate;
00321     Q_PRIVATE_SLOT( d, void _k_slotAddImage() )
00322     Q_PRIVATE_SLOT( d, void _k_slotDeleteLine() )
00323 };
00324 
00325 } // namespace
00326 
00327 #endif

KPIMTextedit Library

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

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kblog
  • kcal
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.7.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