Add and use UIntEdit for 32-bit GRE Key/Seq fields

This commit is contained in:
Srivats P 2022-05-23 17:04:27 +05:30
parent 26d0c8ab9c
commit 60f61ed947
3 changed files with 69 additions and 8 deletions

View File

@ -78,16 +78,10 @@
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="2" column="1">
<widget class="IntEdit" name="key"> <widget class="UIntEdit" name="key">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="prefix">
<string>0x</string>
</property>
<property name="displayIntegerBase">
<number>16</number>
</property>
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item row="3" column="0">
@ -98,7 +92,7 @@
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="3" column="1">
<widget class="IntEdit" name="sequence"> <widget class="UIntEdit" name="sequence">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
</property> </property>
@ -125,6 +119,11 @@
<extends>QSpinBox</extends> <extends>QSpinBox</extends>
<header>intedit.h</header> <header>intedit.h</header>
</customwidget> </customwidget>
<customwidget>
<class>UIntEdit</class>
<extends>QLineEdit</extends>
<header>uintedit.h</header>
</customwidget>
</customwidgets> </customwidgets>
<tabstops> <tabstops>
<tabstop>hasChecksum</tabstop> <tabstop>hasChecksum</tabstop>

57
common/uintedit.h Normal file
View File

@ -0,0 +1,57 @@
/*
Copyright (C) 2022 Srivats P.
This file is part of "Ostinato"
This is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
#ifndef _UINT_EDIT_H
#define _UINT_EDIT_H
#include "ulonglongvalidator.h"
#include <QLineEdit>
#include <limits.h>
class UIntEdit: public QLineEdit
{
public:
UIntEdit(QWidget *parent = 0);
quint32 value();
void setValue(quint32 val);
};
// -------------------- //
inline UIntEdit::UIntEdit(QWidget *parent)
: QLineEdit(parent)
{
setValidator(new ULongLongValidator(0, UINT_MAX));
}
inline quint32 UIntEdit::value()
{
return text().toUInt(Q_NULLPTR, 0);
}
inline void UIntEdit::setValue(quint32 val)
{
setText(QString::number(val));
}
#endif

View File

@ -29,6 +29,11 @@ public:
: QValidator(parent) : QValidator(parent)
{ {
} }
ULongLongValidator(qulonglong min, qulonglong max, QObject *parent = 0)
: QValidator(parent)
{
setRange(min, max);
}
~ULongLongValidator() {} ~ULongLongValidator() {}
void setRange(qulonglong min, qulonglong max) void setRange(qulonglong min, qulonglong max)