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

Update completion model and key when key filter is changed

The key filter is changed when the user switches between OpenPGP and
S/MIME. This change wasn't propagated to the completer (so that the
completer showed matching keys/certificates for the wrong protocol) and
the key wasn't updated.
parent aee74ad8
Pipeline #46856 passed with stage
in 19 minutes and 13 seconds
......@@ -80,6 +80,7 @@ CertificateLineEdit::CertificateLineEdit(AbstractKeyListModel *model,
KeyFilter *filter)
: QLineEdit(parent),
mFilterModel(new KeyListSortFilterProxyModel(this)),
mCompleterFilterModel(new ProxyModel(this)),
mFilter(std::shared_ptr<KeyFilter>(filter)),
mLineAction(new QAction(this))
{
......@@ -87,11 +88,10 @@ CertificateLineEdit::CertificateLineEdit(AbstractKeyListModel *model,
setClearButtonEnabled(true);
addAction(mLineAction, QLineEdit::LeadingPosition);
mCompleterFilterModel->setKeyFilter(mFilter);
mCompleterFilterModel->setSourceModel(model);
auto *completer = new QCompleter(this);
auto *completeFilterModel = new ProxyModel(completer);
completeFilterModel->setKeyFilter(mFilter);
completeFilterModel->setSourceModel(model);
completer->setModel(completeFilterModel);
completer->setModel(mCompleterFilterModel);
completer->setCompletionColumn(KeyListModelInterface::Summary);
completer->setFilterMode(Qt::MatchContains);
completer->setCaseSensitivity(Qt::CaseInsensitive);
......@@ -252,6 +252,8 @@ void CertificateLineEdit::setKeyFilter(const std::shared_ptr<KeyFilter> &filter)
{
mFilter = filter;
mFilterModel->setKeyFilter(filter);
mCompleterFilterModel->setKeyFilter(mFilter);
updateKey();
}
#include "certificatelineedit.moc"
......@@ -84,6 +84,7 @@ private Q_SLOTS:
private:
KeyListSortFilterProxyModel *const mFilterModel;
KeyListSortFilterProxyModel *const mCompleterFilterModel;
QLabel *mStatusLabel,
*mStatusIcon;
GpgME::Key mKey;
......
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