13 Commits

Author SHA1 Message Date
Krad
7edfe1d8f5 Add Version build function to CMakeLists.txt 2022-03-08 10:43:35 +08:00
Krad
95804d618f Fix Account Dialog stuck, when change pwd dialog show and click the Account Dialog. 2022-03-08 10:12:12 +08:00
Krad
a8d4614da1 Fix unselect bug of Patient grid after delete. 2022-03-08 10:10:52 +08:00
Krad
619db892dd Add confirm to delete Patient. 2022-03-08 10:09:02 +08:00
Krad
75584d9b44 New method to set USE_SHIMLIB(use cmake parameter -DUSE_SHIMLIB=ON) 2022-03-08 10:05:52 +08:00
Krad
ae175f2ef3 Add setTitle to AlertDialog 2022-03-08 10:04:48 +08:00
krad
7c8e4ffea8 double check state for stop 2022-03-07 16:15:51 +08:00
Krad
50738a31b8 Style fix 2022-02-14 11:06:28 +08:00
Krad
6f2fb25556 Merge branch 'master' of http://localhost:3000/kradchen/GUI 2022-02-14 09:57:21 +08:00
xueyan hu
aaa730d3cd bug fixes 2022-01-25 17:07:34 +08:00
xueyan hu
bcc6ce1a13 Merge branch 'master' of http://192.168.1.178:3000/kradchen/GUI 2022-01-25 17:04:14 +08:00
xueyan hu
0bb2ec20bc complete two finger swipe 2022-01-25 17:02:56 +08:00
Krad
0282e6d13d Fix a GUIErrorFactory out of bound bug. 2022-01-25 09:23:11 +08:00
103 changed files with 793 additions and 1772 deletions

View File

@@ -7,5 +7,4 @@
#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

View File

