Skip to content

Commit

Permalink
Feature: Start Adding Node Commands - RefreshNodeInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
Fishwaldo committed Jun 23, 2020
1 parent 5be009f commit da04ebf
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 16 deletions.
11 changes: 9 additions & 2 deletions ozwadmin-main/controllercommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ ControllerCommands::ControllerCommands(QMainWindow *parent) :


void ControllerCommands::addNode() {



this->m_command = ControllerCommands::Command_addNode;
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);
if (ret == QMessageBox::Cancel) {
Expand Down Expand Up @@ -334,6 +333,14 @@ void ControllerCommands::controllerCommandNotification(quint8 node, Notification
}
}
}
}
}

void ControllerCommands::refreshNodeInfo(quint8 node)
{
QMessageBox::StandardButton ret = QMessageBox::question(qobject_cast<QMainWindow*>(this->parent()), "Refresh Node?", "Refreshing the Node?", QMessageBox::Yes|QMessageBox::No);
if (ret == QMessageBox::No) {
return;
}
OZWCore::get()->getQTOZWManager()->refreshNodeInfo(node);
}
3 changes: 2 additions & 1 deletion ozwadmin-main/controllercommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ class ControllerCommands : public QObject
explicit ControllerCommands(QMainWindow *parent = nullptr);
enum Command {Command_addNode, Command_delNode, Command_healNetwork, Command_cancel, Command_none};
Q_ENUM(Command);

public slots:
void addNode();
void delNode();
void healNetwork();
void cancelCommand();

void controllerCommandNotification(quint8 node, NotificationTypes::QTOZW_Notification_Controller_Cmd command, NotificationTypes::QTOZW_Notification_Controller_State state, NotificationTypes::QTOZW_Notification_Controller_Error error);
void refreshNodeInfo(quint8 node);
private:
QMessageBox m_msgBox;
Command m_command;
Expand Down
4 changes: 2 additions & 2 deletions ozwadmin-main/eventwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
</property>
<property name="icon">
<iconset resource="ozwadmin-main.qrc">
<normaloff>:/res/buttonIcons/play.svg</normaloff>
<normalon>:/res/buttonIcons/pause.svg</normalon>:/res/buttonIcons/play.svg</iconset>
<normaloff>:/res/buttonIcons/pause.svg</normaloff>
<normalon>:/res/buttonIcons/play.svg</normalon>:/res/buttonIcons/pause.svg</iconset>
</property>
<property name="iconSize">
<size>
Expand Down
1 change: 1 addition & 0 deletions ozwadmin-main/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ void MainWindow::openDefaultWindows() {
connect(this->ntw, &nodeTableWidget::currentRowChanged, this, &MainWindow::NodeSelected);
connect(this->ntw, &nodeTableWidget::currentRowChanged, di, &DeviceInfo::NodeSelected);
connect(this->ntw, &nodeTableWidget::currentRowChanged, ni, &NodeStatus::NodeSelected);
connect(this->ntw, &nodeTableWidget::refreshNodeInfo, this->m_controllerCommands, &ControllerCommands::refreshNodeInfo);
connect(this->sbMsg, &statusBarMessages::newMessage, ew, &EventWindow::newEvent);
connect(di, &DeviceInfo::openMetaDataWindow, this, &MainWindow::openMetaDataWindow);

Expand Down
28 changes: 23 additions & 5 deletions ozwadmin-main/nodetablewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ nodeTableWidget::nodeTableWidget(QWidget *parent) :
ui(new Ui::nodeTableWidget)
{
this->ui->setupUi(this);
this->ui->verticalLayout->insertWidget(0, &this->tb);

Node_Delegate *nodeflagdelegate = new Node_Delegate(this);

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

this->ui->nodeList->setContextMenuPolicy(Qt::CustomContextMenu);
connect(this->ui->nodeList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(rightClickMenu(QPoint)));

this->tb.insertAction(nullptr, this->ui->actionRefresh_Node_Info);
connect(this->ui->actionRefresh_Node_Info, &QAction::triggered, this, &nodeTableWidget::refreshNodeInfoTriggered);

}

nodeTableWidget::~nodeTableWidget()
Expand All @@ -51,6 +57,7 @@ void nodeTableWidget::setModel(QAbstractItemModel *model)
}
}
connect(ui->nodeList->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &nodeTableWidget::currentRowChanged);
connect(ui->nodeList->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &nodeTableWidget::updateSelectedNode);
connect(proxyNodeList, &QTOZW_proxyNodeModel::rowsInserted, this, &nodeTableWidget::resizeContents);
connect(proxyNodeList, &QTOZW_proxyNodeModel::rowsRemoved, this, &nodeTableWidget::resizeContents);
QTimer::singleShot(500, this, &nodeTableWidget::resizeContents);
Expand All @@ -67,15 +74,26 @@ QItemSelectionModel *nodeTableWidget::selectionModel()

