kmail

kmedit.h

00001 /* -*- mode: C++; c-file-style: "gnu" -*-
00002  * KMComposeWin Header File
00003  * Author: Markus Wuebben <markus.wuebben@kde.org>
00004  */
00005 #ifndef __KMAIL_KMEDIT_H__
00006 #define __KMAIL_KMEDIT_H__
00007 
00008 #include <kdeversion.h>
00009 #include <keditcl.h>
00010 #include <qmap.h>
00011 #include <qstringlist.h>
00012 #include <qclipboard.h>
00013 
00014 class KMComposeWin;
00015 class KSpellConfig;
00016 class KSpell;
00017 class SpellingFilter;
00018 class KTempFile;
00019 class KDictSpellingHighlighter;
00020 class KDirWatch;
00021 class KProcess;
00022 class QPopupMenu;
00023 
00024 
00025 class KMEdit : public KEdit {
00026   Q_OBJECT
00027 public:
00028   KMEdit(QWidget *parent=0,KMComposeWin* composer=0,
00029          KSpellConfig* spellConfig = 0,
00030      const char *name=0);
00031   ~KMEdit();
00032 
00036   void spellcheck();
00037 
00041   QString brokenText();
00042 
00046   int autoSpellChecking( bool );
00047 
00051   void setUseExternalEditor( bool use ) { mUseExtEditor = use; }
00052   void setExternalEditorPath( const QString & path ) { mExtEditor = path; }
00053 
00060   bool checkExternalEditorFinished();
00061 
00062   QPopupMenu* createPopupMenu(const QPoint&);
00063   void setSpellCheckingActive(bool spellCheckingActive);
00064 
00066   void contentsDragEnterEvent(QDragEnterEvent *e);
00067   void contentsDragMoveEvent(QDragMoveEvent *e);
00068   void contentsDropEvent(QDropEvent *e);
00069 
00070   void deleteAutoSpellChecking();
00071 
00072   unsigned int lineBreakColumn() const;
00073   
00075   void setCursorPositionFromStart(unsigned int pos);
00076 
00077 signals:
00078   void spellcheck_done(int result);
00079   void attachPNGImageData(const QByteArray &image);
00080   void pasteImage();
00081   void focusUp();
00082   void focusChanged( bool );
00083   void selectionAvailable( bool );
00084   void insertSnippet();
00085 public slots:
00086   void initializeAutoSpellChecking();
00087   void slotSpellcheck2(KSpell*);
00088   void slotSpellResult(const QString&);
00089   void slotSpellDone();
00090   void slotExternalEditorDone(KProcess*);
00091   void slotMisspelling(const QString &, const QStringList &, unsigned int);
00092   void slotCorrected (const QString &, const QString &, unsigned int);
00093   void addSuggestion(const QString& text, const QStringList& lst, unsigned int );
00094   void cut();
00095   void clear();
00096   void del();
00097   void paste();
00098 protected:
00102   bool eventFilter(QObject*, QEvent*);
00103   void keyPressEvent( QKeyEvent* );
00104   
00105   void contentsMouseReleaseEvent( QMouseEvent * e );
00106 
00107 private slots:
00108   void slotExternalEditorTempFileChanged( const QString & fileName );
00109   void slotSelectionChanged() {
00110     // use !text.isEmpty() here, as null-selections exist, but make no sense
00111     emit selectionAvailable( !selectedText().isEmpty() );
00112   }
00113 
00114 private:
00115   void killExternalEditor();
00116 
00117 private:
00118   KMComposeWin* mComposer;
00119 
00120   KSpell *mKSpell;
00121   KSpellConfig *mSpellConfig;
00122   QMap<QString,QStringList> mReplacements;
00123   SpellingFilter* mSpellingFilter;
00124   KTempFile *mExtEditorTempFile;
00125   KDirWatch *mExtEditorTempFileWatcher;
00126   KProcess  *mExtEditorProcess;
00127   bool      mUseExtEditor;
00128   QString   mExtEditor;
00129   bool      mWasModifiedBeforeSpellCheck;
00130   KDictSpellingHighlighter *mSpellChecker;
00131   bool mSpellLineEdit;
00132   QClipboard::Mode mPasteMode;
00133 };
00134 
00135 #endif // __KMAIL_KMEDIT_H__
00136