Refactor Network Module and add C-GET protocol.

This commit is contained in:
sunwen
2022-10-21 15:57:01 +08:00
parent f575691a60
commit 6e1dfb868e
24 changed files with 785 additions and 578 deletions

View File

@@ -8,6 +8,7 @@
#include <QFrame>
#include <QEvent>
#include <QIcon>
#include <QMenu>
#include <QStandardItemModel>
#include <QItemSelectionModel>
#include <QHeaderView>
@@ -29,6 +30,8 @@ ConfigurationDialog::ConfigurationDialog(QWidget *parent)
, m_pSpacerItem(nullptr)
, m_pDelButton(nullptr)
, m_pPacsInfo(nullptr)
, m_pPacsMenu(nullptr)
, m_pRetriveProtocolMenu(nullptr)
, m_pEditWidget(nullptr)
, m_pEditLayout(nullptr)
, m_pPeerIpAddressLabel(nullptr)
@@ -120,10 +123,24 @@ void ConfigurationDialog::initUi()
m_pPacsInfo->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
m_pPacsInfo->verticalHeader()->setVisible(false);
m_pPacsInfo->setShowGrid(false);
m_pPacsInfo->setContextMenuPolicy(Qt::CustomContextMenu);
m_pPacsInfo->setSelectionMode(QAbstractItemView::SingleSelection);
m_pPacsInfo->setSelectionBehavior(QAbstractItemView::SelectRows);
m_pPacsInfo->setModel(m_pPacsModel);
connect(m_pPacsInfo,&QTableView::customContextMenuRequested,this,&ConfigurationDialog::pacsMenuRequest);
m_pMainLayout->addWidget(m_pPacsInfo);
m_pPacsMenu = new QMenu(m_pPacsInfo);
m_pRetriveProtocolMenu = new QMenu(tr("Retrive Protocol"),m_pPacsMenu);
QAction* cGetAction = new QAction("C-GET",m_pRetriveProtocolMenu);
cGetAction->setCheckable(true);
connect(cGetAction,&QAction::triggered,this,&ConfigurationDialog::changeHostProtocol);
QAction* cMoveAction = new QAction("C-MOVE",m_pRetriveProtocolMenu);
cMoveAction->setCheckable(true);
connect(cMoveAction,&QAction::triggered,this,&ConfigurationDialog::changeHostProtocol);
m_pRetriveProtocolMenu->addAction(cGetAction);
m_pRetriveProtocolMenu->addAction(cMoveAction);
m_pPacsMenu->addMenu(m_pRetriveProtocolMenu);
m_pEditWidget = new QWidget(this);
m_pEditLayout = new QGridLayout(this);
@@ -197,7 +214,7 @@ void ConfigurationDialog::initSys()
connect(m_pModifyButton, SIGNAL(clicked()), this, SLOT(modify()));
connect(m_pSaveButton, SIGNAL(clicked()), this, SLOT(save()));
connect(m_pCancelButton, SIGNAL(clicked()), this, SLOT(cancel()));
connect(m_pPacsInfo, SIGNAL(clicked(const QModelIndex &)), this, SLOT(onSelected(const QModelIndex &)));
connect(m_pPacsInfo, SIGNAL(pressed(const QModelIndex &)), this, SLOT(onSelected(const QModelIndex &)));
}
void ConfigurationDialog::initHeaderInfo()
@@ -239,7 +256,7 @@ void ConfigurationDialog::initPacsInfo()
QStandardItem* port = new QStandardItem(var.port); port->setEditable(false);
QStandardItem* ae = new QStandardItem(var.ae); ae->setEditable(false);
QStandardItem* name = new QStandardItem(var.name); name->setEditable(false);
QStandardItem* protocol = new QStandardItem("C-MOVE"); protocol->setEditable(false);
QStandardItem* protocol = new QStandardItem(var.protocol == 0 ? "C-MOVE" : "C-GET"); protocol->setEditable(false);
QStandardItem* count = new QStandardItem("1"); count->setEditable(false);
QStandardItem* xfers = new QStandardItem("Explicit VR LE"); xfers->setEditable(false);
QStandardItem* cset = new QStandardItem("Default"); cset->setEditable(false);
@@ -265,7 +282,7 @@ void ConfigurationDialog::updatePacsView()
QStandardItem* port = new QStandardItem(itr->port); port->setEditable(false);
QStandardItem* ae = new QStandardItem(itr->ae); ae->setEditable(false);
QStandardItem* name = new QStandardItem(itr->name); name->setEditable(false);
QStandardItem* protocol = new QStandardItem("C-MOVE"); protocol->setEditable(false);
QStandardItem* protocol = new QStandardItem(itr->protocol == 0 ? "C-MOVE" : "C-GET"); protocol->setEditable(false);
QStandardItem* count = new QStandardItem("1"); count->setEditable(false);
QStandardItem* xfers = new QStandardItem("Explicit VR LE"); xfers->setEditable(false);
QStandardItem* cset = new QStandardItem("Default"); cset->setEditable(false);
@@ -558,3 +575,49 @@ bool ConfigurationDialog::eventFilter(QObject *obj, QEvent *event)
return QDialog::eventFilter(obj, event);
}
void ConfigurationDialog::changeHostProtocol()
{
QAction* action = qobject_cast<QAction*>(sender());
if (action != nullptr && currentRow != -1)
{
QString selectedName = m_pPacsModel->index(currentRow, 3).data().toString();
for (auto itr = m_lHostsNew.begin(); itr != m_lHostsNew.end(); ++itr)
{
if (selectedName == itr->name)
{
if (action->text() == "C-GET")
{
itr->protocol = 1;
}
else if(action->text() == "C-MOVE")
{
itr->protocol = 0;
}
updatePacsView();
DicomViewerHelper::setPacsInfo(m_lHostsNew);
emit updatePacsInfo();
return;
}
}
}
}
void ConfigurationDialog::pacsMenuRequest(QPoint pos)
{
auto index = m_pPacsInfo->indexAt(pos);
auto actions = m_pRetriveProtocolMenu->actions();
for(int i = 0; i < actions.count(); ++i)
{
if (actions.at(i)->text() == m_pPacsModel->item(index.row(),4)->text())
{
actions.at(i)->setChecked(true);
}
else
{
actions.at(i)->setChecked(false);
}
}
m_pPacsMenu->exec(QCursor::pos());
}