KPIMTextedit Library
textedit.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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
00035 class KUrl;
00036
00037 namespace KPIMTextEdit {
00038
00039 class TextEditPrivate;
00040 class EMailQuoteHighlighter;
00041
00046 struct EmbeddedImage
00047 {
00048 QByteArray image;
00049 QString contentID;
00050 QString imageName;
00051 };
00052
00059 struct ImageWithName
00060 {
00061 QImage image;
00062 QString name;
00063 };
00064
00065 typedef QSharedPointer<ImageWithName> ImageWithNamePtr;
00066 typedef QList< ImageWithNamePtr > ImageWithNameList;
00067 typedef QList< QSharedPointer<EmbeddedImage> > ImageList;
00068
00080 class KPIMTEXTEDIT_EXPORT TextEdit : public KRichTextWidget,
00081 protected KTextEditSpellInterface
00082 {
00083 Q_OBJECT
00084
00085 public:
00086
00092 explicit TextEdit( const QString& text, QWidget *parent = 0 );
00093
00098 explicit TextEdit( QWidget *parent = 0 );
00099
00108 void enableImageActions();
00109
00113 ~TextEdit();
00114
00124 virtual void createActions( KActionCollection *actionCollection );
00125
00132 void addImage( const KUrl &url );
00133
00144 void loadImage( const QImage &image, const QString &matchName, const QString &resourceName );
00145
00150 void deleteCurrentLine();
00151
00159 ImageList embeddedImages() const;
00160
00167 ImageWithNameList imagesWithName() const;
00168
00173 QString toWrappedPlainText() const;
00174
00179 QString toCleanPlainText() const;
00180
00192 virtual void setHighlighterColors( EMailQuoteHighlighter *highlighter );
00193
00197 bool isLineQuoted( const QString &line ) const;
00198
00209 virtual int quoteLength( const QString &line ) const;
00210
00215 virtual const QString defaultQuoteSign() const;
00216
00234 static QByteArray imageNamesToContentIds( const QByteArray &htmlBody, const ImageList &imageList );
00235
00244 bool isFormattingUsed() const;
00245
00246 protected:
00247
00251 virtual bool canInsertFromMimeData( const QMimeData *source ) const;
00252
00256 virtual void insertFromMimeData( const QMimeData *source );
00257
00262 virtual bool eventFilter( QObject*o, QEvent* e );
00263
00268 virtual void keyPressEvent ( QKeyEvent * e );
00269
00270
00271
00272
00276 virtual bool isSpellCheckingEnabled() const;
00277
00281 virtual void setSpellCheckingEnabled( bool enable );
00282
00287 virtual bool shouldBlockBeSpellChecked( const QString& block ) const;
00288
00293 virtual void createHighlighter();
00294
00295 private:
00296
00297 std::auto_ptr<TextEditPrivate> const d;
00298 friend class TextEditPrivate;
00299 Q_PRIVATE_SLOT( d, void _k_slotAddImage() )
00300 Q_PRIVATE_SLOT( d, void _k_slotDeleteLine() )
00301 };
00302
00303 }
00304
00305 #endif