diff --git a/common/gre.ui b/common/gre.ui index fdd4150..22ab6b6 100644 --- a/common/gre.ui +++ b/common/gre.ui @@ -78,16 +78,10 @@ - + false - - 0x - - - 16 - @@ -98,7 +92,7 @@ - + false @@ -125,6 +119,11 @@ QSpinBox
intedit.h
+ + UIntEdit + QLineEdit +
uintedit.h
+
hasChecksum diff --git a/common/uintedit.h b/common/uintedit.h new file mode 100644 index 0000000..28bee9f --- /dev/null +++ b/common/uintedit.h @@ -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 +*/ + +#ifndef _UINT_EDIT_H +#define _UINT_EDIT_H + +#include "ulonglongvalidator.h" + +#include + +#include + +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 + diff --git a/common/ulonglongvalidator.h b/common/ulonglongvalidator.h index 05bab0e..6a4dad1 100644 --- a/common/ulonglongvalidator.h +++ b/common/ulonglongvalidator.h @@ -29,6 +29,11 @@ public: : QValidator(parent) { } + ULongLongValidator(qulonglong min, qulonglong max, QObject *parent = 0) + : QValidator(parent) + { + setRange(min, max); + } ~ULongLongValidator() {} void setRange(qulonglong min, qulonglong max)