Select form state change logic

This commit is contained in:
Krad
2021-11-03 16:19:11 +08:00
parent f3d38dc02e
commit 9c20eb6f73
3 changed files with 22 additions and 1 deletions

View File

@@ -123,10 +123,15 @@ SelectFormWidget::SelectFormWidget(QWidget *parent) :
connect(btnAdd, &QToolButton::clicked,[=](){ connect(btnAdd, &QToolButton::clicked,[=](){
edit_patient->clearPatientInformation(); edit_patient->clearPatientInformation();
edit_patient->setEditEnable(true); edit_patient->setEditEnable(true);
btnSelect->setEnabled(false);
}); });
connect(btnEdit, &QToolButton::clicked,[=](){ connect(btnEdit, &QToolButton::clicked,[=](){
table->clicked(table->currentIndex()); table->clicked(table->currentIndex());
edit_patient->setEditEnable(true); edit_patient->setEditEnable(true);
btnSelect->setEnabled(false);
});
connect(edit_patient, &EditPatientForm::editCancel,[=](){
btnSelect->setEnabled(true);
}); });
connect(edit_patient, &EditPatientForm::editAccept,[=](PatientInformation* inf){ connect(edit_patient, &EditPatientForm::editAccept,[=](PatientInformation* inf){
int selectedRow = currentRow; int selectedRow = currentRow;
@@ -148,11 +153,13 @@ SelectFormWidget::SelectFormWidget(QWidget *parent) :
else{ else{
//TODO:add some error handle logic //TODO:add some error handle logic
} }
btnSelect->setEnabled(true);
}); });
connect(btnDelete, &QToolButton::clicked,[=](){ connect(btnDelete, &QToolButton::clicked,[=](){
if (currentRow<0)return; if (currentRow<0)return;
model->removeRow(currentRow); model->setData(model->index(currentRow,PatientInformationEnum::Flag),9);
// model->removeRow(currentRow);
if (model->submitAll()) if (model->submitAll())
{ {
model->select(); model->select();
@@ -160,12 +167,20 @@ SelectFormWidget::SelectFormWidget(QWidget *parent) :
{ {
table->selectRow(0); table->selectRow(0);
model->selectRow(0); model->selectRow(0);
PatientInformation pat;
#define ADD_PATIENT_PROPERTY(val)\
pat. val = model->data(model->index(0,PatientInformationEnum:: val)).toString();
EDIT_PATIENT()
#undef ADD_PATIENT_PROPERTY
edit_patient->setPatientInformation(&pat);
} else{ } else{
currentRow=-1; currentRow=-1;
} }
} else{ } else{
//TODO:error handle //TODO:error handle
} }
}); });
connect(btnSelect, &QToolButton::clicked,[=](){ connect(btnSelect, &QToolButton::clicked,[=](){

View File

@@ -47,6 +47,7 @@ EditPatientForm::EditPatientForm(QWidget *parent) :
clearPatientInformation(); clearPatientInformation();
this->setEditEnable(false); this->setEditEnable(false);
restorePatientInformation(); restorePatientInformation();
emit editCancel();
}); });
connect(btnEditAccept,&QToolButton::clicked,[=](){ connect(btnEditAccept,&QToolButton::clicked,[=](){
if (ui->tbx_ID->text().isEmpty())return; if (ui->tbx_ID->text().isEmpty())return;

View File

@@ -13,6 +13,7 @@ ADD_PATIENT_PROPERTY(Name)\
ADD_PATIENT_PROPERTY(BirthDate)\ ADD_PATIENT_PROPERTY(BirthDate)\
ADD_PATIENT_PROPERTY(Sex)\ ADD_PATIENT_PROPERTY(Sex)\
ADD_PATIENT_PROPERTY(Comment)\ ADD_PATIENT_PROPERTY(Comment)\
ADD_PATIENT_PROPERTY(Flag)
#define EDIT_PATIENT()\ #define EDIT_PATIENT()\
ADD_PATIENT_PROPERTY(PatientUID)\ ADD_PATIENT_PROPERTY(PatientUID)\
@@ -33,6 +34,9 @@ public:
#define ADD_PATIENT_PROPERTY(val) QString val; #define ADD_PATIENT_PROPERTY(val) QString val;
EDIT_PATIENT(); EDIT_PATIENT();
#undef ADD_PATIENT_PROPERTY #undef ADD_PATIENT_PROPERTY
PatientInformation(){
this->Flag = QString("0");
}
PatientInformation* Copy() PatientInformation* Copy()
{ {
PatientInformation* n=new PatientInformation; PatientInformation* n=new PatientInformation;
@@ -64,6 +68,7 @@ public:
void setEditEnable(bool enable); void setEditEnable(bool enable);
signals: signals:
void editAccept(PatientInformation * detail); void editAccept(PatientInformation * detail);
void editCancel();
private: private:
Ui::EditPatientForm *ui; Ui::EditPatientForm *ui;
QString currentPatientUID; QString currentPatientUID;