openmw-tes3coop/apps/opencs/view/world/scriptedit.hpp

107 lines
2.3 KiB
C++
Raw Normal View History

2014-02-15 16:55:18 +00:00
#ifndef SCRIPTEDIT_H
#define SCRIPTEDIT_H
#include <QPlainTextEdit>
#include <QWidget>
#include <QVector>
#include <QTimer>
#include "../../model/world/universalid.hpp"
2014-08-24 15:56:20 +00:00
#include "scripthighlighter.hpp"
2014-02-17 07:58:55 +00:00
class QRegExp;
2014-02-15 16:55:18 +00:00
namespace CSMDoc
{
class Document;
}
2014-02-15 16:55:18 +00:00
namespace CSVWorld
{
class LineNumberArea;
class ScriptEdit : public QPlainTextEdit
2014-02-15 16:55:18 +00:00
{
Q_OBJECT
public:
class ChangeLock
{
ScriptEdit& mEdit;
ChangeLock (const ChangeLock&);
ChangeLock& operator= (const ChangeLock&);
public:
ChangeLock (ScriptEdit& edit);
~ChangeLock();
};
friend class ChangeLock;
private:
int mChangeLocked;
ScriptHighlighter *mHighlighter;
QTimer mUpdateTimer;
QWidget *lineNumberArea;
public:
2014-08-24 15:56:20 +00:00
ScriptEdit (const CSMDoc::Document& document, ScriptHighlighter::Mode mode,
QWidget* parent);
/// Should changes to the data be ignored (i.e. not cause updated)?
///
/// \note This mechanism is used to avoid infinite update recursions
bool isChangeLocked() const;
void lineNumberAreaPaintEvent(QPaintEvent *event);
int lineNumberAreaWidth();
protected:
virtual void resizeEvent(QResizeEvent *e);
private:
QVector<CSMWorld::UniversalId::Type> mAllowedTypes;
const CSMDoc::Document& mDocument;
2014-02-17 07:58:55 +00:00
const QRegExp mWhiteListQoutes;
2014-02-15 16:55:18 +00:00
void dragEnterEvent (QDragEnterEvent* event);
void dropEvent (QDropEvent* event);
void dragMoveEvent (QDragMoveEvent* event);
2014-02-16 17:41:42 +00:00
2014-02-17 07:58:55 +00:00
bool stringNeedsQuote(const std::string& id) const;
private slots:
void idListChanged();
void updateHighlighting();
void updateLineNumberAreaWidth(int newBlockCount);
void updateLineNumberArea(const QRect &, int);
};
class LineNumberArea : public QWidget
{
ScriptEdit *mScriptEdit;
public:
LineNumberArea(ScriptEdit *editor);
QSize sizeHint() const;
protected:
void paintEvent(QPaintEvent *event);
2014-02-15 16:55:18 +00:00
};
}
2015-03-11 14:54:45 +00:00
#endif // SCRIPTEDIT_H