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
KAlarm
Commits
bb140a1f
Commit
bb140a1f
authored
Oct 14, 2013
by
David Jarvie
Browse files
Don't detach QLists unnecessarily
parent
bae65b76
Changes
5
Hide whitespace changes
Inline
Side-by-side
alarmtext.cpp
View file @
bb140a1f
...
...
@@ -2,7 +2,7 @@
* alarmtext.cpp - text/email alarm text conversion
* This file is part of kalarmcal library, which provides access to KAlarm
* calendar data.
* Copyright © 2004,2005,2007-201
2
by David Jarvie <djarvie@kde.org>
* Copyright © 2004,2005,2007-201
3
by David Jarvie <djarvie@kde.org>
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
...
...
@@ -391,7 +391,7 @@ bool AlarmText::checkIfEmail(const QString& text)
*/
QString
AlarmText
::
emailHeaders
(
const
QString
&
text
,
bool
subjectOnly
)
{
QStringList
lines
=
text
.
split
(
'\n'
,
QString
::
SkipEmptyParts
);
const
QStringList
lines
=
text
.
split
(
'\n'
,
QString
::
SkipEmptyParts
);
int
n
=
Private
::
emailHeaderCount
(
lines
);
if
(
!
n
)
return
QString
();
...
...
@@ -415,7 +415,7 @@ QString AlarmText::emailHeaders(const QString& text, bool subjectOnly)
QString
AlarmText
::
fromCalendarText
(
const
QString
&
text
,
bool
&
email
)
{
Private
::
initialise
();
QStringList
lines
=
text
.
split
(
'\n'
,
QString
::
SkipEmptyParts
);
const
QStringList
lines
=
text
.
split
(
'\n'
,
QString
::
SkipEmptyParts
);
int
maxn
=
lines
.
count
();
if
(
maxn
>=
4
&&
lines
[
0
].
startsWith
(
Private
::
mFromPrefixEn
)
...
...
@@ -455,7 +455,7 @@ QString AlarmText::fromCalendarText(const QString& text, bool& email)
QString
AlarmText
::
toCalendarText
(
const
QString
&
text
)
{
Private
::
setUpTranslations
();
QStringList
lines
=
text
.
split
(
'\n'
,
QString
::
SkipEmptyParts
);
const
QStringList
lines
=
text
.
split
(
'\n'
,
QString
::
SkipEmptyParts
);
int
maxn
=
lines
.
count
();
if
(
maxn
>=
4
&&
lines
[
0
].
startsWith
(
Private
::
mFromPrefix
)
...
...
@@ -547,7 +547,7 @@ int AlarmText::Private::emailHeaderCount(const QStringList& lines)
QString
AlarmText
::
Private
::
todoTitle
(
const
QString
&
text
)
{
setUpTranslations
();
QStringList
lines
=
text
.
split
(
'\n'
,
QString
::
SkipEmptyParts
);
const
QStringList
lines
=
text
.
split
(
'\n'
,
QString
::
SkipEmptyParts
);
int
n
;
for
(
n
=
0
;
n
<
lines
.
count
()
&&
lines
[
n
].
contains
(
'\t'
);
++
n
)
;
if
(
!
n
||
n
>
3
)
...
...
kacalendar.cpp
View file @
bb140a1f
...
...
@@ -2,7 +2,7 @@
* kacalendar.cpp - KAlarm kcal library calendar and event functions
* This file is part of kalarmcal library, which provides access to KAlarm
* calendar data.
* Copyright © 2001-201
2
by David Jarvie <djarvie@kde.org>
* Copyright © 2001-201
3
by David Jarvie <djarvie@kde.org>
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
...
...
@@ -266,7 +266,7 @@ bool isUTC(const QString& localFile)
const
QByteArray
BEGIN_VCALENDAR
(
"BEGIN:VCALENDAR"
);
const
QByteArray
BEGIN_VEVENT
(
"BEGIN:VEVENT"
);
const
QByteArray
CREATED
(
"CREATED:"
);
QList
<
QByteArray
>
lines
=
text
.
split
(
'\n'
);
const
QList
<
QByteArray
>
lines
=
text
.
split
(
'\n'
);
for
(
int
i
=
0
,
end
=
lines
.
count
();
i
<
end
;
++
i
)
{
if
(
lines
[
i
].
startsWith
(
BEGIN_VCALENDAR
))
...
...
kaevent.cpp
View file @
bb140a1f
...
...
@@ -859,40 +859,42 @@ void KAEventPrivate::set(const Event* event)
flags
<<
QString
()
<<
QString
();
// to avoid having to check for end of list
for
(
int
i
=
0
,
end
=
flags
.
count
()
-
1
;
i
<
end
;
++
i
)
{
if
(
flags
[
i
]
==
DATE_ONLY_FLAG
)
QString
flag
=
flags
.
at
(
i
);
if
(
flag
==
DATE_ONLY_FLAG
)
dateOnly
=
true
;
else
if
(
flag
s
[
i
]
==
CONFIRM_ACK_FLAG
)
else
if
(
flag
==
CONFIRM_ACK_FLAG
)
mConfirmAck
=
true
;
else
if
(
flag
s
[
i
]
==
EMAIL_BCC_FLAG
)
else
if
(
flag
==
EMAIL_BCC_FLAG
)
mEmailBcc
=
true
;
else
if
(
flag
s
[
i
]
==
KORGANIZER_FLAG
)
else
if
(
flag
==
KORGANIZER_FLAG
)
mCopyToKOrganizer
=
true
;
else
if
(
flag
s
[
i
]
==
EXCLUDE_HOLIDAYS_FLAG
)
else
if
(
flag
==
EXCLUDE_HOLIDAYS_FLAG
)
mExcludeHolidays
=
mHolidays
;
else
if
(
flag
s
[
i
]
==
WORK_TIME_ONLY_FLAG
)
else
if
(
flag
==
WORK_TIME_ONLY_FLAG
)
mWorkTimeOnly
=
1
;
else
if
(
flag
s
[
i
]
==
KMAIL_SERNUM_FLAG
)
else
if
(
flag
==
KMAIL_SERNUM_FLAG
)
{
const
unsigned
long
n
=
flags
[
i
+
1
]
.
toULong
(
&
ok
);
const
unsigned
long
n
=
flags
.
at
(
i
+
1
)
.
toULong
(
&
ok
);
if
(
!
ok
)
continue
;
mKMailSerialNumber
=
n
;
++
i
;
}
else
if
(
flag
s
[
i
]
==
KAEventPrivate
::
ARCHIVE_FLAG
)
else
if
(
flag
==
KAEventPrivate
::
ARCHIVE_FLAG
)
mArchive
=
true
;
else
if
(
flag
s
[
i
]
==
KAEventPrivate
::
AT_LOGIN_TYPE
)
else
if
(
flag
==
KAEventPrivate
::
AT_LOGIN_TYPE
)
mArchiveRepeatAtLogin
=
true
;
else
if
(
flag
s
[
i
]
==
KAEventPrivate
::
REMINDER_TYPE
)
else
if
(
flag
==
KAEventPrivate
::
REMINDER_TYPE
)
{
if
(
flags
[
++
i
]
==
KAEventPrivate
::
REMINDER_ONCE_FLAG
)
flag
=
flags
.
at
(
++
i
);
if
(
flag
==
KAEventPrivate
::
REMINDER_ONCE_FLAG
)
{
mReminderOnceOnly
=
true
;
++
i
;
}
const
int
len
=
flag
s
[
i
]
.
length
()
-
1
;
mReminderMinutes
=
-
flag
s
[
i
]
.
left
(
len
).
toInt
();
// -> 0 if conversion fails
switch
(
flag
s
[
i
]
.
at
(
len
).
toLatin1
())
const
int
len
=
flag
.
length
()
-
1
;
mReminderMinutes
=
-
flag
.
left
(
len
).
toInt
();
// -> 0 if conversion fails
switch
(
flag
.
at
(
len
).
toLatin1
())
{
case
'M'
:
break
;
case
'H'
:
mReminderMinutes
*=
60
;
break
;
...
...
@@ -900,9 +902,9 @@ void KAEventPrivate::set(const Event* event)
default:
mReminderMinutes
=
0
;
break
;
}
}
else
if
(
flag
s
[
i
]
==
DEFER_FLAG
)
else
if
(
flag
==
DEFER_FLAG
)
{
QString
mins
=
flags
[
i
+
1
]
;
QString
mins
=
flags
.
at
(
i
+
1
)
;
if
(
mins
.
endsWith
(
'D'
))
{
mDeferDefaultDateOnly
=
true
;
...
...
@@ -914,25 +916,25 @@ void KAEventPrivate::set(const Event* event)
mDeferDefaultMinutes
=
n
;
++
i
;
}
else
if
(
flag
s
[
i
]
==
TEMPL_AFTER_TIME_FLAG
)
else
if
(
flag
==
TEMPL_AFTER_TIME_FLAG
)
{
const
int
n
=
static_cast
<
int
>
(
flags
[
i
+
1
]
.
toUInt
(
&
ok
));
const
int
n
=
static_cast
<
int
>
(
flags
.
at
(
i
+
1
)
.
toUInt
(
&
ok
));
if
(
!
ok
)
continue
;
mTemplateAfterTime
=
n
;
++
i
;
}
else
if
(
flag
s
[
i
]
==
LATE_CANCEL_FLAG
)
else
if
(
flag
==
LATE_CANCEL_FLAG
)
{
mLateCancel
=
static_cast
<
int
>
(
flags
[
i
+
1
]
.
toUInt
(
&
ok
));
mLateCancel
=
static_cast
<
int
>
(
flags
.
at
(
i
+
1
)
.
toUInt
(
&
ok
));
if
(
ok
)
++
i
;
if
(
!
ok
||
!
mLateCancel
)
mLateCancel
=
1
;
// invalid parameter defaults to 1 minute
}
else
if
(
flag
s
[
i
]
==
AUTO_CLOSE_FLAG
)
else
if
(
flag
==
AUTO_CLOSE_FLAG
)
{
mLateCancel
=
static_cast
<
int
>
(
flags
[
i
+
1
]
.
toUInt
(
&
ok
));
mLateCancel
=
static_cast
<
int
>
(
flags
.
at
(
i
+
1
)
.
toUInt
(
&
ok
));
if
(
ok
)
++
i
;
if
(
!
ok
||
!
mLateCancel
)
...
...
@@ -4187,7 +4189,7 @@ DateTime KAEventPrivate::readDateTime(const Event* event, bool dateOnly, DateTim
start
.
setDateOnly
(
true
);
}
DateTime
next
=
start
;
QString
prop
=
event
->
customProperty
(
KACalendar
::
APPNAME
,
KAEventPrivate
::
NEXT_RECUR_PROPERTY
);
const
QString
prop
=
event
->
customProperty
(
KACalendar
::
APPNAME
,
KAEventPrivate
::
NEXT_RECUR_PROPERTY
);
if
(
prop
.
length
()
>=
8
)
{
// The next due recurrence time is specified
...
...
@@ -4223,7 +4225,7 @@ void KAEventPrivate::readAlarms(const Event* event, void* almap, bool cmdDisplay
#endif
{
AlarmMap
*
alarmMap
=
(
AlarmMap
*
)
almap
;
Alarm
::
List
alarms
=
event
->
alarms
();
const
Alarm
::
List
alarms
=
event
->
alarms
();
// Check if it's an audio event with no display alarm
bool
audioOnly
=
false
;
...
...
@@ -5362,7 +5364,7 @@ bool KAEvent::convertKCalEvents(CalendarLocal& calendar, int calendarVersion)
bool
deferral
=
false
;
bool
lateCancel
=
false
;
KAAlarm
::
Action
action
=
KAAlarm
::
MESSAGE
;
QString
txt
=
alarm
->
text
();
const
QString
txt
=
alarm
->
text
();
const
int
length
=
txt
.
length
();
int
i
=
0
;
if
(
txt
[
0
].
isDigit
())
...
...
@@ -5400,7 +5402,7 @@ bool KAEvent::convertKCalEvents(CalendarLocal& calendar, int calendarVersion)
}
else
i
=
0
;
txt
=
txt
.
mid
(
i
);
const
QString
al
txt
=
txt
.
mid
(
i
);
QStringList
types
;
switch
(
action
)
...
...
@@ -5409,10 +5411,10 @@ bool KAEvent::convertKCalEvents(CalendarLocal& calendar, int calendarVersion)
types
+=
KAEventPrivate
::
FILE_TYPE
;
// fall through to MESSAGE
case
KAAlarm
::
MESSAGE
:
alarm
->
setDisplayAlarm
(
txt
);
alarm
->
setDisplayAlarm
(
al
txt
);
break
;
case
KAAlarm
::
COMMAND
:
setProcedureAlarm
(
alarm
,
txt
);
setProcedureAlarm
(
alarm
,
al
txt
);
break
;
case
KAAlarm
::
EMAIL
:
// email alarms were introduced in KAlarm 0.9
case
KAAlarm
::
AUDIO
:
// audio alarms (with no display) were introduced in KAlarm 2.3.2
...
...
@@ -5504,14 +5506,14 @@ bool KAEvent::convertKCalEvents(CalendarLocal& calendar, int calendarVersion)
#endif
if
(
alarm
->
type
()
==
Alarm
::
Display
)
alarm
->
setCustomProperty
(
KACalendar
::
APPNAME
,
KAEventPrivate
::
FONT_COLOUR_PROPERTY
,
QString
::
fromLatin1
(
"%1;;"
).
arg
(
cats
[
0
]
));
QString
::
fromLatin1
(
"%1;;"
).
arg
(
cats
.
at
(
0
)
));
}
cats
.
removeAt
(
0
);
}
for
(
int
i
=
0
,
end
=
cats
.
count
();
i
<
end
;
++
i
)
{
if
(
cats
[
i
]
==
BEEP_CATEGORY
)
if
(
cats
.
at
(
i
)
==
BEEP_CATEGORY
)
{
cats
.
removeAt
(
i
);
...
...
@@ -5614,7 +5616,7 @@ bool KAEvent::convertKCalEvents(CalendarLocal& calendar, int calendarVersion)
CalEvent
::
setStatus
(
event
,
CalEvent
::
status
(
event
));
for
(
int
i
=
0
;
i
<
cats
.
count
();
)
{
QString
cat
=
cats
[
i
]
;
const
QString
cat
=
cats
.
at
(
i
)
;
if
(
cat
==
DATE_ONLY_CATEGORY
)
flags
+=
KAEventPrivate
::
DATE_ONLY_FLAG
;
else
if
(
cat
==
CONFIRM_ACK_CATEGORY
)
...
...
@@ -5701,7 +5703,7 @@ bool KAEvent::convertKCalEvents(CalendarLocal& calendar, int calendarVersion)
// - DISPLAYING_TYPE
bool
mainAlarm
=
true
;
QString
property
=
alarm
->
customProperty
(
KACalendar
::
APPNAME
,
KAEventPrivate
::
TYPE_PROPERTY
);
QStringList
types
=
property
.
split
(
QChar
(
','
),
QString
::
SkipEmptyParts
);
const
QStringList
types
=
property
.
split
(
QChar
(
','
),
QString
::
SkipEmptyParts
);
for
(
int
t
=
0
;
t
<
types
.
count
();
++
t
)
{
QString
type
=
types
[
t
];
...
...
karecurrence.cpp
View file @
bb140a1f
...
...
@@ -2,7 +2,7 @@
* karecurrence.cpp - recurrence with special yearly February 29th handling
* This file is part of kalarmcal library, which provides access to KAlarm
* calendar data.
* Copyright © 2005-201
2
by David Jarvie <djarvie@kde.org>
* Copyright © 2005-201
3
by David Jarvie <djarvie@kde.org>
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
...
...
@@ -317,7 +317,7 @@ void KARecurrence::Private::fix()
int
convert
=
0
;
int
days
[
2
]
=
{
0
,
0
};
RecurrenceRule
*
rrules
[
2
];
RecurrenceRule
::
List
rrulelist
=
mRecurrence
.
rRules
();
const
RecurrenceRule
::
List
rrulelist
=
mRecurrence
.
rRules
();
int
rri
=
0
;
int
rrend
=
rrulelist
.
count
();
for
(
int
i
=
0
;
i
<
2
&&
rri
<
rrend
;
++
i
,
++
rri
)
...
...
@@ -860,11 +860,11 @@ bool KARecurrence::recursOn(const QDate& dt, const KDateTime::Spec& timeSpec) co
// so we just need to check if it's in RDATES or RRULES
if
(
d
->
mRecurrence
.
rDates
().
contains
(
dt
))
return
true
;
RecurrenceRule
::
List
rulelist
=
d
->
mRecurrence
.
rRules
();
const
RecurrenceRule
::
List
rulelist
=
d
->
mRecurrence
.
rRules
();
for
(
int
rri
=
0
,
rrend
=
rulelist
.
count
();
rri
<
rrend
;
++
rri
)
if
(
rulelist
[
rri
]
->
recursOn
(
dt
,
timeSpec
))
return
true
;
DateTimeList
dtlist
=
d
->
mRecurrence
.
rDateTimes
();
const
DateTimeList
dtlist
=
d
->
mRecurrence
.
rDateTimes
();
for
(
int
dti
=
0
,
dtend
=
dtlist
.
count
();
dti
<
dtend
;
++
dti
)
if
(
dtlist
[
dti
].
date
()
==
dt
)
return
true
;
...
...
@@ -1005,7 +1005,7 @@ Duration KARecurrence::longestInterval() const
case
DAILY
:
{
QList
<
RecurrenceRule
::
WDayPos
>
days
=
d
->
mRecurrence
.
defaultRRuleConst
()
->
byDays
();
const
QList
<
RecurrenceRule
::
WDayPos
>
days
=
d
->
mRecurrence
.
defaultRRuleConst
()
->
byDays
();
if
(
days
.
isEmpty
())
return
Duration
(
freq
,
Duration
::
Days
);
...
...
@@ -1137,7 +1137,7 @@ Duration KARecurrence::regularInterval() const
return
Duration
(
freq
*
60
,
Duration
::
Seconds
);
case
DAILY
:
{
QList
<
RecurrenceRule
::
WDayPos
>
days
=
d
->
mRecurrence
.
defaultRRuleConst
()
->
byDays
();
const
QList
<
RecurrenceRule
::
WDayPos
>
days
=
d
->
mRecurrence
.
defaultRRuleConst
()
->
byDays
();
if
(
days
.
isEmpty
())
return
Duration
(
freq
,
Duration
::
Days
);
// After applying the frequency, the specified days of the week
...
...
@@ -1167,7 +1167,7 @@ Duration KARecurrence::regularInterval() const
}
case
WEEKLY
:
{
QList
<
RecurrenceRule
::
WDayPos
>
days
=
d
->
mRecurrence
.
defaultRRuleConst
()
->
byDays
();
const
QList
<
RecurrenceRule
::
WDayPos
>
days
=
d
->
mRecurrence
.
defaultRRuleConst
()
->
byDays
();
if
(
days
.
isEmpty
())
return
Duration
(
freq
*
7
,
Duration
::
Days
);
// The specified days of the week occur every week in which the
...
...
@@ -1283,7 +1283,7 @@ bool KARecurrence::dailyType(const RecurrenceRule* rrule)
||
!
rrule
->
bySetPos
().
isEmpty
()
||
!
rrule
->
byYearDays
().
isEmpty
())
return
false
;
QList
<
RecurrenceRule
::
WDayPos
>
days
=
rrule
->
byDays
();
const
QList
<
RecurrenceRule
::
WDayPos
>
days
=
rrule
->
byDays
();
if
(
days
.
isEmpty
())
return
true
;
// Check that all the positions are zero (i.e. every time)
...
...
version.cpp
View file @
bb140a1f
...
...
@@ -2,7 +2,7 @@
* version.cpp - program version functions
* This file is part of kalarmcal library, which provides access to KAlarm
* calendar data.
* Copyright © 2002-2007,2011 by David Jarvie <djarvie@kde.org>
* Copyright © 2002-2007,2011
,2013
by David Jarvie <djarvie@kde.org>
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
...
...
@@ -56,7 +56,7 @@ int getVersionNumber(const QString& version, QString* subVersion)
if
(
count
>=
3
)
{
// Issue number: allow other characters to follow the last digit
QString
issue
=
version
.
section
(
'.'
,
2
);
const
QString
issue
=
version
.
section
(
'.'
,
2
);
int
n
=
issue
.
length
();
if
(
!
n
||
!
issue
[
0
].
isDigit
())
return
0
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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