Change SelectFormWidget, use EditPatientDialog instead of EditPatientForm to fulfill patient edit and adding.
This commit is contained in:
@@ -23,20 +23,8 @@
|
|||||||
|
|
||||||
#include <QScroller>
|
#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) :
|
SelectFormWidget::SelectFormWidget(QWidget* parent) :
|
||||||
TabFormWidget(parent)
|
TabFormWidget(parent)
|
||||||
{
|
{
|
||||||
@@ -171,20 +159,31 @@ SelectFormWidget::SelectFormWidget(QWidget* parent) :
|
|||||||
|
|
||||||
// btn add slot
|
// btn add slot
|
||||||
connect(btnAdd, &QToolButton::clicked, [=]() {
|
connect(btnAdd, &QToolButton::clicked, [=]() {
|
||||||
edit_patient->show();
|
EditPatientDialog dialog(this);
|
||||||
btnShowEdit->hide();
|
dialog.clearPatientInformation();
|
||||||
edit_patient->clearPatientInformation();
|
dialog.setWindowModality(Qt::WindowModal);
|
||||||
edit_patient->setEditEnable(true);
|
dialog.setModel(model);
|
||||||
btnSelect->setEnabled(false);
|
// accept change
|
||||||
|
if (dialog.exec() == QDialog::Accepted) {
|
||||||
|
table->selectRow(0);
|
||||||
|
model->selectRow(0);
|
||||||
|
}
|
||||||
|
LOG_USER_OPERATION(AddPatient);
|
||||||
|
btnSelect->setEnabled(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
// btn edit slot
|
// btn edit slot
|
||||||
connect(btnEdit, &QToolButton::clicked, [=]() {
|
connect(btnEdit, &QToolButton::clicked, [=]() {
|
||||||
edit_patient->show();
|
EditPatientDialog dialog(this);
|
||||||
btnShowEdit->hide();
|
dialog.setPatientInformation(edit_patient->getPatientInformation());
|
||||||
|
dialog.setWindowModality(Qt::WindowModal);
|
||||||
|
dialog.setModel(model);
|
||||||
|
// accept change
|
||||||
|
if (dialog.exec() == QDialog::Accepted) {
|
||||||
table->clicked(table->currentIndex());
|
table->clicked(table->currentIndex());
|
||||||
edit_patient->setEditEnable(true);
|
LOG_USER_OPERATION(AddPatient);
|
||||||
btnSelect->setEnabled(false);
|
btnSelect->setEnabled(true);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// btn add slot
|
// btn add slot
|
||||||
@@ -198,17 +197,6 @@ SelectFormWidget::SelectFormWidget(QWidget* parent) :
|
|||||||
int selectedRow = table->currentIndex().row();
|
int selectedRow = table->currentIndex().row();
|
||||||
bool isAdd = inf->PatientUID.isEmpty();
|
bool isAdd = inf->PatientUID.isEmpty();
|
||||||
if (isAdd) {
|
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();
|
selectedRow = model->rowCount();
|
||||||
inf->PatientUID = QUuid::createUuid().toString();
|
inf->PatientUID = QUuid::createUuid().toString();
|
||||||
inf->AddDate = QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss");
|
inf->AddDate = QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#define GUI_SELECTFORMWIDGET_H
|
#define GUI_SELECTFORMWIDGET_H
|
||||||
|
|
||||||
#include "tabformwidget.h"
|
#include "tabformwidget.h"
|
||||||
|
#include "EditPatientDialog.h"
|
||||||
class EditPatientForm;
|
class EditPatientForm;
|
||||||
class SelectFormWidget: public TabFormWidget {
|
class SelectFormWidget: public TabFormWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -15,6 +16,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QString selectedPatientUID;
|
QString selectedPatientUID;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user