From 9c20eb6f73a9d75adc1bcdbc7e135770670172b5 Mon Sep 17 00:00:00 2001 From: Krad Date: Wed, 3 Nov 2021 16:19:11 +0800 Subject: [PATCH] Select form state change logic --- src/SelectFormWidget.cpp | 17 ++++++++++++++++- src/editpatientform.cpp | 1 + src/editpatientform.h | 5 +++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/SelectFormWidget.cpp b/src/SelectFormWidget.cpp index 1ba7c30..8082987 100644 --- a/src/SelectFormWidget.cpp +++ b/src/SelectFormWidget.cpp @@ -123,10 +123,15 @@ SelectFormWidget::SelectFormWidget(QWidget *parent) : connect(btnAdd, &QToolButton::clicked,[=](){ edit_patient->clearPatientInformation(); edit_patient->setEditEnable(true); + btnSelect->setEnabled(false); }); connect(btnEdit, &QToolButton::clicked,[=](){ table->clicked(table->currentIndex()); edit_patient->setEditEnable(true); + btnSelect->setEnabled(false); + }); + connect(edit_patient, &EditPatientForm::editCancel,[=](){ + btnSelect->setEnabled(true); }); connect(edit_patient, &EditPatientForm::editAccept,[=](PatientInformation* inf){ int selectedRow = currentRow; @@ -148,11 +153,13 @@ SelectFormWidget::SelectFormWidget(QWidget *parent) : else{ //TODO:add some error handle logic } + btnSelect->setEnabled(true); }); connect(btnDelete, &QToolButton::clicked,[=](){ if (currentRow<0)return; - model->removeRow(currentRow); + model->setData(model->index(currentRow,PatientInformationEnum::Flag),9); +// model->removeRow(currentRow); if (model->submitAll()) { model->select(); @@ -160,12 +167,20 @@ SelectFormWidget::SelectFormWidget(QWidget *parent) : { table->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{ currentRow=-1; } } else{ //TODO:error handle } + + }); connect(btnSelect, &QToolButton::clicked,[=](){ diff --git a/src/editpatientform.cpp b/src/editpatientform.cpp index 55e178e..cbf2729 100644 --- a/src/editpatientform.cpp +++ b/src/editpatientform.cpp @@ -47,6 +47,7 @@ EditPatientForm::EditPatientForm(QWidget *parent) : clearPatientInformation(); this->setEditEnable(false); restorePatientInformation(); + emit editCancel(); }); connect(btnEditAccept,&QToolButton::clicked,[=](){ if (ui->tbx_ID->text().isEmpty())return; diff --git a/src/editpatientform.h b/src/editpatientform.h index 3873de3..0a4214d 100644 --- a/src/editpatientform.h +++ b/src/editpatientform.h @@ -13,6 +13,7 @@ ADD_PATIENT_PROPERTY(Name)\ ADD_PATIENT_PROPERTY(BirthDate)\ ADD_PATIENT_PROPERTY(Sex)\ ADD_PATIENT_PROPERTY(Comment)\ +ADD_PATIENT_PROPERTY(Flag) #define EDIT_PATIENT()\ ADD_PATIENT_PROPERTY(PatientUID)\ @@ -33,6 +34,9 @@ public: #define ADD_PATIENT_PROPERTY(val) QString val; EDIT_PATIENT(); #undef ADD_PATIENT_PROPERTY + PatientInformation(){ + this->Flag = QString("0"); + } PatientInformation* Copy() { PatientInformation* n=new PatientInformation; @@ -64,6 +68,7 @@ public: void setEditEnable(bool enable); signals: void editAccept(PatientInformation * detail); + void editCancel(); private: Ui::EditPatientForm *ui; QString currentPatientUID;