Skip to content

Commit

Permalink
Add tooltip for PerLibraryModel
Browse files Browse the repository at this point in the history
  • Loading branch information
milianw committed Dec 3, 2023
1 parent 0a1a0a9 commit 241948f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/models/treemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ QVariant PerLibraryModel::rowData(const Data::PerLibrary* row, int column, int r

column -= m_results.costs.numTypes();
return m_results.costs.totalCost(column);
} else if (role == Qt::ToolTipRole) {
return Util::formatBinaryTooltip(row->id, row->symbol, m_results.costs);
} else {
return {};
}
Expand Down
5 changes: 5 additions & 0 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,11 @@ QString Util::formatFrequency(quint64 occurrences, quint64 nanoseconds)
return QString::number(hz, 'G', 4) + QLatin1String(*unit);
}

QString Util::formatBinaryTooltip(int id, const Data::Symbol& symbol, const Data::Costs& costs)
{
return formatTooltipImpl(id, Util::formatString(symbol.binary), nullptr, &costs);
}

QString Util::formatTooltip(int id, const Data::Symbol& symbol, const Data::Costs& costs)
{
return formatTooltipImpl(id, formatForTooltip(symbol), nullptr, &costs);
Expand Down
1 change: 1 addition & 0 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ QString formatCost(quint64 cost);
QString formatCostRelative(quint64 selfCost, quint64 totalCost, bool addPercentSign = false);
QString formatTimeString(quint64 nanoseconds, bool shortForm = false);
QString formatFrequency(quint64 occurrences, quint64 nanoseconds);
QString formatBinaryTooltip(int id, const Data::Symbol& symbol, const Data::Costs& costs);
QString formatTooltip(int id, const Data::Symbol& symbol, const Data::Costs& costs);
QString formatTooltip(int id, const Data::Symbol& symbol, const Data::Costs& selfCosts,
const Data::Costs& inclusiveCosts);
Expand Down

0 comments on commit 241948f

Please sign in to comment.