OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
scriptedit.hpp
Go to the documentation of this file.
1 #ifndef SCRIPTEDIT_H
2 #define SCRIPTEDIT_H
3 
4 #include <QPlainTextEdit>
5 #include <QWidget>
6 #include <QVector>
7 #include <QTimer>
8 #include <QFont>
9 
10 #include "../../model/world/universalid.hpp"
11 
12 #include "scripthighlighter.hpp"
13 
14 class QRegExp;
15 
16 namespace CSMDoc
17 {
18  class Document;
19 }
20 
21 namespace CSVWorld
22 {
23  class LineNumberArea;
24 
26  class ScriptEdit : public QPlainTextEdit
27  {
28  Q_OBJECT
29 
30  public:
31 
32  class ChangeLock
33  {
35 
36  ChangeLock (const ChangeLock&);
38 
39  public:
40 
41  ChangeLock (ScriptEdit& edit);
42  ~ChangeLock();
43  };
44 
45  friend class ChangeLock;
46 
47  private:
48 
51  QTimer mUpdateTimer;
54  QFont mDefaultFont;
55  QFont mMonoFont;
57 
58  protected:
59 
60  bool event (QEvent *event);
61 
62  public:
63 
65  QWidget* parent);
66 
70  bool isChangeLocked() const;
71 
72  void lineNumberAreaPaintEvent(QPaintEvent *event);
73  int lineNumberAreaWidth();
74  void showLineNum(bool show);
75 
76  protected:
77 
78  virtual void resizeEvent(QResizeEvent *e);
79 
80  private:
81 
82  QVector<CSMWorld::UniversalId::Type> mAllowedTypes;
84  const QRegExp mWhiteListQoutes;
85 
86  void dragEnterEvent (QDragEnterEvent* event);
87 
88  void dropEvent (QDropEvent* event);
89 
90  void dragMoveEvent (QDragMoveEvent* event);
91 
92  bool stringNeedsQuote(const std::string& id) const;
93 
95  void setTabWidth();
96 
99  void wrapLines(bool wrap);
100 
101  private slots:
102 
105  void settingChanged(const CSMPrefs::Setting *setting);
106 
107  void idListChanged();
108 
109  void updateHighlighting();
110 
111  void updateLineNumberAreaWidth(int newBlockCount);
112 
113  void updateLineNumberArea(const QRect &, int);
114  };
115 
116  class LineNumberArea : public QWidget
117  {
119 
120  public:
121 
122  LineNumberArea(ScriptEdit *editor);
123  QSize sizeHint() const;
124 
125  protected:
126 
127  void paintEvent(QPaintEvent *event);
128  };
129 }
130 #endif // SCRIPTEDIT_H
void updateLineNumberArea(const QRect &, int)
Definition: scriptedit.cpp:276
Mode
Definition: scripthighlighter.hpp:36
void paintEvent(QPaintEvent *event)
Definition: scriptedit.cpp:357
void idListChanged()
Definition: scriptedit.cpp:235
bool isChangeLocked() const
Definition: scriptedit.cpp:124
LineNumberArea(ScriptEdit *editor)
Definition: scriptedit.cpp:349
void dropEvent(QDropEvent *event)
Definition: scriptedit.cpp:153
QFont mMonoFont
Definition: scriptedit.hpp:55
void wrapLines(bool wrap)
Turn line wrapping in script editor on or off.
Definition: scriptedit.cpp:196
LineNumberArea * mLineNumberArea
Definition: scriptedit.hpp:53
QTimer mUpdateTimer
Definition: scriptedit.hpp:51
int mTabCharCount
Definition: scriptedit.hpp:56
void showLineNum(bool show)
Definition: scriptedit.cpp:115
ChangeLock(const ChangeLock &)
virtual void resizeEvent(QResizeEvent *e)
Definition: scriptedit.cpp:287
ScriptEdit * mScriptEdit
Definition: scriptedit.hpp:118
void setTabWidth()
Set tab width for script editor.
Definition: scriptedit.cpp:190
bool stringNeedsQuote(const std::string &id) const
Definition: scriptedit.cpp:183
int wrap(int index, int max)
Definition: race.cpp:24
Definition: scriptedit.hpp:116
void settingChanged(const CSMPrefs::Setting *setting)
Update editor when related setting is changed.
Definition: scriptedit.cpp:208
const QRegExp mWhiteListQoutes
Definition: scriptedit.hpp:84
bool event(QEvent *event)
Definition: scriptedit.cpp:27
void dragMoveEvent(QDragMoveEvent *event)
Definition: scriptedit.cpp:141
~ChangeLock()
Definition: scriptedit.cpp:22
Definition: setting.hpp:22
void updateLineNumberAreaWidth(int newBlockCount)
Definition: scriptedit.cpp:271
Definition: document.hpp:57
const CSMDoc::Document & mDocument
Definition: scriptedit.hpp:83
void lineNumberAreaPaintEvent(QPaintEvent *event)
Definition: scriptedit.cpp:295
ScriptHighlighter * mHighlighter
Definition: scriptedit.hpp:50
QVector< CSMWorld::UniversalId::Type > mAllowedTypes
Definition: scriptedit.hpp:82
int lineNumberAreaWidth()
Definition: scriptedit.cpp:253
QFont mDefaultFont
Definition: scriptedit.hpp:54
int mChangeLocked
Definition: scriptedit.hpp:49
QSize sizeHint() const
Definition: scriptedit.cpp:352
Definition: scriptedit.hpp:32
Definition: scripthighlighter.hpp:21
bool mShowLineNum
Definition: scriptedit.hpp:52
ScriptEdit & mEdit
Definition: scriptedit.hpp:34
ScriptEdit(const CSMDoc::Document &document, ScriptHighlighter::Mode mode, QWidget *parent)
Definition: scriptedit.cpp:41
void dragEnterEvent(QDragEnterEvent *event)
Definition: scriptedit.cpp:129
ChangeLock & operator=(const ChangeLock &)
void updateHighlighting()
Definition: scriptedit.cpp:243
Editor for scripts.
Definition: scriptedit.hpp:26