projects
/
pulseview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Installer: Remove examples start menu entry when uninstalling
[pulseview.git]
/
pv
/
util.cpp
diff --git
a/pv/util.cpp
b/pv/util.cpp
index c25c373b3c23e15ff8178f06615087e0659cfd18..8f2d7d2544cd8e30301a28c56f6537269dbe759a 100644
(file)
--- a/
pv/util.cpp
+++ b/
pv/util.cpp
@@
-21,12
+21,20
@@
#include <extdef.h>
#include <extdef.h>
-#include <cassert>
#include <algorithm>
#include <algorithm>
+#include <cassert>
#include <sstream>
#include <sstream>
-#include <QTextStream>
#include <QDebug>
#include <QDebug>
+#include <QTextStream>
+
+using std::fixed;
+using std::max;
+using std::ostringstream;
+using std::setfill;
+using std::setprecision;
+using std::showpos;
+using std::string;
using namespace Qt;
using namespace Qt;
@@
-82,18
+90,18
@@
static QTextStream& operator<<(QTextStream& stream, const Timestamp& t)
int precision = stream.realNumberPrecision();
int precision = stream.realNumberPrecision();
-
std::
ostringstream ss;
- ss <<
std::
fixed;
+ ostringstream ss;
+ ss << fixed;
if (stream.numberFlags() & QTextStream::ForceSign)
if (stream.numberFlags() & QTextStream::ForceSign)
- ss << s
td::s
howpos;
+ ss << showpos;
if (0 == precision)
if (0 == precision)
- ss << s
td::s
etprecision(1) << round(t);
+ ss << setprecision(1) << round(t);
else
else
- ss << s
td::s
etprecision(precision) << t;
+ ss << setprecision(precision) << t;
- st
d::st
ring str(ss.str());
+ string str(ss.str());
if (0 == precision) {
// remove the separator and the unwanted decimal place
str.resize(str.size() - 2);
if (0 == precision) {
// remove the separator and the unwanted decimal place
str.resize(str.size() - 2);
@@
-102,12
+110,8
@@
static QTextStream& operator<<(QTextStream& stream, const Timestamp& t)
return stream << QString::fromStdString(str);
}
return stream << QString::fromStdString(str);
}
-QString format_time_si(
- const Timestamp& v,
- SIPrefix prefix,
- unsigned int precision,
- QString unit,
- bool sign)
+QString format_time_si(const Timestamp& v, SIPrefix prefix,
+ unsigned int precision, QString unit, bool sign)
{
if (prefix == SIPrefix::unspecified) {
// No prefix given, calculate it
{
if (prefix == SIPrefix::unspecified) {
// No prefix given, calculate it
@@
-134,22
+138,14
@@
QString format_time_si(
QTextStream ts(&s);
if (sign && !v.is_zero())
ts << forcesign;
QTextStream ts(&s);
if (sign && !v.is_zero())
ts << forcesign;
- ts
- << qSetRealNumberPrecision(precision)
- << (v * multiplier)
- << ' '
- << prefix
- << unit;
+ ts << qSetRealNumberPrecision(precision) << (v * multiplier) << ' '
+ << prefix << unit;
return s;
}
return s;
}
-QString format_time_si_adjusted(
- const Timestamp& t,
- SIPrefix prefix,
- unsigned precision,
- QString unit,
- bool sign)
+QString format_time_si_adjusted(const Timestamp& t, SIPrefix prefix,
+ unsigned precision, QString unit, bool sign)
{
// The precision is always given without taking the prefix into account
// so we need to deduct the number of decimals the prefix might imply
{
// The precision is always given without taking the prefix into account
// so we need to deduct the number of decimals the prefix might imply
@@
-157,12
+153,11
@@
QString format_time_si_adjusted(
const unsigned int relative_prec =
(prefix >= SIPrefix::none) ? precision :
const unsigned int relative_prec =
(prefix >= SIPrefix::none) ? precision :
-
std::
max((int)(precision - prefix_order), 0);
+ max((int)(precision - prefix_order), 0);
return format_time_si(t, prefix, relative_prec, unit, sign);
}
return format_time_si(t, prefix, relative_prec, unit, sign);
}
-
// Helper for 'format_time_minutes()'.
static QString pad_number(unsigned int number, int length)
{
// Helper for 'format_time_minutes()'.
static QString pad_number(unsigned int number, int length)
{
@@
-212,13
+207,9
@@
QString format_time_minutes(const Timestamp& t, signed precision, bool sign)
const Timestamp fraction = fabs(t) - whole_seconds;
const Timestamp fraction = fabs(t) - whole_seconds;
- std::ostringstream ss;
- ss
- << std::fixed
- << std::setprecision(precision)
- << std::setfill('0')
- << fraction;
- std::string fs = ss.str();
+ ostringstream ss;
+ ss << fixed << setprecision(precision) << setfill('0') << fraction;
+ string fs = ss.str();
// Copy all digits, inserting spaces as unit separators
for (int i = 1; i <= precision; i++) {
// Copy all digits, inserting spaces as unit separators
for (int i = 1; i <= precision; i++) {