Skip to content

Commit da04ebf

Browse files
committed
Feature: Start Adding Node Commands - RefreshNodeInfo
1 parent 5be009f commit da04ebf

9 files changed

Lines changed: 67 additions & 16 deletions

File tree

ozwadmin-main/controllercommands.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ ControllerCommands::ControllerCommands(QMainWindow *parent) :
1313

1414

1515
void ControllerCommands::addNode() {
16-
17-
16+
1817
this->m_command = ControllerCommands::Command_addNode;
1918
QMessageBox::StandardButton ret = QMessageBox::question(qobject_cast<QMainWindow*>(this->parent()), "Include Secure?", "Do you wish to include the new device with encryption?", QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel);
2019
if (ret == QMessageBox::Cancel) {
@@ -334,6 +333,14 @@ void ControllerCommands::controllerCommandNotification(quint8 node, Notification
334333
}
335334
}
336335
}
336+
}
337+
}
337338

339+
void ControllerCommands::refreshNodeInfo(quint8 node)
340+
{
341+
QMessageBox::StandardButton ret = QMessageBox::question(qobject_cast<QMainWindow*>(this->parent()), "Refresh Node?", "Refreshing the Node?", QMessageBox::Yes|QMessageBox::No);
342+
if (ret == QMessageBox::No) {
343+
return;
338344
}
345+
OZWCore::get()->getQTOZWManager()->refreshNodeInfo(node);
339346
}

ozwadmin-main/controllercommands.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ class ControllerCommands : public QObject
1414
explicit ControllerCommands(QMainWindow *parent = nullptr);
1515
enum Command {Command_addNode, Command_delNode, Command_healNetwork, Command_cancel, Command_none};
1616
Q_ENUM(Command);
17+
1718
public slots:
1819
void addNode();
1920
void delNode();
2021
void healNetwork();
2122
void cancelCommand();
22-
2323
void controllerCommandNotification(quint8 node, NotificationTypes::QTOZW_Notification_Controller_Cmd command, NotificationTypes::QTOZW_Notification_Controller_State state, NotificationTypes::QTOZW_Notification_Controller_Error error);
24+
void refreshNodeInfo(quint8 node);
2425
private:
2526
QMessageBox m_msgBox;
2627
Command m_command;

ozwadmin-main/eventwindow.ui

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
</property>
2222
<property name="icon">
2323
<iconset resource="ozwadmin-main.qrc">
24-
<normaloff>:/res/buttonIcons/play.svg</normaloff>
25-
<normalon>:/res/buttonIcons/pause.svg</normalon>:/res/buttonIcons/play.svg</iconset>
24+
<normaloff>:/res/buttonIcons/pause.svg</normaloff>
25+
<normalon>:/res/buttonIcons/play.svg</normalon>:/res/buttonIcons/pause.svg</iconset>
2626
</property>
2727
<property name="iconSize">
2828
<size>

ozwadmin-main/mainwindow.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ void MainWindow::openDefaultWindows() {
145145
connect(this->ntw, &nodeTableWidget::currentRowChanged, this, &MainWindow::NodeSelected);
146146
connect(this->ntw, &nodeTableWidget::currentRowChanged, di, &DeviceInfo::NodeSelected);
147147
connect(this->ntw, &nodeTableWidget::currentRowChanged, ni, &NodeStatus::NodeSelected);
148+
connect(this->ntw, &nodeTableWidget::refreshNodeInfo, this->m_controllerCommands, &ControllerCommands::refreshNodeInfo);
148149
connect(this->sbMsg, &statusBarMessages::newMessage, ew, &EventWindow::newEvent);
149150
connect(di, &DeviceInfo::openMetaDataWindow, this, &MainWindow::openMetaDataWindow);
150151

ozwadmin-main/nodetablewidget.cpp

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ nodeTableWidget::nodeTableWidget(QWidget *parent) :
1515
ui(new Ui::nodeTableWidget)
1616
{
1717
this->ui->setupUi(this);
18+
this->ui->verticalLayout->insertWidget(0, &this->tb);
19+
1820
Node_Delegate *nodeflagdelegate = new Node_Delegate(this);
1921

2022
this->ui->nodeList->setItemDelegateForColumn(QTOZW_Nodes::NodeColumns::NodeFlags, nodeflagdelegate);
@@ -27,6 +29,10 @@ nodeTableWidget::nodeTableWidget(QWidget *parent) :
2729

2830
this->ui->nodeList->setContextMenuPolicy(Qt::CustomContextMenu);
2931
connect(this->ui->nodeList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(rightClickMenu(QPoint)));
32+
33+
this->tb.insertAction(nullptr, this->ui->actionRefresh_Node_Info);
34+
connect(this->ui->actionRefresh_Node_Info, &QAction::triggered, this, &nodeTableWidget::refreshNodeInfoTriggered);
35+
3036
}
3137

3238
nodeTableWidget::~nodeTableWidget()
@@ -51,6 +57,7 @@ void nodeTableWidget::setModel(QAbstractItemModel *model)
5157
}
5258
}
5359
connect(ui->nodeList->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &nodeTableWidget::currentRowChanged);
60+
connect(ui->nodeList->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &nodeTableWidget::updateSelectedNode);
5461
connect(proxyNodeList, &QTOZW_proxyNodeModel::rowsInserted, this, &nodeTableWidget::resizeContents);
5562
connect(proxyNodeList, &QTOZW_proxyNodeModel::rowsRemoved, this, &nodeTableWidget::resizeContents);
5663
QTimer::singleShot(500, this, &nodeTableWidget::resizeContents);
@@ -67,15 +74,26 @@ QItemSelectionModel *nodeTableWidget::selectionModel()
6774

