summaryrefslogtreecommitdiffstats
blob: 38d5d0ab0bfe17dc3e075954bfe1625589bd7b99 (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
/*
 * Copyright (c) 2010 Kevin Smith
 * Licensed under the GNU General Public License v3.
 * See Documentation/Licenses/GPLv3.txt for more information.
 */

#pragma once

#include <SwifTools/SpellParser.h>

#include <Swift/Controllers/Settings/SettingsProvider.h>
#include <Swift/Controllers/SettingConstants.h>

#include <QTextEdit>

namespace Swift {
	class SpellChecker;
	class QtTextEdit : public QTextEdit {
		Q_OBJECT
	public:
		QtTextEdit(SettingsProvider* settings, QWidget* parent = 0);
		virtual ~QtTextEdit();
		virtual QSize sizeHint() const;
	signals:
		void wordCorrected(QString& word);
		void returnPressed();
		void unhandledKeyPressEvent(QKeyEvent* event);
	public slots:
		void handleReplaceMisspellWord(const QString& word, const boost::tuple<int,int>& wordPosition);
	protected:
		virtual void keyPressEvent(QKeyEvent* event);
		virtual void contextMenuEvent(QContextMenuEvent* event);
	private slots:
		void handleTextChanged();
	private:
		SpellChecker *checker_;
		PositionPairList misspelledPositions_;
		SettingsProvider *settings_;
		void setUpSpellChecker();
		void underlineMisspells();
		boost::tuple<int,int> getWordFromCursor(int cursorPosition);
	};
}