Commit 230acff7 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port some foreach

parent 7a241aa7
Pipeline #48167 failed with stage
in 1 minute and 38 seconds
......@@ -511,7 +511,8 @@ std::vector<Subkey> KeyCache::findSubkeysByKeyID(const std::vector<std::string>
std::vector<Key> KeyCache::findRecipients(const DecryptionResult &res) const
{
std::vector<std::string> keyids;
Q_FOREACH (const DecryptionResult::Recipient &r, res.recipients())
const auto recipients = res.recipients();
for (const DecryptionResult::Recipient &r : recipients)
if (const char *kid = r.keyID()) {
keyids.push_back(kid);
}
......@@ -529,7 +530,8 @@ std::vector<Key> KeyCache::findRecipients(const DecryptionResult &res) const
std::vector<Key> KeyCache::findSigners(const VerificationResult &res) const
{
std::vector<std::string> fprs;
Q_FOREACH (const Signature &s, res.signatures())
const auto signatures = res.signatures();
for (const Signature &s : signatures)
if (const char *fpr = s.fingerprint()) {
fprs.push_back(fpr);
}
......@@ -767,7 +769,8 @@ static std::string email(const UserID &uid)
static std::vector<std::string> emails(const Key &key)
{
std::vector<std::string> emails;
Q_FOREACH (const UserID &uid, key.userIDs()) {
const auto userIDs = key.userIDs();
for (const UserID &uid : userIDs) {
const std::string e = email(uid);
if (!e.empty()) {
emails.push_back(e);
......
......@@ -779,7 +779,8 @@ QList<QModelIndex> HierarchicalKeyListModel::doAddKeys(const std::vector<Key> &k
std::set<Key, _detail::ByFingerprint<std::less> > changedParents;
Q_FOREACH (const Key &key, topological_sort(keys)) {
const auto topologicalSortedList = topological_sort(keys);
for (const Key &key : topologicalSortedList) {
// check to see whether this key is a parent for a previously parent-less group:
const char *const fpr = key.primaryFingerprint();
......
......@@ -965,7 +965,8 @@ Kleo::ParsedKeyserver Kleo::parseKeyserver(const QString &str)
}
Kleo::ParsedKeyserver result;
result.url = list.front();
Q_FOREACH (const QString &kvpair, list.mid(1)) {
const auto listMid = list.mid(1);
for (const QString &kvpair : listMid) {
const int idx = kvpair.indexOf(QLatin1Char('='));
if (idx < 0) {
result.options.push_back(qMakePair(kvpair, QString())); // null QString
......
......@@ -526,7 +526,8 @@ Kleo::KeyListViewItem *Kleo::KeyListView::selectedItem() const
QList<Kleo::KeyListViewItem *> Kleo::KeyListView::selectedItems() const
{
QList<KeyListViewItem *> result;
foreach (QTreeWidgetItem *selectedItem, QTreeWidget::selectedItems()) {
const auto selectedItems = QTreeWidget::selectedItems();
for (QTreeWidgetItem *selectedItem : selectedItems) {
if (auto *i = Kleo::lvi_cast<Kleo::KeyListViewItem>(selectedItem)) {
result.append(i);
}
......
......@@ -392,9 +392,11 @@ bool Kleo::isChecksumFile(const QString &file)
return false;
}
if (!initialized) {
Q_FOREACH (const std::shared_ptr<ChecksumDefinition> &cd, ChecksumDefinition::getChecksumDefinitions()) {
const auto getChecksumDefinitions = ChecksumDefinition::getChecksumDefinitions();
for (const std::shared_ptr<ChecksumDefinition> &cd : getChecksumDefinitions) {
if (cd) {
Q_FOREACH (const QString &pattern, cd->patterns()) {
const auto patternsList = cd->patterns();
for (const QString &pattern : patternsList) {
#ifdef Q_OS_WIN
patterns << QRegExp(pattern, Qt::CaseInsensitive);
#else
......
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