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

Public Functions

void _q_ensureVisible (QRectF)
 
bool _q_mouseOnEdge (QGraphicsSceneMouseEvent *)
 
void _q_update (QRectF)
 
void _q_updateBoundingRect (const QSizeF &)
 
QPointF controlOffset () const
 
 QGraphicsTextItemPrivate ()
 
void sendControlEvent (QEvent *e)
 
QTextControltextControl () const
 

Public Variables

QRectF boundingRect
 
uint clickCausedFocus: 1
 
QTextControlcontrol
 
int pageNumber
 
QGraphicsTextItemqq
 
bool tabChangesFocus
 
bool useDefaultImpl
 

Detailed Description

Definition at line 10403 of file qgraphicsitem.cpp.

Constructors and Destructors

◆ QGraphicsTextItemPrivate()

QGraphicsTextItemPrivate::QGraphicsTextItemPrivate ( )
inline

Functions

◆ _q_ensureVisible()

void QGraphicsTextItemPrivate::_q_ensureVisible ( QRectF  rect)
Warning
This function is not part of the public interface.

Definition at line 11050 of file qgraphicsitem.cpp.

11051 {
11052  if (qq->hasFocus()) {
11053  rect.translate(-controlOffset());
11054  qq->ensureVisible(rect, /*xmargin=*/0, /*ymargin=*/0);
11055  }
11056 }
bool hasFocus() const
Returns true if this item is active, and it or its focus proxy has keyboard input focus; otherwise...
void ensureVisible(const QRectF &rect=QRectF(), int xmargin=50, int ymargin=50)
If this item is part of a scene that is viewed by a QGraphicsView, this convenience function will att...
void translate(qreal dx, qreal dy)
Moves the rectangle dx along the x-axis and dy along the y-axis, relative to the current position...
Definition: qrect.h:716
QGraphicsTextItem * qq

◆ _q_mouseOnEdge()

bool QGraphicsTextItemPrivate::_q_mouseOnEdge ( QGraphicsSceneMouseEvent event)
Warning
This function is not part of the public interface.

Definition at line 11091 of file qgraphicsitem.cpp.

Referenced by QGraphicsTextItem::mousePressEvent().

11092 {
11093  QPainterPath path;
11094  path.addRect(qq->boundingRect());
11095 
11096  QPainterPath docPath;
11098  docPath.addRect(
11100  format.leftMargin(),
11101  format.topMargin(),
11102  -format.rightMargin(),
11103  -format.bottomMargin()));
11104 
11105  return path.subtracted(docPath).contains(event->pos());
11106 }
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
QPainterPath subtracted(const QPainterPath &r) const
Returns a path which is p's fill area subtracted from this path's fill area.
qreal leftMargin() const
Returns the width of the frame's left margin in pixels.
bool contains(const QPointF &pt) const
Returns true if the given point is inside the path, otherwise returns false.
QTextFrame * rootFrame() const
Returns the document's root frame.
qreal topMargin() const
Returns the width of the frame's top margin in pixels.
qreal bottomMargin() const
Returns the width of the frame's bottom margin in pixels.
void addRect(const QRectF &rect)
Adds the given rectangle to this path as a closed subpath.
QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
Definition: qrect.h:781
QTextDocument * document() const
qreal rightMargin() const
Returns the width of the frame's right margin in pixels.
The QTextFrameFormat class provides formatting information for frames in a QTextDocument.
Definition: qtextformat.h:727
QPointF pos() const
Returns the mouse cursor position in item coordinates.
QRectF boundingRect() const
Reimplemented Function
QGraphicsTextItem * qq
QTextFrameFormat frameFormat() const
Returns the frame's format.
Definition: qtextobject.h:131

◆ _q_update()

void QGraphicsTextItemPrivate::_q_update ( QRectF  rect)
Warning
This function is not part of the public interface.

Definition at line 11021 of file qgraphicsitem.cpp.

