Change SelectFormWidget, use EditPatientDialog instead of EditPatientForm to fulfill patient edit and adding.
This commit is contained in:
@@ -23,20 +23,8 @@
|
||||
|
||||
#include <QScroller>
|
||||
|
||||
#define ADD_CENTER_ITEM(row,col,text)\
|
||||
item = new QTableWidgetItem(text);\
|
||||
item->setTextAlignment(Qt::AlignmentFlag::AlignCenter);\
|
||||
table->setItem(row,col,item);
|
||||
|
||||
|
||||
int queryValue(QSqlTableModel* model, int colID, QVariant var)
|
||||
{
|
||||
for (int i = 0; i < model->rowCount(); ++i) {
|
||||
if (model->data(model->index(i, colID)) == var) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
SelectFormWidget::SelectFormWidget(QWidget* parent) :
|
||||
TabFormWidget(parent)
|
||||
{
|
||||
@@ -171,20 +159,31 @@ SelectFormWidget::SelectFormWidget(QWidget* parent) :
|
||||
|
||||
// btn add slot
|
||||
connect(btnAdd, &QToolButton::clicked, [=]() {
|
||||
edit_patient->show();
|
||||
btnShowEdit->hide();
|
||||
edit_patient->clearPatientInformation();
|
||||
edit_patient->setEditEnable(true);
|
||||
btnSelect->setEnabled(false);
|
||||
});
|
||||
EditPatientDialog dialog(this);
|
||||
dialog.clearPatientInformation();
|
||||
dialog.setWindowModality(Qt::WindowModal);
|
||||
dialog.setModel(model);
|
||||
// accept change
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
table->selectRow(0);
|
||||
model->selectRow(0);
|
||||
}
|
||||
LOG_USER_OPERATION(AddPatient);
|
||||
btnSelect->setEnabled(true);
|
||||
});
|
||||
|
||||
// btn edit slot
|
||||
connect(btnEdit, &QToolButton::clicked, [=]() {
|
||||
edit_patient->show();
|
||||
btnShowEdit->hide();
|
||||
table->clicked(table->currentIndex());
|
||||
edit_patient->setEditEnable(true);
|
||||
btnSelect->setEnabled(false);
|
||||
EditPatientDialog dialog(this);
|
||||
dialog.setPatientInformation(edit_patient->getPatientInformation());
|
||||
dialog.setWindowModality(Qt::WindowModal);
|
||||
dialog.setModel(model);
|
||||
// accept change
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
table->clicked(table->currentIndex());
|
||||
LOG_USER_OPERATION(AddPatient);
|
||||
btnSelect->setEnabled(true);
|
||||
}
|
||||
});
|
||||
|
||||
// btn add slot
|
||||
@@ -198,17 +197,6 @@ SelectFormWidget::SelectFormWidget(QWidget* parent) :
|
||||
int selectedRow = table->currentIndex().row();
|
||||
bool isAdd = inf->PatientUID.isEmpty();
|
||||
if (isAdd) {
|
||||
int ref_rowid = queryValue(model, 1, inf->ID);
|
||||
if (ref_rowid >= 0)
|
||||
{
|
||||
//非触屏时,如果被选中的行在选中区域外,以下代码可能会出错
|
||||
//但是触屏时一般没问题
|
||||
qDebug() << ref_rowid;
|
||||
table->scrollTo(model->index(ref_rowid, 3));
|
||||
table->selectRow(ref_rowid);
|
||||
result = false;
|
||||
return;
|
||||
}
|
||||
selectedRow = model->rowCount();
|
||||
inf->PatientUID = QUuid::createUuid().toString();
|
||||
inf->AddDate = QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#define GUI_SELECTFORMWIDGET_H
|
||||
|
||||
#include "tabformwidget.h"
|
||||
#include "EditPatientDialog.h"
|
||||
class EditPatientForm;
|
||||
class SelectFormWidget: public TabFormWidget {
|
||||
Q_OBJECT
|
||||
@@ -15,6 +16,7 @@ public:
|
||||
|
||||
private:
|
||||
QString selectedPatientUID;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user