From 68f95cf68c3a8d29c2cc81929287eabb3a6d7682 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sun, 13 Mar 2016 23:57:18 +0100 Subject: Sync action --- components/mail/contents/ui/main.qml | 21 +++++++++++++++++++++ framework/domain/actions/sinkactions.cpp | 13 +++++++------ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/components/mail/contents/ui/main.qml b/components/mail/contents/ui/main.qml index 83bd85b2..414e3f5d 100644 --- a/components/mail/contents/ui/main.qml +++ b/components/mail/contents/ui/main.qml @@ -52,6 +52,12 @@ ApplicationWindow { mail: mailListView.currentMail } + KubeAction.Context { + id: folderListContext + property variant folder + folder: folderListView.currentFolder + } + KubeAction.Action { id: markAsReadAction actionId: "org.kde.kube.actions.mark-as-read" @@ -64,6 +70,12 @@ ApplicationWindow { context: maillistcontext } + KubeAction.Action { + id: syncAction + actionId: "org.kde.kube.actions.synchronize" + context: folderListContext + } + //UI toolBar: ToolBar { @@ -140,6 +152,15 @@ ApplicationWindow { } } + PlasmaComponents.ToolButton { + height: parent.height + iconName: "view-refresh" + text: "Sync" + enabled: syncAction.ready + onClicked: { + syncAction.execute() + } + } } Rectangle { diff --git a/framework/domain/actions/sinkactions.cpp b/framework/domain/actions/sinkactions.cpp index a19ab149..57d63752 100644 --- a/framework/domain/actions/sinkactions.cpp +++ b/framework/domain/actions/sinkactions.cpp @@ -57,15 +57,16 @@ static ActionHandlerHelper deleteHandler("org.kde.kube.actions.delete", static ActionHandlerHelper synchronizeHandler("org.kde.kube.actions.synchronize", [](Context *context) -> bool { - return context->property("folder").isValid(); + return true; }, [](Context *context) { - auto folder = context->property("folder").value(); - if (!folder) { - qWarning() << "Failed to get the folder: " << context->property("folder"); - return; + if (auto folder = context->property("folder").value()) { + qDebug() << "Synchronizing resource " << folder->resourceInstanceIdentifier(); + Sink::Store::synchronize(Sink::Query::ResourceFilter(folder->resourceInstanceIdentifier())).exec(); + } else { + qDebug() << "Synchronizing all"; + Sink::Store::synchronize(Sink::Query()).exec(); } - Sink::Store::synchronize(Sink::Query::ResourceFilter(folder->resourceInstanceIdentifier())).exec(); } ); -- cgit v1.2.3