-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpatientview.cpp
52 lines (41 loc) · 1.3 KB
/
patientview.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "patientview.h"
#include "ui_patientview.h"
PatientView::PatientView(QWidget *parent) :
QWidget(parent),
ui(new Ui::PatientView)
{
ui->setupUi(this);
ui->tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->tableView->setSelectionMode(QAbstractItemView::SingleSelection);
ui->tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
ui->tableView->setAlternatingRowColors(true);
DataBase &db = DataBase::getInstance();
if (db.initPatientModel()){
ui->tableView->setModel(db.patientTabModel.get());
ui->tableView->setSelectionModel(db.patientSelection.get());
}
}
PatientView::~PatientView()
{
delete ui;
}
void PatientView::on_pushButton_2_clicked()
{
int currow = DataBase::getInstance().addNewPatient();
emit goPatientEdit(currow);
}
void PatientView::on_btn_find_clicked()
{
QString filter = QString("name like '%%1%'").arg(ui->lineEdit->text());
DataBase::getInstance().searchPatient(filter);
}
void PatientView::on_btn_delete_clicked()
{
DataBase::getInstance().deleteCurrentPatient();
}
void PatientView::on_btn_edit_clicked()
{
// 获取当前选择单元格的模型索引
QModelIndex curIndex = DataBase::getInstance().patientSelection->currentIndex();
emit goPatientEdit(curIndex.row());
}