@@ -8,9 +8,8 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
# GUI Version
set(GUI_VERSION_MAJOR 0)
set(GUI_VERSION_MINOR 6)
set(GUI_VERSION_BUILD 11)
set(GUI_VERSION_BETA 1)
# use AppVersion.h as a configure file
set(GUI_VERSION_BUILD 8)
configure_file(
"AppVersion.h.in"
"AppVersion.h"
@@ -40,7 +39,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_RECURSE project_uis ./src/*.ui)
file(GLOB project_uis ./src/*.ui)
qt5_wrap_ui(ui_FILES ${project_uis})
file(GLOB project_res ./src/*.qrc)

View File

@@ -1,5 +0,0 @@
v0.6.10
重写了整个Patient的修改和新增逻辑使用模态对话框替代的原来界面内的显示。
去除了原来界面内编辑区域,只做显示使用。
此外,使用滑动块替换了性别选择,日期选择的功能。

View File

@@ -1,8 +0,0 @@
v0.6.11
1. 修复CMake导致的UI构建错误
2. ShimLib加入了DEV_OUTPATH(当前Scan的数据存储目录)功能
3. 给日期滑块加入了日期限制。
4. 修复了TableView列头点击导致的选中行丢失问题。
5. Windows下新增了异步仿真逻辑。
6. 实现了Scan json的生成。
7. 实现了新的分段Scan逻辑。

View File

@@ -1,3 +0,0 @@
第一个release版本。
基本流程已完备,提交系统测试。
2022年3月8日

View File

@@ -1,8 +0,0 @@
v0.6.9
通过新的当前行判定逻辑修复了Select Tab页中Patient 表格排序、选择导致的一系列问题。
包括:
1. Edit Panel 没有跟随选中更新。
2. Patient 全部删除之后存在当前选中错误。
3. 编辑、删除等按钮可用状态不对的错误。
4. 修复了日期输入框在虚拟键盘下,回车无法退出输入模式的错误。
2022年3月15日

View File

@@ -9,12 +9,12 @@
#include <QHeaderView>
#include "components/AccountRoleComboDelegate.h"
#include "guimacros.h"
#include "src/dialogs/AlertDialog.h"
#include "AlertDialog.h"
#include "db/SQLHelper.h"
#include "models/User.h"
#include <QSqlRecord>
#include "components/SlideableTableView.h"
#include "src/dialogs/AccountFormDialog.h"
#include "AccountFormDialog.h"
#include "event/EventCenter.h"
AccountTableForm::AccountTableForm(QWidget* parent) {
layout = new QVBoxLayout(this);

View File

@@ -7,9 +7,13 @@
#include <QStackedWidget>
#include <QStringListModel>
#include <QListWidget>
#include "tabformwidget.h"
#include <QListWidgetItem>
#include "ui_tabformwidget.h"
#include <QLabel>
#include "UserOperationLogForm.h"
#include "generalform.h"
#include <QPushButton>
#include "systemsettingform.h"
#include "AccountTableForm.h"
#include "event/EventCenter.h"
@@ -53,6 +57,20 @@ 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);

View File

@@ -5,7 +5,7 @@
#ifndef GUI_ADMINSETTINGFORM_H
#define GUI_ADMINSETTINGFORM_H
#include "src/forms/tabformwidget.h"
#include "tabformwidget.h"
class AdminSettingForm:public TabFormWidget {
Q_OBJECT

View File

@@ -1,51 +0,0 @@
//
// Created by Krad on 2022/3/24.
//
#include "DateSelectDialog.h"
#include <QVBoxLayout>
#include <QLabel>
#include <QDate>
#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");
lbl_error = new QLabel(this);
lbl_error->setObjectName("warn");
lbl_error->setVisible(false);
lbl_error->setText(tr("Date exceeded!"));
layout->addWidget(box);
layout->addWidget(lbl_error);
}
DateSelectDialog::~DateSelectDialog() {
}
QString DateSelectDialog::getSelectedValue() {
return box->getSelectedValue();
}
void DateSelectDialog::setSelectedValue(const QString &val) {
box->setSelectedValue(val);
box->resizeLabel();
}
bool DateSelectDialog::updateReferenceData() {
if (onlyBackward){
QDate v = QDate::fromString(box->getSelectedValue(),"yyyy-MM-dd");
bool flag = QDate::currentDate()>=v;
this->setFixedHeight(flag? 380:410);
lbl_error->setVisible(!flag);
return flag;
}
return true;
}
void DateSelectDialog::showEvent(QShowEvent * event) {
QDialog::showEvent(event);
}

View File

@@ -1,30 +0,0 @@
//
// Created by Krad on 2022/3/24.
//
#ifndef GUI_DATESELECTDIALOG_H
#define GUI_DATESELECTDIALOG_H
#include "dialogs/GUIFormBaseDialog.h"
class DateSlidePickerBox;
class QLabel;
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;
void setOnlyBackward(bool val){
onlyBackward = val;
}
protected:
bool updateReferenceData() override;
DateSlidePickerBox* box;
QLabel* lbl_error = nullptr;
bool onlyBackward = true;
};
#endif //GUI_DATESELECTDIALOG_H

View File

@@ -1,212 +0,0 @@
//
// Created by Krad on 2022/3/21.
//
#include <QVBoxLayout>
#include <QLabel>
#include <QDateTime>
#include <QLineEdit>
#include <QTextEdit>
#include <QToolButton>
#include <QSqlTableModel>
#include <QUuid>
#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<<tr("Female")<<tr("Male")<<tr("Other");
dialog.setValues(items);
dialog.setSelectedValue(items[btnSex->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;
}
}

View File

@@ -1,53 +0,0 @@
//
// 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

View File

@@ -1,12 +1,13 @@
#include "InputObject.h"
#include "ui_inputobject.h"
//#include "qdesktopwidget.h"
#include <QDebug>
#include <QEvent>
#include <QKeyEvent>
#include <QComboBox>
#include <QDateEdit>
#include <QtVirtualKeyboard>
#include <QKeyEvent>
#include <QLineEdit>
#include <QAbstractSpinBox>
@@ -90,14 +91,6 @@ bool InputObject::eventFilter(QObject* obj, QEvent* event)
//qDebug() << "touchScreen()";
}
if (event->type() == QEvent::KeyPress) {
QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
if (keyEvent->key() == Qt::Key_Return && curDateEdit)
{
this->HidePanel();
this->hide();
}
}
//mouse button release means setfocus is useless
if (event->type() == QEvent::MouseButtonRelease)
{

View File

@@ -8,7 +8,7 @@
#include <QToolButton>
#include "ui_tabformwidget.h"
#include "guimacros.h"
#include "src/forms/scan/patientinformationform.h"
#include "patientinformationform.h"
#include <QButtonGroup>
#include "event/EventCenter.h"
#include <QImage>
@@ -16,7 +16,6 @@
#include <qdebug.h>
#include "log/UserOperationLog.h"
#include <QLabel>
#include "json/jsonobject.h"
#ifdef WIN32
#else
@@ -219,7 +218,7 @@ ScanFormWidget::ScanFormWidget(QWidget* parent) : TabFormWidget(parent) {
patient_information->setPatientInformation((PatientInformation*)data);
});
connect(btnRefresh, &QToolButton::clicked, [=]() {
QString patientInf(patient_information->getCurrentPatientJsonString(true));
QString patientInf(patient_information->getCurrentPatientJsonString(false));
LOG_USER_OPERATION(StartRefresh);
EventCenter::Default()->triggerEvent(GUIEvents::RequestEmptyScan, nullptr, (QObject*)(&patientInf));
});
@@ -230,11 +229,6 @@ ScanFormWidget::ScanFormWidget(QWidget* parent) : TabFormWidget(parent) {
connect(btnScan, &QToolButton::clicked, [=]() {
QString patientInf(patient_information->getCurrentPatientJsonString(false));
LOG_USER_OPERATION(StartScan);
if (!JsonObject::Instance()->getEmptyScanID()){
QString msg(tr("No refresh data exists, please do Refresh operation first."));
EventCenter::Default()->triggerEvent(GUIEvents::DeviceErrorRaise, nullptr, (QObject*)(&msg));
return;
}
EventCenter::Default()->triggerEvent(GUIEvents::RequestPatientScan, nullptr, (QObject*)(&patientInf));
});
connect(btnStop, &QToolButton::clicked, [=]() {

View File

@@ -5,7 +5,7 @@
#ifndef GUI_SCANFORMWIDGET_H
#define GUI_SCANFORMWIDGET_H
#include "src/forms/tabformwidget.h"
#include "tabformwidget.h"
#include <functional>
class PatientInformationForm;
class ScanFormWidget :public TabFormWidget {

View File

@@ -24,7 +24,7 @@ bool SelectDialog::updateReferenceData() {
return true;
}
void SelectDialog::setValues(const QStringList& dates) {
void SelectDialog::setAvailableDates(QStringList dates) {
box->setItems(dates);
}

View File

@@ -12,7 +12,7 @@ class SelectDialog :public GUIFormBaseDialog{
public:
explicit SelectDialog(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
~SelectDialog() override;
void setValues(const QStringList& values);
void setAvailableDates(QStringList dates);
QString getSelectedValue();
void setSelectedValue(const QString& val);
protected:

View File

@@ -11,18 +11,32 @@
#include <QUuid>
#include <QDate>
#include "db/SQLHelper.h"
#include "editpatientform.h"
#include "guimacros.h"
#include "event/EventCenter.h"
#include "src/dialogs/AccountFormDialog.h"
#include "AccountFormDialog.h"
#include <QDebug>
#include "log/UserOperationLog.h"
#include <QSortFilterProxyModel>
#include "src/components/VerticalTextToolButton.h"
#include "dialogs/AlertDialog.h"
#include "AlertDialog.h"
#include <QScroller>
#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)
{
@@ -53,7 +67,7 @@ SelectFormWidget::SelectFormWidget(QWidget* parent) :
contentLayout->setContentsMargins(5, 5, 0, 5);
this->ui->contentWidget->setLayout(contentLayout);
// TableView for patient
SlideableTableView* table = new SlideableTableView(this);
QTableView* table = new SlideableTableView(this);
table->setAlternatingRowColors(true);
table->setSelectionMode(QAbstractItemView::SingleSelection);
table->setEditTriggers(QAbstractItemView::NoEditTriggers);
@@ -75,6 +89,10 @@ SelectFormWidget::SelectFormWidget(QWidget* parent) :
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);
@@ -82,37 +100,39 @@ SelectFormWidget::SelectFormWidget(QWidget* parent) :
table->hideColumn(7);
table->show();
// table->setSortingEnabled(true);
table->setColumnWidth(1, 250);
table->setColumnWidth(2, 250);
table->setColumnWidth(3, 160);
table->setColumnWidth(4, 120);
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);
// prepare edit panel
EditPatientForm* edit_patient = new EditPatientForm(this);
//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);
// 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();
@@ -122,75 +142,61 @@ SelectFormWidget::SelectFormWidget(QWidget* parent) :
if (model->rowCount() > 0)
{
table->selectRow(0);
setPatientDetail(table, model, edit_patient);
}
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----------------------------------------------------------------------
//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);
if(model->rowCount()>0){
table->selectRow(0);
model->selectRow(0);
}
});
// 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);
}
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);
}
});
// btn add slot
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, [=]() {
if (table->currentIndex().row()<0) return;
btnSelect->setEnabled(true);
});
// EditPatientForm editAccept slot
});
connect(edit_patient, &EditPatientForm::editAccept, [=](PatientInformation* inf, bool& result) {
int selectedRow = table->currentIndex().row();
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");
@@ -198,10 +204,10 @@ SelectFormWidget::SelectFormWidget(QWidget* parent) :
selectedRow = 0;
}
qDebug() << inf->PatientUID << inf->AddDate;
#define ADD_PATIENT_PROPERTY(val)\
#define ADD_PATIENT_PROPERTY(val)\
model->setData(model->index(selectedRow,PatientInformationEnum:: val),inf-> val);
EDIT_PATIENT()
#undef ADD_PATIENT_PROPERTY
#undef ADD_PATIENT_PROPERTY
if (model->submitAll())
{
table->selectRow(selectedRow);
@@ -211,84 +217,78 @@ SelectFormWidget::SelectFormWidget(QWidget* parent) :
//TODO:add some error handle logic
}
if (isAdd) {
LOG_USER_OPERATION(AddPatient)
LOG_USER_OPERATION(AddPatient);
}
else
{
LOG_USER_OPERATION(ChangePatientInfo)
LOG_USER_OPERATION(ChangePatientInfo);
}
btnSelect->setEnabled(true);
});
// btn delete slot
connect(btnDelete, &QToolButton::clicked, [=]() {
if (table->currentIndex().row()<0) return;
if (currentRow < 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.setWindowModality(Qt::WindowModal);
QString pat_name = model->index(currentRow, 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 (dialog.exec()!=QDialog::Accepted) 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);
currentRow = 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
}
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(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();
});
// event ResponsePreview slot
connect(EventCenter::Default(), &EventCenter::ResponsePreview, [=](QObject* sender, QObject* data) {
prepareButtons(true);
btnSelect->setEnabled(false);
btnDelete->setEnabled(false);
btnEdit->setEnabled(false);
btnAdd->setEnabled(false);
});
// event ResponseStop slot
connect(EventCenter::Default(), &EventCenter::ResponseStop, [=](QObject* sender, QObject* data) {
prepareButtons(false);
});
// event ReloadLanguage slot;
btnSelect->setEnabled(true);
btnDelete->setEnabled(true);
btnEdit->setEnabled(true);
btnAdd->setEnabled(true);
});
connect(EventCenter::Default(), &EventCenter::ReloadLanguage, [=]() {
model->setHeaderData(1, Qt::Horizontal, "ID");
@@ -306,18 +306,6 @@ SelectFormWidget::SelectFormWidget(QWidget* parent) :
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);
}
@@ -325,5 +313,3 @@ SelectFormWidget::~SelectFormWidget()
{
}

View File

@@ -5,11 +5,7 @@
#ifndef GUI_SELECTFORMWIDGET_H
#define GUI_SELECTFORMWIDGET_H
#include "forms/tabformwidget.h"
#include "EditPatientDialog.h"
class EditPatientForm;
class SlideableTableView;
#include "tabformwidget.h"
class SelectFormWidget: public TabFormWidget {
Q_OBJECT
public:
@@ -17,10 +13,8 @@ public:
~SelectFormWidget();
private:
QString selectedPatientUID;
int currentRow = -1;
void
setPatientDetail(const SlideableTableView *table, const QSqlTableModel *model, EditPatientForm *edit_patient) const;
};

View File

@@ -1,107 +1,80 @@
#include <stdio.h>
#include <stdlib.h>
#include "ShimLib.h"
#include <Windows.h>
#include <process.h>
#include <time.h>
typedef void(*error_cb)(const char* msg);
int statusCountFlag = 0;
error_cb innerCallback = NULL;
void ThreadFunc(void*);
HANDLE th;
HANDLE e1,e2;
int InitLib(error_cb cb) {
innerCallback = cb;
innerCallback("11111");
e1 = CreateEvent(NULL, FALSE, FALSE, "e1");
e2 = CreateEvent(NULL, FALSE, FALSE, "e2");
th = _beginthread(ThreadFunc,0, NULL);
return 0;
}
volatile int running = 1;
volatile int progress = 0;
volatile int status = READY;
volatile int stop_flag = 0;
char output_path[256] = {0};
void ThreadFunc(void* args){
while (running){
WaitForSingleObject(e1, INFINITE);
status = SCANNING;
stop_flag = 0;
progress = 0;
for (int i = 0; i <= 50; ++i) {
if (stop_flag > 0){
stop_flag = 0;
break;
}
if (i == 20){
progress = 139;
WaitForSingleObject(e2, INFINITE);
}
else if ( i > 20 && i<35){
progress = i * 2 + 100;
}
else if(i >= 35){
progress = i * 2 + 200;
}
else{
progress = i *2;
}
Sleep(300);
}
status = READY;
}
}
int ScanControl(ScanAction actionType) {
switch (actionType) {
case SCAN:
printf("Do Scan!\r\n");
statusCountFlag = 2;
SYSTEMTIME st = {0};
GetLocalTime(&st);
sprintf(output_path, "%d%02d%02dT%02d%02d%02d",
st.wYear,
st.wMonth,
st.wDay,
st.wHour,
st.wMinute,
st.wSecond);
SetEvent(e1);
break;
case PREVIEW_SCAN:
statusCountFlag = 1;
status = SCANNING;
printf("Do preview!\r\n");
break;
case STOP:
statusCountFlag = 0;
stop_flag = 1;
progress = 0;
status = READY;
printf("Stop everything!\r\n");
break;
case SCAN_CONTINUE:
SetEvent(e2);
break;
}
case SCAN:
printf("Do Scan!\r\n");
statusCountFlag = 2;
break;
case PREVIEW_SCAN:
statusCountFlag = 1;
printf("Do preview!\r\n");
break;
case STOP:
statusCountFlag = 0;
printf("Stop everything!\r\n");
break;
}
return 0;
}
StatusInfo GetStatus() {
StatusInfo inf;
inf.status = status;
inf.progress = progress;
switch (statusCountFlag)
{
case 0:
inf.status = READY;
break;
case 1:
inf.status = SCANNING;
inf.progress = 0.0f;
break;
case 2:
inf.status = SCANNING;
inf.progress = 0.3f;
statusCountFlag++;
break;
case 3:
inf.status = SCANNING;
inf.progress = 0.6f;
statusCountFlag++;
break;
case 4:
inf.status = SCANNING;
inf.progress = 0.9f;
statusCountFlag++;
break;
case 5:
inf.status = SCANNING;
inf.progress = 1.0f;
statusCountFlag = 0;
break;
case 6:
// case 7:
// inf.status = BUSY;
// statusCountFlag++;
// break;
// case 8:
inf.status = BUSY;
statusCountFlag = 0;
break;
default:
inf.status = BUSY;
statusCountFlag = 0;
}
return inf;
}
@@ -136,19 +109,8 @@ const char* GetPreviewData() {
const char* GetDeviceInfo(DeviceInfo infoType) {
switch (infoType) {
case MEAN_TEMPERATURE:
return "28";
case VERSION:
return "6.6.06";
case DEV_OUTPATH:
return output_path;
case MEAN_TEMPERATURE:
return "28";
}
return "";
}
#ifdef _WIN32
void StopDevice(){
CloseHandle(e1);
CloseHandle(e2);
}
#endif

View File

@@ -16,7 +16,7 @@ typedef enum {
typedef struct StatusInfo {
DeviceStatus status;// a enum represent device current status
int progress;// percent value of operation
float progress;// percent value of operation
} StatusInfo;
@@ -25,14 +25,11 @@ typedef enum {
SCAN,// Start scan action
PREVIEW_SCAN,// Start preview scan action
STOP,// Stop current scan
SCAN_CONTINUE,//Continue pending scan
} ScanAction;
//kinds of device information
typedef enum {
MEAN_TEMPERATURE,
VERSION,
DEV_OUTPATH
MEAN_TEMPERATURE
} DeviceInfo;
extern int InitLib(void(*)(const char *msg));
@@ -47,11 +44,6 @@ extern const char *GetPreviewData();
extern const char *GetDeviceInfo(DeviceInfo infoType);
#ifdef _WIN32
extern void StopDevice();
#endif
#ifdef __cplusplus
};
#endif

View File

@@ -13,8 +13,8 @@
#include <QTableView>
#include "components/SlideableTableView.h"
#include <QPushButton>
#include "src/dialogs/SelectDialog.h"
#include "src/windows/mainwindow.h"
#include "SelectDialog.h"
#include "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->setValues(dates);
dialog->setAvailableDates(dates);
if (!selectedDateStr.isEmpty()) dialog->setSelectedValue(selectedDateStr);
if (dialog->exec() == QDialog::Accepted)
{

View File

@@ -8,7 +8,6 @@
#include "json/cmdhelper.h"
#include <QThread>
#include "AppVersion.h"
#include "device/DeviceManager.h"
AboutWidget::AboutWidget(QWidget* parent)
: QWidget(parent)
@@ -77,8 +76,7 @@ void AboutWidget::initUi()
pMainLayout->addWidget(pGuiVer);
pEmbededSoftVer = new QLabel(this);
// pEmbededSoftVer->setText(tr("Embedded Software %1").arg(getEmbVersion()));
pEmbededSoftVer->setText(tr("Embedded Software %1, Data store Path:%2").arg(getEmbVersion(), getDataStorePath()));
pEmbededSoftVer->setText(tr("Embedded Software V1.5"));
pEmbededSoftVer->setContentsMargins(subContentMargin, 0, 0, 0);
pMainLayout->addWidget(pEmbededSoftVer);
@@ -158,8 +156,7 @@ void AboutWidget::initUi()
pBtnHelp->setText(tr("?"));
pCompanyCopyRight->setText(tr("Copyright © 2017-2020 Zhejiang Equilibrium Nine Medical Equipment Co., Ltd. All Rights Reversed"));
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()));
pEmbededSoftVer->setText(tr("Embedded Software V1.5"));
pReconSotfVer->setText(tr("Reconstruction Software V1.2"));
pFEBVer->setText(tr("FEB Information"));
});
@@ -183,17 +180,5 @@ void AboutWidget::openHelpFile()
}
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();;
}

View File

@@ -21,8 +21,6 @@ public:
~AboutWidget();
QString getGUIVersion();
QString getEmbVersion();
QString getDataStorePath();
private slots:
void openHelpFile();

View File

@@ -8,8 +8,7 @@
#define APP_VALUES()\
ADD_APP_VALUE(InProcessing)\
ADD_APP_VALUE(LastOperationTime)\
ADD_APP_VALUE(LastOperation)\
ADD_APP_VALUE(EmptyScanFlag)\
ADD_APP_VALUE(LastOperation)
#include <QApplication>
#include <QVariant>

View File

@@ -3,7 +3,9 @@
//
#include "AccountRoleComboDelegate.h"
#include <QComboBox>
#include <QPainter>
#include <QStyleOptionViewItem>
#include "db/SQLHelper.h"
AccountRoleComboDelegate::AccountRoleComboDelegate(QWidget *parent):QItemDelegate(parent) {
SQLHelper::QueryMap("select RoleID,RoleName from Role",map);

View File

@@ -1,152 +0,0 @@
//
// Created by Krad on 2022/3/24.
//
#include "DateSlidePickerBox.h"
#include <QHBoxLayout>
#include <QLabel>
#include <QDate>
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<<QString("%1").arg(i);
}
day->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());
}

View File

@@ -1,34 +0,0 @@
//
// Created by Krad on 2022/3/24.
//
#ifndef GUI_DATESLIDEPICKERBOX_H
#define GUI_DATESLIDEPICKERBOX_H
#include <QWidget>
#include "SlidePickerBox.h"
#include <QDate>
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

View File

@@ -1,20 +0,0 @@
//
// Created by Krad on 2022/3/21.
//
#include <QtWidgets/qstyleoption.h>
#include <QPaintEvent>
#include <QStylePainter>
#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());
}

View File

@@ -1,21 +0,0 @@
//
// Created by Krad on 2022/3/21.
//
#ifndef GUI_LISTBOX_H
#define GUI_LISTBOX_H
#include <QToolButton>
class Listbox: public QToolButton {
public:
explicit Listbox(QWidget* parent = nullptr){};
virtual ~Listbox(){};
protected:
virtual void paintEvent(QPaintEvent* e) override;
private:
};
#endif //GUI_LISTBOX_H

View File

@@ -6,7 +6,7 @@
#include <QPainter>
#include <QMouseEvent>
#include <QLabel>
#include <QFont>
#include <qdebug.h>
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 = {0,50-fontSize/2};
QPoint p = this->mapToGlobal({this->contentsMargins().left(),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 = {0,150-fontSize/2};
QPoint p1 = this->mapToGlobal({this->contentsMargins().left(),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 = {0,250-fontSize/2};
QPoint p2 = this->mapToGlobal({this->contentsMargins().left(),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 = {0,100};
QPoint lp = this->mapToGlobal({this->contentsMargins().left(),100});
line1->move(lp);
selectedIndex = 1;
@@ -76,13 +76,11 @@ void SlidePickerBox::mouseMoveEvent(QMouseEvent *ev) {
}
//防止拉过头
int selectItemCenter = selectedLbl->geometry().center().y();
if (selectedLbl == getEnabledLastLabel() && selectItemCenter<=150 && offset<0) return;
if (selectedLbl == getEnabledFirstLabel() && selectItemCenter>=150 && offset>0) return;
if (selectedLbl == lbls.last() && selectItemCenter<=150 && offset<0) return;
if (selectedLbl == lbls.first() && 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;
@@ -111,8 +109,6 @@ void SlidePickerBox::mouseReleaseEvent(QMouseEvent *ev) {
isDragging = false;
adjustPositon();
QWidget::mouseReleaseEvent(ev);
QString v = getSelectedValue();
emit valueChanged(v);
}
void SlidePickerBox::adjustPositon() const {
@@ -143,7 +139,7 @@ void SlidePickerBox::paintText(QString txt, int x, int y, const QColor& color) {
painter.drawText(x,y,txt);
}
void SlidePickerBox::setItems(const QStringList& itemsList) {
void SlidePickerBox::setItems(QStringList itemsList) {
this->items = itemsList;
hideLabel(selectedLbl);
hideLabel(prevLbl);
@@ -167,7 +163,7 @@ void SlidePickerBox::setItems(const QStringList& itemsList) {
lbl->setFixedHeight(fontSize);
lbl->setFixedWidth(320);
lbls.push_back(lbl);
QPoint p = {0,-150};
QPoint p = this->mapToGlobal({this->contentsMargins().left(),-150});
lbl->move(p);
}
selectedIndex = lbls.count()-1;
@@ -182,32 +178,36 @@ QString SlidePickerBox::getSelectedValue() {
void SlidePickerBox::setCurrentLabel(QLabel *label) {
if (selectedLbl)hideLabel(selectedLbl);
if (label) {
QPoint lp = {0, 100};
QPoint lp = this->mapToGlobal({this->contentsMargins().left(), 100});
label->move(lp);
label->show();
selectedLbl = label;
}
}
QLabel * SlidePickerBox::getEnabledFirstLabel() {
if (disableItems.empty()) return lbls.first();
for(int idx = 0; idx<disableItems.size(); idx++){
if(disableItems.contains(lbls[idx]->text()))continue;
return lbls[idx];
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::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::setPrevLabel(QLabel *label) {
if (prevLbl)hideLabel(prevLbl);
if (label) {
QPoint lp = this->mapToGlobal({this->contentsMargins().left(), 0});
label->move(lp);
label->show();
prevLbl = label;
}
}
void SlidePickerBox::hideLabel(QLabel *label) {
if (!label) return;
QPoint lp = {0, -150};
QPoint lp = this->mapToGlobal({this->contentsMargins().left(), -150});
label->move(lp);
}
@@ -221,53 +221,11 @@ void SlidePickerBox::setSelectedValue(const QString& val) {
}
int first_y = -100 * (selectedIndex-1);
for (int i = 0; i < lbls.count() ; ++i) {
QPoint lp = this->mapTo(this,{0, first_y+i*100});
QPoint lp = {this->contentsMargins().left(), first_y+i*100};
lbls[i]->move(lp);
lbls[i]->show();
lbls[i]->setStyleSheet("background:transparent");
}
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");
lbls[i]->lower();
}
selectedLbl = lbls[selectedIndex];
lbls[selectedIndex]->setStyleSheet("color:white");

View File

@@ -12,22 +12,12 @@ class SlidePickerBox:public QWidget {
public:
explicit SlidePickerBox(QWidget *parent = nullptr);
QString getSelectedValue();
void setItems(const QStringList& itemsList);
void addItem(QString& item) {
void setItems(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<Qt::AlignmentFlag> align){
this->defaultAlign = align;
}
signals:
void valueChanged(QString & value);
protected:
bool isDragging;
@@ -43,10 +33,9 @@ protected:
}
void setCurrentLabel(QLabel* label);
QLabel * getEnabledLastLabel();
QLabel * getEnabledFirstLabel();
void setPrevLabel(QLabel* label);
void setNextLabel(QLabel* label);
void hideLabel(QLabel* label);
void rearrangeLabels();
private:
int o_x=0,o_y=10;
int selectedIndex = -1;
@@ -55,8 +44,7 @@ private:
QLabel* nextLbl = nullptr;
QList<QLabel*> lbls;
QStringList items;
QStringList disableItems;
QFlags<Qt::AlignmentFlag> defaultAlign= Qt::AlignCenter;
void adjustPositon() const;
};

View File

@@ -6,7 +6,7 @@
#include <QScrollBar>
#include <QMouseEvent>
#include <QApplication>
#include <cmath>
#include <math.h>
SlideableTableView::SlideableTableView(QWidget *parent) : QTableView(parent) {
@@ -68,8 +68,3 @@ void SlideableTableView::mouseReleaseEvent(QMouseEvent *ev) {
// }
QTableView::mouseReleaseEvent(ev);
}
void SlideableTableView::currentChanged(const QModelIndex &current, const QModelIndex &previous) {
QTableView::currentChanged(current, previous);
emit currentRowChanged(current.row());
}

View File

@@ -12,15 +12,11 @@ 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 &current,
const QModelIndex &previous) override;
private:
bool isDragging = false;
int ox,oy,ov;

View File

@@ -229,23 +229,23 @@ QColor Battery::getNormalColorEnd() const
QSize Battery::sizeHint() const
{
return {90, 120};
return QSize(90, 120);
}
QSize Battery::minimumSizeHint() const
{
return {10, 30};
return QSize(10, 30);
}
void Battery::setRange(double minVal, double maxVal)
void Battery::setRange(double minValue, double maxValue)
{
//如果最小值大于或者等于最大值则不设置
if (minVal >= maxVal) {
if (minValue >= maxValue) {
return;
}
this->minValue = minVal;
this->maxValue = maxVal;
this->minValue = minValue;
this->maxValue = maxValue;
//如果目标值不在范围值内,则重新设置目标值
//值小于最小值则取最小值,大于最大值则取最大值
@@ -259,19 +259,19 @@ void Battery::setRange(double minVal, double maxVal)
this->update();
}
void Battery::setRange(int minVal, int maxVal)
void Battery::setRange(int minValue, int maxValue)
{
setRange((double)minVal, (double)maxVal);
setRange((double)minValue, (double)maxValue);
}
void Battery::setMinValue(double minVal)
void Battery::setMinValue(double minValue)
{
setRange(minVal, maxValue);
setRange(minValue, maxValue);
}
void Battery::setMaxValue(double maxVal)
void Battery::setMaxValue(double maxValue)
{
setRange(minValue, maxVal);
setRange(minValue, maxValue);
}
void Battery::setValue(double value)

View File

@@ -45,7 +45,7 @@ ImageSwitch::ButtonStyle ImageSwitch::getButtonStyle() const
QSize ImageSwitch::sizeHint() const
{
return {100, 50};
return QSize(100, 50);
}
QSize ImageSwitch::minimumSizeHint() const
@@ -53,19 +53,19 @@ QSize ImageSwitch::minimumSizeHint() const
return sizeHint();
}
void ImageSwitch::setChecked(bool value)
void ImageSwitch::setChecked(bool isChecked)
{
if (this->isChecked != value) {
this->isChecked = value;
if (this->isChecked != isChecked) {
this->isChecked = isChecked;
imgFile = isChecked ? imgOnFile : imgOffFile;
this->update();
}
}
void ImageSwitch::setButtonStyle(const ImageSwitch::ButtonStyle& style)
void ImageSwitch::setButtonStyle(const ImageSwitch::ButtonStyle& buttonStyle)
{
if (this->buttonStyle != style) {
this->buttonStyle = style;
if (this->buttonStyle != buttonStyle) {
this->buttonStyle = buttonStyle;
if (buttonStyle == ButtonStyle_1) {
imgOffFile = ":/icons/imageswitch/btncheckoff1.png";

View File

@@ -15,15 +15,7 @@ protected:
QVariant data(const QModelIndex& index, int role) const override {
if (index.column() >0 && role == Qt::TextAlignmentRole) {
return Qt::AlignCenter;
}
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 {
} else {
return QSqlTableModel::data(index,role);
}
}

View File

@@ -7,10 +7,9 @@
#include <QVariant>
#include <QTimerEvent>
#include <QDate>
#include <QDateTime>
#include <qdebug.h>
#include "appvals/AppGlobalValues.h"
#include "json/ScanJson.h"
#include "json/jsonobject.h"
#define TRIGGER_EVENT EventCenter::Default()->triggerEvent
#define THROW_ERROR(errormsg)\
@@ -32,6 +31,7 @@ const char* getStatusString(int status)
return "";
}
std::string getJsonFromPatInf(QObject* obj)
{
return ((QString*)obj)->toStdString();
@@ -58,7 +58,11 @@ void DeviceManager::initDevice() {
// empty scan
connect(EventCenter::Default(), &EventCenter::RequestEmptyScan, [=](QObject* sender, QObject* detail) {
std::string json = getJsonFromPatInf(detail);
startScan(json.c_str(), true);
// qDebug()<<json.c_str();
// void * jss = malloc(json.size());
// memcpy(jss,json.c_str(),json.size());
// processScan((char*)jss,true);
processScan(json.c_str(), true);
});
// Patient scan
connect(EventCenter::Default(), &EventCenter::RequestPatientScan, [=](QObject* sender, QObject* detail) {
@@ -66,13 +70,12 @@ void DeviceManager::initDevice() {
qDebug() << json.c_str();
if (!json.empty())
{
startScan(json.c_str());
// void * jss = malloc(json.size());
// memcpy(jss,json.c_str(),json.size());
// processScan((char*)jss);
processScan(json.c_str());
}
});
// Continue Scan
connect(EventCenter::Default(), &EventCenter::RequestContinueScan, [=](QObject* sender, QObject* detail) {
postContinueCommand(true);
});
// stop
connect(EventCenter::Default(), &EventCenter::RequestStop, [=]() {
qDebug() << "GetStatus";
@@ -90,6 +93,11 @@ void DeviceManager::initDevice() {
return;
}
}
// if (inf.status == BUSY) {
// QString msg("Device is busy, Stop operation fail!");
// THROW_ERROR(msg);
// return;
// };
AppGlobalValues::setInProcessing(true);
TRIGGER_EVENT(GUIEvents::InvokeOperationStart, nullptr, nullptr);
//ScanControl fail
@@ -116,6 +124,7 @@ void DeviceManager::initDevice() {
TRIGGER_EVENT(GUIEvents::ResponseStop, nullptr, nullptr);
AppGlobalValues::setInProcessing(false);
});
// preview
connect(EventCenter::Default(), &EventCenter::RequestPreviewScan, [=]() {
// check device status=========================================
@@ -146,7 +155,7 @@ void DeviceManager::initDevice() {
THROW_ERROR(msg);
qDebug() << "Error thrown!";
});
// init the preview data caller thread
previewDataCaller = QThread::create([=]() {
while (!endLoop)
{
@@ -183,132 +192,79 @@ void DeviceManager::initDevice() {
}
const char * getPhaseName(int phase){
const char* names[3] = {"Initializing","Scanning", "CE Measuring"};
return names[phase-1];
}
void DeviceManager::timerEvent(QTimerEvent* event) {
if (event->timerId() == deviceInfTimerID) {
QString temp = QString(GetDeviceInfo(MEAN_TEMPERATURE));
TRIGGER_EVENT(GUIEvents::ResponseDeviceTemperature, nullptr, (QObject *) &temp);
return;
}
//scanning progress timer
//error exit, callback error
if (errorOccurred) {
exitScanTimer();
return;
}
// previewing exit
if (previewing) {
QString msg("Device is previewing, exit current operation!");
THROW_ERROR(msg);
} else {
// check device status=========================================
qDebug() << "GetStatus";
StatusInfo inf = GetStatus();
qDebug() << "Scanning request status, status:" << getStatusString(inf.status);
//设备正常扫描中
if (inf.status == SCANNING) {
scanProcess(inf.progress);
return;
} else {
//未发生错误并且,之前状态是扫描,代表正常扫描完成
if (lastStatus == SCANNING) {
prepareFinishScan();
}
//一般不会出现其他情况
else {
QString msg("Unknown error in scanning progress timer");
THROW_ERROR(msg);
}
}
}
exitScanTimer();
}
if (event->timerId() == deviceInfTimerID) {
QString temp = QString(GetDeviceInfo(MEAN_TEMPERATURE));
TRIGGER_EVENT(GUIEvents::ResponseDeviceTemperature, nullptr, (QObject*)&temp);
return;
}
//scanning progress timer
{
//error exit, callback error
if (errorOccurred)
{
// qDebug() << "Error occurred, exit progress timer";
// QString msg("Error occurred, exit current operation!");
// THROW_ERROR(msg);
goto exitTimer;
}
// previewing exit
if (previewing)
{
QString msg("Device is previewing, exit current operation!");
THROW_ERROR(msg);
goto exitTimer;
}
else {
// check device status=========================================
qDebug() << "GetStatus";
StatusInfo inf = GetStatus();
qDebug() << "Scanning request status, status:" << getStatusString(inf.status);
//设备正常扫描中
if (inf.status == SCANNING) {
lastStatus = SCANNING;
//normal scan
QVariant var(inf.progress);
qDebug() << "Normal scan, invoke InvokeOperationProgress:" << inf.progress;
TRIGGER_EVENT(GUIEvents::InvokeOperationProgress, nullptr, (QObject*)&var);
return;
}
else {
//未发生错误并且,之前状态是扫描,代表正常扫描完成
if (lastStatus == SCANNING) {
qDebug() << "Scan finished";
QVariant var(true);
qDebug() << "InvokeOperationEnd";
TRIGGER_EVENT(GUIEvents::InvokeOperationEnd, nullptr, (QObject*)&var);
AppGlobalValues::setInProcessing(false);
lastStatus = -1;
previewing = false;
QString s("%1 %2");
s = s.arg(QDateTime::currentDateTime().toString("yyyy/MM/dd HH:mm:ss")).arg("Scan finished");
TRIGGER_EVENT(GUIEvents::GlobalBannerMessage, nullptr, (QObject*)&s);
}
//一般不会出现其他情况
else {
QString msg("Unknown error in scanning progress timer");
THROW_ERROR(msg);
}
}
}
exitTimer:
qDebug() << "Scanning progress Timer exit";
killTimer(timerID);
timerID = -1;
lastStatus = -1;
previewing = false;
return;
}
void DeviceManager::scanProcess(int sProgress) {
qDebug() << "current output path:" << getScanOutputPath();
lastStatus = SCANNING;
//normal scan pending
int phase = sProgress / 100 + 1;
int progress = sProgress % 100;
// scan with phase 3 has a different message
QString extraMsg = (AppGlobalValues::EmptyScanFlag().toBool() ||
(scanPhase != 3)) ? "": ", patient can leave";
QVariant var(QString("%1%3\r\n progress:%2%").arg(getPhaseName(scanPhase)).arg(progress).arg(extraMsg));
TRIGGER_EVENT(InvokeOperationProgress, nullptr, (QObject *) &var);
// 300 means finished
if (sProgress == 300) return;
//phase control
//no change return
if (scanPhase == phase) return;
// error phase
if (phase > 3 || scanPhase > phase) {
QString errorMsg = QString("Error Scan Phase code, current Phase code:%1, new Phase code:%2!").arg(
scanPhase).arg(phase);
THROW_ERROR(errorMsg)
exitScanTimer();
return;
}
// enter phase 2
if ((scanPhase = phase) == 2) {
if (!AppGlobalValues::EmptyScanFlag().toBool() && JsonObject::Instance()->getScanConfirm()) {
var.setValue(QString("Waiting for operator to start scan!\r\n Click \"Next\" to continue!"));
TRIGGER_EVENT(InvokeOperationPending, nullptr, (QObject *) &var);
exitScanTimer();
}
//empty scan no pending, auto continue
else {
postContinueCommand();
}
}
}
void DeviceManager::exitScanTimer() {
qDebug() << "Scanning progress Timer exit";
killTimer(timerID);
timerID = -1;
lastStatus = -1;
previewing = false;
}
void DeviceManager::prepareFinishScan() {
qDebug() << "Scan finished";
QVariant var(true);
qDebug() << "InvokeOperationEnd";
TRIGGER_EVENT(InvokeOperationEnd, nullptr, (QObject *) &var);
AppGlobalValues::setInProcessing(false);
// log, no need
// QString s("%1 %2");
// s = s.arg(QDateTime::currentDateTime().toString("yyyy/MM/dd HH:mm:ss")).arg("Scan finished");
// TRIGGER_EVENT(GlobalBannerMessage, nullptr, (QObject *) &s);
// get output data path
QString outputPath = GetDeviceInfo(DEV_OUTPATH);
outputPath = outputPath.replace("\\", "/");
// get scan ID from path
if (outputPath.endsWith('/')) outputPath = outputPath.remove(outputPath.length() - 1, 1);
QStringList list = outputPath.split('/');
if (list.length()) {
if (AppGlobalValues::EmptyScanFlag().toBool()) {
ScanJson::Current()->setEmptyScanID(list.last().toStdString().c_str());
} else {
ScanJson::Current()->setScanID(list.last().toStdString().c_str());
}
// save json
ScanJson::Current()->save();
} else {
QString msg("Scan Output Path error!");
THROW_ERROR(msg);
}
}
void DeviceManager::startScan(const char* json, bool empty) {
void DeviceManager::processScan(const char* json, bool empty) {
//clear last error state first
errorOccurred = false;
// check device status=========================================
@@ -325,7 +281,6 @@ void DeviceManager::startScan(const char* json, bool empty) {
AppGlobalValues::setInProcessing(true);
TRIGGER_EVENT(GUIEvents::InvokeOperationStart, nullptr, (QObject*)&msg);
qDebug() << "SetScanInfo>>>>>>>>>>>>>>>>>>>>";
AppGlobalValues::setEmptyScanFlag(empty);
int ret = SetScanInfo(json, empty ? 1 : 0);
if (ret) {
qDebug() << ">>>>>>>>>>>>>>>>>>>>SetScanInfo failed";
@@ -335,52 +290,23 @@ void DeviceManager::startScan(const char* json, bool empty) {
return;
}
qDebug() << ">>>>>>>>>>>>>>>>>>>>SetScanInfo success";
postScanCommand();
}
void DeviceManager::postScanCommand() {
qDebug() << "ScanControl start>>>>>>>>>>>>>>>>>>>>>";
if (!ScanControl(SCAN)) {
qDebug() << ">>>>>>>>>>>>>>>>>>>>>ScanControl success";
//set current state
lastStatus = SCANNING;
previewing = false;
scanPhase = 1;
qDebug() << "Start progress timer";
timerID = startTimer(500);
return;
}
//ScanControl fail
QString errmsg("ScanControl start fail!");
THROW_ERROR(errmsg);
qDebug() << ">>>>>>>>>>>>>>>>>>>>>ScanControl failed";
}
void DeviceManager::postContinueCommand(bool useTimer) {
if (!ScanControl(SCAN_CONTINUE)) {
if (useTimer)timerID = startTimer(500);
return;
}
//ScanControl fail
QString errmsg("ScanControl start fail!");
THROW_ERROR(errmsg);
//ScanControl fail
qDebug() << "ScanControl start>>>>>>>>>>>>>>>>>>>>>";
if (!ScanControl(SCAN)) {
qDebug() << ">>>>>>>>>>>>>>>>>>>>>ScanControl success";
//set current state
lastStatus = SCANNING;
previewing = false;
qDebug() << "Start progress timer";
timerID = startTimer(500);
return;
}
QString errmsg("ScanControl start fail!");
THROW_ERROR(errmsg);
qDebug() << ">>>>>>>>>>>>>>>>>>>>>ScanControl failed";
}
void DeviceManager::close() {
#ifdef _WIN32
StopDevice();
#endif
previewDataCaller->terminate();
delete previewDataCaller;
}
QString DeviceManager::getSoftwareVersion() {
return GetDeviceInfo(VERSION);
}
QString DeviceManager::getScanOutputPath() {
return GetDeviceInfo(DEV_OUTPATH);
}

View File

@@ -15,34 +15,8 @@ public:
static DeviceManager manager;
return &manager;
}
DeviceManager() = default;
~DeviceManager() override = default ;
DeviceManager(const DeviceManager&) = delete;
DeviceManager operator=(const DeviceManager&) = delete;
/**
* init device, include Shimlib and it's error call back,
* deviceInfTimer to get temperature of water, and the
* preview data caller thread.
*/
void initDevice();
/**
* close and release the device reference resource.
*/
void close();
/**
* Get Firm ware version
* @return Firm ware version
*/
QString getSoftwareVersion();
/**
* Get Scan data output path
* @return Scan data output path
*/
QString getScanOutputPath();
void setErrorOccurred(bool v){
errorOccurred = v;
}
@@ -57,48 +31,14 @@ protected:
void timerEvent(QTimerEvent* event) override;
private:
/**
* To start a new scan operation
* @param json The patient information json string
* @param empty Empty scan flag
*/
void startScan(const char* json, bool empty = false);
/**
* Post Scan start command to Shimlib
*/
void postScanCommand();
/**
* Post Continue Scan command to Shimlib
* @param useTimer start a new timer flag
*/
void postContinueCommand(bool useTimer = false);
/**
* Prepare for finishing the Scan
*/
void prepareFinishScan();
/**
* exit the current Scan process timer
*/
void exitScanTimer();
/**
* Process scan progress change
* @param Scan progress
*/
void scanProcess(int progress);
int scanPhase = 1;
void processScan(const char* json, bool empty = false);
int timerID = -1;
int deviceInfTimerID = -1;
int lastStatus = -1;
bool previewing = false;
volatile bool endLoop = false;
bool errorOccurred = false;
QThread* previewDataCaller = nullptr;
QThread* previewDataCaller;
};

