89 lines
3.1 KiB
C++
89 lines
3.1 KiB
C++
#include "editpatientform.h"
|
|
#include "ui_editpatientform.h"
|
|
#include <QListView>
|
|
#include <QHBoxLayout>
|
|
#include <QToolButton>
|
|
#include "guimacros.h"
|
|
EditPatientForm::EditPatientForm(QWidget *parent) :
|
|
QWidget(parent),
|
|
ui(new Ui::EditPatientForm)
|
|
{
|
|
ui->setupUi(this);
|
|
QListView* sex_v = new QListView(ui->cb_Sex);
|
|
sex_v->setItemAlignment(Qt::AlignCenter);
|
|
ui->cb_Sex->setView(sex_v);
|
|
QHBoxLayout* layout =new QHBoxLayout();
|
|
this->ui->editcmdWidget->setLayout(layout);
|
|
ADD_TOOL_BTN(Cancel,":/icons/close_circle.png");
|
|
ADD_TOOL_BTN(Accpet,":/icons/selected.png");
|
|
btnCancel->setEnabled(editEnable);
|
|
btnCancel->setToolButtonStyle(Qt::ToolButtonIconOnly);
|
|
btnCancel->setIcon(QIcon(editEnable?":/icons/close_circle.png":":/icons/close_circle_d.png"));
|
|
btnAccpet->setEnabled(editEnable);
|
|
btnAccpet->setToolButtonStyle(Qt::ToolButtonIconOnly);
|
|
btnAccpet->setIcon(QIcon(editEnable?":/icons/selected.png":":/icons/selected_d.png"));
|
|
btnEditAccept = btnAccpet;
|
|
btnEditCancel = btnCancel;
|
|
connect(btnEditCancel,&QToolButton::clicked,[=](){
|
|
clearPatientInformation();
|
|
this->setEditEnable(false);
|
|
restorePatientInformation();
|
|
});
|
|
connect(btnEditAccept,&QToolButton::clicked,[=](){
|
|
storePatientInformation();
|
|
this->setEditEnable(false);
|
|
emit editAccept(getPatientInformation());
|
|
});
|
|
}
|
|
|
|
EditPatientForm::~EditPatientForm()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
void EditPatientForm::setPatientInformation(PatientInformation *information) {
|
|
if (information)
|
|
{
|
|
ui->tbx_ID->setText(information->ID);
|
|
ui->tbx_Dob->setDate(QDate::fromString(information->BirthDate,"yyyy-MM-dd"));
|
|
ui->tbx_Name->setText(information->Name=="F"?"Female":(information->Name=="M"?"Male":"Other"));
|
|
currentPatientUID = information->PatientUID;
|
|
storePatientInformation();
|
|
}
|
|
}
|
|
|
|
void EditPatientForm::clearPatientInformation() {
|
|
ui->tbx_ID->setText("");
|
|
ui->tbx_Dob->setDate(QDate::currentDate());
|
|
ui->tbx_Name->setText("");
|
|
currentPatientUID = "";
|
|
}
|
|
|
|
void EditPatientForm::setEditEnable(bool enable) {
|
|
ui->tbx_ID->setEnabled(enable);
|
|
ui->tbx_Dob->setEnabled(enable);
|
|
ui->tbx_Name->setEnabled(enable);
|
|
ui->cb_Sex->setEnabled(enable);
|
|
ui->rtbx_Comment->setEnabled(enable);
|
|
btnEditAccept->setEnabled(enable);
|
|
btnEditCancel->setEnabled(enable);
|
|
btnEditCancel->setIcon(QIcon(enable?":/icons/close_circle.png":":/icons/close_circle_d.png"));
|
|
btnEditAccept->setIcon(QIcon(enable?":/icons/selected.png":":/icons/selected_d.png"));
|
|
editEnable = enable;
|
|
// ui->->setEnabled(enable);
|
|
}
|
|
|
|
void EditPatientForm::storePatientInformation() {
|
|
store.PatientUID =currentPatientUID;
|
|
store.ID = ui->tbx_ID->text();
|
|
store.BirthDate = ui->tbx_Dob->date().toString("yyyy-MM-dd");
|
|
store.Name = ui->tbx_Name->text();
|
|
}
|
|
|
|
void EditPatientForm::restorePatientInformation() {
|
|
currentPatientUID = store.PatientUID;
|
|
ui->tbx_ID->setText(store.ID);
|
|
ui->tbx_Dob->setDate(QDate::fromString(store.BirthDate,"yyyy-MM-dd"));
|
|
ui->tbx_Name->setText(store.Name);
|
|
}
|