Qt 4.8
Public Slots | Signals | Public Functions | Protected Functions | Properties | List of all members
QTextControl Class Reference

#include <qtextcontrol_p.h>

Inheritance diagram for QTextControl:
QObject QPlainTextEditControl QTextEditControl

Public Slots

void adjustSize ()
 
void append (const QString &text)
 
void appendHtml (const QString &html)
 
void appendPlainText (const QString &text)
 
void clear ()
 
void copy ()
 
void cut ()
 
void insertHtml (const QString &text)
 
void insertPlainText (const QString &text)
 
void paste (QClipboard::Mode mode=QClipboard::Clipboard)
 
void redo ()
 
void selectAll ()
 
void setHtml (const QString &text)
 
void setPlainText (const QString &text)
 
void undo ()
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 

Signals

void blockCountChanged (int newBlockCount)
 
void copyAvailable (bool b)
 
void currentCharFormatChanged (const QTextCharFormat &format)
 
void cursorPositionChanged ()
 
void documentSizeChanged (const QSizeF &)
 
void linkActivated (const QString &link)
 
void linkHovered (const QString &)
 
void microFocusChanged ()
 
void modificationChanged (bool m)
 
void redoAvailable (bool b)
 
void selectionChanged ()
 
void textChanged ()
 
void undoAvailable (bool b)
 
void updateRequest (const QRectF &rect=QRectF())
 
void visibilityRequest (const QRectF &rect)
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 

Public Functions

bool acceptRichText () const
 
QString anchorAt (const QPointF &pos) const
 
QString anchorAtCursor () const
 
QPointF anchorPosition (const QString &name) const
 
virtual QRectF blockBoundingRect (const QTextBlock &block) const
 
virtual bool canInsertFromMimeData (const QMimeData *source) const
 
bool canPaste () const
 
virtual QMimeDatacreateMimeDataFromSelection () const
 
QMenucreateStandardContextMenu (const QPointF &pos, QWidget *parent)
 
QTextCharFormat currentCharFormat () const
 
QTextCursor cursorForPosition (const QPointF &pos) const
 
bool cursorIsFocusIndicator () const
 
QRectF cursorRect (const QTextCursor &cursor) const
 
QRectF cursorRect () const
 
int cursorWidth () const
 
QTextDocumentdocument () const
 
void drawContents (QPainter *painter, const QRectF &rect=QRectF(), QWidget *widget=0)
 
virtual void ensureCursorVisible ()
 
QList< QTextEdit::ExtraSelectionextraSelections () const
 
bool find (const QString &exp, QTextDocument::FindFlags options=0)
 
bool findNextPrevAnchor (const QTextCursor &from, bool next, QTextCursor &newAnchor)
 
QAbstractTextDocumentLayout::PaintContext getPaintContext (QWidget *widget) const
 
virtual int hitTest (const QPointF &point, Qt::HitTestAccuracy accuracy) const
 
bool ignoreUnusedNavigationEvents () const
 
virtual QVariant inputMethodQuery (Qt::InputMethodQuery property) const
 
virtual void insertFromMimeData (const QMimeData *source)
 
bool isDragEnabled () const
 
bool isWordSelectionEnabled () const
 
virtual QVariant loadResource (int type, const QUrl &name)
 
void mergeCurrentCharFormat (const QTextCharFormat &modifier)
 
void moveCursor (QTextCursor::MoveOperation op, QTextCursor::MoveMode mode=QTextCursor::MoveAnchor)
 
bool openExternalLinks () const
 
bool overwriteMode () const
 
QPalette palette () const
 
void print (QPrinter *printer) const
 
virtual void processEvent (QEvent *e, const QMatrix &matrix, QWidget *contextWidget=0)
 
void processEvent (QEvent *e, const QPointF &coordinateOffset=QPointF(), QWidget *contextWidget=0)
 
 QTextControl (QObject *parent=0)
 
 QTextControl (const QString &text, QObject *parent=0)
 
 QTextControl (QTextDocument *doc, QObject *parent=0)
 
QRectF selectionRect (const QTextCursor &cursor) const
 
QRectF selectionRect () const
 
void setAcceptRichText (bool accept)
 
void setCurrentCharFormat (const QTextCharFormat &format)
 
void setCursorIsFocusIndicator (bool b)
 
void setCursorWidth (int width)
 
void setDocument (QTextDocument *document)
 
void setDragEnabled (bool enabled)
 
void setExtraSelections (const QList< QTextEdit::ExtraSelection > &selections)
 
void setFocus (bool focus, Qt::FocusReason=Qt::OtherFocusReason)
 
bool setFocusToAnchor (const QTextCursor &newCursor)
 
bool setFocusToNextOrPreviousAnchor (bool next)
 
void setIgnoreUnusedNavigationEvents (bool ignore)
 
void setOpenExternalLinks (bool open)
 
void setOverwriteMode (bool overwrite)
 
void setPalette (const QPalette &pal)
 
void setTextCursor (const QTextCursor &cursor)
 
void setTextInteractionFlags (Qt::TextInteractionFlags flags)
 
void setTextWidth (qreal width)
 
void setWordSelectionEnabled (bool enabled)
 
QSizeF size () const
 
QTextCursor textCursor () const
 
Qt::TextInteractionFlags textInteractionFlags () const
 
qreal textWidth () const
 
QString toHtml () const
 
QString toPlainText () const
 
virtual ~QTextControl ()
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Protected Functions

virtual bool event (QEvent *e)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual void timerEvent (QTimerEvent *e)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 

Properties

bool acceptRichText
 
int cursorWidth
 
QString html
 
bool ignoreUnusedNavigationEvents
 
bool openExternalLinks
 
bool overwriteMode
 
Qt::TextInteractionFlags textInteractionFlags
 

Additional Inherited Members

- Static Public Functions inherited from QObject
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 receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 87 of file qtextcontrol_p.h.

Constructors and Destructors

◆ QTextControl() [1/3]

QTextControl::QTextControl ( QObject parent = 0)
explicit

Definition at line 787 of file qtextcontrol.cpp.

