Qt 4.8
Public Functions | Public Variables | List of all members
QTextEditPrivate Class Reference

#include <qtextedit_p.h>

Inheritance diagram for QTextEditPrivate:
QAbstractScrollAreaPrivate QFramePrivate QWidgetPrivate QObjectPrivate QObjectData QTextBrowserPrivate

Public Functions

void _q_adjustScrollbars ()
 
void _q_currentCharFormatChanged (const QTextCharFormat &format)
 
void _q_ensureVisible (const QRectF &rect)
 
void _q_repaintContents (const QRectF &contentsRect)
 
void createAutoBulletList ()
 
int horizontalOffset () const
 
void init (const QString &html=QString())
 
QPoint mapToContents (const QPoint &point) const
 
void pageUpDown (QTextCursor::MoveOperation op, QTextCursor::MoveMode moveMode)
 
void paint (QPainter *p, QPaintEvent *e)
 
 QTextEditPrivate ()
 
void relayoutDocument ()
 
virtual QUrl resolveUrl (const QUrl &url) const
 
void sendControlEvent (QEvent *e)
 
void updateDefaultTextOption ()
 
int verticalOffset () const
 
- Public Functions inherited from QAbstractScrollAreaPrivate
void _q_hslide (int)
 
void _q_showOrHideScrollBars ()
 
void _q_vslide (int)
 
virtual QPoint contentsOffset () const
 
void init ()
 
void layoutChildren ()
 
 QAbstractScrollAreaPrivate ()
 
void replaceScrollBar (QScrollBar *scrollBar, Qt::Orientation orientation)
 
virtual void scrollBarPolicyChanged (Qt::Orientation, Qt::ScrollBarPolicy)
 
void setSingleFingerPanEnabled (bool on=true)
 
bool viewportEvent (QEvent *event)
 
- Public Functions inherited from QFramePrivate
void init ()
 
 QFramePrivate ()
 
void updateFrameWidth ()
 Updated the frameWidth parameter. More...
 
void updateStyledFrameWidths ()
 Updates the frame widths from the style. More...
 
- Public Functions inherited from QWidgetPrivate
void _q_showIfNotHidden ()
 
virtual void aboutToDestroy ()
 
void activateChildLayoutsRecursively ()
 
QSize adjustedSize () const
 
void adjustQuitOnCloseAttribute ()
 
QInputContextassignedInputContext () const
 
QPainterbeginSharedPainter ()
 
QWidgetchildAt_helper (const QPoint &, bool) const
 
QWidgetchildAtRecursiveHelper (const QPoint &p, bool, bool includeFrame=false) const
 
QRect clipRect () const
 
QRegion clipRegion () const
 
void clipToEffectiveMask (QRegion &region) const
 
bool close_helper (CloseMode mode)
 
void create_sys (WId window, bool initializeWindow, bool destroyOldWindow)
 
QWindowSurfacecreateDefaultWindowSurface ()
 
QWindowSurfacecreateDefaultWindowSurface_sys ()
 
void createExtra ()
 Creates the widget extra data. More...
 
void createRecursively ()
 
void createSysExtra ()
 
void createTLExtra ()
 
void createTLSysExtra ()
 
void createWinId (WId id=0)
 
void deactivateWidgetCleanup ()
 
void deleteExtra ()
 Deletes the widget extra data. More...
 
void deleteSysExtra ()
 
void deleteTLSysExtra ()
 
void drawWidget (QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, int flags, QPainter *sharedPainter=0, QWidgetBackingStore *backingStore=0)
 
QWidgeteffectiveFocusWidget ()
 
QRect effectiveRectFor (const QRect &rect) const
 
bool endSharedPainter ()
 
void enforceNativeChildren ()
 
QWExtraextraData () const
 
QRect frameStrut () const
 
void getLayoutItemMargins (int *left, int *top, int *right, int *bottom) const
 
const QRegiongetOpaqueChildren () const
 
void handleSoftwareInputPanel (Qt::MouseButton button, bool clickCausedFocus)
 
virtual bool hasHeightForWidth () const
 
void hide_helper ()
 
void hide_sys ()
 Platform-specific part of QWidget::hide(). More...
 
void hideChildren (bool spontaneous)
 
void inheritStyle ()
 
void init (QWidget *desktopWidget, Qt::WindowFlags f)
 
QInputContextinputContext () const
 
