From 65d8a1592d28163f5217c80b529aaea01e2e1473 Mon Sep 17 00:00:00 2001 From: phfr83 Date: Mon, 26 Feb 2024 11:02:20 +0100 Subject: [PATCH] Remove_Deprecated_In_Qt5.15.x --- client/arpstatusmodel.cpp | 3 ++- client/devicegroupdialog.h | 2 +- client/devicemodel.cpp | 3 ++- client/dumpview.cpp | 2 +- client/main.cpp | 3 ++- client/mainwindow.cpp | 3 ++- client/ndpstatusmodel.cpp | 3 ++- client/portgroup.cpp | 2 +- client/portmodel.cpp | 2 +- client/portstatsfilterdialog.cpp | 6 ++++-- client/portstatsmodel.cpp | 2 +- client/portstatsproxymodel.h | 5 +++-- client/portstatswindow.cpp | 5 +++-- client/portswindow.cpp | 8 ++++---- client/streamconfigdialog.cpp | 8 ++++---- client/streamstatsfiltermodel.h | 2 +- client/streamstatswindow.cpp | 6 +++--- client/streamswidget.cpp | 4 ++-- common/abstractprotocol.cpp | 4 +++- common/abstractprotocol.h | 4 ++-- common/arp.cpp | 9 +++++---- common/comboprotocol.h | 2 +- common/emulation.h | 5 +++-- common/framevalueattrib.h | 3 ++- common/gmpconfig.cpp | 8 ++++---- common/ip4.cpp | 5 +++-- common/ip4.h | 2 +- common/ip4config.cpp | 4 ++-- common/ip6.cpp | 5 +++-- common/ip6.h | 2 +- common/iputils.h | 7 ++++--- common/ipv4addressvalidator.h | 2 +- common/ipv6addressvalidator.h | 4 ++-- common/llcpdml.cpp | 4 ++-- common/mac.cpp | 4 ++-- common/macaddressvalidator.h | 2 +- common/macedit.h | 10 +++++----- common/nativefileformat.cpp | 4 ++-- common/payload.cpp | 4 +++- common/stp.cpp | 4 ++-- common/stpconfig.cpp | 8 ++++---- common/streambase.cpp | 11 +++++++---- common/streambase.h | 1 - common/uint128.h | 2 +- common/userscript.h | 2 +- extra/modeltest/modeltest.cpp | 4 ++-- extra/modeltest/target_wrapper.sh | 6 ++++++ extra/modeltest/tst_modeltest.cpp | 2 +- extra/qhexedit2/src/qhexedit.cpp | 2 +- rpc/rpcconn.cpp | 4 +++- server/devicemanager.h | 2 +- server/linuxport.cpp | 4 ++-- server/portmanager.cpp | 15 +++++++++------ 53 files changed, 131 insertions(+), 99 deletions(-) create mode 100755 extra/modeltest/target_wrapper.sh diff --git a/client/arpstatusmodel.cpp b/client/arpstatusmodel.cpp index 6071644..776c077 100644 --- a/client/arpstatusmodel.cpp +++ b/client/arpstatusmodel.cpp @@ -24,6 +24,7 @@ along with this program. If not, see #include "emulproto.pb.h" #include +#include enum { kIp4Address, @@ -110,7 +111,7 @@ QVariant ArpStatusModel::data(const QModelIndex &index, int role) const switch (role) { case Qt::DisplayRole: return QString("%1").arg(arp.mac(), 6*2, 16, QChar('0')) - .replace(QRegExp("([0-9a-fA-F]{2}\\B)"), "\\1:") + .replace(QRegularExpression("([0-9a-fA-F]{2}\\B)"), "\\1:") .toUpper(); default: break; diff --git a/client/devicegroupdialog.h b/client/devicegroupdialog.h index 41f2358..65e1531 100644 --- a/client/devicegroupdialog.h +++ b/client/devicegroupdialog.h @@ -31,7 +31,7 @@ class DeviceGroupDialog: public QDialog, private Ui::DeviceGroupDialog Q_OBJECT public: DeviceGroupDialog(Port *port, int deviceGroupIndex, - QWidget *parent = NULL, Qt::WindowFlags flags = 0); + QWidget *parent = NULL, Qt::WindowFlags flags = Qt::WindowFlags()); virtual void accept(); private slots: diff --git a/client/devicemodel.cpp b/client/devicemodel.cpp index 0fb4bb2..174f1fc 100644 --- a/client/devicemodel.cpp +++ b/client/devicemodel.cpp @@ -30,6 +30,7 @@ along with this program. If not, see #include #include #include +#include > enum { kMacAddress, @@ -119,7 +120,7 @@ QVariant DeviceModel::data(const QModelIndex &index, int role) const switch (role) { case Qt::DisplayRole: return QString("%1").arg(dev->mac(), 6*2, 16, QChar('0')) - .replace(QRegExp("([0-9a-fA-F]{2}\\B)"), "\\1:") + .replace(QRegularExpression("([0-9a-fA-F]{2}\\B)"), "\\1:") .toUpper(); default: break; diff --git a/client/dumpview.cpp b/client/dumpview.cpp index 5dc5216..cf93729 100644 --- a/client/dumpview.cpp +++ b/client/dumpview.cpp @@ -31,7 +31,7 @@ DumpView::DumpView(QWidget *parent) // NOTE: Monospaced fonts only !!!!!!!!!!! setFont(QFont("Courier")); - w = fontMetrics().width('X'); + w = fontMetrics().horizontalAdvance("X"); h = fontMetrics().height(); mLineHeight = h; diff --git a/client/main.cpp b/client/main.cpp index d497e90..eaa2df7 100644 --- a/client/main.cpp +++ b/client/main.cpp @@ -31,6 +31,7 @@ along with this program. If not, see #include #include #include +#include #include @@ -87,7 +88,7 @@ int main(int argc, char* argv[]) ThemeManager::instance()->setTheme(appSettings->value(kThemeKey).toString()); - qsrand(QDateTime::currentDateTime().toTime_t()); +// qsrand(QDateTime::currentDateTime().toTime_t()); mainWindow = new MainWindow; mainWindow->show(); diff --git a/client/mainwindow.cpp b/client/mainwindow.cpp index 2daffdd..1509f43 100644 --- a/client/mainwindow.cpp +++ b/client/mainwindow.cpp @@ -49,6 +49,7 @@ along with this program. If not, see #include #include #include +#include #ifdef Q_OS_WIN32 #define WIN32_NO_STATUS @@ -326,7 +327,7 @@ _retry: goto _exit; if (QFileInfo(fileName).suffix().isEmpty()) { - QString fileExt = fileType.section(QRegExp("[\\*\\)]"), 1, 1); + QString fileExt = fileType.section(QRegularExpression("[\\*\\)]"), 1, 1); qDebug("Adding extension '%s' to '%s'", qPrintable(fileExt), qPrintable(fileName)); fileName.append(fileExt); diff --git a/client/ndpstatusmodel.cpp b/client/ndpstatusmodel.cpp index 27dea15..839144e 100644 --- a/client/ndpstatusmodel.cpp +++ b/client/ndpstatusmodel.cpp @@ -25,6 +25,7 @@ along with this program. If not, see #include "uint128.h" #include +#include > enum { kIp4Address, @@ -114,7 +115,7 @@ QVariant NdpStatusModel::data(const QModelIndex &index, int role) const switch (role) { case Qt::DisplayRole: return QString("%1").arg(ndp.mac(), 6*2, 16, QChar('0')) - .replace(QRegExp("([0-9a-fA-F]{2}\\B)"), "\\1:") + .replace(QRegularExpression("([0-9a-fA-F]{2}\\B)"), "\\1:") .toUpper(); default: break; diff --git a/client/portgroup.cpp b/client/portgroup.cpp index c70c7b0..bc5bae5 100644 --- a/client/portgroup.cpp +++ b/client/portgroup.cpp @@ -32,7 +32,7 @@ along with this program. If not, see #include #include #include -#include +#include > #include #include #include diff --git a/client/portmodel.cpp b/client/portmodel.cpp index f42bfdd..8d469b8 100644 --- a/client/portmodel.cpp +++ b/client/portmodel.cpp @@ -294,7 +294,7 @@ QPixmap PortModel::statusIcon( QString key = QString("$ost:portStatusIcon:%1:%2:%3:%4") .arg(linkState).arg(exclusive).arg(transmit).arg(capture); - if (QPixmapCache::find(key, pixmap)) + if (QPixmapCache::find(key, &pixmap)) return pixmap; static int sz = QPixmap(":/icons/frag_link_up.png").width(); diff --git a/client/portstatsfilterdialog.cpp b/client/portstatsfilterdialog.cpp index 61faad7..419766f 100644 --- a/client/portstatsfilterdialog.cpp +++ b/client/portstatsfilterdialog.cpp @@ -19,6 +19,8 @@ along with this program. If not, see #include "portstatsfilterdialog.h" +#include + PortStatsFilterDialog::PortStatsFilterDialog(QWidget *parent) : QDialog(parent) { @@ -88,7 +90,7 @@ void PortStatsFilterDialog::on_tbSelectIn_clicked() foreach(QModelIndex idx, lvUnselected->selectionModel()->selectedIndexes()) rows.append(idx.row()); - std::sort(rows.begin(), rows.end(), qGreater()); + std::sort(rows.begin(), rows.end(), std::greater()); QModelIndex idx = lvSelected->selectionModel()->currentIndex(); int insertAt = idx.isValid() ? idx.row() : mSelected.rowCount(); @@ -106,7 +108,7 @@ void PortStatsFilterDialog::on_tbSelectOut_clicked() foreach(QModelIndex idx, lvSelected->selectionModel()->selectedIndexes()) rows.append(idx.row()); - std::sort(rows.begin(), rows.end(), qGreater()); + std::sort(rows.begin(), rows.end(), std::greater()); foreach(int row, rows) { diff --git a/client/portstatsmodel.cpp b/client/portstatsmodel.cpp index 30c8dff..d29e776 100644 --- a/client/portstatsmodel.cpp +++ b/client/portstatsmodel.cpp @@ -431,7 +431,7 @@ QPixmap PortStatsModel::statusIcons( QString key = QString("$ost:statusList:%1:%2:%3") .arg(linkState).arg(transmit).arg(capture); - if (QPixmapCache::find(key, pixmap)) + if (QPixmapCache::find(key, &pixmap)) return pixmap; static int sz = QPixmap(":/icons/transmit_on.png").width(); diff --git a/client/portstatsproxymodel.h b/client/portstatsproxymodel.h index 011daba..0aa6a67 100644 --- a/client/portstatsproxymodel.h +++ b/client/portstatsproxymodel.h @@ -21,6 +21,7 @@ along with this program. If not, see #define _PORT_STATS_PROXY_MODEL_H #include +#include class PortStatsProxyModel : public QSortFilterProxyModel { @@ -29,7 +30,7 @@ public: PortStatsProxyModel(int userRow, QObject *parent = 0) : QSortFilterProxyModel(parent), userRow_(userRow) { - setFilterRegExp(QRegExp(".*")); + setFilterRegularExpression(QRegularExpression(".*")); } protected: @@ -39,7 +40,7 @@ protected: QModelIndex index = sourceModel()->index(userRow_, sourceColumn,sourceParent); QString user = sourceModel()->data(index).toString(); - return filterRegExp().exactMatch(user) ? true : false; + return filterRegularExpression().match(user).hasMatch() ? true : false; } bool filterAcceptsRow(int sourceRow, const QModelIndex &/*sourceParent*/) const diff --git a/client/portstatswindow.cpp b/client/portstatswindow.cpp index 56f917c..d410e05 100644 --- a/client/portstatswindow.cpp +++ b/client/portstatswindow.cpp @@ -32,6 +32,7 @@ along with this program. If not, see #include #include #include +#include > extern QMainWindow *mainWindow; @@ -113,10 +114,10 @@ void PortStatsWindow::showMyReservedPortsOnly(bool enabled) if (enabled) { QString rx(appSettings->value(kUserKey, kUserDefaultValue).toString()); - proxyStatsModel->setFilterRegExp(QRegExp::escape(rx)); + proxyStatsModel->setFilterRegularExpression(QRegularExpression::escape(rx)); } else - proxyStatsModel->setFilterRegExp(QRegExp(".*")); // match all + proxyStatsModel->setFilterRegularExpression(QRegularExpression(".*")); // match all } /* ------------- SLOTS (private) -------------- */ diff --git a/client/portswindow.cpp b/client/portswindow.cpp index 4c5747b..c3c0872 100644 --- a/client/portswindow.cpp +++ b/client/portswindow.cpp @@ -266,14 +266,14 @@ void PortsWindow::showMyReservedPortsOnly(bool enabled) if (enabled) { QString rx = "Port Group|\\[" - + QRegExp::escape(appSettings->value(kUserKey, + + QRegularExpression::escape(appSettings->value(kUserKey, kUserDefaultValue).toString()) + "\\]"; - qDebug("%s: regexp: <%s>", __FUNCTION__, qPrintable(rx)); - proxyPortModel->setFilterRegExp(QRegExp(rx)); + qDebug("%s: RegularExpression: <%s>", __FUNCTION__, qPrintable(rx)); + proxyPortModel->setFilterRegularExpression(QRegularExpression(rx)); } else - proxyPortModel->setFilterRegExp(QRegExp("")); + proxyPortModel->setFilterRegularExpression(QRegularExpression("")); } void PortsWindow::when_portView_currentChanged(const QModelIndex& currentIndex, diff --git a/client/streamconfigdialog.cpp b/client/streamconfigdialog.cpp index 49440e4..2c99f81 100644 --- a/client/streamconfigdialog.cpp +++ b/client/streamconfigdialog.cpp @@ -219,9 +219,9 @@ StreamConfigDialog::StreamConfigDialog( void StreamConfigDialog::setupUiExtra() { - QRegExp reHex2B("[0-9,a-f,A-F]{1,4}"); - QRegExp reHex4B("[0-9,a-f,A-F]{1,8}"); - QRegExp reMac("([0-9,a-f,A-F]{2,2}[:-]){5,5}[0-9,a-f,A-F]{2,2}"); + QRegularExpression reHex2B("[0-9,a-f,A-F]{1,4}"); + QRegularExpression reHex4B("[0-9,a-f,A-F]{1,8}"); + QRegularExpression reMac("([0-9,a-f,A-F]{2,2}[:-]){5,5}[0-9,a-f,A-F]{2,2}"); // ---- Setup default stuff that cannot be done in designer ---- bgProto[ProtoL1] = new QButtonGroup(); @@ -1253,7 +1253,7 @@ bool StreamConfigDialog::isCurrentStreamValid() if (QMessageBox::warning(this, "Preflight Check", tr("

