+QString CursorPair::format_string_sub(int time_precision, int freq_precision, bool show_unit)
+{
+ QString s = " ";
+
+ const pv::util::SIPrefix prefix = view_.tick_prefix();
+ const pv::util::Timestamp diff = abs(second_->time() - first_->time());
+
+ const QString time = Ruler::format_time_with_distance(
+ diff, diff, prefix, (show_unit ? view_.time_unit() : pv::util::TimeUnit::None),
+ time_precision, false);
+
+ // We can only show a frequency when there's a time base
+ if (view_.time_unit() == pv::util::TimeUnit::Time) {
+ int items = 0;
+
+ if (show_frequency_) {
+ const QString freq = util::format_value_si(
+ 1 / diff.convert_to<double>(), pv::util::SIPrefix::unspecified,
+ freq_precision, (show_unit ? "Hz" : nullptr), false);
+ s = QString("%1").arg(freq);
+ items++;
+ }
+
+ if (show_interval_) {
+ if (items > 0)
+ s = QString("%1 / %2").arg(s, time);
+ else
+ s = QString("%1").arg(time);
+ items++;
+ }
+ } else
+ // In this case, we return the number of samples, really
+ s = time;
+
+ return s;
+}
+