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
3895eeb2
Commit
3895eeb2
authored
Aug 16, 2022
by
David Jarvie
Browse files
Make QRegularExpressions static const
parent
95fe1f8b
Pipeline
#218437
passed with stage
in 1 minute and 49 seconds
Changes
10
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Changelog
View file @
3895eeb2
KAlarm Change Log
=== Version 3.5.2 (KDE Gear 22.12) ---
3
August 2022 ===
=== Version 3.5.2 (KDE Gear 22.12) ---
15
August 2022 ===
* Provide build option to disable use of X11, even if it is available.
=== Version 3.5.1 (KDE Gear 22.08.1) --- 15 August 2022 ===
...
...
src/eventid.cpp
View file @
3895eeb2
...
...
@@ -33,7 +33,7 @@ ResourceId EventId::resourceDisplayId() const
QString
EventId
::
extractIDs
(
const
QString
&
resourceEventId
,
QString
&
eventId
)
{
QRegularExpression
rx
(
QStringLiteral
(
"^(
\\
w+):(.*)$"
));
static
const
QRegularExpression
rx
(
QStringLiteral
(
"^(
\\
w+):(.*)$"
));
QRegularExpressionMatch
rxmatch
=
rx
.
match
(
resourceEventId
);
if
(
!
rxmatch
.
hasMatch
())
{
...
...
src/kalarmcalendar/kadatetime.cpp
View file @
3895eeb2
...
...
@@ -1971,7 +1971,7 @@ KADateTime KADateTime::fromString(const QString& string, TimeFormat format, bool
int
nmin
=
8
;
int
nsec
=
9
;
// Also accept obsolete form "Weekday, DD-Mon-YY HH:MM:SS ±hhmm"
const
QRegularExpression
rx1
(
Q
Latin1
String
(
R"(^(?:([A-Z][a-z]+),\s*)?(\d{1,2})(\s+|-)([^-\s]+)(\s+|-)(\d{2,4})\s+(\d\d):(\d\d)(?::(\d\d))?\s+(\S+)$)"
));
static
const
QRegularExpression
rx1
(
QString
Literal
(
R"(^(?:([A-Z][a-z]+),\s*)?(\d{1,2})(\s+|-)([^-\s]+)(\s+|-)(\d{2,4})\s+(\d\d):(\d\d)(?::(\d\d))?\s+(\S+)$)"
));
const
QRegularExpressionMatch
match1
=
rx1
.
match
(
str
);
QStringList
parts_
;
if
(
match1
.
hasMatch
())
...
...
@@ -1986,7 +1986,7 @@ KADateTime KADateTime::fromString(const QString& string, TimeFormat format, bool
else
{
// Check for the obsolete form "Wdy Mon DD HH:MM:SS YYYY"
const
QRegularExpression
rx2
(
Q
Latin1
String
(
R"(^([A-Z][a-z]+)\s+(\S+)\s+(\d\d)\s+(\d\d):(\d\d):(\d\d)\s+(\d\d\d\d)$)"
));
static
const
QRegularExpression
rx2
(
QString
Literal
(
R"(^([A-Z][a-z]+)\s+(\S+)\s+(\d\d)\s+(\d\d):(\d\d):(\d\d)\s+(\d\d\d\d)$)"
));
const
QRegularExpressionMatch
match2
=
rx2
.
match
(
str
);
QStringList
parts_
;
if
(
!
match2
.
hasMatch
())
...
...
@@ -2044,7 +2044,7 @@ KADateTime KADateTime::fromString(const QString& string, TimeFormat format, bool
bool
negOffset
=
false
;
if
(
parts
.
count
()
>
10
)
{
const
QRegularExpression
rx
(
Q
Latin1
String
(
R"(^([+-])(\d\d)(\d\d)$)"
));
static
const
QRegularExpression
rx
(
QString
Literal
(
R"(^([+-])(\d\d)(\d\d)$)"
));
const
QRegularExpressionMatch
match
=
rx
.
match
(
parts
[
10
]);
if
(
match
.
hasMatch
())
{
...
...
@@ -2110,7 +2110,7 @@ KADateTime KADateTime::fromString(const QString& string, TimeFormat format, bool
}
case
RFC3339Date
:
// format is YYYY-MM-DDThh:mm:ss[.s]TZ
{
const
QRegularExpression
rx
(
Q
Latin1
String
(
R"(^(\d{4})-(\d\d)-(\d\d)[Tt](\d\d):(\d\d):(\d\d)(?:\.(\d+))?([Zz]|([+-])(\d\d):(\d\d))$)"
));
static
const
QRegularExpression
rx
(
QString
Literal
(
R"(^(\d{4})-(\d\d)-(\d\d)[Tt](\d\d):(\d\d):(\d\d)(?:\.(\d+))?([Zz]|([+-])(\d\d):(\d\d))$)"
));
const
QRegularExpressionMatch
match
=
rx
.
match
(
str
);
if
(
!
match
.
hasMatch
())
break
;
...
...
@@ -2196,31 +2196,31 @@ KADateTime KADateTime::fromString(const QString& string, TimeFormat format, bool
*/
bool
dateOnly
=
false
;
// Check first for the extended format of ISO 8601
const
QRegularExpression
rx1
(
Q
Latin1
String
(
R"(^([+-])?(\d{4,})-(\d\d\d|\d\d-\d\d)[T ](\d\d)(?::(\d\d)(?::(\d\d)(?:(?:\.|,)(\d+))?)?)?(Z|([+-])(\d\d)(?::(\d\d))?)?$)"
));
static
const
QRegularExpression
rx1
(
QString
Literal
(
R"(^([+-])?(\d{4,})-(\d\d\d|\d\d-\d\d)[T ](\d\d)(?::(\d\d)(?::(\d\d)(?:(?:\.|,)(\d+))?)?)?(Z|([+-])(\d\d)(?::(\d\d))?)?$)"
));
QRegularExpressionMatch
match
=
rx1
.
match
(
str
);
if
(
!
match
.
hasMatch
())
{
// It's not the extended format - check for the basic format
const
QRegularExpression
rx2
(
Q
Latin1
String
(
R"(^([+-])?(\d{4,})(\d{4})[T ](\d\d)(?:(\d\d)(?:(\d\d)(?:(?:\.|,)(\d+))?)?)?(Z|([+-])(\d\d)(\d\d)?)?$)"
));
static
const
QRegularExpression
rx2
(
QString
Literal
(
R"(^([+-])?(\d{4,})(\d{4})[T ](\d\d)(?:(\d\d)(?:(\d\d)(?:(?:\.|,)(\d+))?)?)?(Z|([+-])(\d\d)(\d\d)?)?$)"
));
match
=
rx2
.
match
(
str
);
if
(
!
match
.
hasMatch
())
{
const
QRegularExpression
rx3
(
Q
Latin1
String
(
R"(^([+-])?(\d{4})(\d{3})[T ](\d\d)(?:(\d\d)(?:(\d\d)(?:(?:\.|,)(\d+))?)?)?(Z|([+-])(\d\d)(\d\d)?)?$)"
));
static
const
QRegularExpression
rx3
(
QString
Literal
(
R"(^([+-])?(\d{4})(\d{3})[T ](\d\d)(?:(\d\d)(?:(\d\d)(?:(?:\.|,)(\d+))?)?)?(Z|([+-])(\d\d)(\d\d)?)?$)"
));
match
=
rx3
.
match
(
str
);
if
(
!
match
.
hasMatch
())
{
// Check for date-only formats
dateOnly
=
true
;
const
QRegularExpression
rx4
(
Q
Latin1
String
(
R"(^([+-])?(\d{4,})-(\d\d\d|\d\d-\d\d)$)"
));
static
const
QRegularExpression
rx4
(
QString
Literal
(
R"(^([+-])?(\d{4,})-(\d\d\d|\d\d-\d\d)$)"
));
match
=
rx4
.
match
(
str
);
if
(
!
match
.
hasMatch
())
{
// It's not the extended format - check for the basic format
const
QRegularExpression
rx5
(
Q
Latin1
String
(
"^([+-])?(
\\
d{4,})(
\\
d{4})$"
));
static
const
QRegularExpression
rx5
(
QString
Literal
(
"^([+-])?(
\\
d{4,})(
\\
d{4})$"
));
match
=
rx5
.
match
(
str
);
if
(
!
match
.
hasMatch
())
{
const
QRegularExpression
rx6
(
Q
Latin1
String
(
"^([+-])?(
\\
d{4})(
\\
d{3})$"
));
static
const
QRegularExpression
rx6
(
QString
Literal
(
"^([+-])?(
\\
d{4})(
\\
d{3})$"
));
match
=
rx6
.
match
(
str
);
if
(
!
match
.
hasMatch
())
break
;
...
...
@@ -2355,7 +2355,7 @@ KADateTime KADateTime::fromString(const QString& string, TimeFormat format, bool
case
QtTextDate
:
// format is Wdy Mth DD [hh:mm:ss] YYYY [±hhmm]
{
int
offset
=
0
;
const
QRegularExpression
rx
(
Q
Latin1
String
(
R"(^(\S+\s+\S+\s+\d\d\s+(\d\d:\d\d:\d\d\s+)?\d\d\d\d)\s*(.*)$)"
));
static
const
QRegularExpression
rx
(
QString
Literal
(
R"(^(\S+\s+\S+\s+\d\d\s+(\d\d:\d\d:\d\d\s+)?\d\d\d\d)\s*(.*)$)"
));
const
QRegularExpressionMatch
match
=
rx
.
match
(
str
);
if
(
!
match
.
hasMatch
())
break
;
...
...
@@ -2386,7 +2386,7 @@ KADateTime KADateTime::fromString(const QString& string, TimeFormat format, bool
return
KADateTime
(
qdt
.
date
(),
qdt
.
time
(),
KADateTimePrivate
::
fromStringDefault
());
}
}
const
QRegularExpression
rx2
(
Q
Latin1
String
(
R"(([+-])([\d][\d])(?::?([\d][\d]))?$)"
));
static
const
QRegularExpression
rx2
(
QString
Literal
(
R"(([+-])([\d][\d])(?::?([\d][\d]))?$)"
));
const
QRegularExpressionMatch
match2
=
rx2
.
match
(
parts
[
3
]);
if
(
!
match2
.
hasMatch
())
break
;
...
...
src/lib/file.cpp
View file @
3895eeb2
...
...
@@ -163,7 +163,8 @@ bool browseFile(QString& file, const QString& caption, QString& defaultDir,
bool
existing
,
QWidget
*
parent
)
{
file
.
clear
();
const
QString
initialDir
=
!
initialFile
.
isEmpty
()
?
pathOrUrl
(
initialFile
).
remove
(
QRegularExpression
(
QLatin1String
(
"/[^/]*$"
)))
static
const
QRegularExpression
re
(
QStringLiteral
(
"/[^/]*$"
));
const
QString
initialDir
=
!
initialFile
.
isEmpty
()
?
pathOrUrl
(
initialFile
).
remove
(
re
)
:
!
defaultDir
.
isEmpty
()
?
defaultDir
:
QDir
::
homePath
();
// Use AutoQPointer to guard against crash on application exit while
...
...
src/lib/lineedit.cpp
View file @
3895eeb2
...
...
@@ -150,7 +150,7 @@ void LineEdit::dropEvent(QDropEvent* e)
{
// Remove newlines from a list of email addresses, and allow an eventual mailto: scheme
const
QString
mailto
=
QStringLiteral
(
"mailto:"
);
static
QRegularExpression
regexp
(
Q
Latin1
String
(
"[
\r\n
]+"
));
static
const
QRegularExpression
regexp
(
QString
Literal
(
"[
\r\n
]+"
));
newEmails
=
txt
.
split
(
regexp
,
Qt
::
SkipEmptyParts
);
for
(
QStringList
::
Iterator
it
=
newEmails
.
begin
();
it
!=
newEmails
.
end
();
++
it
)
{
...
...
src/messagedisplayhelper.cpp
View file @
3895eeb2
...
...
@@ -210,7 +210,7 @@ void MessageDisplayHelper::initTexts()
// start of the translated string, allowing for possible HTML tags
// enclosing "Reminder".
QString
s
=
i18nc
(
"@info"
,
"Reminder"
);
const
QRegularExpression
re
(
QStringLiteral
(
"^(<[^>]+>)*"
));
// search for HTML tag "<...>"
static
const
QRegularExpression
re
(
QStringLiteral
(
"^(<[^>]+>)*"
));
// search for HTML tag "<...>"
const
QRegularExpressionMatch
match
=
re
.
match
(
s
);
// Prefix the time, plus a newline, to "Reminder", inside any HTML tags.
s
.
insert
(
match
.
capturedEnd
(
0
),
mTexts
.
time
+
QLatin1String
(
"<br/>"
));
...
...
src/resources/fileresource.cpp
View file @
3895eeb2
...
...
@@ -433,7 +433,8 @@ bool FileResource::save(QString* errorMessage, bool writeThroughCache, bool forc
if
(
errorMessage
)
{
*
errorMessage
=
msg
+
errMessage
;
errorMessage
->
replace
(
QRegularExpression
(
QStringLiteral
(
"</html><html>"
)),
QStringLiteral
(
"<br><br>"
));
static
const
QRegularExpression
re
(
QStringLiteral
(
"</html><html>"
));
errorMessage
->
replace
(
re
,
QStringLiteral
(
"<br><br>"
));
}
else
Resources
::
notifyResourceMessage
(
this
,
MessageType
::
Error
,
msg
,
errMessage
);
...
...
src/resources/fileresourceconfigmanager.cpp
View file @
3895eeb2
...
...
@@ -57,7 +57,8 @@ void FileResourceConfigManager::createResources(QObject* parent)
return
;
manager
->
mCreated
=
1
;
QStringList
resourceGroups
=
manager
->
mConfig
->
groupList
().
filter
(
QRegularExpression
(
QStringLiteral
(
"^Resource_
\\
d+$"
)));
static
const
QRegularExpression
re
(
QStringLiteral
(
"^Resource_
\\
d+$"
));
QStringList
resourceGroups
=
manager
->
mConfig
->
groupList
().
filter
(
re
);
if
(
!
resourceGroups
.
isEmpty
())
{
std
::
sort
(
resourceGroups
.
begin
(),
resourceGroups
.
end
(),
...
...
src/resources/resourcedatamodelbase.cpp
View file @
3895eeb2
...
...
@@ -710,9 +710,9 @@ QString ResourceDataModelBase::alarmTimeText(const DateTime& dateTime, char lead
// 'HH' and 'hh' provide leading zeroes; single 'H' or 'h' provide no
// leading zeroes.
static
const
QRegularExpression
hourReg
(
Q
Latin1
String
(
"[hH]"
));
static
const
QRegularExpression
hourReg
(
QString
Literal
(
"[hH]"
));
int
i
=
timeFormat
.
indexOf
(
hourReg
);
static
const
QRegularExpression
hourMinAmPmReg
(
Q
Latin1
String
(
"[hHmaA]"
));
static
const
QRegularExpression
hourMinAmPmReg
(
QString
Literal
(
"[hHmaA]"
));
int
first
=
timeFormat
.
indexOf
(
hourMinAmPmReg
);
if
(
i
>=
0
&&
i
==
first
&&
(
i
==
timeFormat
.
size
()
-
1
||
timeFormat
.
at
(
i
)
!=
timeFormat
.
at
(
i
+
1
)))
{
...
...
src/resources/resourcemodel.cpp
View file @
3895eeb2
...
...
@@ -677,7 +677,8 @@ bool ResourceView::viewportEvent(QEvent* e)
int
i
=
toolTip
.
indexOf
(
QLatin1Char
(
'@'
));
if
(
i
>
0
)
{
const
int
j
=
toolTip
.
indexOf
(
QRegularExpression
(
QLatin1String
(
"<(nl|br)"
),
QRegularExpression
::
CaseInsensitiveOption
),
i
+
1
);
static
const
QRegularExpression
re
(
QStringLiteral
(
"<(nl|br)"
),
QRegularExpression
::
CaseInsensitiveOption
);
const
int
j
=
toolTip
.
indexOf
(
re
,
i
+
1
);
const
int
k
=
toolTip
.
indexOf
(
QLatin1Char
(
'@'
),
j
);
const
QString
name
=
toolTip
.
mid
(
i
+
1
,
j
-
i
-
1
);
value
=
model
()
->
data
(
index
,
Qt
::
FontRole
);
...
...
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