[vlc-devel] [PATCH 4/4] Qt GUI: use callback to fetch cloud directory.

Paweł Wegner pawel.wegner95 at gmail.com
Thu Oct 20 07:59:28 CEST 2016


---
 modules/gui/qt/components/open_panels.cpp | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/modules/gui/qt/components/open_panels.cpp b/modules/gui/qt/components/open_panels.cpp
index 2232dbe..db118e9 100644
--- a/modules/gui/qt/components/open_panels.cpp
+++ b/modules/gui/qt/components/open_panels.cpp
@@ -1433,6 +1433,29 @@ public:
     {
     }
 };
+
+class CloudListDirectoryCallback : public cloudstorage::IListDirectoryCallback {
+public:
+    CloudListDirectoryCallback(DirectoryModel* model) : model(model)
+    {
+    }
+
+    void receivedItem(IItem::Pointer item) override
+    {
+        model->addItem(item);
+    }
+
+    void done(const std::vector<IItem::Pointer>&) override
+    {
+    }
+
+    void error(const std::string&) override
+    {
+    }
+
+private:
+    DirectoryModel* model;
+};
 } // namespace
 
 CloudOpenPanel::CloudOpenPanel( QWidget *parent, intf_thread_t *t ) :
@@ -1535,11 +1558,9 @@ void CloudOpenPanel::itemClicked(const QModelIndex& index)
 void CloudOpenPanel::listDirectory()
 {
     directoryModel.clear();
+    std::unique_ptr<CloudListDirectoryCallback> callback(new CloudListDirectoryCallback(&directoryModel));
     listDirectoryRequest = currentProvider->listDirectoryAsync(currentDirectory,
-                                                               [this](const std::vector<cloudstorage::IItem::Pointer>& d) {
-        for (auto i : d)
-            directoryModel.addItem(i);
-    });
+                                                               std::move(callback));
 }
 
 void CloudOpenPanel::updateMRL()
-- 
2.9.3



More information about the vlc-devel mailing list