Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
InformationListIdModel.h
Go to the documentation of this file.
1#pragma once
3
4#include <QAbstractItemView>
5#include <QAbstractListModel>
7#include <gii/global.h>
8#include <gii/qt/Namespace.h>
9
10namespace sf
11{
12
16class _GII_CLASS InformationListIdModel final : public QAbstractListModel
17{
18 Q_OBJECT
19
20 public:
21 // Data structure assigned to hold the information
23 {
24 public:
31 Entry(InformationBase* info_base, const QString& purpose, const QString& tip = {});
32
40 Entry(gii::TypeId type_id, gii::IdType* id, const QString& purpose, const QString& tip = {});
41
46
50 QString getIdString() const;
51
57
62 void setIdString(const QString& id);
63
69 QString getName(int level) const;
70
71 private:
73 gii::TypeId _typeId;
75 InformationBase* _infoBase;
77 gii::IdType* _id = 0;
79 QString _purpose;
81 QString _tip;
82
84 };
85
89 typedef QList<Entry*> ListType;
90
94 explicit InformationListIdModel(QObject* parent = nullptr);
95
100
104 int nameLevel() const;
105
109 void setNameLevel(int level);
110
114 enum EField : int
115 {
123 cNamePath
124 };
125
129 void setItemDelegate(QAbstractItemView* view);
130
134 void refresh();
135
141 EField getField(int column) const;
142
148 int getColumn(EField field) const;
149
156 void update(int row = -1, int column = -1, const QList<int>& roles = {});
157
164 void updateField(int row, EField field, const QList<int>& roles = {});
165
169 [[nodiscard]] QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
170
174 [[nodiscard]] int rowCount(const QModelIndex& parent = QModelIndex()) const override;
175
179 [[nodiscard]] QVariant data(const QModelIndex& index, int role) const override;
180
184 [[nodiscard]] int columnCount(const QModelIndex& parent = {}) const override;
185
189 [[nodiscard]] Qt::ItemFlags flags(const QModelIndex& index) const override;
190
197 void addEntry(InformationBase* info_base, const QString& purpose, const QString& tip = {});
198
206 void addEntry(gii::TypeId type_id, gii::IdType* id, const QString& purpose, const QString& tip);
207
212
216 const ListType& getList() const;
217
221 bool setData(const QModelIndex& index, const QVariant& value, int role) override;
222
227 Q_SIGNAL void changed(const Entry* entry);
228
229 private:
231 ListType _list;
233 int _nameLevel;
235 QList<EField> _columns;
237 QIcon _iconVariable;
239 QIcon _iconResuleData;
240};
241
242}// namespace sf
Base class for all generic information objects to be able to put them in a typed list together.
Definition InformationBase.h:13
Definition InformationListIdModel.h:23
Entry(gii::TypeId type_id, gii::IdType *id, const QString &purpose, const QString &tip={})
Initializing constructor.
void setIdString(const QString &id)
Sets the information id.
gii::IdType getId() const
Gets the current desired id of the information object.
QString getIdString() const
Gets the current desired id of the information object as a hexadecimal string.
Entry(InformationBase *info_base, const QString &purpose, const QString &tip={})
Initializing constructor.
QString getName(int level) const
Gets the name path of the information object.
void setId(gii::IdType id)
Sets the information id.
List model for a sf::InformationBase list.
Definition InformationListIdModel.h:17
void refresh()
Refresh the attached viewer.
void setItemDelegate(QAbstractItemView *view)
Creates a sf::CommonItemDelegate instance for the passed view.
void update(int row=-1, int column=-1, const QList< int > &roles={})
Update values in the given column and row.
int columnCount(const QModelIndex &parent={}) const override
Overridden from base class to provide the amount of columns.
void clearEntries()
Clear the variables added.
void addEntry(InformationBase *info_base, const QString &purpose, const QString &tip={})
Adds an entry to the list with pointer to the instance actually changed.
EField
Displayable columns.
Definition InformationListIdModel.h:115
@ cId
Desired id of the information item.
Definition InformationListIdModel.h:117
@ cType
Type of the information item.
Definition InformationListIdModel.h:119
@ cPurpose
Purpose of the item for the user to base the selection on.
Definition InformationListIdModel.h:121
QList< Entry * > ListType
Type for containing the information for this model.
Definition InformationListIdModel.h:89
int getColumn(EField field) const
Gets the column position or number where the field is displayed.
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
Overridden from base class to provide column display names.
void addEntry(gii::TypeId type_id, gii::IdType *id, const QString &purpose, const QString &tip)
Adds an entry to the list only by id and type.
EField getField(int column) const
Gets the field displayed in the column.
int nameLevel() const
Gets the levels of names displayed of the variables in the list.
Q_SIGNAL void changed(const Entry *entry)
Signals a change of the Variable's property.
const ListType & getList() const
Gets the entry list of the model.
~InformationListIdModel() override
Constructor.
void setNameLevel(int level)
Sets the levels of names displayed of the variables in the list.
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Overridden from base class to provide the amount of rows.
bool setData(const QModelIndex &index, const QVariant &value, int role) override
Overridden from base class to provide assignment of an item when edited.
InformationListIdModel(QObject *parent=nullptr)
Constructor.
Qt::ItemFlags flags(const QModelIndex &index) const override
Overridden from base class to provide flags on an item by index.
QVariant data(const QModelIndex &index, int role) const override
Overridden from base class to provide the data to present.
void updateField(int row, EField field, const QList< int > &roles={})
Update the column for the given field for all rows.
Base class for all generic information objects to be able to put them in a typed list together.
Definition InformationBase.h:25
#define _GII_CLASS
Definition gii/global.h:38
TypeId
Types of id's.
Definition gii/qt/Namespace.h:22
InformationTypes::id_type IdType
Short type definition for Qt code.
Definition gii/qt/Namespace.h:16
Definition Application.h:10