summaryrefslogtreecommitdiff
path: root/src/editor.h
blob: bb338b07443ede3bb7bfb462c1a6ac077f246702 (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
#include <QObject>
#include <QString>
#include <QWidget>
#include <QWheelEvent>

#ifdef _QCODE_EDIT_
#include <qeditor.h>
class Editor : public QEditor
#else
#include <QTextEdit>
class Editor : public QTextEdit
#endif
{
	Q_OBJECT
public:
#ifdef _QCODE_EDIT_
	Editor(QWidget *parent) : QEditor(parent) {}
	QString toPlainText() const { return text(); }
	void setPlainText(const QString& text) { setText(text); }
public slots:
	//void zoomIn() { zoom(1); }
	void zoomIn(int n = 1) { zoom(n); }
	//void zoomOut() { zoom(-1); } 
	void zoomOut(int n = 1) { zoom(-n); } 
#else
	Editor(QWidget *parent) : QTextEdit(parent) { setAcceptRichText(false); }
public slots:
	void zoomIn();
	void zoomOut();
	void setLineWrapping(bool on) { if(on) setWordWrapMode(QTextOption::WrapAnywhere); }
	void setContentModified(bool y) { document()->setModified(y); }
	bool isContentModified() { return document()->isModified(); }
	void indentSelection();
	void unindentSelection();
	void commentSelection();
	void uncommentSelection();
private:
	void wheelEvent ( QWheelEvent * event );
#endif
};
contact: Jan Huwald // Impressum