2014-02-15 16:55:18 +00:00
|
|
|
#ifndef SCRIPTEDIT_H
|
|
|
|
#define SCRIPTEDIT_H
|
|
|
|
|
2014-09-01 08:52:10 +00:00
|
|
|
#include <QPlainTextEdit>
|
2014-02-15 19:49:09 +00:00
|
|
|
#include <QVector>
|
2014-08-22 10:49:34 +00:00
|
|
|
#include <QTimer>
|
2014-02-15 19:49:09 +00:00
|
|
|
|
|
|
|
#include "../../model/world/universalid.hpp"
|
2014-02-15 18:52:40 +00:00
|
|
|
|
2014-08-24 15:56:20 +00:00
|
|
|
#include "scripthighlighter.hpp"
|
|
|
|
|
2014-02-15 18:52:40 +00:00
|
|
|
class QWidget;
|
2014-02-17 07:58:55 +00:00
|
|
|
class QRegExp;
|
2014-02-15 16:55:18 +00:00
|
|
|
|
2014-02-16 08:51:33 +00:00
|
|
|
namespace CSMDoc
|
|
|
|
{
|
|
|
|
class Document;
|
|
|
|
}
|
|
|
|
|
2014-02-15 16:55:18 +00:00
|
|
|
namespace CSVWorld
|
|
|
|
{
|
2014-09-01 08:52:10 +00:00
|
|
|
class ScriptEdit : public QPlainTextEdit
|
2014-02-15 16:55:18 +00:00
|
|
|
{
|
2014-02-15 18:52:40 +00:00
|
|
|
Q_OBJECT
|
2014-08-21 12:50:13 +00:00
|
|
|
|
2014-02-15 18:52:40 +00:00
|
|
|
public:
|
2014-08-21 12:50:13 +00:00
|
|
|
|
|
|
|
class ChangeLock
|
|
|
|
{
|
|
|
|
ScriptEdit& mEdit;
|
|
|
|
|
|
|
|
ChangeLock (const ChangeLock&);
|
|
|
|
ChangeLock& operator= (const ChangeLock&);
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
ChangeLock (ScriptEdit& edit);
|
|
|
|
~ChangeLock();
|
|
|
|
};
|
|
|
|
|
|
|
|
friend class ChangeLock;
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
int mChangeLocked;
|
2014-08-22 10:49:34 +00:00
|
|
|
ScriptHighlighter *mHighlighter;
|
|
|
|
QTimer mUpdateTimer;
|
2014-08-21 12:50:13 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2014-08-24 15:56:20 +00:00
|
|
|
ScriptEdit (const CSMDoc::Document& document, ScriptHighlighter::Mode mode,
|
|
|
|
QWidget* parent);
|
2014-02-15 18:52:40 +00:00
|
|
|
|
2014-08-21 12:50:13 +00:00
|
|
|
/// 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;
|
|
|
|
|
2014-02-15 18:52:40 +00:00
|
|
|
private:
|
2014-02-15 19:49:09 +00:00
|
|
|
QVector<CSMWorld::UniversalId::Type> mAllowedTypes;
|
2014-02-16 08:51:33 +00:00
|
|
|
const CSMDoc::Document& mDocument;
|
2014-02-17 07:58:55 +00:00
|
|
|
const QRegExp mWhiteListQoutes;
|
2014-02-15 19:49:09 +00:00
|
|
|
|
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;
|
2014-08-22 10:49:34 +00:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
|
|
|
void idListChanged();
|
|
|
|
|
|
|
|
void updateHighlighting();
|
2014-02-15 16:55:18 +00:00
|
|
|
};
|
|
|
|
}
|
2014-02-15 21:14:27 +00:00
|
|
|
#endif // SCRIPTEDIT_H
|