Fix log viewers string/uuid conversion
This commit is contained in:
parent
8d1fb2c73a
commit
6f430b0553
@ -111,12 +111,12 @@ void LogsModelNg::setLive(bool live)
|
||||
}
|
||||
}
|
||||
|
||||
QString LogsModelNg::deviceId() const
|
||||
QUuid LogsModelNg::deviceId() const
|
||||
{
|
||||
return m_deviceId;
|
||||
}
|
||||
|
||||
void LogsModelNg::setDeviceId(const QString &deviceId)
|
||||
void LogsModelNg::setDeviceId(const QUuid &deviceId)
|
||||
{
|
||||
if (m_deviceId != deviceId) {
|
||||
m_deviceId = deviceId;
|
||||
@ -126,13 +126,21 @@ void LogsModelNg::setDeviceId(const QString &deviceId)
|
||||
|
||||
QStringList LogsModelNg::typeIds() const
|
||||
{
|
||||
return m_typeIds;
|
||||
QStringList strings;
|
||||
foreach (const QUuid &id, m_typeIds) {
|
||||
strings.append(id.toString());
|
||||
}
|
||||
return strings;
|
||||
}
|
||||
|
||||
void LogsModelNg::setTypeIds(const QStringList &typeIds)
|
||||
{
|
||||
if (m_typeIds != typeIds) {
|
||||
m_typeIds = typeIds;
|
||||
QList<QUuid> fixedTypeIds;
|
||||
foreach (const QString &id, typeIds) {
|
||||
fixedTypeIds.append(QUuid(id));
|
||||
}
|
||||
if (m_typeIds != fixedTypeIds) {
|
||||
m_typeIds = fixedTypeIds;
|
||||
emit typeIdsChanged();
|
||||
beginResetModel();
|
||||
qDeleteAll(m_list);
|
||||
@ -361,14 +369,14 @@ void LogsModelNg::fetchMore(const QModelIndex &parent)
|
||||
emit busyChanged();
|
||||
|
||||
QVariantMap params;
|
||||
if (!m_deviceId.isEmpty()) {
|
||||
if (!m_deviceId.isNull()) {
|
||||
QVariantList deviceIds;
|
||||
deviceIds.append(m_deviceId);
|
||||
params.insert("deviceIds", deviceIds);
|
||||
}
|
||||
if (!m_typeIds.isEmpty()) {
|
||||
QVariantList typeIds;
|
||||
foreach (const QString &typeId, m_typeIds) {
|
||||
foreach (const QUuid &typeId, m_typeIds) {
|
||||
typeIds.append(typeId);
|
||||
}
|
||||
params.insert("typeIds", typeIds);
|
||||
@ -403,12 +411,12 @@ void LogsModelNg::newLogEntryReceived(const QVariantMap &data)
|
||||
}
|
||||
|
||||
QVariantMap entryMap = data;
|
||||
QString deviceId = entryMap.value("deviceId").toString();
|
||||
QUuid deviceId = entryMap.value("deviceId").toUuid();
|
||||
if (!m_deviceId.isNull() && deviceId != m_deviceId) {
|
||||
return;
|
||||
}
|
||||
|
||||
QString typeId = entryMap.value("typeId").toString();
|
||||
QUuid typeId = entryMap.value("typeId").toUuid();
|
||||
if (!m_typeIds.isEmpty() && !m_typeIds.contains(typeId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -35,6 +35,7 @@
|
||||
#include <QAbstractListModel>
|
||||
#include <QDateTime>
|
||||
#include <QLineSeries>
|
||||
#include <QUuid>
|
||||
|
||||
class LogEntry;
|
||||
class Engine;
|
||||
@ -46,7 +47,7 @@ class LogsModelNg : public QAbstractListModel
|
||||
Q_PROPERTY(bool busy READ busy NOTIFY busyChanged)
|
||||
Q_PROPERTY(bool live READ live WRITE setLive NOTIFY liveChanged)
|
||||
Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
|
||||
Q_PROPERTY(QString deviceId READ deviceId WRITE setDeviceId NOTIFY deviceIdChanged)
|
||||
Q_PROPERTY(QUuid deviceId READ deviceId WRITE setDeviceId NOTIFY deviceIdChanged)
|
||||
Q_PROPERTY(QStringList typeIds READ typeIds WRITE setTypeIds NOTIFY typeIdsChanged)
|
||||
Q_PROPERTY(QDateTime startTime READ startTime WRITE setStartTime NOTIFY startTimeChanged)
|
||||
Q_PROPERTY(QDateTime endTime READ endTime WRITE setEndTime NOTIFY endTimeChanged)
|
||||
@ -80,8 +81,8 @@ public:
|
||||
bool live() const;
|
||||
void setLive(bool live);
|
||||
|
||||
QString deviceId() const;
|
||||
void setDeviceId(const QString &deviceId);
|
||||
QUuid deviceId() const;
|
||||
void setDeviceId(const QUuid &deviceId);
|
||||
|
||||
QStringList typeIds() const;
|
||||
void setTypeIds(const QStringList &typeId);
|
||||
@ -131,8 +132,8 @@ private:
|
||||
Engine *m_engine = nullptr;
|
||||
bool m_busy = false;
|
||||
bool m_live = false;
|
||||
QString m_deviceId;
|
||||
QStringList m_typeIds;
|
||||
QUuid m_deviceId;
|
||||
QList<QUuid> m_typeIds;
|
||||
QDateTime m_startTime;
|
||||
QDateTime m_endTime;
|
||||
int m_blockSize = 100;
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
|
||||
#include <QDateTime>
|
||||
|
||||
LogEntry::LogEntry(const QDateTime ×tamp, const QVariant &value, const QString &deviceId, const QString &typeId, LoggingSource source, LoggingEventType loggingEventType, QObject *parent):
|
||||
LogEntry::LogEntry(const QDateTime ×tamp, const QVariant &value, const QUuid &deviceId, const QUuid &typeId, LoggingSource source, LoggingEventType loggingEventType, QObject *parent):
|
||||
QObject(parent),
|
||||
m_value(value),
|
||||
m_timeStamp(timestamp),
|
||||
@ -54,12 +54,12 @@ QDateTime LogEntry::timestamp() const
|
||||
return m_timeStamp;
|
||||
}
|
||||
|
||||
QString LogEntry::deviceId() const
|
||||
QUuid LogEntry::deviceId() const
|
||||
{
|
||||
return m_deviceId;
|
||||
}
|
||||
|
||||
QString LogEntry::typeId() const
|
||||
QUuid LogEntry::typeId() const
|
||||
{
|
||||
return m_typeId;
|
||||
}
|
||||
|
||||
@ -34,13 +34,14 @@
|
||||
#include <QObject>
|
||||
#include <QVariant>
|
||||
#include <QDateTime>
|
||||
#include <QUuid>
|
||||
|
||||
class LogEntry : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QVariant value READ value CONSTANT)
|
||||
Q_PROPERTY(QString deviceId READ deviceId CONSTANT)
|
||||
Q_PROPERTY(QString typeId READ typeId CONSTANT)
|
||||
Q_PROPERTY(QUuid deviceId READ deviceId CONSTANT)
|
||||
Q_PROPERTY(QUuid typeId READ typeId CONSTANT)
|
||||
Q_PROPERTY(LoggingSource source READ source CONSTANT)
|
||||
Q_PROPERTY(LoggingEventType loggingEventType READ loggingEventType CONSTANT)
|
||||
|
||||
@ -69,12 +70,12 @@ public:
|
||||
};
|
||||
Q_ENUM(LoggingEventType)
|
||||
|
||||
explicit LogEntry(const QDateTime ×tamp, const QVariant &value, const QString &deviceId = QString(), const QString &typeId = QString(), LoggingSource source = LoggingSourceSystem, LoggingEventType loggingEventType = LoggingEventTypeTrigger, QObject *parent = nullptr);
|
||||
explicit LogEntry(const QDateTime ×tamp, const QVariant &value, const QUuid &deviceId = QUuid(), const QUuid &typeId = QUuid(), LoggingSource source = LoggingSourceSystem, LoggingEventType loggingEventType = LoggingEventTypeTrigger, QObject *parent = nullptr);
|
||||
|
||||
QVariant value() const;
|
||||
QDateTime timestamp() const;
|
||||
QString deviceId() const;
|
||||
QString typeId() const;
|
||||
QUuid deviceId() const;
|
||||
QUuid typeId() const;
|
||||
LoggingSource source() const;
|
||||
LoggingEventType loggingEventType() const;
|
||||
|
||||
@ -85,8 +86,8 @@ public:
|
||||
private:
|
||||
QVariant m_value;
|
||||
QDateTime m_timeStamp;
|
||||
QString m_deviceId;
|
||||
QString m_typeId;
|
||||
QUuid m_deviceId;
|
||||
QUuid m_typeId;
|
||||
LoggingSource m_source;
|
||||
LoggingEventType m_loggingEventType;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user