Commit dde08a33 authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Replace bool argument with options enum

parent a726a53b
......@@ -40,6 +40,11 @@ namespace KeyList
NumColumns,
Icon = PrettyName // which column shall the icon be displayed in?
};
enum Options {
AllKeys,
SecretKeysOnly
};
}
}
......
......@@ -70,7 +70,7 @@ public:
mutable QHash<const char *, QVariant> prettyEMailCache;
mutable QHash<const char *, QVariant> remarksCache;
bool m_useKeyCache = false;
bool m_secretOnly = false;
KeyList::Options m_keyListOptions = AllKeys;
std::vector<GpgME::Key> m_remarkKeys;
};
......@@ -82,7 +82,7 @@ AbstractKeyListModel::Private::Private(Kleo::AbstractKeyListModel *qq)
void AbstractKeyListModel::Private::updateFromKeyCache()
{
if (m_useKeyCache) {
q->setKeys(m_secretOnly ? KeyCache::instance()->secretKeys() : KeyCache::instance()->keys());
q->setKeys(m_keyListOptions == SecretKeysOnly ? KeyCache::instance()->secretKeys() : KeyCache::instance()->keys());
}
}
......@@ -1151,9 +1151,9 @@ void HierarchicalKeyListModel::doSetGroups(const std::vector<KeyGroup> &groups)
endInsertRows();
}
void AbstractKeyListModel::useKeyCache(bool value, bool secretOnly)
void AbstractKeyListModel::useKeyCache(bool value, KeyList::Options options)
{
d->m_secretOnly = secretOnly;
d->m_keyListOptions = options;
d->m_useKeyCache = value;
if (!d->m_useKeyCache) {
clear(All);
......
......@@ -16,6 +16,7 @@
#include <kleo_export.h>
#include "keylist.h"
#include "keylistmodelinterface.h"
#include <vector>
......@@ -66,7 +67,7 @@ Q_SIGNALS:
public Q_SLOTS:
void setKeys(const std::vector<GpgME::Key> &keys);
/* Set this to set all or only secret keys from the keycache. */
void useKeyCache(bool value, bool secretOnly);
void useKeyCache(bool value, Kleo::KeyList::Options options);
QModelIndex addKey(const GpgME::Key &key);
QList<QModelIndex> addKeys(const std::vector<GpgME::Key> &keys);
void removeKey(const GpgME::Key &key);
......
......@@ -394,7 +394,7 @@ void KeySelectionCombo::init()
this, [this]() {
// Set useKeyCache ensures that the cache is populated
// so this can be a blocking call if the cache is not initialized
d->model->useKeyCache(true, d->secretOnly);
d->model->useKeyCache(true, d->secretOnly ? KeyList::SecretKeysOnly : KeyList::AllKeys);
d->proxyModel->removeCustomItem(QStringLiteral("-libkleo-loading-keys"));
// We use the useWasEnabled state variable to decide if we should
......@@ -419,7 +419,7 @@ void KeySelectionCombo::init()
if (!d->cache->initialized()) {
refreshKeys();
} else {
d->model->useKeyCache(true, d->secretOnly);
d->model->useKeyCache(true, d->secretOnly ? KeyList::SecretKeysOnly : KeyList::AllKeys);
Q_EMIT keyListingFinished();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment