Commit e9306eb7 authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

Use QString::mid(x) over QString::right(size() - x)

Consistency across all string splitting code, also less code
parent f0fe9ce6
......@@ -324,7 +324,7 @@ CXChildVisitResult declVisitor(CXCursor cursor, CXCursor parent, CXClientData d)
if (kind != CXCursor_Constructor && kind != CXCursor_Destructor) {
int spaceIndex = signature.indexOf(QLatin1Char(' '));
returnType = signature.left(spaceIndex);
rest = signature.right(signature.count() - spaceIndex - 1);
rest = signature.mid(spaceIndex + 1);
} else {
rest = signature;
}
......
......@@ -61,5 +61,5 @@ QString CacheLine::type() const
QString CacheLine::value() const
{
return m_line.right(m_line.size()-equal-1);
return m_line.mid(equal+1);
}
......@@ -71,7 +71,7 @@ void CMakeCacheModel::read()
{
QString line = in.readLine().trimmed();
if(line.startsWith(QLatin1String("//")))
currentComment += line.right(line.count()-2);
currentComment += line.mid(2);
else if(!line.isEmpty() && !line.startsWith('#')) //it is a variable
{
CacheLine c;
......
......@@ -57,11 +57,11 @@ Defines MsvcCompiler::defines(Utils::LanguageType, const QString&) const
if ( !buff.isEmpty() ) {
line = buff;
if ( line.startsWith( QLatin1String("#define ") ) ) {
line = line.right( line.length() - 8 ).trimmed();
line = line.mid(8).trimmed();
int pos = line.indexOf( ' ' );
if ( pos != -1 ) {
ret[line.left( pos )] = line.right( line.length() - pos - 1 ).toUtf8();
ret[line.left( pos )] = line.mid(pos + 1).toUtf8();
} else {
ret[line] = QLatin1String("");
}
......
......@@ -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.right(prefix.length() - 3 - cdIndex).trimmed();
newWorkingDirectory = prefix.mid(cdIndex + 3).trimmed();
if (QFileInfo(newWorkingDirectory).isRelative())
newWorkingDirectory = workingDirectory + '/' + newWorkingDirectory;
newWorkingDirectory = QDir::cleanPath(newWorkingDirectory);
......
......@@ -358,7 +358,7 @@ void IRegisterController::structuredRegistersHandler(const ResultRecord& r)
Q_ASSERT(start != -1);
start += Converters::modeToString(currentMode).size();
QString value = record.right(record.size() - start);
QString value = record.mid(start);
int idx = rx.indexIn(value);
value = rx.cap(1);
......
......@@ -652,7 +652,7 @@ void GitPlugin::parseGitBlameOutput(DVcsJob *job)
continue;
QStringRef name = it->left(it->indexOf(' '));
QStringRef value = it->right(it->size()-name.size()-1);
QStringRef value = it->mid(name.size()+1);
if(name==QLatin1String("author"))
annotation->setAuthor(value.toString());
......@@ -807,7 +807,7 @@ void GitPlugin::parseGitBranchOutput(DVcsJob* job)
QStringRef name = branch;
if (name.startsWith('*'))
name = branch.right(branch.size()-2);
name = branch.mid(2);
branchList << name.trimmed().toString();
}
......@@ -1184,7 +1184,7 @@ void GitPlugin::parseGitStatusOutput_old(DVcsJob* job)
for (const QString& line : outputLines) {
VcsStatusInfo::State status = lsfilesToState(line[0].toLatin1());
QUrl url = QUrl::fromLocalFile(dir.absoluteFilePath(line.right(line.size()-2)));
QUrl url = QUrl::fromLocalFile(dir.absoluteFilePath(line.mid(2)));
allStatus[url] = status;
}
......@@ -1216,7 +1216,7 @@ void GitPlugin::parseGitStatusOutput(DVcsJob* job)
for (const QStringRef& line : outputLines) {
//every line is 2 chars for the status, 1 space then the file desc
QStringRef curr=line.right(line.size()-3);
QStringRef curr=line.mid(3);
QStringRef state = line.left(2);
int arrow = curr.indexOf(QStringLiteral(" -> "));
......
......@@ -99,7 +99,7 @@ void GrepOutputDelegate::paint( QPainter* painter, const QStyleOptionViewItem& o
fmt.clearBackground();
fmt.setFontWeight(QFont::Normal);
cur.insertText(item->text().right(item->text().length() - rng.end().column()), fmt);
cur.insertText(item->text().mid(rng.end().column()), fmt);
}else{
QString text;
if(item)
......@@ -150,7 +150,7 @@ QSize GrepOutputDelegate::sizeHint(const QStyleOptionViewItem& option, const QMo
const KTextEditor::Range rng = item->change()->m_range;
int width = metrics.width(item->text().left(rng.start().column())) +
metrics.width(item->text().right(item->text().length() - rng.end().column())) +
metrics.width(item->text().mid(rng.end().column())) +
bMetrics.width(item->text().mid(rng.start().column(), rng.end().column() - rng.start().column())) +
option.fontMetrics.width(i18n("Line %1: ",item->lineNumber())) +
std::max(option.decorationSize.width(), 0);
......
......@@ -151,7 +151,7 @@ QVariant GrepOutputItem::data ( int role ) const {
// show replaced version in tooltip if we are in replace mode
const QString match = isCheckable() ? grepModel->replacementFor(m_change->m_oldText) : m_change->m_oldText;
const QString repl = QLatin1String("<b>") + match.toHtmlEscaped() + QLatin1String("</b>");
QString end = text().right(text().length() - m_change->m_range.end().column()).toHtmlEscaped();
QString end = text().mid(m_change->m_range.end().column()).toHtmlEscaped();
const QString toolTip = QLatin1String("<span style=\"white-space:nowrap\">") + QString(start + repl + end).trimmed() + QLatin1String("</span>");
return toolTip;
} else if (role == Qt::FontRole) {
......
......@@ -199,7 +199,7 @@ QString PerforcePlugin::getRepositoryName(const QFileInfo& curFile)
for (const QString& line : outputLines) {
int idx(line.indexOf(DEPOT_FILE_STR));
if (idx != -1) {
ret = line.right(line.size() - DEPOT_FILE_STR.size());
ret = line.mid(DEPOT_FILE_STR.size());
return ret;
}
}
......@@ -564,7 +564,7 @@ void PerforcePlugin::parseP4StatusOutput(DVcsJob* job)
for (const QString& line : outputLines) {
int idx(line.indexOf(ACTION_STR));
if (idx != -1) {
QString curr = line.right(line.size() - ACTION_STR.size());
QString curr = line.mid(ACTION_STR.size());
if (curr == QLatin1String("edit")) {
status.setState(VcsStatusInfo::ItemModified);
......@@ -577,7 +577,7 @@ void PerforcePlugin::parseP4StatusOutput(DVcsJob* job)
}
idx = line.indexOf(CLIENT_FILE_STR);
if (idx != -1) {
QUrl fileUrl = QUrl::fromLocalFile(line.right(line.size() - CLIENT_FILE_STR.size()));
QUrl fileUrl = QUrl::fromLocalFile(line.mid(CLIENT_FILE_STR.size()));
status.setUrl(fileUrl);
}
......
......@@ -409,7 +409,7 @@ QList<QMakeProjectFile::DefinePair> QMakeProjectFile::defines() const
int pos = def.indexOf('=');
if (pos >= 0) {
// a value is attached to define
d.append(DefinePair(def.left(pos), def.right(def.length() - (pos + 1))));
d.append(DefinePair(def.left(pos), def.mid(pos + 1)));
} else {
// a value-less define
d.append(DefinePair(def, 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