From 00ff2b06a17e90921d79831a62e95eecf8c6954a Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 21 Mar 2023 15:35:44 +0100 Subject: Qt Designer: Replace QLatin1Char by modern literals Pick-to: 6.5 Change-Id: Ied11784e840d03542a5db281590729838ed625c3 Reviewed-by: Jarek Kobus Reviewed-by: Qt CI Bot --- .../components/formeditor/deviceprofiledialog.cpp | 8 +++---- .../src/components/formeditor/formwindow.cpp | 6 +++--- .../components/formeditor/formwindowsettings.cpp | 4 ++-- .../components/formeditor/qdesigner_resource.cpp | 17 +++++++++------ .../src/components/lib/qdesigner_components.cpp | 5 ++--- .../propertyeditor/designerpropertymanager.cpp | 7 +++--- .../components/propertyeditor/propertyeditor.cpp | 10 ++------- .../propertyeditor/qlonglongvalidator.cpp | 8 ++++--- .../signalsloteditor/signalsloteditorwindow.cpp | 2 +- .../src/components/taskmenu/itemlisteditor.cpp | 6 ++++-- .../widgetbox/widgetboxcategorylistview.cpp | 6 ++---- .../components/widgetbox/widgetboxtreewidget.cpp | 9 ++++---- src/designer/src/designer/appfontdialog.cpp | 4 +--- src/designer/src/designer/assistantclient.cpp | 2 +- src/designer/src/designer/qdesigner.cpp | 2 +- src/designer/src/designer/qdesigner_actions.cpp | 14 ++++-------- src/designer/src/designer/qdesigner_formwindow.cpp | 3 +-- src/designer/src/designer/qdesigner_server.cpp | 10 +++++---- src/designer/src/designer/qdesigner_workbench.cpp | 4 ++-- src/designer/src/designer/saveformastemplate.cpp | 4 +--- src/designer/src/lib/shared/actioneditor.cpp | 7 +++--- src/designer/src/lib/shared/actionrepository.cpp | 8 +++---- src/designer/src/lib/shared/csshighlighter.cpp | 6 ++++-- src/designer/src/lib/shared/formlayoutmenu.cpp | 2 +- src/designer/src/lib/shared/htmlhighlighter.cpp | 25 ++++++++-------------- src/designer/src/lib/shared/iconselector.cpp | 4 ++-- src/designer/src/lib/shared/morphmenu.cpp | 4 ++-- src/designer/src/lib/shared/newformwidget.cpp | 12 +++++------ src/designer/src/lib/shared/previewmanager.cpp | 5 +++-- .../src/lib/shared/qdesigner_formbuilder.cpp | 8 ++----- .../src/lib/shared/qdesigner_membersheet.cpp | 10 ++++----- .../src/lib/shared/qdesigner_promotion.cpp | 2 +- .../src/lib/shared/qdesigner_promotiondialog.cpp | 5 ++--- src/designer/src/lib/shared/qdesigner_utils.cpp | 9 ++++---- .../src/lib/shared/qtresourceeditordialog.cpp | 14 +++++------- src/designer/src/lib/shared/qtresourceview.cpp | 4 ++-- src/designer/src/lib/shared/richtexteditor.cpp | 2 +- src/designer/src/lib/shared/signalslotdialog.cpp | 7 +++--- src/designer/src/lib/shared/stylesheeteditor.cpp | 18 +++++++--------- src/designer/src/lib/shared/textpropertyeditor.cpp | 16 +++++++------- src/designer/src/lib/shared/widgetdatabase.cpp | 13 ++++++----- src/designer/src/lib/uilib/abstractformbuilder.cpp | 3 +-- src/designer/src/lib/uilib/formbuilder.cpp | 8 +++---- src/designer/src/lib/uilib/formbuilderextra.cpp | 4 ++-- src/designer/src/lib/uilib/properties.cpp | 4 ++-- .../src/plugins/activeqt/qaxwidgettaskmenu.cpp | 8 +++---- 46 files changed, 151 insertions(+), 188 deletions(-) diff --git a/src/designer/src/components/formeditor/deviceprofiledialog.cpp b/src/designer/src/components/formeditor/deviceprofiledialog.cpp index 8e77b9ba3..3af31d47f 100644 --- a/src/designer/src/components/formeditor/deviceprofiledialog.cpp +++ b/src/designer/src/components/formeditor/deviceprofiledialog.cpp @@ -19,6 +19,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + static const char *profileExtensionC = "qdp"; static inline QString fileFilter() @@ -130,10 +132,8 @@ void DeviceProfileDialog::save() QString fn = m_dlgGui->getSaveFileName(this, tr("Save Profile"), QString(), fileFilter()); if (fn.isEmpty()) return; - if (QFileInfo(fn).completeSuffix().isEmpty()) { - fn += QLatin1Char('.'); - fn += QLatin1String(profileExtensionC); - } + if (QFileInfo(fn).completeSuffix().isEmpty()) + fn += u'.' + QLatin1StringView(profileExtensionC); QFile file(fn); if (!file.open(QIODevice::WriteOnly|QIODevice::Text)) { diff --git a/src/designer/src/components/formeditor/formwindow.cpp b/src/designer/src/components/formeditor/formwindow.cpp index efad969c8..74e80cfa6 100644 --- a/src/designer/src/components/formeditor/formwindow.cpp +++ b/src/designer/src/components/formeditor/formwindow.cpp @@ -1126,13 +1126,13 @@ bool FormWindow::unify(QObject *w, QString &s, bool changeIt) qlonglong num = 0; qlonglong factor = 1; qsizetype idx = s.size() - 1; - const ushort zeroUnicode = QLatin1Char('0').unicode(); + const char16_t zeroUnicode = u'0'; for ( ; idx > 0 && s.at(idx).isDigit(); --idx) { num += (s.at(idx).unicode() - zeroUnicode) * factor; factor *= 10; } // Position index past '_'. - const QChar underscore = QLatin1Char('_'); + const QChar underscore = u'_'; if (idx >= 0 && s.at(idx) == underscore) { idx++; } else { @@ -1699,7 +1699,7 @@ static inline DomUI *domUIFromClipboard(int *widgetCount, int *actionCount) { *widgetCount = *actionCount = 0; const QString clipboardText = qApp->clipboard()->text(); - if (clipboardText.isEmpty() || clipboardText.indexOf(QLatin1Char('<')) == -1) + if (clipboardText.isEmpty() || clipboardText.indexOf(u'<') == -1) return nullptr; QXmlStreamReader reader(clipboardText); diff --git a/src/designer/src/components/formeditor/formwindowsettings.cpp b/src/designer/src/components/formeditor/formwindowsettings.cpp index e1206cca6..3b64c2f8a 100644 --- a/src/designer/src/components/formeditor/formwindowsettings.cpp +++ b/src/designer/src/components/formeditor/formwindowsettings.cpp @@ -189,7 +189,7 @@ FormWindowData FormWindowSettings::data() const const QString hints = m_ui->includeHintsTextEdit->toPlainText(); if (!hints.isEmpty()) { - rc.includeHints = hints.split(QLatin1Char('\n')); + rc.includeHints = hints.split(u'\n'); // Purge out any lines consisting of blanks only const QRegularExpression blankLine(u"^\\s*$"_s); Q_ASSERT(blankLine.isValid()); @@ -223,7 +223,7 @@ void FormWindowSettings::setData(const FormWindowData &data) if (data.includeHints.isEmpty()) { m_ui->includeHintsTextEdit->clear(); } else { - m_ui->includeHintsTextEdit->setText(data.includeHints.join(QLatin1Char('\n'))); + m_ui->includeHintsTextEdit->setText(data.includeHints.join(u'\n')); } m_ui->gridPanel->setChecked(data.hasFormGrid); diff --git a/src/designer/src/components/formeditor/qdesigner_resource.cpp b/src/designer/src/components/formeditor/qdesigner_resource.cpp index 719d55ddc..64b227d0c 100644 --- a/src/designer/src/components/formeditor/qdesigner_resource.cpp +++ b/src/designer/src/components/formeditor/qdesigner_resource.cpp @@ -518,10 +518,10 @@ void QDesignerResource::saveDom(DomUI *ui, QWidget *widget) if (includeHint.isEmpty()) continue; DomInclude *incl = new DomInclude; - const QString location = includeHint.at(0) == QLatin1Char('<') ? global : local; - includeHint.remove(QLatin1Char('"')); - includeHint.remove(QLatin1Char('<')); - includeHint.remove(QLatin1Char('>')); + const QString location = includeHint.at(0) == u'<' ? global : local; + includeHint.remove(u'"'); + includeHint.remove(u'<'); + includeHint.remove(u'>'); incl->setAttributeLocation(location); incl->setText(includeHint); ui_includes.append(incl); @@ -671,9 +671,11 @@ QWidget *QDesignerResource::create(DomUI *ui, QWidget *parentWidget) continue; if (incl->hasAttributeLocation() && incl->attributeLocation() == global ) { - text = text.prepend(QLatin1Char('<')).append(QLatin1Char('>')); + text.prepend(u'<'); + text.append(u'>'); } else { - text = text.prepend(QLatin1Char('"')).append(QLatin1Char('"')); + text.prepend(u'"'); + text.append(u'"'); } includeHints.append(text); @@ -2112,7 +2114,8 @@ DomResources *QDesignerResource::saveResources(const QStringList &qrcPaths) QString conv_path = path; if (m_resourceBuilder->isSaveRelative()) conv_path = m_formWindow->absoluteDir().relativeFilePath(path); - dom_res->setAttributeLocation(conv_path.replace(QDir::separator(), QLatin1Char('/'))); + conv_path.replace(QDir::separator(), u'/'); + dom_res->setAttributeLocation(conv_path); dom_include.append(dom_res); } } diff --git a/src/designer/src/components/lib/qdesigner_components.cpp b/src/designer/src/components/lib/qdesigner_components.cpp index 7409ef53b..bf50cbc0d 100644 --- a/src/designer/src/components/lib/qdesigner_components.cpp +++ b/src/designer/src/components/lib/qdesigner_components.cpp @@ -123,7 +123,6 @@ static inline void setMinorVersion(int minorVersion, int *qtVersion) static inline QString widgetBoxFileName(int qtVersion, const QDesignerLanguageExtension *lang = nullptr) { QString rc; { - const QChar dot = QLatin1Char('.'); QTextStream str(&rc); str << QDir::homePath() << QDir::separator() << ".designer" << QDir::separator() << "widgetbox"; @@ -131,9 +130,9 @@ static inline QString widgetBoxFileName(int qtVersion, const QDesignerLanguageEx const int major = qtMajorVersion(qtVersion); const int minor = qtMinorVersion(qtVersion); if (major >= 4 && minor >= 4) - str << major << dot << minor; + str << major << '.' << minor; if (lang) - str << dot << lang->uiExtension(); + str << '.' << lang->uiExtension(); str << ".xml"; } return rc; diff --git a/src/designer/src/components/propertyeditor/designerpropertymanager.cpp b/src/designer/src/components/propertyeditor/designerpropertymanager.cpp index 57152f3d2..b7dba1e5d 100644 --- a/src/designer/src/components/propertyeditor/designerpropertymanager.cpp +++ b/src/designer/src/components/propertyeditor/designerpropertymanager.cpp @@ -438,7 +438,7 @@ void TextEditor::resourceActionActivated() oldPath.remove(0, 4); // returns ':/file' QString newPath = IconSelector::choosePixmapResource(m_core, m_core->resourceModel(), oldPath, this); - if (newPath.startsWith(QLatin1Char(':'))) + if (newPath.startsWith(u':')) newPath.remove(0, 1); if (newPath.isEmpty() || newPath == oldPath) return; @@ -743,7 +743,7 @@ void PixmapEditor::pasteActionActivated() QString subtype = u"plain"_s; QString text = clipboard->text(subtype); if (!text.isNull()) { - QStringList list = text.split(QLatin1Char('\n')); + QStringList list = text.split(u'\n'); if (!list.isEmpty()) { text = list.at(0); if (m_iconThemeModeEnabled && QIcon::hasThemeIcon(text)) { @@ -1513,14 +1513,13 @@ QString DesignerPropertyManager::valueText(const QtProperty *property) const if (m_flagValues.contains(const_cast(property))) { const FlagData data = m_flagValues.value(const_cast(property)); const uint v = data.val; - const QChar bar = QLatin1Char('|'); QString valueStr; for (const DesignerIntPair &p : data.flags) { const uint val = p.second; const bool checked = (val == 0) ? (v == 0) : ((val & v) == val); if (checked) { if (!valueStr.isEmpty()) - valueStr += bar; + valueStr += u'|'; valueStr += p.first; } } diff --git a/src/designer/src/components/propertyeditor/propertyeditor.cpp b/src/designer/src/components/propertyeditor/propertyeditor.cpp index c7bfd2861..294357196 100644 --- a/src/designer/src/components/propertyeditor/propertyeditor.cpp +++ b/src/designer/src/components/propertyeditor/propertyeditor.cpp @@ -407,16 +407,13 @@ bool PropertyEditor::isItemVisible(QtBrowserItem *item) const void PropertyEditor::storePropertiesExpansionState(const QList &items) { - const QChar bar = QLatin1Char('|'); for (QtBrowserItem *propertyItem : items) { if (!propertyItem->children().isEmpty()) { QtProperty *property = propertyItem->property(); const QString propertyName = property->propertyName(); const QMap::const_iterator itGroup = m_propertyToGroup.constFind(property); if (itGroup != m_propertyToGroup.constEnd()) { - QString key = itGroup.value(); - key += bar; - key += propertyName; + const QString key = itGroup.value() + u'|' + propertyName; m_expansionState[key] = isExpanded(propertyItem); } } @@ -450,16 +447,13 @@ void PropertyEditor::collapseAll() void PropertyEditor::applyPropertiesExpansionState(const QList &items) { - const QChar bar = QLatin1Char('|'); for (QtBrowserItem *propertyItem : items) { const QMap::const_iterator excend = m_expansionState.constEnd(); QtProperty *property = propertyItem->property(); const QString propertyName = property->propertyName(); const QMap::const_iterator itGroup = m_propertyToGroup.constFind(property); if (itGroup != m_propertyToGroup.constEnd()) { - QString key = itGroup.value(); - key += bar; - key += propertyName; + const QString key = itGroup.value() + u'|' + propertyName; const QMap::const_iterator pit = m_expansionState.constFind(key); if (pit != excend) setExpanded(propertyItem, pit.value()); diff --git a/src/designer/src/components/propertyeditor/qlonglongvalidator.cpp b/src/designer/src/components/propertyeditor/qlonglongvalidator.cpp index 1a40530df..906ffdf80 100644 --- a/src/designer/src/components/propertyeditor/qlonglongvalidator.cpp +++ b/src/designer/src/components/propertyeditor/qlonglongvalidator.cpp @@ -5,6 +5,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { // ---------------------------------------------------------------------------- @@ -24,9 +26,9 @@ QLongLongValidator::~QLongLongValidator() = default; QValidator::State QLongLongValidator::validate(QString & input, int &) const { - if (input.contains(QLatin1Char(' '))) + if (input.contains(u' ')) return Invalid; - if (input.isEmpty() || (b < 0 && input == QString(QLatin1Char('-')))) + if (input.isEmpty() || (b < 0 && input == "-"_L1)) return Intermediate; bool ok; qlonglong entered = input.toLongLong(&ok); @@ -78,7 +80,7 @@ QValidator::State QULongLongValidator::validate(QString & input, int &) const bool ok; qulonglong entered = input.toULongLong(&ok); - if (input.contains(QLatin1Char(' ')) || input.contains(QLatin1Char('-')) || !ok) + if (input.contains(u' ') || input.contains(u'-') || !ok) return Invalid; if (entered >= b && entered <= t) diff --git a/src/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp b/src/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp index 3570f7d96..38a96148d 100644 --- a/src/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp +++ b/src/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp @@ -404,7 +404,7 @@ void InlineEditorModel::addTitle(const QString &title) const int cnt = rowCount(); insertRows(cnt, 1); QModelIndex cat_idx = index(cnt, 0); - setData(cat_idx, QString(title + QLatin1Char(':')), Qt::DisplayRole); + setData(cat_idx, QString(title + u':'), Qt::DisplayRole); setData(cat_idx, TitleItem, Qt::UserRole); QFont font = QApplication::font(); font.setBold(true); diff --git a/src/designer/src/components/taskmenu/itemlisteditor.cpp b/src/designer/src/components/taskmenu/itemlisteditor.cpp index 4fa4f1248..20dd0b919 100644 --- a/src/designer/src/components/taskmenu/itemlisteditor.cpp +++ b/src/designer/src/components/taskmenu/itemlisteditor.cpp @@ -401,9 +401,11 @@ void ItemListEditor::setItemData(int role, const QVariant &v) { QListWidgetItem *item = ui.listWidget->currentItem(); bool reLayout = false; - if ((role == Qt::EditRole && (v.toString().count(QLatin1Char('\n')) != item->data(role).toString().count(QLatin1Char('\n')))) - || role == Qt::FontRole) + if ((role == Qt::EditRole + && (v.toString().count(u'\n') != item->data(role).toString().count(u'\n'))) + || role == Qt::FontRole) { reLayout = true; + } QVariant newValue = v; if (role == Qt::FontRole && newValue.metaType().id() == QMetaType::QFont) { QFont oldFont = ui.listWidget->font(); diff --git a/src/designer/src/components/widgetbox/widgetboxcategorylistview.cpp b/src/designer/src/components/widgetbox/widgetboxcategorylistview.cpp index 4fda87479..392e658eb 100644 --- a/src/designer/src/components/widgetbox/widgetboxcategorylistview.cpp +++ b/src/designer/src/components/widgetbox/widgetboxcategorylistview.cpp @@ -226,10 +226,8 @@ QVariant WidgetBoxCategoryModel::data(const QModelIndex &index, int role) const return QVariant(item.toolTip); // Icon mode tooltip should contain the class name QString tt = item.widget.name(); - if (!item.toolTip.isEmpty()) { - tt += QLatin1Char('\n'); - tt += item.toolTip; - } + if (!item.toolTip.isEmpty()) + tt += u'\n' + item.toolTip; return QVariant(tt); } diff --git a/src/designer/src/components/widgetbox/widgetboxtreewidget.cpp b/src/designer/src/components/widgetbox/widgetboxtreewidget.cpp index d4d6da34f..6f319fd6b 100644 --- a/src/designer/src/components/widgetbox/widgetboxtreewidget.cpp +++ b/src/designer/src/components/widgetbox/widgetboxtreewidget.cpp @@ -50,6 +50,8 @@ enum TopLevelRole { NORMAL_ITEM, SCRATCHPAD_ITEM, CUSTOM_ITEM }; QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + static void setTopLevelRole(TopLevelRole tlr, QTreeWidgetItem *item) { item->setData(0, Qt::UserRole, QVariant(tlr)); @@ -131,7 +133,7 @@ void WidgetBoxTreeWidget::restoreExpandedState() { using StringSet = QSet; QDesignerSettingsInterface *settings = m_core->settingsManager(); - const QString groupKey = QLatin1String(widgetBoxSettingsGroupC) + QLatin1Char('/'); + const QString groupKey = QLatin1StringView(widgetBoxSettingsGroupC) + u'/'; m_iconMode = settings->value(groupKey + QLatin1String(widgetBoxViewModeKeyC)).toBool(); updateViewMode(); const auto &closedCategoryList = settings->value(groupKey + QLatin1String(widgetBoxExpandedKeyC), QStringList()).toStringList(); @@ -497,9 +499,8 @@ bool WidgetBoxTreeWidget::readWidget(Widget *w, const QString &xml, QXmlStreamRe } // Oddity: Startposition is 1 off QString widgetXml = xml.mid(startTagPosition, endTagPosition - startTagPosition); - const QChar lessThan = QLatin1Char('<'); - if (!widgetXml.startsWith(lessThan)) - widgetXml.prepend(lessThan); + if (!widgetXml.startsWith(u'<')) + widgetXml.prepend(u'<'); w->setDomXml(widgetXml); return true; } diff --git a/src/designer/src/designer/appfontdialog.cpp b/src/designer/src/designer/appfontdialog.cpp index e14b40b33..10ebc8c92 100644 --- a/src/designer/src/designer/appfontdialog.cpp +++ b/src/designer/src/designer/appfontdialog.cpp @@ -92,9 +92,7 @@ void AppFontManager::save(QDesignerSettingsInterface *s, const QString &prefix) void AppFontManager::restore(const QDesignerSettingsInterface *s, const QString &prefix) { - QString key = prefix; - key += QLatin1Char('/'); - key += QLatin1String(fontFileKeyC); + const QString key = prefix + u'/' + QLatin1StringView(fontFileKeyC); const QStringList fontFiles = s->value(key, QStringList()).toStringList(); if (debugAppFontWidget) diff --git a/src/designer/src/designer/assistantclient.cpp b/src/designer/src/designer/assistantclient.cpp index 0f01aa295..43934c13e 100644 --- a/src/designer/src/designer/assistantclient.cpp +++ b/src/designer/src/designer/assistantclient.cpp @@ -59,7 +59,7 @@ bool AssistantClient::sendCommand(const QString &cmd, QString *errorMessage) return false; } QTextStream str(m_process); - str << cmd << QLatin1Char('\n') << Qt::endl; + str << cmd << "\n\n"; return true; } diff --git a/src/designer/src/designer/qdesigner.cpp b/src/designer/src/designer/qdesigner.cpp index cc20413c5..3181bd557 100644 --- a/src/designer/src/designer/qdesigner.cpp +++ b/src/designer/src/designer/qdesigner.cpp @@ -85,7 +85,7 @@ void QDesigner::showErrorMessage(const QString &message) const QMessageLogContext emptyContext; previousMessageHandler(QtWarningMsg, emptyContext, message); // just in case we crash m_initializationErrors += qMessage; - m_initializationErrors += QLatin1Char('\n'); + m_initializationErrors += u'\n'; } } diff --git a/src/designer/src/designer/qdesigner_actions.cpp b/src/designer/src/designer/qdesigner_actions.cpp index ba3791f3d..8e01988c1 100644 --- a/src/designer/src/designer/qdesigner_actions.cpp +++ b/src/designer/src/designer/qdesigner_actions.cpp @@ -778,11 +778,8 @@ bool QDesignerActions::readInForm(const QString &fileName) if (!fInfo.exists()) { // Normalize file name const QString directory = fInfo.absolutePath(); - if (QDir(directory).exists()) { - newFormFileName = directory; - newFormFileName += QLatin1Char('/'); - newFormFileName += fInfo.fileName(); - } + if (QDir(directory).exists()) + newFormFileName = directory + u'/' + fInfo.fileName(); } showNewFormDialog(newFormFileName); return false; @@ -1245,11 +1242,8 @@ void QDesignerActions::savePreviewImage() const QString filter = tr("Image files (*.%1)").arg(extension); QString suggestion = fw->fileName(); - if (!suggestion.isEmpty()) { - suggestion = QFileInfo(suggestion).baseName(); - suggestion += QLatin1Char('.'); - suggestion += extension; - } + if (!suggestion.isEmpty()) + suggestion = QFileInfo(suggestion).baseName() + u'.' + extension; QFileDialog dialog(fw, tr("Save Image"), suggestion, filter); dialog.setAcceptMode(QFileDialog::AcceptSave); diff --git a/src/designer/src/designer/qdesigner_formwindow.cpp b/src/designer/src/designer/qdesigner_formwindow.cpp index 7ef8b1f98..3c6dc2f12 100644 --- a/src/designer/src/designer/qdesigner_formwindow.cpp +++ b/src/designer/src/designer/qdesigner_formwindow.cpp @@ -174,8 +174,7 @@ void QDesignerFormWindow::updateWindowTitle(const QString &fileName) if (fileName.isEmpty()) { fileNameTitle += "untitled"_L1; if (const int maxUntitled = getNumberOfUntitledWindows()) { - fileNameTitle += QLatin1Char(' '); - fileNameTitle += QString::number(maxUntitled + 1); + fileNameTitle += u' ' + QString::number(maxUntitled + 1); } } else { fileNameTitle = QFileInfo(fileName).fileName(); diff --git a/src/designer/src/designer/qdesigner_server.cpp b/src/designer/src/designer/qdesigner_server.cpp index 6b4a81a9a..f12a360d1 100644 --- a/src/designer/src/designer/qdesigner_server.cpp +++ b/src/designer/src/designer/qdesigner_server.cpp @@ -15,6 +15,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + // ### review QDesignerServer::QDesignerServer(QObject *parent) @@ -56,8 +58,8 @@ void QDesignerServer::readFromClient() while (m_socket->canReadLine()) { QString file = QString::fromUtf8(m_socket->readLine()); if (!file.isNull()) { - file.remove(QLatin1Char('\n')); - file.remove(QLatin1Char('\r')); + file.remove(u'\n'); + file.remove(u'\r'); qDesigner->postEvent(qDesigner, new QFileOpenEvent(file)); } } @@ -102,8 +104,8 @@ void QDesignerClient::readFromSocket() while (m_socket->canReadLine()) { QString file = QString::fromUtf8(m_socket->readLine()); if (!file.isNull()) { - file.remove(QLatin1Char('\n')); - file.remove(QLatin1Char('\r')); + file.remove(u'\n'); + file.remove(u'\r'); if (QFile::exists(file)) qDesigner->postEvent(qDesigner, new QFileOpenEvent(file)); } diff --git a/src/designer/src/designer/qdesigner_workbench.cpp b/src/designer/src/designer/qdesigner_workbench.cpp index 5ee5f7790..58c856047 100644 --- a/src/designer/src/designer/qdesigner_workbench.cpp +++ b/src/designer/src/designer/qdesigner_workbench.cpp @@ -885,8 +885,8 @@ QDesignerFormWindow * QDesignerWorkbench::loadForm(const QString &fileName, const QString text = QString::fromUtf8(file.readLine()); file.close(); - const int lf = text.indexOf(QLatin1Char('\n')); - if (lf > 0 && text.at(lf-1) == QLatin1Char('\r')) { + const auto lf = text.indexOf(u'\n'); + if (lf > 0 && text.at(lf - 1) == u'\r') { mode = qdesigner_internal::FormWindowBase::CRLFLineTerminator; } else if (lf >= 0) { mode = qdesigner_internal::FormWindowBase::LFLineTerminator; diff --git a/src/designer/src/designer/saveformastemplate.cpp b/src/designer/src/designer/saveformastemplate.cpp index a26b057e9..e8bc64477 100644 --- a/src/designer/src/designer/saveformastemplate.cpp +++ b/src/designer/src/designer/saveformastemplate.cpp @@ -44,10 +44,8 @@ SaveFormAsTemplate::~SaveFormAsTemplate() = default; void SaveFormAsTemplate::accept() { - QString templateFileName = ui.categoryCombo->currentText(); - templateFileName += QLatin1Char('/'); const QString name = ui.templateNameEdit->text(); - templateFileName += name; + QString templateFileName = ui.categoryCombo->currentText() + u'/' + name; const auto extension = ".ui"_L1; if (!templateFileName.endsWith(extension)) templateFileName.append(extension); diff --git a/src/designer/src/lib/shared/actioneditor.cpp b/src/designer/src/lib/shared/actioneditor.cpp index 057616217..24f3fbd8d 100644 --- a/src/designer/src/lib/shared/actioneditor.cpp +++ b/src/designer/src/lib/shared/actioneditor.cpp @@ -672,14 +672,13 @@ void ActionEditor::slotDelete() // UnderScore: "Open file" -> actionOpen_file static QString underscore(QString text) { - const QString underscore = QString(QLatin1Char('_')); static const QRegularExpression nonAsciiPattern(u"[^a-zA-Z_0-9]"_s); Q_ASSERT(nonAsciiPattern.isValid()); - text.replace(nonAsciiPattern, underscore); + text.replace(nonAsciiPattern, "_"_L1); static const QRegularExpression multipleSpacePattern(u"__*"_s); Q_ASSERT(multipleSpacePattern.isValid()); - text.replace(multipleSpacePattern, underscore); - if (text.endsWith(underscore.at(0))) + text.replace(multipleSpacePattern, "_"_L1); + if (text.endsWith(u'_')) text.chop(1); return text; } diff --git a/src/designer/src/lib/shared/actionrepository.cpp b/src/designer/src/lib/shared/actionrepository.cpp index 8f49a6dc7..1fa1e0ebc 100644 --- a/src/designer/src/lib/shared/actionrepository.cpp +++ b/src/designer/src/lib/shared/actionrepository.cpp @@ -153,10 +153,8 @@ void ActionModel::setItems(QDesignerFormEditorInterface *core, QAction *action, // Tooltip, mostly for icon view mode QString firstTooltip = action->objectName(); const QString text = action->text(); - if (!text.isEmpty()) { - firstTooltip += QLatin1Char('\n'); - firstTooltip += text; - } + if (!text.isEmpty()) + firstTooltip += u'\n' + text; Q_ASSERT(sl.size() == NumColumns); @@ -201,7 +199,7 @@ void ActionModel::setItems(QDesignerFormEditorInterface *core, QAction *action, QString toolTip = action->toolTip(); item = sl[ToolTipColumn]; item->setToolTip(toolTip); - item->setText(toolTip.replace(QLatin1Char('\n'), QLatin1Char(' '))); + item->setText(toolTip.replace(u'\n', u' ')); // menuRole const auto menuRole = action->menuRole(); item = sl[MenuRoleColumn]; diff --git a/src/designer/src/lib/shared/csshighlighter.cpp b/src/designer/src/lib/shared/csshighlighter.cpp index c74ed8508..d34e7e4de 100644 --- a/src/designer/src/lib/shared/csshighlighter.cpp +++ b/src/designer/src/lib/shared/csshighlighter.cpp @@ -5,6 +5,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { CssHighlighter::CssHighlighter(const CssHighlightColors &colors, @@ -41,8 +43,8 @@ void CssHighlighter::highlightBlock(const QString& text) // The initial state is based on the precense of a : and the absense of a {. // This is because Qt style sheets support both a full stylesheet as well as // an inline form with just properties. - state = save_state = (text.indexOf(QLatin1Char(':')) > -1 && - text.indexOf(QLatin1Char('{')) == -1) ? Property : Selector; + state = save_state = (text.indexOf(u':') > -1 && + text.indexOf(u'{') == -1) ? Property : Selector; } else { save_state = state>>16; state &= 0x00ff; diff --git a/src/designer/src/lib/shared/formlayoutmenu.cpp b/src/designer/src/lib/shared/formlayoutmenu.cpp index ba0dc6baa..4058e78b7 100644 --- a/src/designer/src/lib/shared/formlayoutmenu.cpp +++ b/src/designer/src/lib/shared/formlayoutmenu.cpp @@ -220,7 +220,7 @@ static inline QString postFixFromClassName(QString className) if (index != -1) className.remove(0, index + 2); if (className.size() > 2) - if (className.at(0) == QLatin1Char('Q') || className.at(0) == QLatin1Char('K')) + if (className.at(0) == u'Q' || className.at(0) == u'K') if (className.at(1).isUpper()) className.remove(0, 1); return className; diff --git a/src/designer/src/lib/shared/htmlhighlighter.cpp b/src/designer/src/lib/shared/htmlhighlighter.cpp index dead3a100..59e2a5efa 100644 --- a/src/designer/src/lib/shared/htmlhighlighter.cpp +++ b/src/designer/src/lib/shared/htmlhighlighter.cpp @@ -48,15 +48,8 @@ void HtmlHighlighter::setFormatFor(Construct construct, void HtmlHighlighter::highlightBlock(const QString &text) { - static const QLatin1Char tab = QLatin1Char('\t'); - static const QLatin1Char space = QLatin1Char(' '); - static const QLatin1Char amp = QLatin1Char('&'); - static const QLatin1Char startTag = QLatin1Char('<'); - static const QLatin1Char endTag = QLatin1Char('>'); - static const QLatin1Char quot = QLatin1Char('"'); - static const QLatin1Char apos = QLatin1Char('\''); - static const QLatin1Char semicolon = QLatin1Char(';'); - static const QLatin1Char equals = QLatin1Char('='); + static const QChar tab = u'\t'; + static const QChar space = u' '; int state = previousBlockState(); qsizetype len = text.size(); @@ -69,14 +62,14 @@ void HtmlHighlighter::highlightBlock(const QString &text) default: while (pos < len) { QChar ch = text.at(pos); - if (ch == startTag) { + if (ch == u'<') { if (QStringView{text}.sliced(pos).startsWith("