Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
sanny committed Sep 11, 2023
2 parents 3e0b182 + b9b3565 commit 1d191ed
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 4 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Open ModScan
Open ModScan is a free implimentation of modbus master (client) utility for modbus-tcp and modbus-rtu protocols.

![image](https://user-images.githubusercontent.com/13627951/227959348-7db5a333-8443-4824-873e-3d87d3ce6f8a.png)
![изображение](https://github.com/sanny32/OpenModScan/assets/13627951/aa912ece-4b76-44b4-9523-5b0b0156a64b)


![image](https://user-images.githubusercontent.com/13627951/227959984-7adbf285-fd1d-4198-8ff9-386a4eea0a87.png)
![изображение](https://github.com/sanny32/OpenModScan/assets/13627951/77bee5d8-09a8-4845-8d64-02b7bf3cf592)



## Features
Expand Down
3 changes: 2 additions & 1 deletion omodscan/controls/numericlineedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <float.h>
#include <QIntValidator>
#include "qhexvalidator.h"
#include "quintvalidator.h"
#include "numericlineedit.h"

///
Expand Down Expand Up @@ -334,7 +335,7 @@ void NumericLineEdit::on_rangeChanged(const QVariant& bottom, const QVariant& to
const int nums = QString::number(top.toUInt()).length();
_paddingZeroWidth = qMax(1, nums);
setMaxLength(qMax(1, nums));
setValidator(new QIntValidator(bottom.toUInt(), top.toUInt(), this));
setValidator(new QUIntValidator(bottom.toUInt(), top.toUInt(), this));
}
break;

Expand Down
4 changes: 3 additions & 1 deletion omodscan/omodscan.pro
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CONFIG += c++17
CONFIG -= debug_and_release
CONFIG -= debug_and_release_target

VERSION = 1.5.0
VERSION = 1.5.1

QMAKE_TARGET_PRODUCT = "Open ModScan"
QMAKE_TARGET_DESCRIPTION = "An Open Source Modbus Master (Client) Utility"
Expand Down Expand Up @@ -72,6 +72,7 @@ SOURCES += \
modbustcpscanner.cpp \
qfixedsizedialog.cpp \
qhexvalidator.cpp \
quintvalidator.cpp \
recentfileactionlist.cpp \
windowactionlist.cpp

Expand Down Expand Up @@ -134,6 +135,7 @@ HEADERS += \
qfixedsizedialog.h \
qhexvalidator.h \
qrange.h \
quintvalidator.h \
recentfileactionlist.h \
windowactionlist.h

Expand Down
43 changes: 43 additions & 0 deletions omodscan/quintvalidator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include "quintvalidator.h"

///
/// \brief QUIntValidator::QUIntValidator
/// \param parent
///
QUIntValidator::QUIntValidator(QObject *parent)
: QValidator{parent}
,_bottom(0)
,_top(UINT_MAX)
{
}

///
/// \brief QUIntValidator::QUIntValidator
/// \param bottom
/// \param top
/// \param parent
///
QUIntValidator::QUIntValidator(uint bottom, uint top, QObject *parent)
: QValidator(parent)
,_bottom(bottom)
,_top(top)
{

}

///
/// \brief QUIntValidator::validate
/// \return
///
QValidator::State QUIntValidator::validate(QString& input, int &) const
{
bool ok = false;
const auto value = input.toUInt(&ok, 10);

if (ok && value >=_bottom && value <=_top )
{
return QValidator::Acceptable;
}

return QValidator::Invalid;
}
21 changes: 21 additions & 0 deletions omodscan/quintvalidator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef QUINTVALIDATOR_H
#define QUINTVALIDATOR_H

#include <QValidator>
#include <QObject>

class QUIntValidator : public QValidator
{
Q_OBJECT
public:
explicit QUIntValidator(QObject *parent = nullptr);
QUIntValidator(uint bottom, uint top, QObject *parent = nullptr);

State validate(QString &, int &) const override;

private:
uint _bottom;
uint _top;
};

#endif // QUINTVALIDATOR_H

0 comments on commit 1d191ed

Please sign in to comment.