Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
InformationItemModel.h
Go to the documentation of this file.
1#pragma once
2#include <QAbstractItemModel>
3#include <QIcon>
5#include <gii/global.h>
6#include <gii/qt/Namespace.h>
7
8namespace sf
9{
10
14class _GII_CLASS InformationItemModel : public QAbstractItemModel
15{
16 public:
20 explicit InformationItemModel(gii::SelectionMode mode, gii::TypeId idType, QObject* parent);
21
26
31
35 QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
36
40 int columnCount(const QModelIndex& parent) const override;
41
45 int rowCount(const QModelIndex& parent) const override;
46
50 QVariant data(const QModelIndex& index, int role) const override;
51
55 Qt::ItemFlags flags(const QModelIndex& index) const override;
56
60 QModelIndex index(int row, int column, const QModelIndex& parent) const override;
61
65 [[nodiscard]] QModelIndex parent(const QModelIndex& child) const override;
66
70 void toggleSelection(const QModelIndex& index);
71
75 bool isFolder(const QModelIndex& index);
79 gii::IdType getId(const QModelIndex& index);
80
85
89 void updateList();
90
91 private:
95 struct TreeItem
96 {
97
98 explicit TreeItem(TreeItem* parent, QString name);
99
100 ~TreeItem();
101
105 enum DataType
106 {
107 dtVariable,
108 dtResultData,
109 dtFolder
110 } _type{dtFolder};
111
115 bool _selected{false};
119 gii::IdType _id{0};
123 QString _name;
127 TreeItem* _parentItem{nullptr};
131 QList<TreeItem*> _childItems;
135 [[nodiscard]] QStringList getNamePath() const;
136 };
137
141 TreeItem* createPath(const QStringList& namePath);
145 gii::SelectionMode _mode;
149 gii::TypeId _idType;
153 TreeItem* _rootItem;
154
155 QList<TreeItem*> _selected;
156
157 QIcon _icons[3];
158};
159
160}// namespace sf
Item model for viewing Variables in a tree view.
Definition InformationItemModel.h:15
bool isFolder(const QModelIndex &index)
Gets the status of a folder type entry of the passed index.
int rowCount(const QModelIndex &parent) const override
Overridden from base class to provide the amount of rows.
void updateList()
Updates the list data.
InformationTypes::IdVector getSelectedIds() const
Toggle the selection of the item at the passed index.
QModelIndex index(int row, int column, const QModelIndex &parent) const override
Overridden from base class.
~InformationItemModel() override
Overridden destructor.
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
Overridden from base class to provide column display names.
gii::IdType getId(const QModelIndex &index)
Gets the information ID from the passed index.
InformationItemModel(gii::SelectionMode mode, gii::TypeId idType, QObject *parent)
Constructor.
void toggleSelection(const QModelIndex &index)
Toggle the selection of the item at the passed index.
Qt::ItemFlags flags(const QModelIndex &index) const override
Overridden from base class to provide flags on an item by index.
QModelIndex parent(const QModelIndex &child) const override
Overridden from base class.
gii::IdType getIdType() const
Gets the type of id's this instance was created for.
QVariant data(const QModelIndex &index, int role) const override
Overridden from base class to provide the data to present.
int columnCount(const QModelIndex &parent) const override
Overridden from base class to provide the amount of columns.
#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
SelectionMode
Mode of item selection.
Definition gii/qt/Namespace.h:35
Definition Application.h:10