feat: add format validation to all AE Title input editor

This commit is contained in:
kradchen
2025-09-04 09:36:58 +08:00
parent 9326651c52
commit b35312c1b5
6 changed files with 43 additions and 2 deletions

View File

@@ -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());

View File

@@ -18,6 +18,8 @@ public:
explicit DicomSettingsArea(QWidget* aParent = nullptr);
~DicomSettingsArea();
bool isServerAETitleValid();
bool isLocalAETitleValid();
bool isIpAddressValid();
bool isPortValid();
QString getServerIpAddress();

View File

@@ -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"));

View File

@@ -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())
{

View File

@@ -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();

View File

@@ -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);
};