ENLIGHTEN
Cross-platform desktop GUI for Wasatch Photonics spectrometers
Loading...
Searching...
No Matches
nodelistmodel.h
Go to the documentation of this file.
1
26
27#ifndef NODELISTMODEL_H
28#define NODELISTMODEL_H
29
31#include "nodelistobject.h"
32
33#include <peak/node_map/peak_node_map.hpp>
34
35#include <QAbstractListModel>
36#include <QDebug>
37#include <QMutex>
38#include <QStringList>
39#include <QThread>
40
41#include <vector>
42
43class NodeListModel : public QAbstractListModel
44{
45 Q_OBJECT
46public:
68
70 ~NodeListModel() override = default;
71 void setNodeMap(const std::shared_ptr<peak::core::NodeMap>& nodeMap);
72 int rowCount(const QModelIndex& index = QModelIndex()) const override;
73 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
74 Q_INVOKABLE NodeListObject* get(const QString& name);
75 Q_INVOKABLE NodeListObject* get(int index);
76 void pauseUpdating();
77 void resumeUpdating();
78 void stopUpdating();
79 QThread* updateThread();
80
81public slots:
82 void updateList(int a, int b, QVector<int> changedRoles = QVector<int>());
83
84protected:
85 QHash<int, QByteArray> roleNames() const override;
86
87private:
88 std::vector<std::shared_ptr<NodeListObject>> m_objects;
89 std::shared_ptr<peak::core::NodeMap> m_nodeMap;
90 QStringList m_nodeNames;
91
93 QThread* m_updateThread = nullptr;
95 void clear();
96
97 mutable QMutex mutex;
98};
99
100#endif // NODELISTMODEL_H
Definition modelupdatethreadworker.h:44
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Definition nodelistmodel.cpp:99
std::vector< std::shared_ptr< NodeListObject > > m_objects
Definition nodelistmodel.h:88
ModelUpdateThreadWorker * m_updateThreadWorker
Definition nodelistmodel.h:92
QMutex mutex
Definition nodelistmodel.h:97
int m_objectCount
Definition nodelistmodel.h:94
QStringList m_nodeNames
Definition nodelistmodel.h:90
QThread * updateThread()
Definition nodelistmodel.cpp:197
QThread * m_updateThread
Definition nodelistmodel.h:93
~NodeListModel() override=default
void stopUpdating()
Definition nodelistmodel.cpp:202
void setNodeMap(const std::shared_ptr< peak::core::NodeMap > &nodeMap)
Definition nodelistmodel.cpp:51
int rowCount(const QModelIndex &index=QModelIndex()) const override
Definition nodelistmodel.cpp:94
NodeListModel()
Definition nodelistmodel.cpp:32
std::shared_ptr< peak::core::NodeMap > m_nodeMap
Definition nodelistmodel.h:89
void clear()
Definition nodelistmodel.cpp:44
void updateList(int a, int b, QVector< int > changedRoles=QVector< int >())
Definition nodelistmodel.cpp:210
Q_INVOKABLE NodeListObject * get(const QString &name)
Definition nodelistmodel.cpp:151
void pauseUpdating()
Definition nodelistmodel.cpp:187
void resumeUpdating()
Definition nodelistmodel.cpp:192
QHash< int, QByteArray > roleNames() const override
Definition nodelistmodel.cpp:318
Roles
Definition nodelistmodel.h:48
@ IncRole
Definition nodelistmodel.h:60
@ DisplayNameRole
Definition nodelistmodel.h:50
@ NodeObjectRole
Definition nodelistmodel.h:66
@ AccessStatusRole
Definition nodelistmodel.h:65
@ EntryListModelRole
Definition nodelistmodel.h:56
@ VisibilityRole
Definition nodelistmodel.h:55
@ TypeRole
Definition nodelistmodel.h:52
@ ValueRole
Definition nodelistmodel.h:57
@ WriteableRole
Definition nodelistmodel.h:64
@ UnitRole
Definition nodelistmodel.h:61
@ CategoryRole
Definition nodelistmodel.h:51
@ ReadableRole
Definition nodelistmodel.h:63
@ MinRole
Definition nodelistmodel.h:58
@ MaxRole
Definition nodelistmodel.h:59
@ AvailableRole
Definition nodelistmodel.h:62
@ TooltipRole
Definition nodelistmodel.h:53
@ DescriptionRole
Definition nodelistmodel.h:54
@ NameRole
Definition nodelistmodel.h:49
Definition nodelistobject.h:39
The ModelUpdateThreadWorker class is used in a worker thread to receive callbacks and check for chang...
The NodeListObject is a prototype for camera property nodes of the types 'Enumeration',...