summaryrefslogtreecommitdiffstats
path: root/kmail/kmedit.h
blob: a44642baa043e06efea0321bcb424f5bfb4b3f19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/* -*- mode: C++; c-file-style: "gnu" -*-
 * KMComposeWin Header File
 * Author: Markus Wuebben <[email protected]>
 */
#ifndef __KMAIL_KMEDIT_H__
#define __KMAIL_KMEDIT_H__

#include <kdeversion.h>
#include <keditcl.h>
#include <tqmap.h>
#include <tqstringlist.h>
#include <tqclipboard.h>

class KMComposeWin;
class KSpellConfig;
class KSpell;
class SpellingFilter;
class KTempFile;
class KDictSpellingHighlighter;
class KDirWatch;
class KProcess;
class QPopupMenu;


class KMEdit : public KEdit {
  Q_OBJECT
public:
  KMEdit(TQWidget *parent=0,KMComposeWin* composer=0,
         KSpellConfig* spellConfig = 0,
	 const char *name=0);
  ~KMEdit();

  /**
   * Start the spell checker.
   */
  void spellcheck();

  /**
   * Text with lines breaks inserted after every row
   */
  TQString brokenText();

   /**
   * Toggle automatic spellchecking
   */
  int autoSpellChecking( bool );

  /**
   * For the external editor
   */
  void setUseExternalEditor( bool use ) { mUseExtEditor = use; }
  void setExternalEditorPath( const TQString & path ) { mExtEditor = path; }

  /**
   * Check that the external editor has finished and output a warning
   * if it hasn't.
   * @return false if the user chose to cancel whatever operation
   * called this method.
   */
  bool checkExternalEditorFinished();

  TQPopupMenu* createPopupMenu(const TQPoint&);
  void setSpellCheckingActive(bool spellCheckingActive);

  /** Drag and drop methods */
  void contentsDragEnterEvent(TQDragEnterEvent *e);
  void contentsDragMoveEvent(TQDragMoveEvent *e);
  void contentsDropEvent(TQDropEvent *e);

  void deleteAutoSpellChecking();

  unsigned int lineBreakColumn() const;
  
  /** set cursor to absolute position pos */
  void setCursorPositionFromStart(unsigned int pos);

signals:
  void spellcheck_done(int result);
  void attachPNGImageData(const TQByteArray &image);
  void pasteImage();
  void focusUp();
  void focusChanged( bool );
  void insertSnippet();
public slots:
  void initializeAutoSpellChecking();
  void slotSpellcheck2(KSpell*);
  void slotSpellResult(const TQString&);
  void slotSpellDone();
  void slotExternalEditorDone(KProcess*);
  void slotMisspelling(const TQString &, const TQStringList &, unsigned int);
  void slotCorrected (const TQString &, const TQString &, unsigned int);
  void addSuggestion(const TQString& text, const TQStringList& lst, unsigned int );
  void cut();
  void clear();
  void del();
  void paste();
protected:
  /**
   * Event filter that does Tab-key handling.
   */
  bool eventFilter(TQObject*, TQEvent*);
  void keyPressEvent( TQKeyEvent* );
  
  void contentsMouseReleaseEvent( TQMouseEvent * e );

private slots:
  void slotExternalEditorTempFileChanged( const TQString & fileName );

private:
  void killExternalEditor();

private:
  KMComposeWin* mComposer;

  KSpell *mKSpell;
  KSpellConfig *mSpellConfig;
  TQMap<TQString,TQStringList> mReplacements;
  SpellingFilter* mSpellingFilter;
  KTempFile *mExtEditorTempFile;
  KDirWatch *mExtEditorTempFileWatcher;
  KProcess  *mExtEditorProcess;
  bool      mUseExtEditor;
  TQString   mExtEditor;
  bool      mWasModifiedBeforeSpellCheck;
  KDictSpellingHighlighter *mSpellChecker;
  bool mSpellLineEdit;
  QClipboard::Mode mPasteMode;
};

#endif // __KMAIL_KMEDIT_H__