#include "GetWorkListDialog.h" #include #include #include #include "components/ULineEdit.h" #include "action/GetWorkListAction.h" #include "action/ActionCreator.h" GetWorkListDialog::GetWorkListDialog(QSqlTableModel* aSqlModel, QWidget* aParent, Qt::WindowFlags aFlags) : AsyncActionDialog(ActionCreator::getAsyncAction("GetWorkListAction"),"Work List", aParent, aFlags) , mAccessionNumber(new ULineEdit(mContentWidget)) , mPatientId(new ULineEdit(mContentWidget)) , mErrorLabel(new QLabel(mContentWidget)) { initializeContentWidgets(); GetWorkListAction* action = qobject_cast(getAction()); if (action != nullptr) { action->setSqlModel(aSqlModel); } } GetWorkListDialog::~GetWorkListDialog() { } void GetWorkListDialog::initializeContentWidgets() { QVBoxLayout* contentLayout = new QVBoxLayout(mContentWidget); //Accession Nummber QLabel* accessionNumText = new QLabel(mContentWidget); accessionNumText->setText(tr("Accession Nummber")); contentLayout->addWidget(accessionNumText); contentLayout->addWidget(mAccessionNumber); QLabel* endLine1 = new QLabel(mContentWidget); endLine1->setObjectName("endline"); contentLayout->addWidget(endLine1); //PatientId QLabel* patientIdText = new QLabel(mContentWidget); patientIdText->setText(tr("Patient ID")); contentLayout->addWidget(patientIdText); contentLayout->addWidget(mPatientId); QLabel* endLine2 = new QLabel(mContentWidget); endLine2->setObjectName("endline"); contentLayout->addWidget(endLine2); //ErrorLabel contentLayout->addWidget(mErrorLabel); mErrorLabel->setObjectName("warn"); mErrorLabel->hide(); } bool GetWorkListDialog::updateReferenceData() { QString accessionNum = mAccessionNumber->text(); QString patientId = mPatientId->text(); if (accessionNum.isEmpty() && patientId.isEmpty()) { mErrorLabel->setText(tr("Accession Number and Patient Id is Empty.")); mErrorLabel->show(); return false; } GetWorkListAction* action = qobject_cast(getAction()); if (action == nullptr) { mErrorLabel->setText(tr("Unknow Error. code:001001001")); return false; } action->setWorkListQueryData(WorkListQueryData(accessionNum, patientId)); return AsyncActionDialog::updateReferenceData(); } void GetWorkListDialog::handleFinishedAction(const ActionResult& aResult) { if (aResult.Code == Failed) { mErrorLabel->setText(aResult.Message); mContentWidget->show(); mBtnWidget->show(); mErrorLabel->show(); } AsyncActionDialog::handleFinishedAction(aResult); }