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 <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, KSpellConfig *spellConfig );
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     // use !text.isEmpty() here, as null-selections exist, but make no sense
00156     emit selectionAvailable( !selectedText().isEmpty() );
00157   }
00158 
00161   void spellerReady( KSpell *speller );
00162 
00164   void spellerDied();
00165 
00167   void createSpellers();
00168 
00169 private:
00170   void killExternalEditor();
00171 
00172 private:
00173   KMComposeWin* mComposer;
00174 
00175   // This is the speller used for the spellcheck dialog. It is only active as long as the spellcheck
00176   // dialog is shown
00177   KSpell *mKSpellForDialog;
00178 
00179   // This is the speller used when right-clicking a word and choosing "add to dictionary". It lives
00180   // as long as the composer lives.
00181   KMSpell *mSpeller;
00182 
00183   KSpellConfig *mSpellConfig;
00184   QMap<QString,QStringList> mReplacements;
00185   SpellingFilter* mSpellingFilter;
00186   KTempFile *mExtEditorTempFile;
00187   KDirWatch *mExtEditorTempFileWatcher;
00188   KProcess  *mExtEditorProcess;
00189   bool      mUseExtEditor;
00190   QString   mExtEditor;
00191   bool      mWasModifiedBeforeSpellCheck;
00192   KMSyntaxHighter *mHighlighter;
00193   bool mSpellLineEdit;
00194   QClipboard::Mode mPasteMode;
00195 };
00196 
00197 #endif // __KMAIL_KMEDIT_H__
00198 
KDE Home | KDE Accessibility Home | Description of Access Keys