refactor: Modify the display and interaction related to worklist.

This commit is contained in:
sunwen
2024-09-06 17:29:25 +08:00
parent c6c3d81ecf
commit b60c4a8be9
60 changed files with 3336 additions and 1512 deletions

View File

@@ -81,7 +81,9 @@ void ReconFormWidget::initTableView(QHBoxLayout *contentLayout)
mScanTable->setModel(mModel);
mScanTable->hideColumn(getTableColumnIndex("ScanID"));
mScanTable->hideColumn(getTableColumnIndex("ReferenceID"));
mScanTable->hideColumn(getTableColumnIndex("UpdateTime"));
mScanTable->hideColumn(getTableColumnIndex("StudyUID"));
mScanTable->hideColumn(getTableColumnIndex("Modality"));
mScanTable->hideColumn(getTableColumnIndex("MPPSUID"));
mScanTable->setColumnWidth(getTableColumnIndex("PatientID"), 200);
mScanTable->setColumnWidth(getTableColumnIndex("AccessionNumber"), 200);

View File

@@ -8,8 +8,10 @@
PatientInformationForm::PatientInformationForm(QWidget* parent)
: QWidget(parent)
, mUI(new Ui::PatientInformationForm)
, mInfo(nullptr)
, mJsonStr(nullptr)
, mStudyUID()
, mModality()
, mMPPSUID()
{
mUI->setupUi(this);
connect(EventCenter::Default(), &EventCenter::ReloadLanguage, [=]() {
@@ -23,15 +25,13 @@ PatientInformationForm::~PatientInformationForm()
delete mJsonStr;
}
void PatientInformationForm::setPatientInformation(PatientInformationPointer information, ScanProtocal aProtocal) {
if(information)
void PatientInformationForm::setPatientInformation(PatientInformation* information) {
if(information != nullptr)
{
mUI->mPatientID->setText(information->ID);
mUI->mPatientBirthday->setText(information->BirthDate);
mUI->mPatientName->setText(information->Name);
mUI->mPatientGender->setText(information->Sex);
mUI->mPaitenAccessionNumber->setText(information->AccessionNumber);
mUI->mScanProtocol->setText(getProtocolString(aProtocal));
mUI->mPatientGender->setText(information->Sex == "F" ? tr("Female") : (information->Sex == "M" ? tr("Male") : tr("Other")));
}
else
{
@@ -40,15 +40,26 @@ void PatientInformationForm::setPatientInformation(PatientInformationPointer inf
mUI->mPatientName->clear();
mUI->mPatientGender->clear();
mUI->mPaitenAccessionNumber->clear();
mUI->mScanProtocol->clear();
mStudyUID.clear();
mModality.clear();
mMPPSUID.clear();
}
mInfo = information;
}
PatientInformationPointer PatientInformationForm::getPatientInformation()
void PatientInformationForm::setAccessionNumber(AccessionInformation* aAccession)
{
return mInfo->Copy();
if(aAccession == nullptr)
{
mUI->mPaitenAccessionNumber->setText("");
mStudyUID.clear();
mModality.clear();
mMPPSUID.clear();
return;
}
mUI->mPaitenAccessionNumber->setText(aAccession->mAccessionNumber);
mStudyUID = aAccession->mStudyUID;
mModality = aAccession->mModality;
mMPPSUID = aAccession->mMPPSUID;
}
int PatientInformationForm::getProtocol()
@@ -75,6 +86,14 @@ QString PatientInformationForm::getPatientID()
void PatientInformationForm::setExecuteProtocol(bool aIsLeft)
{
mIsExecuteProtocolLeft = aIsLeft;
if(mIsExecuteProtocolLeft)
{
mUI->mScanProtocol->setText(tr("Left"));
}
else
{
mUI->mScanProtocol->setText(tr("Right"));
}
}
void PatientInformationForm::clear()
@@ -85,24 +104,29 @@ void PatientInformationForm::clear()
mUI->mPatientGender->clear();
mUI->mPaitenAccessionNumber->clear();
mUI->mScanProtocol->clear();
mStudyUID.clear();
mModality.clear();
mMPPSUID.clear();
}
const char* PatientInformationForm::getCurrentPatientJsonString(bool empty)
{
cJSON* patientInfoObject = cJSON_CreateObject();
cJSON_AddItemToObject(patientInfoObject, "PatientName", cJSON_CreateString(mInfo->Name.toStdString().data()));
cJSON_AddItemToObject(patientInfoObject, "PatientID", cJSON_CreateString(mInfo->ID.toStdString().data()));
cJSON_AddItemToObject(patientInfoObject, "AccessionNumber", cJSON_CreateString(mInfo->AccessionNumber.toStdString().data()));
cJSON_AddItemToObject(patientInfoObject, "PatientSex", cJSON_CreateString(mInfo->Sex.toStdString().data()));
cJSON_AddItemToObject(patientInfoObject, "PatientName", cJSON_CreateString(mUI->mPatientName->text().toStdString().data()));
cJSON_AddItemToObject(patientInfoObject, "PatientID", cJSON_CreateString(mUI->mPatientID->text().toStdString().data()));
cJSON_AddItemToObject(patientInfoObject, "AccessionNumber", cJSON_CreateString(mUI->mPaitenAccessionNumber->text().toStdString().data()));
cJSON_AddItemToObject(patientInfoObject, "PatientSex", cJSON_CreateString(mUI->mPatientGender->text().toStdString().data()));
cJSON_AddItemToObject(patientInfoObject, "PatientBirthDate",
cJSON_CreateString(mInfo->BirthDate.replace("/", "").replace("-", "").replace(' ', '.').toStdString().data()));
cJSON_CreateString(mUI->mPatientBirthday->text().replace("/", "").replace("-", "").replace(' ', '.').toStdString().data()));
cJSON_AddItemToObject(patientInfoObject, "Laterality", cJSON_CreateString(mIsExecuteProtocolLeft ? "L" : "R"));
cJSON_AddItemToObject(patientInfoObject, "IsEmptyData", cJSON_CreateNumber(empty ? 1 : 0));
cJSON_AddItemToObject(patientInfoObject, "OperatorName", cJSON_CreateString(User::Current()->getUserName().toStdString().c_str()));
cJSON_AddItemToObject(patientInfoObject, "ReferringPhysicianName", cJSON_CreateString(User::Current()->getUserName().toStdString().c_str()));
cJSON_AddItemToObject(patientInfoObject, "InstitutionName", cJSON_CreateString("EQ9"));
cJSON_AddItemToObject(patientInfoObject, "InstitutionAddress", cJSON_CreateString("HZ"));
cJSON_AddItemToObject(patientInfoObject, "StudyUID", cJSON_CreateString(mStudyUID.toStdString().data()));
cJSON_AddItemToObject(patientInfoObject, "Modality", cJSON_CreateString(mModality.toStdString().data()));
cJSON_AddItemToObject(patientInfoObject, "MPPSUID", cJSON_CreateString(mMPPSUID.toStdString().data()));
cJSON* rootObject = cJSON_CreateObject();
cJSON_AddItemToObject(rootObject, "Patient Info", patientInfoObject);
delete mJsonStr;

View File

@@ -19,8 +19,8 @@ class PatientInformationForm : public QWidget
public:
explicit PatientInformationForm(QWidget *parent = nullptr);
~PatientInformationForm() override;
void setPatientInformation(PatientInformationPointer information, ScanProtocal aProtocal);
PatientInformationPointer getPatientInformation();
void setPatientInformation(PatientInformation* information);
void setAccessionNumber(AccessionInformation* aAccession);
int getProtocol();
QString getProtocolString(ScanProtocal aProtocal);
void setExecuteProtocol(bool aIsLeft);
@@ -31,10 +31,12 @@ public:
private:
Ui::PatientInformationForm *mUI;
PatientInformationPointer mInfo;
bool mIsExecuteProtocolLeft = false;
ScanProtocal mCurrentProtocol = LSTAND;
char * mJsonStr = nullptr;
QString mStudyUID;
QString mModality;
QString mMPPSUID;
};
#endif // PATIENTINFORMATIONFORM_H

View File

@@ -62,7 +62,7 @@
</item>
<item>
<widget class="QWidget" name="mPatientInfomation" native="true">
<layout class="QGridLayout" name="gridLayout">
<layout class="QGridLayout" name="gridLayout" columnstretch="2,3">
<item row="1" column="0">
<widget class="QLabel" name="mPatientNameLabel">
<property name="text">
@@ -73,14 +73,14 @@
<item row="0" column="1">
<widget class="QLabel" name="mPatientID">
<property name="text">
<string/>
<string notr="true"/>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="mPatientGender">
<property name="text">
<string/>
<string notr="true"/>
</property>
</widget>
</item>
@@ -101,7 +101,7 @@
<item row="3" column="1">
<widget class="QLabel" name="mPatientBirthday">
<property name="text">
<string/>
<string notr="true"/>
</property>
</widget>
</item>
@@ -115,7 +115,7 @@
<item row="4" column="1">
<widget class="QLabel" name="mPaitenAccessionNumber">
<property name="text">
<string/>
<string notr="true"/>
</property>
</widget>
</item>
@@ -129,7 +129,7 @@
<item row="1" column="1">
<widget class="QLabel" name="mPatientName">
<property name="text">
<string/>
<string notr="true"/>
</property>
</widget>
</item>
@@ -143,7 +143,7 @@
<item row="5" column="1">
<widget class="QLabel" name="mScanProtocol">
<property name="text">
<string/>
<string notr="true"/>
</property>
</widget>
</item>

View File

@@ -29,11 +29,11 @@
namespace
{
const size_t PREVIEW_ROW = 140;
const size_t PREVIEW_COL = 140;
const float PIXEL_SPACING = 1.5f;
const float HALF_ROI_WIDTH = 100.0f;
const unsigned int DRAINAGE_TIME = 180000; // 3 minitues
const size_t PREVIEW_ROW = 140;
const size_t PREVIEW_COL = 140;
const float PIXEL_SPACING = 1.5f;
const float HALF_ROI_WIDTH = 100.0f;
const unsigned int DRAINAGE_TIME = 180000; // 3 minitues
}
ScanFormWidget::ScanFormWidget(QWidget* parent)
@@ -41,7 +41,6 @@ ScanFormWidget::ScanFormWidget(QWidget* parent)
, mPatInf(new PatientInformationForm(this))
, mAccountButton(new QToolButton(this))
, mShutdownButton(new QToolButton(this))
, mWorklistButton(new QToolButton(this))
, mStartScanButton(new QToolButton(this))
, mDrainageButton(new QToolButton(this))
, mXYLabel(new CoordinateXYWidget(this))
@@ -59,14 +58,13 @@ ScanFormWidget::ScanFormWidget(QWidget* parent)
initEvents();
mDrainageTimer->setSingleShot(true);
connect(mDrainageTimer, &QTimer::timeout, this, [this]()
{
{
mDrainageButton->click();
});
}
void ScanFormWidget::initCommandWidget(QHBoxLayout *layout)
{
bool anonymousMode = JsonObject::Instance()->getAnonymousMode();
mAccountButton->setObjectName("btnAccount");
mAccountButton->setText(tr("Account"));
layout->addWidget(mAccountButton);
@@ -75,11 +73,6 @@ void ScanFormWidget::initCommandWidget(QHBoxLayout *layout)
mShutdownButton->setText(tr("ShutDown"));
layout->addWidget(mShutdownButton);
mWorklistButton->setObjectName("btnWorklist");
mWorklistButton->setText(tr("Worklist"));
mWorklistButton->setEnabled(!anonymousMode);
layout->addWidget(mWorklistButton);
mStartScanButton->setObjectName("btnScan");
mStartScanButton->setText(tr("Start Scan"));
layout->addWidget(mStartScanButton);
@@ -95,7 +88,7 @@ void ScanFormWidget::initCommandWidget(QHBoxLayout *layout)
layout->addWidget(mDrainageButton);
connect(mDrainageButton, &QToolButton::clicked, [=](bool aSatus)
{
{
//Drainage
if(aSatus && DialogManager::Default()->requestAlertMessage(tr("Make sure to open the drain valve ?"), DialogButtonMode::OkAndCancel, tr("Confirm Drainage")) == QDialog::Rejected)
{
@@ -122,7 +115,7 @@ void ScanFormWidget::initCommandWidget(QHBoxLayout *layout)
});
connect(DeviceManager::Default(), &DeviceManager::startPumpControlResult, [this](bool aIsSucessful)
{
{
mDrainageButton->setEnabled(true);
if(!aIsSucessful)
{
@@ -143,23 +136,16 @@ void ScanFormWidget::initCommandWidget(QHBoxLayout *layout)
connect(mAccountButton, &QToolButton::clicked, DialogManager::Default(),&DialogManager::requestEditSelfAccount);
connect(mShutdownButton, &QToolButton::clicked, []()
{
{
if(DialogManager::Default()->requestAlertMessage(QString(tr("Shut down now ?")), DialogButtonMode::OkAndCancel,tr("Shut Down")) == QDialog::Accepted)
{
LOG_USER_OPERATION("Shut Down")
EventCenter::Default()->triggerEvent(GUIEvents::RequestShutdown, nullptr, nullptr);
EventCenter::Default()->triggerEvent(GUIEvents::RequestShutdown, nullptr, nullptr);
}
});
connect(mWorklistButton, &QToolButton::clicked, [&]()
{
DialogManager::Default()->requestGetWorkList();
});
connect(EventCenter::Default(), &EventCenter::AnonymousModeChanged, this, &ScanFormWidget::updateDataByAnonymousMode);
connect(mStartScanButton, &QToolButton::clicked, [this]()
{
{
if(mStartScanButton->isChecked())
{
LOG_USER_OPERATION(QString("Start Scan Process, ID: %1").arg(mPatInf->getPatientID()));
@@ -173,19 +159,24 @@ void ScanFormWidget::initCommandWidget(QHBoxLayout *layout)
}
});
connect(DeviceManager::Default(), &DeviceManager::startAutoLocateResult, [this]()
{
mWorklistButton->setEnabled(false);
mAccountButton->setEnabled(false);
mDrainageButton->setEnabled(false);
mShutdownButton->setEnabled(false);
mStartScanButton->setText(tr("Stop Scan Process"));
mScanProcessLabel->setText(getAutoLocateMessage());
connect(DeviceManager::Default(), &DeviceManager::startAutoLocateResult, [this](bool aResult)
{
if(aResult)
{
mAccountButton->setEnabled(false);
mDrainageButton->setEnabled(false);
mShutdownButton->setEnabled(false);
mStartScanButton->setText(tr("Stop Scan Process"));
mScanProcessLabel->setText(getAutoLocateMessage());
}
QPair<AccessionInformation*, ScanPosition> accession = ScanProcessSequence::getInstance()->topAccession();
mPatInf->setExecuteProtocol(accession.second == ScanPosition::Left);
mPatInf->setAccessionNumber(accession.first);
});
connect(EventCenter::Default(), &EventCenter::StopScanProcess, [this]()
{
mWorklistButton->setEnabled(true);
{
mAccountButton->setEnabled(true);
mDrainageButton->setEnabled(true);
mShutdownButton->setEnabled(true);
@@ -200,12 +191,12 @@ void ScanFormWidget::initCommandWidget(QHBoxLayout *layout)
});
connect(EventCenter::Default(), &EventCenter::RequestPatientScan, [this]()
{
{
mScanProcessLabel->setText(tr("Data scanning, please keep the current position and don't move."));
});
connect(ScanProcessSequence::getInstance(), &ScanProcessSequence::fullScanDataExport, [this]()
{
{
mScanProcessLabel->setText(tr("Data exporting, patient can leave the holder"));
});
@@ -250,44 +241,6 @@ void ScanFormWidget::initScanContent()
}
void ScanFormWidget::initScanControlBar(QHBoxLayout *layout)
{
// connect(mBtnEScan, &QToolButton::clicked, [=]() {
// int result = DialogManager::Default()->requestAlertMessage(tr("Please make sure the holder is only contain water!"),DialogButtonMode::OkAndCancel,tr("Confirm Scan"));
// if (result != QDialog::Accepted)return;
// QString patientInf(mPatInf->getCurrentPatientJsonString(true));
// LOG_USER_OPERATION("Start Empty Scan")
// EventCenter::Default()->triggerEvent(RequestEmptyScan, nullptr, (QObject*)(&patientInf));
// });
// connect(mBtnPreview, &QToolButton::clicked, [=]() {
// LOG_USER_OPERATION(QString("Start Preview, ID: %1").arg(mPatInf->getPatientID()))
// EventCenter::Default()->triggerEvent(RequestPreviewScan, nullptr, nullptr);
// });
// connect(mBtnScan, &QToolButton::clicked, [=]() {
// if(JsonObject::Instance()->getScanConfirm())
// {
// int ret = DialogManager::Default()->requestPatientConfirm(mPatInf->getPatientInformation(),mPatInf->getProtocol());
// if (ret != QDialog::Accepted) return;
// }
// QString patientInf(mPatInf->getCurrentPatientJsonString(false));
// LOG_USER_OPERATION(QString("Start Scan, ID: %1").arg(mPatInf->getPatientID()))
// if (!DeviceManager::Default()->hasValidEmptyScan()){
// QString msg(tr("No refresh data exists, please do Refresh operation first."));
// EventCenter::Default()->triggerEvent(DeviceErrorRaise, nullptr, (QObject*)(&msg));
// return;
// }
// EventCenter::Default()->triggerEvent(RequestPatientScan, nullptr, (QObject*)(&patientInf));
// });
// connect(mBtnStop, &QToolButton::clicked, [=]() {
// LOG_USER_OPERATION("Stop Preview")
// EventCenter::Default()->triggerEvent(RequestPreviewStop, nullptr, nullptr);
// });
}
void ScanFormWidget::protocolChanged(int type)
{
LOG_USER_OPERATION(QString("Select Laterality %1").arg(type == 0 ? "Left" : "Right"));
@@ -295,8 +248,6 @@ void ScanFormWidget::protocolChanged(int type)
void ScanFormWidget::prepareStartFullScan()
{
ScanPosition position = ScanProcessSequence::getInstance()->topPosition();
mPatInf->setExecuteProtocol(position == ScanPosition::Left);
QString patientInf(mPatInf->getCurrentPatientJsonString(false));
LOG_USER_OPERATION(QString("Start Scan, ID: %1").arg(mPatInf->getPatientID()))
EventCenter::Default()->triggerEvent(RequestPatientScan, nullptr, (QObject*)(&patientInf));
@@ -379,34 +330,19 @@ void ScanFormWidget::initEvents()
connect(EventCenter::Default(), &EventCenter::PatientSelected, [=](QObject* sender, QObject* data) {
if (data)
{
PatientInformation* patientInfo = (PatientInformation*)data;
DialogResult result = DialogManager::Default()->reuqestConfirmStartScan(patientInfo);
if(result.ResultCode == QDialog::Accepted)
{
ScanProtocal protocal = static_cast<ScanProtocal>(result.ResultData.toInt());
mPatInf->setPatientInformation(patientInfo->Copy(), protocal);
setScanProtocal(protocal);
LOG_USER_OPERATION(QString("Select Patient, ID: %1").arg(patientInfo->ID))
if (JsonObject::Instance()->getMppsOpen() && !patientInfo->SPSID.isEmpty() && patientInfo->MPPSUID.isEmpty())
{
MPPSManager::getInstance()->setPatientUID(patientInfo->PatientUID);
}
mStartScanButton->setEnabled(true);
EventCenter::Default()->triggerEvent(SetSelectedPatient, nullptr, patientInfo);
mStartScanButton->click();
PatientInformation* patientInfo = (PatientInformation*)data;
DialogResult result = DialogManager::Default()->reuqestConfirmStartScan(patientInfo);
if(result.ResultCode == QDialog::Accepted)
{
ScanProtocal protocal = static_cast<ScanProtocal>(result.ResultData.toInt());
mPatInf->setPatientInformation(patientInfo);
setScanProtocal(patientInfo, protocal);
LOG_USER_OPERATION(QString("Select Patient, ID: %1").arg(patientInfo->ID))
mStartScanButton->setEnabled(true);
EventCenter::Default()->triggerEvent(SetSelectedPatient, nullptr, (QObject*)patientInfo);
mStartScanButton->click();
}
// mBtnScan->setEnabled(true);
// mBtnEScan->setEnabled(true);
// mBtnPreview->setEnabled(true);
// mBtnStop->setEnabled(true);
}
else{
// mBtnScan->setEnabled(false);
// mBtnEScan->setEnabled(false);
// mBtnPreview->setEnabled(false);
// mBtnStop->setEnabled(false);
}
}
});
connect(EventCenter::Default(), &EventCenter::ResponseStopPreview, [=](QObject* sender, QObject* data) {
@@ -424,18 +360,11 @@ void ScanFormWidget::reloadLanguage()
{
mAccountButton->setText(tr("Account"));
mShutdownButton->setText(tr("ShutDown"));
mWorklistButton->setText(tr("Worklist"));
mStartScanButton->setText(tr("Start Scan"));
mScanProcessLabel->setText(tr("Please confirm checking patient information to start the process"));
mDrainageButton->isChecked() ? mDrainageButton->setText(tr("Drainaging")) : mDrainageButton->setText(tr("Drainage"));
}
void ScanFormWidget::updateDataByAnonymousMode()
{
bool anonymousMode = JsonObject::Instance()->getAnonymousMode();
mWorklistButton->setEnabled(!anonymousMode);
}
QString ScanFormWidget::getAutoLocateMessage()
{
ScanPosition position = ScanProcessSequence::getInstance()->topPosition();
@@ -449,84 +378,26 @@ QString ScanFormWidget::getAutoLocateMessage()
return QString("");
}
void ScanFormWidget::setScanProtocal(int aProtocal)
void ScanFormWidget::setScanProtocal(PatientInformation* aPatient, int aProtocal)
{
ScanProcessSequence::getInstance()->clear();
switch (aProtocal)
{
case ScanProtocal::LSTAND:
ScanProcessSequence::getInstance()->pushPosition(ScanPosition::Right);
ScanProcessSequence::getInstance()->pushPosition(ScanPosition::Left);
ScanProcessSequence::getInstance()->pushAccession(aPatient->findSelectedAccession(ScanRight, false), ScanPosition::Right);
ScanProcessSequence::getInstance()->pushAccession(aPatient->findSelectedAccession(ScanLeft, true), ScanPosition::Left);
return;
case ScanProtocal::RSTAND:
ScanProcessSequence::getInstance()->pushPosition(ScanPosition::Left);
ScanProcessSequence::getInstance()->pushPosition(ScanPosition::Right);
ScanProcessSequence::getInstance()->pushAccession(aPatient->findSelectedAccession(ScanLeft, false), ScanPosition::Left);
ScanProcessSequence::getInstance()->pushAccession(aPatient->findSelectedAccession(ScanRight, true), ScanPosition::Right);
return;
case ScanProtocal::LONE:
ScanProcessSequence::getInstance()->pushPosition(ScanPosition::Left);
ScanProcessSequence::getInstance()->pushAccession(aPatient->findSelectedAccession(ScanLeft, true), ScanPosition::Left);
return;
case ScanProtocal::RONE:
ScanProcessSequence::getInstance()->pushPosition(ScanPosition::Right);
ScanProcessSequence::getInstance()->pushAccession(aPatient->findSelectedAccession(ScanRight, true), ScanPosition::Right);
return;
default:
return;
}
}
void ScanFormWidget::keyPressEvent(QKeyEvent* aEvent)
{
switch (aEvent->key())
{
case Qt::Key_0:
case Qt::Key_1:
case Qt::Key_2:
case Qt::Key_3:
case Qt::Key_4:
case Qt::Key_5:
case Qt::Key_6:
case Qt::Key_7:
case Qt::Key_8:
case Qt::Key_9:
case Qt::Key_A:
case Qt::Key_B:
case Qt::Key_C:
case Qt::Key_D:
case Qt::Key_E:
case Qt::Key_F:
case Qt::Key_G:
case Qt::Key_H:
case Qt::Key_I:
case Qt::Key_J:
case Qt::Key_K:
case Qt::Key_L:
case Qt::Key_M:
case Qt::Key_N:
case Qt::Key_O:
case Qt::Key_P:
case Qt::Key_Q:
case Qt::Key_R:
case Qt::Key_S:
case Qt::Key_T:
case Qt::Key_U:
case Qt::Key_V:
case Qt::Key_W:
case Qt::Key_X:
case Qt::Key_Y:
case Qt::Key_Z:
{
WorkListManager::getInstance()->setSearchString(aEvent->text());
break;
}
case Qt::Key_Enter:
case Qt::Key_Return:
{
QString text = WorkListManager::getInstance()->getSearchString();
EventCenter::Default()->triggerEvent(InputWorkListSearchValue, nullptr, (QObject*)&text);
break;
}
default:
break;
}
QWidget::keyPressEvent(aEvent);
}

View File

@@ -7,6 +7,7 @@
#include <QStack>
class PatientInformationForm;
class PatientInformation;
class QToolButton;
class CoordinateXYWidget;
class CoordinateZWidget;
@@ -18,16 +19,12 @@ public:
~ScanFormWidget() override = default;
void setPreviewing(bool val);
protected:
void keyPressEvent(QKeyEvent *event) override;
private:
PatientInformationForm* mPatInf= nullptr;
bool mUnInited = true;
int mCurrentFrame = 0;
QToolButton* mAccountButton;
QToolButton* mShutdownButton;
QToolButton* mWorklistButton;
QToolButton* mStartScanButton;
QToolButton* mDrainageButton;
CoordinateXYWidget* mXYLabel;
@@ -36,19 +33,16 @@ private:
QTimer* mDrainageTimer;
void initCommandWidget(QHBoxLayout *layout);
void initScanControlBar(QHBoxLayout *layout);
void initScanContent();
void renderLoading();
void renderPreviewData(const QObject* sender, const QObject *data);
void reloadLanguage();
void setScanProtocal(int aProtocal);
void setScanProtocal(PatientInformation* aPatient, int aProtocal);
QString getAutoLocateMessage();
private slots:
void protocolChanged(int type);
void updateDataByAnonymousMode();
void prepareStartFullScan();
//void updateScanProcessLabel(const QString& aText);
void initEvents();
};

View File

@@ -0,0 +1,7 @@
#include "AbstractPatientInfomation.h"
AbstractPatientInfomation::AbstractPatientInfomation(QObject* aParent)
: QObject (aParent)
{
}

View File

@@ -0,0 +1,21 @@
#ifndef ABSTRACTPATIENTINFOMATION_H
#define ABSTRACTPATIENTINFOMATION_H
#include <QObject>
class AbstractPatientInfomation : public QObject
{
Q_OBJECT
public:
enum AbstractInformationType
{
AccessionType = 0, PatientType
};
AbstractPatientInfomation(QObject* aParent);
virtual ~AbstractPatientInfomation() = default;
virtual int getType() = 0;
};
#endif // ABSTRACTPATIENTINFOMATION_H

View File

@@ -0,0 +1,50 @@
#include "AccessionInformation.h"
AccessionInformation::AccessionInformation(PatientInformation* aPatient, QObject* aParent)
: AbstractPatientInfomation (aParent)
, mPatient(aPatient)
{
}
AccessionInformation::AccessionInformation(const QString& aAccessionNumber, const ScanProtocol& aPosition, const QString& aScheduledStartDate, PatientInformation* aPatient, QObject* aParent)
: AbstractPatientInfomation(aParent)
, mAccessionNumber(aAccessionNumber)
, mPosition(aPosition)
, mScheduledStartDate(aScheduledStartDate)
, mPatient(aPatient)
{
}
AccessionInformation::AccessionInformation(const QString& aAccessionNumber, const ScanProtocol& aPosition, const QString& aScheduledStartDate,
const QString& aStudyUID, const QString& aRPID, const QString& aSPSID, const QString& aModality,
const QString& aMPPSUID, PatientInformation* aPatient, QObject* aParent)
: AbstractPatientInfomation(aParent)
, mAccessionNumber(aAccessionNumber)
, mPosition(aPosition)
, mScheduledStartDate(aScheduledStartDate)
, mStudyUID(aStudyUID)
, mRPID(aRPID)
, mSPSID(aSPSID)
, mModality(aModality)
, mMPPSUID(aMPPSUID)
, mPatient(aPatient)
{
}
QString AccessionInformation::getProtocolText()
{
switch (mPosition)
{
case ScanLeft: return "L";
case ScanRight: return "R";
case ScanLeftRight: return "LR";
case UnKnow:return tr("Position");
default: return "";
}
}
int AccessionInformation::getType()
{
return AccessionType;
}

View File

@@ -0,0 +1,42 @@
#ifndef ACCESSIONINFORMATION_H
#define ACCESSIONINFORMATION_H
#include "AbstractPatientInfomation.h"
enum ScanProtocol
{
ScanNone = 0x00000000,
ScanLeft = 0x00000001,
ScanRight = 0x00000002,
ScanLeftRight = 0x00000003,
UnKnow = -1,
};
Q_DECLARE_FLAGS(ScanProtocols, ScanProtocol)
Q_DECLARE_OPERATORS_FOR_FLAGS(ScanProtocols)
class PatientInformation;
class AccessionInformation : public AbstractPatientInfomation
{
Q_OBJECT
public:
AccessionInformation(PatientInformation* aPatient, QObject* aParent);
AccessionInformation(const QString& aAccessionNumber, const ScanProtocol& aPosition, const QString& aScheduledStartDate, PatientInformation* aPatient, QObject* aParent);
AccessionInformation(const QString& aAccessionNumber, const ScanProtocol& aPosition, const QString& aScheduledStartDate,
const QString& aStudyUID, const QString& aRPID, const QString& aSPSID, const QString& aModality,
const QString& aMPPSUID, PatientInformation* aPatient, QObject* aParent);
QString getProtocolText();
virtual int getType() override;
QString mAccessionNumber;
ScanProtocol mPosition;
QString mScheduledStartDate;
QString mStudyUID;
QString mRPID;
QString mSPSID;
QString mModality;
QString mMPPSUID;
PatientInformation* mPatient;
};
#endif // ACCESSIONINFORMATION_H

View File

@@ -12,43 +12,82 @@
#include "event/EventCenter.h"
PatientDetailForm::PatientDetailForm(QWidget* parent) :
QWidget(parent)
, mLblPatInfTitle(new QLabel(this))
, mLblDOB(new QLabel(this))
, mLblName(new QLabel(this))
, mLblPatID(new QLabel(this))
, mLblSex(new QLabel(this))
, mLblAccno(new QLabel(this))
, mLblAddDate(new QLabel(this))
PatientDetailLabel::PatientDetailLabel(QLabel* aTitle, QLabel* aText)
: mLayout(new QHBoxLayout)
, mTitle(aTitle)
, mText(aText)
{
mTitle->setObjectName("displayTitle");
mText->setObjectName("displayDetail");
mLayout->addWidget(mTitle);
mLayout->addWidget(mText);
}
void PatientDetailLabel::hide()
{
mTitle->hide();
mText->hide();
}
void PatientDetailLabel::show()
{
mTitle->show();
mText->show();
}
void PatientDetailLabel::setText(const QString &aText)
{
mText->setText(aText);
}
void PatientDetailLabel::setTitle(const QString &aTitle)
{
mTitle->setText(aTitle);
}
void PatientDetailLabel::clear()
{
mText->clear();
}
void PatientDetailLabel::setLayout(QVBoxLayout* aLayout)
{
aLayout->addLayout(mLayout);
}
PatientDetailForm::PatientDetailForm(QWidget* parent)
: QWidget(parent)
, mLblPatInfTitle(new QLabel(this))
, mLblDOB(new PatientDetailLabel(new QLabel(tr("Birth Date")+":" ,this), new QLabel(this)))
, mLblName(new PatientDetailLabel(new QLabel(tr("Name")+":", this), new QLabel(this)))
, mLblPatID(new PatientDetailLabel(new QLabel(tr("PatientID")+":",this), new QLabel(this)))
, mLblSex(new PatientDetailLabel(new QLabel(tr("Gender")+":",this), new QLabel(this)))
, mLblAccno1(new PatientDetailLabel(new QLabel(tr("AccNo")+":",this), new QLabel(this)))
, mLblProto1(new PatientDetailLabel(new QLabel(tr("Position")+":",this), new QLabel(this)))
, mLblAccno2(new PatientDetailLabel(new QLabel(tr("AccNo")+":",this), new QLabel(this)))
, mLblProto2(new PatientDetailLabel(new QLabel(tr("Position")+":",this), new QLabel(this)))
, mLblAddDate(new PatientDetailLabel(new QLabel(tr("Add Date")+":",this), new QLabel(this)))
{
mLblPatInfTitle->setObjectName("PatInfTitle");
mLblDOB->setObjectName("displayDetail");
mLblName->setObjectName("displayDetail");
mLblPatID->setObjectName("displayDetail");
mLblSex->setObjectName("displayDetail");
mLblAccno->setObjectName("displayDetail");
mLblAddDate->setObjectName("displayDetail");
auto layout = new QVBoxLayout(this);
// mLblPatInfTitle->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
mLblPatInfTitle->setAlignment(Qt::AlignCenter);
layout->addWidget(mLblPatInfTitle);
mLblPatInfTitle->setText(tr("Patient Detail"));
addDetailLabel(layout,tr("Name")+":", mLblName);
addDetailLabel(layout,tr("Gender")+":", mLblSex);
addDetailLabel(layout,tr("Birth Date")+":", mLblDOB);
addDetailLabel(layout,tr("PatientID")+":", mLblPatID);
addDetailLabel(layout,tr("AccNo")+":", mLblAccno);
auto widgetLayout = new QHBoxLayout;
layout->addLayout(widgetLayout);
mLblAddDateTitle = new QLabel(tr("Add Date")+":",this);
mLblAddDateTitle->setObjectName("displayTitle");
widgetLayout->addWidget(mLblAddDateTitle);
widgetLayout->addWidget(mLblAddDate);
mLblName->setLayout(layout);
mLblSex->setLayout(layout);
mLblDOB->setLayout(layout);
mLblPatID->setLayout(layout);
mLblAccno1->setLayout(layout);
mLblAccno1->hide();
mLblProto1->setLayout(layout);
mLblProto1->hide();
mLblAccno2->setLayout(layout);
mLblAccno2->hide();
mLblProto2->setLayout(layout);
mLblProto2->hide();
mLblAddDate->setLayout(layout);
connect(EventCenter::Default(), &EventCenter::ReloadLanguage, this,&PatientDetailForm::reloadLanguage);
layout->addSpacerItem(new QSpacerItem(2,2,QSizePolicy::Expanding, QSizePolicy::Expanding));
@@ -66,15 +105,19 @@ void PatientDetailForm::addDetailLabel(QVBoxLayout *layout, const QString& aTitl
widgetLayout->addWidget(aLabel);
}
void PatientDetailForm::reloadLanguage() {
mLblSex->setText(mStore.Sex == "F" ? tr("Female") : (mStore.Sex == "M" ? tr("Male") : tr("Other")));
QList<std::string> strArray = {"Name","Gender","Birth Date","PatientID","AccNo"};
for (size_t i = 0; i < strArray.length(); i++)
{
mBtnList[i]->setText(tr(strArray[i].data())+":");
}
mLblAddDateTitle->setText(tr("Add Date")+":");
void PatientDetailForm::reloadLanguage()
{
mLblSex->setText(mStore.Sex == "F" ? tr("Female") : (mStore.Sex == "M" ? tr("Male") : mStore.Sex == "O" ? tr("Other") : ""));
mLblPatInfTitle->setText(tr("Patient Detail"));
mLblDOB->setTitle(tr("Birth Date")+":");
mLblName->setTitle(tr("Name")+":");
mLblPatID->setTitle(tr("PatientID")+":");
mLblSex->setTitle(tr("Gender")+":");
mLblAccno1->setTitle(tr("AccNo")+":");
mLblProto1->setTitle(tr("Position")+":");
mLblAccno2->setTitle(tr("AccNo")+":");
mLblProto2->setTitle(tr("Position")+":");
mLblAddDate->setTitle(tr("Add Date")+":");
}
@@ -83,38 +126,83 @@ PatientDetailForm::~PatientDetailForm()
}
void PatientDetailForm::setPatientInformation(PatientInformation* information) {
if (information)
{
mLblPatID->setText(information->ID);
mLblDOB->setText(information->BirthDate);
mLblName->setText(information->Name);
mLblSex->setText((information->Sex == "F" ? tr("Female") : (information->Sex == "M" ? tr("Male") : tr("Other"))));
mCurrentPatientUID = information->PatientUID;
mLblAddDate->setText(QDateTime::fromString(information->AddDate, Qt::ISODate).toString("yyyy-MM-dd HH:mm:ss"));
mLblAccno->setText(information->AccessionNumber);
mStore = *information;
}
}
void PatientDetailForm::clearPatientInformation() {
mLblPatID->clear();
mLblDOB->clear();
mLblName->clear();
mLblDOB->clear();
mLblName->clear();
mLblSex->clear();
mLblAddDate->clear();
mLblAccno->clear();
mLblAddDate->clear();
mLblAccno1->clear();
mLblProto1->clear();
mLblAccno2->clear();
mLblProto2->clear();
}
void PatientDetailForm::confirmModeOn(int protocol)
{
mLblPatInfTitle->setText(tr("Scan with this Patient?"));
mLblAddDate->setText((protocol==0?tr("Left"):tr("Right")));
mLblAddDateTitle->setText(tr("Protocol"));
}
void PatientDetailForm::storePatientInformation() {
void PatientDetailForm::setEmptyInformation()
{
mStore.clear();
mLblPatID->setText("");
mLblDOB->setText("");
mLblName->setText("");
mLblSex->setText("");
mCurrentPatientUID = "";
mLblAddDate->setText("");
mLblAccno1->hide();
mLblProto1->hide();
mLblAccno2->hide();
mLblProto2->hide();
}
PatientInformation* PatientDetailForm::getPatientInformation()
{
return &mStore;
}
void PatientDetailForm::setPatientInformation(PatientInformation* aInformation)
{
if(aInformation == nullptr)
{
setEmptyInformation();
return;
}
mStore = *aInformation;
mLblPatID->setText(aInformation->ID);
mLblDOB->setText(aInformation->BirthDate);
mLblName->setText(aInformation->Name);
mLblSex->setText((aInformation->Sex == "F" ? tr("Female") : (aInformation->Sex == "M" ? tr("Male") : tr("Other"))));
//mCurrentPatientUID = information->PatientUID;
mLblAddDate->setText(QDateTime::fromString(aInformation->AddDate, Qt::ISODate).toString("yyyy-MM-dd HH:mm:ss"));
int selectAccesionSize = aInformation->mSelectedAccessions.size();
if(selectAccesionSize == 1)
{
mLblAccno1->setText(aInformation->mSelectedAccessions[0]->mAccessionNumber);
mLblProto1->setText(aInformation->mSelectedAccessions[0]->getProtocolText());
mLblAccno1->show();
mLblProto1->show();
mLblAccno2->hide();
mLblProto2->hide();
return;
}
else if(selectAccesionSize == 2)
{
mLblAccno1->setText(aInformation->mSelectedAccessions[0]->mAccessionNumber);
mLblProto1->setText(aInformation->mSelectedAccessions[0]->getProtocolText());
mLblAccno2->setText(aInformation->mSelectedAccessions[1]->mAccessionNumber);
mLblProto2->setText(aInformation->mSelectedAccessions[1]->getProtocolText());
mLblAccno1->show();
mLblProto1->show();
mLblAccno2->show();
mLblProto2->show();
return;
}
mLblAccno1->hide();
mLblProto1->hide();
mLblAccno2->hide();
mLblProto2->hide();
}

View File

@@ -3,9 +3,29 @@
#include <QWidget>
#include "PatientInformation.h"
#include "WorklistTableModel.h"
class QToolButton;
class QLabel;
class QVBoxLayout;
class QHBoxLayout;
class PatientDetailLabel
{
public:
PatientDetailLabel(QLabel* aTitle, QLabel* aText);
void show();
void hide();
void setText(const QString& aText);
void setTitle(const QString& aTitle);
void clear();
void setLayout(QVBoxLayout* aLayout);
private:
QHBoxLayout* mLayout;
QLabel* mTitle;
QLabel* mText;
};
class PatientDetailForm : public QWidget
{
@@ -14,32 +34,36 @@ public:
explicit PatientDetailForm(QWidget *parent = nullptr);
void addDetailLabel(QVBoxLayout *layout, const QString& aTitleText, QLabel* aLabel);
~PatientDetailForm();
void setPatientInformation(PatientInformation *information);
PatientInformation *getPatientInformation()
{
return &mStore;
}
PatientInformation* getPatientInformation();
void confirmModeOn(int protocol);
void clearPatientInformation();
public slots:
void setPatientInformation(PatientInformation* information);
signals:
void hideBtnClicked();
void editClicked();
void deleteClicked();
private:
void storePatientInformation();
void reloadLanguage();
void setEmptyInformation();
private:
QString mCurrentPatientUID;
QString mAddDate;
PatientInformation mStore;
QLabel* mLblPatInfTitle;
QLabel* mLblDOB;
QLabel* mLblName;
QLabel* mLblPatID;
QLabel* mLblSex;
QLabel* mLblAccno;
QLabel* mLblAddDate;
QLabel* mLblAddDateTitle;
PatientDetailLabel* mLblDOB;
PatientDetailLabel* mLblName;
PatientDetailLabel* mLblPatID;
PatientDetailLabel* mLblSex;
PatientDetailLabel* mLblAccno1;
PatientDetailLabel* mLblProto1;
PatientDetailLabel* mLblAccno2;
PatientDetailLabel* mLblProto2;
PatientDetailLabel* mLblAddDate;
QList<QLabel*> mBtnList;
};

View File

@@ -0,0 +1,232 @@
#include "PatientInformation.h"
PatientInformation::PatientInformation()
: AbstractPatientInfomation(nullptr)
, ID()
, Name()
, BirthDate()
, Sex()
, AddDate()
{
}
PatientInformation::PatientInformation(const QString& aID, const QString& aName, const QString& aGender, const QString& aBirthDate, const QString& aAddDate)
: AbstractPatientInfomation(nullptr)
, mHeader(new AccessionInformation(tr("Accession Number"), ScanProtocol::UnKnow,tr("Scheduled Date"), this, this))
, mAccessionList(QList<AccessionInformation*>()<<mHeader)
, mSelectedScanProtocol(ScanNone)
, mSelectedAccessions()
, mRecommendAccessions()
, ID(aID)
, Name(aName)
, BirthDate(aBirthDate)
, Sex(aGender)
, AddDate(aAddDate)
{
}
void PatientInformation::clear()
{
ID.clear();
Name.clear();
BirthDate.clear();
Sex.clear();
AddDate.clear();
mAccessionList.clear();
mSelectedAccessions.clear();
mRecommendAccessions.clear();
}
void PatientInformation::setAccessionList(const QList<AccessionInformation*> aAccessionList)
{
mAccessionList.append(aAccessionList);
prepareRecommendAccession();
}
void PatientInformation::setAccession(AccessionInformation* aAccession)
{
mAccessionList.append(aAccession);
}
void PatientInformation::prepareRecommendAccession()
{
mRecommendAccessions.clear();
if(mAccessionList.size() < 2)
{
return;
}
for(int i=1; i<mAccessionList.size(); ++i)
{
if(mAccessionList[i]->mPosition & ScanLeftRight)
{
if(!contains(mRecommendAccessions, mAccessionList[i]->mPosition))
{
mRecommendAccessions << mAccessionList[i];
}
}
}
if(mRecommendAccessions.size() == 0)
{
mRecommendAccessions << mAccessionList[1];
}
}
void PatientInformation::selectAccession(AccessionInformation* aAccession)
{
mSelectedAccessions.push_back(aAccession);
mSelectedScanProtocol |= aAccession->mPosition;
}
void PatientInformation::unSelectAccession(AccessionInformation* aAccession)
{
mSelectedAccessions.removeOne(aAccession);
mSelectedScanProtocol &= ~aAccession->mPosition;
}
int PatientInformation::unSelectLastAccession()
{
if(mSelectedAccessions.size() == 0)
{
return -1;
}
AccessionInformation* accession = mSelectedAccessions.takeLast();
mSelectedScanProtocol &= ~accession->mPosition;
return getAccessionIndex(accession);
}
int PatientInformation::unSelectFirstAccession()
{
if(mSelectedAccessions.size() == 0)
{
return -1;
}
AccessionInformation* accession = mSelectedAccessions.takeFirst();
mSelectedScanProtocol &= ~accession->mPosition;
return getAccessionIndex(accession);
}
int PatientInformation::getAccessionIndex(AccessionInformation* aAccession)
{
return mAccessionList.indexOf(aAccession);
}
bool PatientInformation::isSelectedMax(AccessionInformation* aAccession)
{
return mSelectedAccessions.size() >= 2 ||
((mSelectedScanProtocol & ScanLeft) && (mSelectedScanProtocol & ScanRight)) ||
(aAccession->mPosition == ScanLeftRight && mSelectedAccessions.size() !=0);
}
void PatientInformation::clearSelectedAccession()
{
mSelectedAccessions.clear();
mSelectedScanProtocol = ScanNone;
}
bool PatientInformation::contains(ScanProtocol aProtocol)
{
return mSelectedScanProtocol & aProtocol;
}
bool PatientInformation::contains(QList<AccessionInformation*> aAccessions, ScanProtocol aProtocol)
{
bool result = false;
for(int i=0; i<aAccessions.size(); ++i)
{
result |= (aAccessions[i]->mPosition & aProtocol);
}
return result;
}
QList<int> PatientInformation::unSelectAccession(ScanProtocol aPreSelectProtocol)
{
QList<int> result;
for(int i=mSelectedAccessions.size() - 1; i>=0; --i)
{
if(mSelectedAccessions[i]->mPosition & aPreSelectProtocol)
{
result << getAccessionIndex(mSelectedAccessions[i]);
mSelectedScanProtocol &= ~mSelectedAccessions[i]->mPosition;
mSelectedAccessions.removeAt(i);
}
}
return result;
}
QList<int> PatientInformation::getSelectedAccessionIndex()
{
QList<int> result;
for(int i=0; i<mSelectedAccessions.size(); ++i)
{
result << getAccessionIndex(mSelectedAccessions[i]);
}
return result;
}
void PatientInformation::selectRecommendAccessions()
{
clearSelectedAccession();
for(int i=0; i<mRecommendAccessions.size(); ++i)
{
selectAccession(mRecommendAccessions[i]);
}
}
AccessionInformation* PatientInformation::findSelectedAccession(ScanProtocol aProtocol, bool aIfEmptyGetTop)
{
if(mSelectedAccessions.size() == 0)
{
return nullptr;
}
for(int i=0; i<mSelectedAccessions.size(); ++i)
{
if(mSelectedAccessions[i]->mPosition & aProtocol)
{
return mSelectedAccessions[i];
}
}
if(aIfEmptyGetTop)
{
return mSelectedAccessions.first();
}
else
{
return mSelectedAccessions.last();
}
}
void PatientInformation::reloadHeaderLanguage()
{
mHeader->mAccessionNumber = tr("Accession Number");
mHeader->mScheduledStartDate = tr("Scheduled Date");
}
void PatientInformation::operator=(const PatientInformation& aOther)
{
this->PatientUID = aOther.PatientUID;
this->ID = aOther.ID;
this->Name = aOther.Name;
this->BirthDate = aOther.BirthDate;
this->Sex = aOther.Sex;
this->Comment = aOther.Comment;
this->AddDate = aOther.AddDate;
this->mHeader = aOther.mHeader;
this->mAccessionList = aOther.mAccessionList;
this->mSelectedScanProtocol = aOther.mSelectedScanProtocol;
this->mSelectedAccessions = aOther.mSelectedAccessions;
this->mRecommendAccessions = aOther.mRecommendAccessions;
}
QList<AccessionInformation*> PatientInformation::getSelectedAccession()
{
return mSelectedAccessions;
}
int PatientInformation::getType()
{
return PatientType;
}

View File

@@ -3,25 +3,15 @@
#define EDIT_PATIENT()\
ADD_PATIENT_PROPERTY(PatientUID)\
ADD_PATIENT_PROPERTY(ID)\
ADD_PATIENT_PROPERTY(AccessionNumber)\
ADD_PATIENT_PROPERTY(Name)\
ADD_PATIENT_PROPERTY(BirthDate)\
ADD_PATIENT_PROPERTY(Sex)\
ADD_PATIENT_PROPERTY(AddDate)\
#define ADD_PATIENT()\
EDIT_PATIENT()\
ADD_PATIENT_PROPERTY(StudyUID)\
ADD_PATIENT_PROPERTY(RPID)\
ADD_PATIENT_PROPERTY(SPSID)\
ADD_PATIENT_PROPERTY(Modality)\
ADD_PATIENT_PROPERTY(MPPSUID)\
ADD_PATIENT_PROPERTY(Comment)
enum PatientInformationEnum{
#define ADD_PATIENT_PROPERTY(val) val,
ADD_PATIENT()
@@ -30,56 +20,54 @@ enum PatientInformationEnum{
#include <QObject>
#include <QSharedPointer>
#include "AccessionInformation.h"
/**
* @brief this class was designed to be a edit form,
* but now has been change to a detail display class.
*/
class PatientInformation:public QObject{
class PatientInformation : public AbstractPatientInfomation
{
Q_OBJECT
public:
PatientInformation();
PatientInformation(const QString& aID, const QString& aName, const QString& aGender, const QString& aBirthDate, const QString& aAddDate);
void operator=(const PatientInformation& aOther);
int getType() override;
void clear();
void setAccessionList(const QList<AccessionInformation*> aAccessionList);
void setAccession(AccessionInformation* aAccession);
void prepareRecommendAccession();
void selectAccession(AccessionInformation* aAccession);
void unSelectAccession(AccessionInformation* aAccession);
int unSelectLastAccession();
int unSelectFirstAccession();
int getAccessionIndex(AccessionInformation* aAccession);
bool isSelectedMax(AccessionInformation* aAccession);
void clearSelectedAccession();
bool contains(ScanProtocol aProtocol);
bool contains(QList<AccessionInformation*> aAccessions, ScanProtocol aProtocol);
QList<int> unSelectAccession(ScanProtocol aPreSelectProtocol);
QList<int> getSelectedAccessionIndex();
void selectRecommendAccessions();
void reloadHeaderLanguage();
QList<AccessionInformation*> getSelectedAccession();
AccessionInformation* findSelectedAccession(ScanProtocol aProtocol, bool aIfEmptyGetTop);
AccessionInformation* mHeader;
QList<AccessionInformation*> mAccessionList;
ScanProtocols mSelectedScanProtocol;
QList<AccessionInformation*> mSelectedAccessions;
QList<AccessionInformation*> mRecommendAccessions;
#define ADD_PATIENT_PROPERTY(val) QString val;
ADD_PATIENT()
#undef ADD_PATIENT_PROPERTY
PatientInformation()
: QObject()
{
}
void operator=(const PatientInformation& other){
this->PatientUID = other.PatientUID;
this->ID = other.ID;
this->Name = other.Name;
this->BirthDate = other.BirthDate;
this->Sex = other.Sex;
this->Comment = other.Comment;
this->AccessionNumber = other.AccessionNumber;
this->AddDate = other.AddDate;
this->RPID = other.RPID;
this->SPSID = other.SPSID;
this->MPPSUID = other.MPPSUID;
this->StudyUID = other.StudyUID;
this->Modality = other.Modality;
}
QString ScheduledStartDate;
QSharedPointer<PatientInformation> Copy()
{
QSharedPointer<PatientInformation> n= QSharedPointer<PatientInformation>(new PatientInformation);
n->PatientUID = this->PatientUID;
n->ID = this->ID;
n->Name = this->Name;
n->BirthDate = this->BirthDate;
n->Sex = this->Sex;
n->Comment = this->Comment;
n->AccessionNumber = this->AccessionNumber;
n->AddDate = this->AddDate;
n->RPID = this->RPID;
n->SPSID = this->SPSID;
n->MPPSUID = this->MPPSUID;
n->StudyUID = this->StudyUID;
n->Modality = this->Modality;
return n;
}
// QString ScheduledStartDate;
// QString AccessionNumber;
};
typedef QSharedPointer<PatientInformation> PatientInformationPointer;

View File

@@ -2,11 +2,12 @@
#include "SelectFormWidget.h"
#include <QToolButton>
#include <QTableWidget>
#include <QTreeView>
#include <QScroller>
#include <QHeaderView>
#include <QUuid>
#include <QLabel>
#include <QTabWidget>
#include <QDate>
#include <QSqlRecord>
@@ -22,17 +23,30 @@
#include "PatientAddDateDelegate.h"
#include "dicom/WorkListManager.h"
#include "utilities/ScanProcessSequence.h"
#include "WorklistTableView.h"
#include "WorklistTableModel.h"
#include "WorklistTableSelectModel.h"
#include "WorklistTableStyleItemDelegate.h"
#include "action/ActionCreator.h"
#include "action/GetWorkListAction.h"
SelectFormWidget::SelectFormWidget(QWidget* parent)
: TabFormWidget(parent)
, mBtnEdit(new QToolButton())
, mBtnDelete(new QToolButton())
, mBtnAdd(new QToolButton(this))
, mBtnSelect(new QToolButton(this))
, mPatTable(new SlideTableView(this))
, mModel(nullptr)
, patientDetailForm(new PatientDetailForm(this))
, mSelectTabTitle(new QLabel(this))
: TabFormWidget(parent)
, mTabWidget(new QTabWidget(this))
, mSelectedPatientUID()
, mBtnEdit(new QToolButton(this))
, mBtnDelete(new QToolButton(this))
, mBtnAdd(new QToolButton(this))
, mBtnPull(new QToolButton(this))
, mBtnSelect(new QToolButton(this))
, mWorklistPatTable(new WorklistTableView(this))
, mWorklistTableModel(new WorklistTableModel(this))
, mWorklistTableSelectModel(new WorklistTableSelectModel(mWorklistTableModel, mWorklistPatTable))
, mLocalPatTable(new SlideTableView(this))
, mLocalPatientModel(nullptr)
, mPatientDetailForm(new PatientDetailForm(this))
, mSelectTabTitle(new QLabel(this))
, mGetWorklistAction(ActionCreator::getAsyncAction<GetWorkListAction>("GetWorkListAction"))
{
//process expired patient list
QDate date = QDate::currentDate().addDays(-JsonObject::Instance()->getPatientListExpireDays());
@@ -58,13 +72,43 @@ SelectFormWidget::SelectFormWidget(QWidget* parent)
addVerticalLine(contentLayout);
auto gridBox = new QVBoxLayout;
contentLayout->addLayout(gridBox);
initTableView(gridBox);
initTableView();
connect(mWorklistTableSelectModel, &WorklistTableSelectModel::WorklistTableSelectChanged, this, &SelectFormWidget::setWorklistPatientDetail);
mWorklistPatTable->setModel(mWorklistTableModel);
mWorklistPatTable->setSelectionModel(mWorklistTableSelectModel);
mWorklistPatTable->setColumnWidth(0, 300);
mWorklistPatTable->setColumnWidth(1, 300);
mWorklistPatTable->setColumnWidth(2, 300);
mWorklistPatTable->setColumnWidth(3, 200);
mWorklistPatTable->header()->setDefaultAlignment(Qt::AlignCenter);
mWorklistPatTable->setIndentation(0);
mWorklistPatTable->setAlternatingRowColors(true);
mWorklistPatTable->setSelectionMode(QAbstractItemView::MultiSelection);
mWorklistPatTable->setSelectionBehavior(QAbstractItemView::SelectRows);
mWorklistPatTable->setItemDelegate(new WorklistTableStyleItemDelegate(mWorklistPatTable->header(), mWorklistPatTable));
mTabWidget->addTab(mWorklistPatTable,tr("Worklist"));
mTabWidget->addTab(mLocalPatTable, tr("Local"));
gridBox->addWidget(mTabWidget);
gridBox->addWidget(ui->commandWidget);
connect(mTabWidget, &QTabWidget::tabBarClicked, [this](int aIndex)
{
if(aIndex == 0)
{
switchToWorklistMode();
}
else
{
switchToLocalMode();
}
});
//select default row 0
if (mModel->rowCount() > 0)
if (mLocalPatientModel->rowCount() > 0)
{
mPatTable->selectRow(0);
setPatientDetail(mPatTable, mModel, patientDetailForm);
mLocalPatTable->selectRow(0);
setPatientDetail(mLocalPatTable, mLocalPatientModel, mPatientDetailForm);
}
// event ResponsePreview slot
connect(EventCenter::Default(), &EventCenter::ResponsePreview, [=](QObject* sender, QObject* data) {
@@ -86,17 +130,20 @@ SelectFormWidget::SelectFormWidget(QWidget* parent)
});
connect(ScanProcessSequence::getInstance(), &ScanProcessSequence::ScanProcessSequenceFinished, this, &SelectFormWidget::clearSelectedPatient);
connect(mGetWorklistAction, &AsyncAction::actionCompleted, this, &SelectFormWidget::processWorklistSearchResult);
//first prepare buttons!
prepareButtons(false);
//init WorkListManager table view
WorkListManager::getInstance()->setTableView(mPatTable);
WorkListManager::getInstance()->setTableView(mLocalPatTable);
//init in worklist mode bt default
switchToWorklistMode();
}
void SelectFormWidget::prepareButtons(bool disableALL) {
bool anonymousMode = JsonObject::Instance()->getAnonymousMode();
bool stateFlag = (mPatTable->currentIndex().row() >= 0);
bool stateFlag = (mLocalPatTable->currentIndex().row() >= 0);
mBtnAdd->setEnabled(!anonymousMode && !disableALL);
if (mBtnAdd)mBtnEdit->setEnabled(!anonymousMode && stateFlag && !disableALL);
@@ -108,15 +155,18 @@ void SelectFormWidget::initPatEditButtons(QHBoxLayout *layout) {
mBtnAdd->setObjectName("btnAdd");
mBtnEdit->setObjectName("btnPatEdit");
mBtnDelete->setObjectName("btnPatDelete");
mBtnPull->setObjectName("btnAdd");
mBtnSelect->setObjectName("btnSelect");
mBtnEdit->setText(tr("Edit"));
mBtnDelete->setText(tr("Delete"));
mBtnAdd->setText(tr("Add"));
mBtnPull->setText(tr("Pull"));
mBtnSelect->setText(tr("Select"));
layout->addWidget(mBtnAdd);
layout->addWidget(mBtnEdit);
layout->addWidget(mBtnDelete);
layout->addWidget(mBtnPull);
addVerticalLine(layout);
layout->addWidget(mBtnSelect);
@@ -131,51 +181,53 @@ void SelectFormWidget::initPatEditButtons(QHBoxLayout *layout) {
// mBtn select slot
connect(mBtnSelect, &QToolButton::clicked, this, &SelectFormWidget::selectPatient);
connect(mBtnPull, &QToolButton::clicked, this, &SelectFormWidget::pullPatient);
}
void SelectFormWidget::editPatient() {
bool addFlag = sender() == mBtnAdd;
auto index = mPatTable->currentIndex();
auto index = mLocalPatTable->currentIndex();
// accept change
if (DialogManager::Default()->requestEditPatientInfo(addFlag ? nullptr:patientDetailForm->getPatientInformation(),mModel) == QDialog::Accepted) {
if (DialogManager::Default()->requestEditPatientInfo(addFlag ? nullptr:mPatientDetailForm->getPatientInformation(),mLocalPatientModel) == QDialog::Accepted) {
if (addFlag){
mPatTable->selectRow(0);
mModel->selectRow(0);
LOG_USER_OPERATION(QString("Add Patient, ID: %1").arg(patientDetailForm->getPatientInformation()->ID))
mLocalPatTable->selectRow(0);
mLocalPatientModel->selectRow(0);
LOG_USER_OPERATION(QString("Add Patient, ID: %1").arg(mPatientDetailForm->getPatientInformation()->ID))
}
else{
mPatTable->selectRow(index.row());
mModel->selectRow(index.row());
setPatientDetail(mPatTable, mModel, patientDetailForm);
LOG_USER_OPERATION(QString("Edit Patient, ID: %1").arg(patientDetailForm->getPatientInformation()->ID))
mLocalPatTable->selectRow(index.row());
mLocalPatientModel->selectRow(index.row());
setPatientDetail(mLocalPatTable, mLocalPatientModel, mPatientDetailForm);
LOG_USER_OPERATION(QString("Edit Patient, ID: %1").arg(mPatientDetailForm->getPatientInformation()->ID))
}
mBtnSelect->setEnabled(true);
}
}
void SelectFormWidget::delPatient() {
if (mPatTable->currentIndex().row() < 0) return;
QString pUid = mModel->index(mPatTable->currentIndex().row(), PatientUID).data().toString();
if (mLocalPatTable->currentIndex().row() < 0) return;
QString pUid = mLocalPatientModel->index(mLocalPatTable->currentIndex().row(), PatientUID).data().toString();
// patient has been selected as the scan patient!
if (mSelectedPatientUID == pUid){
DialogManager::Default()->requestAlertMessage(tr("Can't delete selected Patient !"),DialogButtonMode::OkOnly,tr("Alert"));
return;
}
// not the selected one, confirm!
QString pat_name = mModel->index(mPatTable->currentIndex().row(), Name).data().toString();
QString pat_name = mLocalPatientModel->index(mLocalPatTable->currentIndex().row(), Name).data().toString();
if (DialogManager::Default()->requestAlertMessage(QString(tr("Delete Patient \"%1\" ?")),pat_name,DialogButtonMode::OkAndCancel,tr("Confirm")) != QDialog::Accepted) return;
// need delete clear edit panel detail
patientDetailForm->clearPatientInformation();
//mModel->setData(mModel->index(mPatTable->currentIndex().row(), Flag), 9);
mModel->removeRow(mPatTable->currentIndex().row());
mPatientDetailForm->clearPatientInformation();
//mLocalPatientModel->setData(mLocalPatientModel->index(mLocalPatTable->currentIndex().row(), Flag), 9);
mLocalPatientModel->removeRow(mLocalPatTable->currentIndex().row());
if (mModel->submitAll()) {
mModel->select();
if (mModel->rowCount() > 0) {
mPatTable->selectRow(0);
mModel->selectRow(0);
setPatientDetail(mPatTable, mModel, patientDetailForm);
LOG_USER_OPERATION(QString("Delete Patient, ID: %1").arg(patientDetailForm->getPatientInformation()->ID))
if (mLocalPatientModel->submitAll()) {
mLocalPatientModel->select();
if (mLocalPatientModel->rowCount() > 0) {
mLocalPatTable->selectRow(0);
mLocalPatientModel->selectRow(0);
setPatientDetail(mLocalPatTable, mLocalPatientModel, mPatientDetailForm);
LOG_USER_OPERATION(QString("Delete Patient, ID: %1").arg(mPatientDetailForm->getPatientInformation()->ID))
}
} else {
//TODO:error handle
@@ -185,7 +237,7 @@ void SelectFormWidget::delPatient() {
}
void SelectFormWidget::selectPatient() {
EventCenter::Default()->triggerEvent(PatientSelected, nullptr, (QObject*)patientDetailForm->getPatientInformation());
EventCenter::Default()->triggerEvent(PatientSelected, nullptr, (QObject*)mPatientDetailForm->getPatientInformation());
}
void SelectFormWidget::setSelectedPatient(PatientInformation* aPatient)
@@ -199,93 +251,88 @@ void SelectFormWidget::clearSelectedPatient()
}
void SelectFormWidget::initDetailPanel(QHBoxLayout *contentLayout) {// prepare edit panel
patientDetailForm->setObjectName("patientDetailWidget");
contentLayout->addWidget(patientDetailForm);
mPatientDetailForm->setObjectName("patientDetailWidget");
contentLayout->addWidget(mPatientDetailForm);
}
void SelectFormWidget::initTableView(QLayout *contentLayout)
void SelectFormWidget::initTableView()
{
// TableView for patient
mPatTable->setAlternatingRowColors(true);
mPatTable->setSelectionMode(QAbstractItemView::SingleSelection);
mPatTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
mPatTable->setSelectionBehavior(QAbstractItemView::SelectRows);
mPatTable->verticalHeader()->setDefaultSectionSize(38);
mPatTable->horizontalHeader()->setStretchLastSection(true);
mLocalPatTable->setAlternatingRowColors(true);
mLocalPatTable->setSelectionMode(QAbstractItemView::SingleSelection);
mLocalPatTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
mLocalPatTable->setSelectionBehavior(QAbstractItemView::SelectRows);
mLocalPatTable->verticalHeader()->setDefaultSectionSize(38);
mLocalPatTable->horizontalHeader()->setStretchLastSection(true);
//avoid pan comsumed by tableview!
mPatTable->viewport()->ungrabGesture(Qt::PanGesture);
mLocalPatTable->viewport()->ungrabGesture(Qt::PanGesture);
mPatTable->setSortingEnabled(true); // enable sortingEnabled
mPatTable->setModel((QAbstractItemModel*) mModel);
mPatTable->hideColumn(0);
mPatTable->hideColumn(7);
mPatTable->hideColumn(8);
mPatTable->hideColumn(9);
mPatTable->hideColumn(10);
mPatTable->hideColumn(11);
mPatTable->hideColumn(12);
mLocalPatTable->setSortingEnabled(true); // enable sortingEnabled
mLocalPatTable->setModel(mLocalPatientModel);
mLocalPatTable->hideColumn(0);
mLocalPatTable->hideColumn(6);
mLocalPatTable->hideColumn(7);
mLocalPatTable->hideColumn(8);
mLocalPatTable->hideColumn(9);
mLocalPatTable->hideColumn(10);
mLocalPatTable->hideColumn(11);
mPatTable->show();
mLocalPatTable->show();
mPatTable->setColumnWidth(1, 250);
mPatTable->setColumnWidth(2, 250);
mPatTable->setColumnWidth(3, 250);
mPatTable->setColumnWidth(4, 120);
mPatTable->setColumnWidth(5, 80);
mPatTable->setColumnWidth(6, 120);
contentLayout->addWidget(mPatTable);
mLocalPatTable->setColumnWidth(1, 300);
mLocalPatTable->setColumnWidth(2, 300);
mLocalPatTable->setColumnWidth(3, 300);
mLocalPatTable->setColumnWidth(4, 200);
//table current row selection changing event
connect(mPatTable, &SlideTableView::currentRowChanged, [=](int row) {
setPatientDetail(mPatTable, mModel, patientDetailForm);
connect(mLocalPatTable, &SlideTableView::currentRowChanged, [=](int row) {
setPatientDetail(mLocalPatTable, mLocalPatientModel, mPatientDetailForm);
prepareButtons(false);
});
// after sort by column
connect(mPatTable->horizontalHeader(), &QHeaderView::sectionClicked, [=](int index){
patientDetailForm->clearPatientInformation();
connect(mLocalPatTable->horizontalHeader(), &QHeaderView::sectionClicked, [=](int index){
mPatientDetailForm->clearPatientInformation();
prepareButtons(false);
if(mModel->rowCount() > 0){
mPatTable->selectRow(0);
mModel->selectRow(0);
if(mLocalPatientModel->rowCount() > 0){
mLocalPatTable->selectRow(0);
mLocalPatientModel->selectRow(0);
}
});
PatientAddDateDelegate* patientAddDateDelegate = new PatientAddDateDelegate(mPatTable);
mPatTable->setItemDelegateForColumn(6, patientAddDateDelegate);
PatientAddDateDelegate* patientAddDateDelegate = new PatientAddDateDelegate(mLocalPatTable);
mLocalPatTable->setItemDelegateForColumn(5, patientAddDateDelegate);
}
void SelectFormWidget::initDataModel() {
mModel = SQLHelper::getTable("Patient");
WorkListManager::getInstance()->setTableModel(mModel);
mModel->sort(mModel->record().indexOf("AddDate"), Qt::DescendingOrder);
mModel->setEditStrategy(QSqlTableModel::OnManualSubmit);
mLocalPatientModel = SQLHelper::getTable("Patient");
WorkListManager::getInstance()->setTableModel(mLocalPatientModel);
mLocalPatientModel->sort(mLocalPatientModel->record().indexOf("AddDate"), Qt::DescendingOrder);
mLocalPatientModel->setEditStrategy(QSqlTableModel::OnManualSubmit);
bool anonymousMode = JsonObject::Instance()->getAnonymousMode();
if (anonymousMode)
{
mModel->setFilter("1=2");
mLocalPatientModel->setFilter("1=2");
}
mModel->select();
mLocalPatientModel->select();
if (anonymousMode)
{
mModel->insertRow(0);
mModel->setData(mModel->index(0,0),"000000001");
mModel->setData(mModel->index(0,1),"AnonymousPatient");
mModel->setData(mModel->index(0,2),"");
mModel->setData(mModel->index(0,3),"AnonymousPatient");
mModel->setData(mModel->index(0,4),"2000-01-01");
mModel->setData(mModel->index(0,5),"F");
mModel->setData(mModel->index(0,6),"2000-01-01");
mModel->setData(mModel->index(0,7),"");
mLocalPatientModel->insertRow(0);
mLocalPatientModel->setData(mLocalPatientModel->index(0,0),"000000001");
mLocalPatientModel->setData(mLocalPatientModel->index(0,1),"AnonymousPatient");
mLocalPatientModel->setData(mLocalPatientModel->index(0,2),"AnonymousPatient");
mLocalPatientModel->setData(mLocalPatientModel->index(0,3),"2000-01-01");
mLocalPatientModel->setData(mLocalPatientModel->index(0,4),"F");
mLocalPatientModel->setData(mLocalPatientModel->index(0,5),"2000-01-01");
mLocalPatientModel->setData(mLocalPatientModel->index(0,6),"");
}
mModel->setHeaderData(1, Qt::Horizontal, tr("ID"));
mModel->setHeaderData(2, Qt::Horizontal, tr("AccessionNumber"));
mModel->setHeaderData(3, Qt::Horizontal, tr("Name"));
mModel->setHeaderData(4, Qt::Horizontal, tr("Birth Date"));
mModel->setHeaderData(5, Qt::Horizontal, tr("Gender"));
mModel->setHeaderData(6, Qt::Horizontal, tr("Add Date"));
mModel->setHeaderData(7, Qt::Horizontal, tr("Comment"));
mLocalPatientModel->setHeaderData(1, Qt::Horizontal, tr("ID"));
mLocalPatientModel->setHeaderData(2, Qt::Horizontal, tr("Name"));
mLocalPatientModel->setHeaderData(3, Qt::Horizontal, tr("Birth Date"));
mLocalPatientModel->setHeaderData(4, Qt::Horizontal, tr("Gender"));
mLocalPatientModel->setHeaderData(5, Qt::Horizontal, tr("Add Date"));
mLocalPatientModel->setHeaderData(6, Qt::Horizontal, tr("Comment"));
}
void SelectFormWidget::setPatientDetail(const SlideTableView *table, const QSqlTableModel *model,
@@ -296,22 +343,39 @@ void SelectFormWidget::setPatientDetail(const SlideTableView *table, const QSqlT
ADD_PATIENT()
#undef ADD_PATIENT_PROPERTY
edit_patient->setPatientInformation(&pat);
mBtnSelect->setEnabled(true);
}
void SelectFormWidget::setWorklistPatientDetail(PatientInformation* aPatient)
{
mPatientDetailForm->setPatientInformation(aPatient);
if(aPatient == nullptr || aPatient->getSelectedAccessionIndex().size() == 0)
{
mBtnSelect->setEnabled(false);
}
else
{
mBtnSelect->setEnabled(true);
}
}
void SelectFormWidget::reloadLanguage(){
mModel->setHeaderData(1, Qt::Horizontal, "ID");
mModel->setHeaderData(2, Qt::Horizontal, tr("AccessionNumber"));
mModel->setHeaderData(3, Qt::Horizontal, tr("Name"));
mModel->setHeaderData(4, Qt::Horizontal, tr("Birth Date"));
mModel->setHeaderData(5, Qt::Horizontal, tr("Gender"));
mModel->setHeaderData(6, Qt::Horizontal, tr("Add Date"));
mModel->setHeaderData(7, Qt::Horizontal, tr("Comment"));
mLocalPatientModel->setHeaderData(1, Qt::Horizontal, "ID");
mLocalPatientModel->setHeaderData(2, Qt::Horizontal, tr("Name"));
mLocalPatientModel->setHeaderData(3, Qt::Horizontal, tr("Birth Date"));
mLocalPatientModel->setHeaderData(4, Qt::Horizontal, tr("Gender"));
mLocalPatientModel->setHeaderData(5, Qt::Horizontal, tr("Add Date"));
mLocalPatientModel->setHeaderData(6, Qt::Horizontal, tr("Comment"));
mBtnEdit->setText(tr("Edit"));
mBtnDelete->setText(tr("Delete"));
mBtnAdd->setText(tr("Add"));
mBtnSelect->setText(tr("Select"));
mBtnPull->setText(tr("Pull"));
mSelectTabTitle->setText(tr("Patient Information Manage"));
mTabWidget->setTabText(0,tr("Worklist"));
mTabWidget->setTabText(1, tr("Local"));
}
void SelectFormWidget::updateDataByAnonymousMode(){
@@ -319,31 +383,70 @@ void SelectFormWidget::updateDataByAnonymousMode(){
EventCenter::Default()->triggerEvent(GUIEvents::PatientSelected,this,nullptr);
if (anonymousMode)
{
mModel->setFilter("1=2");
mModel->select();
mModel->insertRow(0);
mModel->setData(mModel->index(0,0),"000000001");
mModel->setData(mModel->index(0,1),"AnonymousPatient");
mModel->setData(mModel->index(0,2),"");
mModel->setData(mModel->index(0,3),"AnonymousPatient");
mModel->setData(mModel->index(0,4),"2000-01-01");
mModel->setData(mModel->index(0,5),"M");
mModel->setData(mModel->index(0,6),"2000-01-01");
mModel->setData(mModel->index(0,7),"");
mPatTable->selectRow(0);
mModel->selectRow(0);
mLocalPatientModel->setFilter("1=2");
mLocalPatientModel->select();
mLocalPatientModel->insertRow(0);
mLocalPatientModel->setData(mLocalPatientModel->index(0,0),"000000001");
mLocalPatientModel->setData(mLocalPatientModel->index(0,1),"AnonymousPatient");
mLocalPatientModel->setData(mLocalPatientModel->index(0,2),"");
mLocalPatientModel->setData(mLocalPatientModel->index(0,3),"AnonymousPatient");
mLocalPatientModel->setData(mLocalPatientModel->index(0,4),"2000-01-01");
mLocalPatientModel->setData(mLocalPatientModel->index(0,5),"M");
mLocalPatientModel->setData(mLocalPatientModel->index(0,6),"2000-01-01");
mLocalPatientModel->setData(mLocalPatientModel->index(0,7),"");
mLocalPatTable->selectRow(0);
mLocalPatientModel->selectRow(0);
}
else{
mModel->revertAll();
mModel->setFilter("");
mModel->select();
if (mModel->rowCount()>0){
mPatTable->selectRow(0);
mModel->selectRow(0);
mLocalPatientModel->revertAll();
mLocalPatientModel->setFilter("");
mLocalPatientModel->select();
if (mLocalPatientModel->rowCount()>0){
mLocalPatTable->selectRow(0);
mLocalPatientModel->selectRow(0);
}
}
prepareButtons(false);
}
void SelectFormWidget::switchToWorklistMode()
{
mBtnAdd->hide();
mBtnDelete->hide();
mBtnEdit->hide();
mBtnPull->show();
setWorklistPatientDetail(mWorklistTableSelectModel->getSelectedPatient());
mPatientDetailForm->setPatientInformation(mWorklistTableSelectModel->getSelectedPatient());
}
void SelectFormWidget::switchToLocalMode()
{
mBtnAdd->show();
mBtnDelete->show();
mBtnEdit->show();
mBtnPull->hide();
setPatientDetail(mLocalPatTable, mLocalPatientModel, mPatientDetailForm);
}
void SelectFormWidget::pullPatient()
{
mGetWorklistAction->execute();
DialogManager::Default()->requestLoadingWorklist();
}
void SelectFormWidget::processWorklistSearchResult(const ActionResult& aResult)
{
EventCenter::Default()->triggerEvent(GUIEvents::WorklistSearchFinished, nullptr, nullptr);
mWorklistTableSelectModel->clearSelect();
if(aResult.Code == Sucessed)
{
QList<PatientInformation*> patientList = aResult.Data.value<QList<PatientInformation*>>();
mWorklistTableModel->instertPatients(patientList);
}
else
{
mWorklistTableModel->instertPatients(QList<PatientInformation*>());
DialogManager::Default()->requestAlertMessage(aResult.Data.toString(), DialogButtonMode::OkOnly);
}
}

View File

@@ -6,10 +6,13 @@
#include "dialogs/EditPatientDialog.h"
class PatientDetailForm;
class SlideTableView;
class QToolButton;
class QTabWidget;
class QTreeView;
class WorklistTableModel;
class WorklistTableSelectModel;
class AsyncAction;
class SelectFormWidget : public TabFormWidget {
Q_OBJECT
@@ -20,8 +23,11 @@ public:
public slots:
void updateDataByAnonymousMode();
void processWorklistSearchResult(const ActionResult& aResult);
private:
void setPatientDetail(const SlideTableView *table, const QSqlTableModel *model, PatientDetailForm *edit_patient) const;
void setWorklistPatientDetail(PatientInformation* aPatient);
void prepareButtons(bool disableALL);
void initPatEditButtons(QHBoxLayout *layout);
void editPatient();
@@ -30,20 +36,30 @@ private:
void setSelectedPatient(PatientInformation* aPatient);
void initDataModel();
void initDetailPanel(QHBoxLayout *contentLayout);
void initTableView(QLayout *contentLayout);
void initTableView();
void reloadLanguage();
void clearSelectedPatient();
void switchToWorklistMode();
void switchToLocalMode();
void changeSelectButtonState();
void pullPatient();
private:
QTabWidget* mTabWidget;
QString mSelectedPatientUID;
QToolButton *mBtnEdit;
QToolButton *mBtnDelete;
QToolButton *mBtnAdd;
QToolButton* mBtnPull;
QToolButton *mBtnSelect;
SlideTableView *mPatTable;
QSqlTableModel *mModel;
PatientDetailForm *patientDetailForm;
QTreeView* mWorklistPatTable;
WorklistTableModel* mWorklistTableModel;
WorklistTableSelectModel* mWorklistTableSelectModel;
SlideTableView *mLocalPatTable;
QSqlTableModel *mLocalPatientModel;
PatientDetailForm *mPatientDetailForm;
QLabel* mSelectTabTitle;
AsyncAction* mGetWorklistAction;
};

View File

@@ -0,0 +1,193 @@
#include "WorklistTableModel.h"
#include "event/EventCenter.h"
WorklistTableModel::WorklistTableModel(QObject* aParent)
: QAbstractItemModel(aParent)
, mPatientList()
, mHeader(QStringList()<< tr("ID") << tr("Name") << tr("Birth Date") << tr("Gender") << tr("Add Date"))
{
connect(EventCenter::Default(), &EventCenter::ReloadLanguage, this, &WorklistTableModel::reloadLanguage);
}
WorklistTableModel::~WorklistTableModel()
{
qDeleteAll(mPatientList);
}
QVariant WorklistTableModel::headerData(int aSection, Qt::Orientation aOrientation, int aRole) const
{
if(aOrientation == Qt::Horizontal && aRole == Qt::DisplayRole)
{
if(aSection < mHeader.size())
{
return mHeader[aSection];
}
}
return QVariant();
}
int WorklistTableModel::rowCount(const QModelIndex &aParent) const
{
if (!aParent.isValid())
{
return mPatientList.count();
}
AbstractPatientInfomation* item = static_cast<AbstractPatientInfomation*>(aParent.internalPointer());
if(item->getType() != AbstractPatientInfomation::PatientType)
{
return 0;
}
PatientInformation* patientItem = static_cast<PatientInformation*>(item);
return patientItem->mAccessionList.count();
}
int WorklistTableModel::columnCount(const QModelIndex &aParent) const
{
return mHeader.size();
}
QModelIndex WorklistTableModel::index(int aRow, int aColumn, const QModelIndex &aParent) const
{
if (!hasIndex(aRow, aColumn, aParent))
{
return QModelIndex();
}
if (!aParent.isValid())
{
return createIndex(aRow, aColumn, mPatientList[aRow]);
}
AbstractPatientInfomation* item = static_cast<AbstractPatientInfomation*>(aParent.internalPointer());
if(item->getType() == AbstractPatientInfomation::PatientType)
{
PatientInformation* patientItem = static_cast<PatientInformation*>(item);
return createIndex(aRow, aColumn, patientItem->mAccessionList[aRow]);
}
return QModelIndex();
}
QVariant WorklistTableModel::data(const QModelIndex &aIndex, int aRole) const
{
if (aRole != Qt::DisplayRole)
{
return QVariant();
}
if (!aIndex.isValid())
{
return QVariant();
}
AbstractPatientInfomation* item = static_cast<AbstractPatientInfomation*>(aIndex.internalPointer());
if(item->getType() == AbstractPatientInfomation::PatientType)
{
PatientInformation* patientItem = dynamic_cast<PatientInformation*>(item);
switch (aIndex.column())
{
case 0:return patientItem->ID;
case 1:return patientItem->Name;
case 2:return patientItem->BirthDate;
case 3:return patientItem->Sex == "F" ? tr("Female") : (patientItem->Sex == "M" ? tr("Male") : tr("Other"));
case 4:return patientItem->AddDate;
default:return QVariant();
}
}
if(item->getType() == AbstractPatientInfomation::AccessionType)
{
AccessionInformation* accessionItem = static_cast<AccessionInformation*>(item);
switch (aIndex.column())
{
case 1:return accessionItem->mAccessionNumber;
case 2:return accessionItem->getProtocolText();
case 3:return accessionItem->mScheduledStartDate;
default:return QVariant();
}
}
return QVariant();
}
QModelIndex WorklistTableModel::parent(const QModelIndex &aChild) const
{
if (!aChild.isValid())
{
return QModelIndex();
}
AbstractPatientInfomation *item = static_cast<AbstractPatientInfomation*>(aChild.internalPointer());
if(item->getType() != AbstractPatientInfomation::AccessionType)
{
return QModelIndex();
}
AccessionInformation* accessionItem = static_cast<AccessionInformation*>(item);
int row = mPatientList.indexOf(accessionItem->mPatient);
//parent column must be 0
return createIndex(row, 0, accessionItem->mPatient);
}
void WorklistTableModel::reloadLanguage()
{
beginResetModel();
mHeader = QStringList()<< tr("ID") << tr("Name") << tr("Birth Date") << tr("Gender") << tr("Add Date");
emit headerDataChanged(Qt::Horizontal, 0, mHeader.count() - 1);
for(int i=0; i<mPatientList.size(); ++i)
{
mPatientList[i]->reloadHeaderLanguage();
}
endResetModel();
}
void WorklistTableModel::instertPatients(const QList<PatientInformation*>& aPatientList)
{
beginResetModel();
qDeleteAll(mPatientList);
mPatientList.clear();
mPatientList = aPatientList;
endResetModel();
// PatientInformation* p1 = new PatientInformation("PAT001","Sun","F","1998-08-21","2022-03-03 19:25:23");
// AccessionInformation* a = new AccessionInformation("a1",ScanLeft,"a3", p1, p1);
// AccessionInformation* b = new AccessionInformation("b1",ScanLeft,"b3", p1, p1);
// p1->setAccessionList(QList<AccessionInformation*>()<<a<<b);
// mPatientList << p1;
// PatientInformation* p2 = new PatientInformation("PAT002","wang","F","1998-08-21","2022-03-03 19:25:23");
// AccessionInformation* c = new AccessionInformation("c1",ScanNone,"c3", p2, p2);
// AccessionInformation* d = new AccessionInformation("c1",ScanLeft,"c3", p2, p2);
// p2->setAccessionList(QList<AccessionInformation*>()<<c<<d);
// mPatientList << p2 ;
// PatientInformation* p;
// AccessionInformation* ac;
// p = new PatientInformation("PAT003","jed","F","1998-08-21","2022-03-03 19:25:23");
// ac = new AccessionInformation("left",ScanLeft,"1998-08-21", p, p);
// p->setAccessionList(QList<AccessionInformation*>()<<ac);
// ac = new AccessionInformation("right",ScanRight,"1998-08-21", p, p);
// p->setAccessionList(QList<AccessionInformation*>()<<ac);
// mPatientList << p;
// for(int i=0; i<20; ++i)
// {
// p = new PatientInformation("PAT005","abc","F","1998-08-21","2022-03-03 19:25:23");
// ac = new AccessionInformation("a1",ScanNone,"a3", p, p);
// p->setAccessionList(QList<AccessionInformation*>()<<ac);
// ac = new AccessionInformation("a1",ScanLeft,"a3", p, p);
// p->setAccessionList(QList<AccessionInformation*>()<<ac);
// ac = new AccessionInformation("a1",ScanRight,"a3", p, p);
// p->setAccessionList(QList<AccessionInformation*>()<<ac);
// ac = new AccessionInformation("a1",ScanRight,"a3", p, p);
// p->setAccessionList(QList<AccessionInformation*>()<<ac);
// ac = new AccessionInformation("a1",ScanNone,"a3", p, p);
// p->setAccessionList(QList<AccessionInformation*>()<<ac);
// ac = new AccessionInformation("a1",ScanNone,"a3", p, p);
// p->setAccessionList(QList<AccessionInformation*>()<<ac);
// ac = new AccessionInformation("a1",ScanLeftRight,"a3", p, p);
// p->setAccessionList(QList<AccessionInformation*>()<<ac);
// ac = new AccessionInformation("a1",ScanLeftRight,"a3", p, p);
// p->setAccessionList(QList<AccessionInformation*>()<<ac);
// ac = new AccessionInformation("a1",ScanNone,"a3", p, p);
// p->setAccessionList(QList<AccessionInformation*>()<<ac);
// mPatientList << p;
// }
}

View File

@@ -0,0 +1,34 @@
#ifndef WORKLISTTABLEMODEL_H
#define WORKLISTTABLEMODEL_H
#include <QAbstractItemModel>
#include "PatientInformation.h"
class ActionResult;
class WorklistTableModel : public QAbstractItemModel
{
Q_OBJECT
public:
WorklistTableModel(QObject* aParent = nullptr);
~WorklistTableModel() override;
QVariant headerData(int aSection, Qt::Orientation aOrientation, int aRole = Qt::DisplayRole) const override;
int rowCount(const QModelIndex &aParent = QModelIndex()) const override;
int columnCount(const QModelIndex &aParent = QModelIndex()) const override;
QVariant data(const QModelIndex &aIndex, int aRole) const override;
QModelIndex parent(const QModelIndex &aChild) const override;
QModelIndex index(int aRow, int aColumn, const QModelIndex &aParent = QModelIndex()) const override;
void instertPatients(const QList<PatientInformation*>& aPatientList);
private:
void reloadLanguage();
private:
QList<PatientInformation*> mPatientList;
QStringList mHeader;
};
#endif // WORKLISTTABLEMODEL_H

View File

@@ -0,0 +1,151 @@
#include "WorklistTableSelectModel.h"
#include <QItemSelection>
WorklistTableSelectModel::WorklistTableSelectModel(QAbstractItemModel *aItemModel, QObject *aParent)
: QItemSelectionModel(aItemModel, aParent)
, mSelectedPatient(nullptr)
{
}
WorklistTableSelectModel::~WorklistTableSelectModel()
{
}
void WorklistTableSelectModel::select(const QItemSelection &aIndex, QItemSelectionModel::SelectionFlags aCommand)
{
if(aIndex.size() == 0)
{
return QItemSelectionModel::select(aIndex, aCommand);;
}
if(aCommand & QItemSelectionModel::Select)
{
QModelIndex index = aIndex.indexes()[0];
if(!index.parent().isValid())
{
setSelectedPatient(index);
}
else if(mSelectedPatient != nullptr)
{
setSelectedAccession(index);
}
}
else if(aCommand & QItemSelectionModel::Deselect)
{
QModelIndex index = aIndex.indexes()[0];
if(index.parent().isValid())
{
setUnselectedAccession(index);
}
else
{
mSelectedPatient = nullptr;
}
}
QItemSelectionModel::select(aIndex, aCommand);
emit WorklistTableSelectChanged(mSelectedPatient);
}
void WorklistTableSelectModel::select(const QModelIndex &index, QItemSelectionModel::SelectionFlags command)
{
QItemSelectionModel::select(index, command);
}
void WorklistTableSelectModel::setSelectedPatient(const QModelIndex& aClickModelIndex)
{
AbstractPatientInfomation* item = static_cast<AbstractPatientInfomation*>(aClickModelIndex.internalPointer());
if(item->getType() != AbstractPatientInfomation::PatientType)
{
return;
}
PatientInformation* patient = static_cast<PatientInformation*>(item);
if(mSelectedPatient != nullptr)
{
mSelectedPatient->clearSelectedAccession();
}
mSelectedPatient = patient;
// //handle init selected accession
// {
// mSelectedPatient->selectAccession(mSelectedPatient->mAccessionList[1]);
// //mSelectedPatient->selectAccession(mSelectedPatient->mAccessionList[3]);
mSelectedPatient->selectRecommendAccessions();
// }
updateSelectAccession(aClickModelIndex);
}
void WorklistTableSelectModel::setSelectedAccession(const QModelIndex& aClickModelIndex)
{
AbstractPatientInfomation* item = static_cast<AbstractPatientInfomation*>(aClickModelIndex.internalPointer());
if(item->getType() != AbstractPatientInfomation::AccessionType || aClickModelIndex.row() == 0)
{
return;
}
AccessionInformation* accession = static_cast<AccessionInformation*>(item);
if(mSelectedPatient->contains(accession->mPosition))
{
QList<int> rowIndexs = mSelectedPatient->unSelectAccession(accession->mPosition);
for(int i=0; i<rowIndexs.size(); ++i)
{
unselectRow(aClickModelIndex.parent(), rowIndexs[i]);
}
}
while(mSelectedPatient->isSelectedMax(accession))
{
int rowIndex = mSelectedPatient->unSelectLastAccession();
if(rowIndex == -1)
{
break;
}
unselectRow(aClickModelIndex.parent(), rowIndex);
}
mSelectedPatient->selectAccession(accession);
}
void WorklistTableSelectModel::setUnselectedAccession(const QModelIndex& aClickModelIndex)
{
AbstractPatientInfomation* item = static_cast<AbstractPatientInfomation*>(aClickModelIndex.internalPointer());
if(item->getType() != AbstractPatientInfomation::AccessionType)
{
return;
}
AccessionInformation* accession = static_cast<AccessionInformation*>(item);
mSelectedPatient->unSelectAccession(accession);
}
void WorklistTableSelectModel::updateSelectAccession(const QModelIndex& aClickModelIndex)
{
QList<int> selectedIndex = mSelectedPatient->getSelectedAccessionIndex();
for(int i=0; i<selectedIndex.size(); ++i)
{
QModelIndex start = aClickModelIndex.child(selectedIndex[i],0);
QModelIndex end = aClickModelIndex.child(selectedIndex[i],model()->columnCount() - 1);
QItemSelectionModel::select(QItemSelection(start, end), QItemSelectionModel::Select);
}
}
void WorklistTableSelectModel::unselectRow(const QModelIndex& aParientlIndex, int aRow)
{
QModelIndex start = model()->index(aRow, 0, aParientlIndex);
QModelIndex end = model()->index(aRow, model()->columnCount() - 1, aParientlIndex);
QItemSelectionModel::select(QItemSelection(start, end), QItemSelectionModel::Deselect);
}
PatientInformation* WorklistTableSelectModel::getSelectedPatient()
{
return mSelectedPatient;
}
void WorklistTableSelectModel::clearSelect()
{
mSelectedPatient = nullptr;
emit WorklistTableSelectChanged(mSelectedPatient);
}

View File

@@ -0,0 +1,35 @@
#ifndef WORKLISTTABLESELECTMODEL_H
#define WORKLISTTABLESELECTMODEL_H
#include <QItemSelectionModel>
#include "WorklistTableModel.h"
class WorklistTableSelectModel : public QItemSelectionModel
{
Q_OBJECT
public:
WorklistTableSelectModel(QAbstractItemModel *aItemModel, QObject *aParent = nullptr);
~WorklistTableSelectModel() override;
void select(const QItemSelection &aIndex, QItemSelectionModel::SelectionFlags aCommand) override;
void select(const QModelIndex &index, QItemSelectionModel::SelectionFlags command) override;
PatientInformation* getSelectedPatient();
void clearSelect();
signals:
void WorklistTableSelectChanged(PatientInformation* aPatient);
private:
void setSelectedPatient(const QModelIndex& aClickModelIndex);
void setSelectedAccession(const QModelIndex& aClickModelIndex);
void setUnselectedAccession(const QModelIndex& aClickModelIndex);
void updateSelectAccession(const QModelIndex& aClickModelIndex);
inline void unselectRow(const QModelIndex& aParientlIndex, int aRow);
private:
PatientInformation* mSelectedPatient;
};
#endif // WORKLISTTABLESELECTMODEL_H

View File

@@ -0,0 +1,78 @@
#include "WorklistTableStyleItemDelegate.h"
#include <QPainter>
#include <QApplication>
#include "WorklistTableModel.h"
#include <QDebug>
WorklistTableStyleItemDelegate::WorklistTableStyleItemDelegate(QHeaderView* aHeaderView, QObject* aParent)
: QStyledItemDelegate(aParent)
, mHeaderView(aHeaderView)
, mCheckedIcon(new QPixmap(":icons/radio_check.png"))
, mUncheckedIcon(new QPixmap(":/icons/radio_uncheck.png"))
{
}
WorklistTableStyleItemDelegate::~WorklistTableStyleItemDelegate()
{
delete mCheckedIcon;
delete mUncheckedIcon;
}
void WorklistTableStyleItemDelegate::paint(QPainter* aPainter, const QStyleOptionViewItem& aOption, const QModelIndex& aIndex) const
{
if(aIndex.data().isValid())
{
if (aIndex.parent().isValid() && aIndex.row() == 0)
{
aPainter->save();
QStyleOptionHeader header;
header.initFrom(mHeaderView);
header.state = QStyle::State_None;
header.rect = aOption.rect;
header.text = aIndex.data().toString();
header.textAlignment = Qt::AlignCenter;
aPainter->fillRect(header.rect, QBrush(QColor("#595959")));
mHeaderView->style()->drawControl(QStyle::CE_HeaderLabel, &header, aPainter, mHeaderView);
aPainter->restore();
}
else
{
QStyleOptionViewItem changedOption = aOption;
changedOption.state &= ~QStyle::State_HasFocus;
changedOption.displayAlignment = Qt::AlignCenter;
QStyledItemDelegate::paint(aPainter, changedOption, aIndex);
}
}
aPainter->save();
if (aIndex.parent().isValid() && aIndex.column() == 0 && aIndex.row() != 0)
{
bool isSelected = aOption.state & QStyle::State_Selected;
QStyleOptionButton checkBoxOption;
checkBoxOption.rect = aOption.rect;
checkBoxOption.state |= QStyle::State_On;
checkBoxOption.rect.setWidth(30);
checkBoxOption.rect.setHeight(30);
checkBoxOption.rect.moveLeft(260);
checkBoxOption.rect.moveTop(checkBoxOption.rect.top() + 4);
aPainter->setRenderHint(QPainter::SmoothPixmapTransform, true);
if(isSelected)
{
aPainter->drawPixmap(checkBoxOption.rect,*mCheckedIcon);
}
else
{
aPainter->drawPixmap(checkBoxOption.rect,*mUncheckedIcon);
}
}
aPainter->setPen(QPen(Qt::black));
aPainter->drawLine(aOption.rect.topRight(), aOption.rect.bottomRight());
aPainter->drawLine(aOption.rect.bottomLeft(), aOption.rect.bottomRight());
aPainter->restore();
}

View File

@@ -0,0 +1,21 @@
#ifndef WORKLISTTABLESTYLEITEMDELEGATE_H
#define WORKLISTTABLESTYLEITEMDELEGATE_H
#include <QStyledItemDelegate>
#include <QHeaderView>
class WorklistTableStyleItemDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
WorklistTableStyleItemDelegate(QHeaderView* aHeaderView, QObject* aParent = nullptr);
~WorklistTableStyleItemDelegate();
void paint(QPainter* aPainter, const QStyleOptionViewItem& aOption, const QModelIndex& aIndex) const override;
private:
QHeaderView* mHeaderView;
QPixmap* mCheckedIcon;
QPixmap* mUncheckedIcon;
};
#endif // WORKLISTTABLESTYLEITEMDELEGATE_H

View File

@@ -0,0 +1,133 @@
#include "WorklistTableView.h"
#include <QMouseEvent>
#include <QScrollBar>
#include <cmath>
#include <QGraphicsView>
#include <QDebug>
namespace
{
const int ROW_HEIGHT = 30.0l;
}
WorklistTableView::WorklistTableView(QWidget *aParent)
: QTreeView (aParent)
, mOriginPosY(-1)
, mOriginScrollBarV(0)
, mIsMoved(false)
{
setExpandsOnDoubleClick(false);
}
WorklistTableView::~WorklistTableView()
{
}
void WorklistTableView::singleClickExpand(const QModelIndex& aIndex)
{
if(!aIndex.isValid())
{
return;
}
if(!aIndex.parent().isValid())
{
QModelIndex nodeIndex = model()->index(aIndex.row(), 0, aIndex.parent());
if(isExpanded(nodeIndex))
{
collapse(model()->index(aIndex.row(), 0, aIndex.parent()));
}
else
{
collapseAll();
expand(nodeIndex);
}
}
}
void WorklistTableView::mousePressEvent(QMouseEvent *aEvent)
{
if(aEvent == nullptr)
{
return;
}
mOriginPosY = aEvent->pos().y();
mOriginScrollBarV = this->verticalScrollBar()->value();
aEvent->ignore();
return;
}
void WorklistTableView::mouseReleaseEvent(QMouseEvent *aEvent)
{
if(aEvent == nullptr)
{
return;
}
QModelIndex index = indexAt(aEvent->pos());
if(mIsMoved)
{
mIsMoved = false;
return QTreeView::mouseReleaseEvent(aEvent);
}
QItemSelectionModel *selectionModel = this->selectionModel();
if (index.isValid())
{
if (selectionModel->isSelected(index))
{
QModelIndex startIndex = model()->index(index.row(), 0, index.parent());
QModelIndex endIndex = model()->index(index.row(), model()->columnCount() - 1, index.parent());
selectionModel->select(QItemSelection(startIndex, endIndex), QItemSelectionModel::Deselect);
if(!index.parent().isValid())
{
singleClickExpand(index);
}
return;
}
if(!index.parent().isValid())
{
selectionModel->clear();
}
}
QModelIndex startIndex = model()->index(index.row(), 0, index.parent());
QModelIndex endIndex = model()->index(index.row(), model()->columnCount() - 1, index.parent());
selectionModel->select(QItemSelection(startIndex, endIndex), QItemSelectionModel::Select);
//QTreeView::mousePressEvent(mPressEvent);
singleClickExpand(index);
QTreeView::mouseReleaseEvent(aEvent);
}
void WorklistTableView::mouseMoveEvent(QMouseEvent* aEvent)
{
if(aEvent == nullptr)
{
return;
}
if (this->verticalScrollBar()->isVisible())
{
int nv = (int) round(((double) mOriginScrollBarV * ROW_HEIGHT + ((double) (mOriginPosY - aEvent->pos().y())))
/ ROW_HEIGHT);
// int nv = mOriginScrollBarV * ROW_HEIGHT + ( (mOriginPosY - aEvent->pos().y()))
// / ROW_HEIGHT;
int max = this->verticalScrollBar()->maximum();
int min = this->verticalScrollBar()->minimum();
nv = nv > max ? max : (nv < min ? min : nv);
if(this->verticalScrollBar()->value() != nv )
{
mIsMoved = true;
this->verticalScrollBar()->setValue(nv);
}
}
aEvent->ignore();
}
void WorklistTableView::mouseDoubleClickEvent(QMouseEvent* aEvent)
{
if(aEvent == nullptr)
{
return;
}
aEvent->ignore();
}

View File

@@ -0,0 +1,28 @@
#ifndef WORKLISTTABLEVIEW_H
#define WORKLISTTABLEVIEW_H
#include <QTreeView>
class WorklistTableView : public QTreeView
{
Q_OBJECT
public:
WorklistTableView(QWidget *aParent = nullptr);
~WorklistTableView() override;
protected:
void mousePressEvent(QMouseEvent *aEvent) override;
void mouseReleaseEvent(QMouseEvent *aEvent) override;
void mouseDoubleClickEvent(QMouseEvent* aEvent) override;
void mouseMoveEvent(QMouseEvent* aEvent) override;
private:
void singleClickExpand(const QModelIndex& aIndex);
private:
int mOriginPosY;
int mOriginScrollBarV;
bool mIsMoved;
};
#endif // WORKLISTTABLEVIEW_H

View File

@@ -22,6 +22,7 @@
#include "utilities/DiskInfoWorker.h"
#include "utilities/GetLockScreenTimeHelper.h"
#include "utilities/GetProtocalHelper.h"
#include "utilities/WorklistFilterHelper.h"
GeneralForm::GeneralForm(QWidget* aParent)
: QWidget(aParent)
@@ -63,8 +64,9 @@ GeneralForm::GeneralForm(QWidget* aParent)
lanHeaderLayout->addWidget(languageLabel);
lanHeaderLayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding));
QToolButton* btnLan = new ListBox(lanHeader);
btnLan->setFixedWidth(180);
lanHeaderLayout->addWidget(btnLan);
lanHeaderLayout->addSpacerItem(new QSpacerItem(1220, 20, QSizePolicy::Fixed));
lanHeaderLayout->addSpacerItem(new QSpacerItem(1000, 20, QSizePolicy::Fixed));
//Lock Screen
QWidget* lockHeader = new QWidget(this);
@@ -74,8 +76,9 @@ GeneralForm::GeneralForm(QWidget* aParent)
lockHeaderLayout->addWidget(lockScreenLabel);
lockHeaderLayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding));
ListBox* lockTime = new ListBox(lockHeader);
lockTime->setFixedWidth(180);
lockHeaderLayout->addWidget(lockTime);
lockHeaderLayout->addSpacerItem(new QSpacerItem(1220, 20, QSizePolicy::Fixed));
lockHeaderLayout->addSpacerItem(new QSpacerItem(1000, 20, QSizePolicy::Fixed));
//Scan Protocol
QWidget* scanProtocolHeader = new QWidget(this);
@@ -86,8 +89,35 @@ GeneralForm::GeneralForm(QWidget* aParent)
scanProtocalHeaderLayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding));
ListBox* scanProtocolButton = new ListBox(scanProtocolHeader);
scanProtocolButton->setText(GetProtocalHelper::getProtocalStr());
scanProtocolButton->setFixedWidth(180);
scanProtocalHeaderLayout->addWidget(scanProtocolButton);
scanProtocalHeaderLayout->addSpacerItem(new QSpacerItem(1220, 20, QSizePolicy::Fixed));
scanProtocalHeaderLayout->addSpacerItem(new QSpacerItem(1000, 20, QSizePolicy::Fixed));
//Worklist Modality Filter
QWidget* worklistModalityFilterHeader = new QWidget(this);
mLayout->addWidget(worklistModalityFilterHeader);
QHBoxLayout* worklistFilterModalityHeaderLayout = new QHBoxLayout(worklistModalityFilterHeader);
QLabel* worklistFilterModalityLabel = new QLabel(tr("Worklist Modality Filter"), this);
worklistFilterModalityHeaderLayout->addWidget(worklistFilterModalityLabel);
worklistFilterModalityHeaderLayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding));
ListBox* worklistFilterModalityButton = new ListBox(worklistModalityFilterHeader);
worklistFilterModalityButton->setText(WorklistFilterHelper::getCurrentWorklistFilterModality());
worklistFilterModalityButton->setFixedWidth(180);
worklistFilterModalityHeaderLayout->addWidget(worklistFilterModalityButton);
worklistFilterModalityHeaderLayout->addSpacerItem(new QSpacerItem(1000, 20, QSizePolicy::Fixed));
//Worklist Date Filter
QWidget* worklistDateFilterHeader = new QWidget(this);
mLayout->addWidget(worklistDateFilterHeader);
QHBoxLayout* worklistFilterDateHeaderLayout = new QHBoxLayout(worklistDateFilterHeader);
QLabel* worklistFilterDateLabel = new QLabel(tr("Worklist Date Filter"), this);
worklistFilterDateHeaderLayout->addWidget(worklistFilterDateLabel);
worklistFilterDateHeaderLayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding));
ListBox* worklistFilterDateButton = new ListBox(worklistDateFilterHeader);
worklistFilterDateButton->setFixedWidth(180);
worklistFilterDateButton->setText(WorklistFilterHelper::getCurrentWorklistFilterDate());
worklistFilterDateHeaderLayout->addWidget(worklistFilterDateButton);
worklistFilterDateHeaderLayout->addSpacerItem(new QSpacerItem(1000, 20, QSizePolicy::Fixed));
//Complete Notify
QWidget* scanCompleteHeader = new QWidget(this);
@@ -100,7 +130,7 @@ GeneralForm::GeneralForm(QWidget* aParent)
scanCompleteHeaderLayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding));
scanCompleteHeaderLayout->addWidget(scanCompleteButton);
scanCompleteButton->setChecked(JsonObject::Instance()->getCompleteNotify());
scanCompleteHeaderLayout->addSpacerItem(new QSpacerItem(1220, 20, QSizePolicy::Fixed));
scanCompleteHeaderLayout->addSpacerItem(new QSpacerItem(1000, 20, QSizePolicy::Fixed));
//Anonymous
QWidget* anonyHeader = new QWidget(this);
@@ -112,7 +142,7 @@ GeneralForm::GeneralForm(QWidget* aParent)
ImageSwitch* anonyButton = new ImageSwitch(anonyHeader);
anonyButton->setChecked(JsonObject::Instance()->getAnonymousMode());
anonyHeaderLayout->addWidget(anonyButton);
anonyHeaderLayout->addSpacerItem(new QSpacerItem(1220, 20, QSizePolicy::Fixed));
anonyHeaderLayout->addSpacerItem(new QSpacerItem(1000, 20, QSizePolicy::Fixed));
//Screen Saver
QWidget* screenSaverHeader = new QWidget(this);
@@ -124,7 +154,7 @@ GeneralForm::GeneralForm(QWidget* aParent)
ImageSwitch* screenSaverButton = new ImageSwitch(screenSaverHeader);
screenSaverButton->setChecked(JsonObject::Instance()->getScreenSaverMode());
screenSaverHeaderLayout->addWidget(screenSaverButton);
screenSaverHeaderLayout->addSpacerItem(new QSpacerItem(1220, 20, QSizePolicy::Fixed));
screenSaverHeaderLayout->addSpacerItem(new QSpacerItem(1000, 20, QSizePolicy::Fixed));
//DiskIcon
QWidget* diskHeader = new QWidget(this);
@@ -209,8 +239,12 @@ GeneralForm::GeneralForm(QWidget* aParent)
anonyLabel->setText(tr("Anonymous Mode"));
screenSaverLabel->setText(tr("Screen Saver"));
diskLabel->setText(tr("Disk Storage"));
worklistFilterDateLabel->setText(tr("Worklist Date Filter"));
worklistFilterModalityLabel->setText(tr("Worklist Modality Filter"));
anonyButton->setChecked(JsonObject::Instance()->getAnonymousMode());
scanProtocolButton->setText(GetProtocalHelper::getProtocalStr());
worklistFilterDateButton->setText(WorklistFilterHelper::getCurrentWorklistFilterDate());
worklistFilterModalityButton->setText(WorklistFilterHelper::getCurrentWorklistFilterModality());
lockTime->setText(GetLockScreenTimeHelper::getLockScreenTimeStr());
updateStorageSize();
updateStorageUsed();
@@ -245,6 +279,31 @@ GeneralForm::GeneralForm(QWidget* aParent)
}
});
connect(worklistFilterModalityButton, &QPushButton::clicked, [=]()
{
DialogResult result = DialogManager::Default()->reuqestWorklistFilterModalityDialog();
if (result.ResultCode == QDialog::Accepted)
{
QString modality = result.ResultData.toString();
worklistFilterModalityButton->setText(modality);
JsonObject::Instance()->setWorklistFilterModality(WorklistFilterHelper::processSelectedWorklistFilterModality(modality));
LOG_USER_OPERATION(QString("Set Worklist Modality Filter:%1").arg(modality));
}
});
connect(worklistFilterDateButton, &QPushButton::clicked, [=]()
{
DialogResult result = DialogManager::Default()->reuqestWorklistFilterDateDialog();
if (result.ResultCode == QDialog::Accepted)
{
QString date = result.ResultData.toString();
worklistFilterDateButton->setText(date);
JsonObject::Instance()->setWorklistFilterDate(date);
JsonObject::Instance()->setWorklistFilterDate(WorklistFilterHelper::processSelectedWorklistFilterDate(date));
LOG_USER_OPERATION(QString("Set Worklist Date Filter:%1").arg(date));
}
});
connect(scanCompleteButton, &ImageSwitch::clicked, [=]()
{
bool isOpen = scanCompleteButton->getChecked();