Refactor a setPatientDetail method.
This commit is contained in:
@@ -124,13 +124,8 @@ SelectFormWidget::SelectFormWidget(QWidget* parent) :
|
||||
if (model->rowCount() > 0)
|
||||
{
|
||||
table->selectRow(0);
|
||||
PatientInformation pat;
|
||||
#define ADD_PATIENT_PROPERTY(val)\
|
||||
pat. val = model->data(model->index(table->currentIndex().row(),PatientInformationEnum:: val)).toString();
|
||||
EDIT_PATIENT()
|
||||
#undef ADD_PATIENT_PROPERTY
|
||||
edit_patient->setPatientInformation(&pat);
|
||||
}
|
||||
setPatientDetail(table, model, edit_patient);
|
||||
}
|
||||
//events----------------------------------------------------------------------
|
||||
//prepare button state
|
||||
auto prepareButtons = [=](bool disableALL){
|
||||
@@ -142,12 +137,7 @@ SelectFormWidget::SelectFormWidget(QWidget* parent) :
|
||||
};
|
||||
//table current row selection changing event
|
||||
connect(table, &SlideableTableView::currentRowChanged, [=](int row) {
|
||||
PatientInformation pat;
|
||||
#define ADD_PATIENT_PROPERTY(val)\
|
||||
pat. val = model->data(model->index(row,PatientInformationEnum:: val)).toString();
|
||||
EDIT_PATIENT()
|
||||
#undef ADD_PATIENT_PROPERTY
|
||||
edit_patient->setPatientInformation(&pat);
|
||||
setPatientDetail(table, model, edit_patient);
|
||||
prepareButtons(false);
|
||||
});
|
||||
|
||||
@@ -181,6 +171,7 @@ SelectFormWidget::SelectFormWidget(QWidget* parent) :
|
||||
// accept change
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
table->clicked(table->currentIndex());
|
||||
setPatientDetail(table, model, edit_patient);
|
||||
LOG_USER_OPERATION(AddPatient);
|
||||
btnSelect->setEnabled(true);
|
||||
}
|
||||
@@ -204,10 +195,10 @@ SelectFormWidget::SelectFormWidget(QWidget* parent) :
|
||||
selectedRow = 0;
|
||||
}
|
||||
qDebug() << inf->PatientUID << inf->AddDate;
|
||||
#define ADD_PATIENT_PROPERTY(val)\
|
||||
#define ADD_PATIENT_PROPERTY(val)\
|
||||
model->setData(model->index(selectedRow,PatientInformationEnum:: val),inf-> val);
|
||||
EDIT_PATIENT()
|
||||
#undef ADD_PATIENT_PROPERTY
|
||||
#undef ADD_PATIENT_PROPERTY
|
||||
if (model->submitAll())
|
||||
{
|
||||
table->selectRow(selectedRow);
|
||||
@@ -255,16 +246,15 @@ SelectFormWidget::SelectFormWidget(QWidget* parent) :
|
||||
if (model->rowCount() > 0) {
|
||||
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);
|
||||
setPatientDetail(table, model, edit_patient);
|
||||
LOG_USER_OPERATION(DeletePatient);
|
||||
}
|
||||
} else {
|
||||
//TODO:error handle
|
||||
dialog.setButtonMode(OkOnly);
|
||||
dialog.setTitle(tr("Alert"));
|
||||
dialog.setAlertMessage(QString(tr("Can't delete selected Patient , db submit error!")));
|
||||
dialog.exec();
|
||||
}
|
||||
prepareButtons(false);
|
||||
|
||||
@@ -317,6 +307,16 @@ SelectFormWidget::SelectFormWidget(QWidget* parent) :
|
||||
prepareButtons(false);
|
||||
}
|
||||
|
||||
void SelectFormWidget::setPatientDetail(const SlideableTableView *table, const QSqlTableModel *model,
|
||||
EditPatientForm *edit_patient) const {
|
||||
PatientInformation pat;
|
||||
#define ADD_PATIENT_PROPERTY(val)\
|
||||
pat. val = model->data(model->index(table->currentIndex().row(),PatientInformationEnum:: val),Qt::EditRole).toString();
|
||||
EDIT_PATIENT()
|
||||
#undef ADD_PATIENT_PROPERTY
|
||||
edit_patient->setPatientInformation(&pat);
|
||||
}
|
||||
|
||||
|
||||
SelectFormWidget::~SelectFormWidget()
|
||||
{
|
||||
|
||||
@@ -5,9 +5,11 @@
|
||||
#ifndef GUI_SELECTFORMWIDGET_H
|
||||
#define GUI_SELECTFORMWIDGET_H
|
||||
|
||||
|
||||
#include "tabformwidget.h"
|
||||
#include "EditPatientDialog.h"
|
||||
class EditPatientForm;
|
||||
class SlideableTableView;
|
||||
class SelectFormWidget: public TabFormWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -17,6 +19,8 @@ public:
|
||||
private:
|
||||
QString selectedPatientUID;
|
||||
|
||||
void
|
||||
setPatientDetail(const SlideableTableView *table, const QSqlTableModel *model, EditPatientForm *edit_patient) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user