forked from qt-creator/qt-creator
analyzer: add a button to shorten names of function templates
Task-number: QTCREATORBUG-7746 Change-Id: I5ba6c5b63c319d7b65239c6b730c0da90ef20c4f Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -67,6 +67,7 @@ public:
|
||||
, m_event(0)
|
||||
, m_verboseToolTips(true)
|
||||
, m_cycleDetection(false)
|
||||
, m_shortenTemplates(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -76,6 +77,7 @@ public:
|
||||
int m_event;
|
||||
bool m_verboseToolTips;
|
||||
bool m_cycleDetection;
|
||||
bool m_shortenTemplates;
|
||||
QVector<const Function *> m_functions;
|
||||
};
|
||||
|
||||
@@ -214,6 +216,23 @@ static QString noWrap(const QString &str)
|
||||
return escapedStr.replace(QLatin1Char('-'), "‑");
|
||||
}
|
||||
|
||||
static QString shortenTemplate(QString str)
|
||||
{
|
||||
int depth = 0;
|
||||
int j = 0;
|
||||
for (int i = 0, n = str.size(); i != n; ++i) {
|
||||
int c = str.at(i).unicode();
|
||||
if (c == '>')
|
||||
--depth;
|
||||
if (depth == 0)
|
||||
str[j++] = str.at(i);
|
||||
if (c == '<')
|
||||
++depth;
|
||||
}
|
||||
str.truncate(j);
|
||||
return str;
|
||||
}
|
||||
|
||||
QVariant DataModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
//QTC_ASSERT(index.isValid() && index.model() == this, return QVariant());
|
||||
@@ -224,7 +243,7 @@ QVariant DataModel::data(const QModelIndex &index, int role) const
|
||||
|
||||
if (role == Qt::DisplayRole) {
|
||||
if (index.column() == NameColumn)
|
||||
return func->name();
|
||||
return d->m_shortenTemplates ? shortenTemplate(func->name()) : func->name();
|
||||
if (index.column() == LocationColumn)
|
||||
return func->location();
|
||||
if (index.column() == CalledColumn)
|
||||
@@ -368,5 +387,13 @@ void DataModel::enableCycleDetection(bool enabled)
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void DataModel::setShortenTemplates(bool enabled)
|
||||
{
|
||||
beginResetModel();
|
||||
d->m_shortenTemplates = enabled;
|
||||
d->updateFunctions();
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
} // namespace Valgrind
|
||||
} // namespace Callgrind
|
||||
|
||||
Reference in New Issue
Block a user