fix logsModel to allow filtering for multiple typeIds
This commit is contained in:
parent
e44d5c0fd8
commit
9bbfd9de19
@ -78,16 +78,16 @@ void LogsModel::setDeviceId(const QString &deviceId)
|
||||
}
|
||||
}
|
||||
|
||||
QString LogsModel::typeId() const
|
||||
QStringList LogsModel::typeIds() const
|
||||
{
|
||||
return m_typeId;
|
||||
return m_typeIds;
|
||||
}
|
||||
|
||||
void LogsModel::setTypeId(const QString &typeId)
|
||||
void LogsModel::setTypeIds(const QStringList &typeIds)
|
||||
{
|
||||
if (m_typeId != typeId) {
|
||||
m_typeId = typeId;
|
||||
emit typeIdChanged();
|
||||
if (m_typeIds != typeIds) {
|
||||
m_typeIds = typeIds;
|
||||
emit typeIdsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@ -141,9 +141,11 @@ void LogsModel::update()
|
||||
deviceIds.append(m_deviceId);
|
||||
params.insert("deviceIds", deviceIds);
|
||||
}
|
||||
if (!m_typeId.isEmpty()) {
|
||||
if (!m_typeIds.isEmpty()) {
|
||||
QVariantList typeIds;
|
||||
typeIds.append(m_typeId);
|
||||
foreach (const QString &typeId, m_typeIds) {
|
||||
typeIds.append(typeId);
|
||||
}
|
||||
params.insert("typeIds", typeIds);
|
||||
}
|
||||
QVariantList timeFilters;
|
||||
@ -196,7 +198,7 @@ void LogsModel::newLogEntryReceived(const QVariantMap &data)
|
||||
}
|
||||
|
||||
QString typeId = entryMap.value("typeId").toString();
|
||||
if (!m_typeId.isNull() && typeId != m_typeId) {
|
||||
if (!m_typeIds.isEmpty() && !m_typeIds.contains(typeId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ class LogsModel : public QAbstractListModel
|
||||
Q_PROPERTY(bool busy READ busy NOTIFY busyChanged)
|
||||
Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
|
||||
Q_PROPERTY(QString deviceId READ deviceId WRITE setDeviceId NOTIFY deviceIdChanged)
|
||||
Q_PROPERTY(QString typeId READ typeId WRITE setTypeId NOTIFY typeIdChanged)
|
||||
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)
|
||||
|
||||
@ -40,8 +40,8 @@ public:
|
||||
QString deviceId() const;
|
||||
void setDeviceId(const QString &deviceId);
|
||||
|
||||
QString typeId() const;
|
||||
void setTypeId(const QString &typeId);
|
||||
QStringList typeIds() const;
|
||||
void setTypeIds(const QStringList &typeIds);
|
||||
|
||||
QDateTime startTime() const;
|
||||
void setStartTime(const QDateTime &startTime);
|
||||
@ -58,7 +58,7 @@ signals:
|
||||
void liveChanged();
|
||||
void countChanged();
|
||||
void deviceIdChanged();
|
||||
void typeIdChanged();
|
||||
void typeIdsChanged();
|
||||
void startTimeChanged();
|
||||
void endTimeChanged();
|
||||
|
||||
@ -72,7 +72,7 @@ private slots:
|
||||
protected:
|
||||
QList<LogEntry*> m_list;
|
||||
QString m_deviceId;
|
||||
QString m_typeId;
|
||||
QStringList m_typeIds;
|
||||
QDateTime m_startTime = QDateTime::currentDateTime().addDays(-1);
|
||||
QDateTime m_endTime = QDateTime::currentDateTime();
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ Item {
|
||||
|
||||
readonly property var device: root.model ? Engine.deviceManager.devices.getDevice(root.model.deviceId) : null
|
||||
readonly property var deviceClass: device ? Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
|
||||
readonly property var stateType: deviceClass ? deviceClass.stateTypes.getStateType(root.model.typeId) : null
|
||||
readonly property var stateType: deviceClass ? deviceClass.stateTypes.getStateType(root.model.typeIds[0]) : null
|
||||
|
||||
Label {
|
||||
anchors.centerIn: parent
|
||||
@ -93,7 +93,7 @@ Item {
|
||||
}
|
||||
|
||||
onPaint: {
|
||||
print("painting graph")
|
||||
// print("painting graph")
|
||||
var ctx = canvas.getContext('2d');
|
||||
ctx.save();
|
||||
|
||||
@ -164,7 +164,6 @@ Item {
|
||||
ctx.strokeStyle = Material.foreground
|
||||
ctx.fillStyle = Material.foreground
|
||||
ctx.lineWidth = 0;
|
||||
print("blubb", root.stateType.unitString)
|
||||
var label = root.stateType ? root.stateType.unitString : ""
|
||||
var textSize = ctx.measureText(label)
|
||||
ctx.text(label, -textSize.width - app.margins, height + app.margins + app.smallFont)
|
||||
|
||||
@ -43,6 +43,8 @@ Item {
|
||||
id: logEntryDelegate
|
||||
width: parent.width
|
||||
implicitHeight: app.delegateHeight
|
||||
property var device: Engine.deviceManager.devices.getDevice(model.deviceId)
|
||||
property var deviceClass: Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId)
|
||||
contentItem: RowLayout {
|
||||
ColorIcon {
|
||||
Layout.preferredHeight: app.iconSize
|
||||
@ -59,7 +61,7 @@ Item {
|
||||
}
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
text: qsTr("Data: %1").arg(model.value.trim())
|
||||
text: "%1: %2".arg(deviceClass.eventTypes.getEventType(model.typeId).displayName).arg(model.value.trim())
|
||||
elide: Text.ElideRight
|
||||
font.pixelSize: app.smallFont
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@ CustomViewBase {
|
||||
ValueLogsProxyModel {
|
||||
id: logsModel
|
||||
deviceId: root.device.id
|
||||
typeId: stateType.id
|
||||
typeIds: [stateType.id]
|
||||
average: zoomTabBar.currentItem.avg
|
||||
startTime: zoomTabBar.currentItem.startTime
|
||||
Component.onCompleted: updateTimer.start();
|
||||
|
||||
@ -16,7 +16,14 @@ GenericDevicePage {
|
||||
logsModel: LogsModel {
|
||||
deviceId: root.device.id
|
||||
live: true
|
||||
typeId: root.deviceClass.eventTypes.findByName("pressed").id
|
||||
typeIds: {
|
||||
var ret = [];
|
||||
ret.push(root.deviceClass.eventTypes.findByName("pressed").id)
|
||||
if (root.deviceClass.eventTypes.findByName("longPressed")) {
|
||||
ret.push(root.deviceClass.eventTypes.findByName("longPressed").id)
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
Component.onCompleted: update()
|
||||
}
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@ GenericDevicePage {
|
||||
deviceId: root.device.id
|
||||
live: true
|
||||
Component.onCompleted: update()
|
||||
typeId: root.deviceClass.eventTypes.findByName("triggered").id;
|
||||
typeIds: [root.deviceClass.eventTypes.findByName("triggered").id];
|
||||
}
|
||||
|
||||
onAddRuleClicked: {
|
||||
|
||||
@ -31,7 +31,7 @@ Page {
|
||||
deviceId: root.device.id
|
||||
live: true
|
||||
Component.onCompleted: update()
|
||||
typeId: root.stateType.id
|
||||
typeIds: [root.stateType.id]
|
||||
}
|
||||
|
||||
// LogsModelNg {
|
||||
@ -151,7 +151,7 @@ Page {
|
||||
model: ValueLogsProxyModel {
|
||||
id: graphModel
|
||||
deviceId: root.device.id
|
||||
typeId: stateType.id
|
||||
typeIds: [stateType.id]
|
||||
average: zoomTabBar.currentItem.avg
|
||||
startTime: zoomTabBar.currentItem.startTime
|
||||
Component.onCompleted: updateTimer.start();
|
||||
|
||||
Reference in New Issue
Block a user