-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathfileio.h
44 lines (33 loc) · 938 Bytes
/
fileio.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
#pragma once
#include <QObject>
#include <QtQml>
class FileIO : public QObject
{
Q_OBJECT
QML_ELEMENT
Q_PROPERTY(QUrl filePath READ filePath WRITE setFilePath NOTIFY filePathChanged)
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
Q_PROPERTY(QString errorString READ errorString NOTIFY errorStringChanged)
Q_PROPERTY(bool error READ hasError NOTIFY errorChanged)
public:
explicit FileIO(QObject *parent = nullptr);
public slots:
bool read();
bool write();
QUrl filePath() const;
void setFilePath(const QUrl &filePath);
QString text() const;
void setText(const QString &text);
QString errorString() const;
bool hasError() const;
signals:
void filePathChanged();
void textChanged();
void errorStringChanged();
void errorChanged();
private:
QUrl m_filePath;
QString m_text;
QString m_errorString;
bool m_error;
};