refactor: Modify the display and interaction related to worklist.
This commit is contained in:
7
src/forms/select/AbstractPatientInfomation.cpp
Normal file
7
src/forms/select/AbstractPatientInfomation.cpp
Normal file
@@ -0,0 +1,7 @@
|
||||
#include "AbstractPatientInfomation.h"
|
||||
|
||||
AbstractPatientInfomation::AbstractPatientInfomation(QObject* aParent)
|
||||
: QObject (aParent)
|
||||
{
|
||||
|
||||
}
|
||||
21
src/forms/select/AbstractPatientInfomation.h
Normal file
21
src/forms/select/AbstractPatientInfomation.h
Normal 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
|
||||
50
src/forms/select/AccessionInformation.cpp
Normal file
50
src/forms/select/AccessionInformation.cpp
Normal 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;
|
||||
}
|
||||
42
src/forms/select/AccessionInformation.h
Normal file
42
src/forms/select/AccessionInformation.h
Normal 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
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
232
src/forms/select/PatientInformation.cpp
Normal file
232
src/forms/select/PatientInformation.cpp
Normal 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;
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
193
src/forms/select/WorklistTableModel.cpp
Normal file
193
src/forms/select/WorklistTableModel.cpp
Normal 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;
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
34
src/forms/select/WorklistTableModel.h
Normal file
34
src/forms/select/WorklistTableModel.h
Normal 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
|
||||
151
src/forms/select/WorklistTableSelectModel.cpp
Normal file
151
src/forms/select/WorklistTableSelectModel.cpp
Normal 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);
|
||||
}
|
||||
35
src/forms/select/WorklistTableSelectModel.h
Normal file
35
src/forms/select/WorklistTableSelectModel.h
Normal 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
|
||||
78
src/forms/select/WorklistTableStyleItemDelegate.cpp
Normal file
78
src/forms/select/WorklistTableStyleItemDelegate.cpp
Normal 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();
|
||||
}
|
||||
21
src/forms/select/WorklistTableStyleItemDelegate.h
Normal file
21
src/forms/select/WorklistTableStyleItemDelegate.h
Normal 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
|
||||
133
src/forms/select/WorklistTableView.cpp
Normal file
133
src/forms/select/WorklistTableView.cpp
Normal 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();
|
||||
}
|
||||
28
src/forms/select/WorklistTableView.h
Normal file
28
src/forms/select/WorklistTableView.h
Normal 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
|
||||
Reference in New Issue
Block a user