summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2018-10-20 11:59:35 -0400
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-10-23 22:45:30 +0100
commit466a0bf75838e67e96b61f296de06205f2177030 (patch)
tree07e340f3e7fc58a2b56cd07a02b981a45c9509c8
parent2183e41bb040ab871f0c0b5cb079174b389b171c (diff)
downloadsubsurface-466a0bf75838e67e96b61f296de06205f2177030.tar.gz
Mobile/filtering: update filter in separate thread
We can't use that while the model is shown, which is why this isn't hooked up. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--mobile-widgets/qmlmanager.cpp13
-rw-r--r--mobile-widgets/qmlmanager.h1
2 files changed, 14 insertions, 0 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp
index c5603d434..009b1b4db 100644
--- a/mobile-widgets/qmlmanager.cpp
+++ b/mobile-widgets/qmlmanager.cpp
@@ -15,6 +15,8 @@
#include <QDateTime>
#include <QClipboard>
#include <QFile>
+#include <QtConcurrent>
+#include <QFuture>
#include <QBluetoothLocalDevice>
@@ -1844,6 +1846,17 @@ void QMLManager::showDownloadPage(QString deviceString)
emit pluggedInDeviceNameChanged();
}
+void QMLManager::setFilter(const QString filterText)
+{
+ // show that we are doing something, then do something in another thread in order not to block the UI
+ QMetaObject::invokeMethod(qmlWindow, "showBusy");
+ QtConcurrent::run(QThreadPool::globalInstance(),
+ [=]{
+ dlSortModel->setFilter(filterText);
+ QMetaObject::invokeMethod(qmlWindow, "hideBusy");
+ });
+}
+
#if defined(Q_OS_ANDROID)
// implemented in core/android.cpp
void checkPendingIntents();
diff --git a/mobile-widgets/qmlmanager.h b/mobile-widgets/qmlmanager.h
index a8f67389c..98282425d 100644
--- a/mobile-widgets/qmlmanager.h
+++ b/mobile-widgets/qmlmanager.h
@@ -88,6 +88,7 @@ public:
Q_INVOKABLE int getDetectedProductIndex(const QString &currentVendorText);
Q_INVOKABLE int getConnectionIndex(const QString &deviceSubstr);
Q_INVOKABLE void setGitLocalOnly(const bool &value);
+ Q_INVOKABLE void setFilter(const QString filterText);
static QMLManager *instance();
Q_INVOKABLE void registerError(QString error);