Repository navigation
Expand file tree
/
Copy pathSpectrometerBridge.hpp
More file actions
131 lines (87 loc) · 3.13 KB
/
Copy pathSpectrometerBridge.hpp
File metadata and controls
131 lines (87 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// SPDX-FileCopyrightText: 2026 Błażej Szczygieł <mumei6102@gmail.com>
// SPDX-License-Identifier: BSD-3-Clause
#pragma once
#include "Headers.hpp"
#include "Exposure.hpp"
#include "SpdData.hpp"
class SpectrometerWorker;
class SpectrometerBridge : public QAbstractListModel
{
Q_OBJECT
QML_ELEMENT
QML_SINGLETON
Q_PROPERTY(bool isP3 MEMBER m_isP3 NOTIFY isP3Changed FINAL)
public:
enum class Group : uint32_t
{
None = 0,
Base = 1,
PPFD = 2,
BlueLight = 4,
};
Q_DECLARE_FLAGS(Groups, Group)
Q_FLAG(Groups)
struct ModelEntry
{
QString id;
QString key;
QString value;
Groups groups = Group::None;
qsizetype likedPos = -1;
};
using EntryList = vector<ModelEntry>;
public:
SpectrometerBridge();
~SpectrometerBridge();
Q_INVOKABLE void getWindowColorProfile(QQuickWindow *win);
Q_INVOKABLE void storeSplitView(const QByteArray &data);
Q_INVOKABLE QByteArray restoreSplitView();
Q_INVOKABLE void create(const QUrl &url);
Q_INVOKABLE void createDevice(bool openErr);
Q_INVOKABLE void setDeviceParams(double minNm, double maxNm, const QString &device);
Q_INVOKABLE QVariantMap getDeviceParams();
Q_INVOKABLE void requestQuit();
Q_INVOKABLE QStringList getDevices();
Q_INVOKABLE void start(bool single);
Q_INVOKABLE void stop();
Q_INVOKABLE void setExposure(bool autoExposure, qreal exposureTime);
Q_INVOKABLE int getIdRole() const;
Q_INVOKABLE int getLikedPosRole() const;
Q_INVOKABLE void setLiked(const QString &id, qsizetype likedPos);
Q_INVOKABLE bool storeData(const QUrl &url);
Q_INVOKABLE void setDataInternalCache(bool cache);
Q_INVOKABLE bool canStoreDataInternal(const QString &name);
Q_INVOKABLE bool storeDataInternal(const QString &name);
Q_INVOKABLE bool renameDataInternal(const QString &oldName, const QString &newName);
Q_INVOKABLE QVariantList getStoredMeasurements() const;
Q_INVOKABLE bool deleteStoredMeasurement(const QString &name);
Q_INVOKABLE void copyToClipboard(const QString &id);
public:
int rowCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
QHash<int, QByteArray> roleNames() const;
private:
void onNewExposureData(const Exposure &exposure);
void onNewSpdData(const shared_ptr<SpdData> &spdData);
void emitExposureChanged();
private:
static QString sMeasurementFileName(const QString &name);
Q_SIGNALS:
void quit();
void commandsStarted();
void commandsFinished();
void errorMessage(const QString &errStr);
void exposureChanged(double exposureTime, bool ae, bool aeInProgress, double min, double max);
void staticDataNameChanged(const QString &name);
void isP3Changed();
private:
SpectrometerWorker *m_worker = nullptr;
Exposure m_exposure;
QHash<QString, qsizetype> m_likedSettings;
shared_ptr<SpdData> m_spdData;
EntryList m_entryListTmp;
EntryList m_entryList;
QStringList m_dataInternalCache;
bool m_isP3 = false;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(SpectrometerBridge::Groups)