diff --git a/AppVersion.h.in b/AppVersion.h.in new file mode 100644 index 0000000..bdd7d6a --- /dev/null +++ b/AppVersion.h.in @@ -0,0 +1,11 @@ +// +// Created by Krad on 2022/3/8. +// + +#ifndef GUI_VERSION_H +#define GUI_VERSION_H +#define GUI_VERSION_MAJOR @GUI_VERSION_MAJOR@ +#define GUI_VERSION_MINOR @GUI_VERSION_MINOR@ +#define GUI_VERSION_BUILD @GUI_VERSION_BUILD@ +#define GUI_VERSION_BETA @GUI_VERSION_BETA@ +#endif //GUI_VERSION_H diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e6ff61..df11f4e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,15 +5,24 @@ set(CMAKE_CXX_STANDARD 14) set(CMAKE_INCLUDE_CURRENT_DIR ON) #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O2 -pthread") +# GUI Version +set(GUI_VERSION_MAJOR 0) +set(GUI_VERSION_MINOR 6) +set(GUI_VERSION_BUILD 10) +set(GUI_VERSION_BETA 1) +# use AppVersion.h as a configure file +configure_file( + "AppVersion.h.in" + "AppVersion.h" +) + file(GLOB_RECURSE project_headers ./src/*.h) file(GLOB_RECURSE project_cpps ./src/*.cpp) file(GLOB_RECURSE project_cxx ./src/*.cxx) file(GLOB_RECURSE project_cc ./src/*.cc) -if(UNIX) -set(USE_SHIMLIB ON) -else() -set(USE_SHIMLIB OFF) +if(NOT UNIX) + set(USE_SHIMLIB OFF) endif() if(UNIX AND USE_SHIMLIB) file(GLOB_RECURSE project_c ./src/json/*.c) @@ -31,7 +40,7 @@ source_group(TREE ${CMAKE_SOURCE_DIR} FILES ${project_c}) find_package(Qt5 COMPONENTS Core Widgets Gui OpenGL Sql VirtualKeyboard Network REQUIRED) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) -file(GLOB project_uis ./src/*.ui) +file(GLOB_RECURSE project_uis ./src/*.ui) qt5_wrap_ui(ui_FILES ${project_uis}) file(GLOB project_res ./src/*.qrc) diff --git a/docs/v0.6.10.txt b/docs/v0.6.10.txt new file mode 100644 index 0000000..1660f2c --- /dev/null +++ b/docs/v0.6.10.txt @@ -0,0 +1,5 @@ +v0.6.10 + +重写了整个Patient的修改和新增逻辑,使用模态对话框替代的原来界面内的显示。 +去除了原来界面内编辑区域,只做显示使用。 +此外,使用滑动块替换了性别选择,日期选择的功能。 \ No newline at end of file diff --git a/docs/v0.6.8.txt b/docs/v0.6.8.txt new file mode 100644 index 0000000..cb29f98 --- /dev/null +++ b/docs/v0.6.8.txt @@ -0,0 +1,3 @@ +第一个release版本。 +基本流程已完备,提交系统测试。 +2022年3月8日 \ No newline at end of file diff --git a/docs/v0.6.9.txt b/docs/v0.6.9.txt new file mode 100644 index 0000000..202a0a4 --- /dev/null +++ b/docs/v0.6.9.txt @@ -0,0 +1,8 @@ +v0.6.9 +通过新的当前行判定逻辑,修复了Select Tab页中,Patient 表格排序、选择导致的一系列问题。 +包括: +1. Edit Panel 没有跟随选中更新。 +2. Patient 全部删除之后存在当前选中错误。 +3. 编辑、删除等按钮可用状态不对的错误。 +4. 修复了日期输入框在虚拟键盘下,回车无法退出输入模式的错误。 +2022年3月15日 \ No newline at end of file diff --git a/src/DateSelectDialog.cpp b/src/DateSelectDialog.cpp new file mode 100644 index 0000000..8f936fc --- /dev/null +++ b/src/DateSelectDialog.cpp @@ -0,0 +1,36 @@ +// +// Created by Krad on 2022/3/24. +// + +#include "DateSelectDialog.h" +#include +#include "components/DateSlidePickerBox.h" +DateSelectDialog::DateSelectDialog(QWidget *parent, Qt::WindowFlags f) : GUIFormBaseDialog(parent, f) { + this->setFixedSize(460, 380); + QVBoxLayout* layout = new QVBoxLayout(formWidget); + box = new DateSlidePickerBox(formWidget); + box->setObjectName("slider_one"); + box->setSelectedValue("1990-01-01"); + layout->addWidget(box); +} + +DateSelectDialog::~DateSelectDialog() { + +} + +QString DateSelectDialog::getSelectedValue() { + return box->getSelectedValue(); +} + +void DateSelectDialog::setSelectedValue(const QString &val) { + box->setSelectedValue(val); + box->resizeLabel(); +} + +bool DateSelectDialog::updateReferenceData() { + return true; +} + +void DateSelectDialog::showEvent(QShowEvent * event) { + QDialog::showEvent(event); +} diff --git a/src/DateSelectDialog.h b/src/DateSelectDialog.h new file mode 100644 index 0000000..0c70a55 --- /dev/null +++ b/src/DateSelectDialog.h @@ -0,0 +1,24 @@ +// +// Created by Krad on 2022/3/24. +// + +#ifndef GUI_DATESELECTDIALOG_H +#define GUI_DATESELECTDIALOG_H + +#include "dialogs/GUIFormBaseDialog.h" +class DateSlidePickerBox; +class DateSelectDialog:public GUIFormBaseDialog{ + Q_OBJECT +public: + explicit DateSelectDialog(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); + ~DateSelectDialog() override; + QString getSelectedValue(); + void setSelectedValue(const QString& val); + void showEvent(QShowEvent *) override; +protected: + bool updateReferenceData() override; + DateSlidePickerBox* box; +}; + + +#endif //GUI_DATESELECTDIALOG_H diff --git a/src/EditPatientDialog.cpp b/src/EditPatientDialog.cpp new file mode 100644 index 0000000..39ba09e --- /dev/null +++ b/src/EditPatientDialog.cpp @@ -0,0 +1,212 @@ +// +// Created by Krad on 2022/3/21. +// +#include +#include +#include +#include +#include +#include +#include +#include +#include "EditPatientDialog.h" +#include "dialogs/SelectDialog.h" +#include "DateSelectDialog.h" +#include "components/Listbox.h" + +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; + } + return -1; +} + +EditPatientDialog::EditPatientDialog(QWidget *parent, Qt::WindowFlags f) : GUIFormBaseDialog(parent, f) { + QVBoxLayout* layout = new QVBoxLayout(formWidget); + layout->setSpacing(10); + // add title + QLabel* lbl_title = new QLabel(this); + lbl_title->setAlignment(Qt::AlignCenter); + lbl_title->setText(tr("Edit Patient")); + lbl_title->setObjectName("title"); + layout->addWidget(lbl_title); + + //add old password + QLabel* lbl_id = new QLabel(this); + lbl_id->setText(tr("ID")); + le_id = new QLineEdit(this); + layout->addWidget(lbl_id); + layout->addWidget(le_id); + QLabel* lbl_endline1 = new QLabel(this); + lbl_endline1->setObjectName("endline"); + layout->addWidget(lbl_endline1); + + QLabel* lbl_name= new QLabel(this); + lbl_name->setText(tr("Name")); + le_name = new QLineEdit(this); + layout->addWidget(lbl_name); + layout->addWidget(le_name); + QLabel* lbl_endline2 = new QLabel(this); + lbl_endline2->setObjectName("endline"); + layout->addWidget(lbl_endline2); + + QLabel* lbl_sex= new QLabel(this); + lbl_sex->setText(tr("Gender")); + layout->addWidget(lbl_sex); + btnSex = new Listbox(this); + btnSex->setText(tr("Female")); + btnSex->setProperty("idx",0); + btnSex->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + btnSex->setLayoutDirection(Qt::RightToLeft); + btnSex->setObjectName("editvalBtn"); + btnSex->setIcon(QIcon(":/icons/arrow-down.png")); + btnSex->setIconSize({30, 30}); + + btnSex->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + connect(btnSex, &QToolButton::clicked,[=](){ + SelectDialog dialog(this); + QStringList items; + items<property("idx").toInt()]); + dialog.setWindowModality(Qt::WindowModal); + if (dialog.exec() == QDialog::Accepted){ + btnSex->setText(dialog.getSelectedValue()); + btnSex->setProperty("idx",items.indexOf(dialog.getSelectedValue())); + } + }); + layout->addWidget(btnSex); + QLabel *lbl_endline9 = new QLabel(this); + lbl_endline9->setFixedHeight(2); + lbl_endline9->setObjectName("endline"); + layout->addWidget(lbl_endline9); + + + QLabel* lbl_date = new QLabel(this); + lbl_date->setText(tr("Birth Date")); + + layout->addWidget(lbl_date); + btnDate = new Listbox(this); + btnDate->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + btnDate->setLayoutDirection(Qt::RightToLeft); + btnDate->setObjectName("editvalBtn"); + btnDate->setIcon(QIcon(":/icons/arrow-down.png")); + btnDate->setIconSize({30, 30}); + btnDate->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + btnDate->setText("1990-06-15"); + connect(btnDate, &QToolButton::clicked,[=](){ + DateSelectDialog dialog(this); + dialog.setSelectedValue(btnDate->text()); + dialog.setWindowModality(Qt::WindowModal); + if (dialog.exec() == QDialog::Accepted){ + btnDate->setText(dialog.getSelectedValue()); + } + }); + layout->addWidget(btnDate); + QLabel* lbl_endline5 = new QLabel(this); + lbl_endline5->setObjectName("endline"); + layout->addWidget(lbl_endline5); + + QLabel* lbl_comment = new QLabel(this); + lbl_comment->setText(tr("Comment")); + te_comment = new QTextEdit(this); + layout->addWidget(lbl_comment); + layout->addWidget(te_comment); + QLabel* lbl_endline6 = new QLabel(this); + lbl_endline6->setObjectName("endline"); + layout->addWidget(lbl_endline6); + + lbl_error = new QLabel(this); + lbl_error->setObjectName("warn"); + layout->addWidget(lbl_error); +} + +EditPatientDialog::~EditPatientDialog() { + +} + +void EditPatientDialog::setPatientInformation(PatientInformation* information) { + if (information) + { + le_id->setText(information->ID); + btnSex->setText(information->Sex == tr("F")?tr("Female"):(information->Sex == tr("M")?tr("Male"):tr("Other"))); + le_name->setText(information->Name); + te_comment->setText(information->Comment); + btnDate->setText(information->BirthDate); + currentPatientUID = information->PatientUID; + AddDate = information->AddDate; + le_id->setEnabled(false); + } +} + +void EditPatientDialog::clearPatientInformation() { + le_id->setText(""); +// le_date->setText(""); + le_name->setText(""); + te_comment->setText(""); +} + +void EditPatientDialog::storePatientInformation() { + store.PatientUID = currentPatientUID; +// store.AddDate = AddDate; + store.ID = le_id->text(); + store.BirthDate = le_date->text(); + store.Name = le_name->text(); + store.Sex = le_sex->text(); + store.Comment = te_comment->toPlainText(); +} + +bool EditPatientDialog::updateReferenceData() { + PatientInformation* inf = getPatientInformation(); + if (le_id->text().isEmpty()){ + lbl_error->setText("ID can't be empty!"); + lbl_error->setVisible(true); + return false; + } + inf->ID = le_id->text().trimmed(); + if (le_name->text().isEmpty()){ + lbl_error->setText("Patient Name can't be empty!"); + lbl_error->setVisible(true); + return false; + } + inf->Name = le_name->text().trimmed(); + int selectedRow = 0; + bool isAdd = currentPatientUID.isEmpty(); + if (isAdd) { + int ref_rowid = queryValue(model, 1, inf->ID); + if (ref_rowid >= 0) + { + lbl_error->setText("The ID is already existed!"); + lbl_error->setVisible(true); + return false; + } + inf->PatientUID = QUuid::createUuid().toString(); + inf->AddDate = QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss"); + model->insertRow(0); + } + else{ + inf->PatientUID = currentPatientUID; + selectedRow = queryValue(model, 1, inf->ID); + inf->AddDate = AddDate; + } + inf->Sex = btnSex->text()==tr("Female")?"F":(tr("Male")==btnSex->text()?"M":"O"); + inf->BirthDate = btnDate->text(); + inf->Comment = te_comment->toPlainText(); + + + #define ADD_PATIENT_PROPERTY(val)\ + model->setData(model->index(selectedRow,PatientInformationEnum:: val),inf-> val); + EDIT_PATIENT() + #undef ADD_PATIENT_PROPERTY + if (model->submitAll()) + { + return true; + } + else { + lbl_error->setText("Submit to database error!"); + lbl_error->setVisible(true); + return false; + } + +} diff --git a/src/EditPatientDialog.h b/src/EditPatientDialog.h new file mode 100644 index 0000000..d045df8 --- /dev/null +++ b/src/EditPatientDialog.h @@ -0,0 +1,53 @@ +// +// Created by Krad on 2022/3/21. +// + +#ifndef GUI_EDITPATIENTDIALOG_H +#define GUI_EDITPATIENTDIALOG_H + +#include "dialogs/GUIFormBaseDialog.h" +#include "forms/select/editpatientform.h" + +class QLineEdit; +class QTextEdit; +class QLabel; +class QToolButton; +class QSqlTableModel; +class EditPatientDialog :public GUIFormBaseDialog{ + Q_OBJECT +public: + explicit EditPatientDialog(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); + ~EditPatientDialog(); + + void setModel(QSqlTableModel * m){ + model=m; + } + + PatientInformation * getPatientInformation(){ + return &store; + } + void setPatientInformation(PatientInformation * information); + void clearPatientInformation(); + void storePatientInformation(); + + +protected: + bool updateReferenceData() override; + +private: + QLineEdit* le_id= nullptr; + QLineEdit* le_name = nullptr; + QLineEdit* le_sex = nullptr; + QLineEdit* le_date = nullptr; + QTextEdit* te_comment = nullptr; + QLabel* lbl_error = nullptr; + PatientInformation store; + QString currentPatientUID; + QString AddDate; + QToolButton* btnSex = nullptr; + QToolButton* btnDate = nullptr; + QSqlTableModel* model = nullptr; +}; + + +#endif //GUI_EDITPATIENTDIALOG_H diff --git a/src/SelectFormWidget.cpp b/src/SelectFormWidget.cpp index 6a3569a..e69de29 100644 --- a/src/SelectFormWidget.cpp +++ b/src/SelectFormWidget.cpp @@ -1,305 +0,0 @@ -// -// Created by Krad on 2021/10/8. -// -#include "ui_tabformwidget.h" -#include "SelectFormWidget.h" -#include -#include -#include -#include "components/SlideableTableView.h" -#include -#include -#include -#include "db/SQLHelper.h" -#include "editpatientform.h" -#include "guimacros.h" -#include "event/EventCenter.h" -#include "AccountFormDialog.h" -#include -#include "log/UserOperationLog.h" -#include -#include "src/components/VerticalTextToolButton.h" - -#include - -#define ADD_CENTER_ITEM(row,col,text)\ - item = new QTableWidgetItem(text);\ - item->setTextAlignment(Qt::AlignmentFlag::AlignCenter);\ - table->setItem(row,col,item); - - -int queryValue(QSqlTableModel* model, int colID, QVariant var) -{ - for (int i = 0; i < model->rowCount(); ++i) { - if (model->data(model->index(i, colID)) == var) return i; - } - return -1; -} - -SelectFormWidget::SelectFormWidget(QWidget* parent) : - TabFormWidget(parent) -{ - //init command bar - QHBoxLayout* layout = new QHBoxLayout(); - ui->commandWidget->setLayout(layout); - ADD_TOOL_BTN(Account, ":/icons/account.png"); - ADD_TOOL_BTN(Worklist, ":/icons/setting.png"); - btnAccount->setText(tr("Account")); - btnWorklist->setText(tr("Worklist")); - - layout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding)); - QWidget* spacerLine = new QWidget(this); - spacerLine->setFixedWidth(2); - spacerLine->setObjectName("verSpaceLine"); - layout->addWidget(spacerLine); - ADD_TOOL_BTN(Add, ":/icons/add.png"); - ADD_TOOL_BTN(Edit, ":/icons/details.png"); - ADD_TOOL_BTN(Delete, ":/icons/close_circle.png"); - ADD_TOOL_BTN(Select, ":/icons/selected.png"); - btnAdd->setText(tr("Add")); - btnEdit->setText(tr("Edit")); - btnDelete->setText(tr("Delete")); - btnSelect->setText(tr("Select")); - - //Init content widget - QHBoxLayout* contentLayout = new QHBoxLayout(); - contentLayout->setContentsMargins(5, 5, 0, 5); - this->ui->contentWidget->setLayout(contentLayout); - // TableView for patient - QTableView* table = new SlideableTableView(this); - table->setAlternatingRowColors(true); - table->setSelectionMode(QAbstractItemView::SingleSelection); - table->setEditTriggers(QAbstractItemView::NoEditTriggers); - table->setSelectionBehavior(QAbstractItemView::SelectRows); - table->verticalHeader()->setDefaultSectionSize(38); - table->horizontalHeader()->setStretchLastSection(true); - //data from SQLITE - // - //avoid pan comsumed by tableview! - table->viewport()->ungrabGesture(Qt::PanGesture); - - auto model = SQLHelper::getTable("Patient"); - model->setFilter("Flag=0"); - model->sort(5, Qt::DescendingOrder); - model->select(); - model->setHeaderData(1, Qt::Horizontal, "ID"); - model->setHeaderData(2, Qt::Horizontal, tr("Name")); - model->setHeaderData(3, Qt::Horizontal, tr("Birth Date")); - model->setHeaderData(4, Qt::Horizontal, tr("Gender")); - model->setHeaderData(5, Qt::Horizontal, tr("Add Date")); - model->setHeaderData(6, Qt::Horizontal, tr("Comment")); - - - QSortFilterProxyModel* proxyModel = new QSortFilterProxyModel(model); // create proxy - proxyModel->setSourceModel(model); - table->setSortingEnabled(true); // enable sortingEnabled - - table->setModel((QAbstractItemModel*)model); - table->hideColumn(0); - table->hideColumn(7); - table->show(); - - // table->setSortingEnabled(true); - table->setColumnWidth(1, 250); - table->setColumnWidth(2, 250); - table->setColumnWidth(3, 120); - table->setColumnWidth(4, 80); - table->setColumnWidth(5, 250); - // table->sortByColumn(5); - // table->setSortingEnabled(true); - contentLayout->addWidget(table); - QWidget* spacerLine2 = new QWidget(this); - spacerLine2->setFixedWidth(2); - spacerLine2->setObjectName("verSpaceLine"); - contentLayout->addWidget(spacerLine2); - //edit panel - EditPatientForm* edit_patient = new EditPatientForm(this); - edit_patient->setObjectName("edit_patient"); - edit_patient->hide(); - contentLayout->addWidget(edit_patient); - - auto* btnShowEdit = new VerticalTextToolButton(this); - btnShowEdit->setObjectName("showeditBtn"); - btnShowEdit->setIcon(QIcon(":/icons/edit.png")); - btnShowEdit->setIconSize(QSize(30, 30)); - btnShowEdit->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); - btnShowEdit->setFixedHeight(225); - // btnShowEdit->setVerticalText("E\nd\ni\nt\nP\na\nn\ne\nl"); - btnShowEdit->setVerticalText("Patient Detail"); - contentLayout->addWidget(btnShowEdit); - contentLayout->setAlignment(btnShowEdit, Qt::AlignmentFlag::AlignTop); - connect(btnShowEdit, &QToolButton::clicked, [=]() { - edit_patient->show(); - btnShowEdit->hide(); - }); - connect(edit_patient, &EditPatientForm::hideBtnClicked, [=]() { - edit_patient->hide(); - btnShowEdit->show(); - }); - - //select default row 0 - if (model->rowCount() > 0) - { - table->selectRow(0); - currentRow = 0; - PatientInformation pat; -#define ADD_PATIENT_PROPERTY(val)\ - pat. val = model->data(model->index(currentRow,PatientInformationEnum:: val)).toString(); - EDIT_PATIENT() -#undef ADD_PATIENT_PROPERTY - edit_patient->setPatientInformation(&pat); - } - //events---------------------------------------------------------------------- - //table current row selection changing event - connect(table, &QTableView::clicked, [=](const QModelIndex& modelIndex) { - if (currentRow != modelIndex.row()) - { - currentRow = modelIndex.row(); - PatientInformation pat; -#define ADD_PATIENT_PROPERTY(val)\ - pat. val = model->data(model->index(modelIndex.row(),PatientInformationEnum:: val)).toString(); - EDIT_PATIENT() -#undef ADD_PATIENT_PROPERTY - edit_patient->setPatientInformation(&pat); - } - }); - - connect(btnAdd, &QToolButton::clicked, [=]() { - edit_patient->show(); - btnShowEdit->hide(); - edit_patient->clearPatientInformation(); - edit_patient->setEditEnable(true); - btnSelect->setEnabled(false); - }); - connect(btnEdit, &QToolButton::clicked, [=]() { - edit_patient->show(); - btnShowEdit->hide(); - table->clicked(table->currentIndex()); - edit_patient->setEditEnable(true); - btnSelect->setEnabled(false); - }); - connect(edit_patient, &EditPatientForm::editCancel, [=]() { - btnSelect->setEnabled(true); - }); - connect(edit_patient, &EditPatientForm::editAccept, [=](PatientInformation* inf, bool& result) { - int selectedRow = currentRow; - bool isAdd = inf->PatientUID.isEmpty(); - if (isAdd) { - int ref_rowid = queryValue(model, 1, inf->ID); - if (ref_rowid >= 0) - { - //非触屏时,如果被选中的行在选中区域外,以下代码可能会出错 - //但是触屏时一般没问题 - qDebug() << ref_rowid; - table->scrollTo(model->index(ref_rowid, 3)); - table->selectRow(ref_rowid); - result = false; - return; - } - selectedRow = model->rowCount(); - inf->PatientUID = QUuid::createUuid().toString(); - inf->AddDate = QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss"); - model->insertRow(0); - selectedRow = 0; - } - qDebug() << inf->PatientUID << inf->AddDate; -#define ADD_PATIENT_PROPERTY(val)\ - model->setData(model->index(selectedRow,PatientInformationEnum:: val),inf-> val); - EDIT_PATIENT() -#undef ADD_PATIENT_PROPERTY - if (model->submitAll()) - { - table->selectRow(selectedRow); - model->selectRow(selectedRow); - } - else { - //TODO:add some error handle logic - } - if (isAdd) { - LOG_USER_OPERATION(AddPatient); - } - else - { - LOG_USER_OPERATION(ChangePatientInfo); - } - btnSelect->setEnabled(true); - }); - - connect(btnDelete, &QToolButton::clicked, [=]() { - if (currentRow < 0)return; - model->setData(model->index(currentRow, PatientInformationEnum::Flag), 9); - // model->removeRow(currentRow); - if (model->submitAll()) - { - model->select(); - if (model->rowCount() > 0) - { - table->selectRow(0); - model->selectRow(0); - PatientInformation pat; -#define ADD_PATIENT_PROPERTY(val)\ - pat. val = model->data(model->index(0,PatientInformationEnum:: val)).toString(); - EDIT_PATIENT() -#undef ADD_PATIENT_PROPERTY - edit_patient->setPatientInformation(&pat); - LOG_USER_OPERATION(DeletePatient); - } - else { - currentRow = -1; - edit_patient->editCancel(); - edit_patient->clearPatientInformation(); - } - } - else { - //TODO:error handle - } - - - }); - - connect(btnSelect, &QToolButton::clicked, [=]() { - if (currentRow < 0)return; - EventCenter::Default()->triggerEvent(GUIEvents::PatientSelected, nullptr, edit_patient->getPatientInformation()->Copy()); - LOG_USER_OPERATION(SelectPatient); - }); - - connect(btnAccount, &QToolButton::clicked, [=]() { - AccountFormDialog dia(this); - dia.setWindowModality(Qt::WindowModal); - dia.exec(); - }); - connect(EventCenter::Default(), &EventCenter::ResponsePreview, [=](QObject* sender, QObject* data) { - btnSelect->setEnabled(false); - btnDelete->setEnabled(false); - btnEdit->setEnabled(false); - btnAdd->setEnabled(false); - }); - connect(EventCenter::Default(), &EventCenter::ResponseStop, [=](QObject* sender, QObject* data) { - btnSelect->setEnabled(true); - btnDelete->setEnabled(true); - btnEdit->setEnabled(true); - btnAdd->setEnabled(true); - }); - connect(EventCenter::Default(), &EventCenter::ReloadLanguage, [=]() { - - model->setHeaderData(1, Qt::Horizontal, "ID"); - model->setHeaderData(2, Qt::Horizontal, tr("Name")); - model->setHeaderData(3, Qt::Horizontal, tr("Birth Date")); - model->setHeaderData(4, Qt::Horizontal, tr("Gender")); - model->setHeaderData(5, Qt::Horizontal, tr("Add Date")); - model->setHeaderData(6, Qt::Horizontal, tr("Comment")); - - btnAccount->setText(tr("Account")); - //btnWorklist->setText(tr("Worklist")); - btnAdd->setText(tr("Add")); - btnEdit->setText(tr("Edit")); - btnDelete->setText(tr("Delete")); - btnSelect->setText(tr("Select")); - }); - -} - - -SelectFormWidget::~SelectFormWidget() -{ -} diff --git a/src/ShimLib/ShimLib.c b/src/ShimLib/ShimLib.c index 81a1b2a..b555f5d 100644 --- a/src/ShimLib/ShimLib.c +++ b/src/ShimLib/ShimLib.c @@ -111,6 +111,10 @@ const char* GetDeviceInfo(DeviceInfo infoType) { switch (infoType) { case MEAN_TEMPERATURE: return "28"; + case VERSION: + return "6.6.06"; + case DEV_OUTPATH: + return "path to store bin"; } return ""; } diff --git a/src/ShimLib/ShimLib.h b/src/ShimLib/ShimLib.h index c392d34..8956953 100644 --- a/src/ShimLib/ShimLib.h +++ b/src/ShimLib/ShimLib.h @@ -29,7 +29,9 @@ typedef enum { //kinds of device information typedef enum { - MEAN_TEMPERATURE + MEAN_TEMPERATURE, + VERSION, + DEV_OUTPATH } DeviceInfo; extern int InitLib(void(*)(const char *msg)); diff --git a/src/UserOperationLogForm.cpp b/src/UserOperationLogForm.cpp index e1d3daf..d18f7c4 100644 --- a/src/UserOperationLogForm.cpp +++ b/src/UserOperationLogForm.cpp @@ -13,8 +13,8 @@ #include #include "components/SlideableTableView.h" #include -#include "SelectDialog.h" -#include "mainwindow.h" +#include "src/dialogs/SelectDialog.h" +#include "src/windows/mainwindow.h" #include "event/EventCenter.h" QString fileNameToDate(QString fileName) { @@ -51,7 +51,7 @@ UserOperationLogForm::UserOperationLogForm(QWidget* parent) { dialog = new SelectDialog(this); dialog->setWindowModality(Qt::WindowModal); } - dialog->setAvailableDates(dates); + dialog->setValues(dates); if (!selectedDateStr.isEmpty()) dialog->setSelectedValue(selectedDateStr); if (dialog->exec() == QDialog::Accepted) { 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/DateSlidePickerBox.cpp b/src/components/DateSlidePickerBox.cpp new file mode 100644 index 0000000..89a06db --- /dev/null +++ b/src/components/DateSlidePickerBox.cpp @@ -0,0 +1,152 @@ +// +// Created by Krad on 2022/3/24. +// + +#include "DateSlidePickerBox.h" +#include +#include +#include +DateSlidePickerBox::DateSlidePickerBox(QWidget *parent) { + layout = new QHBoxLayout(this); + myear = new SlidePickerBox(this); + QStringList centry; + centry<<"19"<<"20"; + myear->setFixedWidth(56); + myear->setItems(centry); + layout->addWidget(myear); + + tyear = new SlidePickerBox(this); + QStringList m_centry; + m_centry << "0" << "1" << "2" << "3" << "4" << "5" << "6" << "7" << "8" << "9"; + tyear->setItems(m_centry); + tyear->setFixedWidth(50); + layout->addWidget(tyear); + + year = new SlidePickerBox(this); + year->setItems(m_centry); + year->setFixedWidth(50); + layout->addWidget(year); + + QLabel* label = new QLabel(this); + label->setText("/"); +// label->setFixedHeight(110); + label->setAlignment(Qt::AlignCenter); + + label->setFixedWidth(50); + label->setObjectName("sliderSpliterLabel"); + layout->addWidget(label); + + + month = new SlidePickerBox(this); + QStringList m_mouth; + m_mouth << "01" << "02" << "03" << "04" << "05" << "06" << "07" << "08" << "09"<<"10"<<"11"<<"12"; + month->setItems(m_mouth); + month->setFixedWidth(56); + layout->addWidget(month); + + QLabel* label2 = new QLabel(this); + label2->setText("/"); +// label2->setFixedHeight(110); + label2->setAlignment(Qt::AlignCenter); +// label2->setFixedHeight(80); + label2->setFixedWidth(50); + label2->setObjectName("sliderSpliterLabel"); + + layout->addWidget(label2); + + day = new SlidePickerBox(this); + QStringList days; + days << "01" << "02" << "03" << "04" << "05" << "06" << "07" << "08" << "09"; + + for (int i=10;i<=31;i++){ + days<setFixedWidth(56); + day->setItems(days); + layout->addWidget(day); + + bigMonth << "01" << "03" << "05" << "07" << "08" << "10" << "12"; + connect(myear,&SlidePickerBox::valueChanged,this,&DateSlidePickerBox::leapYearAndFebruaryAdjust); + connect(tyear,&SlidePickerBox::valueChanged,this,&DateSlidePickerBox::leapYearAndFebruaryAdjust); + connect(year,&SlidePickerBox::valueChanged,this,&DateSlidePickerBox::leapYearAndFebruaryAdjust); + connect(month,&SlidePickerBox::valueChanged,this,&DateSlidePickerBox::leapYearAndFebruaryAdjust); +} + +void DateSlidePickerBox::resizeLabel() { + + myear->resizeLabelWidth(); + tyear->resizeLabelWidth(); + year->resizeLabelWidth(); + month->resizeLabelWidth(); + day->resizeLabelWidth(); +} + +QString DateSlidePickerBox::getSelectedValue() { + return QString("%1%2%3-%4-%5").arg(myear->getSelectedValue()). + arg(tyear->getSelectedValue()).arg(year->getSelectedValue()) + .arg(month->getSelectedValue()).arg(day->getSelectedValue()); +} + +void DateSlidePickerBox::setSelectedValue(const QString &val) { + myear->setSelectedValue(val.left(2)); + tyear->setSelectedValue(val.left(3).right(1)); + year->setSelectedValue(val.left(4).right(1)); + QStringList sary = val.split('-'); + month->setSelectedValue(sary[1]); + day->setSelectedValue(sary[2]); +} + +int DateSlidePickerBox::getYear() { + return QString("%1%2%3").arg(myear->getSelectedValue()). + arg(tyear->getSelectedValue()).arg(year->getSelectedValue()).toInt(); + +} + +void DateSlidePickerBox::leapYearAndFebruaryAdjust() { + QString d = day->getSelectedValue(); + //闰年且二月 + if (QDate::isLeapYear(getYear()) && month->getSelectedValue() == "02") { + //seq is important, must enable item firstly + day->enableItem("29"); + if (d.toInt() > 29) { + day->setSelectedValue("29"); + } + + day->disableItem("30"); + day->disableItem("31"); + } + //普通年份2月或其他月份 + else{ + //普通年份2月 + if (month->getSelectedValue() == "02") { + //seq is important, must set selected value firstly + if (d.toInt() > 28) { + day->setSelectedValue("28"); + } + day->disableItem("29"); + day->disableItem("30"); + day->disableItem("31"); + } + //其他月份 + else{ + + day->enableItem("29"); + day->enableItem("30"); + if (isBigMonth()){ + day->enableItem("31"); + } + else{ + //seq is important, must set selected value firstly + if (d == "31") { + day->setSelectedValue("30"); + } + day->disableItem("31"); + } + } + } +// day->setSelectedValue(d); +} + +bool DateSlidePickerBox::isBigMonth() { + return bigMonth.contains(month->getSelectedValue()); +} diff --git a/src/components/DateSlidePickerBox.h b/src/components/DateSlidePickerBox.h new file mode 100644 index 0000000..12492f1 --- /dev/null +++ b/src/components/DateSlidePickerBox.h @@ -0,0 +1,34 @@ +// +// Created by Krad on 2022/3/24. +// + +#ifndef GUI_DATESLIDEPICKERBOX_H +#define GUI_DATESLIDEPICKERBOX_H + +#include +#include "SlidePickerBox.h" +#include +class QHBoxLayout; +class DateSlidePickerBox:public QWidget { + Q_OBJECT +public: + explicit DateSlidePickerBox(QWidget *parent = nullptr); + QString getSelectedValue(); + void setSelectedValue(const QString& val); + void resizeLabel(); + SlidePickerBox* myear; + SlidePickerBox* tyear; + SlidePickerBox* year; + SlidePickerBox* month; + SlidePickerBox* day; +public Q_SLOTS: + void leapYearAndFebruaryAdjust(); +private: + int getYear(); + QStringList bigMonth; + bool isBigMonth(); + QHBoxLayout* layout; +}; + + +#endif //GUI_DATESLIDEPICKERBOX_H diff --git a/src/components/Listbox.cpp b/src/components/Listbox.cpp new file mode 100644 index 0000000..ed2c5f8 --- /dev/null +++ b/src/components/Listbox.cpp @@ -0,0 +1,20 @@ +// +// Created by Krad on 2022/3/21. +// + +#include +#include +#include +#include "Listbox.h" + +void Listbox::paintEvent(QPaintEvent *e) { + QString temp = this->text(); + this->setText(""); + QToolButton::paintEvent(e); + this->setText(temp); + QStylePainter p(this); + QStyleOptionToolButton opt; + initStyleOption(&opt); + + p.drawText((size().width()-this->iconSize().width())/2-(this->text().length()*opt.font.pixelSize())/4,this->iconSize().height()+2,this->text()); +} diff --git a/src/components/Listbox.h b/src/components/Listbox.h new file mode 100644 index 0000000..000a37f --- /dev/null +++ b/src/components/Listbox.h @@ -0,0 +1,21 @@ +// +// Created by Krad on 2022/3/21. +// + +#ifndef GUI_LISTBOX_H +#define GUI_LISTBOX_H + +#include +class Listbox: public QToolButton { +public: + explicit Listbox(QWidget* parent = nullptr){}; + virtual ~Listbox(){}; + +protected: + virtual void paintEvent(QPaintEvent* e) override; + +private: +}; + + +#endif //GUI_LISTBOX_H diff --git a/src/components/SlidePickerBox.cpp b/src/components/SlidePickerBox.cpp index dfbf22d..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) { @@ -19,7 +19,7 @@ SlidePickerBox::SlidePickerBox(QWidget *parent):QWidget(parent) { label->setObjectName("sliderPickerLabel"); label->setFixedHeight(fontSize); label->setFixedWidth(320); - QPoint p = this->mapToGlobal({this->contentsMargins().left(),50-fontSize/2}); + QPoint p = {0,50-fontSize/2}; label->move(p); lbls.push_back(label); QLabel* label1 = new QLabel(this); @@ -29,7 +29,7 @@ SlidePickerBox::SlidePickerBox(QWidget *parent):QWidget(parent) { label1->setObjectName("sliderPickerLabel"); label1->setFixedHeight(fontSize); label1->setFixedWidth(320); - QPoint p1 = this->mapToGlobal({this->contentsMargins().left(),150-fontSize/2}); + QPoint p1 = {0,150-fontSize/2}; label1->move(p1); lbls.push_back(label1); QLabel* label2 = new QLabel(this); @@ -39,7 +39,7 @@ SlidePickerBox::SlidePickerBox(QWidget *parent):QWidget(parent) { label2->setObjectName("sliderPickerLabel"); label2->setFixedHeight(fontSize); label2->setFixedWidth(320); - QPoint p2 = this->mapToGlobal({this->contentsMargins().left(),250-fontSize/2}); + QPoint p2 = {0,250-fontSize/2}; label2->move(p2); lbls.push_back(label2); @@ -51,7 +51,7 @@ SlidePickerBox::SlidePickerBox(QWidget *parent):QWidget(parent) { line1->setFixedSize(320,100); line1->setObjectName("topBottomLine"); line1->raise(); - QPoint lp = this->mapToGlobal({this->contentsMargins().left(),100}); + QPoint lp = {0,100}; line1->move(lp); selectedIndex = 1; @@ -76,11 +76,13 @@ void SlidePickerBox::mouseMoveEvent(QMouseEvent *ev) { } //防止拉过头 int selectItemCenter = selectedLbl->geometry().center().y(); - if (selectedLbl == lbls.last() && selectItemCenter<=150 && offset<0) return; - if (selectedLbl == lbls.first() && selectItemCenter>=150 && offset>0) return; + if (selectedLbl == getEnabledLastLabel() && selectItemCenter<=150 && offset<0) return; + if (selectedLbl == getEnabledFirstLabel() && selectItemCenter>=150 && offset>0) return; int i = 0; for (auto item : lbls) { + if (disableItems.contains(item->text()))continue; + //不需要横向 //int nx = item->geometry().left()+(ev->pos().x()-o_x); int ny = item->geometry().top() + offset; @@ -109,6 +111,8 @@ void SlidePickerBox::mouseReleaseEvent(QMouseEvent *ev) { isDragging = false; adjustPositon(); QWidget::mouseReleaseEvent(ev); + QString v = getSelectedValue(); + emit valueChanged(v); } void SlidePickerBox::adjustPositon() const { @@ -139,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); @@ -163,7 +167,7 @@ void SlidePickerBox::setItems(QStringList itemsList) { lbl->setFixedHeight(fontSize); lbl->setFixedWidth(320); lbls.push_back(lbl); - QPoint p = this->mapToGlobal({this->contentsMargins().left(),-150}); + QPoint p = {0,-150}; lbl->move(p); } selectedIndex = lbls.count()-1; @@ -178,36 +182,32 @@ QString SlidePickerBox::getSelectedValue() { void SlidePickerBox::setCurrentLabel(QLabel *label) { if (selectedLbl)hideLabel(selectedLbl); if (label) { - QPoint lp = this->mapToGlobal({this->contentsMargins().left(), 100}); + QPoint lp = {0, 100}; label->move(lp); label->show(); selectedLbl = label; } } -void SlidePickerBox::setNextLabel(QLabel *label) { - if (nextLbl)hideLabel(nextLbl); - if (label){ - QPoint lp = this->mapToGlobal({this->contentsMargins().left(),200}); - label->move(lp); - label->show(); - nextLbl = label; +QLabel * SlidePickerBox::getEnabledFirstLabel() { + if (disableItems.empty()) return lbls.first(); + for(int idx = 0; idxtext()))continue; + return lbls[idx]; } } -void SlidePickerBox::setPrevLabel(QLabel *label) { - if (prevLbl)hideLabel(prevLbl); - if (label) { - QPoint lp = this->mapToGlobal({this->contentsMargins().left(), 0}); - label->move(lp); - label->show(); - prevLbl = label; +QLabel * SlidePickerBox::getEnabledLastLabel() { + if (disableItems.empty()) return lbls.last(); + for(int idx = lbls.size()-1; idx>=0; idx--){ + if(disableItems.contains(lbls[idx]->text()))continue; + return lbls[idx]; } } void SlidePickerBox::hideLabel(QLabel *label) { if (!label) return; - QPoint lp = this->mapToGlobal({this->contentsMargins().left(), -150}); + QPoint lp = {0, -150}; label->move(lp); } @@ -221,11 +221,53 @@ void SlidePickerBox::setSelectedValue(const QString& val) { } int first_y = -100 * (selectedIndex-1); for (int i = 0; i < lbls.count() ; ++i) { - QPoint lp = {this->contentsMargins().left(), first_y+i*100}; + + QPoint lp = this->mapTo(this,{0, first_y+i*100}); lbls[i]->move(lp); lbls[i]->show(); lbls[i]->setStyleSheet("background:transparent"); - lbls[i]->lower(); + + } + selectedLbl = lbls[selectedIndex]; + lbls[selectedIndex]->setStyleSheet("color:white"); + adjustPositon(); +} + +void SlidePickerBox::resizeLabelWidth() { + for (int i = 0; i < lbls.count() ; ++i) { + lbls[i]->setAlignment(defaultAlign); + lbls[i]->setFixedWidth(this->width()+this->contentsMargins().left()+this->contentsMargins().right()); + } +} + +void SlidePickerBox::disableItem(const QString& val) { + if (!disableItems.contains(val)){ + disableItems.append(val); + rearrangeLabels(); + } +} + +void SlidePickerBox::enableItem(const QString &val) { + if (disableItems.contains(val)){ + disableItems.removeOne(val); + rearrangeLabels(); + } +} + +void SlidePickerBox::rearrangeLabels() { + int first_y = -100 * (selectedIndex-1); + int r_index = 0; + for (int i = 0; i < lbls.count() ; ++i) { + if (disableItems.contains(lbls[i]->text())){ + lbls[i]->hide(); + continue; + } + QPoint lp = this->mapTo(this,{0, first_y+r_index*100}); + r_index++; + lbls[i]->move(lp); + lbls[i]->show(); + lbls[i]->setStyleSheet("background:transparent"); + } selectedLbl = lbls[selectedIndex]; lbls[selectedIndex]->setStyleSheet("color:white"); diff --git a/src/components/SlidePickerBox.h b/src/components/SlidePickerBox.h index fe6e45c..f3e96f0 100644 --- a/src/components/SlidePickerBox.h +++ b/src/components/SlidePickerBox.h @@ -12,12 +12,22 @@ class SlidePickerBox:public QWidget { public: explicit SlidePickerBox(QWidget *parent = nullptr); QString getSelectedValue(); - void setItems(QStringList itemsList); - void addItem(QString& item) - { + void setItems(const QStringList& itemsList); + void addItem(QString& item) { this->items.append(item); } + void disableItem(const QString& val); + void enableItem(const QString& val); + int getItemsCount(){ + return items.size(); + } void setSelectedValue(const QString& val); + void resizeLabelWidth(); + void setDefaultAlignment(QFlags align){ + this->defaultAlign = align; + } + signals: + void valueChanged(QString & value); protected: bool isDragging; @@ -33,9 +43,10 @@ protected: } void setCurrentLabel(QLabel* label); - void setPrevLabel(QLabel* label); - void setNextLabel(QLabel* label); + QLabel * getEnabledLastLabel(); + QLabel * getEnabledFirstLabel(); void hideLabel(QLabel* label); + void rearrangeLabels(); private: int o_x=0,o_y=10; int selectedIndex = -1; @@ -44,7 +55,8 @@ private: QLabel* nextLbl = nullptr; QList lbls; QStringList items; - + QStringList disableItems; + QFlags defaultAlign= Qt::AlignCenter; void adjustPositon() const; }; diff --git a/src/components/SlideableTableView.cpp b/src/components/SlideableTableView.cpp index 186f732..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) { @@ -68,3 +68,8 @@ void SlideableTableView::mouseReleaseEvent(QMouseEvent *ev) { // } QTableView::mouseReleaseEvent(ev); } + +void SlideableTableView::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) { + QTableView::currentChanged(current, previous); + emit currentRowChanged(current.row()); +} diff --git a/src/components/SlideableTableView.h b/src/components/SlideableTableView.h index 212f17c..7388615 100644 --- a/src/components/SlideableTableView.h +++ b/src/components/SlideableTableView.h @@ -12,11 +12,15 @@ public: explicit SlideableTableView(QWidget *parent = nullptr); ~SlideableTableView(); +Q_SIGNALS: + void currentRowChanged(int row); protected: void mousePressEvent(QMouseEvent *ev) override ; void mouseMoveEvent(QMouseEvent *ev) override ; void mouseReleaseEvent(QMouseEvent *ev) override ; + void currentChanged(const QModelIndex ¤t, + const QModelIndex &previous) override; private: bool isDragging = false; int ox,oy,ov; 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/db/CenterAlignSqlTableModel.h b/src/db/CenterAlignSqlTableModel.h index 222fa57..1f22f4e 100644 --- a/src/db/CenterAlignSqlTableModel.h +++ b/src/db/CenterAlignSqlTableModel.h @@ -15,7 +15,15 @@ protected: QVariant data(const QModelIndex& index, int role) const override { if (index.column() >0 && role == Qt::TextAlignmentRole) { return Qt::AlignCenter; - } else { + } + if (index.column() >0 && role == Qt::DisplayRole){ + auto val = QSqlTableModel::data(index,role).toString(); + QStringList list = val.split("\n"); + if (list.size()>1) + return QString("%1...").arg(list[0].left(list[0].length()<20?list[0].length():20)); + return val; + } + else { return QSqlTableModel::data(index,role); } } diff --git a/src/device/DeviceManager.cpp b/src/device/DeviceManager.cpp index df1a367..07e99d5 100644 --- a/src/device/DeviceManager.cpp +++ b/src/device/DeviceManager.cpp @@ -222,6 +222,7 @@ void DeviceManager::timerEvent(QTimerEvent* event) { qDebug() << "Scanning request status, status:" << getStatusString(inf.status); //设备正常扫描中 if (inf.status == SCANNING) { + qDebug() <<"current output path:"<terminate(); delete previewDataCaller; } + +QString DeviceManager::getSoftwareVersion() { + return GetDeviceInfo(VERSION); +} + +QString DeviceManager::getScanOutputPath() { + return GetDeviceInfo(DEV_OUTPATH); +} diff --git a/src/device/DeviceManager.h b/src/device/DeviceManager.h index 79e1e97..60aa53a 100644 --- a/src/device/DeviceManager.h +++ b/src/device/DeviceManager.h @@ -20,6 +20,8 @@ public: void setErrorOccurred(bool v){ errorOccurred = v; } + QString getSoftwareVersion(); + QString getScanOutputPath(); bool getErrorOccurred(){ return errorOccurred; } diff --git a/src/AccountFormDialog.cpp b/src/dialogs/AccountFormDialog.cpp similarity index 98% rename from src/AccountFormDialog.cpp rename to src/dialogs/AccountFormDialog.cpp index 2529c41..5f69143 100644 --- a/src/AccountFormDialog.cpp +++ b/src/dialogs/AccountFormDialog.cpp @@ -131,13 +131,16 @@ AccountFormDialog::AccountFormDialog(QWidget* parent, AccountEditMode mode, Qt:: layout->addWidget(lbl_endline9); if (m_mode == Self) { connect(btn_Pwd, &QPushButton::clicked, [=]() { - ChangePasswordFormDialog dia(this->parentWidget()); + ChangePasswordFormDialog dia(this); + dia.setGeometry(this->geometry()); dia.setWindowModality(Qt::WindowModal); dia.exec(); + }); } else { connect(btn_Pwd, &QAbstractButton::clicked, [=]() { AlertDialog dialog(this); + dialog.setGeometry(this->geometry()); dialog.setButtonMode(OkAndCancel); dialog.setWindowModality(Qt::WindowModal); dialog.setAlertMessage(tr("Reset password to \"123456\" ?")); diff --git a/src/AccountFormDialog.h b/src/dialogs/AccountFormDialog.h similarity index 100% rename from src/AccountFormDialog.h rename to src/dialogs/AccountFormDialog.h diff --git a/src/AlertDialog.cpp b/src/dialogs/AlertDialog.cpp similarity index 86% rename from src/AlertDialog.cpp rename to src/dialogs/AlertDialog.cpp index 749aa4e..f1f20a0 100644 --- a/src/AlertDialog.cpp +++ b/src/dialogs/AlertDialog.cpp @@ -12,7 +12,7 @@ AlertDialog::AlertDialog(QWidget *parent, Qt::WindowFlags f) : GUIFormBaseDialog QVBoxLayout* layout = new QVBoxLayout(formWidget); layout->setSpacing(10); // add title - QLabel* lbl_title = new QLabel(this); + lbl_title = new QLabel(this); lbl_title->setAlignment(Qt::AlignCenter); lbl_title->setText(tr("Warning")); lbl_title->setObjectName("title"); @@ -28,3 +28,7 @@ AlertDialog::~AlertDialog() { void AlertDialog::setAlertMessage(const QString &msg) { this->lbl_msg->setText(msg); } + +void AlertDialog::setTitle(const QString &msg) { + lbl_title->setText(msg); +} diff --git a/src/AlertDialog.h b/src/dialogs/AlertDialog.h similarity index 88% rename from src/AlertDialog.h rename to src/dialogs/AlertDialog.h index 2cb2574..b816451 100644 --- a/src/AlertDialog.h +++ b/src/dialogs/AlertDialog.h @@ -12,11 +12,13 @@ public: explicit AlertDialog(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); ~AlertDialog(); void setAlertMessage(const QString& msg); + void setTitle(const QString& msg); protected: bool updateReferenceData() override{return true;} private: QLabel* lbl_msg; + QLabel* lbl_title; }; diff --git a/src/ChangePasswordFormDialog.cpp b/src/dialogs/ChangePasswordFormDialog.cpp similarity index 100% rename from src/ChangePasswordFormDialog.cpp rename to src/dialogs/ChangePasswordFormDialog.cpp diff --git a/src/ChangePasswordFormDialog.h b/src/dialogs/ChangePasswordFormDialog.h similarity index 100% rename from src/ChangePasswordFormDialog.h rename to src/dialogs/ChangePasswordFormDialog.h diff --git a/src/GUIFormBaseDialog.cpp b/src/dialogs/GUIFormBaseDialog.cpp similarity index 100% rename from src/GUIFormBaseDialog.cpp rename to src/dialogs/GUIFormBaseDialog.cpp diff --git a/src/GUIFormBaseDialog.h b/src/dialogs/GUIFormBaseDialog.h similarity index 100% rename from src/GUIFormBaseDialog.h rename to src/dialogs/GUIFormBaseDialog.h diff --git a/src/SelectDialog.cpp b/src/dialogs/SelectDialog.cpp similarity index 92% rename from src/SelectDialog.cpp rename to src/dialogs/SelectDialog.cpp index 04e98ed..06a4c92 100644 --- a/src/SelectDialog.cpp +++ b/src/dialogs/SelectDialog.cpp @@ -24,7 +24,7 @@ bool SelectDialog::updateReferenceData() { return true; } -void SelectDialog::setAvailableDates(QStringList dates) { +void SelectDialog::setValues(const QStringList& dates) { box->setItems(dates); } diff --git a/src/SelectDialog.h b/src/dialogs/SelectDialog.h similarity index 91% rename from src/SelectDialog.h rename to src/dialogs/SelectDialog.h index 548db61..fb0576c 100644 --- a/src/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 setAvailableDates(QStringList dates); + void setValues(const QStringList& values); QString getSelectedValue(); void setSelectedValue(const QString& val); protected: diff --git a/src/guimessagedialog.cpp b/src/dialogs/guimessagedialog.cpp similarity index 100% rename from src/guimessagedialog.cpp rename to src/dialogs/guimessagedialog.cpp diff --git a/src/guimessagedialog.h b/src/dialogs/guimessagedialog.h similarity index 100% rename from src/guimessagedialog.h rename to src/dialogs/guimessagedialog.h diff --git a/src/guimessagedialog.ui b/src/dialogs/guimessagedialog.ui similarity index 100% rename from src/guimessagedialog.ui rename to src/dialogs/guimessagedialog.ui diff --git a/src/editpatientform.cpp b/src/editpatientform.cpp deleted file mode 100644 index 4745d5f..0000000 --- a/src/editpatientform.cpp +++ /dev/null @@ -1,167 +0,0 @@ -#include "editpatientform.h" -#include "ui_editpatientform.h" -#include -#include -#include -#include -#include "guimacros.h" -#include -#include "event/EventCenter.h" - -EditPatientForm::EditPatientForm(QWidget* parent) : - QWidget(parent), - ui(new Ui::EditPatientForm) -{ -// this->layout()->setContentsMargins(5,5,5,5); - ui->setupUi(this); - //ui->lbl_Sex->setText(tr("Gender")); - QHBoxLayout* sexlayout = new QHBoxLayout(ui->sexpanelwidget); - sexlayout->setMargin(6); - ADD_TOOL_SIZE_BTN_TO_LAYOUT(F, ":/icons/female_d.png", 30, sexlayout); - ADD_TOOL_SIZE_BTN_TO_LAYOUT(M, ":/icons/male_d.png", 30, sexlayout); - btnF->setText(tr("Female")); - btnM->setText(tr("Male")); - - ui->hideBtn->setSizePolicy(QSizePolicy::Policy::Expanding,QSizePolicy::Policy::Preferred); - ui->hideBtn->setObjectName("hideeditBtn"); - ui->hideBtn->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); - ui->hideBtn->setIcon(QIcon(":/icons/hidearrow.png")); - ui->hideBtn->setIconSize({30,30}); - ui->hideBtn->setText(tr(" Hide Panel")); - connect(ui->hideBtn,&QToolButton::clicked,[=](){ - emit hideBtnClicked(); - }); - - // btnFemale->setToolButtonStyle(Qt::ToolButtonIconOnly); - // btnMale->setToolButtonStyle(Qt::ToolButtonIconOnly); - - btnF->setObjectName("sexBtn"); - btnM->setObjectName("sexBtn"); - //btnF->setText("Female"); - //btnM->setText("Male"); - ui->sexpanelwidget->setEnabled(editEnable); - btnF->setEnabled(editEnable); - btnM->setEnabled(editEnable); - btnF->setCheckable(true); - btnM->setCheckable(true); - QButtonGroup* group = new QButtonGroup(this); - group->addButton(btnF); - group->addButton(btnM); - btnF->setChecked(true); - btnFemale = btnF; - btnMale = btnM; - QHBoxLayout* layout = new QHBoxLayout(this->ui->editcmdWidget); - - ADD_TOOL_BTN(Cancel, ":/icons/close_circle.png"); - ADD_TOOL_BTN(Accpet, ":/icons/selected.png"); - btnCancel->setText(tr("Cancel")); - btnAccpet->setText(tr("Accept")); - 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(); - emit editCancel(); - }); - connect(btnEditAccept, &QToolButton::clicked, [=]() { - if (ui->tbx_ID->text().isEmpty())return; - if (ui->tbx_Name->text().isEmpty())return; - storePatientInformation(); - bool result = true; - emit editAccept(getPatientInformation(), result); - if (result) this->setEditEnable(false); - }); - ui->tbx_Dob->setDisplayFormat("yyyy/MM/dd"); - - connect(EventCenter::Default(), &EventCenter::ReloadLanguage, [=]() { - - ui->retranslateUi(this); - btnF->setText(tr("Female")); - btnM->setText(tr("Male")); - btnCancel->setText(tr("Cancel")); - btnAccpet->setText(tr("Accept")); - }); - - - -} - -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); - ui->rtbx_Comment->setText(information->Comment); - btnFemale->setChecked(information->Sex == "F"); - btnMale->setChecked(information->Sex != "F"); - currentPatientUID = information->PatientUID; - AddDate = information->AddDate; - storePatientInformation(); - } -} - -void EditPatientForm::clearPatientInformation() { - ui->tbx_ID->setText(""); - ui->tbx_Dob->setDate(QDate::currentDate()); - ui->tbx_Name->setText(""); - btnFemale->setChecked(true); - btnMale->setChecked(false); - ui->rtbx_Comment->setText(""); - currentPatientUID = ""; - AddDate = ""; -} - -void EditPatientForm::setEditEnable(bool enable) { - ui->tbx_ID->setEnabled(enable); - ui->tbx_Dob->setEnabled(enable); - ui->tbx_Name->setEnabled(enable); - ui->sexpanelwidget->setEnabled(enable); - btnFemale->setEnabled(enable); - btnFemale->setIcon(QIcon(enable ? ":/icons/female.png" : ":/icons/female_d.png")); - btnMale->setEnabled(enable); - btnMale->setIcon(QIcon(enable ? ":/icons/male.png" : ":/icons/male_d.png")); - 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.AddDate = AddDate; - store.ID = ui->tbx_ID->text(); - store.BirthDate = ui->tbx_Dob->date().toString("yyyy-MM-dd"); - store.Name = ui->tbx_Name->text(); - store.Sex = btnFemale->isChecked() ? "F" : "M"; - store.Comment = ui->rtbx_Comment->toPlainText(); - qDebug() << store.PatientUID << "," << store.ID << "," << store.BirthDate << "," << store.Name << "," << store.Sex; -} - -void EditPatientForm::restorePatientInformation() { - currentPatientUID = store.PatientUID; - AddDate = store.AddDate; - ui->tbx_ID->setText(store.ID); - ui->tbx_Dob->setDate(QDate::fromString(store.BirthDate, "yyyy-MM-dd")); - ui->tbx_Name->setText(store.Name); - ui->rtbx_Comment->setText(store.Comment); - btnFemale->setChecked(store.Sex == "F"); - btnMale->setChecked(store.Sex != "F"); - // ui->cb_Sex->setCurrentText(store.Sex=="F"?"Female":(store.Name=="M"?"Male":"Other")); - -} diff --git a/src/editpatientform.ui b/src/editpatientform.ui deleted file mode 100644 index 990d93b..0000000 --- a/src/editpatientform.ui +++ /dev/null @@ -1,152 +0,0 @@ - - - EditPatientForm - - - - 0 - 0 - 400 - 466 - - - - Form - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - ... - - - - - - - 6 - - - 6 - - - 6 - - - 6 - - - - - ID - - - - - - - false - - - - - - - Name - - - - - - - false - - - - - - - Gender - - - - - - - - - - Date Of Birth - - - - - - - false - - - QAbstractSpinBox::NoButtons - - - - - - - - 1 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - Comment - - - - - - - false - - - - - - - - - - - - - diff --git a/src/fonts/MicrosoftYahei.ttf b/src/fonts/MicrosoftYahei.ttf new file mode 100644 index 0000000..ea3c090 Binary files /dev/null and b/src/fonts/MicrosoftYahei.ttf differ diff --git a/src/TopBarWidget.cpp b/src/forms/TopBarWidget.cpp similarity index 100% rename from src/TopBarWidget.cpp rename to src/forms/TopBarWidget.cpp diff --git a/src/TopBarWidget.h b/src/forms/TopBarWidget.h similarity index 100% rename from src/TopBarWidget.h rename to src/forms/TopBarWidget.h diff --git a/src/ScanFormWidget.cpp b/src/forms/scan/ScanFormWidget.cpp similarity index 99% rename from src/ScanFormWidget.cpp rename to src/forms/scan/ScanFormWidget.cpp index 583c189..76b5a60 100644 --- a/src/ScanFormWidget.cpp +++ b/src/forms/scan/ScanFormWidget.cpp @@ -8,7 +8,7 @@ #include #include "ui_tabformwidget.h" #include "guimacros.h" -#include "patientinformationform.h" +#include "src/forms/scan/patientinformationform.h" #include #include "event/EventCenter.h" #include diff --git a/src/ScanFormWidget.h b/src/forms/scan/ScanFormWidget.h similarity index 94% rename from src/ScanFormWidget.h rename to src/forms/scan/ScanFormWidget.h index 9984930..4c54ff2 100644 --- a/src/ScanFormWidget.h +++ b/src/forms/scan/ScanFormWidget.h @@ -5,7 +5,7 @@ #ifndef GUI_SCANFORMWIDGET_H #define GUI_SCANFORMWIDGET_H -#include "tabformwidget.h" +#include "src/forms/tabformwidget.h" #include class PatientInformationForm; class ScanFormWidget :public TabFormWidget { diff --git a/src/patientinformationform.cpp b/src/forms/scan/patientinformationform.cpp similarity index 100% rename from src/patientinformationform.cpp rename to src/forms/scan/patientinformationform.cpp diff --git a/src/patientinformationform.h b/src/forms/scan/patientinformationform.h similarity index 93% rename from src/patientinformationform.h rename to src/forms/scan/patientinformationform.h index b07a0a0..02cc2f9 100644 --- a/src/patientinformationform.h +++ b/src/forms/scan/patientinformationform.h @@ -2,7 +2,7 @@ #define PATIENTINFORMATIONFORM_H #include -#include "editpatientform.h" +#include "src/forms/select/editpatientform.h" namespace Ui { class PatientInformationForm; } diff --git a/src/patientinformationform.ui b/src/forms/scan/patientinformationform.ui similarity index 100% rename from src/patientinformationform.ui rename to src/forms/scan/patientinformationform.ui diff --git a/src/forms/select/SelectFormWidget.cpp b/src/forms/select/SelectFormWidget.cpp new file mode 100644 index 0000000..8d5bb67 --- /dev/null +++ b/src/forms/select/SelectFormWidget.cpp @@ -0,0 +1,324 @@ +// +// Created by Krad on 2021/10/8. +// +#include "ui_tabformwidget.h" +#include "SelectFormWidget.h" +#include +#include +#include +#include "components/SlideableTableView.h" +#include +#include +#include +#include "db/SQLHelper.h" +#include "guimacros.h" +#include "event/EventCenter.h" +#include "src/dialogs/AccountFormDialog.h" +#include +#include "log/UserOperationLog.h" +#include "src/components/VerticalTextToolButton.h" +#include "dialogs/AlertDialog.h" + +#include + + + +SelectFormWidget::SelectFormWidget(QWidget* parent) : + TabFormWidget(parent) +{ + //init command bar + QHBoxLayout* layout = new QHBoxLayout(); + ui->commandWidget->setLayout(layout); + ADD_TOOL_BTN(Account, ":/icons/account.png"); + ADD_TOOL_BTN(Worklist, ":/icons/setting.png"); + btnAccount->setText(tr("Account")); + btnWorklist->setText(tr("Worklist")); + + layout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding)); + QWidget* spacerLine = new QWidget(this); + spacerLine->setFixedWidth(2); + spacerLine->setObjectName("verSpaceLine"); + layout->addWidget(spacerLine); + ADD_TOOL_BTN(Add, ":/icons/add.png"); + ADD_TOOL_BTN(Edit, ":/icons/details.png"); + ADD_TOOL_BTN(Delete, ":/icons/close_circle.png"); + ADD_TOOL_BTN(Select, ":/icons/selected.png"); + btnAdd->setText(tr("Add")); + btnEdit->setText(tr("Edit")); + btnDelete->setText(tr("Delete")); + btnSelect->setText(tr("Select")); + + //Init content widget + QHBoxLayout* contentLayout = new QHBoxLayout(); + contentLayout->setContentsMargins(5, 5, 0, 5); + this->ui->contentWidget->setLayout(contentLayout); + // TableView for patient + SlideableTableView* table = new SlideableTableView(this); + table->setAlternatingRowColors(true); + table->setSelectionMode(QAbstractItemView::SingleSelection); + table->setEditTriggers(QAbstractItemView::NoEditTriggers); + table->setSelectionBehavior(QAbstractItemView::SelectRows); + table->verticalHeader()->setDefaultSectionSize(38); + table->horizontalHeader()->setStretchLastSection(true); + //data from SQLITE + // + //avoid pan comsumed by tableview! + table->viewport()->ungrabGesture(Qt::PanGesture); + + auto model = SQLHelper::getTable("Patient"); + model->setFilter("Flag=0"); + model->sort(5, Qt::DescendingOrder); + model->select(); + model->setHeaderData(1, Qt::Horizontal, "ID"); + model->setHeaderData(2, Qt::Horizontal, tr("Name")); + model->setHeaderData(3, Qt::Horizontal, tr("Birth Date")); + model->setHeaderData(4, Qt::Horizontal, tr("Gender")); + model->setHeaderData(5, Qt::Horizontal, tr("Add Date")); + model->setHeaderData(6, Qt::Horizontal, tr("Comment")); + table->setSortingEnabled(true); // enable sortingEnabled + + table->setModel((QAbstractItemModel*)model); + table->hideColumn(0); + table->hideColumn(7); + table->show(); + + table->setColumnWidth(1, 250); + table->setColumnWidth(2, 250); + table->setColumnWidth(3, 160); + table->setColumnWidth(4, 120); + table->setColumnWidth(5, 250); + contentLayout->addWidget(table); + QWidget* spacerLine2 = new QWidget(this); + spacerLine2->setFixedWidth(2); + spacerLine2->setObjectName("verSpaceLine"); + contentLayout->addWidget(spacerLine2); + // prepare edit panel + EditPatientForm* edit_patient = new EditPatientForm(this); + edit_patient->setObjectName("edit_patient"); + edit_patient->hide(); + contentLayout->addWidget(edit_patient); + auto* btnShowEdit = new VerticalTextToolButton(this); + btnShowEdit->setObjectName("showeditBtn"); + btnShowEdit->setIcon(QIcon(":/icons/edit.png")); + btnShowEdit->setIconSize(QSize(30, 30)); + btnShowEdit->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); + btnShowEdit->setFixedHeight(225); + btnShowEdit->setVerticalText("Patient Detail"); + contentLayout->addWidget(btnShowEdit); + contentLayout->setAlignment(btnShowEdit, Qt::AlignmentFlag::AlignTop); + + // btn show slot + connect(btnShowEdit, &QToolButton::clicked, [=]() { + edit_patient->show(); + btnShowEdit->hide(); + }); + //btn hide slot + connect(edit_patient, &EditPatientForm::hideBtnClicked, [=]() { + edit_patient->hide(); + btnShowEdit->show(); + }); + + //select default row 0 + if (model->rowCount() > 0) + { + table->selectRow(0); + setPatientDetail(table, model, edit_patient); + } + //events---------------------------------------------------------------------- + //prepare button state + auto prepareButtons = [=](bool disableALL){ + bool state_flag = (table->currentIndex().row()>=0); + btnSelect->setEnabled(state_flag && !disableALL); + btnDelete->setEnabled(state_flag && !disableALL); + btnEdit->setEnabled(state_flag && !disableALL); + btnAdd->setEnabled(!disableALL); + }; + //table current row selection changing event + connect(table, &SlideableTableView::currentRowChanged, [=](int row) { + setPatientDetail(table, model, edit_patient); + prepareButtons(false); + }); + + // after sort by column + connect(table->horizontalHeader(),&QHeaderView::sectionClicked,[=](int index){ + edit_patient->clearPatientInformation(); + prepareButtons(false); + }); + + // btn add slot + connect(btnAdd, &QToolButton::clicked, [=]() { + EditPatientDialog dialog(this); + dialog.clearPatientInformation(); + dialog.setWindowModality(Qt::WindowModal); + dialog.setModel(model); + // accept change + if (dialog.exec() == QDialog::Accepted) { + table->selectRow(0); + model->selectRow(0); + } + LOG_USER_OPERATION(AddPatient) + btnSelect->setEnabled(true); + }); + + // btn edit slot + connect(btnEdit, &QToolButton::clicked, [=]() { + EditPatientDialog dialog(this); + dialog.setPatientInformation(edit_patient->getPatientInformation()); + dialog.setWindowModality(Qt::WindowModal); + dialog.setModel(model); + // accept change + if (dialog.exec() == QDialog::Accepted) { + table->clicked(table->currentIndex()); + setPatientDetail(table, model, edit_patient); + LOG_USER_OPERATION(AddPatient); + btnSelect->setEnabled(true); + } + }); + + // btn add slot + connect(edit_patient, &EditPatientForm::editCancel, [=]() { + if (table->currentIndex().row()<0) return; + btnSelect->setEnabled(true); + }); + + // btn add slot + connect(edit_patient, &EditPatientForm::editAccept, [=](PatientInformation* inf, bool& result) { + int selectedRow = table->currentIndex().row(); + bool isAdd = inf->PatientUID.isEmpty(); + if (isAdd) { + selectedRow = model->rowCount(); + inf->PatientUID = QUuid::createUuid().toString(); + inf->AddDate = QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss"); + model->insertRow(0); + selectedRow = 0; + } + qDebug() << inf->PatientUID << inf->AddDate; + #define ADD_PATIENT_PROPERTY(val)\ + model->setData(model->index(selectedRow,PatientInformationEnum:: val),inf-> val); + EDIT_PATIENT() + #undef ADD_PATIENT_PROPERTY + if (model->submitAll()) + { + table->selectRow(selectedRow); + model->selectRow(selectedRow); + } + else { + //TODO:add some error handle logic + } + if (isAdd) { + LOG_USER_OPERATION(AddPatient) + } + else + { + LOG_USER_OPERATION(ChangePatientInfo) + } + btnSelect->setEnabled(true); + }); + + // btn delete slot + connect(btnDelete, &QToolButton::clicked, [=]() { + if (table->currentIndex().row()<0) return; + AlertDialog dialog(this); + dialog.setWindowModality(Qt::WindowModal); + QString pUid = model->index(table->currentIndex().row(), PatientInformationEnum::PatientUID).data().toString(); + // patient has been selected as the scan patient! + if (selectedPatientUID == pUid){ + dialog.setButtonMode(OkOnly); + dialog.setTitle(tr("Alert")); + dialog.setAlertMessage(QString(tr("Can't delete selected Patient !"))); + dialog.exec(); + return; + } + // not the selected one, confirm! + dialog.setButtonMode(OkAndCancel); + dialog.setTitle("Confirm"); + QString pat_name = model->index(table->currentIndex().row(), PatientInformationEnum::Name).data().toString(); + dialog.setAlertMessage(QString(tr("Delete Patient \"%1\" ?")).arg(pat_name)); + if (dialog.exec() != QDialog::Accepted) return; + // need delete clear edit panel detail + edit_patient->clearPatientInformation(); + model->setData(model->index(table->currentIndex().row(), PatientInformationEnum::Flag), 9); + + if (model->submitAll()) { + model->select(); + if (model->rowCount() > 0) { + table->selectRow(0); + model->selectRow(0); + setPatientDetail(table, model, edit_patient); + LOG_USER_OPERATION(DeletePatient) + } + } else { + //TODO:error handle + dialog.setButtonMode(OkOnly); + dialog.setTitle(tr("Alert")); + dialog.setAlertMessage(QString(tr("Can't delete selected Patient , db submit error!"))); + dialog.exec(); + } + prepareButtons(false); + + }); + + // btn select slot + connect(btnSelect, &QToolButton::clicked, [=]() { + + EventCenter::Default()->triggerEvent(GUIEvents::PatientSelected, nullptr, edit_patient->getPatientInformation()->Copy()); + selectedPatientUID = edit_patient->getPatientInformation()->PatientUID; + LOG_USER_OPERATION(SelectPatient) + }); + + // btn account slot + connect(btnAccount, &QToolButton::clicked, [=]() { + AccountFormDialog dia(this); + dia.setWindowModality(Qt::WindowModal); + dia.exec(); + }); + + // event ResponsePreview slot + connect(EventCenter::Default(), &EventCenter::ResponsePreview, [=](QObject* sender, QObject* data) { + prepareButtons(true); + }); + + // event ResponseStop slot + connect(EventCenter::Default(), &EventCenter::ResponseStop, [=](QObject* sender, QObject* data) { + prepareButtons(false); + }); + + // event ReloadLanguage slot; + connect(EventCenter::Default(), &EventCenter::ReloadLanguage, [=]() { + + model->setHeaderData(1, Qt::Horizontal, "ID"); + model->setHeaderData(2, Qt::Horizontal, tr("Name")); + model->setHeaderData(3, Qt::Horizontal, tr("Birth Date")); + model->setHeaderData(4, Qt::Horizontal, tr("Gender")); + model->setHeaderData(5, Qt::Horizontal, tr("Add Date")); + model->setHeaderData(6, Qt::Horizontal, tr("Comment")); + + btnAccount->setText(tr("Account")); + //btnWorklist->setText(tr("Worklist")); + btnAdd->setText(tr("Add")); + btnEdit->setText(tr("Edit")); + btnDelete->setText(tr("Delete")); + btnSelect->setText(tr("Select")); + }); + + //first prepare buttons! + prepareButtons(false); +} + +void SelectFormWidget::setPatientDetail(const SlideableTableView *table, const QSqlTableModel *model, + EditPatientForm *edit_patient) const { + PatientInformation pat; +#define ADD_PATIENT_PROPERTY(val)\ + pat. val = model->data(model->index(table->currentIndex().row(),PatientInformationEnum:: val),Qt::EditRole).toString(); + EDIT_PATIENT() +#undef ADD_PATIENT_PROPERTY + edit_patient->setPatientInformation(&pat); +} + + +SelectFormWidget::~SelectFormWidget() +{ + +} + + diff --git a/src/SelectFormWidget.h b/src/forms/select/SelectFormWidget.h similarity index 52% rename from src/SelectFormWidget.h rename to src/forms/select/SelectFormWidget.h index 97f97bc..1c0ddd1 100644 --- a/src/SelectFormWidget.h +++ b/src/forms/select/SelectFormWidget.h @@ -5,7 +5,11 @@ #ifndef GUI_SELECTFORMWIDGET_H #define GUI_SELECTFORMWIDGET_H -#include "tabformwidget.h" + +#include "forms/tabformwidget.h" +#include "EditPatientDialog.h" +class EditPatientForm; +class SlideableTableView; class SelectFormWidget: public TabFormWidget { Q_OBJECT public: @@ -13,8 +17,10 @@ public: ~SelectFormWidget(); private: - int currentRow = -1; + QString selectedPatientUID; + void + setPatientDetail(const SlideableTableView *table, const QSqlTableModel *model, EditPatientForm *edit_patient) const; }; diff --git a/src/forms/select/editpatientform.cpp b/src/forms/select/editpatientform.cpp new file mode 100644 index 0000000..31ffaa5 --- /dev/null +++ b/src/forms/select/editpatientform.cpp @@ -0,0 +1,88 @@ +#include "editpatientform.h" +#include "ui_editpatientform.h" +#include +#include +#include +#include +#include "guimacros.h" +#include +#include "event/EventCenter.h" + +EditPatientForm::EditPatientForm(QWidget* parent) : + QWidget(parent), + ui(new Ui::EditPatientForm) +{ +// this->layout()->setContentsMargins(5,5,5,5); + ui->setupUi(this); + + ui->hideBtn->setSizePolicy(QSizePolicy::Policy::Expanding,QSizePolicy::Policy::Preferred); + ui->hideBtn->setObjectName("hideeditBtn"); + ui->hideBtn->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + ui->hideBtn->setIcon(QIcon(":/icons/hidearrow.png")); + ui->hideBtn->setIconSize({30,30}); + ui->hideBtn->setText(tr(" Hide Panel")); + connect(ui->hideBtn,&QToolButton::clicked,[=](){ + emit hideBtnClicked(); + }); + ui->tbx_Dob->setDisplayFormat("yyyy/MM/dd"); + + ui->tbx_ID->setEnabled(false); + ui->tbx_ID->setObjectName("display_tbx"); + ui->tbx_Dob->setEnabled(false); + ui->tbx_Dob->setObjectName("display_tbx"); + ui->tbx_Name->setEnabled(false); + ui->tbx_Name->setObjectName("display_tbx"); + ui->tbx_Sex->setEnabled(false); + ui->tbx_Sex->setObjectName("display_tbx"); + ui->rtbx_Comment->setEnabled(false); + ui->rtbx_Comment->setObjectName("display_tbx"); + + connect(EventCenter::Default(), &EventCenter::ReloadLanguage, [=]() { + + ui->retranslateUi(this); + ui->tbx_Sex->setText(store.Sex == "F"?tr("Female"):(store.Sex=="M"?tr("Male"):tr("Other"))); + }); + + + +} + +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); + ui->rtbx_Comment->setText(information->Comment); + ui->tbx_Sex->setText(information->Sex == "F"?tr("Female"):(information->Sex=="M"?tr("Male"):tr("Other"))); + currentPatientUID = information->PatientUID; + AddDate = information->AddDate; + store.Sex = information->Sex; + storePatientInformation(); + } +} + +void EditPatientForm::clearPatientInformation() { + ui->tbx_ID->setText(""); + ui->tbx_Dob->setDate(QDate::currentDate()); + ui->tbx_Name->setText(""); + ui->tbx_Sex->setText(""); + ui->rtbx_Comment->setText(""); + currentPatientUID = ""; + AddDate = ""; +} + +void EditPatientForm::storePatientInformation() { + store.PatientUID = currentPatientUID; + store.AddDate = AddDate; + store.ID = ui->tbx_ID->text(); + store.BirthDate = ui->tbx_Dob->date().toString("yyyy-MM-dd"); + store.Name = ui->tbx_Name->text(); + store.Comment = ui->rtbx_Comment->toPlainText(); +} + diff --git a/src/editpatientform.h b/src/forms/select/editpatientform.h similarity index 88% rename from src/editpatientform.h rename to src/forms/select/editpatientform.h index 012155a..e5cb4f0 100644 --- a/src/editpatientform.h +++ b/src/forms/select/editpatientform.h @@ -29,6 +29,10 @@ enum PatientInformationEnum{ #undef ADD_PATIENT_PROPERTY }; +/** + * @brief this class was designed to be a edit form, + * but now has been change to a detail display class. + */ class PatientInformation:public QObject{ Q_OBJECT public: @@ -65,9 +69,8 @@ public: } void clearPatientInformation(); void storePatientInformation(); - void restorePatientInformation(); - void setEditEnable(bool enable); - signals: + +signals: void editAccept(PatientInformation * detail,bool & accept); void editCancel(); signals: @@ -77,11 +80,6 @@ private: QString currentPatientUID; QString AddDate; PatientInformation store; - bool editEnable=false; - QToolButton* btnEditAccept; - QToolButton* btnEditCancel; - QToolButton* btnFemale; - QToolButton* btnMale; }; #endif // EDITPATIENTFORM_H diff --git a/src/forms/select/editpatientform.ui b/src/forms/select/editpatientform.ui new file mode 100644 index 0000000..467d2b8 --- /dev/null +++ b/src/forms/select/editpatientform.ui @@ -0,0 +1,140 @@ + + + EditPatientForm + + + + 0 + 0 + 400 + 466 + + + + Form + + + + + + ... + + + + + + + ID + + + + + + + true + + + true + + + + + + + Name + + + + + + + true + + + true + + + + + + + Gender + + + + + + + true + + + true + + + + + + + Date Of Birth + + + + + + + true + + + true + + + QAbstractSpinBox::NoButtons + + + + + + + + 1 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + Comment + + + + + + + true + + + true + + + + + + + + + + + diff --git a/src/AccountTableForm.cpp b/src/forms/settings/AccountTableForm.cpp similarity index 98% rename from src/AccountTableForm.cpp rename to src/forms/settings/AccountTableForm.cpp index 97be5f1..7e66530 100644 --- a/src/AccountTableForm.cpp +++ b/src/forms/settings/AccountTableForm.cpp @@ -9,12 +9,12 @@ #include #include "components/AccountRoleComboDelegate.h" #include "guimacros.h" -#include "AlertDialog.h" +#include "src/dialogs/AlertDialog.h" #include "db/SQLHelper.h" #include "models/User.h" #include #include "components/SlideableTableView.h" -#include "AccountFormDialog.h" +#include "src/dialogs/AccountFormDialog.h" #include "event/EventCenter.h" AccountTableForm::AccountTableForm(QWidget* parent) { layout = new QVBoxLayout(this); diff --git a/src/AccountTableForm.h b/src/forms/settings/AccountTableForm.h similarity index 100% rename from src/AccountTableForm.h rename to src/forms/settings/AccountTableForm.h diff --git a/src/AdminSettingForm.cpp b/src/forms/settings/AdminSettingForm.cpp similarity index 81% rename from src/AdminSettingForm.cpp rename to src/forms/settings/AdminSettingForm.cpp index 65ea243..f11541f 100644 --- a/src/AdminSettingForm.cpp +++ b/src/forms/settings/AdminSettingForm.cpp @@ -7,13 +7,9 @@ #include #include #include -#include "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/AdminSettingForm.h b/src/forms/settings/AdminSettingForm.h similarity index 89% rename from src/AdminSettingForm.h rename to src/forms/settings/AdminSettingForm.h index ccca0b0..c5962d9 100644 --- a/src/AdminSettingForm.h +++ b/src/forms/settings/AdminSettingForm.h @@ -5,7 +5,7 @@ #ifndef GUI_ADMINSETTINGFORM_H #define GUI_ADMINSETTINGFORM_H -#include "tabformwidget.h" +#include "src/forms/tabformwidget.h" class AdminSettingForm:public TabFormWidget { Q_OBJECT diff --git a/src/aboutwidget.cpp b/src/forms/settings/aboutwidget.cpp similarity index 82% rename from src/aboutwidget.cpp rename to src/forms/settings/aboutwidget.cpp index deb7b0b..a899b62 100644 --- a/src/aboutwidget.cpp +++ b/src/forms/settings/aboutwidget.cpp @@ -7,6 +7,8 @@ #include #include "json/cmdhelper.h" #include +#include "AppVersion.h" +#include "device/DeviceManager.h" AboutWidget::AboutWidget(QWidget* parent) : QWidget(parent) @@ -70,12 +72,13 @@ void AboutWidget::initUi() pMainLayout->addSpacing(subContentSpacing); pGuiVer = new QLabel(this); - pGuiVer->setText(tr("GUI Software V1.3")); + pGuiVer->setText(QString(tr("GUI Software V%1")).arg(getGUIVersion())); pGuiVer->setContentsMargins(subContentMargin, 0, 0, 0); pMainLayout->addWidget(pGuiVer); pEmbededSoftVer = new QLabel(this); - pEmbededSoftVer->setText(tr("Embedded Software V1.5")); +// pEmbededSoftVer->setText(tr("Embedded Software %1").arg(getEmbVersion())); + pEmbededSoftVer->setText(tr("Embedded Software %1, Data store Path:%2").arg(getEmbVersion(), getDataStorePath())); pEmbededSoftVer->setContentsMargins(subContentMargin, 0, 0, 0); pMainLayout->addWidget(pEmbededSoftVer); @@ -154,8 +157,9 @@ void AboutWidget::initUi() pProductVer->setText(tr("HJ-USCT-01 V1.0")); pBtnHelp->setText(tr("?")); pCompanyCopyRight->setText(tr("Copyright © 2017-2020 Zhejiang Equilibrium Nine Medical Equipment Co., Ltd. All Rights Reversed")); - pGuiVer->setText(tr("GUI Software V1.3")); - pEmbededSoftVer->setText(tr("Embedded Software V1.5")); + pGuiVer->setText(QString(tr("GUI Software V%1")).arg(getGUIVersion())); +// pEmbededSoftVer->setText(tr("Embedded Software %1").arg(getEmbVersion())); + pEmbededSoftVer->setText(tr("Embedded Software %1, Data store Path:%2").arg(getEmbVersion(), getDataStorePath())); pReconSotfVer->setText(tr("Reconstruction Software V1.2")); pFEBVer->setText(tr("FEB Information")); }); @@ -177,3 +181,19 @@ void AboutWidget::openHelpFile() // box.exec(); //} } + +QString AboutWidget::getGUIVersion() { + + if (GUI_VERSION_BETA){ + return QString("%1.%2.%3 beta").arg(GUI_VERSION_MAJOR).arg(GUI_VERSION_MINOR).arg(GUI_VERSION_BUILD); + } + return QString("%1.%2.%3").arg(GUI_VERSION_MAJOR).arg(GUI_VERSION_MINOR).arg(GUI_VERSION_BUILD); +} + +QString AboutWidget::getEmbVersion() { + return DeviceManager::Default()->getSoftwareVersion(); +} + +QString AboutWidget::getDataStorePath() { + return DeviceManager::Default()->getScanOutputPath();; +} diff --git a/src/aboutwidget.h b/src/forms/settings/aboutwidget.h similarity index 85% rename from src/aboutwidget.h rename to src/forms/settings/aboutwidget.h index 3f90be2..d4172ea 100644 --- a/src/aboutwidget.h +++ b/src/forms/settings/aboutwidget.h @@ -20,7 +20,9 @@ public: explicit AboutWidget(QWidget* parent = nullptr); ~AboutWidget(); - + QString getGUIVersion(); + QString getEmbVersion(); + QString getDataStorePath(); private slots: void openHelpFile(); diff --git a/src/generalform.cpp b/src/forms/settings/generalform.cpp similarity index 89% rename from src/generalform.cpp rename to src/forms/settings/generalform.cpp index 4036242..ae55c4e 100644 --- a/src/generalform.cpp +++ b/src/forms/settings/generalform.cpp @@ -10,10 +10,10 @@ #include #include "event/EventCenter.h" #include "json/jsonobject.h" -#include "SelectDialog.h" +#include "src/dialogs/SelectDialog.h" -#include "locker.h" -#include "languageswitcher.h" +#include "src/utilities/locker.h" +#include "src/utilities/languageswitcher.h" GeneralForm::GeneralForm(QWidget* parent) : QWidget(parent) { @@ -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); @@ -93,7 +93,7 @@ GeneralForm::GeneralForm(QWidget* parent) : QWidget(parent) dialog = new SelectDialog(this); dialog->setWindowModality(Qt::WindowModal); } - dialog->setAvailableDates(JsonObject::Instance()->language()); + dialog->setValues(JsonObject::Instance()->language()); dialog->setSelectedValue(JsonObject::Instance()->defaultLanguage()); if (dialog->exec() == QDialog::Accepted) { diff --git a/src/generalform.h b/src/forms/settings/generalform.h similarity index 100% rename from src/generalform.h rename to src/forms/settings/generalform.h diff --git a/src/systemsettingform.cpp b/src/forms/settings/systemsettingform.cpp similarity index 93% rename from src/systemsettingform.cpp rename to src/forms/settings/systemsettingform.cpp index e722cb4..3d49dde 100644 --- a/src/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 "SelectDialog.h" -#include "components/imageswitch.h" +#include "src/dialogs/SelectDialog.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), @@ -116,7 +110,7 @@ systemSettingForm::systemSettingForm(QWidget* parent) : sd_protocal = new SelectDialog(this); sd_protocal->setWindowModality(Qt::WindowModal); } - sd_protocal->setAvailableDates(JsonObject::Instance()->protocals()); + sd_protocal->setValues(JsonObject::Instance()->protocals()); sd_protocal->setSelectedValue(JsonObject::Instance()->defaultProtocal()); if (sd_protocal->exec() == QDialog::Accepted) { @@ -132,7 +126,7 @@ systemSettingForm::systemSettingForm(QWidget* parent) : sd_filter = new SelectDialog(this); sd_filter->setWindowModality(Qt::WindowModal); } - sd_filter->setAvailableDates(JsonObject::Instance()->worklistFilters()); + sd_filter->setValues(JsonObject::Instance()->worklistFilters()); sd_filter->setSelectedValue(JsonObject::Instance()->defaultFilter()); if (sd_filter->exec() == QDialog::Accepted) { diff --git a/src/systemsettingform.h b/src/forms/settings/systemsettingform.h similarity index 100% rename from src/systemsettingform.h rename to src/forms/settings/systemsettingform.h diff --git a/src/systemsettingform.ui b/src/forms/settings/systemsettingform.ui similarity index 100% rename from src/systemsettingform.ui rename to src/forms/settings/systemsettingform.ui diff --git a/src/tabformwidget.cpp b/src/forms/tabformwidget.cpp similarity index 100% rename from src/tabformwidget.cpp rename to src/forms/tabformwidget.cpp diff --git a/src/tabformwidget.h b/src/forms/tabformwidget.h similarity index 100% rename from src/tabformwidget.h rename to src/forms/tabformwidget.h diff --git a/src/tabformwidget.ui b/src/forms/tabformwidget.ui similarity index 100% rename from src/tabformwidget.ui rename to src/forms/tabformwidget.ui diff --git a/src/icons/arrow-down.png b/src/icons/arrow-down.png new file mode 100644 index 0000000..ce3e433 Binary files /dev/null and b/src/icons/arrow-down.png differ diff --git a/src/icons/arrow-up.png b/src/icons/arrow-up.png new file mode 100644 index 0000000..6d1a186 Binary files /dev/null and b/src/icons/arrow-up.png differ diff --git a/src/main.cpp b/src/main.cpp index aa3699a..8a96556 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,7 +1,7 @@ -#include "mainwindow.h" +#include "src/windows/mainwindow.h" #include -#include "loginwindow.h" -#include "InputObject.h" +#include "src/windows/loginwindow.h" +#include "src/utilities/InputObject.h" #include #include "db/SQLHelper.h" #include @@ -13,8 +13,8 @@ #include #include #include "json/jsonobject.h" -#include "locker.h" -#include "languageswitcher.h" +#include "src/utilities/locker.h" +#include "src/utilities/languageswitcher.h" QString loadFontFromFile(QString path) { static QString font; 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/dicomcfgdialog.ui b/src/network/dicomcfgdialog.ui similarity index 100% rename from src/dicomcfgdialog.ui rename to src/network/dicomcfgdialog.ui diff --git a/src/network/getadminpsw.cpp b/src/network/getadminpsw.cpp index 0b58979..f572fc6 100644 --- a/src/network/getadminpsw.cpp +++ b/src/network/getadminpsw.cpp @@ -6,8 +6,10 @@ #include #include #include "getadminpsw.h" -#include "device/networkmanager.h" -#include "device/networkmanager.h" + +#ifndef WIN32 +#include +#endif GetAdminPsw::GetAdminPsw(QWidget* parent, Qt::WindowFlags f) : GUIFormBaseDialog(parent, f) { diff --git a/src/network/getadminpsw.h b/src/network/getadminpsw.h index 362155f..c710011 100644 --- a/src/network/getadminpsw.h +++ b/src/network/getadminpsw.h @@ -5,7 +5,7 @@ #ifndef GUI_GETADMINPSW_H #define GUI_GETADMINPSW_H -#include "GUIFormBaseDialog.h" +#include "src/dialogs/GUIFormBaseDialog.h" class QLineEdit; class QLabel; class GetAdminPsw :public GUIFormBaseDialog { diff --git a/src/network/getipdialog.h b/src/network/getipdialog.h index 0c1bb9c..f123a7d 100644 --- a/src/network/getipdialog.h +++ b/src/network/getipdialog.h @@ -5,7 +5,7 @@ #ifndef GUI_GETIPDIALOG_H #define GUI_GETIPDIALOG_H -#include "GUIFormBaseDialog.h" +#include "src/dialogs/GUIFormBaseDialog.h" class QLineEdit; class QLabel; class GetIPDialog :public GUIFormBaseDialog { diff --git a/src/network/getroutedialog.h b/src/network/getroutedialog.h index 62eae97..03336c0 100644 --- a/src/network/getroutedialog.h +++ b/src/network/getroutedialog.h @@ -5,7 +5,7 @@ #ifndef GUI_GetRouteDialog_H #define GUI_GETROUTEDIALOG_H -#include "GUIFormBaseDialog.h" +#include "src/dialogs/GUIFormBaseDialog.h" class QLineEdit; class QLabel; class GetRouteDialog :public GUIFormBaseDialog { diff --git a/src/network/networkcfgdialog.cpp b/src/network/networkcfgdialog.cpp index f890d89..bdf7b71 100644 --- a/src/network/networkcfgdialog.cpp +++ b/src/network/networkcfgdialog.cpp @@ -8,7 +8,7 @@ #include #include -#include "guimessagedialog.h" +#include "src/dialogs/guimessagedialog.h" #include networkCfgDialog::networkCfgDialog(QWidget* parent) : diff --git a/src/networkcfgdialog.ui b/src/network/networkcfgdialog.ui similarity index 100% rename from src/networkcfgdialog.ui rename to src/network/networkcfgdialog.ui diff --git a/src/res.qrc b/src/res.qrc index 0f889ca..bba3ab3 100644 --- a/src/res.qrc +++ b/src/res.qrc @@ -48,5 +48,7 @@ icons/edit.png icons/hidearrow.png icons/logout.png + icons/arrow-down.png + icons/arrow-up.png diff --git a/src/stylesheet/Dark2.css b/src/stylesheet/Dark2.css index 6d52ead..1a26add 100644 --- a/src/stylesheet/Dark2.css +++ b/src/stylesheet/Dark2.css @@ -1 +1 @@ - /*------1.silver-->grey--------------------------*/ *{background-color:#3c3c3c; color:#fcfcfc;margin:0;font-size:16px;} QWidget#need_border{border:1px solid white} QTabBar::tab { height:60px; width:300px; font-size: 25px; background:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #505050, stop: 1.0 #333333); border: 2px solid #505050; border-bottom-left-radius: 50%; border-bottom-right-radius: 50%; min-width: 8ex; padding: 2px; } QTabBar::tab:selected, QTabBar::tab:hover { border-top:5px solid #4a88c7; background: #505050;} QTabWidget::pane{margin:0} QPlainTextEdit{border:0px} QGroupBox{border:0px} QLabel{color:#fcfcfc; font-weight:bold; font-size:16px;} QLineEdit{min-height:36px;max-height:36px; border:none;border-bottom:1px solid #505050;color:grey;} QLineEdit:enabled{background-color: #505050;border-bottom-color:#4a88c7;color:#fcfcfc;} QDateEdit{min-height:36px;max-height:36px; border:none;border-bottom:1px solid #505050;color:grey;border-radius:3px;} QDateEdit:enabled{background-color: #505050;border-bottom-color:#4a88c7;color:#fcfcfc;} QTextEdit{ border:1px solid #505050;color:grey;border-radius:3px;} QTextEdit:enabled{background-color: #505050; border:1px solid #4a88c7;color:#fcfcfc;} QComboBox{text-align:center;min-height:36px;max-height:36px; border:1px solid #505050} QComboBox:enabled{background-color: #505050} QComboBox::drop-down{width:20px} QComboBox QAbstractItemView{min-width:120px;} QComboBox QAbstractItemView::item {min-height:60px;max-height:60px; border:1px solid white;} QWidget QToolButton#editvalBtn{font-size:20px;font-weight:normal;border:1px solid darkgray;background: #505050;} QWidget QToolButton#showeditBtn{border-top:1px solid darkgray; border-bottom:1px solid darkgray; border-left:1px solid darkgray; border-radius: 0; border-bottom-left-radius:10px; font-size:20px; font-weight:normal; background: #505050; } QWidget QToolButton#hideeditBtn{border-top:1px solid darkgray; border-bottom:1px solid darkgray; border-left:1px solid darkgray; border-radius: 0; border-top-left-radius:10px; border-bottom-left-radius:10px; font-size:20px; font-weight:normal;background: #505050; } QWidget QToolButton{border:none;border-radius:10%;font-size:26px; /*background: #505050;*/ background: qlineargradient(spread:pad,x1: 0.5, y1: 0, x2: 0.5, y2: 1.0,stop:0 #404040, stop:0.5 #505050,stop:1.0 #404040); font-weight:Bold;padding:5px;} QWidget QToolButton:disabled{border:none;color:#606060;background:#3c3c3c} QWidget QToolButton:hover{background:#505050;} QWidget QToolButton:checked{border:5px solid darkorange;padding:0px;} QPushButton{border:1px solid #505050 ;padding-left:50px;padding-right:50px; border-radius:5px; min-height:28px; max-height:28px; background:qlineargradient(spread:pad, x1:0.50, y1:0, x2:0.5, y2:1, stop:0 #505050, stop:1 #606060);} QListView{border:none;margin:5px; font-weight:bold} QListView::item{ /*background:#4d4d4d;*/ background: qlineargradient(spread:pad,x1: 0.5, y1: 0, x2: 0.5, y2: 1.0,stop:0 #404040, stop:0.5 #505050,stop:1.0 #404040); min-height:30px; border:1px solid #505050; border-radius:5px} QListView::item:selected{background:#365880;font-weight:bold;color:#fcfcfc;} /*QListView::item:selected{ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ABAFE5, stop: 1 #8588B2); border:1px solid #505050; }*/ QHeaderView::section{background-color:#595959;min-height:50px;max-height:50px;font-weight:Bold; font-size:16px; border:1px solid #323232;} QHeaderView::section:horizontal{border-bottom: 1px solid rgb(0,170,255);} QHeaderView::section:vertical{min-height:36px;max-height:36px;} QTableView{border:none;alternate-background-color: #595959;selection-color:#fcfcfc;selection-background-color:#0078d8} /*-----------Specific---------------*/ QLabel#sliderPickerLabel{color:grey;padding:0;background:#505050;font-weight:normal;font-size:50px;} QWidget#topbarWidget{min-height:36px;max-height:36px;} QWidget#contentWidget{border-top:1px solid #505050;} QWidget#contentWidgetWithBBorder{border-top:1px solid #505050; border-bottom:1px solid #323232;} QWidget#commandWidget{min-height:123px;max-height:123px;border-top:1px solid #505050; border-bottom:1px solid #323232;} QWidget#commandWidgetnoBBorder{min-height:123px;max-height:123px;border-top:1px solid #505050; } QLabel#logo{min-width:30px;max-width:30px} QLabel#company{min-width:150px;max-width:150px; } QLabel#systemMsgBar{min-width:500px;} QLabel#warn{color:#CCCC00;background:transparent;font-size:20px;} QWidget QWidget#statusBarWidget{min-width:300px;} QToolButton#btn_main{border:2px solid #0078d8;border-radius:10%;font-size:26px; font-weight:Bold;padding:5px;} QWidget#editcmdWidget{min-height:83px;max-height:83px;} QWidget#verSpaceLine{ border-right:1px solid #0078d8;} QWidget#topBottomLine{ border-top:2px solid #0078d8;border-bottom:2px solid #0078d8;background:transparent;} /*-----Settings*/ QPushButton#BigBtn{ padding-left:0px; padding-right:0px; min-height:60px; max-height:60px; min-width:140px; max-width:140px; font-size: 20px; font-weight:bold; } /*-----蒙版Dialog-----*/ QDialog QWidget#innerWidget{background:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0.0 darkgray, stop: 0.5 lightgray, stop: 1.0 darkgray);border-radius:20px;border:5px solid #0078d8; } QDialog#MessageDialog QWidget QWidget{ background:transparent;color:#3078d8;} QDialog#MessageDialog QWidget QWidget QLabel{ font-size:30px} #spacer_1, #spacer_2{min-width:2px;max-width:2px;margin-top:6px;margin-bottom:6px;border-right:1px solid #0078d8;} /*-----FormDialog-----*/ QPushButton#btnOK{background:#365880; font-weight:bold} QDialog#formDialog{border:3px solid grey; border-radius:8px} QWidget#slider_one{border:1px solid #505050; border-radius:8px} QWidget#formWidget QLabel#endline{border-bottom:1px solid grey} QWidget#formWidget{font-size:30px;} QLabel#title{font-size:30px; border-bottom:1px solid #3078d8 } QWidget#edit_patient{min-width:300px;max-width:300px;} QToolButton#sexBtn{min-width:120px;max-width:120px;font-size:20px;padding:2px;} QToolButton#sexBtn:disabled{color:grey} QWidget#sexpanelwidget{border:1px solid #505050;} QWidget#sexpanelwidget:enabled{background-color: #505050;} QToolButton#sexBtn:checked{border:2px solid darkorange;padding:0px;} /*---------Abount----------*/ QLabel#normal{color:#fcfcfc; font-weight:normal; font-size:16px;} QDialog#loginform{background-color:#3c3c3c; color:white;margin:0;font-size:16px;} QDialog#loginform QLabel#title{font-Size:98px;color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0.0 darkgray, stop: 0.5 lightgray, stop: 1.0 darkgray);} QLabel#warn{color:#930000;background:transparent;font-size:20px;} QFrame#login_frame_username{min-width:700px;max-width:700px;max-height:500px;min-height:500px; border:1px solid #0078d8;border-radius:20px; background:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0.0 darkgray, stop: 0.5 gray, stop: 1.0 darkgray);} QDialog#loginform QLineEdit{min-height:100px;max-height:100px; border:1px solid silver;border-radius:10px;font-size:26px;} QDialog#loginform QLineEdit:enabled{background-color: #515151} QDialog#loginform QToolButton#btnlogin{min-height:100px;max-height:100px; min-width:border:1px solid #505050; border-radius:10%;font-size:26px; font-weight:Bold;padding:5px;} QDialog#loginform QToolButton#btnlogin:hover{background:#505050;} \ No newline at end of file + /*------1.silver-->grey--------------------------*/ *{background-color:#3c3c3c; color:#fcfcfc;margin:0;font-size:16px;} QWidget#need_border{border:1px solid white} QTabBar::tab { height:60px; width:300px; font-size: 25px; background:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #505050, stop: 1.0 #333333); border: 2px solid #505050; border-bottom-left-radius: 50%; border-bottom-right-radius: 50%; min-width: 8ex; padding: 2px; } QTabBar::tab:selected, QTabBar::tab:hover { border-top:5px solid #4a88c7; background: #505050;} QTabWidget::pane{margin:0} QPlainTextEdit{border:0px} QGroupBox{border:0px} QLabel{color:#fcfcfc; font-weight:bold; font-size:16px;} QLineEdit{min-height:36px;max-height:36px; border:none;border-bottom:1px solid #505050;color:grey;} QLineEdit:enabled{background-color: #505050;border-bottom-color:#4a88c7;color:#fcfcfc;} QLineEdit#display_tbx:disabled{background-color: #3c3c3c;border-bottom-color:#4a88c7;color:#fcfcfc;} QDateEdit{min-height:36px;max-height:36px; border:none;border-bottom:1px solid #505050;color:grey;border-radius:3px;} QDateEdit:disabled{background-color: #3c3c3c;border-bottom-color:#4a88c7;color:#fcfcfc;} QTextEdit{ border:1px solid #505050;color:grey;border-radius:3px;} QTextEdit:enabled{background-color: #505050; border:1px solid #4a88c7;color:#fcfcfc;} QTextEdit#display_tbx:disabled{background-color: #3c3c3c; border:1px solid #4a88c7;color:#fcfcfc;} QComboBox{text-align:center;min-height:36px;max-height:36px; border:1px solid #505050} QComboBox:enabled{background-color: #505050} QComboBox::drop-down{width:20px} QComboBox QAbstractItemView{min-width:120px;} QComboBox QAbstractItemView::item {min-height:60px;max-height:60px; border:1px solid white;} /*QWidget QToolButton#editvalBtn{font-size:20px;font-weight:normal;border:1px solid darkgray;background: #505050;}*/ QWidget QToolButton#editvalBtn{min-height:36px;max-height:36px;border:none;border-bottom:1px solid #505050;border-radius:0px;color:grey;} QWidget QToolButton#editvalBtn:enabled{background-color: #505050;border-bottom-color:#4a88c7;color:#fcfcfc;} QWidget QToolButton#showeditBtn{border-top:1px solid darkgray; border-bottom:1px solid darkgray; border-left:1px solid darkgray; border-radius: 0; border-bottom-left-radius:10px; font-size:20px; font-weight:normal; background: #505050; } QWidget QToolButton#hideeditBtn{border-top:1px solid darkgray; border-bottom:1px solid darkgray; border-left:1px solid darkgray; border-radius: 0; border-top-left-radius:10px; border-bottom-left-radius:10px; font-size:20px; font-weight:normal;background: #505050; } QWidget QToolButton{border:none;border-radius:10%;font-size:26px; /*background: #505050;*/ background: qlineargradient(spread:pad,x1: 0.5, y1: 0, x2: 0.5, y2: 1.0,stop:0 #404040, stop:0.5 #505050,stop:1.0 #404040); font-weight:Bold;padding:5px;} QWidget QToolButton:disabled{border:none;color:#606060;background:#3c3c3c} QWidget QToolButton:hover{background:#505050;} QWidget QToolButton:checked{border:5px solid darkorange;padding:0px;} QPushButton{border:1px solid #505050 ;padding-left:50px;padding-right:50px; border-radius:5px; min-height:28px; max-height:28px; background:qlineargradient(spread:pad, x1:0.50, y1:0, x2:0.5, y2:1, stop:0 #505050, stop:1 #606060);} QListView{border:none;margin:5px; font-weight:bold} QListView::item{ /*background:#4d4d4d;*/ background: qlineargradient(spread:pad,x1: 0.5, y1: 0, x2: 0.5, y2: 1.0,stop:0 #404040, stop:0.5 #505050,stop:1.0 #404040); min-height:30px; border:1px solid #505050; border-radius:5px} QListView::item:selected{background:#365880;font-weight:bold;color:#fcfcfc;} /*QListView::item:selected{ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ABAFE5, stop: 1 #8588B2); border:1px solid #505050; }*/ QHeaderView::down-arrow { subcontrol-position: center right; image: url(":/icons/arrow-down.png"); padding-right: 8px; } QHeaderView::up-arrow { subcontrol-position: center right; image: url(":/icons/arrow-up.png"); padding-right: 8px; } QHeaderView::section{background-color:#595959;min-height:50px;max-height:50px;font-weight:Bold; font-size:16px; border:1px solid #323232;} QHeaderView::section:horizontal{border-bottom: 1px solid rgb(0,170,255);} QHeaderView::section:vertical{min-height:36px;max-height:36px;} QTableView{border:none;alternate-background-color: #595959;selection-color:#fcfcfc;selection-background-color:#0078d8} /*-----------Specific---------------*/ QLabel#sliderPickerLabel{color:grey;padding:0;background:#505050;font-weight:normal;font-size:50px;} QLabel#sliderSpliterLabel{color:white;padding-top:35px;font-weight:normal;font-size:50px;} QWidget#topbarWidget{min-height:36px;max-height:36px;} QWidget#contentWidget{border-top:1px solid #505050;} QWidget#contentWidgetWithBBorder{border-top:1px solid #505050; border-bottom:1px solid #323232;} QWidget#commandWidget{min-height:123px;max-height:123px;border-top:1px solid #505050; border-bottom:1px solid #323232;} QWidget#commandWidgetnoBBorder{min-height:123px;max-height:123px;border-top:1px solid #505050; } QLabel#logo{min-width:30px;max-width:30px} QLabel#company{min-width:150px;max-width:150px; } QLabel#systemMsgBar{min-width:500px;} QLabel#warn{color:#CCCC00;background:transparent;font-size:20px;} QWidget QWidget#statusBarWidget{min-width:300px;} QToolButton#btn_main{border:2px solid #0078d8;border-radius:10%;font-size:26px; font-weight:Bold;padding:5px;} QWidget#editcmdWidget{min-height:83px;max-height:83px;} QWidget#verSpaceLine{ border-right:1px solid #0078d8;} QWidget#topBottomLine{ border-top:2px solid #0078d8;border-bottom:2px solid #0078d8;background:transparent;} /*-----Settings*/ QPushButton#BigBtn{ padding-left:0px; padding-right:0px; min-height:60px; max-height:60px; min-width:140px; max-width:140px; font-size: 20px; font-weight:bold; } /*-----蒙版Dialog-----*/ QDialog QWidget#innerWidget{background:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0.0 darkgray, stop: 0.5 lightgray, stop: 1.0 darkgray);border-radius:20px;border:5px solid #0078d8; } QDialog#MessageDialog QWidget QWidget{ background:transparent;color:#3078d8;} QDialog#MessageDialog QWidget QWidget QLabel{ font-size:30px} #spacer_1, #spacer_2{min-width:2px;max-width:2px;margin-top:6px;margin-bottom:6px;border-right:1px solid #0078d8;} /*-----FormDialog-----*/ QPushButton#btnOK{background:#365880; font-weight:bold} QDialog#formDialog{border:3px solid grey; border-radius:8px} QWidget#slider_one{border:1px solid #505050; border-radius:8px} QWidget#formWidget QLabel#endline{border-bottom:1px solid grey} QWidget#formWidget{font-size:30px;} QLabel#title{font-size:30px; border-bottom:1px solid #3078d8 } QWidget#edit_patient{min-width:300px;max-width:300px;} QToolButton#sexBtn{min-width:120px;max-width:120px;font-size:20px;padding:2px;} /*QToolButton#sexBtn:disabled{color:grey}*/ QWidget#sexpanelwidget{border:1px solid #505050;} QWidget#sexpanelwidget:enabled{background-color: #505050;} QToolButton#sexBtn:checked{border:2px solid darkorange;padding:0px;} /*---------Abount----------*/ QLabel#normal{color:#fcfcfc; font-weight:normal; font-size:16px;} QDialog#loginform{background-color:#3c3c3c; color:white;margin:0;font-size:16px;} QDialog#loginform QLabel#title{font-Size:98px;color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0.0 darkgray, stop: 0.5 lightgray, stop: 1.0 darkgray);} QLabel#warn{color:#930000;background:transparent;font-size:20px;} QFrame#login_frame_username{min-width:700px;max-width:700px;max-height:500px;min-height:500px; border:1px solid #0078d8;border-radius:20px; background:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0.0 darkgray, stop: 0.5 gray, stop: 1.0 darkgray);} QDialog#loginform QLineEdit{min-height:100px;max-height:100px; border:1px solid silver;border-radius:10px;font-size:26px;} QDialog#loginform QLineEdit:enabled{background-color: #515151} QDialog#loginform QToolButton#btnlogin{min-height:100px;max-height:100px; min-width:200px;border:1px solid #505050; border-radius:10%;font-size:26px; font-weight:Bold;padding:5px;} QDialog#loginform QToolButton#btnlogin:hover{background:#505050;} \ No newline at end of file diff --git a/src/InputObject.cpp b/src/utilities/InputObject.cpp similarity index 96% rename from src/InputObject.cpp rename to src/utilities/InputObject.cpp index ee7480e..a4bfdcd 100644 --- a/src/InputObject.cpp +++ b/src/utilities/InputObject.cpp @@ -1,13 +1,12 @@ #include "InputObject.h" #include "ui_inputobject.h" -//#include "qdesktopwidget.h" #include #include #include #include #include #include - +#include #include #include @@ -91,6 +90,14 @@ bool InputObject::eventFilter(QObject* obj, QEvent* event) //qDebug() << "touchScreen()"; } + if (event->type() == QEvent::KeyPress) { + QKeyEvent* keyEvent = static_cast(event); + if (keyEvent->key() == Qt::Key_Return && curDateEdit) + { + this->HidePanel(); + this->hide(); + } + } //mouse button release means setfocus is useless if (event->type() == QEvent::MouseButtonRelease) { diff --git a/src/InputObject.h b/src/utilities/InputObject.h similarity index 100% rename from src/InputObject.h rename to src/utilities/InputObject.h diff --git a/src/StdOutRedirector.cpp b/src/utilities/StdOutRedirector.cpp similarity index 100% rename from src/StdOutRedirector.cpp rename to src/utilities/StdOutRedirector.cpp diff --git a/src/StdOutRedirector.h b/src/utilities/StdOutRedirector.h similarity index 100% rename from src/StdOutRedirector.h rename to src/utilities/StdOutRedirector.h diff --git a/src/inputobject.ui b/src/utilities/inputobject.ui similarity index 100% rename from src/inputobject.ui rename to src/utilities/inputobject.ui diff --git a/src/languageswitcher.cpp b/src/utilities/languageswitcher.cpp similarity index 78% rename from src/languageswitcher.cpp rename to src/utilities/languageswitcher.cpp index f2fc8ee..0e8a75e 100644 --- a/src/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); + } diff --git a/src/languageswitcher.h b/src/utilities/languageswitcher.h similarity index 100% rename from src/languageswitcher.h rename to src/utilities/languageswitcher.h diff --git a/src/locker.cpp b/src/utilities/locker.cpp similarity index 100% rename from src/locker.cpp rename to src/utilities/locker.cpp diff --git a/src/locker.h b/src/utilities/locker.h similarity index 100% rename from src/locker.h rename to src/utilities/locker.h diff --git a/src/loginwindow.cpp b/src/windows/loginwindow.cpp similarity index 98% rename from src/loginwindow.cpp rename to src/windows/loginwindow.cpp index 59f62c6..4126b86 100644 --- a/src/loginwindow.cpp +++ b/src/windows/loginwindow.cpp @@ -10,11 +10,11 @@ #include #include #include "db/SQLHelper.h" -#include "InputObject.h" +#include "src/utilities/InputObject.h" #include "models/User.h" #include "log/UserOperationLog.h" #include "json/jsonobject.h" -#include "guimessagedialog.h" +#include "src/dialogs/guimessagedialog.h" LoginWindow::LoginWindow(QWidget* parent) : QDialog(parent) diff --git a/src/loginwindow.h b/src/windows/loginwindow.h similarity index 100% rename from src/loginwindow.h rename to src/windows/loginwindow.h diff --git a/src/mainwindow.cpp b/src/windows/mainwindow.cpp similarity index 97% rename from src/mainwindow.cpp rename to src/windows/mainwindow.cpp index d34ea69..9c76a28 100644 --- a/src/mainwindow.cpp +++ b/src/windows/mainwindow.cpp @@ -4,22 +4,22 @@ #include #include #include "event/EventCenter.h" -#include "tabformwidget.h" -#include "SelectFormWidget.h" -#include "ScanFormWidget.h" -#include "guimessagedialog.h" +#include "src/forms/tabformwidget.h" +#include "src/forms/select/SelectFormWidget.h" +#include "src/forms/scan/ScanFormWidget.h" +#include "src/dialogs/guimessagedialog.h" #include "device/DeviceManager.h" #include "errorhandle/GUIErrorHandle.h" #include "loginwindow.h" #include #include #include "models/User.h" -#include "AdminSettingForm.h" +#include "src/forms/settings/AdminSettingForm.h" #include "appvals/AppGlobalValues.h" #include #include #include -#include "TopBarWidget.h" +#include "src/forms/TopBarWidget.h" #include #include diff --git a/src/mainwindow.h b/src/windows/mainwindow.h similarity index 96% rename from src/mainwindow.h rename to src/windows/mainwindow.h index 510f63a..beba157 100644 --- a/src/mainwindow.h +++ b/src/windows/mainwindow.h @@ -4,7 +4,7 @@ #include #include #include -#include "StdOutRedirector.h" +#include "src/utilities/StdOutRedirector.h" #include "json/cJSON.h" #include "loginwindow.h" diff --git a/src/mainwindow.ui b/src/windows/mainwindow.ui similarity index 100% rename from src/mainwindow.ui rename to src/windows/mainwindow.ui