From 9d97fefad3cdb5a0d0e203b524a93156cd14494b Mon Sep 17 00:00:00 2001 From: Srivats P Date: Mon, 21 Jan 2019 19:18:36 +0530 Subject: [PATCH] Add Resolve/Clear buttons to Device Info window Fixes #189 --- client/deviceswidget.cpp | 46 +++++++++++++++++++++++++-- client/deviceswidget.h | 4 +++ client/deviceswidget.ui | 67 ++++++++++++++++++++++++++++++++-------- 3 files changed, 102 insertions(+), 15 deletions(-) diff --git a/client/deviceswidget.cpp b/client/deviceswidget.cpp index 64bbbfe..1a4b303 100644 --- a/client/deviceswidget.cpp +++ b/client/deviceswidget.cpp @@ -32,7 +32,7 @@ DevicesWidget::DevicesWidget(QWidget *parent) setupUi(this); deviceGroupList->setVisible(deviceConfig->isChecked()); deviceList->setVisible(deviceInfo->isChecked()); - refresh->setVisible(deviceInfo->isChecked()); + setDeviceInfoButtonsVisible(deviceInfo->isChecked()); deviceDetail->hide(); deviceGroupList->verticalHeader()->setDefaultSectionSize( @@ -162,7 +162,7 @@ void DevicesWidget::updateDeviceViewActions() void DevicesWidget::on_deviceInfo_toggled(bool checked) { - refresh->setVisible(checked); + setDeviceInfoButtonsVisible(checked); deviceGroupList->setHidden(checked); deviceList->setVisible(checked); deviceDetail->hide(); @@ -236,6 +236,40 @@ void DevicesWidget::on_refresh_clicked() .getDeviceInfo(portGroups_->port(currentPortIndex_).id()); } +void DevicesWidget::on_resolveNeighbors_clicked() +{ + if (!portGroups_) + return; + + Q_ASSERT(portGroups_->isPort(currentPortIndex_)); + QModelIndex curPortGroup = portGroups_->getPortModel() + ->parent(currentPortIndex_); + Q_ASSERT(curPortGroup.isValid()); + Q_ASSERT(portGroups_->isPortGroup(curPortGroup)); + + deviceDetail->hide(); + QList portList({portGroups_->port(currentPortIndex_).id()}); + portGroups_->portGroup(curPortGroup).resolveDeviceNeighbors(&portList); + portGroups_->portGroup(curPortGroup).getDeviceInfo(portList.at(0)); +} + +void DevicesWidget::on_clearNeighbors_clicked() +{ + if (!portGroups_) + return; + + Q_ASSERT(portGroups_->isPort(currentPortIndex_)); + QModelIndex curPortGroup = portGroups_->getPortModel() + ->parent(currentPortIndex_); + Q_ASSERT(curPortGroup.isValid()); + Q_ASSERT(portGroups_->isPortGroup(curPortGroup)); + + deviceDetail->hide(); + QList portList({portGroups_->port(currentPortIndex_).id()}); + portGroups_->portGroup(curPortGroup).clearDeviceNeighbors(&portList); + portGroups_->portGroup(curPortGroup).getDeviceInfo(portList.at(0)); +} + void DevicesWidget::when_deviceList_currentChanged(const QModelIndex &index) { if (!index.isValid() || !portGroups_) @@ -247,3 +281,11 @@ void DevicesWidget::when_deviceList_currentChanged(const QModelIndex &index) deviceDetail->setModel(detailModel); deviceDetail->setVisible(detailModel != NULL); } + +void DevicesWidget::setDeviceInfoButtonsVisible(bool show) +{ + refresh->setVisible(show); + arpNdpLabel->setVisible(show); + resolveNeighbors->setVisible(show); + clearNeighbors->setVisible(show); +} diff --git a/client/deviceswidget.h b/client/deviceswidget.h index d5ef524..d1eb38c 100644 --- a/client/deviceswidget.h +++ b/client/deviceswidget.h @@ -49,10 +49,14 @@ private slots: void on_deviceGroupList_activated(const QModelIndex &index); void on_refresh_clicked(); + void on_resolveNeighbors_clicked(); + void on_clearNeighbors_clicked(); void when_deviceList_currentChanged(const QModelIndex &index); private: + void setDeviceInfoButtonsVisible(bool show); + PortGroupList *portGroups_; QModelIndex currentPortIndex_; }; diff --git a/client/deviceswidget.ui b/client/deviceswidget.ui index 2e09917..ec76836 100644 --- a/client/deviceswidget.ui +++ b/client/deviceswidget.ui @@ -36,19 +36,6 @@ - - - - Qt::Horizontal - - - - 131 - 23 - - - - @@ -66,6 +53,60 @@ + + + + Qt::Horizontal + + + + 131 + 23 + + + + + + + + ARP/ND + + + + + + + Resolve Neighbors + + + Resolve Device Neighbors on selected port(s) + + + + + + + :/icons/neighbor_resolve.png:/icons/neighbor_resolve.png + + + + + + + Clear Neighbors + + + Clear Device Neighbors on selected port(s) + + + + + + + :/icons/neighbor_clear.png:/icons/neighbor_clear.png + + +