diff options
Diffstat (limited to 'Swift/Controllers/FileTransfer')
| -rw-r--r-- | Swift/Controllers/FileTransfer/FileTransferProgressInfo.cpp | 8 | ||||
| -rw-r--r-- | Swift/Controllers/FileTransfer/FileTransferProgressInfo.h | 13 |
2 files changed, 11 insertions, 10 deletions
diff --git a/Swift/Controllers/FileTransfer/FileTransferProgressInfo.cpp b/Swift/Controllers/FileTransfer/FileTransferProgressInfo.cpp index b073017..eddace9 100644 --- a/Swift/Controllers/FileTransfer/FileTransferProgressInfo.cpp +++ b/Swift/Controllers/FileTransfer/FileTransferProgressInfo.cpp | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | /* | 7 | /* |
| 8 | * Copyright (c) 2016 Isode Limited. | 8 | * Copyright (c) 2016-2018 Isode Limited. |
| 9 | * All rights reserved. | 9 | * All rights reserved. |
| 10 | * See the COPYING file for more information. | 10 | * See the COPYING file for more information. |
| 11 | */ | 11 | */ |
| @@ -18,13 +18,13 @@ | |||
| 18 | 18 | ||
| 19 | namespace Swift { | 19 | namespace Swift { |
| 20 | 20 | ||
| 21 | FileTransferProgressInfo::FileTransferProgressInfo(boost::uintmax_t completeBytes) : completeBytes(completeBytes), completedBytes(0), percentage(0) { | 21 | FileTransferProgressInfo::FileTransferProgressInfo(size_t completeBytes) : completeBytes(completeBytes), completedBytes(0), percentage(0) { |
| 22 | onProgressPercentage(0); | 22 | onProgressPercentage(0); |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | void FileTransferProgressInfo::setBytesProcessed(int processedBytes) { | 25 | void FileTransferProgressInfo::setBytesProcessed(size_t processedBytes) { |
| 26 | int oldPercentage = int(double(completedBytes) / double(completeBytes) * 100.0); | 26 | int oldPercentage = int(double(completedBytes) / double(completeBytes) * 100.0); |
| 27 | completedBytes += boost::numeric_cast<boost::uintmax_t>(processedBytes); | 27 | completedBytes += processedBytes; |
| 28 | int newPercentage = int(double(completedBytes) / double(completeBytes) * 100.0); | 28 | int newPercentage = int(double(completedBytes) / double(completeBytes) * 100.0); |
| 29 | if (oldPercentage != newPercentage) { | 29 | if (oldPercentage != newPercentage) { |
| 30 | onProgressPercentage(newPercentage); | 30 | onProgressPercentage(newPercentage); |
diff --git a/Swift/Controllers/FileTransfer/FileTransferProgressInfo.h b/Swift/Controllers/FileTransfer/FileTransferProgressInfo.h index 5fb955c..869ceba 100644 --- a/Swift/Controllers/FileTransfer/FileTransferProgressInfo.h +++ b/Swift/Controllers/FileTransfer/FileTransferProgressInfo.h | |||
| @@ -5,31 +5,32 @@ | |||
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | /* | 7 | /* |
| 8 | * Copyright (c) 2016 Isode Limited. | 8 | * Copyright (c) 2016-2018 Isode Limited. |
| 9 | * All rights reserved. | 9 | * All rights reserved. |
| 10 | * See the COPYING file for more information. | 10 | * See the COPYING file for more information. |
| 11 | */ | 11 | */ |
| 12 | 12 | ||
| 13 | #pragma once | 13 | #pragma once |
| 14 | 14 | ||
| 15 | #include <boost/cstdint.hpp> | 15 | #include <cstddef> |
| 16 | |||
| 16 | #include <boost/signals2.hpp> | 17 | #include <boost/signals2.hpp> |
| 17 | 18 | ||
| 18 | namespace Swift { | 19 | namespace Swift { |
| 19 | 20 | ||
| 20 | class FileTransferProgressInfo { | 21 | class FileTransferProgressInfo { |
| 21 | public: | 22 | public: |
| 22 | FileTransferProgressInfo(boost::uintmax_t completeBytes); | 23 | FileTransferProgressInfo(size_t completeBytes); |
| 23 | 24 | ||
| 24 | public: | 25 | public: |
| 25 | void setBytesProcessed(int processedBytes); | 26 | void setBytesProcessed(size_t processedBytes); |
| 26 | 27 | ||
| 27 | int getPercentage() const; | 28 | int getPercentage() const; |
| 28 | boost::signals2::signal<void (int)> onProgressPercentage; | 29 | boost::signals2::signal<void (int)> onProgressPercentage; |
| 29 | 30 | ||
| 30 | private: | 31 | private: |
| 31 | boost::uintmax_t completeBytes; | 32 | size_t completeBytes; |
| 32 | boost::uintmax_t completedBytes; | 33 | size_t completedBytes; |
| 33 | int percentage; | 34 | int percentage; |
| 34 | }; | 35 | }; |
| 35 | 36 | ||
Swift