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

Simplify a few connects and disconnects

Replace complicated function pointer casts with simple lambdas or the
QOverload helper.

GnuPG-bug-id: 5283
parent f3464a1b
...@@ -367,7 +367,7 @@ KeySelectionCombo::KeySelectionCombo(bool secretOnly, QWidget* parent) ...@@ -367,7 +367,7 @@ KeySelectionCombo::KeySelectionCombo(bool secretOnly, QWidget* parent)
d->proxyModel->setSourceModel(d->sortFilterProxy); d->proxyModel->setSourceModel(d->sortFilterProxy);
setModel(d->proxyModel); setModel(d->proxyModel);
connect(this, static_cast<void(KeySelectionCombo::*)(int)>(&KeySelectionCombo::currentIndexChanged), connect(this, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, [this](int row) { this, [this](int row) {
if (row >= 0 && row < d->proxyModel->rowCount()) { if (row >= 0 && row < d->proxyModel->rowCount()) {
if (d->proxyModel->isCustomItem(row)) { if (d->proxyModel->isCustomItem(row)) {
......
...@@ -427,7 +427,7 @@ void Kleo::KeySelectionDialog::setUpUI(Options options, const QString &initialQu ...@@ -427,7 +427,7 @@ void Kleo::KeySelectionDialog::setUpUI(Options options, const QString &initialQu
le->setFocus(); le->setFocus();
connect(le, &QLineEdit::textChanged, connect(le, &QLineEdit::textChanged,
this, static_cast<void(KeySelectionDialog::*)(const QString &)>(&KeySelectionDialog::slotSearch)); this, [this] (const QString &s) { slotSearch(s); });
connect(mStartSearchTimer, &QTimer::timeout, this, &KeySelectionDialog::slotFilter); connect(mStartSearchTimer, &QTimer::timeout, this, &KeySelectionDialog::slotFilter);
mKeyListView = new KeyListView(new ColumnStrategy(mKeyUsage), nullptr, page); mKeyListView = new KeyListView(new ColumnStrategy(mKeyUsage), nullptr, page);
...@@ -452,7 +452,7 @@ void Kleo::KeySelectionDialog::setUpUI(Options options, const QString &initialQu ...@@ -452,7 +452,7 @@ void Kleo::KeySelectionDialog::setUpUI(Options options, const QString &initialQu
} }
connect(mCheckSelectionTimer, &QTimer::timeout, connect(mCheckSelectionTimer, &QTimer::timeout,
this, static_cast<void(KeySelectionDialog::*)()>(&KeySelectionDialog::slotCheckSelection)); this, [this] () { slotCheckSelection(); });
connectSignals(); connectSignals();
connect(mKeyListView, &Kleo::KeyListView::doubleClicked, this, &KeySelectionDialog::slotTryOk); connect(mKeyListView, &Kleo::KeyListView::doubleClicked, this, &KeySelectionDialog::slotTryOk);
...@@ -531,8 +531,8 @@ void Kleo::KeySelectionDialog::connectSignals() ...@@ -531,8 +531,8 @@ void Kleo::KeySelectionDialog::connectSignals()
if (mKeyListView->isMultiSelection()) if (mKeyListView->isMultiSelection())
connect(mKeyListView, &QTreeWidget::itemSelectionChanged, this, &KeySelectionDialog::slotSelectionChanged); connect(mKeyListView, &QTreeWidget::itemSelectionChanged, this, &KeySelectionDialog::slotSelectionChanged);
else else
connect(mKeyListView, static_cast<void(KeyListView::*)(KeyListViewItem*)>(&KeyListView::selectionChanged), connect(mKeyListView, QOverload<KeyListViewItem*>::of(&KeyListView::selectionChanged),
this, static_cast<void(KeySelectionDialog::*)(KeyListViewItem*)>(&KeySelectionDialog::slotCheckSelection)); this, QOverload<KeyListViewItem*>::of(&KeySelectionDialog::slotCheckSelection));
} }
void Kleo::KeySelectionDialog::disconnectSignals() void Kleo::KeySelectionDialog::disconnectSignals()
...@@ -541,8 +541,8 @@ void Kleo::KeySelectionDialog::disconnectSignals() ...@@ -541,8 +541,8 @@ void Kleo::KeySelectionDialog::disconnectSignals()
disconnect(mKeyListView, &QTreeWidget::itemSelectionChanged, disconnect(mKeyListView, &QTreeWidget::itemSelectionChanged,
this, &KeySelectionDialog::slotSelectionChanged); this, &KeySelectionDialog::slotSelectionChanged);
else else
disconnect(mKeyListView, static_cast<void(KeyListView::*)(KeyListViewItem*)>(&KeyListView::selectionChanged), disconnect(mKeyListView, QOverload<KeyListViewItem*>::of(&KeyListView::selectionChanged),
this, static_cast<void(KeySelectionDialog::*)(KeyListViewItem*)>(&KeySelectionDialog::slotCheckSelection)); this, QOverload<KeyListViewItem*>::of(&KeySelectionDialog::slotCheckSelection));
} }
const GpgME::Key &Kleo::KeySelectionDialog::selectedKey() const const GpgME::Key &Kleo::KeySelectionDialog::selectedKey() const
......
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