From be511a719851c14c5ea5c1479ed2d814fbd3a8e6 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sat, 20 May 2017 12:03:33 +0200 Subject: Get the folder name in the status bar --- framework/src/domain/folderlistmodel.cpp | 24 +++++++++++++++++++++--- framework/src/domain/folderlistmodel.h | 4 ++++ framework/src/sinkfabric.cpp | 5 +++++ 3 files changed, 30 insertions(+), 3 deletions(-) (limited to 'framework/src') diff --git a/framework/src/domain/folderlistmodel.cpp b/framework/src/domain/folderlistmodel.cpp index 4437e75b..1ef6f761 100644 --- a/framework/src/domain/folderlistmodel.cpp +++ b/framework/src/domain/folderlistmodel.cpp @@ -105,7 +105,6 @@ void FolderListModel::setAccountId(const QVariant &accountId) auto query = Query(); query.resourceFilter(account); query.setFlags(Sink::Query::LiveQuery | Sink::Query::UpdateStatus); - query.requestTree(); query.request() .request() .request() @@ -115,6 +114,11 @@ void FolderListModel::setAccountId(const QVariant &accountId) runQuery(query); } +QVariant FolderListModel::accountId() const +{ + return {}; +} + static int getPriority(const Sink::ApplicationDomain::Folder &folder) { auto specialPurpose = folder.getSpecialPurpose(); @@ -144,8 +148,22 @@ bool FolderListModel::lessThan(const QModelIndex &left, const QModelIndex &right return leftPriority < rightPriority; } -QVariant FolderListModel::accountId() const +void FolderListModel::setFolderId(const QVariant &folderId) { - return QVariant(); + const auto folder = folderId.toString().toUtf8(); + + //Get all folders of an account + auto query = Query(); + query.filter(folder); + query.request() + .request() + .request() + .request(); + query.setId("folder" + folder); + runQuery(query); } +QVariant FolderListModel::folderId() const +{ + return {}; +} diff --git a/framework/src/domain/folderlistmodel.h b/framework/src/domain/folderlistmodel.h index 8f157ca2..0e412202 100644 --- a/framework/src/domain/folderlistmodel.h +++ b/framework/src/domain/folderlistmodel.h @@ -34,6 +34,7 @@ class FolderListModel : public QSortFilterProxyModel Q_OBJECT Q_PROPERTY (QVariant accountId READ accountId WRITE setAccountId) + Q_PROPERTY (QVariant folderId READ folderId WRITE setFolderId) public: enum Status { @@ -63,6 +64,9 @@ public: void setAccountId(const QVariant &accountId); QVariant accountId() const; + + void setFolderId(const QVariant &folderId); + QVariant folderId() const; protected: bool lessThan(const QModelIndex &left, const QModelIndex &right) const Q_DECL_OVERRIDE; diff --git a/framework/src/sinkfabric.cpp b/framework/src/sinkfabric.cpp index 8231b7df..82351ebb 100644 --- a/framework/src/sinkfabric.cpp +++ b/framework/src/sinkfabric.cpp @@ -160,6 +160,7 @@ public: default: message["message"] = "An unknown error occurred: " + notification.message; } + Fabric::Fabric{}.postMessage("errorNotification", message); } else if (notification.type == Sink::Notification::Info) { if (notification.code == Sink::ApplicationDomain::TransmissionSuccess) { message["type"] = Notification::Info; @@ -170,6 +171,10 @@ public: } else if (notification.type == Sink::Notification::Progress) { message["progress"] = notification.progress; message["total"] = notification.total; + if (!notification.entities.isEmpty()) { + message["folderId"] = notification.entities.first(); + } + message["resourceId"] = notification.resource; Fabric::Fabric{}.postMessage("progressNotification", message); return; } else { -- cgit v1.2.3