QtGui: fix deprecated QChar conversions
Conversions from non-char-types to QChar are going to be deprecated. Use QChar::fromUcs2(), fromUcs4(), QLatin1Char(), or convert the constructor argument to char16_t. Change-Id: Ib45ebd5560aa3a2bc460037ab09773607485c6e2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
9e56d28663
commit
219e7bafa2
@ -1311,7 +1311,7 @@ QString QKeySequencePrivate::keyName(int key, QKeySequence::SequenceFormat forma
|
|||||||
|
|
||||||
if (key && key < Qt::Key_Escape && key != Qt::Key_Space) {
|
if (key && key < Qt::Key_Escape && key != Qt::Key_Space) {
|
||||||
if (!QChar::requiresSurrogates(key)) {
|
if (!QChar::requiresSurrogates(key)) {
|
||||||
p = QChar(ushort(key)).toUpper();
|
p = QChar::fromUcs2(key).toUpper();
|
||||||
} else {
|
} else {
|
||||||
p += QChar(QChar::highSurrogate(key));
|
p += QChar(QChar::highSurrogate(key));
|
||||||
p += QChar(QChar::lowSurrogate(key));
|
p += QChar(QChar::lowSurrogate(key));
|
||||||
@ -1348,7 +1348,7 @@ NonSymbol:
|
|||||||
// (Really depends on you locale)
|
// (Really depends on you locale)
|
||||||
if (i >= numKeyNames) {
|
if (i >= numKeyNames) {
|
||||||
if (!QChar::requiresSurrogates(key)) {
|
if (!QChar::requiresSurrogates(key)) {
|
||||||
p = QChar(ushort(key)).toUpper();
|
p = QChar::fromUcs2(key).toUpper();
|
||||||
} else {
|
} else {
|
||||||
p += QChar(QChar::highSurrogate(key));
|
p += QChar(QChar::highSurrogate(key));
|
||||||
p += QChar(QChar::lowSurrogate(key));
|
p += QChar(QChar::lowSurrogate(key));
|
||||||
|
@ -496,7 +496,7 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
|
|||||||
case QPlatformTheme::PasswordMaskDelay:
|
case QPlatformTheme::PasswordMaskDelay:
|
||||||
return QVariant(int(0));
|
return QVariant(int(0));
|
||||||
case QPlatformTheme::PasswordMaskCharacter:
|
case QPlatformTheme::PasswordMaskCharacter:
|
||||||
return QVariant(QChar(0x25CF));
|
return QVariant(QChar(u'\x25CF'));
|
||||||
case QPlatformTheme::StartDragVelocity:
|
case QPlatformTheme::StartDragVelocity:
|
||||||
return QVariant(int(0)); // no limit
|
return QVariant(int(0)); // no limit
|
||||||
case QPlatformTheme::UseFullScreenForPopupMenu:
|
case QPlatformTheme::UseFullScreenForPopupMenu:
|
||||||
|
@ -7191,7 +7191,7 @@ start_lengthVariant:
|
|||||||
} else if (!tabarraylen && !tabstops) {
|
} else if (!tabarraylen && !tabstops) {
|
||||||
tabstops = qRound(fm.horizontalAdvance(QLatin1Char('x'))*8);
|
tabstops = qRound(fm.horizontalAdvance(QLatin1Char('x'))*8);
|
||||||
}
|
}
|
||||||
} else if (chr == QChar(ushort(0x9c))) {
|
} else if (chr == u'\x9c') {
|
||||||
// string with multiple length variants
|
// string with multiple length variants
|
||||||
hasMoreLengthVariants = true;
|
hasMoreLengthVariants = true;
|
||||||
break;
|
break;
|
||||||
|
@ -2189,9 +2189,9 @@ QString Scanner::preprocess(const QString &input, bool *hasEscapeSequences)
|
|||||||
|
|
||||||
hexCount = qMin(hexCount, 6);
|
hexCount = qMin(hexCount, 6);
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
ushort code = output.midRef(hexStart, hexCount).toUShort(&ok, 16);
|
const char16_t code = output.midRef(hexStart, hexCount).toUShort(&ok, 16);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
output.replace(hexStart - 1, hexCount + 1, QChar(code));
|
output.replace(hexStart - 1, hexCount + 1, code);
|
||||||
i = hexStart;
|
i = hexStart;
|
||||||
} else {
|
} else {
|
||||||
i = hexStart;
|
i = hexStart;
|
||||||
|
@ -350,7 +350,7 @@ void QFontEngine::getGlyphPositions(const QGlyphLayout &glyphs, const QTransform
|
|||||||
glyphs_out[current] = glyphs.glyphs[i];
|
glyphs_out[current] = glyphs.glyphs[i];
|
||||||
++current;
|
++current;
|
||||||
if (glyphs.justifications[i].nKashidas) {
|
if (glyphs.justifications[i].nKashidas) {
|
||||||
QChar ch(0x640); // Kashida character
|
QChar ch = u'\x640'; // Kashida character
|
||||||
|
|
||||||
glyph_t kashidaGlyph = glyphIndex(ch.unicode());
|
glyph_t kashidaGlyph = glyphIndex(ch.unicode());
|
||||||
QFixed kashidaWidth;
|
QFixed kashidaWidth;
|
||||||
|
@ -183,15 +183,15 @@ QString Qt::convertFromPlainText(const QString &plain, Qt::WhiteSpaceMode mode)
|
|||||||
col = 0;
|
col = 0;
|
||||||
} else {
|
} else {
|
||||||
if (mode == Qt::WhiteSpacePre && plain[i] == QLatin1Char('\t')){
|
if (mode == Qt::WhiteSpacePre && plain[i] == QLatin1Char('\t')){
|
||||||
rich += QChar(0x00a0U);
|
rich += QChar::Nbsp;
|
||||||
++col;
|
++col;
|
||||||
while (col % 8) {
|
while (col % 8) {
|
||||||
rich += QChar(0x00a0U);
|
rich += QChar::Nbsp;
|
||||||
++col;
|
++col;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (mode == Qt::WhiteSpacePre && plain[i].isSpace())
|
else if (mode == Qt::WhiteSpacePre && plain[i].isSpace())
|
||||||
rich += QChar(0x00a0U);
|
rich += QChar::Nbsp;
|
||||||
else if (plain[i] == QLatin1Char('<'))
|
else if (plain[i] == QLatin1Char('<'))
|
||||||
rich += QLatin1String("<");
|
rich += QLatin1String("<");
|
||||||
else if (plain[i] == QLatin1Char('>'))
|
else if (plain[i] == QLatin1Char('>'))
|
||||||
|
@ -85,8 +85,8 @@ class QAbstractTextDocumentLayout;
|
|||||||
class QTextDocument;
|
class QTextDocument;
|
||||||
class QTextFrame;
|
class QTextFrame;
|
||||||
|
|
||||||
#define QTextBeginningOfFrame QChar(0xfdd0)
|
#define QTextBeginningOfFrame QChar(u'\xfdd0')
|
||||||
#define QTextEndOfFrame QChar(0xfdd1)
|
#define QTextEndOfFrame QChar(u'\xfdd1')
|
||||||
|
|
||||||
class QTextFragmentData : public QFragment<>
|
class QTextFragmentData : public QFragment<>
|
||||||
{
|
{
|
||||||
|
@ -3456,7 +3456,7 @@ void QTextDocumentLayoutPrivate::layoutBlock(const QTextBlock &bl, int blockPosi
|
|||||||
QFixed extraMargin;
|
QFixed extraMargin;
|
||||||
if (docPrivate->defaultTextOption.flags() & QTextOption::AddSpaceForLineAndParagraphSeparators) {
|
if (docPrivate->defaultTextOption.flags() & QTextOption::AddSpaceForLineAndParagraphSeparators) {
|
||||||
QFontMetricsF fm(bl.charFormat().font());
|
QFontMetricsF fm(bl.charFormat().font());
|
||||||
extraMargin = QFixed::fromReal(fm.horizontalAdvance(QChar(QChar(0x21B5))));
|
extraMargin = QFixed::fromReal(fm.horizontalAdvance(u'\x21B5'));
|
||||||
}
|
}
|
||||||
|
|
||||||
const QFixed indent = this->blockIndent(blockFormat);
|
const QFixed indent = this->blockIndent(blockFormat);
|
||||||
|
@ -1887,7 +1887,7 @@ void QTextEngine::validate() const
|
|||||||
layoutData->string = block.text();
|
layoutData->string = block.text();
|
||||||
const bool nextBlockValid = block.next().isValid();
|
const bool nextBlockValid = block.next().isValid();
|
||||||
if (!nextBlockValid && option.flags() & QTextOption::ShowDocumentTerminator) {
|
if (!nextBlockValid && option.flags() & QTextOption::ShowDocumentTerminator) {
|
||||||
layoutData->string += QChar(0xA7);
|
layoutData->string += QLatin1Char(0xA7);
|
||||||
} else if (option.flags() & QTextOption::ShowLineAndParagraphSeparators) {
|
} else if (option.flags() & QTextOption::ShowLineAndParagraphSeparators) {
|
||||||
layoutData->string += QLatin1Char(nextBlockValid ? 0xb6 : 0x20);
|
layoutData->string += QLatin1Char(nextBlockValid ? 0xb6 : 0x20);
|
||||||
}
|
}
|
||||||
@ -2413,9 +2413,9 @@ static void set(QJustificationPoint *point, int type, const QGlyphLayout &glyph,
|
|||||||
point->glyph = glyph;
|
point->glyph = glyph;
|
||||||
|
|
||||||
if (type >= Justification_Arabic_Normal) {
|
if (type >= Justification_Arabic_Normal) {
|
||||||
QChar ch(0x640); // Kashida character
|
const char32_t ch = U'\x640'; // Kashida character
|
||||||
|
|
||||||
glyph_t kashidaGlyph = fe->glyphIndex(ch.unicode());
|
glyph_t kashidaGlyph = fe->glyphIndex(ch);
|
||||||
if (kashidaGlyph != 0) {
|
if (kashidaGlyph != 0) {
|
||||||
QGlyphLayout g;
|
QGlyphLayout g;
|
||||||
g.numGlyphs = 1;
|
g.numGlyphs = 1;
|
||||||
@ -3034,7 +3034,7 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int
|
|||||||
{
|
{
|
||||||
QFontEngine *engine = fnt.d->engineForScript(QChar::Script_Common);
|
QFontEngine *engine = fnt.d->engineForScript(QChar::Script_Common);
|
||||||
|
|
||||||
QChar ellipsisChar(0x2026);
|
QChar ellipsisChar = u'\x2026';
|
||||||
|
|
||||||
// We only want to use the ellipsis character if it is from the main
|
// We only want to use the ellipsis character if it is from the main
|
||||||
// font (not one of the fallbacks), since using a fallback font
|
// font (not one of the fallbacks), since using a fallback font
|
||||||
@ -3076,6 +3076,8 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int
|
|||||||
if (!attributes)
|
if (!attributes)
|
||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
|
constexpr char16_t ZWJ = u'\x200d'; // ZERO-WIDTH JOINER
|
||||||
|
|
||||||
if (mode == Qt::ElideRight) {
|
if (mode == Qt::ElideRight) {
|
||||||
QFixed currentWidth;
|
QFixed currentWidth;
|
||||||
int pos;
|
int pos;
|
||||||
@ -3093,7 +3095,7 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int
|
|||||||
&& currentWidth < availableWidth);
|
&& currentWidth < availableWidth);
|
||||||
|
|
||||||
if (nextCharJoins(layoutData->string, pos))
|
if (nextCharJoins(layoutData->string, pos))
|
||||||
ellipsisText.prepend(QChar(0x200d) /* ZWJ */);
|
ellipsisText.prepend(ZWJ);
|
||||||
|
|
||||||
return stringMidRetainingBidiCC(layoutData->string,
|
return stringMidRetainingBidiCC(layoutData->string,
|
||||||
QString(), ellipsisText,
|
QString(), ellipsisText,
|
||||||
@ -3116,7 +3118,7 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int
|
|||||||
&& currentWidth < availableWidth);
|
&& currentWidth < availableWidth);
|
||||||
|
|
||||||
if (prevCharJoins(layoutData->string, pos))
|
if (prevCharJoins(layoutData->string, pos))
|
||||||
ellipsisText.append(QChar(0x200d) /* ZWJ */);
|
ellipsisText.append(ZWJ);
|
||||||
|
|
||||||
return stringMidRetainingBidiCC(layoutData->string,
|
return stringMidRetainingBidiCC(layoutData->string,
|
||||||
ellipsisText, QString(),
|
ellipsisText, QString(),
|
||||||
@ -3151,9 +3153,9 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int
|
|||||||
&& leftWidth + rightWidth < availableWidth);
|
&& leftWidth + rightWidth < availableWidth);
|
||||||
|
|
||||||
if (nextCharJoins(layoutData->string, leftPos))
|
if (nextCharJoins(layoutData->string, leftPos))
|
||||||
ellipsisText.prepend(QChar(0x200d) /* ZWJ */);
|
ellipsisText.prepend(ZWJ);
|
||||||
if (prevCharJoins(layoutData->string, rightPos))
|
if (prevCharJoins(layoutData->string, rightPos))
|
||||||
ellipsisText.append(QChar(0x200d) /* ZWJ */);
|
ellipsisText.append(ZWJ);
|
||||||
|
|
||||||
return layoutData->string.midRef(from, leftPos - from) + ellipsisText + layoutData->string.midRef(rightPos, to - rightPos);
|
return layoutData->string.midRef(from, leftPos - from) + ellipsisText + layoutData->string.midRef(rightPos, to - rightPos);
|
||||||
}
|
}
|
||||||
|
@ -835,14 +835,7 @@ QString QTextHtmlParser::parseEntity()
|
|||||||
if (ok) {
|
if (ok) {
|
||||||
if (uc >= 0x80 && uc < 0x80 + (sizeof(windowsLatin1ExtendedCharacters)/sizeof(windowsLatin1ExtendedCharacters[0])))
|
if (uc >= 0x80 && uc < 0x80 + (sizeof(windowsLatin1ExtendedCharacters)/sizeof(windowsLatin1ExtendedCharacters[0])))
|
||||||
uc = windowsLatin1ExtendedCharacters[uc - 0x80];
|
uc = windowsLatin1ExtendedCharacters[uc - 0x80];
|
||||||
QString str;
|
return QStringView{QChar::fromUcs4(uc)}.toString();
|
||||||
if (QChar::requiresSurrogates(uc)) {
|
|
||||||
str += QChar(QChar::highSurrogate(uc));
|
|
||||||
str += QChar(QChar::lowSurrogate(uc));
|
|
||||||
} else {
|
|
||||||
str = QChar(uc);
|
|
||||||
}
|
|
||||||
return str;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2612,7 +2612,7 @@ void QTextLine::draw(QPainter *p, const QPointF &pos, const QTextLayout::FormatR
|
|||||||
gf.width = iterator.itemWidth;
|
gf.width = iterator.itemWidth;
|
||||||
QPainterPrivate::get(p)->drawTextItem(QPointF(iterator.x.toReal(), y.toReal()), gf, eng);
|
QPainterPrivate::get(p)->drawTextItem(QPointF(iterator.x.toReal(), y.toReal()), gf, eng);
|
||||||
if (eng->option.flags() & QTextOption::ShowTabsAndSpaces) {
|
if (eng->option.flags() & QTextOption::ShowTabsAndSpaces) {
|
||||||
QChar visualTab(0x2192);
|
const QChar visualTab = u'\x2192';
|
||||||
int w = QFontMetrics(f).horizontalAdvance(visualTab);
|
int w = QFontMetrics(f).horizontalAdvance(visualTab);
|
||||||
qreal x = iterator.itemWidth.toReal() - w; // Right-aligned
|
qreal x = iterator.itemWidth.toReal() - w; // Right-aligned
|
||||||
if (x < 0)
|
if (x < 0)
|
||||||
@ -2694,7 +2694,7 @@ void QTextLine::draw(QPainter *p, const QPointF &pos, const QTextLayout::FormatR
|
|||||||
QBrush c = format.foreground();
|
QBrush c = format.foreground();
|
||||||
if (c.style() != Qt::NoBrush)
|
if (c.style() != Qt::NoBrush)
|
||||||
p->setPen(c.color());
|
p->setPen(c.color());
|
||||||
QChar visualSpace(si.analysis.flags == QScriptAnalysis::Space ? (ushort)0xb7 : (ushort)0xb0);
|
const QChar visualSpace = si.analysis.flags == QScriptAnalysis::Space ? u'\xb7' : u'\xb0';
|
||||||
QFont oldFont = p->font();
|
QFont oldFont = p->font();
|
||||||
p->setFont(eng->font(si));
|
p->setFont(eng->font(si));
|
||||||
p->drawText(QPointF(iterator.x.toReal(), itemBaseLine.toReal()), visualSpace);
|
p->drawText(QPointF(iterator.x.toReal(), itemBaseLine.toReal()), visualSpace);
|
||||||
|
@ -213,7 +213,7 @@ QString QTextList::itemText(const QTextBlock &blockIt) const
|
|||||||
int c = item;
|
int c = item;
|
||||||
while (c > 0) {
|
while (c > 0) {
|
||||||
c--;
|
c--;
|
||||||
result.prepend(QChar(baseChar + (c % 26)));
|
result.prepend(QChar::fromUcs2(baseChar + (c % 26)));
|
||||||
c /= 26;
|
c /= 26;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -465,7 +465,7 @@ int QTextMarkdownImporter::cbText(int textType, const char *text, unsigned size)
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case MD_TEXT_NULLCHAR:
|
case MD_TEXT_NULLCHAR:
|
||||||
s = QString(QChar(0xFFFD)); // CommonMark-required replacement for null
|
s = QString(QChar(u'\xFFFD')); // CommonMark-required replacement for null
|
||||||
break;
|
break;
|
||||||
case MD_TEXT_BR:
|
case MD_TEXT_BR:
|
||||||
s = QString(Newline);
|
s = QString(Newline);
|
||||||
|
@ -59,7 +59,7 @@ static const QChar Space = QLatin1Char(' ');
|
|||||||
static const QChar Tab = QLatin1Char('\t');
|
static const QChar Tab = QLatin1Char('\t');
|
||||||
static const QChar Newline = QLatin1Char('\n');
|
static const QChar Newline = QLatin1Char('\n');
|
||||||
static const QChar CarriageReturn = QLatin1Char('\r');
|
static const QChar CarriageReturn = QLatin1Char('\r');
|
||||||
static const QChar LineBreak = QChar(0x2028);
|
static const QChar LineBreak = u'\x2028';
|
||||||
static const QChar DoubleQuote = QLatin1Char('"');
|
static const QChar DoubleQuote = QLatin1Char('"');
|
||||||
static const QChar Backtick = QLatin1Char('`');
|
static const QChar Backtick = QLatin1Char('`');
|
||||||
static const QChar Backslash = QLatin1Char('\\');
|
static const QChar Backslash = QLatin1Char('\\');
|
||||||
|
@ -349,7 +349,7 @@ void QTextOdfWriter::writeBlock(QXmlStreamWriter &writer, const QTextBlock &bloc
|
|||||||
writer.writeStartElement(textNS, QString::fromLatin1("span"));
|
writer.writeStartElement(textNS, QString::fromLatin1("span"));
|
||||||
|
|
||||||
QString fragmentText = frag.fragment().text();
|
QString fragmentText = frag.fragment().text();
|
||||||
if (fragmentText.length() == 1 && fragmentText[0] == QChar(0xFFFC)) { // its an inline character.
|
if (fragmentText.length() == 1 && fragmentText[0] == u'\xFFFC') { // its an inline character.
|
||||||
writeInlineCharacter(writer, frag.fragment());
|
writeInlineCharacter(writer, frag.fragment());
|
||||||
writer.writeEndElement(); // span
|
writer.writeEndElement(); // span
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user