diff --git a/kdevplatform/CMakeLists.txt b/kdevplatform/CMakeLists.txt --- a/kdevplatform/CMakeLists.txt +++ b/kdevplatform/CMakeLists.txt @@ -55,6 +55,12 @@ set(COMPILER_OPTIMIZATIONS_DISABLED FALSE) endif() +add_definitions( + -DQT_NO_CAST_FROM_ASCII + -DQT_NO_CAST_TO_ASCII + -DQT_NO_CAST_FROM_BYTEARRAY +) + add_subdirectory(sublime) add_subdirectory(interfaces) add_subdirectory(project) diff --git a/kdevplatform/debugger/breakpoint/breakpoint.cpp b/kdevplatform/debugger/breakpoint/breakpoint.cpp --- a/kdevplatform/debugger/breakpoint/breakpoint.cpp +++ b/kdevplatform/debugger/breakpoint/breakpoint.cpp @@ -40,7 +40,7 @@ static Breakpoint::BreakpointKind stringToKind(const QString& kindString) { for (int i = 0; i < Breakpoint::LastBreakpointKind; ++i) { - if (BREAKPOINT_KINDS[i] == kindString) { + if (kindString == QLatin1String(BREAKPOINT_KINDS[i])) { return (Breakpoint::BreakpointKind)i; } } @@ -100,7 +100,7 @@ { QString s = value.toString(); if (index == LocationColumn) { - QRegExp rx("^(.+):([0-9]+)$"); + QRegExp rx(QStringLiteral("^(.+):([0-9]+)$")); int idx = rx.indexIn(s); if (m_kind == CodeBreakpoint && idx != -1) { m_url = QUrl::fromLocalFile(rx.cap(1)); @@ -171,7 +171,7 @@ if (column == TypeColumn && role == Qt::DisplayRole) { - return BREAKPOINT_KINDS[m_kind]; + return QLatin1String(BREAKPOINT_KINDS[m_kind]); } if (column == ConditionColumn && (role == Qt::DisplayRole || role == Qt::EditRole)) { @@ -187,7 +187,7 @@ } else { ret = m_url.toDisplayString(QUrl::PreferLocalFile | QUrl::StripTrailingSlash); } - ret += ':' + QString::number(m_line+1); + ret += QLatin1Char(':') + QString::number(m_line+1); } else { ret = m_expression; } diff --git a/kdevplatform/debugger/breakpoint/breakpointmodel.cpp b/kdevplatform/debugger/breakpoint/breakpointmodel.cpp --- a/kdevplatform/debugger/breakpoint/breakpointmodel.cpp +++ b/kdevplatform/debugger/breakpoint/breakpointmodel.cpp @@ -213,7 +213,7 @@ } if (role == Qt::DisplayRole) { - if (section == 0 || section == 1) return ""; + if (section == 0 || section == 1) return QString(); if (section == 2) return i18n("Type"); if (section == 3) return i18n("Location"); if (section == 4) return i18n("Condition"); diff --git a/kdevplatform/debugger/framestack/framestackmodel.cpp b/kdevplatform/debugger/framestack/framestackmodel.cpp --- a/kdevplatform/debugger/framestack/framestackmodel.cpp +++ b/kdevplatform/debugger/framestack/framestackmodel.cpp @@ -205,7 +205,7 @@ QString ret = ICore::self()->projectController() ->prettyFileName(frame.file, IProjectController::FormatPlain); if (frame.line != -1) { - ret += ':' + QString::number(frame.line + 1); + ret += QLatin1Char(':') + QString::number(frame.line + 1); } return ret; } else if (role == Qt::DecorationRole) { diff --git a/kdevplatform/debugger/util/treeitem.cpp b/kdevplatform/debugger/util/treeitem.cpp --- a/kdevplatform/debugger/util/treeitem.cpp +++ b/kdevplatform/debugger/util/treeitem.cpp @@ -188,9 +188,9 @@ : TreeItem(model, parent) { QVector data; - data.push_back("..."); + data.push_back(QVariant(QStringLiteral("..."))); for (int i = 1; i < model->columnCount(QModelIndex()); ++i) - data.push_back(""); + data.push_back(QString()); setData(data); } diff --git a/kdevplatform/interfaces/iplugincontroller.h b/kdevplatform/interfaces/iplugincontroller.h --- a/kdevplatform/interfaces/iplugincontroller.h +++ b/kdevplatform/interfaces/iplugincontroller.h @@ -154,7 +154,7 @@ { QString ext; if( extension.isEmpty() ) { - ext = qobject_interface_iid(); + ext = QString::fromUtf8(qobject_interface_iid()); } else { ext = extension; } diff --git a/kdevplatform/interfaces/isourceformatter.cpp b/kdevplatform/interfaces/isourceformatter.cpp --- a/kdevplatform/interfaces/isourceformatter.cpp +++ b/kdevplatform/interfaces/isourceformatter.cpp @@ -103,7 +103,7 @@ void SourceFormatterStyle::setMimeTypes(const QStringList& types) { foreach ( auto& t, types ) { - auto items = t.split('|'); + auto items = t.split(QLatin1Char('|')); if ( items.size() != 2 ) { continue; } @@ -167,21 +167,18 @@ QString options; QMap::const_iterator it = map.constBegin(); for (; it != map.constEnd(); ++it) { - options += it.key(); - options += '='; - options += it.value().toString(); - options += ','; + options += it.key() + QLatin1Char('=') + it.value().toString() + QLatin1Char(','); } return options; } QMap ISourceFormatter::stringToOptionMap(const QString &options) { QMap map; - QStringList pairs = options.split(',', QString::SkipEmptyParts); + QStringList pairs = options.split(QLatin1Char(','), QString::SkipEmptyParts); QStringList::const_iterator it; for (it = pairs.constBegin(); it != pairs.constEnd(); ++it) { - QStringList bits = (*it).split('='); + const QStringList bits = (*it).split(QLatin1Char('=')); map[bits[0]] = bits[1]; } return map; @@ -191,7 +188,7 @@ { return i18n("The executable %1 cannot be found. Please make sure" " it is installed and can be executed.
" - "The plugin will not work until you fix this problem.", "" + name + ""); + "The plugin will not work until you fix this problem.", QLatin1String("") + name + QLatin1String("")); } } diff --git a/kdevplatform/language/assistant/renameassistant.cpp b/kdevplatform/language/assistant/renameassistant.cpp --- a/kdevplatform/language/assistant/renameassistant.cpp +++ b/kdevplatform/language/assistant/renameassistant.cpp @@ -139,7 +139,7 @@ return; //If the inserted text isn't valid for a variable name, consider the editing ended - QRegExp validDeclName("^[0-9a-zA-Z_]*$"); + QRegExp validDeclName(QStringLiteral("^[0-9a-zA-Z_]*$")); if (removedText.isEmpty() && !validDeclName.exactMatch(doc->text(invocationRange))) { d->reset(); return; diff --git a/kdevplatform/language/backgroundparser/documentchangetracker.cpp b/kdevplatform/language/backgroundparser/documentchangetracker.cpp --- a/kdevplatform/language/backgroundparser/documentchangetracker.cpp +++ b/kdevplatform/language/backgroundparser/documentchangetracker.cpp @@ -163,8 +163,8 @@ static Cursor cursorAdd(Cursor c, const QString& text) { - c.setLine(c.line() + text.count('\n')); - c.setColumn(c.column() + (text.length() - qMin(0, text.lastIndexOf('\n')))); + c.setLine(c.line() + text.count(QLatin1Char('\n'))); + c.setColumn(c.column() + (text.length() - qMin(0, text.lastIndexOf(QLatin1Char('\n'))))); return c; } diff --git a/kdevplatform/language/classmodel/classmodel.cpp b/kdevplatform/language/classmodel/classmodel.cpp --- a/kdevplatform/language/classmodel/classmodel.cpp +++ b/kdevplatform/language/classmodel/classmodel.cpp @@ -132,7 +132,7 @@ QVariant ClassModel::headerData(int, Qt::Orientation, int role) const { if ( role == Qt::DisplayRole ) - return "Class"; + return QStringLiteral("Class"); return QVariant(); } diff --git a/kdevplatform/language/classmodel/classmodelnode.cpp b/kdevplatform/language/classmodel/classmodelnode.cpp --- a/kdevplatform/language/classmodel/classmodelnode.cpp +++ b/kdevplatform/language/classmodel/classmodelnode.cpp @@ -299,9 +299,9 @@ ClassFunctionDeclaration* classmember = dynamic_cast(a_decl); if ( classmember ) { if ( classmember->isConstructor() || classmember->isDestructor() ) - m_sortableString = '0' + m_displayName; + m_sortableString = QLatin1Char('0') + m_displayName; else - m_sortableString = '1' + m_displayName; + m_sortableString = QLatin1Char('1') + m_displayName; } else { m_sortableString = m_displayName; diff --git a/kdevplatform/language/codecompletion/codecompletioncontext.cpp b/kdevplatform/language/codecompletion/codecompletioncontext.cpp --- a/kdevplatform/language/codecompletion/codecompletioncontext.cpp +++ b/kdevplatform/language/codecompletion/codecompletioncontext.cpp @@ -29,7 +29,7 @@ ///Extracts the last line from the given string QString CodeCompletionContext::extractLastLine(const QString& str) { - int prevLineEnd = str.lastIndexOf('\n'); + int prevLineEnd = str.lastIndexOf(QLatin1Char('\n')); if(prevLineEnd != -1) return str.mid(prevLineEnd+1); else diff --git a/kdevplatform/language/codecompletion/codecompletionhelper.cpp b/kdevplatform/language/codecompletion/codecompletionhelper.cpp --- a/kdevplatform/language/codecompletion/codecompletionhelper.cpp +++ b/kdevplatform/language/codecompletion/codecompletionhelper.cpp @@ -51,36 +51,36 @@ //Need to have a paren behind QString suffix = view->document()->text( KTextEditor::Range( pos, pos + KTextEditor::Cursor(1, 0) ) ); - if( suffix.trimmed().startsWith('(') ) { + if (suffix.trimmed().startsWith(QLatin1Char('('))) { //Move the cursor behind the opening paren if( view ) - view->setCursorPosition( pos + KTextEditor::Cursor( 0, suffix.indexOf('(')+1 ) ); + view->setCursorPosition(pos + KTextEditor::Cursor(0, suffix.indexOf(QLatin1Char('(')) + 1)); }else{ //We need to insert an opening paren QString openingParen; if( spaceBeforeParen ) openingParen = QStringLiteral(" ("); else - openingParen = '('; + openingParen = QLatin1Char('('); if( spaceBetweenParens && (haveArguments || spaceBetweenEmptyParens) ) - openingParen += ' '; + openingParen += QLatin1Char(' '); QString closingParen; if( spaceBetweenParens && (haveArguments) ) { closingParen = QStringLiteral(" )"); } else - closingParen = ')'; + closingParen = QLatin1Char(')'); KTextEditor::Cursor jumpPos = pos + KTextEditor::Cursor( 0, openingParen.length() ); // when function returns void, also add a semicolon if (funcType) { if (IntegralType::Ptr type = funcType->returnType().cast()) { if (type->dataType() == IntegralType::TypeVoid) { const QChar nextChar = view->document()->characterAt(pos); - if (nextChar != ';' && nextChar != ')' && nextChar != ',') { - closingParen += ';'; + if (nextChar != QLatin1Char(';') && nextChar != QLatin1Char(')') && nextChar != QLatin1Char(',')) { + closingParen += QLatin1Char(';'); } } } diff --git a/kdevplatform/language/codecompletion/codecompletionworker.cpp b/kdevplatform/language/codecompletion/codecompletionworker.cpp --- a/kdevplatform/language/codecompletion/codecompletionworker.cpp +++ b/kdevplatform/language/codecompletion/codecompletionworker.cpp @@ -111,7 +111,7 @@ } if( position.column() == 0 ) //Seems like when the cursor is a the beginning of a line, kate does not give the \n - text += '\n'; + text += QLatin1Char('\n'); if (aborting()) { failed(); diff --git a/kdevplatform/language/codecompletion/normaldeclarationcompletionitem.cpp b/kdevplatform/language/codecompletion/normaldeclarationcompletionitem.cpp --- a/kdevplatform/language/codecompletion/normaldeclarationcompletionitem.cpp +++ b/kdevplatform/language/codecompletion/normaldeclarationcompletionitem.cpp @@ -156,7 +156,7 @@ if(!m_declaration->context()->owner()->identifier().isEmpty()) return shortenedTypeString(DeclarationPointer(m_declaration->context()->owner()), desiredTypeLength); else - return "enum"; + return QStringLiteral("enum"); } } if (FunctionType::Ptr functionType = m_declaration->type()) { @@ -171,17 +171,17 @@ }else if(argumentHintDepth()) { return QString();//Don't show useless prefixes in the argument-hints }else if(funDecl && funDecl->isConstructor() ) - return ""; + return QStringLiteral(""); else if(funDecl && funDecl->isDestructor() ) - return ""; + return QStringLiteral(""); else - return ""; + return QStringLiteral(""); } else { return shortenedTypeString(m_declaration, desiredTypeLength); } } else { - return ""; + return QStringLiteral(""); } } else if (index.column() == CodeCompletionModel::Arguments) { if (m_declaration->isFunctionDeclaration()) { diff --git a/kdevplatform/language/codegen/applychangeswidget.cpp b/kdevplatform/language/codegen/applychangeswidget.cpp --- a/kdevplatform/language/codegen/applychangeswidget.cpp +++ b/kdevplatform/language/codegen/applychangeswidget.cpp @@ -173,7 +173,7 @@ CodeRepresentation::Ptr repr = createCodeRepresentation(file); if(!repr->fileExists()) { - const QString templateName = QDir::tempPath() + QLatin1Char('/') + url.fileName().split('.').last(); + const QString templateName = QDir::tempPath() + QLatin1Char('/') + url.fileName().split(QLatin1Char('.')).last(); QTemporaryFile * temp(new QTemporaryFile(templateName)); temp->open(); temp->write(repr->text().toUtf8()); diff --git a/kdevplatform/language/codegen/archivetemplateloader.cpp b/kdevplatform/language/codegen/archivetemplateloader.cpp --- a/kdevplatform/language/codegen/archivetemplateloader.cpp +++ b/kdevplatform/language/codegen/archivetemplateloader.cpp @@ -101,5 +101,5 @@ { const KArchiveFile* file = dynamic_cast(m_directory->entry(name)); Q_ASSERT(file); - return file->data(); + return QString::fromUtf8(file->data()); } diff --git a/kdevplatform/language/codegen/basicrefactoring.cpp b/kdevplatform/language/codegen/basicrefactoring.cpp --- a/kdevplatform/language/codegen/basicrefactoring.cpp +++ b/kdevplatform/language/codegen/basicrefactoring.cpp @@ -52,7 +52,7 @@ QPair splitFileAtExtension(const QString& fileName) { - int idx = fileName.indexOf('.'); + int idx = fileName.indexOf(QLatin1Char('.')); if (idx == -1) { return qMakePair(fileName, QString()); } diff --git a/kdevplatform/language/codegen/coderepresentation.cpp b/kdevplatform/language/codegen/coderepresentation.cpp --- a/kdevplatform/language/codegen/coderepresentation.cpp +++ b/kdevplatform/language/codegen/coderepresentation.cpp @@ -44,7 +44,7 @@ QString rangedText = line(range.start().line()).mid(range.start().column()); for(int i = range.start().line() + 1; i <= range.end().line(); ++i) - rangedText += '\n' + ((i == range.end().line()) ? line(i).left(range.end().column()) : line(i)); + rangedText += QLatin1Char('\n') + ((i == range.end().line()) ? line(i).left(range.end().column()) : line(i)); return rangedText; } @@ -64,8 +64,8 @@ pos += identifier.length(); int end = pos; - if(!surroundedByBoundary || ( (end == lineText.length() || !lineText[end].isLetterOrNumber() || lineText[end] != '_') - && (start-1 < 0 || !lineText[start-1].isLetterOrNumber() || lineText[start-1] != '_')) ) + if (!surroundedByBoundary || ( (end == lineText.length() || !lineText[end].isLetterOrNumber() || lineText[end] != QLatin1Char('_')) + && (start-1 < 0 || !lineText[start-1].isLetterOrNumber() || lineText[start-1] != QLatin1Char('_'))) ) { ret << KTextEditor::Range(lineNumber, start, lineNumber, end); } @@ -158,7 +158,7 @@ QFile file( localFile ); if ( file.open(QIODevice::ReadOnly) ) { data = QString::fromLocal8Bit(file.readAll()); - lineData = data.split('\n'); + lineData = data.split(QLatin1Char('\n')); } m_exists = file.exists(); } @@ -228,7 +228,7 @@ } void setData(const QString& data) { m_data = data; - m_lineData = m_data.split('\n'); + m_lineData = m_data.split(QLatin1Char('\n')); } QString data() const { return m_data; diff --git a/kdevplatform/language/codegen/documentchangeset.cpp b/kdevplatform/language/codegen/documentchangeset.cpp --- a/kdevplatform/language/codegen/documentchangeset.cpp +++ b/kdevplatform/language/codegen/documentchangeset.cpp @@ -379,7 +379,7 @@ } //Create the actual new modified file - QStringList textLines = repr->text().split('\n'); + QStringList textLines = repr->text().split(QLatin1Char('\n')); QUrl url = file.toUrl(); @@ -406,8 +406,8 @@ if(formatPolicy == DocumentChangeSet::AutoFormatChangesKeepIndentation) { // Reproduce the previous indentation - QStringList oldLines = oldNewText.split('\n'); - QStringList newLines = change.m_newText.split('\n'); + QStringList oldLines = oldNewText.split(QLatin1Char('\n')); + QStringList newLines = change.m_newText.split(QLatin1Char('\n')); if(oldLines.size() == newLines.size()) { for(int line = 0; line < newLines.size(); ++line) { diff --git a/kdevplatform/language/codegen/templateclassgenerator.cpp b/kdevplatform/language/codegen/templateclassgenerator.cpp --- a/kdevplatform/language/codegen/templateclassgenerator.cpp +++ b/kdevplatform/language/codegen/templateclassgenerator.cpp @@ -39,7 +39,7 @@ /// @param base String such as 'public QObject' or 'QObject' InheritanceDescription descriptionFromString(const QString& base) { - QStringList splitBase = base.split(' '); + QStringList splitBase = base.split(QLatin1Char(' ')); QString identifier = splitBase.takeLast(); QString inheritanceMode = splitBase.join(QStringLiteral(" ")); @@ -159,8 +159,8 @@ void TemplateClassGenerator::setFileUrl(const QString& outputFile, const QUrl& url) { d->fileUrls.insert(outputFile, url); - d->renderer.addVariable("output_file_" + outputFile.toLower(), QDir(d->baseUrl.path()).relativeFilePath(url.path())); - d->renderer.addVariable("output_file_" + outputFile.toLower() + "_absolute", url.toLocalFile()); + d->renderer.addVariable(QLatin1String("output_file_") + outputFile.toLower(), QDir(d->baseUrl.path()).relativeFilePath(url.path())); + d->renderer.addVariable(QLatin1String("output_file_") + outputFile.toLower() + QLatin1String("_absolute"), url.toLocalFile()); } KTextEditor::Cursor TemplateClassGenerator::filePosition(const QString& outputFile) const diff --git a/kdevplatform/language/codegen/templaterenderer.cpp b/kdevplatform/language/codegen/templaterenderer.cpp --- a/kdevplatform/language/codegen/templaterenderer.cpp +++ b/kdevplatform/language/codegen/templaterenderer.cpp @@ -132,9 +132,8 @@ d->errorString.clear(); } - if (d->emptyLinesPolicy == TrimEmptyLines && output.contains('\n')) - { - QStringList lines = output.split('\n', QString::KeepEmptyParts); + if (d->emptyLinesPolicy == TrimEmptyLines && output.contains(QLatin1Char('\n'))) { + QStringList lines = output.split(QLatin1Char('\n'), QString::KeepEmptyParts); QMutableStringListIterator it(lines); // Remove empty lines from the start of the document @@ -201,7 +200,7 @@ } else if (d->emptyLinesPolicy == RemoveEmptyLines) { - QStringList lines = output.split('\n', QString::SkipEmptyParts); + QStringList lines = output.split(QLatin1Char('\n'), QString::SkipEmptyParts); QMutableStringListIterator it(lines); while (it.hasNext()) { @@ -226,7 +225,7 @@ QFile file(url.toLocalFile()); file.open(QIODevice::ReadOnly); - QString content(file.readAll()); + const QString content = QString::fromUtf8(file.readAll()); qCDebug(LANGUAGE) << content; return render(content, name); @@ -260,14 +259,14 @@ DocumentChangeSet changes; const QDir baseDir(baseUrl.path()); - QRegExp nonAlphaNumeric("\\W"); + QRegExp nonAlphaNumeric(QStringLiteral("\\W")); for (QHash::const_iterator it = fileUrls.constBegin(); it != fileUrls.constEnd(); ++it) { QString cleanName = it.key().toLower(); cleanName.replace(nonAlphaNumeric, QStringLiteral("_")); const QString path = it.value().toLocalFile(); - addVariable("output_file_" + cleanName, baseDir.relativeFilePath(path)); - addVariable("output_file_" + cleanName + "_absolute", path); + addVariable(QLatin1String("output_file_") + cleanName, baseDir.relativeFilePath(path)); + addVariable(QLatin1String("output_file_") + cleanName + QLatin1String("_absolute"), path); } const KArchiveDirectory* directory = fileTemplate.directory(); @@ -292,7 +291,7 @@ IndexedString document(url); KTextEditor::Range range(KTextEditor::Cursor(0, 0), 0); - DocumentChange change(document, range, QString(), render(file->data(), outputFile.identifier)); + DocumentChange change(document, range, QString(), render(QString::fromUtf8(file->data()), outputFile.identifier)); changes.addChange(change); qCDebug(LANGUAGE) << "Added change for file" << document.str(); } diff --git a/kdevplatform/language/codegen/templatesmodel.cpp b/kdevplatform/language/codegen/templatesmodel.cpp --- a/kdevplatform/language/codegen/templatesmodel.cpp +++ b/kdevplatform/language/codegen/templatesmodel.cpp @@ -93,8 +93,8 @@ TemplatesModelPrivate::TemplatesModelPrivate(const QString& _typePrefix) : typePrefix(_typePrefix) { - if (!typePrefix.endsWith('/')) { - typePrefix.append('/'); + if (!typePrefix.endsWith(QLatin1Char('/'))) { + typePrefix.append(QLatin1Char('/')); } } @@ -126,7 +126,7 @@ } QStringList templateDescriptions; - const QStringList templatePaths = {QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) +'/'+ d->resourceFilter(TemplatesModelPrivate::Description)}; + const QStringList templatePaths = {QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1Char('/') + d->resourceFilter(TemplatesModelPrivate::Description)}; foreach(const QString& templateDescription, templatePaths) { const QStringList files = QDir(templateDescription).entryList(QDir::Files); foreach(const QString& file, files) { @@ -167,7 +167,7 @@ QStandardItem *TemplatesModelPrivate::createItem(const QString& name, const QString& category, QStandardItem* parent) { - QStringList path = category.split('/'); + QStringList path = category.split(QLatin1Char('/')); QStringList currentPath; foreach (const QString& entry, path) @@ -205,7 +205,7 @@ } } - QString localDescriptionsDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) +'/'+ resourceFilter(Description); + QString localDescriptionsDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1Char('/') + resourceFilter(Description); QDir dir(localDescriptionsDir); if(!dir.exists()) @@ -308,31 +308,31 @@ QModelIndexList TemplatesModel::templateIndexes(const QString& fileName) const { QFileInfo info(fileName); - QString description = QStandardPaths::locate(QStandardPaths::GenericDataLocation, d->resourceFilter(TemplatesModelPrivate::Description, info.baseName() + ".kdevtemplate")); + QString description = QStandardPaths::locate(QStandardPaths::GenericDataLocation, d->resourceFilter(TemplatesModelPrivate::Description, info.baseName() + QLatin1String(".kdevtemplate"))); if (description.isEmpty()) { - description = QStandardPaths::locate(QStandardPaths::GenericDataLocation, d->resourceFilter(TemplatesModelPrivate::Description, info.baseName() + ".desktop")); + description = QStandardPaths::locate(QStandardPaths::GenericDataLocation, d->resourceFilter(TemplatesModelPrivate::Description, info.baseName() + QLatin1String(".desktop"))); } QModelIndexList indexes; if (!description.isEmpty()) { KConfig templateConfig(description); KConfigGroup general(&templateConfig, "General"); - QStringList categories = general.readEntry("Category").split('/'); + QStringList categories = general.readEntry("Category").split(QLatin1Char('/')); QStringList levels; foreach (const QString& category, categories) { levels << category; - indexes << d->templateItems[levels.join(QString('/'))]->index(); + indexes << d->templateItems[levels.join(QStringLiteral("/"))]->index(); } if (!indexes.isEmpty()) { QString name = general.readEntry("Name"); - QStandardItem* categoryItem = d->templateItems[levels.join(QString('/'))]; + QStandardItem* categoryItem = d->templateItems[levels.join(QStringLiteral("/"))]; for (int i = 0; i < categoryItem->rowCount(); ++i) { QStandardItem* templateItem = categoryItem->child(i); @@ -361,7 +361,7 @@ QString TemplatesModel::loadTemplateFile(const QString& fileName) { - QString saveLocation = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) +'/'+ d->resourceFilter(TemplatesModelPrivate::Template); + QString saveLocation = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1Char('/') + d->resourceFilter(TemplatesModelPrivate::Template); QDir dir(saveLocation); if(!dir.exists()) diff --git a/kdevplatform/language/duchain/classfunctiondeclaration.cpp b/kdevplatform/language/duchain/classfunctiondeclaration.cpp --- a/kdevplatform/language/duchain/classfunctiondeclaration.cpp +++ b/kdevplatform/language/duchain/classfunctiondeclaration.cpp @@ -186,7 +186,7 @@ { DUContext* ctx = context(); QString id = identifier().toString(); - return ctx && ctx->type() == DUContext::Class && id.startsWith('~') && id.mid(1) == ctx->localScopeIdentifier().top().toString(); + return ctx && ctx->type() == DUContext::Class && id.startsWith(QLatin1Char('~')) && id.mid(1) == ctx->localScopeIdentifier().top().toString(); } uint ClassFunctionDeclaration::additionalIdentity() const diff --git a/kdevplatform/language/duchain/declaration.cpp b/kdevplatform/language/duchain/declaration.cpp --- a/kdevplatform/language/duchain/declaration.cpp +++ b/kdevplatform/language/duchain/declaration.cpp @@ -181,7 +181,7 @@ if(str.isEmpty()) d->m_comment = 0; else - d->m_comment = commentRepository().index(Repositories::StringRepositoryItemRequest(str, IndexedString::hashString(str, str.length()), str.length())); + d->m_comment = commentRepository().index(Repositories::StringRepositoryItemRequest(str.constData(), IndexedString::hashString(str.constData(), str.length()), str.length())); } void Declaration::setComment(const QString& str) { diff --git a/kdevplatform/language/duchain/duchain.cpp b/kdevplatform/language/duchain/duchain.cpp --- a/kdevplatform/language/duchain/duchain.cpp +++ b/kdevplatform/language/duchain/duchain.cpp @@ -310,7 +310,7 @@ ///Loading of some static data: { ///@todo Solve this more duchain-like - QFile f(globalItemRepositoryRegistry().path() + "/parsing_environment_data"); + QFile f(globalItemRepositoryRegistry().path() + QLatin1String("/parsing_environment_data")); bool opened = f.open(QIODevice::ReadOnly); ///FIXME: ugh, so ugly ParsingEnvironmentFile::m_staticData = reinterpret_cast( new char[sizeof(StaticParsingEnvironmentData)]); @@ -327,7 +327,7 @@ ///Read in the list of available top-context indices { - QFile f(globalItemRepositoryRegistry().path() + "/available_top_context_indices"); + QFile f(globalItemRepositoryRegistry().path() + QLatin1String("/available_top_context_indices")); bool opened = f.open(QIODevice::ReadOnly); if(opened) { @@ -861,7 +861,7 @@ //Store the static parsing-environment file data ///@todo Solve this more elegantly, using a general mechanism to store static duchain-like data Q_ASSERT(ParsingEnvironmentFile::m_staticData); - QFile f(globalItemRepositoryRegistry().path() + "/parsing_environment_data"); + QFile f(globalItemRepositoryRegistry().path() + QLatin1String("/parsing_environment_data")); bool opened = f.open(QIODevice::WriteOnly); Q_ASSERT(opened); Q_UNUSED(opened); @@ -872,7 +872,7 @@ { QMutexLocker lock(&m_chainsMutex); - QFile f(globalItemRepositoryRegistry().path() + "/available_top_context_indices"); + QFile f(globalItemRepositoryRegistry().path() + QLatin1String("/available_top_context_indices")); bool opened = f.open(QIODevice::WriteOnly); Q_ASSERT(opened); Q_UNUSED(opened); diff --git a/kdevplatform/language/duchain/dumpdotgraph.cpp b/kdevplatform/language/duchain/dumpdotgraph.cpp --- a/kdevplatform/language/duchain/dumpdotgraph.cpp +++ b/kdevplatform/language/duchain/dumpdotgraph.cpp @@ -139,10 +139,10 @@ label = QStringLiteral("unknown file"); } if(topCtx->parsingEnvironmentFile() && topCtx->parsingEnvironmentFile()->isProxyContext()) - label = "Proxy-context " + label; + label = QLatin1String("Proxy-context ") + label; }else{ label = /*"context " + */context->localScopeIdentifier().toString(); - label += ' ' + rangeToString(context->range().castToSimpleRange()); + label += QLatin1Char(' ') + rangeToString(context->range().castToSimpleRange()); } //label = QStringLiteral("%1 ").arg((size_t)context) + label; @@ -158,11 +158,11 @@ stream << dotGraphInternal(parent.context(m_topContext), false, true); QString label = QStringLiteral("imports"); if( (!dynamic_cast(parent.context(m_topContext)) || !dynamic_cast(context)) && !(parent.context(m_topContext)->url() == context->url()) ) { - label += " from " + parent.context(m_topContext)->url().toUrl().fileName() - + " to " + context->url().toUrl().fileName(); + label += QLatin1String(" from ") + parent.context(m_topContext)->url().toUrl().fileName() + + QLatin1String(" to ") + context->url().toUrl().fileName(); } - stream << shortLabel(context) << " -> " << shortLabel(parent.context(m_topContext)) << "[style=dotted,label=\"" << label << "\"];\n"; + stream << shortLabel(context) << QLatin1String(" -> ") << shortLabel(parent.context(m_topContext)) << QLatin1String("[style=dotted,label=\"") << label << QLatin1String("\"];\n"); } } @@ -172,7 +172,7 @@ if( !shortened ) { foreach (DUContext* child, context->childContexts()) { stream << dotGraphInternal(child, false, false); - stream << shortLabel(context) << " -> " << shortLabel(child) << "[style=dotted,color=green];\n"; + stream << shortLabel(context) << QLatin1String(" -> ") << shortLabel(child) << QLatin1String("[style=dotted,color=green];\n"); } } diff --git a/kdevplatform/language/duchain/identifier.cpp b/kdevplatform/language/duchain/identifier.cpp --- a/kdevplatform/language/duchain/identifier.cpp +++ b/kdevplatform/language/duchain/identifier.cpp @@ -241,7 +241,7 @@ while( currentStart < (uint)str.length() ) { identifiersList.append(IndexedIdentifier(Identifier( str, currentStart, ¤tStart ))); - while( currentStart < (uint)str.length() && (str[currentStart] == ' ' ) ) + while (currentStart < (uint)str.length() && (str[currentStart] == QLatin1Char(' '))) ++currentStart; currentStart += 2; //Skip "::" } @@ -593,13 +593,13 @@ QString ret = identifier().str(); if (!options.testFlag(RemoveTemplateInformation) && templateIdentifiersCount()) { - ret.append("< "); + ret.append(QStringLiteral("< ")); for (uint i = 0; i < templateIdentifiersCount(); ++i) { ret.append(templateIdentifier(i).toString(options)); if (i != templateIdentifiersCount() - 1) - ret.append(", "); + ret.append(QStringLiteral(", ")); } - ret.append(" >"); + ret.append(QStringLiteral(" >")); } return ret; @@ -1257,15 +1257,15 @@ ret += m_identifier.identifier().toString(options); for(int a = 0; a < pointerDepth(); ++a) { - ret += '*'; + ret += QLatin1Char('*'); if( isConstPointer(a) ) ret += QLatin1String("const"); } if(isRValue()) ret += QLatin1String("&&"); else if(isReference()) - ret += '&'; + ret += QLatin1Char('&'); return ret; } diff --git a/kdevplatform/language/duchain/instantiationinformation.cpp b/kdevplatform/language/duchain/instantiationinformation.cpp --- a/kdevplatform/language/duchain/instantiationinformation.cpp +++ b/kdevplatform/language/duchain/instantiationinformation.cpp @@ -66,15 +66,15 @@ QString InstantiationInformation::toString(bool local) const { QString ret; if(previousInstantiationInformation.index() && !local) - ret = previousInstantiationInformation.information().toString() + "::"; - ret += '<'; + ret = previousInstantiationInformation.information().toString() + QLatin1String("::"); + ret += QLatin1Char('<'); for(uint a = 0; a < templateParametersSize(); ++a) { if(a) ret += QLatin1String(", "); if(templateParameters()[a].abstractType()) ret += templateParameters()[a].abstractType()->toString(); } - ret += '>'; + ret += QLatin1Char('>'); return ret; } diff --git a/kdevplatform/language/duchain/navigation/abstractdeclarationnavigationcontext.cpp b/kdevplatform/language/duchain/navigation/abstractdeclarationnavigationcontext.cpp --- a/kdevplatform/language/duchain/navigation/abstractdeclarationnavigationcontext.cpp +++ b/kdevplatform/language/duchain/navigation/abstractdeclarationnavigationcontext.cpp @@ -88,7 +88,7 @@ clear(); AbstractNavigationContext::html(shorten); - modifyHtml() += "

" + fontSizePrefix(shorten); + modifyHtml() += QLatin1String("

") + fontSizePrefix(shorten); addExternalHtml(prefix()); @@ -127,7 +127,7 @@ eventuallyMakeTypeLinks( useType ); - modifyHtml() += ' ' + identifierHighlight(declarationName(d->m_declaration).toHtmlEscaped(), d->m_declaration); + modifyHtml() += QLatin1Char(' ') + identifierHighlight(declarationName(d->m_declaration).toHtmlEscaped(), d->m_declaration); if(auto integralType = d->m_declaration->type()) { const QString plainValue = integralType->valueAsString(); @@ -180,7 +180,7 @@ } modifyHtml() += QStringLiteral("
"); makeLink(i18n("possible resolution from"), DeclarationPointer(dec), NavigationAction::NavigateDeclaration); - modifyHtml() += ' ' + dec->url().str(); + modifyHtml() += QLatin1Char(' ') + dec->url().str(); } } } @@ -232,10 +232,10 @@ comment.truncate(60); comment += QLatin1String("..."); } - comment.replace('\n', QLatin1String(" ")); + comment.replace(QLatin1Char('\n'), QLatin1Char(' ')); comment.replace(QLatin1String("
"), QLatin1String(" ")); comment.replace(QLatin1String("
"), QLatin1String(" ")); - modifyHtml() += commentHighlight(comment.toHtmlEscaped()) + " "; + modifyHtml() += commentHighlight(comment.toHtmlEscaped()) + QLatin1String(" "); } @@ -311,7 +311,7 @@ connect(doc.data(), &IDocumentation::descriptionChanged, this, &AbstractDeclarationNavigationContext::contentsChanged); if(!comment.isEmpty()) { - modifyHtml() += "

" + commentHighlight(comment) + "

"; + modifyHtml() += QLatin1String("

") + commentHighlight(comment) + QLatin1String("

"); } } @@ -321,17 +321,17 @@ if (!Qt::mightBeRichText(comment)) { // still might contain extra html tags for line breaks (this is the case for doxygen-style comments sometimes) // let's protect them from being removed completely - comment.replace(QRegExp("
"), QStringLiteral("\n")); + comment.replace(QRegExp(QStringLiteral("
")), QStringLiteral("\n")); comment = comment.toHtmlEscaped(); - comment.replace('\n', QLatin1String("
")); //Replicate newlines in html + comment.replace(QLatin1Char('\n'), QLatin1String("
")); //Replicate newlines in html } modifyHtml() += commentHighlight(comment); modifyHtml() += QStringLiteral("

"); } } if(!shorten && doc) { - modifyHtml() += "

" + i18n("Show documentation for "); + modifyHtml() += QLatin1String("

") + i18n("Show documentation for "); makeLink(prettyQualifiedName(d->m_declaration), d->m_declaration, NavigationAction::ShowDocumentation); modifyHtml() += QStringLiteral("

"); @@ -342,7 +342,7 @@ addExternalHtml(suffix()); - modifyHtml() += fontSizeSuffix(shorten) + "

"; + modifyHtml() += fontSizeSuffix(shorten) + QLatin1String("

"); return currentHtml(); } @@ -368,7 +368,7 @@ eventuallyMakeTypeLinks( type->returnType() ); } - modifyHtml() += ' ' + identifierHighlight(prettyIdentifier(d->m_declaration).toString().toHtmlEscaped(), d->m_declaration); + modifyHtml() += QLatin1Char(' ') + identifierHighlight(prettyIdentifier(d->m_declaration).toString().toHtmlEscaped(), d->m_declaration); if( type->indexedArgumentsSize() == 0 ) { @@ -391,13 +391,13 @@ eventuallyMakeTypeLinks( argType ); if (currentArgNum < decls.size()) { - modifyHtml() += ' ' + identifierHighlight(decls[currentArgNum]->identifier().toString().toHtmlEscaped(), d->m_declaration); + modifyHtml() += QLatin1Char(' ') + identifierHighlight(decls[currentArgNum]->identifier().toString().toHtmlEscaped(), d->m_declaration); } if (currentArgNum >= firstDefaultParam) { IndexedString defaultStr = function->defaultParameters()[currentArgNum - firstDefaultParam]; if (!defaultStr.isEmpty()) { - modifyHtml() += " = " + defaultStr.str().toHtmlEscaped(); + modifyHtml() += QLatin1String(" = ") + defaultStr.str().toHtmlEscaped(); } } @@ -575,7 +575,7 @@ eventuallyMakeTypeLinks( klass.cast() ); FOREACH_FUNCTION( const BaseClassInstance& base, classDecl->baseClasses ) { - modifyHtml() += ", " + stringFromAccess(base.access) + " " + (base.virtualInheritance ? QStringLiteral("virtual") : QString()) + " "; + modifyHtml() += QLatin1String(", ") + stringFromAccess(base.access) + QLatin1Char(' ') + (base.virtualInheritance ? QStringLiteral("virtual") : QString()) + QLatin1Char(' '); eventuallyMakeTypeLinks(base.baseClass.abstractType()); } } else { @@ -651,7 +651,7 @@ if(exchanged) { QString typeSuffixString = exchanged->toString(); - QRegExp suffixExp("\\&|\\*"); + QRegExp suffixExp(QStringLiteral("\\&|\\*")); int suffixPos = typeSuffixString.indexOf(suffixExp); if(suffixPos != -1) modifyHtml() += typeHighlight(typeSuffixString.mid(suffixPos)); @@ -711,9 +711,9 @@ { if( NamespaceAliasDeclaration* alias = dynamic_cast(decl.data()) ) { if( alias->identifier().isEmpty() ) - return "using namespace " + alias->importIdentifier().toString(); + return QLatin1String("using namespace ") + alias->importIdentifier().toString(); else - return "namespace " + alias->identifier().toString() + " = " + alias->importIdentifier().toString(); + return QLatin1String("namespace ") + alias->identifier().toString() + QLatin1String(" = ") + alias->importIdentifier().toString(); } if( !decl ) diff --git a/kdevplatform/language/duchain/navigation/abstractincludenavigationcontext.cpp b/kdevplatform/language/duchain/navigation/abstractincludenavigationcontext.cpp --- a/kdevplatform/language/duchain/navigation/abstractincludenavigationcontext.cpp +++ b/kdevplatform/language/duchain/navigation/abstractincludenavigationcontext.cpp @@ -75,7 +75,7 @@ QString AbstractIncludeNavigationContext::html(bool shorten) { clear(); - modifyHtml() += "

" + fontSizePrefix(shorten); + modifyHtml() += QLatin1String("

") + fontSizePrefix(shorten); addExternalHtml(prefix()); QUrl u = m_item.url(); @@ -91,7 +91,7 @@ if(duchain) { getFileInfo(duchain); if(!shorten) { - modifyHtml() += labelHighlight(i18n("Declarations:")) + "
"; + modifyHtml() += labelHighlight(i18n("Declarations:")) + QLatin1String("
"); bool first = true; QList decs; addDeclarationsFromContext(duchain, first, decs); @@ -102,7 +102,7 @@ addExternalHtml(suffix()); - modifyHtml() += fontSizeSuffix(shorten) + "

"; + modifyHtml() += fontSizeSuffix(shorten) + QLatin1String("

"); return currentHtml(); } @@ -155,16 +155,16 @@ else first = false; - modifyHtml() += QString(indent + declarationKind(DeclarationPointer(*declarationIterator)) + " ").toHtmlEscaped(); + modifyHtml() += QString(indent + declarationKind(DeclarationPointer(*declarationIterator)) + QLatin1Char(' ')).toHtmlEscaped(); makeLink((*declarationIterator)->qualifiedIdentifier().toString(), DeclarationPointer(*declarationIterator), NavigationAction::NavigateDeclaration); addedDeclarations << id; } ++declarationIterator; } else { //Eventually Recurse into the context if((*childIterator)->type() == DUContext::Global || (*childIterator)->type() == DUContext::Namespace /*|| (*childIterator)->type() == DUContext::Class*/) - addDeclarationsFromContext(*childIterator, first, addedDeclarations, indent + ' '); + addDeclarationsFromContext(*childIterator, first, addedDeclarations, indent + QLatin1Char(' ')); ++childIterator; } } diff --git a/kdevplatform/language/duchain/navigation/abstractnavigationcontext.cpp b/kdevplatform/language/duchain/navigation/abstractnavigationcontext.cpp --- a/kdevplatform/language/duchain/navigation/abstractnavigationcontext.cpp +++ b/kdevplatform/language/duchain/navigation/abstractnavigationcontext.cpp @@ -100,7 +100,7 @@ pos += fileMark.length(); if( pos != text.length() ) { - int fileEnd = text.indexOf('}', pos); + int fileEnd = text.indexOf(QLatin1Char('}'), pos); if( fileEnd != -1 ) { QString file = text.mid( pos, fileEnd - pos ); pos = fileEnd + 1; @@ -144,9 +144,9 @@ QString str = name.toHtmlEscaped(); if( d->m_linkCount == d->m_selectedLink ) - str = "" + str + ""; + str = QLatin1String("") + str + QLatin1String(""); - QString ret = "m_linkCount == d->m_selectedLink && d->m_currentPositionLine == -1) ? QStringLiteral(" name = \"currentPosition\"") : QString()) + ">" + str + ""; + QString ret = QLatin1String("m_linkCount == d->m_selectedLink && d->m_currentPositionLine == -1) ? QStringLiteral(" name = \"currentPosition\"") : QString()) + QLatin1Char('>') + str + QLatin1String(""); if( d->m_selectedLink == d->m_linkCount ) d->m_selectedLinkAction = action; @@ -508,7 +508,7 @@ } void AbstractNavigationContext::addHtml(const QString& html) { - QRegExp newLineRegExp("
|
"); + QRegExp newLineRegExp(QStringLiteral("
|
")); foreach(const QString& line, splitAndKeep(html, newLineRegExp)) { d->m_currentText += line; if(line.indexOf(newLineRegExp) != -1) { @@ -536,14 +536,14 @@ QString Colorizer::operator() ( const QString& str ) const { - QString ret = "" + str + ""; + QString ret = QLatin1String("") + str + QLatin1String(""); if( m_formatting & Fixed ) - ret = ""+ret+""; + ret = QLatin1String("") + ret + QLatin1String(""); if ( m_formatting & Bold ) - ret = ""+ret+""; + ret = QLatin1String("") + ret + QLatin1String(""); if ( m_formatting & Italic ) - ret = ""+ret+""; + ret = QLatin1String("") + ret + QLatin1String(""); return ret; } diff --git a/kdevplatform/language/duchain/navigation/abstractnavigationwidget.cpp b/kdevplatform/language/duchain/navigation/abstractnavigationwidget.cpp --- a/kdevplatform/language/duchain/navigation/abstractnavigationwidget.cpp +++ b/kdevplatform/language/duchain/navigation/abstractnavigationwidget.cpp @@ -225,9 +225,8 @@ d->m_browser->setMaximumHeight(10000); if(d->m_currentWidget) { - if (d->m_currentWidget->metaObject() - ->indexOfSignal(QMetaObject::normalizedSignature("navigateDeclaration(KDevelop::IndexedDeclaration)")) != -1) - { + const auto signalSignature = QMetaObject::normalizedSignature("navigateDeclaration(KDevelop::IndexedDeclaration)"); + if (d->m_currentWidget->metaObject()->indexOfSignal(signalSignature.constData()) != -1) { connect(d->m_currentWidget, SIGNAL(navigateDeclaration(KDevelop::IndexedDeclaration)), this, SLOT(navigateDeclaration(KDevelop::IndexedDeclaration))); } diff --git a/kdevplatform/language/duchain/navigation/problemnavigationcontext.cpp b/kdevplatform/language/duchain/navigation/problemnavigationcontext.cpp --- a/kdevplatform/language/duchain/navigation/problemnavigationcontext.cpp +++ b/kdevplatform/language/duchain/navigation/problemnavigationcontext.cpp @@ -157,7 +157,7 @@ // Add only non-empty explanation which differs from the problem description. // Skip this if we have more than one problem. if (m_problems.size() == 1 && !explanation.isEmpty() && explanation != description) - modifyHtml() += "

" + explanation + "

"; + modifyHtml() += QLatin1String("

") + explanation + QLatin1String("

"); modifyHtml() += QStringLiteral(""); // END: right column @@ -212,7 +212,7 @@ makeLink(i18n("Solution (%1)", currentIndex + 1), KEY_INVOKE_ACTION( currentIndex ), NavigationAction(KEY_INVOKE_ACTION( currentIndex ))); - modifyHtml() += ": " + assistantAction->description().toHtmlEscaped(); + modifyHtml() += QLatin1String(": ") + assistantAction->description().toHtmlEscaped(); ++currentIndex; } diff --git a/kdevplatform/language/duchain/navigation/usescollector.cpp b/kdevplatform/language/duchain/navigation/usescollector.cpp --- a/kdevplatform/language/duchain/navigation/usescollector.cpp +++ b/kdevplatform/language/duchain/navigation/usescollector.cpp @@ -42,9 +42,9 @@ ///@todo make this language-neutral static Identifier destructorForName(const Identifier& name) { QString str = name.identifier().str(); - if(str.startsWith('~')) + if(str.startsWith(QLatin1Char('~'))) return Identifier(str); - return Identifier('~'+str); + return Identifier(QLatin1Char('~') + str); } ///@todo Only collect uses within currently loaded projects @@ -371,7 +371,7 @@ ///or whether we work on with it. ///@todo We will lose files that were edited right after their update here. qCWarning(LANGUAGE) << "WARNING: context" << topContext->url().str() << "does not have the required features!!"; - ICore::self()->uiController()->showErrorMessage("Updating " + ICore::self()->projectController()->prettyFileName(topContext->url().toUrl(), KDevelop::IProjectController::FormatPlain) + " failed!", 5); + ICore::self()->uiController()->showErrorMessage(QLatin1String("Updating ") + ICore::self()->projectController()->prettyFileName(topContext->url().toUrl(), KDevelop::IProjectController::FormatPlain) + QLatin1String(" failed!"), 5); return; } diff --git a/kdevplatform/language/duchain/navigation/usesnavigationcontext.cpp b/kdevplatform/language/duchain/navigation/usesnavigationcontext.cpp --- a/kdevplatform/language/duchain/navigation/usesnavigationcontext.cpp +++ b/kdevplatform/language/duchain/navigation/usesnavigationcontext.cpp @@ -42,7 +42,7 @@ QString UsesNavigationContext::html(bool shorten) { clear(); - modifyHtml() += "

" + fontSizePrefix(shorten); + modifyHtml() += QLatin1String("

") + fontSizePrefix(shorten); if(auto context = previousContext()) { modifyHtml() += navigationHighlight(i18n("Uses of ")); @@ -54,7 +54,7 @@ } } - modifyHtml() += fontSizeSuffix(shorten) + "

"; + modifyHtml() += fontSizeSuffix(shorten) + QLatin1String("

"); return currentHtml(); } diff --git a/kdevplatform/language/duchain/navigation/useswidget.cpp b/kdevplatform/language/duchain/navigation/useswidget.cpp --- a/kdevplatform/language/duchain/navigation/useswidget.cpp +++ b/kdevplatform/language/duchain/navigation/useswidget.cpp @@ -106,10 +106,10 @@ // mixing (255, 255, 0, 100) with white yields this: const QColor foreground(0, 0, 0); - return "" + line.left(range.start().column()).toHtmlEscaped() - + "" + return QLatin1String("") + line.left(range.start().column()).toHtmlEscaped() + + QLatin1String("") + line.mid(range.start().column(), range.end().column() - range.start().column()).toHtmlEscaped() - + "" + line.mid(range.end().column(), line.length() - range.end().column()).toHtmlEscaped() + ""; + + QLatin1String("") + line.mid(range.end().column(), line.length() - range.end().column()).toHtmlEscaped() + QLatin1String(""); } /** @@ -134,10 +134,10 @@ m_icon->setPixmap(QIcon::fromTheme(QStringLiteral("code-function")).pixmap(16)); DUChainReadLocker lock(DUChain::lock()); - QString text = "" + i18nc("refers to a line in source code", "Line %1:", range.start().line()) + QStringLiteral(""); + QString text = QLatin1String("") + i18nc("refers to a line in source code", "Line %1:", range.start().line()) + QStringLiteral(""); if(!m_sourceLine.isEmpty() && m_sourceLine.length() > m_range->range().end().column()) { - text += "  " + highlightAndEscapeUseText(m_sourceLine, 0, m_range->range()); + text += QLatin1String("  ") + highlightAndEscapeUseText(m_sourceLine, 0, m_range->range()); //Useful tooltip: int start = m_range->range().start().line() - tooltipContextSize; @@ -150,7 +150,7 @@ lineText = QStringLiteral("") + lineText + QStringLiteral(""); } if(!lineText.trimmed().isEmpty()) { - toolTipText += lineText + "
"; + toolTipText += lineText + QLatin1String("
"); } } if ( toolTipText.endsWith(QLatin1String("
")) ) { @@ -172,10 +172,12 @@ } if (highlight) { - m_label->setText(m_label->text().replace("background-color:" + backgroundColor(false), "background-color:" + backgroundColor(true))); + m_label->setText(m_label->text().replace(QLatin1String("background-color:") + backgroundColor(false), + QLatin1String("background-color:") + backgroundColor(true))); m_isHighlighted = true; } else { - m_label->setText(m_label->text().replace("background-color:" + backgroundColor(true), "background-color:" + backgroundColor(false))); + m_label->setText(m_label->text().replace(QLatin1String("background-color:") + backgroundColor(true), + QLatin1String("background-color:") + backgroundColor(false))); m_isHighlighted = false; } } @@ -407,8 +409,8 @@ } } - QLabel* headerLabel = new QLabel(i18nc("%1: source file", "In %1", "" - + headerText.toHtmlEscaped() + ": ")); + QLabel* headerLabel = new QLabel(i18nc("%1: source file", "In %1", QLatin1String("") + + headerText.toHtmlEscaped() + QLatin1String(": "))); addHeaderItem(headerLabel); setUpdatesEnabled(true); connect(headerLabel, &QLabel::linkActivated, this, &ContextUsesWidget::linkWasActivated); @@ -476,7 +478,7 @@ m_usesCount, ICore::self()->projectController()->prettyFileName(topContext.url().toUrl())); label->setText(labelText); - m_toggleButton->setText("   [" + i18nc("Refers to closing a UI element", "Collapse") + "]"); + m_toggleButton->setText(QLatin1String("   [") + i18nc("Refers to closing a UI element", "Collapse") + QLatin1String("]")); connect(m_toggleButton, &QLabel::linkActivated, this, &TopContextUsesWidget::labelClicked); addHeaderItem(headerWidget); @@ -507,10 +509,10 @@ void TopContextUsesWidget::setExpanded(bool expanded) { if(!expanded) { - m_toggleButton->setText("   [" + i18nc("Refers to opening a UI element", "Expand") + "]"); + m_toggleButton->setText(QLatin1String("   [") + i18nc("Refers to opening a UI element", "Expand") + QLatin1String("]")); deleteItems(); }else{ - m_toggleButton->setText("   [" + i18nc("Refers to closing a UI element", "Collapse") + "]"); + m_toggleButton->setText(QLatin1String("   [") + i18nc("Refers to closing a UI element", "Collapse") + QLatin1String("]")); if(hasItems()) return; DUChainReadLocker lock(DUChain::lock()); @@ -588,9 +590,9 @@ const QString UsesWidget::headerLineText() const { - return i18np("1 use found", "%1 uses found", countAllUses()) + " • " - "[" + i18n("Expand all") + "] • " - "[" + i18n("Collapse all") + "]"; + return i18np("1 use found", "%1 uses found", countAllUses()) + QLatin1String(" • " + "[") + i18n("Expand all") + QLatin1String("] • " + "[") + i18n("Collapse all") + QLatin1String("]"); } unsigned int UsesWidget::countAllUses() const diff --git a/kdevplatform/language/duchain/stringhelpers.cpp b/kdevplatform/language/duchain/stringhelpers.cpp --- a/kdevplatform/language/duchain/stringhelpers.cpp +++ b/kdevplatform/language/duchain/stringhelpers.cpp @@ -92,7 +92,7 @@ { T ret; - QList lines = comment.split( '\n' ); + QList lines = comment.split('\n'); if ( !lines.isEmpty() ) { @@ -146,19 +146,19 @@ bool parenFits( QChar c1, QChar c2 ) { - if( c1 == '<' && c2 == '>' ) return true; - else if( c1 == '(' && c2 == ')' ) return true; - else if( c1 == '[' && c2 == ']' ) return true; - else if( c1 == '{' && c2 == '}' ) return true; + if (c1 == QLatin1Char('<') && c2 == QLatin1Char('>')) return true; + else if (c1 == QLatin1Char('(') && c2 == QLatin1Char(')')) return true; + else if (c1 == QLatin1Char('[') && c2 == QLatin1Char(']')) return true; + else if (c1 == QLatin1Char('{') && c2 == QLatin1Char('}')) return true; else return false; } int findClose( const QString& str , int pos ) { int depth = 0; QList st; - QChar last = ' '; + QChar last = QLatin1Char(' '); for( int a = pos; a < (int)str.length(); a++) { @@ -171,7 +171,7 @@ depth++; break; case '>': - if( last == '-' ) break; + if (last == QLatin1Char('-')) break; Q_FALLTHROUGH(); case ')': case ']': @@ -185,17 +185,16 @@ case '"': last = str[a]; a++; - while( a < (int)str.length() && (str[a] != '"' || last == '\\')) - { + while (a < (int)str.length() && (str[a] != QLatin1Char('"') || last == QLatin1Char('\\'))) { last = str[a]; a++; } continue; break; case '\'': last = str[a]; a++; - while( a < (int)str.length() && (str[a] != '\'' || last == '\\')) + while( a < (int)str.length() && (str[a] != QLatin1Char('\'') || last == QLatin1Char('\\'))) { last = str[a]; a++; @@ -234,7 +233,7 @@ case ']': case '}': case '>': - if( validEnd != ' ' && validEnd != str[a] ) + if( validEnd != QLatin1Char(' ') && validEnd != str[a] ) continue; Q_FALLTHROUGH(); case ',': @@ -252,28 +251,28 @@ for( int a = len-1; a >= 0; --a ) { switch(str[a].unicode()) { case '(': - ret += ')'; + ret += QLatin1Char(')'); continue; case '[': - ret += ']'; + ret += QLatin1Char(']'); continue; case '{': - ret += '}'; + ret += QLatin1Char('}'); continue; case '<': - ret += '>'; + ret += QLatin1Char('>'); continue; case ')': - ret += '('; + ret += QLatin1Char('('); continue; case ']': - ret += '['; + ret += QLatin1Char('['); continue; case '}': - ret += '{'; + ret += QLatin1Char('{'); continue; case '>': - ret += '<'; + ret += QLatin1Char('<'); continue; default: ret += str[a]; @@ -321,7 +320,7 @@ if( !arg.isEmpty() ) skippedArguments.push_front( escapeFromBracketMatching(arg) ); //We are processing the reversed reverseding, so push to front } - if( reversed[pos] == ')' || reversed[pos] == '>' ) + if( reversed[pos] == QLatin1Char(')') || reversed[pos] == QLatin1Char('>') ) break; else ++pos; @@ -338,7 +337,7 @@ str = str.trimmed(); QString ret; - QChar spaceChar = ' '; + QChar spaceChar = QLatin1Char(' '); bool hadSpace = false; for( int a = 0; a < str.length(); a++ ) { @@ -375,18 +374,18 @@ QString withoutStrings = clearStrings(str, '$'); int pos = -1, newlinePos = -1, endCommentPos = -1, nextPos = -1, dest = -1; - while ( (pos = str.indexOf('/', pos + 1)) != -1 ) + while ( (pos = str.indexOf(QLatin1Char('/'), pos + 1)) != -1 ) { newlinePos = withoutStrings.indexOf('\n', pos); - if (withoutStrings[pos + 1] == '/') + if (withoutStrings[pos + 1] == QLatin1Char('/')) { //C style comment dest = newlinePos == -1 ? str.length() : newlinePos; fillString(str, pos, dest, replacement); pos = dest; } - else if (withoutStrings[pos + 1] == '*') + else if (withoutStrings[pos + 1] == QLatin1Char('*')) { //CPP style comment endCommentPos = withoutStrings.indexOf(QStringLiteral("*/"), pos + 2); @@ -402,7 +401,7 @@ if (pos == newlinePos) { ++pos; //Keep newlines intact, skip them - newlinePos = withoutStrings.indexOf('\n', pos + 1); + newlinePos = withoutStrings.indexOf(QLatin1Char('\n'), pos + 1); } } } @@ -414,34 +413,30 @@ bool inString = false; for(int pos = 0; pos < str.length(); ++pos) { //Skip cpp comments - if(!inString && pos + 1 < str.length() && str[pos] == '/' && str[pos+1] == '*') - { + if(!inString && pos + 1 < str.length() && str[pos] == QLatin1Char('/') && str[pos+1] == QLatin1Char('*')) { pos += 2; while(pos + 1 < str.length()) { - if (str[pos] == '*' && str[pos + 1] == '/') { + if (str[pos] == '*' && str[pos + 1] == QLatin1Char('/')) { ++pos; break; } ++pos; } } //Skip cstyle comments - if(!inString && pos + 1 < str.length() && str[pos] == '/' && str[pos+1] == '/') - { + if(!inString && pos + 1 < str.length() && str[pos] == QLatin1Char('/') && str[pos+1] == QLatin1Char('/')) { pos += 2; - while(pos < str.length() && str[pos] != '\n') { + while(pos < str.length() && str[pos] != QLatin1Char('\n')) { ++pos; } } //Skip a character a la 'b' - if(!inString && str[pos] == '\'' && pos + 3 <= str.length()) - { + if (!inString && str[pos] == QLatin1Char('\'') && pos + 3 <= str.length()) { //skip the opening ' str[pos] = replacement; ++pos; - if(str[pos] == '\\') - { + if (str[pos] == QLatin1Char('\\')) { //Skip an escape character str[pos] = replacement; ++pos; @@ -452,28 +447,27 @@ ++pos; //Skip the closing ' - if(pos < str.length() && str[pos] == '\'') - { + if (pos < str.length() && str[pos] == QLatin1Char('\'')) { str[pos] = replacement; } continue; } bool intoString = false; - if(str[pos] == '"' && !inString) + if (str[pos] == QLatin1Char('"') && !inString) intoString = true; if(inString || intoString) { if(inString) { - if(str[pos] == '"') + if(str[pos] == QLatin1Char('"')) inString = false; }else{ inString = true; } bool skip = false; - if(str[pos] == '\\') + if (str[pos] == QLatin1Char('\\')) skip = true; str[pos] = replacement; diff --git a/kdevplatform/language/duchain/topducontextdynamicdata.cpp b/kdevplatform/language/duchain/topducontextdynamicdata.cpp --- a/kdevplatform/language/duchain/topducontextdynamicdata.cpp +++ b/kdevplatform/language/duchain/topducontextdynamicdata.cpp @@ -151,7 +151,7 @@ QString basePath() { - return globalItemRepositoryRegistry().path() + "/topcontexts/"; + return globalItemRepositoryRegistry().path() + QLatin1String("/topcontexts/"); } QString pathForTopContext(const uint topContextIndex) diff --git a/kdevplatform/language/duchain/types/functiontype.cpp b/kdevplatform/language/duchain/types/functiontype.cpp --- a/kdevplatform/language/duchain/types/functiontype.cpp +++ b/kdevplatform/language/duchain/types/functiontype.cpp @@ -150,16 +150,16 @@ TYPE_D(FunctionType); if( sigPart == SignatureArguments || sigPart == SignatureWhole ) { - args += '('; + args += QLatin1Char('('); bool first = true; FOREACH_FUNCTION(const IndexedType& type, d->m_arguments) { if (first) first = false; else - args.append(", "); + args.append(QLatin1String(", ")); args.append(type ? type.abstractType()->toString() : QStringLiteral("")); } - args += ')'; + args += QLatin1Char(')'); } if( sigPart == SignatureArguments ) diff --git a/kdevplatform/language/duchain/types/integraltype.cpp b/kdevplatform/language/duchain/types/integraltype.cpp --- a/kdevplatform/language/duchain/types/integraltype.cpp +++ b/kdevplatform/language/duchain/types/integraltype.cpp @@ -127,16 +127,16 @@ } if (modifiers() & UnsignedModifier) - name.prepend("unsigned "); + name.prepend(QLatin1String("unsigned ")); else if (modifiers() & SignedModifier) - name.prepend("signed "); + name.prepend(QLatin1String("signed ")); if (modifiers() & ShortModifier) - name.prepend("short "); + name.prepend(QLatin1String("short ")); else if (modifiers() & LongLongModifier) - name.prepend("long long "); + name.prepend(QLatin1String("long long ")); else if (modifiers() & LongModifier) - name.prepend("long "); + name.prepend(QLatin1String("long ")); return AbstractType::toString() + name; } diff --git a/kdevplatform/language/duchain/types/unsuretype.cpp b/kdevplatform/language/duchain/types/unsuretype.cpp --- a/kdevplatform/language/duchain/types/unsuretype.cpp +++ b/kdevplatform/language/duchain/types/unsuretype.cpp @@ -56,7 +56,7 @@ else ret += QLatin1String("none"); } - ret += ')'; + ret += QLatin1Char(')'); return ret; } diff --git a/kdevplatform/language/editor/modificationrevisionset.cpp b/kdevplatform/language/editor/modificationrevisionset.cpp --- a/kdevplatform/language/editor/modificationrevisionset.cpp +++ b/kdevplatform/language/editor/modificationrevisionset.cpp @@ -257,11 +257,11 @@ first = false; const FileModificationPair* data = fileModificationPairRepository().itemFromIndex(*it); - ret += data->file.str() + ':' + data->revision.toString(); + ret += data->file.str() + QLatin1Char(':') + data->revision.toString(); ++it; } - ret += ']'; + ret += QLatin1Char(']'); return ret; } diff --git a/kdevplatform/language/interfaces/abbreviations.cpp b/kdevplatform/language/interfaces/abbreviations.cpp --- a/kdevplatform/language/interfaces/abbreviations.cpp +++ b/kdevplatform/language/interfaces/abbreviations.cpp @@ -130,8 +130,8 @@ const QChar& c = word.at(i); bool isDoubleColon = false; // if it's not a separation char, walk over it. - if ( c != ' ' && c != '/' && i != word.size() - 1 ) { - if ( c != ':' && i < word.size()-1 && word.at(i+1) != ':' ) { + if (c != QLatin1Char(' ') && c != QLatin1Char('/') && i != word.size() - 1) { + if (c != QLatin1Char(':') && i < word.size()-1 && word.at(i+1) != QLatin1Char(':')) { continue; } isDoubleColon = true; diff --git a/kdevplatform/language/interfaces/editorcontext.cpp b/kdevplatform/language/interfaces/editorcontext.cpp --- a/kdevplatform/language/interfaces/editorcontext.cpp +++ b/kdevplatform/language/interfaces/editorcontext.cpp @@ -37,9 +37,11 @@ { int wordStart = m_position.column(); int wordEnd = m_position.column(); - while(wordStart > 0 && wordStart < m_currentLine.length() && (m_currentLine[wordStart-1].isLetterOrNumber() || m_currentLine[wordStart-1] == '_')) + while (wordStart > 0 && wordStart < m_currentLine.length() && + (m_currentLine[wordStart-1].isLetterOrNumber() || m_currentLine[wordStart-1] == QLatin1Char('_'))) --wordStart; - while(wordEnd >= 0 && wordEnd < m_currentLine.length() && (m_currentLine[wordEnd].isLetterOrNumber() || m_currentLine[wordEnd] == '_')) + while (wordEnd >= 0 && wordEnd < m_currentLine.length() && + (m_currentLine[wordEnd].isLetterOrNumber() || m_currentLine[wordEnd] == QLatin1Char('_'))) ++wordEnd; } diff --git a/kdevplatform/language/interfaces/quickopendataprovider.cpp b/kdevplatform/language/interfaces/quickopendataprovider.cpp --- a/kdevplatform/language/interfaces/quickopendataprovider.cpp +++ b/kdevplatform/language/interfaces/quickopendataprovider.cpp @@ -56,7 +56,7 @@ } bool extractLineNumber(const QString& from, QString& path, uint& lineNumber) { - int colonIndex = from.indexOf(':'); + int colonIndex = from.indexOf(QLatin1Char(':')); if (colonIndex != -1) { if (colonIndex == from.count() - 1) { path = from.mid(0, colonIndex); diff --git a/kdevplatform/outputview/outputexecutejob.cpp b/kdevplatform/outputview/outputexecutejob.cpp --- a/kdevplatform/outputview/outputexecutejob.cpp +++ b/kdevplatform/outputview/outputexecutejob.cpp @@ -536,7 +536,7 @@ const QString joinedCommandLine = joinCommandLine(); if( m_properties.testFlag( OutputExecuteJob::AppendProcessString ) ) { if( !m_jobName.isEmpty() ) { - return m_jobName + ": " + joinedCommandLine; + return m_jobName + QLatin1String(": ") + joinedCommandLine; } else { return joinedCommandLine; } diff --git a/kdevplatform/outputview/tests/CMakeLists.txt b/kdevplatform/outputview/tests/CMakeLists.txt --- a/kdevplatform/outputview/tests/CMakeLists.txt +++ b/kdevplatform/outputview/tests/CMakeLists.txt @@ -1,3 +1,7 @@ +remove_definitions( + -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_BYTEARRAY +) + ecm_add_test(test_outputmodel LINK_LIBRARIES Qt5::Test KDev::Tests diff --git a/kdevplatform/project/CMakeLists.txt b/kdevplatform/project/CMakeLists.txt --- a/kdevplatform/project/CMakeLists.txt +++ b/kdevplatform/project/CMakeLists.txt @@ -11,6 +11,8 @@ projectitemlineedit.cpp helper.cpp debug.cpp + listfilesthread.cpp + listfilesjob.cpp projectproxymodel.cpp abstractfilemanagerplugin.cpp filemanagerlistjob.cpp @@ -63,6 +65,7 @@ projectitemlineedit.h projectbuildsetmodel.h builderjob.h + listfilesjob.h helper.h abstractfilemanagerplugin.h projectfiltermanager.h diff --git a/kdevplatform/project/projectbuildsetmodel.cpp b/kdevplatform/project/projectbuildsetmodel.cpp --- a/kdevplatform/project/projectbuildsetmodel.cpp +++ b/kdevplatform/project/projectbuildsetmodel.cpp @@ -265,7 +265,7 @@ return d->items.at(idx.row()).itemName(); break; case 1: - return KDevelop::joinWithEscaping(d->items.at(idx.row()).itemPath(), '/', '\\'); + return KDevelop::joinWithEscaping(d->items.at(idx.row()).itemPath(), QLatin1Char('/'), QLatin1Char('\\')); break; } } else if(role == Qt::DecorationRole && idx.column()==0) { diff --git a/kdevplatform/project/projectitemlineedit.cpp b/kdevplatform/project/projectitemlineedit.cpp --- a/kdevplatform/project/projectitemlineedit.cpp +++ b/kdevplatform/project/projectitemlineedit.cpp @@ -40,8 +40,8 @@ #include #include "projectproxymodel.h" -static const QChar sep = '/'; -static const QChar escape = '\\'; +static const QChar sep = QLatin1Char('/'); +static const QChar escape = QLatin1Char('\\'); class ProjectItemCompleter : public QCompleter @@ -252,7 +252,7 @@ KDevelop::ProjectBaseItem* ProjectItemLineEdit::currentItem() const { KDevelop::ProjectModel* model = KDevelop::ICore::self()->projectController()->projectModel(); - return model->itemFromIndex(model->pathToIndex(KDevelop::splitWithEscaping(text(),'/', '\\'))); + return model->itemFromIndex(model->pathToIndex(KDevelop::splitWithEscaping(text(), QLatin1Char('/'), QLatin1Char('\\')))); } void ProjectItemLineEdit::setSuggestion(KDevelop::IProject* project) diff --git a/kdevplatform/project/projectmodel.cpp b/kdevplatform/project/projectmodel.cpp --- a/kdevplatform/project/projectmodel.cpp +++ b/kdevplatform/project/projectmodel.cpp @@ -130,7 +130,7 @@ { Q_ASSERT(item->file() || item->folder()); - if (newName.contains('/')) { + if (newName.contains(QLatin1Char('/'))) { return ProjectBaseItem::InvalidNewName; } diff --git a/kdevplatform/project/tests/CMakeLists.txt b/kdevplatform/project/tests/CMakeLists.txt --- a/kdevplatform/project/tests/CMakeLists.txt +++ b/kdevplatform/project/tests/CMakeLists.txt @@ -1,3 +1,7 @@ +remove_definitions( + -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_BYTEARRAY +) + ecm_add_test(test_projectmodel.cpp LINK_LIBRARIES Qt5::Test KDev::Interfaces KDev::Project KDev::Language KDev::Tests) diff --git a/kdevplatform/project/widgets/dependencieswidget.cpp b/kdevplatform/project/widgets/dependencieswidget.cpp --- a/kdevplatform/project/widgets/dependencieswidget.cpp +++ b/kdevplatform/project/widgets/dependencieswidget.cpp @@ -163,7 +163,7 @@ if(pitem) icon=QIcon::fromTheme(pitem->iconName()); - QListWidgetItem* item = new QListWidgetItem(icon, KDevelop::joinWithEscaping( deplist, '/', '\\' ), m_ui->dependencies ); + QListWidgetItem* item = new QListWidgetItem(icon, KDevelop::joinWithEscaping(deplist, QLatin1Char('/'), QLatin1Char('\\')), m_ui->dependencies); item->setData( Qt::UserRole, dep ); } } diff --git a/kdevplatform/serialization/itemrepositoryregistry.cpp b/kdevplatform/serialization/itemrepositoryregistry.cpp --- a/kdevplatform/serialization/itemrepositoryregistry.cpp +++ b/kdevplatform/serialization/itemrepositoryregistry.cpp @@ -232,7 +232,7 @@ { QMutexLocker lock(&m_mutex); //Create is_writing - QFile f(m_path + "/is_writing"); + QFile f(m_path + QLatin1String("/is_writing")); f.open(QIODevice::WriteOnly); f.close(); } @@ -246,7 +246,7 @@ { QMutexLocker lock(&m_mutex); //Delete is_writing - QFile::remove(m_path + "/is_writing"); + QFile::remove(m_path + QLatin1String("/is_writing")); } void ItemRepositoryRegistry::unlockForWriting() @@ -303,7 +303,7 @@ } } - QFile f(path + "/Counters"); + QFile f(path + QLatin1String("/Counters")); if(f.open(QIODevice::ReadOnly)) { QDataStream stream(&f); @@ -337,7 +337,7 @@ } //Store all custom counter values - QFile f(d->m_path + "/Counters"); + QFile f(d->m_path + QLatin1String("/Counters")); if(f.open(QIODevice::WriteOnly)) { f.resize(0); QDataStream stream(&f); diff --git a/kdevplatform/serialization/tests/CMakeLists.txt b/kdevplatform/serialization/tests/CMakeLists.txt --- a/kdevplatform/serialization/tests/CMakeLists.txt +++ b/kdevplatform/serialization/tests/CMakeLists.txt @@ -1,5 +1,11 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) +remove_definitions( + -DQT_NO_CAST_FROM_ASCII + -DQT_NO_CAST_TO_ASCII + -DQT_NO_CAST_FROM_BYTEARRAY +) + if(NOT COMPILER_OPTIMIZATIONS_DISABLED) ecm_add_test(bench_itemrepository.cpp LINK_LIBRARIES LINK_LIBRARIES Qt5::Test KDev::Serialization KDev::Tests) diff --git a/kdevplatform/shell/documentcontroller.cpp b/kdevplatform/shell/documentcontroller.cpp --- a/kdevplatform/shell/documentcontroller.cpp +++ b/kdevplatform/shell/documentcontroller.cpp @@ -958,7 +958,7 @@ if(!target.isEmpty()) { foreach(IProject* project, Core::self()->projectController()->projects()) { if(project->name().startsWith(target, Qt::CaseInsensitive)) { - return project->path().pathOrUrl() + "/."; + return project->path().pathOrUrl() + QLatin1String("/."); } } } @@ -1033,7 +1033,7 @@ if (nextEmptyDocNumber > 0) url = QUrl::fromLocalFile(QStringLiteral("/%1 (%2)").arg(EMPTY_DOCUMENT_URL).arg(nextEmptyDocNumber)); else - url = QUrl::fromLocalFile('/' + EMPTY_DOCUMENT_URL); + url = QUrl::fromLocalFile(QLatin1Char('/') + EMPTY_DOCUMENT_URL); return url; } diff --git a/kdevplatform/shell/languagecontroller.cpp b/kdevplatform/shell/languagecontroller.cpp --- a/kdevplatform/shell/languagecontroller.cpp +++ b/kdevplatform/shell/languagecontroller.cpp @@ -263,15 +263,15 @@ const QString fileName = url.fileName(); ///TODO: cache regexp or simple string pattern for endsWith matching - QRegExp exp("", Qt::CaseInsensitive, QRegExp::Wildcard); + QRegExp exp(QString(), Qt::CaseInsensitive, QRegExp::Wildcard); ///non-crashy part: Use the mime-types of known languages for(LanguageControllerPrivate::MimeTypeCache::const_iterator it = d->mimeTypeCache.constBegin(); it != d->mimeTypeCache.constEnd(); ++it) { foreach(const QString& pattern, it.key().globPatterns()) { - if(pattern.startsWith('*')) { + if(pattern.startsWith(QLatin1Char('*'))) { const QStringRef subPattern = pattern.midRef(1); - if (!subPattern.contains('*')) { + if (!subPattern.contains(QLatin1Char('*'))) { //optimize: we can skip the expensive QRegExp in this case //and do a simple string compare (much faster) if (fileName.endsWith(subPattern)) { diff --git a/kdevplatform/shell/openprojectdialog.cpp b/kdevplatform/shell/openprojectdialog.cpp --- a/kdevplatform/shell/openprojectdialog.cpp +++ b/kdevplatform/shell/openprojectdialog.cpp @@ -92,8 +92,8 @@ QString filterFormat = useKdeFileDialog ? QStringLiteral("%1|%2 (%1)") : QStringLiteral("%2 (%1)"); - allEntry << "*." + ShellExtension::getInstance()->projectFileExtension(); - filters << filterFormat.arg("*." + ShellExtension::getInstance()->projectFileExtension(), ShellExtension::getInstance()->projectFileDescription()); + allEntry << QLatin1String("*.") + ShellExtension::getInstance()->projectFileExtension(); + filters << filterFormat.arg(QLatin1String("*.") + ShellExtension::getInstance()->projectFileExtension(), ShellExtension::getInstance()->projectFileDescription()); QVector plugins = ICore::self()->pluginController()->queryExtensionPlugins(QStringLiteral("org.kdevelop.IProjectFileManager")); foreach(const KPluginMetaData& info, plugins) { @@ -249,11 +249,11 @@ auto plugins = projectManagerForFile(file); if ( plugins.contains(QStringLiteral("")) ) { plugins.removeAll(QStringLiteral("")); - choices.append({i18n("Open existing file \"%1\"", file), "", QString()}); + choices.append({i18n("Open existing file \"%1\"", file), QStringLiteral(""), QString()}); } Q_FOREACH ( const auto& plugin, plugins ) { auto meta = m_projectPlugins.value(plugin); - choices.append({file + QString(" (%1)").arg(plugin), meta.pluginId(), meta.iconName(), file}); + choices.append({file + QLatin1String(" (") + plugin + QLatin1Char(')'), meta.pluginId(), meta.iconName(), file}); } } Q_FOREACH ( const auto& plugin, m_projectFilters.keys() ) { @@ -266,7 +266,7 @@ } page->populateProjectFileCombo(choices); } - m_url.setPath( m_url.path() + '/' + m_url.fileName() + '.' + ShellExtension::getInstance()->projectFileExtension() ); + m_url.setPath( m_url.path() + QLatin1Char('/') + m_url.fileName() + QLatin1Char('.') + ShellExtension::getInstance()->projectFileExtension() ); } else { setAppropriate( projectInfoPage, false ); m_url = url; @@ -319,7 +319,7 @@ if ( m_urlIsDirectory ) { - m_selected = m_url.resolved( QUrl("./" + fileName) ); + m_selected = m_url.resolved( QUrl(QLatin1String("./") + fileName) ); } validateProjectInfo(); diff --git a/kdevplatform/shell/partcontroller.cpp b/kdevplatform/shell/partcontroller.cpp --- a/kdevplatform/shell/partcontroller.cpp +++ b/kdevplatform/shell/partcontroller.cpp @@ -168,7 +168,7 @@ return editorFactory->create( nullptr, this, - className.toLatin1() ); + className); } return nullptr; diff --git a/kdevplatform/shell/plugincontroller.cpp b/kdevplatform/shell/plugincontroller.cpp --- a/kdevplatform/shell/plugincontroller.cpp +++ b/kdevplatform/shell/plugincontroller.cpp @@ -126,8 +126,8 @@ explicit Dependency(const QString &dependency) : interface(dependency) { - if (dependency.contains('@')) { - const auto list = dependency.split('@', QString::SkipEmptyParts); + if (dependency.contains(QLatin1Char('@'))) { + const auto list = dependency.split(QLatin1Char('@'), QString::SkipEmptyParts); if (list.size() == 2) { interface = list.at(0); pluginName = list.at(1); @@ -231,7 +231,7 @@ bool isEnabled(const KPluginMetaData& info) const { // first check black listing from environment - static const QStringList disabledPlugins = QString::fromLatin1(qgetenv("KDEV_DISABLE_PLUGINS")).split(';'); + static const QStringList disabledPlugins = QString::fromLatin1(qgetenv("KDEV_DISABLE_PLUGINS")).split(QLatin1Char(';')); if (disabledPlugins.contains(info.pluginId())) { return false; } @@ -578,7 +578,7 @@ d->foreachEnabledPlugin([&required] (const KPluginMetaData& plugin) -> bool { foreach (const QString& iface, KPluginMetaData::readStringList(plugin.rawData(), KEY_Interfaces())) { required.remove(iface); - required.remove(iface + '@' + plugin.pluginId()); + required.remove(iface + QLatin1Char('@') + plugin.pluginId()); } return !required.isEmpty(); }); diff --git a/kdevplatform/shell/progresswidget/overlaywidget.cpp b/kdevplatform/shell/progresswidget/overlaywidget.cpp --- a/kdevplatform/shell/progresswidget/overlaywidget.cpp +++ b/kdevplatform/shell/progresswidget/overlaywidget.cpp @@ -43,7 +43,7 @@ auto hboxHBoxLayout = new QHBoxLayout(this); hboxHBoxLayout->setMargin(0); - setObjectName(name); + setObjectName(QString::fromUtf8(name)); setAlignWidget( alignWidget ); setWindowFlags(Qt::WindowDoesNotAcceptFocus | windowFlags()); diff --git a/kdevplatform/shell/progresswidget/progressdialog.cpp b/kdevplatform/shell/progresswidget/progressdialog.cpp --- a/kdevplatform/shell/progresswidget/progressdialog.cpp +++ b/kdevplatform/shell/progresswidget/progressdialog.cpp @@ -55,7 +55,7 @@ TransactionItemView::TransactionItemView( QWidget *parent, const char *name ) : QScrollArea( parent ) { - setObjectName( name ); + setObjectName(QString::fromUtf8(name)); setFrameStyle( NoFrame ); mBigBox = new QWidget( this ); auto layout = new QVBoxLayout(mBigBox); diff --git a/kdevplatform/shell/projectcontroller.cpp b/kdevplatform/shell/projectcontroller.cpp --- a/kdevplatform/shell/projectcontroller.cpp +++ b/kdevplatform/shell/projectcontroller.cpp @@ -1059,7 +1059,7 @@ QUrl ProjectController::projectsBaseDirectory() const { KConfigGroup group = ICore::self()->activeSession()->config()->group( "Project Manager" ); - return group.readEntry( "Projects Base Directory", QUrl::fromLocalFile( QDir::homePath() + "/projects" ) ); + return group.readEntry("Projects Base Directory", QUrl::fromLocalFile(QDir::homePath() + QLatin1String("/projects"))); } QString ProjectController::prettyFilePath(const QUrl& url, FormattingOptions format) const @@ -1083,19 +1083,19 @@ QString prefixText; if (project) { if (format == FormatHtml) { - prefixText = "" + project->name() + "/"; + prefixText = QLatin1String("") + project->name() + QLatin1String("/"); } else { - prefixText = project->name() + ':'; + prefixText = project->name() + QLatin1Char(':'); } QString relativePath = project->path().relativePath(parent); if(relativePath.startsWith(QLatin1String("./"))) { relativePath = relativePath.mid(2); } if (!relativePath.isEmpty()) { - prefixText += relativePath + '/'; + prefixText += relativePath + QLatin1Char('/'); } } else { - prefixText = parent.pathOrUrl() + '/'; + prefixText = parent.pathOrUrl() + QLatin1Char('/'); } return prefixText; } @@ -1106,15 +1106,15 @@ if(project && project->path() == Path(url)) { if (format == FormatHtml) { - return "" + project->name() + ""; + return QLatin1String("") + project->name() + QLatin1String(""); } else { return project->name(); } } QString prefixText = prettyFilePath( url, format ); if (format == FormatHtml) { - return prefixText + "" + url.fileName() + ""; + return prefixText + QLatin1String("") + url.fileName() + QLatin1String(""); } else { return prefixText + url.fileName(); } diff --git a/kdevplatform/shell/projectsourcepage.cpp b/kdevplatform/shell/projectsourcepage.cpp --- a/kdevplatform/shell/projectsourcepage.cpp +++ b/kdevplatform/shell/projectsourcepage.cpp @@ -266,7 +266,7 @@ Q_ASSERT(m_locationWidget); if(m_locationWidget->isCorrect()) { QString currentUrl = m_ui->workingDir->text(); - currentUrl = currentUrl.left(currentUrl.lastIndexOf('/')+1); + currentUrl = currentUrl.left(currentUrl.lastIndexOf(QLatin1Char('/'))+1); QUrl current = QUrl::fromUserInput(currentUrl + m_locationWidget->projectName()); m_ui->workingDir->setUrl(current); @@ -279,7 +279,7 @@ { Q_ASSERT(m_providerWidget); QString currentUrl = m_ui->workingDir->text(); - currentUrl = currentUrl.left(currentUrl.lastIndexOf('/')+1); + currentUrl = currentUrl.left(currentUrl.lastIndexOf(QLatin1Char('/'))+1); QUrl current = QUrl::fromUserInput(currentUrl + name); m_ui->workingDir->setUrl(current); diff --git a/kdevplatform/shell/runcontroller.cpp b/kdevplatform/shell/runcontroller.cpp --- a/kdevplatform/shell/runcontroller.cpp +++ b/kdevplatform/shell/runcontroller.cpp @@ -589,7 +589,7 @@ if (!d->jobs.contains(job)) { QAction* stopJobAction = nullptr; if (Core::self()->setupFlags() != Core::NoUi) { - stopJobAction = new QAction(job->objectName().isEmpty() ? i18n("<%1> Unnamed job", job->staticMetaObject.className()) : job->objectName(), this); + stopJobAction = new QAction(job->objectName().isEmpty() ? i18n("<%1> Unnamed job", QString::fromUtf8(job->staticMetaObject.className())) : job->objectName(), this); stopJobAction->setData(QVariant::fromValue(static_cast(job))); d->stopJobsMenu->addAction(stopJobAction); connect (stopJobAction, &QAction::triggered, this, &RunController::slotKillJob); diff --git a/kdevplatform/shell/runtimecontroller.cpp b/kdevplatform/shell/runtimecontroller.cpp --- a/kdevplatform/shell/runtimecontroller.cpp +++ b/kdevplatform/shell/runtimecontroller.cpp @@ -59,7 +59,7 @@ KDevelop::Path pathInHost(const KDevelop::Path & runtimePath) const override { return runtimePath; } KDevelop::Path pathInRuntime(const KDevelop::Path & localPath) const override { return localPath; } void setEnabled(bool /*enabled*/) override {} - QByteArray getenv(const QByteArray & varname) const override { return qgetenv(varname); } + QByteArray getenv(const QByteArray & varname) const override { return qgetenv(varname.constData()); } }; KDevelop::RuntimeController::RuntimeController(KDevelop::Core* core) diff --git a/kdevplatform/shell/session.cpp b/kdevplatform/shell/session.cpp --- a/kdevplatform/shell/session.cpp +++ b/kdevplatform/shell/session.cpp @@ -50,7 +50,7 @@ QUrl pluginArea( const IPlugin* plugin ) { QString name = Core::self()->pluginController()->pluginInfo(plugin).pluginId(); - QUrl url = QUrl::fromLocalFile( info.path + '/' + name ); + QUrl url = QUrl::fromLocalFile(info.path + QLatin1Char('/') + name ); if( !QFile::exists( url.toLocalFile() ) ) { QDir( info.path ).mkdir( name ); } @@ -160,7 +160,7 @@ projectNames << project->name(); } else { QString projectName = url.fileName(); - projectName.remove( QRegExp( "\\.kdev4$", Qt::CaseInsensitive ) ); + projectName.remove(QRegExp(QStringLiteral("\\.kdev4$"), Qt::CaseInsensitive)); projectNames << projectName; } } @@ -180,7 +180,7 @@ if( info.name.isEmpty() ) { description = prettyContentsFormatted; } else { - description = info.name + ": " + prettyContentsFormatted; + description = info.name + QLatin1String(": ") + prettyContentsFormatted; } return description; @@ -212,7 +212,7 @@ ret.uuid = id; ret.path = sessionPath; - ret.config = KSharedConfig::openConfig( sessionPath + "/sessionrc" ); + ret.config = KSharedConfig::openConfig(sessionPath + QLatin1String("/sessionrc")); KConfigGroup cfgRootGroup = ret.config->group( QString() ); KConfigGroup cfgOptionsGroup = ret.config->group( cfgSessionOptionsGroup ); diff --git a/kdevplatform/shell/sessioncontroller.cpp b/kdevplatform/shell/sessioncontroller.cpp --- a/kdevplatform/shell/sessioncontroller.cpp +++ b/kdevplatform/shell/sessioncontroller.cpp @@ -77,7 +77,7 @@ QString arg = QString::fromLocal8Bit(argv[a]); if(arg.startsWith(QLatin1String("-graphicssystem")) || arg.startsWith(QLatin1String("-style"))) { - ret << '-' + arg; + ret << QLatin1Char('-') + arg; if(a+1 < argc) ret << QString::fromLocal8Bit(argv[a+1]); } @@ -217,7 +217,7 @@ a->setData(QVariant::fromValue(s)); sessionActions[s] = a; - q->actionCollection()->addAction( "session_"+s->id().toString(), a ); + q->actionCollection()->addAction(QLatin1String("session_") + s->id().toString(), a); connect( s, &Session::sessionUpdated, this, &SessionControllerPrivate::sessionUpdated ); sessionUpdated( s ); } @@ -233,7 +233,7 @@ static QString sessionBaseDirectory() { return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) - +'/'+ qApp->applicationName() + "/sessions/"; + + QLatin1Char('/') + qApp->applicationName() + QLatin1String("/sessions/"); } QString ownSessionDirectory() const @@ -382,8 +382,7 @@ Session* SessionController::createSession( const QString& name ) { Session* s; - if(name.startsWith('{')) - { + if(name.startsWith(QLatin1Char('{'))) { s = new Session( QUuid(name).toString(), this ); }else{ qsrand(QDateTime::currentDateTimeUtc().toTime_t()); diff --git a/kdevplatform/shell/sessionlock.cpp b/kdevplatform/shell/sessionlock.cpp --- a/kdevplatform/shell/sessionlock.cpp +++ b/kdevplatform/shell/sessionlock.cpp @@ -194,7 +194,7 @@ QString problemResolution = i18nc("@info", "

Please, close the offending application instance " "or choose another session to launch.

"); - QString errmsg = "

" + problemHeader + "
" + problemDescription + "

" + problemResolution; + QString errmsg = QLatin1String("

") + problemHeader + QLatin1String("
") + problemDescription + QLatin1String("

") + problemResolution; KGuiItem retry = KStandardGuiItem::cont(); retry.setText(i18nc("@action:button", "Retry startup")); diff --git a/kdevplatform/shell/settings/pluginpreferences.cpp b/kdevplatform/shell/settings/pluginpreferences.cpp --- a/kdevplatform/shell/settings/pluginpreferences.cpp +++ b/kdevplatform/shell/settings/pluginpreferences.cpp @@ -44,17 +44,17 @@ lay->addWidget( selector ); QMap> plugins; const QMap categories = { - { "Core", i18nc("@title:group", "Core") }, - { "Project Management", i18nc("@title:group", "Project Management") }, - { "Version Control", i18nc("@title:group", "Version Control") }, - { "Utilities", i18nc("@title:group", "Utilities") }, - { "Documentation", i18nc("@title:group", "Documentation") }, - { "Language Support", i18nc("@title:group", "Language Support") }, - { "Debugging", i18nc("@title:group", "Debugging") }, - { "Testing", i18nc("@title:group", "Testing") }, - { "Analyzers", i18nc("@title:group", "Analyzers") }, - { "Runtimes", i18nc("@title:group", "Runtimes") }, - { "Other", i18nc("@title:group", "Other") } + { QStringLiteral("Core"), i18nc("@title:group", "Core") }, + { QStringLiteral("Project Management"), i18nc("@title:group", "Project Management") }, + { QStringLiteral("Version Control"), i18nc("@title:group", "Version Control") }, + { QStringLiteral("Utilities"), i18nc("@title:group", "Utilities") }, + { QStringLiteral("Documentation"), i18nc("@title:group", "Documentation") }, + { QStringLiteral("Language Support"), i18nc("@title:group", "Language Support") }, + { QStringLiteral("Debugging"), i18nc("@title:group", "Debugging") }, + { QStringLiteral("Testing"), i18nc("@title:group", "Testing") }, + { QStringLiteral("Analyzers"), i18nc("@title:group", "Analyzers") }, + { QStringLiteral("Runtimes"), i18nc("@title:group", "Runtimes") }, + { QStringLiteral("Other"), i18nc("@title:group", "Other") } }; foreach (const KPluginMetaData& info, Core::self()->pluginControllerInternal()->allPluginInfos()) { const QString loadMode = info.value(QStringLiteral("X-KDevelop-LoadMode")); diff --git a/kdevplatform/shell/settings/projectconfig.kcfg b/kdevplatform/shell/settings/projectconfig.kcfg --- a/kdevplatform/shell/settings/projectconfig.kcfg +++ b/kdevplatform/shell/settings/projectconfig.kcfg @@ -15,7 +15,7 @@ be slower. - QUrl::fromLocalFile(QDir::homePath()+"/projects") + QUrl::fromLocalFile(QDir::homePath()+QLatin1String("/projects")) Chooses the base directory where new projects are created. diff --git a/kdevplatform/shell/settings/templatepage.cpp b/kdevplatform/shell/settings/templatepage.cpp --- a/kdevplatform/shell/settings/templatepage.cpp +++ b/kdevplatform/shell/settings/templatepage.cpp @@ -135,6 +135,6 @@ archive->open(QIODevice::ReadOnly); - const QString destination = QFileDialog::getExistingDirectory() + '/' + info.baseName(); + const QString destination = QFileDialog::getExistingDirectory() + QLatin1Char('/') + info.baseName(); archive->directory()->copyTo(destination); } diff --git a/kdevplatform/shell/sourceformattercontroller.cpp b/kdevplatform/shell/sourceformattercontroller.cpp --- a/kdevplatform/shell/sourceformattercontroller.cpp +++ b/kdevplatform/shell/sourceformattercontroller.cpp @@ -303,7 +303,7 @@ if( !isMimeTypeSupported(mime) ) return input; - QRegExp kateModelineWithNewline("\\s*\\n//\\s*kate:(.*)$"); + QRegExp kateModelineWithNewline(QStringLiteral("\\s*\\n//\\s*kate:(.*)$")); // If there already is a modeline in the document, adapt it while formatting, even // if "add modeline" is disabled. @@ -339,23 +339,23 @@ qCDebug(SHELL) << "created modeline: " << modeline << endl; - QRegExp kateModeline("^\\s*//\\s*kate:(.*)$"); + QRegExp kateModeline(QStringLiteral("^\\s*//\\s*kate:(.*)$")); bool modelinefound = false; - QRegExp knownOptions("\\s*(indent-width|space-indent|tab-width|indent-mode|replace-tabs)"); + QRegExp knownOptions(QStringLiteral("\\s*(indent-width|space-indent|tab-width|indent-mode|replace-tabs)")); while (!is.atEnd()) { QString line = is.readLine(); // replace only the options we care about if (kateModeline.indexIn(line) >= 0) { // match qCDebug(SHELL) << "Found a kate modeline: " << line << endl; modelinefound = true; QString options = kateModeline.cap(1); - QStringList optionList = options.split(';', QString::SkipEmptyParts); + QStringList optionList = options.split(QLatin1Char(';'), QString::SkipEmptyParts); os << modeline; foreach(QString s, optionList) { if (knownOptions.indexIn(s) < 0) { // unknown option, add it - if(s.startsWith(' ')) + if(s.startsWith(QLatin1Char(' '))) s=s.mid(1); os << s << ";"; qCDebug(SHELL) << "Found unknown option: " << s << endl; @@ -421,7 +421,7 @@ doc->text(KTextEditor::Range(view->selectionRange().end(), doc->documentRange().end()))); //remove the final newline character, unless it should be there - if (!original.endsWith('\n') && output.endsWith('\n')) + if (!original.endsWith(QLatin1Char('\n')) && output.endsWith(QLatin1Char('\n'))) output.resize(output.length() - 1); //there was a selection, so only change the part of the text related to it @@ -457,7 +457,7 @@ const KTextEditor::Cursor cursor = view->cursorPosition(); const QString line = tDoc->line(cursor.line()); const QString prev = tDoc->text(KTextEditor::Range(0, 0, cursor.line(), 0)); - const QString post = '\n' + tDoc->text(KTextEditor::Range(KTextEditor::Cursor(cursor.line() + 1, 0), tDoc->documentEnd())); + const QString post = QLatin1Char('\n') + tDoc->text(KTextEditor::Range(KTextEditor::Cursor(cursor.line() + 1, 0), tDoc->documentEnd())); const QString formatted = formatter->formatSource(line, doc->url(), mime, prev, post); @@ -517,7 +517,7 @@ qCDebug(SHELL) << "adapting mode for" << url; - QRegExp kateModelineWithNewline("\\s*\\n//\\s*kate:(.*)$"); + QRegExp kateModelineWithNewline(QStringLiteral("\\s*\\n//\\s*kate:(.*)$")); // modelines should always take precedence if( !ignoreModeline && kateModelineWithNewline.indexIn( doc->text() ) != -1 ) diff --git a/kdevplatform/shell/sourceformatterjob.cpp b/kdevplatform/shell/sourceformatterjob.cpp --- a/kdevplatform/shell/sourceformatterjob.cpp +++ b/kdevplatform/shell/sourceformatterjob.cpp @@ -141,7 +141,7 @@ // TODO: really fromLocal8Bit/toLocal8Bit? no encoding detection? added in b8062f736a2bf2eec098af531a7fda6ebcdc7cde QString text = QString::fromLocal8Bit(getJob->data()); text = formatter->formatSource(text, url, mime); - text = m_sourceFormatterController->addModelineForCurrentLang(text, url, mime).toUtf8(); + text = m_sourceFormatterController->addModelineForCurrentLang(text, url, mime); auto putJob = KIO::storedPut(text.toLocal8Bit(), url, -1, KIO::Overwrite); // see getJob diff --git a/kdevplatform/shell/statusbar.cpp b/kdevplatform/shell/statusbar.cpp --- a/kdevplatform/shell/statusbar.cpp +++ b/kdevplatform/shell/statusbar.cpp @@ -123,7 +123,8 @@ Qt::QueuedConnection); // Don't try to connect when the status object doesn't provide an error message signal (ie. avoid warning) - if (status->metaObject()->indexOfSignal(QMetaObject::normalizedSignature("showErrorMessage(QString,int)")) != -1) { + const auto signalSignature = QMetaObject::normalizedSignature("showErrorMessage(QString,int)"); + if (status->metaObject()->indexOfSignal(signalSignature.constData()) != -1) { connect(status, SIGNAL(showErrorMessage(QString,int)), SLOT(showErrorMessage(QString,int)), Qt::QueuedConnection); } diff --git a/kdevplatform/shell/textdocument.cpp b/kdevplatform/shell/textdocument.cpp --- a/kdevplatform/shell/textdocument.cpp +++ b/kdevplatform/shell/textdocument.cpp @@ -515,13 +515,13 @@ int startPos = qMax( qMin( start.column(), linestr.length() - 1 ), 0 ); int endPos = startPos; startPos --; - while( startPos >= 0 && ( linestr[startPos].isLetterOrNumber() || linestr[startPos] == '_' || linestr[startPos] == '~' ) ) - { + while (startPos >= 0 && + (linestr[startPos].isLetterOrNumber() || linestr[startPos] == QLatin1Char('_') || linestr[startPos] == QLatin1Char('~'))) { --startPos; } - while( endPos < linestr.length() && ( linestr[endPos].isLetterOrNumber() || linestr[endPos] == '_' || linestr[endPos] == '~' ) ) - { + while (endPos < linestr.length() && + (linestr[endPos].isLetterOrNumber() || linestr[endPos] == QLatin1Char('_') || linestr[endPos] == QLatin1Char('~'))) { ++endPos; } if( startPos != endPos ) @@ -624,8 +624,8 @@ void KDevelop::TextView::setState(const QString & state) { - static QRegExp reCursor("Cursor=([\\d]+),([\\d]+)"); - static QRegExp reSelection("Selection=([\\d]+),([\\d]+),([\\d]+),([\\d]+)"); + static QRegExp reCursor(QStringLiteral("Cursor=([\\d]+),([\\d]+)")); + static QRegExp reSelection(QStringLiteral("Selection=([\\d]+),([\\d]+),([\\d]+),([\\d]+)")); if (reCursor.exactMatch(state)) { setInitialRange(KTextEditor::Range(KTextEditor::Cursor(reCursor.cap(1).toInt(), reCursor.cap(2).toInt()), 0)); } else if (reSelection.exactMatch(state)) { diff --git a/kdevplatform/shell/uicontroller.cpp b/kdevplatform/shell/uicontroller.cpp --- a/kdevplatform/shell/uicontroller.cpp +++ b/kdevplatform/shell/uicontroller.cpp @@ -593,7 +593,7 @@ // FIXME: using object name seems ugly. QString type = defaultArea->objectName(); Sublime::Area* area = this->area(w, type); - KConfigGroup areaConfig(&mainWindowConfig, "Area " + type); + KConfigGroup areaConfig(&mainWindowConfig, QLatin1String("Area ") + type); areaConfig.deleteGroup(); areaConfig.writeEntry("id", type); @@ -646,7 +646,7 @@ QString type = defaultArea->objectName(); Sublime::Area* area = this->area(w, type); - KConfigGroup areaConfig(&mainWindowConfig, "Area " + type); + KConfigGroup areaConfig(&mainWindowConfig, QLatin1String("Area ") + type); qCDebug(SHELL) << "Trying to restore area " << type; diff --git a/kdevplatform/shell/workingsetcontroller.cpp b/kdevplatform/shell/workingsetcontroller.cpp --- a/kdevplatform/shell/workingsetcontroller.cpp +++ b/kdevplatform/shell/workingsetcontroller.cpp @@ -59,7 +59,7 @@ foreach(const QString& set, setConfig.groupList()) { // do not load working set if the id contains an '|', because it then belongs to an area. // this is functionally equivalent to the if ( ! config->icon ) stuff which was there before. - if ( set.contains('|') ) { + if (set.contains(QLatin1Char('|'))) { continue; } getWorkingSet(set); diff --git a/kdevplatform/shell/workingsets/workingset.cpp b/kdevplatform/shell/workingsets/workingset.cpp --- a/kdevplatform/shell/workingsets/workingset.cpp +++ b/kdevplatform/shell/workingsets/workingset.cpp @@ -247,7 +247,7 @@ KConfigGroup setConfig(Core::self()->activeSession()->config(), "Working File Sets"); KConfigGroup setGroup = setConfig.group(m_id); - KConfigGroup areaGroup = setConfig.group(m_id + '|' + area->title()); + KConfigGroup areaGroup = setConfig.group(m_id + QLatin1Char('|') + area->title()); loadToArea(area, areaIndex, setGroup, areaGroup, recycle); @@ -390,7 +390,7 @@ KConfigGroup setGroup = setConfig.group(m_id); deleteGroupRecursive(setGroup); - KConfigGroup areaGroup = setConfig.group(m_id + '|' + area->title()); + KConfigGroup areaGroup = setConfig.group(m_id + QLatin1Char('|') + area->title()); QString lastActiveView = areaGroup.readEntry("Active View", ""); deleteGroupRecursive(areaGroup); if (area->activeView() && area->activeView()->document()) diff --git a/kdevplatform/shell/workingsets/workingsettooltipwidget.cpp b/kdevplatform/shell/workingsets/workingsettooltipwidget.cpp --- a/kdevplatform/shell/workingsets/workingsettooltipwidget.cpp +++ b/kdevplatform/shell/workingsets/workingsettooltipwidget.cpp @@ -177,7 +177,7 @@ WorkingSetFileLabel* fileLabel = new WorkingSetFileLabel; fileLabel->setTextFormat(Qt::RichText); // We add spaces behind and after, to make it look nicer - fileLabel->setText(" " + Core::self()->projectController()->prettyFileName(QUrl::fromUserInput(file)) + " "); + fileLabel->setText(QLatin1String(" ") + Core::self()->projectController()->prettyFileName(QUrl::fromUserInput(file)) + QLatin1String(" ")); fileLabel->setToolTip(i18nc("@info:tooltip", "Click to open and activate this document.")); fileLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); fileLayout->addWidget(fileLabel); diff --git a/kdevplatform/sublime/aggregatemodel.cpp b/kdevplatform/sublime/aggregatemodel.cpp --- a/kdevplatform/sublime/aggregatemodel.cpp +++ b/kdevplatform/sublime/aggregatemodel.cpp @@ -90,7 +90,7 @@ Q_UNUSED(role); //there's nothing to return here because aggregated models will have different headers //so we just use empty headers for aggregate model. - return ""; + return QString(); } int AggregateModel::columnCount(const QModelIndex &parent) const diff --git a/kdevplatform/sublime/area.cpp b/kdevplatform/sublime/area.cpp --- a/kdevplatform/sublime/area.cpp +++ b/kdevplatform/sublime/area.cpp @@ -303,7 +303,7 @@ QMap::iterator i, e; for (i = d->desiredToolViews.begin(), e = d->desiredToolViews.end(); i != e; ++i) { - desired << i.key() + ':' + QString::number(static_cast(i.value())); + desired << i.key() + QLatin1Char(':') + QString::number(static_cast(i.value())); } group.writeEntry("desired views", desired); qCDebug(SUBLIME) << "save " << this << "wrote" << group.readEntry("desired views", ""); @@ -321,7 +321,7 @@ QStringList desired = group.readEntry("desired views", QStringList()); foreach (const QString &s, desired) { - int i = s.indexOf(':'); + int i = s.indexOf(QLatin1Char(':')); if (i != -1) { QString id = s.left(i); diff --git a/kdevplatform/sublime/areaindex.cpp b/kdevplatform/sublime/areaindex.cpp --- a/kdevplatform/sublime/areaindex.cpp +++ b/kdevplatform/sublime/areaindex.cpp @@ -240,7 +240,7 @@ QString AreaIndex::print() const { if(isSplit()) - return " [ " + first()->print() + (orientation() == Qt::Horizontal ? " / " : " - ") + second()->print() + " ] "; + return QLatin1String(" [ ") + first()->print() + QLatin1String(orientation() == Qt::Horizontal ? " / " : " - ") + second()->print() + QLatin1String(" ] "); QStringList ret; foreach(Sublime::View* view, views()) ret << view->document()->title(); diff --git a/kdevplatform/sublime/container.cpp b/kdevplatform/sublime/container.cpp --- a/kdevplatform/sublime/container.cpp +++ b/kdevplatform/sublime/container.cpp @@ -192,9 +192,9 @@ } else { auto url = urlDoc->url().toString(); - int secondOffset = url.lastIndexOf('/'); - secondOffset = url.lastIndexOf('/', secondOffset - 1); - visibleEntryTitle = url.right(url.length() - url.lastIndexOf('/', secondOffset) - 1); + int secondOffset = url.lastIndexOf(QLatin1Char('/')); + secondOffset = url.lastIndexOf(QLatin1Char('/'), secondOffset - 1); + visibleEntryTitle = url.right(url.length() - url.lastIndexOf(QLatin1Char('/'), secondOffset) - 1); } } else { visibleEntryTitle = view->document()->title(); diff --git a/kdevplatform/sublime/idealcontroller.cpp b/kdevplatform/sublime/idealcontroller.cpp --- a/kdevplatform/sublime/idealcontroller.cpp +++ b/kdevplatform/sublime/idealcontroller.cpp @@ -85,7 +85,7 @@ QString dockObjectName = view->document()->title(); // support different configuration for same docks opened in different areas if (m_mainWindow->area()) - dockObjectName += '_' + m_mainWindow->area()->objectName(); + dockObjectName += QLatin1Char('_') + m_mainWindow->area()->objectName(); dock->setObjectName(dockObjectName); diff --git a/kdevplatform/sublime/mainwindow.cpp b/kdevplatform/sublime/mainwindow.cpp --- a/kdevplatform/sublime/mainwindow.cpp +++ b/kdevplatform/sublime/mainwindow.cpp @@ -220,7 +220,7 @@ d->disableConcentrationMode(); QString group = QStringLiteral("MainWindow"); if (area()) - group += '_' + area()->objectName(); + group += QLatin1Char('_') + area()->objectName(); KConfigGroup cg = KSharedConfig::openConfig()->group(group); /* This will try to save window size, too. But it's OK, since we won't use this information when loading. */ @@ -247,7 +247,7 @@ qCDebug(SUBLIME) << "loading settings for " << (area() ? area()->objectName() : QLatin1String("")); QString group = QStringLiteral("MainWindow"); if (area()) - group += '_' + area()->objectName(); + group += QLatin1Char('_') + area()->objectName(); KConfigGroup cg = KSharedConfig::openConfig()->group(group); // What follows is copy-paste from applyMainWindowSettings. Unfortunately, diff --git a/kdevplatform/sublime/tests/CMakeLists.txt b/kdevplatform/sublime/tests/CMakeLists.txt --- a/kdevplatform/sublime/tests/CMakeLists.txt +++ b/kdevplatform/sublime/tests/CMakeLists.txt @@ -1,3 +1,9 @@ +remove_definitions( + -DQT_NO_CAST_FROM_ASCII + -DQT_NO_CAST_TO_ASCII + -DQT_NO_CAST_FROM_BYTEARRAY +) + set(test_areaoperation_SRCS test_areaoperation.cpp areaprinter.cpp) ecm_add_test(${test_areaoperation_SRCS} TEST_NAME test_areaoperation diff --git a/kdevplatform/sublime/urldocument.cpp b/kdevplatform/sublime/urldocument.cpp --- a/kdevplatform/sublime/urldocument.cpp +++ b/kdevplatform/sublime/urldocument.cpp @@ -90,7 +90,7 @@ QString UrlDocument::title(TitleType type) const { if (type == Extended) - return Document::title() + " (" + url().toDisplayString(QUrl::PreferLocalFile) + ')'; + return Document::title() + QLatin1String(" (") + url().toDisplayString(QUrl::PreferLocalFile) + QLatin1Char(')'); else return Document::title(); } diff --git a/kdevplatform/template/filters/kdevfilters.cpp b/kdevplatform/template/filters/kdevfilters.cpp --- a/kdevplatform/template/filters/kdevfilters.cpp +++ b/kdevplatform/template/filters/kdevfilters.cpp @@ -42,14 +42,12 @@ QStringList words(const QVariant& input) { QString string = getSafeString(input); - if (string == string.toLower() && !string.contains('_')) - { + if (string == string.toLower() && !string.contains(QLatin1Char('_'))) { return QStringList(string); } - if (string.contains('_')) - { - return string.toLower().split('_'); + if (string.contains(QLatin1Char('_'))) { + return string.toLower().split(QLatin1Char('_')); } int n = string.size(); @@ -121,11 +119,11 @@ { QStringList retLines; QString start = getSafeString(argument); - foreach (const QString& line, getSafeString(input).split('\n', QString::KeepEmptyParts)) + foreach (const QString& line, getSafeString(input).split(QLatin1Char('\n'), QString::KeepEmptyParts)) { retLines << start + line; } - return Grantlee::SafeString(retLines.join(QString('\n'))); + return Grantlee::SafeString(retLines.join(QStringLiteral("\n"))); } QVariant ArgumentTypeFilter::doFilter (const QVariant& input, const QVariant& /*argument*/, diff --git a/kdevplatform/tests/CMakeLists.txt b/kdevplatform/tests/CMakeLists.txt --- a/kdevplatform/tests/CMakeLists.txt +++ b/kdevplatform/tests/CMakeLists.txt @@ -1,3 +1,6 @@ +add_definitions( + -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_BYTEARRAY +) set(kdevtests_LIB_SRCS autotestshell.cpp kdevsignalspy.cpp diff --git a/kdevplatform/tests/json/delayedoutput.cpp b/kdevplatform/tests/json/delayedoutput.cpp --- a/kdevplatform/tests/json/delayedoutput.cpp +++ b/kdevplatform/tests/json/delayedoutput.cpp @@ -33,7 +33,7 @@ while (!output.isEmpty()) { DepthedOutput curOutput = output.pop(); - qDebug().nospace() << qPrintable(QString(curOutput.second -1, ' ')) << curOutput.first.toUtf8().data(); + qDebug().nospace() << qPrintable(QString(curOutput.second -1, QLatin1Char(' '))) << curOutput.first.toUtf8().data(); } } QStack output; diff --git a/kdevplatform/tests/json/jsontesthelpers.h b/kdevplatform/tests/json/jsontesthelpers.h --- a/kdevplatform/tests/json/jsontesthelpers.h +++ b/kdevplatform/tests/json/jsontesthelpers.h @@ -27,7 +27,7 @@ #define VERIFY_TYPE(qvariantType)\ if (!value.canConvert())\ - return JsonTestHelpers::INVALID_JSON_TYPE().arg(QStringLiteral(#qvariantType), QVariant::typeToName(value.type())) + return JsonTestHelpers::INVALID_JSON_TYPE().arg(QStringLiteral(#qvariantType), QString::fromUtf8(QVariant::typeToName(value.type()))) #define __AddTest(testName, objType)\ bool testName##Added = KDevelop::TestSuite::get().addTest(QStringLiteral(#testName), &testName) diff --git a/kdevplatform/tests/testcore.cpp b/kdevplatform/tests/testcore.cpp --- a/kdevplatform/tests/testcore.cpp +++ b/kdevplatform/tests/testcore.cpp @@ -69,7 +69,7 @@ if (_session.isEmpty()) { // use a distinct session name for unit test sessions // they are temporary (see below) but still - we want to make sure - session = "test-" + qApp->applicationName(); + session = QLatin1String("test-") + qApp->applicationName(); } d->initialize( mode, session ); diff --git a/kdevplatform/tests/testfile.cpp b/kdevplatform/tests/testfile.cpp --- a/kdevplatform/tests/testfile.cpp +++ b/kdevplatform/tests/testfile.cpp @@ -93,9 +93,9 @@ TestProject* project, const QString& dir) : d(new TestFilePrivate()) { - d->suffix = '.' + fileExtension; + d->suffix = QLatin1Char('.') + fileExtension; - QTemporaryFile file((!dir.isEmpty() ? dir : QDir::tempPath()) + "/testfile_XXXXXX" + d->suffix); + QTemporaryFile file((!dir.isEmpty() ? dir : QDir::tempPath()) + QLatin1String("/testfile_XXXXXX") + d->suffix); file.setAutoRemove(false); file.open(); Q_ASSERT(file.isOpen()); @@ -107,7 +107,7 @@ : d(new TestFilePrivate) { QString fileName = base->d->file.mid(0, base->d->file.length() - base->d->suffix.length()); - d->suffix = '.' + fileExtension; + d->suffix = QLatin1Char('.') + fileExtension; fileName += d->suffix; d->init(fileName, contents, base->d->project); } diff --git a/kdevplatform/tests/testproject.cpp b/kdevplatform/tests/testproject.cpp --- a/kdevplatform/tests/testproject.cpp +++ b/kdevplatform/tests/testproject.cpp @@ -32,7 +32,7 @@ , m_root(nullptr) , m_projectConfiguration(KSharedConfig::openConfig()) { - m_path = path.isValid() ? path : Path(QDir::tempPath() + "/kdev-testproject/"); + m_path = path.isValid() ? path : Path(QDir::tempPath() + QLatin1String("/kdev-testproject/")); m_root = new ProjectFolderItem(this, m_path); ICore::self()->projectController()->projectModel()->appendRow( m_root ); } @@ -73,7 +73,7 @@ Path TestProject::projectFile() const { - return Path(m_path, m_path.lastPathSegment() + ".kdev4"); + return Path(m_path, m_path.lastPathSegment() + QLatin1String(".kdev4")); } Path TestProject::path() const diff --git a/kdevplatform/util/commandexecutor.cpp b/kdevplatform/util/commandexecutor.cpp --- a/kdevplatform/util/commandexecutor.cpp +++ b/kdevplatform/util/commandexecutor.cpp @@ -92,7 +92,7 @@ QMap envmap; foreach( const QString& var, env ) { - int sep = var.indexOf( '=' ); + int sep = var.indexOf(QLatin1Char('=')); envmap.insert( var.left( sep ), var.mid( sep + 1 ) ); } d->m_env = envmap; @@ -130,7 +130,7 @@ } else { QStringList arguments; Q_FOREACH( const QString &a, d->m_args ) arguments << KShell::quoteArg( a ); - d->m_process->setShellCommand(d->m_command + ' ' + arguments.join(QLatin1Char(' '))); + d->m_process->setShellCommand(d->m_command + QLatin1Char(' ') + arguments.join(QLatin1Char(' '))); } d->m_process->start(); diff --git a/kdevplatform/util/duchainify/main.cpp b/kdevplatform/util/duchainify/main.cpp --- a/kdevplatform/util/duchainify/main.cpp +++ b/kdevplatform/util/duchainify/main.cpp @@ -253,7 +253,7 @@ QDirIterator contents(path); while(contents.hasNext()) { QString newPath = contents.next(); - if(!newPath.endsWith('.')) + if(!newPath.endsWith(QLatin1Char('.'))) addToBackgroundParser(newPath, features); } } diff --git a/kdevplatform/util/environmentprofilelist.cpp b/kdevplatform/util/environmentprofilelist.cpp --- a/kdevplatform/util/environmentprofilelist.cpp +++ b/kdevplatform/util/environmentprofilelist.cpp @@ -175,8 +175,8 @@ QMap retMap; foreach( const QString &line, defaultEnvironment ) { - QString varName = line.section( '=', 0, 0 ); - QString varValue = line.section( '=', 1 ); + QString varName = line.section(QLatin1Char('='), 0, 0); + QString varValue = line.section(QLatin1Char('='), 1); retMap.insert( varName, varValue ); } @@ -194,7 +194,7 @@ for( QMap::const_iterator it = retMap.constBegin(); it != retMap.constEnd(); ++it ) { - env << it.key() + '=' + it.value(); + env << it.key() + QLatin1Char('=') + it.value(); } return env; diff --git a/kdevplatform/util/formattinghelpers.cpp b/kdevplatform/util/formattinghelpers.cpp --- a/kdevplatform/util/formattinghelpers.cpp +++ b/kdevplatform/util/formattinghelpers.cpp @@ -99,10 +99,10 @@ QString textWhiteSpace = text.left(textWhitespaceEnd); // Step 1: Remove redundant newlines - while(contextWhiteSpace.contains('\n') && textWhiteSpace.contains('\n')) + while(contextWhiteSpace.contains(QLatin1Char('\n')) && textWhiteSpace.contains(QLatin1Char('\n'))) { - int contextOffset = contextWhiteSpace.indexOf('\n')+1; - int textOffset = textWhiteSpace.indexOf('\n')+1; + int contextOffset = contextWhiteSpace.indexOf(QLatin1Char('\n'))+1; + int textOffset = textWhiteSpace.indexOf(QLatin1Char('\n'))+1; contextPosition += contextOffset; contextWhiteSpace.remove(0, contextOffset); @@ -114,24 +114,24 @@ int contextOffset = 0; int textOffset = 0; // Skip redundant ordinary whitespace - while( contextOffset < contextWhiteSpace.size() && textOffset < textWhiteSpace.size() && contextWhiteSpace[contextOffset].isSpace() && contextWhiteSpace[contextOffset] != '\n' && textWhiteSpace[textOffset].isSpace() && textWhiteSpace[textOffset] != '\n' ) + while(contextOffset < contextWhiteSpace.size() && textOffset < textWhiteSpace.size() && contextWhiteSpace[contextOffset].isSpace() && contextWhiteSpace[contextOffset] != QLatin1Char('\n') && textWhiteSpace[textOffset].isSpace() && textWhiteSpace[textOffset] != QLatin1Char('\n')) { - bool contextWasTab = contextWhiteSpace[contextOffset] == ' '; - bool textWasTab = textWhiteSpace[contextOffset] == ' '; + bool contextWasTab = contextWhiteSpace[contextOffset] == QLatin1Char('\t'); + bool textWasTab = textWhiteSpace[contextOffset] == QLatin1Char('\t'); ++contextOffset; ++textOffset; if( contextWasTab != textWasTab ) { // Problem: We have a mismatch of tabs and/or ordinary whitespaces if( contextWasTab ) { for( int s = 1; s < tabWidth; ++s ) - if( textOffset < textWhiteSpace.size() && textWhiteSpace[textOffset] == ' ' ) + if (textOffset < textWhiteSpace.size() && textWhiteSpace[textOffset] == QLatin1Char(' ')) ++textOffset; }else if( textWasTab ) { for( int s = 1; s < tabWidth; ++s ) - if( contextOffset < contextWhiteSpace.size() && contextWhiteSpace[contextOffset] == ' ' ) + if (contextOffset < contextWhiteSpace.size() && contextWhiteSpace[contextOffset] == QLatin1Char(' ')) ++contextOffset; } } @@ -169,10 +169,10 @@ if(!rightContext.isEmpty()) { //Add a whitespace behind the text for matching, so that we definitely capture all trailing whitespace - int endOfText = matchPrefixIgnoringWhitespace( formattedMergedText, text+' ', QString() ); + int endOfText = matchPrefixIgnoringWhitespace(formattedMergedText, text + QLatin1Char(' '), QString()); if(endOfText == -1) { // Try 2: Ignore the fuzzy characters while matching - endOfText = matchPrefixIgnoringWhitespace( formattedMergedText, text+' ', fuzzyCharacters ); + endOfText = matchPrefixIgnoringWhitespace(formattedMergedText, text + QLatin1Char(' '), fuzzyCharacters); if(endOfText == -1) { qCWarning(UTIL) << "problem matching the text while formatting"; return text; diff --git a/kdevplatform/util/kdevformatfile.cpp b/kdevplatform/util/kdevformatfile.cpp --- a/kdevplatform/util/kdevformatfile.cpp +++ b/kdevplatform/util/kdevformatfile.cpp @@ -42,7 +42,7 @@ QDir::setCurrent(srcDir.canonicalPath()); qStdOut() << "found \"" - << QFileInfo(srcDir.canonicalPath() + '/' + formatFileName).canonicalFilePath() + << QFileInfo(srcDir.canonicalPath() + QDir::separator() + formatFileName).canonicalFilePath() << "\"\n"; return true; } @@ -55,7 +55,7 @@ bool KDevFormatFile::read() { - static const QChar delimeter(':'); + static const QChar delimeter = QLatin1Char(':'); QFile formatFile(formatFileName); if (!formatFile.open(QIODevice::ReadOnly | QIODevice::Text)) { @@ -71,8 +71,8 @@ while (!formatFile.atEnd()) { ++lineNumber; - line = formatFile.readLine().trimmed(); - if (line.isEmpty() || line.startsWith('#')) + line = QString::fromUtf8(formatFile.readLine().trimmed()); + if (line.isEmpty() || line.startsWith(QLatin1Char('#'))) continue; if (line.indexOf(delimeter) < 0) { @@ -83,7 +83,7 @@ } else { // We found the correct syntax with "wildcards : command" - wildcards = line.section(delimeter, 0, 0).split(' ', QString::SkipEmptyParts); + wildcards = line.section(delimeter, 0, 0).split(QLatin1Char(' '), QString::SkipEmptyParts); command = line.section(delimeter, 1).trimmed(); if (wildcards.isEmpty()) { @@ -112,7 +112,7 @@ } foreach(const QString& wildcard, formatLine.wildcards) { - if (QDir::match(QDir::current().canonicalPath() + "/" + wildcard.trimmed(), m_origFilePath)) { + if (QDir::match(QDir::current().canonicalPath() + QDir::separator() + wildcard.trimmed(), m_origFilePath)) { qStdOut() << "matched \"" << m_origFilePath << "\" with wildcard \"" << wildcard << '\"'; return executeCommand(formatLine.command); } @@ -131,18 +131,18 @@ command.replace(QStringLiteral("$TMPFILE"), m_tempFilePath); #ifdef Q_OS_WIN - int execResult = QProcess::execute("cmd", {"/c", command}); + int execResult = QProcess::execute(QStringLiteral("cmd"), {QStringLiteral("/c"), command}); #else - int execResult = QProcess::execute(QStringLiteral("sh"), {"-c", command}); + int execResult = QProcess::execute(QStringLiteral("sh"), {QStringLiteral("-c"), command}); #endif if (execResult == -2) { - qStdOut() << "command \"" + command + "\" failed to start\n"; + qStdOut() << "command \"" << command << "\" failed to start\n"; return false; } if (execResult == -1) { - qStdOut() << "command \"" + command + "\" crashed\n"; + qStdOut() << "command \"" << command << "\" crashed\n"; return false; } diff --git a/kdevplatform/util/kdevformatsource.cpp b/kdevplatform/util/kdevformatsource.cpp --- a/kdevplatform/util/kdevformatsource.cpp +++ b/kdevplatform/util/kdevformatsource.cpp @@ -32,7 +32,7 @@ return EXIT_FAILURE; } - QFileInfo origFileInfo(argv[1]); + QFileInfo origFileInfo(QString::fromLocal8Bit(argv[1])); if (!origFileInfo.exists()) { qStdOut() << "orig file \"" << origFileInfo.absoluteFilePath() << "\" does not exits\n"; return EXIT_FAILURE; @@ -42,7 +42,7 @@ QString tempFilePath; if (argc > 2) - tempFilePath = QFileInfo(argv[2]).canonicalFilePath(); + tempFilePath = QFileInfo(QString::fromLocal8Bit(argv[2])).canonicalFilePath(); else { tempFilePath = origFilePath; qStdOut() << "no temp file given, formatting the original file\n"; diff --git a/kdevplatform/util/kdevstringhandler.cpp b/kdevplatform/util/kdevstringhandler.cpp --- a/kdevplatform/util/kdevstringhandler.cpp +++ b/kdevplatform/util/kdevstringhandler.cpp @@ -154,7 +154,7 @@ switch (mode) { case FastMode: { QString result(s); - result.remove(QRegExp("<[^>]+>")); + result.remove(QRegExp(QStringLiteral("<[^>]+>"))); return result; } case CompleteMode: { diff --git a/kdevplatform/util/path.cpp b/kdevplatform/util/path.cpp --- a/kdevplatform/util/path.cpp +++ b/kdevplatform/util/path.cpp @@ -34,21 +34,21 @@ inline bool isWindowsDriveLetter(const QString& segment) { #ifdef Q_OS_WIN - return segment.size() == 2 && segment.at(0).isLetter() && segment.at(1) == ':'; + return segment.size() == 2 && segment.at(0).isLetter() && segment.at(1) == QLatin1Char(':'); #else Q_UNUSED(segment); return false; #endif } inline bool isAbsolutePath(const QString& path) { - if (path.startsWith('/')) { + if (path.startsWith(QLatin1Char('/'))) { return true; // Even on Windows: Potentially a path of a remote URL } #ifdef Q_OS_WIN - return path.size() >= 2 && path.at(0).isLetter() && path.at(1) == ':'; + return path.size() >= 2 && path.at(0).isLetter() && path.at(1) == QLatin1Char(':'); #else return false; #endif @@ -61,7 +61,7 @@ const auto str = url.toString(options | QUrl::PreferLocalFile); #ifdef Q_OS_WIN // potentially strip leading slash - if (url.isLocalFile() && !str.isEmpty() && str[0] == '/') { + if (url.isLocalFile() && !str.isEmpty() && str[0] == QLatin1Char('/')) { return str.mid(1); // expensive copying, but we'd like toString(...) to properly format everything first } #endif @@ -104,11 +104,11 @@ const QString user = url.userName(); if (!user.isEmpty()) { urlPrefix += user; - urlPrefix += '@'; + urlPrefix += QLatin1Char('@'); } urlPrefix += url.host(); if (url.port() != -1) { - urlPrefix += ':' + QString::number(url.port()); + urlPrefix += QLatin1Char(':') + QString::number(url.port()); } m_data << urlPrefix; } @@ -162,15 +162,15 @@ #ifdef Q_OS_WIN if (start == 0 && isLocalFile) { - Q_ASSERT(data.at(0).endsWith(':')); // assume something along "C:" + Q_ASSERT(data.at(0).endsWith(QLatin1Char(':'))); // assume something along "C:" res += data.at(0); start++; } #endif for (int i = start; i < size; ++i) { if (i || isLocalFile) { - res += '/'; + res += QLatin1Char('/'); } res += data.at(i); diff --git a/kdevplatform/util/processlinemaker.cpp b/kdevplatform/util/processlinemaker.cpp --- a/kdevplatform/util/processlinemaker.cpp +++ b/kdevplatform/util/processlinemaker.cpp @@ -52,9 +52,9 @@ int pos; while ( (pos = data.indexOf('\n')) != -1) { if (pos > 0 && data.at(pos - 1) == '\r') - lineList << QString::fromLocal8Bit(data, pos - 1); + lineList << QString::fromLocal8Bit(data.constData(), pos - 1); else - lineList << QString::fromLocal8Bit(data, pos); + lineList << QString::fromLocal8Bit(data.constData(), pos); data.remove(0, pos+1); } return lineList; diff --git a/kdevplatform/util/shellutils.cpp b/kdevplatform/util/shellutils.cpp --- a/kdevplatform/util/shellutils.cpp +++ b/kdevplatform/util/shellutils.cpp @@ -68,7 +68,7 @@ auto rejectButton = KStandardGuiItem::cancel(); rejectButton.setText(rejectText); int userAnswer = KMessageBox::questionYesNo( ICore::self()->uiController()->activeMainWindow(), - mainText + "\n\n" + mboxAdditionalText, + mainText + QLatin1String("\n\n") + mboxAdditionalText, mboxTitle, okButton, rejectButton ); @@ -93,7 +93,7 @@ if (!notWritable.isEmpty()) { int answer = KMessageBox::questionYesNoCancel(ICore::self()->uiController()->activeMainWindow(), - i18n("You don't have write permissions for the following files; add write permissions for owner before saving?")+"\n\n"+notWritable.join(QStringLiteral("\n")), + i18n("You don't have write permissions for the following files; add write permissions for owner before saving?") + QLatin1String("\n\n") + notWritable.join(QStringLiteral("\n")), i18n("Some files are write-protected"), KStandardGuiItem::yes(), KStandardGuiItem::no(), KStandardGuiItem::cancel()); if (answer == KMessageBox::Yes) { diff --git a/kdevplatform/util/tests/CMakeLists.txt b/kdevplatform/util/tests/CMakeLists.txt --- a/kdevplatform/util/tests/CMakeLists.txt +++ b/kdevplatform/util/tests/CMakeLists.txt @@ -1,3 +1,7 @@ +remove_definitions( + -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_BYTEARRAY +) + ecm_add_test(test_embeddedfreetree.cpp LINK_LIBRARIES KF5::TextEditor Qt5::Test KDev::Language KDev::Tests) diff --git a/kdevplatform/vcs/dvcs/dvcsjob.h b/kdevplatform/vcs/dvcs/dvcsjob.h --- a/kdevplatform/vcs/dvcs/dvcsjob.h +++ b/kdevplatform/vcs/dvcs/dvcsjob.h @@ -103,6 +103,7 @@ /** * Overloaded convenience function. + * @param arg command or argument as utf8-encoded string * @see operator<<(const QString& arg). */ DVcsJob& operator<<(const char* arg); diff --git a/kdevplatform/vcs/dvcs/dvcsjob.cpp b/kdevplatform/vcs/dvcs/dvcsjob.cpp --- a/kdevplatform/vcs/dvcs/dvcsjob.cpp +++ b/kdevplatform/vcs/dvcs/dvcsjob.cpp @@ -100,7 +100,7 @@ DVcsJob& DVcsJob::operator<<(const char* arg) { - *d->childproc << arg; + *d->childproc << QString::fromUtf8(arg); return *this; } @@ -123,7 +123,7 @@ endpos = stdoutbuf.lastIndexOf('\n')+1; // Include the final newline or become 0, when there is no newline } - return QString::fromLocal8Bit(stdoutbuf, endpos); + return QString::fromLocal8Bit(stdoutbuf.constData(), endpos); } QByteArray DVcsJob::rawOutput() const @@ -181,14 +181,14 @@ QString service; if(d->vcsplugin) service = d->vcsplugin->objectName(); - setObjectName(service+": "+commandDisplay); + setObjectName(service + QLatin1String(": ") + commandDisplay); d->status = JobRunning; d->childproc->setOutputChannelMode(KProcess::SeparateChannels); //the started() and error() signals may be delayed! It causes crash with deferred deletion!!! d->childproc->start(); - d->model->appendLine(directory().path() + "> " + commandDisplay); + d->model->appendLine(directory().path() + QLatin1String("> ") + commandDisplay); } void DVcsJob::setCommunicationMode(KProcess::OutputChannelMode comm) @@ -267,7 +267,7 @@ void DVcsJob::displayOutput(const QString& data) { - d->model->appendLines(data.split('\n')); + d->model->appendLines(data.split(QLatin1Char('\n'))); } void DVcsJob::slotReceivedStdout() diff --git a/kdevplatform/vcs/models/tests/test_models.cpp b/kdevplatform/vcs/models/tests/test_models.cpp --- a/kdevplatform/vcs/models/tests/test_models.cpp +++ b/kdevplatform/vcs/models/tests/test_models.cpp @@ -30,7 +30,7 @@ void TestModels::initTestCase() { - AutoTestShell::init({"dummy"}); + AutoTestShell::init({QStringLiteral("dummy")}); TestCore::initialize(); } diff --git a/kdevplatform/vcs/models/vcsannotationmodel.cpp b/kdevplatform/vcs/models/vcsannotationmodel.cpp --- a/kdevplatform/vcs/models/vcsannotationmodel.cpp +++ b/kdevplatform/vcs/models/vcsannotationmodel.cpp @@ -96,7 +96,7 @@ VcsAnnotationModel::~VcsAnnotationModel() = default; static QString abbreviateLastName(const QString& author) { - auto parts = author.split(' '); + auto parts = author.split(QLatin1Char(' ')); bool onlyOneFragment = parts.size() == 1 || ( parts.size() == 2 && parts.at(1).isEmpty() ); return onlyOneFragment ? parts.first() : parts.first() + QStringLiteral(" %1.").arg(parts.last()[0]); } diff --git a/kdevplatform/vcs/models/vcseventmodel.cpp b/kdevplatform/vcs/models/vcseventmodel.cpp --- a/kdevplatform/vcs/models/vcseventmodel.cpp +++ b/kdevplatform/vcs/models/vcseventmodel.cpp @@ -76,7 +76,7 @@ return QVariant( ev.revision().revisionValue() ); case SummaryColumn: // show the first line only - return QVariant( ev.message().section('\n', 0, 0) ); + return QVariant( ev.message().section(QLatin1Char('\n'), 0, 0) ); case AuthorColumn: return QVariant( ev.author() ); case DateColumn: diff --git a/kdevplatform/vcs/widgets/vcsdiffpatchsources.cpp b/kdevplatform/vcs/widgets/vcsdiffpatchsources.cpp --- a/kdevplatform/vcs/widgets/vcsdiffpatchsources.cpp +++ b/kdevplatform/vcs/widgets/vcsdiffpatchsources.cpp @@ -258,7 +258,7 @@ qCDebug(VCS) << "Finishing with selection" << selection; QString files; foreach(const QUrl& url, selection) - files += "
  • "+ICore::self()->projectController()->prettyFileName(url, KDevelop::IProjectController::FormatPlain) + "
  • "; + files += QLatin1String("
  • ") + ICore::self()->projectController()->prettyFileName(url, KDevelop::IProjectController::FormatPlain) + QLatin1String("
  • "); QString text = i18n("Files will be committed:\n
      %1
    \nWith message:\n
    %2
    ", files, message);