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