feat: add format validation to all AE Title input editor
This commit is contained in:
@@ -20,6 +20,18 @@ DicomSettingsArea::~DicomSettingsArea()
|
|||||||
delete mUI;
|
delete mUI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DicomSettingsArea::isServerAETitleValid()
|
||||||
|
{
|
||||||
|
|
||||||
|
return InputFormatValidator::ValidateAETitleFormat(mUI->mServerAETitleEdit->text());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DicomSettingsArea::isLocalAETitleValid()
|
||||||
|
{
|
||||||
|
|
||||||
|
return InputFormatValidator::ValidateAETitleFormat(mUI->mMyAETitleEdit->text());
|
||||||
|
}
|
||||||
|
|
||||||
bool DicomSettingsArea::isIpAddressValid()
|
bool DicomSettingsArea::isIpAddressValid()
|
||||||
{
|
{
|
||||||
return InputFormatValidator::ValidateIpAddressFormat(mUI->mServerIpAddressEdit->text());
|
return InputFormatValidator::ValidateIpAddressFormat(mUI->mServerIpAddressEdit->text());
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ public:
|
|||||||
explicit DicomSettingsArea(QWidget* aParent = nullptr);
|
explicit DicomSettingsArea(QWidget* aParent = nullptr);
|
||||||
~DicomSettingsArea();
|
~DicomSettingsArea();
|
||||||
|
|
||||||
|
bool isServerAETitleValid();
|
||||||
|
bool isLocalAETitleValid();
|
||||||
bool isIpAddressValid();
|
bool isIpAddressValid();
|
||||||
bool isPortValid();
|
bool isPortValid();
|
||||||
QString getServerIpAddress();
|
QString getServerIpAddress();
|
||||||
|
|||||||
@@ -113,6 +113,17 @@ bool MppsSettingsDialog::updateReferenceData()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!mSettingsArea->isServerAETitleValid())
|
||||||
|
{
|
||||||
|
mErrorText->setErrorText(tr("Server AE is not valid"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(!mSettingsArea->isLocalAETitleValid())
|
||||||
|
{
|
||||||
|
mErrorText->setErrorText(tr("Local AE is not valid"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if(!mSettingsArea->isIpAddressValid())
|
if(!mSettingsArea->isIpAddressValid())
|
||||||
{
|
{
|
||||||
mErrorText->setErrorText(tr("Ip Address is not valid"));
|
mErrorText->setErrorText(tr("Ip Address is not valid"));
|
||||||
|
|||||||
@@ -104,6 +104,16 @@ bool WorklistSettingsDialog::updateReferenceData()
|
|||||||
mErrorText->setErrorText(tr("Server Port can't be empty"));
|
mErrorText->setErrorText(tr("Server Port can't be empty"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if(!mSettingsArea->isServerAETitleValid())
|
||||||
|
{
|
||||||
|
mErrorText->setErrorText(tr("Server AE is not valid"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(!mSettingsArea->isLocalAETitleValid())
|
||||||
|
{
|
||||||
|
mErrorText->setErrorText(tr("Local AE is not valid"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if(!mSettingsArea->isIpAddressValid())
|
if(!mSettingsArea->isIpAddressValid())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,13 @@
|
|||||||
|
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
|
|
||||||
bool InputFormatValidator::ValidateIpAddressFormat(const QString& aIpAddress)
|
bool InputFormatValidator::ValidateAETitleFormat(const QString &aAeTitle)
|
||||||
|
{
|
||||||
|
QRegularExpression regex("^[0-9a-zA-Z_-]{1,16}$");
|
||||||
|
return regex.match(aAeTitle).hasMatch();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool InputFormatValidator::ValidateIpAddressFormat(const QString &aIpAddress)
|
||||||
{
|
{
|
||||||
QRegularExpression regex("^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$");
|
QRegularExpression regex("^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$");
|
||||||
return regex.match(aIpAddress).hasMatch();
|
return regex.match(aIpAddress).hasMatch();
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ class InputFormatValidator
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InputFormatValidator() = delete;
|
InputFormatValidator() = delete;
|
||||||
|
static bool ValidateAETitleFormat(const QString& aAeTitle);
|
||||||
static bool ValidateIpAddressFormat(const QString& aIpAddress);
|
static bool ValidateIpAddressFormat(const QString& aIpAddress);
|
||||||
static bool ValidatePortFormat(const QString& aPort);
|
static bool ValidatePortFormat(const QString& aPort);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user