ImagingTools Core SDK
CRemoteFileController.h
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ImtCore-Commercial
2#pragma once
3
4
5// Qt includes
6#include <QtCore/QObject>
7
8#undef DeleteFile
9
10
11namespace imtqml
12{
13
14
15class CRemoteFileController: public QObject
16{
17 Q_OBJECT
18 Q_PROPERTY(QString state READ state WRITE SetState NOTIFY stateChanged)
19 Q_PROPERTY(QString downloadedFileLocation READ downloadedFileLocation WRITE setDownloadedFileLocation NOTIFY downloadedFileLocationChanged)
20 Q_PROPERTY(QString downloadedFilePath READ downloadedFilePath WRITE setDownloadedFilePath NOTIFY downloadedFilePathChanged)
21 Q_PROPERTY(QByteArray json READ json WRITE setJson NOTIFY jsonChanged)
22 Q_PROPERTY(QString prefix READ prefix WRITE setPrefix NOTIFY prefixChanged)
23
24 QString m_state;
25 QString m_downloadedFilePath;
26
27public:
28 Q_INVOKABLE inline bool deleteFile(const QString& fileId){ return DeleteFile(fileId); }
29 Q_INVOKABLE inline bool getFile(const QString& fileId, const QString& fileName){ return GetFile(fileId, fileName); }
30 Q_INVOKABLE inline bool sendFile(const QString& fileId){ return SendFile(fileId); }
31 Q_INVOKABLE inline bool openFile(const QString& filePath = QString()){ return OpenFile(filePath); }
32
33 explicit CRemoteFileController(QObject* parent = nullptr);
34 ~CRemoteFileController();
35
36 const QString& state() const;
37 void SetState(const QString& newState);
38 const QString& downloadedFilePath() const;
39 void setDownloadedFilePath(const QString& newDownloadedFilePath);
40 const QString& downloadedFileLocation() const;
41 void setDownloadedFileLocation(const QString& newDownloadedFileLocation);
42 const QByteArray& json() const;
43 void setJson(const QByteArray& newJson);
44 const QString& prefix() const;
45 void setPrefix(const QString& newPrefix);
46
47public Q_SLOTS:
48 virtual bool DeleteFile(const QString& fileId);
49 virtual bool GetFile(const QString& fileId, const QString& fileName);
50 virtual bool SendFile(const QString& fileUrl);
51 virtual bool OpenFile(const QString& filePath = QString()) const;
52
53private Q_SLOTS:
54 void OnFileExists();
55 void OnFileDeleted();
56 void OnFileDownloaded();
57 void OnFileUploaded();
58 void OnProgressChanged(qint64 bytesLoaded, qint64 bytesTotal);
59
60signals:
61 void stateChanged();
62 void downloadedFilePathChanged();
63 void downloadedFileLocationChanged();
64 void jsonChanged();
65 void fileDownloaded(const QString& filePath);
66 void progress(qint64 bytesLoaded, qint64 bytesTotal);
67 void fileUploaded();
68 void fileDeleted();
69 void fileUploadFailed();
70 void fileDeleteFailed();
71 void fileDownloadFailed();
72 void fileExists();
73
74 void prefixChanged();
75
76private:
93private:
94 QString m_preferredFileNameForSave;
95 QString m_downloadedFileLocation;
96 QByteArray m_json;
97 qint64 m_bytesLoaded;
98 qint64 m_bytesTotal;
99 bool m_isAutoOpen;
100 QString m_prefix;
101};
102
103
104} // namespace imtqml
105
106
107Q_DECLARE_METATYPE(imtqml::CRemoteFileController*)
108
109