788  : QObject(*new QTextControlPrivate, parent)
789 {
790  Q_D(QTextControl);
791  d->init();
792 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
Q_INVOKABLE QObject(QObject *parent=0)
Constructs an object with parent object parent.
Definition: qobject.cpp:753

◆ QTextControl() [2/3]

QTextControl::QTextControl ( const QString text,
QObject parent = 0 
)
explicit

Definition at line 794 of file qtextcontrol.cpp.

795  : QObject(*new QTextControlPrivate, parent)
796 {
797  Q_D(QTextControl);
798  d->init(Qt::RichText, text);
799 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
Q_INVOKABLE QObject(QObject *parent=0)
Constructs an object with parent object parent.
Definition: qobject.cpp:753

◆ QTextControl() [3/3]

QTextControl::QTextControl ( QTextDocument doc,
QObject parent = 0 
)
explicit

Definition at line 801 of file qtextcontrol.cpp.

802  : QObject(*new QTextControlPrivate, parent)
803 {
804  Q_D(QTextControl);
805  d->init(Qt::RichText, QString(), doc);
806 }
double d
Definition: qnumeric_p.h:62
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_D(Class)
Definition: qglobal.h:2482
Q_INVOKABLE QObject(QObject *parent=0)
Constructs an object with parent object parent.
Definition: qobject.cpp:753

◆ ~QTextControl()

QTextControl::~QTextControl ( )
virtual

Definition at line 808 of file qtextcontrol.cpp.

809 {
810 }

Functions

◆ acceptRichText()

bool QTextControl::acceptRichText ( ) const

Referenced by setCursorWidth().

◆ adjustSize

void QTextControl::adjustSize ( )
slot

Definition at line 2897 of file qtextcontrol.cpp.

Referenced by QGraphicsTextItem::adjustSize().

2898 {
2899  Q_D(QTextControl);
2900  d->doc->adjustSize();
2901 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ anchorAt()

QString QTextControl::anchorAt ( const QPointF pos) const

Definition at line 2223 of file qtextcontrol.cpp.

Referenced by createStandardContextMenu().

2224 {
2225  Q_D(const QTextControl);
2226  return d->doc->documentLayout()->anchorAt(pos);
2227 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ anchorAtCursor()

QString QTextControl::anchorAtCursor ( ) const

Definition at line 2229 of file qtextcontrol.cpp.

Referenced by QTextBrowserPrivate::setSource().

2230 {
2231  Q_D(const QTextControl);
2232 
2233  return d->anchorForCursor(d->cursor);
2234 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ anchorPosition()

QPointF QTextControl::anchorPosition ( const QString name) const

Definition at line 2868 of file qtextcontrol.cpp.

2869 {
2870  Q_D(const QTextControl);
2871  if (name.isEmpty())
2872  return QPointF();
2873 
2874  QRectF r;
2875  for (QTextBlock block = d->doc->begin(); block.isValid(); block = block.next()) {
2876  QTextCharFormat format = block.charFormat();
2877  if (format.isAnchor() && format.anchorNames().contains(name)) {
2878  r = d->rectForPosition(block.position());
2879  break;
2880  }
2881 
2882  for (QTextBlock::Iterator it = block.begin(); !it.atEnd(); ++it) {
2883  QTextFragment fragment = it.fragment();
2884  format = fragment.charFormat();
2885  if (format.isAnchor() && format.anchorNames().contains(name)) {
2886  r = d->rectForPosition(fragment.position());
2887  block = QTextBlock();
2888  break;
2889  }
2890  }
2891  }
2892  if (!r.isValid())
2893  return QPointF();
2894  return QPointF(0, r.top());
2895 }
double d
Definition: qnumeric_p.h:62
QStringList anchorNames() const
Returns the anchor names associated with this text format, or an empty string list if none has been s...
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
Definition: qtextformat.h:372
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:661
#define it(className, varName)
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
#define Q_D(Class)
Definition: qglobal.h:2482
QTextCharFormat charFormat() const
Returns the text fragment&#39;s character format.
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
bool isAnchor() const
Returns true if the text is formatted as an anchor; otherwise returns false.
Definition: qtextformat.h:501
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
The QTextBlock class provides a container for text fragments in a QTextDocument.
Definition: qtextobject.h:199
QBool contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the list contains the string str; otherwise returns false.
Definition: qstringlist.h:172
The QTextFragment class holds a piece of text in a QTextDocument with a single QTextCharFormat.
Definition: qtextobject.h:297
The QTextBlock::iterator class provides an iterator for reading the contents of a QTextBlock...
Definition: qtextobject.h:251
int position() const
Returns the position of this text fragment in the document.
qreal top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:526

◆ append

void QTextControl::append ( const QString text)
slot

Definition at line 2945 of file qtextcontrol.cpp.

2946 {
2947  Q_D(QTextControl);
2948  d->append(text, Qt::AutoText);
2949 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ appendHtml

void QTextControl::appendHtml ( const QString html)
slot

Definition at line 2951 of file qtextcontrol.cpp.

2952 {
2953  Q_D(QTextControl);
2954  d->append(html, Qt::RichText);
2955 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ appendPlainText

void QTextControl::appendPlainText ( const QString text)
slot

Definition at line 2957 of file qtextcontrol.cpp.

2958 {
2959  Q_D(QTextControl);
2960  d->append(text, Qt::PlainText);
2961 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ blockBoundingRect()

QRectF QTextControl::blockBoundingRect ( const QTextBlock block) const
virtual

Reimplemented in QPlainTextEditControl.

Definition at line 3075 of file qtextcontrol.cpp.

Referenced by selectionRect().

3076 {
3077  Q_D(const QTextControl);
3078  return d->doc->documentLayout()->blockBoundingRect(block);
3079 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ blockCountChanged

void QTextControl::blockCountChanged ( int  newBlockCount)
signal

◆ canInsertFromMimeData()

bool QTextControl::canInsertFromMimeData ( const QMimeData source) const
virtual

Reimplemented in QTextEditControl, and QPlainTextEditControl.

Definition at line 2487 of file qtextcontrol.cpp.

Referenced by QPlainTextEditControl::canInsertFromMimeData(), QTextEditControl::canInsertFromMimeData(), and canPaste().

2488 {
2489  Q_D(const QTextControl);
2490  if (d->acceptRichText)
2491  return (source->hasText() && !source->text().isEmpty())
2492  || source->hasHtml()
2493  || source->hasFormat(QLatin1String("application/x-qrichtext"))
2494  || source->hasFormat(QLatin1String("application/x-qt-richtext"));
2495  else
2496  return source->hasText() && !source->text().isEmpty();
2497 }
double d
Definition: qnumeric_p.h:62
bool hasHtml() const
Returns true if the object can return HTML (MIME type text/html); otherwise returns false...
Definition: qmimedata.cpp:425
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
#define Q_D(Class)
Definition: qglobal.h:2482
QString text() const
Returns a plain text (MIME type text/plain) representation of the data.
Definition: qmimedata.cpp:364
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
virtual bool hasFormat(const QString &mimetype) const
Returns true if the object can return data for the MIME type specified by mimeType; otherwise returns...
Definition: qmimedata.cpp:563
bool hasText() const
Returns true if the object can return plain text (MIME type text/plain); otherwise returns false...
Definition: qmimedata.cpp:389

◆ canPaste()

bool QTextControl::canPaste ( ) const

Definition at line 2401 of file qtextcontrol.cpp.

Referenced by createStandardContextMenu().

2402 {
2403 #ifndef QT_NO_CLIPBOARD
2404  Q_D(const QTextControl);
2405  if (d->interactionFlags & Qt::TextEditable) {
2406  const QMimeData *md = QApplication::clipboard()->mimeData();
2407  return md && canInsertFromMimeData(md);
2408  }
2409 #endif
2410  return false;
2411 }
double d
Definition: qnumeric_p.h:62
virtual bool canInsertFromMimeData(const QMimeData *source) const
#define Q_D(Class)
Definition: qglobal.h:2482
const QMimeData * mimeData(Mode mode=Clipboard) const
Returns a reference to a QMimeData representation of the current clipboard data.
static QClipboard * clipboard()
Returns a pointer to the application global clipboard.
The QMimeData class provides a container for data that records information about its MIME type...
Definition: qmimedata.h:57

◆ clear

void QTextControl::clear ( )
slot

Definition at line 884 of file qtextcontrol.cpp.

885 {
886  Q_D(QTextControl);
887  // clears and sets empty content
888  d->extraSelections.clear();
889  d->setContent();
890 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ copy

void QTextControl::copy ( )
slot

Definition at line 867 of file qtextcontrol.cpp.

Referenced by createStandardContextMenu(), and cut().

868 {
869  Q_D(QTextControl);
870  if (!d->cursor.hasSelection())
871  return;
874 }
double d
Definition: qnumeric_p.h:62
void setMimeData(QMimeData *data, Mode mode=Clipboard)
Sets the clipboard data to src.
#define Q_D(Class)
Definition: qglobal.h:2482
static QClipboard * clipboard()
Returns a pointer to the application global clipboard.
static const char * data(const QByteArray &arr)
virtual QMimeData * createMimeDataFromSelection() const
The QMimeData class provides a container for data that records information about its MIME type...
Definition: qmimedata.h:57

◆ copyAvailable

void QTextControl::copyAvailable ( bool  b)
signal

◆ createMimeDataFromSelection()

QMimeData * QTextControl::createMimeDataFromSelection ( ) const
virtual

Reimplemented in QTextEditControl, and QPlainTextEditControl.

Definition at line 2480 of file qtextcontrol.cpp.

Referenced by copy(), QPlainTextEditControl::createMimeDataFromSelection(), and QTextEditControl::createMimeDataFromSelection().

2481 {
2482  Q_D(const QTextControl);
2483  const QTextDocumentFragment fragment(d->cursor);
2484  return new QTextEditMimeData(fragment);
2485 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextDocumentFragment class represents a piece of formatted text from a QTextDocument.

◆ createStandardContextMenu()

QMenu * QTextControl::createStandardContextMenu ( const QPointF pos,
QWidget parent 
)

Definition at line 2109 of file qtextcontrol.cpp.

2110 {
2111  Q_D(QTextControl);
2112 
2113  const bool showTextSelectionActions = d->interactionFlags & (Qt::TextEditable | Qt::TextSelectableByKeyboard | Qt::TextSelectableByMouse);
2114 
2115  d->linkToCopy = QString();
2116  if (!pos.isNull())
2117  d->linkToCopy = anchorAt(pos);
2118 
2119  if (d->linkToCopy.isEmpty() && !showTextSelectionActions)
2120  return 0;
2121 
2122  QMenu *menu = new QMenu(parent);
2123  QAction *a;
2124 
2125  if (d->interactionFlags & Qt::TextEditable) {
2126  a = menu->addAction(tr("&Undo") + ACCEL_KEY(QKeySequence::Undo), this, SLOT(undo()));
2127  a->setEnabled(d->doc->isUndoAvailable());
2128  a = menu->addAction(tr("&Redo") + ACCEL_KEY(QKeySequence::Redo), this, SLOT(redo()));
2129  a->setEnabled(d->doc->isRedoAvailable());
2130  menu->addSeparator();
2131 
2132  a = menu->addAction(tr("Cu&t") + ACCEL_KEY(QKeySequence::Cut), this, SLOT(cut()));
2133  a->setEnabled(d->cursor.hasSelection());
2134  }
2135 
2136  if (showTextSelectionActions) {
2137  a = menu->addAction(tr("&Copy") + ACCEL_KEY(QKeySequence::Copy), this, SLOT(copy()));
2138  a->setEnabled(d->cursor.hasSelection());
2139  }
2140 
2141  if ((d->interactionFlags & Qt::LinksAccessibleByKeyboard)
2142  || (d->interactionFlags & Qt::LinksAccessibleByMouse)) {
2143 
2144  a = menu->addAction(tr("Copy &Link Location"), this, SLOT(_q_copyLink()));
2145  a->setEnabled(!d->linkToCopy.isEmpty());
2146  }
2147 
2148  if (d->interactionFlags & Qt::TextEditable) {
2149 #if !defined(QT_NO_CLIPBOARD)
2150  a = menu->addAction(tr("&Paste") + ACCEL_KEY(QKeySequence::Paste), this, SLOT(paste()));
2151  a->setEnabled(canPaste());
2152 #endif
2153  a = menu->addAction(tr("Delete"), this, SLOT(_q_deleteSelected()));
2154  a->setEnabled(d->cursor.hasSelection());
2155  }
2156 
2157 
2158  if (showTextSelectionActions) {
2159  menu->addSeparator();
2160  a = menu->addAction(tr("Select All") + ACCEL_KEY(QKeySequence::SelectAll), this, SLOT(selectAll()));
2161  a->setEnabled(!d->doc->isEmpty());
2162  }
2163 
2164 #if !defined(QT_NO_IM)
2165  if (d->contextWidget) {
2166  QInputContext *qic = d->inputContext();
2167  if (qic) {
2168  QList<QAction *> imActions = qic->actions();
2169  for (int i = 0; i < imActions.size(); ++i)
2170  menu->addAction(imActions.at(i));
2171  }
2172  }
2173 #endif
2174 
2175 #if defined(Q_WS_WIN) || defined(Q_WS_X11)
2176  if ((d->interactionFlags & Qt::TextEditable) && qt_use_rtl_extensions) {
2177 #else
2178  if (d->interactionFlags & Qt::TextEditable) {
2179 #endif
2180  menu->addSeparator();
2181  QUnicodeControlCharacterMenu *ctrlCharacterMenu = new QUnicodeControlCharacterMenu(this, menu);
2182  menu->addMenu(ctrlCharacterMenu);
2183  }
2184 
2185  return menu;
2186 }
double d
Definition: qnumeric_p.h:62
#define SLOT(a)
Definition: qobjectdefs.h:226
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
long ASN1_INTEGER_get ASN1_INTEGER * a
void paste(QClipboard::Mode mode=QClipboard::Clipboard)
The QString class provides a Unicode character string.
Definition: qstring.h:83
QAction * addAction(const QString &text)
This convenience function creates a new action with text.
Definition: qmenu.cpp:1453
#define Q_D(Class)
Definition: qglobal.h:2482
virtual QList< QAction * > actions()
This is a preliminary interface for Qt 4.
void setEnabled(bool)
Definition: qaction.cpp:1192
#define ACCEL_KEY(k)
QString anchorAt(const QPointF &pos) const
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QAction * addSeparator()
This convenience function creates a new separator action, i.e.
Definition: qmenu.cpp:1583
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
bool qt_use_rtl_extensions
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QAction * addMenu(QMenu *menu)
This convenience function adds menu as a submenu to this menu.
Definition: qmenu.cpp:1541
bool isNull() const
Returns true if both the x and y coordinates are set to +0.
Definition: qpoint.h:277
The QInputContext class abstracts the input method dependent data and composing state.
Definition: qinputcontext.h:83
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
bool canPaste() const

◆ currentCharFormat()

QTextCharFormat QTextControl::currentCharFormat ( ) const

Definition at line 2848 of file qtextcontrol.cpp.

2849 {
2850  Q_D(const QTextControl);
2851  return d->cursor.charFormat();
2852 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ currentCharFormatChanged

void QTextControl::currentCharFormatChanged ( const QTextCharFormat format)
signal

◆ cursorForPosition()

QTextCursor QTextControl::cursorForPosition ( const QPointF pos) const

Definition at line 2189 of file qtextcontrol.cpp.

Referenced by QTextBrowserPrivate::setSource().

2190 {
2191  Q_D(const QTextControl);
2192  int cursorPos = hitTest(pos, Qt::FuzzyHit);
2193  if (cursorPos == -1)
2194  cursorPos = 0;
2195  QTextCursor c(d->doc);
2196  c.setPosition(cursorPos);
2197  return c;
2198 }
double d
Definition: qnumeric_p.h:62
unsigned char c[8]
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
virtual int hitTest(const QPointF &point, Qt::HitTestAccuracy accuracy) const
The QTextCursor class offers an API to access and modify QTextDocuments.
Definition: qtextcursor.h:70

◆ cursorIsFocusIndicator()

bool QTextControl::cursorIsFocusIndicator ( ) const

◆ cursorPositionChanged

void QTextControl::cursorPositionChanged ( )
signal

Referenced by moveCursor(), and setTextCursor().

◆ cursorRect() [1/2]

QRectF QTextControl::cursorRect ( const QTextCursor cursor) const

Definition at line 2200 of file qtextcontrol.cpp.

Referenced by QTextEditPrivate::pageUpDown().

2201 {
2202  Q_D(const QTextControl);
2203  if (cursor.isNull())
2204  return QRectF();
2205 
2206  return d->rectForPosition(cursor.position());
2207 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
int position() const
Returns the absolute position of the cursor within the document.
bool isNull() const
Returns true if the cursor is null; otherwise returns false.

◆ cursorRect() [2/2]

QRectF QTextControl::cursorRect ( ) const

Definition at line 2209 of file qtextcontrol.cpp.

Referenced by QPlainTextEditControl::cursorRect(), and inputMethodQuery().

2210 {
2211  Q_D(const QTextControl);
2212  return cursorRect(d->cursor);
2213 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
QRectF cursorRect() const

◆ cursorWidth()

int QTextControl::cursorWidth ( ) const

◆ cut

void QTextControl::cut ( )
slot

Definition at line 858 of file qtextcontrol.cpp.

Referenced by createStandardContextMenu().

859 {
860  Q_D(QTextControl);
861  if (!(d->interactionFlags & Qt::TextEditable) || !d->cursor.hasSelection())
862  return;
863  copy();
864  d->cursor.removeSelectedText();
865 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ document()

QTextDocument * QTextControl::document ( ) const

◆ documentSizeChanged

void QTextControl::documentSizeChanged ( const QSizeF )
signal

◆ drawContents()

void QTextControl::drawContents ( QPainter painter,
const QRectF rect = QRectF(),
QWidget widget = 0 
)

Definition at line 3037 of file qtextcontrol.cpp.

Referenced by QGraphicsTextItem::paint().

3038 {
3039  Q_D(QTextControl);
3040  p->save();
3042  if (rect.isValid())
3043  p->setClipRect(rect, Qt::IntersectClip);
3044  ctx.clip = rect;
3045 
3046  d->doc->documentLayout()->draw(p, ctx);
3047  p->restore();
3048 }
double d
Definition: qnumeric_p.h:62
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:661
#define Q_D(Class)
Definition: qglobal.h:2482
QRectF clip
a hint to the layout specifying the area around paragraphs, frames or text require painting...
QAbstractTextDocumentLayout::PaintContext getPaintContext(QWidget *widget) const
#define ctx
Definition: qgl.cpp:6094
The QAbstractTextDocumentLayout::PaintContext class is a convenience class defining the parameters us...

◆ ensureCursorVisible()

void QTextControl::ensureCursorVisible ( )
virtual

Reimplemented in QPlainTextEditControl.

Definition at line 2964 of file qtextcontrol.cpp.

Referenced by insertFromMimeData(), moveCursor(), and setTextCursor().

2965 {
2966  Q_D(QTextControl);
2967  QRectF crect = d->rectForPosition(d->cursor.position()).adjusted(-5, 0, 5, 0);
2968  emit visibilityRequest(crect);
2970 }
double d
Definition: qnumeric_p.h:62
void visibilityRequest(const QRectF &rect)
#define Q_D(Class)
Definition: qglobal.h:2482
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
#define emit
Definition: qobjectdefs.h:76
void microFocusChanged()

◆ event()

bool QTextControl::event ( QEvent e)
protectedvirtual

This virtual function receives events to an object and should return true if the event e was recognized and processed.

The event() function can be reimplemented to customize the behavior of an object.

See also
installEventFilter(), timerEvent(), QApplication::sendEvent(), QApplication::postEvent(), QWidget::event()

Reimplemented from QObject.

Definition at line 1133 of file qtextcontrol.cpp.

1134 {
1135  return QObject::event(e);
1136 }
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200

◆ extraSelections()

QList< QTextEdit::ExtraSelection > QTextControl::extraSelections ( ) const

Definition at line 2332 of file qtextcontrol.cpp.

2333 {
2334  Q_D(const QTextControl);
2336  for (int i = 0; i < d->extraSelections.count(); ++i) {
2338  sel.cursor = d->extraSelections.at(i).cursor;
2339  sel.format = d->extraSelections.at(i).format;
2340  selections.append(sel);
2341  }
2342  return selections;
2343 }
double d
Definition: qnumeric_p.h:62
QTextCursor cursor
A cursor that contains a selection in a QTextDocument.
Definition: qtextedit.h:224
#define Q_D(Class)
Definition: qglobal.h:2482
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
The QTextEdit::ExtraSelection structure provides a way of specifying a character format for a given s...
Definition: qtextedit.h:222
QTextCharFormat format
A format that is used to specify a foreground or background brush/color for the selection.
Definition: qtextedit.h:225
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ find()

bool QTextControl::find ( const QString exp,
QTextDocument::FindFlags  options = 0 
)

Definition at line 2903 of file qtextcontrol.cpp.

2904 {
2905  Q_D(QTextControl);
2906  QTextCursor search = d->doc->find(exp, d->cursor, options);
2907  if (search.isNull())
2908  return false;
2909 
2910  setTextCursor(search);
2911  return true;
2912 }
double d
Definition: qnumeric_p.h:62
void setTextCursor(const QTextCursor &cursor)
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextCursor class offers an API to access and modify QTextDocuments.
Definition: qtextcursor.h:70
bool isNull() const
Returns true if the cursor is null; otherwise returns false.

◆ findNextPrevAnchor()

bool QTextControl::findNextPrevAnchor ( const QTextCursor from,
bool  next,
QTextCursor newAnchor 
)

Definition at line 2533 of file qtextcontrol.cpp.

Referenced by setFocusToNextOrPreviousAnchor(), and QTextBrowserPrivate::setSource().

2534 {
2535  Q_D(QTextControl);
2536 
2537  int anchorStart = -1;
2538  QString anchorHref;
2539  int anchorEnd = -1;
2540 
2541  if (next) {
2542  const int startPos = startCursor.selectionEnd();
2543 
2544  QTextBlock block = d->doc->findBlock(startPos);
2545  QTextBlock::Iterator it = block.begin();
2546 
2547  while (!it.atEnd() && it.fragment().position() < startPos)
2548  ++it;
2549 
2550  while (block.isValid()) {
2551  anchorStart = -1;
2552 
2553  // find next anchor
2554  for (; !it.atEnd(); ++it) {
2555  const QTextFragment fragment = it.fragment();
2556  const QTextCharFormat fmt = fragment.charFormat();
2557 
2558  if (fmt.isAnchor() && fmt.hasProperty(QTextFormat::AnchorHref)) {
2559  anchorStart = fragment.position();
2560  anchorHref = fmt.anchorHref();
2561  break;
2562  }
2563  }
2564 
2565  if (anchorStart != -1) {
2566  anchorEnd = -1;
2567 
2568  // find next non-anchor fragment
2569  for (; !it.atEnd(); ++it) {
2570  const QTextFragment fragment = it.fragment();
2571  const QTextCharFormat fmt = fragment.charFormat();
2572 
2573  if (!fmt.isAnchor() || fmt.anchorHref() != anchorHref) {
2574  anchorEnd = fragment.position();
2575  break;
2576  }
2577  }
2578 
2579  if (anchorEnd == -1)
2580  anchorEnd = block.position() + block.length() - 1;
2581 
2582  // make found selection
2583  break;
2584  }
2585 
2586  block = block.next();
2587  it = block.begin();
2588  }
2589  } else {
2590  int startPos = startCursor.selectionStart();
2591  if (startPos > 0)
2592  --startPos;
2593 
2594  QTextBlock block = d->doc->findBlock(startPos);
2595  QTextBlock::Iterator blockStart = block.begin();
2596  QTextBlock::Iterator it = block.end();
2597 
2598  if (startPos == block.position()) {
2599  it = block.begin();
2600  } else {
2601  do {
2602  if (it == blockStart) {
2603  it = QTextBlock::Iterator();
2604  block = QTextBlock();
2605  } else {
2606  --it;
2607  }
2608  } while (!it.atEnd() && it.fragment().position() + it.fragment().length() - 1 > startPos);
2609  }
2610 
2611  while (block.isValid()) {
2612  anchorStart = -1;
2613 
2614  if (!it.atEnd()) {
2615  do {
2616  const QTextFragment fragment = it.fragment();
2617  const QTextCharFormat fmt = fragment.charFormat();
2618 
2619  if (fmt.isAnchor() && fmt.hasProperty(QTextFormat::AnchorHref)) {
2620  anchorStart = fragment.position() + fragment.length();
2621  anchorHref = fmt.anchorHref();
2622  break;
2623  }
2624 
2625  if (it == blockStart)
2626  it = QTextBlock::Iterator();
2627  else
2628  --it;
2629  } while (!it.atEnd());
2630  }
2631 
2632  if (anchorStart != -1 && !it.atEnd()) {
2633  anchorEnd = -1;
2634 
2635  do {
2636  const QTextFragment fragment = it.fragment();
2637  const QTextCharFormat fmt = fragment.charFormat();
2638 
2639  if (!fmt.isAnchor() || fmt.anchorHref() != anchorHref) {
2640  anchorEnd = fragment.position() + fragment.length();
2641  break;
2642  }
2643 
2644  if (it == blockStart)
2645  it = QTextBlock::Iterator();
2646  else
2647  --it;
2648  } while (!it.atEnd());
2649 
2650  if (anchorEnd == -1)
2651  anchorEnd = qMax(0, block.position());
2652 
2653  break;
2654  }
2655 
2656  block = block.previous();
2657  it = block.end();
2658  if (it != block.begin())
2659  --it;
2660  blockStart = block.begin();
2661  }
2662 
2663  }
2664 
2665  if (anchorStart != -1 && anchorEnd != -1) {
2666  newAnchor = d->cursor;
2667  newAnchor.setPosition(anchorStart);
2668  newAnchor.setPosition(anchorEnd, QTextCursor::KeepAnchor);
2669  return true;
2670  }
2671 
2672  return false;
2673 }
double d
Definition: qnumeric_p.h:62
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
Definition: qtextformat.h:372
#define it(className, varName)
iterator end() const
Returns a text block iterator pointing to the end of the text block.
bool atEnd() const
Returns true if the current item is the last item in the text block.
Definition: qtextobject.h:264
iterator begin() const
Returns a text block iterator pointing to the beginning of the text block.
QString anchorHref() const
Returns the text format&#39;s hypertext link, or an empty string if none has been set.
Definition: qtextformat.h:506
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_D(Class)
Definition: qglobal.h:2482
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
QTextBlock next() const
Returns the text block in the document after this block, or an empty text block if this is the last o...
int position() const
Returns the index of the block&#39;s first character within the document.
QTextBlock previous() const
Returns the text block in the document before this block, or an empty text block if this is the first...
bool hasProperty(int propertyId) const
Returns true if the text format has a property with the given propertyId; otherwise returns false...
QTextCharFormat charFormat() const
Returns the text fragment&#39;s character format.
bool isAnchor() const
Returns true if the text is formatted as an anchor; otherwise returns false.
Definition: qtextformat.h:501
The QTextBlock class provides a container for text fragments in a QTextDocument.
Definition: qtextobject.h:199
int length() const
Returns the length of the block in characters.
int length() const
Returns the number of characters in the text fragment.
The QTextFragment class holds a piece of text in a QTextDocument with a single QTextCharFormat.
Definition: qtextobject.h:297
The QTextBlock::iterator class provides an iterator for reading the contents of a QTextBlock...
Definition: qtextobject.h:251
int position() const
Returns the position of this text fragment in the document.
iterator Iterator
Qt-style synonym for QTextBlock::iterator.
Definition: qtextobject.h:275
void setPosition(int pos, MoveMode mode=MoveAnchor)
Moves the cursor to the absolute position in the document specified by pos using a MoveMode specified...
bool isValid() const
Returns true if this text block is valid; otherwise returns false.
Definition: qtextobject.h:208
QTextFragment fragment() const
Returns the text fragment the iterator currently points to.

◆ getPaintContext()

QAbstractTextDocumentLayout::PaintContext QTextControl::getPaintContext ( QWidget widget) const

Definition at line 2984 of file qtextcontrol.cpp.

Referenced by drawContents().

2985 {
2986  Q_D(const QTextControl);
2987 
2989 
2990  ctx.selections = d->extraSelections;
2991  ctx.palette = d->palette;
2992  if (d->cursorOn && d->isEnabled) {
2993  if (d->hideCursor)
2994  ctx.cursorPosition = -1;
2995  else if (d->preeditCursor != 0)
2996  ctx.cursorPosition = - (d->preeditCursor + 2);
2997  else
2998  ctx.cursorPosition = d->cursor.position();
2999  }
3000 
3001  if (!d->dndFeedbackCursor.isNull())
3002  ctx.cursorPosition = d->dndFeedbackCursor.position();
3003 #ifdef QT_KEYPAD_NAVIGATION
3004  if (!QApplication::keypadNavigationEnabled() || d->hasEditFocus)
3005 #endif
3006  if (d->cursor.hasSelection()) {
3008  selection.cursor = d->cursor;
3009  if (d->cursorIsFocusIndicator) {
3010  QStyleOption opt;
3011  opt.palette = ctx.palette;
3013  QStyle *style = QApplication::style();
3014  if (widget)
3015  style = widget->style();
3017  selection.format = qvariant_cast<QTextFormat>(ret.variant).toCharFormat();
3018  } else {
3022  QStyleOption opt;
3023  QStyle *style = QApplication::style();
3024  if (widget) {
3025  opt.initFrom(widget);
3026  style = widget->style();
3027  }
3028  if (style->styleHint(QStyle::SH_RichText_FullWidthSelection, &opt, widget))
3030  }
3031  ctx.selections.append(selection);
3032  }
3033 
3034  return ctx;
3035 }
double d
Definition: qnumeric_p.h:62
The QStyleHintReturnVariant class provides style hints that return a QVariant.
Definition: qstyleoption.h:933
QTextCharFormat format
the format of the selection
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
QTextCursor cursor
the selection&#39;s cursor
static QStyle * style()
Returns the application&#39;s style object.
void setBackground(const QBrush &brush)
Sets the brush use to paint the document&#39;s background to the brush specified.
Definition: qtextformat.h:343
QPalette palette
the default color that is used for the text, when no color is specified.
#define Q_D(Class)
Definition: qglobal.h:2482
int cursorPosition
the position within the document, where the cursor line should be drawn.
QStyle * style() const
Definition: qwidget.cpp:2742
ColorGroup
Definition: qpalette.h:92
The QAbstractTextDocumentLayout::Selection class is a convenience class defining the parameters of a ...
The QStyleOption class stores the parameters used by QStyle functions.
Definition: qstyleoption.h:67
The QTextFormat class provides formatting information for a QTextDocument.
Definition: qtextformat.h:129
void initFrom(const QWidget *w)
Definition: qstyleoption.h:99
const QBrush & brush(ColorGroup cg, ColorRole cr) const
Returns the brush in the specified color group, used for the given color role.
Definition: qpalette.cpp:874
QPalette palette
the palette that should be used when painting the control
Definition: qstyleoption.h:92
#define ctx
Definition: qgl.cpp:6094
The QAbstractTextDocumentLayout::PaintContext class is a convenience class defining the parameters us...
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
Definition: qstyle.h:68
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571
void setForeground(const QBrush &brush)
Sets the foreground brush to the specified brush.
Definition: qtextformat.h:350
QVector< Selection > selections
the collection of selections that will be rendered when passing this paint context to QAbstractTextDo...
QVariant variant
the variant for style hints that return a QVariant
Definition: qstyleoption.h:940

◆ hitTest()

int QTextControl::hitTest ( const QPointF point,
Qt::HitTestAccuracy  accuracy 
) const
virtual

Reimplemented in QPlainTextEditControl.

Definition at line 3069 of file qtextcontrol.cpp.

Referenced by cursorForPosition().

3070 {
3071  Q_D(const QTextControl);
3072  return d->doc->documentLayout()->hitTest(point, accuracy);
3073 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ ignoreUnusedNavigationEvents()

bool QTextControl::ignoreUnusedNavigationEvents ( ) const

Referenced by setOpenExternalLinks().

◆ inputMethodQuery()

QVariant QTextControl::inputMethodQuery ( Qt::InputMethodQuery  property) const
virtual

Definition at line 2006 of file qtextcontrol.cpp.

Referenced by QGraphicsTextItem::inputMethodQuery().

2007 {
2008  Q_D(const QTextControl);
2009  QTextBlock block = d->cursor.block();
2010  switch(property) {
2011  case Qt::ImMicroFocus:
2012  return cursorRect();
2013  case Qt::ImFont:
2014  return QVariant(d->cursor.charFormat().font());
2015  case Qt::ImCursorPosition:
2016  return QVariant(d->cursor.position() - block.position());
2017  case Qt::ImSurroundingText:
2018  return QVariant(block.text());
2020  return QVariant(d->cursor.selectedText());
2022  return QVariant(); // No limit.
2023  case Qt::ImAnchorPosition:
2024  return QVariant(qBound(0, d->cursor.anchor() - block.position(), block.length()));
2025  default:
2026  return QVariant();
2027  }
2028 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
double d
Definition: qnumeric_p.h:62
QString text() const
Returns the block&#39;s contents as plain text.
#define Q_D(Class)
Definition: qglobal.h:2482
int position() const
Returns the index of the block&#39;s first character within the document.
The QTextBlock class provides a container for text fragments in a QTextDocument.
Definition: qtextobject.h:199
int length() const
Returns the length of the block in characters.
QRectF cursorRect() const
Q_DECL_CONSTEXPR const T & qBound(const T &min, const T &val, const T &max)
Definition: qglobal.h:1219
QVariant property(const char *name) const
Returns the value of the object&#39;s name property.
Definition: qobject.cpp:3807

◆ insertFromMimeData()

void QTextControl::insertFromMimeData ( const QMimeData source)
virtual

Reimplemented in QTextEditControl, and QPlainTextEditControl.

Definition at line 2499 of file qtextcontrol.cpp.

Referenced by QPlainTextEditControl::insertFromMimeData(), QTextEditControl::insertFromMimeData(), and paste().

2500 {
2501  Q_D(QTextControl);
2502  if (!(d->interactionFlags & Qt::TextEditable) || !source)
2503  return;
2504 
2505  bool hasData = false;
2506  QTextDocumentFragment fragment;
2507 #ifndef QT_NO_TEXTHTMLPARSER
2508  if (source->hasFormat(QLatin1String("application/x-qrichtext")) && d->acceptRichText) {
2509  // x-qrichtext is always UTF-8 (taken from Qt3 since we don't use it anymore).
2510  QString richtext = QString::fromUtf8(source->data(QLatin1String("application/x-qrichtext")));
2511  richtext.prepend(QLatin1String("<meta name=\"qrichtext\" content=\"1\" />"));
2512  fragment = QTextDocumentFragment::fromHtml(richtext, d->doc);
2513  hasData = true;
2514  } else if (source->hasHtml() && d->acceptRichText) {
2515  fragment = QTextDocumentFragment::fromHtml(source->html(), d->doc);
2516  hasData = true;
2517  } else {
2518  QString text = source->text();
2519  if (!text.isNull()) {
2520  fragment = QTextDocumentFragment::fromPlainText(text);
2521  hasData = true;
2522  }
2523  }
2524 #else
2525  fragment = QTextDocumentFragment::fromPlainText(source->text());
2526 #endif // QT_NO_TEXTHTMLPARSER
2527 
2528  if (hasData)
2529  d->cursor.insertFragment(fragment);
2531 }
double d
Definition: qnumeric_p.h:62
virtual void ensureCursorVisible()
bool hasHtml() const
Returns true if the object can return HTML (MIME type text/html); otherwise returns false...
Definition: qmimedata.cpp:425
QString & prepend(QChar c)
Definition: qstring.h:261
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QByteArray data(const QString &mimetype) const
Returns the data stored in the object in the format described by the MIME type specified by mimeType...
Definition: qmimedata.cpp:524
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_D(Class)
Definition: qglobal.h:2482
static QTextDocumentFragment fromHtml(const QString &html)
Returns a QTextDocumentFragment based on the arbitrary piece of HTML in the given text...
QString text() const
Returns a plain text (MIME type text/plain) representation of the data.
Definition: qmimedata.cpp:364
QString html() const
Returns a string if the data stored in the object is HTML (MIME type text/html); otherwise returns an...
Definition: qmimedata.cpp:400
static QTextDocumentFragment fromPlainText(const QString &plainText)
Returns a document fragment that contains the given plainText.
static QString fromUtf8(const char *, int size=-1)
Returns a QString initialized with the first size bytes of the UTF-8 string str.
Definition: qstring.cpp:4302
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505
virtual bool hasFormat(const QString &mimetype) const
Returns true if the object can return data for the MIME type specified by mimeType; otherwise returns...
Definition: qmimedata.cpp:563
The QTextDocumentFragment class represents a piece of formatted text from a QTextDocument.
#define text
Definition: qobjectdefs.h:80

◆ insertHtml

void QTextControl::insertHtml ( const QString text)
slot

Definition at line 2861 of file qtextcontrol.cpp.

2862 {
2863  Q_D(QTextControl);
2864  d->cursor.insertHtml(text);
2865 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ insertPlainText

void QTextControl::insertPlainText ( const QString text)
slot

Definition at line 2854 of file qtextcontrol.cpp.

2855 {
2856  Q_D(QTextControl);
2857  d->cursor.insertText(text);
2858 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ isDragEnabled()

bool QTextControl::isDragEnabled ( ) const

Definition at line 2433 of file qtextcontrol.cpp.

2434 {
2435  Q_D(const QTextControl);
2436  return d->dragEnabled;
2437 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ isWordSelectionEnabled()

bool QTextControl::isWordSelectionEnabled ( ) const

Definition at line 2445 of file qtextcontrol.cpp.

2446 {
2447  Q_D(const QTextControl);
2448  return d->wordSelectionEnabled;
2449 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ linkActivated

void QTextControl::linkActivated ( const QString link)
signal

◆ linkHovered

void QTextControl::linkHovered ( const QString )
signal

◆ loadResource()

QVariant QTextControl::loadResource ( int  type,
const QUrl name 
)
virtual

Reimplemented in QPlainTextEditControl.

Definition at line 1325 of file qtextcontrol.cpp.

1326 {
1327 #ifdef QT_NO_TEXTEDIT
1328  Q_UNUSED(type);
1329  Q_UNUSED(name);
1330 #else
1331  if (QTextEdit *textEdit = qobject_cast<QTextEdit *>(parent())) {
1332  QUrl resolvedName = textEdit->d_func()->resolveUrl(name);
1333  return textEdit->loadResource(type, resolvedName);
1334  }
1335 #endif
1336  return QVariant();
1337 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
int type
Definition: qmetatype.cpp:239
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
#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
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ mergeCurrentCharFormat()

void QTextControl::mergeCurrentCharFormat ( const QTextCharFormat modifier)

Definition at line 2834 of file qtextcontrol.cpp.

2835 {
2836  Q_D(QTextControl);
2837  d->cursor.mergeCharFormat(modifier);
2838  d->updateCurrentCharFormat();
2839 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ microFocusChanged

void QTextControl::microFocusChanged ( )
signal

◆ modificationChanged

void QTextControl::modificationChanged ( bool  m)
signal

◆ moveCursor()

void QTextControl::moveCursor ( QTextCursor::MoveOperation  op,
QTextCursor::MoveMode  mode = QTextCursor::MoveAnchor 
)

Definition at line 2389 of file qtextcontrol.cpp.

Referenced by QPlainTextEditPrivate::mapToContents().

2390 {
2391  Q_D(QTextControl);
2392  const QTextCursor oldSelection = d->cursor;
2393  const bool moved = d->cursor.movePosition(op, mode);
2394  d->_q_updateCurrentCharFormatAndSelection();
2396  d->repaintOldAndNewSelection(oldSelection);
2397  if (moved)
2399 }
double d
Definition: qnumeric_p.h:62
virtual void ensureCursorVisible()
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextCursor class offers an API to access and modify QTextDocuments.
Definition: qtextcursor.h:70
#define emit
Definition: qobjectdefs.h:76
void cursorPositionChanged()

◆ openExternalLinks()

bool QTextControl::openExternalLinks ( ) const

◆ overwriteMode()

bool QTextControl::overwriteMode ( ) const

◆ palette()

QPalette QTextControl::palette ( ) const

Definition at line 2972 of file qtextcontrol.cpp.

Referenced by QGraphicsTextItem::defaultTextColor(), and QGraphicsTextItem::setDefaultTextColor().

2973 {
2974  Q_D(const QTextControl);
2975  return d->palette;
2976 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ paste

void QTextControl::paste ( QClipboard::Mode  mode = QClipboard::Clipboard)
slot

Definition at line 876 of file qtextcontrol.cpp.

Referenced by createStandardContextMenu().

877 {
878  const QMimeData *md = QApplication::clipboard()->mimeData(mode);
879  if (md)
880  insertFromMimeData(md);
881 }
virtual void insertFromMimeData(const QMimeData *source)
const QMimeData * mimeData(Mode mode=Clipboard) const
Returns a reference to a QMimeData representation of the current clipboard data.
static QClipboard * clipboard()
Returns a pointer to the application global clipboard.
The QMimeData class provides a container for data that records information about its MIME type...
Definition: qmimedata.h:57

◆ print()

void QTextControl::print ( QPrinter printer) const

Definition at line 2452 of file qtextcontrol.cpp.

2453 {
2454 #ifndef QT_NO_PRINTER
2455  Q_D(const QTextControl);
2456  if (!printer || !printer->isValid())
2457  return;
2458  QTextDocument *tempDoc = 0;
2459  const QTextDocument *doc = d->doc;
2460  if (printer->printRange() == QPrinter::Selection) {
2461  if (!d->cursor.hasSelection())
2462  return;
2463  tempDoc = new QTextDocument(const_cast<QTextDocument *>(doc));
2465  tempDoc->setPageSize(doc->pageSize());
2466  tempDoc->setDefaultFont(doc->defaultFont());
2467  tempDoc->setUseDesignMetrics(doc->useDesignMetrics());
2468  QTextCursor(tempDoc).insertFragment(d->cursor.selection());
2469  doc = tempDoc;
2470 
2471  // copy the custom object handlers
2472  doc->documentLayout()->d_func()->handlers = d->doc->documentLayout()->d_func()->handlers;
2473  }
2474  doc->print(printer);
2475  delete tempDoc;
2476 #endif
2477 }
double d
Definition: qnumeric_p.h:62
QSizeF pageSize
the page size that should be used for laying out the document
void setPageSize(const QSizeF &size)
void print(QPrinter *printer) const
Prints the document to the given printer.
QFont defaultFont
the default font used to display the document&#39;s text
#define Q_D(Class)
Definition: qglobal.h:2482
void setMetaInformation(MetaInformation info, const QString &)
Sets the document&#39;s meta information of the type specified by info to the given string.
The QTextCursor class offers an API to access and modify QTextDocuments.
Definition: qtextcursor.h:70
bool isValid() const
Returns true if the printer currently selected is a valid printer in the system, or a pure PDF/PostSc...
Definition: qprinter.cpp:895
PrintRange printRange() const
Returns the page range of the QPrinter.
Definition: qprinter.cpp:2265
void insertFragment(const QTextDocumentFragment &fragment)
Inserts the text fragment at the current position().
void setUseDesignMetrics(bool b)
void setDefaultFont(const QFont &font)
Sets the default font to use in the document layout.
QString metaInformation(MetaInformation info) const
Returns meta information about the document of the type specified by info.
QAbstractTextDocumentLayout * documentLayout() const
Returns the document layout for this document.
The QTextDocument class holds formatted text that can be viewed and edited using a QTextEdit...
bool useDesignMetrics
whether the document uses design metrics of fonts to improve the accuracy of text layout ...

◆ processEvent() [1/2]

void QTextControl::processEvent ( QEvent e,
const QMatrix matrix,
QWidget contextWidget = 0 
)
virtual

Definition at line 910 of file qtextcontrol.cpp.

Referenced by processEvent(), QTextEditPrivate::sendControlEvent(), QGraphicsTextItemPrivate::sendControlEvent(), and setFocus().

911 {
912  Q_D(QTextControl);
913  if (d->interactionFlags == Qt::NoTextInteraction) {
914  e->ignore();
915  return;
916  }
917 
918  d->contextWidget = contextWidget;
919 
920  if (!d->contextWidget) {
921  switch (e->type()) {
922 #ifndef QT_NO_GRAPHICSVIEW
936  QGraphicsSceneEvent *ev = static_cast<QGraphicsSceneEvent *>(e);
937  d->contextWidget = ev->widget();
938  break;
939  }
940 #endif // QT_NO_GRAPHICSVIEW
941  default: break;
942  };
943  }
944 
945  switch (e->type()) {
946  case QEvent::KeyPress:
947  d->keyPressEvent(static_cast<QKeyEvent *>(e));
948  break;
950  QMouseEvent *ev = static_cast<QMouseEvent *>(e);
951  d->mousePressEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(),
952  ev->buttons(), ev->globalPos());
953  break; }
954  case QEvent::MouseMove: {
955  QMouseEvent *ev = static_cast<QMouseEvent *>(e);
956  d->mouseMoveEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(),
957  ev->buttons(), ev->globalPos());
958  break; }
960  QMouseEvent *ev = static_cast<QMouseEvent *>(e);
961  d->mouseReleaseEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(),
962  ev->buttons(), ev->globalPos());
963  break; }
965  QMouseEvent *ev = static_cast<QMouseEvent *>(e);
966  d->mouseDoubleClickEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(),
967  ev->buttons(), ev->globalPos());
968  break; }
969  case QEvent::InputMethod:
970  d->inputMethodEvent(static_cast<QInputMethodEvent *>(e));
971  break;
972 #ifndef QT_NO_CONTEXTMENU
973  case QEvent::ContextMenu: {
974  QContextMenuEvent *ev = static_cast<QContextMenuEvent *>(e);
975  d->contextMenuEvent(ev->globalPos(), matrix.map(ev->pos()), contextWidget);
976  break; }
977 #endif // QT_NO_CONTEXTMENU
978  case QEvent::FocusIn:
979  case QEvent::FocusOut:
980  d->focusEvent(static_cast<QFocusEvent *>(e));
981  break;
982 
984  d->isEnabled = e->isAccepted();
985  break;
986 
987 #ifndef QT_NO_TOOLTIP
988  case QEvent::ToolTip: {
989  QHelpEvent *ev = static_cast<QHelpEvent *>(e);
990  d->showToolTip(ev->globalPos(), matrix.map(ev->pos()), contextWidget);
991  break;
992  }
993 #endif // QT_NO_TOOLTIP
994 
995 #ifndef QT_NO_DRAGANDDROP
996  case QEvent::DragEnter: {
997  QDragEnterEvent *ev = static_cast<QDragEnterEvent *>(e);
998  if (d->dragEnterEvent(e, ev->mimeData()))
999  ev->acceptProposedAction();
1000  break;
1001  }
1002  case QEvent::DragLeave:
1003  d->dragLeaveEvent();
1004  break;
1005  case QEvent::DragMove: {
1006  QDragMoveEvent *ev = static_cast<QDragMoveEvent *>(e);
1007  if (d->dragMoveEvent(e, ev->mimeData(), matrix.map(ev->pos())))
1008  ev->acceptProposedAction();
1009  break;
1010  }
1011  case QEvent::Drop: {
1012  QDropEvent *ev = static_cast<QDropEvent *>(e);
1013  if (d->dropEvent(ev->mimeData(), matrix.map(ev->pos()), ev->dropAction(), ev->source()))
1014  ev->acceptProposedAction();
1015  break;
1016  }
1017 #endif
1018 
1019 #ifndef QT_NO_GRAPHICSVIEW
1021  QGraphicsSceneMouseEvent *ev = static_cast<QGraphicsSceneMouseEvent *>(e);
1022  d->mousePressEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), ev->buttons(),
1023  ev->screenPos());
1024  break; }
1026  QGraphicsSceneMouseEvent *ev = static_cast<QGraphicsSceneMouseEvent *>(e);
1027  d->mouseMoveEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), ev->buttons(),
1028  ev->screenPos());
1029  break; }
1031  QGraphicsSceneMouseEvent *ev = static_cast<QGraphicsSceneMouseEvent *>(e);
1032  d->mouseReleaseEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), ev->buttons(),
1033  ev->screenPos());
1034  break; }
1036  QGraphicsSceneMouseEvent *ev = static_cast<QGraphicsSceneMouseEvent *>(e);
1037  d->mouseDoubleClickEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), ev->buttons(),
1038  ev->screenPos());
1039  break; }
1042  d->contextMenuEvent(ev->screenPos(), matrix.map(ev->pos()), contextWidget);
1043  break; }
1044 
1046  QGraphicsSceneHoverEvent *ev = static_cast<QGraphicsSceneHoverEvent *>(e);
1047  d->mouseMoveEvent(ev, Qt::NoButton, matrix.map(ev->pos()), ev->modifiers(),Qt::NoButton,
1048  ev->screenPos());
1049  break; }
1050 
1053  if (d->dragEnterEvent(e, ev->mimeData()))
1054  ev->acceptProposedAction();
1055  break; }
1057  d->dragLeaveEvent();
1058  break;
1061  if (d->dragMoveEvent(e, ev->mimeData(), matrix.map(ev->pos())))
1062  ev->acceptProposedAction();
1063  break; }
1066  if (d->dropEvent(ev->mimeData(), matrix.map(ev->pos()), ev->dropAction(), ev->source()))
1067  ev->accept();
1068  break; }
1069 #endif // QT_NO_GRAPHICSVIEW
1070 #ifdef QT_KEYPAD_NAVIGATION
1071  case QEvent::EnterEditFocus:
1072  case QEvent::LeaveEditFocus:
1073  if (QApplication::keypadNavigationEnabled())
1074  d->editFocusEvent(e);
1075  break;
1076 #endif
1078  if (d->interactionFlags & Qt::TextEditable) {
1079  QKeyEvent* ke = static_cast<QKeyEvent *>(e);
1080  if (ke->modifiers() == Qt::NoModifier
1081  || ke->modifiers() == Qt::ShiftModifier
1082  || ke->modifiers() == Qt::KeypadModifier) {
1083  if (ke->key() < Qt::Key_Escape) {
1084  ke->accept();
1085  } else {
1086  switch (ke->key()) {
1087  case Qt::Key_Return:
1088  case Qt::Key_Enter:
1089  case Qt::Key_Delete:
1090  case Qt::Key_Home:
1091  case Qt::Key_End:
1092  case Qt::Key_Backspace:
1093  case Qt::Key_Left:
1094  case Qt::Key_Right:
1095  case Qt::Key_Up:
1096  case Qt::Key_Down:
1097  case Qt::Key_Tab:
1098  ke->accept();
1099  default:
1100  break;
1101  }
1102  }
1103 #ifndef QT_NO_SHORTCUT
1104  } else if (ke == QKeySequence::Copy
1105  || ke == QKeySequence::Paste
1106  || ke == QKeySequence::Cut
1107  || ke == QKeySequence::Redo
1108  || ke == QKeySequence::Undo
1121  || ke == QKeySequence::SelectAll
1122  ) {
1123  ke->accept();
1124 #endif
1125  }
1126  }
1127  break;
1128  default:
1129  break;
1130  }
1131 }
Qt::DropAction dropAction() const
Returns the action that was performed in this drag and drop.
const QMimeData * mimeData() const
This function returns the MIME data of the event.
double d
Definition: qnumeric_p.h:62
void acceptProposedAction()
Sets the drop action to be the proposed action.
Definition: qevent.h:492
The QKeyEvent class describes a key event.
Definition: qevent.h:224
QPoint screenPos() const
Returns the mouse cursor position in screen coordinates.
The QContextMenuEvent class contains parameters that describe a context menu event.
Definition: qevent.h:396
const QPoint & pos() const
Returns the position of the mouse pointer relative to the widget that received the event...
Definition: qevent.h:412
QPoint screenPos() const
Returns the position of the mouse cursor in screen coordinates at the moment the hover event was sent...
The QGraphicsSceneMouseEvent class provides mouse events in the graphics view framework.
Qt::DropAction dropAction() const
Returns the action to be performed on the data by the target.
Definition: qevent.h:494
Qt::MouseButton button() const
Returns the mouse button (if any) that caused the event.
QWidget * widget() const
Returns the widget where the event originated, or 0 if the event originates from another application...
The QDragMoveEvent class provides an event which is sent while a drag and drop action is in progress...
Definition: qevent.h:530
#define Q_D(Class)
Definition: qglobal.h:2482
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
Definition: qevent.h:95
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately after the event occurred.
Definition: qevent.cpp:999
int key() const
Returns the code of the key that was pressed or released.
Definition: qevent.h:231
QWidget * source() const
This function returns the QGraphicsView that created the QGraphicsSceneDragDropEvent.
bool isAccepted() const
Definition: qcoreevent.h:307
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifiers at the moment the hover event was sent.
QPointF pos() const
Returns the position of the mouse cursor in item coordinates at the moment the context menu was reque...
QPoint screenPos() const
Returns the position of the mouse cursor in screen coordinates at the moment the the context menu was...
The QGraphicsSceneEvent class provides a base class for all graphics view related events...
Qt::MouseButton button() const
Returns the button that caused the event.
Definition: qevent.h:101
void acceptProposedAction()
Sets the proposed action as accepted, i.e, the drop action is set to the proposed action...
The QMouseEvent class contains parameters that describe a mouse event.
Definition: qevent.h:85
The QDropEvent class provides an event which is sent when a drag and drop action is completed...
Definition: qevent.h:476
Qt::MouseButtons buttons() const
Returns the button state when the event was generated.
Definition: qevent.h:102
void map(int x, int y, int *tx, int *ty) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qmatrix.cpp:384
The QGraphicsSceneDragDropEvent class provides events for drag and drop in the graphics view framewor...
QWidget * source() const
If the source of the drag operation is a widget in this application, this function returns that sourc...
Definition: qevent.cpp:2739
The QDragEnterEvent class provides an event which is sent to a widget when a drag and drop action ent...
Definition: qevent.h:555
const QPoint & globalPos() const
Returns the mouse cursor position when the event was generated in global coordinates.
Definition: qevent.h:598
QPointF pos() const
Returns the position of the mouse cursor in item coordinates at the moment the hover event was sent...
QPointF pos() const
Returns the mouse cursor position in item coordinates.
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifiers in use at the time the event was sent.
void ignore()
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
Definition: qcoreevent.h:310
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
Definition: qcoreevent.h:309
const QMimeData * mimeData() const
Returns the data that was dropped on the widget and its associated MIME type information.
Definition: qevent.h:498
const QPoint & globalPos() const
Returns the global position of the mouse pointer at the time of the event.
Definition: qevent.h:413
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately before the event occurred.
Definition: qevent.h:79
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
const QPoint & pos() const
Returns the position where the drop was made.
Definition: qevent.h:486
Qt::MouseButtons buttons() const
Returns the combination of mouse buttons that were pressed at the time the event was sent...
QPointF pos() const
Returns the mouse position of the event relative to the view that sent the event. ...
The QGraphicsSceneHoverEvent class provides hover events in the graphics view framework.
The QHelpEvent class provides an event that is used to request helpful information about a particular...
Definition: qevent.h:586
The QGraphicsSceneContextMenuEvent class provides context menu events in the graphics view framework...
const QPoint & pos() const
Returns the mouse cursor position when the event was generated, relative to the widget to which the e...
Definition: qevent.h:597

