mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-20 20:06:12 +00:00
Removed useless information from tooltip and removed very slow data retrieving with afij
(#1087)
Now tooltip will show Disasm Preview and Highlights
This commit is contained in:
parent
975fd77116
commit
78fe3eb3c1
@ -196,21 +196,6 @@ QVariant FunctionModel::data(const QModelIndex &index, int role) const
|
||||
return static_cast<int>(Qt::AlignLeft | Qt::AlignVCenter);
|
||||
|
||||
case Qt::ToolTipRole: {
|
||||
const QJsonArray &info = Core()->cmdj("afij @ " + function.name).array();
|
||||
if (!info.isEmpty()) {
|
||||
const QJsonObject &funcInfo = info[0].toObject();
|
||||
|
||||
static const QStringList kRequiredFields{ "size", "cc", "nbbs" };
|
||||
for (const auto& key : kRequiredFields) {
|
||||
if (!funcInfo.contains(key)) {
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
const int size = funcInfo["size"].toInt();
|
||||
const int complex = funcInfo["cc"].toInt();
|
||||
const int bb = funcInfo["nbbs"].toInt();
|
||||
QStringList disasmPreview;
|
||||
|
||||
QJsonArray jDisasmEntries;
|
||||
{
|
||||
// temporarily simplify the disasm output to get it colorful and simple to read
|
||||
@ -228,6 +213,7 @@ QVariant FunctionModel::data(const QModelIndex &index, int role) const
|
||||
|
||||
jDisasmEntries = Core()->cmdj(QString("pDJ %1 @ %2").arg(function.size).arg(function.offset)).array();
|
||||
}
|
||||
QStringList disasmPreview;
|
||||
for (const QJsonValue &value : jDisasmEntries) {
|
||||
const QJsonObject &object = value.toObject();
|
||||
|
||||
@ -255,12 +241,7 @@ QVariant FunctionModel::data(const QModelIndex &index, int role) const
|
||||
QString toolTipContent = QString("<html><div style=\"font-family: %1; font-size: %2pt; white-space: nowrap;\">")
|
||||
.arg(fnt.family())
|
||||
.arg(qMax(6, fnt.pointSize() - 1)) // slightly decrease font size, to keep more text in the same box
|
||||
+ tr("<div><strong>Summary</strong>:<br>")
|
||||
+ tr("Size: %1, Cyclomatic complexity: %2, Basic blocks: %3")
|
||||
.arg(size)
|
||||
.arg(complex)
|
||||
.arg(bb)
|
||||
+ tr("</div><div style=\"margin-top: 10px;\"><strong>Disassembly preview</strong>:<br>%1</div>")
|
||||
+ tr("<div><strong>Disassembly preview</strong>:<br>%1</div>")
|
||||
.arg(disasmPreview.join("<br>"));
|
||||
|
||||
if (!highlights.isEmpty()) {
|
||||
@ -270,8 +251,6 @@ QVariant FunctionModel::data(const QModelIndex &index, int role) const
|
||||
toolTipContent += "</div></html>";
|
||||
return toolTipContent;
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
case Qt::ForegroundRole:
|
||||
if (functionIsImport(function.offset))
|
||||
|
Loading…
Reference in New Issue
Block a user