Remove_Deprecated_In_Qt5.15.x

This commit is contained in:
phfr83 2024-02-26 11:02:20 +01:00
parent 318fe124bf
commit 65d8a1592d
53 changed files with 131 additions and 99 deletions

View File

@ -24,6 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#include "emulproto.pb.h"
#include <QHostAddress>
#include <QRegularExpression>
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;

View File

@ -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:

View File

@ -30,6 +30,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#include <QColor>
#include <QFont>
#include <QHostAddress>
#include <QRegularExpression>>
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;

View File

@ -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;

View File

@ -31,6 +31,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#include <QFile>
#include <QSettings>
#include <QtGlobal>
#include <QRandomGenerator>
#include <google/protobuf/stubs/common.h>
@ -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();

View File

@ -49,6 +49,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#include <QProgressDialog>
#include <QTimer>
#include <QUrl>
#include <QRegularExpression>
#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);

View File

@ -25,6 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#include "uint128.h"
#include <QHostAddress>
#include <QRegularExpression>>
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;

View File

@ -32,7 +32,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#include <QMainWindow>
#include <QMessageBox>
#include <QProcess>
#include <QRegExp>
#include <QRegularExpression>>
#include <QTemporaryFile>
#include <QTimer>
#include <QtGlobal>

View File

@ -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();

View File

@ -19,6 +19,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#include "portstatsfilterdialog.h"
#include <functional>
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<int>());
std::sort(rows.begin(), rows.end(), std::greater<int>());
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<int>());
std::sort(rows.begin(), rows.end(), std::greater<int>());
foreach(int row, rows)
{

View File

@ -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();

View File

@ -21,6 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#define _PORT_STATS_PROXY_MODEL_H
#include <QSortFilterProxyModel>
#include <QRegularExpression>
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

View File

@ -32,6 +32,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#include <QDockWidget>
#include <QHeaderView>
#include <QMainWindow>
#include <QRegularExpression>>
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) -------------- */

View File

@ -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,

View File

@ -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("<p>We found possible problems with this stream -</p>")
+ "<ul>"
+ log.replaceInStrings(QRegExp("(.*)"), "<li>\\1</li>")
+ log.replaceInStrings(QRegularExpression("(.*)"), "<li>\\1</li>")
.join("\n")
+ "</ul>"
+ tr("<p>Ignore?</p>"),

View File

@ -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

View File

@ -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();
}

View File

@ -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"))
{

View File

@ -26,6 +26,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#include <qendian.h>
#include <QRandomGenerator>
#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",

View File

@ -23,7 +23,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#include <QByteArray>
#include <QFlags>
#include <QHash>
#include <QLinkedList>
#include <QString>
#include <QVariant>
#include <qendian.h>
@ -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;

View File

@ -20,11 +20,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#include "arp.h"
#include <QHostAddress>
#include <QRegExp>
#include <QRegularExpression>
#include <QRandomGenerator>
#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:

View File

@ -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;

View File

@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#include "emulproto.pb.h"
#include <QtGlobal>
#include <QRandomGenerator>
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

View File

@ -25,12 +25,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
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) {

View File

@ -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")

View File

@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#include "ip4.h"
#include <QHostAddress>
#include <QRandomGenerator>
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:

View File

@ -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:

View File

@ -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())));
}
/*

View File

@ -21,6 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#include "uint128.h"
#include <QHostAddress>
#include <QRandomGenerator>
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;

View File

@ -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:

View File

@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#include "uint128.h"
#include <QHostAddress>
#include <QRandomGenerator>
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;

View File

@ -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");

View File

@ -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

View File

@ -22,7 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#include "llc.pb.h"
#include "snap.pb.h"
#include <QRegExp>
#include <QRegularExpression>
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);

View File

@ -22,11 +22,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#include "framevalueattrib.h"
#include "../common/streambase.h"
#include <QRegExp>
#include <QRegularExpression>
#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)

View File

@ -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");

View File

@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#define _MAC_EDIT_H
#include <QLineEdit>
#include <QRegExpValidator>
#include <QRegularExpressionValidator>
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)

View File

@ -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(

View File

@ -20,6 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#include "payload.h"
#include "streambase.h"
#include <QRandomGenerator>
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",

View File

@ -20,11 +20,11 @@ This module is developed by PLVision <developers@plvision.eu>
*/
#include "stp.h"
#include <QRegExp>
#include <QRegularExpression>
#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)

View File

@ -22,7 +22,7 @@ This module is developed by PLVision <developers@plvision.eu>
#include "stpconfig.h"
#include "stp.h"
#include <QRegExpValidator>
#include <QRegularExpressionValidator>
#include <QIntValidator>
#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 =

View File

@ -27,6 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#include "uint128.h"
#include <QDebug>
#include <QRandomGenerator>
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<ulong>(this));
// qsrand(reinterpret_cast<ulong>(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<T>() << dec
<< "findMask" << Qt::hex << findMask.value<T>() << Qt::dec
<< "findValue" << findValue.value<T>();
if ((fieldValue & findMask.value<T>()) == findValue.value<T>()) {
T newValue = (fieldValue & ~replaceMask.value<T>())
| (replaceValue.value<T>() & replaceMask.value<T>());
qDebug() << "findReplace:"
<< "replaceMask" << hex << replaceMask.value<T>() << dec
<< "replaceMask" << Qt::hex << replaceMask.value<T>() << Qt::dec
<< "replaceValue" << replaceValue.value<T>()
<< "newValue" << newValue;

View File

@ -21,7 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#define _STREAM_BASE_H
#include <QString>
#include <QLinkedList>
#include <QVariant>
#include "protocol.pb.h"

View File

@ -219,7 +219,7 @@ template <> inline UInt128 qToBigEndian<UInt128>(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;
}

View File

@ -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;

View File

@ -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<QColor>() );
}
colorVariant = model->data ( model->index ( 0, 0 ), Qt::TextColorRole );
colorVariant = model->data ( model->index ( 0, 0 ), Qt::ForegroundRole );
if ( colorVariant.isValid() ) {
QVERIFY( colorVariant.canConvert<QColor>() );
}

View File

@ -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 "$@"

View File

@ -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()

View File

@ -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;

View File

@ -34,6 +34,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#include <QTcpSocket>
#include <QThreadStorage>
#include <QtGlobal>
#include <qendian.h>
#include <stdio.h>
@ -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())));

View File

@ -78,7 +78,7 @@ private:
AbstractPort *port_;
QMutex listLock_; // protects all the lists
QHash<uint, OstProto::DeviceGroup*> deviceGroupList_;
QMultiHash<uint, OstProto::DeviceGroup*> deviceGroupList_;
QHash<DeviceKey, Device*> deviceList_; // fast access to devices
QMap<DeviceKey, Device*> sortedDeviceList_; // sorted access to devices
QMultiHash<DeviceKey, Device*> bcastList_;

View File

@ -28,7 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#include <QByteArray>
#include <QHash>
#include <QTime>
#include <QElapsedTimer>
#include <errno.h>
#include <fcntl.h>
@ -982,7 +982,7 @@ void LinuxPort::StatsMonitor::stop()
bool LinuxPort::StatsMonitor::waitForSetupFinished(int msecs)
{
QTime t;
QElapsedTimer t;
t.start();
while (!setupDone_)

View File

@ -29,6 +29,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#include <QHostAddress>
#include <QStringList>
#include <QRegularExpression>>
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;
}