Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
Kleopatra
Commits
cd0712f6
Commit
cd0712f6
authored
Jan 20, 2021
by
Laurent Montel
😁
Browse files
Port some foreach
parent
ad31002c
Pipeline
#48172
failed with stage
in 11 minutes and 50 seconds
Changes
18
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/commands/exportopenpgpcertstoservercommand.cpp
View file @
cd0712f6
...
...
@@ -83,7 +83,8 @@ QStringList ExportOpenPGPCertsToServerCommand::arguments() const
result
<<
QStringLiteral
(
"--keyserver"
)
<<
QStringLiteral
(
"keys.gnupg.net"
);
}
result
<<
QStringLiteral
(
"--send-keys"
);
Q_FOREACH
(
const
Key
&
key
,
d
->
keys
())
{
const
auto
keys
=
d
->
keys
();
for
(
const
Key
&
key
:
keys
)
{
result
<<
QLatin1String
(
key
.
primaryFingerprint
());
}
return
result
;
...
...
src/commands/importcertificatescommand.cpp
View file @
cd0712f6
...
...
@@ -506,8 +506,9 @@ void ImportCertificatesCommand::Private::handleExternalCMSImports()
// For external CMS Imports we have to manually do a keylist
// with validation to get the intermediate and root ca imported
// automatically if trusted-certs and extra-certs are used.
Q_FOREACH
(
const
ImportResult
&
result
,
results
)
{
Q_FOREACH
(
const
Import
&
import
,
result
.
imports
())
{
for
(
const
ImportResult
&
result
:
qAsConst
(
results
))
{
const
auto
imports
=
result
.
imports
();
for
(
const
Import
&
import
:
imports
)
{
if
(
!
import
.
fingerprint
())
{
continue
;
}
...
...
src/crypto/autodecryptverifyfilescontroller.cpp
View file @
cd0712f6
...
...
@@ -142,7 +142,7 @@ void AutoDecryptVerifyFilesController::Private::exec()
m_runnableTasks
.
swap
(
tasks
);
std
::
shared_ptr
<
TaskCollection
>
coll
(
new
TaskCollection
);
Q_FOREACH
(
const
std
::
shared_ptr
<
Task
>
&
i
,
m_runnableTasks
)
{
for
(
const
std
::
shared_ptr
<
Task
>
&
i
:
qAsConst
(
m_runnableTasks
)
)
{
q
->
connectTask
(
i
);
}
coll
->
setTasks
(
m_runnableTasks
);
...
...
src/crypto/createchecksumscontroller.cpp
View file @
cd0712f6
...
...
@@ -167,10 +167,12 @@ static QList<QRegExp> get_patterns(const std::vector< std::shared_ptr<ChecksumDe
{
QList
<
QRegExp
>
result
;
for
(
const
std
::
shared_ptr
<
ChecksumDefinition
>
&
cd
:
checksumDefinitions
)
if
(
cd
)
Q_FOREACH
(
const
QString
&
pattern
,
cd
->
patterns
())
{
if
(
cd
)
{
const
auto
patterns
=
cd
->
patterns
();
for
(
const
QString
&
pattern
:
patterns
)
{
result
.
push_back
(
QRegExp
(
pattern
,
fs_cs
));
}
}
return
result
;
}
...
...
@@ -445,7 +447,8 @@ static std::shared_ptr<ChecksumDefinition> filename2definition(const QString &fi
{
for
(
const
std
::
shared_ptr
<
ChecksumDefinition
>
&
cd
:
checksumDefinitions
)
{
if
(
cd
)
{
Q_FOREACH
(
const
QString
&
pattern
,
cd
->
patterns
())
{
const
auto
patterns
=
cd
->
patterns
();
for
(
const
QString
&
pattern
:
patterns
)
{
if
(
QRegExp
(
pattern
,
fs_cs
).
exactMatch
(
fileName
))
{
return
cd
;
}
...
...
@@ -683,7 +686,7 @@ void CreateChecksumsController::Private::run()
const
quint64
factor
=
total
/
std
::
numeric_limits
<
int
>::
max
()
+
1
;
quint64
done
=
0
;
Q_FOREACH
(
const
Dir
&
dir
,
dirs
)
{
for
(
const
Dir
&
dir
:
dirs
)
{
Q_EMIT
progress
(
done
/
factor
,
total
/
factor
,
i18n
(
"Checksumming (%2) in %1"
,
dir
.
checksumDefinition
->
label
(),
dir
.
dir
.
path
()));
bool
fatal
=
false
;
...
...
src/crypto/decryptverifyemailcontroller.cpp
View file @
cd0712f6
...
...
@@ -171,7 +171,7 @@ void DecryptVerifyEMailController::Private::schedule()
}
if
(
!
m_runningTask
)
{
kleo_assert
(
m_runnableTasks
.
empty
());
Q_FOREACH
(
const
std
::
shared_ptr
<
const
DecryptVerifyResult
>
&
i
,
m_results
)
{
for
(
const
std
::
shared_ptr
<
const
DecryptVerifyResult
>
&
i
:
qAsConst
(
m_results
)
)
{
Q_EMIT
q
->
verificationResult
(
i
->
verificationResult
());
}
// if there is a popup, wait for either the client cancel or the user closing the popup.
...
...
src/crypto/encryptemailcontroller.cpp
View file @
cd0712f6
...
...
@@ -195,7 +195,7 @@ void EncryptEMailController::start()
coll
->
setTasks
(
tmp
);
d
->
ensureWizardCreated
();
d
->
wizard
->
setTaskCollection
(
coll
);
Q_FOREACH
(
const
std
::
shared_ptr
<
Task
>
&
t
,
tmp
)
{
for
(
const
std
::
shared_ptr
<
Task
>
&
t
:
qAsConst
(
tmp
)
)
{
connectTask
(
t
);
}
d
->
schedule
();
...
...
src/crypto/gui/resolverecipientspage.cpp
View file @
cd0712f6
...
...
@@ -124,7 +124,7 @@ void ResolveRecipientsPage::ListWidget::setProtocol(GpgME::Protocol prot)
return
;
}
m_protocol
=
prot
;
Q_FOREACH
(
ItemWidget
*
i
,
widgets
)
{
for
(
ItemWidget
*
i
:
qAsConst
(
widgets
)
)
{
i
->
setProtocol
(
prot
);
}
}
...
...
@@ -291,7 +291,7 @@ void ResolveRecipientsPage::ItemWidget::resetCertificates()
}
m_certCombo
->
clear
();
Q_FOREACH
(
const
Key
&
i
,
certs
)
{
for
(
const
Key
&
i
:
qAsConst
(
certs
)
)
{
addCertificateToComboBox
(
i
);
}
if
(
!
m_selectedCertificates
[
m_protocol
].
isNull
())
{
...
...
@@ -550,7 +550,7 @@ void ResolveRecipientsPage::Private::addRecipient()
const
std
::
vector
<
Key
>
keys
=
dlg
->
selectedCertificates
();
int
i
=
0
;
Q_FOREACH
(
const
Key
&
key
,
keys
)
{
for
(
const
Key
&
key
:
keys
)
{
const
QStringList
existing
=
m_listWidget
->
identifiers
();
QString
rec
=
i18n
(
"Recipient"
);
while
(
existing
.
contains
(
rec
))
{
...
...
@@ -603,7 +603,7 @@ void ResolveRecipientsPage::setRecipients(const std::vector<Mailbox> &recipients
uint
cmsCount
=
0
;
uint
pgpCount
=
0
;
uint
senders
=
0
;
Q_FOREACH
(
const
Mailbox
&
mb
,
encryptToSelfRecipients
)
{
for
(
const
Mailbox
&
mb
:
encryptToSelfRecipients
)
{
const
QString
id
=
QLatin1String
(
"sender-"
)
+
QString
::
number
(
++
senders
);
d
->
m_listWidget
->
addEntry
(
id
,
i18n
(
"Sender"
),
mb
);
const
std
::
vector
<
Key
>
pgp
=
makeSuggestions
(
d
->
m_recipientPreferences
,
mb
,
OpenPGP
);
...
...
@@ -612,7 +612,7 @@ void ResolveRecipientsPage::setRecipients(const std::vector<Mailbox> &recipients
cmsCount
+=
!
cms
.
empty
();
d
->
m_listWidget
->
setCertificates
(
id
,
pgp
,
cms
);
}
Q_FOREACH
(
const
Mailbox
&
i
,
recipients
)
{
for
(
const
Mailbox
&
i
:
recipients
)
{
//TODO:
const
QString
address
=
i
.
prettyAddress
();
d
->
addRecipient
(
i
);
...
...
src/crypto/gui/signencryptemailconflictdialog.cpp
View file @
cd0712f6
...
...
@@ -155,13 +155,13 @@ private:
bool
first
;
first
=
true
;
Q_FOREACH
(
const
CertificateSelectionLine
&
line
,
ui
.
signers
)
{
for
(
const
CertificateSelectionLine
&
line
:
qAsConst
(
ui
.
signers
)
)
{
line
.
showHide
(
proto
,
first
,
showAll
,
sign
);
}
ui
.
selectSigningCertificatesGB
.
setVisible
(
sign
&&
(
showAll
||
!
first
));
first
=
true
;
Q_FOREACH
(
const
CertificateSelectionLine
&
line
,
ui
.
recipients
)
{
for
(
const
CertificateSelectionLine
&
line
:
qAsConst
(
ui
.
recipients
)
)
{
line
.
showHide
(
proto
,
first
,
showAll
,
encrypt
);
}
ui
.
selectEncryptionCertificatesGB
.
setVisible
(
encrypt
&&
(
showAll
||
!
first
));
...
...
src/crypto/gui/signencryptfileswizard.cpp
View file @
cd0712f6
...
...
@@ -255,7 +255,8 @@ public:
void
setOutputNames
(
const
QMap
<
int
,
QString
>
&
names
)
{
Q_ASSERT
(
mOutNames
.
isEmpty
());
mOutNames
=
names
;
Q_FOREACH
(
int
i
,
mOutNames
.
keys
())
{
const
auto
keys
=
mOutNames
.
keys
();
for
(
int
i
:
keys
)
{
mRequester
[
i
]
=
createRequester
(
i
,
mOutLayout
);
}
updateFileWidgets
();
...
...
src/crypto/gui/signencryptwidget.cpp
View file @
cd0712f6
...
...
@@ -135,7 +135,7 @@ SignEncryptWidget::SignEncryptWidget(QWidget *parent, bool sigEncExclusive)
mEncOtherChk
->
setChecked
(
true
);
connect
(
mEncOtherChk
,
&
QCheckBox
::
toggled
,
this
,
[
this
](
bool
toggled
)
{
Q_FOREACH
(
CertificateLineEdit
*
edit
,
mRecpWidgets
)
{
for
(
CertificateLineEdit
*
edit
:
qAsConst
(
mRecpWidgets
)
)
{
edit
->
setEnabled
(
toggled
);
}
updateOp
();
...
...
@@ -301,7 +301,7 @@ void SignEncryptWidget::addUnknownRecipient(const char *keyID)
void
SignEncryptWidget
::
recipientsChanged
()
{
bool
oneEmpty
=
false
;
Q_FOREACH
(
const
CertificateLineEdit
*
w
,
mRecpWidgets
)
{
for
(
const
CertificateLineEdit
*
w
:
qAsConst
(
mRecpWidgets
)
)
{
if
(
w
->
key
().
isNull
())
{
oneEmpty
=
true
;
break
;
...
...
@@ -332,7 +332,7 @@ Key SignEncryptWidget::selfKey() const
QVector
<
Key
>
SignEncryptWidget
::
recipients
()
const
{
QVector
<
Key
>
ret
;
Q_FOREACH
(
const
CertificateLineEdit
*
w
,
mRecpWidgets
)
{
for
(
const
CertificateLineEdit
*
w
:
qAsConst
(
mRecpWidgets
)
)
{
if
(
!
w
->
isEnabled
())
{
// If one is disabled, all are disabled.
break
;
...
...
@@ -401,7 +401,7 @@ void SignEncryptWidget::recpRemovalRequested(CertificateLineEdit *w)
return
;
}
int
emptyEdits
=
0
;
Q_FOREACH
(
const
CertificateLineEdit
*
edit
,
mRecpWidgets
)
{
for
(
const
CertificateLineEdit
*
edit
:
qAsConst
(
mRecpWidgets
)
)
{
if
(
edit
->
isEmpty
())
{
emptyEdits
++
;
}
...
...
@@ -491,7 +491,7 @@ void SignEncryptWidget::setProtocol(GpgME::Protocol proto)
mSigSelect
->
setKeyFilter
(
std
::
shared_ptr
<
KeyFilter
>
(
new
SignCertificateFilter
(
proto
)));
mSelfSelect
->
setKeyFilter
(
std
::
shared_ptr
<
KeyFilter
>
(
new
EncryptSelfCertificateFilter
(
proto
)));
const
auto
encFilter
=
std
::
shared_ptr
<
KeyFilter
>
(
new
EncryptCertificateFilter
(
proto
));
Q_FOREACH
(
CertificateLineEdit
*
edit
,
mRecpWidgets
)
{
for
(
CertificateLineEdit
*
edit
:
qAsConst
(
mRecpWidgets
)
)
{
edit
->
setKeyFilter
(
encFilter
);
}
...
...
src/crypto/newsignencryptemailcontroller.cpp
View file @
cd0712f6
...
...
@@ -470,7 +470,7 @@ void NewSignEncryptEMailController::Private::startEncryption()
// ### use a new result dialog
dialog->setTaskCollection(coll);
#endif
Q_FOREACH
(
const
std
::
shared_ptr
<
Task
>
&
t
,
tmp
)
{
for
(
const
std
::
shared_ptr
<
Task
>
&
t
:
qAsConst
(
tmp
)
)
{
q
->
connectTask
(
t
);
}
schedule
();
...
...
@@ -521,7 +521,7 @@ void NewSignEncryptEMailController::Private::startSigning()
// ### use a new result dialog
dialog->setTaskCollection(coll);
#endif
Q_FOREACH
(
const
std
::
shared_ptr
<
Task
>
&
t
,
tmp
)
{
for
(
const
std
::
shared_ptr
<
Task
>
&
t
:
qAsConst
(
tmp
)
)
{
q
->
connectTask
(
t
);
}
schedule
();
...
...
src/crypto/signemailcontroller.cpp
View file @
cd0712f6
...
...
@@ -214,7 +214,7 @@ void SignEMailController::start()
coll
->
setTasks
(
tmp
);
d
->
ensureWizardCreated
();
d
->
wizard
->
setTaskCollection
(
coll
);
Q_FOREACH
(
const
std
::
shared_ptr
<
Task
>
&
t
,
tmp
)
{
for
(
const
std
::
shared_ptr
<
Task
>
&
t
:
qAsConst
(
tmp
)
)
{
connectTask
(
t
);
}
...
...
src/crypto/verifychecksumscontroller.cpp
View file @
cd0712f6
...
...
@@ -85,10 +85,12 @@ static QList<QRegExp> get_patterns(const std::vector< std::shared_ptr<ChecksumDe
{
QList
<
QRegExp
>
result
;
for
(
const
std
::
shared_ptr
<
ChecksumDefinition
>
&
cd
:
checksumDefinitions
)
if
(
cd
)
Q_FOREACH
(
const
QString
&
pattern
,
cd
->
patterns
())
{
if
(
cd
)
{
const
auto
patterns
=
cd
->
patterns
();
for
(
const
QString
&
pattern
:
patterns
)
{
result
.
push_back
(
QRegExp
(
pattern
,
fs_cs
));
}
}
return
result
;
}
...
...
@@ -326,11 +328,13 @@ static std::shared_ptr<ChecksumDefinition> filename2definition(const QString &fi
const
std
::
vector
<
std
::
shared_ptr
<
ChecksumDefinition
>
>
&
checksumDefinitions
)
{
for
(
const
std
::
shared_ptr
<
ChecksumDefinition
>
&
cd
:
checksumDefinitions
)
if
(
cd
)
Q_FOREACH
(
const
QString
&
pattern
,
cd
->
patterns
())
if
(
cd
)
{
const
auto
patterns
=
cd
->
patterns
();
for
(
const
QString
&
pattern
:
patterns
)
if
(
QRegExp
(
pattern
,
fs_cs
).
exactMatch
(
fileName
))
{
return
cd
;
}
}
return
std
::
shared_ptr
<
ChecksumDefinition
>
();
}
...
...
src/kleopatraapplication.cpp
View file @
cd0712f6
...
...
@@ -255,7 +255,8 @@ QString KleopatraApplication::newInstance(const QCommandLineParser &parser,
// Query and Search treat positional arguments differently, see below.
if
(
!
queryMode
)
{
Q_FOREACH
(
const
QString
&
file
,
parser
.
positionalArguments
())
{
const
auto
positionalArguments
=
parser
.
positionalArguments
();
for
(
const
QString
&
file
:
positionalArguments
)
{
// We do not check that file exists here. Better handle
// these errors in the UI.
if
(
QFileInfo
(
file
).
isAbsolute
())
{
...
...
@@ -379,7 +380,7 @@ QString KleopatraApplication::newInstance(const QCommandLineParser &parser,
openOrRaiseMainWindow
();
}
}
else
{
Q_FOREACH
(
const
QString
&
fileName
,
files
)
{
for
(
const
QString
&
fileName
:
qAsConst
(
files
)
)
{
QFileInfo
fi
(
fileName
);
if
(
!
fi
.
isReadable
())
{
errors
<<
i18n
(
"Cannot read
\"
%1
\"
"
,
fileName
);
...
...
src/newcertificatewizard/newcertificatewizard.cpp
View file @
cd0712f6
...
...
@@ -1426,7 +1426,7 @@ void EnterDetailsPage::updateForm()
QMap
<
int
,
Line
>
lines
;
Q_FOREACH
(
const
QString
&
rawKey
,
attrOrder
)
{
for
(
const
QString
&
rawKey
:
qAsConst
(
attrOrder
)
)
{
const
QString
key
=
rawKey
.
trimmed
().
toUpper
();
const
QString
attr
=
attributeFromKey
(
key
);
if
(
attr
.
isEmpty
())
{
...
...
src/smartcard/readerstatus.cpp
View file @
cd0712f6
...
...
@@ -774,7 +774,7 @@ private Q_SLOTS:
std
::
list
<
Transaction
>
ft
;
KDAB_SYNCHRONIZED
(
m_mutex
)
ft
.
splice
(
ft
.
begin
(),
m_finishedTransactions
);
Q_FOREACH
(
const
Transaction
&
t
,
ft
)
for
(
const
Transaction
&
t
:
qAsConst
(
ft
)
)
if
(
t
.
receiver
&&
t
.
slot
&&
*
t
.
slot
)
{
QMetaObject
::
invokeMethod
(
t
.
receiver
,
t
.
slot
,
Qt
::
DirectConnection
,
Q_ARG
(
GpgME
::
Error
,
err
));
}
...
...
src/view/keytreeview.cpp
View file @
cd0712f6
...
...
@@ -106,8 +106,8 @@ protected:
});
}
for
each
(
QAction
*
action
,
mColumnActions
)
{
int
column
=
action
->
data
().
toInt
();
for
(
QAction
*
action
:
qAsConst
(
mColumnActions
)
)
{
const
int
column
=
action
->
data
().
toInt
();
action
->
setChecked
(
!
isColumnHidden
(
column
));
}
...
...
tests/test_uiserver.cpp
View file @
cd0712f6
...
...
@@ -274,7 +274,7 @@ int main(int argc, char *argv[])
}
}
Q_FOREACH
(
const
char
*
opt
,
options
)
{
for
(
const
char
*
opt
:
qAsConst
(
options
)
)
{
std
::
string
line
=
"OPTION "
;
line
+=
opt
;
if
(
const
gpg_error_t
err
=
assuan_transact
(
ctx
,
line
.
c_str
(),
nullptr
,
nullptr
,
nullptr
,
nullptr
,
nullptr
,
nullptr
))
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment