summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Heinecke <aheinecke@intevation.de>2016-08-04 16:26:54 (GMT)
committerAndre Heinecke <aheinecke@intevation.de>2016-08-05 07:40:57 (GMT)
commitbc2d2a986b131f483eaee5773609917abb998dac (patch)
tree3670facca42a91e25a2930134d1bc120b31719aa
parenta76396774f49d4bdbbe97ac5e374b0283b605e13 (diff)
Handle existing keycache in keyselectioncombo
Refresh jobs can take a while, especially if multiple jobs are started in parallel. Since the keycache is usually automatically updated we don't need to refresh manually if it is not necessary.
-rw-r--r--src/ui/keyselectioncombo.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/ui/keyselectioncombo.cpp b/src/ui/keyselectioncombo.cpp
index f7ea0a6..443c3c7 100644
--- a/src/ui/keyselectioncombo.cpp
+++ b/src/ui/keyselectioncombo.cpp
@@ -216,19 +216,25 @@ KeySelectionCombo::KeySelectionCombo(QWidget* parent)
: QComboBox(parent)
, d(new KeySelectionComboPrivate(this))
{
- setEnabled(false);
-
d->cache = Kleo::KeyCache::mutableInstance();
- connect(d->cache.get(), &Kleo::KeyCache::keyListingDone,
- this, [this]() {
- qDebug() << "Key listing done";
- d->model->useKeyCache(true, true);
- setEnabled(true);
- setCurrentIndex(0);
- });
- d->cache->startKeyListing();
-
d->model = Kleo::AbstractKeyListModel::createFlatKeyListModel(this);
+
+ if (!d->cache->initialized()) {
+ setEnabled(false);
+ connect(d->cache.get(), &Kleo::KeyCache::keyListingDone,
+ this, [this]() {
+ qDebug() << "Key listing done";
+ setEnabled(true);
+ // Set useKeyCache ensures that the cache is populated
+ // so this can be a blocking call if the cache is not initalized
+ d->model->useKeyCache(true, true);
+ setCurrentIndex(0);
+ });
+ d->cache->startKeyListing();
+ } else {
+ d->model->useKeyCache(true, true);
+ }
+
d->sortFilterProxy = new Kleo::KeyListSortFilterProxyModel(this);
d->sortFilterProxy->setSourceModel(d->model);