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/QObject>
7#include <QtQmlIntegration/QtQmlIntegration>
8
9class Fact;
10
13class FactValueSliderListModel : public QAbstractListModel
14{
15 Q_OBJECT
16 QML_ELEMENT
17 QML_UNCREATABLE("")
20
21public:
22 explicit FactValueSliderListModel(const Fact &fact, QObject *parent = nullptr);
24
25 double initialValueAtPrecision() const { return _initialValueAtPrecision; }
26
27 Q_INVOKABLE int resetInitialValue(void);
28 Q_INVOKABLE double valueAtModelIndex(int index) const;
29 Q_INVOKABLE int valueIndexAtModelIndex(int index) const;
30
31signals:
33
34private:
35 double _valueAtPrecision(double value) const;
36
37 int rowCount(const QModelIndex &parent = QModelIndex()) const final { Q_UNUSED(parent); return _cValues; }
38 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const final;
39 QHash<int, QByteArray> roleNames() const final;
40
41 const Fact &_fact;
42 int _cValues = 0;
43 int _firstValueIndexInWindow = 0;
44 int _initialValueIndex = 0;
45 int _cPrevValues = 0;
46 int _cNextValues = 0;
47 int _windowSize = 0;
48 double _initialValue = 0;
49 double _initialValueAtPrecision = 0;
50 double _increment = 0;
51
52 static constexpr int _valueRole = Qt::UserRole;
53 static constexpr int _valueIndexRole = Qt::UserRole + 1;
54};
Provides a list model of values for incrementing/decrementing the value of a Fact.
Q_INVOKABLE double valueAtModelIndex(int index) const
Q_INVOKABLE int valueIndexAtModelIndex(int index) const
Q_INVOKABLE int resetInitialValue(void)
A Fact is used to hold a single value within the system.
Definition Fact.h:17