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 (!QChar::requiresSurrogates(key)) {
|
||||
p = QChar(ushort(key)).toUpper();
|
||||
p = QChar::fromUcs2(key).toUpper();
|
||||
} else {
|
||||
p += QChar(QChar::highSurrogate(key));
|
||||
p += QChar(QChar::lowSurrogate(key));
|
||||
@ -1348,7 +1348,7 @@ NonSymbol:
|
||||
// (Really depends on you locale)
|
||||
if (i >= numKeyNames) {
|
||||
if (!QChar::requiresSurrogates(key)) {
|
||||
p = QChar(ushort(key)).toUpper();
|
||||
p = QChar::fromUcs2(key).toUpper();
|
||||
} else {
|
||||
p += QChar(QChar::highSurrogate(key));
|
||||
p += QChar(QChar::lowSurrogate(key));
|
||||
|
@ -496,7 +496,7 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
|
||||
case QPlatformTheme::PasswordMaskDelay:
|
||||
return QVariant(int(0));
|
||||
case QPlatformTheme::PasswordMaskCharacter:
|
||||
return QVariant(QChar(0x25CF));
|
||||
return QVariant(QChar(u'\x25CF'));
|
||||
case QPlatformTheme::StartDragVelocity:
|
||||
return QVariant(int(0)); // no limit
|
||||
case QPlatformTheme::UseFullScreenForPopupMenu:
|
||||
|
@ -7191,7 +7191,7 @@ start_lengthVariant:
|
||||
} else if (!tabarraylen && !tabstops) {
|
||||
tabstops = qRound(fm.horizontalAdvance(QLatin1Char('x'))*8);
|
||||
}
|
||||
} else if (chr == QChar(ushort(0x9c))) {
|
||||
} else if (chr == u'\x9c') {
|
||||
// string with multiple length variants
|
||||
hasMoreLengthVariants = true;
|
||||
break;
|
||||
|
@ -2189,9 +2189,9 @@ QString Scanner::preprocess(const QString &input, bool *hasEscapeSequences)
|
||||
|
||||
hexCount = qMin(hexCount, 6);
|
||||
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) {
|
||||
output.replace(hexStart - 1, hexCount + 1, QChar(code));
|
||||
output.replace(hexStart - 1, hexCount + 1, code);
|
||||
i = hexStart;
|
||||
} else {
|
||||
i = hexStart;
|
||||
|
@ -350,7 +350,7 @@ void QFontEngine::getGlyphPositions(const QGlyphLayout &glyphs, const QTransform
|
||||
glyphs_out[current] = glyphs.glyphs[i];
|
||||
++current;
|
||||
if (glyphs.justifications[i].nKashidas) {
|
||||
QChar ch(0x640); // Kashida character
|
||||
QChar ch = u'\x640'; // Kashida character
|
||||
|
||||
glyph_t kashidaGlyph = glyphIndex(ch.unicode());
|
||||
QFixed kashidaWidth;
|
||||
|
@ -183,15 +183,15 @@ QString Qt::convertFromPlainText(const QString &plain, Qt::WhiteSpaceMode mode)
|
||||
col = 0;
|
||||
} else {
|
||||
if (mode == Qt::WhiteSpacePre && plain[i] == QLatin1Char('\t')){
|
||||
rich += QChar(0x00a0U);
|
||||
rich += QChar::Nbsp;
|
||||
++col;
|
||||
while (col % 8) {
|
||||
rich += QChar(0x00a0U);
|
||||
rich += QChar::Nbsp;
|
||||
++col;
|
||||
}
|
||||
}
|
||||
else if (mode == Qt::WhiteSpacePre && plain[i].isSpace())
|
||||
rich += QChar(0x00a0U);
|
||||
rich += QChar::Nbsp;
|
||||
else if (plain[i] == QLatin1Char('<'))
|
||||
rich += QLatin1String("<");
|
||||
else if (plain[i] == QLatin1Char('>'))
|
||||
|
@ -85,8 +85,8 @@ class QAbstractTextDocumentLayout;
|
||||
class QTextDocument;
|
||||
class QTextFrame;
|
||||
|
||||
#define QTextBeginningOfFrame QChar(0xfdd0)
|
||||
#define QTextEndOfFrame QChar(0xfdd1)
|
||||
#define QTextBeginningOfFrame QChar(u'\xfdd0')
|
||||
#define QTextEndOfFrame QChar(u'\xfdd1')
|
||||
|
||||
class QTextFragmentData : public QFragment<>
|
||||
{
|
||||
|
@ -3456,7 +3456,7 @@ void QTextDocumentLayoutPrivate::layoutBlock(const QTextBlock &bl, int blockPosi
|
||||
QFixed extraMargin;
|
||||
if (docPrivate->defaultTextOption.flags() & QTextOption::AddSpaceForLineAndParagraphSeparators) {
|
||||
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);
|
||||
|
@ -1887,7 +1887,7 @@ void QTextEngine::validate() const
|
||||
layoutData->string = block.text();
|
||||
const bool nextBlockValid = block.next().isValid();
|
||||
if (!nextBlockValid && option.flags() & QTextOption::ShowDocumentTerminator) {
|
||||
layoutData->string += QChar(0xA7);
|
||||
layoutData->string += QLatin1Char(0xA7);
|
||||
} else if (option.flags() & QTextOption::ShowLineAndParagraphSeparators) {
|
||||
layoutData->string += QLatin1Char(nextBlockValid ? 0xb6 : 0x20);
|
||||
}
|
||||
@ -2413,9 +2413,9 @@ static void set(QJustificationPoint *point, int type, const QGlyphLayout &glyph,
|
||||
point->glyph = glyph;
|
||||
|
||||
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) {
|
||||
QGlyphLayout g;
|
||||
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);
|
||||
|
||||
QChar ellipsisChar(0x2026);
|
||||
QChar ellipsisChar = u'\x2026';
|
||||
|
||||
// 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
|
||||
@ -3076,6 +3076,8 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int
|
||||
if (!attributes)
|
||||
return QString();
|
||||
|
||||
constexpr char16_t ZWJ = u'\x200d'; // ZERO-WIDTH JOINER
|
||||
|
||||
if (mode == Qt::ElideRight) {
|
||||
QFixed currentWidth;
|
||||
int pos;
|
||||
@ -3093,7 +3095,7 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int
|
||||
&& currentWidth < availableWidth);
|
||||
|
||||
if (nextCharJoins(layoutData->string, pos))
|
||||
ellipsisText.prepend(QChar(0x200d) /* ZWJ */);
|
||||
ellipsisText.prepend(ZWJ);
|
||||
|
||||
return stringMidRetainingBidiCC(layoutData->string,
|
||||
QString(), ellipsisText,
|
||||
@ -3116,7 +3118,7 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int
|
||||
&& currentWidth < availableWidth);
|
||||
|
||||
if (prevCharJoins(layoutData->string, pos))
|
||||
ellipsisText.append(QChar(0x200d) /* ZWJ */);
|
||||
ellipsisText.append(ZWJ);
|
||||
|
||||
return stringMidRetainingBidiCC(layoutData->string,
|
||||
ellipsisText, QString(),
|
||||
@ -3151,9 +3153,9 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int
|
||||
&& leftWidth + rightWidth < availableWidth);
|
||||
|
||||
if (nextCharJoins(layoutData->string, leftPos))
|
||||
ellipsisText.prepend(QChar(0x200d) /* ZWJ */);
|
||||
ellipsisText.prepend(ZWJ);
|
||||
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);
|
||||
}
|
||||
|
@ -835,14 +835,7 @@ QString QTextHtmlParser::parseEntity()
|
||||
if (ok) {
|
||||
if (uc >= 0x80 && uc < 0x80 + (sizeof(windowsLatin1ExtendedCharacters)/sizeof(windowsLatin1ExtendedCharacters[0])))
|
||||
uc = windowsLatin1ExtendedCharacters[uc - 0x80];
|
||||
QString str;
|
||||
if (QChar::requiresSurrogates(uc)) {
|
||||
str += QChar(QChar::highSurrogate(uc));
|
||||
str += QChar(QChar::lowSurrogate(uc));
|
||||
} else {
|
||||
str = QChar(uc);
|
||||
}
|
||||
return str;
|
||||
return QStringView{QChar::fromUcs4(uc)}.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2612,7 +2612,7 @@ void QTextLine::draw(QPainter *p, const QPointF &pos, const QTextLayout::FormatR
|
||||
gf.width = iterator.itemWidth;
|
||||
QPainterPrivate::get(p)->drawTextItem(QPointF(iterator.x.toReal(), y.toReal()), gf, eng);
|
||||
if (eng->option.flags() & QTextOption::ShowTabsAndSpaces) {
|
||||
QChar visualTab(0x2192);
|
||||
const QChar visualTab = u'\x2192';
|
||||
int w = QFontMetrics(f).horizontalAdvance(visualTab);
|
||||
qreal x = iterator.itemWidth.toReal() - w; // Right-aligned
|
||||
if (x < 0)
|
||||
@ -2694,7 +2694,7 @@ void QTextLine::draw(QPainter *p, const QPointF &pos, const QTextLayout::FormatR
|
||||
QBrush c = format.foreground();
|
||||
if (c.style() != Qt::NoBrush)
|
||||
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();
|
||||
p->setFont(eng->font(si));
|
||||
p->drawText(QPointF(iterator.x.toReal(), itemBaseLine.toReal()), visualSpace);
|
||||
|
@ -213,7 +213,7 @@ QString QTextList::itemText(const QTextBlock &blockIt) const
|
||||
int c = item;
|
||||
while (c > 0) {
|
||||
c--;
|
||||
result.prepend(QChar(baseChar + (c % 26)));
|
||||
result.prepend(QChar::fromUcs2(baseChar + (c % 26)));
|
||||
c /= 26;
|
||||
}
|
||||
}
|
||||
|
@ -465,7 +465,7 @@ int QTextMarkdownImporter::cbText(int textType, const char *text, unsigned size)
|
||||
#endif
|
||||
break;
|
||||
case MD_TEXT_NULLCHAR:
|
||||
s = QString(QChar(0xFFFD)); // CommonMark-required replacement for null
|
||||
s = QString(QChar(u'\xFFFD')); // CommonMark-required replacement for null
|
||||
break;
|
||||
case MD_TEXT_BR:
|
||||
s = QString(Newline);
|
||||
|
@ -59,7 +59,7 @@ static const QChar Space = QLatin1Char(' ');
|
||||
static const QChar Tab = QLatin1Char('\t');
|
||||
static const QChar Newline = QLatin1Char('\n');
|
||||
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 Backtick = QLatin1Char('`');
|
||||
static const QChar Backslash = QLatin1Char('\\');
|
||||
|
@ -349,7 +349,7 @@ void QTextOdfWriter::writeBlock(QXmlStreamWriter &writer, const QTextBlock &bloc
|
||||
writer.writeStartElement(textNS, QString::fromLatin1("span"));
|
||||
|
||||
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());
|
||||
writer.writeEndElement(); // span
|
||||
continue;
|
||||
|
Loading…
x
Reference in New Issue
Block a user