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 Calendar Tools
Commits
e92c0c1b
Commit
e92c0c1b
authored
Jan 20, 2021
by
Laurent Montel
😁
Browse files
Port foreach
parent
cc9681f6
Pipeline
#48162
failed with stage
in 1 minute and 43 seconds
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
e92c0c1b
...
...
@@ -68,6 +68,7 @@ configure_file(console-version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/console-versi
add_definitions
(
-DQT_DISABLE_DEPRECATED_BEFORE=0x050f00
)
add_definitions
(
-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x054F00
)
add_definitions
(
-DQT_NO_EMIT
)
add_definitions
(
-DQT_NO_FOREACH
)
set
(
CMAKE_CXX_STANDARD 14
)
set
(
CMAKE_CXX_STANDARD_REQUIRED ON
)
option
(
USE_UNITY_CMAKE_SUPPORT
"Use UNITY cmake support (speedup compile time)"
FALSE
)
...
...
calendarjanitor/backuper.cpp
View file @
e92c0c1b
...
...
@@ -79,7 +79,8 @@ void Backuper::onCollectionsFetched(KJob *job)
const
QStringList
mimetypes
=
KCalendarCore
::
Incidence
::
mimeTypes
();
QSet
<
QString
>
mimeTypeSet
=
QSet
<
QString
>
(
mimetypes
.
begin
(),
mimetypes
.
end
());
Akonadi
::
CollectionFetchJob
*
cfj
=
qobject_cast
<
Akonadi
::
CollectionFetchJob
*>
(
job
);
foreach
(
const
Akonadi
::
Collection
&
collection
,
cfj
->
collections
())
{
const
auto
collections
=
cfj
->
collections
();
for
(
const
Akonadi
::
Collection
&
collection
:
collections
)
{
if
(
!
m_requestedCollectionIds
.
isEmpty
()
&&
!
m_requestedCollectionIds
.
contains
(
collection
.
id
()))
{
continue
;
}
...
...
@@ -121,10 +122,10 @@ void Backuper::onCollectionLoaded(KJob *job)
Akonadi
::
ItemFetchJob
*
ifj
=
qobject_cast
<
Akonadi
::
ItemFetchJob
*>
(
job
);
Akonadi
::
Collection
::
Id
id
=
ifj
->
property
(
"collectionId"
).
toInt
();
Q_ASSERT
(
id
!=
-
1
);
Akonadi
::
Item
::
List
items
=
ifj
->
items
();
const
Akonadi
::
Item
::
List
items
=
ifj
->
items
();
m_pendingCollections
.
removeAll
(
id
);
for
each
(
const
Akonadi
::
Item
&
item
,
items
)
{
for
(
const
Akonadi
::
Item
&
item
:
items
)
{
KCalendarCore
::
Incidence
::
Ptr
incidence
=
CalendarSupport
::
incidence
(
item
);
Q_ASSERT
(
incidence
);
m_calendar
->
addIncidence
(
incidence
);
...
...
calendarjanitor/calendarjanitor.cpp
View file @
e92c0c1b
...
...
@@ -88,7 +88,8 @@ void CalendarJanitor::onCollectionsFetched(bool success)
return
;
}
foreach
(
const
Akonadi
::
Collection
&
collection
,
m_collectionLoader
->
collections
())
{
const
auto
collections
=
m_collectionLoader
->
collections
();
for
(
const
Akonadi
::
Collection
&
collection
:
collections
)
{
if
(
m_options
.
testCollection
(
collection
.
id
()))
{
m_collectionsToProcess
<<
collection
;
}
...
...
@@ -184,7 +185,7 @@ void CalendarJanitor::processNextCollection()
processNextCollection
();
}
else
{
m_incidenceMap
.
clear
();
for
each
(
const
Akonadi
::
Item
&
item
,
m_itemsToProcess
)
{
for
(
const
Akonadi
::
Item
&
item
:
qAsConst
(
m_itemsToProcess
)
)
{
KCalendarCore
::
Incidence
::
Ptr
incidence
=
CalendarSupport
::
incidence
(
item
);
Q_ASSERT
(
incidence
);
m_incidenceMap
.
insert
(
incidence
->
instanceIdentifier
(),
incidence
);
...
...
@@ -250,7 +251,7 @@ void CalendarJanitor::sanityCheck1()
{
beginTest
(
i18n
(
"Checking for incidences with empty summary and description..."
));
for
each
(
const
Akonadi
::
Item
&
item
,
m_itemsToProcess
)
{
for
(
const
Akonadi
::
Item
&
item
:
qAsConst
(
m_itemsToProcess
)
)
{
KCalendarCore
::
Incidence
::
Ptr
incidence
=
CalendarSupport
::
incidence
(
item
);
if
(
incidence
->
summary
().
isEmpty
()
&&
incidence
->
description
().
isEmpty
()
&&
incidence
->
attachments
().
isEmpty
())
{
...
...
@@ -266,7 +267,7 @@ void CalendarJanitor::sanityCheck2()
{
beginTest
(
i18n
(
"Checking for incidences with empty UID..."
));
for
each
(
const
Akonadi
::
Item
&
item
,
m_itemsToProcess
)
{
for
(
const
Akonadi
::
Item
&
item
:
qAsConst
(
m_itemsToProcess
)
)
{
KCalendarCore
::
Incidence
::
Ptr
incidence
=
CalendarSupport
::
incidence
(
item
);
if
(
incidence
->
uid
().
isEmpty
())
{
printFound
(
item
);
...
...
@@ -284,7 +285,7 @@ void CalendarJanitor::sanityCheck2()
void
CalendarJanitor
::
sanityCheck3
()
{
beginTest
(
i18n
(
"Checking for events with invalid DTSTART..."
));
for
each
(
const
Akonadi
::
Item
&
item
,
m_itemsToProcess
)
{
for
(
const
Akonadi
::
Item
&
item
:
qAsConst
(
m_itemsToProcess
)
)
{
KCalendarCore
::
Incidence
::
Ptr
incidence
=
CalendarSupport
::
incidence
(
item
);
KCalendarCore
::
Event
::
Ptr
event
=
incidence
.
dynamicCast
<
KCalendarCore
::
Event
>
();
if
(
!
event
)
{
...
...
@@ -321,7 +322,7 @@ void CalendarJanitor::sanityCheck3()
void
CalendarJanitor
::
sanityCheck4
()
{
beginTest
(
i18n
(
"Checking for recurring to-dos with invalid DTSTART..."
));
for
each
(
const
Akonadi
::
Item
&
item
,
m_itemsToProcess
)
{
for
(
const
Akonadi
::
Item
&
item
:
qAsConst
(
m_itemsToProcess
)
)
{
KCalendarCore
::
Incidence
::
Ptr
incidence
=
CalendarSupport
::
incidence
(
item
);
KCalendarCore
::
Todo
::
Ptr
todo
=
incidence
.
dynamicCast
<
KCalendarCore
::
Todo
>
();
if
(
!
todo
)
{
...
...
@@ -357,7 +358,7 @@ void CalendarJanitor::sanityCheck4()
void
CalendarJanitor
::
sanityCheck5
()
{
beginTest
(
i18n
(
"Checking for journals with invalid DTSTART..."
));
for
each
(
const
Akonadi
::
Item
&
item
,
m_itemsToProcess
)
{
for
(
const
Akonadi
::
Item
&
item
:
qAsConst
(
m_itemsToProcess
)
)
{
KCalendarCore
::
Incidence
::
Ptr
incidence
=
CalendarSupport
::
incidence
(
item
);
if
(
incidence
->
type
()
!=
KCalendarCore
::
Incidence
::
TypeJournal
)
{
continue
;
...
...
@@ -379,7 +380,7 @@ void CalendarJanitor::sanityCheck6()
{
beginTest
(
i18n
(
"Checking for orphans..."
));
// Incidences without a parent
for
each
(
const
Akonadi
::
Item
&
item
,
m_itemsToProcess
)
{
for
(
const
Akonadi
::
Item
&
item
:
qAsConst
(
m_itemsToProcess
)
)
{
KCalendarCore
::
Incidence
::
Ptr
incidence
=
CalendarSupport
::
incidence
(
item
);
const
QString
parentUid
=
incidence
->
relatedTo
();
if
(
!
parentUid
.
isEmpty
()
&&
!
m_calendar
->
incidence
(
parentUid
))
{
...
...
@@ -399,15 +400,15 @@ void CalendarJanitor::sanityCheck7()
{
beginTest
(
i18n
(
"Checking for duplicate UIDs..."
));
for
each
(
const
Akonadi
::
Item
&
item
,
m_itemsToProcess
)
{
for
(
const
Akonadi
::
Item
&
item
:
qAsConst
(
m_itemsToProcess
)
)
{
KCalendarCore
::
Incidence
::
Ptr
incidence
=
CalendarSupport
::
incidence
(
item
);
QList
<
KCalendarCore
::
Incidence
::
Ptr
>
existingIncidences
=
m_incidenceMap
.
values
(
incidence
->
instanceIdentifier
());
const
QList
<
KCalendarCore
::
Incidence
::
Ptr
>
existingIncidences
=
m_incidenceMap
.
values
(
incidence
->
instanceIdentifier
());
if
(
existingIncidences
.
count
()
==
1
)
{
continue
;
}
for
each
(
const
KCalendarCore
::
Incidence
::
Ptr
&
existingIncidence
,
existingIncidences
)
{
for
(
const
KCalendarCore
::
Incidence
::
Ptr
&
existingIncidence
:
existingIncidences
)
{
if
(
existingIncidence
!=
incidence
&&
*
incidence
==
*
existingIncidence
)
{
printFound
(
item
);
deleteIncidence
(
item
);
...
...
@@ -416,9 +417,9 @@ void CalendarJanitor::sanityCheck7()
}
}
for
each
(
const
Akonadi
::
Item
&
item
,
m_itemsToProcess
)
{
for
(
const
Akonadi
::
Item
&
item
:
qAsConst
(
m_itemsToProcess
)
)
{
KCalendarCore
::
Incidence
::
Ptr
incidence
=
CalendarSupport
::
incidence
(
item
);
QList
<
KCalendarCore
::
Incidence
::
Ptr
>
existingIncidences
=
m_incidenceMap
.
values
(
incidence
->
instanceIdentifier
());
const
QList
<
KCalendarCore
::
Incidence
::
Ptr
>
existingIncidences
=
m_incidenceMap
.
values
(
incidence
->
instanceIdentifier
());
if
(
existingIncidences
.
count
()
==
1
)
{
continue
;
...
...
@@ -464,10 +465,11 @@ void CalendarJanitor::sanityCheck8()
int
numEmptyRID
=
0
;
QHash
<
KCalendarCore
::
Incidence
::
IncidenceType
,
int
>
m_counts
;
for
each
(
const
Akonadi
::
Item
&
item
,
m_itemsToProcess
)
{
for
(
const
Akonadi
::
Item
&
item
:
qAsConst
(
m_itemsToProcess
)
)
{
KCalendarCore
::
Incidence
::
Ptr
incidence
=
CalendarSupport
::
incidence
(
item
);
if
(
!
incidence
->
attachments
().
isEmpty
())
{
foreach
(
const
KCalendarCore
::
Attachment
&
attachment
,
incidence
->
attachments
())
{
const
auto
attachments
=
incidence
->
attachments
();
for
(
const
KCalendarCore
::
Attachment
&
attachment
:
attachments
)
{
if
(
!
attachment
.
isUri
())
{
numAttachments
++
;
totalAttachmentSize
+=
attachment
.
size
();
...
...
@@ -515,7 +517,7 @@ void CalendarJanitor::sanityCheck8()
void
CalendarJanitor
::
sanityCheck9
()
{
beginTest
(
i18n
(
"Checking for RECURRING-ID incidences with nonexistent master incidence..."
));
for
each
(
const
Akonadi
::
Item
&
item
,
m_itemsToProcess
)
{
for
(
const
Akonadi
::
Item
&
item
:
qAsConst
(
m_itemsToProcess
)
)
{
KCalendarCore
::
Incidence
::
Ptr
incidence
=
CalendarSupport
::
incidence
(
item
);
if
(
incidence
->
recurs
()
&&
incidence
->
hasRecurrenceId
()
&&
!
m_calendar
->
incidence
(
incidence
->
uid
()))
{
printFound
(
item
);
...
...
@@ -563,7 +565,7 @@ void CalendarJanitor::stripOldAlarms()
{
beginTest
(
i18n
(
"Deleting alarms older than 365 days..."
));
for
each
(
const
Akonadi
::
Item
&
item
,
m_itemsToProcess
)
{
for
(
const
Akonadi
::
Item
&
item
:
qAsConst
(
m_itemsToProcess
)
)
{
KCalendarCore
::
Incidence
::
Ptr
incidence
=
CalendarSupport
::
incidence
(
item
);
if
(
!
incidence
->
alarms
().
isEmpty
()
&&
incidenceIsOld
(
incidence
))
{
incidence
->
clearAlarms
();
...
...
calendarjanitor/collectionloader.cpp
View file @
e92c0c1b
...
...
@@ -42,7 +42,8 @@ void CollectionLoader::onCollectionsLoaded(KJob *job)
Q_ASSERT
(
cfj
);
const
QStringList
mimetypes
=
KCalendarCore
::
Incidence
::
mimeTypes
();
QSet
<
QString
>
mimeTypeSet
=
QSet
<
QString
>
(
mimetypes
.
begin
(),
mimetypes
.
end
());
foreach
(
const
Akonadi
::
Collection
&
collection
,
cfj
->
collections
())
{
const
auto
collections
=
cfj
->
collections
();
for
(
const
Akonadi
::
Collection
&
collection
:
collections
)
{
const
QStringList
contentMimeTypesLst
=
collection
.
contentMimeTypes
();
QSet
<
QString
>
collectionMimeTypeSet
=
QSet
<
QString
>
(
contentMimeTypesLst
.
begin
(),
contentMimeTypesLst
.
end
());
if
(
!
mimeTypeSet
.
intersect
(
collectionMimeTypeSet
).
isEmpty
())
{
...
...
calendarjanitor/main.cpp
View file @
e92c0c1b
...
...
@@ -85,9 +85,9 @@ int main(int argv, char *argc[])
Options
janitorOptions
;
if
(
parser
.
isSet
(
colsOpt
))
{
QString
option
=
parser
.
value
(
colsOpt
);
QStringList
collections
=
option
.
split
(
QLatin1Char
(
','
));
const
QStringList
collections
=
option
.
split
(
QLatin1Char
(
','
));
QList
<
Akonadi
::
Collection
::
Id
>
ids
;
for
each
(
const
QString
&
collection
,
collections
)
{
for
(
const
QString
&
collection
:
collections
)
{
bool
ok
=
false
;
int
num
=
collection
.
toInt
(
&
ok
);
if
(
ok
)
{
...
...
konsolekalendar/konsolekalendar.cpp
View file @
e92c0c1b
...
...
@@ -81,14 +81,14 @@ bool KonsoleKalendar::printCalendarList()
return
false
;
}
Akonadi
::
Collection
::
List
collections
=
job
->
collections
();
const
Akonadi
::
Collection
::
List
collections
=
job
->
collections
();
if
(
collections
.
isEmpty
())
{
cout
<<
i18n
(
"There are no calendars available."
).
toLocal8Bit
().
data
()
<<
endl
;
}
else
{
cout
<<
"--------------------------"
<<
endl
;
auto
mimeTypeSet
=
QSet
<
QString
>
(
mimeTypes
.
begin
(),
mimeTypes
.
end
());
// set changes by run method intersect
for
each
(
const
Akonadi
::
Collection
&
collection
,
collections
)
{
for
(
const
Akonadi
::
Collection
&
collection
:
collections
)
{
const
QStringList
contentMimeTypes
=
collection
.
contentMimeTypes
();
auto
collectionMimeTypeSet
=
QSet
<
QString
>
(
contentMimeTypes
.
begin
(),
contentMimeTypes
.
end
());
...
...
@@ -210,12 +210,12 @@ bool KonsoleKalendar::showInstance()
qCDebug
(
KONSOLEKALENDAR_LOG
)
<<
"konsolekalendar.cpp::showInstance() |"
<<
"view all events sorted list"
;
Event
::
List
sortedList
=
calendar
->
events
(
EventSortStartDate
);
const
Event
::
List
sortedList
=
calendar
->
events
(
EventSortStartDate
);
qCDebug
(
KONSOLEKALENDAR_LOG
)
<<
"Found"
<<
sortedList
.
count
()
<<
"events"
;
if
(
!
sortedList
.
isEmpty
())
{
// The code that was here before the akonadi port was really slow with 200 events
// this is much faster:
for
each
(
const
KCalendarCore
::
Event
::
Ptr
&
event
,
sortedList
)
{
for
(
const
KCalendarCore
::
Event
::
Ptr
&
event
:
sortedList
)
{
status
&=
printEvent
(
&
ts
,
event
,
event
->
dtStart
().
date
());
}
}
...
...
konsolekalendar/konsolekalendaradd.cpp
View file @
e92c0c1b
...
...
@@ -151,7 +151,8 @@ bool KonsoleKalendarAdd::addImportedCalendar()
QObject
::
connect
(
calendar
.
data
(),
&
Akonadi
::
CalendarBase
::
createFinished
,
&
loop
,
&
QEventLoop
::
quit
);
QElapsedTimer
t
;
foreach
(
const
auto
&
event
,
cal
->
rawEvents
())
{
const
auto
rawEvents
=
cal
->
rawEvents
();
for
(
const
auto
&
event
:
rawEvents
)
{
if
(
calendar
->
incidence
(
event
->
uid
())
!=
nullptr
)
{
if
(
m_variables
->
isVerbose
())
{
cout
<<
i18n
(
"Insert Event skipped, because UID
\"
%1
\"
is already known. <Verbose>"
,
event
->
uid
()).
toLocal8Bit
().
data
()
...
...
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