From 427d17351d990859392baed5c1d5bf280ddeccd5 Mon Sep 17 00:00:00 2001 From: Jon Beniston Date: Mon, 21 Oct 2024 17:08:41 +0100 Subject: [PATCH] Remove use of obsolete QRegExp --- .../channelrx/demodpager/pagerdemodgui.cpp | 8 ++-- plugins/feature/pertester/pertesterworker.cpp | 43 ++++++++++--------- .../feature/satellitetracker/CMakeLists.txt | 3 -- sdrbase/CMakeLists.txt | 1 - sdrbase/dsp/wavfilerecord.cpp | 34 ++++++++------- 5 files changed, 45 insertions(+), 44 deletions(-) diff --git a/plugins/channelrx/demodpager/pagerdemodgui.cpp b/plugins/channelrx/demodpager/pagerdemodgui.cpp index 7d05b1a28..a561c3776 100644 --- a/plugins/channelrx/demodpager/pagerdemodgui.cpp +++ b/plugins/channelrx/demodpager/pagerdemodgui.cpp @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include @@ -433,15 +433,15 @@ void PagerDemodGUI::filterRow(int row) bool hidden = false; if (m_settings.m_filterAddress != "") { - QRegExp re(m_settings.m_filterAddress); + QRegularExpression re(QRegularExpression::anchoredPattern(m_settings.m_filterAddress)); QTableWidgetItem *fromItem = ui->messages->item(row, PagerDemodSettings::MESSAGE_COL_ADDRESS); - if (!re.exactMatch(fromItem->text())) { + QRegularExpressionMatch match = re.match(fromItem->text()); + if (!match.hasMatch()) { hidden = true; } } ui->messages->setRowHidden(row, hidden); } - void PagerDemodGUI::filter() { for (int i = 0; i < ui->messages->rowCount(); i++) { diff --git a/plugins/feature/pertester/pertesterworker.cpp b/plugins/feature/pertester/pertesterworker.cpp index 96319f8e5..72e3d8568 100644 --- a/plugins/feature/pertester/pertesterworker.cpp +++ b/plugins/feature/pertester/pertesterworker.cpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include "util/ax25.h" @@ -205,11 +205,12 @@ void PERTesterWorker::rx() void PERTesterWorker::tx() { - QRegExp ax25Dst("^%\\{ax25\\.dst=([A-Za-z0-9-]+)\\}"); - QRegExp ax25Src("^%\\{ax25\\.src=([A-Za-z0-9-]+)\\}"); - QRegExp num("^%\\{num\\}"); - QRegExp data("^%\\{data=([0-9]+),([0-9]+)\\}"); - QRegExp hex("^(0x)?([0-9a-fA-F]?[0-9a-fA-F])"); + QRegularExpression ax25Dst("^%\\{ax25\\.dst=([A-Za-z0-9-]+)\\}"); + QRegularExpression ax25Src("^%\\{ax25\\.src=([A-Za-z0-9-]+)\\}"); + QRegularExpression num("^%\\{num\\}"); + QRegularExpression data("^%\\{data=([0-9]+),([0-9]+)\\}"); + QRegularExpression hex("^(0x)?([0-9a-fA-F]?[0-9a-fA-F])"); + QRegularExpressionMatch match; QByteArray bytes; int pos = 0; @@ -217,34 +218,34 @@ void PERTesterWorker::tx() { if (m_settings.m_packet[pos] == '%') { - if (ax25Dst.indexIn(m_settings.m_packet, pos, QRegExp::CaretAtOffset) != -1) + if ((match = ax25Dst.match(m_settings.m_packet, pos, QRegularExpression::NormalMatch, QRegularExpression::AnchoredMatchOption)).hasMatch()) { // AX.25 destination callsign & SSID - QString address = ax25Dst.capturedTexts()[1]; + QString address = match.captured(1); bytes.append(AX25Packet::encodeAddress(address)); - pos += ax25Dst.matchedLength(); + pos += match.capturedLength(); } - else if (ax25Src.indexIn(m_settings.m_packet, pos, QRegExp::CaretAtOffset) != -1) + else if ((match = ax25Src.match(m_settings.m_packet, pos, QRegularExpression::NormalMatch, QRegularExpression::AnchoredMatchOption)).hasMatch()) { // AX.25 source callsign & SSID - QString address = ax25Src.capturedTexts()[1]; + QString address = match.captured(1); bytes.append(AX25Packet::encodeAddress(address, 1)); - pos += ax25Src.matchedLength(); + pos += match.capturedLength(); } - else if (num.indexIn(m_settings.m_packet, pos, QRegExp::CaretAtOffset) != -1) + else if ((match = num.match(m_settings.m_packet, pos, QRegularExpression::NormalMatch, QRegularExpression::AnchoredMatchOption)).hasMatch()) { // Big endian packet number bytes.append((m_tx >> 24) & 0xff); bytes.append((m_tx >> 16) & 0xff); bytes.append((m_tx >> 8) & 0xff); bytes.append(m_tx & 0xff); - pos += num.matchedLength(); + pos += match.capturedLength(); } - else if (data.indexIn(m_settings.m_packet, pos, QRegExp::CaretAtOffset) != -1) + else if ((match = data.match(m_settings.m_packet, pos, QRegularExpression::NormalMatch, QRegularExpression::AnchoredMatchOption)).hasMatch()) { // Constrained random number of random bytes - int minBytes = data.capturedTexts()[1].toInt(); - int maxBytes = data.capturedTexts()[2].toInt(); + int minBytes = match.captured(1).toInt(); + int maxBytes = match.captured(2).toInt(); std::random_device rd; std::mt19937 gen(rd()); std::uniform_int_distribution<> distr0(minBytes, maxBytes); @@ -252,7 +253,7 @@ void PERTesterWorker::tx() int count = distr0(gen); for (int i = 0; i < count; i++) bytes.append(distr1(gen)); - pos += data.matchedLength(); + pos += match.capturedLength(); } else { @@ -278,12 +279,12 @@ void PERTesterWorker::tx() break; } } - else if (hex.indexIn(m_settings.m_packet, pos, QRegExp::CaretAtOffset) != -1) + else if ((match = hex.match(m_settings.m_packet, pos, QRegularExpression::NormalMatch, QRegularExpression::AnchoredMatchOption)).hasMatch()) { // Hex byte - int value = hex.capturedTexts()[2].toInt(nullptr, 16); + int value = match.captured(2).toInt(nullptr, 16); bytes.append(value); - pos += hex.matchedLength(); + pos += match.capturedLength(); } else if ((m_settings.m_packet[pos] == ' ') || (m_settings.m_packet[pos] == ',') || (m_settings.m_packet[pos] == ':')) { diff --git a/plugins/feature/satellitetracker/CMakeLists.txt b/plugins/feature/satellitetracker/CMakeLists.txt index 2c78453d8..aeb81e92e 100644 --- a/plugins/feature/satellitetracker/CMakeLists.txt +++ b/plugins/feature/satellitetracker/CMakeLists.txt @@ -82,9 +82,6 @@ target_link_libraries(${TARGET_NAME} PRIVATE ${TARGET_LIB_GUI} ${SGP4_LIBRARIES} ) -if (Qt6_FOUND) - target_link_libraries(${TARGET_NAME} PRIVATE Qt::Core5Compat) -endif() install(TARGETS ${TARGET_NAME} DESTINATION ${INSTALL_FOLDER}) diff --git a/sdrbase/CMakeLists.txt b/sdrbase/CMakeLists.txt index bc66651f6..3748c3a89 100644 --- a/sdrbase/CMakeLists.txt +++ b/sdrbase/CMakeLists.txt @@ -702,7 +702,6 @@ if (LIBSIGMF_FOUND) endif() if (Qt6_FOUND) target_link_libraries(sdrbase - Qt::Core5Compat Qt::CorePrivate ) endif() diff --git a/sdrbase/dsp/wavfilerecord.cpp b/sdrbase/dsp/wavfilerecord.cpp index 18e2f8b12..b201f2c77 100644 --- a/sdrbase/dsp/wavfilerecord.cpp +++ b/sdrbase/dsp/wavfilerecord.cpp @@ -22,7 +22,7 @@ #include #include -#include +#include #include "dsp/dspcommands.h" #include "util/message.h" @@ -472,16 +472,19 @@ void WavFileRecord::writeHeader(QFile& sampleFile, Header& header) bool WavFileRecord::getCenterFrequency(QString fileName, quint64& centerFrequency) { // Attempt to extract center frequency from filename - QRegExp freqkRE("(([0-9]+)kHz)"); - QRegExp freqRE("(([0-9]+)Hz)"); - if (freqkRE.indexIn(fileName)) + QRegularExpression freqkRE("(([0-9]+)kHz)"); + QRegularExpression freqRE("(([0-9]+)Hz)"); + QRegularExpressionMatch freqkREMatch = freqkRE.match(fileName); + QRegularExpressionMatch freqREMatch = freqRE.match(fileName); + + if (freqkREMatch.hasMatch()) { - centerFrequency = freqkRE.capturedTexts()[2].toLongLong() * 1000LL; + centerFrequency = freqkREMatch.capturedTexts()[2].toLongLong() * 1000LL; return true; } - else if (freqRE.indexIn(fileName)) + else if (freqREMatch.hasMatch()) { - centerFrequency = freqRE.capturedTexts()[2].toLongLong(); + centerFrequency = freqREMatch.capturedTexts()[2].toLongLong(); return true; } return false; @@ -490,17 +493,18 @@ bool WavFileRecord::getCenterFrequency(QString fileName, quint64& centerFrequenc bool WavFileRecord::getStartTime(QString fileName, QDateTime& startTime) { // Attempt to extract start time from filename - QRegExp dateTimeRE("([12][0-9][0-9][0-9]).?([01][0-9]).?([0-3][0-9]).?([0-2][0-9]).?([0-5][0-9]).?([0-5][0-9])"); - if (dateTimeRE.indexIn(fileName) != -1) + QRegularExpression dateTimeRE("([12][0-9][0-9][0-9]).?([01][0-9]).?([0-3][0-9]).?([0-2][0-9]).?([0-5][0-9]).?([0-5][0-9])"); + QRegularExpressionMatch match = dateTimeRE.match(fileName); + if (match.hasMatch()) { startTime = QDateTime(QDate( - dateTimeRE.capturedTexts()[1].toInt(), - dateTimeRE.capturedTexts()[2].toInt(), - dateTimeRE.capturedTexts()[3].toInt()), + match.capturedTexts()[1].toInt(), + match.capturedTexts()[2].toInt(), + match.capturedTexts()[3].toInt()), QTime( - dateTimeRE.capturedTexts()[4].toInt(), - dateTimeRE.capturedTexts()[5].toInt(), - dateTimeRE.capturedTexts()[6].toInt())); + match.capturedTexts()[4].toInt(), + match.capturedTexts()[5].toInt(), + match.capturedTexts()[6].toInt())); return true; } return false;