implement script editor via QPlainTextEdit instead of QTextEdit

This commit is contained in:
Marc Zinnschlag 2014-09-01 10:52:10 +02:00
parent ea4cd94c25
commit 7e653cebdf
2 changed files with 8 additions and 8 deletions

View file

@ -25,13 +25,13 @@ CSVWorld::ScriptEdit::ChangeLock::~ChangeLock()
CSVWorld::ScriptEdit::ScriptEdit (const CSMDoc::Document& document, ScriptHighlighter::Mode mode, CSVWorld::ScriptEdit::ScriptEdit (const CSMDoc::Document& document, ScriptHighlighter::Mode mode,
QWidget* parent) QWidget* parent)
: QTextEdit (parent), : QPlainTextEdit (parent),
mDocument (document), mDocument (document),
mWhiteListQoutes("^[a-z|_]{1}[a-z|0-9|_]{0,}$", Qt::CaseInsensitive), mWhiteListQoutes("^[a-z|_]{1}[a-z|0-9|_]{0,}$", Qt::CaseInsensitive),
mChangeLocked (0) mChangeLocked (0)
{ {
setAcceptRichText (false); // setAcceptRichText (false);
setLineWrapMode (QTextEdit::NoWrap); setLineWrapMode (QPlainTextEdit::NoWrap);
setTabStopWidth (4); setTabStopWidth (4);
setUndoRedoEnabled (false); // we use OpenCS-wide undo/redo instead setUndoRedoEnabled (false); // we use OpenCS-wide undo/redo instead
@ -83,7 +83,7 @@ void CSVWorld::ScriptEdit::dragEnterEvent (QDragEnterEvent* event)
{ {
const CSMWorld::TableMimeData* mime = dynamic_cast<const CSMWorld::TableMimeData*> (event->mimeData()); const CSMWorld::TableMimeData* mime = dynamic_cast<const CSMWorld::TableMimeData*> (event->mimeData());
if (!mime) if (!mime)
QTextEdit::dragEnterEvent(event); QPlainTextEdit::dragEnterEvent(event);
else else
{ {
setTextCursor (cursorForPosition (event->pos())); setTextCursor (cursorForPosition (event->pos()));
@ -95,7 +95,7 @@ void CSVWorld::ScriptEdit::dragMoveEvent (QDragMoveEvent* event)
{ {
const CSMWorld::TableMimeData* mime = dynamic_cast<const CSMWorld::TableMimeData*> (event->mimeData()); const CSMWorld::TableMimeData* mime = dynamic_cast<const CSMWorld::TableMimeData*> (event->mimeData());
if (!mime) if (!mime)
QTextEdit::dragMoveEvent(event); QPlainTextEdit::dragMoveEvent(event);
else else
{ {
setTextCursor (cursorForPosition (event->pos())); setTextCursor (cursorForPosition (event->pos()));
@ -108,7 +108,7 @@ void CSVWorld::ScriptEdit::dropEvent (QDropEvent* event)
const CSMWorld::TableMimeData* mime = dynamic_cast<const CSMWorld::TableMimeData*> (event->mimeData()); const CSMWorld::TableMimeData* mime = dynamic_cast<const CSMWorld::TableMimeData*> (event->mimeData());
if (!mime) // May happen when non-records (e.g. plain text) are dragged and dropped if (!mime) // May happen when non-records (e.g. plain text) are dragged and dropped
{ {
QTextEdit::dropEvent(event); QPlainTextEdit::dropEvent(event);
return; return;
} }

View file

@ -1,7 +1,7 @@
#ifndef SCRIPTEDIT_H #ifndef SCRIPTEDIT_H
#define SCRIPTEDIT_H #define SCRIPTEDIT_H
#include <QTextEdit> #include <QPlainTextEdit>
#include <QVector> #include <QVector>
#include <QTimer> #include <QTimer>
@ -19,7 +19,7 @@ namespace CSMDoc
namespace CSVWorld namespace CSVWorld
{ {
class ScriptEdit : public QTextEdit class ScriptEdit : public QPlainTextEdit
{ {
Q_OBJECT Q_OBJECT