void nodeTableWidget::rightClickMenu(QPoint pos)
{
//QModelIndex index=this->ui->nodeList->indexAt(pos);

QMenu *menu=new QMenu(this);
menu->addAction(new QAction("Action 1", this));
menu->addAction(new QAction("Action 2", this));
menu->addAction(new QAction("Action 3", this));
menu->addAction(this->ui->actionRefresh_Node_Info);
menu->popup(this->ui->nodeList->viewport()->mapToGlobal(pos));
}

void nodeTableWidget::updateSelectedNode(const QModelIndex &current, const QModelIndex &previous)
{
Q_UNUSED(previous);
this->ui->actionRefresh_Node_Info->setData(current.model()->data(current.model()->index(current.row(), QTOZW_Nodes::NodeID)).toInt());
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()));
}

void nodeTableWidget::refreshNodeInfoTriggered() {
quint8 node = this->ui->actionRefresh_Node_Info->data().toInt();
emit this->refreshNodeInfo(node);
}




void nodeTableWidget::resizeContents() {
this->ui->nodeList->resizeColumnsToContents();
if (!this->ui->nodeList->selectionModel()->hasSelection()) {
Expand Down
5 changes: 5 additions & 0 deletions ozwadmin-main/nodetablewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <QPoint>
#include <qabstractitemmodel.h>
#include <qitemselectionmodel.h>
#include <QToolBar>


namespace Ui {
Expand All @@ -23,13 +24,17 @@ class nodeTableWidget : public QWidget
QItemSelectionModel *selectionModel();
Q_SIGNALS:
void currentRowChanged(const QModelIndex &current, const QModelIndex &previous);
void refreshNodeInfo(const quint8 node);
public Q_SLOTS:
void rightClickMenu(QPoint pos);
private slots:
void resizeContents();
void updateSelectedNode(const QModelIndex &current, const QModelIndex &previous);
void refreshNodeInfoTriggered();

private:
Ui::nodeTableWidget *ui;
QToolBar tb;
};

#endif // NODETABLEWIDGET_H
23 changes: 17 additions & 6 deletions ozwadmin-main/nodetablewidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
Expand All @@ -26,18 +29,26 @@
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<item>
<widget class="QTableView" name="nodeList">
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
</widget>
</item>
</layout>
<action name="actionRefresh_Node_Info">
<property name="icon">
<iconset resource="ozwadmin-main.qrc">
<normaloff>:/res/buttonIcons/refresh.svg</normaloff>:/res/buttonIcons/refresh.svg</iconset>
</property>
<property name="text">
<string>Refresh Node Info</string>
</property>
</action>
</widget>
<resources/>
<resources>
<include location="ozwadmin-main.qrc"/>
</resources>
<connections/>
</ui>
1 change: 1 addition & 0 deletions ozwadmin-main/ozwadmin-main.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
<file>res/start.svg</file>
<file>res/buttonIcons/pause.svg</file>
<file>res/buttonIcons/play.svg</file>
<file>res/buttonIcons/refresh.svg</file>
</qresource>
</RCC>
7 changes: 7 additions & 0 deletions ozwadmin-main/res/buttonIcons/refresh.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit da04ebf

Please sign in to comment.