From 27487fdf3c51fd0a19077eaf002879b0f63a91d6 Mon Sep 17 00:00:00 2001 From: Krad Date: Fri, 22 Apr 2022 17:16:45 +0800 Subject: [PATCH] Code clean, and code style error fix. --- src/DateSelectDialog.cpp | 1 - src/EditPatientDialog.cpp | 2 +- src/components/AccountRoleComboDelegate.cpp | 2 - src/components/SlidePickerBox.cpp | 4 +- src/components/SlidePickerBox.h | 2 +- src/components/SlideableTableView.cpp | 2 +- src/components/battery.cpp | 24 +- src/components/imageswitch.cpp | 14 +- src/dialogs/SelectDialog.cpp | 2 +- src/dialogs/SelectDialog.h | 2 +- src/forms/select/SelectFormWidget.cpp | 12 +- src/forms/settings/AdminSettingForm.cpp | 18 -- src/forms/settings/generalform.cpp | 6 +- src/forms/settings/systemsettingform.cpp | 6 - src/models/User.cpp | 12 +- src/models/User.h | 12 +- src/network/getadminpsw.cpp | 2 - src/translations/en_US.ts | 12 +- src/translations/zh_CN.ts | 297 ++++++++++---------- src/utilities/InputObject.cpp | 1 - src/utilities/languageswitcher.cpp | 5 +- 21 files changed, 198 insertions(+), 240 deletions(-) diff --git a/src/DateSelectDialog.cpp b/src/DateSelectDialog.cpp index f046ef8..8f936fc 100644 --- a/src/DateSelectDialog.cpp +++ b/src/DateSelectDialog.cpp @@ -5,7 +5,6 @@ #include "DateSelectDialog.h" #include #include "components/DateSlidePickerBox.h" -#include DateSelectDialog::DateSelectDialog(QWidget *parent, Qt::WindowFlags f) : GUIFormBaseDialog(parent, f) { this->setFixedSize(460, 380); QVBoxLayout* layout = new QVBoxLayout(formWidget); diff --git a/src/EditPatientDialog.cpp b/src/EditPatientDialog.cpp index 94802a9..39ba09e 100644 --- a/src/EditPatientDialog.cpp +++ b/src/EditPatientDialog.cpp @@ -14,7 +14,7 @@ #include "DateSelectDialog.h" #include "components/Listbox.h" -int queryValue(QSqlTableModel* model, int colID, QVariant var) +int queryValue(QSqlTableModel* model, int colID, const QVariant& var) { for (int i = 0; i < model->rowCount(); ++i) { if (model->data(model->index(i, colID)) == var) return i; diff --git a/src/components/AccountRoleComboDelegate.cpp b/src/components/AccountRoleComboDelegate.cpp index 17c518c..e675e18 100644 --- a/src/components/AccountRoleComboDelegate.cpp +++ b/src/components/AccountRoleComboDelegate.cpp @@ -3,9 +3,7 @@ // #include "AccountRoleComboDelegate.h" -#include #include -#include #include "db/SQLHelper.h" AccountRoleComboDelegate::AccountRoleComboDelegate(QWidget *parent):QItemDelegate(parent) { SQLHelper::QueryMap("select RoleID,RoleName from Role",map); diff --git a/src/components/SlidePickerBox.cpp b/src/components/SlidePickerBox.cpp index 9691229..6ccb97c 100644 --- a/src/components/SlidePickerBox.cpp +++ b/src/components/SlidePickerBox.cpp @@ -6,7 +6,7 @@ #include #include #include -#include + #include const int fontSize = 80; SlidePickerBox::SlidePickerBox(QWidget *parent):QWidget(parent) { @@ -143,7 +143,7 @@ void SlidePickerBox::paintText(QString txt, int x, int y, const QColor& color) { painter.drawText(x,y,txt); } -void SlidePickerBox::setItems(QStringList itemsList) { +void SlidePickerBox::setItems(const QStringList& itemsList) { this->items = itemsList; hideLabel(selectedLbl); hideLabel(prevLbl); diff --git a/src/components/SlidePickerBox.h b/src/components/SlidePickerBox.h index 7df8865..f3e96f0 100644 --- a/src/components/SlidePickerBox.h +++ b/src/components/SlidePickerBox.h @@ -12,7 +12,7 @@ class SlidePickerBox:public QWidget { public: explicit SlidePickerBox(QWidget *parent = nullptr); QString getSelectedValue(); - void setItems(QStringList itemsList); + void setItems(const QStringList& itemsList); void addItem(QString& item) { this->items.append(item); } diff --git a/src/components/SlideableTableView.cpp b/src/components/SlideableTableView.cpp index 36858cb..d07b72d 100644 --- a/src/components/SlideableTableView.cpp +++ b/src/components/SlideableTableView.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include SlideableTableView::SlideableTableView(QWidget *parent) : QTableView(parent) { diff --git a/src/components/battery.cpp b/src/components/battery.cpp index ed143d4..a243e01 100644 --- a/src/components/battery.cpp +++ b/src/components/battery.cpp @@ -229,23 +229,23 @@ QColor Battery::getNormalColorEnd() const QSize Battery::sizeHint() const { - return QSize(90, 120); + return {90, 120}; } QSize Battery::minimumSizeHint() const { - return QSize(10, 30); + return {10, 30}; } -void Battery::setRange(double minValue, double maxValue) +void Battery::setRange(double minVal, double maxVal) { //如果最小值大于或者等于最大值则不设置 - if (minValue >= maxValue) { + if (minVal >= maxVal) { return; } - this->minValue = minValue; - this->maxValue = maxValue; + this->minValue = minVal; + this->maxValue = maxVal; //如果目标值不在范围值内,则重新设置目标值 //值小于最小值则取最小值,大于最大值则取最大值 @@ -259,19 +259,19 @@ void Battery::setRange(double minValue, double maxValue) this->update(); } -void Battery::setRange(int minValue, int maxValue) +void Battery::setRange(int minVal, int maxVal) { - setRange((double)minValue, (double)maxValue); + setRange((double)minVal, (double)maxVal); } -void Battery::setMinValue(double minValue) +void Battery::setMinValue(double minVal) { - setRange(minValue, maxValue); + setRange(minVal, maxValue); } -void Battery::setMaxValue(double maxValue) +void Battery::setMaxValue(double maxVal) { - setRange(minValue, maxValue); + setRange(minValue, maxVal); } void Battery::setValue(double value) diff --git a/src/components/imageswitch.cpp b/src/components/imageswitch.cpp index 9a5829d..78cb676 100644 --- a/src/components/imageswitch.cpp +++ b/src/components/imageswitch.cpp @@ -45,7 +45,7 @@ ImageSwitch::ButtonStyle ImageSwitch::getButtonStyle() const QSize ImageSwitch::sizeHint() const { - return QSize(100, 50); + return {100, 50}; } QSize ImageSwitch::minimumSizeHint() const @@ -53,19 +53,19 @@ QSize ImageSwitch::minimumSizeHint() const return sizeHint(); } -void ImageSwitch::setChecked(bool isChecked) +void ImageSwitch::setChecked(bool value) { - if (this->isChecked != isChecked) { - this->isChecked = isChecked; + if (this->isChecked != value) { + this->isChecked = value; imgFile = isChecked ? imgOnFile : imgOffFile; this->update(); } } -void ImageSwitch::setButtonStyle(const ImageSwitch::ButtonStyle& buttonStyle) +void ImageSwitch::setButtonStyle(const ImageSwitch::ButtonStyle& style) { - if (this->buttonStyle != buttonStyle) { - this->buttonStyle = buttonStyle; + if (this->buttonStyle != style) { + this->buttonStyle = style; if (buttonStyle == ButtonStyle_1) { imgOffFile = ":/icons/imageswitch/btncheckoff1.png"; diff --git a/src/dialogs/SelectDialog.cpp b/src/dialogs/SelectDialog.cpp index 571c693..06a4c92 100644 --- a/src/dialogs/SelectDialog.cpp +++ b/src/dialogs/SelectDialog.cpp @@ -24,7 +24,7 @@ bool SelectDialog::updateReferenceData() { return true; } -void SelectDialog::setValues(QStringList dates) { +void SelectDialog::setValues(const QStringList& dates) { box->setItems(dates); } diff --git a/src/dialogs/SelectDialog.h b/src/dialogs/SelectDialog.h index 433fcfb..fb0576c 100644 --- a/src/dialogs/SelectDialog.h +++ b/src/dialogs/SelectDialog.h @@ -12,7 +12,7 @@ class SelectDialog :public GUIFormBaseDialog{ public: explicit SelectDialog(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); ~SelectDialog() override; - void setValues(QStringList values); + void setValues(const QStringList& values); QString getSelectedValue(); void setSelectedValue(const QString& val); protected: diff --git a/src/forms/select/SelectFormWidget.cpp b/src/forms/select/SelectFormWidget.cpp index 3a4a50b..8d5bb67 100644 --- a/src/forms/select/SelectFormWidget.cpp +++ b/src/forms/select/SelectFormWidget.cpp @@ -11,13 +11,11 @@ #include #include #include "db/SQLHelper.h" -#include "editpatientform.h" #include "guimacros.h" #include "event/EventCenter.h" #include "src/dialogs/AccountFormDialog.h" #include #include "log/UserOperationLog.h" -#include #include "src/components/VerticalTextToolButton.h" #include "dialogs/AlertDialog.h" @@ -158,7 +156,7 @@ SelectFormWidget::SelectFormWidget(QWidget* parent) : table->selectRow(0); model->selectRow(0); } - LOG_USER_OPERATION(AddPatient); + LOG_USER_OPERATION(AddPatient) btnSelect->setEnabled(true); }); @@ -208,11 +206,11 @@ SelectFormWidget::SelectFormWidget(QWidget* parent) : //TODO:add some error handle logic } if (isAdd) { - LOG_USER_OPERATION(AddPatient); + LOG_USER_OPERATION(AddPatient) } else { - LOG_USER_OPERATION(ChangePatientInfo); + LOG_USER_OPERATION(ChangePatientInfo) } btnSelect->setEnabled(true); }); @@ -247,7 +245,7 @@ SelectFormWidget::SelectFormWidget(QWidget* parent) : table->selectRow(0); model->selectRow(0); setPatientDetail(table, model, edit_patient); - LOG_USER_OPERATION(DeletePatient); + LOG_USER_OPERATION(DeletePatient) } } else { //TODO:error handle @@ -265,7 +263,7 @@ SelectFormWidget::SelectFormWidget(QWidget* parent) : EventCenter::Default()->triggerEvent(GUIEvents::PatientSelected, nullptr, edit_patient->getPatientInformation()->Copy()); selectedPatientUID = edit_patient->getPatientInformation()->PatientUID; - LOG_USER_OPERATION(SelectPatient); + LOG_USER_OPERATION(SelectPatient) }); // btn account slot diff --git a/src/forms/settings/AdminSettingForm.cpp b/src/forms/settings/AdminSettingForm.cpp index 8b6ae3e..f11541f 100644 --- a/src/forms/settings/AdminSettingForm.cpp +++ b/src/forms/settings/AdminSettingForm.cpp @@ -7,13 +7,9 @@ #include #include #include -#include "src/forms/tabformwidget.h" -#include #include "ui_tabformwidget.h" -#include #include "UserOperationLogForm.h" #include "generalform.h" -#include #include "systemsettingform.h" #include "AccountTableForm.h" #include "event/EventCenter.h" @@ -57,20 +53,6 @@ AdminSettingForm::AdminSettingForm(QWidget* parent, Qt::WindowFlags f) : TabForm systemSettingForm* systemSetting = new systemSettingForm(this); stackedWidget->addWidget(systemSetting); - //QLabel* systemSetting = new QLabel(this); - //systemSetting->setText("systemSetting"); - //stackedWidget->addWidget(systemSetting); - - //QLabel* Info = new QLabel(this); - //Info->setText("info"); - //stackedWidget->addWidget(Info); - - //UserOperationLogForm* operationLogForm = new UserOperationLogForm(this); - //stackedWidget->addWidget(operationLogForm); - - //QLabel* about = new QLabel(this); - //about->setText(tr("About")); - AboutWidget* about = new AboutWidget(this); stackedWidget->addWidget(about); diff --git a/src/forms/settings/generalform.cpp b/src/forms/settings/generalform.cpp index 4c756e7..ae55c4e 100644 --- a/src/forms/settings/generalform.cpp +++ b/src/forms/settings/generalform.cpp @@ -71,16 +71,16 @@ GeneralForm::GeneralForm(QWidget* parent) : QWidget(parent) lockTime->setText(JsonObject::Instance()->lockScreenTimeout()); //connection - connect(instName, &QLineEdit::textChanged, [=](QString str) + connect(instName, &QLineEdit::textChanged, [=](const QString& str) { JsonObject::Instance()->setInstitutionName(str); }); - connect(instAddr, &QLineEdit::textChanged, [=](QString str) + connect(instAddr, &QLineEdit::textChanged, [=](const QString& str) { JsonObject::Instance()->setInstitutionAddr(str); }); - connect(lockTime, &QLineEdit::textChanged, [=](QString str) + connect(lockTime, &QLineEdit::textChanged, [=](const QString& str) { //take effect JsonObject::Instance()->setLockScreenTimeout(str); diff --git a/src/forms/settings/systemsettingform.cpp b/src/forms/settings/systemsettingform.cpp index 25bcf94..3d49dde 100644 --- a/src/forms/settings/systemsettingform.cpp +++ b/src/forms/settings/systemsettingform.cpp @@ -2,16 +2,11 @@ #include "ui_systemsettingform.h" #include -#include -#include #include -#include #include -#include #include #include "src/dialogs/SelectDialog.h" -#include "components/imageswitch.h" #include "network/networkcfgdialog.h" #include "network/dicomcfgdialog.h" #include "network/getadminpsw.h" @@ -20,7 +15,6 @@ #include "event/EventCenter.h" #include "device/DeviceManager.h" #include "json/cmdhelper.h" -#include "appvals/AppGlobalValues.h" systemSettingForm::systemSettingForm(QWidget* parent) : QWidget(parent), diff --git a/src/models/User.cpp b/src/models/User.cpp index f78429f..e2a48e4 100644 --- a/src/models/User.cpp +++ b/src/models/User.cpp @@ -48,7 +48,7 @@ bool User::submitChange() { return result; } -bool User::QueryUser(QString userID, QString Pwd) { +bool User::QueryUser(const QString& userID, const QString& Pwd) { QString sql = QString("select * from Account where UserCode=:userID and Password=:pwd"); QMap map; @@ -82,7 +82,7 @@ bool User::QueryUser(QString userID, QString Pwd) { } -bool User::existsUser(QString userCode) { +bool User::existsUser(const QString& userCode) { QString sql = QString("select * from Account where UserCode=:userID"); QMap map; QMap params; @@ -91,7 +91,7 @@ bool User::existsUser(QString userCode) { return !map.isEmpty(); } -bool User::getUser(QString userUID, User& user) { +bool User::getUser(const QString& userUID, User& user) { QString sql = QString("select * from Account where UserID=:userUID"); QMap map; QMap params; @@ -113,7 +113,7 @@ bool User::getUser(QString userUID, User& user) { static bool LOAD_ALL_ROLE = false; static QMap roleCache; -QString User::getRoleName(QString RoleID) { +QString User::getRoleName(const QString& RoleID) { if (roleCache.contains(RoleID)) return roleCache[RoleID]; QString sql = QString("select RoleName from Role where RoleID=:RoleID"); QMap map; @@ -124,7 +124,7 @@ QString User::getRoleName(QString RoleID) { return map["RoleName"].toString(); } -QString User::getRoleID(QString RoleName) { +QString User::getRoleID(const QString& RoleName) { if (roleCache.values().contains(RoleName)) { int index = roleCache.values().indexOf(RoleName); return roleCache.keys()[index]; @@ -155,7 +155,7 @@ QStringList User::getAllRoleName() { return roleCache.values(); } -bool User::insertUser(QString UserCode, User &user) { +bool User::insertUser(const QString& UserCode, User &user) { user.m_UserID = QUuid::createUuid().toString(); user.m_UserCode = UserCode; static QString updateSQL = "insert into Account (%1) values (%2)"; diff --git a/src/models/User.h b/src/models/User.h index d9941af..7781392 100644 --- a/src/models/User.h +++ b/src/models/User.h @@ -20,8 +20,8 @@ USER_PROPERTY(Comment) class User:public QObject { Q_OBJECT public: - static bool QueryUser(QString userID, QString Pwd); - static bool existsUser(QString userCode); + static bool QueryUser(const QString& userID, const QString& Pwd); + static bool existsUser(const QString& userCode); static QString getEncryptedPassword(const QString& password) { QByteArray bytePwd = password.toLatin1(); @@ -31,8 +31,8 @@ public: static User* Current(){ return currentUser; } - static bool getUser(QString userUID,User& user); - static bool insertUser(QString UserCode,User& user); + static bool getUser(const QString& userUID,User& user); + static bool insertUser(const QString& UserCode,User& user); explicit User(QObject *parent=nullptr); ~User(); QString getIndexName(){ @@ -65,8 +65,8 @@ public: bool isAdmin(); bool isEngineer(); bool resetPassword(); - static QString getRoleName(QString RoleID); - static QString getRoleID(QString RoleName); + static QString getRoleName(const QString& RoleID); + static QString getRoleID(const QString& RoleName); static QStringList getAllRoleName(); private: static User* currentUser; diff --git a/src/network/getadminpsw.cpp b/src/network/getadminpsw.cpp index 0b58979..1b017ea 100644 --- a/src/network/getadminpsw.cpp +++ b/src/network/getadminpsw.cpp @@ -6,8 +6,6 @@ #include #include #include "getadminpsw.h" -#include "device/networkmanager.h" -#include "device/networkmanager.h" GetAdminPsw::GetAdminPsw(QWidget* parent, Qt::WindowFlags f) : GUIFormBaseDialog(parent, f) { diff --git a/src/translations/en_US.ts b/src/translations/en_US.ts index aa609e7..7a9caf5 100644 --- a/src/translations/en_US.ts +++ b/src/translations/en_US.ts @@ -15,6 +15,10 @@ Copyright © 2017-2020 Zhejiang Equilibrium Nine Medical Equipment Co., Ltd. All Rights Reversed + + GUI Software V1.3 + + Embedded Software V1.5 @@ -51,10 +55,6 @@ Loading... - - GUI Software V%1 - - AccountFormDialog @@ -587,10 +587,6 @@ parameters Comment - - Delete Patient "%1" ? - - TabFormWidget diff --git a/src/translations/zh_CN.ts b/src/translations/zh_CN.ts index a179c8f..2651393 100644 --- a/src/translations/zh_CN.ts +++ b/src/translations/zh_CN.ts @@ -4,74 +4,74 @@ AboutWidget - - + + HJ-USCT-01 V1.0 - - + + ? - + cJSON - + Copyright © 2017-2020 Zhejiang Equilibrium Nine Medical Equipment Co., Ltd. All Rights Reversed - + + + GUI Software V1.3 + + + + Copyright © 2017-2022 Zhejiang Equilibrium Nine Medical Equipment Co., Ltd. All Rights Reversed - + - GUI Software V%1 - - - - - Embedded Software V1.5 - - + + Reconstruction Software V1.2 - - + + FEB Information - + Qt 5.12.0 - - + + Loading... 正在加载 - + Copyright (c) 1994-2021, OFFIS e.V. - + Copyright (c) 2009-2017 Dave Gamble @@ -145,18 +145,18 @@ 医生 - + Reset password to "123456" ? 密码重置为"123456"? - + Inner error, can't find reference user! 内部错误! - - + + Submit change to database fail! 修改提交至数据库失败! @@ -166,34 +166,34 @@ 备注 - - - + + + User Name can't be empty! 用户名不能为空! - + User ID can't be empty! 用户ID不能为空! - + Password can't be empty! 密码不能为空! - + Inner error ,unset data model! 内部错误! - + User Id exists! 用户ID已存在! - + Submit to data base fail! 提交至数据库失败! @@ -207,47 +207,47 @@ - + Name 姓名 - + Role 角色 - + Comment 备注 - - + + Add 新增 - - + + Edit 编辑 - - + + Delete 删除 - + Can't delete current log in account! 当前用户无法删除日志! - + Delete account with ID:"%1"! 删除账户ID:"%1"! @@ -255,20 +255,20 @@ AdminSettingForm - - + + General 通用 - - + + Account 用户 - - + + System 系统 @@ -297,8 +297,8 @@ 操作日志 - - + + About 关于 @@ -362,37 +362,37 @@ EditPatientForm - + Form - + ... DICOM - + ID - + Name 姓名 - + Date Of Birth 出生日期 - + Comment 备注 - + Gender 性别 @@ -442,12 +442,12 @@ GUIMessageDialog - + Dialog - + ... @@ -555,7 +555,7 @@ InputObject - + Form @@ -590,7 +590,7 @@ MainWindow - + MainWindow @@ -626,47 +626,47 @@ PatientInformationForm - + Form - + Patient Information 患者信息 - + <html><head/><body><p>PatientID:</p></body></html> <html><head/><body><p>患者ID:</p></body></html> - + Someone Somebody XXX - + 2021/11/11 - + Female - + Acc# 27812398 - + Current Protocol 当前协议 - + LEFT ONLY 左侧 @@ -769,80 +769,75 @@ parameters SelectFormWidget - - + + Account 账户 - + Worklist - - + + Add 新增 - - + + Edit 编辑 - - + + Delete 删除 - - + + Select 选择 - - + + Name 姓名 - - + + Birth Date 出生日期 - - + + Gender 性别 - - + + Add Date 添加日期 - - + + Comment 备注 - - - Delete Patient "%1" ? - - TabFormWidget - + Form @@ -899,7 +894,7 @@ parameters dicomCfgDialog - + Dialog @@ -908,57 +903,57 @@ parameters DICOM 设置 - + DICOM Settings DICOM 配置 - - - + + + Name - - - + + + IP - - - + + + Port - - - + + + AE - + Worklist - - - + + + ... DICOM - + PACS - + 3D Recon @@ -976,18 +971,18 @@ parameters networkCfgDialog - - + + Network Settings 网络配置 - + Address IP配置 - + IP Address IP地址 @@ -1001,85 +996,85 @@ parameters 动态地址 - + Dev 设备 - + Subnet Mask 子网掩码 - + Additional Address 额外地址 - - + + Add 新增 - - + + Edit 编辑 - - + + Delete 删除 - + Routing 路由配置 - + Default IPv4 Gateway 默认网关 - + DHCP - + Routing Table 路由表 - + Name - + Port - + AE - + IP - + DICOM - + Result 结果 @@ -1113,7 +1108,7 @@ parameters systemSettingForm - + Form @@ -1122,17 +1117,17 @@ parameters 网络配置 - + Protocal 默认扫描协议 - + Worklist Filter Worklist过滤器 - + Disk Storage 磁盘存储 @@ -1141,7 +1136,7 @@ parameters DICOM - + Auto Verify 自动验证 @@ -1150,7 +1145,7 @@ parameters 配置 - + IP @@ -1167,7 +1162,7 @@ parameters 接受 - + DICOM diff --git a/src/utilities/InputObject.cpp b/src/utilities/InputObject.cpp index dbd022a..a4bfdcd 100644 --- a/src/utilities/InputObject.cpp +++ b/src/utilities/InputObject.cpp @@ -1,6 +1,5 @@ #include "InputObject.h" #include "ui_inputobject.h" -//#include "qdesktopwidget.h" #include #include #include diff --git a/src/utilities/languageswitcher.cpp b/src/utilities/languageswitcher.cpp index f2fc8ee..0e8a75e 100644 --- a/src/utilities/languageswitcher.cpp +++ b/src/utilities/languageswitcher.cpp @@ -29,9 +29,8 @@ void LanguageSwitcher::setDefaultLanguage(QString str) QString lan = QString(":/translations/" + str + ".qm"); if (translator->load(lan)) { - //qDebug() << "installTranslator"; - //QApplication::installTranslator(translator); + EventCenter::Default()->triggerEvent(ReloadLanguage, nullptr, nullptr); } - EventCenter::Default()->triggerEvent(ReloadLanguage, nullptr, nullptr); + }