forked from qt-creator/qt-creator
ClangTools: Fix showing location for ExplainingStepItem
In case the ExplainingStepItem refers to another file than the main diagnostic, display the file name too. Change-Id: I1df2781766dc0c7a58b451e3c96b78574d574e54 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -524,21 +524,28 @@ QVariant ExplainingStepItem::data(int column, int role) const
|
|||||||
case ClangToolsDiagnosticModel::DiagnosticRole:
|
case ClangToolsDiagnosticModel::DiagnosticRole:
|
||||||
return QVariant::fromValue(static_cast<DiagnosticItem *>(parent())->diagnostic());
|
return QVariant::fromValue(static_cast<DiagnosticItem *>(parent())->diagnostic());
|
||||||
case Qt::DisplayRole: {
|
case Qt::DisplayRole: {
|
||||||
|
const QString mainFilePath = static_cast<DiagnosticItem *>(parent())->diagnostic().location.filePath;
|
||||||
|
const QString locationString
|
||||||
|
= m_step.location.filePath == mainFilePath
|
||||||
|
? lineColumnString(m_step.location)
|
||||||
|
: QString("%1:%2").arg(QFileInfo(m_step.location.filePath).fileName(),
|
||||||
|
lineColumnString(m_step.location));
|
||||||
|
|
||||||
if (m_step.isFixIt) {
|
if (m_step.isFixIt) {
|
||||||
if (m_step.ranges[0] == m_step.ranges[1]) {
|
if (m_step.ranges[0] == m_step.ranges[1]) {
|
||||||
return QString("%1: Insertion of \"%2\".")
|
return QString("%1: Insertion of \"%2\".")
|
||||||
.arg(lineColumnString(m_step.location), m_step.message);
|
.arg(locationString, m_step.message);
|
||||||
}
|
}
|
||||||
if (m_step.message.isEmpty()) {
|
if (m_step.message.isEmpty()) {
|
||||||
return QString("%1: Removal of %2.")
|
return QString("%1: Removal of %2.")
|
||||||
.arg(lineColumnString(m_step.location), rangeString(m_step.ranges));
|
.arg(locationString, rangeString(m_step.ranges));
|
||||||
}
|
}
|
||||||
return QString("%1: Replacement of %2 with: \"%3\".")
|
return QString("%1: Replacement of %2 with: \"%3\".")
|
||||||
.arg(lineColumnString(m_step.location),
|
.arg(locationString,
|
||||||
rangeString(m_step.ranges),
|
rangeString(m_step.ranges),
|
||||||
m_step.message);
|
m_step.message);
|
||||||
}
|
}
|
||||||
return QString("%1: %2").arg(lineColumnString(m_step.location), m_step.message);
|
return QString("%1: %2").arg(locationString, m_step.message);
|
||||||
}
|
}
|
||||||
case Qt::ToolTipRole:
|
case Qt::ToolTipRole:
|
||||||
return createExplainingStepToolTipString(m_step);
|
return createExplainingStepToolTipString(m_step);
|
||||||
|
Reference in New Issue
Block a user