◆ processEvent() [2/2]

void QTextControl::processEvent ( QEvent e,
const QPointF coordinateOffset = QPointF(),
QWidget contextWidget = 0 
)

Definition at line 903 of file qtextcontrol.cpp.

904 {
905  QMatrix m;
906  m.translate(coordinateOffset.x(), coordinateOffset.y());
907  processEvent(e, m, contextWidget);
908 }
The QMatrix class specifies 2D transformations of a coordinate system.
Definition: qmatrix.h:61
QMatrix & translate(qreal dx, qreal dy)
Moves the coordinate system dx along the x axis and dy along the y axis, and returns a reference to t...
Definition: qmatrix.cpp:922
virtual void processEvent(QEvent *e, const QMatrix &matrix, QWidget *contextWidget=0)
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287

◆ redo

void QTextControl::redo ( )
slot

Definition at line 775 of file qtextcontrol.cpp.

Referenced by createStandardContextMenu().

776 {
777  Q_D(QTextControl);
778  d->repaintSelection();
779  const int oldCursorPos = d->cursor.position();
780  d->doc->redo(&d->cursor);
781  if (d->cursor.position() != oldCursorPos)
785 }
double d
Definition: qnumeric_p.h:62
virtual void ensureCursorVisible()
#define Q_D(Class)
Definition: qglobal.h:2482
#define emit
Definition: qobjectdefs.h:76
void microFocusChanged()
void cursorPositionChanged()

