summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>2010-02-17 15:58:53 (GMT)
committerThorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>2010-02-17 16:02:23 (GMT)
commit4dc56aa381d72335f8759da0bb8ca29897fce3a1 (patch)
treee45587f8ee3073f5bfd5345e229131cb7e662671 /src/gui
parent27f8dc149efa49bdea809df130b0c14d15359964 (diff)
downloadQt-4dc56aa381d72335f8759da0bb8ca29897fce3a1.zip
Qt-4dc56aa381d72335f8759da0bb8ca29897fce3a1.tar.gz
Qt-4dc56aa381d72335f8759da0bb8ca29897fce3a1.tar.bz2
Added QPlainTextEditor::anchorAt(const QPoint &pos)
The equivalent of QTextEdit::anchorAt. Done-with: mae
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/widgets/qplaintextedit.cpp20
-rw-r--r--src/gui/widgets/qplaintextedit.h2
2 files changed, 22 insertions, 0 deletions
diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp
index 0d798b7..ef9fac3 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.
diff --git a/src/gui/widgets/qplaintextedit.h b/src/gui/widgets/qplaintextedit.h
index 15cf0967..106ae6d 100644
--- a/src/gui/widgets/qplaintextedit.h
+++ b/src/gui/widgets/qplaintextedit.h
@@ -159,6 +159,8 @@ public:
QRect cursorRect(const QTextCursor &cursor) const;
QRect cursorRect() const;
+ QString anchorAt(const QPoint &pos) const;
+
bool overwriteMode() const;
void setOverwriteMode(bool overwrite);