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

Use std::vector for lists of keys everywhere

This way we avoid unnecessary conversions between std::vector and QVector.
parent 9e50e0f9
......@@ -194,21 +194,20 @@ public:
return true;
}
QVector<Key> recipients() const
std::vector<Key> recipients() const
{
return mWidget->recipients();
}
/* In the future we might find a usecase for multiple
* signers */
QVector<Key> signers() const
std::vector<Key> signers() const
{
QVector<Key> ret;
const Key k = mWidget->signKey();
if (!k.isNull()) {
ret << k;
return {k};
}
return ret;
return {};
}
private:
......@@ -309,7 +308,7 @@ private Q_SLOTS:
if (mRequester.isEmpty()) {
return;
}
const QVector<Key> recipients = mWidget->recipients();
const std::vector<Key> recipients = mWidget->recipients();
const Key sigKey = mWidget->signKey();
bool pgp = mWidget->encryptSymmetric();
bool cms = false;
......@@ -461,12 +460,12 @@ void SignEncryptFilesWizard::setArchiveMutable(bool archive)
mSigEncPage->setArchiveMutable(archive);
}
QVector<Key> SignEncryptFilesWizard::resolvedRecipients() const
std::vector<Key> SignEncryptFilesWizard::resolvedRecipients() const
{
return mSigEncPage->recipients();
}
QVector<Key> SignEncryptFilesWizard::resolvedSigners() const
std::vector<Key> SignEncryptFilesWizard::resolvedSigners() const
{
return mSigEncPage->signers();
}
......
......@@ -76,8 +76,8 @@ public:
void setTaskCollection(const std::shared_ptr<Kleo::Crypto::TaskCollection> &coll);
// Outputs
QVector<GpgME::Key> resolvedRecipients() const;
QVector<GpgME::Key> resolvedSigners() const;
std::vector<GpgME::Key> resolvedRecipients() const;
std::vector<GpgME::Key> resolvedSigners() const;
bool encryptSymmetric() const;
void setLabelText(const QString &label) const;
......
......@@ -406,9 +406,9 @@ Key SignEncryptWidget::selfKey() const
return Key();
}
QVector <Key> SignEncryptWidget::recipients() const
std::vector<Key> SignEncryptWidget::recipients() const
{
QVector<Key> ret;
std::vector<Key> ret;
for (const CertificateLineEdit *w : qAsConst(mRecpWidgets)) {
if (!w->isEnabled()) {
// If one is disabled, all are disabled.
......@@ -417,7 +417,7 @@ QVector <Key> SignEncryptWidget::recipients() const
const Key k = w->key();
const KeyGroup g = w->group();
if (!k.isNull()) {
ret << k;
ret.push_back(k);
} else if (!g.isNull()) {
const auto keys = g.keys();
std::copy(keys.begin(), keys.end(), std::back_inserter(ret));
......@@ -425,7 +425,7 @@ QVector <Key> SignEncryptWidget::recipients() const
}
const Key k = selfKey();
if (!k.isNull()) {
ret << k;
ret.push_back(k);
}
return ret;
}
......@@ -454,12 +454,12 @@ bool SignEncryptWidget::isDeVsAndValid() const
void SignEncryptWidget::updateOp()
{
const Key sigKey = signKey();
const QVector<Key> recp = recipients();
const std::vector<Key> recp = recipients();
QString newOp;
if (!sigKey.isNull() && (!recp.isEmpty() || encryptSymmetric())) {
if (!sigKey.isNull() && (!recp.empty() || encryptSymmetric())) {
newOp = i18nc("@action", "Sign / Encrypt");
} else if (!recp.isEmpty() || encryptSymmetric()) {
} else if (!recp.empty() || encryptSymmetric()) {
newOp = i18nc("@action", "Encrypt");
} else if (!sigKey.isNull()) {
newOp = i18nc("@action", "Sign");
......
......@@ -34,7 +34,7 @@ public:
/** Returns the list of recipients selected in the dialog
* or an empty list if encryption is disabled */
QVector <GpgME::Key> recipients() const;
std::vector<GpgME::Key> recipients() const;
/** Returns the selected signing key or a null key if signing
* is disabled. */
......
......@@ -507,26 +507,26 @@ void SignEncryptFilesController::Private::slotWizardOperationPrepared()
const bool archive = (wizard->outputNames().value(SignEncryptFilesWizard::Directory).isNull() && files.size() > 1) ||
((operation & ArchiveMask) == ArchiveForced);
const QVector<Key> recipients = wizard->resolvedRecipients();
const QVector<Key> signers = wizard->resolvedSigners();
const std::vector<Key> recipients = wizard->resolvedRecipients();
const std::vector<Key> signers = wizard->resolvedSigners();
const FileOperationsPreferences prefs;
const bool ascii = prefs.addASCIIArmor();
QVector<Key> pgpRecipients, cmsRecipients, pgpSigners, cmsSigners;
std::vector<Key> pgpRecipients, cmsRecipients, pgpSigners, cmsSigners;
Q_FOREACH (const Key &k, recipients) {
if (k.protocol() == GpgME::OpenPGP) {
pgpRecipients << k;
pgpRecipients.push_back(k);
} else {
cmsRecipients << k;
cmsRecipients.push_back(k);
}
}
Q_FOREACH (const Key &k, signers) {
if (k.protocol() == GpgME::OpenPGP) {
pgpSigners << k;
pgpSigners.push_back(k);
} else {
cmsSigners << k;
cmsSigners.push_back(k);
}
}
......@@ -539,10 +539,10 @@ void SignEncryptFilesController::Private::slotWizardOperationPrepared()
tasks = createArchiveSignEncryptTasksForFiles(files,
getDefaultAd(),
ascii,
pgpRecipients.toStdVector(),
pgpSigners.toStdVector(),
cmsRecipients.toStdVector(),
cmsSigners.toStdVector(),
pgpRecipients,
pgpSigners,
cmsRecipients,
cmsSigners,
wizard->outputNames(),
wizard->encryptSymmetric());
......@@ -550,10 +550,10 @@ void SignEncryptFilesController::Private::slotWizardOperationPrepared()
Q_FOREACH (const QString &file, files) {
const std::vector< std::shared_ptr<SignEncryptTask> > created =
createSignEncryptTasksForFileInfo(QFileInfo(file), ascii,
pgpRecipients.toStdVector(),
pgpSigners.toStdVector(),
cmsRecipients.toStdVector(),
cmsSigners.toStdVector(),
pgpRecipients,
pgpSigners,
cmsRecipients,
cmsSigners,
buildOutputNamesForDir(file, wizard->outputNames()),
wizard->encryptSymmetric());
tasks.insert(tasks.end(), created.begin(), created.end());
......
......@@ -378,8 +378,9 @@ public:
const auto sigKey = mSigEncWidget->signKey();
bool encrypt = mSigEncWidget->encryptSymmetric() || !mSigEncWidget->recipients().isEmpty();
bool sign = !sigKey.isNull();
const std::vector<GpgME::Key> recipients = mSigEncWidget->recipients();
const bool encrypt = mSigEncWidget->encryptSymmetric() || !recipients.empty();
const bool sign = !sigKey.isNull();
if (sign) {
task->setSign(true);
......@@ -390,7 +391,7 @@ public:
task->setSign(false);
}
task->setEncrypt(encrypt);
task->setRecipients(mSigEncWidget->recipients().toStdVector());
task->setRecipients(recipients);
task->setEncryptSymmetric(mSigEncWidget->encryptSymmetric());
task->setAsciiArmor(true);
......
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