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
bb343d6d
Commit
bb343d6d
authored
May 06, 2021
by
Laurent Montel
😁
Browse files
Modernize code
parent
24017329
Pipeline
#60850
passed with stage
in 3 minutes and 47 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
calendarjanitor/backuper.cpp
View file @
bb343d6d
...
...
@@ -68,7 +68,7 @@ void Backuper::backup(const QString &filename, const QList<Akonadi::Collection::
m_backupInProgress
=
true
;
m_filename
=
filename
;
Akonadi
::
CollectionFetchJob
*
job
=
new
Akonadi
::
CollectionFetchJob
(
Akonadi
::
Collection
::
root
(),
Akonadi
::
CollectionFetchJob
::
Recursive
);
auto
job
=
new
Akonadi
::
CollectionFetchJob
(
Akonadi
::
Collection
::
root
(),
Akonadi
::
CollectionFetchJob
::
Recursive
);
job
->
fetchScope
().
setContentMimeTypes
(
KCalendarCore
::
Incidence
::
mimeTypes
());
connect
(
job
,
&
Akonadi
::
CollectionFetchJob
::
result
,
this
,
&
Backuper
::
onCollectionsFetched
);
...
...
@@ -80,7 +80,7 @@ void Backuper::onCollectionsFetched(KJob *job)
if
(
job
->
error
()
==
0
)
{
const
QStringList
mimetypes
=
KCalendarCore
::
Incidence
::
mimeTypes
();
QSet
<
QString
>
mimeTypeSet
=
QSet
<
QString
>
(
mimetypes
.
begin
(),
mimetypes
.
end
());
Akonadi
::
CollectionFetchJob
*
cfj
=
qobject_cast
<
Akonadi
::
CollectionFetchJob
*>
(
job
);
auto
cfj
=
qobject_cast
<
Akonadi
::
CollectionFetchJob
*>
(
job
);
const
auto
collections
=
cfj
->
collections
();
for
(
const
Akonadi
::
Collection
&
collection
:
collections
)
{
if
(
!
m_requestedCollectionIds
.
isEmpty
()
&&
!
m_requestedCollectionIds
.
contains
(
collection
.
id
()))
{
...
...
@@ -107,7 +107,7 @@ void Backuper::onCollectionsFetched(KJob *job)
void
Backuper
::
loadCollection
(
const
Akonadi
::
Collection
&
collection
)
{
printOut
(
i18n
(
"Processing collection %1 (id=%2)..."
,
collection
.
displayName
(),
collection
.
id
()));
Akonadi
::
ItemFetchJob
*
ifj
=
new
Akonadi
::
ItemFetchJob
(
collection
,
this
);
auto
ifj
=
new
Akonadi
::
ItemFetchJob
(
collection
,
this
);
ifj
->
setProperty
(
"collectionId"
,
collection
.
id
());
ifj
->
fetchScope
().
fetchFullPayload
(
true
);
connect
(
ifj
,
&
Akonadi
::
ItemFetchJob
::
result
,
this
,
&
Backuper
::
onCollectionLoaded
);
...
...
@@ -121,7 +121,7 @@ void Backuper::onCollectionLoaded(KJob *job)
m_calendar
.
clear
();
emitFinished
(
false
,
job
->
errorString
());
}
else
{
Akonadi
::
ItemFetchJob
*
ifj
=
qobject_cast
<
Akonadi
::
ItemFetchJob
*>
(
job
);
auto
ifj
=
qobject_cast
<
Akonadi
::
ItemFetchJob
*>
(
job
);
Akonadi
::
Collection
::
Id
id
=
ifj
->
property
(
"collectionId"
).
toInt
();
Q_ASSERT
(
id
!=
-
1
);
const
Akonadi
::
Item
::
List
items
=
ifj
->
items
();
...
...
calendarjanitor/collectionloader.cpp
View file @
bb343d6d
...
...
@@ -22,7 +22,7 @@ CollectionLoader::CollectionLoader(QObject *parent)
void
CollectionLoader
::
load
()
{
Akonadi
::
CollectionFetchJob
*
job
=
new
Akonadi
::
CollectionFetchJob
(
Akonadi
::
Collection
::
root
(),
Akonadi
::
CollectionFetchJob
::
Recursive
);
auto
job
=
new
Akonadi
::
CollectionFetchJob
(
Akonadi
::
Collection
::
root
(),
Akonadi
::
CollectionFetchJob
::
Recursive
);
job
->
fetchScope
().
setContentMimeTypes
(
KCalendarCore
::
Incidence
::
mimeTypes
());
connect
(
job
,
&
Akonadi
::
CollectionFetchJob
::
result
,
this
,
&
CollectionLoader
::
onCollectionsLoaded
);
...
...
@@ -37,7 +37,7 @@ Akonadi::Collection::List CollectionLoader::collections() const
void
CollectionLoader
::
onCollectionsLoaded
(
KJob
*
job
)
{
if
(
job
->
error
()
==
0
)
{
Akonadi
::
CollectionFetchJob
*
cfj
=
qobject_cast
<
Akonadi
::
CollectionFetchJob
*>
(
job
);
auto
cfj
=
qobject_cast
<
Akonadi
::
CollectionFetchJob
*>
(
job
);
Q_ASSERT
(
cfj
);
const
QStringList
mimetypes
=
KCalendarCore
::
Incidence
::
mimeTypes
();
QSet
<
QString
>
mimeTypeSet
=
QSet
<
QString
>
(
mimetypes
.
begin
(),
mimetypes
.
end
());
...
...
calendarjanitor/main.cpp
View file @
bb343d6d
...
...
@@ -143,13 +143,13 @@ int main(int argv, char *argc[])
switch
(
janitorOptions
.
action
())
{
case
Options
::
ActionBackup
:
{
Backuper
*
backuper
=
new
Backuper
();
auto
backuper
=
new
Backuper
();
backuper
->
backup
(
backupFile
,
janitorOptions
.
collections
());
break
;
}
case
Options
::
ActionScan
:
case
Options
::
ActionScanAndFix
:
{
CalendarJanitor
*
janitor
=
new
CalendarJanitor
(
janitorOptions
);
auto
janitor
=
new
CalendarJanitor
(
janitorOptions
);
janitor
->
start
();
break
;
}
...
...
konsolekalendar/konsolekalendar.cpp
View file @
bb343d6d
...
...
@@ -65,7 +65,7 @@ bool KonsoleKalendar::importCalendar()
bool
KonsoleKalendar
::
printCalendarList
()
{
Akonadi
::
CollectionFetchJob
*
job
=
new
Akonadi
::
CollectionFetchJob
(
Akonadi
::
Collection
::
root
(),
Akonadi
::
CollectionFetchJob
::
Recursive
);
auto
job
=
new
Akonadi
::
CollectionFetchJob
(
Akonadi
::
Collection
::
root
(),
Akonadi
::
CollectionFetchJob
::
Recursive
);
const
QStringList
mimeTypes
=
QStringList
()
<<
QStringLiteral
(
"text/calendar"
)
<<
KCalendarCore
::
Event
::
eventMimeType
()
<<
KCalendarCore
::
Todo
::
todoMimeType
()
<<
KCalendarCore
::
Journal
::
journalMimeType
();
job
->
fetchScope
().
setContentMimeTypes
(
mimeTypes
);
...
...
@@ -109,7 +109,7 @@ bool KonsoleKalendar::printCalendarList()
bool
KonsoleKalendar
::
createAkonadiResource
(
const
QString
&
icalFileUri
)
{
Akonadi
::
AgentType
type
=
Akonadi
::
AgentManager
::
self
()
->
type
(
QStringLiteral
(
"akonadi_ical_resource"
));
Akonadi
::
AgentInstanceCreateJob
*
job
=
new
Akonadi
::
AgentInstanceCreateJob
(
type
);
auto
job
=
new
Akonadi
::
AgentInstanceCreateJob
(
type
);
QEventLoop
loop
;
QObject
::
connect
(
job
,
&
Akonadi
::
CollectionFetchJob
::
result
,
&
loop
,
&
QEventLoop
::
quit
);
job
->
start
();
...
...
@@ -253,7 +253,7 @@ bool KonsoleKalendar::showInstance()
<<
"HTML view all events sorted list"
;
// sort the events for this date by start date
// in order to determine the date range.
Event
::
List
*
events
=
new
Event
::
List
(
calendar
->
rawEvents
(
EventSortStartDate
,
SortDirectionAscending
));
auto
events
=
new
Event
::
List
(
calendar
->
rawEvents
(
EventSortStartDate
,
SortDirectionAscending
));
firstdate
=
events
->
first
()
->
dtStart
().
date
();
lastdate
=
events
->
last
()
->
dtStart
().
date
();
}
else
if
(
m_variables
->
isUID
())
{
...
...
@@ -307,7 +307,7 @@ bool KonsoleKalendar::showInstance()
htmlSettings
.
setDateStart
(
QDateTime
(
firstdate
.
startOfDay
()));
htmlSettings
.
setDateEnd
(
QDateTime
(
lastdate
.
startOfDay
()));
KCalUtils
::
HtmlExport
*
exp
=
new
KCalUtils
::
HtmlExport
(
calendar
.
data
(),
&
htmlSettings
);
auto
exp
=
new
KCalUtils
::
HtmlExport
(
calendar
.
data
(),
&
htmlSettings
);
status
=
exp
->
save
(
&
ts
);
delete
exp
;
}
...
...
konsolekalendar/main.cpp
View file @
bb343d6d
...
...
@@ -537,7 +537,7 @@ int main(int argc, char *argv[])
<<
"("
<<
option
<<
")"
;
}
KonsoleKalendar
*
konsolekalendar
=
new
KonsoleKalendar
(
&
variables
);
auto
konsolekalendar
=
new
KonsoleKalendar
(
&
variables
);
if
(
parser
.
isSet
(
QStringLiteral
(
"list-calendars"
)))
{
konsolekalendar
->
printCalendarList
();
...
...
Write
Preview
Markdown
is supported
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