Skip to content
GitLab
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
1ad0783c
Commit
1ad0783c
authored
Dec 12, 2018
by
Laurent Montel
Browse files
GIT_SILENT: coding style
parent
8303831f
Changes
15
Hide whitespace changes
Inline
Side-by-side
calendarjanitor/backuper.cpp
View file @
1ad0783c
...
...
@@ -59,7 +59,8 @@ void Backuper::emitFinished(bool success, const QString &message)
qApp
->
exit
(
success
?
0
:
-
1
);
// TODO: If we move this class to kdepimlibs, remove this
}
Backuper
::
Backuper
(
QObject
*
parent
)
:
QObject
(
parent
),
m_backupInProgress
(
false
)
Backuper
::
Backuper
(
QObject
*
parent
)
:
QObject
(
parent
)
,
m_backupInProgress
(
false
)
{
}
...
...
@@ -81,7 +82,7 @@ void Backuper::backup(const QString &filename, const QList<Akonadi::Collection::
m_filename
=
filename
;
Akonadi
::
CollectionFetchJob
*
job
=
new
Akonadi
::
CollectionFetchJob
(
Akonadi
::
Collection
::
root
(),
Akonadi
::
CollectionFetchJob
::
Recursive
);
Akonadi
::
CollectionFetchJob
::
Recursive
);
job
->
fetchScope
().
setContentMimeTypes
(
KCalCore
::
Incidence
::
mimeTypes
());
connect
(
job
,
&
Akonadi
::
CollectionFetchJob
::
result
,
this
,
&
Backuper
::
onCollectionsFetched
);
...
...
calendarjanitor/backuper.h
View file @
1ad0783c
...
...
@@ -59,7 +59,6 @@ private:
KCalCore
::
MemoryCalendar
::
Ptr
m_calendar
;
bool
m_backupInProgress
;
};
#endif // BACKUPER_H
calendarjanitor/calendarjanitor.cpp
View file @
1ad0783c
...
...
@@ -57,8 +57,8 @@ static void bailOut()
static
bool
collectionIsReadOnly
(
const
Akonadi
::
Collection
&
collection
)
{
return
!
(
collection
.
rights
()
&
Akonadi
::
Collection
::
CanChangeItem
)
||
!
(
collection
.
rights
()
&
Akonadi
::
Collection
::
CanDeleteItem
);
return
!
(
collection
.
rights
()
&
Akonadi
::
Collection
::
CanChangeItem
)
||
!
(
collection
.
rights
()
&
Akonadi
::
Collection
::
CanDeleteItem
);
}
static
bool
incidenceIsOld
(
const
KCalCore
::
Incidence
::
Ptr
&
incidence
)
...
...
@@ -135,8 +135,7 @@ void CalendarJanitor::onItemsFetched(bool success, const QString &errorMessage)
processNextCollection
();
}
void
CalendarJanitor
::
onModifyFinished
(
int
changeId
,
const
Akonadi
::
Item
&
item
,
Akonadi
::
IncidenceChanger
::
ResultCode
resultCode
,
const
QString
&
errorMessage
)
void
CalendarJanitor
::
onModifyFinished
(
int
changeId
,
const
Akonadi
::
Item
&
item
,
Akonadi
::
IncidenceChanger
::
ResultCode
resultCode
,
const
QString
&
errorMessage
)
{
Q_UNUSED
(
changeId
);
if
(
resultCode
!=
Akonadi
::
IncidenceChanger
::
ResultCodeSuccess
)
{
...
...
@@ -154,8 +153,7 @@ void CalendarJanitor::onModifyFinished(int changeId, const Akonadi::Item &item,
}
}
void
CalendarJanitor
::
onDeleteFinished
(
int
changeId
,
const
QVector
<
Akonadi
::
Item
::
Id
>
&
items
,
Akonadi
::
IncidenceChanger
::
ResultCode
resultCode
,
const
QString
&
errorMessage
)
void
CalendarJanitor
::
onDeleteFinished
(
int
changeId
,
const
QVector
<
Akonadi
::
Item
::
Id
>
&
items
,
Akonadi
::
IncidenceChanger
::
ResultCode
resultCode
,
const
QString
&
errorMessage
)
{
Q_UNUSED
(
changeId
);
if
(
resultCode
!=
Akonadi
::
IncidenceChanger
::
ResultCodeSuccess
)
{
...
...
@@ -271,8 +269,8 @@ void CalendarJanitor::sanityCheck1()
foreach
(
const
Akonadi
::
Item
&
item
,
m_itemsToProcess
)
{
KCalCore
::
Incidence
::
Ptr
incidence
=
CalendarSupport
::
incidence
(
item
);
if
(
incidence
->
summary
().
isEmpty
()
&&
incidence
->
description
().
isEmpty
()
&&
incidence
->
attachments
().
isEmpty
())
{
if
(
incidence
->
summary
().
isEmpty
()
&&
incidence
->
description
().
isEmpty
()
&&
incidence
->
attachments
().
isEmpty
())
{
printFound
(
item
);
deleteIncidence
(
item
);
}
...
...
@@ -311,7 +309,7 @@ void CalendarJanitor::sanityCheck3()
}
QDateTime
start
=
event
->
dtStart
();
QDateTime
end
=
event
->
dtEnd
();
QDateTime
end
=
event
->
dtEnd
();
bool
modify
=
false
;
QString
message
;
...
...
@@ -348,7 +346,7 @@ void CalendarJanitor::sanityCheck4()
}
QDateTime
start
=
todo
->
dtStart
();
QDateTime
due
=
todo
->
dtDue
();
QDateTime
due
=
todo
->
dtDue
();
bool
modify
=
false
;
if
(
todo
->
recurs
()
&&
!
start
.
isValid
()
&&
due
.
isValid
())
{
modify
=
true
;
...
...
@@ -528,7 +526,7 @@ void CalendarJanitor::sanityCheck8()
m_returnCode
=
-
2
;
}
endTest
(
/**print=*/
false
);
endTest
(
/**print=*/
false
);
}
void
CalendarJanitor
::
sanityCheck9
()
...
...
@@ -543,7 +541,7 @@ void CalendarJanitor::sanityCheck9()
QDateTime
recId
=
incidence
->
recurrenceId
();
QDateTime
start
=
incidence
->
dtStart
();
QDateTime
end
=
incidence
->
dateTime
(
KCalCore
::
Incidence
::
RoleEnd
);
QDateTime
end
=
incidence
->
dateTime
(
KCalCore
::
Incidence
::
RoleEnd
);
KCalCore
::
Event
::
Ptr
event
=
incidence
.
dynamicCast
<
KCalCore
::
Event
>
();
KCalCore
::
Todo
::
Ptr
todo
=
incidence
.
dynamicCast
<
KCalCore
::
Todo
>
();
...
...
calendarjanitor/calendarjanitor.h
View file @
1ad0783c
...
...
@@ -51,10 +51,8 @@ Q_SIGNALS:
private
Q_SLOTS
:
void
onCollectionsFetched
(
bool
success
);
void
onItemsFetched
(
bool
success
,
const
QString
&
errorMessage
);
void
onModifyFinished
(
int
changeId
,
const
Akonadi
::
Item
&
item
,
Akonadi
::
IncidenceChanger
::
ResultCode
resultCode
,
const
QString
&
errorMessage
);
void
onDeleteFinished
(
int
changeId
,
const
QVector
<
Akonadi
::
Item
::
Id
>
&
,
Akonadi
::
IncidenceChanger
::
ResultCode
resultCode
,
const
QString
&
errorMessage
);
void
onModifyFinished
(
int
changeId
,
const
Akonadi
::
Item
&
item
,
Akonadi
::
IncidenceChanger
::
ResultCode
resultCode
,
const
QString
&
errorMessage
);
void
onDeleteFinished
(
int
changeId
,
const
QVector
<
Akonadi
::
Item
::
Id
>
&
,
Akonadi
::
IncidenceChanger
::
ResultCode
resultCode
,
const
QString
&
errorMessage
);
void
processNextCollection
();
...
...
@@ -76,8 +74,7 @@ private Q_SLOTS:
void
printFound
(
const
Akonadi
::
Item
&
item
,
const
QString
&
explanation
=
QString
());
void
beginTest
(
const
QString
&
message
);
void
endTest
(
bool
print
=
true
,
const
QString
&
fixExplanation
=
QString
(),
const
QString
&
fixExplanation2
=
QString
());
void
endTest
(
bool
print
=
true
,
const
QString
&
fixExplanation
=
QString
(),
const
QString
&
fixExplanation2
=
QString
());
void
deleteIncidence
(
const
Akonadi
::
Item
&
item
);
...
...
calendarjanitor/collectionloader.cpp
View file @
1ad0783c
...
...
@@ -31,15 +31,15 @@
#include
<QDebug>
CollectionLoader
::
CollectionLoader
(
QObject
*
parent
)
:
QObject
(
parent
)
CollectionLoader
::
CollectionLoader
(
QObject
*
parent
)
:
QObject
(
parent
)
{
}
void
CollectionLoader
::
load
()
{
Akonadi
::
CollectionFetchJob
*
job
=
new
Akonadi
::
CollectionFetchJob
(
Akonadi
::
Collection
::
root
(),
Akonadi
::
CollectionFetchJob
::
Recursive
);
Akonadi
::
CollectionFetchJob
::
Recursive
);
job
->
fetchScope
().
setContentMimeTypes
(
KCalCore
::
Incidence
::
mimeTypes
());
connect
(
job
,
&
Akonadi
::
CollectionFetchJob
::
result
,
this
,
&
CollectionLoader
::
onCollectionsLoaded
);
...
...
calendarjanitor/main.cpp
View file @
1ad0783c
...
...
@@ -83,7 +83,6 @@ int main(int argv, char *argc[])
aboutData
.
addAuthor
(
i18n
(
"Sérgio Martins"
),
i18n
(
"Maintainer"
),
QStringLiteral
(
"iamsergiogmail.com"
));
aboutData
.
setShortDescription
(
i18n
(
progDesc
));
QCoreApplication
app
(
argv
,
argc
);
QCommandLineParser
parser
;
...
...
@@ -157,13 +156,15 @@ int main(int argv, char *argc[])
}
switch
(
janitorOptions
.
action
())
{
case
Options
::
ActionBackup
:
{
case
Options
::
ActionBackup
:
{
Backuper
*
backuper
=
new
Backuper
();
backuper
->
backup
(
backupFile
,
janitorOptions
.
collections
());
break
;
}
case
Options
::
ActionScan
:
case
Options
::
ActionScanAndFix
:
{
case
Options
::
ActionScanAndFix
:
{
CalendarJanitor
*
janitor
=
new
CalendarJanitor
(
janitorOptions
);
janitor
->
start
();
break
;
...
...
konsolekalendar/konsolekalendar.cpp
View file @
1ad0783c
...
...
@@ -84,11 +84,11 @@ bool KonsoleKalendar::importCalendar()
bool
KonsoleKalendar
::
printCalendarList
()
{
Akonadi
::
CollectionFetchJob
*
job
=
new
Akonadi
::
CollectionFetchJob
(
Akonadi
::
Collection
::
root
(),
Akonadi
::
CollectionFetchJob
::
Recursive
);
Akonadi
::
CollectionFetchJob
::
Recursive
);
QStringList
mimeTypes
=
QStringList
()
<<
QStringLiteral
(
"text/calendar"
)
<<
KCalCore
::
Event
::
eventMimeType
()
<<
KCalCore
::
Todo
::
todoMimeType
()
<<
KCalCore
::
Journal
::
journalMimeType
();
<<
KCalCore
::
Event
::
eventMimeType
()
<<
KCalCore
::
Todo
::
todoMimeType
()
<<
KCalCore
::
Journal
::
journalMimeType
();
job
->
fetchScope
().
setContentMimeTypes
(
mimeTypes
);
QEventLoop
loop
;
QObject
::
connect
(
job
,
&
Akonadi
::
CollectionFetchJob
::
result
,
&
loop
,
&
QEventLoop
::
quit
);
...
...
@@ -111,9 +111,9 @@ bool KonsoleKalendar::printCalendarList()
QString
colId
=
QString
::
number
(
collection
.
id
()).
leftJustified
(
6
,
QLatin1Char
(
' '
));
colId
+=
QLatin1String
(
"- "
);
bool
readOnly
=
!
(
collection
.
rights
()
&
Akonadi
::
Collection
::
CanCreateItem
||
collection
.
rights
()
&
Akonadi
::
Collection
::
CanChangeItem
||
collection
.
rights
()
&
Akonadi
::
Collection
::
CanDeleteItem
);
bool
readOnly
=
!
(
collection
.
rights
()
&
Akonadi
::
Collection
::
CanCreateItem
||
collection
.
rights
()
&
Akonadi
::
Collection
::
CanChangeItem
||
collection
.
rights
()
&
Akonadi
::
Collection
::
CanDeleteItem
);
QString
readOnlyString
=
readOnly
?
i18n
(
"(Read only)"
)
+
QLatin1Char
(
' '
)
:
QString
();
...
...
@@ -136,7 +136,7 @@ bool KonsoleKalendar::createAkonadiResource(const QString &icalFileUri)
if
(
job
->
error
()
!=
0
)
{
return
false
;
}
auto
inst
=
job
->
instance
();
auto
inst
=
job
->
instance
();
inst
.
setName
(
QFileInfo
(
icalFileUri
).
baseName
());
QDBusInterface
iface
(
QStringLiteral
(
"org.freedesktop.Akonadi.Resource."
)
+
inst
.
identifier
(),
QStringLiteral
(
"/Settings"
));
QDBusReply
<
void
>
reply
=
iface
.
call
(
QStringLiteral
(
"setDisplayName"
),
QFileInfo
(
icalFileUri
).
baseName
());
...
...
@@ -219,9 +219,8 @@ bool KonsoleKalendar::showInstance()
QTextStream
ts
(
&
f
);
if
(
m_variables
->
getExportType
()
!=
ExportTypeHTML
&&
m_variables
->
getExportType
()
!=
ExportTypeMonthHTML
)
{
if
(
m_variables
->
getExportType
()
!=
ExportTypeHTML
&&
m_variables
->
getExportType
()
!=
ExportTypeMonthHTML
)
{
if
(
m_variables
->
getAll
())
{
qCDebug
(
KONSOLEKALENDAR_LOG
)
<<
"konsolekalendar.cpp::showInstance() |"
<<
"view all events sorted list"
;
...
...
@@ -243,7 +242,6 @@ bool KonsoleKalendar::showInstance()
//If this UID represents a recurring Event,
//only the first day of the Event will be printed
status
=
printEvent
(
&
ts
,
event
,
event
->
dtStart
().
date
());
}
else
if
(
m_variables
->
isNext
())
{
qCDebug
(
KONSOLEKALENDAR_LOG
)
<<
"konsolekalendar.cpp::showInstance() |"
<<
"Show next activity in calendar"
;
...
...
@@ -253,8 +251,8 @@ bool KonsoleKalendar::showInstance()
QDate
dt
;
for
(
dt
=
m_variables
->
getStartDateTime
().
date
();
dt
<=
datetime
.
date
();
dt
=
dt
.
addDays
(
1
))
{
dt
<=
datetime
.
date
();
dt
=
dt
.
addDays
(
1
))
{
Event
::
List
events
=
calendar
->
events
(
dt
,
timeZone
,
EventSortStartDate
,
SortDirectionAscending
);
...
...
@@ -273,8 +271,8 @@ bool KonsoleKalendar::showInstance()
QDate
dt
;
for
(
dt
=
m_variables
->
getStartDateTime
().
date
();
dt
<=
m_variables
->
getEndDateTime
().
date
()
&&
status
!=
false
;
dt
=
dt
.
addDays
(
1
))
{
dt
<=
m_variables
->
getEndDateTime
().
date
()
&&
status
!=
false
;
dt
=
dt
.
addDays
(
1
))
{
Event
::
List
events
=
calendar
->
events
(
dt
,
timeZone
,
EventSortStartDate
,
SortDirectionAscending
);
...
...
@@ -289,9 +287,9 @@ 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
));
Event
::
List
*
events
=
new
Event
::
List
(
calendar
->
rawEvents
(
EventSortStartDate
,
SortDirectionAscending
));
firstdate
=
events
->
first
()
->
dtStart
().
date
();
lastdate
=
events
->
last
()
->
dtStart
().
date
();
}
else
if
(
m_variables
->
isUID
())
{
...
...
@@ -299,7 +297,7 @@ bool KonsoleKalendar::showInstance()
qCDebug
(
KONSOLEKALENDAR_LOG
)
<<
"konsolekalendar.cpp::showInstance() |"
<<
"HTML view events by uid list"
;
cout
<<
i18n
(
"Sorry, export to HTML by UID is not supported yet"
).
toLocal8Bit
().
data
()
<<
endl
;
toLocal8Bit
().
data
()
<<
endl
;
return
false
;
}
else
{
qCDebug
(
KONSOLEKALENDAR_LOG
)
<<
"konsolekalendar.cpp::showInstance() |"
...
...
@@ -360,8 +358,7 @@ bool KonsoleKalendar::showInstance()
return
status
;
}
bool
KonsoleKalendar
::
printEventList
(
QTextStream
*
ts
,
Event
::
List
*
eventList
,
QDate
date
)
bool
KonsoleKalendar
::
printEventList
(
QTextStream
*
ts
,
Event
::
List
*
eventList
,
QDate
date
)
{
bool
status
=
true
;
...
...
@@ -371,8 +368,8 @@ bool KonsoleKalendar::printEventList(QTextStream *ts,
Event
::
List
::
ConstIterator
it
;
for
(
it
=
eventList
->
constBegin
();
it
!=
eventList
->
constEnd
()
&&
status
!=
false
;
++
it
)
{
it
!=
eventList
->
constEnd
()
&&
status
!=
false
;
++
it
)
{
singleEvent
=
*
it
;
status
=
printEvent
(
ts
,
singleEvent
,
date
);
...
...
@@ -390,7 +387,6 @@ bool KonsoleKalendar::printEvent(QTextStream *ts, const Event::Ptr &event, QDate
if
(
event
)
{
switch
(
m_variables
->
getExportType
())
{
case
ExportTypeCSV
:
qCDebug
(
KONSOLEKALENDAR_LOG
)
<<
"konsolekalendar.cpp::printEvent() |"
<<
"CSV export"
;
...
...
@@ -433,7 +429,6 @@ bool KonsoleKalendar::addEvent()
bool
KonsoleKalendar
::
changeEvent
()
{
qCDebug
(
KONSOLEKALENDAR_LOG
)
<<
"konsolecalendar.cpp::changeEvent() |"
<<
"Create Changing"
;
KonsoleKalendarChange
change
(
m_variables
);
...
...
@@ -452,8 +447,7 @@ bool KonsoleKalendar::deleteEvent()
return
del
.
deleteEvent
();
}
bool
KonsoleKalendar
::
isEvent
(
const
QDateTime
&
startdate
,
const
QDateTime
&
enddate
,
const
QString
&
summary
)
bool
KonsoleKalendar
::
isEvent
(
const
QDateTime
&
startdate
,
const
QDateTime
&
enddate
,
const
QString
&
summary
)
{
// Search for an event with specified start and end datetime stamp and summary
...
...
@@ -469,8 +463,8 @@ bool KonsoleKalendar::isEvent(const QDateTime &startdate,
SortDirectionAscending
));
for
(
it
=
eventList
.
constBegin
();
it
!=
eventList
.
constEnd
();
++
it
)
{
event
=
*
it
;
if
(
event
->
dtEnd
().
toTimeZone
(
timeZone
)
==
enddate
&&
event
->
summary
()
==
summary
)
{
if
(
event
->
dtEnd
().
toTimeZone
(
timeZone
)
==
enddate
&&
event
->
summary
()
==
summary
)
{
found
=
true
;
break
;
}
...
...
konsolekalendar/konsolekalendaradd.cpp
View file @
1ad0783c
...
...
@@ -125,7 +125,6 @@ bool KonsoleKalendarAdd::addEvent()
cout
<<
i18n
(
"Success:
\"
%1
\"
inserted"
,
m_variables
->
getSummary
()).
toLocal8Bit
().
data
()
<<
endl
;
}
else
{
cout
<<
i18n
(
"Failure:
\"
%1
\"
not inserted"
,
m_variables
->
getSummary
()).
toLocal8Bit
().
data
()
...
...
@@ -144,8 +143,8 @@ bool KonsoleKalendarAdd::addImportedCalendar()
FileStorage
instore
(
cal
,
m_variables
->
getImportFile
());
if
(
!
instore
.
load
())
{
qCDebug
(
KONSOLEKALENDAR_LOG
)
<<
"konsolekalendaradd.cpp::importCalendar() |"
<<
"Can't import file:"
<<
m_variables
->
getImportFile
();
<<
"Can't import file:"
<<
m_variables
->
getImportFile
();
return
false
;
}
Akonadi
::
CalendarBase
::
Ptr
calendar
=
m_variables
->
getCalendar
();
...
...
@@ -154,7 +153,7 @@ bool KonsoleKalendarAdd::addImportedCalendar()
Akonadi
::
IncidenceChanger
*
changer
=
calendar
->
incidenceChanger
();
changer
->
setShowDialogsOnError
(
false
);
Akonadi
::
Collection
collection
=
m_variables
->
collectionId
()
!=
-
1
?
Akonadi
::
Collection
(
m_variables
->
collectionId
())
:
Akonadi
::
Collection
(
CalendarSupport
::
KCalPrefs
::
instance
()
->
defaultCalendarId
());
:
Akonadi
::
Collection
(
CalendarSupport
::
KCalPrefs
::
instance
()
->
defaultCalendarId
());
if
(
!
collection
.
isValid
())
{
cout
<<
i18n
(
"Calendar is invalid. Please specify one with --calendar"
).
toLocal8Bit
().
data
()
<<
"
\n
"
;
...
...
@@ -166,13 +165,13 @@ bool KonsoleKalendarAdd::addImportedCalendar()
QEventLoop
loop
;
QObject
::
connect
(
calendar
.
data
(),
&
Akonadi
::
CalendarBase
::
createFinished
,
&
loop
,
&
QEventLoop
::
quit
);
&
loop
,
&
QEventLoop
::
quit
);
QElapsedTimer
t
;
foreach
(
const
auto
&
event
,
cal
->
rawEvents
())
{
foreach
(
const
auto
&
event
,
cal
->
rawEvents
())
{
if
(
calendar
->
incidence
(
event
->
uid
())
!=
0
)
{
if
(
m_variables
->
isVerbose
())
{
cout
<<
i18n
(
"Insert Event skipped, because UID
\"
%1
\"
is already known. <Verbose>"
,
event
->
uid
()).
toLocal8Bit
().
data
()
<<
endl
;
<<
endl
;
}
else
{
qCInfo
(
KONSOLEKALENDAR_LOG
)
<<
"Event with UID "
<<
event
->
uid
()
<<
"is already in calendar, skipping import of this Event."
;
}
...
...
@@ -180,7 +179,7 @@ bool KonsoleKalendarAdd::addImportedCalendar()
}
if
(
m_variables
->
isVerbose
())
{
cout
<<
i18n
(
"Add Event with UID
\"
%1
\"
. <Verbose>"
,
event
->
uid
()).
toLocal8Bit
().
data
()
<<
endl
;
<<
endl
;
}
if
(
m_variables
->
isDryRun
())
{
continue
;
...
...
@@ -194,8 +193,8 @@ bool KonsoleKalendarAdd::addImportedCalendar()
}
}
qCDebug
(
KONSOLEKALENDAR_LOG
)
<<
"konsolekalendaradd.cpp::importCalendar() |"
<<
"Successfully imported file:"
<<
m_variables
->
getImportFile
();
<<
"Successfully imported file:"
<<
m_variables
->
getImportFile
();
return
true
;
}
...
...
konsolekalendar/konsolekalendaradd.h
View file @
1ad0783c
...
...
@@ -74,6 +74,5 @@ private:
* Variable to how to make it
*/
KonsoleKalendarVariables
*
m_variables
=
nullptr
;
};
#endif
konsolekalendar/konsolekalendardelete.cpp
View file @
1ad0783c
...
...
@@ -39,7 +39,6 @@
#include
<KLocalizedString>
#include
<QEventLoop>
using
namespace
KCalCore
;
using
namespace
std
;
...
...
@@ -99,13 +98,13 @@ bool KonsoleKalendarDelete::deleteEvent()
void
KonsoleKalendarDelete
::
printSpecs
(
const
Event
::
Ptr
&
event
)
{
cout
<<
i18n
(
" UID: %1"
,
m_variables
->
getUID
()).
data
()
cout
<<
i18n
(
" UID: %1"
,
m_variables
->
getUID
()).
data
()
<<
endl
;
cout
<<
i18n
(
" What: %1"
,
event
->
summary
()).
data
()
<<
endl
;
const
auto
timeZone
=
m_variables
->
getCalendar
()
->
timeZone
();
const
auto
timeZone
=
m_variables
->
getCalendar
()
->
timeZone
();
cout
<<
i18n
(
" Begin: %1"
,
event
->
dtStart
().
toTimeZone
(
timeZone
).
toString
(
Qt
::
TextDate
)).
data
()
<<
endl
;
...
...
konsolekalendar/konsolekalendarepoch.cpp
View file @
1ad0783c
...
...
@@ -63,8 +63,8 @@ uint KonsoleKalendarEpoch::QDateTime2epoch(const QDateTime &dt)
// SORRY QT DOESN'T HANDLE DAYLIGHT SAVINGS TIME.
// Compute #seconds to subtract for local timezone difference from UTC.
int
offset
=
QDateTime
::
currentDateTime
().
toUTC
().
toTime_t
()
-
QDateTime
::
currentDateTime
().
toTime_t
();
int
offset
=
QDateTime
::
currentDateTime
().
toUTC
().
toTime_t
()
-
QDateTime
::
currentDateTime
().
toTime_t
();
return
dt
.
toTime_t
()
-
offset
;
}
...
...
konsolekalendar/konsolekalendarepoch.h
View file @
1ad0783c
...
...
@@ -64,7 +64,6 @@ public:
* @param dt is a QDateTime to convert to an epoch.
*/
static
uint
QDateTime2epoch
(
const
QDateTime
&
dt
);
};
#endif
konsolekalendar/konsolekalendarexports.cpp
View file @
1ad0783c
...
...
@@ -56,10 +56,8 @@ KonsoleKalendarExports::~KonsoleKalendarExports()
{
}
bool
KonsoleKalendarExports
::
exportAsTxt
(
QTextStream
*
ts
,
const
Event
::
Ptr
&
event
,
const
QDate
&
date
)
bool
KonsoleKalendarExports
::
exportAsTxt
(
QTextStream
*
ts
,
const
Event
::
Ptr
&
event
,
const
QDate
&
date
)
{
// Export "Text" Format:
//
// Date:\t<Incidence Date>(dddd yyyy-MM-dd)
...
...
@@ -144,11 +142,8 @@ bool KonsoleKalendarExports::exportAsTxt(QTextStream *ts,
return
true
;
}
bool
KonsoleKalendarExports
::
exportAsTxtShort
(
QTextStream
*
ts
,
const
Event
::
Ptr
&
event
,
const
QDate
&
date
,
bool
sameday
)
bool
KonsoleKalendarExports
::
exportAsTxtShort
(
QTextStream
*
ts
,
const
Event
::
Ptr
&
event
,
const
QDate
&
date
,
bool
sameday
)
{
// Export "Text-Short" Format:
//
// [--------------------------------------------------]
...
...
@@ -201,8 +196,7 @@ bool KonsoleKalendarExports::exportAsTxtShort(QTextStream *ts,
return
true
;
}
QString
KonsoleKalendarExports
::
processField
(
const
QString
&
field
,
const
QString
&
dquote
)
QString
KonsoleKalendarExports
::
processField
(
const
QString
&
field
,
const
QString
&
dquote
)
{
// little function that processes a field for CSV compliance:
// 1. Replaces double quotes by a pair of consecutive double quotes
...
...
@@ -215,13 +209,11 @@ QString KonsoleKalendarExports::processField(const QString &field,
}
//@cond IGNORE
#define pF(
x
) processField(
( x
), dquote
)
#define pF(
x
) processField(
(x
), dquote)
//@endcond
bool
KonsoleKalendarExports
::
exportAsCSV
(
QTextStream
*
ts
,
const
Event
::
Ptr
&
event
,
const
QDate
&
date
)
bool
KonsoleKalendarExports
::
exportAsCSV
(
QTextStream
*
ts
,
const
Event
::
Ptr
&
event
,
const
QDate
&
date
)
{
// Export "CSV" Format:
//
// startdate,starttime,enddate,endtime,summary,location,description,UID
...
...
konsolekalendar/konsolekalendarexports.h
View file @
1ad0783c
...
...
@@ -74,8 +74,7 @@ public:
* @param sameday flags that this Event is on the same date as the
* previously exported Event.
*/
bool
exportAsTxtShort
(
QTextStream
*
ts
,
const
KCalCore
::
Event
::
Ptr
&
event
,
const
QDate
&
date
,
bool
sameday
);
bool
exportAsTxtShort
(
QTextStream
*
ts
,
const
KCalCore
::
Event
::
Ptr
&
event
,
const
QDate
&
date
,
bool
sameday
);
/**
* Export the Event in Comma-Separated Values (CSV) Mode.
...
...
@@ -99,7 +98,6 @@ private:
* @param dquote is a QString containing the double quote character.
*/
QString
processField
(
const
QString
&
field
,
const
QString
&
dquote
);
};
#endif
konsolekalendar/main.cpp
View file @
1ad0783c
...
...
@@ -82,20 +82,20 @@ int main(int argc, char *argv[])
ki18n
(
0
),
// any free form text
progURL
,
// program home page address
"bugs.kde.org"
// bug report email address
);
);
aboutData
.
addAuthor
(
ki18n
(
"Allen Winter"
),
// developer's name
ki18n
(
"Maintainer"
),
// task or role
"winter@kde.org"
,
// email address
0
// home page or relevant link
);
);
aboutData
.
addAuthor
(
ki18n
(
"Tuukka Pasanen"
),
// developer's name
ki18n
(
"Author"
),
// task or role
"illuusio@mailcity.com"
,
// email address
0
// home page or relevant link
);
);
KCmdLineArgs
::
init
(
argc
,
argv
,
&
aboutData
,
KCmdLineArgs
::
CmdLineArgNone
);
...
...
@@ -178,8 +178,8 @@ int main(int argc, char *argv[])
"--description
\"
Get My Head Examined
\"\n
"
" konsolekalendar --delete --uid KOrganizer-1740326.803"
));
options
.
add
(
""
,
ki18n
(
"Without any options konsolekalendar will output today's events
\n
"
"from 7am to 5pm or nothing at all if there aren't any"
));
ki18n
(
"Without any options konsolekalendar will output today's events
\n
"
"from 7am to 5pm or nothing at all if there aren't any"
));
options
.
add
(
""
,
ki18n
(
"For more information visit the program home page at:
\n
"
" https://userbase.kde.org/KonsoleKalendar"
));
...
...
@@ -190,7 +190,7 @@ int main(int argc, char *argv[])
KApplication
app
(
// when not set (default) GUI is not enabled - disable all GUI stuff
args
->
isSet
(
"allow-gui"
)
);
);
// Default values for start date/time (today at 07:00)
QDate
startdate
=
QDate
::
currentDate
();
...
...
@@ -277,9 +277,9 @@ int main(int argc, char *argv[])
return
1
;
}
// Use Events if no incidence type is specified on the command line
if
(
!
args
->
isSet
(
"event"
)
&&
!
args
->
isSet
(
"todo"
)
&&
!
args
->
isSet
(
"journal"
))
{
if
(
!
args
->
isSet
(
"event"
)
&&
!
args
->
isSet
(
"todo"
)
&&
!
args
->
isSet
(
"journal"
))
{
variables
.
setUseEvents
(
true
);
qCDebug
(
KONSOLEKALENDAR_LOG
)
<<
"main | parse options | use Events (Default)"
;
}
...
...
@@ -597,7 +597,7 @@ int main(int argc, char *argv[])
<<
"Epoch start:"
<<
"("
<<
option
<<
")"
;
epochstart
=
(
time_t
)
option
.
toULong
(
0
,
10
);
epochstart
=
(
time_t
)
option
.
toULong
(
0
,
10
);
}
/*
...
...
@@ -611,7 +611,7 @@ int main(int argc, char *argv[])
<<
"Epoch end:"
<<
"("
<<
option
<<
")"
;
epochend
=
(
time_t
)
option
.
toULong
(
0
,
10
);
epochend
=
(
time_t
)
option
.
toULong
(
0
,
10
);
}
if
(
args
->
isSet
(
"all"
))
{
...
...
@@ -655,8 +655,8 @@ int main(int argc, char *argv[])
QDateTime
startdatetime
,
enddatetime
;
// Handle case with either date or end-date unspecified
if
(
!
args
->
isSet
(
"end-date"
)
&&
!
args
->
isSet
(
"show-next"
)
&&
args
->
isSet
(
"date"
))
{
if
(
!
args
->
isSet
(
"end-date"
)
&&
!
args
->
isSet
(
"show-next"
)
&&
args
->
isSet
(
"date"
))
{
enddate
=
startdate
;
qCDebug
(
KONSOLEKALENDAR_LOG
)
<<
"main | datetimestamp |"
<<
"setting enddate to startdate"
;
...
...
@@ -702,8 +702,8 @@ int main(int argc, char *argv[])
// Case:
// Time (or epoch) unspecified, and end-time (or epoch) unspecified.
if
(
!
args
->
isSet
(
"time"
)
&&
!
args
->
isSet
(
"epoch-start"
)
&&
!
args
->
isSet
(
"end-time"
)
&&
!
args
->
isSet
(
"epoch-end"
))
{
if
(
!
args
->
isSet
(
"time"
)
&&
!
args
->
isSet
(
"epoch-start"
)
&&
!
args
->
isSet
(
"end-time"
)
&&
!
args
->
isSet
(
"epoch-end"
))
{
// set default start date/time