aboutsummaryrefslogtreecommitdiff
path: root/lib/room.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-12-28 12:53:01 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2019-01-05 21:01:28 +0900
commite017dd42637071687f88f5a36e7e03f1536332be (patch)
tree88de440b83243b49181fa0a4a1cb3d74f2c98ad3 /lib/room.cpp
parent3b88c2b537b6cb98dcd0f2066d39e426b5cc52da (diff)
downloadlibquotient-e017dd42637071687f88f5a36e7e03f1536332be.tar.gz
libquotient-e017dd42637071687f88f5a36e7e03f1536332be.zip
FileTransferInfo: new properties: isUpload and started
Also: use constructors instead of list-based initialisation in FileTransferPrivateInfo to enable a case of "invalid/empty" FileTransferPrivateInfo with status == None.
Diffstat (limited to 'lib/room.cpp')
-rw-r--r--lib/room.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/room.cpp b/lib/room.cpp
index 156b5b1f..d613fd77 100644
--- a/lib/room.cpp
+++ b/lib/room.cpp
@@ -126,15 +126,17 @@ class Room::Private
struct FileTransferPrivateInfo
{
-#ifdef WORKAROUND_EXTENDED_INITIALIZER_LIST
FileTransferPrivateInfo() = default;
- FileTransferPrivateInfo(BaseJob* j, QString fileName)
- : job(j), localFileInfo(fileName)
+ FileTransferPrivateInfo(BaseJob* j, const QString& fileName,
+ bool isUploading = false)
+ : status(FileTransferInfo::Started), job(j)
+ , localFileInfo(fileName), isUpload(isUploading)
{ }
-#endif
+
+ FileTransferInfo::Status status = FileTransferInfo::None;
QPointer<BaseJob> job = nullptr;
QFileInfo localFileInfo { };
- FileTransferInfo::Status status = FileTransferInfo::Started;
+ bool isUpload = false;
qint64 progress = 0;
qint64 total = -1;
@@ -969,7 +971,7 @@ FileTransferInfo Room::fileTransferInfo(const QString& id) const
fti.localPath = QUrl::fromLocalFile(infoIt->localFileInfo.absoluteFilePath());
return fti;
#else
- return { infoIt->status, int(progress), int(total),
+ return { infoIt->status, infoIt->isUpload, int(progress), int(total),
QUrl::fromLocalFile(infoIt->localFileInfo.absolutePath()),
QUrl::fromLocalFile(infoIt->localFileInfo.absoluteFilePath())
};
@@ -1532,7 +1534,7 @@ void Room::uploadFile(const QString& id, const QUrl& localFilename,
auto job = connection()->uploadFile(fileName, overrideContentType);
if (isJobRunning(job))
{
- d->fileTransfers.insert(id, { job, fileName });
+ d->fileTransfers.insert(id, { job, fileName, true });
connect(job, &BaseJob::uploadProgress, this,
[this,id] (qint64 sent, qint64 total) {
d->fileTransfers[id].update(sent, total);