void invalidateBuffer (const QRegion &)
 Invalidates the rgn (in widget's coordinates) of the backing store, i.e. More...
 
void invalidateBuffer (const QRect &)
 This function is equivalent to calling invalidateBuffer(QRegion(rect), ...), but is more efficient as it eliminates QRegion operations/allocations and can use the rect more precisely for additional cut-offs. More...
 
void invalidateBuffer_resizeHelper (const QPoint &oldPos, const QSize &oldSize)
 Invalidates the buffer when the widget is resized. More...
 
void invalidateGraphicsEffectsRecursively ()
 
bool isAboutToShow () const
 
bool isBackgroundInherited () const
 
bool isOverlapped (const QRect &) const
 
void lower_sys ()
 
QPoint mapFromGlobal (const QPoint &pos) const
 
QPoint mapToGlobal (const QPoint &pos) const
 
QWidgetBackingStoremaybeBackingStore () const
 
QTLWExtramaybeTopData () const
 
void moveRect (const QRect &, int dx, int dy)
 
bool nativeChildrenForced () const
 
QFont naturalWidgetFont (uint inheritedMask) const
 
QPalette naturalWidgetPalette (uint inheritedMask) const
 Returns the palette that the widget w inherits from its ancestors and QApplication::palette. More...
 
void paintBackground (QPainter *, const QRegion &, int flags=DrawAsRoot) const
 
bool paintOnScreen () const
 
void paintSiblingsRecursive (QPaintDevice *pdev, const QObjectList &children, int index, const QRegion &rgn, const QPoint &offset, int flags, QPainter *sharedPainter, QWidgetBackingStore *backingStore)
 
bool pointInsideRectAndMask (const QPoint &) const
 
QRegion prepareToRender (const QRegion &region, QWidget::RenderFlags renderFlags)
 
void propagatePaletteChange ()
 Propagate this widget's palette to all children, except style sheet widgets, and windows that don't enable window propagation (palettes don't normally propagate to windows). More...
 
 QWidgetPrivate (int version=QObjectPrivateVersion)
 
void raise_sys ()
 
QPaintDeviceredirected (QPoint *offset) const
 
void registerDropSite (bool)
 
void render (QPaintDevice *target, const QPoint &targetOffset, const QRegion &sourceRegion, QWidget::RenderFlags renderFlags, bool readyToRender)
 
void render_helper (QPainter *painter, const QPoint &targetOffset, const QRegion &sourceRegion, QWidget::RenderFlags renderFlags)
 
void repaint_sys (const QRegion &rgn)
 
void reparentFocusWidgets (QWidget *oldtlw)
 
void resolveFont ()
 Determine which font is implicitly imposed on this widget by its ancestors and QApplication::font, resolve this against its own font (attributes from the implicit font are copied over). More...
 
void resolveLayoutDirection ()
 
void resolveLocale ()
 
void resolvePalette ()
 Determine which palette is inherited from this widget's ancestors and QApplication::palette, resolve this against this widget's palette (attributes from the inherited palette are copied over this widget's palette). More...
 
void restoreRedirected ()
 
void scroll_sys (int dx, int dy)
 
void scroll_sys (int dx, int dy, const QRect &r)
 
void scrollChildren (int dx, int dy)
 
void scrollRect (const QRect &, int dx, int dy)
 
void sendPendingMoveAndResizeEvents (bool recursive=false, bool disableUpdates=false)
 
void sendStartupMessage (const char *message) const
 Platform-specific part of QWidget::show(). More...
 
void setConstraints_sys ()
 
void setCursor_sys (const QCursor &cursor)
 
void setDirtyOpaqueRegion ()
 
void setEnabled_helper (bool)
 
void setFocus_sys ()
 
void setFont_helper (const QFont &font)
 
void setGeometry_sys (int, int, int, int, bool)
 
void setLayoutDirection_helper (Qt::LayoutDirection)
 
void setLayoutItemMargins (int left, int top, int right, int bottom)
 
void setLayoutItemMargins (QStyle::SubElement element, const QStyleOption *opt=0)
 
void setLocale_helper (const QLocale &l, bool forceUpdate=false)
 
void setMask_sys (const QRegion &)
 
bool setMaximumSize_helper (int &maxw, int &maxh)
 
bool setMinimumSize_helper (int &minw, int &minh)
 
void setModal_sys ()
 
void setNetWmWindowTypes ()
 
void setOpaque (bool opaque)
 
void setPalette_helper (const QPalette &)
 
void setParent_sys (QWidget *parent, Qt::WindowFlags)
 
void setRedirected (QPaintDevice *replacement, const QPoint &offset)
 
void setSharedPainter (QPainter *painter)
 
void setStyle_helper (QStyle *newStyle, bool propagate, bool metalHack=false)
 
void setUpdatesEnabled_helper (bool)
 
void setWindowFilePath_helper (const QString &filePath)
 
void setWindowIcon_helper ()
 
void setWindowIcon_sys (bool forceReset=false)
 
void setWindowIconText_helper (const QString &cap)
 
void setWindowIconText_sys (const QString &cap)
 
void setWindowOpacity_sys (qreal opacity)
 
void setWindowRole ()
 
void setWindowTitle_helper (const QString &cap)
 
void setWindowTitle_sys (const QString &cap)
 
void setWinId (WId)
 
QPaintersharedPainter () const
 
void show_helper ()
 
void show_recursive ()
 Makes the widget visible in the isVisible() meaning of the word. More...
 
void show_sys ()
 Platform-specific part of QWidget::show(). More...
 
void showChildren (bool spontaneous)
 
void stackUnder_sys (QWidget *)
 
void subtractOpaqueChildren (QRegion &rgn, const QRect &clipRect) const
 
void subtractOpaqueSiblings (QRegion &source, bool *hasDirtySiblingsAbove=0, bool alsoNonOpaque=false) const
 
void syncBackingStore ()
 
void syncBackingStore (const QRegion &region)
 
QTLWExtratopData () const
 
void unsetCursor_sys ()
 
void updateFont (const QFont &)
 Assign font to this widget, and propagate it to all children, except style sheet widgets (handled differently) and windows that don't enable window propagation. More...
 
void updateFrameStrut ()
 Computes the frame rectangle when needed. More...
 
void updateGeometry_helper (bool forceUpdate)
 
void updateIsOpaque ()
 
void updateIsTranslucent ()
 
void updateSystemBackground ()
 
void updateX11AcceptFocus ()
 
void x11UpdateIsOpaque ()
 
 ~QWidgetPrivate ()
 
- Public Functions inherited from QObjectPrivate
void _q_reregisterTimers (void *pointer)
 
void addConnection (int signal, Connection *c)
 
void cleanConnectionLists ()
 
void connectNotify (const char *signal)
 
void deleteChildren ()
 
void disconnectNotify (const char *signal)
 
bool isSender (const QObject *receiver, const char *signal) const
 
bool isSignalConnected (uint signalIdx) const
 Returns true if the signal with index signal_index from object sender is connected. More...
 
void moveToThread_helper ()
 
 QObjectPrivate (int version=QObjectPrivateVersion)
 
QObjectList receiverList (const char *signal) const
 
QObjectList senderList () const
 
void setParent_helper (QObject *)
 
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData)
 
int signalIndex (const char *signalName) const
 Returns the signal index used in the internal connectionLists vector. More...
 
virtual ~QObjectPrivate ()
 
- Public Functions inherited from QObjectData
virtual ~QObjectData ()=0
 

Public Variables

QString anchorToScrollToWhenVisible
 
QTextEdit::AutoFormatting autoFormatting
 
QPoint autoScrollDragPos
 
QBasicTimer autoScrollTimer
 
uint clickCausedFocus: 1
 
QTextControlcontrol
 
uint ignoreAutomaticScrollbarAdjustment: 1
 
uint inDrag: 1
 
QTextEdit::LineWrapMode lineWrap
 
int lineWrapColumnOrWidth
 
uint preferRichText: 1
 
uint showCursorOnInitialShow: 1
 
bool tabChangesFocus
 
Qt::TextFormat textFormat
 
QTextOption::WrapMode wordWrap
 
- Public Variables inherited from QAbstractScrollAreaPrivate
int bottom
 
QRect cornerPaintingRect
 
QWidgetcornerWidget
 
QScrollBarhbar
 
Qt::ScrollBarPolicy hbarpolicy
 
int left
 
QRect reverseCornerPaintingRect
 
int right
 
QAbstractScrollAreaScrollBarContainerscrollBarContainers [Qt::Vertical+1]
 
bool singleFingerPanEnabled
 
int top
 
QScrollBarvbar
 
Qt::ScrollBarPolicy vbarpolicy
 
QWidgetviewport
 
QScopedPointer< QObjectviewportFilter
 
int xoffset
 
int yoffset
 
- Public Variables inherited from QFramePrivate
short bottomFrameWidth
 
int frameStyle
 
short frameWidth
 
QRect frect
 
short leftFrameWidth
 
short lineWidth
 
short midLineWidth
 
short rightFrameWidth
 
short topFrameWidth
 
- Public Variables inherited from QWidgetPrivate
QString accessibleDescription
 
QString accessibleName
 
QList< QAction * > actions
 
QPalette::ColorRole bg_role: 8
 
signed char bottomLayoutItemMargin
 
short bottommargin
 
QWidgetData data
 
QRegion dirty
 
uint dirtyOpaqueChildren: 1
 
QWExtraextra
 
QPaintEngineextraPaintEngine
 
QPalette::ColorRole fg_role: 8
 
QWidgetfocus_child
 
QWidgetfocus_next
 
QWidgetfocus_prev
 
QMap< Qt::GestureType, Qt::GestureFlags > gestureContext
 
QGraphicsEffectgraphicsEffect
 
Qt::HANDLE hd
 
uint high_attributes [4]
 
QPointer< QInputContextic
 
Qt::InputMethodHints imHints
 
uint inDirtyList: 1
 
uint inheritedFontResolveMask
 
uint inheritedPaletteResolveMask
 
uint inheritsInputMethodHints: 1
 
uint inSetParent: 1
 
uint isGLWidget: 1
 
uint isMoved: 1
 
uint isOpaque: 1
 
uint isScrolled: 1
 
QLayoutlayout
 
signed char leftLayoutItemMargin
 
short leftmargin
 
QLocale locale
 
QRegionneedsFlush
 
QRegion opaqueChildren
 
Qt::HANDLE picture
 
const QMetaObjectpolished
 
QPaintDeviceredirectDev
 
QPoint redirectOffset
 
signed char rightLayoutItemMargin
 
short rightmargin
 
QSizePolicy size_policy
 
QString statusTip
 
QString toolTip
 
signed char topLayoutItemMargin
 
short topmargin
 
uint usesDoubleBufferedGLContext: 1
 
QString whatsThis
 
QWidgetItemV2widgetItem
 
QX11Info xinfo
 
- Public Variables inherited from QObjectPrivate
union {
   QObject *   currentChildBeingDeleted
 
   QAbstractDeclarativeData *   declarativeData
 
}; 
 
quint32 connectedSignals [2]
 
QObjectConnectionListVectorconnectionLists
 
SendercurrentSender
 
QList< QPointer< QObject > > eventFilters
 
ExtraDataextraData
 
QString objectName
 
Connectionsenders
 
QAtomicPointer< QtSharedPointer::ExternalRefCountData > sharedRefcount
 
QThreadDatathreadData
 
void * unused
 
- Public Variables inherited from QObjectData
uint blockSig: 1
 
QObjectList children
 
uint hasGuards: 1
 
uint inEventHandler: 1
 
uint inThreadChangeEvent: 1
 
uint isWidget: 1
 
QMetaObjectmetaObject
 
uint ownObjectName: 1
 
QObjectparent
 
uint pendTimer: 1
 
int postedEvents
 
QObjectq_ptr
 
uint receiveChildEvents: 1
 
uint sendChildEvents: 1
 
uint unused: 22
 
uint wasDeleted: 1
 

Additional Inherited Members

- Public Types inherited from QWidgetPrivate
enum  CloseMode { CloseNoEvent, CloseWithEvent, CloseWithSpontaneousEvent }
 
enum  Direction { DirectionNorth = 0x01, DirectionEast = 0x10, DirectionSouth = 0x02, DirectionWest = 0x20 }
 
enum  DrawWidgetFlags {
  DrawAsRoot = 0x01, DrawPaintOnScreen = 0x02, DrawRecursive = 0x04, DrawInvisible = 0x08,
  DontSubtractOpaqueChildren = 0x10, DontSetCompositionMode = 0x20, DontDrawOpaqueChildren = 0x40, DontDrawNativeChildren = 0x80
}
 
- Public Types inherited from QObjectPrivate
typedef void(* StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)
 
- Static Public Functions inherited from QWidgetPrivate
static void adjustFlags (Qt::WindowFlags &flags, QWidget *w=0)
 
static QGraphicsProxyWidgetnearestGraphicsProxyWidget (const QWidget *origin)
 Finds the nearest widget embedded in a graphics proxy widget along the chain formed by this widget and its ancestors. More...
 
static int pointToRect (const QPoint &p, const QRect &r)
 
static QRect screenGeometry (const QWidget *widget)
 
- Static Public Functions inherited from QObjectPrivate
static void clearGuards (QObject *)
 
static QObjectPrivateget (QObject *o)
 
static void resetCurrentSender (QObject *receiver, Sender *currentSender, Sender *previousSender)
 
static SendersetCurrentSender (QObject *receiver, Sender *sender)
 
static void signalSignature (const QMetaMethod &signal, QVarLengthArray< char > *result)
 
- Static Public Variables inherited from QWidgetPrivate
static QWidgetSetallWidgets = 0
 
static int instanceCounter = 0
 
static QWidgetkeyboardGrabber = 0
 
static QWidgetMappermapper = 0
 
static int maxInstances = 0
 
static QWidgetmouseGrabber = 0
 

Detailed Description

Definition at line 73 of file qtextedit_p.h.

Constructors and Destructors

◆ QTextEditPrivate()

QTextEditPrivate::QTextEditPrivate ( )

Definition at line 108 of file qtextedit.cpp.

109  : control(0),
114 {
116  preferRichText = false;
118  inDrag = false;
119 }
uint ignoreAutomaticScrollbarAdjustment
Definition: qtextedit_p.h:121
QTextEdit::AutoFormatting autoFormatting
Definition: qtextedit_p.h:111
QTextOption::WrapMode wordWrap
Definition: qtextedit_p.h:119
QTextControl * control
Definition: qtextedit_p.h:109
uint showCursorOnInitialShow
Definition: qtextedit_p.h:123
QTextEdit::LineWrapMode lineWrap
Definition: qtextedit_p.h:117
Qt::TextFormat textFormat
Definition: qtextedit_p.h:128

Functions

◆ _q_adjustScrollbars()

void QTextEditPrivate::_q_adjustScrollbars ( )

Definition at line 258 of file qtextedit.cpp.

Referenced by _q_ensureVisible(), init(), and mapToContents().

259 {
261  return;
262  ignoreAutomaticScrollbarAdjustment = true; // avoid recursion, #106108
263 
264  QSize viewportSize = viewport->size();
265  QSize docSize = documentSize(control);
266 
267  // due to the recursion guard we have to repeat this step a few times,
268  // as adding/removing a scroll bar will cause the document or viewport
269  // size to change
270  // ideally we should loop until the viewport size and doc size stabilize,
271  // but in corner cases they might fluctuate, so we need to limit the
272  // number of iterations
273  for (int i = 0; i < 4; ++i) {
274  hbar->setRange(0, docSize.width() - viewportSize.width());
275  hbar->setPageStep(viewportSize.width());
276 
277  vbar->setRange(0, docSize.height() - viewportSize.height());
278  vbar->setPageStep(viewportSize.height());
279 
280  // if we are in left-to-right mode widening the document due to
281  // lazy layouting does not require a repaint. If in right-to-left
282  // the scroll bar has the value zero and it visually has the maximum
283  // value (it is visually at the right), then widening the document
284  // keeps it at value zero but visually adjusts it to the new maximum
285  // on the right, hence we need an update.
286  if (q_func()->isRightToLeft())
287  viewport->update();
288 
290 
291  const QSize oldViewportSize = viewportSize;
292  const QSize oldDocSize = docSize;
293 
294  // make sure the document is layouted if the viewport width changes
295  viewportSize = viewport->size();
296  if (viewportSize.width() != oldViewportSize.width())
298 
299  docSize = documentSize(control);
300  if (viewportSize == oldViewportSize && docSize == oldDocSize)
301  break;
302  }
304 }
static QSize documentSize(QTextControl *control)
Definition: qtextedit.cpp:238
void relayoutDocument()
Definition: qtextedit.cpp:1434
void setRange(int min, int max)
Sets the slider&#39;s minimum to min and its maximum to max.
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
uint ignoreAutomaticScrollbarAdjustment
Definition: qtextedit_p.h:121
int width() const
Returns the width.
Definition: qsize.h:126
QSize size
the size of the widget excluding any window frame
Definition: qwidget.h:165
QTextControl * control
Definition: qtextedit_p.h:109
int height() const
Returns the height.
Definition: qsize.h:129
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ _q_currentCharFormatChanged()

void QTextEditPrivate::_q_currentCharFormatChanged ( const QTextCharFormat format)

Definition at line 1546 of file qtextedit.cpp.

Referenced by init(), and sendControlEvent().

1547 {
1548  Q_Q(QTextEdit);
1549  emit q->currentCharFormatChanged(fmt);
1550 #ifdef QT3_SUPPORT
1551  // compat signals
1552  emit q->currentFontChanged(fmt.font());
1553  emit q->currentColorChanged(fmt.foreground().color());
1554 #endif
1555 }
#define Q_Q(Class)
Definition: qglobal.h:2483
#define emit
Definition: qobjectdefs.h:76
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ _q_ensureVisible()

void QTextEditPrivate::_q_ensureVisible ( const QRectF rect)

Definition at line 308 of file qtextedit.cpp.

Referenced by init(), and mapToContents().

309 {
310  const QRect rect = _rect.toRect();
311  if ((vbar->isVisible() && vbar->maximum() < rect.bottom())
312  || (hbar->isVisible() && hbar->maximum() < rect.right()))
314  const int visibleWidth = viewport->width();
315  const int visibleHeight = viewport->height();
316  const bool rtl = q_func()->isRightToLeft();
317 
318  if (rect.x() < horizontalOffset()) {
319  if (rtl)
320  hbar->setValue(hbar->maximum() - rect.x());
321  else
322  hbar->setValue(rect.x());
323  } else if (rect.x() + rect.width() > horizontalOffset() + visibleWidth) {
324  if (rtl)
325  hbar->setValue(hbar->maximum() - (rect.x() + rect.width() - visibleWidth));
326  else
327  hbar->setValue(rect.x() + rect.width() - visibleWidth);
328  }
329 
330  if (rect.y() < verticalOffset())
331  vbar->setValue(rect.y());
332  else if (rect.y() + rect.height() > verticalOffset() + visibleHeight)
333  vbar->setValue(rect.y() + rect.height() - visibleHeight);
334 }
int width
the width of the widget excluding any window frame
Definition: qwidget.h:166
bool isVisible() const
Definition: qwidget.h:1005
int horizontalOffset() const
Definition: qtextedit_p.h:93
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
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
int height
the height of the widget excluding any window frame
Definition: qwidget.h:167
QRect toRect() const
Returns a QRect based on the values of this rectangle.
Definition: qrect.h:845
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void _q_adjustScrollbars()
Definition: qtextedit.cpp:258
int verticalOffset() const
Definition: qtextedit_p.h:95
int maximum() const

◆ _q_repaintContents()

void QTextEditPrivate::_q_repaintContents ( const QRectF contentsRect)

Definition at line 193 of file qtextedit.cpp.

Referenced by init().

194 {
195  if (!contentsRect.isValid()) {
196  viewport->update();
197  return;
198  }
199  const int xOffset = horizontalOffset();
200  const int yOffset = verticalOffset();
201  const QRectF visibleRect(xOffset, yOffset, viewport->width(), viewport->height());
202 
203  QRect r = contentsRect.intersected(visibleRect).toAlignedRect();
204  if (r.isEmpty())
205  return;
206 
207  r.translate(-xOffset, -yOffset);
208  viewport->update(r);
209 }
QRect toAlignedRect() const
Returns a QRect based on the values of this rectangle that is the smallest possible integer rectangle...
Definition: qrect.cpp:2817
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:661
int width
the width of the widget excluding any window frame
Definition: qwidget.h:166
int horizontalOffset() const
Definition: qtextedit_p.h:93
QRectF intersected(const QRectF &other) const
Returns the intersection of this rectangle and the given rectangle.
Definition: qrect.h:818
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
int height
the height of the widget excluding any window frame
Definition: qwidget.h:167
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
int verticalOffset() const
Definition: qtextedit_p.h:95
void translate(int dx, int dy)
Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position...
Definition: qrect.h:312

◆ createAutoBulletList()

void QTextEditPrivate::createAutoBulletList ( )

Definition at line 121 of file qtextedit.cpp.

Referenced by mapToContents().

122 {
123  QTextCursor cursor = control->textCursor();
124  cursor.beginEditBlock();
125 
126  QTextBlockFormat blockFmt = cursor.blockFormat();
127 
128  QTextListFormat listFmt;
130  listFmt.setIndent(blockFmt.indent() + 1);
131 
132  blockFmt.setIndent(0);
133  cursor.setBlockFormat(blockFmt);
134 
135  cursor.createList(listFmt);
136 
137  cursor.endEditBlock();
138  control->setTextCursor(cursor);
139 }
void endEditBlock()
Indicates the end of a block of editing operations on the document that should appear as a single ope...
The QTextListFormat class provides formatting information for lists in a QTextDocument.
Definition: qtextformat.h:642
void setTextCursor(const QTextCursor &cursor)
void setIndent(int indent)
Sets the list format&#39;s indentation.
Definition: qtextformat.h:685
QTextList * createList(const QTextListFormat &format)
Creates and returns a new list with the given format, and makes the current paragraph the cursor is i...
QTextBlockFormat blockFormat() const
Returns the block format of the block the cursor is in.
int indent() const
Returns the paragraph&#39;s indent.
Definition: qtextformat.h:590
QTextCursor textCursor() const
void setBlockFormat(const QTextBlockFormat &format)
Sets the block format of the current block (or all blocks that are contained in the selection) to for...
The QTextCursor class offers an API to access and modify QTextDocuments.
Definition: qtextcursor.h:70
void beginEditBlock()
Indicates the start of a block of editing operations on the document that should appear as a single o...
The QTextBlockFormat class provides formatting information for blocks of text in a QTextDocument...
Definition: qtextformat.h:545
QTextControl * control
Definition: qtextedit_p.h:109
void setIndent(int indent)
Sets the paragraph&#39;s indentation.
Definition: qtextformat.h:622
void setStyle(Style style)
Sets the list format&#39;s style.
Definition: qtextformat.h:682

◆ horizontalOffset()

int QTextEditPrivate::horizontalOffset ( ) const
inline

Definition at line 93 of file qtextedit_p.h.

Referenced by _q_ensureVisible(), _q_repaintContents(), mapToContents(), and sendControlEvent().

94  { return q_func()->isRightToLeft() ? (hbar->maximum() - hbar->value()) : hbar->value(); }
int value() const
int maximum() const

◆ init()

void QTextEditPrivate::init ( const QString html = QString())

Definition at line 141 of file qtextedit.cpp.

142 {
143  Q_Q(QTextEdit);
144  control = new QTextEditControl(q);
145  control->setPalette(q->palette());
146 
147  QObject::connect(control, SIGNAL(microFocusChanged()), q, SLOT(updateMicroFocus()));
148  QObject::connect(control, SIGNAL(documentSizeChanged(QSizeF)), q, SLOT(_q_adjustScrollbars()));
150  QObject::connect(control, SIGNAL(visibilityRequest(QRectF)), q, SLOT(_q_ensureVisible(QRectF)));
151  QObject::connect(control, SIGNAL(currentCharFormatChanged(QTextCharFormat)),
153 
154  QObject::connect(control, SIGNAL(textChanged()), q, SIGNAL(textChanged()));
155  QObject::connect(control, SIGNAL(undoAvailable(bool)), q, SIGNAL(undoAvailable(bool)));
156  QObject::connect(control, SIGNAL(redoAvailable(bool)), q, SIGNAL(redoAvailable(bool)));
157  QObject::connect(control, SIGNAL(copyAvailable(bool)), q, SIGNAL(copyAvailable(bool)));
158  QObject::connect(control, SIGNAL(selectionChanged()), q, SIGNAL(selectionChanged()));
159  QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SIGNAL(cursorPositionChanged()));
160 
161  QObject::connect(control, SIGNAL(textChanged()), q, SLOT(updateMicroFocus()));
162 
163  QTextDocument *doc = control->document();
164  // set a null page size initially to avoid any relayouting until the textedit
165  // is shown. relayoutDocument() will take care of setting the page size to the
166  // viewport dimensions later.
167  doc->setPageSize(QSize(0, 0));
169  doc->setDefaultFont(q->font());
170  doc->setUndoRedoEnabled(false); // flush undo buffer.
171  doc->setUndoRedoEnabled(true);
172 
173  if (!html.isEmpty())
174  control->setHtml(html);
175 
176  hbar->setSingleStep(20);
177  vbar->setSingleStep(20);
178 
180  q->setAcceptDrops(true);
181  q->setFocusPolicy(Qt::WheelFocus);
182  q->setAttribute(Qt::WA_KeyCompression);
183  q->setAttribute(Qt::WA_InputMethodEnabled);
184 
185 #ifndef QT_NO_CURSOR
187 #endif
188 #ifdef Q_WS_WIN
190 #endif
191 }
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
Definition: qtextformat.h:372
void setPalette(const QPalette &pal)
#define SLOT(a)
Definition: qobjectdefs.h:226
void setPageSize(const QSizeF &size)
The QSizeF class defines the size of a two-dimensional object using floating point precision...
Definition: qsize.h:202
#define Q_Q(Class)
Definition: qglobal.h:2483
#define SIGNAL(a)
Definition: qobjectdefs.h:227
void _q_currentCharFormatChanged(const QTextCharFormat &format)
Definition: qtextedit.cpp:1546
void _q_repaintContents(const QRectF &contentsRect)
Definition: qtextedit.cpp:193
void setBackgroundRole(QPalette::ColorRole)
Sets the background role of the widget to role.
Definition: qwidget.cpp:4708
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
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
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
void setHtml(const QString &text)
void _q_ensureVisible(const QRectF &rect)
Definition: qtextedit.cpp:308
void setCursor(const QCursor &)
Definition: qwidget.cpp:5290
QTextDocument * document() const
void setDefaultFont(const QFont &font)
Sets the default font to use in the document layout.
QAbstractTextDocumentLayout * documentLayout() const
Returns the document layout for this document.
QTextControl * control
Definition: qtextedit_p.h:109
void setUndoRedoEnabled(bool enable)
void _q_adjustScrollbars()
Definition: qtextedit.cpp:258
The QTextDocument class holds formatted text that can be viewed and edited using a QTextEdit...
void setPaintDevice(QPaintDevice *device)
Sets the paint device used for rendering the document&#39;s layout to the given device.
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
void setSingleFingerPanEnabled(bool on=true)
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ mapToContents()

QPoint QTextEditPrivate::mapToContents ( const QPoint point) const
inline

Definition at line 83 of file qtextedit_p.h.

84  { return QPoint(point.x() + horizontalOffset(), point.y() + verticalOffset()); }
int horizontalOffset() const
Definition: qtextedit_p.h:93
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
int verticalOffset() const
Definition: qtextedit_p.h:95
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128

◆ pageUpDown()

void QTextEditPrivate::pageUpDown ( QTextCursor::MoveOperation  op,
QTextCursor::MoveMode  moveMode 
)

Definition at line 211 of file qtextedit.cpp.

Referenced by mapToContents().

212 {
213  QTextCursor cursor = control->textCursor();
214  bool moved = false;
215  qreal lastY = control->cursorRect(cursor).top();
216  qreal distance = 0;
217  // move using movePosition to keep the cursor's x
218  do {
219  qreal y = control->cursorRect(cursor).top();
220  distance += qAbs(y - lastY);
221  lastY = y;
222  moved = cursor.movePosition(op, moveMode);
223  } while (moved && distance < viewport->height());
224 
225  if (moved) {
226  if (op == QTextCursor::Up) {
227  cursor.movePosition(QTextCursor::Down, moveMode);
229  } else {
230  cursor.movePosition(QTextCursor::Up, moveMode);
232  }
233  }
234  control->setTextCursor(cursor);
235 }
double qreal
Definition: qglobal.h:1193
void setTextCursor(const QTextCursor &cursor)
void triggerAction(SliderAction action)
Triggers a slider action.
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
QTextCursor textCursor() const
The QTextCursor class offers an API to access and modify QTextDocuments.
Definition: qtextcursor.h:70
static int distance(QWidget *source, QWidget *target, QAccessible::RelationFlag relation)
QTextControl * control
Definition: qtextedit_p.h:109
bool movePosition(MoveOperation op, MoveMode=MoveAnchor, int n=1)
Moves the cursor by performing the given operation n times, using the specified mode, and returns true if all operations were completed successfully; otherwise returns false.
qreal top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:526
QRectF cursorRect(const QTextCursor &cursor) const

◆ paint()

void QTextEditPrivate::paint ( QPainter p,
QPaintEvent e 
)

Definition at line 1508 of file qtextedit.cpp.

1509 {
1510  const int xOffset = horizontalOffset();
1511  const int yOffset = verticalOffset();
1512 
1513  QRect r = e->rect();
1514  p->translate(-xOffset, -yOffset);
1515  r.translate(xOffset, yOffset);
1516 
1517  QTextDocument *doc = control->document();
1519 
1520  // the layout might need to expand the root frame to
1521  // the viewport if NoWrap is set
1522  if (layout)
1523  layout->setViewport(viewport->rect());
1524 
1525  control->drawContents(p, r, q_func());
1526 
1527  if (layout)
1528  layout->setViewport(QRect());
1529 }
T qobject_cast(QObject *object)
Definition: qobject.h:375
QLayout * layout
Definition: qwidget_p.h:704
int horizontalOffset() const
Definition: qtextedit_p.h:93
QTextDocument * document() const
QRect rect
the internal geometry of the widget excluding any window frame
Definition: qwidget.h:168
QAbstractTextDocumentLayout * documentLayout() const
Returns the document layout for this document.
QTextControl * control
Definition: qtextedit_p.h:109
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
int verticalOffset() const
Definition: qtextedit_p.h:95
The QTextDocument class holds formatted text that can be viewed and edited using a QTextEdit...
void drawContents(QPainter *painter, const QRectF &rect=QRectF(), QWidget *widget=0)
void setViewport(const QRectF &viewport)
const QRect & rect() const
Returns the rectangle that needs to be updated.
Definition: qevent.h:305
void translate(int dx, int dy)
Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position...
Definition: qrect.h:312
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.
Definition: qpainter.cpp:3311

◆ relayoutDocument()

void QTextEditPrivate::relayoutDocument ( )

Definition at line 1434 of file qtextedit.cpp.

Referenced by _q_adjustScrollbars(), and mapToContents().

1435 {
1436  QTextDocument *doc = control->document();
1438 
1439  if (QTextDocumentLayout *tlayout = qobject_cast<QTextDocumentLayout *>(layout)) {
1441  tlayout->setFixedColumnWidth(lineWrapColumnOrWidth);
1442  else
1443  tlayout->setFixedColumnWidth(-1);
1444  }
1445 
1447  QSize lastUsedSize;
1448  if (tlayout)
1449  lastUsedSize = tlayout->dynamicDocumentSize().toSize();
1450  else
1451  lastUsedSize = layout->documentSize().toSize();
1452 
1453  // ignore calls to _q_adjustScrollbars caused by an emission of the
1454  // usedSizeChanged() signal in the layout, as we're calling it
1455  // later on our own anyway (or deliberately not) .
1456  const bool oldIgnoreScrollbarAdjustment = ignoreAutomaticScrollbarAdjustment;
1458 
1459  int width = viewport->width();
1461  width = lineWrapColumnOrWidth;
1462  else if (lineWrap == QTextEdit::NoWrap) {
1463  QVariant alignmentProperty = doc->documentLayout()->property("contentHasAlignment");
1464  if (alignmentProperty.type() == QVariant::Bool && !alignmentProperty.toBool()) {
1465 
1466  width = 0;
1467  }
1468  }
1469 
1470  doc->setPageSize(QSize(width, -1));
1471  if (tlayout)
1472  tlayout->ensureLayouted(verticalOffset() + viewport->height());
1473 
1474  ignoreAutomaticScrollbarAdjustment = oldIgnoreScrollbarAdjustment;
1475 
1476  QSize usedSize;
1477  if (tlayout)
1478  usedSize = tlayout->dynamicDocumentSize().toSize();
1479  else
1480  usedSize = layout->documentSize().toSize();
1481 
1482  // this is an obscure situation in the layout that can happen:
1483  // if a character at the end of a line is the tallest one and therefore
1484  // influencing the total height of the line and the line right below it
1485  // is always taller though, then it can happen that if due to line breaking
1486  // that tall character wraps into the lower line the document not only shrinks
1487  // horizontally (causing the character to wrap in the first place) but also
1488  // vertically, because the original line is now smaller and the one below kept
1489  // its size. So a layout with less width _can_ take up less vertical space, too.
1490  // If the wider case causes a vertical scroll bar to appear and the narrower one
1491  // (narrower because the vertical scroll bar takes up horizontal space)) to disappear
1492  // again then we have an endless loop, as _q_adjustScrollBars sets new ranges on the
1493  // scroll bars, the QAbstractScrollArea will find out about it and try to show/hide
1494  // the scroll bars again. That's why we try to detect this case here and break out.
1495  //
1496  // (if you change this please also check the layoutingLoop() testcase in
1497  // QTextEdit's autotests)
1498  if (lastUsedSize.isValid()
1499  && !vbar->isHidden()
1500  && viewport->width() < lastUsedSize.width()
1501  && usedSize.height() < lastUsedSize.height()
1502  && usedSize.height() <= viewport->height())
1503  return;
1504 
1506 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
T qobject_cast(QObject *object)
Definition: qobject.h:375
int width
the width of the widget excluding any window frame
Definition: qwidget.h:166
QSize toSize() const
Returns an integer based copy of this size.
Definition: qsize.h:355
QLayout * layout
Definition: qwidget_p.h:704
bool toBool() const
Returns the variant as a bool if the variant has type() Bool.
Definition: qvariant.cpp:2691
void setPageSize(const QSizeF &size)
bool isHidden() const
Returns true if the widget is hidden, otherwise returns false.
Definition: qwidget.h:1008
uint ignoreAutomaticScrollbarAdjustment
Definition: qtextedit_p.h:121
QSizeF dynamicDocumentSize() const
int height
the height of the widget excluding any window frame
Definition: qwidget.h:167
virtual QSizeF documentSize() const =0
Returns the total size of the document&#39;s layout.
QTextDocument * document() const
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
QAbstractTextDocumentLayout * documentLayout() const
Returns the document layout for this document.
QTextControl * control
Definition: qtextedit_p.h:109
int height() const
Returns the height.
Definition: qsize.h:129
void _q_adjustScrollbars()
Definition: qtextedit.cpp:258
int verticalOffset() const
Definition: qtextedit_p.h:95
QVariant property(const char *name) const
Returns the value of the object&#39;s name property.
Definition: qobject.cpp:3807
The QTextDocument class holds formatted text that can be viewed and edited using a QTextEdit...
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
QTextEdit::LineWrapMode lineWrap
Definition: qtextedit_p.h:117
The QAbstractTextDocumentLayout class is an abstract base class used to implement custom layouts for ...

◆ resolveUrl()

virtual QUrl QTextEditPrivate::resolveUrl ( const QUrl url) const
inlinevirtual

Reimplemented in QTextBrowserPrivate.

Definition at line 106 of file qtextedit_p.h.

107  { return url; }

◆ sendControlEvent()

void QTextEditPrivate::sendControlEvent ( QEvent e)
inline

Definition at line 98 of file qtextedit_p.h.

int horizontalOffset() const
Definition: qtextedit_p.h:93
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
virtual void processEvent(QEvent *e, const QMatrix &matrix, QWidget *contextWidget=0)
QTextControl * control
Definition: qtextedit_p.h:109
int verticalOffset() const
Definition: qtextedit_p.h:95

◆ updateDefaultTextOption()

void QTextEditPrivate::updateDefaultTextOption ( )

Definition at line 1557 of file qtextedit.cpp.

Referenced by sendControlEvent().

1558 {
1559  QTextDocument *doc = control->document();
1560 
1561  QTextOption opt = doc->defaultTextOption();
1562  QTextOption::WrapMode oldWrapMode = opt.wrapMode();
1563 
1564  if (lineWrap == QTextEdit::NoWrap)
1566  else
1567  opt.setWrapMode(wordWrap);
1568 
1569  if (opt.wrapMode() != oldWrapMode)
1570  doc->setDefaultTextOption(opt);
1571 }
WrapMode
This enum describes how text is wrapped in a document.
Definition: qtextoption.h:102
void setDefaultTextOption(const QTextOption &option)
Sets the default text option.
QTextOption::WrapMode wordWrap
Definition: qtextedit_p.h:119
QTextDocument * document() const
QTextControl * control
Definition: qtextedit_p.h:109
WrapMode wrapMode() const
Returns the text wrap mode defined by the option.
Definition: qtextoption.h:110
The QTextOption class provides a description of general rich text properties.
Definition: qtextoption.h:59
The QTextDocument class holds formatted text that can be viewed and edited using a QTextEdit...
void setWrapMode(WrapMode wrap)
Sets the option&#39;s text wrap mode to the given mode.
Definition: qtextoption.h:109
QTextEdit::LineWrapMode lineWrap
Definition: qtextedit_p.h:117
QTextOption defaultTextOption() const
the default text option will be set on all QTextLayout in the document.

◆ verticalOffset()

int QTextEditPrivate::verticalOffset ( ) const
inline

Definition at line 95 of file qtextedit_p.h.

Referenced by _q_ensureVisible(), _q_repaintContents(), mapToContents(), and sendControlEvent().

96  { return vbar->value(); }
int value() const

Properties

◆ anchorToScrollToWhenVisible

QString QTextEditPrivate::anchorToScrollToWhenVisible

Definition at line 130 of file qtextedit_p.h.

◆ autoFormatting

QTextEdit::AutoFormatting QTextEditPrivate::autoFormatting

Definition at line 111 of file qtextedit_p.h.

◆ autoScrollDragPos

QPoint QTextEditPrivate::autoScrollDragPos

Definition at line 115 of file qtextedit_p.h.

◆ autoScrollTimer

QBasicTimer QTextEditPrivate::autoScrollTimer

Definition at line 114 of file qtextedit_p.h.

◆ clickCausedFocus

uint QTextEditPrivate::clickCausedFocus

Definition at line 125 of file qtextedit_p.h.

◆ control

QTextControl* QTextEditPrivate::control

◆ ignoreAutomaticScrollbarAdjustment

uint QTextEditPrivate::ignoreAutomaticScrollbarAdjustment

Definition at line 121 of file qtextedit_p.h.

Referenced by _q_adjustScrollbars(), and QTextEditPrivate().

◆ inDrag

uint QTextEditPrivate::inDrag

Definition at line 124 of file qtextedit_p.h.

Referenced by QTextEditPrivate().

◆ lineWrap

QTextEdit::LineWrapMode QTextEditPrivate::lineWrap

Definition at line 117 of file qtextedit_p.h.

◆ lineWrapColumnOrWidth

int QTextEditPrivate::lineWrapColumnOrWidth

Definition at line 118 of file qtextedit_p.h.

◆ preferRichText

uint QTextEditPrivate::preferRichText

Definition at line 122 of file qtextedit_p.h.

Referenced by QTextEditPrivate().

◆ showCursorOnInitialShow

uint QTextEditPrivate::showCursorOnInitialShow

Definition at line 123 of file qtextedit_p.h.

Referenced by QTextEditPrivate().

◆ tabChangesFocus

bool QTextEditPrivate::tabChangesFocus

Definition at line 112 of file qtextedit_p.h.

◆ textFormat

Qt::TextFormat QTextEditPrivate::textFormat

Definition at line 128 of file qtextedit_p.h.

◆ wordWrap

QTextOption::WrapMode QTextEditPrivate::wordWrap

Definition at line 119 of file qtextedit_p.h.


The documentation for this class was generated from the following files: