From 3ccc8d7fa8fab2fb466492f2df1bf47f5e8098d6 Mon Sep 17 00:00:00 2001 From: Krad Date: Fri, 15 Jul 2022 17:32:21 +0800 Subject: [PATCH] Refactor TopBarWidget & SelectFormWidget.(clean and rename member) --- src/forms/TopBarWidget.cpp | 35 +++++++++++++------------- src/forms/select/PatientDetailForm.cpp | 2 +- src/forms/select/SelectFormWidget.cpp | 34 ++++++++++++------------- src/forms/select/SelectFormWidget.h | 2 +- src/stylesheet/Dark2.css | 4 +-- 5 files changed, 39 insertions(+), 38 deletions(-) diff --git a/src/forms/TopBarWidget.cpp b/src/forms/TopBarWidget.cpp index e260a61..e5456b6 100644 --- a/src/forms/TopBarWidget.cpp +++ b/src/forms/TopBarWidget.cpp @@ -3,55 +3,56 @@ // #include "TopBarWidget.h" + #include #include -#include "components/RollingMessageWidget.h" #include + +#include "components/RollingMessageWidget.h" #include "event/EventCenter.h" #include "errorhandle/GUIErrorLW.h" #include "json/jsonobject.h" TopBarWidget::TopBarWidget(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f) { - QHBoxLayout* layout = new QHBoxLayout(this); + auto layout = new QHBoxLayout(this); layout->setMargin(0); - QLabel * logo = new QLabel(this); + auto logo = new QLabel(this); logo->setObjectName("logo"); layout->addWidget(logo); - QLabel * company = new QLabel(this); + auto company = new QLabel(this); company->setObjectName("company"); layout->addWidget(company); company->setText(tr("浙江衡玖医疗科技")); - QWidget* spacerLine0 = new QWidget(this); + auto spacerLine0 = new QWidget(this); spacerLine0->setFixedWidth(2); spacerLine0->setObjectName("verSpaceLine"); layout->addWidget(spacerLine0); - QLabel * lbl_msglogo = new QLabel(this); + auto lbl_msglogo = new QLabel(this); lbl_msglogo->setObjectName("msglogo"); layout->addWidget(lbl_msglogo); - QWidget* widgetMsg = new QWidget(this); + auto widgetMsg = new QWidget(this); layout->addWidget(widgetMsg,1); widgetMsg->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); layout->addSpacerItem(new QSpacerItem(10, 10, QSizePolicy::Expanding)); - QWidget* statusBarWidget = new QWidget(this); + auto statusBarWidget = new QWidget(this); layout->addWidget(statusBarWidget); - QLabel* hosp = new QLabel(this); + auto hosp = new QLabel(this); 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")); - QLabel* linkIcon = new QLabel(this); + auto linkIcon = new QLabel(this); linkIcon->setObjectName("link"); - QLabel* readyIcon = new QLabel(this); + auto readyIcon = new QLabel(this); readyIcon->setObjectName("ready"); - QLabel* lockIcon = new QLabel(this); + auto lockIcon = new QLabel(this); lockIcon->setText(""); - // lockIcon->setPixmap(QPixmap(":/icons/lock.png").scaledToHeight(22,Qt::SmoothTransformation)); - QHBoxLayout* status_layout = new QHBoxLayout(statusBarWidget); + auto status_layout = new QHBoxLayout(statusBarWidget); status_layout->setMargin(0); status_layout->addWidget(hosp); status_layout->addWidget(nowDate); - QWidget* spacerLine = new QWidget(this); + auto spacerLine = new QWidget(this); spacerLine->setFixedWidth(2); spacerLine->setObjectName("verSpaceLine"); @@ -60,7 +61,7 @@ TopBarWidget::TopBarWidget(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, layout->addWidget(readyIcon); layout->addWidget(lockIcon); - QVBoxLayout* l = new QVBoxLayout(widgetMsg); + auto l = new QVBoxLayout(widgetMsg); l->setMargin(0); auto w = new RollingMessageWidget(this); diff --git a/src/forms/select/PatientDetailForm.cpp b/src/forms/select/PatientDetailForm.cpp index 7535810..0620383 100644 --- a/src/forms/select/PatientDetailForm.cpp +++ b/src/forms/select/PatientDetailForm.cpp @@ -14,7 +14,7 @@ PatientDetailForm::PatientDetailForm(QWidget* parent) : { mUI->setupUi(this); mUI->hideBtn->setSizePolicy(QSizePolicy::Policy::Expanding, QSizePolicy::Policy::Preferred); - mUI->hideBtn->setObjectName("hideeditBtn"); + mUI->hideBtn->setObjectName("btnHidePanel"); mUI->hideBtn->setText(tr(" Hide Panel")); connect(mUI->hideBtn, &QToolButton::clicked, [=](){ emit hideBtnClicked(); diff --git a/src/forms/select/SelectFormWidget.cpp b/src/forms/select/SelectFormWidget.cpp index 885366c..bbd4099 100644 --- a/src/forms/select/SelectFormWidget.cpp +++ b/src/forms/select/SelectFormWidget.cpp @@ -30,7 +30,7 @@ SelectFormWidget::SelectFormWidget(QWidget* parent) , mBtnSelect(new QToolButton(this)) , mPatTable(new SlideTableView(this)) , mModel(nullptr) -, mEditPatForm(new PatientDetailForm(this)) +, patientDetailForm(new PatientDetailForm(this)) { //init command bar auto layout = new QHBoxLayout(); @@ -51,7 +51,7 @@ SelectFormWidget::SelectFormWidget(QWidget* parent) if (mModel->rowCount() > 0) { mPatTable->selectRow(0); - setPatientDetail(mPatTable, mModel, mEditPatForm); + setPatientDetail(mPatTable, mModel, patientDetailForm); } // event ResponsePreview slot connect(EventCenter::Default(), &EventCenter::ResponsePreview, [=](QObject* sender, QObject* data) { @@ -122,7 +122,7 @@ void SelectFormWidget::editPatient() { dialog.clearPatientInformation(); } else{ - dialog.setPatientInformation(mEditPatForm->getPatientInformation()); + dialog.setPatientInformation(patientDetailForm->getPatientInformation()); } dialog.setWindowModality(Qt::WindowModal); @@ -135,7 +135,7 @@ void SelectFormWidget::editPatient() { } else{ mPatTable->clicked(mPatTable->currentIndex()); - setPatientDetail(mPatTable, mModel, mEditPatForm); + setPatientDetail(mPatTable, mModel, patientDetailForm); } LOG_USER_OPERATION(AddPatient) mBtnSelect->setEnabled(true); @@ -162,7 +162,7 @@ void SelectFormWidget::delPatient() { dialog.setAlertMessage(QString(tr("Delete Patient \"%1\" ?")).arg(pat_name)); if (dialog.exec() != QDialog::Accepted) return; // need delete clear edit panel detail - mEditPatForm->clearPatientInformation(); + patientDetailForm->clearPatientInformation(); mModel->setData(mModel->index(mPatTable->currentIndex().row(), Flag), 9); if (mModel->submitAll()) { @@ -170,7 +170,7 @@ void SelectFormWidget::delPatient() { if (mModel->rowCount() > 0) { mPatTable->selectRow(0); mModel->selectRow(0); - setPatientDetail(mPatTable, mModel, mEditPatForm); + setPatientDetail(mPatTable, mModel, patientDetailForm); LOG_USER_OPERATION(DeletePatient) } } else { @@ -184,17 +184,17 @@ void SelectFormWidget::delPatient() { } void SelectFormWidget::selectPatient() { - EventCenter::Default()->triggerEvent(PatientSelected, nullptr, mEditPatForm->getPatientInformation()->Copy()); - selectedPatientUID = mEditPatForm->getPatientInformation()->PatientUID; + EventCenter::Default()->triggerEvent(PatientSelected, nullptr, patientDetailForm->getPatientInformation()->Copy()); + selectedPatientUID = patientDetailForm->getPatientInformation()->PatientUID; LOG_USER_OPERATION(SelectPatient) } void SelectFormWidget::initDetailPanel(QHBoxLayout *contentLayout) {// prepare edit panel - mEditPatForm->setObjectName("patientDetailWidget"); - mEditPatForm->hide(); - contentLayout->addWidget(mEditPatForm); + patientDetailForm->setObjectName("patientDetailWidget"); + patientDetailForm->hide(); + contentLayout->addWidget(patientDetailForm); auto* btnShowEdit = new VerticalTextToolButton(this); - btnShowEdit->setObjectName("showeditBtn"); + btnShowEdit->setObjectName("btnShowPanel"); btnShowEdit->setFixedHeight(225); btnShowEdit->setVerticalText("Patient Detail"); contentLayout->addWidget(btnShowEdit); @@ -202,12 +202,12 @@ void SelectFormWidget::initDetailPanel(QHBoxLayout *contentLayout) {// prepare e // btn show slot connect(btnShowEdit, &QToolButton::clicked, [=]() { - mEditPatForm->show(); + patientDetailForm->show(); btnShowEdit->hide(); }); //btn hide slot - connect(mEditPatForm, &PatientDetailForm::hideBtnClicked, [=]() { - mEditPatForm->hide(); + connect(patientDetailForm, &PatientDetailForm::hideBtnClicked, [=]() { + patientDetailForm->hide(); btnShowEdit->show(); }); } @@ -238,13 +238,13 @@ void SelectFormWidget::initTableView(QHBoxLayout *contentLayout) {// TableView f contentLayout->addWidget(mPatTable); //table current row selection changing event connect(mPatTable, &SlideTableView::currentRowChanged, [=](int row) { - setPatientDetail(mPatTable, mModel, mEditPatForm); + setPatientDetail(mPatTable, mModel, patientDetailForm); prepareButtons(false); }); // after sort by column connect(mPatTable->horizontalHeader(), &QHeaderView::sectionClicked, [=](int index){ - mEditPatForm->clearPatientInformation(); + patientDetailForm->clearPatientInformation(); prepareButtons(false); if(mModel->rowCount() > 0){ mPatTable->selectRow(0); diff --git a/src/forms/select/SelectFormWidget.h b/src/forms/select/SelectFormWidget.h index 0d95c52..938a107 100644 --- a/src/forms/select/SelectFormWidget.h +++ b/src/forms/select/SelectFormWidget.h @@ -36,7 +36,7 @@ private: QToolButton *mBtnSelect; SlideTableView *mPatTable; QSqlTableModel *mModel; - PatientDetailForm *mEditPatForm; + PatientDetailForm *patientDetailForm; void prepareButtons(bool disableALL); diff --git a/src/stylesheet/Dark2.css b/src/stylesheet/Dark2.css index dc33c4f..acc0c97 100644 --- a/src/stylesheet/Dark2.css +++ b/src/stylesheet/Dark2.css @@ -387,7 +387,7 @@ QWidget#patientDetailWidget { margin-top: 5; } -QToolButton#showeditBtn { +QToolButton#btnShowPanel { margin-top: 5; padding-top: 0; border-top: 1px solid darkgray; @@ -403,7 +403,7 @@ QToolButton#showeditBtn { qproperty-iconSize:30px 30px; } -QToolButton#hideeditBtn { +QToolButton#btnHidePanel { border-top: 1px solid darkgray; border-bottom: 1px solid darkgray; border-left: 1px solid darkgray;