class FileProviderDomainSyncStatus : public QObject
{
Q_OBJECT
+ Q_PROPERTY(bool syncing READ syncing NOTIFY syncingChanged)
+ Q_PROPERTY(bool downloading READ downloading NOTIFY downloadingChanged)
+ Q_PROPERTY(bool uploading READ uploading NOTIFY uploadingChanged)
+ Q_PROPERTY(double fractionCompleted READ fractionCompleted NOTIFY fractionCompletedChanged)
+ Q_PROPERTY(double downloadFractionCompleted READ downloadFractionCompleted NOTIFY downloadFractionCompletedChanged)
+ Q_PROPERTY(double uploadFractionCompleted READ uploadFractionCompleted NOTIFY uploadFractionCompletedChanged)
+ Q_PROPERTY(int downloadFileTotalCount READ downloadFileTotalCount NOTIFY downloadFileTotalCountChanged)
+ Q_PROPERTY(int downloadFileCompletedCount READ downloadFileCompletedCount NOTIFY downloadFileCompletedCountChanged)
+ Q_PROPERTY(int uploadFileTotalCount READ uploadFileTotalCount NOTIFY uploadFileTotalCountChanged)
+ Q_PROPERTY(int uploadFileCompletedCount READ uploadFileCompletedCount NOTIFY uploadFileCompletedCountChanged)
+ // TODO: more detailed reporting (time remaining, megabytes, etc.)
public:
explicit FileProviderDomainSyncStatus(const QString &domainIdentifier, QObject *parent = nullptr);
+ bool syncing() const;
+ bool downloading() const;
+ bool uploading() const;
+ double fractionCompleted() const;
+ double downloadFractionCompleted() const;
+ double uploadFractionCompleted() const;
+ int downloadFileTotalCount() const;
+ int downloadFileCompletedCount() const;
+ int uploadFileTotalCount() const;
+ int uploadFileCompletedCount() const;
+
+signals:
+ void syncingChanged(bool syncing);
+ void downloadingChanged(bool downloading);
+ void uploadingChanged(bool uploading);
+ void fractionCompletedChanged(double fractionCompleted);
+ void downloadFractionCompletedChanged(double downloadFractionCompleted);
+ void uploadFractionCompletedChanged(double uploadFractionCompleted);
+ void downloadFileTotalCountChanged(int downloadFileTotalCount);
+ void downloadFileCompletedCountChanged(int downloadFileCompletedCount);
+ void uploadFileTotalCountChanged(int uploadFileTotalCount);
+ void uploadFileCompletedCountChanged(int uploadFileCompletedCount);
+
private:
+ void setDownloading(const bool syncing);
+ void setUploading(const bool syncing);
+ void setDownloadFractionCompleted(const double fractionCompleted);
+ void setUploadFractionCompleted(const double fractionCompleted);
+ void setDownloadFileTotalCount(const int fileTotalCount);
+ void setDownloadFileCompletedCount(const int fileCompletedCount);
+ void setUploadFileTotalCount(const int fileTotalCount);
+ void setUploadFileCompletedCount(const int fileCompletedCount);
+
+ bool _downloading = false;
+ bool _uploading = false;
+ double _downloadFractionCompleted = 0.0;
+ double _uploadFractionCompleted = 0.0;
+ int _downloadFileTotalCount = 0;
+ int _downloadFileCompletedCount = 0;
+ int _uploadFileTotalCount = 0;
+ int _uploadFileCompletedCount = 0;
+
class MacImplementation;
std::unique_ptr<MacImplementation> d;
};
{
}
+FileProviderDomainSyncStatus::~FileProviderDomainSyncStatus() = default;
+
+bool FileProviderDomainSyncStatus::syncing() const
+{
+ return downloading() || uploading();
+}
+
+bool FileProviderDomainSyncStatus::downloading() const
+{
+ return _downloading;
+}
+
+bool FileProviderDomainSyncStatus::uploading() const
+{
+ return _uploading;
+}
+
+double FileProviderDomainSyncStatus::fractionCompleted() const
+{
+ return (downloadFractionCompleted() + uploadFractionCompleted()) / 2;
+}
+
+double FileProviderDomainSyncStatus::downloadFractionCompleted() const
+{
+ return _downloadFractionCompleted;
+}
+
+double FileProviderDomainSyncStatus::uploadFractionCompleted() const
+{
+ return _uploadFractionCompleted;
+}
+
+int FileProviderDomainSyncStatus::downloadFileTotalCount() const
+{
+ return _downloadFileTotalCount;
+}
+
+int FileProviderDomainSyncStatus::downloadFileCompletedCount() const
+{
+ return _downloadFileCompletedCount;
+}
+
+int FileProviderDomainSyncStatus::uploadFileTotalCount() const
+{
+ return _uploadFileTotalCount;
+}
+
+int FileProviderDomainSyncStatus::uploadFileCompletedCount() const
+{
+ return _uploadFileCompletedCount;
+}
+
+void FileProviderDomainSyncStatus::setDownloading(const bool downloading)
+{
+ if (_downloading == downloading) {
+ return;
+ }
+
+ _downloading = downloading;
+ emit downloadingChanged(_downloading);
+ emit syncingChanged(syncing());
+}
+
+void FileProviderDomainSyncStatus::setUploading(const bool uploading)
+{
+ if (_uploading == uploading) {
+ return;
+ }
+
+ _uploading = uploading;
+ emit uploadingChanged(_uploading);
+ emit syncingChanged(syncing());
+}
+
+void FileProviderDomainSyncStatus::setDownloadFractionCompleted(const double fractionCompleted)
+{
+ if (_downloadFractionCompleted == fractionCompleted) {
+ return;
+ }
+
+ _downloadFractionCompleted = fractionCompleted;
+ emit downloadFractionCompletedChanged(_downloadFractionCompleted);
+ emit fractionCompletedChanged(fractionCompleted());
+}
+
+void FileProviderDomainSyncStatus::setUploadFractionCompleted(const double fractionCompleted)
+{
+ if (_uploadFractionCompleted == fractionCompleted) {
+ return;
+ }
+
+ _uploadFractionCompleted = fractionCompleted;
+ emit uploadFractionCompletedChanged(_uploadFractionCompleted);
+ emit fractionCompletedChanged(fractionCompleted());
+}
+
+void FileProviderDomainSyncStatus::setDownloadFileTotalCount(const int fileTotalCount)
+{
+ if (_downloadFileTotalCount == fileTotalCount) {
+ return;
+ }
+
+ _downloadFileTotalCount = fileTotalCount;
+ emit downloadFileTotalCountChanged(_downloadFileTotalCount);
+}
+
+void FileProviderDomainSyncStatus::setDownloadFileCompletedCount(const int fileCompletedCount)
+{
+ if (_downloadFileCompletedCount == fileCompletedCount) {
+ return;
+ }
+
+ _downloadFileCompletedCount = fileCompletedCount;
+ emit downloadFileCompletedCountChanged(_downloadFileCompletedCount);
+}
+
+void FileProviderDomainSyncStatus::setUploadFileTotalCount(const int fileTotalCount)
+{
+ if (_uploadFileTotalCount == fileTotalCount) {
+ return;
+ }
+
+ _uploadFileTotalCount = fileTotalCount;
+ emit uploadFileTotalCountChanged(_uploadFileTotalCount);
+}
+
+void FileProviderDomainSyncStatus::setUploadFileCompletedCount(const int fileCompletedCount)
+{
+ if (_uploadFileCompletedCount == fileCompletedCount) {
+ return;
+ }
+
+ _uploadFileCompletedCount = fileCompletedCount;
+ emit uploadFileCompletedCountChanged(_uploadFileCompletedCount);
+}
+
} // OCC::Mac