QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
LogStoreQueryModel.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtCore/QAbstractTableModel>
4#include <QtCore/QFutureWatcher>
5#include <QtCore/QList>
6#include <QtCore/QString>
7#include <QtQmlIntegration/QtQmlIntegration>
8
10
11class LogStore;
12
14{
15 Q_OBJECT
16 QML_ELEMENT
17 QML_UNCREATABLE("")
18
19 Q_PROPERTY(QString sessionFilter READ sessionFilter WRITE setSessionFilter NOTIFY sessionFilterChanged)
20 Q_PROPERTY(int filterLevel READ filterLevel WRITE setFilterLevel NOTIFY filterLevelChanged)
21 Q_PROPERTY(QString filterCategory READ filterCategory WRITE setFilterCategory NOTIFY filterCategoryChanged)
22 Q_PROPERTY(QString filterText READ filterText WRITE setFilterText NOTIFY filterTextChanged)
23 Q_PROPERTY(qint64 totalResults READ totalResults NOTIFY totalResultsChanged)
24 Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged)
25 Q_PROPERTY(QStringList availableSessions READ availableSessions NOTIFY availableSessionsChanged)
26
27public:
28 explicit LogStoreQueryModel(LogStore* store, QObject* parent = nullptr);
29
30 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
31
32 QString sessionFilter() const { return _sessionFilter; }
33
34 void setSessionFilter(const QString& session);
35
36 int filterLevel() const { return _filterLevel; }
37
38 void setFilterLevel(int level);
39
40 QString filterCategory() const { return _filterCategory; }
41
42 void setFilterCategory(const QString& category);
43
44 QString filterText() const { return _filterText; }
45
46 void setFilterText(const QString& text);
47
48 qint64 totalResults() const { return _totalResults; }
49
50 bool loading() const { return _loading; }
51
52 Q_INVOKABLE void refresh();
53 Q_INVOKABLE void loadMore();
54 QStringList availableSessions() const;
55
56signals:
64
65protected:
66 const LogEntry* entryAt(int row) const override;
67
68private:
69 struct QueryResult
70 {
71 QList<LogEntry> page;
72 bool append = false;
73 quint64 generation = 0;
74 };
75
76 void _executeQuery(bool append);
77 void _onQueryFinished();
78
79 LogStore* _store = nullptr;
80
81 QString _sessionFilter;
82 int _filterLevel = LogEntry::Debug;
83 QString _filterCategory;
84 QString _filterText;
85
86 QList<LogEntry> _results;
87 qint64 _totalResults = 0;
88 bool _loading = false;
89 quint64 _queryGeneration = 0;
90 QFutureWatcher<QueryResult> _queryWatcher;
91
92 static constexpr int kPageSize = 1000;
93};
void filterCategoryChanged()
void availableSessionsChanged()
void sessionFilterChanged()
const LogEntry * entryAt(int row) const override
Return entry at visible row, or nullptr if out of range.
void totalResultsChanged()