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
Akonadi
Commits
1e65e93d
Commit
1e65e93d
authored
Jan 31, 2021
by
Laurent Montel
😁
Browse files
Port some foreach
parent
21203777
Pipeline
#49240
passed with stage
in 13 minutes and 1 second
Changes
15
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
autotests/libs/autoincrementtest.cpp
View file @
1e65e93d
...
...
@@ -97,7 +97,7 @@ void AutoIncrementTest::testCollectionAutoIncrement()
}
// Delete the 20 collections
for
each
(
const
Collection
&
collection
,
collectionsToDelete
)
{
for
(
const
Collection
&
collection
:
qAsConst
(
collectionsToDelete
)
)
{
auto
*
job
=
new
CollectionDeleteJob
(
collection
);
AKVERIFYEXEC
(
job
);
}
...
...
autotests/libs/collectionjobtest.cpp
View file @
1e65e93d
...
...
@@ -54,7 +54,7 @@ static Collection findCol(const Collection::List &list, const QString &name)
template
<
class
T
>
static
void
compareLists
(
const
QList
<
T
>
&
l1
,
const
QList
<
T
>
&
l2
)
{
QCOMPARE
(
l1
.
count
(),
l2
.
count
());
for
each
(
const
T
&
entry
,
l1
)
{
for
(
const
T
&
entry
:
l1
)
{
QVERIFY
(
l2
.
contains
(
entry
));
}
}
...
...
@@ -62,7 +62,7 @@ template<class T> static void compareLists(const QList<T> &l1, const QList<T> &l
template
<
class
T
>
static
void
compareLists
(
const
QVector
<
T
>
&
l1
,
const
QVector
<
T
>
&
l2
)
{
QCOMPARE
(
l1
.
count
(),
l2
.
count
());
for
each
(
const
T
&
entry
,
l1
)
{
for
(
const
T
&
entry
:
l1
)
{
QVERIFY
(
l2
.
contains
(
entry
));
}
}
...
...
@@ -70,7 +70,7 @@ template<class T> static void compareLists(const QVector<T> &l1, const QVector<T
template
<
typename
T
>
static
T
*
extractAttribute
(
QList
<
Attribute
*>
attrs
)
{
T
dummy
;
for
each
(
Attribute
*
attr
,
attrs
)
{
for
(
Attribute
*
attr
:
attrs
)
{
if
(
attr
->
type
()
==
dummy
.
type
())
{
return
dynamic_cast
<
T
*>
(
attr
);
}
...
...
autotests/libs/gidtest.cpp
View file @
1e65e93d
...
...
@@ -100,7 +100,7 @@ void GidTest::testSetAndFetch()
QFETCH
(
Item
,
toFetch
);
QFETCH
(
Item
::
List
,
expected
);
Q_FOREACH
(
const
Item
&
item
,
input
)
{
for
(
const
Item
&
item
:
qAsConst
(
input
)
)
{
fetchAndSetGid
(
item
);
}
...
...
@@ -109,7 +109,7 @@ void GidTest::testSetAndFetch()
AKVERIFYEXEC
(
fetch
);
Item
::
List
fetched
=
fetch
->
items
();
QCOMPARE
(
fetched
.
count
(),
expected
.
size
());
Q_FOREACH
(
const
Item
&
item
,
expected
)
{
for
(
const
Item
&
item
:
qAsConst
(
expected
)
)
{
QVERIFY
(
expected
.
removeOne
(
item
));
}
QVERIFY
(
expected
.
isEmpty
());
...
...
autotests/libs/linktest.cpp
View file @
1e65e93d
...
...
@@ -52,7 +52,8 @@ private Q_SLOTS:
auto
*
f
=
new
ItemFetchJob
(
items
,
this
);
f
->
fetchScope
().
fetchFullPayload
();
AKVERIFYEXEC
(
f
);
Q_FOREACH
(
const
Item
&
item
,
f
->
items
())
{
const
auto
itemsLst
=
f
->
items
();
for
(
const
Item
&
item
:
itemsLst
)
{
QVERIFY
(
item
.
hasPayload
<
QByteArray
>
());
}
...
...
autotests/libs/transactiontest.cpp
View file @
1e65e93d
...
...
@@ -33,8 +33,8 @@ void TransactionTest::testTransaction()
CollectionFetchJob
*
listJob
=
new
CollectionFetchJob
(
Collection
::
root
(),
CollectionFetchJob
::
Recursive
);
AKVERIFYEXEC
(
listJob
);
Collection
::
List
list
=
listJob
->
collections
();
for
each
(
const
Collection
&
col
,
list
)
const
Collection
::
List
list
=
listJob
->
collections
();
for
(
const
Collection
&
col
:
list
)
if
(
col
.
name
()
==
QLatin1String
(
"res3"
))
{
basisCollection
=
col
;
}
...
...
src/core/jobs/specialcollectionshelperjobs.cpp
View file @
1e65e93d
...
...
@@ -437,8 +437,7 @@ void DefaultResourceJobPrivate::collectionFetchResult(KJob *job)
// These collections have been created by the maildir resource, when it
// found the folders on disk. So give them the necessary attributes now.
Q_ASSERT
(
mPendingModifyJobs
==
0
);
for
(
Collection
collection
:
qAsConst
(
toRecover
))
{
// krazy:exclude=foreach
for
(
Collection
collection
:
qAsConst
(
toRecover
))
{
if
(
collection
.
hasAttribute
<
SpecialCollectionAttribute
>
())
{
continue
;
}
...
...
src/server/handler/itemcreatehandler.cpp
View file @
1e65e93d
...
...
@@ -103,7 +103,8 @@ bool ItemCreateHandler::insertItem(const Protocol::CreateItemCommand &cmd, PimIt
// Handle individual parts
qint64
partSizes
=
0
;
PartStreamer
streamer
(
connection
(),
item
);
Q_FOREACH
(
const
QByteArray
&
partName
,
cmd
.
parts
())
{
const
auto
parts
=
cmd
.
parts
();
for
(
const
QByteArray
&
partName
:
parts
)
{
qint64
partSize
=
0
;
try
{
streamer
.
stream
(
true
,
partName
,
partSize
);
...
...
src/server/handler/itemmovehandler.cpp
View file @
1e65e93d
...
...
@@ -52,7 +52,7 @@ void ItemMoveHandler::itemsRetrieved(const QVector<qint64> &ids)
QMultiMap
<
Entity
::
Id
/* collection */
,
PimItem
>
toMove
;
QMap
<
Entity
::
Id
/* collection */
,
Collection
>
sources
;
ImapSet
toMoveIds
;
for
(
PimItem
item
:
items
)
{
// krazy:exclude=foreach
for
(
PimItem
item
:
items
)
{
if
(
!
item
.
isValid
())
{
failureResponse
(
"Invalid item in result set!?"
);
return
;
...
...
src/server/handler/searchhelper.cpp
View file @
1e65e93d
...
...
@@ -72,7 +72,7 @@ QVector<qint64> SearchHelper::matchSubcollectionsByMimeType(const QVector<qint64
}
// Try to resolve direct descendants
Q_FOREACH
(
qint64
ancestor
,
ancestors
)
{
for
(
qint64
ancestor
:
ancestors
)
{
const
QVector
<
qint64
>
cols
=
candidateCollections
.
take
(
ancestor
);
if
(
!
cols
.
isEmpty
())
{
results
+=
cols
;
...
...
src/server/handlerhelper.cpp
View file @
1e65e93d
...
...
@@ -86,8 +86,9 @@ Protocol::CachePolicy HandlerHelper::cachePolicyResponse(const Collection &col)
Protocol
::
FetchCollectionsResponse
HandlerHelper
::
fetchCollectionsResponse
(
AkonadiServer
&
akonadi
,
const
Collection
&
col
)
{
QStringList
mimeTypes
;
mimeTypes
.
reserve
(
col
.
mimeTypes
().
size
());
Q_FOREACH
(
const
MimeType
&
mt
,
col
.
mimeTypes
())
{
const
auto
mimeTypesList
=
col
.
mimeTypes
();
mimeTypes
.
reserve
(
mimeTypesList
.
size
());
for
(
const
MimeType
&
mt
:
mimeTypesList
)
{
mimeTypes
<<
mt
.
name
();
}
...
...
src/server/storage/datastore.cpp
View file @
1e65e93d
...
...
@@ -729,7 +729,7 @@ bool DataStore::removeItemParts(const PimItem &item, const QSet<QByteArray> &par
}
const
Part
::
List
existingParts
=
qb
.
result
();
for
(
Part
part
:
qAsConst
(
existingParts
))
{
// krazy:exclude=foreach
for
(
Part
part
:
qAsConst
(
existingParts
))
{
if
(
!
PartHelper
::
remove
(
&
part
))
{
qCWarning
(
AKONADISERVER_LOG
)
<<
"Failed to remove part"
<<
part
.
id
()
<<
"("
<<
part
.
partType
().
ns
()
<<
":"
<<
part
.
partType
().
name
()
<<
") from Item"
<<
item
.
id
();
...
...
src/server/storage/dbinitializer.cpp
View file @
1e65e93d
...
...
@@ -61,13 +61,15 @@ bool DbInitializer::run()
try
{
qCInfo
(
AKONADISERVER_LOG
)
<<
"Running DB initializer"
;
Q_FOREACH
(
const
TableDescription
&
table
,
mSchema
->
tables
())
{
const
auto
tables
=
mSchema
->
tables
();
for
(
const
TableDescription
&
table
:
tables
)
{
if
(
!
checkTable
(
table
))
{
return
false
;
}
}
Q_FOREACH
(
const
RelationDescription
&
relation
,
mSchema
->
relations
())
{
const
auto
relations
=
mSchema
->
relations
();
for
(
const
RelationDescription
&
relation
:
relations
)
{
if
(
!
checkRelation
(
relation
))
{
return
false
;
}
...
...
@@ -142,7 +144,7 @@ void DbInitializer::checkForeignKeys(const TableDescription &tableDescription)
const
QVector
<
DbIntrospector
::
ForeignKey
>
existingForeignKeys
=
m_introspector
->
foreignKeyConstraints
(
tableDescription
.
name
);
Q_FOREACH
(
const
ColumnDescription
&
column
,
tableDescription
.
columns
)
{
DbIntrospector
::
ForeignKey
existingForeignKey
;
Q_FOREACH
(
const
DbIntrospector
::
ForeignKey
&
fk
,
existingForeignKeys
)
{
for
(
const
DbIntrospector
::
ForeignKey
&
fk
:
existingForeignKeys
)
{
if
(
QString
::
compare
(
fk
.
column
,
column
.
name
,
Qt
::
CaseInsensitive
)
==
0
)
{
existingForeignKey
=
fk
;
break
;
...
...
src/server/storagejanitor.cpp
View file @
1e65e93d
...
...
@@ -188,7 +188,8 @@ qint64 StorageJanitor::lostAndFoundCollection()
qCCritical
(
AKONADISERVER_LOG
)
<<
"Failed to create lost+found collection!"
;
}
Q_FOREACH
(
const
MimeType
&
mt
,
MimeType
::
retrieveAll
())
{
const
auto
retrieveAll
=
MimeType
::
retrieveAll
();
for
(
const
MimeType
&
mt
:
retrieveAll
)
{
lfCol
.
addMimeType
(
mt
);
}
...
...
src/xml/xmlwriter.cpp
View file @
1e65e93d
...
...
@@ -35,7 +35,8 @@ template<typename T> static void writeAttributesImpl(const T &entity, QDomElemen
}
QDomDocument
doc
=
parentElem
.
ownerDocument
();
Q_FOREACH
(
Attribute
*
attr
,
entity
.
attributes
())
{
const
auto
attributes
=
entity
.
attributes
();
for
(
Attribute
*
attr
:
attributes
)
{
parentElem
.
appendChild
(
XmlWriter
::
attributeToElement
(
attr
,
doc
));
}
}
...
...
@@ -96,7 +97,8 @@ QDomElement XmlWriter::itemToElement(const Akonadi::Item &item, QDomDocument &do
writeAttributes
(
item
,
top
);
Q_FOREACH
(
const
Item
::
Flag
&
flag
,
item
.
flags
())
{
const
auto
flags
=
item
.
flags
();
for
(
const
Item
::
Flag
&
flag
:
flags
)
{
QDomElement
flagElem
=
document
.
createElement
(
Format
::
Tag
::
flag
());
QDomText
flagText
=
document
.
createTextNode
(
QString
::
fromUtf8
(
flag
));
flagElem
.
appendChild
(
flagText
);
...
...
tests/libs/collectiondialog.cpp
View file @
1e65e93d
...
...
@@ -36,7 +36,8 @@ int main(int argc, char **argv)
dlg
.
changeCollectionDialogOptions
(
CollectionDialog
::
AllowToCreateNewChildCollection
);
dlg
.
exec
();
foreach
(
const
Collection
&
collection
,
dlg
.
selectedCollections
())
{
const
auto
selectedCollections
=
dlg
.
selectedCollections
();
for
(
const
Collection
&
collection
:
selectedCollections
)
{
qDebug
()
<<
"Selected collection:"
<<
collection
.
name
();
}
...
...
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