167
src/editpatientform.cpp Normal file
View File

@@ -0,0 +1,167 @@
#include "editpatientform.h"
#include "ui_editpatientform.h"
#include <QListView>
#include <QHBoxLayout>
#include <QToolButton>
#include <QButtonGroup>
#include "guimacros.h"
#include <qdebug.h>
#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"));
}

View File

@@ -29,10 +29,6 @@ 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:
@@ -69,8 +65,9 @@ public:
}
void clearPatientInformation();
void storePatientInformation();
signals:
void restorePatientInformation();
void setEditEnable(bool enable);
signals:
void editAccept(PatientInformation * detail,bool & accept);
void editCancel();
signals:
@@ -80,6 +77,11 @@ private:
QString currentPatientUID;
QString AddDate;
PatientInformation store;
bool editEnable=false;
QToolButton* btnEditAccept;
QToolButton* btnEditCancel;
QToolButton* btnFemale;
QToolButton* btnMale;
};
#endif // EDITPATIENTFORM_H

152
src/editpatientform.ui Normal file
View File

@@ -0,0 +1,152 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>EditPatientForm</class>
<widget class="QWidget" name="EditPatientForm">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>466</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QToolButton" name="hideBtn">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<item>
<widget class="QLabel" name="lbl_ID">
<property name="text">
<string>ID</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="tbx_ID">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_Name">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="tbx_Name">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_Sex">
<property name="text">
<string>Gender</string>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="sexpanelwidget" native="true"/>
</item>
<item>
<widget class="QLabel" name="lbl_DOB">
<property name="text">
<string>Date Of Birth</string>
</property>
</widget>
</item>
<item>
<widget class="QDateEdit" name="tbx_Dob">
<property name="enabled">
<bool>false</bool>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>1</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_Comment">
<property name="text">
<string>Comment</string>
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="rtbx_Comment">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="editcmdWidget" native="true"/>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -14,7 +14,6 @@ ADD_EVENT_VALUE(PatientSelected)\
ADD_EVENT_VALUE(RequestPreviewScan)\
ADD_EVENT_VALUE(RequestEmptyScan)\
ADD_EVENT_VALUE(RequestPatientScan)\
ADD_EVENT_VALUE(RequestContinueScan)\
ADD_EVENT_VALUE(RequestStop)\
ADD_EVENT_VALUE(ResponseDeviceTemperature)\
ADD_EVENT_VALUE(ResponsePreview)\
@@ -24,7 +23,6 @@ ADD_EVENT_VALUE(DeviceErrorRaise)\
ADD_EVENT_VALUE(ShimLibInnerFault)\
ADD_EVENT_VALUE(InvokeOperationStart)\
ADD_EVENT_VALUE(InvokeOperationProgress)\
ADD_EVENT_VALUE(InvokeOperationPending)\
ADD_EVENT_VALUE(InvokeOperationEnd)\
ADD_EVENT_VALUE(PromptDialogOpen)\
ADD_EVENT_VALUE(GlobalBannerMessage)\

