Avoid more uses of non-explicit QChar(int) constructor

Will be gone in Qt6.

Task-number: QTCREATORBUG-24098
Change-Id: Id76b15bb11879b2e8ff0f71af45acbfb1720f763
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
hjk
2020-11-06 11:53:41 +01:00
parent 8edae33b42
commit eb45b8f9b9
5 changed files with 14 additions and 12 deletions

View File

@@ -986,7 +986,7 @@ int Lexer::scanString(ScanStringMode mode)
_tokenText += QChar(QChar::highSurrogate(codePoint)); _tokenText += QChar(QChar::highSurrogate(codePoint));
u = QChar::lowSurrogate(codePoint); u = QChar::lowSurrogate(codePoint);
} else { } else {
u = codePoint; u = QChar(codePoint);
} }
} break; } break;

View File

@@ -61,6 +61,11 @@
using namespace Core; using namespace Core;
namespace BinEditor {
namespace Internal {
const QChar MidpointChar = QLatin1Char(0xB7);
static QByteArray calculateHexPattern(const QByteArray &pattern) static QByteArray calculateHexPattern(const QByteArray &pattern)
{ {
QByteArray result; QByteArray result;
@@ -78,9 +83,6 @@ static QByteArray calculateHexPattern(const QByteArray &pattern)
return result; return result;
} }
namespace BinEditor {
namespace Internal {
class BinEditorWidgetPrivate : public EditorService class BinEditorWidgetPrivate : public EditorService
{ {
public: public:
@@ -567,7 +569,7 @@ Utils::optional<qint64> BinEditorWidget::posAt(const QPoint &pos, bool includeEm
break; break;
QChar qc(QLatin1Char(dataAt(dataPos))); QChar qc(QLatin1Char(dataAt(dataPos)));
if (!qc.isPrint()) if (!qc.isPrint())
qc = 0xB7; qc = MidpointChar;
x -= fontMetrics().horizontalAdvance(qc); x -= fontMetrics().horizontalAdvance(qc);
if (x <= 0) if (x <= 0)
break; break;
@@ -863,7 +865,7 @@ void BinEditorWidget::paintEvent(QPaintEvent *e)
break; break;
QChar qc(QLatin1Char(dataAt(pos, isOld))); QChar qc(QLatin1Char(dataAt(pos, isOld)));
if (qc.unicode() >= 127 || !qc.isPrint()) if (qc.unicode() >= 127 || !qc.isPrint())
qc = 0xB7; qc = MidpointChar;
printable += qc; printable += qc;
} }
} else { } else {

View File

@@ -84,7 +84,7 @@ void StringInputStream::appendInt(IntType i)
if (hexPrefix) if (hexPrefix)
pad -= 2; pad -= 2;
if (pad > 0) if (pad > 0)
m_target.append(QString('0', pad)); m_target.append(QString('0', QLatin1Char(pad)));
} }
m_target.append(n); m_target.append(n);
} }

View File

@@ -308,9 +308,9 @@ QString GdbMi::escapeCString(const QString &ba)
default: default:
if (c < 32 || c == 127) { if (c < 32 || c == 127) {
ret += '\\'; ret += '\\';
ret += ('0' + (c >> 6)); ret += QLatin1Char('0' + (c >> 6));
ret += ('0' + ((c >> 3) & 7)); ret += QLatin1Char('0' + ((c >> 3) & 7));
ret += ('0' + (c & 7)); ret += QLatin1Char('0' + (c & 7));
} else { } else {
ret += c; ret += c;
} }
@@ -521,7 +521,7 @@ static QString quoteUnprintableLatin1(const QString &ba)
for (int i = 0, n = ba.size(); i != n; ++i) { for (int i = 0, n = ba.size(); i != n; ++i) {
const unsigned char c = ba.at(i).unicode(); const unsigned char c = ba.at(i).unicode();
if (isprint(c)) { if (isprint(c)) {
res += c; res += ba.at(i);
} else { } else {
qsnprintf(buf, sizeof(buf) - 1, "\\%x", int(c)); qsnprintf(buf, sizeof(buf) - 1, "\\%x", int(c));
res += QLatin1String(buf); res += QLatin1String(buf);

View File

@@ -1189,7 +1189,7 @@ public:
return '\n'; return '\n';
if (m_key == Key_Escape) if (m_key == Key_Escape)
return QChar(27); return QChar(27);
return m_xkey; return QChar(m_xkey);
} }
QString toString() const QString toString() const