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