Update/fix QTextBoundaryFinder simple usage cases in qtbase

Change-Id: I4d3000558bce86e2de3c32247915868ba18fc8b7
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
This commit is contained in:
Konstantin Ritt 2012-10-08 16:51:41 +03:00 committed by The Qt Project
parent a895359c19
commit 539ef45689
3 changed files with 12 additions and 16 deletions

View File

@ -157,27 +157,27 @@ private:
m_splitter->setPosition(start);
QScriptAnalysis itemAnalysis = m_analysis[start];
if (m_splitter->boundaryReasons() & QTextBoundaryFinder::StartWord) {
if (m_splitter->boundaryReasons() & QTextBoundaryFinder::StartOfItem)
itemAnalysis.flags = QScriptAnalysis::Uppercase;
m_splitter->toNextBoundary();
}
m_splitter->toNextBoundary();
const int end = start + length;
for (int i = start + 1; i < end; ++i) {
bool atWordBoundary = false;
bool atWordStart = false;
if (i == m_splitter->position()) {
if (m_splitter->boundaryReasons() & QTextBoundaryFinder::StartWord
&& m_analysis[i].flags < QScriptAnalysis::TabOrObject)
atWordBoundary = true;
if (m_splitter->boundaryReasons() & QTextBoundaryFinder::StartOfItem) {
Q_ASSERT(m_analysis[i].flags < QScriptAnalysis::TabOrObject);
atWordStart = true;
}
m_splitter->toNextBoundary();
}
if (m_analysis[i] == itemAnalysis
&& m_analysis[i].flags < QScriptAnalysis::TabOrObject
&& !atWordBoundary
&& !atWordStart
&& i - start < MaxItemLength)
continue;
@ -185,7 +185,7 @@ private:
start = i;
itemAnalysis = m_analysis[start];
if (atWordBoundary)
if (atWordStart)
itemAnalysis.flags = QScriptAnalysis::Uppercase;
}
m_items.append(QScriptItem(start, itemAnalysis));

View File

@ -949,7 +949,7 @@ QPair< int, int > QAccessibleTextWidget::getBoundaries(int offset, BoundaryType
sentenceFinder.setPosition(offsetWithinBlockText);
int prevBoundary = offsetWithinBlockText;
int nextBoundary = offsetWithinBlockText;
if (!sentenceFinder.isAtBoundary())
if (!(sentenceFinder.boundaryReasons() & QTextBoundaryFinder::StartOfItem))
prevBoundary = sentenceFinder.toPreviousBoundary();
nextBoundary = sentenceFinder.toNextBoundary();
if (nextBoundary != -1)

View File

@ -560,12 +560,8 @@ int QWindowsInputContext::reconvertString(RECONVERTSTRING *reconv)
// Find the word in the surrounding text.
QTextBoundaryFinder bounds(QTextBoundaryFinder::Word, surroundingText);
bounds.setPosition(pos);
if (bounds.isAtBoundary()) {
if (QTextBoundaryFinder::EndWord == bounds.boundaryReasons())
bounds.toPreviousBoundary();
} else {
if (bounds.position() > 0 && !(bounds.boundaryReasons() & QTextBoundaryFinder::StartOfItem))
bounds.toPreviousBoundary();
}
const int startPos = bounds.position();
bounds.toNextBoundary();
const int endPos = bounds.position();