File: texteditex.cpp

package info (click to toggle)
olive-editor 20181223-2
  • links: PTS
  • area: main
  • in suites: buster
  • size: 2,844 kB
  • sloc: cpp: 20,147; xml: 315; ansic: 16; makefile: 11
file content (42 lines) | stat: -rw-r--r-- 872 bytes parent folder | download
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
#include "texteditex.h"

#include <QDebug>

TextEditEx::TextEditEx(QWidget *parent) : QTextEdit(parent) {
	setUndoRedoEnabled(false);
	connect(this, SIGNAL(textChanged()), this, SLOT(updateInternals()));
	connect(this, SIGNAL(updateSelf()), this, SLOT(updateText()));
}

const QString& TextEditEx::getPlainTextEx() {
	return text;
}

void TextEditEx::setPlainTextEx(const QString &t) {
	previousText = text;
	text = t;
	emit updateSelf();
}

const QString &TextEditEx::getPreviousValue() {
	return previousText;
}

void TextEditEx::updateInternals() {
	previousText = text;
	text = toPlainText();
}

void TextEditEx::updateText() {
	blockSignals(true);

	int pos = textCursor().position();

	setPlainText(text);

	QTextCursor newCursor(document());
	newCursor.setPosition(pos);
	setTextCursor(newCursor);

	blockSignals(false);
}