Qt 4.8
qscriptedit.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtSCriptTools module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qscriptedit_p.h"
44 
45 #include <QtGui/qpainter.h>
46 #include <QtGui/qicon.h>
47 #include <QtGui/qboxlayout.h>
48 #include <QtGui/qlabel.h>
49 #include <QtGui/qlineedit.h>
50 #include <QtGui/qmenu.h>
51 #include <QtGui/qaction.h>
52 #include <QtGui/qwidgetaction.h>
53 #include <QtCore/qdebug.h>
54 
56 
58 {
59 public:
61  : QWidget(edit)
62  {
63  setMouseTracking(true);
64  }
65 
66  QSize sizeHint() const {
67  return QSize(editor()->extraAreaWidth(), 0);
68  }
69 
70 protected:
72  {
73  editor()->extraAreaPaintEvent(event);
74  }
76  {
77  editor()->extraAreaMouseEvent(event);
78  }
80  {
81  editor()->extraAreaMouseEvent(event);
82  }
84  {
85  editor()->extraAreaMouseEvent(event);
86  }
88  {
89  if (editor()->extraAreaEvent(event))
90  return true;
91  return QWidget::event(event);
92  }
93 
94 private:
96  {
97  return qobject_cast<QScriptEdit*>(parent());
98  }
99 };
100 
101 
102 
104  : QPlainTextEdit(parent)
105 {
106  m_baseLineNumber = 1;
108 
109  m_extraArea = new QScriptEditExtraArea(this);
110 
112  this, SLOT(updateExtraAreaWidth()));
114  this, SLOT(updateExtraArea(QRect,int)));
116  this, SLOT(highlightCurrentLine()));
117 
119 
120 #ifndef QT_NO_SYNTAXHIGHLIGHTER
121  (void) new QScriptSyntaxHighlighter(document());
122 #endif
123 }
124 
126 {
127 }
128 
130 {
131  return m_baseLineNumber;
132 }
133 
135 {
137  m_extraArea->update();
138 }
139 
141 {
142  return m_executionLineNumber;
143 }
144 
145 void QScriptEdit::setExecutionLineNumber(int lineNumber, bool error)
146 {
147  m_executionLineNumber = lineNumber;
149  m_extraArea->update();
151  gotoLine(lineNumber);
152 }
153 
155 {
156  m_executableLineNumbers = lineNumbers;
157 }
158 
159 bool QScriptEdit::isExecutableLine(int lineNumber) const
160 {
161 #if 0 // ### enable me once we have information about the script again
162  return m_executableLineNumbers.contains(lineNumber);
163 #else
164  Q_UNUSED(lineNumber);
165  return true;
166 #endif
167 }
168 
170 {
172 }
173 
174 void QScriptEdit::gotoLine(int lineNumber)
175 {
176  int blockNumber = lineNumber - m_baseLineNumber;
177  const QTextBlock &block = document()->findBlockByNumber(blockNumber);
178  if (block.isValid()) {
179  setTextCursor(QTextCursor(block));
180  centerCursor();
181  }
182 }
183 
184 void QScriptEdit::setBreakpoint(int lineNumber)
185 {
186  m_breakpoints[lineNumber] = BreakpointData();
187  m_extraArea->update();
188 }
189 
190 void QScriptEdit::setBreakpointEnabled(int lineNumber, bool enable)
191 {
192  m_breakpoints[lineNumber].enabled = enable;
193  m_extraArea->update();
194 }
195 
196 void QScriptEdit::deleteBreakpoint(int lineNumber)
197 {
198  m_breakpoints.remove(lineNumber);
199  m_extraArea->update();
200 }
201 
203 {
205 }
206 
208 {
210 
211  QRect cr = contentsRect();
212  int x = isLeftToRight() ? cr.left() : cr.left() + cr.width() - extraAreaWidth();
214 }
215 
217 {
218  if (isLeftToRight())
220  else
222 }
223 
225 {
226  if (dy)
227  m_extraArea->scroll(0, dy);
228  else
229  m_extraArea->update(0, rect.y(), m_extraArea->width(), rect.height());
230 
231  if (rect.contains(viewport()->rect()))
233 }
234 
236 {
238 }
239 
241 {
243 
244  {
245  QTextEdit::ExtraSelection selection;
246  QColor lineColor = QColor(Qt::yellow).lighter(160);
247  selection.format.setBackground(lineColor);
249  selection.cursor = textCursor();
250  selection.cursor.clearSelection();
251  extraSelections.append(selection);
252  }
253  if (m_executionLineNumber != -1) {
254  QTextEdit::ExtraSelection selection;
255  QColor lineColor;
257  lineColor = QColor(Qt::red);
258  else
259  lineColor = QColor(Qt::green).lighter(160);
260  selection.format.setBackground(lineColor);
262  int blockNumber = m_executionLineNumber - m_baseLineNumber;
263  selection.cursor = QTextCursor(document()->findBlockByNumber(blockNumber));
264  selection.cursor.clearSelection();
265  extraSelections.append(selection);
266  }
267 
268  setExtraSelections(extraSelections);
269 }
270 
272 {
273  int space = 0;
274  const QFontMetrics fm(fontMetrics());
275 
276  int digits = 1;
277  int max = qMax(1, blockCount() + m_baseLineNumber);
278  while (max >= 10) {
279  max /= 10;
280  ++digits;
281  }
282  space += fm.width(QLatin1Char('9')) * digits;
283 
284  int markWidth = fm.lineSpacing();
285  space += markWidth;
286 
287  space += 4;
288 
289  return space;
290 }
291 
293 {
294  QRect rect = e->rect();
295  QPalette pal = palette();
297  QPainter painter(m_extraArea);
298  painter.fillRect(rect, Qt::lightGray);
299  const QFontMetrics fm(fontMetrics());
300 
301  int markWidth = fm.lineSpacing();
303 
304  QLinearGradient gradient(QPointF(extraAreaWidth - 10, 0), QPointF(extraAreaWidth, 0));
305  gradient.setColorAt(0, pal.color(QPalette::Background));
306  gradient.setColorAt(1, pal.color(QPalette::Base));
307  painter.fillRect(rect, gradient);
308 
309  QLinearGradient gradient2(QPointF(0, 0), QPointF(markWidth, 0));
310  gradient2.setColorAt(0, pal.color(QPalette::Dark));
311  gradient2.setColorAt(1, pal.color(QPalette::Background));
312  painter.fillRect(rect.intersected(QRect(rect.x(), rect.y(), markWidth, rect.height())), gradient2);
313 
314  painter.setPen(QPen(pal.color(QPalette::Background), 2));
315  if (isLeftToRight())
316  painter.drawLine(rect.x() + extraAreaWidth-1, rect.top(), rect.x() + extraAreaWidth-1, rect.bottom());
317  else
318  painter.drawLine(rect.x(), rect.top(), rect.x(), rect.bottom());
320 
321  QTextBlock block = firstVisibleBlock();
322  int blockNumber = block.blockNumber();
324  qreal bottom = top + blockBoundingRect(block).height();
325 
326  QString imagesPath = QString::fromLatin1(":/qt/scripttools/debugging/images");
327  QString imageExt;
328 // SVGs don't work on all platforms, even when QT_NO_SVG is not defined, so disable SVG usage for now.
329 // #ifndef QT_NO_SVG
330 #if 0
331  imageExt = QString::fromLatin1("svg");
332 #else
333  imageExt = QString::fromLatin1("png");
334 #endif
335 
336  while (block.isValid() && top <= rect.bottom()) {
337  if (block.isVisible() && bottom >= rect.top()) {
338 
339  int lineNumber = blockNumber + m_baseLineNumber;
340  if (m_breakpoints.contains(lineNumber)) {
341  int radius = fm.lineSpacing() - 1;
342  QRect r(rect.x(), (int)top, radius, radius);
343  QIcon icon(m_breakpoints[lineNumber].enabled
344  ? QString::fromLatin1("%0/breakpoint.%1").arg(imagesPath).arg(imageExt)
345  : QString::fromLatin1("%0/d_breakpoint.%1").arg(imagesPath).arg(imageExt));
346  icon.paint(&painter, r, Qt::AlignCenter);
347  }
348  if (m_executionLineNumber == lineNumber) {
349  int radius = fm.lineSpacing() - 1;
350  QRect r(rect.x(), (int)top, radius, radius);
351  QIcon icon(QString::fromLatin1("%0/location.%1").arg(imagesPath).arg(imageExt));
352  icon.paint(&painter, r, Qt::AlignCenter);
353  }
354 
355  if (!isExecutableLine(lineNumber))
356  painter.setPen(pal.color(QPalette::Mid));
357  else
358  painter.setPen(QColor(Qt::darkCyan));
359  QString number = QString::number(lineNumber);
360  painter.drawText(rect.x() + markWidth, (int)top, rect.x() + extraAreaWidth - markWidth - 4,
361  fm.height(), Qt::AlignRight, number);
362  }
363 
364  block = block.next();
365  top = bottom;
366  bottom = top + blockBoundingRect(block).height();
367  ++blockNumber;
368  }
369 }
370 
372 {
374  cursor.setPosition(cursor.block().position());
375 
376  QFontMetrics fm(font());
377  int markWidth = fm.lineSpacing();
378 
379  if (e->type() == QEvent::MouseMove && e->buttons() == 0) { // mouse tracking
380  bool hand = (e->pos().x() <= markWidth);
381  int lineNumber = cursor.blockNumber() + m_baseLineNumber;
382  hand = hand && isExecutableLine(lineNumber);
383 #ifndef QT_NO_CURSOR
384  if (hand != (m_extraArea->cursor().shape() == Qt::PointingHandCursor))
386 #endif
387  }
388 
389  if (e->type() == QEvent::MouseButtonPress) {
390  if (e->button() == Qt::LeftButton) {
391  int lineNumber = cursor.blockNumber() + m_baseLineNumber;
392  bool executable = isExecutableLine(lineNumber);
393  if ((e->pos().x() <= markWidth) && executable)
395  else
397  }
398  } else if (e->type() == QEvent::MouseButtonRelease) {
399  if (e->button() == Qt::LeftButton) {
400  if ((m_extraAreaToggleBlockNumber != -1) && (e->pos().x() <= markWidth)) {
402  bool on = !m_breakpoints.contains(lineNumber);
403  emit breakpointToggleRequest(lineNumber, on);
404  }
405  } else if (e->button() == Qt::RightButton) {
406  int lineNumber = cursor.blockNumber() + m_baseLineNumber;
407  if (!isExecutableLine(lineNumber))
408  return;
409  bool has = m_breakpoints.contains(lineNumber);
410  QMenu *popup = new QMenu();
411  QAction *toggleAct = new QAction(tr("Toggle Breakpoint"), popup);
412  popup->addAction(toggleAct);
413  QAction *disableAct = new QAction(tr("Disable Breakpoint"), popup);
414  QAction *enableAct = new QAction(tr("Enable Breakpoint"), popup);
415  QWidget *conditionWidget = new QWidget();
416  {
417  QHBoxLayout *hbox = new QHBoxLayout(conditionWidget);
418  hbox->addWidget(new QLabel(tr("Breakpoint Condition:")));
419  hbox->addWidget(new QLineEdit());
420  }
421 // QWidgetAction *conditionAct = new QWidgetAction(popup);
422 // conditionAct->setDefaultWidget(conditionWidget);
423  if (has) {
424  popup->addSeparator();
425  popup->addAction(m_breakpoints[lineNumber].enabled ? disableAct : enableAct);
426 // popup->addAction(conditionAct);
427  }
428  QAction *ret = popup->exec(e->globalPos());
429  if (ret) {
430  if (ret == toggleAct) {
431  emit breakpointToggleRequest(lineNumber, !has);
432  } else if (ret == disableAct) {
433  emit breakpointEnableRequest(lineNumber, false);
434  } else if (ret == enableAct) {
435  emit breakpointEnableRequest(lineNumber, true);
436  }// else if (ret == conditionAct) {
437  //}
438  }
439  popup->deleteLater();
440  }
441  }
442 }
443 
445 {
446  if (e->type() == QEvent::ToolTip) {
447  // ### show the breakpoint's condition, if any
448  return true;
449  }
450  return false;
451 }
452 
void scroll(int dx, int dy)
Scrolls the widget including its children dx pixels to the right and dy downward. ...
Definition: qwidget.cpp:10684
void breakpointToggleRequest(int lineNumber, bool on)
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
bool enabled
whether the widget is enabled
Definition: qwidget.h:157
void blockCountChanged(int newBlockCount)
This signal is emitted whenever the block count changes.
void setExtraSelections(const QList< QTextEdit::ExtraSelection > &selections)
This function allows temporarily marking certain regions in the document with a given color...
void setViewportMargins(int left, int top, int right, int bottom)
Sets the margins around the scrolling area to left, top, right and bottom.
QRectF blockBoundingGeometry(const QTextBlock &block) const
Returns the bounding rectangle of the text block in content coordinates.
void extraAreaPaintEvent(QPaintEvent *e)
int width(const QString &, int len=-1) const
Returns the width in pixels of the first len characters of text.
double qreal
Definition: qglobal.h:1193
The QFontMetrics class provides font metrics information.
Definition: qfontmetrics.h:65
void setColorAt(qreal pos, const QColor &color)
Creates a stop point at the given position with the given color.
Definition: qbrush.cpp:1475
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
bool extraAreaEvent(QEvent *e)
QCursor cursor() const
void extraAreaMouseEvent(QMouseEvent *e)
void centerCursor()
Scrolls the document in order to center the cursor vertically.
QRect contentsRect() const
Returns the area inside the widget&#39;s margins.
Definition: qwidget.cpp:7544
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.
int m_executionLineNumber
#define error(msg)
QTextCursor cursor
A cursor that contains a selection in a QTextDocument.
Definition: qtextedit.h:224
QTextDocument * document() const
Returns a pointer to the underlying document.
#define SLOT(a)
Definition: qobjectdefs.h:226
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void cursorPositionChanged()
This signal is emitted whenever the position of the cursor changed.
int currentLineNumber() const
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int blockCount() const
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
bool isExecutableLine(int lineNumber) const
QRect intersected(const QRect &other) const
Returns the intersection of this rectangle and the given rectangle.
Definition: qrect.h:481
QTextCursor textCursor() const
Returns a copy of the QTextCursor that represents the currently visible cursor.
void breakpointEnableRequest(int lineNumber, bool enable)
int m_baseLineNumber
void drawLine(const QLineF &line)
Draws a line defined by line.
Definition: qpainter.h:573
void setGeometry(int x, int y, int w, int h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qwidget.h:1017
void setBackground(const QBrush &brush)
Sets the brush use to paint the document&#39;s background to the brush specified.
Definition: qtextformat.h:343
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
The QString class provides a Unicode character string.
Definition: qstring.h:83
T * qobject_cast(QObject *object)
Definition: qobject.h:375
QAction * addAction(const QString &text)
This convenience function creates a new action with text.
Definition: qmenu.cpp:1453
int extraAreaWidth() const
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Definition: qpalette.h:107
void addWidget(QWidget *, int stretch=0, Qt::Alignment alignment=0)
Adds widget to the end of this box layout, with a stretch factor of stretch and alignment alignment...
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
static const uint base
Definition: qurl.cpp:268
void setExecutionLineNumber(int lineNumber, bool error)
virtual void paintEvent(QPaintEvent *e)
Reimplemented Function
void paintEvent(QPaintEvent *event)
This event handler can be reimplemented in a subclass to receive paint events passed in event...
Definition: qscriptedit.cpp:71
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
Definition: qevent.h:95
QScriptEditExtraArea(QScriptEdit *edit)
Definition: qscriptedit.cpp:60
QTextBlock next() const
Returns the text block in the document after this block, or an empty text block if this is the last o...
void updateRequest(const QRect &rect, int dy)
This signal is emitted when the text document needs an update of the specified rect.
QSize sizeHint() const
Definition: qscriptedit.cpp:66
int position() const
Returns the index of the block&#39;s first character within the document.
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
QTextCursor cursorForPosition(const QPoint &pos) const
returns a QTextCursor at position pos (in viewport coordinates).
QWidget * viewport() const
Returns the viewport widget.
void setCurrentColorGroup(ColorGroup cg)
Set the palette&#39;s current color group to cg.
Definition: qpalette.h:105
#define SIGNAL(a)
Definition: qobjectdefs.h:227
void drawText(const QPointF &p, const QString &s)
Draws the given text with the currently defined text direction, beginning at the given position...
Definition: qpainter.cpp:6231
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint...
Definition: qpainter.cpp:7620
bool isVisible() const
Returns true if the block is visible; otherwise returns false.
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
int blockNumber() const
Returns the number of the block the cursor is in, or 0 if the cursor is invalid.
bool contains(const T &value) const
Definition: qset.h:91
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
The QTextCursor class offers an API to access and modify QTextDocuments.
Definition: qtextcursor.h:70
QWidget(QWidget *parent=0, Qt::WindowFlags f=0)
Constructs a widget which is a child of parent, with widget flags set to f.
Definition: qwidget.cpp:1189
int width() const
qreal height() const
Returns the height of the rectangle.
Definition: qrect.h:710
#define emit
Definition: qobjectdefs.h:76
QHash< int, BreakpointData > m_breakpoints
const QPalette & palette() const
QFontMetrics fontMetrics() const
Returns the font metrics for the widget&#39;s current font.
Definition: qwidget.h:984
The QResizeEvent class contains event parameters for resize events.
Definition: qevent.h:349
QRectF blockBoundingRect(const QTextBlock &block) const
Returns the bounding rectangle of the text block in the block&#39;s own coordinates.
QAction * addSeparator()
This convenience function creates a new separator action, i.e.
Definition: qmenu.cpp:1583
The QTextBlock class provides a container for text fragments in a QTextDocument.
Definition: qtextobject.h:199
The QPlainTextEdit class provides a widget that is used to edit and display plain text...
void setCursor(const QCursor &)
Definition: qwidget.cpp:5290
QScriptEditExtraArea * m_extraArea
int m_extraAreaToggleBlockNumber
QScriptEdit(QWidget *parent=0)
Qt::MouseButton button() const
Returns the button that caused the event.
Definition: qevent.h:101
QRect rect() const
QTextBlock findBlockByNumber(int blockNumber) const
Returns the text block with the specified blockNumber.
bool contains(const QPoint &p, bool proper=false) const
Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false...
Definition: qrect.cpp:1101
QTextBlock block() const
Returns the block that contains the cursor.
void clearSelection()
Clears the current selection by setting the anchor to the cursor position.
void resizeEvent(QResizeEvent *e)
Reimplemented Function
void deleteBreakpoint(int lineNumber)
void paintEvent(QPaintEvent *e)
Reimplemented Function
void setMouseTracking(bool enable)
Definition: qwidget.h:990
The QMouseEvent class contains parameters that describe a mouse event.
Definition: qevent.h:85
int executionLineNumber() const
QAction * exec()
Executes this menu synchronously.
Definition: qmenu.cpp:2101
void mousePressEvent(QMouseEvent *event)
This event handler, for event event, can be reimplemented in a subclass to receive mouse press events...
Definition: qscriptedit.cpp:75
QPointF contentOffset() const
Returns the content&#39;s origin in viewport coordinates.
void highlightCurrentLine()
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
void updateExtraAreaWidth()
Qt::MouseButtons buttons() const
Returns the button state when the event was generated.
Definition: qevent.h:102
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
int x() const
The QLinearGradient class is used in combination with QBrush to specify a linear gradient brush...
Definition: qbrush.h:280
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
void setBreakpointEnabled(int lineNumber, bool enable)
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
bool event(QEvent *event)
This is the main event handler; it handles event event.
Definition: qscriptedit.cpp:87
int baseLineNumber() const
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
void setPen(const QColor &color)
Sets the painter&#39;s pen to have style Qt::SolidLine, width 0 and the specified color.
Definition: qpainter.cpp:4047
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QTextEdit::ExtraSelection structure provides a way of specifying a character format for a given s...
Definition: qtextedit.h:222
QList< QTextEdit::ExtraSelection > extraSelections() const
Returns previously set extra selections.
The QLabel widget provides a text or image display.
Definition: qlabel.h:55
virtual void resizeEvent(QResizeEvent *e)
Reimplemented Function
The QHBoxLayout class lines up widgets horizontally.
Definition: qboxlayout.h:129
void updateExtraSelections()
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
friend class QScriptEditExtraArea
The QLineEdit widget is a one-line text editor.
Definition: qlineedit.h:66
int lineSpacing() const
Returns the distance from one base line to the next.
void setTextCursor(const QTextCursor &cursor)
Sets the visible cursor.
void setPosition(int pos, MoveMode mode=MoveAnchor)
Moves the cursor to the absolute position in the document specified by pos using a MoveMode specified...
void setExecutableLineNumbers(const QSet< int > &lineNumbers)
bool isLeftToRight() const
Definition: qwidget.h:429
void mouseMoveEvent(QMouseEvent *event)
This event handler, for event event, can be reimplemented in a subclass to receive mouse move events ...
Definition: qscriptedit.cpp:79
bool isValid() const
Returns true if this text block is valid; otherwise returns false.
Definition: qtextobject.h:208
qreal top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:526
const QFont & font() const
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
void setBreakpoint(int lineNumber)
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
QSet< int > m_executableLineNumbers
void mouseReleaseEvent(QMouseEvent *event)
This event handler, for event event, can be reimplemented in a subclass to receive mouse release even...
Definition: qscriptedit.cpp:83
void updateExtraArea(const QRect &, int)
bool event(QEvent *)
This is the main event handler; it handles event event.
Definition: qwidget.cpp:8636
bool m_executionLineNumberHasError
QRectF translated(qreal dx, qreal dy) const
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis...
Definition: qrect.h:740
QTextCharFormat format
A format that is used to specify a foreground or background brush/color for the selection.
Definition: qtextedit.h:225
const QRect & rect() const
Returns the rectangle that needs to be updated.
Definition: qevent.h:305
int height() const
Returns the height of the font.
QColor lighter(int f=150) const
Returns a lighter (or darker) color, but does not change this object.
Definition: qcolor.h:298
The QPaintEvent class contains event parameters for paint events.
Definition: qevent.h:298
void gotoLine(int lineNumber)
QScriptEdit * editor() const
Definition: qscriptedit.cpp:95
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
const QPoint & globalPos() const
Returns the global position of the mouse cursor at the time of the event.
Definition: qevent.h:96
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
void deleteLater()
Schedules this object for deletion.
Definition: qobject.cpp:2145
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64
int blockNumber() const
Returns the number of this block, or -1 if the block is invalid.
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
Definition: qpainter.cpp:7420
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
void setBaseLineNumber(int base)
void paint(QPainter *painter, const QRect &rect, Qt::Alignment alignment=Qt::AlignCenter, Mode mode=Normal, State state=Off) const
Uses the painter to paint the icon with specified alignment, required mode, and state into the rectan...
Definition: qicon.cpp:744
Qt::CursorShape shape() const
Returns the cursor shape identifier.
Definition: qcursor.cpp:469
QTextBlock firstVisibleBlock() const
Returns the first visible block.
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60