Change SelectFormWidget layout and active logic.

This commit is contained in:
chenhuijun
2024-04-23 15:33:36 +08:00
parent 982b54b727
commit 435569aa70
8 changed files with 353 additions and 497 deletions

View File

@@ -6,102 +6,113 @@
#include <QButtonGroup>
#include <QDateTime>
#include <qboxlayout.h>
#include <QFormLayout>
#include <qdebug.h>
#include <qwidget.h>
#include "event/EventCenter.h"
PatientDetailForm::PatientDetailForm(QWidget* parent) :
QWidget(parent),
mUI(new Ui::PatientDetailForm)
, mBtnEdit(new QToolButton())
, mBtnDelete(new QToolButton())
, mBtnPlaceWidget(new QWidget(this))
, mLblMessage(new QLabel(this))
QWidget(parent)
, mLblPatInfTitle(new QLabel(this))
, mLblDOB(new QLabel(this))
, mLblName(new QLabel(this))
, mLblPatID(new QLabel(this))
, mLblSex(new QLabel(this))
, mLblAccno(new QLabel(this))
, mLblAddDate(new QLabel(this))
{
mUI->setupUi(this);
mUI->lblPatInfPanel->setObjectName("PatInfTitle");
mUI->lblIcon->setObjectName("PatIcon");
mUI->lbl_DOB->setObjectName("displayDetail");
mUI->lbl_Name->setObjectName("displayDetail");
mUI->lblPatID->setObjectName("displayDetail");
mUI->lbl_Sex->setObjectName("displayDetail");
mUI->lblAccno->setObjectName("displayDetail");
mUI->lblAddDate->setObjectName("displayDetail");
connect(EventCenter::Default(), &EventCenter::ReloadLanguage, this,&PatientDetailForm::reloadLanguage);
mBtnPlaceWidget->setFixedHeight(120);
mUI->verticalLayout_2->setSpacing(50);
mLblPatInfTitle->setObjectName("PatInfTitle");
mLblDOB->setObjectName("displayDetail");
mLblName->setObjectName("displayDetail");
mLblPatID->setObjectName("displayDetail");
mLblSex->setObjectName("displayDetail");
mLblAccno->setObjectName("displayDetail");
mLblAddDate->setObjectName("displayDetail");
mUI->verticalLayout_3->insertWidget(5, mBtnPlaceWidget);
mUI->verticalLayout_3->insertWidget(5, mLblMessage);
mLblMessage->setVisible(false);
QHBoxLayout * layout = new QHBoxLayout(mBtnPlaceWidget);
mBtnEdit->setObjectName("btnPatEdit");
mBtnDelete->setObjectName("btnPatDelete");
mBtnEdit->setText(tr("Edit"));
mBtnDelete->setText(tr("Delete"));
layout->addWidget(mBtnEdit);
layout->addWidget(mBtnDelete);
connect(mBtnEdit, &QToolButton::clicked, [=](){
emit editClicked();
});
connect(mBtnDelete, &QToolButton::clicked, [=](){
emit deleteClicked();
});
setBtnEnable(false);
auto layout = new QVBoxLayout(this);
// mLblPatInfTitle->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
mLblPatInfTitle->setAlignment(Qt::AlignCenter);
layout->addWidget(mLblPatInfTitle);
mLblPatInfTitle->setText(tr("Patient Detail"));
addDetailLabel(layout,tr("Name")+":", mLblName);
addDetailLabel(layout,tr("Gender")+":", mLblSex);
addDetailLabel(layout,tr("Birth Date")+":", mLblDOB);
addDetailLabel(layout,tr("PatientID")+":", mLblPatID);
addDetailLabel(layout,tr("AccNo")+":", mLblAccno);
auto widgetLayout = new QHBoxLayout;
layout->addLayout(widgetLayout);
mLblAddDateTitle = new QLabel(tr("Add Date")+":",this);
mLblAddDateTitle->setObjectName("displayTitle");
widgetLayout->addWidget(mLblAddDateTitle);
widgetLayout->addWidget(mLblAddDate);
connect(EventCenter::Default(), &EventCenter::ReloadLanguage, this,&PatientDetailForm::reloadLanguage);
layout->addSpacerItem(new QSpacerItem(2,2,QSizePolicy::Expanding, QSizePolicy::Expanding));
}
void PatientDetailForm::addDetailLabel(QVBoxLayout *layout, const QString& aTitleText, QLabel* aLabel)
{
auto widgetLayout = new QHBoxLayout;
layout->addLayout(widgetLayout);
auto lblTitle = new QLabel(aTitleText,this);
mBtnList.append(lblTitle);
lblTitle->setObjectName("displayTitle");
widgetLayout->addWidget(lblTitle);
widgetLayout->addWidget(aLabel);
}
void PatientDetailForm::reloadLanguage() {
mUI->retranslateUi(this);
mUI->lbl_Sex->setText(mStore.Sex == "F" ? tr("Female") : (mStore.Sex == "M" ? tr("Male") : tr("Other")));
mLblSex->setText(mStore.Sex == "F" ? tr("Female") : (mStore.Sex == "M" ? tr("Male") : tr("Other")));
QList<std::string> strArray = {"Name","Gender","Birth Date","PatientID","AccNo"};
for (size_t i = 0; i < strArray.length(); i++)
{
mBtnList[i]->setText(tr(strArray[i].data())+":");
}
mLblAddDateTitle->setText(tr("Add Date")+":");
mLblPatInfTitle->setText(tr("Patient Detail"));
}
PatientDetailForm::~PatientDetailForm()
{
delete mUI;
}
void PatientDetailForm::setPatientInformation(PatientInformation* information) {
if (information)
{
mUI->lblPatID->setText(tr("PatientID: ")+information->ID);
mUI->lbl_DOB->setText(" "+information->BirthDate);
mUI->lbl_Name->setText(" "+information->Name);
mUI->lbl_Sex->setText(" "+ (information->Sex == "F" ? tr("Female") : (information->Sex == "M" ? tr("Male") : tr("Other"))));
mLblPatID->setText(information->ID);
mLblDOB->setText(information->BirthDate);
mLblName->setText(information->Name);
mLblSex->setText((information->Sex == "F" ? tr("Female") : (information->Sex == "M" ? tr("Male") : tr("Other"))));
mCurrentPatientUID = information->PatientUID;
mUI->lblAddDate->setText(tr("Add Date: ")+ QDateTime::fromString(information->AddDate, Qt::ISODate).toString("yyyy-MM-dd HH:mm:ss"));
mUI->lblAccno->setText(tr("AccNo: ")+information->AccessionNumber);
mLblAddDate->setText(QDateTime::fromString(information->AddDate, Qt::ISODate).toString("yyyy-MM-dd HH:mm:ss"));
mLblAccno->setText(information->AccessionNumber);
mStore = *information;
setBtnEnable(true);
}
}
void PatientDetailForm::clearPatientInformation() {
mUI->lblPatID->clear();
mUI->lbl_DOB->clear();
mUI->lbl_Name->clear();
mUI->lbl_Sex->clear();
mUI->lblAddDate->clear();
mUI->lblAccno->clear();
mLblPatID->clear();
mLblDOB->clear();
mLblName->clear();
mLblSex->clear();
mLblAddDate->clear();
mLblAccno->clear();
}
void PatientDetailForm::confirmModeOn(int protocol)
{
mBtnPlaceWidget->setVisible(false);
mLblMessage->setVisible(true);
mUI->lblPatInfPanel->setText(tr("Scan with this Patient?"));
mUI->lblAddDate->setText(tr("Protocol: ")+(protocol==0?tr("Left"):tr("Right")));
}
void PatientDetailForm::setBtnEnable(bool enable)
{
mBtnDelete->setEnabled(enable);
mBtnEdit->setEnabled(enable);
mLblPatInfTitle->setText(tr("Scan with this Patient?"));
mLblAddDate->setText((protocol==0?tr("Left"):tr("Right")));
mLblAddDateTitle->setText(tr("Protocol"));
}
void PatientDetailForm::storePatientInformation() {