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