Verified Commit c6245ade authored by Ingo Klöcker's avatar Ingo Klöcker Committed by Ingo Klöcker
Browse files

Simplify c'tor taking a key

All users of the c'tor that takes a key pass nullptr to the second
parameter. Remove the superfluous parameter.

GnuPG-bug-id: 6157
parent cb2c7922
Pipeline #230829 passed with stage
in 2 minutes and 14 seconds
......@@ -300,6 +300,6 @@ Command *Command::commandForQuery(const QString &query)
if (key.isNull()) {
return new LookupCertificatesCommand(query, nullptr);
} else {
return new DetailsCommand(key, nullptr);
return new DetailsCommand(key);
}
}
......@@ -29,7 +29,7 @@ class DetailsCommand::Private : public Command::Private
return static_cast<DetailsCommand *>(q);
}
public:
explicit Private(DetailsCommand *qq, KeyListController *c);
explicit Private(DetailsCommand *qq, KeyListController *c = nullptr);
~Private() override;
private:
......@@ -87,10 +87,9 @@ DetailsCommand::Private::Private(DetailsCommand *qq, KeyListController *c)
: Command::Private(qq, c),
dialog()
{
}
DetailsCommand::Private::~Private() {}
DetailsCommand::Private::~Private() = default;
DetailsCommand::DetailsCommand(QAbstractItemView *v, KeyListController *p)
: Command(v, new Private(this, p))
......@@ -98,15 +97,15 @@ DetailsCommand::DetailsCommand(QAbstractItemView *v, KeyListController *p)
d->init();
}
DetailsCommand::DetailsCommand(const Key &key, QAbstractItemView *v, KeyListController *p)
: Command(v, new Private(this, p))
DetailsCommand::DetailsCommand(const Key &key)
: Command{new Private{this}}
{
Q_ASSERT(!key.isNull());
d->init();
setKey(key);
}
DetailsCommand::~DetailsCommand() {}
DetailsCommand::~DetailsCommand() = default;
void DetailsCommand::doStart()
{
......
......@@ -25,8 +25,8 @@ class DetailsCommand : public Command
{
Q_OBJECT
public:
explicit DetailsCommand(QAbstractItemView *view, KeyListController *parent);
explicit DetailsCommand(const GpgME::Key &key, KeyListController *parent);
DetailsCommand(QAbstractItemView *view, KeyListController *parent);
explicit DetailsCommand(const GpgME::Key &key);
~DetailsCommand() override;
/* reimp */ static Restrictions restrictions()
......
......@@ -546,7 +546,7 @@ void LookupCertificatesCommand::Private::slotSaveAsRequested(const std::vector<K
void LookupCertificatesCommand::Private::slotDetailsRequested(const Key &key)
{
Command *const cmd = new DetailsCommand(key, nullptr);
Command *const cmd = new DetailsCommand(key);
cmd->setParentWidget(dialogOrParentWidgetOrView());
cmd->start();
}
......
......@@ -293,7 +293,7 @@ CertificateLineEdit::Private::Private(CertificateLineEdit *qq, AbstractKeyListMo
void CertificateLineEdit::Private::openDetailsDialog()
{
if (!q->key().isNull()) {
auto cmd = new Commands::DetailsCommand{q->key(), nullptr};
auto cmd = new Commands::DetailsCommand{q->key()};
cmd->setParentWidget(q);
cmd->start();
} else if (!q->group().isNull()) {
......
......@@ -1050,7 +1050,7 @@ void CertificateDetailsWidget::Private::showIssuerCertificate()
KMessageBox::error(q, i18n("The issuer certificate could not be found locally."));
return;
}
auto cmd = new Kleo::Commands::DetailsCommand(parentKeys.front(), nullptr);
auto cmd = new Kleo::Commands::DetailsCommand(parentKeys.front());
cmd->setParentWidget(q);
cmd->start();
}
......
......@@ -271,7 +271,7 @@ private:
}
const auto key = index.model()->data(index, KeyList::KeyRole).value<GpgME::Key>();
if (!key.isNull()) {
auto cmd = new DetailsCommand(key, nullptr);
auto cmd = new DetailsCommand(key);
cmd->setParentWidget(q);
cmd->start();
}
......
......@@ -114,7 +114,7 @@ private:
{
const auto key = ui.treeView->view()->model()->data(index, KeyList::KeyRole).value<GpgME::Key>();
if (!key.isNull()) {
auto cmd = new DetailsCommand(key, nullptr);
auto cmd = new DetailsCommand(key);
cmd->setParentWidget(q);
cmd->start();
}
......
......@@ -658,7 +658,7 @@ void KeyListController::Private::slotDoubleClicked(const QModelIndex &idx)
}
if (const auto *const keyListModel = dynamic_cast<KeyListModelInterface *>(view->model())) {
DetailsCommand *const c = new DetailsCommand{keyListModel->key(idx), nullptr};
DetailsCommand *const c = new DetailsCommand{keyListModel->key(idx)};
c->setParentWidget(parentWidget ? parentWidget : view);
c->start();
}
......
......@@ -128,7 +128,7 @@ NetKeyWidget::NetKeyWidget(QWidget *parent) :
qCDebug(KLEOPATRA_LOG) << "Unhandled Model: " << mTreeView->view()->model()->metaObject()->className();
return;
}
auto cmd = new DetailsCommand(klm->key(idx), nullptr);
auto cmd = new DetailsCommand(klm->key(idx));
cmd->setParentWidget(this);
cmd->start();
});
......
......@@ -221,7 +221,7 @@ void OpenPGPKeyCardWidget::Private::showCertificateDetails(const std::string &op
const std::string keyid = widgets.keyFingerprint.substr(widgets.keyFingerprint.size() - 16);
const auto subkeys = KeyCache::instance()->findSubkeysByKeyID({keyid});
if (!subkeys.empty() && !subkeys[0].isNull()) {
auto cmd = new Commands::DetailsCommand(subkeys[0].parent(), nullptr);
auto cmd = new Commands::DetailsCommand(subkeys[0].parent());
cmd->setParentWidget(q);
cmd->start();
return;
......
Supports Markdown
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