◆ redoAvailable

void QTextControl::redoAvailable ( bool  b)
signal

◆ selectAll

void QTextControl::selectAll ( )
slot

Definition at line 893 of file qtextcontrol.cpp.

Referenced by createStandardContextMenu().

894 {
895  Q_D(QTextControl);
896  const int selectionLength = qAbs(d->cursor.position() - d->cursor.anchor());
897  d->cursor.select(QTextCursor::Document);
898  d->selectionChanged(selectionLength != qAbs(d->cursor.position() - d->cursor.anchor()));
899  d->cursorIsFocusIndicator = false;
901 }
double d
Definition: qnumeric_p.h:62
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
#define Q_D(Class)
Definition: qglobal.h:2482
void updateRequest(const QRectF &rect=QRectF())
#define emit
Definition: qobjectdefs.h:76

◆ selectionChanged

void QTextControl::selectionChanged ( )
signal

◆ selectionRect() [1/2]

QRectF QTextControl::selectionRect ( const QTextCursor cursor) const

Definition at line 1423 of file qtextcontrol.cpp.

Referenced by QTextBrowserPrivate::setSource().

1424 {
1425  Q_D(const QTextControl);
1426 
1427  QRectF r = d->rectForPosition(cursor.selectionStart());
1428 
1429  if (cursor.hasComplexSelection() && cursor.currentTable()) {
1430  QTextTable *table = cursor.currentTable();
1431 
1432  r = d->doc->documentLayout()->frameBoundingRect(table);
1433  /*
1434  int firstRow, numRows, firstColumn, numColumns;
1435  cursor.selectedTableCells(&firstRow, &numRows, &firstColumn, &numColumns);
1436 
1437  const QTextTableCell firstCell = table->cellAt(firstRow, firstColumn);
1438  const QTextTableCell lastCell = table->cellAt(firstRow + numRows - 1, firstColumn + numColumns - 1);
1439 
1440  const QAbstractTextDocumentLayout * const layout = doc->documentLayout();
1441 
1442  QRectF tableSelRect = layout->blockBoundingRect(firstCell.firstCursorPosition().block());
1443 
1444  for (int col = firstColumn; col < firstColumn + numColumns; ++col) {
1445  const QTextTableCell cell = table->cellAt(firstRow, col);
1446  const qreal y = layout->blockBoundingRect(cell.firstCursorPosition().block()).top();
1447 
1448  tableSelRect.setTop(qMin(tableSelRect.top(), y));
1449  }
1450 
1451  for (int row = firstRow; row < firstRow + numRows; ++row) {
1452  const QTextTableCell cell = table->cellAt(row, firstColumn);
1453  const qreal x = layout->blockBoundingRect(cell.firstCursorPosition().block()).left();
1454 
1455  tableSelRect.setLeft(qMin(tableSelRect.left(), x));
1456  }
1457 
1458  for (int col = firstColumn; col < firstColumn + numColumns; ++col) {
1459  const QTextTableCell cell = table->cellAt(firstRow + numRows - 1, col);
1460  const qreal y = layout->blockBoundingRect(cell.lastCursorPosition().block()).bottom();
1461 
1462  tableSelRect.setBottom(qMax(tableSelRect.bottom(), y));
1463  }
1464 
1465  for (int row = firstRow; row < firstRow + numRows; ++row) {
1466  const QTextTableCell cell = table->cellAt(row, firstColumn + numColumns - 1);
1467  const qreal x = layout->blockBoundingRect(cell.lastCursorPosition().block()).right();
1468 
1469  tableSelRect.setRight(qMax(tableSelRect.right(), x));
1470  }
1471 
1472  r = tableSelRect.toRect();
1473  */
1474  } else if (cursor.hasSelection()) {
1475  const int position = cursor.selectionStart();
1476  const int anchor = cursor.selectionEnd();
1477  const QTextBlock posBlock = d->doc->findBlock(position);
1478  const QTextBlock anchorBlock = d->doc->findBlock(anchor);
1479  if (posBlock == anchorBlock && posBlock.isValid() && posBlock.layout()->lineCount()) {
1480  const QTextLine posLine = posBlock.layout()->lineForTextPosition(position - posBlock.position());
1481  const QTextLine anchorLine = anchorBlock.layout()->lineForTextPosition(anchor - anchorBlock.position());
1482 
1483  const int firstLine = qMin(posLine.lineNumber(), anchorLine.lineNumber());
1484  const int lastLine = qMax(posLine.lineNumber(), anchorLine.lineNumber());
1485  const QTextLayout *layout = posBlock.layout();
1486  r = QRectF();
1487  for (int i = firstLine; i <= lastLine; ++i) {
1488  r |= layout->lineAt(i).rect();
1489  r |= layout->lineAt(i).naturalTextRect(); // might be bigger in the case of wrap not enabled
1490  }
1491  r.translate(blockBoundingRect(posBlock).topLeft());
1492  } else {
1493  QRectF anchorRect = d->rectForPosition(cursor.selectionEnd());
1494  r |= anchorRect;
1495  r |= boundingRectOfFloatsInSelection(cursor);
1496  QRectF frameRect(d->doc->documentLayout()->frameBoundingRect(cursor.currentFrame()));
1497  r.setLeft(frameRect.left());
1498  r.setRight(frameRect.right());
1499  }
1500  if (r.isValid())
1501  r.adjust(-1, -1, 1, 1);
1502  }
1503 
1504  return r;
1505 }
double d
Definition: qnumeric_p.h:62
virtual QRectF blockBoundingRect(const QTextBlock &block) const
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:661
void setLeft(qreal pos)
Sets the left edge of the rectangle to the given x coordinate.
Definition: qrect.h:670
int selectionEnd() const
Returns the end of the selection or position() if the cursor doesn&#39;t have a selection.
The QTextLine class represents a line of text inside a QTextLayout.
Definition: qtextlayout.h:197
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
static QRectF boundingRectOfFloatsInSelection(const QTextCursor &cursor)
#define Q_D(Class)
Definition: qglobal.h:2482
void setRight(qreal pos)
Sets the right edge of the rectangle to the given x coordinate.
Definition: qrect.h:672
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
QTextLine lineForTextPosition(int pos) const
Returns the line that contains the cursor position specified by pos.
int position() const
Returns the index of the block&#39;s first character within the document.
QTextFrame * currentFrame() const
Returns a pointer to the current frame.
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
bool hasSelection() const
Returns true if the cursor contains a selection; otherwise returns false.
QTextTable * currentTable() const
Returns a pointer to the current table if the cursor position() is inside a block that is part of a t...
int lineNumber() const
Returns the position of the line in the text engine.
Definition: qtextlayout.h:243
const char * layout
The QTextBlock class provides a container for text fragments in a QTextDocument.
Definition: qtextobject.h:199
The QTextTable class represents a table in a QTextDocument.
Definition: qtexttable.h:103
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
The QTextLayout class is used to lay out and render text.
Definition: qtextlayout.h:105
void adjust(qreal x1, qreal y1, qreal x2, qreal y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition: qrect.h:778
bool hasComplexSelection() const
Returns true if the cursor contains a selection that is not simply a range from selectionStart() to s...
bool isValid() const
Returns true if this text block is valid; otherwise returns false.
Definition: qtextobject.h:208
int selectionStart() const
Returns the start of the selection or position() if the cursor doesn&#39;t have a selection.
int lineCount() const
Returns the number of lines in this text layout.
QTextLayout * layout() const
Returns the QTextLayout that is used to lay out and display the block&#39;s contents. ...

◆ selectionRect() [2/2]

QRectF QTextControl::selectionRect ( ) const

Definition at line 1507 of file qtextcontrol.cpp.

Referenced by setExtraSelections(), setFocusToAnchor(), and setFocusToNextOrPreviousAnchor().

1508 {
1509  Q_D(const QTextControl);
1510  return selectionRect(d->cursor);
1511 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
QRectF selectionRect() const

◆ setAcceptRichText()

void QTextControl::setAcceptRichText ( bool  accept)

Definition at line 2278 of file qtextcontrol.cpp.

Referenced by QPlainTextEditControl::QPlainTextEditControl().

2279 {
2280  Q_D(QTextControl);
2281  d->acceptRichText = accept;
2282 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ setCurrentCharFormat()

void QTextControl::setCurrentCharFormat ( const QTextCharFormat format)

Definition at line 2841 of file qtextcontrol.cpp.

2842 {
2843  Q_D(QTextControl);
2844  d->cursor.setCharFormat(format);
2845  d->updateCurrentCharFormat();
2846 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ setCursorIsFocusIndicator()

void QTextControl::setCursorIsFocusIndicator ( bool  b)

Definition at line 2413 of file qtextcontrol.cpp.

Referenced by QTextBrowserPrivate::restoreHistoryEntry().

2414 {
2415  Q_D(QTextControl);
2416  d->cursorIsFocusIndicator = b;
2417  d->repaintCursor();
2418 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ setCursorWidth()

void QTextControl::setCursorWidth ( int  width)

Definition at line 2261 of file qtextcontrol.cpp.

2262 {
2263  Q_D(QTextControl);
2264 #ifdef QT_NO_PROPERTIES
2265  Q_UNUSED(width);
2266 #else
2267  d->doc->documentLayout()->setProperty("cursorWidth", width);
2268 #endif
2269  d->repaintCursor();
2270 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
#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

◆ setDocument()

void QTextControl::setDocument ( QTextDocument document)

Definition at line 812 of file qtextcontrol.cpp.

Referenced by QPlainTextEditPrivate::init(), and QGraphicsTextItem::setDocument().

813 {
814  Q_D(QTextControl);
815  if (d->doc == document)
816  return;
817 
818  d->doc->disconnect(this);
819  d->doc->documentLayout()->disconnect(this);
820  d->doc->documentLayout()->setPaintDevice(0);
821 
822  if (d->doc->parent() == this)
823  delete d->doc;
824 
825  d->doc = 0;
826  d->setContent(Qt::RichText, QString(), document);
827 }
double d
Definition: qnumeric_p.h:62
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_D(Class)
Definition: qglobal.h:2482

◆ setDragEnabled()

void QTextControl::setDragEnabled ( bool  enabled)

Definition at line 2427 of file qtextcontrol.cpp.

2428 {
2429  Q_D(QTextControl);
2430  d->dragEnabled = enabled;
2431 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
#define enabled

◆ setExtraSelections()

void QTextControl::setExtraSelections ( const QList< QTextEdit::ExtraSelection > &  selections)

Definition at line 2286 of file qtextcontrol.cpp.

2287 {
2288  Q_D(QTextControl);
2289 
2291  for (int i = 0; i < d->extraSelections.count(); ++i) {
2292  const QAbstractTextDocumentLayout::Selection &esel = d->extraSelections.at(i);
2293  hash.insertMulti(esel.cursor.anchor(), i);
2294  }
2295 
2296  for (int i = 0; i < selections.count(); ++i) {
2297  const QTextEdit::ExtraSelection &sel = selections.at(i);
2299  if (it != hash.end()) {
2300  const QAbstractTextDocumentLayout::Selection &esel = d->extraSelections.at(it.value());
2301  if (esel.cursor.position() == sel.cursor.position()
2302  && esel.format == sel.format) {
2303  hash.erase(it);
2304  continue;
2305  }
2306  }
2307  QRectF r = selectionRect(sel.cursor);
2309  r.setLeft(0);
2310  r.setWidth(qreal(INT_MAX));
2311  }
2312  emit updateRequest(r);
2313  }
2314 
2315  for (QHash<int, int>::iterator it = hash.begin(); it != hash.end(); ++it) {
2316  const QAbstractTextDocumentLayout::Selection &esel = d->extraSelections.at(it.value());
2317  QRectF r = selectionRect(esel.cursor);
2319  r.setLeft(0);
2320  r.setWidth(qreal(INT_MAX));
2321  }
2322  emit updateRequest(r);
2323  }
2324 
2325  d->extraSelections.resize(selections.count());
2326  for (int i = 0; i < selections.count(); ++i) {
2327  d->extraSelections[i].cursor = selections.at(i).cursor;
2328  d->extraSelections[i].format = selections.at(i).format;
2329  }
2330 }
double d
Definition: qnumeric_p.h:62
static uint hash(const uchar *p, int n)
Definition: qhash.cpp:68
int anchor() const
Returns the anchor position; this is the same as position() unless there is a selection in which case...
double qreal
Definition: qglobal.h:1193
QTextCharFormat format
the format of the selection
void setLeft(qreal pos)
Sets the left edge of the rectangle to the given x coordinate.
Definition: qrect.h:670
#define it(className, varName)
QTextCursor cursor
A cursor that contains a selection in a QTextDocument.
Definition: qtextedit.h:224
QTextCursor cursor
the selection&#39;s cursor
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
#define Q_D(Class)
Definition: qglobal.h:2482
QRectF selectionRect() const
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
The QAbstractTextDocumentLayout::Selection class is a convenience class defining the parameters of a ...
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
void updateRequest(const QRectF &rect=QRectF())
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
#define emit
Definition: qobjectdefs.h:76
int position() const
Returns the absolute position of the cursor within the document.
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
bool boolProperty(int propertyId) const
Returns the value of the property specified by propertyId.
iterator begin()
Returns an STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:464
The QTextEdit::ExtraSelection structure provides a way of specifying a character format for a given s...
Definition: qtextedit.h:222
void setWidth(qreal w)
Sets the width of the rectangle to the given width.
Definition: qrect.h:784
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
Definition: qhash.h:865
iterator insertMulti(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:772
QTextCharFormat format
A format that is used to specify a foreground or background brush/color for the selection.
Definition: qtextedit.h:225
iterator erase(iterator it)
Removes the (key, value) pair associated with the iterator pos from the hash, and returns an iterator...
Definition: qhash.h:827
#define INT_MAX

◆ setFocus()

void QTextControl::setFocus ( bool  focus,
Qt::FocusReason  reason = Qt::OtherFocusReason 
)

Definition at line 2030 of file qtextcontrol.cpp.

2031 {
2033  reason);
2034  processEvent(&ev);
2035 }
virtual void processEvent(QEvent *e, const QMatrix &matrix, QWidget *contextWidget=0)
The QFocusEvent class contains event parameters for widget focus events.
Definition: qevent.h:275

◆ setFocusToAnchor()

bool QTextControl::setFocusToAnchor ( const QTextCursor newCursor)

Definition at line 2791 of file qtextcontrol.cpp.

Referenced by QTextBrowserPrivate::setSource().

2792 {
2793  Q_D(QTextControl);
2794 
2795  if (!(d->interactionFlags & Qt::LinksAccessibleByKeyboard))
2796  return false;
2797 
2798  // Verify that this is an anchor.
2799  const QString anchorHref = d->anchorForCursor(newCursor);
2800  if (anchorHref.isEmpty())
2801  return false;
2802 
2803  // and process it
2804  QRectF crect = selectionRect();
2805  emit updateRequest(crect);
2806 
2807  d->cursor.setPosition(newCursor.selectionStart());
2808  d->cursor.setPosition(newCursor.selectionEnd(), QTextCursor::KeepAnchor);
2809  d->cursorIsFocusIndicator = true;
2810 
2811  crect = selectionRect();
2812  emit updateRequest(crect);
2813  emit visibilityRequest(crect);
2814  return true;
2815 }
double d
Definition: qnumeric_p.h:62
void visibilityRequest(const QRectF &rect)
int selectionEnd() const
Returns the end of the selection or position() if the cursor doesn&#39;t have a selection.
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_D(Class)
Definition: qglobal.h:2482
QRectF selectionRect() const
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
void updateRequest(const QRectF &rect=QRectF())
#define emit
Definition: qobjectdefs.h:76
int selectionStart() const
Returns the start of the selection or position() if the cursor doesn&#39;t have a selection.

◆ setFocusToNextOrPreviousAnchor()

bool QTextControl::setFocusToNextOrPreviousAnchor ( bool  next)

Definition at line 2754 of file qtextcontrol.cpp.

2755 {
2756  Q_D(QTextControl);
2757 
2758  if (!(d->interactionFlags & Qt::LinksAccessibleByKeyboard))
2759  return false;
2760 
2761  QRectF crect = selectionRect();
2762  emit updateRequest(crect);
2763 
2764  // If we don't have a current anchor, we start from the start/end
2765  if (!d->cursor.hasSelection()) {
2766  d->cursor = QTextCursor(d->doc);
2767  if (next)
2768  d->cursor.movePosition(QTextCursor::Start);
2769  else
2770  d->cursor.movePosition(QTextCursor::End);
2771  }
2772 
2773  QTextCursor newAnchor;
2774  if (findNextPrevAnchor(d->cursor, next, newAnchor)) {
2775  d->cursor = newAnchor;
2776  d->cursorIsFocusIndicator = true;
2777  } else {
2778  d->cursor.clearSelection();
2779  }
2780 
2781  if (d->cursor.hasSelection()) {
2782  crect = selectionRect();
2783  emit updateRequest(crect);
2784  emit visibilityRequest(crect);
2785  return true;
2786  } else {
2787  return false;
2788  }
2789 }
double d
Definition: qnumeric_p.h:62
bool findNextPrevAnchor(const QTextCursor &from, bool next, QTextCursor &newAnchor)
void visibilityRequest(const QRectF &rect)
#define Q_D(Class)
Definition: qglobal.h:2482
QRectF selectionRect() const
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
The QTextCursor class offers an API to access and modify QTextDocuments.
Definition: qtextcursor.h:70
void updateRequest(const QRectF &rect=QRectF())
#define emit
Definition: qobjectdefs.h:76

◆ setHtml

void QTextControl::setHtml ( const QString text)
slot

Definition at line 1160 of file qtextcontrol.cpp.

Referenced by QTextEditPrivate::init(), and QGraphicsTextItem::setHtml().

1161 {
1162  Q_D(QTextControl);
1163  d->setContent(Qt::RichText, text);
1164 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ setIgnoreUnusedNavigationEvents()

void QTextControl::setIgnoreUnusedNavigationEvents ( bool  ignore)

Definition at line 2383 of file qtextcontrol.cpp.

2384 {
2385  Q_D(QTextControl);
2386  d->ignoreUnusedNavigationEvents = ignore;
2387 }
double d
Definition: qnumeric_p.h:62
static bool ignore(const char *test, const char *const *table)
Definition: qaxserver.cpp:660
#define Q_D(Class)
Definition: qglobal.h:2482

◆ setOpenExternalLinks()

void QTextControl::setOpenExternalLinks ( bool  open)

Definition at line 2365 of file qtextcontrol.cpp.

Referenced by QGraphicsTextItem::setOpenExternalLinks().

2366 {
2367  Q_D(QTextControl);
2368  d->openExternalLinks = open;
2369 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
int open(const char *, int,...)

◆ setOverwriteMode()

void QTextControl::setOverwriteMode ( bool  overwrite)

Definition at line 2242 of file qtextcontrol.cpp.

2243 {
2244  Q_D(QTextControl);
2245  d->overwriteMode = overwrite;
2246 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ setPalette()

void QTextControl::setPalette ( const QPalette pal)

Definition at line 2978 of file qtextcontrol.cpp.

Referenced by QTextEditPrivate::init(), QPlainTextEditPrivate::init(), and QGraphicsTextItem::setDefaultTextColor().

2979 {
2980  Q_D(QTextControl);
2981  d->palette = pal;
2982 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ setPlainText

void QTextControl::setPlainText ( const QString text)
slot

Definition at line 1154 of file qtextcontrol.cpp.

Referenced by QPlainTextEditPrivate::init(), and QGraphicsTextItem::setPlainText().

1155 {
1156  Q_D(QTextControl);
1157  d->setContent(Qt::PlainText, text);
1158 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ setTextCursor()

void QTextControl::setTextCursor ( const QTextCursor cursor)

Definition at line 835 of file qtextcontrol.cpp.

Referenced by QTextEditPrivate::createAutoBulletList(), find(), QTextEditPrivate::pageUpDown(), QPlainTextEditPrivate::pageUpDown(), QTextBrowserPrivate::restoreHistoryEntry(), QTextBrowserPrivate::setSource(), and QGraphicsTextItem::setTextCursor().

836 {
837  Q_D(QTextControl);
838  d->cursorIsFocusIndicator = false;
839  const bool posChanged = cursor.position() != d->cursor.position();
840  const QTextCursor oldSelection = d->cursor;
841  d->cursor = cursor;
842  d->cursorOn = d->hasFocus && (d->interactionFlags & Qt::TextEditable);
843  d->_q_updateCurrentCharFormatAndSelection();
845  d->repaintOldAndNewSelection(oldSelection);
846  if (posChanged)
848 }
double d
Definition: qnumeric_p.h:62
virtual void ensureCursorVisible()
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextCursor class offers an API to access and modify QTextDocuments.
Definition: qtextcursor.h:70
#define emit
Definition: qobjectdefs.h:76
int position() const
Returns the absolute position of the cursor within the document.
void cursorPositionChanged()

◆ setTextInteractionFlags()

void QTextControl::setTextInteractionFlags ( Qt::TextInteractionFlags  flags)

Definition at line 2817 of file qtextcontrol.cpp.

Referenced by QTextBrowserPrivate::init(), and QGraphicsTextItem::setTextInteractionFlags().

2818 {
2819  Q_D(QTextControl);
2820  if (flags == d->interactionFlags)
2821  return;
2822  d->interactionFlags = flags;
2823 
2824  if (d->hasFocus)
2825  d->setBlinkingCursorEnabled(flags & (Qt::TextEditable | Qt::TextSelectableByKeyboard));
2826 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ setTextWidth()

void QTextControl::setTextWidth ( qreal  width)

Definition at line 2347 of file qtextcontrol.cpp.

Referenced by QGraphicsTextItem::setTextWidth().

2348 {
2349  Q_D(QTextControl);
2350  d->doc->setTextWidth(width);
2351 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ setWordSelectionEnabled()

void QTextControl::setWordSelectionEnabled ( bool  enabled)

Definition at line 2439 of file qtextcontrol.cpp.

2440 {
2441  Q_D(QTextControl);
2442  d->wordSelectionEnabled = enabled;
2443 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
#define enabled

◆ size()

QSizeF QTextControl::size ( ) const

Definition at line 2359 of file qtextcontrol.cpp.

Referenced by QGraphicsTextItem::setDocument(), and QTextBrowserPrivate::setSource().

2360 {
2361  Q_D(const QTextControl);
2362  return d->doc->size();
2363 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ textChanged

void QTextControl::textChanged ( )
signal

◆ textCursor()

QTextCursor QTextControl::textCursor ( ) const

◆ textInteractionFlags()

Qt::TextInteractionFlags QTextControl::textInteractionFlags ( ) const

Referenced by setTextInteractionFlags().

◆ textWidth()

qreal QTextControl::textWidth ( ) const

Definition at line 2353 of file qtextcontrol.cpp.

Referenced by QGraphicsTextItem::textWidth().

2354 {
2355  Q_D(const QTextControl);
2356  return d->doc->textWidth();
2357 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ timerEvent()

void QTextControl::timerEvent ( QTimerEvent event)
protectedvirtual

This event handler can be reimplemented in a subclass to receive timer events for the object.

QTimer provides a higher-level interface to the timer functionality, and also more general information about timers. The timer event is passed in the event parameter.

See also
startTimer(), killTimer(), event()

Reimplemented from QObject.

Definition at line 1138 of file qtextcontrol.cpp.

1139 {
1140  Q_D(QTextControl);
1141  if (e->timerId() == d->cursorBlinkTimer.timerId()) {
1142  d->cursorOn = !d->cursorOn;
1143 
1144  if (d->cursor.hasSelection())
1146  != 0);
1147 
1148  d->repaintCursor();
1149  } else if (e->timerId() == d->trippleClickTimer.timerId()) {
1150  d->trippleClickTimer.stop();
1151  }
1152 }
double d
Definition: qnumeric_p.h:62
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
static QStyle * style()
Returns the application&#39;s style object.
#define Q_D(Class)
Definition: qglobal.h:2482

◆ toHtml()

QString QTextControl::toHtml ( ) const
inline

Definition at line 125 of file qtextcontrol_p.h.

Referenced by QGraphicsTextItem::toHtml().

126  { return document()->toHtml(); }
QTextDocument * document() const
QString toHtml(const QByteArray &encoding=QByteArray()) const
Returns a string containing an HTML representation of the document.

◆ toPlainText()

QString QTextControl::toPlainText ( ) const
inline

Definition at line 122 of file qtextcontrol_p.h.

Referenced by QGraphicsTextItem::toPlainText().

123  { return document()->toPlainText(); }
QString toPlainText() const
Returns the plain text contained in the document.
QTextDocument * document() const

◆ undo

void QTextControl::undo ( )
slot

Definition at line 763 of file qtextcontrol.cpp.

Referenced by createStandardContextMenu().

764 {
765  Q_D(QTextControl);
766  d->repaintSelection();
767  const int oldCursorPos = d->cursor.position();
768  d->doc->undo(&d->cursor);
769  if (d->cursor.position() != oldCursorPos)
773 }
double d
Definition: qnumeric_p.h:62
virtual void ensureCursorVisible()
#define Q_D(Class)
Definition: qglobal.h:2482
#define emit
Definition: qobjectdefs.h:76
void microFocusChanged()
void cursorPositionChanged()

◆ undoAvailable

void QTextControl::undoAvailable ( bool  b)
signal

◆ updateRequest

void QTextControl::updateRequest ( const QRectF rect = QRectF())
signal

◆ visibilityRequest

void QTextControl::visibilityRequest ( const QRectF rect)
signal

Properties

◆ acceptRichText

bool QTextControl::acceptRichText
private

Definition at line 95 of file qtextcontrol_p.h.

◆ cursorWidth

int QTextControl::cursorWidth
private

Definition at line 96 of file qtextcontrol_p.h.

◆ html

QString QTextControl::html
private

Definition at line 92 of file qtextcontrol_p.h.

◆ ignoreUnusedNavigationEvents

bool QTextControl::ignoreUnusedNavigationEvents
private

Definition at line 99 of file qtextcontrol_p.h.

◆ openExternalLinks

bool QTextControl::openExternalLinks
private

Definition at line 98 of file qtextcontrol_p.h.

Referenced by QGraphicsTextItem::openExternalLinks().

◆ overwriteMode

bool QTextControl::overwriteMode
private

Definition at line 94 of file qtextcontrol_p.h.

◆ textInteractionFlags

Qt::TextInteractionFlags QTextControl::textInteractionFlags
private

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