From: Jens Steinhauser Date: Fri, 28 Aug 2015 15:34:29 +0000 (+0200) Subject: Remove unused arguments from 'format_time()' X-Git-Tag: pulseview-0.3.0~127 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=dae21ebcf60d6a5d7c194736b1dc792a5cbf06a5;p=pulseview.git Remove unused arguments from 'format_time()' This function is already complicated enough (it tries to guess in what context it is currently used and changes its behaviour accordingly), so remove the unused parameters to make it somewhat comprehensible. --- diff --git a/pv/util.cpp b/pv/util.cpp index 029ae079..d2d70827 100644 --- a/pv/util.cpp +++ b/pv/util.cpp @@ -76,7 +76,7 @@ static QString pad_number(unsigned int number, int length) return QString("%1").arg(number, length, 10, QChar('0')); } -static QString format_time_in_full(double t, signed precision, bool force_sign) +static QString format_time_in_full(double t, signed precision) { const unsigned int whole_seconds = abs((int) t); const unsigned int days = whole_seconds / (60 * 60 * 24); @@ -87,9 +87,9 @@ static QString format_time_in_full(double t, signed precision, bool force_sign) QString s; QTextStream ts(&s); - if (force_sign && (t >= 0)) + if (t >= 0) ts << "+"; - if (t < 0) + else ts << "-"; bool use_padding = false; @@ -142,7 +142,7 @@ static QString format_time_in_full(double t, signed precision, bool force_sign) } static QString format_time_with_si(double t, QString unit, int prefix, - unsigned int precision, bool sign) + unsigned int precision) { // The precision is always given without taking the prefix into account // so we need to deduct the number of decimals the prefix might imply @@ -153,11 +153,10 @@ static QString format_time_with_si(double t, QString unit, int prefix, (prefix >= pv::util::FirstSIPrefix) ? precision : std::max((int)(precision - prefix_order), 0); - return format_si_value(t, unit, prefix, relative_prec, sign); + return format_si_value(t, unit, prefix, relative_prec); } -QString format_time(double t, int prefix, TimeUnit unit, - unsigned int precision, double step_size, bool sign) +QString format_time(double t, int prefix, TimeUnit unit, unsigned int precision) { // Make 0 appear as 0, not random +0 or -0 if (fabs(t) < MinTimeDelta) @@ -165,21 +164,16 @@ QString format_time(double t, int prefix, TimeUnit unit, // If we have to use samples then we have no alternative formats if (unit == Samples) - return format_time_with_si(t, "sa", prefix, precision, sign); - - // View zoomed way out -> low precision (0), high step size (>=60s) - // -> DD:HH:MM - if ((precision == 0) && (step_size >= 60)) - return format_time_in_full(t, -1, sign); + return format_time_with_si(t, "sa", prefix, precision); // View in "normal" range -> medium precision, medium step size // -> HH:MM:SS.mmm... or xxxx (si unit) if less than 60 seconds // View zoomed way in -> high precision (>3), low step size (<1s) // -> HH:MM:SS.mmm... or xxxx (si unit) if less than 60 seconds if (abs(t) < 60) - return format_time_with_si(t, "s", prefix, precision, sign); + return format_time_with_si(t, "s", prefix, precision); else - return format_time_in_full(t, precision, sign); + return format_time_in_full(t, precision); } QString format_second(double second) diff --git a/pv/util.hpp b/pv/util.hpp index ba6702f7..d59ad10e 100644 --- a/pv/util.hpp +++ b/pv/util.hpp @@ -57,14 +57,11 @@ QString format_si_value( * 8 for 'giga'. If prefix is set to -1, the prefix will be calculated. * @param unit The unit of quantity. * @param precision The number of digits after the decimal separator or period (.). - * @param step_size The delta between two consecutive time markers (if applicable). - * @param sign Whether or not to add a sign also for positive numbers. * * @return The formated value. */ QString format_time( - double t, int prefix = -1, TimeUnit unit = Time, unsigned precision = 0, - double step_size = 0, bool sign = true); + double t, int prefix = -1, TimeUnit unit = Time, unsigned precision = 0); /** * Formats a given time value with a SI prefix so that the