kmail

kmedit.h
1 /*
2  * KMComposeWin Header File
3  * Author: Markus Wuebben <markus.wuebben@kde.org>
4  */
5 #ifndef __KMAIL_KMEDIT_H__
6 #define __KMAIL_KMEDIT_H__
7 
8 #include <tdeversion.h>
9 #include <keditcl.h>
10 #include <tdespell.h>
11 #include <ksyntaxhighlighter.h>
12 #include <tqmap.h>
13 #include <tqstringlist.h>
14 #include <tqclipboard.h>
15 
16 class KMComposeWin;
17 class KSpellConfig;
18 class SpellingFilter;
19 class KTempFile;
20 class KDirWatch;
21 class TDEProcess;
22 class TQPopupMenu;
23 
29 class KMSpell : public KSpell
30 {
31  public:
32 
33  KMSpell( TQObject *receiver, const char *slot, KSpellConfig *spellConfig );
34  using KSpell::writePersonalDictionary;
35 };
36 
40 class KMSyntaxHighter : public KDictSpellingHighlighter
41 {
42  public:
43 
44  KMSyntaxHighter( TQTextEdit *textEdit,
45  bool spellCheckingActive = true,
46  bool autoEnable = true,
47  const TQColor& spellColor = red,
48  bool colorQuoting = false,
49  const TQColor& QuoteColor0 = black,
50  const TQColor& QuoteColor1 = TQColor( 0x00, 0x80, 0x00 ),
51  const TQColor& QuoteColor2 = TQColor( 0x00, 0x70, 0x00 ),
52  const TQColor& QuoteColor3 = TQColor( 0x00, 0x60, 0x00 ),
53  KSpellConfig *spellConfig = 0 );
54 
56  virtual bool isMisspelled( const TQString &word );
57 
58  void ignoreWord( const TQString &word );
59 
60  TQStringList ignoredWords() const;
61 
62  private:
63  TQStringList mIgnoredWords;
64 };
65 
66 class KMEdit : public KEdit {
67  TQ_OBJECT
68 
69 public:
70  KMEdit(TQWidget *parent=0,KMComposeWin* composer=0,
71  KSpellConfig* spellConfig = 0,
72  const char *name=0);
73  ~KMEdit();
74 
78  void spellcheck();
79 
83  TQString brokenText();
84 
88  int autoSpellChecking( bool );
89 
93  void setUseExternalEditor( bool use ) { mUseExtEditor = use; }
94  void setExternalEditorPath( const TQString & path ) { mExtEditor = path; }
95 
102  bool checkExternalEditorFinished();
103 
104  TQPopupMenu* createPopupMenu(const TQPoint&);
105  void setSpellCheckingActive(bool spellCheckingActive);
106 
108  void contentsDragEnterEvent(TQDragEnterEvent *e);
109  void contentsDragMoveEvent(TQDragMoveEvent *e);
110  void contentsDropEvent(TQDropEvent *e);
111 
112  void deleteAutoSpellChecking();
113 
114  unsigned int lineBreakColumn() const;
115 
117  void setCursorPositionFromStart(unsigned int pos);
118 
119  int indexOfCurrentLineStart( int paragraph, int index );
120 
121 signals:
122  void spellcheck_done(int result);
123  void attachPNGImageData(const TQByteArray &image);
124  void pasteImage();
125  void focusUp();
126  void focusChanged( bool );
127  void selectionAvailable( bool );
128  void insertSnippet();
129 public slots:
130  void initializeAutoSpellChecking();
131  void slotSpellcheck2(KSpell*);
132  void slotSpellResult(const TQString&);
133  void slotSpellDone();
134  void slotExternalEditorDone(TDEProcess*);
135  void slotMisspelling(const TQString &, const TQStringList &, unsigned int);
136  void slotCorrected (const TQString &, const TQString &, unsigned int);
137  void addSuggestion(const TQString& text, const TQStringList& lst, unsigned int );
138  void cut();
139  void clear();
140  void del();
141  void paste();
142 protected:
146  bool eventFilter(TQObject*, TQEvent*);
147  void keyPressEvent( TQKeyEvent* );
148 
149  void contentsMouseReleaseEvent( TQMouseEvent * e );
150 
153  virtual void contentsMouseDoubleClickEvent( TQMouseEvent *e );
154 
155 private slots:
156  void slotExternalEditorTempFileChanged( const TQString & fileName );
157  void slotSelectionChanged() {
158  // use !text.isEmpty() here, as null-selections exist, but make no sense
159  emit selectionAvailable( !selectedText().isEmpty() );
160  }
161 
164  void spellerReady( KSpell *speller );
165 
167  void spellerDied();
168 
170  void createSpellers();
171 
172 private:
173  void killExternalEditor();
174 
175 private:
176  KMComposeWin* mComposer;
177 
178  // This is the speller used for the spellcheck dialog. It is only active as long as the spellcheck
179  // dialog is shown
180  KSpell *mKSpellForDialog;
181 
182  // This is the speller used when right-clicking a word and choosing "add to dictionary". It lives
183  // as long as the composer lives.
184  KMSpell *mSpeller;
185 
186  KSpellConfig *mSpellConfig;
187  TQMap<TQString,TQStringList> mReplacements;
188  SpellingFilter* mSpellingFilter;
189  KTempFile *mExtEditorTempFile;
190  KDirWatch *mExtEditorTempFileWatcher;
191  TDEProcess *mExtEditorProcess;
192  bool mUseExtEditor;
193  TQString mExtEditor;
194  bool mWasModifiedBeforeSpellCheck;
195  KMSyntaxHighter *mHighlighter;
196  bool mSpellLineEdit;
197  TQClipboard::Mode mPasteMode;
198 };
199 
200 #endif // __KMAIL_KMEDIT_H__
201 
Reimplemented to make writePersonalDictionary() public, which we call everytime after adding a word t...
Definition: kmedit.h:30
Reimplemented to add support for ignored words.
Definition: kmedit.h:41
virtual bool isMisspelled(const TQString &word)
Reimplemented.
Definition: kmedit.cpp:383