work on LogsModelNg with support for 1.10 jsonrpc's pagination
This commit is contained in:
parent
e5f3ff4f3f
commit
c84cd88d76
@ -303,7 +303,7 @@ void JsonRpcClient::sendRequest(const QVariantMap &request)
|
|||||||
{
|
{
|
||||||
QVariantMap newRequest = request;
|
QVariantMap newRequest = request;
|
||||||
newRequest.insert("token", m_token);
|
newRequest.insert("token", m_token);
|
||||||
qDebug() << "Sending request" << qUtf8Printable(QJsonDocument::fromVariant(newRequest).toJson());
|
// qDebug() << "Sending request" << qUtf8Printable(QJsonDocument::fromVariant(newRequest).toJson());
|
||||||
m_connection->sendData(QJsonDocument::fromVariant(newRequest).toJson(QJsonDocument::Compact) + "\n");
|
m_connection->sendData(QJsonDocument::fromVariant(newRequest).toJson(QJsonDocument::Compact) + "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -340,7 +340,7 @@ void JsonRpcClient::dataReceived(const QByteArray &data)
|
|||||||
// qWarning() << "Could not parse json data from nymea" << m_receiveBuffer.left(splitIndex) << error.errorString();
|
// qWarning() << "Could not parse json data from nymea" << m_receiveBuffer.left(splitIndex) << error.errorString();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qDebug() << "received response" << qUtf8Printable(jsonDoc.toJson(QJsonDocument::Indented));
|
// qDebug() << "received response" << qUtf8Printable(jsonDoc.toJson(QJsonDocument::Indented));
|
||||||
m_receiveBuffer = m_receiveBuffer.right(m_receiveBuffer.length() - splitIndex - 1);
|
m_receiveBuffer = m_receiveBuffer.right(m_receiveBuffer.length() - splitIndex - 1);
|
||||||
if (!m_receiveBuffer.isEmpty()) {
|
if (!m_receiveBuffer.isEmpty()) {
|
||||||
staticMetaObject.invokeMethod(this, "dataReceived", Qt::QueuedConnection, Q_ARG(QByteArray, QByteArray()));
|
staticMetaObject.invokeMethod(this, "dataReceived", Qt::QueuedConnection, Q_ARG(QByteArray, QByteArray()));
|
||||||
|
|||||||
@ -213,7 +213,7 @@ void LogsModel::fetchEarlier(int hours)
|
|||||||
|
|
||||||
void LogsModel::logsReply(const QVariantMap &data)
|
void LogsModel::logsReply(const QVariantMap &data)
|
||||||
{
|
{
|
||||||
qDebug() << "logs reply";// << data;
|
// qDebug() << "logs reply" << data;
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
qDeleteAll(m_list);
|
qDeleteAll(m_list);
|
||||||
m_list.clear();
|
m_list.clear();
|
||||||
@ -242,7 +242,7 @@ void LogsModel::logsReply(const QVariantMap &data)
|
|||||||
|
|
||||||
void LogsModel::fetchEarlierReply(const QVariantMap &data)
|
void LogsModel::fetchEarlierReply(const QVariantMap &data)
|
||||||
{
|
{
|
||||||
qDebug() << "logs reply";// << data;
|
// qDebug() << "logs reply" << data;
|
||||||
|
|
||||||
QList<QVariant> logEntries = data.value("params").toMap().value("logEntries").toList();
|
QList<QVariant> logEntries = data.value("params").toMap().value("logEntries").toList();
|
||||||
QList<LogEntry*> newEntries;
|
QList<LogEntry*> newEntries;
|
||||||
|
|||||||
@ -19,6 +19,7 @@ class LogsModel : public QAbstractListModel
|
|||||||
Q_PROPERTY(QStringList typeIds READ typeIds WRITE setTypeIds NOTIFY typeIdsChanged)
|
Q_PROPERTY(QStringList typeIds READ typeIds WRITE setTypeIds NOTIFY typeIdsChanged)
|
||||||
Q_PROPERTY(QDateTime startTime READ startTime WRITE setStartTime NOTIFY startTimeChanged)
|
Q_PROPERTY(QDateTime startTime READ startTime WRITE setStartTime NOTIFY startTimeChanged)
|
||||||
Q_PROPERTY(QDateTime endTime READ endTime WRITE setEndTime NOTIFY endTimeChanged)
|
Q_PROPERTY(QDateTime endTime READ endTime WRITE setEndTime NOTIFY endTimeChanged)
|
||||||
|
// Q_PROPERTY(int paginationCount READ paginationCount WRITE setPaginationCount NOTIFY paginationCountChanged)
|
||||||
|
|
||||||
Q_PROPERTY(bool live READ live WRITE setLive NOTIFY liveChanged)
|
Q_PROPERTY(bool live READ live WRITE setLive NOTIFY liveChanged)
|
||||||
|
|
||||||
@ -56,6 +57,9 @@ public:
|
|||||||
QDateTime endTime() const;
|
QDateTime endTime() const;
|
||||||
void setEndTime(const QDateTime &endTime);
|
void setEndTime(const QDateTime &endTime);
|
||||||
|
|
||||||
|
// int paginationCount() const;
|
||||||
|
// void setPaginationCount(int paginationCount);
|
||||||
|
|
||||||
Q_INVOKABLE LogEntry* get(int index) const;
|
Q_INVOKABLE LogEntry* get(int index) const;
|
||||||
|
|
||||||
Q_INVOKABLE void notificationReceived(const QVariantMap &data);
|
Q_INVOKABLE void notificationReceived(const QVariantMap &data);
|
||||||
@ -69,6 +73,7 @@ signals:
|
|||||||
void typeIdsChanged();
|
void typeIdsChanged();
|
||||||
void startTimeChanged();
|
void startTimeChanged();
|
||||||
void endTimeChanged();
|
void endTimeChanged();
|
||||||
|
// void paginationCountChanged();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void update();
|
virtual void update();
|
||||||
|
|||||||
@ -5,22 +5,24 @@
|
|||||||
|
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
#include "types/logentry.h"
|
#include "types/logentry.h"
|
||||||
|
#include "logmanager.h"
|
||||||
|
|
||||||
LogsModelNg::LogsModelNg(QObject *parent) : QAbstractListModel(parent)
|
LogsModelNg::LogsModelNg(QObject *parent) : QAbstractListModel(parent)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonRpcClient *LogsModelNg::jsonRpcClient() const
|
Engine *LogsModelNg::engine() const
|
||||||
{
|
{
|
||||||
return m_jsonRpcClient;
|
return m_engine;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogsModelNg::setJsonRpcClient(JsonRpcClient *jsonRpcClient)
|
void LogsModelNg::setEngine(Engine *engine)
|
||||||
{
|
{
|
||||||
if (m_jsonRpcClient != jsonRpcClient) {
|
if (m_engine != engine) {
|
||||||
m_jsonRpcClient = jsonRpcClient;
|
m_engine = engine;
|
||||||
emit jsonRpcClientChanged();
|
connect(engine->logManager(), &LogManager::logEntryReceived, this, &LogsModelNg::newLogEntryReceived);
|
||||||
|
emit engineChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,16 +94,16 @@ void LogsModelNg::setDeviceId(const QString &deviceId)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString LogsModelNg::typeId() const
|
QStringList LogsModelNg::typeIds() const
|
||||||
{
|
{
|
||||||
return m_typeId;
|
return m_typeIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogsModelNg::setTypeId(const QString &typeId)
|
void LogsModelNg::setTypeIds(const QStringList &typeIds)
|
||||||
{
|
{
|
||||||
if (m_typeId != typeId) {
|
if (m_typeIds != typeIds) {
|
||||||
m_typeId = typeId;
|
m_typeIds = typeIds;
|
||||||
emit typeIdChanged();
|
emit typeIdsChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,7 +117,6 @@ void LogsModelNg::setStartTime(const QDateTime &startTime)
|
|||||||
if (m_startTime != startTime) {
|
if (m_startTime != startTime) {
|
||||||
m_startTime = startTime;
|
m_startTime = startTime;
|
||||||
emit startTimeChanged();
|
emit startTimeChanged();
|
||||||
update();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,13 +130,57 @@ void LogsModelNg::setEndTime(const QDateTime &endTime)
|
|||||||
if (m_endTime != endTime) {
|
if (m_endTime != endTime) {
|
||||||
m_endTime = endTime;
|
m_endTime = endTime;
|
||||||
emit endTimeChanged();
|
emit endTimeChanged();
|
||||||
update();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogsModelNg::update()
|
void LogsModelNg::logsReply(const QVariantMap &data)
|
||||||
{
|
{
|
||||||
if (!m_jsonRpcClient) {
|
qDebug() << "logs reply" << data;
|
||||||
|
|
||||||
|
m_busy = false;
|
||||||
|
emit busyChanged();
|
||||||
|
|
||||||
|
int offset = data.value("params").toMap().value("offset").toInt();
|
||||||
|
int count = data.value("params").toMap().value("count").toInt();
|
||||||
|
|
||||||
|
QList<LogEntry*> newBlock;
|
||||||
|
QList<QVariant> logEntries = data.value("params").toMap().value("logEntries").toList();
|
||||||
|
foreach (const QVariant &logEntryVariant, logEntries) {
|
||||||
|
QVariantMap entryMap = logEntryVariant.toMap();
|
||||||
|
QDateTime timeStamp = QDateTime::fromMSecsSinceEpoch(entryMap.value("timestamp").toLongLong());
|
||||||
|
QString deviceId = entryMap.value("deviceId").toString();
|
||||||
|
QString typeId = entryMap.value("typeId").toString();
|
||||||
|
QMetaEnum sourceEnum = QMetaEnum::fromType<LogEntry::LoggingSource>();
|
||||||
|
LogEntry::LoggingSource loggingSource = static_cast<LogEntry::LoggingSource>(sourceEnum.keyToValue(entryMap.value("source").toByteArray()));
|
||||||
|
QMetaEnum loggingEventTypeEnum = QMetaEnum::fromType<LogEntry::LoggingEventType>();
|
||||||
|
LogEntry::LoggingEventType loggingEventType = static_cast<LogEntry::LoggingEventType>(loggingEventTypeEnum.keyToValue(entryMap.value("eventType").toByteArray()));
|
||||||
|
QVariant value = loggingEventType == LogEntry::LoggingEventTypeActiveChange ? entryMap.value("active").toBool() : entryMap.value("value");
|
||||||
|
LogEntry *entry = new LogEntry(timeStamp, value, deviceId, typeId, loggingSource, loggingEventType, this);
|
||||||
|
newBlock.append(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count < m_blockSize) {
|
||||||
|
m_canFetchMore = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newBlock.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
beginInsertRows(QModelIndex(), offset, offset + newBlock.count() - 1);
|
||||||
|
for (int i = 0; i < newBlock.count(); i++) {
|
||||||
|
m_list.insert(offset + i, newBlock.at(i));
|
||||||
|
}
|
||||||
|
endInsertRows();
|
||||||
|
emit countChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LogsModelNg::fetchMore(const QModelIndex &parent)
|
||||||
|
{
|
||||||
|
Q_UNUSED(parent)
|
||||||
|
qDebug() << "fetchMore called";
|
||||||
|
|
||||||
|
if (!m_engine->jsonRpcClient()) {
|
||||||
qWarning() << "Cannot update. JsonRpcClient not set";
|
qWarning() << "Cannot update. JsonRpcClient not set";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -143,66 +188,11 @@ void LogsModelNg::update()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_startTime.isNull() || m_endTime.isNull()) {
|
if ((!m_startTime.isNull() && m_endTime.isNull()) || (m_startTime.isNull() && !m_endTime.isNull())) {
|
||||||
// Need both, startTime and endTime set
|
// Need neither or both, startTime and endTime set
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_currentFetchStartTime = QDateTime();
|
|
||||||
m_currentFetchEndTime = QDateTime();
|
|
||||||
bool haveData = false;
|
|
||||||
for(int i = 0; i < m_fetchedPeriods.length(); i++) {
|
|
||||||
if (m_fetchedPeriods.at(i).first < m_startTime) {
|
|
||||||
if (m_fetchedPeriods.at(i).second == true) {
|
|
||||||
haveData = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (m_fetchedPeriods.at(i).second == false) {
|
|
||||||
haveData = false;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (m_fetchedPeriods.at(i).first == m_startTime) {
|
|
||||||
if (m_fetchedPeriods.at(i).second == true) {
|
|
||||||
haveData = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (m_fetchedPeriods.at(i).second == false) {
|
|
||||||
m_currentFetchStartTime = m_startTime;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (m_fetchedPeriods.at(i).first > m_startTime) {
|
|
||||||
if (m_fetchedPeriods.at(i).second == true) {
|
|
||||||
if (m_currentFetchStartTime.isNull()) {
|
|
||||||
m_currentFetchStartTime = m_startTime;
|
|
||||||
}
|
|
||||||
m_currentFetchEndTime = m_fetchedPeriods.at(i).first;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (m_fetchedPeriods.at(i).second == false) {
|
|
||||||
if (m_currentFetchStartTime.isNull()) {
|
|
||||||
haveData = false;
|
|
||||||
m_currentFetchStartTime = m_fetchedPeriods.at(i).first;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (haveData) {
|
|
||||||
qDebug() << "all the data is fetched";
|
|
||||||
m_busy = false;
|
|
||||||
emit busyChanged();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (m_currentFetchStartTime.isNull()) {
|
|
||||||
m_currentFetchStartTime = m_startTime;
|
|
||||||
}
|
|
||||||
if (m_currentFetchEndTime.isNull()) {
|
|
||||||
m_currentFetchEndTime = m_endTime;
|
|
||||||
}
|
|
||||||
qDebug() << "Fetching from" << m_currentFetchStartTime << "to" << m_currentFetchEndTime;
|
|
||||||
|
|
||||||
m_busy = true;
|
m_busy = true;
|
||||||
emit busyChanged();
|
emit busyChanged();
|
||||||
|
|
||||||
@ -212,103 +202,65 @@ void LogsModelNg::update()
|
|||||||
deviceIds.append(m_deviceId);
|
deviceIds.append(m_deviceId);
|
||||||
params.insert("deviceIds", deviceIds);
|
params.insert("deviceIds", deviceIds);
|
||||||
}
|
}
|
||||||
if (!m_typeId.isEmpty()) {
|
if (!m_typeIds.isEmpty()) {
|
||||||
QVariantList typeIds;
|
QVariantList typeIds;
|
||||||
typeIds.append(m_typeId);
|
foreach (const QString &typeId, m_typeIds) {
|
||||||
|
typeIds.append(typeId);
|
||||||
|
}
|
||||||
params.insert("typeIds", typeIds);
|
params.insert("typeIds", typeIds);
|
||||||
}
|
}
|
||||||
QVariantList timeFilters;
|
if (!m_startTime.isNull() && !m_endTime.isNull()) {
|
||||||
QVariantMap timeFilter;
|
QVariantList timeFilters;
|
||||||
timeFilter.insert("startDate", m_currentFetchStartTime.toSecsSinceEpoch());
|
QVariantMap timeFilter;
|
||||||
timeFilter.insert("endDate", m_currentFetchEndTime.toSecsSinceEpoch());
|
timeFilter.insert("startDate", m_currentFetchStartTime.toSecsSinceEpoch());
|
||||||
timeFilters.append(timeFilter);
|
timeFilter.insert("endDate", m_currentFetchEndTime.toSecsSinceEpoch());
|
||||||
params.insert("timeFilters", timeFilters);
|
timeFilters.append(timeFilter);
|
||||||
m_jsonRpcClient->sendCommand("Logging.GetLogEntries", params, this, "logsReply");
|
params.insert("timeFilters", timeFilters);
|
||||||
|
}
|
||||||
|
|
||||||
|
params.insert("limit", m_blockSize);
|
||||||
|
params.insert("offset", m_list.count());
|
||||||
|
|
||||||
|
m_engine->jsonRpcClient()->sendCommand("Logging.GetLogEntries", params, this, "logsReply");
|
||||||
|
qDebug() << "GetLogEntries called";
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogsModelNg::logsReply(const QVariantMap &data)
|
bool LogsModelNg::canFetchMore(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
qDebug() << "logs reply";// << data;
|
Q_UNUSED(parent)
|
||||||
|
qDebug() << "canFetchMore" << m_canFetchMore;
|
||||||
// First update the fetched periods information
|
return m_canFetchMore;
|
||||||
int insertIndex = -1;
|
|
||||||
bool noNeedToInsert = false;
|
|
||||||
for (int i = 0; i < m_fetchedPeriods.count(); i++) {
|
|
||||||
if (m_fetchedPeriods.at(i).first < m_currentFetchStartTime) {
|
|
||||||
// skip it
|
|
||||||
insertIndex = i+1;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (m_fetchedPeriods.at(i).first == m_currentFetchStartTime) {
|
|
||||||
if (m_fetchedPeriods.at(i).second == false) {
|
|
||||||
// Have an end marker where we start inserting. We can drop the existing end marker and just update the end marker
|
|
||||||
if (m_fetchedPeriods.count() > i+1) {
|
|
||||||
if (m_fetchedPeriods.at(i+1).first < m_currentFetchEndTime) {
|
|
||||||
qWarning() << "Overlap detected!";
|
|
||||||
} else if (m_fetchedPeriods.at(i+1).first == m_currentFetchEndTime) {
|
|
||||||
if (m_fetchedPeriods.at(i+1).second == true) {
|
|
||||||
m_fetchedPeriods.removeAt(i+1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_fetchedPeriods.removeAt(i);
|
|
||||||
noNeedToInsert = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (m_fetchedPeriods.at(i).first > m_currentFetchStartTime) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!noNeedToInsert) {
|
|
||||||
if (insertIndex == -1) {
|
|
||||||
insertIndex = 0;
|
|
||||||
}
|
|
||||||
m_fetchedPeriods.insert(insertIndex, qMakePair<QDateTime,bool>(m_currentFetchStartTime, true));
|
|
||||||
m_fetchedPeriods.insert(insertIndex+1, qMakePair<QDateTime,bool>(m_currentFetchEndTime, false));
|
|
||||||
}
|
|
||||||
qDebug() << "new fetched periods:" << m_fetchedPeriods << "insertIndex:" << insertIndex;
|
|
||||||
m_busy = false;
|
|
||||||
emit busyChanged();
|
|
||||||
|
|
||||||
|
|
||||||
QList<LogEntry*> newBlock;
|
|
||||||
QList<QVariant> logEntries = data.value("params").toMap().value("logEntries").toList();
|
|
||||||
foreach (const QVariant &logEntryVariant, logEntries) {
|
|
||||||
QVariantMap entryMap = logEntryVariant.toMap();
|
|
||||||
QDateTime timeStamp = QDateTime::fromMSecsSinceEpoch(entryMap.value("timestamp").toLongLong());
|
|
||||||
QString deviceId = entryMap.value("deviceId").toString();
|
|
||||||
QString typeId = entryMap.value("typeId").toString();
|
|
||||||
QMetaEnum sourceEnum = QMetaEnum::fromType<LogEntry::LoggingSource>();
|
|
||||||
LogEntry::LoggingSource loggingSource = (LogEntry::LoggingSource)sourceEnum.keyToValue(entryMap.value("source").toByteArray());
|
|
||||||
QMetaEnum loggingEventTypeEnum = QMetaEnum::fromType<LogEntry::LoggingEventType>();
|
|
||||||
LogEntry::LoggingEventType loggingEventType = (LogEntry::LoggingEventType)loggingEventTypeEnum.keyToValue(entryMap.value("eventType").toByteArray());
|
|
||||||
QVariant value = loggingEventType == LogEntry::LoggingEventTypeActiveChange ? entryMap.value("active").toBool() : entryMap.value("value");
|
|
||||||
LogEntry *entry = new LogEntry(timeStamp, value, deviceId, typeId, loggingSource, loggingEventType, this);
|
|
||||||
newBlock.append(entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now let's find where to insert stuff in the model
|
|
||||||
if (!newBlock.isEmpty()) {
|
|
||||||
int indexToInsert = 0;
|
|
||||||
for (int i = 0; i < m_list.count(); i++) {
|
|
||||||
LogEntry *entry = m_list.at(i);
|
|
||||||
if (entry->timestamp() < newBlock.first()->timestamp()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
indexToInsert = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
beginInsertRows(QModelIndex(), indexToInsert, indexToInsert + newBlock.count() - 1);
|
|
||||||
for (int i = 0; i < newBlock.count(); i++) {
|
|
||||||
m_list.insert(indexToInsert + i, newBlock.at(i));
|
|
||||||
}
|
|
||||||
endInsertRows();
|
|
||||||
emit countChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LogsModelNg::newLogEntryReceived(const QVariantMap &data)
|
||||||
|
{
|
||||||
|
if (!m_live) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariantMap entryMap = data;
|
||||||
|
QString deviceId = entryMap.value("deviceId").toString();
|
||||||
|
if (!m_deviceId.isNull() && deviceId != m_deviceId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString typeId = entryMap.value("typeId").toString();
|
||||||
|
if (!m_typeIds.isEmpty() && !m_typeIds.contains(typeId)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
beginInsertRows(QModelIndex(), 0, 0);
|
||||||
|
QDateTime timeStamp = QDateTime::fromMSecsSinceEpoch(entryMap.value("timestamp").toLongLong());
|
||||||
|
QMetaEnum sourceEnum = QMetaEnum::fromType<LogEntry::LoggingSource>();
|
||||||
|
LogEntry::LoggingSource loggingSource = static_cast<LogEntry::LoggingSource>(sourceEnum.keyToValue(entryMap.value("source").toByteArray()));
|
||||||
|
QMetaEnum loggingEventTypeEnum = QMetaEnum::fromType<LogEntry::LoggingEventType>();
|
||||||
|
LogEntry::LoggingEventType loggingEventType = static_cast<LogEntry::LoggingEventType>(loggingEventTypeEnum.keyToValue(entryMap.value("eventType").toByteArray()));
|
||||||
|
QVariant value = loggingEventType == LogEntry::LoggingEventTypeActiveChange ? entryMap.value("active").toBool() : entryMap.value("value");
|
||||||
|
LogEntry *entry = new LogEntry(timeStamp, value, deviceId, typeId, loggingSource, loggingEventType, this);
|
||||||
|
m_list.prepend(entry);
|
||||||
|
endInsertRows();
|
||||||
|
emit countChanged();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,16 +6,17 @@
|
|||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
|
||||||
class LogEntry;
|
class LogEntry;
|
||||||
class JsonRpcClient;
|
class Engine;
|
||||||
|
|
||||||
class LogsModelNg : public QAbstractListModel
|
class LogsModelNg : public QAbstractListModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(JsonRpcClient* jsonRpcClient READ jsonRpcClient WRITE setJsonRpcClient NOTIFY jsonRpcClientChanged)
|
Q_PROPERTY(Engine* engine READ engine WRITE setEngine NOTIFY engineChanged)
|
||||||
Q_PROPERTY(bool busy READ busy NOTIFY busyChanged)
|
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(int count READ rowCount NOTIFY countChanged)
|
||||||
Q_PROPERTY(QString deviceId READ deviceId WRITE setDeviceId NOTIFY deviceIdChanged)
|
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 startTime READ startTime WRITE setStartTime NOTIFY startTimeChanged)
|
||||||
Q_PROPERTY(QDateTime endTime READ endTime WRITE setEndTime NOTIFY endTimeChanged)
|
Q_PROPERTY(QDateTime endTime READ endTime WRITE setEndTime NOTIFY endTimeChanged)
|
||||||
|
|
||||||
@ -31,8 +32,8 @@ public:
|
|||||||
|
|
||||||
explicit LogsModelNg(QObject *parent = nullptr);
|
explicit LogsModelNg(QObject *parent = nullptr);
|
||||||
|
|
||||||
JsonRpcClient *jsonRpcClient() const;
|
Engine *engine() const;
|
||||||
void setJsonRpcClient(JsonRpcClient* jsonRpcClient);
|
void setEngine(Engine* jsonRpcClient);
|
||||||
|
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||||
QVariant data(const QModelIndex &index, int role) const override;
|
QVariant data(const QModelIndex &index, int role) const override;
|
||||||
@ -46,8 +47,8 @@ public:
|
|||||||
QString deviceId() const;
|
QString deviceId() const;
|
||||||
void setDeviceId(const QString &deviceId);
|
void setDeviceId(const QString &deviceId);
|
||||||
|
|
||||||
QString typeId() const;
|
QStringList typeIds() const;
|
||||||
void setTypeId(const QString &typeId);
|
void setTypeIds(const QStringList &typeId);
|
||||||
|
|
||||||
QDateTime startTime() const;
|
QDateTime startTime() const;
|
||||||
void setStartTime(const QDateTime &startTime);
|
void setStartTime(const QDateTime &startTime);
|
||||||
@ -55,34 +56,40 @@ public:
|
|||||||
QDateTime endTime() const;
|
QDateTime endTime() const;
|
||||||
void setEndTime(const QDateTime &endTime);
|
void setEndTime(const QDateTime &endTime);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void fetchMore(const QModelIndex &parent = QModelIndex()) override;
|
||||||
|
virtual bool canFetchMore(const QModelIndex &parent = QModelIndex()) const override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void busyChanged();
|
void busyChanged();
|
||||||
void liveChanged();
|
void liveChanged();
|
||||||
void deviceIdChanged();
|
void deviceIdChanged();
|
||||||
void typeIdChanged();
|
void typeIdsChanged();
|
||||||
void countChanged();
|
void countChanged();
|
||||||
void startTimeChanged();
|
void startTimeChanged();
|
||||||
void endTimeChanged();
|
void endTimeChanged();
|
||||||
void jsonRpcClientChanged();
|
void engineChanged();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void newLogEntryReceived(const QVariantMap &data);
|
||||||
|
void logsReply(const QVariantMap &data);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<LogEntry*> m_list;
|
QList<LogEntry*> m_list;
|
||||||
|
|
||||||
JsonRpcClient *m_jsonRpcClient = nullptr;
|
Engine *m_engine = nullptr;
|
||||||
bool m_busy = false;
|
bool m_busy = false;
|
||||||
bool m_live = false;
|
bool m_live = false;
|
||||||
QString m_deviceId;
|
QString m_deviceId;
|
||||||
QString m_typeId;
|
QStringList m_typeIds;
|
||||||
QDateTime m_startTime;
|
QDateTime m_startTime;
|
||||||
QDateTime m_endTime;
|
QDateTime m_endTime;
|
||||||
QDateTime m_currentFetchStartTime;
|
QDateTime m_currentFetchStartTime;
|
||||||
QDateTime m_currentFetchEndTime;
|
QDateTime m_currentFetchEndTime;
|
||||||
|
int m_blockSize = 100;
|
||||||
|
bool m_canFetchMore = true;
|
||||||
|
|
||||||
QList<QPair<QDateTime, bool> > m_fetchedPeriods;
|
QList<QPair<QDateTime, bool> > m_fetchedPeriods;
|
||||||
|
|
||||||
void update();
|
|
||||||
Q_INVOKABLE void logsReply(const QVariantMap &data);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,8 +6,6 @@ import "../components"
|
|||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
// %1 will be replaced with count
|
|
||||||
property string text
|
|
||||||
|
|
||||||
signal addRuleClicked(var value)
|
signal addRuleClicked(var value)
|
||||||
|
|
||||||
@ -15,122 +13,74 @@ Item {
|
|||||||
|
|
||||||
property alias delegate: listView.delegate
|
property alias delegate: listView.delegate
|
||||||
|
|
||||||
property bool autoscroll: true
|
ListView {
|
||||||
|
id: listView
|
||||||
ColumnLayout {
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
model: logsModel
|
||||||
|
clip: true
|
||||||
|
|
||||||
Label {
|
ScrollBar.vertical: ScrollBar {}
|
||||||
id: titleLabel
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.margins: app.margins
|
|
||||||
wrapMode: Text.WordWrap
|
|
||||||
text: root.text.arg(logsModel.count).arg((logsModel.endTime.getTime() - logsModel.startTime.getTime())/ 1000 / 60 / 60 /24)
|
|
||||||
}
|
|
||||||
|
|
||||||
ThinDivider {}
|
onContentYChanged: {
|
||||||
|
if (!engine.jsonRpcClient.ensureServerVersion("1.10")) {
|
||||||
RulesFilterModel {
|
|
||||||
id: rulesFilterModel
|
|
||||||
rules: engine.ruleManager.rules
|
|
||||||
filterDeviceId: root.logsModel.deviceId
|
|
||||||
}
|
|
||||||
|
|
||||||
ListView {
|
|
||||||
id: listView
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.fillHeight: true
|
|
||||||
model: logsModel
|
|
||||||
clip: true
|
|
||||||
onCountChanged: {
|
|
||||||
if (root.autoscroll) {
|
|
||||||
positionViewAtEnd()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onContentYChanged: {
|
|
||||||
if (!logsModel.busy && contentY - originY < 5 * height) {
|
if (!logsModel.busy && contentY - originY < 5 * height) {
|
||||||
logsModel.fetchEarlier(24)
|
logsModel.fetchEarlier(24)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
delegate: SwipeDelegate {
|
delegate: SwipeDelegate {
|
||||||
id: logEntryDelegate
|
id: logEntryDelegate
|
||||||
width: parent.width
|
width: parent.width
|
||||||
implicitHeight: app.delegateHeight
|
implicitHeight: app.delegateHeight
|
||||||
property var device: engine.deviceManager.devices.getDevice(model.deviceId)
|
property var device: engine.deviceManager.devices.getDevice(model.deviceId)
|
||||||
property var deviceClass: engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId)
|
property var deviceClass: engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId)
|
||||||
contentItem: RowLayout {
|
contentItem: RowLayout {
|
||||||
ColorIcon {
|
ColorIcon {
|
||||||
Layout.preferredHeight: app.iconSize
|
Layout.preferredHeight: app.iconSize
|
||||||
Layout.preferredWidth: height
|
Layout.preferredWidth: height
|
||||||
name: "../images/event.svg"
|
name: "../images/event.svg"
|
||||||
color: app.accentColor
|
color: app.accentColor
|
||||||
}
|
|
||||||
|
|
||||||
ColumnLayout {
|
|
||||||
Label {
|
|
||||||
id: timeStampLabel
|
|
||||||
Layout.fillWidth: true
|
|
||||||
text: Qt.formatDateTime(model.timestamp,"dd.MM.yy - hh:mm:ss")
|
|
||||||
}
|
|
||||||
Label {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
text: "%1: %2".arg(deviceClass.eventTypes.getEventType(model.typeId).displayName).arg(model.value.trim())
|
|
||||||
elide: Text.ElideRight
|
|
||||||
font.pixelSize: app.smallFont
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// ColorIcon {
|
|
||||||
// Layout.preferredWidth: app.iconSize
|
|
||||||
// Layout.preferredHeight: width
|
|
||||||
// name: "../images/magic.svg"
|
|
||||||
// color: {
|
|
||||||
// for (var i = 0; i < rulesFilterModel.count; i++) {
|
|
||||||
// var rule = rulesFilterModel.get(i);
|
|
||||||
// for (var j = 0; j < rule.eventDescriptors.count; j++) {
|
|
||||||
// var eventDescriptor = rule.eventDescriptors.get(j);
|
|
||||||
// if (eventDescriptor.eventTypeId === root.logsModel.typeId) {
|
|
||||||
// var matching = true;
|
|
||||||
// for (var k = 0; k < eventDescriptor.paramDescriptors.count; k++) {
|
|
||||||
// var paramDescriptor = eventDescriptor.paramDescriptors.get(k);
|
|
||||||
// if (paramDescriptor.value === model.value) {
|
|
||||||
// return app.accentColor;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return keyColor;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
swipe.right: MouseArea {
|
|
||||||
height: logEntryDelegate.height
|
ColumnLayout {
|
||||||
width: height
|
Label {
|
||||||
anchors.right: parent.right
|
id: timeStampLabel
|
||||||
ColorIcon {
|
Layout.fillWidth: true
|
||||||
anchors.fill: parent
|
text: Qt.formatDateTime(model.timestamp,"dd.MM.yy - hh:mm:ss")
|
||||||
anchors.margins: app.margins
|
|
||||||
name: "../images/magic.svg"
|
|
||||||
}
|
}
|
||||||
onClicked: root.addRuleClicked(model.value)
|
Label {
|
||||||
}
|
Layout.fillWidth: true
|
||||||
onClicked: {
|
text: "%1: %2".arg(deviceClass.eventTypes.getEventType(model.typeId).displayName).arg(model.value.trim())
|
||||||
if (swipe.complete) {
|
elide: Text.ElideRight
|
||||||
swipe.close()
|
font.pixelSize: app.smallFont
|
||||||
} else {
|
|
||||||
swipe.open(SwipeDelegate.Right)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
swipe.right: MouseArea {
|
||||||
BusyIndicator {
|
height: logEntryDelegate.height
|
||||||
anchors.centerIn: parent
|
width: height
|
||||||
visible: root.logsModel.busy
|
anchors.right: parent.right
|
||||||
running: visible
|
ColorIcon {
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: app.margins
|
||||||
|
name: "../images/magic.svg"
|
||||||
|
}
|
||||||
|
onClicked: root.addRuleClicked(model.value)
|
||||||
}
|
}
|
||||||
|
onClicked: {
|
||||||
|
if (swipe.complete) {
|
||||||
|
swipe.close()
|
||||||
|
} else {
|
||||||
|
swipe.open(SwipeDelegate.Right)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BusyIndicator {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
visible: root.logsModel.busy
|
||||||
|
running: visible
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -304,6 +304,7 @@ ItemDelegate {
|
|||||||
property var value: null
|
property var value: null
|
||||||
text: root.actionType.displayName
|
text: root.actionType.displayName
|
||||||
onClicked: {
|
onClicked: {
|
||||||
|
print("ActionDelegate: Button clicked")
|
||||||
var params = [];
|
var params = [];
|
||||||
print("fooo", root.actionType.paramTypes.count)
|
print("fooo", root.actionType.paramTypes.count)
|
||||||
for (var i = 0; i < root.actionType.paramTypes.count; i++) {
|
for (var i = 0; i < root.actionType.paramTypes.count; i++) {
|
||||||
|
|||||||
@ -5,15 +5,29 @@ import Nymea 1.0
|
|||||||
import "../components"
|
import "../components"
|
||||||
import "../customviews"
|
import "../customviews"
|
||||||
|
|
||||||
GenericDevicePage {
|
DevicePageBase {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
|
||||||
GenericTypeLogView {
|
GenericTypeLogView {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
text: qsTr("This button has been pressed %1 times in the last %2 days.")
|
|
||||||
|
|
||||||
logsModel: LogsModel {
|
logsModel: engine.jsonRpcClient.ensureServerVersion("1.10") ? logsModelNg : logsModel
|
||||||
|
LogsModelNg {
|
||||||
|
id: logsModelNg
|
||||||
|
engine: _engine
|
||||||
|
deviceId: root.device.id
|
||||||
|
live: true
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LogsModel {
|
||||||
|
id: logsModel
|
||||||
engine: _engine
|
engine: _engine
|
||||||
deviceId: root.device.id
|
deviceId: root.device.id
|
||||||
live: true
|
live: true
|
||||||
|
|||||||
@ -26,14 +26,28 @@ DevicePageBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ThinDivider {}
|
ThinDivider {}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.margins: app.margins
|
||||||
|
text: qsTr("Access log:")
|
||||||
|
}
|
||||||
|
|
||||||
GenericTypeLogView {
|
GenericTypeLogView {
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
text: qsTr("%1 fingerprints recognized on this device in the last %2 days.")
|
|
||||||
|
|
||||||
logsModel: LogsModel {
|
logsModel: engine.jsonRpcClient.ensureServerVersion("1.10") ? logsModelNg : logsModel
|
||||||
|
LogsModelNg {
|
||||||
|
id: logsModelNg
|
||||||
|
deviceId: root.device.id
|
||||||
|
engine: _engine
|
||||||
|
live: true
|
||||||
|
typeIds: [root.accessGrantedEventType.id, root.accessDeniedEventType.id];
|
||||||
|
}
|
||||||
|
LogsModel {
|
||||||
|
id: logsModel
|
||||||
deviceId: root.device.id
|
deviceId: root.device.id
|
||||||
engine: _engine
|
engine: _engine
|
||||||
live: true
|
live: true
|
||||||
|
|||||||
@ -5,14 +5,22 @@ import Nymea 1.0
|
|||||||
import "../components"
|
import "../components"
|
||||||
import "../customviews"
|
import "../customviews"
|
||||||
|
|
||||||
GenericDevicePage {
|
DevicePageBase {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
GenericTypeLogView {
|
GenericTypeLogView {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
text: qsTr("This event has appeared %1 times in the last %2 days.")
|
|
||||||
|
|
||||||
logsModel: LogsModel {
|
logsModel: engine.jsonRpcClient.ensureServerVersion("1.10") ? logsModelNg : logsModel
|
||||||
|
LogsModelNg {
|
||||||
|
id: logsModelNg
|
||||||
|
engine: _engine
|
||||||
|
deviceId: root.device.id
|
||||||
|
live: true
|
||||||
|
typeIds: [root.deviceClass.eventTypes.findByName("triggered").id];
|
||||||
|
}
|
||||||
|
LogsModel {
|
||||||
|
id: logsModel
|
||||||
engine: _engine
|
engine: _engine
|
||||||
deviceId: root.device.id
|
deviceId: root.device.id
|
||||||
live: true
|
live: true
|
||||||
|
|||||||
@ -71,18 +71,33 @@ DevicePageBase {
|
|||||||
|
|
||||||
ThinDivider {}
|
ThinDivider {}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.margins: app.margins
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
text: qsTr("Sent notifications:")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
GenericTypeLogView {
|
GenericTypeLogView {
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
text: qsTr("%1 notifications sent to this device in the last %2 days.")
|
|
||||||
|
|
||||||
logsModel: LogsModel {
|
logsModel: engine.jsonRpcClient.ensureServerVersion("1.10") ? logsModelNg : logsModel
|
||||||
|
LogsModelNg {
|
||||||
|
id: logsModelNg
|
||||||
|
deviceId: root.device.id
|
||||||
|
engine: _engine
|
||||||
|
typeIds: [root.deviceClass.actionTypes.findByName("notify").id];
|
||||||
|
}
|
||||||
|
|
||||||
|
LogsModel {
|
||||||
|
id: logsModel
|
||||||
deviceId: root.device.id
|
deviceId: root.device.id
|
||||||
live: true
|
live: true
|
||||||
engine: _engine
|
engine: _engine
|
||||||
Component.onCompleted: update()
|
Component.onCompleted: update()
|
||||||
typeIds: [root.deviceClass.actionTypes.findByName("notify").id];
|
typeIds: [root.deviceClass.actionTypes.findByName("notify").id];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delegate: MeaListItemDelegate {
|
delegate: MeaListItemDelegate {
|
||||||
|
|||||||
@ -37,17 +37,13 @@ Page {
|
|||||||
typeIds: [root.stateType.id]
|
typeIds: [root.stateType.id]
|
||||||
}
|
}
|
||||||
|
|
||||||
// LogsModelNg {
|
LogsModelNg {
|
||||||
// id: logsModelNg
|
id: logsModelNg
|
||||||
// deviceId: root.device.id
|
engine: _engine
|
||||||
// typeId: root.stateType.id
|
deviceId: root.device.id
|
||||||
// startTime: {
|
typeIds: [root.stateType.id]
|
||||||
// var date = new Date();
|
live: true
|
||||||
// date.setHours(new Date().getHours() - 24)
|
}
|
||||||
// return date;
|
|
||||||
// }
|
|
||||||
// endTime: new Date();
|
|
||||||
// }
|
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@ -75,9 +71,8 @@ Page {
|
|||||||
id: logView
|
id: logView
|
||||||
width: swipeView.width
|
width: swipeView.width
|
||||||
height: swipeView.height
|
height: swipeView.height
|
||||||
text: qsTr("%1, %2 has changed %3 times in the last %4 days").arg(device.name).arg(stateType.displayName)
|
|
||||||
|
|
||||||
logsModel: logsModel
|
logsModel: engine.jsonRpcClient.ensureServerVersion("1.10") ? logsModelNg : logsModel
|
||||||
|
|
||||||
onAddRuleClicked: {
|
onAddRuleClicked: {
|
||||||
var rule = engine.ruleManager.createNewRule();
|
var rule = engine.ruleManager.createNewRule();
|
||||||
|
|||||||
@ -33,7 +33,6 @@ Page {
|
|||||||
}
|
}
|
||||||
endTime: new Date()
|
endTime: new Date()
|
||||||
live: true
|
live: true
|
||||||
Component.onCompleted: update()
|
|
||||||
onCountChanged: {
|
onCountChanged: {
|
||||||
if (root.autoScroll) {
|
if (root.autoScroll) {
|
||||||
listView.positionViewAtEnd()
|
listView.positionViewAtEnd()
|
||||||
@ -41,6 +40,12 @@ Page {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogsModelNg {
|
||||||
|
id: logsModelNg
|
||||||
|
engine: _engine
|
||||||
|
live: true
|
||||||
|
}
|
||||||
|
|
||||||
BusyIndicator {
|
BusyIndicator {
|
||||||
anchors.centerIn: listView
|
anchors.centerIn: listView
|
||||||
visible: logsModel.busy
|
visible: logsModel.busy
|
||||||
@ -48,11 +53,13 @@ Page {
|
|||||||
|
|
||||||
ListView {
|
ListView {
|
||||||
id: listView
|
id: listView
|
||||||
model: logsModel
|
model: engine.jsonRpcClient.ensureServerVersion("1.10") ? logsModelNg : logsModel
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
clip: true
|
clip: true
|
||||||
headerPositioning: ListView.OverlayHeader
|
headerPositioning: ListView.OverlayHeader
|
||||||
|
|
||||||
|
Component.onCompleted: model.update()
|
||||||
|
|
||||||
onDraggingChanged: {
|
onDraggingChanged: {
|
||||||
if (dragging) {
|
if (dragging) {
|
||||||
root.autoScroll = false;
|
root.autoScroll = false;
|
||||||
@ -62,8 +69,10 @@ Page {
|
|||||||
ScrollBar.vertical: ScrollBar {}
|
ScrollBar.vertical: ScrollBar {}
|
||||||
|
|
||||||
onContentYChanged: {
|
onContentYChanged: {
|
||||||
if (!logsModel.busy && contentY - originY < 5 * height) {
|
if (!engine.jsonRpcClient.ensureServerVersion("1.10")) {
|
||||||
logsModel.fetchEarlier(1)
|
if (!logsModel.busy && contentY - originY < 5 * height) {
|
||||||
|
logsModel.fetchEarlier(1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user