#include <pv/device/devinst.h>
#include <pv/popups/deviceoptions.h>
#include <pv/popups/probes.h>
+#include <pv/util.h>
using boost::shared_ptr;
using std::map;
if ((watched == &_sample_count || watched == &_sample_rate) &&
(event->type() == QEvent::ToolTip)) {
double sec = (double)_sample_count.value() / _sample_rate.value();
-
- QString str;
- QTextStream(&str)
- << tr("Total sampling time: ")
- << fixed
- << qSetRealNumberPrecision(1)
- << sec
- << "s";
-
QHelpEvent *help_event = static_cast<QHelpEvent*>(event);
+
+ QString str = tr("Total sampling time: %1").arg(pv::util::format_second(sec));
QToolTip::showText(help_event->globalPos(), str);
return true;
return s;
}
+QString format_second(double second)
+{
+ unsigned int i = 0;
+ int exp = - FirstSIPrefixPower;
+
+ while ((second * pow(10.0, exp)) > 999.0 && i < countof(SIPrefixes) - 1) {
+ i++;
+ exp -= 3;
+ }
+
+ return format_time(second, i, 0, false);
+}
+
} // namespace util
} // namespace pv
double t, unsigned int prefix,
unsigned precision = 0, bool sign = true);
+/**
+ * Formats a given time value with a SI prefix so that the
+ * value is between 1 and 999.
+ * @param second The time value in seconds to format.
+ *
+ * @return The formated value.
+ */
+QString format_second(double second);
+
} // namespace util
} // namespace pv