QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
FactValueSliderListModel.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtCore/QAbstractListModel>
4#include <QtCore/QByteArray>
5#include <QtCore/QHash>
6#include <QtCore/QLoggingCategory>
7#include <QtCore/QObject>
8#include <QtQmlIntegration/QtQmlIntegration>
9
10class Fact;
11
12Q_DECLARE_LOGGING_CATEGORY(FactValueSliderListModelLog)
13
14
15class FactValueSliderListModel : public QAbstractListModel
16{
17 Q_OBJECT
18 QML_ELEMENT
19 QML_UNCREATABLE("")
21 Q_PROPERTY(double initialValueAtPrecision READ initialValueAtPrecision NOTIFY initialValueAtPrecisionChanged)
22
23public:
24 explicit FactValueSliderListModel(const Fact &fact, QObject *parent = nullptr);
26
27 double initialValueAtPrecision() const { return _initialValueAtPrecision; }
28
29 Q_INVOKABLE int resetInitialValue(void);
30 Q_INVOKABLE double valueAtModelIndex(int index) const;
31 Q_INVOKABLE int valueIndexAtModelIndex(int index) const;
32
33signals:
35
36private:
37 double _valueAtPrecision(double value) const;
38
39 int rowCount(const QModelIndex &parent = QModelIndex()) const final { Q_UNUSED(parent); return _cValues; }
40 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const final;
41 QHash<int, QByteArray> roleNames() const final;
42
43 const Fact &_fact;
44 int _cValues = 0;
45 int _firstValueIndexInWindow = 0;
46 int _initialValueIndex = 0;
47 int _cPrevValues = 0;
48 int _cNextValues = 0;
49 int _windowSize = 0;
50 double _initialValue = 0;
51 double _initialValueAtPrecision = 0;
52 double _increment = 0;
53
54 static constexpr int _valueRole = Qt::UserRole;
55 static constexpr int _valueIndexRole = Qt::UserRole + 1;
56};
Q_DECLARE_LOGGING_CATEGORY(AndroidSerialLog)
Provides a list model of values for incrementing/decrementing the value of a Fact.
A Fact is used to hold a single value within the system.
Definition Fact.h:19