Use QString::midRef where possible

parent 575895a9
......@@ -222,7 +222,7 @@ void EnvironmentProfileModel::setVariablesFromString(const QString& plainText)
if (variableName.isEmpty()) {
continue;
}
const QString value = line.mid(pos+1).trimmed();
const QString value = line.midRef(pos+1).trimmed().toString();
m_varsByIndex << variableName;
variables.insert(variableName, value);
}
......
......@@ -120,10 +120,9 @@ void CMakeCodeCompletionModel::completionInvoked(View* view, const Range& range,
int lastdir=tocomplete.lastIndexOf(QLatin1Char('/'));
QString path = KIO::upUrl(QUrl(d->url())).adjusted(QUrl::StripTrailingSlash).toLocalFile()+QLatin1Char('/');
QString basePath;
if(lastdir>=0) {
basePath=tocomplete.mid(0, lastdir);
path+=basePath;
const QStringRef basePath = tocomplete.midRef(0, lastdir);
path += basePath;
}
QDir dir(path);
......
......@@ -120,7 +120,7 @@ KJob* CMakeBuilder::build(KDevelop::ProjectBaseItem *dom)
}
KDevelop::ProjectFileItem* file = dom->file();
int lastDot = file->text().lastIndexOf(QLatin1Char('.'));
QString target = file->text().mid(0, lastDot) + QLatin1String(".o");
const QString target = file->text().midRef(0, lastDot) + QLatin1String(".o");
build = makeBuilder->executeMakeTarget(dom->parent(), target);
qCDebug(KDEV_CMAKEBUILDER) << "create build job for target" << build << dom << target;
}
......
......@@ -57,7 +57,7 @@ Defines MsvcCompiler::defines(Utils::LanguageType, const QString&) const
if ( !buff.isEmpty() ) {
line = QString::fromUtf8(buff);
if ( line.startsWith( QLatin1String("#define ") ) ) {
line = line.mid(8).trimmed();
line = line.midRef(8).trimmed().toString();
int pos = line.indexOf(QLatin1Char(' '));
if ( pos != -1 ) {
......
......@@ -473,7 +473,7 @@ PathResolutionResult MakeFileResolver::resolveIncludePathInternal(const QString&
//We use the second directory. For t hat reason we search for the last index of "cd "
int cdIndex = prefix.lastIndexOf(QLatin1String("cd "));
if (cdIndex != -1) {
newWorkingDirectory = prefix.mid(cdIndex + 3).trimmed();
newWorkingDirectory = prefix.midRef(cdIndex + 3).trimmed().toString();
if (QFileInfo(newWorkingDirectory).isRelative())
newWorkingDirectory = workingDirectory + QLatin1Char('/') + newWorkingDirectory;
newWorkingDirectory = QDir::cleanPath(newWorkingDirectory);
......
......@@ -47,7 +47,7 @@ int Utils::expressionAt( const QString& text, int index ) {
}
QChar ch = text[ index ];
QString ch2 = text.mid( index - 1, 2 );
const QStringRef ch2 = text.midRef(index - 1, 2);
if ((last != T_IDE) && (ch.isLetterOrNumber() || ch == QLatin1Char('_'))) {
while (index > 0 && (text[index].isLetterOrNumber() || text[index] == QLatin1Char('_'))) {
--index;
......
......@@ -47,7 +47,7 @@ QString repairDiff(const QString& diff) {
QMap<QString, QString> headers;
for(int a = 0; a < lines.size()-1; ++a) {
if(lines[a].startsWith(QLatin1String("Index: ")) && lines[a+1].startsWith(QLatin1String("====="))) {
QString fileName = lines[a].mid(strlen("Index: ")).trimmed();
const QString fileName = lines[a].midRef(strlen("Index: ")).trimmed().toString();
headers[fileName] = lines[a];
qCDebug(PLUGIN_SVN) << "found header for" << fileName;
lines[a] = QString();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment