Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
ConversionListModel.h
Go to the documentation of this file.
1#pragma once
2
3#include <QAbstractItemView>
4#include <QAbstractListModel>
6
7namespace sf
8{
9
13class ConversionListModel : public QAbstractListModel
14{
15 public:
19 explicit ConversionListModel(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
56 bool edit(const QModelIndex& index);
57
61 bool add();
62
66 bool remove(const QModelIndex& index);
67
71 [[nodiscard]] bool isDirty() const
72 {
73 return _dirty;
74 };
75
79 void sync();
80
81 private:
85 UnitConversionServerEx* _ucs{nullptr};
86
90 struct Entry
91 {
92 QString _option;
93 QString _from_unit;
94 int _from_precision{0};
95 double _multiplier{1};
96 double _offset{0};
97 QString _to_unit;
98 int _to_precision{0};
99 };
100
101 class Adapter;
102
106 void update();
107
111 QList<Entry> _list;
115 bool _dirty{false};
116};
117
118}// namespace sf
List model for manipulating the passed script manager.
Definition ConversionListModel.h:14
bool isDirty() const
Gets the modification flag.
Definition ConversionListModel.h:71
ConversionListModel(UnitConversionServerEx *ucs, QObject *parent=nullptr)
Constructor.
bool remove(const QModelIndex &index)
Removes entry with the passed index row.
void sync()
Saves changes to the unit server and resets the list's dirty flag.
int columnCount(const QModelIndex &parent) const override
Overridden from base class to provide the amount of columns.
bool edit(const QModelIndex &index)
Edits a entry depending on the validity of the passed 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.
QVariant data(const QModelIndex &index, int role) const override
Overridden from base class to provide the data to present.
int rowCount(const QModelIndex &parent) const override
Overridden from base class to provide the amount of rows.
void refresh()
Called to refresh the attached viewer.
Extended UnitConversionServer with master and slaved variables.
Definition UnitConversionServerEx.h:16
Definition Application.h:10