mirror of
https://github.com/Fishwaldo/ozw-admin.git
synced 2025-03-16 03:41:39 +00:00
Start Work on Dialogs for Controller Commands
This commit is contained in:
parent
1ad62549d9
commit
29fba4f4d6
11 changed files with 335 additions and 142 deletions
21
.vscode/c_cpp_properties.json
vendored
21
.vscode/c_cpp_properties.json
vendored
|
@ -13,7 +13,26 @@
|
|||
"compilerPath": "/usr/bin/gcc",
|
||||
"cStandard": "c11",
|
||||
"cppStandard": "c++17",
|
||||
"intelliSenseMode": "clang-x64"
|
||||
"intelliSenseMode": "clang-x64",
|
||||
"compileCommands": "${workspaceFolder}/compile_commands.json"
|
||||
},
|
||||
{
|
||||
"name": "Mac",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/**",
|
||||
"${workspaceFolder}/../open-zwave/cpp/src/**",
|
||||
"${workspaceFolder}/../qt-openzwave/qt-openzwave/include/**",
|
||||
"${workspaceFolder}/../qt-openzwave/qt-openzwavedatabase/include/**"
|
||||
],
|
||||
"macFrameworkPath": [
|
||||
"/Users/fish/Qt/5.12.6/clang_64/lib/"
|
||||
],
|
||||
"defines": [],
|
||||
"compilerPath": "/usr/bin/gcc",
|
||||
"cStandard": "c11",
|
||||
"cppStandard": "c++17",
|
||||
"intelliSenseMode": "clang-x64",
|
||||
"compileCommands": "${workspaceFolder}/compile_commands.json"
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
|
|
42
ozwadmin-main/controllercommands.cpp
Normal file
42
ozwadmin-main/controllercommands.cpp
Normal file
|
@ -0,0 +1,42 @@
|
|||
#include <QMessageBox>
|
||||
#include "controllercommands.h"
|
||||
|
||||
|
||||
|
||||
ControllerCommands::ControllerCommands(QMainWindow *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ControllerCommands::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) {
|
||||
return;
|
||||
}
|
||||
this->m_msgBox = new QMessageBox(QMessageBox::Information, "Adding Node", "Starting....", QMessageBox::Cancel, qobject_cast<QMainWindow*>(this->parent()));
|
||||
this->m_msgBox->setDetailedText("Waiting for the Controller to Enter AddNode Mode...");
|
||||
connect(this->m_msgBox, &QMessageBox::rejected, this, &ControllerCommands::cancelCommand);
|
||||
this->m_msgBox->show();
|
||||
if (ret == QMessageBox::Yes) {
|
||||
OZWCore::get()->getQTOZWManager()->addNode(true);
|
||||
} else if (ret == QMessageBox::No) {
|
||||
OZWCore::get()->getQTOZWManager()->addNode(false);
|
||||
}
|
||||
}
|
||||
void ControllerCommands::delNode() {
|
||||
OZWCore::get()->getQTOZWManager()->removeNode();
|
||||
}
|
||||
void ControllerCommands::healNetwork() {
|
||||
QMessageBox::StandardButton ret = QMessageBox::information(qobject_cast<QMainWindow*>(this->parent()), "Heal Network", "Healing the Network Should only be performed after Adding/Removing or Physically Moving Mains Powered Devices. Are you sure?", QMessageBox::Ok|QMessageBox::Cancel);
|
||||
if (ret == QMessageBox::Ok) {
|
||||
OZWCore::get()->getQTOZWManager()->healNetwork(false);
|
||||
}
|
||||
}
|
||||
void ControllerCommands::cancelCommand() {
|
||||
QMessageBox::StandardButton ret = QMessageBox::question(qobject_cast<QMainWindow*>(this->parent()), "Cancel Command", "Are you sure you wish to cancel the command?");
|
||||
if (ret == QMessageBox::Yes) {
|
||||
OZWCore::get()->getQTOZWManager()->cancelControllerCommand();
|
||||
}
|
||||
}
|
||||
|
25
ozwadmin-main/controllercommands.h
Normal file
25
ozwadmin-main/controllercommands.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
#ifndef CONTROLLERCOMMANDS_H
|
||||
#define CONTROLLERCOMMANDS_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QMainWindow>
|
||||
#include "ozwcore.h"
|
||||
|
||||
class OZWCore;
|
||||
|
||||
class ControllerCommands : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ControllerCommands(QMainWindow *parent = nullptr);
|
||||
|
||||
public slots:
|
||||
void addNode();
|
||||
void delNode();
|
||||
void healNetwork();
|
||||
void cancelCommand();
|
||||
private:
|
||||
QMessageBox *m_msgBox;
|
||||
};
|
||||
|
||||
#endif // CONTROLLERCOMMANDS_H
|
|
@ -19,11 +19,10 @@
|
|||
#include <QInputDialog>
|
||||
#include <QSettings>
|
||||
#include <QFileInfo>
|
||||
#include <QMessageBox>
|
||||
#include <QFileDialog>
|
||||
#include <QStandardPaths>
|
||||
|
||||
#include <qt-openzwave/qt-openzwavedatabase.h>
|
||||
|
||||
|
||||
#include <qt-openzwave/qtozwoptions.h>
|
||||
#include <qt-openzwave/qtozw_pods.h>
|
||||
|
@ -46,11 +45,6 @@
|
|||
#include "ozwcore.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow),
|
||||
|
@ -58,9 +52,15 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
{
|
||||
this->ui->setupUi(this);
|
||||
this->m_DockManager = new ads::CDockManager(this);
|
||||
this->m_controllerCommands = new ControllerCommands(this);
|
||||
this->connected(false);
|
||||
|
||||
|
||||
connect(OZWCore::get(), &OZWCore::raiseCriticalError, this, &MainWindow::openCriticalDialog, Qt::DirectConnection);
|
||||
OZWCore::get()->initilize();
|
||||
|
||||
|
||||
|
||||
DeviceInfo *di = new DeviceInfo(this);
|
||||
NodeStatus *ni = new NodeStatus(this);
|
||||
statusBar()->showMessage(tr("Starting..."));
|
||||
|
@ -72,6 +72,11 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
connect(ui->actionDevice_Database, SIGNAL(triggered()), this, SLOT(OpenDeviceDB()));
|
||||
connect(ui->action_Configuration, SIGNAL(triggered()), this, SLOT(openConfigWindow()));
|
||||
connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(openAboutWindow()));
|
||||
connect(ui->action_AddNode, SIGNAL(triggered()), this, SLOT(addNode()));
|
||||
connect(ui->action_Delete_Node, SIGNAL(triggered()), this, SLOT(delNode()));
|
||||
connect(ui->action_Heal_Network, SIGNAL(triggered()), this, SLOT(healNetwork()));
|
||||
|
||||
|
||||
connect(di, &DeviceInfo::openMetaDataWindow, this, &MainWindow::openMetaDataWindow);
|
||||
|
||||
this->ntw = new nodeTableWidget(this);
|
||||
|
@ -87,6 +92,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
ads::CDockWidget* DeviceInfoDW = new ads::CDockWidget("Node Info");
|
||||
DeviceInfoDW->setWidget(di);
|
||||
auto RightDockWidget = this->m_DockManager->addDockWidget(ads::RightDockWidgetArea, DeviceInfoDW);
|
||||
|
||||
ads::CDockWidget* DeviceStatusDW = new ads::CDockWidget("Node Status");
|
||||
DeviceStatusDW->setWidget(ni);
|
||||
this->m_DockManager->addDockWidget(ads::CenterDockWidgetArea, DeviceStatusDW, RightDockWidget);
|
||||
|
@ -109,100 +115,22 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
RightDockWidget->setCurrentDockWidget(DeviceInfoDW);
|
||||
|
||||
|
||||
QStringList PossibleDBPaths;
|
||||
PossibleDBPaths << settings.value("openzwave/ConfigPath", QDir::toNativeSeparators("../../../config/")).toString().append("/");
|
||||
PossibleDBPaths << QStandardPaths::standardLocations(QStandardPaths::AppDataLocation);
|
||||
this->sbMsg.setQTOZWManager(OZWCore::get()->getQTOZWManager());
|
||||
|
||||
QObject::connect(OZWCore::get()->getQTOZWManager(), &QTOZWManager::ready, this, &MainWindow::QTOZW_Ready);
|
||||
|
||||
QString path, dbPath, userPath;
|
||||
foreach(path, PossibleDBPaths) {
|
||||
qCDebug(ozwadmin) << "Checking " << QFileInfo(QDir::toNativeSeparators(path + "/config/manufacturer_specific.xml")).absoluteFilePath() << " for manufacturer_specific.xml";
|
||||
if (QFileInfo(QDir::toNativeSeparators(path + "/config/manufacturer_specific.xml")).exists()) {
|
||||
dbPath = QFileInfo(QDir::toNativeSeparators(path + "/config/manufacturer_specific.xml")).absoluteFilePath();
|
||||
break;
|
||||
}
|
||||
qCDebug(ozwadmin) << "Checking " << QFileInfo(QDir::toNativeSeparators(path + "../config/manufacturer_specific.xml")).absoluteFilePath() << " for manufacturer_specific.xml";
|
||||
if (QFile(QDir::toNativeSeparators(path + "/../config/manufacturer_specific.xml")).exists()) {
|
||||
dbPath = QFileInfo(QDir::toNativeSeparators(path + "/../config/manufacturer_specific.xml")).absoluteFilePath();
|
||||
break;
|
||||
}
|
||||
}
|
||||
PossibleDBPaths.clear();
|
||||
PossibleDBPaths << settings.value("openzwave/UserPath", QDir::toNativeSeparators("../../../config/")).toString().append("/");
|
||||
PossibleDBPaths << QStandardPaths::standardLocations(QStandardPaths::AppDataLocation);
|
||||
OZWCore::get()->getQTOZWManager()->initilizeSource(OZWCore::get()->settings.value("StartServer").toBool());
|
||||
this->m_logWindow.setModel(OZWCore::get()->getQTOZWManager()->getLogModel());
|
||||
|
||||
foreach(path, PossibleDBPaths) {
|
||||
qCDebug(ozwadmin) << "Checking " << QFileInfo(QDir::toNativeSeparators(path + "/config/Options.xml")).absoluteFilePath() << " for Options.xml";
|
||||
if (QFileInfo(QDir::toNativeSeparators(path + "/config/Options.xml")).exists()) {
|
||||
userPath = QFileInfo(QDir::toNativeSeparators(path + "/config/Options.xml")).absoluteFilePath();
|
||||
break;
|
||||
}
|
||||
qCDebug(ozwadmin) << "Checking " << QFileInfo(QDir::toNativeSeparators(path + "/../config/Options.xml")).absoluteFilePath() << " for Options.xml";
|
||||
if (QFile(QDir::toNativeSeparators(path + "/../config/Options.xml")).exists()) {
|
||||
userPath = QFileInfo(QDir::toNativeSeparators(path + "/../config/Options.xml")).absoluteFilePath();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
qCDebug(ozwadmin) << "DBPath: " << dbPath;
|
||||
qCDebug(ozwadmin) << "userPath: " << userPath;
|
||||
|
||||
if (dbPath.isEmpty()) {
|
||||
qCInfo(ozwadmin) << "Deploying OZW Database to " << QStandardPaths::standardLocations(QStandardPaths::AppDataLocation).at(0);
|
||||
QStringList paths;
|
||||
paths << "." << "../../qt-openzwave/qt-openzwavedatabase/";
|
||||
if (!initConfigDatabase(paths)) {
|
||||
QMessageBox::critical(this, "Missing qt-openzwavedatabase.rcc Database File", "The qt-openzwavedatabase.rcc file could not be found");
|
||||
exit(-1);
|
||||
}
|
||||
QString dir = QStandardPaths::standardLocations(QStandardPaths::AppDataLocation).at(0);
|
||||
if (copyConfigDatabase(QDir(dir).absolutePath())) {
|
||||
qCInfo(ozwadmin) << "Copied Database to " << dir;
|
||||
}
|
||||
else {
|
||||
QMessageBox::critical(this, "Missing qt-openzwavedatabase.rcc Database File", "The qt-openzwavedatabase.rcc file could not be found");
|
||||
exit(-1);
|
||||
}
|
||||
dbPath = QFileInfo(dir.append("/config/")).absolutePath();
|
||||
m_configpath.setPath(dbPath);
|
||||
settings.setValue("openzwave/ConfigPath", m_configpath.absolutePath());
|
||||
qCInfo(ozwadmin) << "m_configPath set to " << m_configpath.absolutePath();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_configpath.setPath(QFileInfo(dbPath).absolutePath());
|
||||
settings.setValue("openzwave/ConfigPath", m_configpath.absolutePath());
|
||||
qCInfo(ozwadmin) << "Found Existing DB Path" << m_configpath.absolutePath();
|
||||
}
|
||||
|
||||
if (userPath.isEmpty()) {
|
||||
userPath = dbPath;
|
||||
m_userpath.setPath(QFileInfo(userPath).absolutePath());
|
||||
settings.setValue("openzwave/UserPath", m_userpath.absolutePath());
|
||||
qCInfo(ozwadmin) << "UserPath is Set to DBPath: " << m_userpath.absolutePath();
|
||||
}
|
||||
else {
|
||||
m_userpath.setPath(QFileInfo(userPath).absolutePath());
|
||||
qCInfo(ozwadmin) << "UserPath is Set from Settings" << m_userpath.absolutePath();
|
||||
settings.setValue("openzwave/UserPath", m_userpath.absolutePath());
|
||||
}
|
||||
|
||||
this->m_openzwave = new QTOpenZwave(this, m_configpath, m_userpath);
|
||||
this->m_qtozwmanager = this->m_openzwave->GetManager();
|
||||
this->sbMsg.setQTOZWManager(this->m_qtozwmanager);
|
||||
QObject::connect(this->m_qtozwmanager, &QTOZWManager::ready, this, &MainWindow::QTOZW_Ready);
|
||||
|
||||
this->m_qtozwmanager->initilizeSource(this->settings.value("StartServer").toBool());
|
||||
this->m_logWindow.setModel(this->m_qtozwmanager->getLogModel());
|
||||
|
||||
userValues->setModel(this->m_qtozwmanager->getValueModel(), this->ntw->selectionModel());
|
||||
systemValues->setModel(this->m_qtozwmanager->getValueModel(), this->ntw->selectionModel());
|
||||
configValues->setModel(this->m_qtozwmanager->getValueModel(), this->ntw->selectionModel());
|
||||
userValues->setModel(OZWCore::get()->getQTOZWManager()->getValueModel(), this->ntw->selectionModel());
|
||||
systemValues->setModel(OZWCore::get()->getQTOZWManager()->getValueModel(), this->ntw->selectionModel());
|
||||
configValues->setModel(OZWCore::get()->getQTOZWManager()->getValueModel(), this->ntw->selectionModel());
|
||||
|
||||
|
||||
di->setQTOZWManager(this->m_qtozwmanager);
|
||||
ni->setQTOZWManager(this->m_qtozwmanager);
|
||||
di->setQTOZWManager(OZWCore::get()->getQTOZWManager());
|
||||
ni->setQTOZWManager(OZWCore::get()->getQTOZWManager());
|
||||
|
||||
SplashDialog *sw = new SplashDialog(this->m_openzwave, this);
|
||||
SplashDialog *sw = new SplashDialog(OZWCore::get()->getQTOZW(), this);
|
||||
sw->show();
|
||||
sw->move(this->geometry().center() - sw->rect().center());
|
||||
|
||||
|
@ -220,32 +148,30 @@ void MainWindow::QTOZW_Ready() {
|
|||
qCDebug(ozwadmin) << "QTOZW Ready";
|
||||
|
||||
/* apply our Local Configuration Options to the OZW Options Class */
|
||||
settings.beginGroup("openzwave");
|
||||
QStringList optionlist = settings.allKeys();
|
||||
OZWCore::get()->settings.beginGroup("openzwave");
|
||||
QStringList optionlist = OZWCore::get()->settings.allKeys();
|
||||
for (int i = 0; i < optionlist.size(); i++) {
|
||||
qCDebug(ozwadmin) << "Updating Option " << optionlist.at(i) << " to " << settings.value(optionlist.at(i));
|
||||
QTOZWOptions *ozwoptions = this->m_qtozwmanager->getOptions();
|
||||
qCDebug(ozwadmin) << "Updating Option " << optionlist.at(i) << " to " << OZWCore::get()->settings.value(optionlist.at(i));
|
||||
QTOZWOptions *ozwoptions = OZWCore::get()->getQTOZWManager()->getOptions();
|
||||
QStringList listtypes;
|
||||
listtypes << "SaveLogLevel" << "QueueLogLevel" << "DumpLogLevel";
|
||||
if (listtypes.contains(optionlist.at(i))) {
|
||||
OptionList list = ozwoptions->property(optionlist.at(i).toLocal8Bit()).value<OptionList>();
|
||||
if (list.getEnums().size() > 0)
|
||||
list.setSelected(settings.value(optionlist.at(i)).toString());
|
||||
list.setSelected(OZWCore::get()->settings.value(optionlist.at(i)).toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
ozwoptions->setProperty(optionlist.at(i).toLocal8Bit(), settings.value(optionlist.at(i)));
|
||||
ozwoptions->setProperty(optionlist.at(i).toLocal8Bit(), OZWCore::get()->settings.value(optionlist.at(i)));
|
||||
}
|
||||
}
|
||||
settings.endGroup();
|
||||
OZWCore::get()->settings.endGroup();
|
||||
|
||||
this->ntw->setModel(this->m_qtozwmanager->getNodeModel());
|
||||
this->ntw->setModel(OZWCore::get()->getQTOZWManager()->getNodeModel());
|
||||
}
|
||||
|
||||
void MainWindow::OpenConnection() {
|
||||
|
||||
this->ui->actionOpen->setEnabled(false);
|
||||
this->ui->action_Close->setEnabled(true);
|
||||
this->connected(true);
|
||||
|
||||
Startup su(this);
|
||||
su.setModal(true);
|
||||
|
@ -261,37 +187,42 @@ void MainWindow::OpenConnection() {
|
|||
qCDebug(ozwadmin) << "Connecting to " << server;
|
||||
startupprogress *sup = new startupprogress(true, this);
|
||||
sup->setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
|
||||
sup->setQTOZWManager(this->m_qtozwmanager);
|
||||
sup->setQTOZWManager(OZWCore::get()->getQTOZWManager());
|
||||
sup->show();
|
||||
this->m_qtozwmanager->setClientAuth(su.getauthKey());
|
||||
this->m_qtozwmanager->initilizeReplica(server);
|
||||
this->settings.setValue("connection/remotehost", su.getremoteHost());
|
||||
this->settings.setValue("connection/remoteport", su.getremotePort());
|
||||
this->settings.setValue("connection/authKey", su.getauthKey());
|
||||
OZWCore::get()->getQTOZWManager()->setClientAuth(su.getauthKey());
|
||||
OZWCore::get()->getQTOZWManager()->initilizeReplica(server);
|
||||
OZWCore::get()->settings.setValue("connection/remotehost", su.getremoteHost());
|
||||
OZWCore::get()->settings.setValue("connection/remoteport", su.getremotePort());
|
||||
OZWCore::get()->settings.setValue("connection/authKey", su.getauthKey());
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
qCDebug(ozwadmin) << "Doing Local Connection: " << su.getserialPort() << su.getstartServer();
|
||||
this->m_serialport = su.getserialPort();
|
||||
startupprogress *sup = new startupprogress(false, this);
|
||||
sup->setQTOZWManager(this->m_qtozwmanager);
|
||||
sup->setQTOZWManager(OZWCore::get()->getQTOZWManager());
|
||||
sup->show();
|
||||
this->m_qtozwmanager->open(this->m_serialport);
|
||||
this->settings.setValue("connection/serialport", su.getserialPort());
|
||||
this->settings.setValue("connection/startserver", su.getstartServer());
|
||||
OZWCore::get()->getQTOZWManager()->open(su.getserialPort());
|
||||
OZWCore::get()->settings.setValue("connection/serialport", su.getserialPort());
|
||||
OZWCore::get()->settings.setValue("connection/startserver", su.getstartServer());
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
qCDebug(ozwadmin) << "Open Dialog was Canceled" << ret;
|
||||
this->ui->actionOpen->setEnabled(true);
|
||||
this->ui->action_Close->setEnabled(false);
|
||||
|
||||
this->connected(false);
|
||||
}
|
||||
|
||||
}
|
||||
void MainWindow::CloseConnection() {
|
||||
|
||||
if (OZWCore::get()->getQTOZWManager()->getConnectionType() == QTOZWManager::connectionType::Local) {
|
||||
OZWCore::get()->getQTOZWManager()->close();
|
||||
} else if (OZWCore::get()->getQTOZWManager()->getConnectionType() == QTOZWManager::connectionType::Remote) {
|
||||
QMessageBox::critical(this, "Close Connection", "TODO: Please restart the application for now");
|
||||
exit(1);
|
||||
} else {
|
||||
QMessageBox::critical(this, "Unknown Connection Type", "Unknown Connection Type");
|
||||
}
|
||||
this->connected(false);
|
||||
}
|
||||
|
||||
|
||||
|
@ -326,7 +257,7 @@ void MainWindow::openMetaDataWindow() {
|
|||
const QAbstractItemModel *model = index.model();
|
||||
quint8 node = model->data(model->index(index.row(), QTOZW_Nodes::NodeColumns::NodeID)).value<quint8>();
|
||||
MetaDataWindow *mdwin = new MetaDataWindow(this);
|
||||
mdwin->populate(this->m_qtozwmanager, node);
|
||||
mdwin->populate(OZWCore::get()->getQTOZWManager(), node);
|
||||
mdwin->setModal(true);
|
||||
mdwin->exec();
|
||||
}
|
||||
|
@ -337,12 +268,35 @@ void MainWindow::OpenDeviceDB() {
|
|||
}
|
||||
|
||||
void MainWindow::openConfigWindow() {
|
||||
Configuration *cfg = new Configuration(this->m_qtozwmanager->getOptions(), this);
|
||||
Configuration *cfg = new Configuration(OZWCore::get()->getQTOZWManager()->getOptions(), this);
|
||||
cfg->show();
|
||||
}
|
||||
|
||||
void MainWindow::openAboutWindow() {
|
||||
SplashDialog *sw = new SplashDialog(this->m_openzwave, this);
|
||||
SplashDialog *sw = new SplashDialog(OZWCore::get()->getQTOZW(), this);
|
||||
sw->show();
|
||||
sw->move(this->geometry().center() - sw->rect().center());
|
||||
}
|
||||
|
||||
QMessageBox::StandardButton MainWindow::openCriticalDialog(QString title, QString msg) {
|
||||
return QMessageBox::critical(this, title, msg);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::addNode() {
|
||||
this->m_controllerCommands->addNode();
|
||||
}
|
||||
void MainWindow::delNode() {
|
||||
this->m_controllerCommands->delNode();
|
||||
}
|
||||
void MainWindow::healNetwork() {
|
||||
this->m_controllerCommands->healNetwork();
|
||||
}
|
||||
|
||||
void MainWindow::connected(bool connected) {
|
||||
this->ui->actionOpen->setEnabled(!connected);
|
||||
this->ui->action_Close->setEnabled(connected);
|
||||
this->ui->action_AddNode->setEnabled(connected);
|
||||
this->ui->action_Delete_Node->setEnabled(connected);
|
||||
this->ui->action_Heal_Network->setEnabled(connected);
|
||||
}
|
|
@ -23,14 +23,13 @@
|
|||
#include <QModelIndex>
|
||||
#include <QDir>
|
||||
#include <QTimer>
|
||||
|
||||
#include <qt-openzwave/qtopenzwave.h>
|
||||
#include <qt-openzwave/qtozwmanager.h>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "qt-ads/DockManager.h"
|
||||
#include "logwindow.h"
|
||||
#include "statusbarmessages.h"
|
||||
#include "nodetablewidget.h"
|
||||
#include "controllercommands.h"
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
|
@ -42,7 +41,6 @@ class MainWindow : public QMainWindow
|
|||
public:
|
||||
explicit MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
Q_PROPERTY(QString SerialPort MEMBER m_serialport)
|
||||
public slots:
|
||||
void OpenConnection();
|
||||
void CloseConnection();
|
||||
|
@ -52,23 +50,23 @@ public slots:
|
|||
void OpenDeviceDB();
|
||||
void QTOZW_Ready();
|
||||
void openAboutWindow();
|
||||
|
||||
void openMetaDataWindow();
|
||||
void openConfigWindow();
|
||||
|
||||
void addNode();
|
||||
void delNode();
|
||||
void healNetwork();
|
||||
|
||||
QMessageBox::StandardButton openCriticalDialog(QString title, QString msg);
|
||||
|
||||
private:
|
||||
void connected(bool);
|
||||
ControllerCommands *m_controllerCommands;
|
||||
|
||||
Ui::MainWindow *ui;
|
||||
QString m_serialport;
|
||||
QSettings settings;
|
||||
statusBarMessages sbMsg;
|
||||
nodeTableWidget *ntw;
|
||||
|
||||
QTOpenZwave *m_openzwave;
|
||||
QTOZWManager *m_qtozwmanager;
|
||||
LogWindow m_logWindow;
|
||||
QDir m_configpath;
|
||||
QDir m_userpath;
|
||||
ads::CDockManager* m_DockManager;
|
||||
};
|
||||
|
||||
|
|
|
@ -68,6 +68,11 @@
|
|||
</attribute>
|
||||
<addaction name="actionOpen"/>
|
||||
<addaction name="action_Close"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="action_AddNode"/>
|
||||
<addaction name="action_Delete_Node"/>
|
||||
<addaction name="action_Heal_Network"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionOpen_Log_Window"/>
|
||||
<addaction name="actionDevice_Database"/>
|
||||
</widget>
|
||||
|
@ -93,6 +98,9 @@
|
|||
</property>
|
||||
</action>
|
||||
<action name="actionDevice_Database">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Device Database</string>
|
||||
</property>
|
||||
|
@ -118,6 +126,21 @@
|
|||
<string>About</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_AddNode">
|
||||
<property name="text">
|
||||
<string>&Add Node</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_Delete_Node">
|
||||
<property name="text">
|
||||
<string>&Delete Node</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_Heal_Network">
|
||||
<property name="text">
|
||||
<string>&Heal Network</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
|
||||
#include <QMenu>
|
||||
|
||||
#include <qt-openzwave/qtozwnodemodel.h>
|
||||
#include <qt-openzwave/qtozwproxymodels.h>
|
||||
|
||||
|
@ -22,6 +25,9 @@ nodeTableWidget::nodeTableWidget(QWidget *parent) :
|
|||
this->ui->nodeList->horizontalHeader()->setSectionsMovable(true);
|
||||
// this->ui->nodeList->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
// this->ui->nodeList->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
|
||||
this->ui->nodeList->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(this->ui->nodeList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(rightClickMenu(QPoint)));
|
||||
}
|
||||
|
||||
nodeTableWidget::~nodeTableWidget()
|
||||
|
@ -55,4 +61,15 @@ QModelIndex nodeTableWidget::currentIndex()
|
|||
QItemSelectionModel *nodeTableWidget::selectionModel()
|
||||
{
|
||||
return this->ui->nodeList->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->popup(this->ui->nodeList->viewport()->mapToGlobal(pos));
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
#define NODETABLEWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPoint>
|
||||
#include <qabstractitemmodel.h>
|
||||
#include <qitemselectionmodel.h>
|
||||
|
||||
|
@ -22,6 +23,8 @@ public:
|
|||
QItemSelectionModel *selectionModel();
|
||||
Q_SIGNALS:
|
||||
void currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
||||
public Q_SLOTS:
|
||||
void rightClickMenu(QPoint pos);
|
||||
private:
|
||||
Ui::nodeTableWidget *ui;
|
||||
};
|
||||
|
|
|
@ -20,6 +20,7 @@ DEFINES +=APP_VERSION=$$VERSION
|
|||
|
||||
SOURCES += main.cpp\
|
||||
configuration.cpp \
|
||||
controllercommands.cpp \
|
||||
deviceinfo.cpp \
|
||||
logwindow.cpp \
|
||||
mainwindow.cpp \
|
||||
|
@ -36,6 +37,7 @@ SOURCES += main.cpp\
|
|||
|
||||
HEADERS += mainwindow.h \
|
||||
configuration.h \
|
||||
controllercommands.h \
|
||||
deviceinfo.h \
|
||||
logwindow.h \
|
||||
metadatawindow.h \
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
#include <QDebug>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <qt-openzwave/qt-openzwavedatabase.h>
|
||||
|
||||
#include "ozwcore.h"
|
||||
#include "util.h"
|
||||
|
||||
Q_GLOBAL_STATIC(OZWCore, globalState)
|
||||
|
||||
OZWCore::OZWCore(QObject *parent) : QObject(parent)
|
||||
OZWCore::OZWCore(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
qDebug() << "Created";
|
||||
}
|
||||
|
||||
OZWCore *OZWCore::get() {
|
||||
|
@ -14,5 +19,92 @@ OZWCore *OZWCore::get() {
|
|||
|
||||
|
||||
void OZWCore::initilize() {
|
||||
QStringList PossibleDBPaths;
|
||||
PossibleDBPaths << settings.value("openzwave/ConfigPath", QDir::toNativeSeparators("../../../config/")).toString().append("/");
|
||||
PossibleDBPaths << QStandardPaths::standardLocations(QStandardPaths::AppDataLocation);
|
||||
|
||||
}
|
||||
QString path, dbPath, userPath;
|
||||
foreach(path, PossibleDBPaths) {
|
||||
qCDebug(ozwadmin) << "Checking " << QFileInfo(QDir::toNativeSeparators(path + "/config/manufacturer_specific.xml")).absoluteFilePath() << " for manufacturer_specific.xml";
|
||||
if (QFileInfo(QDir::toNativeSeparators(path + "/config/manufacturer_specific.xml")).exists()) {
|
||||
dbPath = QFileInfo(QDir::toNativeSeparators(path + "/config/manufacturer_specific.xml")).absoluteFilePath();
|
||||
break;
|
||||
}
|
||||
qCDebug(ozwadmin) << "Checking " << QFileInfo(QDir::toNativeSeparators(path + "../config/manufacturer_specific.xml")).absoluteFilePath() << " for manufacturer_specific.xml";
|
||||
if (QFile(QDir::toNativeSeparators(path + "/../config/manufacturer_specific.xml")).exists()) {
|
||||
dbPath = QFileInfo(QDir::toNativeSeparators(path + "/../config/manufacturer_specific.xml")).absoluteFilePath();
|
||||
break;
|
||||
}
|
||||
}
|
||||
PossibleDBPaths.clear();
|
||||
PossibleDBPaths << settings.value("openzwave/UserPath", QDir::toNativeSeparators("../../../config/")).toString().append("/");
|
||||
PossibleDBPaths << QStandardPaths::standardLocations(QStandardPaths::AppDataLocation);
|
||||
|
||||
foreach(path, PossibleDBPaths) {
|
||||
qCDebug(ozwadmin) << "Checking " << QFileInfo(QDir::toNativeSeparators(path + "/config/Options.xml")).absoluteFilePath() << " for Options.xml";
|
||||
if (QFileInfo(QDir::toNativeSeparators(path + "/config/Options.xml")).exists()) {
|
||||
userPath = QFileInfo(QDir::toNativeSeparators(path + "/config/Options.xml")).absoluteFilePath();
|
||||
break;
|
||||
}
|
||||
qCDebug(ozwadmin) << "Checking " << QFileInfo(QDir::toNativeSeparators(path + "/../config/Options.xml")).absoluteFilePath() << " for Options.xml";
|
||||
if (QFile(QDir::toNativeSeparators(path + "/../config/Options.xml")).exists()) {
|
||||
userPath = QFileInfo(QDir::toNativeSeparators(path + "/../config/Options.xml")).absoluteFilePath();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
qCDebug(ozwadmin) << "DBPath: " << dbPath;
|
||||
qCDebug(ozwadmin) << "userPath: " << userPath;
|
||||
|
||||
if (dbPath.isEmpty()) {
|
||||
qCInfo(ozwadmin) << "Deploying OZW Database to " << QStandardPaths::standardLocations(QStandardPaths::AppDataLocation).at(0);
|
||||
QStringList paths;
|
||||
paths << "." << "../../qt-openzwave/qt-openzwavedatabase/";
|
||||
if (!initConfigDatabase(paths)) {
|
||||
qCWarning(ozwadmin) << "The qt-openzwavedatabase.rcc file could not be found";
|
||||
emit raiseCriticalError("Missing qt-openzwavedatabase.rcc Database File", "The qt-openzwavedatabase.rcc file could not be found");
|
||||
exit(-1);
|
||||
}
|
||||
QString dir = QStandardPaths::standardLocations(QStandardPaths::AppDataLocation).at(0);
|
||||
if (copyConfigDatabase(QDir(dir).absolutePath())) {
|
||||
qCInfo(ozwadmin) << "Copied Database to " << dir;
|
||||
}
|
||||
else {
|
||||
qCWarning(ozwadmin) << "Copying Config Database Failed";
|
||||
emit raiseCriticalError("Copying Config Database Failed", "Copying Config Database Failed");
|
||||
exit(-1);
|
||||
}
|
||||
dbPath = QFileInfo(dir.append("/config/")).absolutePath();
|
||||
m_configpath.setPath(dbPath);
|
||||
settings.setValue("openzwave/ConfigPath", m_configpath.absolutePath());
|
||||
qCInfo(ozwadmin) << "m_configPath set to " << m_configpath.absolutePath();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_configpath.setPath(QFileInfo(dbPath).absolutePath());
|
||||
settings.setValue("openzwave/ConfigPath", m_configpath.absolutePath());
|
||||
qCInfo(ozwadmin) << "Found Existing DB Path" << m_configpath.absolutePath();
|
||||
}
|
||||
|
||||
if (userPath.isEmpty()) {
|
||||
userPath = dbPath;
|
||||
m_userpath.setPath(QFileInfo(userPath).absolutePath());
|
||||
settings.setValue("openzwave/UserPath", m_userpath.absolutePath());
|
||||
qCInfo(ozwadmin) << "UserPath is Set to DBPath: " << m_userpath.absolutePath();
|
||||
}
|
||||
else {
|
||||
m_userpath.setPath(QFileInfo(userPath).absolutePath());
|
||||
qCInfo(ozwadmin) << "UserPath is Set from Settings" << m_userpath.absolutePath();
|
||||
settings.setValue("openzwave/UserPath", m_userpath.absolutePath());
|
||||
}
|
||||
|
||||
this->m_openzwave = new QTOpenZwave(this, m_configpath, m_userpath);
|
||||
this->m_qtozwmanager = this->m_openzwave->GetManager();
|
||||
}
|
||||
|
||||
QTOpenZwave *OZWCore::getQTOZW() {
|
||||
return this->m_openzwave;
|
||||
}
|
||||
QTOZWManager *OZWCore::getQTOZWManager() {
|
||||
return this->m_qtozwmanager;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,13 @@
|
|||
#define OZWCORE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QMessageBox>
|
||||
#include <qt-openzwave/qtopenzwave.h>
|
||||
#include <qt-openzwave/qtozwmanager.h>
|
||||
|
||||
#include "controllercommands.h"
|
||||
|
||||
class ControllerCommands;
|
||||
|
||||
class OZWCore : public QObject
|
||||
{
|
||||
|
@ -10,9 +17,20 @@ public:
|
|||
explicit OZWCore(QObject *parent = nullptr);
|
||||
static OZWCore *get();
|
||||
void initilize();
|
||||
signals:
|
||||
QTOpenZwave *getQTOZW();
|
||||
QTOZWManager *getQTOZWManager();
|
||||
QSettings settings;
|
||||
|
||||
signals:
|
||||
QMessageBox::StandardButton raiseCriticalError(QString title, QString message);
|
||||
public slots:
|
||||
|
||||
private:
|
||||
QTOpenZwave *m_openzwave;
|
||||
QTOZWManager *m_qtozwmanager;
|
||||
QString m_serialport;
|
||||
QDir m_configpath;
|
||||
QDir m_userpath;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue