From bc4eec1047012b8f63c8d10a0c39520407470693 Mon Sep 17 00:00:00 2001 From: "Luis Gustavo S. Barreto" Date: Mon, 18 Nov 2013 14:37:15 -0200 Subject: [PATCH] HttpHandlerFileTransfer: Added progress signal --- pillowcore/HttpHandler.cpp | 8 ++++++++ pillowcore/HttpHandler.h | 1 + 2 files changed, 9 insertions(+) diff --git a/pillowcore/HttpHandler.cpp b/pillowcore/HttpHandler.cpp index 8eae4ff..b93d700 100644 --- a/pillowcore/HttpHandler.cpp +++ b/pillowcore/HttpHandler.cpp @@ -371,7 +371,15 @@ void HttpHandlerFileTransfer::writeNextPayload() { _connection->writeContent(_sourceDevice->read(bytesToRead)); + if (bytesAvailable != _sourceDevice->size()) // this avoids division by zero + emit progress((int)(100 - (100 * (bytesAvailable / (qreal)_sourceDevice->size())))); + else + emit progress(0); + if (_sourceDevice->atEnd()) + { + emit progress(100); emit finished(); + } } } diff --git a/pillowcore/HttpHandler.h b/pillowcore/HttpHandler.h index 5f26961..cf315a3 100644 --- a/pillowcore/HttpHandler.h +++ b/pillowcore/HttpHandler.h @@ -213,6 +213,7 @@ namespace Pillow signals: void finished(); + int progress(int progress); }; } #endif // PILLOW_HTTPHANDLER_H