diff --git a/qt-openzwave/include/qt-openzwave/qtozwlog.h b/qt-openzwave/include/qt-openzwave/qtozwlog.h index 10cfeab..afb63a5 100644 --- a/qt-openzwave/include/qt-openzwave/qtozwlog.h +++ b/qt-openzwave/include/qt-openzwave/qtozwlog.h @@ -57,7 +57,7 @@ class QTOPENZWAVESHARED_EXPORT QTOZWLog : public QTOZWReplicaBase { bool initilizeBase() override; bool initilizeSource(QRemoteObjectHost *m_sourceNode) override; bool initilizeReplica(QRemoteObjectNode *m_replicaNode) override; - QVector getLogEntries(); + const QVector &getLogEntries(); public: quint32 getLogCount() const; @@ -113,7 +113,7 @@ class QTOPENZWAVESHARED_EXPORT QTOZWLogModel : public QAbstractTableModel { void resetModel(); void logsPoppped(quint32 size); private: - QTOZWLog::QTOZW_LogEntry getLogData(int) const; + const QTOZWLog::QTOZW_LogEntry getLogData(const int) const; QTOZWLog *m_qtozwlog; }; diff --git a/qt-openzwave/source/qtozwlog.cpp b/qt-openzwave/source/qtozwlog.cpp index 34a10d2..9e7eca5 100644 --- a/qt-openzwave/source/qtozwlog.cpp +++ b/qt-openzwave/source/qtozwlog.cpp @@ -164,9 +164,10 @@ bool QTOZWLog::syncroniseLogs() } } -QVector QTOZWLog::getLogEntries() { - if (!this->isReady()) - return QVector(); +const QVector &QTOZWLog::getLogEntries() { + if (!this->isReady()) { + return this->m_logData; + } if (this->getConnectionType() == ConnectionType::Type::Local) { return this->d_ptr_internal->m_logData; @@ -301,13 +302,14 @@ QVariant QTOZWLogModel::headerData(int section, Qt::Orientation orientation, int } return QVariant(); } + Qt::ItemFlags QTOZWLogModel::flags(const QModelIndex &index) const { if (!index.isValid()) return Qt::NoItemFlags; return QAbstractTableModel::flags(index); } -QTOZWLog::QTOZW_LogEntry QTOZWLogModel::getLogData(int pos) const { +const QTOZWLog::QTOZW_LogEntry QTOZWLogModel::getLogData(const int pos) const { if (this->m_qtozwlog->getLogEntries().count() >= pos) return this->m_qtozwlog->getLogEntries().at(pos+1); qCWarning(logModel) << "Can't find LogEntry at " << pos << " size:" << this->m_qtozwlog->getLogEntries().count(); diff --git a/qt-openzwave/source/qtozwlog_p.cpp b/qt-openzwave/source/qtozwlog_p.cpp index 2cf8821..e33091c 100644 --- a/qt-openzwave/source/qtozwlog_p.cpp +++ b/qt-openzwave/source/qtozwlog_p.cpp @@ -124,6 +124,7 @@ void QTOZWLog_Internal::Write(OpenZWave::LogLevel _level, uint8 const _nodeId, c le.s_time = QDateTime::currentDateTime(); le.s_level = qtozwlevel; if (static_cast(this->m_logData.size()) >= this->m_maxLogLength) { + qCDebug(logModel) << "popping Log Mesages"; this->m_logData.pop_front(); emit logLinesPopped(1); } @@ -155,6 +156,7 @@ quint32 QTOZWLog_Internal::getLogCount() { return this->m_logData.count(); }; + bool QTOZWLog_Internal::syncroniseLogs() { qCDebug(logModel) << "QTOZWLog_Internal::syncroniseLogs() called"; @@ -189,12 +191,11 @@ void QTOZWLog_Internal::sendSyncLogsBatch() qCDebug(logModel) << "QTOZWLog_Internal::sendSyncLogsBatch() Finished"; } - - quint32 QTOZWLog_Internal::getLogBufSize() const { return this->m_maxLogLength; } + void QTOZWLog_Internal::setLogBufSize(quint32 size) { if (this->m_maxLogLength != size) {