Updates for Qt v5.14 compaibility

This commit is contained in:
Bill Somerville 2020-05-07 02:56:57 +01:00
parent eb7681c7c5
commit 1403c186d2
No known key found for this signature in database
GPG Key ID: D864B06D1E81618F
8 changed files with 77 additions and 45 deletions

View File

@ -187,7 +187,7 @@ QString DecodedText::report() const // returns a string of the SNR field with a
sr = 49;
QString rpt;
rpt.sprintf("%d",abs(sr));
rpt = rpt.asprintf("%d",abs(sr));
if (sr > 9)
rpt = "+" + rpt;
else

View File

@ -35,7 +35,7 @@ namespace
{
QString message;
static char constexpr fmt[] = "Hamlib: %s";
message = message.vsprintf (format, ap).trimmed ();
message = message.vasprintf (format, ap).trimmed ();
switch (level)
{

View File

@ -274,10 +274,10 @@ WSPRBandHopping::WSPRBandHopping (QSettings * settings, Configuration const * co
: m_ {settings, configuration, parent_widget}
{
// detect changes to the working frequencies model
m_->WSPR_bands_ = m_->configuration_->frequencies ()->all_bands (m_->configuration_->region (), Modes::WSPR).toList ();
m_->WSPR_bands_ = m_->configuration_->frequencies ()->all_bands (m_->configuration_->region (), Modes::WSPR).values ();
connect (m_->configuration_->frequencies (), &QAbstractItemModel::layoutChanged
, [this] () {
m_->WSPR_bands_ = m_->configuration_->frequencies ()->all_bands (m_->configuration_->region (), Modes::WSPR).toList ();
m_->WSPR_bands_ = m_->configuration_->frequencies ()->all_bands (m_->configuration_->region (), Modes::WSPR).values ();
});
// load settings
@ -379,7 +379,11 @@ auto WSPRBandHopping::next_hop (bool tx_enabled) -> Hop
if (frequencies_index < 0)
{
// build sets of available rx and tx bands
#if QT_VERSION < QT_VERSION_CHECK (5, 14, 0)
auto target_rx_bands = m_->WSPR_bands_.toSet ();
#else
QSet<QString> target_rx_bands {m_->WSPR_bands_.begin (), m_->WSPR_bands_.end ()};
#endif
auto target_tx_bands = target_rx_bands;
for (auto i = 0; i < m_->bands_[period_index].size (); ++i)
{
@ -403,16 +407,23 @@ auto WSPRBandHopping::next_hop (bool tx_enabled) -> Hop
// if we have some bands to permute
if (target_rx_bands.size () + target_tx_bands.size ())
{
#if QT_VERSION < QT_VERSION_CHECK (5, 14, 0)
auto rx_permutations = m_->rx_permutation_.toSet ();
auto tx_permutations = m_->tx_permutation_.toSet ();
#else
QSet<QString> rx_permutations {m_->rx_permutation_.begin (), m_->rx_permutation_.end ()};
QSet<QString> tx_permutations {m_->tx_permutation_.begin (), m_->tx_permutation_.end ()};
#endif
if (!(m_->rx_permutation_.size () + m_->tx_permutation_.size ()) // all used up
// or rx list contains a band no longer scheduled
|| !target_rx_bands.contains (m_->rx_permutation_.toSet ())
|| !target_rx_bands.contains (rx_permutations)
// or tx list contains a band no longer scheduled for tx
|| !target_tx_bands.contains (m_->tx_permutation_.toSet ()))
|| !target_tx_bands.contains (tx_permutations))
{
// build new random permutations
m_->rx_permutation_ = target_rx_bands.toList ();
m_->rx_permutation_ = target_rx_bands.values ();
std::random_shuffle (std::begin (m_->rx_permutation_), std::end (m_->rx_permutation_));
m_->tx_permutation_ = target_tx_bands.toList ();
m_->tx_permutation_ = target_tx_bands.values ();
std::random_shuffle (std::begin (m_->tx_permutation_), std::end (m_->tx_permutation_));
// qDebug () << "New random Rx permutation:" << m_->rx_permutation_
// << "random Tx permutation:" << m_->tx_permutation_;

View File

@ -212,7 +212,7 @@ int ptt(int nport, int ntx, int* iptt, int* nopen)
FILE_ATTRIBUTE_NORMAL,NULL);
if(hFile==INVALID_HANDLE_VALUE) {
QString t;
t.sprintf("Cannot open COM port %d for PTT\n",nport);
t = t.asprintf("Cannot open COM port %d for PTT\n",nport);
return 1;
}
*nopen=1;

View File

@ -463,7 +463,7 @@ void DisplayText::displayTransmittedText(QString text, QString modeTx, qint32 tx
if(modeTx=="JT65") t1=" # ";
if(modeTx=="MSK144") t1=" & ";
QString t2;
t2.sprintf("%4d",txFreq);
t2 = t2.asprintf("%4d",txFreq);
QString t;
if(bFastMode or modeTx=="FT8" or modeTx=="FT4") {
t = QDateTime::currentDateTimeUtc().toString("hhmmss") + \

View File

@ -155,7 +155,7 @@ void FPlotter::draw() //draw()
int ih=m_UTCdisk/10000;
int im=m_UTCdisk/100 % 100;
int is=m_UTCdisk % 100;
m_t.sprintf("%2.2d:%2.2d:%2.2d",ih,im,is);
m_t = m_t.asprintf("%2.2d:%2.2d:%2.2d",ih,im,is);
}
int k0=m_jh0;
@ -168,7 +168,7 @@ void FPlotter::draw() //draw()
int ih=m_UTCdisk/10000;
int im=m_UTCdisk/100 % 100;
int is=m_UTCdisk % 100;
m_t.sprintf("%2.2d:%2.2d:%2.2d",ih,im,is);
m_t = m_t.asprintf("%2.2d:%2.2d:%2.2d",ih,im,is);
} else {
m_t=QDateTime::currentDateTimeUtc().toString("hh:mm:ss");
}
@ -243,7 +243,7 @@ void FPlotter::mouseMoveEvent(QMouseEvent *event)
// int y=event->y();
float t=x/m_pixPerSecond;
QString t1;
t1.sprintf("%5.2f",t);
t1 = t1.asprintf("%5.2f",t);
QRectF rect0(78,85,40,13); //### Should use font metrics ###
painter.fillRect(rect0,Qt::black);
painter.setPen(Qt::yellow);

View File

@ -649,29 +649,50 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
setWindowTitle (program_title ());
connect(&proc_jt9, &QProcess::readyReadStandardOutput, this, &MainWindow::readFromStdout);
#if QT_VERSION < QT_VERSION_CHECK (5, 6, 0)
connect(&proc_jt9, static_cast<void (QProcess::*) (QProcess::ProcessError)> (&QProcess::error),
[this] (QProcess::ProcessError error) {
subProcessError (&proc_jt9, error);
});
#else
connect(&proc_jt9, static_cast<void (QProcess::*) (QProcess::ProcessError)> (&QProcess::errorOccurred),
[this] (QProcess::ProcessError error) {
subProcessError (&proc_jt9, error);
});
#endif
connect(&proc_jt9, static_cast<void (QProcess::*) (int, QProcess::ExitStatus)> (&QProcess::finished),
[this] (int exitCode, QProcess::ExitStatus status) {
subProcessFailed (&proc_jt9, exitCode, status);
});
connect(&p1, &QProcess::readyReadStandardOutput, this, &MainWindow::p1ReadFromStdout);
#if QT_VERSION < QT_VERSION_CHECK (5, 6, 0)
connect(&p1, static_cast<void (QProcess::*) (QProcess::ProcessError)> (&QProcess::error),
[this] (QProcess::ProcessError error) {
subProcessError (&p1, error);
});
#else
connect(&p1, static_cast<void (QProcess::*) (QProcess::ProcessError)> (&QProcess::errorOccurred),
[this] (QProcess::ProcessError error) {
subProcessError (&p1, error);
});
#endif
connect(&p1, static_cast<void (QProcess::*) (int, QProcess::ExitStatus)> (&QProcess::finished),
[this] (int exitCode, QProcess::ExitStatus status) {
subProcessFailed (&p1, exitCode, status);
});
#if QT_VERSION < QT_VERSION_CHECK (5, 6, 0)
connect(&p3, static_cast<void (QProcess::*) (QProcess::ProcessError)> (&QProcess::error),
[this] (QProcess::ProcessError error) {
subProcessError (&p3, error);
});
#else
connect(&p3, static_cast<void (QProcess::*) (QProcess::ProcessError)> (&QProcess::errorOccurred),
[this] (QProcess::ProcessError error) {
subProcessError (&p3, error);
});
#endif
connect(&p3, static_cast<void (QProcess::*) (int, QProcess::ExitStatus)> (&QProcess::finished),
[this] (int exitCode, QProcess::ExitStatus status) {
subProcessFailed (&p3, exitCode, status);
@ -795,7 +816,7 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
float dbm=(10.0*i)/3.0;
int ndbm=int(dbm+0.5);
QString t;
t.sprintf("%d dBm ",ndbm);
t = t.asprintf("%d dBm ",ndbm);
t+=t1[i];
ui->TxPowerComboBox->addItem(t);
}
@ -1435,7 +1456,7 @@ void MainWindow::dataSink(qint64 frames)
avecho_(dec_data.d2,&nDop,&nfrit,&nqual,&f1,&xlevel,&sigdb,
&snr,&dfreq,&width);
QString t;
t.sprintf("%3d %7.1f %7.1f %7.1f %7.1f %3d",echocom_.nsum,xlevel,sigdb,
t = t.asprintf("%3d %7.1f %7.1f %7.1f %7.1f %3d",echocom_.nsum,xlevel,sigdb,
dfreq,width,nqual);
t=QDateTime::currentDateTimeUtc().toString("hh:mm:ss ") + t;
if (ui) ui->decodedTextBrowser->appendText(t);
@ -1498,12 +1519,12 @@ void MainWindow::dataSink(qint64 frames)
if(m_mode.startsWith ("WSPR")) {
QString t2,cmnd,depth_string;
double f0m1500=m_dialFreqRxWSPR/1000000.0; // + 0.000001*(m_BFO - 1500);
t2.sprintf(" -f %.6f ",f0m1500);
t2 = t2.asprintf(" -f %.6f ",f0m1500);
if((m_ndepth&7)==1) depth_string=" -qB "; //2 pass w subtract, no Block detection, no shift jittering
if((m_ndepth&7)==2) depth_string=" -C 500 -o 4 "; //3 pass, subtract, Block detection, OSD
if((m_ndepth&7)==3) depth_string=" -C 500 -o 4 -d "; //3 pass, subtract, Block detect, OSD, more candidates
QString degrade;
degrade.sprintf("-d %4.1f ",m_config.degrade());
degrade = degrade.asprintf("-d %4.1f ",m_config.degrade());
if(m_diskData) {
cmnd='"' + m_appDir + '"' + "/wsprd " + depth_string + " -a \"" +
@ -1631,7 +1652,7 @@ void MainWindow::fastSink(qint64 frames)
&ddir[0],fast_green,fast_s,&fast_jh,&pxmax,&rmsNoGain,&line[0],12,12,512,80);
float px = fast_green[fast_jh];
QString t;
t.sprintf(" Rx noise: %5.1f ",px);
t = t.asprintf(" Rx noise: %5.1f ",px);
ui->signal_meter_widget->setValue(rmsNoGain,pxmax); // Update thermometer
m_fastGraph->plotSpec(m_diskData,m_UTCdisk);
@ -3014,8 +3035,8 @@ void MainWindow::decode() //decode()
double tseq = fmod(double(now.toMSecsSinceEpoch()),1000.0*m_TRperiod)/1000.0;
if(tseq < 0.5*m_TRperiod) tseq+= m_TRperiod;
if(m_ihsym==m_earlyDecode) qDebug() << "";
QString t="";
t.sprintf("aa release_jt9 %11.3f %5d %5d %7.3f ",tsec,m_ihsym,m_ihsym,tseq);
QString t;
t = t.asprintf("aa release_jt9 %11.3f %5d %5d %7.3f ",tsec,m_ihsym,m_ihsym,tseq);
qDebug().noquote() << t << QDateTime::currentDateTimeUtc().toString("hh:mm:ss.zzz");
*/
@ -3712,7 +3733,7 @@ void MainWindow::guiUpdate()
if(m_mode.startsWith ("WSPR")) {
QString sdBm,msg0,msg1,msg2;
sdBm.sprintf(" %d",m_dBm);
sdBm = sdBm.asprintf(" %d",m_dBm);
m_tx=1-m_tx;
int i2=m_config.my_callsign().indexOf("/");
if(i2>0
@ -4056,7 +4077,7 @@ void MainWindow::guiUpdate()
int isec=int(fmod(tsec,m_TRperiod));
if(m_TRperiod-int(m_TRperiod)>0.0) {
QString progBarLabel;
progBarLabel.sprintf("%d/%3.1f",isec,m_TRperiod);
progBarLabel = progBarLabel.asprintf("%d/%3.1f",isec,m_TRperiod);
progressBar.setFormat (progBarLabel);
}
progressBar.setValue(isec);
@ -4106,7 +4127,7 @@ void MainWindow::guiUpdate()
if(m_mode=="MSK144") {
int npct=int(100.0*m_fCPUmskrtd/0.298667);
if(npct>90) tx_status_label.setStyleSheet("QLabel{background-color: #ff0000}");
t.sprintf("Receiving %2d%%",npct);
t = t.asprintf("Receiving %2d%%",npct);
}
tx_status_label.setText (t);
}
@ -5092,7 +5113,7 @@ void MainWindow::genStdMsgs(QString rpt, bool unconditional)
msgtype("73", ui->tx5->lineEdit());
} else {
int n=rpt.toInt();
rpt.sprintf("%+2.2d",n);
rpt = rpt.asprintf("%+2.2d",n);
if(m_mode=="MSK144" or m_mode=="FT8" or m_mode=="FT4") {
QString t2,t3;
@ -5101,7 +5122,7 @@ void MainWindow::genStdMsgs(QString rpt, bool unconditional)
int nn=(n+36)/6;
if(nn<2) nn=2;
if(nn>9) nn=9;
rst.sprintf("5%1d9 ",nn);
rst = rst.asprintf("5%1d9 ",nn);
rs=rst.mid(0,2);
t=t0;
if(!bMyCall) {
@ -5119,14 +5140,14 @@ void MainWindow::genStdMsgs(QString rpt, bool unconditional)
sent=rst + m_config.RTTY_Exchange();
QString t1=m_config.RTTY_Exchange();
if(t1=="DX" or t1=="#") {
t1.sprintf("%4.4d",ui->sbSerialNumber->value());
t1 = t1.asprintf("%4.4d",ui->sbSerialNumber->value());
sent=rst + t1;
}
}
if(SpecOp::EU_VHF==m_config.special_op_id()) {
QString a;
t="<" + t0.split(" ").at(0) + "> <" + t0.split(" ").at(1) + "> ";
a.sprintf("%4.4d ",ui->sbSerialNumber->value());
a = a.asprintf("%4.4d ",ui->sbSerialNumber->value());
sent=rs + a + m_config.my_grid();
}
msgtype(t + sent, ui->tx2);
@ -5154,7 +5175,7 @@ void MainWindow::genStdMsgs(QString rpt, bool unconditional)
if(n>=8 and n<=11) n=10;
if(n>=12 and n<=14) n=13;
if(n>=15) n=16;
rpt.sprintf("%+2.2d",n);
rpt = rpt.asprintf("%+2.2d",n);
}
}
@ -5552,10 +5573,10 @@ void MainWindow::on_dxGridEntry_textChanged (QString const& grid)
int nd=nDkm;
if(m_config.miles()) nd=nDmiles;
if(m_mode=="MSK144") {
if(nHotABetter==0)t.sprintf("Az: %d B: %d El: %d %d",nAz,nHotAz,nEl,nd);
if(nHotABetter!=0)t.sprintf("Az: %d A: %d El: %d %d",nAz,nHotAz,nEl,nd);
if(nHotABetter==0)t = t.asprintf("Az: %d B: %d El: %d %d",nAz,nHotAz,nEl,nd);
if(nHotABetter!=0)t = t.asprintf("Az: %d A: %d El: %d %d",nAz,nHotAz,nEl,nd);
} else {
t.sprintf("Az: %d %d",nAz,nd);
t = t.asprintf("Az: %d %d",nAz,nd);
}
if(m_config.miles()) t += " mi";
if(!m_config.miles()) t += " km";
@ -7681,9 +7702,9 @@ void MainWindow::p1ReadFromStdout() //p1readFromStdout
&nAz,&nEl,&nDmiles,&nDkm,&nHotAz,&nHotABetter,6,6);
QString t1;
if(m_config.miles()) {
t1.sprintf("%7d",nDmiles);
t1 = t1.asprintf("%7d",nDmiles);
} else {
t1.sprintf("%7d",nDkm);
t1 = t1.asprintf("%7d",nDkm);
}
rxLine += t1;
}
@ -7706,7 +7727,7 @@ QString MainWindow::WSPR_hhmm(int n)
QDateTime t=QDateTime::currentDateTimeUtc().addSecs(n);
int m=t.toString("hhmm").toInt()/2;
QString t1;
t1.sprintf("%04d",2*m);
t1 = t1.asprintf("%04d",2*m);
return t1;
}
@ -7716,12 +7737,12 @@ void MainWindow::WSPR_history(Frequency dialFreq, int ndecodes)
QString t1=t.toString("yyMMdd");
QString t2=WSPR_hhmm(-60);
QString t3;
t3.sprintf("%13.6f",0.000001*dialFreq);
t3 = t3.asprintf("%13.6f",0.000001*dialFreq);
if(ndecodes<0) {
t1=t1 + " " + t2 + t3 + " T";
} else {
QString t4;
t4.sprintf("%4d",ndecodes);
t4 = t4.asprintf("%4d",ndecodes);
t1=t1 + " " + t2 + t3 + " R" + t4;
}
QFile f {m_config.writeable_data_dir ().absoluteFilePath ("WSPR_history.txt")};
@ -8192,7 +8213,7 @@ void MainWindow::on_sbNslots_valueChanged(int n)
{
m_Nslots=n;
QString t;
t.sprintf(" NSlots %d",m_Nslots);
t = t.asprintf(" NSlots %d",m_Nslots);
writeFoxQSO(t);
}
@ -8200,7 +8221,7 @@ void MainWindow::on_sbMax_dB_valueChanged(int n)
{
m_max_dB=n;
QString t;
t.sprintf(" Max_dB %d",m_max_dB);
t = t.asprintf(" Max_dB %d",m_max_dB);
writeFoxQSO(t);
}
@ -8690,7 +8711,7 @@ void MainWindow::foxGenWaveform(int i,QString fm)
if(fm.mid(0,3)=="CQ ") m_tFoxTxSinceCQ=-1;
QString txModeArg;
txModeArg.sprintf("FT8fox %d",i+1);
txModeArg = txModeArg.asprintf("FT8fox %d",i+1);
ui->decodedTextBrowser2->displayTransmittedText(fm.trimmed(), txModeArg,
ui->TxFreqSpinBox->value()+60*i,m_bFastMode);
foxcom_.i3bit[i]=0;
@ -8698,14 +8719,14 @@ void MainWindow::foxGenWaveform(int i,QString fm)
strncpy(&foxcom_.cmsg[i][0],fm.toLatin1(),40); //Copy this message into cmsg[i]
if(i==0) m_fm1=fm;
QString t;
t.sprintf(" Tx%d: ",i+1);
t = t.asprintf(" Tx%d: ",i+1);
writeFoxQSO(t + fm.trimmed());
}
void MainWindow::writeFoxQSO(QString const& msg)
{
QString t;
t.sprintf("%3d%3d%3d",m_houndQueue.count(),m_foxQSOinProgress.count(),m_foxQSO.count());
t = t.asprintf("%3d%3d%3d",m_houndQueue.count(),m_foxQSOinProgress.count(),m_foxQSO.count());
QFile f {m_config.writeable_data_dir ().absoluteFilePath ("FoxQSO.txt")};
if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) {
QTextStream out(&f);
@ -8781,7 +8802,7 @@ void MainWindow::foxTest()
if(line.contains("Tx1:")) {
foxTxSequencer();
} else {
t.sprintf("%3d %3d %3d %3d %5d ",m_houndQueue.count(),
t = t.asprintf("%3d %3d %3d %3d %5d ",m_houndQueue.count(),
m_foxQSOinProgress.count(),m_foxQSO.count(),
m_loggedByFox.count(),m_tFoxTx);
sdiag << t << line.mid(37).trimmed() << "\n";
@ -8812,7 +8833,7 @@ void MainWindow::write_all(QString txRx, QString message)
msg=msg.mid(0,15) + msg.mid(18,-1);
t.sprintf("%5d",ui->TxFreqSpinBox->value());
t = t.asprintf("%5d",ui->TxFreqSpinBox->value());
if (txRx=="Tx") msg=" 0 0.0" + t + " " + message;
auto time = QDateTime::currentDateTimeUtc ();
if( txRx=="Rx" ) {
@ -8822,7 +8843,7 @@ void MainWindow::write_all(QString txRx, QString message)
}
time = time.addSecs(-tdec);
}
t.sprintf("%10.3f ",m_freqNominal/1.e6);
t = t.asprintf("%10.3f ",m_freqNominal/1.e6);
if (m_diskData) {
if (m_fileDateTime.size()==11) {
line=m_fileDateTime + " " + t + txRx + " " + mode_string + msg;

View File

@ -102,6 +102,6 @@ void SignalMeter::setValue(float value, float valueMax)
m_meter->setValue(int(value));
m_meter->set_sigPeak(valueMax);
QString t;
t.sprintf("%d dB",int(value+0.5));
t = t.asprintf("%d dB",int(value+0.5));
m_reading->setText(t);
}