QtWidgets: stop using QLatin1Char constructor for creating char literals
Required for porting away from QLatin1Char/QLatin1String in scope of QTBUG-98434. As a drive-by, fix qsizetype -> int narrowing conversion warnings for the touched lines. Change-Id: I133b80334b66e0a5ab9546dd8e1ff0631e79601e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
a7dc1e280b
commit
63b042fb21
@ -112,18 +112,18 @@ static QString buddyString(const QWidget *widget)
|
||||
/* This function will return the offset of the '&' in the text that would be
|
||||
preceding the accelerator character.
|
||||
If this text does not have an accelerator, -1 will be returned. */
|
||||
static int qt_accAmpIndex(const QString &text)
|
||||
static qsizetype qt_accAmpIndex(const QString &text)
|
||||
{
|
||||
#ifndef QT_NO_SHORTCUT
|
||||
if (text.isEmpty())
|
||||
return -1;
|
||||
|
||||
int fa = 0;
|
||||
while ((fa = text.indexOf(QLatin1Char('&'), fa)) != -1) {
|
||||
qsizetype fa = 0;
|
||||
while ((fa = text.indexOf(u'&', fa)) != -1) {
|
||||
++fa;
|
||||
if (fa < text.length()) {
|
||||
// ignore "&&"
|
||||
if (text.at(fa) == QLatin1Char('&')) {
|
||||
if (text.at(fa) == u'&') {
|
||||
|
||||
++fa;
|
||||
continue;
|
||||
@ -144,7 +144,7 @@ static int qt_accAmpIndex(const QString &text)
|
||||
QString qt_accStripAmp(const QString &text)
|
||||
{
|
||||
QString newText(text);
|
||||
int ampIndex = qt_accAmpIndex(newText);
|
||||
qsizetype ampIndex = qt_accAmpIndex(newText);
|
||||
if (ampIndex != -1)
|
||||
newText.remove(ampIndex, 1);
|
||||
|
||||
@ -154,7 +154,7 @@ QString qt_accStripAmp(const QString &text)
|
||||
QString qt_accHotKey(const QString &text)
|
||||
{
|
||||
#ifndef QT_NO_SHORTCUT
|
||||
int ampIndex = qt_accAmpIndex(text);
|
||||
qsizetype ampIndex = qt_accAmpIndex(text);
|
||||
if (ampIndex != -1)
|
||||
return QKeySequence(Qt::ALT).toString(QKeySequence::NativeText) + text.at(ampIndex + 1);
|
||||
#else
|
||||
|
@ -761,7 +761,7 @@ class AttributeFormatterRef {
|
||||
public:
|
||||
template <typename RHS>
|
||||
void operator=(RHS &&rhs)
|
||||
{ string += QLatin1String(key) + QLatin1Char(':') + std::forward<RHS>(rhs) + QLatin1Char(';'); }
|
||||
{ string += QLatin1String(key) + u':' + std::forward<RHS>(rhs) + u';'; }
|
||||
};
|
||||
|
||||
/*!
|
||||
@ -769,7 +769,7 @@ public:
|
||||
\brief Small string-builder class that supports a map-like API to serialize key-value pairs.
|
||||
\code
|
||||
AttributeFormatter attrs;
|
||||
attrs["foo"] = QLatinString("hello") + world + QLatin1Char('!');
|
||||
attrs["foo"] = QLatinString("hello") + world + u'!';
|
||||
\endcode
|
||||
The key type is always \c{const char*}, and the right-hand-side can
|
||||
be any QStringBuilder expression.
|
||||
@ -858,7 +858,7 @@ QString QAccessibleTextWidget::attributes(int offset, int *startOffset, int *end
|
||||
family = family.replace(u'=', QLatin1String("\\="));
|
||||
family = family.replace(u';', QLatin1String("\\;"));
|
||||
family = family.replace(u'\"', QLatin1String("\\\""));
|
||||
attrs["font-family"] = QLatin1Char('"') + family + QLatin1Char('"');
|
||||
attrs["font-family"] = u'"' + family + u'"';
|
||||
}
|
||||
|
||||
int fontSize = int(charFormatFont.pointSize());
|
||||
@ -966,7 +966,7 @@ QString QAccessibleTextWidget::text(int startOffset, int endOffset) const
|
||||
cursor.setPosition(startOffset, QTextCursor::MoveAnchor);
|
||||
cursor.setPosition(endOffset, QTextCursor::KeepAnchor);
|
||||
|
||||
return cursor.selectedText().replace(QChar(QChar::ParagraphSeparator), QLatin1Char('\n'));
|
||||
return cursor.selectedText().replace(QChar(QChar::ParagraphSeparator), u'\n');
|
||||
}
|
||||
|
||||
QPoint QAccessibleTextWidget::scrollBarPosition() const
|
||||
|
@ -963,10 +963,10 @@ void QFileDialog::setDirectory(const QString &directory)
|
||||
d->qFileDialogUi->newFolderButton->setEnabled(d->model->flags(root) & Qt::ItemIsDropEnabled);
|
||||
if (root != d->rootIndex()) {
|
||||
#if QT_CONFIG(fscompleter)
|
||||
if (directory.endsWith(QLatin1Char('/')))
|
||||
if (directory.endsWith(u'/'))
|
||||
d->completer->setCompletionPrefix(newDirectory);
|
||||
else
|
||||
d->completer->setCompletionPrefix(newDirectory + QLatin1Char('/'));
|
||||
d->completer->setCompletionPrefix(newDirectory + u'/');
|
||||
#endif
|
||||
d->setRootIndex(root);
|
||||
}
|
||||
@ -1065,7 +1065,7 @@ static inline QString fileFromPath(const QString &rootPath, QString path)
|
||||
if (path.at(0) == QDir::separator()
|
||||
#ifdef Q_OS_WIN
|
||||
//On Windows both cases can happen
|
||||
|| path.at(0) == QLatin1Char('/')
|
||||
|| path.at(0) == u'/'
|
||||
#endif
|
||||
) {
|
||||
path.remove(0, 1);
|
||||
@ -1089,8 +1089,8 @@ void QFileDialog::selectFile(const QString &filename)
|
||||
if (QFileInfo(filename).isRelative()) {
|
||||
url = d->options->initialDirectory();
|
||||
QString path = url.path();
|
||||
if (!path.endsWith(QLatin1Char('/')))
|
||||
path += QLatin1Char('/');
|
||||
if (!path.endsWith(u'/'))
|
||||
path += u'/';
|
||||
url.setPath(path + filename);
|
||||
} else {
|
||||
url = QUrl::fromLocalFile(filename);
|
||||
@ -1139,7 +1139,7 @@ void QFileDialog::selectUrl(const QUrl &url)
|
||||
#ifdef Q_OS_UNIX
|
||||
Q_AUTOTEST_EXPORT QString qt_tildeExpansion(const QString &path)
|
||||
{
|
||||
if (!path.startsWith(QLatin1Char('~')))
|
||||
if (!path.startsWith(u'~'))
|
||||
return path;
|
||||
int separatorPosition = path.indexOf(QDir::separator());
|
||||
if (separatorPosition < 0)
|
||||
@ -1185,7 +1185,7 @@ QStringList QFileDialogPrivate::typedFiles() const
|
||||
Q_Q(const QFileDialog);
|
||||
QStringList files;
|
||||
QString editText = lineEdit()->text();
|
||||
if (!editText.contains(QLatin1Char('"'))) {
|
||||
if (!editText.contains(u'"')) {
|
||||
#ifdef Q_OS_UNIX
|
||||
const QString prefix = q->directory().absolutePath() + QDir::separator();
|
||||
if (QFile::exists(prefix + editText))
|
||||
@ -1199,7 +1199,7 @@ QStringList QFileDialogPrivate::typedFiles() const
|
||||
} else {
|
||||
// " is used to separate files like so: "file1" "file2" "file3" ...
|
||||
// ### need escape character for filenames with quotes (")
|
||||
QStringList tokens = editText.split(QLatin1Char('\"'));
|
||||
QStringList tokens = editText.split(u'\"');
|
||||
for (int i=0; i<tokens.size(); ++i) {
|
||||
if ((i % 2) == 0)
|
||||
continue; // Every even token is a separator
|
||||
@ -1252,7 +1252,7 @@ QStringList QFileDialogPrivate::addDefaultSuffixToFiles(const QStringList &files
|
||||
// if the filename has no suffix, add the default suffix
|
||||
const QString defaultSuffix = options->defaultSuffix();
|
||||
if (!defaultSuffix.isEmpty() && !info.isDir() && !info.fileName().contains(u'.'))
|
||||
name += QLatin1Char('.') + defaultSuffix;
|
||||
name += u'.' + defaultSuffix;
|
||||
|
||||
if (info.isAbsolute()) {
|
||||
files.append(name);
|
||||
@ -1261,8 +1261,8 @@ QStringList QFileDialogPrivate::addDefaultSuffixToFiles(const QStringList &files
|
||||
// This check is needed since we might be at the root directory
|
||||
// and on Windows it already ends with slash.
|
||||
QString path = rootPath();
|
||||
if (!path.endsWith(QLatin1Char('/')))
|
||||
path += QLatin1Char('/');
|
||||
if (!path.endsWith(u'/'))
|
||||
path += u'/';
|
||||
path += name;
|
||||
files.append(path);
|
||||
}
|
||||
@ -1352,8 +1352,8 @@ QStringList qt_make_filter_list(const QString &filter)
|
||||
return QStringList();
|
||||
|
||||
QString sep(QLatin1String(";;"));
|
||||
if (!filter.contains(sep) && filter.contains(QLatin1Char('\n')))
|
||||
sep = QLatin1Char('\n');
|
||||
if (!filter.contains(sep) && filter.contains(u'\n'))
|
||||
sep = u'\n';
|
||||
|
||||
return filter.split(sep);
|
||||
}
|
||||
@ -1554,8 +1554,8 @@ static QString nameFilterForMime(const QString &mimeType)
|
||||
if (mime.isDefault()) {
|
||||
return QFileDialog::tr("All files (*)");
|
||||
} else {
|
||||
const QString patterns = mime.globPatterns().join(QLatin1Char(' '));
|
||||
return mime.comment() + QLatin1String(" (") + patterns + QLatin1Char(')');
|
||||
const QString patterns = mime.globPatterns().join(u' ');
|
||||
return mime.comment() + QLatin1String(" (") + patterns + u')';
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
@ -3625,7 +3625,7 @@ void QFileDialogPrivate::_q_deleteCurrent()
|
||||
|
||||
void QFileDialogPrivate::_q_autoCompleteFileName(const QString &text)
|
||||
{
|
||||
if (text.startsWith(QLatin1String("//")) || text.startsWith(QLatin1Char('\\'))) {
|
||||
if (text.startsWith(QLatin1String("//")) || text.startsWith(u'\\')) {
|
||||
qFileDialogUi->listView->selectionModel()->clearSelection();
|
||||
return;
|
||||
}
|
||||
@ -3667,7 +3667,7 @@ void QFileDialogPrivate::_q_updateOkButton()
|
||||
const QStringList files = q->selectedFiles();
|
||||
QString lineEditText = lineEdit()->text();
|
||||
|
||||
if (lineEditText.startsWith(QLatin1String("//")) || lineEditText.startsWith(QLatin1Char('\\'))) {
|
||||
if (lineEditText.startsWith(QLatin1String("//")) || lineEditText.startsWith(u'\\')) {
|
||||
button->setEnabled(true);
|
||||
updateOkButtonText();
|
||||
return;
|
||||
@ -3697,7 +3697,7 @@ void QFileDialogPrivate::_q_updateOkButton()
|
||||
if (info.isDir()) {
|
||||
fileDir = info.canonicalFilePath();
|
||||
} else {
|
||||
fileDir = fn.mid(0, fn.lastIndexOf(QLatin1Char('/')));
|
||||
fileDir = fn.mid(0, fn.lastIndexOf(u'/'));
|
||||
fileName = fn.mid(fileDir.length() + 1);
|
||||
}
|
||||
if (lineEditText.contains(QLatin1String(".."))) {
|
||||
@ -3875,11 +3875,11 @@ void QFileDialogPrivate::_q_selectionChanged()
|
||||
allFiles.append(index.data().toString());
|
||||
}
|
||||
if (allFiles.count() > 1)
|
||||
for (int i = 0; i < allFiles.count(); ++i) {
|
||||
allFiles.replace(i, QString(QLatin1Char('"') + allFiles.at(i) + QLatin1Char('"')));
|
||||
for (qsizetype i = 0; i < allFiles.count(); ++i) {
|
||||
allFiles.replace(i, QString(u'"' + allFiles.at(i) + u'"'));
|
||||
}
|
||||
|
||||
QString finalFiles = allFiles.join(QLatin1Char(' '));
|
||||
QString finalFiles = allFiles.join(u' ');
|
||||
if (!finalFiles.isEmpty() && !lineEdit()->hasFocus() && lineEdit()->isVisible())
|
||||
lineEdit()->setText(finalFiles);
|
||||
else
|
||||
@ -4003,11 +4003,11 @@ bool QFileDialogPrivate::itemViewKeyboardEvent(QKeyEvent *event) {
|
||||
QString QFileDialogPrivate::getEnvironmentVariable(const QString &string)
|
||||
{
|
||||
#ifdef Q_OS_UNIX
|
||||
if (string.size() > 1 && string.startsWith(QLatin1Char('$'))) {
|
||||
if (string.size() > 1 && string.startsWith(u'$')) {
|
||||
return QString::fromLocal8Bit(qgetenv(QStringView{string}.mid(1).toLatin1().constData()));
|
||||
}
|
||||
#else
|
||||
if (string.size() > 2 && string.startsWith(QLatin1Char('%')) && string.endsWith(QLatin1Char('%'))) {
|
||||
if (string.size() > 2 && string.startsWith(u'%') && string.endsWith(u'%')) {
|
||||
return QString::fromLocal8Bit(qgetenv(QStringView{string}.mid(1, string.size() - 2).toLatin1().constData()));
|
||||
}
|
||||
#endif
|
||||
@ -4196,7 +4196,7 @@ QString QFSCompleter::pathFromIndex(const QModelIndex &index) const
|
||||
if (currentLocation == QDir::separator())
|
||||
return path.mid(currentLocation.length());
|
||||
#endif
|
||||
if (currentLocation.endsWith(QLatin1Char('/')))
|
||||
if (currentLocation.endsWith(u'/'))
|
||||
return path.mid(currentLocation.length());
|
||||
else
|
||||
return path.mid(currentLocation.length()+1);
|
||||
@ -4247,7 +4247,7 @@ QStringList QFSCompleter::splitPath(const QString &path) const
|
||||
#endif
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
bool startsFromRoot = !parts.isEmpty() && parts[0].endsWith(QLatin1Char(':'));
|
||||
bool startsFromRoot = !parts.isEmpty() && parts[0].endsWith(u':');
|
||||
#else
|
||||
bool startsFromRoot = pathCopy[0] == sep;
|
||||
#endif
|
||||
@ -4259,7 +4259,7 @@ QStringList QFSCompleter::splitPath(const QString &path) const
|
||||
dirModel = sourceModel;
|
||||
QString currentLocation = QDir::toNativeSeparators(dirModel->rootPath());
|
||||
#if defined(Q_OS_WIN)
|
||||
if (currentLocation.endsWith(QLatin1Char(':')))
|
||||
if (currentLocation.endsWith(u':'))
|
||||
currentLocation.append(sep);
|
||||
#endif
|
||||
if (currentLocation.contains(sep) && path != currentLocation) {
|
||||
|
@ -182,7 +182,7 @@ public:
|
||||
{
|
||||
#if defined(Q_OS_WIN)
|
||||
QString n(path);
|
||||
n.replace(QLatin1Char('\\'), QLatin1Char('/'));
|
||||
n.replace(u'\\', u'/');
|
||||
return n;
|
||||
#else // the compile should optimize away this
|
||||
return path;
|
||||
|
@ -1497,19 +1497,19 @@ void QMessageBox::keyPressEvent(QKeyEvent *e)
|
||||
if (e == QKeySequence::Copy) {
|
||||
const QLatin1String separator("---------------------------\n");
|
||||
QString textToCopy;
|
||||
textToCopy += separator + windowTitle() + QLatin1Char('\n') + separator // title
|
||||
+ d->label->text() + QLatin1Char('\n') + separator; // text
|
||||
textToCopy += separator + windowTitle() + u'\n' + separator // title
|
||||
+ d->label->text() + u'\n' + separator; // text
|
||||
|
||||
if (d->informativeLabel)
|
||||
textToCopy += d->informativeLabel->text() + QLatin1Char('\n') + separator;
|
||||
textToCopy += d->informativeLabel->text() + u'\n' + separator;
|
||||
|
||||
const QList<QAbstractButton *> buttons = d->buttonBox->buttons();
|
||||
for (const auto *button : buttons)
|
||||
textToCopy += button->text() + QLatin1String(" ");
|
||||
textToCopy += QLatin1Char('\n') + separator;
|
||||
textToCopy += u'\n' + separator;
|
||||
#if QT_CONFIG(textedit)
|
||||
if (d->detailsText)
|
||||
textToCopy += d->detailsText->text() + QLatin1Char('\n') + separator;
|
||||
textToCopy += d->detailsText->text() + u'\n' + separator;
|
||||
#endif
|
||||
QGuiApplication::clipboard()->setText(textToCopy);
|
||||
return;
|
||||
|
@ -206,7 +206,7 @@ QWizardField::QWizardField(QWizardPage *page, const QString &spec, QObject *obje
|
||||
: page(page), name(spec), mandatory(false), object(object), property(property),
|
||||
changedSignal(changedSignal)
|
||||
{
|
||||
if (name.endsWith(QLatin1Char('*'))) {
|
||||
if (name.endsWith(u'*')) {
|
||||
name.chop(1);
|
||||
mandatory = true;
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ void MainWindow::setupContents()
|
||||
|
||||
do {
|
||||
QString line = titlesFile.readLine().trimmed();
|
||||
QStringList parts = line.split(QLatin1Char('\t'), Qt::SkipEmptyParts);
|
||||
QStringList parts = line.split(u'\t', Qt::SkipEmptyParts);
|
||||
if (parts.size() != 2)
|
||||
break;
|
||||
|
||||
|
@ -670,7 +670,7 @@ void JavaStyle::drawControl(ControlElement control, const QStyleOption *option,
|
||||
textRect);
|
||||
QString s = menuitem->text;
|
||||
if (!s.isEmpty()) {
|
||||
int t = s.indexOf(QLatin1Char('\t'));
|
||||
qsizetype t = s.indexOf(u'\t');
|
||||
int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic |
|
||||
Qt::TextDontClip | Qt::TextSingleLine;
|
||||
if (!styleHint(SH_UnderlineShortcut, menuitem, widget))
|
||||
@ -2727,7 +2727,7 @@ QSize JavaStyle::sizeFromContents(ContentsType type,
|
||||
if (!menuItem->text.isEmpty()) {
|
||||
QFontMetrics metrics(menuItem->font);
|
||||
QString text = menuItem->text;
|
||||
text.remove(QLatin1Char('\t'));
|
||||
text.remove(u'\t');
|
||||
QRect textRect = metrics.boundingRect(text);
|
||||
width += textRect.width();
|
||||
if (height < textRect.height())
|
||||
|
@ -10611,7 +10611,7 @@ void QGraphicsSimpleTextItemPrivate::updateBoundingRect()
|
||||
br = QRectF();
|
||||
} else {
|
||||
QString tmp = text;
|
||||
tmp.replace(QLatin1Char('\n'), QChar::LineSeparator);
|
||||
tmp.replace(u'\n', QChar::LineSeparator);
|
||||
QStackTextEngine engine(tmp, font);
|
||||
QTextLayout layout(&engine);
|
||||
br = setupTextLayout(&layout);
|
||||
@ -10772,7 +10772,7 @@ void QGraphicsSimpleTextItem::paint(QPainter *painter, const QStyleOptionGraphic
|
||||
painter->setFont(d->font);
|
||||
|
||||
QString tmp = d->text;
|
||||
tmp.replace(QLatin1Char('\n'), QChar::LineSeparator);
|
||||
tmp.replace(u'\n', QChar::LineSeparator);
|
||||
QStackTextEngine engine(tmp, d->font);
|
||||
QTextLayout layout(&engine);
|
||||
|
||||
|
@ -605,7 +605,7 @@ QString QAbstractItemDelegatePrivate::textForRole(Qt::ItemDataRole role, const Q
|
||||
default: {
|
||||
text = value.toString();
|
||||
if (role == Qt::DisplayRole)
|
||||
text.replace(QLatin1Char('\n'), QChar::LineSeparator);
|
||||
text.replace(u'\n', QChar::LineSeparator);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ public:
|
||||
|
||||
inline static QString replaceNewLine(QString text)
|
||||
{
|
||||
text.replace(QLatin1Char('\n'), QChar::LineSeparator);
|
||||
text.replace(u'\n', QChar::LineSeparator);
|
||||
return text;
|
||||
}
|
||||
|
||||
|
@ -4391,7 +4391,7 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex
|
||||
case SC_GroupBoxLabel: {
|
||||
QFontMetrics fontMetrics = groupBox->fontMetrics;
|
||||
int th = fontMetrics.height();
|
||||
int tw = fontMetrics.size(Qt::TextShowMnemonic, groupBox->text + QLatin1Char(' ')).width();
|
||||
int tw = fontMetrics.size(Qt::TextShowMnemonic, groupBox->text + u' ').width();
|
||||
int marg = (groupBox->features & QStyleOptionFrame::Flat) ? 0 : 8;
|
||||
ret = groupBox->rect.adjusted(marg, 0, -marg, 0);
|
||||
|
||||
@ -4926,7 +4926,7 @@ QSize QCommonStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
|
||||
h = qMax(h, mi->icon.actualSize(QSize(iconExtent, iconExtent)).height() + 4);
|
||||
}
|
||||
}
|
||||
if (mi->text.contains(QLatin1Char('\t')))
|
||||
if (mi->text.contains(u'\t'))
|
||||
w += 12;
|
||||
if (maxpmw > 0)
|
||||
w += maxpmw + 6;
|
||||
|
@ -1693,7 +1693,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
|
||||
QStringView s(menuitem->text);
|
||||
if (!s.isEmpty()) { // draw text
|
||||
p->save();
|
||||
const int tabIndex = s.indexOf(QLatin1Char('\t'));
|
||||
const qsizetype tabIndex = s.indexOf(u'\t');
|
||||
int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
|
||||
if (!proxy()->styleHint(SH_UnderlineShortcut, menuitem, widget))
|
||||
text_flags |= Qt::TextHideMnemonic;
|
||||
@ -3185,7 +3185,7 @@ QSize QFusionStyle::sizeFromContents(ContentsType type, const QStyleOption *opti
|
||||
case CT_MenuItem:
|
||||
if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
|
||||
int w = size.width(); // Don't rely of QCommonStyle's width calculation here
|
||||
if (menuItem->text.contains(QLatin1Char('\t')))
|
||||
if (menuItem->text.contains(u'\t'))
|
||||
w += menuItem->reservedShortcutWidth;
|
||||
else if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu)
|
||||
w += 2 * QStyleHelper::dpiScaled(QFusionStylePrivate::menuArrowHMargin, option);
|
||||
|
@ -1205,10 +1205,10 @@ QPixmap QPixmapStylePrivate::getCachedPixmap(QPixmapStyle::ControlDescriptor con
|
||||
{
|
||||
Q_Q(const QPixmapStyle);
|
||||
|
||||
const QString sizeString = QString::number(size.width()) % QLatin1Char('*')
|
||||
const QString sizeString = QString::number(size.width()) % u'*'
|
||||
% QString::number(size.height());
|
||||
const QString key = QLatin1String(q->metaObject()->className()) % QString::number(control)
|
||||
% QLatin1Char('@') % sizeString;
|
||||
% u'@' % sizeString;
|
||||
|
||||
QPixmap result;
|
||||
|
||||
|
@ -75,7 +75,7 @@ QString uniqueName(const QString &key, const QStyleOption *option, const QSize &
|
||||
if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
|
||||
tmp = tmp % HexString<uint>(spinBox->buttonSymbols)
|
||||
% HexString<uint>(spinBox->stepEnabled)
|
||||
% QLatin1Char(spinBox->frame ? '1' : '0'); ;
|
||||
% QChar(spinBox->frame ? u'1' : u'0');
|
||||
}
|
||||
#endif // QT_CONFIG(spinbox)
|
||||
|
||||
|
@ -1567,7 +1567,7 @@ public:
|
||||
#endif
|
||||
QStringList result;
|
||||
do {
|
||||
result += QString::fromLatin1(metaObject->className()).replace(QLatin1Char(':'), QLatin1Char('-'));
|
||||
result += QString::fromLatin1(metaObject->className()).replace(u':', u'-');
|
||||
metaObject = metaObject->superClass();
|
||||
} while (metaObject != nullptr);
|
||||
return result;
|
||||
@ -1592,8 +1592,8 @@ public:
|
||||
if (!value.isValid()) {
|
||||
if (name == "class"_L1) {
|
||||
QString className = QString::fromLatin1(obj->metaObject()->className());
|
||||
if (className.contains(QLatin1Char(':')))
|
||||
className.replace(QLatin1Char(':'), QLatin1Char('-'));
|
||||
if (className.contains(u':'))
|
||||
className.replace(u':', u'-');
|
||||
valueStr = className;
|
||||
} else if (name == "style"_L1) {
|
||||
QWidget *w = qobject_cast<QWidget *>(obj);
|
||||
@ -1616,7 +1616,7 @@ public:
|
||||
if (value.isValid()) {
|
||||
valueStr = (value.userType() == QMetaType::QStringList
|
||||
|| value.userType() == QMetaType::QVariantList)
|
||||
? value.toStringList().join(QLatin1Char(' '))
|
||||
? value.toStringList().join(u' ')
|
||||
: value.toString();
|
||||
}
|
||||
cache[name] = valueStr;
|
||||
@ -1718,7 +1718,7 @@ QList<QCss::StyleRule> QStyleSheetStyle::styleRules(const QObject *obj) const
|
||||
if (objCacheIt == styleSheetCaches->styleSheetCache.constEnd()) {
|
||||
parser.init(styleSheet);
|
||||
if (!parser.parse(&ss)) {
|
||||
parser.init(QLatin1String("* {") + styleSheet + QLatin1Char('}'));
|
||||
parser.init(QLatin1String("* {") + styleSheet + u'}');
|
||||
if (Q_UNLIKELY(!parser.parse(&ss)))
|
||||
qWarning() << "Could not parse stylesheet of object" << o;
|
||||
}
|
||||
@ -3961,7 +3961,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
|
||||
int text_flags = Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
|
||||
if (!styleHint(SH_UnderlineShortcut, &mi, w))
|
||||
text_flags |= Qt::TextHideMnemonic;
|
||||
int t = s.indexOf(QLatin1Char('\t'));
|
||||
qsizetype t = s.indexOf(u'\t');
|
||||
if (t >= 0) {
|
||||
QRect vShortcutRect = visualRect(opt->direction, mi.rect,
|
||||
QRect(textRect.topRight(), QPoint(mi.rect.right(), textRect.bottom())));
|
||||
@ -5365,7 +5365,7 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op
|
||||
}
|
||||
if ((pe == PseudoElement_Item) && (subRule.hasBox() || subRule.hasBorder() || subRule.hasFont)) {
|
||||
QSize sz(csz);
|
||||
if (mi->text.contains(QLatin1Char('\t')))
|
||||
if (mi->text.contains(u'\t'))
|
||||
sz.rwidth() += 12; //as in QCommonStyle
|
||||
if (!mi->icon.isNull()) {
|
||||
const int pmSmall = pixelMetric(PM_SmallIconSize);
|
||||
|
@ -1190,7 +1190,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai
|
||||
QStringView s(menuitem->text);
|
||||
if (!s.isEmpty()) { // draw text
|
||||
p->save();
|
||||
int t = s.indexOf(QLatin1Char('\t'));
|
||||
qsizetype t = s.indexOf(u'\t');
|
||||
int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
|
||||
if (!proxy()->styleHint(SH_UnderlineShortcut, menuitem, widget))
|
||||
text_flags |= Qt::TextHideMnemonic;
|
||||
@ -2348,7 +2348,7 @@ QSize QWindowsStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
|
||||
}
|
||||
int maxpmw = mi->maxIconWidth;
|
||||
int tabSpacing = 20;
|
||||
if (mi->text.contains(QLatin1Char('\t')))
|
||||
if (mi->text.contains(u'\t'))
|
||||
w += tabSpacing;
|
||||
else if (mi->menuItemType == QStyleOptionMenuItem::SubMenu)
|
||||
w += 2 * QWindowsStylePrivate::windowsArrowHMargin;
|
||||
|
@ -983,7 +983,7 @@ static bool completeOnLoaded(const QFileSystemModel *model,
|
||||
if (prefixSize == pathSize)
|
||||
return path.compare(prefix, caseSensitivity) == 0 && isRoot(model, path);
|
||||
// The user is typing something within that directory and is not in a subdirectory yet.
|
||||
const auto separator = QLatin1Char('/');
|
||||
const auto separator = u'/';
|
||||
return prefix.startsWith(path, caseSensitivity) && prefix.at(pathSize) == separator
|
||||
&& !QStringView{prefix}.right(prefixSize - pathSize - 1).contains(separator);
|
||||
}
|
||||
@ -1893,7 +1893,7 @@ QStringList QCompleter::splitPath(const QString& path) const
|
||||
parts[0].prepend(QLatin1String("\\\\"));
|
||||
#else
|
||||
if (pathCopy[0] == sep) // readd the "/" at the beginning as the split removed it
|
||||
parts[0] = QLatin1Char('/');
|
||||
parts[0] = u'/';
|
||||
#endif
|
||||
|
||||
return parts;
|
||||
|
@ -906,7 +906,7 @@ QSize QAbstractSpinBox::sizeHint() const
|
||||
int h = d->edit->sizeHint().height();
|
||||
int w = 0;
|
||||
QString s;
|
||||
QString fixedContent = d->prefix + d->suffix + QLatin1Char(' ');
|
||||
QString fixedContent = d->prefix + d->suffix + u' ';
|
||||
s = d->textFromValue(d->minimum);
|
||||
s.truncate(18);
|
||||
s += fixedContent;
|
||||
@ -946,7 +946,7 @@ QSize QAbstractSpinBox::minimumSizeHint() const
|
||||
int w = 0;
|
||||
|
||||
QString s;
|
||||
QString fixedContent = d->prefix + QLatin1Char(' ');
|
||||
QString fixedContent = d->prefix + u' ';
|
||||
s = d->textFromValue(d->minimum);
|
||||
s.truncate(18);
|
||||
s += fixedContent;
|
||||
|
@ -75,7 +75,7 @@ namespace {
|
||||
|
||||
static QString formatNumber(int number, int fieldWidth)
|
||||
{
|
||||
return QString::number(number).rightJustified(fieldWidth, QLatin1Char('0'));
|
||||
return QString::number(number).rightJustified(fieldWidth, u'0');
|
||||
}
|
||||
|
||||
class QCalendarDateSectionValidator
|
||||
@ -544,7 +544,7 @@ void QCalendarDateValidator::setFormat(const QString &format)
|
||||
clear();
|
||||
|
||||
int pos = 0;
|
||||
const QLatin1Char quote('\'');
|
||||
const auto quote = u'\'';
|
||||
bool quoting = false;
|
||||
QString separator;
|
||||
while (pos < format.size()) {
|
||||
@ -560,13 +560,13 @@ void QCalendarDateValidator::setFormat(const QString &format)
|
||||
quoting = false;
|
||||
} else {
|
||||
QCalendarDateSectionValidator *validator = nullptr;
|
||||
if (nextChar == QLatin1Char('d')) {
|
||||
if (nextChar == u'd') {
|
||||
offset = qMin(4, countRepeat(format, pos));
|
||||
validator = &m_dayValidator;
|
||||
} else if (nextChar == QLatin1Char('M')) {
|
||||
} else if (nextChar == u'M') {
|
||||
offset = qMin(4, countRepeat(format, pos));
|
||||
validator = &m_monthValidator;
|
||||
} else if (nextChar == QLatin1Char('y')) {
|
||||
} else if (nextChar == u'y') {
|
||||
offset = qMin(4, countRepeat(format, pos));
|
||||
validator = &m_yearValidator;
|
||||
} else {
|
||||
|
@ -159,7 +159,7 @@ QStyleOptionMenuItem QComboMenuDelegate::getStyleOption(const QStyleOptionViewIt
|
||||
qvariant_cast<QBrush>(index.data(Qt::BackgroundRole)));
|
||||
}
|
||||
menuOption.text = index.model()->data(index, Qt::DisplayRole).toString()
|
||||
.replace(QLatin1Char('&'), QLatin1String("&&"));
|
||||
.replace(u'&', QLatin1String("&&"));
|
||||
menuOption.reservedShortcutWidth = 0;
|
||||
menuOption.maxIconWidth = option.decorationSize.width() + 4;
|
||||
menuOption.menuRect = option.rect;
|
||||
@ -398,7 +398,7 @@ QSize QComboBoxPrivate::recomputeSizeHint(QSize &sh) const
|
||||
case QComboBox::AdjustToContents:
|
||||
case QComboBox::AdjustToContentsOnFirstShow:
|
||||
if (count == 0) {
|
||||
sh.rwidth() = 7 * fm.horizontalAdvance(QLatin1Char('x'));
|
||||
sh.rwidth() = 7 * fm.horizontalAdvance(u'x');
|
||||
} else {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
if (!q->itemIcon(i).isNull()) {
|
||||
@ -418,7 +418,7 @@ QSize QComboBoxPrivate::recomputeSizeHint(QSize &sh) const
|
||||
hasIcon = !q->itemIcon(i).isNull();
|
||||
}
|
||||
if (minimumContentsLength > 0)
|
||||
sh.setWidth(qMax(sh.width(), minimumContentsLength * fm.horizontalAdvance(QLatin1Char('X')) + (hasIcon ? iconSize.width() + 4 : 0)));
|
||||
sh.setWidth(qMax(sh.width(), minimumContentsLength * fm.horizontalAdvance(u'X') + (hasIcon ? iconSize.width() + 4 : 0)));
|
||||
if (!placeholderText.isEmpty())
|
||||
sh.setWidth(qMax(sh.width(), fm.boundingRect(placeholderText).width()));
|
||||
|
||||
|
@ -1065,9 +1065,9 @@ QSize QDateTimeEdit::sizeHint() const
|
||||
int h = d->edit->sizeHint().height();
|
||||
int w = 0;
|
||||
QString s;
|
||||
s = d->textFromValue(d->minimum) + QLatin1Char(' ');
|
||||
s = d->textFromValue(d->minimum) + u' ';
|
||||
w = qMax<int>(w, fm.horizontalAdvance(s));
|
||||
s = d->textFromValue(d->maximum) + QLatin1Char(' ');
|
||||
s = d->textFromValue(d->maximum) + u' ';
|
||||
w = qMax<int>(w, fm.horizontalAdvance(s));
|
||||
if (d->specialValueText.size()) {
|
||||
s = d->specialValueText;
|
||||
@ -1950,7 +1950,7 @@ int QDateTimeEditPrivate::nextPrevSection(int current, bool forward) const
|
||||
|
||||
void QDateTimeEditPrivate::clearSection(int index)
|
||||
{
|
||||
const QLatin1Char space(' ');
|
||||
const auto space = u' ';
|
||||
int cursorPos = edit->cursorPosition();
|
||||
const QSignalBlocker blocker(edit);
|
||||
QString t = edit->text();
|
||||
|
@ -567,7 +567,7 @@ QSize QFontComboBox::sizeHint() const
|
||||
{
|
||||
QSize sz = QComboBox::sizeHint();
|
||||
QFontMetrics fm(font());
|
||||
sz.setWidth(fm.horizontalAdvance(QLatin1Char('m'))*14);
|
||||
sz.setWidth(fm.horizontalAdvance(u'm') * 14);
|
||||
return sz;
|
||||
}
|
||||
|
||||
|
@ -496,7 +496,7 @@ QSize QGroupBox::minimumSizeHint() const
|
||||
|
||||
QFontMetrics metrics(fontMetrics());
|
||||
|
||||
int baseWidth = metrics.horizontalAdvance(d->title) + metrics.horizontalAdvance(QLatin1Char(' '));
|
||||
int baseWidth = metrics.horizontalAdvance(d->title) + metrics.horizontalAdvance(u' ');
|
||||
int baseHeight = metrics.height();
|
||||
if (d->checkable) {
|
||||
baseWidth += style()->pixelMetric(QStyle::PM_IndicatorWidth, &option);
|
||||
|
@ -616,7 +616,7 @@ QSize QLabelPrivate::sizeForWidth(int w) const
|
||||
int m = indent;
|
||||
|
||||
if (m < 0 && q->frameWidth()) // no indent, but we do have a frame
|
||||
m = fm.horizontalAdvance(QLatin1Char('x')) - margin*2;
|
||||
m = fm.horizontalAdvance(u'x') - margin*2;
|
||||
if (m > 0) {
|
||||
if ((align & Qt::AlignLeft) || (align & Qt::AlignRight))
|
||||
hextra += m;
|
||||
@ -1244,7 +1244,7 @@ void QLabelPrivate::updateShortcut()
|
||||
// But then we do want to hide the ampersands, so we can't use shortcutId.
|
||||
hasShortcut = false;
|
||||
|
||||
if (!text.contains(QLatin1Char('&')))
|
||||
if (!text.contains(u'&'))
|
||||
return;
|
||||
hasShortcut = true;
|
||||
shortcutId = q->grabShortcut(QKeySequence::mnemonic(text));
|
||||
@ -1513,7 +1513,7 @@ QRect QLabelPrivate::documentRect() const
|
||||
: q->layoutDirection(), QFlag(this->align));
|
||||
int m = indent;
|
||||
if (m < 0 && q->frameWidth()) // no indent, but we do have a frame
|
||||
m = q->fontMetrics().horizontalAdvance(QLatin1Char('x')) / 2 - margin;
|
||||
m = q->fontMetrics().horizontalAdvance(u'x') / 2 - margin;
|
||||
if (m > 0) {
|
||||
if (align & Qt::AlignLeft)
|
||||
cr.setLeft(cr.left() + m);
|
||||
|
@ -179,18 +179,18 @@ static QString int2string(int num, int base, int ndigits, bool *oflow)
|
||||
} while (n != 0);
|
||||
len = ndigits - len;
|
||||
if (len > 0)
|
||||
s += QString(len, QLatin1Char(' '));
|
||||
s += QString(len, u' ');
|
||||
s += QLatin1String(p);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (negative) {
|
||||
for (int i=0; i<(int)s.length(); i++) {
|
||||
if (s[i] != QLatin1Char(' ')) {
|
||||
if (s[i] != u' ') {
|
||||
if (i != 0) {
|
||||
s[i-1] = QLatin1Char('-');
|
||||
s[i-1] = u'-';
|
||||
} else {
|
||||
s.insert(0, QLatin1Char('-'));
|
||||
s.insert(0, u'-');
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -217,10 +217,10 @@ static QString double2string(double num, int base, int ndigits, bool *oflow)
|
||||
int nd = ndigits;
|
||||
do {
|
||||
s = QString::asprintf("%*.*g", ndigits, nd, num);
|
||||
int i = s.indexOf(QLatin1Char('e'));
|
||||
if (i > 0 && s[i+1]==QLatin1Char('+')) {
|
||||
s[i] = QLatin1Char(' ');
|
||||
s[i+1] = QLatin1Char('e');
|
||||
qsizetype i = s.indexOf(u'e');
|
||||
if (i > 0 && s[i+1]==u'+') {
|
||||
s[i] = u' ';
|
||||
s[i+1] = u'e';
|
||||
}
|
||||
} while (nd-- && (int)s.length() > ndigits);
|
||||
}
|
||||
@ -408,9 +408,9 @@ void QLCDNumber::setDigitCount(int numDigits)
|
||||
}
|
||||
if (d->digitStr.isNull()) { // from constructor
|
||||
d->ndigits = numDigits;
|
||||
d->digitStr.fill(QLatin1Char(' '), d->ndigits);
|
||||
d->digitStr.fill(u' ', d->ndigits);
|
||||
d->points.fill(0, d->ndigits);
|
||||
d->digitStr[d->ndigits - 1] = QLatin1Char('0'); // "0" is the default number
|
||||
d->digitStr[d->ndigits - 1] = u'0'; // "0" is the default number
|
||||
} else {
|
||||
bool doDisplay = d->ndigits == 0;
|
||||
if (numDigits == d->ndigits) // no change
|
||||
@ -420,7 +420,7 @@ void QLCDNumber::setDigitCount(int numDigits)
|
||||
if (numDigits > d->ndigits) { // expand
|
||||
dif = numDigits - d->ndigits;
|
||||
QString buf;
|
||||
buf.fill(QLatin1Char(' '), dif);
|
||||
buf.fill(u' ', dif);
|
||||
d->digitStr.insert(0, buf);
|
||||
d->points.resize(numDigits);
|
||||
for (i=numDigits-1; i>=dif; i--)
|
||||
@ -722,18 +722,18 @@ void QLCDNumberPrivate::internalSetString(const QString& s)
|
||||
if (len == ndigits)
|
||||
buffer = s;
|
||||
else
|
||||
buffer = s.right(ndigits).rightJustified(ndigits, QLatin1Char(' '));
|
||||
buffer = s.right(ndigits).rightJustified(ndigits, u' ');
|
||||
} else {
|
||||
int index = -1;
|
||||
bool lastWasPoint = true;
|
||||
newPoints.clearBit(0);
|
||||
for (i=0; i<len; i++) {
|
||||
if (s[i] == QLatin1Char('.')) {
|
||||
if (s[i] == u'.') {
|
||||
if (lastWasPoint) { // point already set for digit?
|
||||
if (index == ndigits - 1) // no more digits
|
||||
break;
|
||||
index++;
|
||||
buffer[index] = QLatin1Char(' '); // 2 points in a row, add space
|
||||
buffer[index] = u' '; // 2 points in a row, add space
|
||||
}
|
||||
newPoints.setBit(index); // set decimal point
|
||||
lastWasPoint = true;
|
||||
@ -753,7 +753,7 @@ void QLCDNumberPrivate::internalSetString(const QString& s)
|
||||
newPoints.testBit(i));
|
||||
}
|
||||
for(i=0; i<ndigits-index-1; i++) {
|
||||
buffer[i] = QLatin1Char(' ');
|
||||
buffer[i] = u' ';
|
||||
newPoints.clearBit(i);
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +85,7 @@
|
||||
#include "qkeysequence.h"
|
||||
#define ACCEL_KEY(k) (!QCoreApplication::testAttribute(Qt::AA_DontShowShortcutsInContextMenus) \
|
||||
&& !QGuiApplicationPrivate::instance()->shortcutMap.hasShortcutForKeySequence(k) ? \
|
||||
QLatin1Char('\t') + QKeySequence(k).toString(QKeySequence::NativeText) : QString())
|
||||
u'\t' + QKeySequence(k).toString(QKeySequence::NativeText) : QString())
|
||||
#else
|
||||
#define ACCEL_KEY(k) QString()
|
||||
#endif
|
||||
@ -697,7 +697,7 @@ QSize QLineEdit::sizeHint() const
|
||||
int h = qMax(fm.height(), qMax(14, iconSize - 2)) + 2 * QLineEditPrivate::verticalMargin
|
||||
+ tm.top() + tm.bottom()
|
||||
+ d->topmargin + d->bottommargin;
|
||||
int w = fm.horizontalAdvance(QLatin1Char('x')) * 17 + 2 * QLineEditPrivate::horizontalMargin
|
||||
int w = fm.horizontalAdvance(u'x') * 17 + 2 * QLineEditPrivate::horizontalMargin
|
||||
+ tm.left() + tm.right()
|
||||
+ d->leftmargin + d->rightmargin; // "some"
|
||||
QStyleOptionFrame opt;
|
||||
|
@ -432,7 +432,7 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const
|
||||
sz = QSize(2, 2);
|
||||
} else {
|
||||
QString s = action->text();
|
||||
int t = s.indexOf(QLatin1Char('\t'));
|
||||
qsizetype t = s.indexOf(u'\t');
|
||||
if (t != -1) {
|
||||
tabWidth = qMax(int(tabWidth), qfm.horizontalAdvance(s.mid(t+1)));
|
||||
s = s.left(t);
|
||||
@ -1637,10 +1637,10 @@ void QMenu::initStyleOption(QStyleOptionMenuItem *option, const QAction *action)
|
||||
QString textAndAccel = action->text();
|
||||
#ifndef QT_NO_SHORTCUT
|
||||
if ((action->isShortcutVisibleInContextMenu() || !d->isContextMenu())
|
||||
&& textAndAccel.indexOf(QLatin1Char('\t')) == -1) {
|
||||
&& textAndAccel.indexOf(u'\t') == -1) {
|
||||
QKeySequence seq = action->shortcut();
|
||||
if (!seq.isEmpty())
|
||||
textAndAccel += QLatin1Char('\t') + seq.toString(QKeySequence::NativeText);
|
||||
textAndAccel += u'\t' + seq.toString(QKeySequence::NativeText);
|
||||
}
|
||||
#endif
|
||||
option->text = textAndAccel;
|
||||
|
@ -1105,7 +1105,7 @@ void QMenuBar::keyPressEvent(QKeyEvent *e)
|
||||
QAction *act = d->actions.at(i);
|
||||
QString s = act->text();
|
||||
if (!s.isEmpty()) {
|
||||
int ampersand = s.indexOf(QLatin1Char('&'));
|
||||
qsizetype ampersand = s.indexOf(u'&');
|
||||
if (ampersand >= 0) {
|
||||
if (s[ampersand+1].toUpper() == c) {
|
||||
clashCount++;
|
||||
|
@ -422,7 +422,7 @@ QSize QProgressBar::sizeHint() const
|
||||
QStyleOptionProgressBar opt;
|
||||
initStyleOption(&opt);
|
||||
int cw = style()->pixelMetric(QStyle::PM_ProgressBarChunkWidth, &opt, this);
|
||||
QSize size = QSize(qMax(9, cw) * 7 + fm.horizontalAdvance(QLatin1Char('0')) * 4, fm.height() + 8);
|
||||
QSize size = QSize(qMax(9, cw) * 7 + fm.horizontalAdvance(u'0') * 4, fm.height() + 8);
|
||||
if (!(opt.state & QStyle::State_Horizontal))
|
||||
size = size.transposed();
|
||||
return style()->sizeFromContents(QStyle::CT_ProgressBar, &opt, size, this);
|
||||
|
@ -977,9 +977,8 @@ void QDoubleSpinBox::setDecimals(int decimals)
|
||||
This virtual function is used by the spin box whenever it needs to
|
||||
display the given \a value. The default implementation returns a string
|
||||
containing \a value printed using QWidget::locale().toString(\a value,
|
||||
QLatin1Char('f'), decimals()) and will remove the thousand
|
||||
separator unless setGroupSeparatorShown() is set. Reimplementations may
|
||||
return anything.
|
||||
\c u'f', decimals()) and will remove the thousand separator unless
|
||||
setGroupSeparatorShown() is set. Reimplementations may return anything.
|
||||
|
||||
Note: QDoubleSpinBox does not call this function for
|
||||
specialValueText() and that neither prefix() nor suffix() should
|
||||
@ -1131,7 +1130,7 @@ QVariant QSpinBoxPrivate::validateAndInterpret(QString &input, int &pos,
|
||||
|| (max >= 0 && copy == QLatin1String("+")))) {
|
||||
state = QValidator::Intermediate;
|
||||
QSBDEBUG() << __FILE__ << __LINE__<< "num is set to" << num;
|
||||
} else if (copy.startsWith(QLatin1Char('-')) && min >= 0) {
|
||||
} else if (copy.startsWith(u'-') && min >= 0) {
|
||||
state = QValidator::Invalid; // special-case -0 will be interpreted as 0 and thus not be invalid with a range from 0-100
|
||||
} else {
|
||||
bool ok = false;
|
||||
@ -1291,15 +1290,15 @@ QVariant QDoubleSpinBoxPrivate::validateAndInterpret(QString &input, int &pos,
|
||||
goto end;
|
||||
case 1:
|
||||
if (copy.at(0) == locale.decimalPoint()
|
||||
|| (plus && copy.at(0) == QLatin1Char('+'))
|
||||
|| (minus && copy.at(0) == QLatin1Char('-'))) {
|
||||
|| (plus && copy.at(0) == u'+')
|
||||
|| (minus && copy.at(0) == u'-')) {
|
||||
state = QValidator::Intermediate;
|
||||
goto end;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (copy.at(1) == locale.decimalPoint()
|
||||
&& ((plus && copy.at(0) == QLatin1Char('+')) || (minus && copy.at(0) == QLatin1Char('-')))) {
|
||||
&& ((plus && copy.at(0) == u'+') || (minus && copy.at(0) == u'-'))) {
|
||||
state = QValidator::Intermediate;
|
||||
goto end;
|
||||
}
|
||||
|
@ -189,8 +189,8 @@ QString QTextBrowserPrivate::findFile(const QUrl &name) const
|
||||
return fileName;
|
||||
|
||||
for (QString path : qAsConst(searchPaths)) {
|
||||
if (!path.endsWith(QLatin1Char('/')))
|
||||
path.append(QLatin1Char('/'));
|
||||
if (!path.endsWith(u'/'))
|
||||
path.append(u'/');
|
||||
path.append(fileName);
|
||||
if (QFileInfo(path).isReadable())
|
||||
return path;
|
||||
@ -336,7 +336,7 @@ void QTextBrowserPrivate::setSource(const QUrl &url, QTextDocument::ResourceType
|
||||
qWarning("QTextBrowser: No document for %s", url.toString().toLatin1().constData());
|
||||
|
||||
if (q->isVisible()) {
|
||||
const QStringView firstTag = QStringView{txt}.left(txt.indexOf(QLatin1Char('>')) + 1);
|
||||
const QStringView firstTag = QStringView{txt}.left(txt.indexOf(u'>') + 1);
|
||||
if (firstTag.startsWith(QLatin1String("<qt")) && firstTag.contains(QLatin1String("type")) && firstTag.contains(QLatin1String("detail"))) {
|
||||
#ifndef QT_NO_CURSOR
|
||||
QGuiApplication::restoreOverrideCursor();
|
||||
|
@ -1408,7 +1408,7 @@ void QTextEdit::keyPressEvent(QKeyEvent *e)
|
||||
if (cursor.atBlockStart()
|
||||
&& (d->autoFormatting & AutoBulletList)
|
||||
&& (text.length() == 1)
|
||||
&& (text.at(0) == QLatin1Char('-') || text.at(0) == QLatin1Char('*'))
|
||||
&& (text.at(0) == u'-' || text.at(0) == u'*')
|
||||
&& (!cursor.currentList())) {
|
||||
|
||||
d->createAutoBulletList();
|
||||
|
@ -347,7 +347,7 @@ QSize QToolButton::sizeHint() const
|
||||
|
||||
if (opt.toolButtonStyle != Qt::ToolButtonIconOnly) {
|
||||
QSize textSize = fm.size(Qt::TextShowMnemonic, text());
|
||||
textSize.setWidth(textSize.width() + fm.horizontalAdvance(QLatin1Char(' '))*2);
|
||||
textSize.setWidth(textSize.width() + fm.horizontalAdvance(u' ') * 2);
|
||||
if (opt.toolButtonStyle == Qt::ToolButtonTextUnderIcon) {
|
||||
h += 4 + textSize.height();
|
||||
if (textSize.width() > w)
|
||||
|
@ -974,7 +974,7 @@ void QWidgetLineControl::removeSelectedText()
|
||||
*/
|
||||
void QWidgetLineControl::parseInputMask(const QString &maskFields)
|
||||
{
|
||||
int delimiter = maskFields.indexOf(QLatin1Char(';'));
|
||||
qsizetype delimiter = maskFields.indexOf(u';');
|
||||
if (maskFields.isEmpty() || delimiter == 0) {
|
||||
if (m_maskData) {
|
||||
m_maskData.reset();
|
||||
@ -985,11 +985,11 @@ void QWidgetLineControl::parseInputMask(const QString &maskFields)
|
||||
}
|
||||
|
||||
if (delimiter == -1) {
|
||||
m_blank = QLatin1Char(' ');
|
||||
m_blank = u' ';
|
||||
m_inputMask = maskFields;
|
||||
} else {
|
||||
m_inputMask = maskFields.left(delimiter);
|
||||
m_blank = (delimiter + 1 < maskFields.length()) ? maskFields[delimiter + 1] : QLatin1Char(' ');
|
||||
m_blank = (delimiter + 1 < maskFields.length()) ? maskFields[delimiter + 1] : u' ';
|
||||
}
|
||||
|
||||
// calculate m_maxLength / m_maskData length
|
||||
@ -1008,10 +1008,8 @@ void QWidgetLineControl::parseInputMask(const QString &maskFields)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c != QLatin1Char('\\') && c != QLatin1Char('!') &&
|
||||
c != QLatin1Char('<') && c != QLatin1Char('>') &&
|
||||
c != QLatin1Char('{') && c != QLatin1Char('}') &&
|
||||
c != QLatin1Char('[') && c != QLatin1Char(']'))
|
||||
if (c != u'\\' && c != u'!' && c != u'<' && c != u'>' &&
|
||||
c != u'{' && c != u'}' && c != u'[' && c != u']')
|
||||
m_maxLength++;
|
||||
}
|
||||
|
||||
@ -1030,13 +1028,13 @@ void QWidgetLineControl::parseInputMask(const QString &maskFields)
|
||||
m_maskData[index].caseMode = m;
|
||||
index++;
|
||||
escape = false;
|
||||
} else if (c == QLatin1Char('<')) {
|
||||
m = MaskInputData::Lower;
|
||||
} else if (c == QLatin1Char('>')) {
|
||||
} else if (c == u'<') {
|
||||
m = MaskInputData::Lower;
|
||||
} else if (c == u'>') {
|
||||
m = MaskInputData::Upper;
|
||||
} else if (c == QLatin1Char('!')) {
|
||||
} else if (c == u'!') {
|
||||
m = MaskInputData::NoCaseMode;
|
||||
} else if (c != QLatin1Char('{') && c != QLatin1Char('}') && c != QLatin1Char('[') && c != QLatin1Char(']')) {
|
||||
} else if (c != u'{' && c != u'}' && c != u'[' && c != u']') {
|
||||
switch (c.unicode()) {
|
||||
case 'A':
|
||||
case 'a':
|
||||
@ -1124,23 +1122,23 @@ bool QWidgetLineControl::isValidInput(QChar key, QChar mask) const
|
||||
return true;
|
||||
break;
|
||||
case '#':
|
||||
if (key.isNumber() || key == QLatin1Char('+') || key == QLatin1Char('-') || key == m_blank)
|
||||
if (key.isNumber() || key == u'+' || key == u'-' || key == m_blank)
|
||||
return true;
|
||||
break;
|
||||
case 'B':
|
||||
if (key == QLatin1Char('0') || key == QLatin1Char('1'))
|
||||
if (key == u'0' || key == u'1')
|
||||
return true;
|
||||
break;
|
||||
case 'b':
|
||||
if (key == QLatin1Char('0') || key == QLatin1Char('1') || key == m_blank)
|
||||
if (key == u'0' || key == u'1' || key == m_blank)
|
||||
return true;
|
||||
break;
|
||||
case 'H':
|
||||
if (key.isNumber() || (key >= QLatin1Char('a') && key <= QLatin1Char('f')) || (key >= QLatin1Char('A') && key <= QLatin1Char('F')))
|
||||
if (key.isNumber() || (key >= u'a' && key <= u'f') || (key >= u'A' && key <= u'F'))
|
||||
return true;
|
||||
break;
|
||||
case 'h':
|
||||
if (key.isNumber() || (key >= QLatin1Char('a') && key <= QLatin1Char('f')) || (key >= QLatin1Char('A') && key <= QLatin1Char('F')) || key == m_blank)
|
||||
if (key.isNumber() || (key >= u'a' && key <= u'f') || (key >= u'A' && key <= u'F') || key == m_blank)
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
|
@ -323,8 +323,8 @@ public:
|
||||
QString mask;
|
||||
if (m_maskData) {
|
||||
mask = m_inputMask;
|
||||
if (m_blank != QLatin1Char(' ')) {
|
||||
mask += QLatin1Char(';');
|
||||
if (m_blank != u' ') {
|
||||
mask += u';';
|
||||
mask += m_blank;
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +100,7 @@
|
||||
#include <qkeysequence.h>
|
||||
#define ACCEL_KEY(k) (!QCoreApplication::testAttribute(Qt::AA_DontShowShortcutsInContextMenus) \
|
||||
&& !QGuiApplicationPrivate::instance()->shortcutMap.hasShortcutForKeySequence(k) ? \
|
||||
QLatin1Char('\t') + QKeySequence(k).toString(QKeySequence::NativeText) : QString())
|
||||
u'\t' + QKeySequence(k).toString(QKeySequence::NativeText) : QString())
|
||||
|
||||
#else
|
||||
#define ACCEL_KEY(k) QString()
|
||||
@ -682,7 +682,7 @@ void QWidgetTextControlPrivate::_q_contentsChanged(int from, int charsRemoved, i
|
||||
QString newText = tmp.selectedText();
|
||||
|
||||
// always report the right number of removed chars, but in lack of the real string use spaces
|
||||
QString oldText = QString(charsRemoved, QLatin1Char(' '));
|
||||
QString oldText = QString(charsRemoved, u' ');
|
||||
|
||||
QAccessibleEvent *ev = nullptr;
|
||||
if (charsRemoved == 0) {
|
||||
@ -1449,7 +1449,7 @@ QRectF QWidgetTextControlPrivate::rectForPosition(int position) const
|
||||
if (relativePos < line.textLength() - line.textStart())
|
||||
w = line.cursorToX(relativePos + 1) - x;
|
||||
else
|
||||
w = QFontMetrics(block.layout()->font()).horizontalAdvance(QLatin1Char(' ')); // in sync with QTextLine::draw()
|
||||
w = QFontMetrics(block.layout()->font()).horizontalAdvance(u' '); // in sync with QTextLine::draw()
|
||||
}
|
||||
r = QRectF(layoutPos.x() + x, layoutPos.y() + line.y(),
|
||||
cursorWidth + w, line.height());
|
||||
@ -2198,7 +2198,7 @@ QVariant QWidgetTextControl::inputMethodQuery(Qt::InputMethodQuery property, QVa
|
||||
tmpCursor.movePosition(QTextCursor::NextBlock);
|
||||
if (tmpCursor.blockNumber() == currentBlock)
|
||||
break;
|
||||
result += QLatin1Char('\n') + tmpCursor.block().text();
|
||||
result += u'\n' + tmpCursor.block().text();
|
||||
}
|
||||
return QVariant(result);
|
||||
}
|
||||
@ -2219,7 +2219,7 @@ QVariant QWidgetTextControl::inputMethodQuery(Qt::InputMethodQuery property, QVa
|
||||
}
|
||||
QString result;
|
||||
while (numBlocks) {
|
||||
result += tmpCursor.block().text() + QLatin1Char('\n');
|
||||
result += tmpCursor.block().text() + u'\n';
|
||||
tmpCursor.movePosition(QTextCursor::NextBlock);
|
||||
--numBlocks;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user