summaryrefslogtreecommitdiff
path: root/src/gui/widgets/qplaintextedit.cpp
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>2010-02-17 16:58:53 +0100
committerThorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>2010-02-17 17:02:23 +0100
commit4dc56aa381d72335f8759da0bb8ca29897fce3a1 (patch)
treee45587f8ee3073f5bfd5345e229131cb7e662671 /src/gui/widgets/qplaintextedit.cpp
parent27f8dc149efa49bdea809df130b0c14d15359964 (diff)
downloadqt4-tools-4dc56aa381d72335f8759da0bb8ca29897fce3a1.tar.gz
Added QPlainTextEditor::anchorAt(const QPoint &pos)
The equivalent of QTextEdit::anchorAt. Done-with: mae
Diffstat (limited to 'src/gui/widgets/qplaintextedit.cpp')
-rw-r--r--src/gui/widgets/qplaintextedit.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp
index 0d798b7ad7..ef9fac382d 100644
--- a/src/gui/widgets/qplaintextedit.cpp
+++ b/src/gui/widgets/qplaintextedit.cpp
@@ -1320,6 +1320,26 @@ QTextCursor QPlainTextEdit::textCursor() const
return d->control->textCursor();
}
+/*!
+ Returns the reference of the anchor at position \a pos, or an
+ empty string if no anchor exists at that point.
+
+ \since 4.7
+ */
+QString QPlainTextEdit::anchorAt(const QPoint &pos) const
+{
+ Q_D(const QPlainTextEdit);
+ int cursorPos = d->control->hitTest(pos + QPoint(d->horizontalOffset(),
+ d->verticalOffset()),
+ Qt::ExactHit);
+ if (cursorPos < 0)
+ return QString();
+
+ QTextDocumentPrivate *pieceTable = document()->docHandle();
+ QTextDocumentPrivate::FragmentIterator it = pieceTable->find(cursorPos);
+ QTextCharFormat fmt = pieceTable->formatCollection()->charFormat(it->format);
+ return fmt.anchorHref();
+}
/*!
Undoes the last operation.