Refactor TopBarWidget & SelectFormWidget.(clean and rename member)
This commit is contained in:
@@ -3,55 +3,56 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "TopBarWidget.h"
|
#include "TopBarWidget.h"
|
||||||
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include "components/RollingMessageWidget.h"
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
|
||||||
|
#include "components/RollingMessageWidget.h"
|
||||||
#include "event/EventCenter.h"
|
#include "event/EventCenter.h"
|
||||||
#include "errorhandle/GUIErrorLW.h"
|
#include "errorhandle/GUIErrorLW.h"
|
||||||
#include "json/jsonobject.h"
|
#include "json/jsonobject.h"
|
||||||
|
|
||||||
TopBarWidget::TopBarWidget(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f) {
|
TopBarWidget::TopBarWidget(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f) {
|
||||||
QHBoxLayout* layout = new QHBoxLayout(this);
|
auto layout = new QHBoxLayout(this);
|
||||||
layout->setMargin(0);
|
layout->setMargin(0);
|
||||||
QLabel * logo = new QLabel(this);
|
auto logo = new QLabel(this);
|
||||||
logo->setObjectName("logo");
|
logo->setObjectName("logo");
|
||||||
layout->addWidget(logo);
|
layout->addWidget(logo);
|
||||||
QLabel * company = new QLabel(this);
|
auto company = new QLabel(this);
|
||||||
company->setObjectName("company");
|
company->setObjectName("company");
|
||||||
layout->addWidget(company);
|
layout->addWidget(company);
|
||||||
company->setText(tr("浙江衡玖医疗科技"));
|
company->setText(tr("浙江衡玖医疗科技"));
|
||||||
QWidget* spacerLine0 = new QWidget(this);
|
auto spacerLine0 = new QWidget(this);
|
||||||
spacerLine0->setFixedWidth(2);
|
spacerLine0->setFixedWidth(2);
|
||||||
spacerLine0->setObjectName("verSpaceLine");
|
spacerLine0->setObjectName("verSpaceLine");
|
||||||
layout->addWidget(spacerLine0);
|
layout->addWidget(spacerLine0);
|
||||||
QLabel * lbl_msglogo = new QLabel(this);
|
auto lbl_msglogo = new QLabel(this);
|
||||||
lbl_msglogo->setObjectName("msglogo");
|
lbl_msglogo->setObjectName("msglogo");
|
||||||
layout->addWidget(lbl_msglogo);
|
layout->addWidget(lbl_msglogo);
|
||||||
|
|
||||||
QWidget* widgetMsg = new QWidget(this);
|
auto widgetMsg = new QWidget(this);
|
||||||
layout->addWidget(widgetMsg,1);
|
layout->addWidget(widgetMsg,1);
|
||||||
widgetMsg->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
|
widgetMsg->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
|
||||||
layout->addSpacerItem(new QSpacerItem(10, 10, QSizePolicy::Expanding));
|
layout->addSpacerItem(new QSpacerItem(10, 10, QSizePolicy::Expanding));
|
||||||
QWidget* statusBarWidget = new QWidget(this);
|
auto statusBarWidget = new QWidget(this);
|
||||||
layout->addWidget(statusBarWidget);
|
layout->addWidget(statusBarWidget);
|
||||||
QLabel* hosp = new QLabel(this);
|
auto hosp = new QLabel(this);
|
||||||
hosp->setText(JsonObject::Instance()->institutionName());
|
hosp->setText(JsonObject::Instance()->institutionName());
|
||||||
QLabel* nowDate = new QLabel(this);
|
auto nowDate = new QLabel(this);
|
||||||
nowDate->setText(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss"));
|
nowDate->setText(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss"));
|
||||||
QLabel* linkIcon = new QLabel(this);
|
auto linkIcon = new QLabel(this);
|
||||||
linkIcon->setObjectName("link");
|
linkIcon->setObjectName("link");
|
||||||
QLabel* readyIcon = new QLabel(this);
|
auto readyIcon = new QLabel(this);
|
||||||
readyIcon->setObjectName("ready");
|
readyIcon->setObjectName("ready");
|
||||||
QLabel* lockIcon = new QLabel(this);
|
auto lockIcon = new QLabel(this);
|
||||||
lockIcon->setText("");
|
lockIcon->setText("");
|
||||||
// lockIcon->setPixmap(QPixmap(":/icons/lock.png").scaledToHeight(22,Qt::SmoothTransformation));
|
auto status_layout = new QHBoxLayout(statusBarWidget);
|
||||||
QHBoxLayout* status_layout = new QHBoxLayout(statusBarWidget);
|
|
||||||
status_layout->setMargin(0);
|
status_layout->setMargin(0);
|
||||||
|
|
||||||
status_layout->addWidget(hosp);
|
status_layout->addWidget(hosp);
|
||||||
status_layout->addWidget(nowDate);
|
status_layout->addWidget(nowDate);
|
||||||
QWidget* spacerLine = new QWidget(this);
|
auto spacerLine = new QWidget(this);
|
||||||
spacerLine->setFixedWidth(2);
|
spacerLine->setFixedWidth(2);
|
||||||
spacerLine->setObjectName("verSpaceLine");
|
spacerLine->setObjectName("verSpaceLine");
|
||||||
|
|
||||||
@@ -60,7 +61,7 @@ TopBarWidget::TopBarWidget(QWidget *parent, Qt::WindowFlags f) : QWidget(parent,
|
|||||||
layout->addWidget(readyIcon);
|
layout->addWidget(readyIcon);
|
||||||
layout->addWidget(lockIcon);
|
layout->addWidget(lockIcon);
|
||||||
|
|
||||||
QVBoxLayout* l = new QVBoxLayout(widgetMsg);
|
auto l = new QVBoxLayout(widgetMsg);
|
||||||
l->setMargin(0);
|
l->setMargin(0);
|
||||||
auto w = new RollingMessageWidget(this);
|
auto w = new RollingMessageWidget(this);
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ PatientDetailForm::PatientDetailForm(QWidget* parent) :
|
|||||||
{
|
{
|
||||||
mUI->setupUi(this);
|
mUI->setupUi(this);
|
||||||
mUI->hideBtn->setSizePolicy(QSizePolicy::Policy::Expanding, QSizePolicy::Policy::Preferred);
|
mUI->hideBtn->setSizePolicy(QSizePolicy::Policy::Expanding, QSizePolicy::Policy::Preferred);
|
||||||
mUI->hideBtn->setObjectName("hideeditBtn");
|
mUI->hideBtn->setObjectName("btnHidePanel");
|
||||||
mUI->hideBtn->setText(tr(" Hide Panel"));
|
mUI->hideBtn->setText(tr(" Hide Panel"));
|
||||||
connect(mUI->hideBtn, &QToolButton::clicked, [=](){
|
connect(mUI->hideBtn, &QToolButton::clicked, [=](){
|
||||||
emit hideBtnClicked();
|
emit hideBtnClicked();
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ SelectFormWidget::SelectFormWidget(QWidget* parent)
|
|||||||
, mBtnSelect(new QToolButton(this))
|
, mBtnSelect(new QToolButton(this))
|
||||||
, mPatTable(new SlideTableView(this))
|
, mPatTable(new SlideTableView(this))
|
||||||
, mModel(nullptr)
|
, mModel(nullptr)
|
||||||
, mEditPatForm(new PatientDetailForm(this))
|
, patientDetailForm(new PatientDetailForm(this))
|
||||||
{
|
{
|
||||||
//init command bar
|
//init command bar
|
||||||
auto layout = new QHBoxLayout();
|
auto layout = new QHBoxLayout();
|
||||||
@@ -51,7 +51,7 @@ SelectFormWidget::SelectFormWidget(QWidget* parent)
|
|||||||
if (mModel->rowCount() > 0)
|
if (mModel->rowCount() > 0)
|
||||||
{
|
{
|
||||||
mPatTable->selectRow(0);
|
mPatTable->selectRow(0);
|
||||||
setPatientDetail(mPatTable, mModel, mEditPatForm);
|
setPatientDetail(mPatTable, mModel, patientDetailForm);
|
||||||
}
|
}
|
||||||
// event ResponsePreview slot
|
// event ResponsePreview slot
|
||||||
connect(EventCenter::Default(), &EventCenter::ResponsePreview, [=](QObject* sender, QObject* data) {
|
connect(EventCenter::Default(), &EventCenter::ResponsePreview, [=](QObject* sender, QObject* data) {
|
||||||
@@ -122,7 +122,7 @@ void SelectFormWidget::editPatient() {
|
|||||||
dialog.clearPatientInformation();
|
dialog.clearPatientInformation();
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
dialog.setPatientInformation(mEditPatForm->getPatientInformation());
|
dialog.setPatientInformation(patientDetailForm->getPatientInformation());
|
||||||
}
|
}
|
||||||
|
|
||||||
dialog.setWindowModality(Qt::WindowModal);
|
dialog.setWindowModality(Qt::WindowModal);
|
||||||
@@ -135,7 +135,7 @@ void SelectFormWidget::editPatient() {
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
mPatTable->clicked(mPatTable->currentIndex());
|
mPatTable->clicked(mPatTable->currentIndex());
|
||||||
setPatientDetail(mPatTable, mModel, mEditPatForm);
|
setPatientDetail(mPatTable, mModel, patientDetailForm);
|
||||||
}
|
}
|
||||||
LOG_USER_OPERATION(AddPatient)
|
LOG_USER_OPERATION(AddPatient)
|
||||||
mBtnSelect->setEnabled(true);
|
mBtnSelect->setEnabled(true);
|
||||||
@@ -162,7 +162,7 @@ void SelectFormWidget::delPatient() {
|
|||||||
dialog.setAlertMessage(QString(tr("Delete Patient \"%1\" ?")).arg(pat_name));
|
dialog.setAlertMessage(QString(tr("Delete Patient \"%1\" ?")).arg(pat_name));
|
||||||
if (dialog.exec() != QDialog::Accepted) return;
|
if (dialog.exec() != QDialog::Accepted) return;
|
||||||
// need delete clear edit panel detail
|
// need delete clear edit panel detail
|
||||||
mEditPatForm->clearPatientInformation();
|
patientDetailForm->clearPatientInformation();
|
||||||
mModel->setData(mModel->index(mPatTable->currentIndex().row(), Flag), 9);
|
mModel->setData(mModel->index(mPatTable->currentIndex().row(), Flag), 9);
|
||||||
|
|
||||||
if (mModel->submitAll()) {
|
if (mModel->submitAll()) {
|
||||||
@@ -170,7 +170,7 @@ void SelectFormWidget::delPatient() {
|
|||||||
if (mModel->rowCount() > 0) {
|
if (mModel->rowCount() > 0) {
|
||||||
mPatTable->selectRow(0);
|
mPatTable->selectRow(0);
|
||||||
mModel->selectRow(0);
|
mModel->selectRow(0);
|
||||||
setPatientDetail(mPatTable, mModel, mEditPatForm);
|
setPatientDetail(mPatTable, mModel, patientDetailForm);
|
||||||
LOG_USER_OPERATION(DeletePatient)
|
LOG_USER_OPERATION(DeletePatient)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -184,17 +184,17 @@ void SelectFormWidget::delPatient() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SelectFormWidget::selectPatient() {
|
void SelectFormWidget::selectPatient() {
|
||||||
EventCenter::Default()->triggerEvent(PatientSelected, nullptr, mEditPatForm->getPatientInformation()->Copy());
|
EventCenter::Default()->triggerEvent(PatientSelected, nullptr, patientDetailForm->getPatientInformation()->Copy());
|
||||||
selectedPatientUID = mEditPatForm->getPatientInformation()->PatientUID;
|
selectedPatientUID = patientDetailForm->getPatientInformation()->PatientUID;
|
||||||
LOG_USER_OPERATION(SelectPatient)
|
LOG_USER_OPERATION(SelectPatient)
|
||||||
}
|
}
|
||||||
|
|
||||||
void SelectFormWidget::initDetailPanel(QHBoxLayout *contentLayout) {// prepare edit panel
|
void SelectFormWidget::initDetailPanel(QHBoxLayout *contentLayout) {// prepare edit panel
|
||||||
mEditPatForm->setObjectName("patientDetailWidget");
|
patientDetailForm->setObjectName("patientDetailWidget");
|
||||||
mEditPatForm->hide();
|
patientDetailForm->hide();
|
||||||
contentLayout->addWidget(mEditPatForm);
|
contentLayout->addWidget(patientDetailForm);
|
||||||
auto* btnShowEdit = new VerticalTextToolButton(this);
|
auto* btnShowEdit = new VerticalTextToolButton(this);
|
||||||
btnShowEdit->setObjectName("showeditBtn");
|
btnShowEdit->setObjectName("btnShowPanel");
|
||||||
btnShowEdit->setFixedHeight(225);
|
btnShowEdit->setFixedHeight(225);
|
||||||
btnShowEdit->setVerticalText("Patient Detail");
|
btnShowEdit->setVerticalText("Patient Detail");
|
||||||
contentLayout->addWidget(btnShowEdit);
|
contentLayout->addWidget(btnShowEdit);
|
||||||
@@ -202,12 +202,12 @@ void SelectFormWidget::initDetailPanel(QHBoxLayout *contentLayout) {// prepare e
|
|||||||
|
|
||||||
// btn show slot
|
// btn show slot
|
||||||
connect(btnShowEdit, &QToolButton::clicked, [=]() {
|
connect(btnShowEdit, &QToolButton::clicked, [=]() {
|
||||||
mEditPatForm->show();
|
patientDetailForm->show();
|
||||||
btnShowEdit->hide();
|
btnShowEdit->hide();
|
||||||
});
|
});
|
||||||
//btn hide slot
|
//btn hide slot
|
||||||
connect(mEditPatForm, &PatientDetailForm::hideBtnClicked, [=]() {
|
connect(patientDetailForm, &PatientDetailForm::hideBtnClicked, [=]() {
|
||||||
mEditPatForm->hide();
|
patientDetailForm->hide();
|
||||||
btnShowEdit->show();
|
btnShowEdit->show();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -238,13 +238,13 @@ void SelectFormWidget::initTableView(QHBoxLayout *contentLayout) {// TableView f
|
|||||||
contentLayout->addWidget(mPatTable);
|
contentLayout->addWidget(mPatTable);
|
||||||
//table current row selection changing event
|
//table current row selection changing event
|
||||||
connect(mPatTable, &SlideTableView::currentRowChanged, [=](int row) {
|
connect(mPatTable, &SlideTableView::currentRowChanged, [=](int row) {
|
||||||
setPatientDetail(mPatTable, mModel, mEditPatForm);
|
setPatientDetail(mPatTable, mModel, patientDetailForm);
|
||||||
prepareButtons(false);
|
prepareButtons(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
// after sort by column
|
// after sort by column
|
||||||
connect(mPatTable->horizontalHeader(), &QHeaderView::sectionClicked, [=](int index){
|
connect(mPatTable->horizontalHeader(), &QHeaderView::sectionClicked, [=](int index){
|
||||||
mEditPatForm->clearPatientInformation();
|
patientDetailForm->clearPatientInformation();
|
||||||
prepareButtons(false);
|
prepareButtons(false);
|
||||||
if(mModel->rowCount() > 0){
|
if(mModel->rowCount() > 0){
|
||||||
mPatTable->selectRow(0);
|
mPatTable->selectRow(0);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ private:
|
|||||||
QToolButton *mBtnSelect;
|
QToolButton *mBtnSelect;
|
||||||
SlideTableView *mPatTable;
|
SlideTableView *mPatTable;
|
||||||
QSqlTableModel *mModel;
|
QSqlTableModel *mModel;
|
||||||
PatientDetailForm *mEditPatForm;
|
PatientDetailForm *patientDetailForm;
|
||||||
|
|
||||||
void prepareButtons(bool disableALL);
|
void prepareButtons(bool disableALL);
|
||||||
|
|
||||||
|
|||||||
@@ -387,7 +387,7 @@ QWidget#patientDetailWidget {
|
|||||||
margin-top: 5;
|
margin-top: 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
QToolButton#showeditBtn {
|
QToolButton#btnShowPanel {
|
||||||
margin-top: 5;
|
margin-top: 5;
|
||||||
padding-top: 0;
|
padding-top: 0;
|
||||||
border-top: 1px solid darkgray;
|
border-top: 1px solid darkgray;
|
||||||
@@ -403,7 +403,7 @@ QToolButton#showeditBtn {
|
|||||||
qproperty-iconSize:30px 30px;
|
qproperty-iconSize:30px 30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
QToolButton#hideeditBtn {
|
QToolButton#btnHidePanel {
|
||||||
border-top: 1px solid darkgray;
|
border-top: 1px solid darkgray;
|
||||||
border-bottom: 1px solid darkgray;
|
border-bottom: 1px solid darkgray;
|
||||||
border-left: 1px solid darkgray;
|
border-left: 1px solid darkgray;
|
||||||
|
|||||||
Reference in New Issue
Block a user