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
KAlarm
Commits
8343246d
Commit
8343246d
authored
Sep 10, 2014
by
David Jarvie
Browse files
Constify local variables
parent
147212b1
Changes
7
Hide whitespace changes
Inline
Side-by-side
alarmtext.cpp
View file @
8343246d
...
...
@@ -379,7 +379,7 @@ QString AlarmText::summary(const KAEvent& event, int maxLines, bool* truncated)
*/
bool
AlarmText
::
checkIfEmail
(
const
QString
&
text
)
{
QStringList
lines
=
text
.
split
(
QLatin1Char
(
'\n'
),
QString
::
SkipEmptyParts
);
const
QStringList
lines
=
text
.
split
(
QLatin1Char
(
'\n'
),
QString
::
SkipEmptyParts
);
return
Private
::
emailHeaderCount
(
lines
);
}
...
...
@@ -391,7 +391,7 @@ bool AlarmText::checkIfEmail(const QString& text)
QString
AlarmText
::
emailHeaders
(
const
QString
&
text
,
bool
subjectOnly
)
{
const
QStringList
lines
=
text
.
split
(
QLatin1Char
(
'\n'
),
QString
::
SkipEmptyParts
);
int
n
=
Private
::
emailHeaderCount
(
lines
);
const
int
n
=
Private
::
emailHeaderCount
(
lines
);
if
(
!
n
)
return
QString
();
if
(
subjectOnly
)
...
...
@@ -415,7 +415,7 @@ QString AlarmText::fromCalendarText(const QString& text, bool& email)
{
Private
::
initialise
();
const
QStringList
lines
=
text
.
split
(
QLatin1Char
(
'\n'
),
QString
::
SkipEmptyParts
);
int
maxn
=
lines
.
count
();
const
int
maxn
=
lines
.
count
();
if
(
maxn
>=
4
&&
lines
[
0
].
startsWith
(
Private
::
mFromPrefixEn
)
&&
lines
[
1
].
startsWith
(
Private
::
mToPrefixEn
))
...
...
@@ -455,7 +455,7 @@ QString AlarmText::toCalendarText(const QString& text)
{
Private
::
setUpTranslations
();
const
QStringList
lines
=
text
.
split
(
QLatin1Char
(
'\n'
),
QString
::
SkipEmptyParts
);
int
maxn
=
lines
.
count
();
const
int
maxn
=
lines
.
count
();
if
(
maxn
>=
4
&&
lines
[
0
].
startsWith
(
Private
::
mFromPrefix
)
&&
lines
[
1
].
startsWith
(
Private
::
mToPrefix
))
...
...
@@ -524,7 +524,7 @@ void AlarmText::Private::setUpTranslations()
int
AlarmText
::
Private
::
emailHeaderCount
(
const
QStringList
&
lines
)
{
setUpTranslations
();
int
maxn
=
lines
.
count
();
const
int
maxn
=
lines
.
count
();
if
(
maxn
>=
4
&&
lines
[
0
].
startsWith
(
mFromPrefix
)
&&
lines
[
1
].
startsWith
(
mToPrefix
))
...
...
collectionattribute.cpp
View file @
8343246d
...
...
@@ -206,7 +206,7 @@ void CollectionAttribute::deserialize(const QByteArray& data)
bool
ok
;
int
c
[
4
];
const
QList
<
QByteArray
>
items
=
data
.
simplified
().
split
(
' '
);
int
count
=
items
.
count
();
const
int
count
=
items
.
count
();
int
index
=
0
;
if
(
count
>
index
)
{
...
...
compatibilityattribute.cpp
View file @
8343246d
...
...
@@ -102,8 +102,8 @@ QByteArray CompatibilityAttribute::name()
QByteArray
CompatibilityAttribute
::
serialized
()
const
{
QByteArray
v
=
QByteArray
::
number
(
d
->
mCompatibility
)
+
' '
+
QByteArray
::
number
(
d
->
mVersion
);
const
QByteArray
v
=
QByteArray
::
number
(
d
->
mCompatibility
)
+
' '
+
QByteArray
::
number
(
d
->
mVersion
);
kDebug
()
<<
v
;
return
v
;
}
...
...
@@ -118,13 +118,13 @@ void CompatibilityAttribute::deserialize(const QByteArray& data)
bool
ok
;
const
QList
<
QByteArray
>
items
=
data
.
simplified
().
split
(
' '
);
int
count
=
items
.
count
();
const
int
count
=
items
.
count
();
int
index
=
0
;
if
(
count
>
index
)
{
// 0: calendar format compatibility
int
c
=
items
[
index
++
].
toInt
(
&
ok
);
KACalendar
::
Compat
AllCompat
(
KACalendar
::
Current
|
KACalendar
::
Converted
|
KACalendar
::
Convertible
|
KACalendar
::
Incompatible
|
KACalendar
::
Unknown
);
const
int
c
=
items
[
index
++
].
toInt
(
&
ok
);
const
KACalendar
::
Compat
AllCompat
(
KACalendar
::
Current
|
KACalendar
::
Converted
|
KACalendar
::
Convertible
|
KACalendar
::
Incompatible
|
KACalendar
::
Unknown
);
if
(
!
ok
||
(
c
&
AllCompat
)
!=
c
)
{
kError
()
<<
"Invalid compatibility:"
<<
c
;
...
...
@@ -135,7 +135,7 @@ void CompatibilityAttribute::deserialize(const QByteArray& data)
if
(
count
>
index
)
{
// 1: KAlarm calendar version number
int
c
=
items
[
index
++
].
toInt
(
&
ok
);
const
int
c
=
items
[
index
++
].
toInt
(
&
ok
);
if
(
!
ok
)
{
kError
()
<<
"Invalid version:"
<<
c
;
...
...
eventattribute.cpp
View file @
8343246d
...
...
@@ -84,7 +84,7 @@ EventAttribute* EventAttribute::clone() const
QByteArray
EventAttribute
::
serialized
()
const
{
QByteArray
v
=
QByteArray
::
number
(
d
->
mCommandError
);
const
QByteArray
v
=
QByteArray
::
number
(
d
->
mCommandError
);
kDebug
()
<<
v
;
return
v
;
}
...
...
kacalendar.cpp
View file @
8343246d
...
...
@@ -131,9 +131,9 @@ int updateVersion(CalendarLocal& calendar, const QString& localFile, QString& ve
{
QString
subVersion
;
#ifndef KALARMCAL_USE_KRESOURCES
int
version
=
Private
::
readKAlarmVersion
(
fileStorage
,
subVersion
,
versionString
);
const
int
version
=
Private
::
readKAlarmVersion
(
fileStorage
,
subVersion
,
versionString
);
#else
int
version
=
Private
::
readKAlarmVersion
(
calendar
,
localFile
,
subVersion
,
versionString
);
const
int
version
=
Private
::
readKAlarmVersion
(
calendar
,
localFile
,
subVersion
,
versionString
);
#endif
if
(
version
==
CurrentFormat
)
return
CurrentFormat
;
// calendar is in the current KAlarm format
...
...
@@ -205,9 +205,9 @@ int Private::readKAlarmVersion(CalendarLocal& calendar, const QString& localFile
// Check whether the calendar file is empty, in which case
// it can be written to freely.
#ifndef KALARMCAL_USE_KRESOURCES
QFileInfo
fi
(
fileStorage
->
fileName
());
const
QFileInfo
fi
(
fileStorage
->
fileName
());
#else
QFileInfo
fi
(
localFile
);
const
QFileInfo
fi
(
localFile
);
#endif
if
(
!
fi
.
size
())
return
KACalendar
::
CurrentFormat
;
...
...
@@ -229,7 +229,7 @@ int Private::readKAlarmVersion(CalendarLocal& calendar, const QString& localFile
// Extract the KAlarm version string
versionString
=
prodid
.
mid
(
i
+
progname
.
length
()).
trimmed
();
i
=
versionString
.
indexOf
(
QLatin1Char
(
'/'
));
int
j
=
versionString
.
indexOf
(
QLatin1Char
(
' '
));
const
int
j
=
versionString
.
indexOf
(
QLatin1Char
(
' '
));
if
(
j
>=
0
&&
j
<
i
)
i
=
j
;
if
(
i
<=
0
)
...
...
@@ -238,7 +238,7 @@ int Private::readKAlarmVersion(CalendarLocal& calendar, const QString& localFile
}
if
(
versionString
==
QLatin1String
(
KAEvent
::
currentCalendarVersionString
()))
return
KACalendar
::
CurrentFormat
;
// the calendar is in the current KAlarm format
int
ver
=
KAlarmCal
::
getVersionNumber
(
versionString
,
&
subVersion
);
const
int
ver
=
KAlarmCal
::
getVersionNumber
(
versionString
,
&
subVersion
);
if
(
ver
==
KAEvent
::
currentCalendarVersion
())
return
KACalendar
::
CurrentFormat
;
// the calendar is in the current KAlarm format
return
KAlarmCal
::
getVersionNumber
(
versionString
,
&
subVersion
);
...
...
@@ -258,7 +258,7 @@ bool isUTC(const QString& localFile)
return
false
;
QTextStream
ts
(
&
file
);
ts
.
setCodec
(
"ISO 8859-1"
);
QByteArray
text
=
ts
.
readAll
().
toLocal8Bit
();
const
QByteArray
text
=
ts
.
readAll
().
toLocal8Bit
();
file
.
close
();
// Extract the CREATED property for the first VEVENT from the calendar
...
...
@@ -401,7 +401,7 @@ Type status(const Event* event, QString* param)
param
->
clear
();
if
(
!
event
)
return
EMPTY
;
Alarm
::
List
alarms
=
event
->
alarms
();
const
Alarm
::
List
alarms
=
event
->
alarms
();
if
(
alarms
.
isEmpty
())
return
EMPTY
;
...
...
@@ -413,7 +413,7 @@ Type status(const Event* event, QString* param)
PropertyMap
::
ConstIterator
it
=
properties
.
constFind
(
property
);
if
(
it
!=
properties
.
constEnd
())
return
it
.
value
();
int
i
=
property
.
indexOf
(
QLatin1Char
(
';'
));
const
int
i
=
property
.
indexOf
(
QLatin1Char
(
';'
));
if
(
i
<
0
)
return
EMPTY
;
it
=
properties
.
constFind
(
property
.
left
(
i
));
...
...
@@ -426,7 +426,7 @@ Type status(const Event* event, QString* param)
// The event either wasn't written by KAlarm, or was written by a pre-2.0 version.
// Check first for an old KAlarm format, which indicated the event type in its UID.
QString
uid
=
event
->
uid
();
const
QString
uid
=
event
->
uid
();
if
(
uid
.
indexOf
(
staticStrings
->
ARCHIVED_UID
)
>
0
)
return
ARCHIVED
;
if
(
uid
.
indexOf
(
staticStrings
->
TEMPLATE_UID
)
>
0
)
...
...
karecurrence.cpp
View file @
8343246d
...
...
@@ -218,10 +218,10 @@ bool KARecurrence::Private::init(RecurrenceRule::PeriodType recurType, int freq,
const
KDateTime
&
end
)
{
clear
();
Feb29Type
feb29Type
=
(
f29
==
-
1
)
?
mDefaultFeb29
:
static_cast
<
Feb29Type
>
(
f29
);
const
Feb29Type
feb29Type
=
(
f29
==
-
1
)
?
mDefaultFeb29
:
static_cast
<
Feb29Type
>
(
f29
);
if
(
count
<
-
1
)
return
false
;
bool
dateOnly
=
start
.
isDateOnly
();
const
bool
dateOnly
=
start
.
isDateOnly
();
if
(
!
count
&&
((
!
dateOnly
&&
!
end
.
isValid
())
||
(
dateOnly
&&
!
end
.
date
().
isValid
())))
return
false
;
...
...
@@ -274,7 +274,7 @@ bool KARecurrence::Private::init(RecurrenceRule::PeriodType recurType, int freq,
*/
bool
KARecurrence
::
set
(
const
QString
&
icalRRULE
)
{
static
QString
RRULE
=
QLatin1String
(
"RRULE:"
);
static
const
QString
RRULE
=
QLatin1String
(
"RRULE:"
);
d
->
clear
();
if
(
icalRRULE
.
isEmpty
())
return
true
;
...
...
@@ -314,14 +314,13 @@ void KARecurrence::Private::fix()
RecurrenceRule
*
rrules
[
2
];
const
RecurrenceRule
::
List
rrulelist
=
mRecurrence
.
rRules
();
int
rri
=
0
;
int
rrend
=
rrulelist
.
count
();
const
int
rrend
=
rrulelist
.
count
();
for
(
int
i
=
0
;
i
<
2
&&
rri
<
rrend
;
++
i
,
++
rri
)
{
RecurrenceRule
*
rrule
=
rrulelist
[
rri
];
rrules
[
i
]
=
rrule
;
bool
stop
=
true
;
int
rtype
=
mRecurrence
.
recurrenceType
(
rrule
);
switch
(
rtype
)
switch
(
mRecurrence
.
recurrenceType
(
rrule
))
{
case
Recurrence
::
rHourly
:
// Convert an hourly recurrence to a minutely one
...
...
@@ -356,7 +355,7 @@ void KARecurrence::Private::fix()
||
rrule
->
startDt
()
!=
rrules
[
0
]
->
startDt
())
break
;
}
QList
<
int
>
ds
=
rrule
->
byYearDays
();
const
QList
<
int
>
ds
=
rrule
->
byYearDays
();
if
(
!
ds
.
isEmpty
()
&&
ds
.
first
()
==
60
)
{
++
convert
;
// this rule needs to be converted
...
...
@@ -390,7 +389,7 @@ void KARecurrence::Private::fix()
if
(
day
==
-
1
)
{
// Last day of the month - only combine if it's February
QList
<
int
>
months
=
rrule
->
byMonths
();
const
QList
<
int
>
months
=
rrule
->
byMonths
();
if
(
months
.
count
()
!=
1
||
months
.
first
()
!=
2
)
day
=
0
;
}
...
...
@@ -431,7 +430,7 @@ void KARecurrence::Private::fix()
RecurrenceRule
*
rr
=
rrules
[
0
];
rrules
[
0
]
=
rrules
[
1
];
// the 29th rule
rrules
[
1
]
=
rr
;
int
d
=
days
[
0
];
const
int
d
=
days
[
0
];
days
[
0
]
=
days
[
1
];
days
[
1
]
=
d
;
// the non-29th day
}
...
...
@@ -513,10 +512,10 @@ void KARecurrence::Private::writeRecurrence(const KARecurrence* q, Recurrence& r
break
;
case
ANNUAL_DATE
:
{
QList
<
int
>
months
=
rrule
->
byMonths
();
QList
<
int
>
days
=
mRecurrence
.
monthDays
();
bool
special
=
(
mFeb29Type
!=
Feb29_None
&&
!
days
.
isEmpty
()
&&
days
.
first
()
==
29
&&
months
.
removeAll
(
2
));
QList
<
int
>
months
=
rrule
->
byMonths
();
const
QList
<
int
>
days
=
mRecurrence
.
monthDays
();
const
bool
special
=
(
mFeb29Type
!=
Feb29_None
&&
!
days
.
isEmpty
()
&&
days
.
first
()
==
29
&&
months
.
removeAll
(
2
));
RecurrenceRule
*
rrule1
=
recur
.
defaultRRule
();
rrule1
->
setByMonths
(
months
);
rrule1
->
setByMonthDays
(
days
);
...
...
@@ -575,15 +574,15 @@ void KARecurrence::Private::writeRecurrence(const KARecurrence* q, Recurrence& r
* all. In that case, retain it so that the February 29th characteristic
* is not lost should the user later change the recurrence count.
*/
KDateTime
end
=
endDateTime
();
int
count1
=
rrule1
->
durationTo
(
end
)
-
(
rrule1
->
recursOn
(
mRecurrence
.
startDate
(),
mRecurrence
.
startDateTime
().
timeSpec
())
?
0
:
1
);
const
KDateTime
end
=
endDateTime
();
const
int
count1
=
rrule1
->
durationTo
(
end
)
-
(
rrule1
->
recursOn
(
mRecurrence
.
startDate
(),
mRecurrence
.
startDateTime
().
timeSpec
())
?
0
:
1
);
if
(
count1
>
0
)
rrule1
->
setDuration
(
count1
);
else
rrule1
->
setEndDt
(
mRecurrence
.
startDateTime
());
int
count2
=
rrule2
->
durationTo
(
end
)
-
(
rrule2
->
recursOn
(
mRecurrence
.
startDate
(),
mRecurrence
.
startDateTime
().
timeSpec
())
?
0
:
1
);
const
int
count2
=
rrule2
->
durationTo
(
end
)
-
(
rrule2
->
recursOn
(
mRecurrence
.
startDate
(),
mRecurrence
.
startDateTime
().
timeSpec
())
?
0
:
1
);
if
(
count2
>
0
)
rrule2
->
setDuration
(
count2
);
else
...
...
@@ -951,7 +950,7 @@ int KARecurrence::Private::combineDurations(const RecurrenceRule* rrule1, const
// Swap the two rules to make rr1 have the earlier end date
rr1
=
rrule2
;
rr2
=
rrule1
;
KDateTime
e
=
end1
;
const
KDateTime
e
=
end1
;
end1
=
end2
;
end2
=
e
;
}
...
...
@@ -978,7 +977,7 @@ int KARecurrence::Private::combineDurations(const RecurrenceRule* rrule1, const
end
=
end2
.
date
();
return
count1
+
count2
;
}
QDate
prev2
=
rr2
->
getPreviousDate
(
next1
).
date
();
const
QDate
prev2
=
rr2
->
getPreviousDate
(
next1
).
date
();
end
=
(
prev2
>
end1
.
date
())
?
prev2
:
end1
.
date
();
}
if
(
count2
)
...
...
@@ -992,7 +991,7 @@ int KARecurrence::Private::combineDurations(const RecurrenceRule* rrule1, const
*/
Duration
KARecurrence
::
longestInterval
()
const
{
int
freq
=
d
->
mRecurrence
.
frequency
();
const
int
freq
=
d
->
mRecurrence
.
frequency
();
switch
(
type
())
{
case
MINUTELY
:
...
...
@@ -1029,7 +1028,7 @@ Duration KARecurrence::longestInterval() const
last
=
i
;
}
}
int
wrap
=
freq
*
7
-
last
+
first
;
const
int
wrap
=
freq
*
7
-
last
+
first
;
if
(
wrap
>
maxgap
)
maxgap
=
wrap
;
return
Duration
(
maxgap
,
Duration
::
Days
);
...
...
@@ -1047,13 +1046,13 @@ Duration KARecurrence::longestInterval() const
{
// Find which days of the week it recurs on, and if on more than
// one, reduce the maximum interval accordingly.
QBitArray
ds
=
d
->
mRecurrence
.
days
();
const
QBitArray
ds
=
d
->
mRecurrence
.
days
();
int
first
=
-
1
;
int
last
=
-
1
;
int
maxgap
=
1
;
// Use the user's definition of the week, starting at the
// day of the week specified by the user's locale.
int
weekStart
=
KGlobal
::
locale
()
->
weekStartDay
()
-
1
;
// zero-based
const
int
weekStart
=
KGlobal
::
locale
()
->
weekStartDay
()
-
1
;
// zero-based
for
(
int
i
=
0
;
i
<
7
;
++
i
)
{
// Get the standard KDE day-of-week number (zero-based)
...
...
@@ -1069,7 +1068,7 @@ Duration KARecurrence::longestInterval() const
}
if
(
first
<
0
)
break
;
// no days recur
int
span
=
last
-
first
;
const
int
span
=
last
-
first
;
if
(
freq
>
1
)
return
Duration
(
freq
*
7
-
span
,
Duration
::
Days
);
if
(
7
-
span
>
maxgap
)
...
...
@@ -1099,13 +1098,13 @@ Duration KARecurrence::longestInterval() const
first
=
months
[
i
];
else
{
int
span
=
QDate
(
2001
,
last
,
1
).
daysTo
(
QDate
(
2001
,
months
[
i
],
1
));
const
int
span
=
QDate
(
2001
,
last
,
1
).
daysTo
(
QDate
(
2001
,
months
[
i
],
1
));
if
(
span
>
maxgap
)
maxgap
=
span
;
}
last
=
months
[
i
];
}
int
span
=
QDate
(
2001
,
first
,
1
).
daysTo
(
QDate
(
2001
,
last
,
1
));
const
int
span
=
QDate
(
2001
,
first
,
1
).
daysTo
(
QDate
(
2001
,
last
,
1
));
if
(
freq
>
1
)
return
Duration
(
freq
*
365
-
span
,
Duration
::
Days
);
if
(
365
-
span
>
maxgap
)
...
...
version.cpp
View file @
8343246d
...
...
@@ -42,7 +42,7 @@ int getVersionNumber(const QString& version, QString* subVersion)
// if the representation returned by this method changes.
if
(
subVersion
)
subVersion
->
clear
();
int
count
=
version
.
count
(
QLatin1Char
(
'.'
))
+
1
;
const
int
count
=
version
.
count
(
QLatin1Char
(
'.'
))
+
1
;
if
(
count
<
2
)
return
0
;
bool
ok
;
...
...
@@ -57,7 +57,7 @@ int getVersionNumber(const QString& version, QString* subVersion)
{
// Issue number: allow other characters to follow the last digit
const
QString
issue
=
version
.
section
(
QLatin1Char
(
'.'
),
2
);
int
n
=
issue
.
length
();
const
int
n
=
issue
.
length
();
if
(
!
n
||
!
issue
[
0
].
isDigit
())
return
0
;
int
i
;
...
...
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