11022 {
11023  if (rect.isValid()) {
11024  rect.translate(-controlOffset());
11025  } else {
11026  rect = boundingRect;
11027  }
11028  if (rect.intersects(boundingRect))
11029  qq->update(rect);
11030 }
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:661
bool intersects(const QRectF &r) const
Returns true if this rectangle intersects with the given rectangle (i.
Definition: qrect.cpp:2744
void update(const QRectF &rect=QRectF())
Schedules a redraw of the area covered by rect in this item.
void translate(qreal dx, qreal dy)
Moves the rectangle dx along the x-axis and dy along the y-axis, relative to the current position...
Definition: qrect.h:716
QGraphicsTextItem * qq

◆ _q_updateBoundingRect()

void QGraphicsTextItemPrivate::_q_updateBoundingRect ( const QSizeF size)
Warning
This function is not part of the public interface.

Definition at line 11035 of file qgraphicsitem.cpp.

Referenced by QGraphicsTextItem::setDocument(), and textControl().

11036 {
11037  if (!control) return; // can't happen
11038  const QSizeF pageSize = control->document()->pageSize();
11039  // paged items have a constant (page) size
11040  if (size == boundingRect.size() || pageSize.height() != -1)
11041  return;
11043  boundingRect.setSize(size);
11044  qq->update();
11045 }
QSizeF pageSize
the page size that should be used for laying out the document
qreal height() const
Returns the height.
Definition: qsize.h:287
void update(const QRectF &rect=QRectF())
Schedules a redraw of the area covered by rect in this item.
The QSizeF class defines the size of a two-dimensional object using floating point precision...
Definition: qsize.h:202
void setSize(const QSizeF &s)
Sets the size of the rectangle to the given size.
Definition: qrect.h:790
QTextDocument * document() const
void prepareGeometryChange()
Prepares the item for a geometry change.
QSizeF size() const
Returns the size of the rectangle.
Definition: qrect.h:713
QGraphicsTextItem * qq

◆ controlOffset()

QPointF QGraphicsTextItemPrivate::controlOffset ( ) const
inline

Definition at line 10413 of file qgraphicsitem.cpp.

Referenced by QGraphicsTextItem::inputMethodQuery(), and QGraphicsTextItem::paint().

10414  { return QPointF(0., pageNumber * control->document()->pageSize().height()); }
QSizeF pageSize
the page size that should be used for laying out the document
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
qreal height() const
Returns the height.
Definition: qsize.h:287
QTextDocument * document() const

◆ sendControlEvent()

void QGraphicsTextItemPrivate::sendControlEvent ( QEvent e)
inline

◆ textControl()

QTextControl * QGraphicsTextItemPrivate::textControl ( ) const

Definition at line 11058 of file qgraphicsitem.cpp.

Referenced by QGraphicsTextItem::defaultTextColor(), QGraphicsTextItem::document(), QGraphicsTextItem::setDefaultTextColor(), QGraphicsTextItem::setDocument(), QGraphicsTextItem::setFont(), QGraphicsTextItem::setHtml(), QGraphicsTextItem::setOpenExternalLinks(), QGraphicsTextItem::setPlainText(), QGraphicsTextItem::setTextCursor(), QGraphicsTextItem::setTextInteractionFlags(), and QGraphicsTextItem::setTextWidth().

11059 {
11060  if (!control) {
11061  QGraphicsTextItem *that = const_cast<QGraphicsTextItem *>(qq);
11062  control = new QTextControl(that);
11064 
11065  QObject::connect(control, SIGNAL(updateRequest(QRectF)),
11066  qq, SLOT(_q_update(QRectF)));
11067  QObject::connect(control, SIGNAL(documentSizeChanged(QSizeF)),
11069  QObject::connect(control, SIGNAL(visibilityRequest(QRectF)),
11071  QObject::connect(control, SIGNAL(linkActivated(QString)),
11072  qq, SIGNAL(linkActivated(QString)));
11073  QObject::connect(control, SIGNAL(linkHovered(QString)),
11074  qq, SIGNAL(linkHovered(QString)));
11075 
11076  const QSizeF pgSize = control->document()->pageSize();
11077  if (pgSize.height() != -1) {
11079  that->dd->boundingRect.setSize(pgSize);
11080  qq->update();
11081  } else {
11082  that->dd->_q_updateBoundingRect(control->size());
11083  }
11084  }
11085  return control;
11086 }
QSizeF pageSize
the page size that should be used for laying out the document
QSizeF size() const
void setTextInteractionFlags(Qt::TextInteractionFlags flags)
#define SLOT(a)
Definition: qobjectdefs.h:226
qreal height() const
Returns the height.
Definition: qsize.h:287
void _q_updateBoundingRect(const QSizeF &)
The QString class provides a Unicode character string.
Definition: qstring.h:83
void update(const QRectF &rect=QRectF())
Schedules a redraw of the area covered by rect in this item.
The QGraphicsTextItem class provides a text item that you can add to a QGraphicsScene to display form...
The QSizeF class defines the size of a two-dimensional object using floating point precision...
Definition: qsize.h:202
#define SIGNAL(a)
Definition: qobjectdefs.h:227
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
void setSize(const QSizeF &s)
Sets the size of the rectangle to the given size.
Definition: qrect.h:790
QTextDocument * document() const
void prepareGeometryChange()
Prepares the item for a geometry change.
QGraphicsTextItemPrivate * dd
QGraphicsTextItem * qq

Properties

◆ boundingRect

QRectF QGraphicsTextItemPrivate::boundingRect

◆ clickCausedFocus

uint QGraphicsTextItemPrivate::clickCausedFocus

◆ control

QTextControl* QGraphicsTextItemPrivate::control
mutable

◆ pageNumber

int QGraphicsTextItemPrivate::pageNumber

Definition at line 10424 of file qgraphicsitem.cpp.

◆ qq

QGraphicsTextItem* QGraphicsTextItemPrivate::qq

Definition at line 10430 of file qgraphicsitem.cpp.

Referenced by QGraphicsTextItem::QGraphicsTextItem().

◆ tabChangesFocus

bool QGraphicsTextItemPrivate::tabChangesFocus

◆ useDefaultImpl

bool QGraphicsTextItemPrivate::useDefaultImpl

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