Add QChar::SoftHyphen enum value
authorKonstantin Ritt <ritt.ks@gmail.com>
Fri, 29 Jun 2012 06:07:34 +0000 (09:07 +0300)
committerQt by Nokia <qt-info@nokia.com>
Tue, 3 Jul 2012 12:39:02 +0000 (14:39 +0200)
Just like for the QChar::ByteOrderMark, `ch == QChar::SoftHyphen`
is much more readable than `ch == 0x00ad // (soft-hyphen)`, etc.

Change-Id: I9c85f14cfd979037d35103c3259a435fd729b869
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
src/corelib/tools/qchar.h
src/corelib/tools/qunicodetools.cpp
src/gui/text/qtextengine.cpp
tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp

index 97edf12..760b7a5 100644 (file)
@@ -72,6 +72,7 @@ public:
         CarriageReturn = 0x000d,
         Space = 0x0020,
         Nbsp = 0x00a0,
+        SoftHyphen = 0x00ad,
         ReplacementCharacter = 0xfffd,
         ObjectReplacementCharacter = 0xfffc,
         ByteOrderMark = 0xfeff,
index 1fef6ae..f8db6cb 100644 (file)
@@ -480,7 +480,7 @@ static void getLineBreaks(const ushort *string, quint32 len, HB_CharAttributes *
         switch (LB::breakTable[cls][ncls < QUnicodeTables::LineBreak_SA ? ncls : QUnicodeTables::LineBreak_AL]) {
         case LB::DirectBreak:
             lineBreakType = HB_Break;
-            if (lucs4 == 0x00ad) // soft hyphen
+            if (lucs4 == QChar::SoftHyphen)
                 lineBreakType = HB_SoftHyphen;
             break;
         case LB::IndirectBreak:
index 41d12a6..3e5e89c 100644 (file)
@@ -3220,7 +3220,7 @@ QScriptItem &QTextLineItemIterator::next()
     }
     // show soft-hyphen at line-break
     if (si->position + itemLength >= lineEnd
-        && eng->layoutData->string.at(lineEnd - 1) == 0x00ad)
+        && eng->layoutData->string.at(lineEnd - 1).unicode() == QChar::SoftHyphen)
         glyphs.attributes[glyphsEnd - 1].dontPrint = false;
 
     itemWidth = 0;
index ad48ebf..045da9f 100644 (file)
@@ -550,7 +550,7 @@ void tst_QTextBoundaryFinder::isAtSoftHyphen_data()
     QTest::addColumn<QList<int> >("expectedBreakPositions");
 
     QString testString = QString::fromUtf8("I a-m break-able");
-    testString.replace(QLatin1Char('-'), QChar(0x00AD));
+    testString.replace(QLatin1Char('-'), QChar(QChar::SoftHyphen));
     QList<int> expectedBreakPositions;
     expectedBreakPositions << 0 << 2 << 4 << 6 << 12 << 16;
     QTest::newRow("Soft Hyphen") << testString << expectedBreakPositions;
@@ -564,7 +564,7 @@ void tst_QTextBoundaryFinder::isAtSoftHyphen()
     doTestData(testString, expectedBreakPositions, QTextBoundaryFinder::Line);
 
     QTextBoundaryFinder boundaryFinder(QTextBoundaryFinder::Line, testString);
-    for (int i = 0; (i = testString.indexOf(QChar(0x00AD), i)) != -1; ++i) {
+    for (int i = 0; (i = testString.indexOf(QChar(QChar::SoftHyphen), i)) != -1; ++i) {
         QVERIFY(expectedBreakPositions.contains(i + 1));
         boundaryFinder.setPosition(i + 1);
         QVERIFY(boundaryFinder.isAtBoundary());