Binary file not shown.

View File

@@ -1,88 +0,0 @@
#include "editpatientform.h"
#include "ui_editpatientform.h"
#include <QListView>
#include <QHBoxLayout>
#include <QToolButton>
#include <QButtonGroup>
#include "guimacros.h"
#include <qdebug.h>
#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();
}

View File

@@ -1,140 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>EditPatientForm</class>
<widget class="QWidget" name="EditPatientForm">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>466</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QToolButton" name="hideBtn">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_ID">
<property name="text">
<string>ID</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="tbx_ID">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_Name">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="tbx_Name">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_Sex">
<property name="text">
<string>Gender</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="tbx_Sex">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_DOB">
<property name="text">
<string>Date Of Birth</string>
</property>
</widget>
</item>
<item>
<widget class="QDateEdit" name="tbx_Dob">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>1</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_Comment">
<property name="text">
<string>Comment</string>
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="rtbx_Comment">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="editcmdWidget" native="true"/>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -10,10 +10,10 @@
#include <QEvent>
#include "event/EventCenter.h"
#include "json/jsonobject.h"
#include "src/dialogs/SelectDialog.h"
#include "SelectDialog.h"
#include "src/utilities/locker.h"
#include "src/utilities/languageswitcher.h"
#include "locker.h"
#include "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, [=](const QString& str)
connect(instName, &QLineEdit::textChanged, [=](QString str)
{
JsonObject::Instance()->setInstitutionName(str);
});
connect(instAddr, &QLineEdit::textChanged, [=](const QString& str)
connect(instAddr, &QLineEdit::textChanged, [=](QString str)
{
JsonObject::Instance()->setInstitutionAddr(str);
});
connect(lockTime, &QLineEdit::textChanged, [=](const QString& str)
connect(lockTime, &QLineEdit::textChanged, [=](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->setValues(JsonObject::Instance()->language());
dialog->setAvailableDates(JsonObject::Instance()->language());
dialog->setSelectedValue(JsonObject::Instance()->defaultLanguage());
if (dialog->exec() == QDialog::Accepted)
{

View File

@@ -2,8 +2,6 @@
#include "guimessagedialog.h"
#include "ui_guimessagedialog.h"
#include "event/EventCenter.h"
#include <QToolButton>
#include <QHBoxLayout>
GUIMessageDialog::GUIMessageDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::GUIMessageDialog)
@@ -14,21 +12,8 @@ GUIMessageDialog::GUIMessageDialog(QWidget *parent) :
this->showFullScreen ();
ui->lbl_msg->setVisible(false);
ui->lbl_progressicon->setVisible(false);
btn_main = new QToolButton(this);
btn_main->setObjectName("btn_main");
btn_main->setVisible(false);
btn_main->setText("OK");
btn_Append = new QToolButton(this);
btn_Append->setObjectName("btn_main");
btn_Append->setVisible(false);
btn_Append->setText("Stop");
QWidget* btnContainer = new QWidget(this);
QHBoxLayout* hlayout = new QHBoxLayout(btnContainer);
hlayout->setMargin(0);
hlayout->addWidget(btn_main);
hlayout->addWidget(btn_Append);
ui->widget_2->layout()->addWidget(btnContainer);
ui->btn_main->setVisible(false);
ui->btn_main->setText("OK");
this->setWindowOpacity(0.6);
for (int i=1; i<=6;i++)
{
@@ -66,14 +51,14 @@ void GUIMessageDialog::stopLoading() {
killTimer(timerID);
timerID=-1;
}
disconnect(btn_main,0,0,0);
disconnect(ui->btn_main,0,0,0);
ui->lbl_progressicon->setVisible(false);
}
void GUIMessageDialog::startLoading() {
ui->lbl_progressicon->setVisible(true);
disconnect(btn_main,0,0,0);
connect(btn_main,&QToolButton::clicked,[=](){
disconnect(ui->btn_main,0,0,0);
connect(ui->btn_main,&QToolButton::clicked,[=](){
if (timerID != -1){
killTimer(timerID);
timerID = -1;
@@ -83,8 +68,9 @@ void GUIMessageDialog::startLoading() {
LOG_USER_OPERATION(Stop);
});
timerID = startTimer(100);
btn_main->setText("Stop");
btn_main->setVisible(true);
ui->btn_main->setText("Stop");
ui->btn_main->setVisible(true);
}
void GUIMessageDialog::showMessage(QString msg) {
@@ -93,10 +79,10 @@ void GUIMessageDialog::showMessage(QString msg) {
}
void GUIMessageDialog::showExitButton() {
btn_main->setText("OK");
btn_main->setVisible(true);
disconnect(btn_main,0,0,0);
connect(btn_main,&QToolButton::clicked,[=](){
ui->btn_main->setText("OK");
ui->btn_main->setVisible(true);
disconnect(ui->btn_main,0,0,0);
connect(ui->btn_main,&QToolButton::clicked,[=](){
if (timerID != -1){
killTimer(timerID);
timerID = -1;
@@ -112,27 +98,10 @@ void GUIMessageDialog::hideMessage() {
}
void GUIMessageDialog::hideExitButton() {
btn_main->setVisible(false);
disconnect(btn_main,0,0,0);
ui->btn_main->setVisible(false);
disconnect(ui->btn_main,0,0,0);
}
void GUIMessageDialog::setOpacity(double opacity) {
this->setWindowOpacity(opacity);
}
void GUIMessageDialog::startPending() {
disconnect(btn_Append,0,0,0);
connect(btn_Append,&QToolButton::clicked,[=](){
EventCenter::Default()->triggerEvent(GUIEvents::RequestContinueScan, nullptr, nullptr);
stopPending();
});
btn_Append->setText("Next");
btn_Append->setVisible(true);
pending = true;
}
void GUIMessageDialog::stopPending() {
disconnect(btn_Append,0,0,0);
btn_Append->setVisible(false);
pending = false;
}

View File

@@ -6,7 +6,7 @@
namespace Ui {
class GUIMessageDialog;
}
class QToolButton;
class GUIMessageDialog : public QDialog
{
Q_OBJECT
@@ -20,22 +20,14 @@ public:
void hideExitButton();
void startLoading();
void stopLoading();
void startPending();
void stopPending();
bool Pending(){
return pending;
}
void setOpacity(double);
protected:
void timerEvent(QTimerEvent* event) override ;
private:
Ui::GUIMessageDialog *ui;
QList<QString> frame;
QToolButton *btn_main;
QToolButton *btn_Append;
int frameIndex=0;
int timerID = -1;
bool pending = false;
};
#endif // GUIMESSAGEDIALOG_H

View File

@@ -96,6 +96,13 @@
</layout>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QToolButton" name="btn_main">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 231 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 227 B

View File

@@ -1,25 +0,0 @@
//
// Created by Krad on 2022/5/11.
//
#include "ScanJson.h"
#include <QFile>
#include <QDir>
#include <QCoreApplication>
void ScanJson::save() {
if (!root) return;
QDir d(QCoreApplication::applicationDirPath());
if (!d.exists("jsons")){
d.mkdir("jsons");
}
QFile f(QString("%1/jsons/%2.json").arg(QCoreApplication::applicationDirPath(),scanID.c_str()));
f.open(QFileDevice::ReadWrite);
cJSON_AddItemToObject(root, "EmptyScanID",
cJSON_CreateString(emptyScanID.empty()?JsonObject::Instance()->getEmptyScanID():emptyScanID.c_str()));
cJSON_AddItemToObject(root, "ScanID", cJSON_CreateString(scanID.c_str()));
char* content = cJSON_Print(root);
f.write(content);
f.flush();
f.close();
free(content);
}

View File

@@ -1,47 +0,0 @@
//
// Created by Krad on 2022/5/11.
//
#ifndef GUI_SCANJSON_H
#define GUI_SCANJSON_H
#include <string>
#include "cJSON.h"
#include "jsonobject.h"
class ScanJson {
public:
~ScanJson(){
if(root)cJSON_Delete(root);
}
void store(cJSON* json){
if(root){
cJSON_Delete(root);
root = nullptr;
}
root = json;
}
void setScanID(const char * id){
scanID.clear();
scanID.append(id);
}
void setEmptyScanID(const char * id){
emptyScanID.clear();
emptyScanID.append(id);
JsonObject::Instance()->setEmptyScanID(id);
setScanID(id);
}
void save();
static ScanJson* Current(){
static ScanJson instance;
return &instance;
}
private:
std::string emptyScanID;
std::string scanID;
cJSON* root = nullptr;
};
#endif //GUI_SCANJSON_H

View File

@@ -30,13 +30,7 @@ void JsonObject::setJsonString(const char* catergory, const char* stringName, co
if (!first) return;
cJSON* Item = cJSON_CreateString(stringValue);
cJSON* valItem = cJSON_GetObjectItem(first, stringName);
if (valItem){
cJSON_ReplaceItemInObject(first, stringName, Item);
}
else{
cJSON_AddItemToObject(first, stringName , Item);
}
cJSON_ReplaceItemInObject(first, stringName, Item);
if (save)
{
savecfg();
@@ -56,41 +50,6 @@ char* JsonObject::getJsonString(const char* catergory, const char* stringName)
return second->valuestring;
}
void JsonObject::setBool(const char *catergory, const char *stringName, bool val, bool save) {
if (!loadcfg())
return;
cJSON* first = cJSON_GetObjectItem((cJSON*)json_root, catergory);
if (!first) return;
cJSON* Item = cJSON_CreateBool(val?1:0);
cJSON* valItem = cJSON_GetObjectItem(first, stringName);
if (valItem){
cJSON_ReplaceItemInObject(first, stringName, Item);
}
else{
cJSON_AddItemToObject(first, stringName , Item);
}
if (save)
{
savecfg();
}
}
bool JsonObject::getBool(const char* catergory, const char* stringName)
{
if (!loadcfg())
return false;
cJSON* first = cJSON_GetObjectItem((cJSON*)json_root, catergory);
if (!first) return false;
cJSON* second = cJSON_GetObjectItem(first, stringName);
if (!second) return false;
return second->valueint;
}
char* JsonObject::getArrayNode(const char* catergory, const char* stringName, int index, const char* id)
{
if (!loadcfg())
@@ -437,12 +396,6 @@ void JsonObject::autoDHCP(bool ena)
setJsonString("address", "dhcp", str.toStdString().c_str());
}
bool JsonObject::getScanConfirm() {
return getBool("general","ScanConfirm");
}
void JsonObject::setScanConfirm(bool val) {
setBool("general","ScanConfirm", val, true);
}
IpAddr JsonObject::getDefaultIpAddr()
{
@@ -521,13 +474,3 @@ void JsonObject::setIpRouteList(const QList<QStringList>& list)
}
savecfg();
}
void JsonObject::setEmptyScanID(const char *id) {
setJsonString("deviceparam","EmptyScanID",id, true);
}
const char *JsonObject::getEmptyScanID() {
return getJsonString("deviceparam","EmptyScanID");
}

View File

@@ -87,12 +87,6 @@ public:
bool isDHCP();
void autoDHCP(bool);
bool getScanConfirm();
void setScanConfirm(bool val);
const char* getEmptyScanID();
void setEmptyScanID(const char* id);
IpAddr getDefaultIpAddr();
void setDefaultIpAddr(const IpAddr& addr);
@@ -110,9 +104,6 @@ private:
void setJsonString(const char* catergory, const char* stringName, const char* stringValue, bool save = true);
char* getJsonString(const char* catergory, const char* stringName);
void setBool(const char* catergory, const char* stringName,bool val, bool save = true);
bool getBool(const char* catergory, const char* stringName);
char* getArrayNode(const char* catergory, const char* stringName, int index, const char* id);
void setArrayNode(const char* catergory, const char* stringName, int index, const char* id, const char* stringValue);
int getArraySize(const char* catergory, const char* stringName);

View File

@@ -29,8 +29,9 @@ void LanguageSwitcher::setDefaultLanguage(QString str)
QString lan = QString(":/translations/" + str + ".qm");
if (translator->load(lan))
{
EventCenter::Default()->triggerEvent(ReloadLanguage, nullptr, nullptr);
//qDebug() << "installTranslator";
//QApplication::installTranslator(translator);
}
EventCenter::Default()->triggerEvent(ReloadLanguage, nullptr, nullptr);
}

View File

@@ -10,11 +10,11 @@
#include <QCryptographicHash>
#include <src/event/EventCenter.h>
#include "db/SQLHelper.h"
#include "src/utilities/InputObject.h"
#include "InputObject.h"
#include "models/User.h"
#include "log/UserOperationLog.h"
#include "json/jsonobject.h"
#include "src/dialogs/guimessagedialog.h"
#include "guimessagedialog.h"
LoginWindow::LoginWindow(QWidget* parent)
: QDialog(parent)

View File

@@ -1,7 +1,7 @@
#include "src/windows/mainwindow.h"
#include "mainwindow.h"
#include <QApplication>
#include "src/windows/loginwindow.h"
#include "src/utilities/InputObject.h"
#include "loginwindow.h"
#include "InputObject.h"
#include <QQmlApplicationEngine>
#include "db/SQLHelper.h"
#include <QTextCodec>
@@ -13,8 +13,8 @@
#include <QTranslator>
#include <src/device/DeviceManager.h>
#include "json/jsonobject.h"
#include "src/utilities/locker.h"
#include "src/utilities/languageswitcher.h"
#include "locker.h"
#include "languageswitcher.h"
QString loadFontFromFile(QString path)
{
static QString font;

View File

@@ -4,22 +4,22 @@
#include <QSizePolicy>
#include <QHBoxLayout>
#include "event/EventCenter.h"
#include "src/forms/tabformwidget.h"
#include "src/forms/select/SelectFormWidget.h"
#include "src/forms/scan/ScanFormWidget.h"
#include "src/dialogs/guimessagedialog.h"
#include "tabformwidget.h"
#include "SelectFormWidget.h"
#include "ScanFormWidget.h"
#include "guimessagedialog.h"
#include "device/DeviceManager.h"
#include "errorhandle/GUIErrorHandle.h"
#include "loginwindow.h"
#include <QTextEdit>
#include <QScrollBar>
#include "models/User.h"
#include "src/forms/settings/AdminSettingForm.h"
#include "AdminSettingForm.h"
#include "appvals/AppGlobalValues.h"
#include <fstream>
#include <sstream>
#include <QDateTime>
#include "src/forms/TopBarWidget.h"
#include "TopBarWidget.h"
#include <QGestureEvent>
#include <QDockWidget>
@@ -126,8 +126,7 @@ MainWindow::MainWindow(QWidget* parent) :
if (msg)
{
QVariant* var = (QVariant*)msg;
if (msgDialog->Pending())msgDialog->stopPending();
msgDialog->showMessage(var->toString());
msgDialog->showMessage(QString("Scanning %1%").arg((int)(var->toFloat() * 100.0f)));
}
else {
msgDialog->hideMessage();
@@ -135,14 +134,6 @@ MainWindow::MainWindow(QWidget* parent) :
// msgDialog->showFullScreen();
if (msgDialog->isHidden())msgDialog->show();
});
connect(EventCenter::Default(), &EventCenter::InvokeOperationPending, [=](QObject*, QObject* msg) {
if (!msgDialog) return;
if (!msgDialog->Pending()){
msgDialog->startPending();
QVariant* var = (QVariant*)msg;
msgDialog->showMessage(var->toString());
}
});
connect(EventCenter::Default(), &EventCenter::InvokeOperationEnd, [=]() {
if (!msgDialog) return;
if (!msgDialog->isHidden())msgDialog->accept();

View File

@@ -4,7 +4,7 @@
#include <QMainWindow>
#include <QDebug>
#include <QTimer>
#include "src/utilities/StdOutRedirector.h"
#include "StdOutRedirector.h"
#include "json/cJSON.h"
#include "loginwindow.h"

View File

@@ -48,7 +48,7 @@ bool User::submitChange() {
return result;
}
bool User::QueryUser(const QString& userID, const QString& Pwd) {
bool User::QueryUser(QString userID, QString Pwd) {
QString sql = QString("select * from Account where UserCode=:userID and Password=:pwd");
QMap<QString,QVariant> map;
@@ -82,7 +82,7 @@ bool User::QueryUser(const QString& userID, const QString& Pwd) {
}
bool User::existsUser(const QString& userCode) {
bool User::existsUser(QString userCode) {
QString sql = QString("select * from Account where UserCode=:userID");
QMap<QString,QVariant> map;
QMap<QString,QVariant> params;
@@ -91,7 +91,7 @@ bool User::existsUser(const QString& userCode) {
return !map.isEmpty();
}
bool User::getUser(const QString& userUID, User& user) {
bool User::getUser(QString userUID, User& user) {
QString sql = QString("select * from Account where UserID=:userUID");
QMap<QString,QVariant> map;
QMap<QString,QVariant> params;
@@ -113,7 +113,7 @@ bool User::getUser(const QString& userUID, User& user) {
static bool LOAD_ALL_ROLE = false;
static QMap<QString,QString> roleCache;
QString User::getRoleName(const QString& RoleID) {
QString User::getRoleName(QString RoleID) {
if (roleCache.contains(RoleID)) return roleCache[RoleID];
QString sql = QString("select RoleName from Role where RoleID=:RoleID");
QMap<QString,QVariant> map;
@@ -124,7 +124,7 @@ QString User::getRoleName(const QString& RoleID) {
return map["RoleName"].toString();
}
QString User::getRoleID(const QString& RoleName) {
QString User::getRoleID(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(const QString& UserCode, User &user) {
bool User::insertUser(QString UserCode, User &user) {
user.m_UserID = QUuid::createUuid().toString();
user.m_UserCode = UserCode;
static QString updateSQL = "insert into Account (%1) values (%2)";

View File

@@ -20,8 +20,8 @@ USER_PROPERTY(Comment)
class User:public QObject {
Q_OBJECT
public:
static bool QueryUser(const QString& userID, const QString& Pwd);
static bool existsUser(const QString& userCode);
static bool QueryUser(QString userID, QString Pwd);
static bool existsUser(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(const QString& userUID,User& user);
static bool insertUser(const QString& UserCode,User& user);
static bool getUser(QString userUID,User& user);
static bool insertUser(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(const QString& RoleID);
static QString getRoleID(const QString& RoleName);
static QString getRoleName(QString RoleID);
static QString getRoleID(QString RoleName);
static QStringList getAllRoleName();
private:
static User* currentUser;

View File

@@ -6,10 +6,8 @@
#include <QLabel>
#include <QtWidgets/QLineEdit>
#include "getadminpsw.h"
#ifndef WIN32
#include <src/device/networkmanager.h>
#endif
#include "device/networkmanager.h"
#include "device/networkmanager.h"
GetAdminPsw::GetAdminPsw(QWidget* parent, Qt::WindowFlags f) : GUIFormBaseDialog(parent, f) {

View File

@@ -5,7 +5,7 @@
#ifndef GUI_GETADMINPSW_H
#define GUI_GETADMINPSW_H
#include "src/dialogs/GUIFormBaseDialog.h"
#include "GUIFormBaseDialog.h"
class QLineEdit;
class QLabel;
class GetAdminPsw :public GUIFormBaseDialog {

View File

@@ -5,7 +5,7 @@
#ifndef GUI_GETIPDIALOG_H
#define GUI_GETIPDIALOG_H
#include "src/dialogs/GUIFormBaseDialog.h"
#include "GUIFormBaseDialog.h"
class QLineEdit;
class QLabel;
class GetIPDialog :public GUIFormBaseDialog {

View File

@@ -5,7 +5,7 @@
#ifndef GUI_GetRouteDialog_H
#define GUI_GETROUTEDIALOG_H
#include "src/dialogs/GUIFormBaseDialog.h"
#include "GUIFormBaseDialog.h"
class QLineEdit;
class QLabel;
class GetRouteDialog :public GUIFormBaseDialog {

View File

@@ -8,7 +8,7 @@
#include <QItemSelectionModel>
#include <QGraphicsDropShadowEffect>
#include "src/dialogs/guimessagedialog.h"
#include "guimessagedialog.h"
#include <QThread>
networkCfgDialog::networkCfgDialog(QWidget* parent) :

View File

@@ -2,13 +2,17 @@
#include "ui_patientinformationform.h"
#include "json/cJSON.h"
#include "event/EventCenter.h"
#include "json/ScanJson.h"
PatientInformationForm::PatientInformationForm(QWidget* parent) :
QWidget(parent),
ui(new Ui::PatientInformationForm)
{
ui->setupUi(this);
//ui->lbl_ID->setText(tr(""));
//ui->lbl_Date->setText(tr(""));
//ui->lbl_Name->setText(tr(""));
//ui->lbl_Sex->setText(tr(""));
//ui->lbl_Acc->setText(tr(""));
connect(EventCenter::Default(), &EventCenter::ReloadLanguage, [=]() {
ui->retranslateUi(this);
@@ -59,6 +63,6 @@ const char* PatientInformationForm::getCurrentPatientJsonString(bool empty) {
cJSON_AddItemToObject(root, "InstitutionAddress", cJSON_CreateString("HZ"));
delete jsonstr;
jsonstr = cJSON_Print(root);
ScanJson::Current()->store(root);
cJSON_Delete(root);
return jsonstr;
}

View File

@@ -2,7 +2,7 @@
#define PATIENTINFORMATIONFORM_H
#include <QWidget>
#include "src/forms/select/editpatientform.h"
#include "editpatientform.h"
namespace Ui {
class PatientInformationForm;
}

View File

@@ -48,7 +48,5 @@
<file>icons/edit.png</file>
<file>icons/hidearrow.png</file>
<file>icons/logout.png</file>
<file>icons/arrow-down.png</file>
<file>icons/arrow-up.png</file>
</qresource>
</RCC>

File diff suppressed because one or more lines are too long

View File

@@ -2,13 +2,16 @@
#include "ui_systemsettingform.h"
#include <QPushButton>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QDebug>
#include <QLabel>
#include <QLineEdit>
#include <QEvent>
#include <QToolButton>
#include <QGridLayout>
#include "src/dialogs/SelectDialog.h"
#include "SelectDialog.h"
#include "components/imageswitch.h"
#include "network/networkcfgdialog.h"
#include "network/dicomcfgdialog.h"
#include "network/getadminpsw.h"
@@ -17,6 +20,7 @@
#include "event/EventCenter.h"
#include "device/DeviceManager.h"
#include "json/cmdhelper.h"
#include "appvals/AppGlobalValues.h"
systemSettingForm::systemSettingForm(QWidget* parent) :
QWidget(parent),
@@ -50,19 +54,7 @@ systemSettingForm::systemSettingForm(QWidget* parent) :
ui->btnFlt->setText(JsonObject::Instance()->defaultFilter());
ui->btnFlt->setObjectName("BigBtn");
QGridLayout* gridLayout = (QGridLayout*)ui->block10->layout();
auto btn_needConfirm = new ImageSwitch(this);
auto lbl_needConfirm = new QLabel(this);
lbl_needConfirm->setText("Scan Confirm");
gridLayout->addWidget(btn_needConfirm, 4, 2, 1, 1);
gridLayout->addWidget(lbl_needConfirm, 4, 0, 1, 1);
btn_needConfirm->setChecked(JsonObject::Instance()->getScanConfirm());
QFrame* line5 = new QFrame(this);
line5->setFrameShape(QFrame::HLine);
line5->setFrameShadow(QFrame::Sunken);
gridLayout->addWidget(line5,5,0);
////test begin
////test begin
//flag_disksize = true;
//m_disksize = 75.0;
////test end
@@ -100,9 +92,6 @@ systemSettingForm::systemSettingForm(QWidget* parent) :
////
}
});
connect(btn_needConfirm, &ImageSwitch::clicked, [=]() {
JsonObject::Instance()->setScanConfirm(btn_needConfirm->getChecked());
});
connect(ui->btn_network, &QToolButton::clicked, [=]() {
GetAdminPsw dialog(this);
if (dialog.exec() == QDialog::Accepted)
@@ -127,7 +116,7 @@ systemSettingForm::systemSettingForm(QWidget* parent) :
sd_protocal = new SelectDialog(this);
sd_protocal->setWindowModality(Qt::WindowModal);
}
sd_protocal->setValues(JsonObject::Instance()->protocals());
sd_protocal->setAvailableDates(JsonObject::Instance()->protocals());
sd_protocal->setSelectedValue(JsonObject::Instance()->defaultProtocal());
if (sd_protocal->exec() == QDialog::Accepted)
{
@@ -143,7 +132,7 @@ systemSettingForm::systemSettingForm(QWidget* parent) :
sd_filter = new SelectDialog(this);
sd_filter->setWindowModality(Qt::WindowModal);
}
sd_filter->setValues(JsonObject::Instance()->worklistFilters());
sd_filter->setAvailableDates(JsonObject::Instance()->worklistFilters());
sd_filter->setSelectedValue(JsonObject::Instance()->defaultFilter());
if (sd_filter->exec() == QDialog::Accepted)
{

Some files were not shown because too many files have changed in this diff Show More