Refactor system page in GUI Alpha.
This commit is contained in:
107
src/dialogs/WorklistSettingsDialog.cpp
Normal file
107
src/dialogs/WorklistSettingsDialog.cpp
Normal file
@@ -0,0 +1,107 @@
|
||||
#include "WorklistSettingsDialog.h"
|
||||
#include "components/ULineEdit.h"
|
||||
#include "dialogs/DicomSettingsArea.h"
|
||||
#include "json/jsonobject.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
|
||||
namespace
|
||||
{
|
||||
const int ENDLINE_SPACE = 3;
|
||||
}
|
||||
|
||||
WorklistSettingsDialog::WorklistSettingsDialog(QWidget* aParent, Qt::WindowFlags aWindowFlag)
|
||||
: GUIFormBaseDialog(aParent, aWindowFlag)
|
||||
, mSettingsArea(new DicomSettingsArea(this))
|
||||
, mErrorText(new QLabel(this))
|
||||
{
|
||||
QVBoxLayout* layout = new QVBoxLayout(mFormWidget);
|
||||
layout->setSpacing(10);
|
||||
//Title
|
||||
QLabel* title = new QLabel(this);
|
||||
title->setAlignment(Qt::AlignCenter);
|
||||
title->setText(tr("Worklist Settings"));
|
||||
title->setObjectName("title");
|
||||
layout->addWidget(title);
|
||||
layout->addWidget(mSettingsArea);
|
||||
|
||||
QLabel* endline = new QLabel(this);
|
||||
endline->setFixedHeight(ENDLINE_SPACE);
|
||||
endline->setObjectName("endline");
|
||||
layout->addWidget(endline);
|
||||
layout->addWidget(mErrorText);
|
||||
mErrorText->setObjectName("warn");
|
||||
mErrorText->hide();
|
||||
|
||||
initConfig();
|
||||
}
|
||||
|
||||
WorklistSettingsDialog::~WorklistSettingsDialog()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void WorklistSettingsDialog::initConfig()
|
||||
{
|
||||
host serverInfo;
|
||||
serverInfo = JsonObject::Instance()->getServer(JsonObject::WORKLIST);
|
||||
mSettingsArea->setServerAETitle(serverInfo.ae);
|
||||
mSettingsArea->setServerIpAddress(serverInfo.ip);
|
||||
mSettingsArea->setMyAETitle(serverInfo.name);
|
||||
mSettingsArea->setServerPort(serverInfo.port);
|
||||
}
|
||||
|
||||
bool WorklistSettingsDialog::updateReferenceData()
|
||||
{
|
||||
QString myAETitle = mSettingsArea->getMyAETitle();
|
||||
QString serverIp = mSettingsArea->getServerIpAddress();
|
||||
QString serverPort = mSettingsArea->getServerPort();
|
||||
QString serverAETitle = mSettingsArea->getServerAETitle();
|
||||
mErrorText->show();
|
||||
|
||||
if(myAETitle.isEmpty())
|
||||
{
|
||||
mErrorText->setText(tr("AE can't be empty"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(serverAETitle.isEmpty())
|
||||
{
|
||||
mErrorText->setText(tr("Server AE can't be empty"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(serverIp.isEmpty())
|
||||
{
|
||||
mErrorText->setText(tr("Server Ip can't be empty"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(serverPort.isEmpty())
|
||||
{
|
||||
mErrorText->setText(tr("Server Port can't be empty"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!mSettingsArea->isIpAddressValid())
|
||||
{
|
||||
mErrorText->setText(tr("Ip Address is not valid"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!mSettingsArea->isPortValid())
|
||||
{
|
||||
mErrorText->setText(tr("Port is not valid"));
|
||||
return false;
|
||||
}
|
||||
|
||||
host serverInfo;
|
||||
serverInfo.ip = serverIp;
|
||||
serverInfo.ae = serverAETitle;
|
||||
serverInfo.name = myAETitle;
|
||||
serverInfo.port = serverPort;
|
||||
JsonObject::Instance()->setServer(JsonObject::WORKLIST, serverInfo);
|
||||
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user