summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2012-05-25 05:00:28 +0300
committerQt by Nokia <qt-info@nokia.com>2012-06-07 21:18:36 +0200
commit8aac04f705c8f9e4193444b904f9819aea85b326 (patch)
tree6e1b0117717551f3fdeb11969dff98b4e4444e0f /src/corelib
parent824180a12249e48c0e3280fec64940825ce0aa6e (diff)
QTextBoundaryFinder: Consider soft hyphen as line breaking opportunity
SoftHyphen enum value was added to specify such a boundary reason Change-Id: I4248909eed6ab8cbca419de4dcf9fe917620a158 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/tools/qtextboundaryfinder.cpp10
-rw-r--r--src/corelib/tools/qtextboundaryfinder.h6
2 files changed, 11 insertions, 5 deletions
diff --git a/src/corelib/tools/qtextboundaryfinder.cpp b/src/corelib/tools/qtextboundaryfinder.cpp
index b3b3d83a83..1e12d6e4a3 100644
--- a/src/corelib/tools/qtextboundaryfinder.cpp
+++ b/src/corelib/tools/qtextboundaryfinder.cpp
@@ -160,6 +160,8 @@ static void init(QTextBoundaryFinder::BoundaryType type, const QChar *chars, int
\value NotAtBoundary The boundary finder is not at a boundary position.
\value StartWord The boundary finder is at the start of a word.
\value EndWord The boundary finder is at the end of a word.
+ \value SoftHyphen The boundary finder is at the soft hyphen
+ (can occur for a Line boundary type only).
*/
/*!
@@ -373,7 +375,7 @@ int QTextBoundaryFinder::toNextBoundary()
break;
case Line:
Q_ASSERT(pos);
- while (pos < length && d->attributes[pos-1].lineBreakType < HB_Break)
+ while (pos < length && d->attributes[pos-1].lineBreakType == HB_NoBreak)
++pos;
break;
}
@@ -415,7 +417,7 @@ int QTextBoundaryFinder::toPreviousBoundary()
--pos;
break;
case Line:
- while (pos > 0 && d->attributes[pos-1].lineBreakType < HB_Break)
+ while (pos > 0 && d->attributes[pos-1].lineBreakType == HB_NoBreak)
--pos;
break;
}
@@ -440,7 +442,7 @@ bool QTextBoundaryFinder::isAtBoundary() const
case Word:
return d->attributes[pos].wordBoundary;
case Line:
- return (pos > 0) ? d->attributes[pos-1].lineBreakType >= HB_Break : true;
+ return (pos > 0) ? d->attributes[pos-1].lineBreakType != HB_NoBreak : true;
case Sentence:
return d->attributes[pos].sentenceBoundary;
}
@@ -456,6 +458,8 @@ QTextBoundaryFinder::BoundaryReasons QTextBoundaryFinder::boundaryReasons() cons
return NotAtBoundary;
if (! isAtBoundary())
return NotAtBoundary;
+ if (t == Line && pos < length && d->attributes[pos-1].lineBreakType == HB_SoftHyphen)
+ return SoftHyphen;
if (pos == 0) {
if (d->attributes[pos].whiteSpace)
return NotAtBoundary;
diff --git a/src/corelib/tools/qtextboundaryfinder.h b/src/corelib/tools/qtextboundaryfinder.h
index dc26939664..61af89b208 100644
--- a/src/corelib/tools/qtextboundaryfinder.h
+++ b/src/corelib/tools/qtextboundaryfinder.h
@@ -70,8 +70,8 @@ public:
enum BoundaryReason {
NotAtBoundary = 0,
StartWord = 1,
- EndWord = 2
- //Hyphen
+ EndWord = 2,
+ SoftHyphen = 4
};
Q_DECLARE_FLAGS( BoundaryReasons, BoundaryReason )
@@ -105,6 +105,8 @@ private:
QTextBoundaryFinderPrivate *d;
};
+Q_DECLARE_OPERATORS_FOR_FLAGS(QTextBoundaryFinder::BoundaryReasons)
+
QT_END_NAMESPACE
QT_END_HEADER