summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qwidgettextcontrol.cpp
diff options
context:
space:
mode:
authorThomas Hartmann <Thomas.Hartmann@digia.com>2012-10-02 16:50:01 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-04 11:58:48 +0200
commit1fb3d849e426fafcd5af30ce8ee6a00a10891746 (patch)
tree524abcda43eb0e536153958baf01d2a20ab01271 /src/widgets/widgets/qwidgettextcontrol.cpp
parent642867d2ddae37bdf756e1466ba723b6b7f4e844 (diff)
compile fix for MSVC 2008 and std::upper_bound
qUpperBound was replaced by std::upper_bound. Unfortunately the STL of MSVC 2008 enforces the definition of the operator in both directions. Change-Id: I3e0f775c23e43332d106e0847d3611e488da6c06 Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Diffstat (limited to 'src/widgets/widgets/qwidgettextcontrol.cpp')
-rw-r--r--src/widgets/widgets/qwidgettextcontrol.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp
index ec3663ef84..a2e82306aa 100644
--- a/src/widgets/widgets/qwidgettextcontrol.cpp
+++ b/src/widgets/widgets/qwidgettextcontrol.cpp
@@ -1408,14 +1408,15 @@ QRectF QWidgetTextControlPrivate::rectForPosition(int position) const
return r;
}
-static inline bool firstFramePosLessThanCursorPos(QTextFrame *frame, int position)
-{
- return frame->firstPosition() < position;
-}
-
-static inline bool cursorPosLessThanLastFramePos(int position, QTextFrame *frame)
-{
- return position < frame->lastPosition();
+namespace {
+struct QTextFrameComparator {
+#if defined(Q_CC_MSVC) && _MSC_VER < 1600
+//The STL implementation of MSVC 2008 requires the definition
+ bool operator()(QTextFrame *frame1, QTextFrame *frame2) { return frame1->firstPosition() < frame2->firstPosition(); }
+#endif
+ bool operator()(QTextFrame *frame, int position) { return frame->firstPosition() < position; }
+ bool operator()(int position, QTextFrame *frame) { return position < frame->firstPosition(); }
+};
}
static QRectF boundingRectOfFloatsInSelection(const QTextCursor &cursor)
@@ -1425,9 +1426,9 @@ static QRectF boundingRectOfFloatsInSelection(const QTextCursor &cursor)
const QList<QTextFrame *> children = frame->childFrames();
const QList<QTextFrame *>::ConstIterator firstFrame = std::lower_bound(children.constBegin(), children.constEnd(),
- cursor.selectionStart(), firstFramePosLessThanCursorPos);
+ cursor.selectionStart(), QTextFrameComparator());
const QList<QTextFrame *>::ConstIterator lastFrame = std::upper_bound(children.constBegin(), children.constEnd(),
- cursor.selectionEnd(), cursorPosLessThanLastFramePos);
+ cursor.selectionEnd(), QTextFrameComparator());
for (QList<QTextFrame *>::ConstIterator it = firstFrame; it != lastFrame; ++it) {
if ((*it)->frameFormat().position() != QTextFrameFormat::InFlow)
r |= frame->document()->documentLayout()->frameBoundingRect(*it);