From 3df0cf619679921b58297ab12943109b66a8080b Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 1 Apr 2020 07:36:31 -0700 Subject: core/fulltext: give progress update while populating index Especially with large dive logs this will prevent the user from thinking that the app is hung. Signed-off-by: Dirk Hohndel --- core/fulltext.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'core') diff --git a/core/fulltext.cpp b/core/fulltext.cpp index 2d7af752c..78988b1ab 100644 --- a/core/fulltext.cpp +++ b/core/fulltext.cpp @@ -4,6 +4,7 @@ #include "dive.h" #include "divesite.h" #include "trip.h" +#include "qthelper.h" #include #include @@ -142,11 +143,20 @@ static std::vector getWords(const dive *d) void FullText::reload() { + // we want this to be two calls as the second text is overwritten below by the lines starting with "\r" + uiNotification(QObject::tr("Create full text index")); + uiNotification(QObject::tr("start processing")); words.clear(); int i; dive *d; - for_each_dive(i, d) + for_each_dive(i, d) { + // this makes sure that every once in a while we allow the + // UI to respond to events + if (i % 100 == 99) + uiNotification(QObject::tr("\r%1 dives processed").arg(i + 1)); registerDive(d); + } + uiNotification(QObject::tr("\r%1 dives processed").arg(dive_table.nr)); } void FullText::registerDive(struct dive *d) -- cgit v1.2.3-70-g09d2