X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fviews%2Ftrace%2Fruler.cpp;fp=pv%2Fviews%2Ftrace%2Fruler.cpp;h=401fc3da28e86e81d2c1ba3858bd1d4cb866a0e3;hb=66279897e318a2549557054d1204c862f7d99469;hp=98f55ddb06fb72ebac091263abb65c062e87bfc5;hpb=ef85cfa4599d3741e7007921e39a44490e97cfaf;p=pulseview.git diff --git a/pv/views/trace/ruler.cpp b/pv/views/trace/ruler.cpp index 98f55ddb..401fc3da 100644 --- a/pv/views/trace/ruler.cpp +++ b/pv/views/trace/ruler.cpp @@ -88,8 +88,7 @@ QString Ruler::format_time_with_distance( pv::util::SIPrefix prefix, pv::util::TimeUnit unit, unsigned precision, - bool sign, - bool show_unit) + bool sign) { const unsigned limit = 60; @@ -98,7 +97,12 @@ QString Ruler::format_time_with_distance( // If we have to use samples then we have no alternative formats if (unit == pv::util::TimeUnit::Samples) - return pv::util::format_time_si_adjusted(t, prefix, precision, show_unit ? "sa" : NULL, sign); + return pv::util::format_time_si_adjusted(t, prefix, precision, "sa", sign); + + QString unit_string; + if (unit == pv::util::TimeUnit::Time) + unit_string = "s"; + // Note: In case of pv::util::TimeUnit::None, unit_string remains empty // View zoomed way out -> low precision (0), big distance (>=60s) // -> DD:HH:MM @@ -110,7 +114,7 @@ QString Ruler::format_time_with_distance( // View zoomed way in -> high precision (>3), low step size (<1s) // -> HH:MM:SS.mmm... or xxxx (si unit) if less than limit seconds if (abs(t) < limit) - return pv::util::format_time_si_adjusted(t, prefix, precision, show_unit ? "s" : NULL, sign); + return pv::util::format_time_si_adjusted(t, prefix, precision, unit_string, sign); else return pv::util::format_time_minutes(t, precision, sign); }