Skip to content

Commit

Permalink
Refactoring Log Class
Browse files Browse the repository at this point in the history
  • Loading branch information
Fishwaldo committed Jun 3, 2020
1 parent 4ed702d commit 826a2f4
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
9 changes: 9 additions & 0 deletions ozwadmin-main/logwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "logwindow.h"
#include "ui_logwindow.h"
#include "ozwcore.h"
#include "util.h"

LogWindow::LogWindow(QWidget *parent) :
QWidget(parent),
Expand All @@ -14,6 +16,8 @@ LogWindow::LogWindow(QWidget *parent) :
this->ui->logview->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
// this->ui->logview->resizeColumnsToContents();

this->m_log = OZWCore::get()->getQTOZWManager()->getLog();
connect(this->m_log, &QTOZWLog::newLogLine, this, &LogWindow::newMsg);

}

Expand All @@ -22,6 +26,11 @@ LogWindow::~LogWindow()
delete ui;
}

void LogWindow::newMsg(QDateTime time, LogLevels::Level level, quint8 s_node, QString s_msg) {
qCDebug(ozwadmin) << time << level << s_node << s_msg;
}


void LogWindow::setModel(QAbstractItemModel *model) {
this->ui->logview->setModel(model);
// this->ui->logview->resizeColumnsToContents();
Expand Down
4 changes: 4 additions & 0 deletions ozwadmin-main/logwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <QDialog>
#include <QAbstractItemModel>
#include <qt-openzwave/qtozwlog.h>

namespace Ui {
class LogWindow;
Expand All @@ -16,9 +17,12 @@ class LogWindow : public QWidget
explicit LogWindow(QWidget *parent = nullptr);
~LogWindow();
void setModel(QAbstractItemModel *model);
private slots:
void newMsg(QDateTime time, LogLevels::Level level, quint8 s_node, QString s_msg);
private:
Ui::LogWindow *ui;
bool viewAtBottom = true;
QTOZWLog *m_log;
};

#endif // LOGWINDOW_H
2 changes: 1 addition & 1 deletion ozwadmin-main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ int main(int argc, char *argv[])

#if 1
QLoggingCategory::setFilterRules("*.debug=false\n"
"qt.remoteobjects.debug=true\n"
"qt.remoteobjects.debug=false\n"
"qt.remoteobjects.warning=true\n"
"ozw.*.debug=true\n"
"ozw.library.debug=false\n"
Expand Down
5 changes: 2 additions & 3 deletions ozwadmin-main/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ void MainWindow::openDefaultWindows() {
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());
lw->setModel(OZWCore::get()->getQTOZWManager()->getLogModel());

di->setQTOZWManager(OZWCore::get()->getQTOZWManager());
this->m_WindowsSetup = true;
Expand Down Expand Up @@ -242,9 +241,9 @@ void MainWindow::connectToRemote(QUrl server, QString key) {
}

void MainWindow::CloseConnection() {
if (OZWCore::get()->getQTOZWManager()->getConnectionType() == QTOZWManager::connectionType::Local) {
if (OZWCore::get()->getQTOZWManager()->getConnectionType() == ConnectionType::Type::Local) {
OZWCore::get()->getQTOZWManager()->close();
} else if (OZWCore::get()->getQTOZWManager()->getConnectionType() == QTOZWManager::connectionType::Remote) {
} else if (OZWCore::get()->getQTOZWManager()->getConnectionType() == ConnectionType::Type::Remote) {
//QMessageBox::critical(this, "Close Connection", "TODO: Please restart the application for now");
//exit(1);
} else {
Expand Down
1 change: 0 additions & 1 deletion ozwadmin-main/nodestatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ NodeStatus::~NodeStatus()
}

void NodeStatus::updateNodeStats() {

if (OZWCore::get()->getQTOZWManager()->isReady()) {
if (!this->m_statTimer.isActive())
this->m_statTimer.start(1000);
Expand Down

0 comments on commit 826a2f4

Please sign in to comment.