From 0107901be95c3f5e7c80bfc6f7fcb82f2842a8d8 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Wed, 17 Mar 2021 00:09:02 +0000 Subject: [PATCH] Replace deprecated QString member functions --- widgets/plotter.cpp | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/widgets/plotter.cpp b/widgets/plotter.cpp index 3b8daa9cd..8c2e96138 100644 --- a/widgets/plotter.cpp +++ b/widgets/plotter.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "qt_helpers.hpp" #include "commons.h" #include "moc_plotter.cpp" #include @@ -247,23 +248,14 @@ void CPlotter::draw(float swide[], bool bScroll, bool bRed) painter1.setPen(Qt::white); QString t; if(m_nUTC<0) { - qint64 ms = QDateTime::currentMSecsSinceEpoch() % 86400000; - int n = fmod(0.001*ms,m_TRperiod); - QDateTime t1=QDateTime::currentDateTimeUtc().addSecs(-n); - if(m_TRperiod<60.0) { - t=t1.toString("hh:mm:ss") + " " + m_rxBand; - } else { - t=t1.toString("hh:mm") + " " + m_rxBand; - } + auto start = qt_truncate_date_time_to (QDateTime::currentDateTimeUtc(), m_TRperiod * 1e3) + .toString (m_TRperiod < 60. ? "hh:mm:ss" : "hh:mm"); + t = QString {"%1 %2"}.arg (start, m_rxBand); } else { - int ih=m_nUTC/10000; - int im=(m_nUTC - 10000*ih)/100; - int is=m_nUTC%100; - if(m_TRperiod<60) { - t.sprintf("%02d:%02d:%02d",ih,im,is) + " " + m_rxBand; - } else { - t.sprintf("%02d:%02d",ih,im) + " " + m_rxBand; - } + auto hr = m_nUTC / 10000; + auto start = QTime {hr, (m_nUTC - 10000 * hr) / 100, m_nUTC % 100} + .toString (m_TRperiod < 60. ? "hh:mm:ss" : "hh:mm"); + t = QString {"%1 %2"}.arg (start).arg (m_rxBand); } painter1.drawText (5, painter1.fontMetrics ().ascent (), t); }