Improve EditPatientDialog errormessage display effect.
This commit is contained in:
@@ -11,6 +11,11 @@
|
||||
#include <QSqlError>
|
||||
#include <QUuid>
|
||||
#include <QDebug>
|
||||
#include <QFont>
|
||||
#include <QFontMetrics>
|
||||
#include <QRegExpValidator>
|
||||
#include <QRegExp>
|
||||
|
||||
|
||||
#include "dialogs/SelectDialog.h"
|
||||
#include "dialogs/DialogManager.h"
|
||||
@@ -46,6 +51,7 @@ EditPatientDialog::EditPatientDialog(QWidget* parent, Qt::WindowFlags f) : GUIFo
|
||||
QLabel* lbl_id = new QLabel(this);
|
||||
lbl_id->setText(tr("ID ") + QString("<font color='#930000'>*</font>"));
|
||||
le_id = new ULineEdit(this);
|
||||
le_id->setValidator(new QRegExpValidator(QRegExp("[a-zA-z0-9]+$")));
|
||||
layout->addWidget(lbl_id);
|
||||
layout->addWidget(le_id);
|
||||
QLabel* lbl_endline1 = new QLabel(this);
|
||||
@@ -56,6 +62,8 @@ EditPatientDialog::EditPatientDialog(QWidget* parent, Qt::WindowFlags f) : GUIFo
|
||||
QLabel* lbl_AccessionNumber = new QLabel(this);
|
||||
lbl_AccessionNumber->setText(tr("Accession Number"));
|
||||
mAccessionNumber = new ULineEdit(this);
|
||||
mAccessionNumber->setValidator(new QRegExpValidator(QRegExp("[a-zA-z0-9]+$")));
|
||||
|
||||
layout->addWidget(lbl_AccessionNumber);
|
||||
layout->addWidget(mAccessionNumber);
|
||||
QLabel* accessionNumber_endline1 = new QLabel(this);
|
||||
@@ -66,6 +74,7 @@ EditPatientDialog::EditPatientDialog(QWidget* parent, Qt::WindowFlags f) : GUIFo
|
||||
QLabel* lbl_name = new QLabel(this);
|
||||
lbl_name->setText(tr("Name") + QString("<font color='#930000'>*</font>"));
|
||||
le_name = new ULineEdit(this);
|
||||
le_name->setValidator(new QRegExpValidator(QRegExp("^[A-Za-z0-9\u4e00-\u9fa5]+$")));
|
||||
layout->addWidget(lbl_name);
|
||||
layout->addWidget(le_name);
|
||||
QLabel* lbl_endline2 = new QLabel(this);
|
||||
@@ -124,6 +133,7 @@ EditPatientDialog::EditPatientDialog(QWidget* parent, Qt::WindowFlags f) : GUIFo
|
||||
lbl_error = new QLabel(this);
|
||||
lbl_error->setObjectName("warn");
|
||||
layout->addWidget(lbl_error);
|
||||
lbl_error->setWordWrap(true);
|
||||
}
|
||||
|
||||
EditPatientDialog::~EditPatientDialog()
|
||||
@@ -155,20 +165,31 @@ void EditPatientDialog::clearPatientInformation()
|
||||
mAccessionNumber->setText("");
|
||||
}
|
||||
|
||||
void EditPatientDialog::showErrorMessage(const QString& aMessage)
|
||||
{
|
||||
QFontMetrics metrics(lbl_error->font());
|
||||
if (metrics.width(aMessage)>450){
|
||||
lbl_error->setMinimumHeight(80);
|
||||
}
|
||||
else{
|
||||
lbl_error->setMinimumHeight(40);
|
||||
}
|
||||
lbl_error->setText(aMessage);
|
||||
lbl_error->setVisible(true);
|
||||
}
|
||||
|
||||
bool EditPatientDialog::updateReferenceData()
|
||||
{
|
||||
PatientInformation* inf = getPatientInformation();
|
||||
if (le_id->text().isEmpty())
|
||||
{
|
||||
lbl_error->setText("ID can't be empty!");
|
||||
lbl_error->setVisible(true);
|
||||
showErrorMessage("ID can't be empty!");
|
||||
return false;
|
||||
}
|
||||
inf->ID = le_id->text().trimmed();
|
||||
if (le_name->text().isEmpty())
|
||||
{
|
||||
lbl_error->setText("Patient Name can't be empty!");
|
||||
lbl_error->setVisible(true);
|
||||
showErrorMessage("Patient Name can't be empty!");
|
||||
return false;
|
||||
}
|
||||
inf->AccessionNumber = mAccessionNumber->text().trimmed();
|
||||
@@ -180,8 +201,7 @@ bool EditPatientDialog::updateReferenceData()
|
||||
int ref_rowid = queryValue(model, 1, inf->ID, 2, inf->AccessionNumber);
|
||||
if (ref_rowid >= 0)
|
||||
{
|
||||
lbl_error->setText("The ID and Accession number is already existed!");
|
||||
lbl_error->setVisible(true);
|
||||
showErrorMessage("The ID and Accession number is already existed!");
|
||||
return false;
|
||||
}
|
||||
inf->PatientUID = QUuid::createUuid().toString();
|
||||
@@ -208,8 +228,7 @@ bool EditPatientDialog::updateReferenceData()
|
||||
else
|
||||
{
|
||||
qDebug()<<model->lastError().text();
|
||||
lbl_error->setText("Submit fail by database error!");
|
||||
lbl_error->setVisible(true);
|
||||
showErrorMessage("Submit fail by database error!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ public:
|
||||
}
|
||||
void setPatientInformation(PatientInformation* information);
|
||||
void clearPatientInformation();
|
||||
void showErrorMessage(const QString& aMessage);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
@@ -245,6 +245,7 @@ QLabel#warn {
|
||||
color: #930000;
|
||||
background: transparent;
|
||||
font-size: 20px;
|
||||
max-height: 80px;
|
||||
}
|
||||
|
||||
QLabel#title {
|
||||
@@ -475,14 +476,12 @@ QLabel#WarningPanelTitle{
|
||||
}
|
||||
QWidget#ErrorPanelContent QLabel#WarningLabelText{
|
||||
font-size: 12px;
|
||||
qproperty-wordWrap:true;
|
||||
margin-left: 1px;
|
||||
border-top: 1px solid darkgoldenrod ;
|
||||
padding-top: 3px;
|
||||
}
|
||||
QWidget#WarningPanelContent QLabel#WarningLabelText{
|
||||
font-size: 12px;
|
||||
qproperty-wordWrap:true;
|
||||
margin-left: 1px;
|
||||
border-top: 1px solid darkgoldenrod;
|
||||
padding-top: 3px;
|
||||
@@ -850,6 +849,8 @@ QWidget#formWidget {
|
||||
|
||||
QWidget#formWidget QLabel{
|
||||
font-size: 32px;
|
||||
/* max-width: 450px; */
|
||||
word-wrap: normal;
|
||||
}
|
||||
|
||||
GUIFormBaseDialog QToolButton{
|
||||
|
||||
Reference in New Issue
Block a user