Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
FollowersListModel.h
Go to the documentation of this file.
1#pragma once
2
3#include <QAbstractItemView>
4#include <QAbstractListModel>
6
7namespace sf
8{
9
13class FollowersListModel : public QAbstractListModel
14{
15 public:
19 explicit FollowersListModel(UnitConversionServerEx* ucs, QObject* parent = nullptr);
20
24 void refresh();
25
29 [[nodiscard]] QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
30
34 [[nodiscard]] int rowCount(const QModelIndex& parent) const override;
35
39 [[nodiscard]] QVariant data(const QModelIndex& index, int role) const override;
40
44 [[nodiscard]] int columnCount(const QModelIndex& parent) const override;
45
49 [[nodiscard]] Qt::ItemFlags flags(const QModelIndex& index) const override;
50
51 bool remove(const QModelIndex& index);
52
58 bool edit(const QModelIndex& index);
59
63 bool add();
64
68 [[nodiscard]] bool isDirty() const
69 {
70 return _dirty;
71 };
72
76 void sync();
77
81 struct Entry
82 {
84 QString _formula;
85 QString _unit;
86 QList<Variable::id_type> _followerIds;
87 };
88
89 private:
93 UnitConversionServerEx* _ucs{nullptr};
94
95 void update();
96
100 QList<Entry> _list;
101
105 bool _dirty{false};
106};
107
108}// namespace sf
List model for manipulating the passed script manager.
Definition FollowersListModel.h:14
FollowersListModel(UnitConversionServerEx *ucs, QObject *parent=nullptr)
Constructor.
int columnCount(const QModelIndex &parent) const override
Overridden from base class to provide the amount of columns.
int rowCount(const QModelIndex &parent) const override
Overridden from base class to provide the amount of rows.
QVariant data(const QModelIndex &index, int role) const override
Overridden from base class to provide the data to present.
void sync()
Saves changes to the unit server and resets the list's dirty flag.
bool isDirty() const
Gets the modification flag.
Definition FollowersListModel.h:68
bool edit(const QModelIndex &index)
Edits a entry depending on the validity of the passed index.
void refresh()
Called to refresh the attached viewer.
bool remove(const QModelIndex &index)
Qt::ItemFlags flags(const QModelIndex &index) const override
Overridden from base class to provide flags on an item by index.
bool add()
Adds a entry depending on the validity of the passed index.
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
Overridden from base class to provide column display names.
unsigned long long id_type
Type used for the identifying integer (64-bits).
Definition InformationBase.h:30
Extended UnitConversionServer with master and slaved variables.
Definition UnitConversionServerEx.h:16
Definition Application.h:10
Entry in to the temporary list of followers.
Definition FollowersListModel.h:82
Variable::id_type _masterId
Definition FollowersListModel.h:83
QList< Variable::id_type > _followerIds
Definition FollowersListModel.h:86
QString _unit
Definition FollowersListModel.h:85
QString _formula
Definition FollowersListModel.h:84