kmail
kmedit.h00001
00002
00003
00004
00005 #ifndef __KMAIL_KMEDIT_H__
00006 #define __KMAIL_KMEDIT_H__
00007
00008 #include <kdeversion.h>
00009 #include <keditcl.h>
00010 #include <kspell.h>
00011 #include <ksyntaxhighlighter.h>
00012 #include <qmap.h>
00013 #include <qstringlist.h>
00014 #include <qclipboard.h>
00015
00016 class KMComposeWin;
00017 class KSpellConfig;
00018 class SpellingFilter;
00019 class KTempFile;
00020 class KDirWatch;
00021 class KProcess;
00022 class QPopupMenu;
00023
00029 class KMSpell : public KSpell
00030 {
00031 public:
00032
00033 KMSpell( QObject *receiver, const char *slot );
00034 using KSpell::writePersonalDictionary;
00035 };
00036
00040 class KMSyntaxHighter : public KDictSpellingHighlighter
00041 {
00042 public:
00043
00044 KMSyntaxHighter( QTextEdit *textEdit,
00045 bool spellCheckingActive = true,
00046 bool autoEnable = true,
00047 const QColor& spellColor = red,
00048 bool colorQuoting = false,
00049 const QColor& QuoteColor0 = black,
00050 const QColor& QuoteColor1 = QColor( 0x00, 0x80, 0x00 ),
00051 const QColor& QuoteColor2 = QColor( 0x00, 0x70, 0x00 ),
00052 const QColor& QuoteColor3 = QColor( 0x00, 0x60, 0x00 ),
00053 KSpellConfig *spellConfig = 0 );
00054
00056 virtual bool isMisspelled( const QString &word );
00057
00058 void ignoreWord( const QString &word );
00059
00060 QStringList ignoredWords() const;
00061
00062 private:
00063 QStringList mIgnoredWords;
00064 };
00065
00066 class KMEdit : public KEdit {
00067 Q_OBJECT
00068 public:
00069 KMEdit(QWidget *parent=0,KMComposeWin* composer=0,
00070 KSpellConfig* spellConfig = 0,
00071 const char *name=0);
00072 ~KMEdit();
00073
00077 void spellcheck();
00078
00082 QString brokenText();
00083
00087 int autoSpellChecking( bool );
00088
00092 void setUseExternalEditor( bool use ) { mUseExtEditor = use; }
00093 void setExternalEditorPath( const QString & path ) { mExtEditor = path; }
00094
00101 bool checkExternalEditorFinished();
00102
00103 QPopupMenu* createPopupMenu(const QPoint&);
00104 void setSpellCheckingActive(bool spellCheckingActive);
00105
00107 void contentsDragEnterEvent(QDragEnterEvent *e);
00108 void contentsDragMoveEvent(QDragMoveEvent *e);
00109 void contentsDropEvent(QDropEvent *e);
00110
00111 void deleteAutoSpellChecking();
00112
00113 unsigned int lineBreakColumn() const;
00114
00116 void setCursorPositionFromStart(unsigned int pos);
00117
00118 signals:
00119 void spellcheck_done(int result);
00120 void attachPNGImageData(const QByteArray &image);
00121 void pasteImage();
00122 void focusUp();
00123 void focusChanged( bool );
00124 void selectionAvailable( bool );
00125 void insertSnippet();
00126 public slots:
00127 void initializeAutoSpellChecking();
00128 void slotSpellcheck2(KSpell*);
00129 void slotSpellResult(const QString&);
00130 void slotSpellDone();
00131 void slotExternalEditorDone(KProcess*);
00132 void slotMisspelling(const QString &, const QStringList &, unsigned int);
00133 void slotCorrected (const QString &, const QString &, unsigned int);
00134 void addSuggestion(const QString& text, const QStringList& lst, unsigned int );
00135 void cut();
00136 void clear();
00137 void del();
00138 void paste();
00139 protected:
00143 bool eventFilter(QObject*, QEvent*);
00144 void keyPressEvent( QKeyEvent* );
00145
00146 void contentsMouseReleaseEvent( QMouseEvent * e );
00147
00150 virtual void contentsMouseDoubleClickEvent( QMouseEvent *e );
00151
00152 private slots:
00153 void slotExternalEditorTempFileChanged( const QString & fileName );
00154 void slotSelectionChanged() {
00155
00156 emit selectionAvailable( !selectedText().isEmpty() );
00157 }
00158
00161 void spellerReady( KSpell *speller );
00162
00164 void spellerDied();
00165
00166 private:
00167 void killExternalEditor();
00168
00169 private:
00170 KMComposeWin* mComposer;
00171
00172
00173
00174 KSpell *mKSpellForDialog;
00175
00176
00177
00178 KMSpell *mSpeller;
00179
00180 KSpellConfig *mSpellConfig;
00181 QMap<QString,QStringList> mReplacements;
00182 SpellingFilter* mSpellingFilter;
00183 KTempFile *mExtEditorTempFile;
00184 KDirWatch *mExtEditorTempFileWatcher;
00185 KProcess *mExtEditorProcess;
00186 bool mUseExtEditor;
00187 QString mExtEditor;
00188 bool mWasModifiedBeforeSpellCheck;
00189 KMSyntaxHighter *mHighlighter;
00190 bool mSpellLineEdit;
00191 QClipboard::Mode mPasteMode;
00192 };
00193
00194 #endif // __KMAIL_KMEDIT_H__
00195
|