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
30 [[nodiscard]] QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
31
35 [[nodiscard]] int columnCount(const QModelIndex& parent) const override;
36
40 [[nodiscard]] int rowCount(const QModelIndex& parent) const override;
41
45 [[nodiscard]] QVariant data(const QModelIndex& index, int role) const override;
46
50 [[nodiscard]] Qt::ItemFlags flags(const QModelIndex& index) const override;
51
55 [[nodiscard]] QModelIndex index(int row, int column, const QModelIndex& parent) const override;
56
60 [[nodiscard]] QModelIndex parent(const QModelIndex& child) const override;
61
65 void toggleSelection(const QModelIndex& index);
66
70 bool isFolder(const QModelIndex& index);
74 gii::IdType getId(const QModelIndex& index);
75
80
84 void updateList();
85
86 private:
90 struct TreeItem
91 {
92
93 explicit TreeItem(TreeItem* parent, QString name);
94
95 ~TreeItem();
96
100 enum DataType
101 {
102 dtVariable,
103 dtResultData,
104 dtFolder
105 } _type{dtFolder};
106
110 bool _selected{false};
114 gii::IdType _id{0};
118 QString _name;
122 TreeItem* _parentItem{nullptr};
126 QList<TreeItem*> _childItems;
130 [[nodiscard]] QStringList getNamePath() const;
131 };
132
136 TreeItem* createPath(const QStringList& namePath);
140 gii::SelectionMode _mode;
144 gii::TypeId _idType;
148 TreeItem* _rootItem;
149
150 QList<TreeItem*> _selected;
151
152 QIcon _icons[3];
153};
154
155}// 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.
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.
Counted vector having additional methods and operators for ease of usage.
Definition TVector.h:25
#define _GII_CLASS
Definition gii/global.h:38
InformationTypes::id_type IdType
Short type definition for Qt code.
Definition Namespace.h:16
SelectionMode
Mode of item selection.
Definition Namespace.h:34
TypeId
Types of id's.
Definition Namespace.h:22
Definition Application.h:10