-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocument.h
45 lines (36 loc) · 1.13 KB
/
document.h
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
#pragma once
#include "measurements.h"
#include <QImage>
#include <QObject>
#include <QUndoStack>
#include <QUrl>
#include <memory>
class Document : public QObject {
Q_OBJECT
Q_PROPERTY(
Measurements *measurements READ measurements NOTIFY measurementsChanged)
Q_PROPERTY(QUrl mapImageUrl WRITE setMapImageUrl NOTIFY mapImageChanged)
Q_PROPERTY(bool needsSaving READ needsSaving NOTIFY needsSavingChanged)
public:
Document(QUndoStack *undoStack, QObject *parent = nullptr);
Q_INVOKABLE void newDocument();
Q_INVOKABLE bool save(QUrl fileUrl);
Q_INVOKABLE void load(QUrl fileUrl);
Measurements *measurements() const;
QImage mapImage() const;
void setMapImageUrl(const QUrl &mapImageUrl);
bool needsSaving() const;
signals:
void mapImageChanged();
void measurementsChanged(Measurements *measurements);
void needsSavingChanged(bool value);
private:
void setMapImage(const QImage &mapImage);
void setMeasurements();
void setNeedsSaving(bool value);
std::unique_ptr<Measurements> mMeasurements{nullptr};
QUndoStack *mUndoStack;
QImage mMapImage;
bool mNeedsSaving{false};
void read(QByteArray data);
};