New UI for sex choose

This commit is contained in:
Krad
2021-10-12 15:07:06 +08:00
parent 4de4cfd25a
commit 8406ac104c
10 changed files with 66 additions and 64 deletions

View File

@@ -3,6 +3,7 @@
#include <QListView>
#include <QHBoxLayout>
#include <QToolButton>
#include <QButtonGroup>
#include "guimacros.h"
#include <qdebug.h>
EditPatientForm::EditPatientForm(QWidget *parent) :
@@ -10,11 +11,28 @@ EditPatientForm::EditPatientForm(QWidget *parent) :
ui(new Ui::EditPatientForm)
{
ui->setupUi(this);
QListView* sex_v = new QListView(ui->cb_Sex);
sex_v->setItemAlignment(Qt::AlignCenter);
ui->cb_Sex->setView(sex_v);
QHBoxLayout* layout =new QHBoxLayout();
this->ui->editcmdWidget->setLayout(layout);
QHBoxLayout* sexlayout =new QHBoxLayout(ui->sexpanelwidget);
sexlayout->setMargin(6);
ADD_TOOL_SIZE_BTN_TO_LAYOUT(F,":/icons/female_d.png",30, sexlayout);
ADD_TOOL_SIZE_BTN_TO_LAYOUT(M,":/icons/male_d.png", 30,sexlayout);
// btnFemale->setToolButtonStyle(Qt::ToolButtonIconOnly);
// btnMale->setToolButtonStyle(Qt::ToolButtonIconOnly);
btnF->setObjectName("sexBtn");
btnM->setObjectName("sexBtn");
btnF->setText("Female");
btnM->setText("Male");
ui->sexpanelwidget->setEnabled(editEnable);
btnF->setEnabled(editEnable);
btnM->setEnabled(editEnable);
btnF->setCheckable(true);
btnM->setCheckable(true);
QButtonGroup* group= new QButtonGroup(this);
group->addButton(btnF);
group->addButton(btnM);
btnF->setChecked(true);
btnFemale=btnF;
btnMale=btnM;
QHBoxLayout* layout =new QHBoxLayout(this->ui->editcmdWidget);
ADD_TOOL_BTN(Cancel,":/icons/close_circle.png");
ADD_TOOL_BTN(Accpet,":/icons/selected.png");
btnCancel->setEnabled(editEnable);
@@ -31,6 +49,8 @@ EditPatientForm::EditPatientForm(QWidget *parent) :
restorePatientInformation();
});
connect(btnEditAccept,&QToolButton::clicked,[=](){
if (ui->tbx_ID->text().isEmpty())return;
if (ui->tbx_Name->text().isEmpty())return;
storePatientInformation();
this->setEditEnable(false);
emit editAccept(getPatientInformation());
@@ -49,7 +69,8 @@ void EditPatientForm::setPatientInformation(PatientInformation *information) {
ui->tbx_Dob->setDate(QDate::fromString(information->BirthDate,"yyyy-MM-dd"));
ui->tbx_Name->setText(information->Name);
ui->rtbx_Comment->setText(information->Comment);
ui->cb_Sex->setCurrentIndex(information->Sex=="F"?1:(information->Name=="M"?0:2));
btnFemale->setChecked(information->Sex=="F");
btnMale->setChecked(information->Sex!="F");
currentPatientUID = information->PatientUID;
storePatientInformation();
}
@@ -59,6 +80,8 @@ void EditPatientForm::clearPatientInformation() {
ui->tbx_ID->setText("");
ui->tbx_Dob->setDate(QDate::currentDate());
ui->tbx_Name->setText("");
btnFemale->setChecked(true);
btnMale->setChecked(false);
ui->rtbx_Comment->setText("");
currentPatientUID = "";
}
@@ -67,7 +90,11 @@ void EditPatientForm::setEditEnable(bool enable) {
ui->tbx_ID->setEnabled(enable);
ui->tbx_Dob->setEnabled(enable);
ui->tbx_Name->setEnabled(enable);
ui->cb_Sex->setEnabled(enable);
ui->sexpanelwidget->setEnabled(enable);
btnFemale->setEnabled(enable);
btnFemale->setIcon(QIcon(enable?":/icons/female.png":":/icons/female_d.png"));
btnMale->setEnabled(enable);
btnMale->setIcon(QIcon(enable?":/icons/male.png":":/icons/male_d.png"));
ui->rtbx_Comment->setEnabled(enable);
btnEditAccept->setEnabled(enable);
btnEditCancel->setEnabled(enable);
@@ -82,7 +109,7 @@ void EditPatientForm::storePatientInformation() {
store.ID = ui->tbx_ID->text();
store.BirthDate = ui->tbx_Dob->date().toString("yyyy-MM-dd");
store.Name = ui->tbx_Name->text();
store.Sex = ui->cb_Sex->currentText().left(1);
store.Sex = btnFemale->isChecked()?"F":"M";
store.Comment = ui->rtbx_Comment->toPlainText();
qDebug()<<store.PatientUID<<","<<store.ID<<","<<store.BirthDate<<","<<store.Name<<","<<store.Sex;
}
@@ -93,6 +120,8 @@ void EditPatientForm::restorePatientInformation() {
ui->tbx_Dob->setDate(QDate::fromString(store.BirthDate,"yyyy-MM-dd"));
ui->tbx_Name->setText(store.Name);
ui->rtbx_Comment->setText(store.Comment);
ui->cb_Sex->setCurrentText(store.Sex=="F"?"Female":(store.Name=="M"?"Male":"Other"));
btnFemale->setChecked(store.Sex=="F");
btnMale->setChecked(store.Sex!="F");
// ui->cb_Sex->setCurrentText(store.Sex=="F"?"Female":(store.Name=="M"?"Male":"Other"));
}