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