From 502f1b90d14e84045683e30f5e2d08e4513d2bba Mon Sep 17 00:00:00 2001 From: Milian Wolff Date: Fri, 15 Jan 2016 14:06:37 +0100 Subject: [PATCH] Make chart tooltips better readable. --- gui/chartmodel.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/gui/chartmodel.cpp b/gui/chartmodel.cpp index f40ed88..85092e6 100644 --- a/gui/chartmodel.cpp +++ b/gui/chartmodel.cpp @@ -121,13 +121,23 @@ QVariant ChartModel::data(const QModelIndex& index, int role) const const auto cost = data.cost[column]; if (role == Qt::ToolTipRole) { const QString time = QString::number(double(data.timeStamp) / 1000, 'g', 3) + QLatin1Char('s'); - const auto label = m_data.labels.value(column); - if (m_type == Allocations || m_type == Temporary) { - return i18n("%1: %2 at %3", label, cost, time); - } else { - KFormat format; - return i18n("%1: %2 at %3", label, format.formatByteSize(cost, 1, KFormat::MetricBinaryDialect), time); + const auto label = m_data.labels.value(column).toHtmlEscaped(); + KFormat format; + switch (m_type) { + case Allocations: + return i18n("%2 allocations after %3 from:

%1

", + label, cost, time); + case Temporary: + return i18n("%2 temporary allocations after %3 from:

%1

", + label, cost, time); + case Consumed: + return i18n("%2 consumed after %3 from:

%1

", + label, format.formatByteSize(cost, 1, KFormat::MetricBinaryDialect), time); + case Allocated: + return i18n("%2 allocated after %3 from:

%1

", + label, format.formatByteSize(cost, 1, KFormat::MetricBinaryDialect), time); } + return {}; } return cost; -- 2.7.4