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
a1443c5d
Commit
a1443c5d
authored
Feb 22, 2022
by
David Jarvie
Browse files
Remove Qt6 conditionals: the Qt6 code can be used with Qt5
parent
ce6d8e28
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/kacalendar.cpp
View file @
a1443c5d
...
...
@@ -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.
* SPDX-FileCopyrightText: 2001-202
0
David Jarvie <djarvie@kde.org>
* SPDX-FileCopyrightText: 2001-202
2
David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
...
...
@@ -34,9 +34,7 @@ const QLatin1String MIME_ARCHIVED("application/x-vnd.kde.alarm.archived");
const
QLatin1String
MIME_TEMPLATE
(
"application/x-vnd.kde.alarm.template"
);
static
const
QByteArray
VERSION_PROPERTY
(
"VERSION"
);
// X-KDE-KALARM-VERSION VCALENDAR property
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
static
bool
isUTC
(
const
QString
&
localFile
);
#endif
class
Private
{
public:
...
...
@@ -89,24 +87,10 @@ int updateVersion(const FileStorage::Ptr &fileStorage, QString &versionString)
return
IncompatibleFormat
;
// calendar was created by another program, or an unknown version of KAlarm
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
// Calendar was created by an earlier version of KAlarm.
// Convert it to the current format.
const
QString
localFile
=
fileStorage
->
fileName
();
int
ver
=
version
;
if
(
version
==
KAlarmCal
::
Version
(
0
,
5
,
7
)
&&
!
localFile
.
isEmpty
())
{
// KAlarm version 0.5.7 - check whether times are stored in UTC, in which
// case it is the KDE 3.0.0 version, which needs adjustment of summer times.
if
(
isUTC
(
localFile
))
{
ver
=
-
version
;
}
qCDebug
(
KALARMCAL_LOG
)
<<
"KAlarm version 0.5.7 ("
<<
(
ver
<
0
?
""
:
"non-"
)
<<
"UTC)"
;
}
else
{
qCDebug
(
KALARMCAL_LOG
)
<<
"KAlarm version"
<<
version
;
}
// Convert events to current KAlarm format for when/if the calendar is saved.
KAEvent
::
convertKCalEvents
(
fileStorage
->
calendar
(),
ver
)
;
#endif
qCDebug
(
KALARMCAL_LOG
)
<<
"KAlarm version"
<<
version
;
KAEvent
::
convertKCalEvents
(
fileStorage
->
calendar
(),
version
);
// Set the new calendar version.
setKAlarmVersion
(
fileStorage
->
calendar
());
return
version
;
...
...
@@ -175,48 +159,7 @@ int Private::readKAlarmVersion(const FileStorage::Ptr &fileStorage, QString &sub
}
return
KAlarmCal
::
getVersionNumber
(
versionString
,
&
subVersion
);
}
// This code is for kde 3.0.0 (we will release in the future kf6
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
/******************************************************************************
* Check whether the calendar file has its times stored as UTC times,
* indicating that it was written by the KDE 3.0.0 version of KAlarm 0.5.7.
* Reply = true if times are stored in UTC
* = false if the calendar is a vCalendar, times are not UTC, or any error occurred.
*/
bool
isUTC
(
const
QString
&
localFile
)
{
// Read the calendar file into a string
QFile
file
(
localFile
);
if
(
!
file
.
open
(
QIODevice
::
ReadOnly
))
{
return
false
;
}
QTextStream
ts
(
&
file
);
ts
.
setCodec
(
"ISO 8859-1"
);
const
QByteArray
text
=
ts
.
readAll
().
toLocal8Bit
();
file
.
close
();
// Extract the CREATED property for the first VEVENT from the calendar
const
QByteArray
BEGIN_VCALENDAR
(
"BEGIN:VCALENDAR"
);
const
QByteArray
BEGIN_VEVENT
(
"BEGIN:VEVENT"
);
const
QByteArray
CREATED
(
"CREATED:"
);
const
QList
<
QByteArray
>
lines
=
text
.
split
(
'\n'
);
for
(
int
i
=
0
,
end
=
lines
.
count
();
i
<
end
;
++
i
)
{
if
(
lines
[
i
].
startsWith
(
BEGIN_VCALENDAR
))
{
while
(
++
i
<
end
)
{
if
(
lines
[
i
].
startsWith
(
BEGIN_VEVENT
))
{
while
(
++
i
<
end
)
{
if
(
lines
[
i
].
startsWith
(
CREATED
))
{
return
lines
[
i
].
endsWith
(
'Z'
);
}
}
}
}
break
;
}
}
return
false
;
}
#endif
//=============================================================================
namespace
CalEvent
...
...
src/kadatetime.cpp
View file @
a1443c5d
...
...
@@ -2265,13 +2265,8 @@ KADateTime KADateTime::fromString(const QString &string, TimeFormat format, bool
//month = d.month();
}
else
{
// A month and day are specified
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
month
=
parts
[
3
].
leftRef
(
2
).
toInt
(
&
ok
);
day
=
parts
[
3
].
rightRef
(
2
).
toInt
(
&
ok1
);
#else
month
=
QStringView
(
parts
[
3
]).
left
(
2
).
toInt
(
&
ok
);
day
=
QStringView
(
parts
[
3
]).
right
(
2
).
toInt
(
&
ok1
);
#endif
if
(
!
ok
||
!
ok1
)
{
break
;
}
...
...
@@ -2864,17 +2859,10 @@ QDateTime fromStr(const QString &string, const QString &format, int &utcOffset,
case
's'
:
{
// milliseconds, with decimal point prefix
if
(
str
[
s
]
!=
QLatin1Char
(
'.'
))
{
// If no locale, try comma, it is preferred by ISO8601 as the decimal point symbol
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
const
QChar
dpt
=
QLocale
().
decimalPoint
();
if
(
!
str
.
midRef
(
s
).
startsWith
(
dpt
))
{
return
{};
}
#else
const
QString
dpt
=
QLocale
().
decimalPoint
();
if
(
!
QStringView
(
str
).
mid
(
s
).
startsWith
(
dpt
))
{
return
{};
}
#endif
}
++
s
;
if
(
s
>=
send
)
{
...
...
@@ -3225,11 +3213,7 @@ bool getNumber(const QString &string, int &offset, int mindigits, int maxdigits,
return
false
;
}
bool
ok
;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
int
n
=
string
.
midRef
(
offset
,
ndigits
).
toInt
(
&
ok
);
#else
int
n
=
QStringView
(
string
).
mid
(
offset
,
ndigits
).
toInt
(
&
ok
);
#endif
if
(
neg
)
{
n
=
-
n
;
}
...
...
src/kaevent.cpp
View file @
a1443c5d
...
...
@@ -656,11 +656,7 @@ KAEventPrivate::KAEventPrivate(const KCalendarCore::Event::Ptr &event)
flag
=
flags
.
at
(
++
i
);
}
const
int
len
=
flag
.
length
()
-
1
;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
mReminderMinutes
=
-
flag
.
leftRef
(
len
).
toInt
();
// -> 0 if conversion fails
#else
mReminderMinutes
=
-
QStringView
(
flag
).
left
(
len
).
toInt
();
// -> 0 if conversion fails
#endif
switch
(
flag
.
at
(
len
).
toLatin1
())
{
case
'M'
:
break
;
case
'H'
:
mReminderMinutes
*=
60
;
break
;
...
...
@@ -4019,28 +4015,16 @@ DateTime KAEventPrivate::readDateTime(const Event::Ptr &event, bool localZone, b
const
QString
prop
=
event
->
customProperty
(
KACalendar
::
APPNAME
,
KAEventPrivate
::
NEXT_RECUR_PROPERTY
);
if
(
prop
.
length
()
>=
SZ_DATE
)
{
// The next due recurrence time is specified
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
const
QDate
d
(
prop
.
leftRef
(
SZ_YEAR
).
toInt
(),
prop
.
midRef
(
SZ_YEAR
,
SZ_MONTH
).
toInt
(),
prop
.
midRef
(
SZ_YEAR
+
SZ_MONTH
,
SZ_DAY
).
toInt
());
#else
const
QDate
d
(
QStringView
(
prop
).
left
(
SZ_YEAR
).
toInt
(),
QStringView
(
prop
).
mid
(
SZ_YEAR
,
SZ_MONTH
).
toInt
(),
QStringView
(
prop
).
mid
(
SZ_YEAR
+
SZ_MONTH
,
SZ_DAY
).
toInt
());
#endif
if
(
d
.
isValid
())
{
if
(
dateOnly
&&
prop
.
length
()
==
SZ_DATE
)
{
next
.
setDate
(
d
);
}
else
if
(
!
dateOnly
&&
prop
.
length
()
==
IX_TIME
+
SZ_TIME
&&
prop
[
SZ_DATE
]
==
QLatin1Char
(
'T'
))
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
const
QTime
t
(
prop
.
midRef
(
IX_TIME
,
SZ_HOUR
).
toInt
(),
prop
.
midRef
(
IX_TIME
+
SZ_HOUR
,
SZ_MIN
).
toInt
(),
prop
.
midRef
(
IX_TIME
+
SZ_HOUR
+
SZ_MIN
,
SZ_SEC
).
toInt
());
#else
const
QTime
t
(
QStringView
(
prop
).
mid
(
IX_TIME
,
SZ_HOUR
).
toInt
(),
QStringView
(
prop
).
mid
(
IX_TIME
+
SZ_HOUR
,
SZ_MIN
).
toInt
(),
QStringView
(
prop
).
mid
(
IX_TIME
+
SZ_HOUR
+
SZ_MIN
,
SZ_SEC
).
toInt
());
#endif
if
(
t
.
isValid
())
{
next
.
setDate
(
d
);
next
.
setTime
(
t
);
...
...
src/version.cpp
View file @
a1443c5d
...
...
@@ -58,11 +58,7 @@ int getVersionNumber(const QString &version, QString *subVersion)
if
(
subVersion
)
{
*
subVersion
=
issue
.
mid
(
i
);
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
v
=
issue
.
leftRef
(
i
).
toUInt
();
// issue number
#else
v
=
QStringView
(
issue
).
left
(
i
).
toUInt
();
// issue number
#endif
vernum
+=
(
v
<
99
?
v
:
99
);
}
return
vernum
;
...
...
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