QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
LogViewerController.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtCore/QHash>
4#include <QtCore/QObject>
5#include <QtCore/QSet>
6#include <QtCore/QString>
7#include <QtCore/QStringList>
8#include <QtCore/QVariantList>
9#include <QtQmlIntegration/QtQmlIntegration>
10
11class LogViewerController : public QObject
12{
13 Q_OBJECT
14 QML_ELEMENT
15
17 Q_PROPERTY(QString currentLogPath READ currentLogPath NOTIFY currentLogPathChanged)
18 Q_PROPERTY(bool hasLoadedLog READ hasLoadedLog NOTIFY currentLogPathChanged)
19 Q_PROPERTY(QVariantList fieldRows READ fieldRows NOTIFY fieldRowsChanged)
20 Q_PROPERTY(QStringList selectedFields READ selectedFields NOTIFY selectedFieldsChanged)
21
22public:
23 enum class SourceType {
24 None,
25 TLog,
26 Bin,
27 ULog,
28 };
29 Q_ENUM(SourceType)
30
31 explicit LogViewerController(QObject *parent = nullptr);
33
34 SourceType sourceType() const { return _sourceType; }
35 QString currentLogPath() const { return _currentLogPath; }
36 bool hasLoadedLog() const { return !_currentLogPath.isEmpty(); }
37 QVariantList fieldRows() const { return _fieldRows; }
38 QStringList selectedFields() const { return _selectedFields; }
39
40 Q_INVOKABLE void clear();
41 Q_INVOKABLE void openTLog(const QString &path);
42 Q_INVOKABLE void openBinLog(const QString &path);
43 Q_INVOKABLE void openULogFile(const QString &path);
44 Q_INVOKABLE void setPlottableFields(const QStringList &fieldNames);
45 Q_INVOKABLE void clearSelection();
46 Q_INVOKABLE void toggleGroupExpanded(const QString &groupName);
47 Q_INVOKABLE bool isGroupExpanded(const QString &groupName) const;
48 Q_INVOKABLE void setFieldSelected(const QString &fieldName, bool selected);
49 Q_INVOKABLE bool isFieldSelected(const QString &fieldName) const;
52 Q_INVOKABLE QString fieldColor(const QString &fieldName) const;
53 Q_INVOKABLE QString eventColor(const QString &eventType) const;
54
55signals:
60
61private:
62 void _rebuildFieldRows();
63 QString _assignColorForKey(const QString &key) const;
64 void _setLog(SourceType sourceType, const QString &path);
65
66 SourceType _sourceType = SourceType::None;
67 QString _currentLogPath;
68 QStringList _plottableFields;
69 QVariantList _fieldRows;
70 QStringList _selectedFields;
71 QSet<QString> _expandedGroups;
72};
Q_INVOKABLE bool isGroupExpanded(const QString &groupName) const
Q_INVOKABLE void openTLog(const QString &path)
void currentLogPathChanged()
Q_INVOKABLE void openBinLog(const QString &path)
Q_INVOKABLE void clear()
SourceType sourceType() const
Q_INVOKABLE void setPlottableFields(const QStringList &fieldNames)
Q_INVOKABLE bool isFieldSelected(const QString &fieldName) const
Q_INVOKABLE QString fieldColor(const QString &fieldName) const
QString currentLogPath() const
Q_INVOKABLE void setFieldSelected(const QString &fieldName, bool selected)
QStringList selectedFields() const
Q_INVOKABLE void clearSelection()
Q_INVOKABLE void openULogFile(const QString &path)
Q_INVOKABLE void toggleGroupExpanded(const QString &groupName)
Q_INVOKABLE QString eventColor(const QString &eventType) const
void selectedFieldsChanged()
QVariantList fieldRows() const