We found possible problems with this stream -

") + "
    " - + log.replaceInStrings(QRegExp("(.*)"), "
  • \\1
  • ") + + log.replaceInStrings(QRegularExpression("(.*)"), "
  • \\1
  • ") .join("\n") + "
" + tr("

Ignore?

"), diff --git a/client/streamstatsfiltermodel.h b/client/streamstatsfiltermodel.h index afb8b48..0109226 100644 --- a/client/streamstatsfiltermodel.h +++ b/client/streamstatsfiltermodel.h @@ -37,7 +37,7 @@ protected: { QString title = sourceModel()->headerData(sourceColumn, Qt::Horizontal) .toString(); - return filterRegExp().exactMatch(title) ? true : false; + return filterRegularExpression().match(title).hasMatch() ? true : false; } bool filterAcceptsRow(int /*sourceRow*/, const QModelIndex &/*sourceParent*/) const diff --git a/client/streamstatswindow.cpp b/client/streamstatswindow.cpp index 35615a8..0b06bb2 100644 --- a/client/streamstatswindow.cpp +++ b/client/streamstatswindow.cpp @@ -39,7 +39,7 @@ StreamStatsWindow::StreamStatsWindow(QAbstractItemModel *model, QWidget *parent) count++; filterModel_ = new StreamStatsFilterModel(this); - filterModel_->setFilterRegExp(QRegExp(kDefaultFilter_)); + filterModel_->setFilterRegularExpression(QRegularExpression(kDefaultFilter_)); filterModel_->setSourceModel(model); streamStats->setModel(filterModel_); @@ -63,9 +63,9 @@ StreamStatsWindow::~StreamStatsWindow() void StreamStatsWindow::on_actionShowDetails_triggered(bool checked) { if (checked) - filterModel_->setFilterRegExp(QRegExp(".*")); + filterModel_->setFilterRegularExpression(QRegularExpression(".*")); else - filterModel_->setFilterRegExp(QRegExp(kDefaultFilter_)); + filterModel_->setFilterRegularExpression(QRegularExpression(kDefaultFilter_)); streamStats->resizeColumnsToContents(); } diff --git a/client/streamswidget.cpp b/client/streamswidget.cpp index acaea06..81e7544 100644 --- a/client/streamswidget.cpp +++ b/client/streamswidget.cpp @@ -476,7 +476,7 @@ _retry: goto _exit; if (QFileInfo(fileName).suffix().isEmpty()) { - QString fileExt = fileType.section(QRegExp("[\\*\\)]"), 1, 1); + QString fileExt = fileType.section(QRegularExpression("[\\*\\)]"), 1, 1); qDebug("Adding extension '%s' to '%s'", qPrintable(fileExt), qPrintable(fileName)); fileName.append(fileExt); @@ -491,7 +491,7 @@ _retry: } } - fileType = fileType.remove(QRegExp("\\(.*\\)")).trimmed(); + fileType = fileType.remove(QRegularExpression("\\(.*\\)")).trimmed(); if (!fileType.startsWith("Ostinato") && !fileType.startsWith("Python")) { diff --git a/common/abstractprotocol.cpp b/common/abstractprotocol.cpp index 562db61..e601bd8 100644 --- a/common/abstractprotocol.cpp +++ b/common/abstractprotocol.cpp @@ -26,6 +26,8 @@ along with this program. If not, see #include +#include + #if 0 #ifdef qDebug #undef qDebug @@ -1160,7 +1162,7 @@ bool varyCounter(QString protocolName, QByteArray &buf, int frameIndex, break; case OstProto::VariableField::kRandom: newfv = (oldfv & ~varField.mask()) - | ((varField.value() + qrand()) & varField.mask()); + | ((varField.value() + QRandomGenerator::global()->generate()) & varField.mask()); break; default: qWarning("%s Unsupported varField mode %d", diff --git a/common/abstractprotocol.h b/common/abstractprotocol.h index 27568ef..c42f5c2 100644 --- a/common/abstractprotocol.h +++ b/common/abstractprotocol.h @@ -23,7 +23,6 @@ along with this program. If not, see #include #include #include -#include #include #include #include @@ -109,6 +108,7 @@ public: //! Flags affecting cksum calculation, can be OR'd enum CksumFlag { + ExcludeCksumField = 0x0, IncludeCksumField = 0x1, //!< Default: exclude cksum field(s) }; Q_DECLARE_FLAGS(CksumFlags, CksumFlag); //!< \private abcd @@ -171,7 +171,7 @@ public: bool protocolHasPayload() const; virtual quint32 protocolFrameCksum(int streamIndex = 0, - CksumType cksumType = CksumIp, CksumFlags cksumFlags = 0) const; + CksumType cksumType = CksumIp, CksumFlags cksumFlags = CksumFlag::ExcludeCksumField) const; quint32 protocolFrameHeaderCksum(int streamIndex = 0, CksumType cksumType = CksumIp, CksumScope cksumScope = CksumScopeAdjacentProtocol) const; diff --git a/common/arp.cpp b/common/arp.cpp index 93fe283..50d562c 100644 --- a/common/arp.cpp +++ b/common/arp.cpp @@ -20,11 +20,12 @@ along with this program. If not, see #include "arp.h" #include -#include +#include +#include #define uintToMacStr(num) \ QString("%1").arg(num, 6*2, BASE_HEX, QChar('0')) \ - .replace(QRegExp("([0-9a-fA-F]{2}\\B)"), "\\1:").toUpper() + .replace(QRegularExpression("([0-9a-fA-F]{2}\\B)"), "\\1:").toUpper() ArpProtocol::ArpProtocol(StreamBase *stream, AbstractProtocol *parent) : AbstractProtocol(stream, parent) @@ -348,7 +349,7 @@ QVariant ArpProtocol::fieldData(int index, FieldAttrib attrib, case OstProto::Arp::kRandomHost: subnet = data.sender_proto_addr() & data.sender_proto_addr_mask(); - host = (qrand() & ~data.sender_proto_addr_mask()); + host = (QRandomGenerator::global()->generate() & ~data.sender_proto_addr_mask()); protoAddr = subnet | host; break; default: @@ -456,7 +457,7 @@ QVariant ArpProtocol::fieldData(int index, FieldAttrib attrib, case OstProto::Arp::kRandomHost: subnet = data.target_proto_addr() & data.target_proto_addr_mask(); - host = (qrand() & ~data.target_proto_addr_mask()); + host = (QRandomGenerator::global()->generate() & ~data.target_proto_addr_mask()); protoAddr = subnet | host; break; default: diff --git a/common/comboprotocol.h b/common/comboprotocol.h index 0e7ae41..92a0f06 100644 --- a/common/comboprotocol.h +++ b/common/comboprotocol.h @@ -188,7 +188,7 @@ public: } virtual quint32 protocolFrameCksum(int streamIndex = 0, - CksumType cksumType = CksumIp, CksumFlags cksumFlags = 0) const + CksumType cksumType = CksumIp, CksumFlags cksumFlags = CksumFlag::ExcludeCksumField) const { // For a Pseudo IP cksum, we assume it is the succeeding protocol // that is requesting it and hence return protoB's cksum; diff --git a/common/emulation.h b/common/emulation.h index 919849d..bf3baad 100644 --- a/common/emulation.h +++ b/common/emulation.h @@ -23,6 +23,7 @@ along with this program. If not, see #include "emulproto.pb.h" #include +#include static inline OstProto::DeviceGroup* newDeviceGroup(uint portId) { @@ -37,10 +38,10 @@ static inline OstProto::DeviceGroup* newDeviceGroup(uint portId) // Create a mac address as per RFC 4814 Sec 4.2 // (RR & 0xFC):PP:PP:RR:RR:RR // where RR is a random number, PP:PP is 1-indexed port index - // NOTE: although qrand() return type is a int, the max value + // NOTE: although QRandomGenerator::global()->generate() return type is a int, the max value // is RAND_MAX (stdlib.h) which is often 16-bit only, so we // use two random numbers - quint32 r1 = qrand(), r2 = qrand(); + quint32 r1 = QRandomGenerator::global()->generate(), r2 = QRandomGenerator::global()->generate(); quint64 mac; mac = quint64(r1 & 0xfc00) << 32 | quint64(portId + 1) << 24 diff --git a/common/framevalueattrib.h b/common/framevalueattrib.h index 9319a8d..1064359 100644 --- a/common/framevalueattrib.h +++ b/common/framevalueattrib.h @@ -25,12 +25,13 @@ along with this program. If not, see struct FrameValueAttrib { enum ErrorFlag { + NoError = 0x0, UnresolvedSrcMacError = 0x1, UnresolvedDstMacError = 0x2, OutOfMemoryError = 0x4, }; Q_DECLARE_FLAGS(ErrorFlags, ErrorFlag); - ErrorFlags errorFlags{0}; + ErrorFlags errorFlags{ErrorFlag::NoError}; // TODO?: int len; FrameValueAttrib& operator+=(const FrameValueAttrib& rhs) { diff --git a/common/gmpconfig.cpp b/common/gmpconfig.cpp index 5cafb4f..9677e41 100644 --- a/common/gmpconfig.cpp +++ b/common/gmpconfig.cpp @@ -25,8 +25,8 @@ GmpConfigForm::GmpConfigForm(QWidget *parent) { setupUi(this); - auxData->setValidator(new QRegExpValidator( - QRegExp("[0-9A-Fa-f]*"), this)); + auxData->setValidator(new QRegularExpressionValidator( + QRegularExpression("[0-9A-Fa-f]*"), this)); } GmpConfigForm::~GmpConfigForm() @@ -272,7 +272,7 @@ void GmpConfigForm::on_addGroupRecord_clicked() grpRec["overrideAuxDataLength"] = defRec.is_override_aux_data_length(); grpRec["auxDataLength"] = defRec.aux_data_length(); grpRec["auxData"] = QByteArray().append( - QString().fromStdString(defRec.aux_data())); + QString().fromStdString(defRec.aux_data()).toUtf8()); item->setData(Qt::UserRole, grpRec); item->setText(QString("%1: %2") @@ -320,7 +320,7 @@ void GmpConfigForm::on_groupList_currentItemChanged(QListWidgetItem *current, rec["groupRecordSourceCount"] = groupRecordSourceCount->text().toUInt(); rec["overrideAuxDataLength"] = overrideAuxDataLength->isChecked(); rec["auxDataLength"] = auxDataLength->text().toUInt(); - rec["auxData"] = QByteArray().fromHex(QByteArray().append(auxData->text())); + rec["auxData"] = QByteArray().fromHex(QByteArray().append(auxData->text().toUtf8())); previous->setData(Qt::UserRole, rec); previous->setText(QString("%1: %2") diff --git a/common/ip4.cpp b/common/ip4.cpp index f4b413b..8681ad0 100644 --- a/common/ip4.cpp +++ b/common/ip4.cpp @@ -20,6 +20,7 @@ along with this program. If not, see #include "ip4.h" #include +#include Ip4Protocol::Ip4Protocol(StreamBase *stream, AbstractProtocol *parent) : AbstractProtocol(stream, parent) @@ -433,7 +434,7 @@ QVariant Ip4Protocol::fieldData(int index, FieldAttrib attrib, break; case OstProto::Ip4::e_im_random_host: subnet = data.src_ip() & data.src_ip_mask(); - host = (qrand() & ~data.src_ip_mask()); + host = (QRandomGenerator::global()->generate() & ~data.src_ip_mask()); srcIp = subnet | host; break; default: @@ -486,7 +487,7 @@ QVariant Ip4Protocol::fieldData(int index, FieldAttrib attrib, break; case OstProto::Ip4::e_im_random_host: subnet = data.dst_ip() & data.dst_ip_mask(); - host = (qrand() & ~data.dst_ip_mask()); + host = (QRandomGenerator::global()->generate() & ~data.dst_ip_mask()); dstIp = subnet | host; break; default: diff --git a/common/ip4.h b/common/ip4.h index ba41e60..5f334e3 100644 --- a/common/ip4.h +++ b/common/ip4.h @@ -89,7 +89,7 @@ public: virtual int protocolFrameVariableCount() const; virtual quint32 protocolFrameCksum(int streamIndex = 0, - CksumType cksumType = CksumIp, CksumFlags cksumFlags = 0) const; + CksumType cksumType = CksumIp, CksumFlags cksumFlags = CksumFlag::ExcludeCksumField) const; virtual bool hasErrors(QStringList *errors = nullptr) const; private: diff --git a/common/ip4config.cpp b/common/ip4config.cpp index 8209ebd..2c854da 100644 --- a/common/ip4config.cpp +++ b/common/ip4config.cpp @@ -29,7 +29,7 @@ Ip4ConfigForm::Ip4ConfigForm(QWidget *parent) setupUi(this); leIpVersion->setValidator(new QIntValidator(0, 15, this)); - leIpOptions->setValidator(new QRegExpValidator(QRegExp("[0-9a-fA-F]*"), + leIpOptions->setValidator(new QRegularExpressionValidator(QRegularExpression("[0-9a-fA-F]*"), this)); leIpSrcAddr->setValidator(new IPv4AddressValidator(this)); leIpSrcAddrMask->setValidator(new IPv4AddressValidator(this)); @@ -277,7 +277,7 @@ void Ip4ConfigForm::storeWidget(AbstractProtocol *proto) QHostAddress(leIpDstAddrMask->text()).toIPv4Address()); proto->setFieldData( Ip4Protocol::ip4_options, - QByteArray::fromHex(QByteArray().append(leIpOptions->text()))); + QByteArray::fromHex(QByteArray().append(leIpOptions->text().toUtf8()))); } /* diff --git a/common/ip6.cpp b/common/ip6.cpp index 4971fea..def1f4e 100644 --- a/common/ip6.cpp +++ b/common/ip6.cpp @@ -21,6 +21,7 @@ along with this program. If not, see #include "uint128.h" #include +#include Ip6Protocol::Ip6Protocol(StreamBase *stream, AbstractProtocol *parent) @@ -340,7 +341,7 @@ QVariant Ip6Protocol::fieldData(int index, FieldAttrib attrib, else if (data.src_addr_mode()==OstProto::Ip6::kRandomHost) { // XXX: qrand is int (32bit) not 64bit, some stdlib // implementations have RAND_MAX as low as 0x7FFF - host = UInt128(qrand(), qrand()) & ~mask; + host = UInt128(QRandomGenerator::global()->generate(), QRandomGenerator::global()->generate()) & ~mask; } src = prefix | host; break; @@ -403,7 +404,7 @@ QVariant Ip6Protocol::fieldData(int index, FieldAttrib attrib, else if (data.dst_addr_mode()==OstProto::Ip6::kRandomHost) { // XXX: qrand is int (32bit) not 64bit, some stdlib // implementations have RAND_MAX as low as 0x7FFF - host = UInt128(qrand(), qrand()) & ~mask; + host = UInt128(QRandomGenerator::global()->generate(), QRandomGenerator::global()->generate()) & ~mask; } dst = prefix | host; break; diff --git a/common/ip6.h b/common/ip6.h index c08b1cd..d58d036 100644 --- a/common/ip6.h +++ b/common/ip6.h @@ -103,7 +103,7 @@ public: virtual int protocolFrameVariableCount() const; virtual quint32 protocolFrameCksum(int streamIndex = 0, - CksumType cksumType = CksumIp, CksumFlags cksumFlags = 0) const; + CksumType cksumType = CksumIp, CksumFlags cksumFlags = CksumFlag::ExcludeCksumField) const; virtual bool hasErrors(QStringList *errors = nullptr) const; private: diff --git a/common/iputils.h b/common/iputils.h index 51d2f5b..731e68d 100644 --- a/common/iputils.h +++ b/common/iputils.h @@ -23,6 +23,7 @@ along with this program. If not, see #include "uint128.h" #include +#include namespace ipUtils { enum AddrMode { @@ -60,7 +61,7 @@ quint32 inline ipAddress(quint32 baseIp, int prefix, AddrMode mode, int count, break; case kRandom: subnet = baseIp & mask; - host = (qrand() & ~mask); + host = (QRandomGenerator::global()->generate() & ~mask); ip = subnet | host; break; default: @@ -111,8 +112,8 @@ void inline ipAddress(quint64 baseIpHi, quint64 baseIpLo, int prefix, hostLo = ((baseIpLo & ~maskLo) - u) & ~maskLo; } else if (mode==kRandom) { - hostHi = qrand() & ~maskHi; - hostLo = qrand() & ~maskLo; + hostHi = QRandomGenerator::global()->generate() & ~maskHi; + hostLo = QRandomGenerator::global()->generate() & ~maskLo; } ipHi = prefixHi | hostHi; ipLo = prefixLo | hostLo; diff --git a/common/ipv4addressvalidator.h b/common/ipv4addressvalidator.h index aaa03ae..a297c54 100644 --- a/common/ipv4addressvalidator.h +++ b/common/ipv4addressvalidator.h @@ -36,7 +36,7 @@ public: virtual void fixup(QString &input) const { - QStringList bytes = input.split('.', QString::SkipEmptyParts); + QStringList bytes = input.split('.', Qt::SkipEmptyParts); while (bytes.count() < 4) bytes.append("0"); diff --git a/common/ipv6addressvalidator.h b/common/ipv6addressvalidator.h index 3eea843..a0f849e 100644 --- a/common/ipv6addressvalidator.h +++ b/common/ipv6addressvalidator.h @@ -43,7 +43,7 @@ public: if (addr.protocol() == QAbstractSocket::IPv6Protocol) state = Acceptable; else - if (_ip6ValidChars.exactMatch(input)) + if (_ip6ValidChars.match(input).hasMatch()) state = Intermediate; else state = Invalid; @@ -69,7 +69,7 @@ public: input = addr.toString(); } private: - QRegExp _ip6ValidChars; + QRegularExpression _ip6ValidChars; }; #endif diff --git a/common/llcpdml.cpp b/common/llcpdml.cpp index a5584cc..5c38b49 100644 --- a/common/llcpdml.cpp +++ b/common/llcpdml.cpp @@ -22,7 +22,7 @@ along with this program. If not, see #include "llc.pb.h" #include "snap.pb.h" -#include +#include PdmlLlcProtocol::PdmlLlcProtocol() { @@ -56,7 +56,7 @@ void PdmlLlcProtocol::unknownFieldHandler(QString name, int /*pos*/, .toUInt(&isOk, kBaseHex)); snap->set_is_override_oui(true); } - else if ((name == "llc.type") || (name.contains(QRegExp("llc\\..*pid")))) + else if ((name == "llc.type") || (name.contains(QRegularExpression("llc\\..*pid")))) { OstProto::Snap *snap = stream->mutable_protocol( stream->protocol_size()-1)->MutableExtension(OstProto::snap); diff --git a/common/mac.cpp b/common/mac.cpp index 32c30f6..340b31c 100644 --- a/common/mac.cpp +++ b/common/mac.cpp @@ -22,11 +22,11 @@ along with this program. If not, see #include "framevalueattrib.h" #include "../common/streambase.h" -#include +#include #define uintToMacStr(num) \ QString("%1").arg(num, 6*2, BASE_HEX, QChar('0')) \ - .replace(QRegExp("([0-9a-fA-F]{2}\\B)"), "\\1:").toUpper() + .replace(QRegularExpression("([0-9a-fA-F]{2}\\B)"), "\\1:").toUpper() MacProtocol::MacProtocol(StreamBase *stream, AbstractProtocol *parent) : AbstractProtocol(stream, parent) diff --git a/common/macaddressvalidator.h b/common/macaddressvalidator.h index 97e5ab4..069110e 100644 --- a/common/macaddressvalidator.h +++ b/common/macaddressvalidator.h @@ -37,7 +37,7 @@ public: virtual void fixup(QString &input) const { QStringList bytes = input.split(QRegularExpression("[:-]"), - QString::SkipEmptyParts); + Qt::SkipEmptyParts); if (!bytes.isEmpty() && bytes.last().size() == 1) bytes.last().prepend("0"); diff --git a/common/macedit.h b/common/macedit.h index 6c005be..c1f5ced 100644 --- a/common/macedit.h +++ b/common/macedit.h @@ -21,7 +21,7 @@ along with this program. If not, see #define _MAC_EDIT_H #include -#include +#include class MacEdit: public QLineEdit { @@ -39,14 +39,14 @@ inline MacEdit::MacEdit(QWidget *parent) : QLineEdit(parent) { // Allow : or - as separator - QRegExp reMac("([0-9,a-f,A-F]{0,2}[:-]){5,5}[0-9,a-f,A-F]{0,2}"); + QRegularExpression reMac("([0-9,a-f,A-F]{0,2}[:-]){5,5}[0-9,a-f,A-F]{0,2}"); - setValidator(new QRegExpValidator(reMac, this)); + setValidator(new QRegularExpressionValidator(reMac, this)); } inline quint64 MacEdit::value() { - QStringList bytes = text().split(QRegExp("[:-]")); + QStringList bytes = text().split(QRegularExpression("[:-]")); quint64 mac = 0; while (bytes.count() > 6) @@ -61,7 +61,7 @@ inline quint64 MacEdit::value() inline void MacEdit::setValue(quint64 val) { setText(QString("%1").arg(val, 6*2, 16, QChar('0')) - .replace(QRegExp("([0-9a-fA-F]{2}\\B)"), "\\1:").toUpper()); + .replace(QRegularExpression("([0-9a-fA-F]{2}\\B)"), "\\1:").toUpper()); } inline void MacEdit::focusOutEvent(QFocusEvent *e) diff --git a/common/nativefileformat.cpp b/common/nativefileformat.cpp index 12ff4b6..b9f9af7 100644 --- a/common/nativefileformat.cpp +++ b/common/nativefileformat.cpp @@ -64,8 +64,8 @@ NativeFileFormat::NativeFileFormat() // TODO: convert Q_ASSERT to something that will run in RELEASE mode also Q_ASSERT(magic.IsInitialized()); Q_ASSERT(cksum.IsInitialized()); - Q_ASSERT(magic.ByteSize() == kFileMagicSize); - Q_ASSERT(cksum.ByteSize() == kFileChecksumSize); + Q_ASSERT(magic.ByteSizeLong() == kFileMagicSize); + Q_ASSERT(cksum.ByteSizeLong() == kFileChecksumSize); } bool NativeFileFormat::open( diff --git a/common/payload.cpp b/common/payload.cpp index 886111d..d1022fb 100644 --- a/common/payload.cpp +++ b/common/payload.cpp @@ -20,6 +20,8 @@ along with this program. If not, see #include "payload.h" #include "streambase.h" +#include + PayloadProtocol::PayloadProtocol(StreamBase *stream, AbstractProtocol *parent) : AbstractProtocol(stream, parent) { @@ -149,7 +151,7 @@ QVariant PayloadProtocol::fieldData(int index, FieldAttrib attrib, case OstProto::Payload::e_dp_random: //! \todo (HIGH) cksum is incorrect for random pattern for (int i = 0; i < dataLen; i++) - fv[i] = qrand() % (0xFF + 1); + fv[i] = QRandomGenerator::global()->generate() % (0xFF + 1); break; default: qWarning("Unhandled data pattern %d", diff --git a/common/stp.cpp b/common/stp.cpp index b1e3239..d7892f5 100644 --- a/common/stp.cpp +++ b/common/stp.cpp @@ -20,11 +20,11 @@ This module is developed by PLVision */ #include "stp.h" -#include +#include #define uintToMacStr(num) \ QString("%1").arg(num, 6 * 2, BASE_HEX, QChar('0')) \ - .replace(QRegExp("([0-9a-fA-F]{2}\\B)"), "\\1:").toUpper() + .replace(QRegularExpression("([0-9a-fA-F]{2}\\B)"), "\\1:").toUpper() #define ONE_BIT(pos) ((unsigned int)(1 << (pos))) #define BITS(bit) (bit) #define BYTES(byte) (byte) diff --git a/common/stpconfig.cpp b/common/stpconfig.cpp index 9a7c14a..9b1b02d 100644 --- a/common/stpconfig.cpp +++ b/common/stpconfig.cpp @@ -22,7 +22,7 @@ This module is developed by PLVision #include "stpconfig.h" #include "stp.h" -#include +#include #include #define ONE_BYTE_MAX 255 @@ -59,11 +59,11 @@ public: StpConfigForm::StpConfigForm(QWidget *parent) : AbstractProtocolConfigForm(parent) { - QRegExp reMac("([0-9,a-f,A-F]{2,2}[:-]){5,5}[0-9,a-f,A-F]{2,2}"); + QRegularExpression reMac("([0-9,a-f,A-F]{2,2}[:-]){5,5}[0-9,a-f,A-F]{2,2}"); setupUi(this); - QRegExpValidator *validateMACAddress = - new QRegExpValidator(reMac, this); + QRegularExpressionValidator *validateMACAddress = + new QRegularExpressionValidator(reMac, this); UNumberValidator *validateByte = new UNumberValidator(0, ONE_BYTE_MAX, this); UNumberValidator *validate2Byte = diff --git a/common/streambase.cpp b/common/streambase.cpp index bc9d0bd..8a1052d 100644 --- a/common/streambase.cpp +++ b/common/streambase.cpp @@ -27,6 +27,7 @@ along with this program. If not, see #include "uint128.h" #include +#include extern ProtocolManager *OstProtocolManager; extern quint64 getDeviceMacAddress(int portId, int streamId, int frameIndex); @@ -235,9 +236,11 @@ quint16 StreamBase::frameLen(int streamIndex) const case e_fl_random: //! \todo (MED) This 'random' sequence is same across iterations pktLen = 64; // to avoid the 'maybe used uninitialized' warning - qsrand(reinterpret_cast(this)); + +// qsrand(reinterpret_cast(this)); + for (int i = 0; i <= streamIndex; i++) - pktLen = qrand(); + pktLen = QRandomGenerator::global()->generate(); pktLen = frameLenMin() + (pktLen % (frameLenMax() - frameLenMin() + 1)); break; @@ -622,13 +625,13 @@ int StreamBase::findReplace(quint32 protocolNumber, int fieldIndex, qDebug() << "findReplace:" << "stream" << mStreamId->id() << "field" << fieldValue - << "findMask" << hex << findMask.value() << dec + << "findMask" << Qt::hex << findMask.value() << Qt::dec << "findValue" << findValue.value(); if ((fieldValue & findMask.value()) == findValue.value()) { T newValue = (fieldValue & ~replaceMask.value()) | (replaceValue.value() & replaceMask.value()); qDebug() << "findReplace:" - << "replaceMask" << hex << replaceMask.value() << dec + << "replaceMask" << Qt::hex << replaceMask.value() << Qt::dec << "replaceValue" << replaceValue.value() << "newValue" << newValue; diff --git a/common/streambase.h b/common/streambase.h index b6f907a..86ccd79 100644 --- a/common/streambase.h +++ b/common/streambase.h @@ -21,7 +21,6 @@ along with this program. If not, see #define _STREAM_BASE_H #include -#include #include #include "protocol.pb.h" diff --git a/common/uint128.h b/common/uint128.h index 68f4f57..82b440c 100644 --- a/common/uint128.h +++ b/common/uint128.h @@ -219,7 +219,7 @@ template <> inline UInt128 qToBigEndian(const UInt128 src) inline QDebug operator<<(QDebug debug, const UInt128 &value) { QDebugStateSaver saver(debug); - debug.maybeSpace() << hex << value.hi64() << " " << value.lo64(); + debug.maybeSpace() << Qt::hex << value.hi64() << " " << value.lo64(); return debug; } diff --git a/common/userscript.h b/common/userscript.h index 5e45161..23b56a4 100644 --- a/common/userscript.h +++ b/common/userscript.h @@ -138,7 +138,7 @@ public: virtual int protocolFrameVariableCount() const; virtual quint32 protocolFrameCksum(int streamIndex = 0, - CksumType cksumType = CksumIp, CksumFlags cksumFlags = 0) const; + CksumType cksumType = CksumIp, CksumFlags cksumFlags = CksumFlag::ExcludeCksumField) const; void evaluateUserScript() const; bool isScriptValid() const; diff --git a/extra/modeltest/modeltest.cpp b/extra/modeltest/modeltest.cpp index 4da00bd..5a320dc 100644 --- a/extra/modeltest/modeltest.cpp +++ b/extra/modeltest/modeltest.cpp @@ -443,12 +443,12 @@ void ModelTest::data() } // General Purpose roles that should return a QColor - QVariant colorVariant = model->data ( model->index ( 0, 0 ), Qt::BackgroundColorRole ); + QVariant colorVariant = model->data ( model->index ( 0, 0 ), Qt::BackgroundRole ); if ( colorVariant.isValid() ) { QVERIFY( colorVariant.canConvert() ); } - colorVariant = model->data ( model->index ( 0, 0 ), Qt::TextColorRole ); + colorVariant = model->data ( model->index ( 0, 0 ), Qt::ForegroundRole ); if ( colorVariant.isValid() ) { QVERIFY( colorVariant.canConvert() ); } diff --git a/extra/modeltest/target_wrapper.sh b/extra/modeltest/target_wrapper.sh new file mode 100755 index 0000000..f569e32 --- /dev/null +++ b/extra/modeltest/target_wrapper.sh @@ -0,0 +1,6 @@ +#!/bin/sh +LD_LIBRARY_PATH=/usr/lib64${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} +export LD_LIBRARY_PATH +QT_PLUGIN_PATH=/usr/lib64/qt5/plugins${QT_PLUGIN_PATH:+:$QT_PLUGIN_PATH} +export QT_PLUGIN_PATH +exec "$@" diff --git a/extra/modeltest/tst_modeltest.cpp b/extra/modeltest/tst_modeltest.cpp index f81fefe..9aab33c 100644 --- a/extra/modeltest/tst_modeltest.cpp +++ b/extra/modeltest/tst_modeltest.cpp @@ -66,7 +66,7 @@ void tst_ModelTest::stringListModel() model.setStringList(QStringList() << "a" << "e" << "plop" << "b" << "c" ); proxy.setDynamicSortFilter(true); - proxy.setFilterRegExp(QRegExp("[^b]")); + proxy.setFilterRegularExpression(QRegularExpression("[^b]")); } void tst_ModelTest::treeWidgetModel() diff --git a/extra/qhexedit2/src/qhexedit.cpp b/extra/qhexedit2/src/qhexedit.cpp index df99332..05fab90 100644 --- a/extra/qhexedit2/src/qhexedit.cpp +++ b/extra/qhexedit2/src/qhexedit.cpp @@ -426,7 +426,7 @@ QString QHexEdit::selectionToReadableString() void QHexEdit::setFont(const QFont &font) { QWidget::setFont(font); - _pxCharWidth = fontMetrics().width(QLatin1Char('2')); + _pxCharWidth = fontMetrics().horizontalAdvance("2"); _pxCharHeight = fontMetrics().height(); _pxGapAdr = _pxCharWidth / 2; _pxGapAdrHex = _pxCharWidth; diff --git a/rpc/rpcconn.cpp b/rpc/rpcconn.cpp index 566f096..d44844b 100644 --- a/rpc/rpcconn.cpp +++ b/rpc/rpcconn.cpp @@ -34,6 +34,7 @@ along with this program. If not, see #include #include #include + #include #include @@ -83,7 +84,8 @@ void RpcConnection::start() return; } qDebug("clientSock Thread = %p", clientSock->thread()); - qsrand(QDateTime::currentDateTime().toTime_t()); + +// qsrand(QDateTime::currentDateTime().toTime_t()); connId.setLocalData(new QString(id.arg(clientSock->peerAddress().toString()) .arg(clientSock->peerPort()))); diff --git a/server/devicemanager.h b/server/devicemanager.h index a64c972..5517c10 100644 --- a/server/devicemanager.h +++ b/server/devicemanager.h @@ -78,7 +78,7 @@ private: AbstractPort *port_; QMutex listLock_; // protects all the lists - QHash deviceGroupList_; + QMultiHash deviceGroupList_; QHash deviceList_; // fast access to devices QMap sortedDeviceList_; // sorted access to devices QMultiHash bcastList_; diff --git a/server/linuxport.cpp b/server/linuxport.cpp index 3ef2281..14e2508 100644 --- a/server/linuxport.cpp +++ b/server/linuxport.cpp @@ -28,7 +28,7 @@ along with this program. If not, see #include #include -#include +#include #include #include @@ -982,7 +982,7 @@ void LinuxPort::StatsMonitor::stop() bool LinuxPort::StatsMonitor::waitForSetupFinished(int msecs) { - QTime t; + QElapsedTimer t; t.start(); while (!setupDone_) diff --git a/server/portmanager.cpp b/server/portmanager.cpp index 5940bb9..2afb598 100644 --- a/server/portmanager.cpp +++ b/server/portmanager.cpp @@ -29,6 +29,7 @@ along with this program. If not, see #include #include +#include > PortManager *PortManager::instance_ = NULL; @@ -242,13 +243,11 @@ AbstractPort::Accuracy PortManager::rateAccuracy() bool PortManager::filterAcceptsPort(const char *name) { - QRegExp pattern; QStringList includeList = appSettings->value(kPortListIncludeKey) .toStringList(); QStringList excludeList = appSettings->value(kPortListExcludeKey) .toStringList(); - pattern.setPatternSyntax(QRegExp::Wildcard); // An empty (or missing) includeList accepts all ports // NOTE: A blank "IncludeList=" is read as a stringlist with one @@ -258,8 +257,10 @@ bool PortManager::filterAcceptsPort(const char *name) goto _include_pass; foreach (QString str, includeList) { - pattern.setPattern(str); - if (pattern.exactMatch(name)) + QString wildcardExp = QRegularExpression::wildcardToRegularExpression(str); + QRegularExpression pattern(QRegularExpression::anchoredPattern(wildcardExp), + QRegularExpression::CaseInsensitiveOption); + if (pattern.match(name).hasMatch()) goto _include_pass; } @@ -268,8 +269,10 @@ bool PortManager::filterAcceptsPort(const char *name) _include_pass: foreach (QString str, excludeList) { - pattern.setPattern(str); - if (pattern.exactMatch(name)) + QString wildcardExp = QRegularExpression::wildcardToRegularExpression(str); + QRegularExpression pattern(QRegularExpression::anchoredPattern(wildcardExp), + QRegularExpression::CaseInsensitiveOption); + if (pattern.match(name).hasMatch()) return false; }