diff --git a/DSView/pv/data/decode/annotation.cpp b/DSView/pv/data/decode/annotation.cpp index ee7e2cc7..50741629 100755 --- a/DSView/pv/data/decode/annotation.cpp +++ b/DSView/pv/data/decode/annotation.cpp @@ -147,7 +147,7 @@ const std::vector& Annotation::annotations() const char sz_format_tmp_buf[50] = {0}; QString src = rd_src.replace("{$}", "%s"); const char *num_str = _status->m_resTable.format_numberic(resItem.str_number_hex, resItem.cur_display_format); - sprintf(sz_format_tmp_buf, src.toLatin1().data(), num_str); + sprintf(sz_format_tmp_buf, src.toUtf8().data(), num_str); resItem.cvt_lines.push_back(QString(sz_format_tmp_buf)); } } diff --git a/DSView/pv/data/decoderstack.cpp b/DSView/pv/data/decoderstack.cpp index e68b111a..6c049109 100755 --- a/DSView/pv/data/decoderstack.cpp +++ b/DSView/pv/data/decoderstack.cpp @@ -344,11 +344,6 @@ bool DecoderStack::list_row_title(int row, QString &title) return 0; } -QString DecoderStack::error_message() -{ - return _error_message; -} - void DecoderStack::clear() { init(); diff --git a/DSView/pv/data/decoderstack.h b/DSView/pv/data/decoderstack.h index fab50833..a1465ac2 100755 --- a/DSView/pv/data/decoderstack.h +++ b/DSView/pv/data/decoderstack.h @@ -126,7 +126,7 @@ public: bool list_row_title(int row, QString &title); - QString error_message(); + void clear(); void init(); uint64_t get_max_sample_count(); @@ -149,6 +149,10 @@ public: int64_t get_mark_index(); void frame_ended(); + inline QString error_message(){ + return _error_message; + } + private: void decode_data(const uint64_t decode_start, const uint64_t decode_end, srd_session *const session); void decode_proc(); diff --git a/DSView/pv/dock/protocoldock.cpp b/DSView/pv/dock/protocoldock.cpp index 2be0a286..80d1fed0 100755 --- a/DSView/pv/dock/protocoldock.cpp +++ b/DSView/pv/dock/protocoldock.cpp @@ -124,7 +124,7 @@ ProtocolDock::ProtocolDock(QWidget *parent, view::View &view, SigSession *sessio if (repeatNammes != ""){ QString err = "Any protocol have repeated id or name: "; err += repeatNammes; - MsgBox::Show("error", err.toLatin1().data()); + MsgBox::Show("error", err.toUtf8().data()); } hori_layout->addWidget(_add_button); diff --git a/DSView/pv/view/ruler.cpp b/DSView/pv/view/ruler.cpp index 716a5be3..4d75bd65 100755 --- a/DSView/pv/view/ruler.cpp +++ b/DSView/pv/view/ruler.cpp @@ -36,7 +36,6 @@ #include #include -#include #include @@ -96,21 +95,22 @@ QString Ruler::format_freq(double period, unsigned precision) const int prefix = ceil((order - FirstSIPrefixPower) / 3.0f); const double multiplier = pow(10.0, max(-prefix * 3.0 - FirstSIPrefixPower, 0.0)); + /* QString s; QTextStream ts(&s); ts.setRealNumberPrecision(precision); ts << fixed << 1 / (period * multiplier) << FreqPrefixes[prefix] << "Hz"; return s; - - /* - char buf[20] = {0}; - char format[10] = {0}; - sprintf(format, "%%.%df%%s", precision); - QString prev = FreqPrefixes[prefix] + "Hz"; - sprintf(buf, format, 1 / (period * multiplier), prev.toLatin1().data()); - return QString(buf); */ + + char buffer[20] = {0}; + char format[10] = {0}; + QString units = FreqPrefixes[prefix] + "Hz"; + sprintf(format, "%%.%df", (int)precision); + sprintf(buffer, format, 1 / (period * multiplier)); + strcat(buffer, units.toUtf8().data()); + return QString(buffer); } } @@ -119,21 +119,24 @@ QString Ruler::format_time(double t, int prefix, { const double multiplier = pow(10.0, -prefix * 3 - FirstSIPrefixPower + 6.0); + /* QString s; QTextStream ts(&s); ts.setRealNumberPrecision(precision); ts << fixed << forcesign << (t * multiplier) / 1000000.0 << SIPrefixes[prefix] << "s"; return s; - - /* - char buf[20] = {0}; - char format[10] = {0}; - sprintf(format, "%%.%df%%s", precision); - QString prev = SIPrefixes[prefix] + "s"; - sprintf(buf, format, (t * multiplier) / 1000000.0, prev.toLatin1().data()); - return QString(buf); */ + + char buffer[20] = {0}; + char format[10] = {0}; + QString units = SIPrefixes[prefix] + "s"; + double v = (t * multiplier) / 1000000.0; + buffer[0] = v >= 0 ? '+' : '-'; + sprintf(format, "%%.%df", (int)precision); + sprintf(buffer + 1, format, v); + strcat(buffer + 1, units.toUtf8().data()); + return QString(buffer); } QString Ruler::format_time(double t) diff --git a/DSView/pv/view/spectrumtrace.cpp b/DSView/pv/view/spectrumtrace.cpp index 12f8469f..fde8564f 100755 --- a/DSView/pv/view/spectrumtrace.cpp +++ b/DSView/pv/view/spectrumtrace.cpp @@ -210,20 +210,21 @@ QString SpectrumTrace::format_freq(double freq, unsigned precision) const int prefix = floor((order - FirstSIPrefixPower)/ 3.0f); const double divider = pow(10.0, max(prefix * 3.0 + FirstSIPrefixPower, 0.0)); + /* QString s; QTextStream ts(&s); ts.setRealNumberPrecision(precision); ts << fixed << freq / divider << FreqPrefixes[prefix] << "Hz"; return s; + */ - /* - char buf[20] = {0}; + char buffer[20] = {0}; char format[10] = {0}; - sprintf(format, "%%.%df%%s", precision); - QString prev = FreqPrefixes[prefix] + "Hz"; - sprintf(buf, format, freq / divider, prev.toLatin1().data()); - return QString(buf); - */ + QString units = FreqPrefixes[prefix] + "Hz"; + sprintf(format, "%%.%df", (int)precision); + sprintf(buffer, format, freq / divider); + strcat(buffer, units.toUtf8().data()); + return QString(buffer); } }