Update GUI and Recon connection.
This commit is contained in:
@@ -8,7 +8,9 @@
|
||||
|
||||
#include "components/SlideTableView.h"
|
||||
#include "db/SQLHelper.h"
|
||||
#include "device/DeviceManager.h"
|
||||
#include "ScanSearchCriteriaForm.h"
|
||||
#include "ReconStateDelegate.h"
|
||||
|
||||
ReconFormWidget::ReconFormWidget(QWidget *parent)
|
||||
: TabFormWidget(parent)
|
||||
@@ -16,9 +18,9 @@ ReconFormWidget::ReconFormWidget(QWidget *parent)
|
||||
, mBtnDelete(new QToolButton(this))
|
||||
, mBtnRefresh(new QToolButton(this))
|
||||
, mScanTable(new SlideTableView(this))
|
||||
, mModel(nullptr){
|
||||
|
||||
|
||||
, mSearchWidget(new ScanSearchCriteriaForm(this))
|
||||
, mModel(nullptr)
|
||||
{
|
||||
auto layout = new QHBoxLayout(ui->commandWidget);
|
||||
layout->setAlignment(Qt::AlignmentFlag::AlignLeft);
|
||||
mBtnDiscard->setObjectName("btnDiscard");
|
||||
@@ -37,17 +39,24 @@ ReconFormWidget::ReconFormWidget(QWidget *parent)
|
||||
initDataModel();
|
||||
//Init content widget
|
||||
|
||||
QWidget * widget = new ScanSearchCriteriaForm(this);
|
||||
widget->setObjectName("SearchCriteriaForm");
|
||||
ui->horizontalLayout->insertWidget(0,widget);
|
||||
mSearchWidget->setObjectName("SearchCriteriaForm");
|
||||
ui->horizontalLayout->insertWidget(0, mSearchWidget);
|
||||
insertVerticalLine(1,ui->horizontalLayout);
|
||||
auto* contentLayout = new QHBoxLayout(this->ui->contentWidget);
|
||||
contentLayout->setContentsMargins(0, 0, 0, 0);
|
||||
initTableView(contentLayout);
|
||||
|
||||
connect(mBtnRefresh, &QToolButton::clicked, DeviceManager::Default(), &DeviceManager::updateReconState);
|
||||
connect(DeviceManager::Default(), &DeviceManager::updateReconStateFinished, mModel, &QSqlTableModel::select);
|
||||
connect(mSearchWidget, &ScanSearchCriteriaForm::searchFilterUpdated, this, &ReconFormWidget::updateSearchFilter);
|
||||
|
||||
}
|
||||
|
||||
void ReconFormWidget::initTableView(QHBoxLayout *contentLayout) {// TableView for Scan
|
||||
void ReconFormWidget::initTableView(QHBoxLayout *contentLayout)
|
||||
{
|
||||
// TableView for Scan
|
||||
ReconStateDelegate* delegate = new ReconStateDelegate(this);
|
||||
mScanTable->setItemDelegateForColumn(8, delegate);
|
||||
mScanTable->setAlternatingRowColors(true);
|
||||
mScanTable->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
mScanTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
@@ -60,30 +69,41 @@ void ReconFormWidget::initTableView(QHBoxLayout *contentLayout) {// TableView fo
|
||||
mScanTable->viewport()->ungrabGesture(Qt::PanGesture);
|
||||
|
||||
mScanTable->setSortingEnabled(true); // enable sortingEnabled
|
||||
mScanTable->setModel((QAbstractItemModel*) mModel);
|
||||
mScanTable->setModel(mModel);
|
||||
mScanTable->hideColumn(0);
|
||||
mScanTable->hideColumn(1);
|
||||
mScanTable->show();
|
||||
mScanTable->hideColumn(4);
|
||||
|
||||
mScanTable->setColumnWidth(2, 250);
|
||||
mScanTable->setColumnWidth(3, 200);
|
||||
mScanTable->setColumnWidth(4, 160);
|
||||
mScanTable->setColumnWidth(3, 250);
|
||||
mScanTable->setColumnWidth(5, 250);
|
||||
mScanTable->setColumnWidth(6, 250);
|
||||
mScanTable->setColumnWidth(6, 100);
|
||||
mScanTable->setColumnWidth(7, 250);
|
||||
contentLayout->addWidget(mScanTable);
|
||||
|
||||
mScanTable->show();
|
||||
//table current row selection changing event
|
||||
|
||||
// after sort by column
|
||||
}
|
||||
|
||||
void ReconFormWidget::initDataModel() {//TODO:单独初始化预防SQL错误
|
||||
void ReconFormWidget::initDataModel()
|
||||
{
|
||||
//TODO:单独初始化预防SQL错误
|
||||
mModel = SQLHelper::getTable("Scan");
|
||||
mModel->sort(5, Qt::DescendingOrder);
|
||||
mModel->select();
|
||||
mModel->setHeaderData(2, Qt::Horizontal, "PatientID");
|
||||
mModel->sort(3, Qt::DescendingOrder);
|
||||
updateSearchFilter();
|
||||
|
||||
mModel->setHeaderData(2, Qt::Horizontal, tr("PatientID"));
|
||||
mModel->setHeaderData(5, Qt::Horizontal, tr("PatientName"));
|
||||
mModel->setHeaderData(3, Qt::Horizontal, tr("Scan Time"));
|
||||
mModel->setHeaderData(6, Qt::Horizontal, tr("Laterality"));
|
||||
mModel->setHeaderData(7, Qt::Horizontal, tr("OperatorName"));
|
||||
mModel->setHeaderData(8, Qt::Horizontal, tr("State"));
|
||||
}
|
||||
|
||||
void ReconFormWidget::updateSearchFilter()
|
||||
{
|
||||
mModel->setFilter(mSearchWidget->getSearchFilter());
|
||||
mModel->select();
|
||||
}
|
||||
|
||||
@@ -3,21 +3,29 @@
|
||||
#define IMG1_V2_BIN_RECONFORMWIDGET_H
|
||||
|
||||
#include "forms/TabFormWidget.h"
|
||||
|
||||
class QToolButton;
|
||||
class SlideTableView;
|
||||
class QSqlTableModel;
|
||||
class ReconFormWidget: public TabFormWidget {
|
||||
class ScanSearchCriteriaForm;
|
||||
|
||||
class ReconFormWidget: public TabFormWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ReconFormWidget(QWidget *parent = nullptr);
|
||||
|
||||
~ReconFormWidget() override = default;
|
||||
|
||||
private slots:
|
||||
void updateSearchFilter();
|
||||
|
||||
private:
|
||||
QToolButton* mBtnDiscard;
|
||||
QToolButton* mBtnDelete;
|
||||
QToolButton* mBtnRefresh;
|
||||
SlideTableView* mScanTable;
|
||||
ScanSearchCriteriaForm* mSearchWidget;
|
||||
QSqlTableModel *mModel;
|
||||
|
||||
void initTableView(QHBoxLayout *contentLayout);
|
||||
|
||||
87
src/forms/recon/ReconStateDelegate.cpp
Normal file
87
src/forms/recon/ReconStateDelegate.cpp
Normal file
@@ -0,0 +1,87 @@
|
||||
#include "ReconStateDelegate.h"
|
||||
#include "device/DeviceManager.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QProgressBar>
|
||||
#include <QApplication>
|
||||
|
||||
ReconStateDelegate::ReconStateDelegate(QObject* aParent)
|
||||
: QStyledItemDelegate(aParent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ReconStateDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
QVariant data = index.data(Qt::DisplayRole);
|
||||
|
||||
if (data.isValid())
|
||||
{
|
||||
int state = data.toInt();
|
||||
QString displayText;
|
||||
switch (state)
|
||||
{
|
||||
case 0:
|
||||
displayText = tr("Wait to transfer");
|
||||
break;
|
||||
case 100:
|
||||
{
|
||||
displayText = tr("Transfering");
|
||||
int progress = DeviceManager::Default()->getTransferProgress();
|
||||
QRect textRect = option.rect;
|
||||
textRect.setRight(option.rect.right() - 300);
|
||||
painter->drawText(textRect, Qt::AlignCenter, displayText);
|
||||
|
||||
QRect progressBarRect = option.rect;
|
||||
progressBarRect.setLeft(textRect.right() + 20);
|
||||
progressBarRect.setRight(option.rect.right() - 5);
|
||||
progressBarRect.setTop(option.rect.top() + 5);
|
||||
progressBarRect.setBottom(option.rect.bottom() - 5);
|
||||
|
||||
QStyleOptionProgressBarV2 progressBarOption;
|
||||
progressBarOption.rect = progressBarRect;
|
||||
progressBarOption.minimum = 0;
|
||||
progressBarOption.maximum = 100;
|
||||
progressBarOption.progress = progress;
|
||||
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &progressBarOption, painter);
|
||||
|
||||
return;
|
||||
}
|
||||
case 104:
|
||||
displayText = tr("Transfer failed");
|
||||
break;
|
||||
case 200:
|
||||
displayText = tr("Transfer completed");
|
||||
break;
|
||||
case 204:
|
||||
displayText = tr("Recon create failed");
|
||||
break;
|
||||
case 300:
|
||||
displayText = tr("Recon create succeed");
|
||||
break;
|
||||
case 400:
|
||||
displayText = tr("Wait to recon");
|
||||
break;
|
||||
case 500:
|
||||
displayText = tr("Recon ing");
|
||||
break;
|
||||
case 504:
|
||||
displayText = tr("Recon failed");
|
||||
break;
|
||||
case 600:
|
||||
displayText = tr("Recon succeed");
|
||||
break;
|
||||
case 604:
|
||||
displayText = tr("PACS failed");
|
||||
break;
|
||||
case 999:
|
||||
displayText = tr("PACS succeed");
|
||||
break;
|
||||
default:
|
||||
displayText = tr("Unknow");
|
||||
break;
|
||||
}
|
||||
|
||||
painter->drawText(option.rect, Qt::AlignCenter, displayText);
|
||||
}
|
||||
}
|
||||
15
src/forms/recon/ReconStateDelegate.h
Normal file
15
src/forms/recon/ReconStateDelegate.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef RECONSTATEDELEGATE_H
|
||||
#define RECONSTATEDELEGATE_H
|
||||
|
||||
#include <QStyledItemDelegate>
|
||||
|
||||
class ReconStateDelegate : public QStyledItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ReconStateDelegate(QObject* aParent);
|
||||
|
||||
void paint(QPainter *aPainter, const QStyleOptionViewItem &aOption, const QModelIndex &aIndex) const override;
|
||||
};
|
||||
|
||||
#endif // RECONSTATEDELEGATE_H
|
||||
@@ -3,15 +3,17 @@
|
||||
|
||||
#include <QDate>
|
||||
#include "components/ListBox.h"
|
||||
#include "dialogs/DialogManager.h"
|
||||
|
||||
ScanSearchCriteriaForm::ScanSearchCriteriaForm(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::ScanSearchCriteriaForm)
|
||||
ScanSearchCriteriaForm::ScanSearchCriteriaForm(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::ScanSearchCriteriaForm)
|
||||
, mSearchFilter()
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
auto beginBox = new ListBox(this);
|
||||
// beginBox->setSmallBox(true);
|
||||
// beginBox->setSmallBox(true);
|
||||
ui->verticalLayoutDate->replaceWidget(ui->mLBBeginDate,beginBox);
|
||||
ui->mLBBeginDate->setVisible(false);
|
||||
ui->mLBBeginDate->deleteLater();
|
||||
@@ -21,7 +23,7 @@ ScanSearchCriteriaForm::ScanSearchCriteriaForm(QWidget *parent) :
|
||||
ui->mLBBeginDate->setText(QDate::currentDate().toString("yyyy-MM-dd"));
|
||||
|
||||
auto endBox = new ListBox(this);
|
||||
// endBox->setSmallBox(true);
|
||||
// endBox->setSmallBox(true);
|
||||
ui->verticalLayoutDate->replaceWidget(ui->mLBEndDate,endBox);
|
||||
ui->mLBEndDate->setVisible(false);
|
||||
ui->mLBEndDate->deleteLater();
|
||||
@@ -33,9 +35,71 @@ ScanSearchCriteriaForm::ScanSearchCriteriaForm(QWidget *parent) :
|
||||
ui->ScanTitle->setObjectName("parameterTitle");
|
||||
|
||||
ui->holder1->setObjectName("endSpaceLine");
|
||||
|
||||
connect(ui->mLBEndDate, &QToolButton::clicked, [=]()
|
||||
{
|
||||
DialogResult result = DialogManager::Default()->requestSelectDate(ui->mLBEndDate->text());
|
||||
if (result.ResultCode == QDialog::Accepted)
|
||||
{
|
||||
ui->mLBEndDate->setText(result.ResultData.toString());
|
||||
}
|
||||
});
|
||||
|
||||
connect(ui->mLBBeginDate, &QToolButton::clicked, [=]()
|
||||
{
|
||||
DialogResult result = DialogManager::Default()->requestSelectDate(ui->mLBEndDate->text());
|
||||
if (result.ResultCode == QDialog::Accepted)
|
||||
{
|
||||
ui->mLBBeginDate->setText(result.ResultData.toString());
|
||||
}
|
||||
});
|
||||
|
||||
connect(ui->mBtnToday, &QToolButton::clicked, [=]()
|
||||
{
|
||||
QString today = QDate::currentDate().toString("yyyy-MM-dd");
|
||||
ui->mLBEndDate->setText(today);
|
||||
ui->mLBBeginDate->setText(today);
|
||||
updateSearchFilter();
|
||||
});
|
||||
|
||||
connect(ui->mBtnSevenDays, &QToolButton::clicked, [=]()
|
||||
{
|
||||
ui->mLBEndDate->setText(QDate::currentDate().toString("yyyy-MM-dd"));
|
||||
ui->mLBBeginDate->setText(QDate::currentDate().addDays(-7).toString("yyyy-MM-dd"));
|
||||
updateSearchFilter();
|
||||
});
|
||||
|
||||
connect(ui->mBtnYesterday, &QToolButton::clicked, [=]()
|
||||
{
|
||||
QString yesterday = QDate::currentDate().addDays(-1).toString("yyyy-MM-dd");
|
||||
ui->mLBEndDate->setText(yesterday);
|
||||
ui->mLBBeginDate->setText(yesterday);
|
||||
updateSearchFilter();
|
||||
});
|
||||
|
||||
connect(ui->mBtnAll, &QToolButton::clicked, [=]()
|
||||
{
|
||||
QString today = QDate::currentDate().toString("yyyy-MM-dd");
|
||||
ui->mLBEndDate->setText(today);
|
||||
ui->mLBBeginDate->setText("1990-01-01");
|
||||
updateSearchFilter();
|
||||
});
|
||||
|
||||
connect(ui->mBtnDates, &QPushButton::clicked, this, &ScanSearchCriteriaForm::updateSearchFilter);
|
||||
|
||||
}
|
||||
|
||||
ScanSearchCriteriaForm::~ScanSearchCriteriaForm()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
QString ScanSearchCriteriaForm::getSearchFilter()
|
||||
{
|
||||
return QString("ScanDateTime >= '%1 00:00:00' And ScanDateTime <= '%2 23:59:59'").arg(ui->mLBBeginDate->text()).arg(ui->mLBEndDate->text());
|
||||
}
|
||||
|
||||
void ScanSearchCriteriaForm::updateSearchFilter()
|
||||
{
|
||||
emit searchFilterUpdated();
|
||||
}
|
||||
|
||||
@@ -15,8 +15,17 @@ public:
|
||||
explicit ScanSearchCriteriaForm(QWidget *parent = nullptr);
|
||||
~ScanSearchCriteriaForm();
|
||||
|
||||
QString getSearchFilter();
|
||||
|
||||
private slots:
|
||||
void updateSearchFilter();
|
||||
|
||||
signals:
|
||||
void searchFilterUpdated();
|
||||
|
||||
private:
|
||||
Ui::ScanSearchCriteriaForm *ui;
|
||||
QString mSearchFilter;
|
||||
};
|
||||
|
||||
#endif // SCANSEARCHCRITERIAFORM_H
|
||||
|
||||
Reference in New Issue
Block a user