6875
void nodeTableWidget::rightClickMenu(QPoint pos)
6976
{
70-
//QModelIndex index=this->ui->nodeList->indexAt(pos);
71-
7277
QMenu *menu=new QMenu(this);
73-
menu->addAction(new QAction("Action 1", this));
74-
menu->addAction(new QAction("Action 2", this));
75-
menu->addAction(new QAction("Action 3", this));
78+
menu->addAction(this->ui->actionRefresh_Node_Info);
7679
menu->popup(this->ui->nodeList->viewport()->mapToGlobal(pos));
7780
}
7881

82+
void nodeTableWidget::updateSelectedNode(const QModelIndex &current, const QModelIndex &previous)
83+
{
84+
Q_UNUSED(previous);
85+
this->ui->actionRefresh_Node_Info->setData(current.model()->data(current.model()->index(current.row(), QTOZW_Nodes::NodeID)).toInt());
86+
this->ui->actionRefresh_Node_Info->setToolTip(QString("Refresh Node Info for Node %1").arg(current.model()->data(current.model()->index(current.row(), QTOZW_Nodes::NodeID)).toInt()));
87+
}
88+
89+
void nodeTableWidget::refreshNodeInfoTriggered() {
90+
quint8 node = this->ui->actionRefresh_Node_Info->data().toInt();
91+
emit this->refreshNodeInfo(node);
92+
}
93+
94+
95+
96+
7997
void nodeTableWidget::resizeContents() {
8098
this->ui->nodeList->resizeColumnsToContents();
8199
if (!this->ui->nodeList->selectionModel()->hasSelection()) {

ozwadmin-main/nodetablewidget.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <QPoint>
66
#include <qabstractitemmodel.h>
77
#include <qitemselectionmodel.h>
8+
#include <QToolBar>
89

910

1011
namespace Ui {
@@ -23,13 +24,17 @@ class nodeTableWidget : public QWidget
2324
QItemSelectionModel *selectionModel();
2425
Q_SIGNALS:
2526
void currentRowChanged(const QModelIndex &current, const QModelIndex &previous);
27+
void refreshNodeInfo(const quint8 node);
2628
public Q_SLOTS:
2729
void rightClickMenu(QPoint pos);
2830
private slots:
2931
void resizeContents();
32+
void updateSelectedNode(const QModelIndex &current, const QModelIndex &previous);
33+
void refreshNodeInfoTriggered();
3034

3135
private:
3236
Ui::nodeTableWidget *ui;
37+
QToolBar tb;
3338
};
3439

3540
#endif // NODETABLEWIDGET_H

ozwadmin-main/nodetablewidget.ui

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
<property name="windowTitle">
1414
<string>Form</string>
1515
</property>
16-
<layout class="QGridLayout" name="gridLayout">
16+
<layout class="QVBoxLayout" name="verticalLayout">
17+
<property name="spacing">
18+
<number>0</number>
19+
</property>
1720
<property name="leftMargin">
1821
<number>0</number>
1922
</property>
@@ -26,18 +29,26 @@
2629
<property name="bottomMargin">
2730
<number>0</number>
2831
</property>
29-
<property name="spacing">
30-
<number>0</number>
31-
</property>
32-
<item row="0" column="0">
32+
<item>
3333
<widget class="QTableView" name="nodeList">
3434
<attribute name="horizontalHeaderStretchLastSection">
3535
<bool>true</bool>
3636
</attribute>
3737
</widget>
3838
</item>
3939
</layout>
40+
<action name="actionRefresh_Node_Info">
41+
<property name="icon">
42+
<iconset resource="ozwadmin-main.qrc">
43+
<normaloff>:/res/buttonIcons/refresh.svg</normaloff>:/res/buttonIcons/refresh.svg</iconset>
44+
</property>
45+
<property name="text">
46+
<string>Refresh Node Info</string>
47+
</property>
48+
</action>
4049
</widget>
41-
<resources/>
50+
<resources>
51+
<include location="ozwadmin-main.qrc"/>
52+
</resources>
4253
<connections/>
4354
</ui>

ozwadmin-main/ozwadmin-main.qrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
<file>res/start.svg</file>
1515
<file>res/buttonIcons/pause.svg</file>
1616
<file>res/buttonIcons/play.svg</file>
17+
<file>res/buttonIcons/refresh.svg</file>
1718
</qresource>
1819
</RCC>
Lines changed: 7 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)