626 lines
20 KiB
C++
626 lines
20 KiB
C++
#include "pacsconfiguration.h"
|
||
#include "pacsconfiguretitlebar.h"
|
||
#include <QVBoxLayout>
|
||
#include <QLabel>
|
||
#include <QLineEdit>
|
||
#include <QPushButton>
|
||
#include <QTableView>
|
||
#include <QFrame>
|
||
#include <QEvent>
|
||
#include <QIcon>
|
||
#include <QMenu>
|
||
#include <QStandardItemModel>
|
||
#include <QItemSelectionModel>
|
||
#include <QHeaderView>
|
||
#include "PACS/Dialog/promptdialog.h"
|
||
#include "PACS/Dialog/ConnectionTestDialog.h"
|
||
|
||
ConfigurationDialog::ConfigurationDialog(QWidget *parent)
|
||
: QDialog(parent)
|
||
, m_pOurInfoLayout(nullptr)
|
||
, m_pTitleBar(nullptr)
|
||
, m_pOurPortLabel(nullptr)
|
||
, m_pOurPortEdit(nullptr)
|
||
, m_pOurTitleLabel(nullptr)
|
||
, m_pOurTitleEdit(nullptr)
|
||
, m_AdvancedSettingsButton(nullptr)
|
||
, m_pOurInfoEndLine(nullptr)
|
||
, m_pToolsWidget(nullptr)
|
||
, m_pToolsLayout(nullptr)
|
||
, m_pTitleLabel(nullptr)
|
||
, m_pSpacerItem(nullptr)
|
||
, m_pDelButton(nullptr)
|
||
, m_pPacsInfo(nullptr)
|
||
, m_pPacsMenu(nullptr)
|
||
, m_TestConnectionMenu(nullptr)
|
||
, m_pEditWidget(nullptr)
|
||
, m_pEditLayout(nullptr)
|
||
, m_pPeerIpAddressLabel(nullptr)
|
||
, m_pPeerPortLabel(nullptr)
|
||
, m_pPeerTitleLabel(nullptr)
|
||
, m_pPeerDescritopnLabel(nullptr)
|
||
, m_pPeerIpAddressEdit(nullptr)
|
||
, m_pPeerPortEdit(nullptr)
|
||
, m_pPeerTitleEdit(nullptr)
|
||
, m_pPeerDescriptionEdit(nullptr)
|
||
, m_pAddButton(nullptr)
|
||
, m_pModifyButton(nullptr)
|
||
, m_pEditEndLine(nullptr)
|
||
, m_pActionWidget(nullptr)
|
||
, m_pActionLayout(nullptr)
|
||
, m_pSpacerItem1(nullptr)
|
||
, m_pSaveButton(nullptr)
|
||
, m_pCancelButton(nullptr)
|
||
, currentRow(-1)
|
||
, m_pMsgDialog(nullptr)
|
||
{
|
||
initUi();
|
||
initSys();
|
||
initPacsInfo();
|
||
}
|
||
|
||
ConfigurationDialog::~ConfigurationDialog()
|
||
{
|
||
}
|
||
|
||
void ConfigurationDialog::initUi()
|
||
{
|
||
this->setWindowFlags( windowFlags() | Qt::FramelessWindowHint);
|
||
this->resize(620, 430);
|
||
this->setObjectName("PacsConfigurationDialog");
|
||
|
||
m_pMainLayout = new QVBoxLayout(this);
|
||
m_pTitleBar = new ConfigurationTitleBar(this);
|
||
m_pTitleBar->setFixedHeight(30);
|
||
m_pMainLayout->addWidget(m_pTitleBar);
|
||
|
||
//validators for line editor
|
||
QRegularExpression portRegex("^(6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|6[0-4][0-9]{3}|[1-5][0-9]{4}|[1-9][0-9]{0,3}|0)$");
|
||
QRegularExpressionValidator * portValidator = new QRegularExpressionValidator(this);
|
||
portValidator->setRegularExpression(portRegex);
|
||
QRegularExpression ipRegex("^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$");
|
||
QRegularExpressionValidator * ipValidator = new QRegularExpressionValidator(this);
|
||
ipValidator->setRegularExpression(ipRegex);
|
||
QRegularExpression aeTitleRegex("^[0-9a-zA-Z_-]{1,16}$");
|
||
QRegularExpressionValidator * aeTitleValidator = new QRegularExpressionValidator(this);
|
||
aeTitleValidator->setRegularExpression(aeTitleRegex);
|
||
|
||
m_pOurInfoWidget = new QWidget(this);
|
||
m_pOurInfoLayout = new QHBoxLayout(this);
|
||
m_pOurPortLabel = new QLabel(m_pOurInfoWidget);
|
||
m_pOurPortLabel->setText(tr("Listening port:"));
|
||
m_pOurInfoLayout->addWidget(m_pOurPortLabel);
|
||
m_pOurPortEdit = new QLineEdit(m_pOurInfoWidget);
|
||
m_pOurPortEdit->setValidator(portValidator);
|
||
m_pOurInfoLayout->addWidget(m_pOurPortEdit);
|
||
m_pOurTitleLabel = new QLabel(m_pOurInfoWidget);
|
||
m_pOurTitleLabel->setText(tr("Local AE title:"));
|
||
m_pOurInfoLayout->addWidget(m_pOurTitleLabel);
|
||
m_pOurTitleEdit = new QLineEdit(m_pOurInfoWidget);
|
||
m_pOurTitleEdit->setValidator(aeTitleValidator);
|
||
m_pOurInfoLayout->addWidget(m_pOurTitleEdit);
|
||
m_AdvancedSettingsButton = new QPushButton(m_pOurInfoWidget);
|
||
m_AdvancedSettingsButton->setText(tr("Advanced settings"));
|
||
m_AdvancedSettingsButton->setVisible(false);
|
||
m_pOurInfoLayout->addWidget(m_AdvancedSettingsButton);
|
||
m_pOurInfoWidget->setLayout(m_pOurInfoLayout);
|
||
m_pMainLayout->addWidget(m_pOurInfoWidget);
|
||
|
||
m_pOurInfoEndLine = new QFrame(this);
|
||
m_pOurInfoEndLine->setFrameShape(QFrame::HLine);
|
||
m_pOurInfoEndLine->setFrameShadow(QFrame::Sunken);
|
||
m_pMainLayout->addWidget(m_pOurInfoEndLine);
|
||
|
||
m_pToolsWidget = new QWidget(this);
|
||
m_pToolsLayout = new QHBoxLayout(this);
|
||
m_pTitleLabel = new QLabel(m_pToolsWidget);
|
||
m_pTitleLabel->setText(tr("PACS location"));
|
||
m_pToolsLayout->addWidget(m_pTitleLabel);
|
||
m_pSpacerItem = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||
m_pToolsLayout->addItem(m_pSpacerItem);
|
||
m_pDelButton = new QPushButton(m_pToolsWidget);
|
||
QIcon delIcon;
|
||
delIcon.addPixmap(QPixmap(QString::fromUtf8(":/importwidget/Resources/import/remove.png")));
|
||
m_pDelButton->setIcon(delIcon);
|
||
m_pDelButton->setIconSize(QSize(22, 22));
|
||
m_pDelButton->setStyleSheet("QPushButton{background:rgba(0,0,0,0);border:1px solid rgba(0,0,0,0);}");
|
||
m_pToolsLayout->addWidget(m_pDelButton);
|
||
m_pToolsWidget->setLayout(m_pToolsLayout);
|
||
m_pMainLayout->addWidget(m_pToolsWidget);
|
||
|
||
initHeaderInfo();
|
||
m_pPacsInfo = new QTableView(this);
|
||
m_pPacsModel = new QStandardItemModel;
|
||
m_pPacsModel->setHorizontalHeaderLabels(m_lPacsInfoHeaders);
|
||
//m_pPacsSelectionModel = new QItemSelectionModel;
|
||
//m_pPacsInfo->setSelectionModel(m_pPacsSelectionModel);
|
||
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);
|
||
m_pPacsInfo->setMinimumHeight(123);
|
||
connect(m_pPacsInfo,&QTableView::customContextMenuRequested,this,&ConfigurationDialog::pacsMenuRequest);
|
||
m_pMainLayout->addWidget(m_pPacsInfo);
|
||
m_pPacsMenu = new QMenu(m_pPacsInfo);
|
||
QAction* cTestAction = new QAction(tr("Test connection"),m_pPacsMenu);
|
||
connect(cTestAction, &QAction::triggered,[=](){
|
||
ConnectionTestDialog testDialog(this);
|
||
// testDialog.setModal(true);
|
||
testDialog.startTest(m_pOurTitleEdit->text(), m_pPeerTitleEdit->text(), m_pPeerIpAddressEdit->text(),
|
||
m_pPeerPortEdit->text().toULong());
|
||
testDialog.exec();
|
||
});
|
||
m_pPacsMenu->addAction(cTestAction);
|
||
|
||
m_pEditWidget = new QWidget(this);
|
||
m_pEditLayout = new QGridLayout(this);
|
||
m_pEditWidget->setMinimumHeight(63);
|
||
m_pPeerIpAddressLabel = new QLabel(m_pEditWidget);
|
||
m_pPeerIpAddressLabel->setText(tr("IP address"));
|
||
m_pPeerIpAddressLabel->setAlignment(Qt::AlignLeft);
|
||
m_pEditLayout->addWidget(m_pPeerIpAddressLabel, 0, 0, 1, 3);
|
||
m_pPeerPortLabel = new QLabel(m_pEditWidget);
|
||
m_pPeerPortLabel->setText(tr("Port"));
|
||
m_pPeerPortLabel->setAlignment(Qt::AlignLeft);
|
||
m_pEditLayout->addWidget(m_pPeerPortLabel, 0, 3, 1, 1);
|
||
m_pPeerTitleLabel = new QLabel(m_pEditWidget);
|
||
m_pPeerTitleLabel->setText(tr("AE title"));
|
||
m_pPeerTitleLabel->setAlignment(Qt::AlignLeft);
|
||
m_pEditLayout->addWidget(m_pPeerTitleLabel, 0, 4, 1, 2);
|
||
m_pPeerDescritopnLabel = new QLabel(m_pEditWidget);
|
||
m_pPeerDescritopnLabel->setText(tr("Description"));
|
||
m_pPeerDescritopnLabel->setAlignment(Qt::AlignLeft);
|
||
m_pEditLayout->addWidget(m_pPeerDescritopnLabel, 0, 6, 1, 5);
|
||
|
||
m_pPeerIpAddressEdit = new QLineEdit(m_pEditWidget);
|
||
m_pPeerIpAddressEdit->setValidator(ipValidator);
|
||
m_pEditLayout->addWidget(m_pPeerIpAddressEdit, 1, 0, 1, 3);
|
||
m_pPeerPortEdit = new QLineEdit(m_pEditWidget);
|
||
m_pPeerPortEdit->setValidator(portValidator);
|
||
m_pEditLayout->addWidget(m_pPeerPortEdit, 1, 3, 1, 1);
|
||
m_pPeerTitleEdit = new QLineEdit(m_pEditWidget);
|
||
m_pPeerTitleEdit->setValidator(aeTitleValidator);
|
||
m_pEditLayout->addWidget(m_pPeerTitleEdit, 1, 4, 1, 2);
|
||
m_pPeerDescriptionEdit = new QLineEdit(m_pEditWidget);
|
||
m_pEditLayout->addWidget(m_pPeerDescriptionEdit, 1, 6, 1, 3);
|
||
m_pAddButton = new QPushButton(m_pEditWidget);
|
||
QIcon addIcon;
|
||
addIcon.addPixmap(QPixmap(QString::fromUtf8(":/importwidget/Resources/import/add.png")));
|
||
m_pAddButton->setIcon(addIcon);
|
||
m_pAddButton->setIconSize(QSize(22, 22));
|
||
m_pAddButton->setStyleSheet("QPushButton{background:rgba(0,0,0,0);border:1px solid rgba(0,0,0,0);}");
|
||
m_pEditLayout->addWidget(m_pAddButton, 1, 9, 1, 1);
|
||
m_pModifyButton = new QPushButton(m_pEditWidget);
|
||
QIcon modIcon;
|
||
modIcon.addPixmap(QPixmap(QString::fromUtf8(":/importwidget/Resources/import/arrow.png")));
|
||
m_pModifyButton->setIcon(modIcon);
|
||
m_pModifyButton->setIconSize(QSize(22, 22));
|
||
m_pModifyButton->setStyleSheet("QPushButton{background:rgba(0,0,0,0);border:1px solid rgba(0,0,0,0);}");
|
||
m_pEditLayout->addWidget(m_pModifyButton, 1, 10, 1, 1);
|
||
m_pEditWidget->setLayout(m_pEditLayout);
|
||
m_pMainLayout->addWidget(m_pEditWidget);
|
||
|
||
m_pEditEndLine = new QFrame(this);
|
||
m_pEditEndLine->setFrameShape(QFrame::HLine);
|
||
m_pEditEndLine->setFrameShadow(QFrame::Sunken);
|
||
m_pMainLayout->addWidget(m_pEditEndLine);
|
||
|
||
m_pActionWidget = new QWidget(this);
|
||
m_pActionLayout = new QHBoxLayout(m_pActionWidget);
|
||
m_pSpacerItem1 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||
m_pActionLayout->addItem(m_pSpacerItem1);
|
||
m_pSaveButton = new QPushButton(m_pActionWidget);
|
||
m_pSaveButton->setText(tr("Save"));
|
||
m_pActionLayout->addWidget(m_pSaveButton);
|
||
m_pCancelButton = new QPushButton(m_pActionWidget);
|
||
m_pCancelButton->setText(tr("Cancel"));
|
||
m_pActionLayout->addWidget(m_pCancelButton);
|
||
m_pMainLayout->addWidget(m_pActionWidget);
|
||
|
||
}
|
||
|
||
void ConfigurationDialog::initSys()
|
||
{
|
||
m_pTitleBar->installEventFilter(this);
|
||
connect(m_pTitleBar, SIGNAL(sigClose()), this, SLOT(close()));
|
||
connect(m_pDelButton, SIGNAL(clicked()), this, SLOT(del()));
|
||
connect(m_pAddButton, SIGNAL(clicked()), this, SLOT(add()));
|
||
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(pressed(const QModelIndex &)), this, SLOT(onSelected(const QModelIndex &)));
|
||
}
|
||
|
||
void ConfigurationDialog::initHeaderInfo()
|
||
{
|
||
m_lPacsInfoHeaders.clear();
|
||
m_lPacsInfoHeaders << tr("IP address") << tr("Port") << tr("AE title")
|
||
<< tr("Description") << tr("Retrieval protocol") << tr("Maximum active downloads Number")
|
||
<< tr("Preferred transfer syntax") << tr("Character set");
|
||
}
|
||
|
||
void ConfigurationDialog::initPacsInfo()
|
||
{
|
||
m_pOurPortEdit->setText(DicomViewerHelper::ourPort());
|
||
m_pOurTitleEdit->setText(DicomViewerHelper::ourTitle());
|
||
|
||
m_lHosts.clear();
|
||
DicomViewerHelper::pacsInfo(m_lHosts);
|
||
m_lHostsNew.clear();
|
||
DicomViewerHelper::pacsInfo(m_lHostsNew);
|
||
|
||
m_pPacsModel->clear();
|
||
m_pPacsModel->setHorizontalHeaderLabels(m_lPacsInfoHeaders);
|
||
int iRowIdx = 0;
|
||
for each (host var in m_lHostsNew)
|
||
{
|
||
////QList<QStandardItem*> list;
|
||
////list << new QStandardItem(var.ip) \
|
||
//// << new QStandardItem(var.port) \
|
||
//// << new QStandardItem(var.ae) \
|
||
//// << new QStandardItem(var.name) \
|
||
//// << new QStandardItem("C-MOVE") \
|
||
//// << new QStandardItem("1") \
|
||
//// << new QStandardItem("Explicit VR LE") \
|
||
//// << new QStandardItem("Default");
|
||
////m_pPacsModel->insertRow(iRowIdx, list);
|
||
////++iRowIdx;
|
||
|
||
QStandardItem* ip = new QStandardItem(var.ip); ip->setEditable(false);
|
||
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* 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);
|
||
QList<QStandardItem*> list;
|
||
list << ip << port << ae << name << protocol << count << xfers << cset;
|
||
m_pPacsModel->insertRow(iRowIdx, list);
|
||
++iRowIdx;
|
||
}
|
||
|
||
m_pPacsInfo->setModel(m_pPacsModel);
|
||
}
|
||
|
||
void ConfigurationDialog::updatePacsView()
|
||
{
|
||
m_pPacsModel->clear();
|
||
m_pPacsModel->setHorizontalHeaderLabels(m_lPacsInfoHeaders);
|
||
int iRowIdx = 0;
|
||
|
||
QList<host>::ConstIterator itr = m_lHostsNew.begin();
|
||
for (; itr != m_lHostsNew.end(); ++itr)
|
||
{
|
||
QStandardItem* ip = new QStandardItem(itr->ip); ip->setEditable(false);
|
||
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* 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);
|
||
QList<QStandardItem*> list;
|
||
list << ip << port << ae << name << protocol << count << xfers << cset;
|
||
m_pPacsModel->insertRow(iRowIdx, list);
|
||
++iRowIdx;
|
||
}
|
||
|
||
//for each (host var in m_lHostsNew)
|
||
//{
|
||
// QStandardItem* ip = new QStandardItem(var.ip); ip->setEditable(false);
|
||
// 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* 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);
|
||
// QList<QStandardItem*> list;
|
||
// list << ip << port << ae << name << protocol << count << xfers << cset;
|
||
// m_pPacsModel->insertRow(iRowIdx, list);
|
||
// ++iRowIdx;
|
||
//}
|
||
m_pPacsInfo->setModel(m_pPacsModel);
|
||
}
|
||
|
||
|
||
void ConfigurationDialog::clearModify()
|
||
{
|
||
m_pPeerIpAddressEdit->clear();
|
||
m_pPeerPortEdit->clear();
|
||
m_pPeerTitleEdit->clear();
|
||
m_pPeerDescriptionEdit->clear();
|
||
}
|
||
|
||
void ConfigurationDialog::close()
|
||
{
|
||
reject();
|
||
}
|
||
|
||
|
||
void ConfigurationDialog::del()
|
||
{
|
||
if (currentRow == -1)
|
||
return;
|
||
|
||
QString name = m_pPacsModel->index(currentRow, 3).data().toString();
|
||
for (int index = 0; index < m_lHostsNew.size(); ++index)
|
||
{
|
||
if (name == m_lHostsNew[index].name)
|
||
m_lHostsNew.removeAt(index);
|
||
}
|
||
|
||
//for each (host var in m_lHostsNew)
|
||
//{
|
||
// if (name == var.name)
|
||
// m_lHostsNew.removeAt(index);
|
||
// index++;
|
||
//}
|
||
|
||
updatePacsView();
|
||
clearModify();
|
||
}
|
||
|
||
void ConfigurationDialog::save()
|
||
{
|
||
DicomViewerHelper::setOurPort(m_pOurPortEdit->text());
|
||
DicomViewerHelper::setOurTitle(m_pOurTitleEdit->text());
|
||
DicomViewerHelper::setPacsInfo(m_lHostsNew);
|
||
emit updatePacsInfo();
|
||
reject();
|
||
}
|
||
|
||
void ConfigurationDialog::cancel()
|
||
{
|
||
reject();
|
||
}
|
||
|
||
// ֱ<><D6B1><EFBFBD>ж<EFBFBD>name<6D>Ƿ<EFBFBD><C7B7><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD>
|
||
void ConfigurationDialog::add()
|
||
{
|
||
QString name = m_pPeerDescriptionEdit->text();
|
||
if (name.isEmpty())
|
||
return;
|
||
|
||
bool bFound = false;
|
||
QList<host>::ConstIterator itr = m_lHostsNew.begin();
|
||
for (; itr != m_lHostsNew.end(); ++itr)
|
||
{
|
||
if (itr->name == name)
|
||
{
|
||
bFound = true;
|
||
break;
|
||
}
|
||
}
|
||
|
||
//for each (host var in m_lHostsNew)
|
||
//{
|
||
// if (var.name == name)
|
||
// {
|
||
// bFound = true;
|
||
// break;
|
||
// }
|
||
//}
|
||
|
||
if (bFound)
|
||
{
|
||
if (m_pMsgDialog == nullptr)
|
||
m_pMsgDialog = new PromptDialog("Alreay existed", this);
|
||
m_pMsgDialog->exec();
|
||
return;
|
||
}
|
||
|
||
host h;
|
||
h.name = name;
|
||
h.ae = m_pPeerTitleEdit->text();
|
||
h.ip = m_pPeerIpAddressEdit->text();
|
||
h.port = m_pPeerPortEdit->text();
|
||
m_lHostsNew.push_back(h);
|
||
|
||
updatePacsView();
|
||
clearModify();
|
||
}
|
||
|
||
// <20><>ǰѡ<C7B0>к<EFBFBD><D0BA>ĵ<DEB8>name<6D>Ƿ<EFBFBD>һ<EFBFBD>£<EFBFBD><C2A3><EFBFBD><EFBFBD>һ<EFBFBD>£<EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>ĵ<DEB8>ǰѡ<C7B0><D1A1>
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>£<EFBFBD><C2A3>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><DAA3>ĵ<DEB8>ǰѡ<C7B0><D1A1>
|
||
void ConfigurationDialog::modify()
|
||
{
|
||
if (currentRow == -1)
|
||
return;
|
||
|
||
QString selectedName = m_pPacsModel->index(currentRow, 3).data().toString();
|
||
QString addName = m_pPeerDescriptionEdit->text();
|
||
if (selectedName == addName)
|
||
{
|
||
QList<host>::iterator itr = m_lHostsNew.begin();
|
||
for (; itr != m_lHostsNew.end(); ++itr)
|
||
{
|
||
if (addName == itr->name)
|
||
{
|
||
itr->name = addName;
|
||
itr->ae = m_pPeerTitleEdit->text();
|
||
itr->ip = m_pPeerIpAddressEdit->text();
|
||
itr->port = m_pPeerPortEdit->text();
|
||
updatePacsView();
|
||
return;
|
||
}
|
||
}
|
||
|
||
//for each (host var in m_lHostsNew)
|
||
//{
|
||
// if (addName == var.name)
|
||
// {
|
||
// var.name = addName;
|
||
// var.ae = m_pPeerTitleEdit->text();
|
||
// var.ip = m_pPeerIpAddressEdit->text();
|
||
// var.port = m_pPeerPortEdit->text();
|
||
// updatePacsView();
|
||
// return;
|
||
// }
|
||
//}
|
||
}
|
||
else
|
||
{
|
||
bool bFound = false;
|
||
QList<host>::iterator itr = m_lHostsNew.begin();
|
||
for (; itr != m_lHostsNew.end(); ++itr)
|
||
{
|
||
if (addName == itr->name)
|
||
{
|
||
bFound = true;
|
||
break;
|
||
}
|
||
}
|
||
|
||
//for each (host var in m_lHostsNew)
|
||
//{
|
||
// if (addName == var.name)
|
||
// {
|
||
// bFound = true;
|
||
// break;
|
||
// }
|
||
//}
|
||
if (bFound)
|
||
{
|
||
if (m_pMsgDialog == nullptr)
|
||
m_pMsgDialog = new PromptDialog("Alreay existed", this);
|
||
m_pMsgDialog->exec();
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
itr = m_lHostsNew.begin();
|
||
for (; itr != m_lHostsNew.end(); ++itr)
|
||
{
|
||
if (selectedName == itr->name) // <20><><EFBFBD>ﲻҪ<EFB2BB><D2AA><EFBFBD><EFBFBD>ˣ<EFBFBD><CBA3><EFBFBD>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD>ѡ<EFBFBD>е<EFBFBD><D0B5><EFBFBD>һ<EFBFBD><D2BB>
|
||
{
|
||
itr->name = addName;
|
||
itr->ae = m_pPeerTitleEdit->text();
|
||
itr->ip = m_pPeerIpAddressEdit->text();
|
||
itr->port = m_pPeerPortEdit->text();
|
||
updatePacsView();
|
||
return;
|
||
}
|
||
}
|
||
//for each (host var in m_lHostsNew)
|
||
//{
|
||
// if (selectedName == var.name) // <20><><EFBFBD>ﲻҪ<EFB2BB><D2AA><EFBFBD><EFBFBD>ˣ<EFBFBD><CBA3><EFBFBD>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD>ѡ<EFBFBD>е<EFBFBD><D0B5><EFBFBD>һ<EFBFBD><D2BB>
|
||
// {
|
||
// var.name = addName;
|
||
// var.ae = m_pPeerTitleEdit->text();
|
||
// var.ip = m_pPeerIpAddressEdit->text();
|
||
// var.port = m_pPeerPortEdit->text();
|
||
// updatePacsView();
|
||
// return;
|
||
// }
|
||
//}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
void ConfigurationDialog::onSelected(const QModelIndex ¤t)
|
||
{
|
||
int row = current.row();
|
||
currentRow = row;
|
||
if (row < 0)
|
||
return;
|
||
QString name = m_pPacsModel->index(row, 3).data().toString();
|
||
QList<host>::ConstIterator itr = m_lHostsNew.begin();
|
||
for (; itr != m_lHostsNew.end(); ++itr)
|
||
{
|
||
if (name == itr->name)
|
||
{
|
||
m_pPeerIpAddressEdit->setText(itr->ip);
|
||
m_pPeerPortEdit->setText(itr->port);
|
||
m_pPeerTitleEdit->setText(itr->ae);
|
||
m_pPeerDescriptionEdit->setText(itr->name);
|
||
}
|
||
}
|
||
|
||
//for each (host var in m_lHostsNew)
|
||
//{
|
||
// if (name == var.name)
|
||
// {
|
||
// m_pPeerIpAddressEdit->setText(var.ip);
|
||
// m_pPeerPortEdit->setText(var.port);
|
||
// m_pPeerTitleEdit->setText(var.ae);
|
||
// m_pPeerDescriptionEdit->setText(var.name);
|
||
// }
|
||
//}
|
||
}
|
||
|
||
void ConfigurationDialog::onTitleBarDestroyed()
|
||
{
|
||
if (m_pTitleBar == QObject::sender())
|
||
{
|
||
m_pTitleBar = Q_NULLPTR;
|
||
}
|
||
}
|
||
|
||
bool ConfigurationDialog::eventFilter(QObject *obj, QEvent *event)
|
||
{
|
||
if (m_pTitleBar == obj)
|
||
{
|
||
if (event->type() == QEvent::MouseButtonPress)
|
||
{
|
||
QRect dragArea = m_pTitleBar->geometry();
|
||
if (dragArea.contains(mapFromGlobal(QCursor::pos())) && !this->isMaximized())
|
||
{
|
||
m_dragState.dragging = true;
|
||
m_dragState.dragStartPosition = QCursor::pos();
|
||
}
|
||
}
|
||
else if (event->type() == QEvent::MouseButtonRelease)
|
||
{
|
||
m_dragState.dragging = false;
|
||
}
|
||
else if (m_dragState.dragging && event->type() == QEvent::MouseMove)
|
||
{
|
||
const QPoint& curPos = QCursor::pos();
|
||
this->move(this->geometry().topLeft() + (curPos - m_dragState.dragStartPosition));
|
||
m_dragState.dragStartPosition = curPos;
|
||
}
|
||
}
|
||
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);
|
||
m_pPacsMenu->exec(QCursor::pos());
|
||
}
|
||
|