Changeset View
Changeset View
Standalone View
Standalone View
src/kpac/script.cpp
Show All 15 Lines | 1 | /* | |||
---|---|---|---|---|---|
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to | ||
17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | 18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #include "script.h" | 21 | #include "script.h" | ||
22 | 22 | | |||
23 | #include <QString> | 23 | #include <QString> | ||
24 | #include <QRegExp> | 24 | #include <QRegularExpression> | ||
25 | #include <QDateTime> | 25 | #include <QDateTime> | ||
26 | #include <QUrl> | 26 | #include <QUrl> | ||
27 | 27 | | |||
28 | #include <QHostInfo> | 28 | #include <QHostInfo> | ||
29 | #include <QHostAddress> | 29 | #include <QHostAddress> | ||
30 | #include <QNetworkInterface> | 30 | #include <QNetworkInterface> | ||
31 | 31 | | |||
32 | #include <QJSEngine> | 32 | #include <QJSEngine> | ||
▲ Show 20 Lines • Show All 276 Lines • ▼ Show 20 Line(s) | 305 | { | |||
309 | 309 | | |||
310 | return QJSValue(host.count(QLatin1Char('.'))); | 310 | return QJSValue(host.count(QLatin1Char('.'))); | ||
311 | } | 311 | } | ||
312 | 312 | | |||
313 | // shExpMatch(str, pattern) | 313 | // shExpMatch(str, pattern) | ||
314 | // @returns true if @p str matches the shell @p pattern | 314 | // @returns true if @p str matches the shell @p pattern | ||
315 | Q_INVOKABLE QJSValue ShExpMatch(QString str, QString patternStr) | 315 | Q_INVOKABLE QJSValue ShExpMatch(QString str, QString patternStr) | ||
316 | { | 316 | { | ||
317 | QRegExp pattern(patternStr, Qt::CaseSensitive, QRegExp::Wildcard); | 317 | const QRegularExpression pattern(QRegularExpression::anchoredPattern( | ||
318 | return QJSValue(pattern.exactMatch(str)); | 318 | QRegularExpression::wildcardToRegularExpression(patternStr))); | ||
319 | return QJSValue(pattern.match(str).hasMatch()); | ||||
319 | } | 320 | } | ||
320 | 321 | | |||
321 | // weekdayRange(day [, "GMT" ]) | 322 | // weekdayRange(day [, "GMT" ]) | ||
322 | // weekdayRange(day1, day2 [, "GMT" ]) | 323 | // weekdayRange(day1, day2 [, "GMT" ]) | ||
323 | // @returns true if the current day equals day or between day1 and day2 resp. | 324 | // @returns true if the current day equals day or between day1 and day2 resp. | ||
324 | // If the last argument is "GMT", GMT timezone is used, otherwise local time | 325 | // If the last argument is "GMT", GMT timezone is used, otherwise local time | ||
325 | Q_INVOKABLE QJSValue WeekdayRange(QString day1, QString arg2 = QString(), QString tz = QString()) | 326 | Q_INVOKABLE QJSValue WeekdayRange(QString day1, QString arg2 = QString(), QString tz = QString()) | ||
326 | { | 327 | { | ||
▲ Show 20 Lines • Show All 384 Lines • Show Last 20 Lines |